Index: /EcnlProtoTool/trunk/asp3_dcre/.cproject
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/.cproject	(revision 279)
+++ /EcnlProtoTool/trunk/asp3_dcre/.cproject	(revision 279)
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="com.renesas.cdt.rz.debug.win32.configuration.Id.2092268252">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.renesas.cdt.rz.debug.win32.configuration.Id.2092268252" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactName="asp3_dcre" buildArtefactType="com.renesas.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=com.renesas.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf *.lst *.lis *.lpp *.map libgcc.a" description="" id="com.renesas.cdt.rz.debug.win32.configuration.Id.2092268252" name="Debug" parent="com.renesas.cdt.rz.debug.win32.configuration.Id">
+					<folderInfo id="com.renesas.cdt.rz.debug.win32.configuration.Id.2092268252." name="/" resourcePath="">
+						<toolChain id="com.renesas.cdt.rz.debug.win32.toolchain.Id.1330656554" name="KPIT GNUARM-NONE-EABI Toolchain" superClass="com.renesas.cdt.rz.debug.win32.toolchain.Id">
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.PE" id="com.renesas.cdt.rz.debug.win32.targetplatform.Id.2000849951" name="Target Platform" osList="all" superClass="com.renesas.cdt.rz.debug.win32.targetplatform.Id"/>
+							<builder buildPath="${workspace_loc:/asp3_dcre}/Debug" id="com.renesas.cdt.rz.debug.win32.builder.Id.1316838534" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Builder" superClass="com.renesas.cdt.rz.debug.win32.builder.Id"/>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.libgen.Id.549450220" name="Library Generator" superClass="com.renesas.cdt.rz.debug.win32.tool.libgen.Id">
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.ctype.169331272" name="ctype.h : æå­ãæ±ããã§ãã¯ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.ctype" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.math.2060617615" name="math.h : ä¸è§é¢æ°ãªã©æ°å¤ã®è¨ç®ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.math" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdio.1276105827" name="stdio.h : å
+¥å/åºåãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdio" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdlib.1471847177" name="stdlib.h : æ ¼ç´é åã®ç®¡çãªã© C ãã­ã°ã©ã ã®æ¨æºå¦çãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdlib" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.string.1340704445" name="string.h : æå­åã®æ¯è¼ã¨ã³ãã¼ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.string" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary.336514305" name="ã©ã¤ãã©ãªã¼ã®é¸æ" superClass="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary" value="com.renesas.core.LibraryGenerator.option.selectLibrary.newLib" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.libraryType.2042178815" name="ã©ã¤ãã©ãªã¼å" superClass="com.renesas.cdt.core.LibraryGenerator.option.libraryType" value="com.renesas.cdt.core.LibraryGenerator.option.libraryType.projectBuilt" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc9.103678875" name="åé¢æ°ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-ffunction-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc9" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc14.1646102274" name="é¢æ°ã®ã¢ãã¬ã¹ãã¬ã¸ã¹ã¿ã¼ã«ç½®ããªã (-fno-function-cse)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc14" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc36.1245833341" name="Parse the whole compilation unit before starting to produce code ( -funit-at-a-time)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc36" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc10.186332838" name="åãã¼ã¿ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-fdata-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc10" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc37.611438064" name="Align branch targets to a power-of-two boundary (-falign-jumps)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc37" value="true" valueType="boolean"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.compiler.Id.2129676447" name="Compiler" superClass="com.renesas.cdt.rz.debug.win32.tool.compiler.Id">
+								<option defaultValue="true" id="com.renesas.cdt.core.Compiler.option.misc2.474910942" name="æ¨æºã·ã¹ãã ã»ãã£ã¬ã¯ããªã¼ã§ãããã¼ã»ãã¡ã¤ã«ãæ¤ç´¢ããªã (-nostdinc)" superClass="com.renesas.cdt.core.Compiler.option.misc2" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.architecture.283267340" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Compiler.option.architecture" value="com.renesas.cdt.rz.Debug.Compiler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.730461588" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.cpuType" value="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.1575628028" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.1078258171" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.instructionset" value="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.interworking.2143686662" name="ã¤ã³ã¿ã¼ã»ã¯ã¼ã­ã³ã° (-mthumb-interwork)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.interworking" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.615392605" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu" value="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.753205564" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.soft" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warnStackSize.1447419982" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.core.Compiler.option.warnStackSize" value="100" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.CPUSeries.938541441" name="CPU ã·ãªã¼ãº" superClass="com.renesas.cdt.core.Compiler.option.CPUSeries" value="RZ/A" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.device.175730635" name="Device" superClass="com.renesas.cdt.core.Compiler.option.device" value="R7S721001" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.deviceShortName.195768597" name="DeviceShortName" superClass="com.renesas.cdt.core.Compiler.option.deviceShortName" value="R7S721001" valueType="string"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines.681399750" name="ãã¯ã­å®ç¾©" superClass="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="SIMULATOR_DEBUG"/>
+									<listOptionValue builtIn="false" value="CPPAPP"/>
+									<listOptionValue builtIn="false" value="TOPPERS_EXECUTE_ON_ROM"/>
+									<listOptionValue builtIn="false" value="__TARGET_ARCH_ARM=7"/>
+									<listOptionValue builtIn="false" value="TARGET_RZ_A1H"/>
+									<listOptionValue builtIn="false" value="TARGET_MBRZA1H"/>
+									<listOptionValue builtIn="false" value="TOOLCHAIN_GCC_ARM"/>
+									<listOptionValue builtIn="false" value="TOOLCHAIN_GCC"/>
+									<listOptionValue builtIn="false" value="TARGET_CORTEX_A"/>
+									<listOptionValue builtIn="false" value="MBED_BUILD_TIMESTAMP=1460441486.52"/>
+									<listOptionValue builtIn="false" value="TARGET_RENESAS"/>
+									<listOptionValue builtIn="false" value="__FPU_PRESENT"/>
+									<listOptionValue builtIn="false" value="TARGET_KERNEL_ASP"/>
+									<listOptionValue builtIn="false" value="SUPPORT_INET4"/>
+									<listOptionValue builtIn="false" value="SUPPORT_ETHER"/>
+									<listOptionValue builtIn="false" value="SUPPORT_TCP"/>
+									<listOptionValue builtIn="false" value="SUPPORT_UDP"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Compiler.option.includeFileDir.1965153703" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Compiler.option.includeFileDir" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/include}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/target/gr_peach_gcc}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/arch/arm_gcc/rza1}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/arch/arm_gcc/common}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/arch/gcc}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/api}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/hal}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc/iodefines}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mruby-1.2.0/include}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/sample8/src}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/tinet/netdev/if_mbed}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/tinet}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/tecs_kernel}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/sample8/Debug}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/sample8/Debug/gen}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../webserver&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../gr_peach&quot;"/>
+								</option>
+								<inputType id="%Base.Compiler.C.InputType.Id.479471606" name="C å
+¥å" superClass="%Base.Compiler.C.InputType.Id"/>
+								<inputType id="Base.Compiler.CPP.InputType.Id.1684974226" name="C++ å
+¥å" superClass="Base.Compiler.CPP.InputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.assembler.Id.30934973" name="Assembler" superClass="com.renesas.cdt.rz.debug.win32.tool.assembler.Id">
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.architecture.1967834551" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Assembler.option.architecture" value="com.renesas.cdt.rz.Debug.Assembler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.907440326" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.cpuType" value="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.408491063" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.1476398350" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.instructionset" value="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu.1561922685" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu" value="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu.vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.2104392911" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.soft" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Assembler.option.includeFileDirectories.355394960" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Assembler.option.includeFileDirectories" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/src&quot;"/>
+								</option>
+								<inputType id="%Base.Assembler.inputType.Id.63454341" name="ã¢ã»ã³ãã©ã¼å
+¥åã¿ã¤ã" superClass="%Base.Assembler.inputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.linker.Id.606735805" name="Linker" superClass="com.renesas.cdt.rz.debug.win32.tool.linker.Id">
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories.1968268518" name="ã¢ã¼ã«ã¤ãæ¤ç´¢ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;${CONFIGDIR}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/lib/gcc/arm-none-eabi/${GCC_VERSION}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/arm-none-eabi/lib&quot;"/>
+								</option>
+								<option id="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.326979634" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Linker.option.dataEndian" value="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.little" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles.420087168" name="ã¢ã¼ã«ã¤ã ( ã©ã¤ãã©ãªã¼ ) ãã¡ã¤ã«" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles" valueType="stringList">
+									<listOptionValue builtIn="false" value="${BuildArtifactFileBaseName}"/>
+									<listOptionValue builtIn="false" value="gcc"/>
+									<listOptionValue builtIn="false" value="stdc++"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.userDefinedOptions.1635961165" name="ã¦ã¼ã¶ã¼å®ç¾©ãªãã·ã§ã³" superClass="com.renesas.cdt.core.Linker.option.userDefinedOptions" valueType="stringList">
+									<listOptionValue builtIn="false" value="-e_PowerON_Reset"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.linkOrderList.662931274" name="" superClass="com.renesas.cdt.core.Linker.option.linkOrderList" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;.\src\asp3_dcre.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\hardware_setup.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\interrupt_handlers.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\reset_program.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\vector_table.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\libasp3_dcre.a&quot;"/>
+								</option>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id.106287146" name="Objcopy" superClass="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="asp3_dcre.com.renesas.cdt.rz.projectType.win32.Id.712445337" name="Executable (Renesas)" projectType="com.renesas.cdt.rz.projectType.win32.Id"/>
+	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+	<storageModule moduleId="refreshScope" versionNumber="2">
+		<configuration configurationName="HardwareDebug">
+			<resource resourceType="PROJECT" workspacePath="/asp3_dcre"/>
+		</configuration>
+		<configuration configurationName="Debug">
+			<resource resourceType="PROJECT" workspacePath="/asp3_dcre"/>
+		</configuration>
+	</storageModule>
+</cproject>
Index: /EcnlProtoTool/trunk/asp3_dcre/.info
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/.info	(revision 279)
+++ /EcnlProtoTool/trunk/asp3_dcre/.info	(revision 279)
@@ -0,0 +1,7 @@
+TOOL_CHAIN=KPIT GNUARM-NONE-EABI Toolchain
+VERSION=v16.01
+TC_INSTALL=C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\
+GCC_STRING=5.2-GNUARM-NONE_v16.01
+VERSION_IDE=
+E2STUDIO_VERSION=5.3.1.002
+ACTIVE_CONFIGURATION=Debug
Index: /EcnlProtoTool/trunk/asp3_dcre/.project
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/.project	(revision 279)
+++ /EcnlProtoTool/trunk/asp3_dcre/.project	(revision 279)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>asp3_dcre</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+			<triggers>clean,full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>org.eclipse.cdt.core.ccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>
Index: /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/common/core_support.S
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/common/core_support.S	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/common/core_support.S	(revision 279)
@@ -267,8 +267,7 @@
 #else /* TOPPERS_CUSTOM_IDLE */
 	msr		cpsr_c, #CPSR_SVC_MODE	/* å²è¾¼ã¿ãè¨±å¯ï¼ã¹ã¼ããã¤ã¶ã¢ã¼ãï¼*/
-ALABEL(dispatcher_2)
-	b		dispatcher_2			/* å²è¾¼ã¿å¾
+#endif /* TOPPERS_CUSTOM_IDLE */
+	b		dispatcher_1			/* å²è¾¼ã¿å¾
 ã¡ */
-#endif /* TOPPERS_CUSTOM_IDLE */
 
 /*
Index: /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/common/gic_support.S
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/common/gic_support.S	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/common/gic_support.S	(revision 279)
@@ -5,5 +5,5 @@
  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
  *                              Toyohashi Univ. of Technology, JAPAN
- *  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+ *  Copyright (C) 2006-2017 by Embedded and Real-Time Systems Laboratory
  *              Graduate School of Information Science, Nagoya Univ., JAPAN
  * 
Index: /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/rza1/chip_timer.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/rza1/chip_timer.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/arch/arm_gcc/rza1/chip_timer.c	(revision 279)
@@ -4,5 +4,5 @@
  *      Advanced Standard Profile Kernel
  * 
- *  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+ *  Copyright (C) 2006-2017 by Embedded and Real-Time Systems Laboratory
  *              Graduate School of Information Science, Nagoya Univ., JAPAN
  * 
Index: /EcnlProtoTool/trunk/asp3_dcre/kernel/dataqueue.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/kernel/dataqueue.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/kernel/dataqueue.c	(revision 279)
@@ -6,5 +6,5 @@
  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
  *                              Toyohashi Univ. of Technology, JAPAN
- *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
  *              Graduate School of Information Science, Nagoya Univ., JAPAN
  * 
@@ -612,9 +612,11 @@
 	CHECK_ID(VALID_DTQID(dtqid));
 	p_dtqcb = get_dtqcb(dtqid);
-	CHECK_ILUSE(p_dtqcb->p_dtqinib->dtqcnt > 0U);
 
 	lock_cpu();
 	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
 		ercd = E_NOEXS;
+	}
+	else if (!(p_dtqcb->p_dtqinib->dtqcnt > 0U)) {
+		ercd = E_ILUSE;
 	}
 	else {
@@ -628,6 +630,6 @@
 			}
 		}
-	}
 	ercd = E_OK;
+	}
 	unlock_cpu();
 
Index: /EcnlProtoTool/trunk/asp3_dcre/kernel/eventflag.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/kernel/eventflag.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/kernel/eventflag.c	(revision 279)
@@ -6,5 +6,5 @@
  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
  *                              Toyohashi Univ. of Technology, JAPAN
- *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
  *              Graduate School of Information Science, Nagoya Univ., JAPAN
  * 
@@ -250,4 +250,5 @@
 		ercd = FLGID(p_flgcb);
 	}
+	unlock_cpu();
 
   error_exit:
Index: /EcnlProtoTool/trunk/asp3_dcre/kernel/task_manage.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/kernel/task_manage.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/kernel/task_manage.c	(revision 279)
@@ -388,25 +388,27 @@
 		ercd = E_NOEXS;							/*ï¼»NGKI3617ï¼½*/
 	}
-	else if (TSTAT_DORMANT(tstat)) {			/*ï¼»NGKI3620ï¼½*/
-		*p_tskstat = TTS_DMT;
-	}
-	else if (TSTAT_SUSPENDED(tstat)) {
-		if (TSTAT_WAITING(tstat)) {
-			*p_tskstat = TTS_WAS;
+	else {
+		if (TSTAT_DORMANT(tstat)) {				/*ï¼»NGKI3620ï¼½*/
+			*p_tskstat = TTS_DMT;
+		}
+		else if (TSTAT_SUSPENDED(tstat)) {
+			if (TSTAT_WAITING(tstat)) {
+				*p_tskstat = TTS_WAS;
+			}
+			else {
+				*p_tskstat = TTS_SUS;
+			}
+		}
+		else if (TSTAT_WAITING(tstat)) {
+			*p_tskstat = TTS_WAI;
+		}
+		else if (p_tcb == p_runtsk) {
+			*p_tskstat = TTS_RUN;
 		}
 		else {
-			*p_tskstat = TTS_SUS;
-		}
-	}
-	else if (TSTAT_WAITING(tstat)) {
-		*p_tskstat = TTS_WAI;
-	}
-	else if (p_tcb == p_runtsk) {
-		*p_tskstat = TTS_RUN;
-	}
-	else {
-		*p_tskstat = TTS_RDY;
-	}
-	ercd = E_OK;
+			*p_tskstat = TTS_RDY;
+		}
+		ercd = E_OK;
+	}
 	unlock_cpu();
 
Index: /EcnlProtoTool/trunk/asp3_dcre/kernel/time_manage.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/kernel/time_manage.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/kernel/time_manage.c	(revision 279)
@@ -6,5 +6,5 @@
  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
  *                              Toyohashi Univ. of Technology, JAPAN
- *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
  *              Graduate School of Information Science, Nagoya Univ., JAPAN
  * 
@@ -280,4 +280,6 @@
 		}
 		switch (p_nfyinfo->nfymode & ~0x0fU) {
+		case 0:
+			break;
 		case TENFY_SETVAR:
 			CHECK_PAR(INTPTR_ALIGN(p_nfyinfo->enfy.setvar.p_var));
@@ -352,5 +354,5 @@
 		break;
 	case TNFY_SNDDTQ:
-		ercd = snd_dtq(p_nfyinfo->nfy.snddtq.dtqid,
+		ercd = psnd_dtq(p_nfyinfo->nfy.snddtq.dtqid,
 							p_nfyinfo->nfy.snddtq.data);
 		break;
@@ -384,5 +386,5 @@
 			break;
 		case TENFY_SNDDTQ:
-			(void) snd_dtq(p_nfyinfo->enfy.snddtq.dtqid, (intptr_t) ercd);
+			(void) psnd_dtq(p_nfyinfo->enfy.snddtq.dtqid, (intptr_t) ercd);
 			break;
 		default:
Index: /EcnlProtoTool/trunk/asp3_dcre/library/vasyslog.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/library/vasyslog.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/library/vasyslog.c	(revision 279)
@@ -66,8 +66,7 @@
 
 void
-syslog(uint_t prio, const char *format, ...)
+vsyslog(uint_t prio, const char *format, va_list ap)
 {
 	SYSLOG	logbuf;
-	va_list	ap;
 	uint_t	i;
 	char	sz;
@@ -77,5 +76,4 @@
 	logbuf.logpar[0] = (LOGPAR) format;
 	i = 1U;
-	va_start(ap, format);
 
 	while ((c = *format++) != '\0' && i < TNUM_LOGPAR) {
@@ -124,7 +122,25 @@
 		}
 	}
-	va_end(ap);
 	(void) tSysLog_eSysLog_write(prio, &logbuf);
 }
 
+void
+syslog(uint_t prio, const char *format, ...)
+{
+	va_list	ap;
+	va_start(ap, format);
+	vsyslog(prio, format, ap);
+	va_end(ap);
+}
+
+/* mbed weak error function */
+void
+error(const char* format, ...) {
+	va_list arg;
+	va_start(arg, format);
+	vsyslog(LOG_ERROR, format, arg);
+	va_end(arg);
+	ext_ker();
+}
+
 #endif /* TOPPERS_OMIT_SYSLOG */
Index: /EcnlProtoTool/trunk/asp3_dcre/mbed/Makefile.mbed
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/mbed/Makefile.mbed	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/mbed/Makefile.mbed	(revision 279)
@@ -61,5 +61,5 @@
 START_OBJS = startup_RZ1AH.o
 SYSSVC_COBJS := $(SYSSVC_COBJS)\
-	assert.o board.o error.o gpio.o lp_ticker_api.o mbed_interface.o\
+	assert.o board.o gpio.o lp_ticker_api.o mbed_interface.o\
 	pinmap_common.o rtc_time.o semihost_api.o ticker_api.o us_ticker_api.o\
 	RZ_A1_Init.o cmsis_nvic.o gic.o mbed_sf_boot.o mmu_Renesas_RZ_A1.o\
Index: /EcnlProtoTool/trunk/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/mmu_Renesas_RZ_A1.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/mmu_Renesas_RZ_A1.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/mmu_Renesas_RZ_A1.c	(revision 279)
@@ -160,4 +160,5 @@
     //Define Image
     __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RO_DATA$$Base, RO_DATA_SIZE, Sect_Normal_RO);
+    __TTSection (&Image$$TTB$$ZI$$Base, 0x18200000, 4, Sect_Normal_Cod);
     __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$VECTORS$$Base, VECTORS_SIZE, Sect_Normal_Cod);
     __TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA$$Base, RW_DATA_SIZE, Sect_Normal_RW);
Index: /EcnlProtoTool/trunk/asp3_dcre/target/gr_peach_gcc/target_kernel_impl.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/target/gr_peach_gcc/target_kernel_impl.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/target/gr_peach_gcc/target_kernel_impl.c	(revision 279)
@@ -298,4 +298,6 @@
 target_exit(void)
 {
+	static int first = 1;
+
 	/*
 	 *  ãããä¾å­ã®çµäºå¦ç
@@ -306,5 +308,8 @@
 	 *  bkptå½ä»¤ã«ãããããã¬ã«å¶å¾¡ãç§»ãï¼ãã©ã¡ã¼ã¿ãä½ãè¯ããæªæ¤è¨ï¼
 	 */
-	Asm("bkpt #0");
+	if (first){
+		first = 0;
+		Asm("bkpt #0");
+	}
 
 	while (true) ;
Index: /EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq.c
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq.c	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq.c	(revision 279)
@@ -485,5 +485,5 @@
 		return E_NOEXS;
 
-	return E_PAR;
+	return E_OK/*E_PAR*/;
 	}
 
@@ -518,5 +518,5 @@
 		return E_NOEXS;
 
-	return E_PAR;
+	return E_OK/*E_PAR*/;
 	}
 
Index: /EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.def
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.def	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.def	(revision 279)
@@ -5,8 +5,8 @@
 UDP_CRE_CEP  #udp4_cepid* { .udp4_cepatr { &ipv4addr &portno } &callback }
 UDP6_CRE_CEP #udp6_cepid* { .udp6_cepatr { &ipv6addr &portno } &callback }
-VRID_TCP_REP  #vrid_tcp4_repid*
-VRID_TCP_CEP  #vrid_tcp4_cepid*
+VRID_TCP4_REP  #vrid_tcp4_repid*
+VRID_TCP4_CEP  #vrid_tcp4_cepid*
 VRID_TCP6_REP #vrid_tcp6_repid*
 VRID_TCP6_CEP #vrid_tcp6_cepid*
-VRID_UDP_CEP  #vrid_udp4_cepid*
+VRID_UDP4_CEP  #vrid_udp4_cepid*
 VRID_UDP6_CEP #vrid_udp6_cepid*
Index: /EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb
===================================================================
--- /EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb	(revision 278)
+++ /EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb	(revision 279)
@@ -78,21 +78,21 @@
 	$tinetCfgH.add("#define #{params[:udp6_cepid]}	#{params[:udp6_cepid].val}")
 end
-$cfgData[:VRID_TCP_REP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:tcp4_repid]}	#{params[:tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}")
-end
-$cfgData[:VRID_TCP_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:tcp4_cepid]}	#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}")
+$cfgData[:VRID_TCP4_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp4_repid]}	#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}")
+end
+$cfgData[:VRID_TCP4_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp4_cepid]}	#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}")
 end
 $cfgData[:VRID_TCP6_REP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:tcp6_repid]}	#{params[:tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}")
+	$tinetCfgH.add("#define #{params[:vrid_tcp6_repid]}	#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}")
 end
 $cfgData[:VRID_TCP6_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:tcp6_cepid]}	#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}")
-end
-$cfgData[:VRID_UDP_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:udp4_cepid]}	#{params[:udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}")
+	$tinetCfgH.add("#define #{params[:vrid_tcp6_cepid]}	#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}")
+end
+$cfgData[:VRID_UDP4_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_udp4_cepid]}	#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}")
 end
 $cfgData[:VRID_UDP6_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:udp6_cepid]}	#{params[:udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}")
+	$tinetCfgH.add("#define #{params[:vrid_udp6_cepid]}	#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}")
 end
 $tinetCfgH.add()
@@ -144,7 +144,7 @@
 
 #	// TCP (IPv4) åä»å£
-if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
-	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_TCP_REPID	#{$cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP_REP].size}")
+if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP4_REP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("#define TNUM_TCP_REPID	#{$cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP4_REP].size}")
 	$tinetCfgC.add()
 	$tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP_REPID - 1);")
@@ -161,5 +161,5 @@
 			$tinetCfgC.add("\t\t},")
 	end
-	$cfgData[:VRID_TCP_REP].each do |key, params|
+	$cfgData[:VRID_TCP4_REP].each do |key, params|
 		$tinetCfgC.add("\t{")
 			$tinetCfgC.add("\t\t0,")
@@ -167,5 +167,5 @@
 	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
 			$tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:tcp4_repid].val + $cfgData[:TCP_CRE_REP].size},")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size},")
 	$tinetCfgC.add("#endif")
 			$tinetCfgC.add("\t\t},")
@@ -198,5 +198,5 @@
 	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
 			$tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size},")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size},")
 	$tinetCfgC.add("#endif")
 			$tinetCfgC.add("\t\t},")
@@ -206,7 +206,7 @@
 
 #	// TCP (IPv4) éä¿¡ç«¯ç¹
-if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
-	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_TCP_CEPID	#{$cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP_CEP].size}")
+if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP4_CEP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("#define TNUM_TCP_CEPID	#{$cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP4_CEP].size}")
 	$tinetCfgC.add()
 	$tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP_CEPID - 1);")
@@ -228,5 +228,5 @@
 			$tinetCfgC.add("\t\t},")
 	end
-	$cfgData[:VRID_TCP_CEP].each do |key, params|
+	$cfgData[:VRID_TCP4_CEP].each do |key, params|
 		$tinetCfgC.add("\t{")
 			$tinetCfgC.add("\t\t0,")
@@ -237,8 +237,8 @@
 			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
 			$tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
 			$tinetCfgC.add("\t\t},")
 	end
@@ -278,8 +278,8 @@
 			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
 			$tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
 			$tinetCfgC.add("\t\t},")
 	end
@@ -288,7 +288,7 @@
 
 #	// UDP (IPv4) éä¿¡ç«¯ç¹
-if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
-	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_UDP_CEPID	#{$cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP_CEP].size}")
+if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP4_CEP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("#define TNUM_UDP_CEPID	#{$cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP4_CEP].size}")
 	$tinetCfgC.add()
 	$tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP_CEPID - 1);")
@@ -307,5 +307,5 @@
 			$tinetCfgC.add("\t\t},")
 	end
-	$cfgData[:VRID_UDP_CEP].each do |key, params|
+	$cfgData[:VRID_UDP4_CEP].each do |key, params|
 		$tinetCfgC.add("\t{")
 			$tinetCfgC.add("\t\t0,")
@@ -313,8 +313,8 @@
 			$tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
 			$tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
 			$tinetCfgC.add("\t\t},")
 	end
@@ -348,8 +348,8 @@
 			$tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
 			$tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
 			$tinetCfgC.add("\t\t},")
 	end
@@ -362,5 +362,5 @@
 
 #	// TCP (IPv4) åä»å£
-if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
+if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP4_REP].size > 0
 	$cfgData[:TCP_CRE_REP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
@@ -371,7 +371,7 @@
 		$cfgFileInfo.push(cfgInfo)
 	end
-	$cfgData[:VRID_TCP_REP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}"
+	$cfgData[:VRID_TCP4_REP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -393,5 +393,5 @@
 	$cfgData[:VRID_TCP6_REP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}"
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -402,5 +402,5 @@
 
 #	// TCP (IPv4) éä¿¡ç«¯ç¹
-if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
+if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP4_CEP].size > 0
 	$cfgData[:TCP_CRE_CEP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
@@ -429,26 +429,26 @@
 		$cfgFileInfo.push(cfgInfo)
 	end
-	$cfgData[:VRID_TCP_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
+	$cfgData[:VRID_TCP4_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
 		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
 		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
@@ -487,24 +487,24 @@
 	$cfgData[:VRID_TCP6_CEP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
 		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
 		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
@@ -514,5 +514,5 @@
 
 #	// UDP (IPv4) éä¿¡ç«¯ç¹
-if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
+if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP4_CEP].size > 0
 	$cfgData[:UDP_CRE_CEP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
@@ -530,7 +530,7 @@
 		$cfgFileInfo.push(cfgInfo)
 	end
-	$cfgData[:VRID_UDP_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
+	$cfgData[:VRID_UDP4_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -539,5 +539,5 @@
 
 		cfgInfo = { APINAME: "CRE_DTQ" }
-		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
+		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
 		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
 		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
@@ -566,5 +566,5 @@
 	$cfgData[:VRID_UDP6_CEP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
+		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -573,5 +573,5 @@
 
 		cfgInfo = { APINAME: "CRE_DTQ" }
-		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
+		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
 		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
 		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
Index: /EcnlProtoTool/trunk/mrbgems/.project
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/.project	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/.project	(revision 279)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>mrbgems</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/.gitignore
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/.gitignore	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/.gitignore	(revision 279)
@@ -0,0 +1,5 @@
+gem_*
+gem-*
+mrb-*.a
+src/*.o
+/tmp
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/.travis.yml
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/.travis.yml	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/.travis.yml	(revision 279)
@@ -0,0 +1,2 @@
+script:
+  - "ruby run_test.rb all test"
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/README.md
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/README.md	(revision 279)
@@ -0,0 +1,56 @@
+mruby-dir
+=========
+
+Dir class for mruby.  Supported methods are:
+
+`.chdir`
+`.delete`
+`.entries`
+`.exist?`
+`.foreach`
+`.getwd`
+`.mkdir`
+`.open`
+`#close`
+`#each`
+`#read`
+`#rewind`
+`#seek`
+`#tell`
+
+
+## License
+
+Copyright (c) 2012 Internet Initiative Japan Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a 
+copy of this software and associated documentation files (the "Software"), 
+to deal in the Software without restriction, including without limitation 
+the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+and/or sell copies of the Software, and to permit persons to whom the 
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in 
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+DEALINGS IN THE SOFTWARE.
+
+
+- On Windows platforms, you must agree on addional license too:
+
+Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose is hereby granted without fee, provided
+that this copyright and permissions notice appear in all copies and
+derivatives.
+
+This software is supplied "as is" without express or implied warranty.
+
+But that said, if there are any problems please get in touch.
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/mrbgem.rake	(revision 279)
@@ -0,0 +1,6 @@
+MRuby::Gem::Specification.new('mruby-dir') do |spec|
+  spec.license = 'MIT and MIT-like license'
+  spec.authors = [ 'Internet Initiative Japan Inc.', 'Kevlin Henney']
+
+  spec.cc.include_paths << "#{build.root}/src"
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/mrblib/dir.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/mrblib/dir.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/mrblib/dir.rb	(revision 279)
@@ -0,0 +1,64 @@
+class Dir
+  def each(&block)
+    while s = self.read
+      block.call(s)
+    end
+    self
+  end
+
+  alias pos tell
+  alias pos= seek
+
+  def self.entries(path)
+    a = []
+      self.open(path) { |d|
+      while s = d.read
+        a << s
+      end
+    }
+    a
+  end
+
+  def self.foreach(path, &block)
+    if block
+      self.open(path).each { |f| block.call(f) }
+    else
+      self.open(path).each
+    end
+  end
+
+  def self.open(path, &block)
+    if block
+      d = self.new(path)
+      begin
+        block.call(d)
+      ensure
+        d.close
+      end
+    else
+      self.new(path)
+    end
+  end
+
+  def self.chdir(path, &block)
+    my = self # workaround for https://github.com/mruby/mruby/issues/1579
+    if block
+      wd = self.getwd
+      begin
+        self._chdir(path)
+        block.call(path)
+      ensure
+        my._chdir(wd)
+      end
+    else
+      self._chdir(path)
+    end
+  end
+
+  class << self
+    alias exists? exist?
+    alias pwd getwd
+    alias rmdir delete
+    alias unlink delete
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/run_test.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/run_test.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/run_test.rb	(revision 279)
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+#
+# mrbgems test runner
+#
+
+gemname = File.basename(File.dirname(File.expand_path __FILE__))
+
+if __FILE__ == $0
+  repository, dir = 'https://github.com/mruby/mruby.git', 'tmp/mruby'
+  build_args = ARGV
+  build_args = ['all', 'test']  if build_args.nil? or build_args.empty?
+
+  Dir.mkdir 'tmp'  unless File.exist?('tmp')
+  unless File.exist?(dir)
+    system "git clone #{repository} #{dir}"
+  end
+
+  exit system(%Q[cd #{dir}; MRUBY_CONFIG=#{File.expand_path __FILE__} ruby minirake #{build_args.join(' ')}])
+end
+
+MRuby::Build.new do |conf|
+  toolchain :gcc
+  conf.gembox 'default'
+  conf.enable_test
+
+  conf.gem File.expand_path(File.dirname(__FILE__))
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/src/Win/dirent.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/src/Win/dirent.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/src/Win/dirent.c	(revision 279)
@@ -0,0 +1,154 @@
+/*
+
+    Implementation of POSIX directory browsing functions and types for Win32.
+
+    Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
+    History: Created March 1997. Updated June 2003 and July 2012.
+    Rights:  See end of file.
+
+*/
+
+#include <errno.h>
+#include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef ptrdiff_t handle_type; /* C99's intptr_t not sufficiently portable */
+
+struct dirent
+{
+    char *d_name;
+};
+
+struct DIR
+{
+    handle_type         handle; /* -1 for failed rewind */
+    struct _finddata_t  info;
+    struct dirent       result; /* d_name null iff first time */
+    char                *name;  /* null-terminated char string */
+};
+
+typedef struct DIR DIR;
+
+DIR *opendir(const char *name)
+{
+    DIR *dir = 0;
+
+    if(name && name[0])
+    {
+        size_t base_length = strlen(name);
+        const char *all = /* search pattern must end with suitable wildcard */
+            strchr("/\\", name[base_length - 1]) ? "*" : "/*";
+
+        if((dir = (DIR *) malloc(sizeof *dir)) != 0 &&
+           (dir->name = (char *) malloc(base_length + strlen(all) + 1)) != 0)
+        {
+            strcat(strcpy(dir->name, name), all);
+
+            if((dir->handle =
+                (handle_type) _findfirst(dir->name, &dir->info)) != -1)
+            {
+                dir->result.d_name = 0;
+            }
+            else /* rollback */
+            {
+                free(dir->name);
+                free(dir);
+                dir = 0;
+            }
+        }
+        else /* rollback */
+        {
+            free(dir);
+            dir   = 0;
+            errno = ENOMEM;
+        }
+    }
+    else
+    {
+        errno = EINVAL;
+    }
+
+    return dir;
+}
+
+int closedir(DIR *dir)
+{
+    int result = -1;
+
+    if(dir)
+    {
+        if(dir->handle != -1)
+        {
+            result = _findclose(dir->handle);
+        }
+
+        free(dir->name);
+        free(dir);
+    }
+
+    if(result == -1) /* map all errors to EBADF */
+    {
+        errno = EBADF;
+    }
+
+    return result;
+}
+
+struct dirent *readdir(DIR *dir)
+{
+    struct dirent *result = 0;
+
+    if(dir && dir->handle != -1)
+    {
+        if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
+        {
+            result         = &dir->result;
+            result->d_name = dir->info.name;
+        }
+    }
+    else
+    {
+        errno = EBADF;
+    }
+
+    return result;
+}
+
+void rewinddir(DIR *dir)
+{
+    if(dir && dir->handle != -1)
+    {
+        _findclose(dir->handle);
+        dir->handle = (handle_type) _findfirst(dir->name, &dir->info);
+        dir->result.d_name = 0;
+    }
+    else
+    {
+        errno = EBADF;
+    }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+
+    Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved.
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose is hereby granted without fee, provided
+    that this copyright and permissions notice appear in all copies and
+    derivatives.
+    
+    This software is supplied "as is" without express or implied warranty.
+
+    But that said, if there are any problems please get in touch.
+
+*/
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/src/dir.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/src/dir.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/src/dir.c	(revision 279)
@@ -0,0 +1,308 @@
+/*
+** dir.c - Dir
+**
+** See Copyright Notice in mruby.h
+*/
+
+#include "mruby.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/string.h"
+#include "error.h"
+#include <sys/types.h>
+#if (defined(_WIN32) || defined(_WIN64)) && !defined(MUSL_LIBC)
+  #define MAXPATHLEN 1024
+ #if !defined(PATH_MAX)
+  #define PATH_MAX MAX_PATH
+ #endif
+  #define S_ISDIR(B) ((B)&_S_IFDIR)
+  #include "Win/dirent.c"
+  #include <direct.h>
+  #define rmdir _rmdir
+  #define getcwd _getcwd
+  #define mkdir _mkdir
+  #define chdir _chdir
+#elif defined(__NEWLIB__)
+  #include <sys/param.h>
+  #include "_dirent.h"
+  #include <unistd.h>
+#else
+  #include <sys/param.h>
+  #include <dirent.h>
+  #include <unistd.h>
+#endif
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+
+/* with/without IO module */
+#ifdef ENABLE_IO
+#include "mruby/ext/io.h"
+#else
+#define E_IO_ERROR E_RUNTIME_ERROR
+#endif
+
+struct mrb_dir {
+  DIR *dir;
+};
+
+void
+mrb_dir_free(mrb_state *mrb, void *ptr)
+{
+  struct mrb_dir *mdir = (struct mrb_dir *)ptr;
+
+  if (mdir->dir) {
+    closedir(mdir->dir);
+    mdir->dir = NULL;
+  }
+  mrb_free(mrb, mdir);
+}
+
+static struct mrb_data_type mrb_dir_type = { "DIR", mrb_dir_free };
+
+mrb_value
+mrb_dir_close(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_dir *mdir;
+  mdir = (struct mrb_dir *)mrb_get_datatype(mrb, self, &mrb_dir_type);
+  if (!mdir) return mrb_nil_value();
+  if (!mdir->dir) {
+    mrb_raise(mrb, E_IO_ERROR, "closed directory");
+  }
+  if (closedir(mdir->dir) == -1) {
+    mrb_sys_fail(mrb, "closedir");
+  }
+  mdir->dir = NULL;
+  return mrb_nil_value();
+}
+
+mrb_value
+mrb_dir_init(mrb_state *mrb, mrb_value self)
+{
+  DIR *dir;
+  struct mrb_dir *mdir;
+  mrb_value path;
+  char *cpath;
+
+  mdir = (struct mrb_dir *)DATA_PTR(self);
+  if (mdir) {
+    mrb_dir_free(mrb, mdir);
+  }
+  DATA_TYPE(self) = &mrb_dir_type;
+  DATA_PTR(self) = NULL;
+
+  mdir = (struct mrb_dir *)mrb_malloc(mrb, sizeof(*mdir));
+  mdir->dir = NULL;
+  DATA_PTR(self) = mdir;
+
+  mrb_get_args(mrb, "S", &path);
+  cpath = mrb_str_to_cstr(mrb, path);
+  if ((dir = opendir(cpath)) == NULL) {
+    mrb_sys_fail(mrb, cpath);
+  }
+  mdir->dir = dir;
+  return self;
+}
+
+mrb_value
+mrb_dir_delete(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value path;
+  char *cpath;
+
+  mrb_get_args(mrb, "S", &path);
+  cpath = mrb_str_to_cstr(mrb, path);
+  if (rmdir(cpath) == -1) {
+    mrb_sys_fail(mrb, cpath);
+  }
+  return mrb_fixnum_value(0);
+}
+
+mrb_value
+mrb_dir_existp(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value path;
+  struct stat sb;
+  char *cpath;
+
+  mrb_get_args(mrb, "S", &path);
+  cpath = mrb_str_to_cstr(mrb, path);
+  if (stat(cpath, &sb) == 0 && S_ISDIR(sb.st_mode)) {
+    return mrb_true_value();
+  } else {
+    return mrb_false_value();
+  }
+}
+
+mrb_value
+mrb_dir_getwd(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value path;
+
+  path = mrb_str_buf_new(mrb, MAXPATHLEN);
+  if (getcwd(RSTRING_PTR(path), MAXPATHLEN) == NULL) {
+    mrb_sys_fail(mrb, "getcwd(2)");
+  }
+  mrb_str_resize(mrb, path, strlen(RSTRING_PTR(path)));
+  return path;
+}
+
+mrb_value
+mrb_dir_mkdir(mrb_state *mrb, mrb_value klass)
+{
+  mrb_int mode;
+  mrb_value spath;
+  char *path;
+
+  mode = 0777;
+  mrb_get_args(mrb, "S|i", &spath, &mode);
+  path = mrb_str_to_cstr(mrb, spath);
+#if (!defined(_WIN32) && !defined(_WIN64)) || defined(MUSL_LIBC)
+  if (mkdir(path, mode) == -1) {
+#else
+  if (mkdir(path) == -1) {
+#endif
+    mrb_sys_fail(mrb, path);
+  }
+  return mrb_fixnum_value(0);
+}
+
+mrb_value
+mrb_dir_chdir(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value spath;
+  char *path;
+
+  mrb_get_args(mrb, "S", &spath);
+  path = mrb_str_to_cstr(mrb, spath);
+  if (chdir(path) == -1) {
+    mrb_sys_fail(mrb, path);
+  }
+  return mrb_fixnum_value(0);
+}
+
+mrb_value
+mrb_dir_chroot(mrb_state *mrb, mrb_value self)
+{
+  #if defined(_WIN32) || defined(_WIN64) || defined(__android__)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "chroot() unreliable on Win platforms");
+  return mrb_fixnum_value(0);
+  #else
+  mrb_value spath;
+  char *path;
+  int res;
+
+  mrb_get_args(mrb, "S", &spath);
+  path = mrb_str_to_cstr(mrb, spath);
+  res = chroot(path);
+  if (res == -1) {
+    mrb_sys_fail(mrb, path);
+  }
+
+  return mrb_fixnum_value(res);
+  #endif
+}
+
+mrb_value
+mrb_dir_read(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_dir *mdir;
+  struct dirent *dp;
+
+  mdir = (struct mrb_dir *)mrb_get_datatype(mrb, self, &mrb_dir_type);
+  if (!mdir) return mrb_nil_value();
+  if (!mdir->dir) {
+    mrb_raise(mrb, E_IO_ERROR, "closed directory");
+  }
+  dp = readdir(mdir->dir);
+  if (dp != NULL) {
+    return mrb_str_new_cstr(mrb, dp->d_name);
+  } else {
+    return mrb_nil_value();
+  }
+}
+
+mrb_value
+mrb_dir_rewind(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_dir *mdir;
+
+  mdir = (struct mrb_dir *)mrb_get_datatype(mrb, self, &mrb_dir_type);
+  if (!mdir) return mrb_nil_value();
+  if (!mdir->dir) {
+    mrb_raise(mrb, E_IO_ERROR, "closed directory");
+  }
+  rewinddir(mdir->dir);
+  return self;
+}
+
+mrb_value
+mrb_dir_seek(mrb_state *mrb, mrb_value self)
+{
+  #if defined(_WIN32) || defined(_WIN64) || defined(__android__)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "dirseek() unreliable on Win platforms");
+  return self;
+  #else
+  struct mrb_dir *mdir;
+  mrb_int pos;
+
+  mdir = (struct mrb_dir *)mrb_get_datatype(mrb, self, &mrb_dir_type);
+  if (!mdir) return mrb_nil_value();
+  if (!mdir->dir) {
+    mrb_raise(mrb, E_IO_ERROR, "closed directory");
+  }
+  mrb_get_args(mrb, "i", &pos);
+  seekdir(mdir->dir, (long)pos);
+  return self;
+  #endif
+}
+
+mrb_value
+mrb_dir_tell(mrb_state *mrb, mrb_value self)
+{
+  #if defined(_WIN32) || defined(_WIN64) || defined(__android__)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "dirtell() unreliable on Win platforms");
+  return mrb_fixnum_value(0);
+  #else
+  struct mrb_dir *mdir;
+  mrb_int pos;
+
+  mdir = (struct mrb_dir *)mrb_get_datatype(mrb, self, &mrb_dir_type);
+  if (!mdir) return mrb_nil_value();
+  if (!mdir->dir) {
+    mrb_raise(mrb, E_IO_ERROR, "closed directory");
+  }
+  pos = (mrb_int)telldir(mdir->dir);
+  return mrb_fixnum_value(pos);
+  #endif
+}
+
+void
+mrb_mruby_dir_gem_init(mrb_state *mrb)
+{
+  struct RClass *d;
+
+  d = mrb_define_class(mrb, "Dir", mrb->object_class);
+  MRB_SET_INSTANCE_TT(d, MRB_TT_DATA);
+  mrb_define_class_method(mrb, d, "delete", mrb_dir_delete, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, d, "exist?", mrb_dir_existp, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, d, "getwd",  mrb_dir_getwd,  MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, d, "mkdir",  mrb_dir_mkdir,  MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  mrb_define_class_method(mrb, d, "_chdir", mrb_dir_chdir,  MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, d, "chroot", mrb_dir_chroot, MRB_ARGS_REQ(1));
+
+  mrb_define_method(mrb, d, "close",      mrb_dir_close,  MRB_ARGS_NONE());
+  mrb_define_method(mrb, d, "initialize", mrb_dir_init,   MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, d, "read",       mrb_dir_read,   MRB_ARGS_NONE());
+  mrb_define_method(mrb, d, "rewind",     mrb_dir_rewind, MRB_ARGS_NONE());
+  mrb_define_method(mrb, d, "seek",       mrb_dir_seek,   MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, d, "tell",       mrb_dir_tell,   MRB_ARGS_NONE());
+}
+
+void
+mrb_mruby_dir_gem_final(mrb_state *mrb)
+{
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/test/dir.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/test/dir.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/test/dir.rb	(revision 279)
@@ -0,0 +1,136 @@
+assert('Dir') do
+  assert_equal(Class, Dir.class)
+end
+
+assert('DirTest.setup') do
+  DirTest.setup
+end
+
+assert('Dir.chdir') do
+  assert_equal 0, Dir.chdir(DirTest.sandbox)
+end
+
+assert('Dir.entries') do
+  a = Dir.entries(DirTest.sandbox)
+  assert_true a.include? "a"
+  assert_true a.include? "b"
+end
+
+assert('Dir.exist?') do
+  assert_true Dir.exist?(DirTest.sandbox)
+  assert_false Dir.exist?(DirTest.sandbox + "/nosuchdir")
+end
+
+assert('Dir.foreach') do
+  a = []
+  Dir.foreach(DirTest.sandbox) { |s| a << s }
+  assert_true a.include? "a"
+  assert_true a.include? "b"
+end
+
+assert('Dir.getwd') do
+  s = Dir.getwd
+  assert_true s.kind_of? String
+end
+
+assert('Dir.mkdir') do
+  m1 = DirTest.sandbox + "/mkdir1"
+  m2 = DirTest.sandbox + "/mkdir2"
+  assert_equal 0, Dir.mkdir(m1)
+  assert_equal 0, Dir.mkdir(m2, 0765)
+end
+
+assert('Dir.delete') do
+  s = DirTest.sandbox + "/delete"
+  Dir.mkdir(s)
+  assert_true Dir.exist?(s)
+
+  Dir.delete(s)
+  assert_false Dir.exist?(s)
+end
+
+assert('Dir.open') do
+  a = []
+  Dir.open(DirTest.sandbox) { |d|
+    d.each { |s| a << s }
+  }
+  assert_true a.include? "a"
+  assert_true a.include? "b"
+end
+
+assert('Dir#initialize and Dir#close') do
+  d = Dir.new(".")
+  assert_true d.instance_of? Dir
+  assert_nil d.close
+end
+
+assert('Dir#close') do
+  d = Dir.new(".")
+end
+
+assert('Dir#each') do
+  a = []
+  d = Dir.open(DirTest.sandbox)
+  d.each { |s| a << s }
+  d.close
+  assert_true a.include? "a"
+  assert_true a.include? "b"
+end
+
+assert('Dir#read') do
+  a = []
+  d = Dir.open(DirTest.sandbox)
+  while s = d.read
+    a << s
+  end
+  d.close
+  assert_true a.include? "a"
+  assert_true a.include? "b"
+end
+
+assert('Dir#rewind') do
+  d = Dir.open(DirTest.sandbox)
+  while d.read; end
+
+  assert_equal d, d.rewind
+
+  a = []
+  while s = d.read
+    a << s
+  end
+  d.close
+  assert_true a.include? "a"
+  assert_true a.include? "b"
+end
+
+# Note: behaviors of seekdir(3) and telldir(3) are so platform-dependent
+# that we cannot write portable tests here.
+
+assert('Dir#tell') do
+  n = nil
+  begin
+    Dir.open(DirTest.sandbox) { |d|
+      n = d.tell
+    }
+    assert_true n.is_a? Integer
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('Dir#seek') do
+  d1 = Dir.open(DirTest.sandbox)
+  d1.read
+  begin
+    n = d1.tell
+    d1.read
+    d2 = d1.seek(n)
+    assert_equal d1, d2
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('DirTest.teardown') do
+  DirTest.teardown
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-dir/test/dirtest.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-dir/test/dirtest.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-dir/test/dirtest.c	(revision 279)
@@ -0,0 +1,129 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <unistd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "mruby.h"
+#include "mruby/string.h"
+#include "mruby/variable.h"
+
+
+mrb_value
+mrb_dirtest_setup(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value s;
+  char buf[1024];
+  const char *aname = "a";
+  const char *bname = "b";
+
+  /* save current working directory */
+  if (getcwd(buf, sizeof(buf)) == NULL) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "getcwd() failed");
+  }
+  mrb_cv_set(mrb, klass, mrb_intern_cstr(mrb, "pwd"), mrb_str_new_cstr(mrb, buf));
+
+  /* create sandbox */
+#if defined(_WIN32) || defined(_WIN64)
+  snprintf(buf, sizeof(buf), "%s\\mruby-dir-test.XXXXXX", _getcwd(NULL,0));
+  if ((mktemp(buf) == NULL) || mkdir(buf) != 0) {
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "mkdtemp(%S) failed", mrb_str_new_cstr(mrb, buf));
+  }
+#else
+  snprintf(buf, sizeof(buf), "%s/mruby-dir-test.XXXXXX", P_tmpdir);
+  if (mkdtemp(buf) == NULL) {
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "mkdtemp(%S) failed", mrb_str_new_cstr(mrb, buf));
+  }
+#endif
+  s = mrb_str_new_cstr(mrb, buf);
+  mrb_cv_set(mrb, klass, mrb_intern_cstr(mrb, "sandbox"), s);
+
+  /* go to sandbox */
+  if (chdir(buf) == -1) {
+    rmdir(buf);
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "chdir(%S) failed", s);
+  }
+  
+  /* make some directories in the sandbox */
+#if defined(_WIN32) || defined(_WIN64)
+  if (mkdir(aname) == -1) {
+#else
+  if (mkdir(aname, 0) == -1) {
+#endif
+    chdir("..");
+    rmdir(buf);
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "mkdir(%S) failed", mrb_str_new_cstr(mrb, aname));
+  }
+#if defined(_WIN32) || defined(_WIN64)
+  if (mkdir(bname) == -1) {
+#else
+  if (mkdir(bname, 0) == -1) {
+#endif
+    rmdir(aname);
+    chdir("..");
+    rmdir(buf);
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "mkdir(%S) failed", mrb_str_new_cstr(mrb, bname));
+  }
+
+  return mrb_true_value();
+}
+
+mrb_value
+mrb_dirtest_teardown(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value d, sandbox;
+  DIR *dirp;
+  struct dirent *dp;
+  const char *path;
+
+  /* cleanup sandbox */
+  sandbox = mrb_cv_get(mrb, klass, mrb_intern_cstr(mrb, "sandbox"));
+  path = mrb_str_to_cstr(mrb, sandbox);
+
+  dirp = opendir(path);
+  while ((dp = readdir(dirp)) != NULL) {
+    if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)
+      continue;
+    if (rmdir(dp->d_name) == -1) {
+      mrb_raisef(mrb, E_RUNTIME_ERROR, "rmdir(%S) failed", mrb_str_new_cstr(mrb, dp->d_name));
+    }
+  }
+  closedir(dirp);
+
+  /* back to original pwd */
+  d = mrb_cv_get(mrb, klass, mrb_intern_cstr(mrb, "pwd"));
+  path = mrb_str_to_cstr(mrb, d);
+  if (chdir(path) == -1) {
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "chdir(%S) failed", d);
+  }
+
+  /* remove sandbox directory */
+  sandbox = mrb_cv_get(mrb, klass, mrb_intern_cstr(mrb, "sandbox"));
+  path = mrb_str_to_cstr(mrb, sandbox);
+  if (rmdir(path) == -1) {
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "rmdir(%S) failed", sandbox);
+  }
+
+  return mrb_true_value();
+}
+
+mrb_value
+mrb_dirtest_sandbox(mrb_state *mrb, mrb_value klass)
+{
+  return mrb_cv_get(mrb, klass, mrb_intern_cstr(mrb, "sandbox"));
+}
+
+void
+mrb_mruby_dir_gem_test(mrb_state *mrb)
+{
+  struct RClass *c = mrb_define_module(mrb, "DirTest");
+
+  mrb_define_class_method(mrb, c, "sandbox", mrb_dirtest_sandbox, MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, c, "setup", mrb_dirtest_setup, MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, c, "teardown", mrb_dirtest_teardown, MRB_ARGS_NONE());
+}
+
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/.gitignore
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/.gitignore	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/.gitignore	(revision 279)
@@ -0,0 +1,1 @@
+/tmp
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/.travis.yml
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/.travis.yml	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/.travis.yml	(revision 279)
@@ -0,0 +1,2 @@
+script:
+  - "ruby run_test.rb all test"
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/README.md
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/README.md	(revision 279)
@@ -0,0 +1,191 @@
+mruby-io
+========
+
+IO, File module for mruby
+
+## Installation
+Add the line below to your `build_config.rb`:
+
+```
+  conf.gem :github => 'iij/mruby-io'
+```
+
+## Implemented methods
+
+### IO
+ - http://doc.ruby-lang.org/ja/1.9.3/class/IO.html
+
+| method                     | mruby-io | memo |
+| -------------------------  | -------- | ---- |
+| IO.binread                 |          |      |
+| IO.binwrite                |          |      |
+| IO.copy_stream             |          |      |
+| IO.new, IO.for_fd, IO.open |  o  |     |
+| IO.foreach                 |          |      |
+| IO.pipe                    |    o     |      |
+| IO.popen                   |    o     |      |
+| IO.read                    |    o     |      |
+| IO.readlines               |          |      |
+| IO.select                  |    o     |      |
+| IO.sysopen                 |    o     |      |
+| IO.try_convert             |          |      |
+| IO.write                   |          |      |
+| IO#<<                      |          |      |
+| IO#advise                  |          |      |
+| IO#autoclose=              |          |      |
+| IO#autoclose?              |          |      |
+| IO#binmode                 |          |      |
+| IO#binmode?                |          |      |
+| IO#bytes                   |          | obsolete |
+| IO#chars                   |          | obsolete |
+| IO#clone, IO#dup           |          |      |
+| IO#close                   |    o     |      |
+| IO#close_on_exec=          |    o     |      |
+| IO#close_on_exec?          |    o     |      |
+| IO#close_read              |          |      |
+| IO#close_write             |          |      |
+| IO#closed?                 |    o     |      |
+| IO#codepoints              |          | obsolete |
+| IO#each_byte               |    o     |      |
+| IO#each_char               |    o     |      |
+| IO#each_codepoint          |          |      |
+| IO#each_line               |    o     |      |
+| IO#eof, IO#eof?            |    o     |      |
+| IO#external_encoding       |          |      |
+| IO#fcntl                   |          |      |
+| IO#fdatasync               |          |      |
+| IO#fileno, IO#to_i         |    o     |      |
+| IO#flush                   |    o     |      |
+| IO#fsync                   |          |      |
+| IO#getbyte                 |          |      |
+| IO#getc                    |    o     |      |
+| IO#gets                    |    o     |      |
+| IO#internal_encoding       |          |      |
+| IO#ioctl                   |          |      |
+| IO#isatty, IO#tty?         |          |      |
+| IO#lineno                  |          |      |
+| IO#lineno=                 |          |      |
+| IO#lines                   |          | obsolete |
+| IO#pid                     |    o     |      |
+| IO#pos, IO#tell            |    o     |      |
+| IO#pos=                    |    o     |      |
+| IO#print                   |    o     |      |
+| IO#printf                  |    o     |      |
+| IO#putc                    |          |      |
+| IO#puts                    |    o     |      |
+| IO#read                    |    o     |      |
+| IO#read_nonblock           |          |      |
+| IO#readbyte                |          |      |
+| IO#readchar                |    o     |      |
+| IO#readline                |    o     |      |
+| IO#readlines               |    o     |      |
+| IO#readpartial             |          |      |
+| IO#reopen                  |          |      |
+| IO#rewind                  |          |      |
+| IO#seek                    |    o     |      |
+| IO#set_encoding            |          |      |
+| IO#stat                    |          |      |
+| IO#sync                    |    o     |      |
+| IO#sync=                   |    o     |      |
+| IO#sysread                 |    o     |      |
+| IO#sysseek                 |    o     |      |
+| IO#syswrite                |    o     |      |
+| IO#to_io                   |          |      |
+| IO#ungetbyte               |          |      |
+| IO#ungetc                  |    o     |      |
+| IO#write                   |    o     |      |
+| IO#write_nonblock          |          |      |
+
+### File
+ - http://doc.ruby-lang.org/ja/1.9.3/class/File.html
+
+| method                      | mruby-io | memo |
+| --------------------------- | -------- | ---- |
+| File.absolute_path          |          |      |
+| File.atime                  |          |      |
+| File.basename               |   o      |      |
+| File.blockdev?              |          | FileTest |
+| File.chardev?               |          | FileTest |
+| File.chmod                  |          |      |
+| File.chown                  |          |      |
+| File.ctime                  |          |      |
+| File.delete, File.unlink    |   o      |      |
+| File.directory?             |   o      | FileTest |
+| File.dirname                |   o      |      |
+| File.executable?            |          | FileTest |
+| File.executable_real?       |          | FileTest |
+| File.exist?, exists?        |   o      | FileTest |
+| File.expand_path            |   o      |      |
+| File.extname                |   o      |      |
+| File.file?                  |   o      | FileTest |
+| File.fnmatch, File.fnmatch? |          |      |
+| File.ftype                  |          |      |
+| File.grpowned?              |          | FileTest |
+| File.identical?             |          | FileTest |
+| File.join                   |   o      |      |
+| File.lchmod                 |          |      |
+| File.lchown                 |          |      |
+| File.link                   |          |      |
+| File.lstat                  |          |      |
+| File.mtime                  |          |      |
+| File.new, File.open         |   o      |      |
+| File.owned?                 |          | FileTest |
+| File.path                   |          |      |
+| File.pipe?                  |   o      | FileTest |
+| File.readable?              |          | FileTest |
+| File.readable_real?         |          | FileTest |
+| File.readlink               |          |      |
+| File.realdirpath            |          |      |
+| File.realpath               |   o      |      |
+| File.rename                 |   o      |      |
+| File.setgid?                |          | FileTest |
+| File.setuid?                |          | FileTest |
+| File.size                   |   o      |      |
+| File.size?                  |   o      | FileTest |
+| File.socket?                |   o      | FileTest |
+| File.split                  |          |      |
+| File.stat                   |          |      |
+| File.sticky?                |          | FileTest |
+| File.symlink                |          |      |
+| File.symlink?               |   o      | FileTest |
+| File.truncate               |          |      |
+| File.umask                  |   o      |      |
+| File.utime                  |          |      |
+| File.world_readable?        |          |      |
+| File.world_writable?        |          |      |
+| File.writable?              |          | FileTest |
+| File.writable_real?         |          | FileTest |
+| File.zero?                  |   o      | FileTest |
+| File#atime                  |          |      |
+| File#chmod                  |          |      |
+| File#chown                  |          |      |
+| File#ctime                  |          |      |
+| File#flock                  |   o      |      |
+| File#lstat                  |          |      |
+| File#mtime                  |          |      |
+| File#path, File#to_path     |   o      |      |
+| File#size                   |          |      |
+| File#truncate               |          |      |
+
+
+## License
+
+Copyright (c) 2013 Internet Initiative Japan Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a 
+copy of this software and associated documentation files (the "Software"), 
+to deal in the Software without restriction, including without limitation 
+the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+and/or sell copies of the Software, and to permit persons to whom the 
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in 
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+DEALINGS IN THE SOFTWARE.
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/include/mruby/ext/io.h
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/include/mruby/ext/io.h	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/include/mruby/ext/io.h	(revision 279)
@@ -0,0 +1,37 @@
+/*
+** io.h - IO class
+*/
+
+#ifndef MRUBY_IO_H
+#define MRUBY_IO_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct mrb_io {
+  int fd;   /* file descriptor, or -1 */
+  int fd2;  /* file descriptor to write if it's different from fd, or -1 */
+  int pid;  /* child's pid (for pipes)  */
+  unsigned int readable:1,
+               writable:1,
+               sync:1;
+};
+
+#define FMODE_READABLE             0x00000001
+#define FMODE_WRITABLE             0x00000002
+#define FMODE_READWRITE            (FMODE_READABLE|FMODE_WRITABLE)
+#define FMODE_BINMODE              0x00000004
+#define FMODE_APPEND               0x00000040
+#define FMODE_CREATE               0x00000080
+#define FMODE_TRUNC                0x00000800
+
+#define E_IO_ERROR                 (mrb_class_get(mrb, "IOError"))
+#define E_EOF_ERROR                (mrb_class_get(mrb, "EOFError"))
+
+mrb_value mrb_io_fileno(mrb_state *mrb, mrb_value io);
+
+#if defined(__cplusplus)
+} /* extern "C" { */
+#endif
+#endif /* MRUBY_IO_H */
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/mrbgem.rake	(revision 279)
@@ -0,0 +1,16 @@
+MRuby::Gem::Specification.new('mruby-io') do |spec|
+  spec.license = 'MIT'
+  spec.authors = 'Internet Initiative Japan Inc.'
+
+  spec.cc.include_paths << "#{build.root}/src"
+  
+  case RUBY_PLATFORM
+  when /mingw|mswin/
+    spec.linker.libraries += ['Ws2_32']
+    #spec.cc.include_paths += ["C:/Windows/system/include"]
+    spec.linker.library_paths += ["C:/Windows/system"]
+  end
+  if build.kind_of?(MRuby::CrossBuild) && %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
+    spec.linker.libraries += ['ws2_32']
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/file.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/file.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/file.rb	(revision 279)
@@ -0,0 +1,208 @@
+class File < IO
+  class FileError < Exception; end
+  class NoFileError < FileError; end
+  class UnableToStat < FileError; end
+  class PermissionError < FileError; end
+
+  attr_accessor :path
+
+  def initialize(fd_or_path, mode = "r", perm = 0666)
+    if fd_or_path.kind_of? Fixnum
+      super(fd_or_path, mode)
+    else
+      @path = fd_or_path
+      fd = IO.sysopen(@path, mode, perm)
+      super(fd, mode)
+    end
+  end
+
+  def self.join(*names)
+    return "" if names.empty?
+
+    names.map! do |name|
+      case name
+      when String
+        name
+      when Array
+        if names == name
+          raise ArgumentError, "recursive array"
+        end
+        join(*name)
+      else
+        raise TypeError, "no implicit conversion of #{name.class} into String"
+      end
+    end
+
+    return names[0] if names.size == 1
+
+    if names[0][-1] == File::SEPARATOR
+      s = names[0][0..-2]
+    else
+      s = names[0].dup
+    end
+
+    (1..names.size-2).each { |i|
+      t = names[i]
+      if t[0] == File::SEPARATOR and t[-1] == File::SEPARATOR
+        t = t[1..-2]
+      elsif t[0] == File::SEPARATOR
+        t = t[1..-1]
+      elsif t[-1] == File::SEPARATOR
+        t = t[0..-2]
+      end
+      s += File::SEPARATOR + t if t != ""
+    }
+    if names[-1][0] == File::SEPARATOR
+      s += File::SEPARATOR + names[-1][1..-1]
+    else
+      s += File::SEPARATOR + names[-1]
+    end
+    s
+  end
+
+  def self.expand_path(path, default_dir = '.')
+    def concat_path(path, base_path)
+      if path[0] == "/" || path[1] == ':' # Windows root!
+        expanded_path = path
+      elsif path[0] == "~"
+        if (path[1] == "/" || path[1] == nil)
+          dir = path[1, path.size]
+          home_dir = _gethome
+
+          unless home_dir
+            raise ArgumentError, "couldn't find HOME environment -- expanding '~'"
+          end
+
+          expanded_path = home_dir
+          expanded_path += dir if dir
+          expanded_path += "/"
+        else
+          splitted_path = path.split("/")
+          user = splitted_path[0][1, splitted_path[0].size]
+          dir = "/" + splitted_path[1, splitted_path.size].join("/")
+
+          home_dir = _gethome(user)
+
+          unless home_dir
+            raise ArgumentError, "user #{user} doesn't exist"
+          end
+
+          expanded_path = home_dir
+          expanded_path += dir if dir
+          expanded_path += "/"
+        end
+      else
+        expanded_path = concat_path(base_path, _getwd)
+        expanded_path += "/" + path
+      end
+
+      expanded_path
+    end
+
+    expanded_path = concat_path(path, default_dir)
+    drive_prefix = ""
+    if File::ALT_SEPARATOR && expanded_path.size > 2 &&
+        ("A".."Z").include?(expanded_path[0].upcase) && expanded_path[1] == ":"
+      drive_prefix = expanded_path[0, 2]
+      expanded_path = expanded_path[2, expanded_path.size]
+    end
+    expand_path_array = []
+    if File::ALT_SEPARATOR && expanded_path.include?(File::ALT_SEPARATOR)
+      expanded_path.gsub!(File::ALT_SEPARATOR, '/')
+    end
+    while expanded_path.include?('//')
+      expanded_path = expanded_path.gsub('//', '/')
+    end
+
+    if expanded_path != "/"
+      expanded_path.split('/').each do |path_token|
+        if path_token == '..'
+          if expand_path_array.size > 1
+            expand_path_array.pop
+          end
+        elsif path_token == '.'
+          # nothing to do.
+        else
+          expand_path_array << path_token
+        end
+      end
+
+      expanded_path = expand_path_array.join("/")
+      if expanded_path.empty?
+        expanded_path = '/'
+      end
+    end
+    if drive_prefix.empty?
+      expanded_path
+    else
+      drive_prefix + expanded_path.gsub("/", File::ALT_SEPARATOR)
+    end
+  end
+
+  def self.foreach(file)
+    if block_given?
+      self.open(file) do |f|
+        f.each {|l| yield l}
+      end
+    else
+      return self.new(file)
+    end
+  end
+
+  def self.directory?(file)
+    FileTest.directory?(file)
+  end
+
+  def self.exist?(file)
+    FileTest.exist?(file)
+  end
+
+  def self.exists?(file)
+    FileTest.exists?(file)
+  end
+
+  def self.file?(file)
+    FileTest.file?(file)
+  end
+
+  def self.pipe?(file)
+    FileTest.pipe?(file)
+  end
+
+  def self.size(file)
+    FileTest.size(file)
+  end
+
+  def self.size?(file)
+    FileTest.size?(file)
+  end
+
+  def self.socket?(file)
+    FileTest.socket?(file)
+  end
+
+  def self.symlink?(file)
+    FileTest.symlink?(file)
+  end
+
+  def self.zero?(file)
+    FileTest.zero?(file)
+  end
+
+  def self.extname(filename)
+    fname = self.basename(filename)
+    return '' if fname[0] == '.' || fname.index('.').nil?
+    ext = fname.split('.').last
+    ext.empty? ? '' : ".#{ext}"
+  end
+
+  def self.path(filename)
+    if filename.kind_of?(String)
+      filename
+    elsif filename.respond_to?(:to_path)
+      filename.to_path
+    else
+      raise TypeError, "no implicit conversion of #{filename.class} into String"
+    end
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/file_constants.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/file_constants.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/file_constants.rb	(revision 279)
@@ -0,0 +1,29 @@
+class File
+  module Constants
+    RDONLY   = 0
+    WRONLY   = 1
+    RDWR     = 2
+    NONBLOCK = 4
+    APPEND   = 8
+
+    BINARY   = 0
+    SYNC     = 128
+    NOFOLLOW = 256
+    CREAT    = 512
+    TRUNC    = 1024
+    EXCL     = 2048
+
+    NOCTTY   = 131072
+    DSYNC    = 4194304
+
+    FNM_SYSCASE  = 0
+    FNM_NOESCAPE = 1
+    FNM_PATHNAME = 2
+    FNM_DOTMATCH = 4
+    FNM_CASEFOLD = 8
+  end
+end
+
+class File
+  include File::Constants
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/io.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/io.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/io.rb	(revision 279)
@@ -0,0 +1,393 @@
+##
+# IO
+
+class IOError < StandardError; end
+class EOFError < IOError; end
+
+class IO
+  SEEK_SET = 0
+  SEEK_CUR = 1
+  SEEK_END = 2
+
+  BUF_SIZE = 4096
+
+  def self.open(*args, &block)
+    io = self.new(*args)
+
+    return io unless block
+
+    begin
+      yield io
+    ensure
+      begin
+        io.close unless io.closed?
+      rescue StandardError
+      end
+    end
+  end
+
+  def self.popen(command, mode = 'r', opts={}, &block)
+    if !self.respond_to?(:_popen)
+      raise NotImplementedError, "popen is not supported on this platform"
+    end
+    io = self._popen(command, mode, opts)
+    return io unless block
+
+    begin
+      yield io
+    ensure
+      begin
+        io.close unless io.closed?
+      rescue IOError
+        # nothing
+      end
+    end
+  end
+
+  def self.pipe(&block)
+    if !self.respond_to?(:_pipe)
+      raise NotImplementedError, "pipe is not supported on this platform"
+    end
+    if block
+      begin
+        r, w = IO._pipe
+        yield r, w
+      ensure
+        r.close unless r.closed?
+        w.close unless w.closed?
+      end
+    else
+      IO._pipe
+    end
+  end
+
+  def self.read(path, length=nil, offset=nil, opt=nil)
+    if not opt.nil?        # 4 arguments
+      offset ||= 0
+    elsif not offset.nil?  # 3 arguments
+      if offset.is_a? Hash
+        opt = offset
+        offset = 0
+      else
+        opt = {}
+      end
+    elsif not length.nil?  # 2 arguments
+      if length.is_a? Hash
+        opt = length
+        offset = 0
+        length = nil
+      else
+        offset = 0
+        opt = {}
+      end
+    else                   # only 1 argument
+      opt = {}
+      offset = 0
+      length = nil
+    end
+
+    str = ""
+    fd = -1
+    io = nil
+    begin
+      if path[0] == "|"
+        io = IO.popen(path[1..-1], (opt[:mode] || "r"))
+      else
+        fd = IO.sysopen(path)
+        io = IO.open(fd, opt[:mode] || "r")
+      end
+      io.seek(offset) if offset > 0
+      str = io.read(length)
+    ensure
+      if io
+        io.close
+      elsif fd != -1
+        IO._sysclose(fd)
+      end
+    end
+    str
+  end
+
+  def flush
+    # mruby-io always writes immediately (no output buffer).
+    raise IOError, "closed stream" if self.closed?
+    self
+  end
+
+  def hash
+    # We must define IO#hash here because IO includes Enumerable and
+    # Enumerable#hash will call IO#read...
+    self.__id__
+  end
+
+  def write(string)
+    str = string.is_a?(String) ? string : string.to_s
+    return str.size unless str.size > 0
+
+    len = syswrite(str)
+    if len != -1
+      @pos += len
+      return len
+    end
+
+    raise IOError
+  end
+
+  def <<(str)
+    write(str)
+    self
+  end
+
+  def eof?
+    _check_readable
+    begin
+      buf = _read_buf
+      return buf.size == 0
+    rescue EOFError
+      return true
+    end
+  end
+  alias_method :eof, :eof?
+
+  def pos
+    raise IOError if closed?
+    @pos
+  end
+  alias_method :tell, :pos
+
+  def pos=(i)
+    seek(i, SEEK_SET)
+  end
+
+  def rewind
+    seek(0, SEEK_SET)
+  end
+
+  def seek(i, whence = SEEK_SET)
+    raise IOError if closed?
+    @pos = sysseek(i, whence)
+    @buf = ''
+    0
+  end
+
+  def _read_buf
+    return @buf if @buf && @buf.size > 0
+    @buf = sysread(BUF_SIZE)
+  end
+
+  def ungetc(substr)
+    raise TypeError.new "expect String, got #{substr.class}" unless substr.is_a?(String)
+    @pos -= substr.size
+    if @buf.empty?
+      @buf = substr.dup
+    else
+      @buf = substr + @buf
+    end
+    nil
+  end
+
+  def read(length = nil)
+    unless length.nil?
+      unless length.is_a? Fixnum
+        raise TypeError.new "can't convert #{length.class} into Integer"
+      end
+      if length < 0
+        raise ArgumentError.new "negative length: #{length} given"
+      end
+      if length == 0
+        return ""   # easy case
+      end
+    end
+
+    array = []
+    start_pos = @pos
+    while 1
+      begin
+        _read_buf
+      rescue EOFError => e
+        array = nil if array.empty? and (not length.nil?) and length != 0
+        break
+      end
+
+      if length && (@pos - start_pos + @buf.size) >= length
+        len = length - (@pos - start_pos)
+        array.push @buf[0, len]
+        @pos += len
+        @buf = @buf[len, @buf.size - len]
+        break
+      else
+        array.push @buf
+        @pos += @buf.size
+        @buf = ''
+      end
+    end
+
+    array && array.join
+  end
+
+  def readline(arg = $/, limit = nil)
+    case arg
+    when String
+      rs = arg
+    when Fixnum
+      rs = $/
+      limit = arg
+    else
+      raise ArgumentError
+    end
+
+    if rs.nil?
+      return read
+    end
+
+    if rs == ""
+      rs = $/ + $/
+    end
+
+    array = []
+    start_pos = @pos
+    while 1
+      begin
+        _read_buf
+      rescue EOFError => e
+        array = nil if array.empty?
+        break
+      end
+
+      if limit && (@pos - start_pos + @buf.size) >= limit
+        len = limit - (@pos - start_pos)
+        array.push @buf[0, len]
+        @pos += len
+        @buf = @buf[len, @buf.size - len]
+        break
+      elsif idx = @buf.index(rs)
+        len = idx + rs.size
+        array.push @buf[0, len]
+        @pos += len
+        @buf = @buf[len, @buf.size - len]
+        break
+      else
+        array.push @buf
+        @pos += @buf.size
+        @buf = ''
+      end
+    end
+
+    raise EOFError.new "end of file reached" if array.nil?
+
+    array.join
+  end
+
+  def gets(*args)
+    begin
+      readline(*args)
+    rescue EOFError => e
+      nil
+    end
+  end
+
+  def readchar
+    _read_buf
+    c = @buf[0]
+    @buf = @buf[1, @buf.size]
+    @pos += 1
+    c
+  end
+
+  def getc
+    begin
+      readchar
+    rescue EOFError => e
+      nil
+    end
+  end
+
+  # 15.2.20.5.3
+  def each(&block)
+    while line = self.gets
+      block.call(line)
+    end
+    self
+  end
+
+  # 15.2.20.5.4
+  def each_byte(&block)
+    while char = self.getc
+      block.call(char)
+    end
+    self
+  end
+
+  # 15.2.20.5.5
+  alias each_line each
+
+  alias each_char each_byte
+
+  def readlines
+    ary = []
+    while (line = gets)
+      ary << line
+    end
+    ary
+  end
+
+  def puts(*args)
+    i = 0
+    len = args.size
+    while i < len
+      s = args[i].to_s
+      write s
+      write "\n" if (s[-1] != "\n")
+      i += 1
+    end
+    write "\n" if len == 0
+    nil
+  end
+
+  def print(*args)
+    i = 0
+    len = args.size
+    while i < len
+      write args[i].to_s
+      i += 1
+    end
+  end
+
+  def printf(*args)
+    write sprintf(*args)
+    nil
+  end
+
+  alias_method :to_i, :fileno
+  alias_method :tty?, :isatty
+end
+
+STDIN  = IO.open(0, "r")
+STDOUT = IO.open(1, "w")
+STDERR = IO.open(2, "w")
+
+$stdin  = STDIN
+$stdout = STDOUT
+$stderr = STDERR
+
+module Kernel
+  def print(*args)
+    $stdout.print(*args)
+  end
+
+  def puts(*args)
+    $stdout.puts(*args)
+  end
+
+  def printf(*args)
+    $stdout.printf(*args)
+  end
+
+  def gets(*args)
+    $stdin.gets(*args)
+  end
+
+  def getc(*args)
+    $stdin.getc(*args)
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/kernel.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/kernel.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/mrblib/kernel.rb	(revision 279)
@@ -0,0 +1,15 @@
+module Kernel
+  def `(cmd)
+    IO.popen(cmd) { |io| io.read }
+  end
+
+  def open(file, *rest, &block)
+    raise ArgumentError unless file.is_a?(String)
+
+    if file[0] == "|"
+      IO.popen(file[1..-1], *rest, &block)
+    else
+      File.open(file, *rest, &block)
+    end
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/run_test.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/run_test.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/run_test.rb	(revision 279)
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# mrbgems test runner
+#
+
+if __FILE__ == $0
+  repository, dir = 'https://github.com/mruby/mruby.git', 'tmp/mruby'
+  build_args = ARGV
+
+  Dir.mkdir 'tmp'  unless File.exist?('tmp')
+  unless File.exist?(dir)
+    system "git clone #{repository} #{dir}"
+  end
+
+  exit system(%Q[cd #{dir}; MRUBY_CONFIG=#{File.expand_path __FILE__} ruby minirake #{build_args.join(' ')}])
+end
+
+MRuby::Build.new do |conf|
+  toolchain :gcc
+  conf.gembox 'default'
+
+  conf.gem :git => 'https://github.com/iij/mruby-env.git'
+  conf.enable_test
+
+  conf.gem File.expand_path(File.dirname(__FILE__))
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/src/file.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/src/file.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/src/file.c	(revision 279)
@@ -0,0 +1,431 @@
+/*
+** file.c - File class
+*/
+
+#include "mruby.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/string.h"
+#include "mruby/ext/io.h"
+
+#if MRUBY_RELEASE_NO < 10000
+#include "error.h"
+#else
+#include "mruby/error.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <fcntl.h>
+#include <limits.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#if defined(_WIN32) || defined(_WIN64)
+  #define NULL_FILE "NUL"
+  #define UNLINK _unlink
+  #define GETCWD _getcwd
+  #define CHMOD(a, b) 0
+  #define MAXPATHLEN 1024
+ #if !defined(PATH_MAX)
+  #define PATH_MAX _MAX_PATH
+ #endif
+  #define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
+  #include <direct.h>
+#else
+  #define NULL_FILE "/dev/null"
+  #include <unistd.h>
+  #define UNLINK unlink
+  #define GETCWD getcwd
+  #define CHMOD(a, b) chmod(a,b)
+  #include <sys/file.h>
+  #include <libgen.h>
+  #include <sys/param.h>
+  #include <pwd.h>
+#endif
+#if defined(__NEWLIB__)
+  #define _MAX_DIR		253
+  #define _MAX_DRIVE	2
+  #define PATH_MAX		(_MAX_DRIVE + _MAX_DIR)
+  #define MAXPATHLEN	(_MAX_DRIVE + _MAX_DIR)
+#endif
+
+#define FILE_SEPARATOR "/"
+
+#if defined(_WIN32) || defined(_WIN64)
+  #define PATH_SEPARATOR ";"
+  #define FILE_ALT_SEPARATOR "\\"
+#else
+  #define PATH_SEPARATOR ":"
+#endif
+
+#ifndef LOCK_SH
+#define LOCK_SH 1
+#endif
+#ifndef LOCK_EX
+#define LOCK_EX 2
+#endif
+#ifndef LOCK_NB
+#define LOCK_NB 4
+#endif
+#ifndef LOCK_UN
+#define LOCK_UN 8
+#endif
+
+#define STAT(p, s)        stat(p, s)
+
+
+mrb_value
+mrb_file_s_umask(mrb_state *mrb, mrb_value klass)
+{
+#if defined(_WIN32) || defined(_WIN64) || defined(__NEWLIB__)
+  /* nothing to do on windows */
+  return mrb_fixnum_value(0);
+
+#else
+  mrb_int mask, omask;
+  if (mrb_get_args(mrb, "|i", &mask) == 0) {
+    omask = umask(0);
+    umask(omask);
+  } else {
+    omask = umask(mask);
+  }
+  return mrb_fixnum_value(omask);
+#endif
+}
+
+static mrb_value
+mrb_file_s_unlink(mrb_state *mrb, mrb_value obj)
+{
+  mrb_value *argv;
+  mrb_value pathv;
+  mrb_int argc, i;
+  const char *path;
+
+  mrb_get_args(mrb, "*", &argv, &argc);
+  for (i = 0; i < argc; i++) {
+    pathv = mrb_convert_type(mrb, argv[i], MRB_TT_STRING, "String", "to_str");
+    path = mrb_string_value_cstr(mrb, &pathv);
+    if (UNLINK(path) < 0) {
+      mrb_sys_fail(mrb, path);
+    }
+  }
+  return mrb_fixnum_value(argc);
+}
+
+static mrb_value
+mrb_file_s_rename(mrb_state *mrb, mrb_value obj)
+{
+  mrb_value from, to;
+  const char *src, *dst;
+
+  mrb_get_args(mrb, "SS", &from, &to);
+  src = mrb_string_value_cstr(mrb, &from);
+  dst = mrb_string_value_cstr(mrb, &to);
+  if (rename(src, dst) < 0) {
+    if (CHMOD(dst, 0666) == 0 && UNLINK(dst) == 0 && rename(src, dst) == 0) {
+      return mrb_fixnum_value(0);
+    }
+    mrb_sys_fail(mrb, mrb_str_to_cstr(mrb, mrb_format(mrb, "(%S, %S)", from, to)));
+  }
+  return mrb_fixnum_value(0);
+}
+
+static mrb_value
+mrb_file_dirname(mrb_state *mrb, mrb_value klass)
+{
+#if defined(_WIN32) || defined(_WIN64)
+  char dname[_MAX_DIR], vname[_MAX_DRIVE];
+  char buffer[_MAX_DRIVE + _MAX_DIR];
+  char *path;
+  size_t ridx;
+  mrb_value s;
+  mrb_get_args(mrb, "S", &s);
+  path = mrb_str_to_cstr(mrb, s);
+  _splitpath((const char*)path, vname, dname, NULL, NULL);
+  snprintf(buffer, _MAX_DRIVE + _MAX_DIR, "%s%s", vname, dname);
+  ridx = strlen(buffer);
+  if (ridx == 0) {
+    strncpy(buffer, ".", 2);  /* null terminated */
+  } else if (ridx > 1) {
+    ridx--;
+    while (ridx > 0 && (buffer[ridx] == '/' || buffer[ridx] == '\\')) {
+      buffer[ridx] = '\0';  /* remove last char */
+      ridx--;
+    }
+  }
+  return mrb_str_new_cstr(mrb, buffer);
+#else
+  char *dname, *path;
+  mrb_value s;
+  mrb_get_args(mrb, "S", &s);
+  path = mrb_str_to_cstr(mrb, s);
+
+  if ((dname = dirname(path)) == NULL) {
+    mrb_sys_fail(mrb, "dirname");
+  }
+#endif
+  return mrb_str_new_cstr(mrb, dname);
+}
+
+static mrb_value
+mrb_file_basename(mrb_state *mrb, mrb_value klass)
+{
+#if defined(_WIN32) || defined(_WIN64)
+  char bname[_MAX_DIR];
+  char extname[_MAX_EXT];
+  char *path;
+  size_t ridx;
+  char buffer[_MAX_DIR + _MAX_EXT];
+  mrb_value s;
+  mrb_get_args(mrb, "S", &s);
+  path = mrb_str_to_cstr(mrb, s);
+  ridx = strlen(path);
+  if (ridx > 0) {
+    ridx--;
+    while (ridx > 0 && (path[ridx] == '/' || path[ridx] == '\\')) {
+      path[ridx] = '\0';
+      ridx--;
+    }
+    if (strncmp(path, "/", 2) == 0) {
+      return mrb_str_new_cstr(mrb, path);
+    }
+  }
+  _splitpath((const char*)path, NULL, NULL, bname, extname);
+  snprintf(buffer, _MAX_DIR + _MAX_EXT, "%s%s", bname, extname);
+  return mrb_str_new_cstr(mrb, buffer);
+#else
+  char *bname, *path;
+  mrb_value s;
+  mrb_get_args(mrb, "S", &s);
+  path = mrb_str_to_cstr(mrb, s);
+  if ((bname = basename(path)) == NULL) {
+    mrb_sys_fail(mrb, "basename");
+  }
+  return mrb_str_new_cstr(mrb, bname);
+#endif
+}
+
+static mrb_value
+mrb_file_realpath(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value pathname, dir_string, s, result;
+  int argc;
+  char *cpath;
+
+  argc = mrb_get_args(mrb, "S|S", &pathname, &dir_string);
+  if (argc == 2) {
+    s = mrb_str_dup(mrb, dir_string);
+    s = mrb_str_append(mrb, s, mrb_str_new_cstr(mrb, FILE_SEPARATOR));
+    s = mrb_str_append(mrb, s, pathname);
+    pathname = s;
+  }
+  cpath = mrb_str_to_cstr(mrb, pathname);
+  result = mrb_str_buf_new(mrb, PATH_MAX);
+  if (realpath(cpath, RSTRING_PTR(result)) == NULL)
+    mrb_sys_fail(mrb, cpath);
+  mrb_str_resize(mrb, result, strlen(RSTRING_PTR(result)));
+  return result;
+}
+
+mrb_value
+mrb_file__getwd(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value path;
+
+  path = mrb_str_buf_new(mrb, MAXPATHLEN);
+  if (GETCWD(RSTRING_PTR(path), MAXPATHLEN) == NULL) {
+    mrb_sys_fail(mrb, "getcwd(2)");
+  }
+  mrb_str_resize(mrb, path, strlen(RSTRING_PTR(path)));
+  return path;
+}
+
+static int
+mrb_file_is_absolute_path(const char *path)
+{
+  return (path[0] == '/');
+}
+
+static mrb_value
+mrb_file__gethome(mrb_state *mrb, mrb_value klass)
+{
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__NEWLIB__)
+  mrb_value username;
+  int argc;
+  char *home;
+
+  argc = mrb_get_args(mrb, "|S", &username);
+  if (argc == 0) {
+    home = getenv("HOME");
+    if (home == NULL) {
+      return mrb_nil_value();
+    }
+    if (!mrb_file_is_absolute_path(home)) {
+      mrb_raise(mrb, E_ARGUMENT_ERROR, "non-absolute home");
+    }
+  } else {
+    const char *cuser = mrb_str_to_cstr(mrb, username);
+    struct passwd *pwd = getpwnam(cuser);
+    if (pwd == NULL) {
+      return mrb_nil_value();
+    }
+    home = pwd->pw_dir;
+    if (!mrb_file_is_absolute_path(home)) {
+      mrb_raisef(mrb, E_ARGUMENT_ERROR, "non-absolute home of ~%S", username);
+    }
+  }
+  return mrb_str_new_cstr(mrb, home);
+#else
+
+  return mrb_nil_value();
+#endif
+}
+
+mrb_value
+mrb_file_flock(mrb_state *mrb, mrb_value self)
+{
+#if defined(_WIN32) || defined(_WIN64) || defined(sun) || defined(__NEWLIB__)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "flock is not supported on Illumos/Solaris/Windows");
+#else
+  mrb_int operation;
+  int fd;
+
+  mrb_get_args(mrb, "i", &operation);
+  fd = mrb_fixnum(mrb_io_fileno(mrb, self));
+
+  while (flock(fd, operation) == -1) {
+    switch (errno) {
+      case EINTR:
+        /* retry */
+        break;
+      case EAGAIN:      /* NetBSD */
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+      case EWOULDBLOCK: /* FreeBSD OpenBSD Linux */
+#endif
+        if (operation & LOCK_NB) {
+          return mrb_false_value();
+        }
+        /* FALLTHRU - should not happen */
+      default:
+        mrb_sys_fail(mrb, "flock failed");
+        break;
+    }
+  }
+#endif
+  return mrb_fixnum_value(0);
+}
+
+static mrb_value
+mrb_file_s_symlink(mrb_state *mrb, mrb_value klass)
+{
+#if defined(_WIN32) || defined(_WIN64) || defined(__NEWLIB__)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "symlink is not supported on this platform");
+#else
+  mrb_value from, to;
+  const char *src, *dst;
+  int ai = mrb_gc_arena_save(mrb);
+
+  mrb_get_args(mrb, "SS", &from, &to);
+  src = mrb_str_to_cstr(mrb, from);
+  dst = mrb_str_to_cstr(mrb, to);
+
+  if (symlink(src, dst) == -1) {
+    mrb_sys_fail(mrb, mrb_str_to_cstr(mrb, mrb_format(mrb, "(%S, %S)", from, to)));
+  }
+  mrb_gc_arena_restore(mrb, ai);
+#endif
+  return mrb_fixnum_value(0);
+}
+
+static mrb_value
+mrb_file_s_chmod(mrb_state *mrb, mrb_value klass) {
+  mrb_int mode;
+  mrb_int argc, i;
+  mrb_value *filenames;
+  int ai = mrb_gc_arena_save(mrb);
+
+  mrb_get_args(mrb, "i*", &mode, &filenames, &argc);
+  for (i = 0; i < argc; i++) {
+    char *path = mrb_str_to_cstr(mrb, filenames[i]);
+    if (CHMOD(path, mode) == -1) {
+      mrb_sys_fail(mrb, path);
+    }
+  }
+
+  mrb_gc_arena_restore(mrb, ai);
+  return mrb_fixnum_value(argc);
+}
+
+static mrb_value
+mrb_file_s_readlink(mrb_state *mrb, mrb_value klass) {
+#if defined(_WIN32) || defined(_WIN64) || defined(__NEWLIB__)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "readlink is not supported on this platform");
+  return mrb_nil_value(); // unreachable
+#else
+  char *path, *buf;
+  size_t bufsize = 100;
+  ssize_t rc;
+  mrb_value ret;
+  int ai = mrb_gc_arena_save(mrb);
+
+  mrb_get_args(mrb, "z", &path);
+
+  buf = (char *)mrb_malloc(mrb, bufsize);
+  while ((rc = readlink(path, buf, bufsize)) == bufsize && rc != -1) {
+    bufsize *= 2;
+    buf = (char *)mrb_realloc(mrb, buf, bufsize);
+  }
+  if (rc == -1) {
+    mrb_free(mrb, buf);
+    mrb_sys_fail(mrb, path);
+  }
+  ret = mrb_str_new(mrb, buf, rc);
+  mrb_free(mrb, buf);
+
+  mrb_gc_arena_restore(mrb, ai);
+  return ret;
+#endif
+}
+
+void
+mrb_init_file(mrb_state *mrb)
+{
+  struct RClass *io, *file, *cnst;
+
+  io   = mrb_class_get(mrb, "IO");
+  file = mrb_define_class(mrb, "File", io);
+  MRB_SET_INSTANCE_TT(file, MRB_TT_DATA);
+  mrb_define_class_method(mrb, file, "umask",  mrb_file_s_umask, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, file, "delete", mrb_file_s_unlink, MRB_ARGS_ANY());
+  mrb_define_class_method(mrb, file, "unlink", mrb_file_s_unlink, MRB_ARGS_ANY());
+  mrb_define_class_method(mrb, file, "rename", mrb_file_s_rename, MRB_ARGS_REQ(2));
+  mrb_define_class_method(mrb, file, "symlink", mrb_file_s_symlink, MRB_ARGS_REQ(2));
+  mrb_define_class_method(mrb, file, "chmod", mrb_file_s_chmod, MRB_ARGS_REQ(1) | MRB_ARGS_REST());
+  mrb_define_class_method(mrb, file, "readlink", mrb_file_s_readlink, MRB_ARGS_REQ(1));
+
+  mrb_define_class_method(mrb, file, "dirname",   mrb_file_dirname,    MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, file, "basename",  mrb_file_basename,   MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, file, "realpath",  mrb_file_realpath,   MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  mrb_define_class_method(mrb, file, "_getwd",    mrb_file__getwd,     MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, file, "_gethome",  mrb_file__gethome,   MRB_ARGS_OPT(1));
+
+  mrb_define_method(mrb, file, "flock", mrb_file_flock, MRB_ARGS_REQ(1));
+
+  cnst = mrb_define_module_under(mrb, file, "Constants");
+  mrb_define_const(mrb, cnst, "LOCK_SH", mrb_fixnum_value(LOCK_SH));
+  mrb_define_const(mrb, cnst, "LOCK_EX", mrb_fixnum_value(LOCK_EX));
+  mrb_define_const(mrb, cnst, "LOCK_UN", mrb_fixnum_value(LOCK_UN));
+  mrb_define_const(mrb, cnst, "LOCK_NB", mrb_fixnum_value(LOCK_NB));
+  mrb_define_const(mrb, cnst, "SEPARATOR", mrb_str_new_cstr(mrb, FILE_SEPARATOR));
+  mrb_define_const(mrb, cnst, "PATH_SEPARATOR", mrb_str_new_cstr(mrb, PATH_SEPARATOR));
+#if defined(_WIN32) || defined(_WIN64)
+  mrb_define_const(mrb, cnst, "ALT_SEPARATOR", mrb_str_new_cstr(mrb, FILE_ALT_SEPARATOR));
+#else
+  mrb_define_const(mrb, cnst, "ALT_SEPARATOR", mrb_nil_value());
+#endif
+  mrb_define_const(mrb, cnst, "NULL", mrb_str_new_cstr(mrb, NULL_FILE));
+
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/src/file_test.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/src/file_test.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/src/file_test.c	(revision 279)
@@ -0,0 +1,378 @@
+/*
+** file.c - File class
+*/
+
+#include "mruby.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/string.h"
+#include "mruby/ext/io.h"
+
+#if MRUBY_RELEASE_NO < 10000
+#include "error.h"
+#else
+#include "mruby/error.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(_WIN32) || defined(_WIN64)
+  #define LSTAT stat
+  #include <winsock.h>
+#else
+  //#define LSTAT lstat
+  #define LSTAT stat
+  #include <sys/file.h>
+  #include <sys/param.h>
+  #include <sys/wait.h>
+  #include <libgen.h>
+  #include <pwd.h>
+  #include <unistd.h>
+#endif
+
+#include <fcntl.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern struct mrb_data_type mrb_io_type;
+
+static int
+mrb_stat0(mrb_state *mrb, mrb_value obj, struct stat *st, int do_lstat)
+{
+  mrb_value tmp;
+  mrb_value io_klass, str_klass;
+
+  io_klass  = mrb_obj_value(mrb_class_get(mrb, "IO"));
+  str_klass = mrb_obj_value(mrb_class_get(mrb, "String"));
+
+  tmp = mrb_funcall(mrb, obj, "is_a?", 1, io_klass);
+  if (mrb_test(tmp)) {
+    struct mrb_io *fptr;
+    fptr = (struct mrb_io *)mrb_get_datatype(mrb, obj, &mrb_io_type);
+
+    if (fptr && fptr->fd >= 0) {
+      return fstat(fptr->fd, st);
+    }
+
+    mrb_raise(mrb, E_IO_ERROR, "closed stream");
+    return -1;
+  }
+
+  tmp = mrb_funcall(mrb, obj, "is_a?", 1, str_klass);
+  if (mrb_test(tmp)) {
+    if (do_lstat) {
+      return LSTAT(mrb_str_to_cstr(mrb, obj), st);
+    } else {
+      return stat(mrb_str_to_cstr(mrb, obj), st);
+    }
+  }
+
+  return -1;
+}
+
+static int
+mrb_stat(mrb_state *mrb, mrb_value obj, struct stat *st)
+{
+  return mrb_stat0(mrb, obj, st, 0);
+}
+
+static int
+mrb_lstat(mrb_state *mrb, mrb_value obj, struct stat *st)
+{
+  return mrb_stat0(mrb, obj, st, 1);
+}
+
+/*
+ * Document-method: directory?
+ *
+ * call-seq:
+ *   File.directory?(file_name)   ->  true or false
+ *
+ * Returns <code>true</code> if the named file is a directory,
+ * or a symlink that points at a directory, and <code>false</code>
+ * otherwise.
+ *
+ *    File.directory?(".")
+ */
+
+mrb_value
+mrb_filetest_s_directory_p(mrb_state *mrb, mrb_value klass)
+{
+#ifndef S_ISDIR
+#   define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_stat(mrb, obj, &st) < 0)
+    return mrb_false_value();
+  if (S_ISDIR(st.st_mode))
+    return mrb_true_value();
+
+  return mrb_false_value();
+}
+
+/*
+ * call-seq:
+ *   File.pipe?(file_name)   ->  true or false
+ *
+ * Returns <code>true</code> if the named file is a pipe.
+ */
+
+mrb_value
+mrb_filetest_s_pipe_p(mrb_state *mrb, mrb_value klass)
+{
+#if defined(_WIN32) || defined(_WIN64)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "pipe is not supported on this platform");
+#else
+#ifdef S_IFIFO
+#  ifndef S_ISFIFO
+#    define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#  endif
+
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_stat(mrb, obj, &st) < 0)
+    return mrb_false_value();
+  if (S_ISFIFO(st.st_mode))
+    return mrb_true_value();
+
+#endif
+  return mrb_false_value();
+#endif
+}
+
+/*
+ * call-seq:
+ *   File.symlink?(file_name)   ->  true or false
+ *
+ * Returns <code>true</code> if the named file is a symbolic link.
+ */
+
+mrb_value
+mrb_filetest_s_symlink_p(mrb_state *mrb, mrb_value klass)
+{
+#if defined(_WIN32) || defined(_WIN64)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "symlink is not supported on this platform");
+#else
+#ifndef S_ISLNK
+#  ifdef _S_ISLNK
+#    define S_ISLNK(m) _S_ISLNK(m)
+#  else
+#    ifdef _S_IFLNK
+#      define S_ISLNK(m) (((m) & S_IFMT) == _S_IFLNK)
+#    else
+#      ifdef S_IFLNK
+#        define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef S_ISLNK
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_lstat(mrb, obj, &st) == -1)
+    return mrb_false_value();
+  if (S_ISLNK(st.st_mode))
+    return mrb_true_value();
+#endif
+
+  return mrb_false_value();
+#endif
+}
+
+/*
+ * call-seq:
+ *   File.socket?(file_name)   ->  true or false
+ *
+ * Returns <code>true</code> if the named file is a socket.
+ */
+
+mrb_value
+mrb_filetest_s_socket_p(mrb_state *mrb, mrb_value klass)
+{
+#if defined(_WIN32) || defined(_WIN64)
+  mrb_raise(mrb, E_NOTIMP_ERROR, "socket is not supported on this platform");
+#else
+#ifndef S_ISSOCK
+#  ifdef _S_ISSOCK
+#    define S_ISSOCK(m) _S_ISSOCK(m)
+#  else
+#    ifdef _S_IFSOCK
+#      define S_ISSOCK(m) (((m) & S_IFMT) == _S_IFSOCK)
+#    else
+#      ifdef S_IFSOCK
+#        define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef S_ISSOCK
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_stat(mrb, obj, &st) < 0)
+    return mrb_false_value();
+  if (S_ISSOCK(st.st_mode))
+    return mrb_true_value();
+#endif
+
+  return mrb_false_value();
+#endif
+}
+
+/*
+ * call-seq:
+ *    File.exist?(file_name)    ->  true or false
+ *    File.exists?(file_name)   ->  true or false
+ *
+ * Return <code>true</code> if the named file exists.
+ */
+
+mrb_value
+mrb_filetest_s_exist_p(mrb_state *mrb, mrb_value klass)
+{
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+  if (mrb_stat(mrb, obj, &st) < 0)
+    return mrb_false_value();
+
+  return mrb_true_value();
+}
+
+/*
+ * call-seq:
+ *    File.file?(file_name)   -> true or false
+ *
+ * Returns <code>true</code> if the named file exists and is a
+ * regular file.
+ */
+
+mrb_value
+mrb_filetest_s_file_p(mrb_state *mrb, mrb_value klass)
+{
+#ifndef S_ISREG
+#   define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_stat(mrb, obj, &st) < 0)
+    return mrb_false_value();
+  if (S_ISREG(st.st_mode))
+    return mrb_true_value();
+
+  return mrb_false_value();
+}
+
+/*
+ * call-seq:
+ *    File.zero?(file_name)   -> true or false
+ *
+ * Returns <code>true</code> if the named file exists and has
+ * a zero size.
+ */
+
+mrb_value
+mrb_filetest_s_zero_p(mrb_state *mrb, mrb_value klass)
+{
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_stat(mrb, obj, &st) < 0)
+    return mrb_false_value();
+  if (st.st_size == 0)
+    return mrb_true_value();
+
+  return mrb_false_value();
+}
+
+/*
+ * call-seq:
+ *    File.size(file_name)   -> integer
+ *
+ * Returns the size of <code>file_name</code>.
+ *
+ * _file_name_ can be an IO object.
+ */
+
+mrb_value
+mrb_filetest_s_size(mrb_state *mrb, mrb_value klass)
+{
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_stat(mrb, obj, &st) < 0)
+    mrb_sys_fail(mrb, "mrb_stat");
+
+  return mrb_fixnum_value(st.st_size);
+}
+
+/*
+ * call-seq:
+ *    File.size?(file_name)   -> Integer or nil
+ *
+ * Returns +nil+ if +file_name+ doesn't exist or has zero size, the size of the
+ * file otherwise.
+ */
+
+mrb_value
+mrb_filetest_s_size_p(mrb_state *mrb, mrb_value klass)
+{
+  struct stat st;
+  mrb_value obj;
+
+  mrb_get_args(mrb, "o", &obj);
+
+  if (mrb_stat(mrb, obj, &st) < 0)
+    return mrb_nil_value();
+  if (st.st_size == 0)
+    return mrb_nil_value();
+
+  return mrb_fixnum_value(st.st_size);
+}
+
+void
+mrb_init_file_test(mrb_state *mrb)
+{
+  struct RClass *f;
+
+  f = mrb_define_class(mrb, "FileTest", mrb->object_class);
+
+  mrb_define_class_method(mrb, f, "directory?", mrb_filetest_s_directory_p, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "exist?",     mrb_filetest_s_exist_p,     MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "exists?",    mrb_filetest_s_exist_p,     MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "file?",      mrb_filetest_s_file_p,      MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "pipe?",      mrb_filetest_s_pipe_p,      MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "size",       mrb_filetest_s_size,        MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "size?",      mrb_filetest_s_size_p,      MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "socket?",    mrb_filetest_s_socket_p,    MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "symlink?",   mrb_filetest_s_symlink_p,   MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, f, "zero?",      mrb_filetest_s_zero_p,      MRB_ARGS_REQ(1));
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/src/io.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/src/io.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/src/io.c	(revision 279)
@@ -0,0 +1,1102 @@
+/*
+** io.c - IO class
+*/
+
+#include "mruby.h"
+#include "mruby/array.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/hash.h"
+#include "mruby/string.h"
+#include "mruby/variable.h"
+#include "mruby/ext/io.h"
+
+#if MRUBY_RELEASE_NO < 10000
+#include "error.h"
+#else
+#include "mruby/error.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(_WIN32) || defined(_WIN64)
+  #include <winsock.h>
+  #include <io.h>
+  #define open  _open
+  #define close _close
+  #define read  _read
+  #define write _write
+  #define lseek _lseek
+#else
+  #include <sys/wait.h>
+  #include <unistd.h>
+#endif
+
+#include <fcntl.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static void mrb_io_free(mrb_state *mrb, void *ptr);
+struct mrb_data_type mrb_io_type = { "IO", mrb_io_free };
+
+
+static struct mrb_io *io_get_open_fptr(mrb_state *mrb, mrb_value self);
+static int mrb_io_modestr_to_flags(mrb_state *mrb, const char *modestr);
+static int mrb_io_flags_to_modenum(mrb_state *mrb, int flags);
+static void fptr_finalize(mrb_state *mrb, struct mrb_io *fptr, int quiet);
+
+#if MRUBY_RELEASE_NO < 10000
+static struct RClass *
+mrb_module_get(mrb_state *mrb, const char *name)
+{
+  return mrb_class_get(mrb, name);
+}
+#endif
+
+static struct mrb_io *
+io_get_open_fptr(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_io *fptr;
+
+  fptr = (struct mrb_io *)mrb_get_datatype(mrb, self, &mrb_io_type);
+  if (fptr->fd < 0) {
+    mrb_raise(mrb, E_IO_ERROR, "closed stream.");
+  }
+  return fptr;
+}
+
+#if !defined(_WIN32) && !defined(_WIN64)
+static void
+io_set_process_status(mrb_state *mrb, pid_t pid, int status)
+{
+  struct RClass *c_process, *c_status;
+  mrb_value v;
+
+  c_status = NULL;
+  if (mrb_class_defined(mrb, "Process")) {
+    c_process = mrb_module_get(mrb, "Process");
+    if (mrb_const_defined(mrb, mrb_obj_value(c_process), mrb_intern_cstr(mrb, "Status"))) {
+      c_status = mrb_class_get_under(mrb, c_process, "Status");
+    }
+  }
+  if (c_status != NULL) {
+    v = mrb_funcall(mrb, mrb_obj_value(c_status), "new", 2, mrb_fixnum_value(pid), mrb_fixnum_value(status));
+  } else {
+    v = mrb_fixnum_value(WEXITSTATUS(status));
+  }
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$?"), v);
+}
+#endif
+
+static int
+mrb_io_modestr_to_flags(mrb_state *mrb, const char *mode)
+{
+  int flags = 0;
+  const char *m = mode;
+
+  switch (*m++) {
+    case 'r':
+      flags |= FMODE_READABLE;
+      break;
+    case 'w':
+      flags |= FMODE_WRITABLE | FMODE_CREATE | FMODE_TRUNC;
+      break;
+    case 'a':
+      flags |= FMODE_WRITABLE | FMODE_APPEND | FMODE_CREATE;
+      break;
+    default:
+      mrb_raisef(mrb, E_ARGUMENT_ERROR, "illegal access mode %S", mrb_str_new_cstr(mrb, mode));
+  }
+
+  while (*m) {
+    switch (*m++) {
+      case 'b':
+        flags |= FMODE_BINMODE;
+        break;
+      case '+':
+        flags |= FMODE_READWRITE;
+        break;
+      case ':':
+        /* XXX: PASSTHROUGH*/
+      default:
+        mrb_raisef(mrb, E_ARGUMENT_ERROR, "illegal access mode %S", mrb_str_new_cstr(mrb, mode));
+    }
+  }
+
+  return flags;
+}
+
+static int
+mrb_io_flags_to_modenum(mrb_state *mrb, int flags)
+{
+  int modenum = 0;
+
+  switch(flags & (FMODE_READABLE|FMODE_WRITABLE|FMODE_READWRITE)) {
+    case FMODE_READABLE:
+      modenum = O_RDONLY;
+      break;
+    case FMODE_WRITABLE:
+      modenum = O_WRONLY;
+      break;
+    case FMODE_READWRITE:
+      modenum = O_RDWR;
+      break;
+  }
+
+  if (flags & FMODE_APPEND) {
+    modenum |= O_APPEND;
+  }
+  if (flags & FMODE_TRUNC) {
+    modenum |= O_TRUNC;
+  }
+  if (flags & FMODE_CREATE) {
+    modenum |= O_CREAT;
+  }
+#ifdef O_BINARY
+  if (flags & FMODE_BINMODE) {
+    modenum |= O_BINARY;
+  }
+#endif
+
+  return modenum;
+}
+
+void
+mrb_fd_cloexec(mrb_state *mrb, int fd)
+{
+#if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
+  int flags, flags2;
+
+  flags = fcntl(fd, F_GETFD);
+  if (flags == -1) {
+    mrb_sys_fail(mrb, "fcntl");
+  }
+  if (fd <= 2) {
+    flags2 = flags & ~FD_CLOEXEC; /* Clear CLOEXEC for standard file descriptors: 0, 1, 2. */
+  }
+  else {
+    flags2 = flags | FD_CLOEXEC; /* Set CLOEXEC for non-standard file descriptors: 3, 4, 5, ... */
+  }
+  if (flags != flags2) {
+    if (fcntl(fd, F_SETFD, flags2) == -1) {
+      mrb_sys_fail(mrb, "fcntl");
+    }
+  }
+#endif
+}
+
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__NEWLIB__)
+static int
+mrb_cloexec_pipe(mrb_state *mrb, int fildes[2])
+{
+  int ret;
+  ret = pipe(fildes);
+  if (ret == -1)
+    return -1;
+  mrb_fd_cloexec(mrb, fildes[0]);
+  mrb_fd_cloexec(mrb, fildes[1]);
+  return ret;
+}
+
+static int
+mrb_pipe(mrb_state *mrb, int pipes[2])
+{
+  int ret;
+  ret = mrb_cloexec_pipe(mrb, pipes);
+  if (ret == -1) {
+    if (errno == EMFILE || errno == ENFILE) {
+      mrb_garbage_collect(mrb);
+      ret = mrb_cloexec_pipe(mrb, pipes);
+    }
+  }
+  return ret;
+}
+
+static int
+mrb_proc_exec(const char *pname)
+{
+  const char *s;
+  s = pname;
+
+  while (*s == ' ' || *s == '\t' || *s == '\n')
+    s++;
+
+  if (!*s) {
+    errno = ENOENT;
+    return -1;
+  }
+
+  execl("/bin/sh", "sh", "-c", pname, (char *)NULL);
+  return -1;
+}
+#endif
+
+static void
+mrb_io_free(mrb_state *mrb, void *ptr)
+{
+  struct mrb_io *io = (struct mrb_io *)ptr;
+  if (io != NULL) {
+    fptr_finalize(mrb, io, TRUE);
+    mrb_free(mrb, io);
+  }
+}
+
+static struct mrb_io *
+mrb_io_alloc(mrb_state *mrb)
+{
+  struct mrb_io *fptr;
+
+  fptr = (struct mrb_io *)mrb_malloc(mrb, sizeof(struct mrb_io));
+  fptr->fd = -1;
+  fptr->fd2 = -1;
+  fptr->pid = 0;
+  fptr->readable = 0;
+  fptr->writable = 0;
+  fptr->sync = 0;
+  return fptr;
+}
+
+#ifndef NOFILE
+#define NOFILE 64
+#endif
+
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__NEWLIB__)
+static int
+option_to_fd(mrb_state *mrb, mrb_value obj, const char *key)
+{
+  mrb_value opt = mrb_funcall(mrb, obj, "[]", 1, mrb_symbol_value(mrb_intern_static(mrb, key, strlen(key))));
+  if (mrb_nil_p(opt)) {
+    return -1;
+  }
+
+  switch (mrb_type(opt)) {
+    case MRB_TT_DATA: /* IO */
+      return mrb_fixnum(mrb_io_fileno(mrb, opt));
+    case MRB_TT_FIXNUM:
+      return mrb_fixnum(opt);
+    default:
+      mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong exec redirect action");
+      break;
+  }
+  return -1; /* never reached */
+}
+
+mrb_value
+mrb_io_s_popen(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value cmd, io, result;
+  mrb_value mode = mrb_str_new_cstr(mrb, "r");
+  mrb_value opt  = mrb_hash_new(mrb);
+
+  struct mrb_io *fptr;
+  const char *pname;
+  int pid, flags, fd, write_fd = -1;
+  int pr[2] = { -1, -1 };
+  int pw[2] = { -1, -1 };
+  int doexec;
+  int saved_errno;
+  int opt_in, opt_out, opt_err;
+
+  mrb_get_args(mrb, "S|SH", &cmd, &mode, &opt);
+  io = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
+
+  pname = mrb_string_value_cstr(mrb, &cmd);
+  flags = mrb_io_modestr_to_flags(mrb, mrb_string_value_cstr(mrb, &mode));
+
+  doexec = (strcmp("-", pname) != 0);
+  opt_in = option_to_fd(mrb, opt, "in");
+  opt_out = option_to_fd(mrb, opt, "out");
+  opt_err = option_to_fd(mrb, opt, "err");
+
+  if (flags & FMODE_READABLE) {
+    if (pipe(pr) == -1) {
+      mrb_sys_fail(mrb, "pipe");
+    }
+    mrb_fd_cloexec(mrb, pr[0]);
+    mrb_fd_cloexec(mrb, pr[1]);
+  }
+
+  if (flags & FMODE_WRITABLE) {
+    if (pipe(pw) == -1) {
+      if (pr[0] != -1) close(pr[0]);
+      if (pr[1] != -1) close(pr[1]);
+      mrb_sys_fail(mrb, "pipe");
+    }
+    mrb_fd_cloexec(mrb, pw[0]);
+    mrb_fd_cloexec(mrb, pw[1]);
+  }
+
+  if (!doexec) {
+    // XXX
+    fflush(stdin);
+    fflush(stdout);
+    fflush(stderr);
+  }
+
+  result = mrb_nil_value();
+  switch (pid = fork()) {
+    case 0: /* child */
+      if (opt_in != -1) {
+        dup2(opt_in, 0);
+      }
+      if (opt_out != -1) {
+        dup2(opt_out, 1);
+      }
+      if (opt_err != -1) {
+        dup2(opt_err, 2);
+      }
+      if (flags & FMODE_READABLE) {
+        close(pr[0]);
+        if (pr[1] != 1) {
+          dup2(pr[1], 1);
+          close(pr[1]);
+        }
+      }
+      if (flags & FMODE_WRITABLE) {
+        close(pw[1]);
+        if (pw[0] != 0) {
+          dup2(pw[0], 0);
+          close(pw[0]);
+        }
+      }
+      if (doexec) {
+        for (fd = 3; fd < NOFILE; fd++) {
+          close(fd);
+        }
+        mrb_proc_exec(pname);
+        mrb_raisef(mrb, E_IO_ERROR, "command not found: %S", cmd);
+        _exit(127);
+      }
+      result = mrb_nil_value();
+      break;
+
+    default: /* parent */
+      if ((flags & FMODE_READABLE) && (flags & FMODE_WRITABLE)) {
+        close(pr[1]);
+        fd = pr[0];
+        close(pw[0]);
+        write_fd = pw[1];
+      } else if (flags & FMODE_READABLE) {
+        close(pr[1]);
+        fd = pr[0];
+      } else {
+        close(pw[0]);
+        fd = pw[1];
+      }
+
+      mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
+      mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@pos"), mrb_fixnum_value(0));
+
+      fptr = mrb_io_alloc(mrb);
+      fptr->fd = fd;
+      fptr->fd2 = write_fd;
+      fptr->pid = pid;
+      fptr->readable = ((flags & FMODE_READABLE) != 0);
+      fptr->writable = ((flags & FMODE_WRITABLE) != 0);
+      fptr->sync = 0;
+
+      DATA_TYPE(io) = &mrb_io_type;
+      DATA_PTR(io)  = fptr;
+      result = io;
+      break;
+
+    case -1: /* error */
+      saved_errno = errno;
+      if (flags & FMODE_READABLE) {
+        close(pr[0]);
+        close(pr[1]);
+      }
+      if (flags & FMODE_WRITABLE) {
+        close(pw[0]);
+        close(pw[1]);
+      }
+      errno = saved_errno;
+      mrb_sys_fail(mrb, "pipe_open failed.");
+      break;
+  }
+  return result;
+}
+#endif
+
+mrb_value
+mrb_io_initialize(mrb_state *mrb, mrb_value io)
+{
+  struct mrb_io *fptr;
+  mrb_int fd;
+  mrb_value mode, opt;
+  int flags;
+
+  mode = opt = mrb_nil_value();
+
+  mrb_get_args(mrb, "i|So", &fd, &mode, &opt);
+  if (mrb_nil_p(mode)) {
+    mode = mrb_str_new_cstr(mrb, "r");
+  }
+  if (mrb_nil_p(opt)) {
+    opt = mrb_hash_new(mrb);
+  }
+
+  flags = mrb_io_modestr_to_flags(mrb, mrb_string_value_cstr(mrb, &mode));
+
+  mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
+  mrb_iv_set(mrb, io, mrb_intern_cstr(mrb, "@pos"), mrb_fixnum_value(0));
+
+  fptr = (struct mrb_io *)DATA_PTR(io);
+  if (fptr != NULL) {
+    fptr_finalize(mrb, fptr, TRUE);
+    mrb_free(mrb, fptr);
+  }
+  fptr = mrb_io_alloc(mrb);
+
+  DATA_TYPE(io) = &mrb_io_type;
+  DATA_PTR(io) = fptr;
+
+  fptr->fd = fd;
+  fptr->readable = ((flags & FMODE_READABLE) != 0);
+  fptr->writable = ((flags & FMODE_WRITABLE) != 0);
+  fptr->sync = 0;
+  return io;
+}
+
+static void
+fptr_finalize(mrb_state *mrb, struct mrb_io *fptr, int quiet)
+{
+  int saved_errno = 0;
+
+  if (fptr == NULL) {
+    return;
+  }
+
+  if (fptr->fd > 2) {
+    if (close(fptr->fd) == -1) {
+      saved_errno = errno;
+    }
+    fptr->fd = -1;
+  }
+
+  if (fptr->fd2 > 2) {
+    if (close(fptr->fd2) == -1) {
+      if (saved_errno == 0) {
+        saved_errno = errno;
+      }
+    }
+    fptr->fd2 = -1;
+  }
+
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__NEWLIB__)
+  if (fptr->pid != 0) {
+    pid_t pid;
+    int status;
+    do {
+      pid = waitpid(fptr->pid, &status, 0);
+    } while (pid == -1 && errno == EINTR);
+    if (!quiet && pid == fptr->pid) {
+      io_set_process_status(mrb, pid, status);
+    }
+    fptr->pid = 0;
+    /* Note: we don't raise an exception when waitpid(3) fails */
+  }
+#endif
+
+  if (!quiet && saved_errno != 0) {
+    errno = saved_errno;
+    mrb_sys_fail(mrb, "fptr_finalize failed.");
+  }
+}
+
+mrb_value
+mrb_io_check_readable(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_io *fptr = io_get_open_fptr(mrb, self);
+  if (! fptr->readable) {
+    mrb_raise(mrb, E_IO_ERROR, "not opened for reading");
+  }
+  return mrb_nil_value();
+}
+
+mrb_value
+mrb_io_isatty(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_io *fptr;
+
+  fptr = io_get_open_fptr(mrb, self);
+  if (isatty(fptr->fd) == 0)
+    return mrb_false_value();
+  return mrb_true_value();
+}
+
+mrb_value
+mrb_io_s_for_fd(mrb_state *mrb, mrb_value klass)
+{
+  struct RClass *c = mrb_class_ptr(klass);
+  enum mrb_vtype ttype = MRB_INSTANCE_TT(c);
+  mrb_value obj;
+
+  /* copied from mrb_instance_alloc() */
+  if (ttype == 0) ttype = MRB_TT_OBJECT;
+  obj = mrb_obj_value((struct RObject*)mrb_obj_alloc(mrb, ttype, c));
+  return mrb_io_initialize(mrb, obj);
+}
+
+mrb_value
+mrb_io_s_sysclose(mrb_state *mrb, mrb_value klass)
+{
+  mrb_int fd;
+  mrb_get_args(mrb, "i", &fd);
+  if (close(fd) == -1) {
+    mrb_sys_fail(mrb, "close");
+  }
+  return mrb_fixnum_value(0);
+}
+
+int
+mrb_cloexec_open(mrb_state *mrb, const char *pathname, mrb_int flags, mrb_int mode)
+{
+  int fd, retry = FALSE;
+
+#ifdef O_CLOEXEC
+  /* O_CLOEXEC is available since Linux 2.6.23.  Linux 2.6.18 silently ignore it. */
+  flags |= O_CLOEXEC;
+#elif defined O_NOINHERIT
+  flags |= O_NOINHERIT;
+#endif
+reopen:
+  fd = open(pathname, flags, mode);
+  if (fd == -1) {
+    if (!retry) {
+      switch (errno) {
+        case ENFILE:
+        case EMFILE:
+        mrb_garbage_collect(mrb);
+        retry = TRUE;
+        goto reopen;
+      }
+    }
+    mrb_sys_fail(mrb, "open");
+  }
+
+  if (fd <= 2) {
+    mrb_fd_cloexec(mrb, fd);
+  }
+  return fd;
+}
+
+mrb_value
+mrb_io_s_sysopen(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value path = mrb_nil_value();
+  mrb_value mode = mrb_nil_value();
+  mrb_int fd, flags, perm = -1;
+  const char *pat;
+  int modenum;
+
+  mrb_get_args(mrb, "S|Si", &path, &mode, &perm);
+  if (mrb_nil_p(mode)) {
+    mode = mrb_str_new_cstr(mrb, "r");
+  }
+  if (perm < 0) {
+    perm = 0666;
+  }
+
+  pat = mrb_string_value_cstr(mrb, &path);
+  flags = mrb_io_modestr_to_flags(mrb, mrb_string_value_cstr(mrb, &mode));
+  modenum = mrb_io_flags_to_modenum(mrb, flags);
+  fd = mrb_cloexec_open(mrb, pat, modenum, perm);
+  return mrb_fixnum_value(fd);
+}
+
+mrb_value
+mrb_io_sysread(mrb_state *mrb, mrb_value io)
+{
+  struct mrb_io *fptr;
+  mrb_value buf = mrb_nil_value();
+  mrb_int maxlen;
+  int ret;
+
+  mrb_get_args(mrb, "i|S", &maxlen, &buf);
+  if (maxlen < 0) {
+    return mrb_nil_value();
+  }
+
+  if (mrb_nil_p(buf)) {
+    buf = mrb_str_new(mrb, NULL, maxlen);
+  }
+  if (RSTRING_LEN(buf) != maxlen) {
+    buf = mrb_str_resize(mrb, buf, maxlen);
+  }
+
+  fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
+  ret = read(fptr->fd, RSTRING_PTR(buf), maxlen);
+  switch (ret) {
+    case 0: /* EOF */
+      if (maxlen == 0) {
+        buf = mrb_str_new_cstr(mrb, "");
+      } else {
+        mrb_raise(mrb, E_EOF_ERROR, "sysread failed: End of File");
+      }
+      break;
+    case -1: /* Error */
+      mrb_sys_fail(mrb, "sysread failed");
+      break;
+    default:
+      if (RSTRING_LEN(buf) != ret) {
+        buf = mrb_str_resize(mrb, buf, ret);
+      }
+      break;
+  }
+
+  return buf;
+}
+
+mrb_value
+mrb_io_sysseek(mrb_state *mrb, mrb_value io)
+{
+  struct mrb_io *fptr;
+  off_t pos;
+  mrb_int offset, whence = -1;
+
+  mrb_get_args(mrb, "i|i", &offset, &whence);
+  if (whence < 0) {
+    whence = 0;
+  }
+
+  fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
+  pos = lseek(fptr->fd, offset, whence);
+  if (pos == -1) {
+    mrb_sys_fail(mrb, "sysseek");
+  }
+  if (pos > MRB_INT_MAX) {
+    return mrb_float_value(mrb, (mrb_float)pos);
+  } else {
+    return mrb_fixnum_value(pos);
+  }
+}
+
+mrb_value
+mrb_io_syswrite(mrb_state *mrb, mrb_value io)
+{
+  struct mrb_io *fptr;
+  mrb_value str, buf;
+  int fd, length;
+
+  fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
+  if (! fptr->writable) {
+    mrb_raise(mrb, E_IO_ERROR, "not opened for writing");
+  }
+
+  mrb_get_args(mrb, "S", &str);
+  if (mrb_type(str) != MRB_TT_STRING) {
+    buf = mrb_funcall(mrb, str, "to_s", 0);
+  } else {
+    buf = str;
+  }
+
+  if (fptr->fd2 == -1) {
+    fd = fptr->fd;
+  } else {
+    fd = fptr->fd2;
+  }
+  length = write(fd, RSTRING_PTR(buf), RSTRING_LEN(buf));
+
+  return mrb_fixnum_value(length);
+}
+
+mrb_value
+mrb_io_close(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_io *fptr;
+  fptr = io_get_open_fptr(mrb, self);
+  fptr_finalize(mrb, fptr, FALSE);
+  return mrb_nil_value();
+}
+
+mrb_value
+mrb_io_closed(mrb_state *mrb, mrb_value io)
+{
+  struct mrb_io *fptr;
+  fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
+  if (fptr->fd >= 0) {
+    return mrb_false_value();
+  }
+
+  return mrb_true_value();
+}
+
+mrb_value
+mrb_io_pid(mrb_state *mrb, mrb_value io)
+{
+  struct mrb_io *fptr;
+  fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
+
+  if (fptr->pid > 0) {
+    return mrb_fixnum_value(fptr->pid);
+  }
+
+  return mrb_nil_value();
+}
+
+static struct timeval
+time2timeval(mrb_state *mrb, mrb_value time)
+{
+  struct timeval t = { 0, 0 };
+
+  switch (mrb_type(time)) {
+    case MRB_TT_FIXNUM:
+      t.tv_sec = mrb_fixnum(time);
+      t.tv_usec = 0;
+      break;
+
+    case MRB_TT_FLOAT:
+      t.tv_sec = mrb_float(time);
+      t.tv_usec = (mrb_float(time) - t.tv_sec) * 1000000.0;
+      break;
+
+    default:
+      mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class");
+  }
+
+  return t;
+}
+
+static int
+mrb_io_read_data_pending(mrb_state *mrb, mrb_value io)
+{
+  mrb_value buf = mrb_iv_get(mrb, io, mrb_intern_cstr(mrb, "@buf"));
+  if (mrb_type(buf) == MRB_TT_STRING && RSTRING_LEN(buf) > 0) {
+    return 1;
+  }
+  return 0;
+}
+
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__NEWLIB__)
+static mrb_value
+mrb_io_s_pipe(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value r = mrb_nil_value();
+  mrb_value w = mrb_nil_value();
+  struct mrb_io *fptr_r;
+  struct mrb_io *fptr_w;
+  int pipes[2];
+
+  if (mrb_pipe(mrb, pipes) == -1) {
+    mrb_sys_fail(mrb, "pipe");
+  }
+
+  r = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
+  mrb_iv_set(mrb, r, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
+  mrb_iv_set(mrb, r, mrb_intern_cstr(mrb, "@pos"), mrb_fixnum_value(0));
+  fptr_r = mrb_io_alloc(mrb);
+  fptr_r->fd = pipes[0];
+  fptr_r->readable = 1;
+  fptr_r->writable = 0;
+  fptr_r->sync = 0;
+  DATA_TYPE(r) = &mrb_io_type;
+  DATA_PTR(r)  = fptr_r;
+
+  w = mrb_obj_value(mrb_data_object_alloc(mrb, mrb_class_ptr(klass), NULL, &mrb_io_type));
+  mrb_iv_set(mrb, w, mrb_intern_cstr(mrb, "@buf"), mrb_str_new_cstr(mrb, ""));
+  mrb_iv_set(mrb, w, mrb_intern_cstr(mrb, "@pos"), mrb_fixnum_value(0));
+  fptr_w = mrb_io_alloc(mrb);
+  fptr_w->fd = pipes[1];
+  fptr_w->readable = 0;
+  fptr_w->writable = 1;
+  fptr_w->sync = 1;
+  DATA_TYPE(w) = &mrb_io_type;
+  DATA_PTR(w)  = fptr_w;
+
+  return mrb_assoc_new(mrb, r, w);
+}
+#endif
+
+static mrb_value
+mrb_io_s_select(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value *argv;
+  mrb_int argc;
+  mrb_value read, read_io, write, except, timeout, list;
+  struct timeval *tp, timerec;
+  fd_set pset, rset, wset, eset;
+  fd_set *rp, *wp, *ep;
+  struct mrb_io *fptr;
+  int pending = 0;
+  mrb_value result;
+  int max = 0;
+  int interrupt_flag = 0;
+  int i, n;
+
+  mrb_get_args(mrb, "*", &argv, &argc);
+
+  if (argc < 1 || argc > 4) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%S for 1..4)", mrb_fixnum_value(argc));
+  }
+
+  timeout = mrb_nil_value();
+  except = mrb_nil_value();
+  write = mrb_nil_value();
+  if (argc > 3)
+    timeout = argv[3];
+  if (argc > 2)
+    except = argv[2];
+  if (argc > 1)
+    write = argv[1];
+  read = argv[0];
+
+  if (mrb_nil_p(timeout)) {
+    tp = NULL;
+  } else {
+    timerec = time2timeval(mrb, timeout);
+    tp = &timerec;
+  }
+
+  FD_ZERO(&pset);
+  if (!mrb_nil_p(read)) {
+    mrb_check_type(mrb, read, MRB_TT_ARRAY);
+    rp = &rset;
+    FD_ZERO(rp);
+    for (i = 0; i < RARRAY_LEN(read); i++) {
+      read_io = RARRAY_PTR(read)[i];
+      fptr = (struct mrb_io *)mrb_get_datatype(mrb, read_io, &mrb_io_type);
+      FD_SET(fptr->fd, rp);
+      if (mrb_io_read_data_pending(mrb, read_io)) {
+        pending++;
+        FD_SET(fptr->fd, &pset);
+      }
+      if (max < fptr->fd)
+        max = fptr->fd;
+    }
+    if (pending) {
+      timerec.tv_sec = timerec.tv_usec = 0;
+      tp = &timerec;
+    }
+  } else {
+    rp = NULL;
+  }
+
+  if (!mrb_nil_p(write)) {
+    mrb_check_type(mrb, write, MRB_TT_ARRAY);
+    wp = &wset;
+    FD_ZERO(wp);
+    for (i = 0; i < RARRAY_LEN(write); i++) {
+      fptr = (struct mrb_io *)mrb_get_datatype(mrb, RARRAY_PTR(write)[i], &mrb_io_type);
+      FD_SET(fptr->fd, wp);
+      if (max < fptr->fd)
+        max = fptr->fd;
+      if (fptr->fd2 >= 0) {
+        FD_SET(fptr->fd2, wp);
+        if (max < fptr->fd2)
+          max = fptr->fd2;
+      }
+    }
+  } else {
+    wp = NULL;
+  }
+
+  if (!mrb_nil_p(except)) {
+    mrb_check_type(mrb, except, MRB_TT_ARRAY);
+    ep = &eset;
+    FD_ZERO(ep);
+    for (i = 0; i < RARRAY_LEN(except); i++) {
+      fptr = (struct mrb_io *)mrb_get_datatype(mrb, RARRAY_PTR(except)[i], &mrb_io_type);
+      FD_SET(fptr->fd, ep);
+      if (max < fptr->fd)
+        max = fptr->fd;
+      if (fptr->fd2 >= 0) {
+        FD_SET(fptr->fd2, ep);
+        if (max < fptr->fd2)
+          max = fptr->fd2;
+      }
+    }
+  } else {
+    ep = NULL;
+  }
+
+  max++;
+
+retry:
+  n = select(max, rp, wp, ep, tp);
+  if (n < 0) {
+    if (errno != EINTR)
+      mrb_sys_fail(mrb, "select failed");
+    if (tp == NULL)
+      goto retry;
+    interrupt_flag = 1;
+  }
+
+  if (!pending && n == 0)
+    return mrb_nil_value();
+
+  result = mrb_ary_new_capa(mrb, 3);
+  mrb_ary_push(mrb, result, rp? mrb_ary_new(mrb) : mrb_ary_new_capa(mrb, 0));
+  mrb_ary_push(mrb, result, wp? mrb_ary_new(mrb) : mrb_ary_new_capa(mrb, 0));
+  mrb_ary_push(mrb, result, ep? mrb_ary_new(mrb) : mrb_ary_new_capa(mrb, 0));
+
+  if (interrupt_flag == 0) {
+    if (rp) {
+      list = RARRAY_PTR(result)[0];
+      for (i = 0; i < RARRAY_LEN(read); i++) {
+        fptr = (struct mrb_io *)mrb_get_datatype(mrb, RARRAY_PTR(read)[i], &mrb_io_type);
+        if (FD_ISSET(fptr->fd, rp) ||
+            FD_ISSET(fptr->fd, &pset)) {
+          mrb_ary_push(mrb, list, RARRAY_PTR(read)[i]);
+        }
+      }
+    }
+
+    if (wp) {
+      list = RARRAY_PTR(result)[1];
+      for (i = 0; i < RARRAY_LEN(write); i++) {
+        fptr = (struct mrb_io *)mrb_get_datatype(mrb, RARRAY_PTR(write)[i], &mrb_io_type);
+        if (FD_ISSET(fptr->fd, wp)) {
+          mrb_ary_push(mrb, list, RARRAY_PTR(write)[i]);
+        } else if (fptr->fd2 >= 0 && FD_ISSET(fptr->fd2, wp)) {
+          mrb_ary_push(mrb, list, RARRAY_PTR(write)[i]);
+        }
+      }
+    }
+
+    if (ep) {
+      list = RARRAY_PTR(result)[2];
+      for (i = 0; i < RARRAY_LEN(except); i++) {
+        fptr = (struct mrb_io *)mrb_get_datatype(mrb, RARRAY_PTR(except)[i], &mrb_io_type);
+        if (FD_ISSET(fptr->fd, ep)) {
+          mrb_ary_push(mrb, list, RARRAY_PTR(except)[i]);
+        } else if (fptr->fd2 >= 0 && FD_ISSET(fptr->fd2, ep)) {
+          mrb_ary_push(mrb, list, RARRAY_PTR(except)[i]);
+        }
+      }
+    }
+  }
+
+  return result;
+}
+
+mrb_value
+mrb_io_fileno(mrb_state *mrb, mrb_value io)
+{
+  struct mrb_io *fptr;
+  fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
+  return mrb_fixnum_value(fptr->fd);
+}
+
+mrb_value
+mrb_io_close_on_exec_p(mrb_state *mrb, mrb_value self)
+{
+#if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
+  struct mrb_io *fptr;
+  int ret;
+
+  fptr = io_get_open_fptr(mrb, self);
+
+  if (fptr->fd2 >= 0) {
+    if ((ret = fcntl(fptr->fd2, F_GETFD)) == -1) mrb_sys_fail(mrb, "F_GETFD failed");
+    if (!(ret & FD_CLOEXEC)) return mrb_false_value();
+  }
+
+  if ((ret = fcntl(fptr->fd, F_GETFD)) == -1) mrb_sys_fail(mrb, "F_GETFD failed");
+  if (!(ret & FD_CLOEXEC)) return mrb_false_value();
+  return mrb_true_value();
+
+#else
+  mrb_raise(mrb, E_NOTIMP_ERROR, "IO#close_on_exec? is not supported on the platform");
+  return mrb_false_value();
+#endif
+}
+
+mrb_value
+mrb_io_set_close_on_exec(mrb_state *mrb, mrb_value self)
+{
+#if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
+  struct mrb_io *fptr;
+  int flag, ret;
+  mrb_bool b;
+
+  fptr = io_get_open_fptr(mrb, self);
+  mrb_get_args(mrb, "b", &b);
+  flag = b ? FD_CLOEXEC : 0;
+
+  if (fptr->fd2 >= 0) {
+    if ((ret = fcntl(fptr->fd2, F_GETFD)) == -1) mrb_sys_fail(mrb, "F_GETFD failed");
+    if ((ret & FD_CLOEXEC) != flag) {
+      ret = (ret & ~FD_CLOEXEC) | flag;
+      ret = fcntl(fptr->fd2, F_SETFD, ret);
+
+      if (ret == -1) mrb_sys_fail(mrb, "F_SETFD failed");
+    }
+  }
+
+  if ((ret = fcntl(fptr->fd, F_GETFD)) == -1) mrb_sys_fail(mrb, "F_GETFD failed");
+  if ((ret & FD_CLOEXEC) != flag) {
+    ret = (ret & ~FD_CLOEXEC) | flag;
+    ret = fcntl(fptr->fd, F_SETFD, ret);
+    if (ret == -1) mrb_sys_fail(mrb, "F_SETFD failed");
+  }
+
+  return mrb_bool_value(b);
+#else
+  mrb_raise(mrb, E_NOTIMP_ERROR, "IO#close_on_exec= is not supported on the platform");
+  return mrb_nil_value();
+#endif
+}
+
+mrb_value
+mrb_io_set_sync(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_io *fptr;
+  mrb_bool b;
+
+  fptr = io_get_open_fptr(mrb, self);
+  mrb_get_args(mrb, "b", &b);
+  fptr->sync = b;
+  return mrb_bool_value(b);
+}
+
+mrb_value
+mrb_io_sync(mrb_state *mrb, mrb_value self)
+{
+  struct mrb_io *fptr;
+  fptr = io_get_open_fptr(mrb, self);
+  return mrb_bool_value(fptr->sync);
+}
+
+void
+mrb_init_io(mrb_state *mrb)
+{
+  struct RClass *io;
+
+  io      = mrb_define_class(mrb, "IO", mrb->object_class);
+  MRB_SET_INSTANCE_TT(io, MRB_TT_DATA);
+
+  mrb_include_module(mrb, io, mrb_module_get(mrb, "Enumerable")); /* 15.2.20.3 */
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__NEWLIB__)
+  mrb_define_class_method(mrb, io, "_popen",  mrb_io_s_popen,   MRB_ARGS_ANY());
+  mrb_define_class_method(mrb, io, "_sysclose",  mrb_io_s_sysclose, MRB_ARGS_REQ(1));
+#endif
+  mrb_define_class_method(mrb, io, "for_fd",  mrb_io_s_for_fd,   MRB_ARGS_ANY());
+  mrb_define_class_method(mrb, io, "select",  mrb_io_s_select,  MRB_ARGS_ANY());
+  mrb_define_class_method(mrb, io, "sysopen", mrb_io_s_sysopen, MRB_ARGS_ANY());
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__NEWLIB__)
+  mrb_define_class_method(mrb, io, "_pipe", mrb_io_s_pipe, MRB_ARGS_NONE());
+#endif
+
+  mrb_define_method(mrb, io, "initialize", mrb_io_initialize, MRB_ARGS_ANY());    /* 15.2.20.5.21 (x)*/
+  mrb_define_method(mrb, io, "_check_readable", mrb_io_check_readable, MRB_ARGS_NONE());
+  mrb_define_method(mrb, io, "isatty",     mrb_io_isatty,     MRB_ARGS_NONE());
+  mrb_define_method(mrb, io, "sync",       mrb_io_sync,       MRB_ARGS_NONE());
+  mrb_define_method(mrb, io, "sync=",      mrb_io_set_sync,   MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, io, "sysread",    mrb_io_sysread,    MRB_ARGS_ANY());
+  mrb_define_method(mrb, io, "sysseek",    mrb_io_sysseek,    MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, io, "syswrite",   mrb_io_syswrite,   MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, io, "close",      mrb_io_close,      MRB_ARGS_NONE());   /* 15.2.20.5.1 */
+  mrb_define_method(mrb, io, "close_on_exec=", mrb_io_set_close_on_exec, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, io, "close_on_exec?", mrb_io_close_on_exec_p,   MRB_ARGS_NONE());
+  mrb_define_method(mrb, io, "closed?",    mrb_io_closed,     MRB_ARGS_NONE());   /* 15.2.20.5.2 */
+  mrb_define_method(mrb, io, "pid",        mrb_io_pid,        MRB_ARGS_NONE());   /* 15.2.20.5.2 */
+  mrb_define_method(mrb, io, "fileno",     mrb_io_fileno,     MRB_ARGS_NONE());
+
+
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$/"), mrb_str_new_cstr(mrb, "\n"));
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/src/mruby_io_gem.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/src/mruby_io_gem.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/src/mruby_io_gem.c	(revision 279)
@@ -0,0 +1,20 @@
+#include "mruby.h"
+
+void mrb_init_io(mrb_state *mrb);
+void mrb_init_file(mrb_state *mrb);
+void mrb_init_file_test(mrb_state *mrb);
+
+#define DONE mrb_gc_arena_restore(mrb, 0)
+
+void
+mrb_mruby_io_gem_init(mrb_state* mrb)
+{
+  mrb_init_io(mrb); DONE;
+  mrb_init_file(mrb); DONE;
+  mrb_init_file_test(mrb); DONE;
+}
+
+void
+mrb_mruby_io_gem_final(mrb_state* mrb)
+{
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/test/file.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/test/file.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/test/file.rb	(revision 279)
@@ -0,0 +1,188 @@
+##
+# IO Test
+
+assert('File', '15.2.21') do
+  File.class == Class
+end
+
+assert('File', '15.2.21.2') do
+  File.superclass == IO
+end
+
+assert('File TEST SETUP') do
+  MRubyIOTestUtil.io_test_setup
+end
+
+assert('File#initialize', '15.2.21.4.1') do
+  io = File.open($mrbtest_io_rfname, "r")
+  assert_nil io.close
+  assert_raise IOError do
+    io.close
+  end
+end
+
+assert('File#path', '15.2.21.4.2') do
+  io = File.open($mrbtest_io_rfname, "r")
+  assert_equal $mrbtest_io_msg, io.read
+  assert_equal $mrbtest_io_rfname, io.path
+  io.close
+  assert_equal $mrbtest_io_rfname, io.path
+  io.closed?
+end
+
+assert('File.basename') do
+  assert_equal '/', File.basename('//')
+  assert_equal 'a', File.basename('/a/')
+  assert_equal 'b', File.basename('/a/b')
+  assert_equal 'b', File.basename('../a/b')
+end
+
+assert('File.dirname') do
+  assert_equal '.',    File.dirname('')
+  assert_equal '.',    File.dirname('a')
+  assert_equal '/',    File.dirname('/a')
+  assert_equal 'a',    File.dirname('a/b')
+  assert_equal '/a',   File.dirname('/a/b')
+end
+
+assert('File.extname') do
+  assert_equal '.txt', File.extname('foo/foo.txt')
+  assert_equal '.gz',  File.extname('foo/foo.tar.gz')
+  assert_equal '', File.extname('foo/bar')
+  assert_equal '', File.extname('foo/.bar')
+  assert_equal '', File.extname('foo.txt/bar')
+  assert_equal '', File.extname('.foo')
+end
+
+assert('IO#flock') do
+  f = File.open $mrbtest_io_rfname
+  begin
+    assert_equal(f.flock(File::LOCK_SH), 0)
+    assert_equal(f.flock(File::LOCK_UN), 0)
+    assert_equal(f.flock(File::LOCK_EX | File::LOCK_NB), 0)
+    assert_equal(f.flock(File::LOCK_UN), 0)
+  rescue NotImplementedError => e
+    skip e.message
+  ensure
+    f.close
+  end
+end
+
+assert('File.join') do
+  assert_equal "", File.join()
+  assert_equal "a", File.join("a")
+  assert_equal "/a", File.join("/a")
+  assert_equal "a/", File.join("a/")
+  assert_equal "a/b/c", File.join("a", "b", "c")
+  assert_equal "/a/b/c", File.join("/a", "b", "c")
+  assert_equal "a/b/c/", File.join("a", "b", "c/")
+  assert_equal "a/b/c", File.join("a/", "/b/", "/c")
+  assert_equal "a/b/c", File.join(["a", "b", "c"])
+  assert_equal "a/b/c", File.join("a", ["b", ["c"]])
+end
+
+assert('File.realpath') do
+  if File::ALT_SEPARATOR
+    readme_path = File._getwd + File::ALT_SEPARATOR + "README.md"
+    assert_equal readme_path, File.realpath("README.md")
+  else
+    dir = MRubyIOTestUtil.mkdtemp("mruby-io-test.XXXXXX")
+    begin
+      dir1 = File.realpath($mrbtest_io_rfname)
+      dir2 = File.realpath("./#{dir}//./../#{$mrbtest_io_symlinkname}")
+      assert_equal dir1, dir2
+    ensure
+      MRubyIOTestUtil.rmdir dir
+    end
+  end
+end
+
+assert("File.readlink") do
+  begin
+    assert_equal $mrbtest_io_rfname, File.readlink($mrbtest_io_symlinkname)
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert("File.readlink fails with non-symlink") do
+  begin
+    assert_raise(RuntimeError) {
+      begin
+        File.readlink($mrbtest_io_rfname)
+      rescue => e
+        if Object.const_defined?(:SystemCallError) and e.kind_of?(SystemCallError)
+          raise RuntimeError, "SystemCallError converted to RuntimeError"
+        end
+        raise e
+      end
+    }
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('File TEST CLEANUP') do
+  assert_nil MRubyIOTestUtil.io_test_cleanup
+end
+
+assert('File.expand_path') do
+  assert_equal "/",    File.expand_path("..", "/tmp"),       "parent path with base_dir (1)"
+  assert_equal "/tmp", File.expand_path("..", "/tmp/mruby"), "parent path with base_dir (2)"
+
+  assert_equal "/home", File.expand_path("/home"),      "absolute"
+  assert_equal "/home", File.expand_path("/home", "."), "absolute with base_dir"
+
+  assert_equal "/hoge", File.expand_path("/tmp/..//hoge")
+  assert_equal "/hoge", File.expand_path("////tmp/..///////hoge")
+
+  assert_equal "/", File.expand_path("../../../..", "/")
+  if File._getwd[1] == ":"
+    drive_letter = File._getwd[0]
+    assert_equal drive_letter + ":\\", File.expand_path(([".."] * 100).join("/"))
+  else
+    assert_equal "/", File.expand_path(([".."] * 100).join("/"))
+  end
+end
+
+assert('File.expand_path (with ENV)') do
+  skip unless Object.const_defined?(:ENV) && ENV['HOME']
+
+  assert_equal ENV['HOME'], File.expand_path("~/"),      "home"
+  assert_equal ENV['HOME'], File.expand_path("~/", "/"), "home with base_dir"
+
+  assert_equal "#{ENV['HOME']}/user", File.expand_path("user", ENV['HOME']), "relative with base_dir"
+end
+
+assert('File.path') do
+  assert_equal "", File.path("")
+  assert_equal "a/b/c", File.path("a/b/c")
+  assert_equal "a/../b/./c", File.path("a/../b/./c")
+  assert_raise(TypeError) { File.path(nil) }
+  assert_raise(TypeError) { File.path(123) }
+
+end
+
+assert('File.symlink') do
+  target_name = "/usr/bin"
+  symlink_name = "test-bin-dummy"
+  if !File.exist?(target_name)
+    skip("target directory of File.symlink is not found")
+  else
+    assert_equal 0, File.symlink(target_name, symlink_name)
+    begin
+      assert_equal true, File.symlink?(symlink_name)
+    ensure
+      File.delete symlink_name
+    end
+  end
+end
+
+assert('File.chmod') do
+  File.open('chmod-test', 'w') {}
+  begin
+    assert_equal 1, File.chmod(0400, 'chmod-test')
+  ensure
+    File.delete('chmod-test')
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/test/file_test.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/test/file_test.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/test/file_test.rb	(revision 279)
@@ -0,0 +1,117 @@
+##
+# FileTest
+
+assert('FileTest TEST SETUP') do
+  MRubyIOTestUtil.io_test_setup
+end
+
+assert("FileTest.directory?") do
+  dir = MRubyIOTestUtil.mkdtemp("mruby-io-test.XXXXXX")
+  begin
+    assert_true  FileTest.directory?(dir)
+    assert_false FileTest.directory?($mrbtest_io_rfname)
+  ensure
+    MRubyIOTestUtil.rmdir dir
+  end
+end
+
+assert("FileTest.exist?") do
+  assert_equal true,  FileTest.exist?($mrbtest_io_rfname), "filename - exist"
+  assert_equal false, FileTest.exist?($mrbtest_io_rfname + "-"), "filename - not exist"
+  io = IO.new(IO.sysopen($mrbtest_io_rfname))
+  assert_equal true,  FileTest.exist?(io), "io obj - exist"
+  io.close
+  assert_equal true, io.closed?
+  assert_raise IOError do
+    FileTest.exist?(io)
+  end
+end
+
+assert("FileTest.file?") do
+  dir = MRubyIOTestUtil.mkdtemp("mruby-io-test.XXXXXX")
+  begin
+    assert_true  FileTest.file?($mrbtest_io_rfname)
+    assert_false FileTest.file?(dir)
+  ensure
+    MRubyIOTestUtil.rmdir dir
+  end
+end
+
+assert("FileTest.pipe?") do
+  begin
+    assert_equal false, FileTest.pipe?("/tmp")
+    io = IO.popen("ls")
+    assert_equal true,  FileTest.pipe?(io)
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('FileTest.size') do
+  assert_equal FileTest.size($mrbtest_io_rfname), $mrbtest_io_msg.size
+  assert_equal FileTest.size($mrbtest_io_wfname), 0
+end
+
+assert("FileTest.size?") do
+  assert_equal $mrbtest_io_msg.size, FileTest.size?($mrbtest_io_rfname)
+  assert_equal nil, FileTest.size?($mrbtest_io_wfname)
+  assert_equal nil, FileTest.size?("not-exist-test-target-file")
+
+  fp1 = File.open($mrbtest_io_rfname)
+  fp2 = File.open($mrbtest_io_wfname)
+  assert_equal $mrbtest_io_msg.size,  FileTest.size?(fp1)
+  assert_equal nil, FileTest.size?(fp2)
+  fp1.close
+  fp2.close
+
+  assert_raise IOError do
+    FileTest.size?(fp1)
+  end
+  assert_raise IOError do
+    FileTest.size?(fp2)
+  end
+
+  fp1.closed? && fp2.closed?
+end
+
+assert("FileTest.socket?") do
+  begin
+    assert_true FileTest.socket?($mrbtest_io_socketname)
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert("FileTest.symlink?") do
+  begin
+    assert_true FileTest.symlink?($mrbtest_io_symlinkname)
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert("FileTest.zero?") do
+  assert_equal false, FileTest.zero?($mrbtest_io_rfname)
+  assert_equal true,  FileTest.zero?($mrbtest_io_wfname)
+  assert_equal false, FileTest.zero?("not-exist-test-target-file")
+
+  fp1 = File.open($mrbtest_io_rfname)
+  fp2 = File.open($mrbtest_io_wfname)
+  assert_equal false, FileTest.zero?(fp1)
+  assert_equal true,  FileTest.zero?(fp2)
+  fp1.close
+  fp2.close
+
+  assert_raise IOError do
+    FileTest.zero?(fp1)
+  end
+  assert_raise IOError do
+    FileTest.zero?(fp2)
+  end
+
+  fp1.closed? && fp2.closed?
+end
+
+assert('FileTest TEST CLEANUP') do
+  assert_nil MRubyIOTestUtil.io_test_cleanup
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/test/gc_filedes.sh
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/test/gc_filedes.sh	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/test/gc_filedes.sh	(revision 279)
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+ulimit -n 20
+mruby -e '100.times { File.open "'$0'" }'
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/test/io.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/test/io.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/test/io.rb	(revision 279)
@@ -0,0 +1,578 @@
+##
+# IO Test
+
+unless Object.respond_to? :assert_nothing_raised
+  def assert_nothing_raised(*exp)
+    ret = true
+    if $mrbtest_assert
+      $mrbtest_assert_idx += 1
+      msg = exp.last.class == String ? exp.pop : ""
+      begin
+        yield
+      rescue Exception => e
+        msg = "#{msg} exception raised."
+        diff = "      Class: <#{e.class}>\n" +
+          "    Message: #{e.message}"
+        $mrbtest_assert.push([$mrbtest_assert_idx, msg, diff])
+        ret = false
+      end
+    end
+    ret
+  end
+end
+
+assert('IO TEST SETUP') do
+  MRubyIOTestUtil.io_test_setup
+end
+
+assert('IO', '15.2.20') do
+  assert_equal(Class, IO.class)
+end
+
+assert('IO', '15.2.20.2') do
+  assert_equal(Object, IO.superclass)
+end
+
+assert('IO', '15.2.20.3') do
+  assert_include(IO.included_modules, Enumerable)
+end
+
+assert('IO.open', '15.2.20.4.1') do
+  fd = IO.sysopen $mrbtest_io_rfname
+  assert_equal Fixnum, fd.class
+  io = IO.open fd
+  assert_equal IO, io.class
+  assert_equal $mrbtest_io_msg, io.read
+  io.close
+
+  fd = IO.sysopen $mrbtest_io_rfname
+  IO.open(fd) do |io|
+    assert_equal $mrbtest_io_msg, io.read
+  end
+
+  true
+end
+
+assert('IO#close', '15.2.20.5.1') do
+  io = IO.new(IO.sysopen($mrbtest_io_rfname))
+  assert_nil io.close
+end
+
+assert('IO#closed?', '15.2.20.5.2') do
+  io = IO.new(IO.sysopen($mrbtest_io_rfname))
+  assert_false io.closed?
+  io.close
+  assert_true io.closed?
+end
+
+#assert('IO#each', '15.2.20.5.3') do
+#assert('IO#each_byte', '15.2.20.5.4') do
+#assert('IO#each_line', '15.2.20.5.5') do
+
+assert('IO#eof?', '15.2.20.5.6') do
+  io = IO.new(IO.sysopen($mrbtest_io_wfname, 'w'), 'w')
+  assert_raise(IOError) do
+    io.eof?
+  end
+  io.close
+
+  # empty file
+  io = IO.open(IO.sysopen($mrbtest_io_wfname, 'w'), 'w')
+  io.close
+  io = IO.open(IO.sysopen($mrbtest_io_wfname, 'r'), 'r')
+  assert_true io.eof?
+  io.close
+
+  # nonempty file
+  io = IO.new(IO.sysopen($mrbtest_io_rfname))
+  assert_false io.eof?
+  io.readchar
+  assert_false io.eof?
+  io.read
+  assert_true io.eof?
+  io.close
+
+  true
+end
+
+assert('IO#flush', '15.2.20.5.7') do
+  # Note: mruby-io does not have any buffer to be flushed now.
+  io = IO.new(IO.sysopen($mrbtest_io_wfname))
+  assert_equal io, io.flush
+  io.close
+  assert_raise(IOError) do
+    io.flush
+  end
+end
+
+assert('IO#getc', '15.2.20.5.8') do
+  io = IO.new(IO.sysopen($mrbtest_io_rfname))
+  $mrbtest_io_msg.each_char { |ch|
+    assert_equal ch, io.getc
+  }
+  assert_equal nil, io.getc
+  io.close
+  true
+end
+
+#assert('IO#gets', '15.2.20.5.9') do
+#assert('IO#initialize_copy', '15.2.20.5.10') do
+#assert('IO#print', '15.2.20.5.11') do
+#assert('IO#putc', '15.2.20.5.12') do
+#assert('IO#puts', '15.2.20.5.13') do
+
+assert('IO#read', '15.2.20.5.14') do
+  IO.open(IO.sysopen($mrbtest_io_rfname)) do |io|
+    assert_raise(ArgumentError) { io.read(-5) }
+    assert_raise(TypeError) { io.read("str") }
+
+    len = $mrbtest_io_msg.length
+    assert_equal '', io.read(0)
+    assert_equal 'mruby', io.read(5)
+    assert_equal $mrbtest_io_msg[5,len], io.read(len)
+
+    assert_equal "", io.read
+    assert_nil io.read(1)
+  end
+
+  IO.open(IO.sysopen($mrbtest_io_rfname)) do |io|
+    assert_equal $mrbtest_io_msg, io.read
+  end
+end
+
+assert('IO#readchar', '15.2.20.5.15') do
+  # almost same as IO#getc
+  IO.open(IO.sysopen($mrbtest_io_rfname)) do |io|
+    $mrbtest_io_msg.each_char { |ch|
+      assert_equal ch, io.readchar
+    }
+    assert_raise(EOFError) do
+      io.readchar
+    end
+  end
+end
+
+#assert('IO#readline', '15.2.20.5.16') do
+#assert('IO#readlines', '15.2.20.5.17') do
+
+assert('IO#sync', '15.2.20.5.18') do
+  io = IO.new(IO.sysopen($mrbtest_io_rfname))
+  s = io.sync
+  assert_true(s == true || s == false)
+  io.close
+  assert_raise(IOError) do
+    io.sync
+  end
+end
+
+assert('IO#sync=', '15.2.20.5.19') do
+  io = IO.new(IO.sysopen($mrbtest_io_rfname))
+  io.sync = true
+  assert_true io.sync
+  io.sync = false
+  assert_false io.sync
+  io.close
+  assert_raise(IOError) do
+    io.sync = true
+  end
+end
+
+assert('IO#write', '15.2.20.5.20') do
+  io = IO.open(IO.sysopen($mrbtest_io_wfname))
+  assert_equal 0, io.write("")
+  io.close
+  true
+end
+
+assert('IO#<<') do
+  io = IO.open(IO.sysopen($mrbtest_io_wfname))
+  io << "" << ""
+  assert_equal 0, io.pos
+  io.close
+  true
+end
+
+assert('IO.for_fd') do
+  fd = IO.sysopen($mrbtest_io_rfname)
+  io = IO.for_fd(fd)
+    assert_equal $mrbtest_io_msg, io.read
+  io.close
+  true
+end
+
+assert('IO.new') do
+  io = IO.new(0)
+  io.close
+  true
+end
+
+assert('IO gc check') do
+  100.times { IO.new(0) }
+end
+
+assert('IO.sysopen("./nonexistent")') do
+  if Object.const_defined? :Errno
+    eclass = Errno::ENOENT
+  else
+    eclass = RuntimeError
+  end
+  assert_raise eclass do
+    fd = IO.sysopen "./nonexistent"
+    IO._sysclose fd
+  end
+end
+
+assert('IO.sysopen, IO#sysread') do
+  fd = IO.sysopen $mrbtest_io_rfname
+  io = IO.new fd
+  str1 = "     "
+  str2 = io.sysread(5, str1)
+  assert_equal $mrbtest_io_msg[0,5], str1
+  assert_equal $mrbtest_io_msg[0,5], str2
+  assert_raise EOFError do
+    io.sysread(10000)
+    io.sysread(10000)
+  end
+  io.close
+  io.closed?
+end
+
+assert('IO.sysopen, IO#syswrite') do
+  fd = IO.sysopen $mrbtest_io_wfname, "w"
+  io = IO.new fd, "w"
+  str = "abcdefg"
+  len = io.syswrite(str)
+  assert_equal str.size, len
+  io.close
+
+  io = IO.new(IO.sysopen($mrbtest_io_rfname), "r")
+  assert_raise(IOError) { io.syswrite("a") }
+  io.close
+
+  true
+end
+
+assert('IO#_read_buf') do
+  fd = IO.sysopen $mrbtest_io_rfname
+  io = IO.new fd
+  def io._buf
+    @buf
+  end
+  msg_len = $mrbtest_io_msg.size
+  assert_equal '', io._buf
+  assert_equal $mrbtest_io_msg, io._read_buf
+  assert_equal $mrbtest_io_msg, io._buf
+  assert_equal 'mruby', io.read(5)
+  assert_equal 5, io.pos
+  assert_equal msg_len - 5, io._buf.size
+  assert_equal $mrbtest_io_msg[5,100], io.read
+  assert_equal 0, io._buf.size
+  assert_raise EOFError do
+    io._read_buf
+  end
+  assert_equal true, io.eof
+  assert_equal true, io.eof?
+  io.close
+  io.closed?
+end
+
+assert('IO#isatty') do
+  f1 = File.open("/dev/tty")
+  f2 = File.open($mrbtest_io_rfname)
+
+  assert_true  f1.isatty
+  assert_false f2.isatty
+
+  f1.close
+  f2.close
+  true
+end
+
+assert('IO#pos=, IO#seek') do
+  fd = IO.sysopen $mrbtest_io_rfname
+  io = IO.new fd
+  def io._buf
+    @buf
+  end
+  assert_equal 'm', io.getc
+  assert_equal 1, io.pos
+  assert_equal 0, io.seek(0)
+  assert_equal 0, io.pos
+  io.close
+  io.closed?
+end
+
+assert('IO#rewind') do
+  fd = IO.sysopen $mrbtest_io_rfname
+  io = IO.new fd
+  assert_equal 'm', io.getc
+  assert_equal 1, io.pos
+  assert_equal 0, io.rewind
+  assert_equal 0, io.pos
+  io.close
+  io.closed?
+end
+
+assert('IO#gets') do
+  fd = IO.sysopen $mrbtest_io_rfname
+  io = IO.new fd
+
+  # gets without arguments
+  assert_equal $mrbtest_io_msg, io.gets, "gets without arguments"
+  assert_equal nil, io.gets, "gets returns nil, when EOF"
+
+  # gets with limit
+  io.pos = 0
+  assert_equal $mrbtest_io_msg[0, 5], io.gets(5), "gets with limit"
+
+  # gets with rs
+  io.pos = 0
+  assert_equal $mrbtest_io_msg[0, 6], io.gets(' '), "gets with rs"
+
+  # gets with rs, limit
+  io.pos = 0
+  assert_equal $mrbtest_io_msg[0, 5], io.gets(' ', 5), "gets with rs, limit"
+  io.close
+  assert_equal true, io.closed?, "close success"
+
+  # reading many-lines file.
+  fd = IO.sysopen $mrbtest_io_wfname, "w"
+  io = IO.new fd, "w"
+  io.write "0123456789" * 2 + "\na"
+  assert_equal 22, io.pos
+  io.close
+  assert_equal true, io.closed?
+
+  fd = IO.sysopen $mrbtest_io_wfname
+  io = IO.new fd
+  line = io.gets
+
+  # gets first line
+  assert_equal "0123456789" * 2 + "\n", line, "gets first line"
+  assert_equal 21, line.size
+  assert_equal 21, io.pos
+
+  # gets second line
+  assert_equal "a", io.gets, "gets second line"
+
+  # gets third line
+  assert_equal nil, io.gets, "gets third line; returns nil"
+
+  io.close
+  io.closed?
+end
+
+assert('IO#gets - paragraph mode') do
+  fd = IO.sysopen $mrbtest_io_wfname, "w"
+  io = IO.new fd, "w"
+  io.write "0" * 10 + "\n"
+  io.write "1" * 10 + "\n\n"
+  io.write "2" * 10 + "\n"
+  assert_equal 34, io.pos
+  io.close
+  assert_equal true, io.closed?
+
+  fd = IO.sysopen $mrbtest_io_wfname
+  io = IO.new fd
+  para1 = "#{'0' * 10}\n#{'1' * 10}\n\n"
+  text1 = io.gets("")
+  assert_equal para1, text1
+  para2 = "#{'2' * 10}\n"
+  text2 = io.gets("")
+  assert_equal para2, text2
+  io.close
+  io.closed?
+end
+
+assert('IO.popen') do
+  begin
+    $? = nil
+    io = IO.popen("echo mruby-io")
+    assert_true io.close_on_exec?
+    assert_equal Fixnum, io.pid.class
+
+    out = io.read
+    assert_equal out.class, String
+    assert_include out, 'mruby-io'
+
+    io.close
+    if Object.const_defined? :Process
+      assert_true $?.success?
+    else
+      assert_equal 0, $?
+    end
+
+    assert_true io.closed?
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('IO.popen with in option') do
+  begin
+    IO.pipe do |r, w|
+      w.write 'hello'
+      w.close
+      assert_equal "hello", IO.popen("cat", "r", in: r) { |i| i.read }
+      assert_equal "", r.read
+    end
+    assert_raise(ArgumentError) { IO.popen("hello", "r", in: Object.new) }
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('IO.popen with out option') do
+  begin
+    IO.pipe do |r, w|
+      IO.popen("echo 'hello'", "w", out: w) {}
+      w.close
+      assert_equal "hello\n", r.read
+    end
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('IO.popen with err option') do
+  begin
+    IO.pipe do |r, w|
+      assert_equal "", IO.popen("echo 'hello' 1>&2", "r", err: w) { |i| i.read }
+      w.close
+      assert_equal "hello\n", r.read
+    end
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('IO.read') do
+  # empty file
+  fd = IO.sysopen $mrbtest_io_wfname, "w"
+  io = IO.new fd, "w"
+  io.close
+  assert_equal "",  IO.read($mrbtest_io_wfname)
+  assert_equal nil, IO.read($mrbtest_io_wfname, 1)
+
+  # one byte file
+  fd = IO.sysopen $mrbtest_io_wfname, "w"
+  io = IO.new fd, "w"
+  io.write "123"
+  io.close
+  assert_equal "123", IO.read($mrbtest_io_wfname)
+  assert_equal "",    IO.read($mrbtest_io_wfname, 0)
+  assert_equal "1",   IO.read($mrbtest_io_wfname, 1)
+  assert_equal "",    IO.read($mrbtest_io_wfname, 0, 10)
+  assert_equal "23",  IO.read($mrbtest_io_wfname, 2, 1)
+  assert_equal "23",  IO.read($mrbtest_io_wfname, 10, 1)
+  assert_equal "",    IO.read($mrbtest_io_wfname, nil, 10)
+  assert_equal nil,   IO.read($mrbtest_io_wfname, 1, 10)
+end
+
+assert('IO#fileno') do
+  fd = IO.sysopen $mrbtest_io_rfname
+  io = IO.new fd
+  assert_equal io.fileno, fd
+  assert_equal io.to_i, fd
+  io.close
+  io.closed?
+end
+
+assert('IO#close_on_exec') do
+  fd = IO.sysopen $mrbtest_io_wfname, "w"
+  io = IO.new fd, "w"
+  begin
+    # IO.sysopen opens a file descripter with O_CLOEXEC flag.
+    assert_true io.close_on_exec?
+  rescue ScriptError
+    skip "IO\#close_on_exec is not implemented."
+  end
+
+  io.close_on_exec = false
+  assert_equal(false, io.close_on_exec?)
+  io.close_on_exec = true
+  assert_equal(true, io.close_on_exec?)
+  io.close_on_exec = false
+  assert_equal(false, io.close_on_exec?)
+
+  io.close
+  io.closed?
+
+  begin
+    r, w = IO.pipe
+    assert_equal(true, r.close_on_exec?)
+    r.close_on_exec = false
+    assert_equal(false, r.close_on_exec?)
+    r.close_on_exec = true
+    assert_equal(true, r.close_on_exec?)
+
+    assert_equal(true, w.close_on_exec?)
+    w.close_on_exec = false
+    assert_equal(false, w.close_on_exec?)
+    w.close_on_exec = true
+    assert_equal(true, w.close_on_exec?)
+  ensure
+    r.close unless r.closed?
+    w.close unless w.closed?
+  end
+end
+
+assert('IO#sysseek') do
+  IO.open(IO.sysopen($mrbtest_io_rfname)) do |io|
+    assert_equal 2, io.sysseek(2)
+    assert_equal 5, io.sysseek(3, IO::SEEK_CUR) # 2 + 3 => 5
+    assert_equal $mrbtest_io_msg.size - 4, io.sysseek(-4, IO::SEEK_END)
+  end
+end
+
+assert('IO.pipe') do
+  begin
+    called = false
+    IO.pipe do |r, w|
+      assert_true r.kind_of?(IO)
+      assert_true w.kind_of?(IO)
+      assert_false r.closed?
+      assert_false w.closed?
+      assert_true FileTest.pipe?(r)
+      assert_true FileTest.pipe?(w)
+      assert_nil r.pid
+      assert_nil w.pid
+      assert_true 2 < r.fileno
+      assert_true 2 < w.fileno
+      assert_true r.fileno != w.fileno
+      assert_false r.sync
+      assert_true w.sync
+      assert_equal 8, w.write('test for')
+      assert_equal 'test', r.read(4)
+      assert_equal ' for', r.read(4)
+      assert_equal 5, w.write(' pipe')
+      assert_equal nil, w.close
+      assert_equal ' pipe', r.read
+      called = true
+      assert_raise(IOError) { r.write 'test' }
+      # TODO:
+      # This assert expect raise IOError but got RuntimeError
+      # Because mruby-io not have flag for I/O readable
+      # assert_raise(IOError) { w.read }
+    end
+    assert_true called
+
+    assert_nothing_raised do
+      IO.pipe { |r, w| r.close; w.close }
+    end
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('`cmd`') do
+  begin
+    assert_equal `echo foo`, "foo\n"
+  rescue NotImplementedError => e
+    skip e.message
+  end
+end
+
+assert('IO TEST CLEANUP') do
+  assert_nil MRubyIOTestUtil.io_test_cleanup
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-io/test/mruby_io_test.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-io/test/mruby_io_test.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-io/test/mruby_io_test.c	(revision 279)
@@ -0,0 +1,191 @@
+#include <sys/types.h>
+#include <errno.h>
+
+#if defined(_WIN32) || defined(_WIN64)
+  #include <winsock.h>
+  #include <io.h>
+#else
+  #include <sys/socket.h>
+  #include <unistd.h>
+  #include <sys/un.h>
+#endif
+
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mruby.h"
+#include "mruby/array.h"
+#include "mruby/error.h"
+#include "mruby/string.h"
+#include "mruby/variable.h"
+
+static mrb_value
+mrb_io_test_io_setup(mrb_state *mrb, mrb_value self)
+{
+  char rfname[]      = "tmp.mruby-io-test.XXXXXXXX";
+  char wfname[]      = "tmp.mruby-io-test.XXXXXXXX";
+  char symlinkname[] = "tmp.mruby-io-test.XXXXXXXX";
+  char socketname[]  = "/tmp/mruby-io-test.XXXXXXXX";
+  char msg[] = "mruby io test\n";
+  mode_t mask;
+  int fd0, fd1, fd2, fd3;
+  FILE *fp;
+
+#ifndef _WIN32
+  struct sockaddr_un sun0;
+#endif
+
+  mask = umask(077);
+  fd0 = mkstemp(rfname);
+  fd1 = mkstemp(wfname);
+#ifndef _WIN32
+  fd2 = mkstemp(symlinkname);
+  fd3 = mkstemp(socketname);
+#endif
+  if (fd0 == -1 || fd1 == -1 || fd2 == -1 || fd3 == -1) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't create temporary file");
+    return mrb_nil_value();
+  }
+  umask(mask);
+
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_rfname"), mrb_str_new_cstr(mrb, rfname));
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_wfname"), mrb_str_new_cstr(mrb, wfname));
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_symlinkname"), mrb_str_new_cstr(mrb, symlinkname));
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_socketname"), mrb_str_new_cstr(mrb, socketname));
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_msg"), mrb_str_new_cstr(mrb, msg));
+
+  fp = fopen(rfname, "wb");
+  if (fp == NULL) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't open temporary file");
+    return mrb_nil_value();
+  }
+  fputs(msg, fp);
+  fclose(fp);
+
+  fp = fopen(wfname, "wb");
+  if (fp == NULL) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't open temporary file");
+    return mrb_nil_value();
+  }
+  fclose(fp);
+
+#ifndef _WIN32
+  unlink(symlinkname);
+  close(fd2);
+  if (symlink(rfname, symlinkname) == -1) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't make a symbolic link");
+  }
+
+  unlink(socketname);
+  close(fd3);
+  fd3 = socket(AF_UNIX, SOCK_STREAM, 0);
+  if (fd3 == -1) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't make a socket");
+  }
+  sun0.sun_family = AF_UNIX;
+  snprintf(sun0.sun_path, sizeof(sun0.sun_path), "%s", socketname);
+  if (bind(fd3, (struct sockaddr *)&sun0, sizeof(sun0)) == -1) {
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "can't bind AF_UNIX socket to %S: %S",
+               mrb_str_new_cstr(mrb, sun0.sun_path),
+               mrb_fixnum_value(errno));
+  }
+  close(fd3);
+#endif
+
+  return mrb_true_value();
+}
+
+static mrb_value
+mrb_io_test_io_cleanup(mrb_state *mrb, mrb_value self)
+{
+  mrb_value rfname = mrb_gv_get(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_rfname"));
+  mrb_value wfname = mrb_gv_get(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_wfname"));
+  mrb_value symlinkname = mrb_gv_get(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_symlinkname"));
+  mrb_value socketname = mrb_gv_get(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_socketname"));
+
+  if (mrb_type(rfname) == MRB_TT_STRING) {
+    remove(RSTRING_PTR(rfname));
+  }
+  if (mrb_type(wfname) == MRB_TT_STRING) {
+    remove(RSTRING_PTR(wfname));
+  }
+  if (mrb_type(symlinkname) == MRB_TT_STRING) {
+    remove(RSTRING_PTR(symlinkname));
+  }
+  if (mrb_type(socketname) == MRB_TT_STRING) {
+    remove(RSTRING_PTR(socketname));
+  }
+
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_rfname"), mrb_nil_value());
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_wfname"), mrb_nil_value());
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_symlinkname"), mrb_nil_value());
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_socketname"), mrb_nil_value());
+  mrb_gv_set(mrb, mrb_intern_cstr(mrb, "$mrbtest_io_msg"), mrb_nil_value());
+
+  return mrb_nil_value();
+}
+
+static mrb_value
+mrb_io_test_file_setup(mrb_state *mrb, mrb_value self)
+{
+  mrb_value ary = mrb_io_test_io_setup(mrb, self);
+#ifndef _WIN32
+  if (symlink("/usr/bin", "test-bin") == -1) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't make a symbolic link");
+  }
+#endif
+
+  return ary;
+}
+
+static mrb_value
+mrb_io_test_file_cleanup(mrb_state *mrb, mrb_value self)
+{
+  mrb_io_test_io_cleanup(mrb, self);
+  remove("test-bin");
+
+  return mrb_nil_value();
+}
+
+static mrb_value
+mrb_io_test_mkdtemp(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value str;
+  char *cp;
+
+  mrb_get_args(mrb, "S", &str);
+  cp = mrb_str_to_cstr(mrb, str);
+  if (mkdtemp(cp) == NULL) {
+    mrb_sys_fail(mrb, "mkdtemp");
+  }
+  return mrb_str_new_cstr(mrb, cp);
+}
+
+static mrb_value
+mrb_io_test_rmdir(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value str;
+  char *cp;
+
+  mrb_get_args(mrb, "S", &str);
+  cp = mrb_str_to_cstr(mrb, str);
+  if (rmdir(cp) == -1) {
+    mrb_sys_fail(mrb, "rmdir");
+  }
+  return mrb_true_value();
+}
+
+void
+mrb_mruby_io_gem_test(mrb_state* mrb)
+{
+  struct RClass *io_test = mrb_define_module(mrb, "MRubyIOTestUtil");
+  mrb_define_class_method(mrb, io_test, "io_test_setup", mrb_io_test_io_setup, MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, io_test, "io_test_cleanup", mrb_io_test_io_cleanup, MRB_ARGS_NONE());
+
+  mrb_define_class_method(mrb, io_test, "file_test_setup", mrb_io_test_file_setup, MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, io_test, "file_test_cleanup", mrb_io_test_file_cleanup, MRB_ARGS_NONE());
+
+  mrb_define_class_method(mrb, io_test, "mkdtemp", mrb_io_test_mkdtemp, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, io_test, "rmdir", mrb_io_test_rmdir, MRB_ARGS_REQ(1));
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/.travis.yml
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/.travis.yml	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/.travis.yml	(revision 279)
@@ -0,0 +1,11 @@
+sudo: false
+addons:
+  apt:
+    packages:
+      - gperf
+      - libonig-dev
+script:
+  - export MRUBY_CONFIG="$TRAVIS_BUILD_DIR/.travis_config.rb"
+  - git clone --depth 1 "https://github.com/mruby/mruby.git"
+  - cd mruby
+  - ./minirake all test
Index: /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/.travis_config.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/.travis_config.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/.travis_config.rb	(revision 279)
@@ -0,0 +1,21 @@
+MRuby::Build.new do |conf|
+  toolchain :gcc
+  enable_debug
+  enable_test
+
+  gem :core => 'mruby-print'
+  gem :core => 'mruby-sprintf'
+  gem "#{MRUBY_ROOT}/.."
+end
+
+MRuby::Build.new("onigmo-bundled") do |conf|
+  toolchain :gcc
+  enable_debug
+  enable_test
+
+  gem :core => 'mruby-print'
+  gem :core => 'mruby-sprintf'
+  gem "#{MRUBY_ROOT}/.." do |g|
+    g.bundle_onigmo
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/mrbgem.rake	(revision 279)
@@ -0,0 +1,5 @@
+MRuby::Gem::Specification.new('mruby-onig-regexp') do |spec|
+  spec.license = 'MIT'
+  spec.authors = 'mattn'
+  spec.summary = 'Onigmo Onigruma Regular expression'
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/mrblib/onig_regexp.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/mrblib/onig_regexp.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/mrblib/onig_regexp.rb	(revision 279)
@@ -0,0 +1,140 @@
+class OnigRegexp
+  @memo = {}
+
+  # ISO 15.2.15.6.1
+  def self.compile(*args)
+    as = args.to_s
+    unless @memo.key? as
+      @memo[as] = self.new(*args)
+    end
+    @memo[as]
+  end
+
+  # ISO 15.2.15.6.3
+  def self.last_match
+    @last_match
+  end
+
+  # ISO 15.2.15.7.2
+  def initialize_copy(other)
+    initialize(other.source, other.options)
+  end
+
+  # ISO 15.2.15.7.4
+  def ===(str)
+    not self.match(str).nil?
+  end
+
+  # ISO 15.2.15.7.5
+  def =~(str)
+    m = self.match(str)
+    m ? m.begin(0) : nil
+  end
+
+  # ISO 15.2.15.7.8
+  attr_reader :source
+end
+
+class String
+  # ISO 15.2.10.5.5
+  def =~(a)
+    begin
+      (a.class.to_s == 'String' ?  Regexp.new(a.to_s) : a) =~ self
+    rescue
+      false
+    end
+  end
+
+  # redefine methods with oniguruma regexp version
+  [:sub, :gsub, :split, :scan].each do |v|
+    alias_method "string_#{v}".to_sym, v
+    alias_method v, "onig_regexp_#{v}".to_sym
+  end
+
+  alias_method :old_slice, :slice
+  alias_method :old_square_brancket, :[]
+
+  def [](*args)
+    return old_square_brancket(*args) unless args[0].class == Regexp
+
+    if args.size == 2
+      match = args[0].match(self)
+      if match
+        if args[1] == 0
+          str = match[0]
+        else
+          str = match.captures[args[1] - 1]
+        end
+        return str
+      end
+    end
+
+    match_data = args[0].match(self)
+    if match_data
+      result = match_data.to_s
+      return result
+    end
+  end
+
+  alias_method :slice, :[]
+
+  def slice!(*args)
+    if args.size < 2
+      result = slice(*args)
+      nth = args[0]
+
+      if nth.class == Regexp
+        lm = Regexp.last_match
+        self[nth] = '' if result
+        Regexp.last_match = lm
+      else
+        self[nth] = '' if result
+      end
+    else
+      result = slice(*args)
+
+      nth = args[0]
+      len = args[1]
+
+      if nth.class == Regexp
+        lm = Regexp.last_match
+        self[nth, len] = '' if result
+        Regexp.last_match = lm
+      else
+        self[nth, len] = '' if result && nth != self.size
+      end
+    end
+
+    result
+  end
+
+  alias_method :old_index, :index
+
+  def index(pattern, pos=0)
+    if pattern.class == Regexp
+      str = self[pos..-1]
+      if str
+        if num = (pattern =~ str)
+          if pos < 0
+            num += self.size
+          end
+          return num + pos
+        end
+      end
+      nil
+    else
+      self.old_index(pattern, pos)
+    end
+  end
+end
+
+module Kernel
+  def =~(_)
+    nil
+  end
+end
+
+Regexp = OnigRegexp unless Object.const_defined?(:Regexp)
+MatchData = OnigMatchData unless Object.const_defined? :MatchData
+
+# This is based on https://github.com/masamitsu-murase/mruby-hs-regexp
Index: /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/src/mruby_onig_regexp.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/src/mruby_onig_regexp.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/src/mruby_onig_regexp.c	(revision 279)
@@ -0,0 +1,1021 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2015 mattn.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/variable.h>
+#include <mruby/array.h>
+#include <mruby/string.h>
+#include <mruby/data.h>
+#include <mruby/variable.h>
+#ifdef _MSC_VER
+#define ONIG_EXTERN extern
+#endif
+#include "oniguruma.h"
+
+#ifdef MRUBY_VERSION
+#define mrb_args_int mrb_int
+#else
+#define mrb_args_int int
+#endif
+
+static void
+onig_regexp_free(mrb_state *mrb, void *p) {
+  onig_free((OnigRegex) p);
+}
+
+static struct mrb_data_type mrb_onig_regexp_type = {
+  "PosixRegexp", onig_regexp_free
+};
+
+static void
+match_data_free(mrb_state* mrb, void* p) {
+  (void)mrb;
+  onig_region_free((OnigRegion*)p, 1);
+}
+
+static struct mrb_data_type mrb_onig_region_type = {
+  "OnigRegion", match_data_free
+};
+
+static mrb_value
+onig_regexp_initialize(mrb_state *mrb, mrb_value self) {
+  mrb_value str, flag = mrb_nil_value(), code = mrb_nil_value();
+  mrb_get_args(mrb, "S|oo", &str, &flag, &code);
+
+  int cflag = 0;
+  OnigSyntaxType* syntax = ONIG_SYNTAX_RUBY;
+  OnigEncoding enc = ONIG_ENCODING_UTF8;
+  if(mrb_string_p(code)) {
+    char const* str_code = mrb_string_value_ptr(mrb, code);
+    if(strchr(str_code, 'n') || strchr(str_code, 'N')) {
+      enc = ONIG_ENCODING_ASCII;
+    }
+  }
+  if(mrb_nil_p(flag)) {
+  } else if(mrb_type(flag) == MRB_TT_TRUE) {
+    cflag |= ONIG_OPTION_IGNORECASE;
+  } else if(mrb_fixnum_p(flag)) {
+    int int_flags = mrb_fixnum(flag);
+    if(int_flags & 0x1) { cflag |= ONIG_OPTION_IGNORECASE; }
+    if(int_flags & 0x2) { cflag |= ONIG_OPTION_EXTEND; }
+    if(int_flags & 0x4) { cflag |= ONIG_OPTION_MULTILINE; }
+  } else if(mrb_string_p(flag)) {
+    char const* str_flags = mrb_string_value_ptr(mrb, flag);
+    if(strchr(str_flags, 'i')) { cflag |= ONIG_OPTION_IGNORECASE; }
+    if(strchr(str_flags, 'x')) { cflag |= ONIG_OPTION_EXTEND; }
+    if(strchr(str_flags, 'm')) { cflag |= ONIG_OPTION_MULTILINE; }
+  } else {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "unknown regexp flag: %S", flag);
+  }
+
+  OnigErrorInfo einfo;
+  OnigRegex reg;
+  int result = onig_new(&reg, (OnigUChar*)RSTRING_PTR(str), (OnigUChar*) RSTRING_PTR(str) + RSTRING_LEN(str),
+                        cflag, enc, syntax, &einfo);
+  if (result != ONIG_NORMAL) {
+    char err[ONIG_MAX_ERROR_MESSAGE_LEN] = "";
+    onig_error_code_to_str((OnigUChar*)err, result);
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "'%S' is an invalid regular expression because %S.",
+               str, mrb_str_new_cstr(mrb, err));
+  }
+  mrb_iv_set(mrb, self, mrb_intern_lit(mrb, "@source"), str);
+
+  DATA_PTR(self) = reg;
+  DATA_TYPE(self) = &mrb_onig_regexp_type;
+
+  return self;
+}
+
+static mrb_value
+create_onig_region(mrb_state* mrb, mrb_value const str, mrb_value rex) {
+  mrb_assert(mrb_string_p(str));
+  mrb_assert(mrb_type(rex) == MRB_TT_DATA && DATA_TYPE(rex) == &mrb_onig_regexp_type);
+  mrb_value const c = mrb_obj_value(mrb_data_object_alloc(
+      mrb, mrb_class_get(mrb, "OnigMatchData"), onig_region_new(), &mrb_onig_region_type));
+  mrb_iv_set(mrb, c, mrb_intern_lit(mrb, "string"), mrb_str_dup(mrb, str));
+  mrb_iv_set(mrb, c, mrb_intern_lit(mrb, "regexp"), rex);
+  return c;
+}
+
+static int
+onig_match_common(mrb_state* mrb, OnigRegex reg, mrb_value match_value, mrb_value str, int pos) {
+  mrb_assert(mrb_string_p(str));
+  mrb_assert(DATA_TYPE(match_value) == &mrb_onig_region_type);
+  OnigRegion* const match = (OnigRegion*)DATA_PTR(match_value);
+  OnigUChar const* str_ptr = (OnigUChar const*)RSTRING_PTR(str);
+  int const result = onig_search(reg, str_ptr, str_ptr + RSTRING_LEN(str),
+                                 str_ptr + pos, str_ptr + RSTRING_LEN(str), match, 0);
+  if (result != ONIG_MISMATCH && result < 0) {
+    char err[ONIG_MAX_ERROR_MESSAGE_LEN] = "";
+    onig_error_code_to_str((OnigUChar*)err, result);
+    mrb_raise(mrb, E_REGEXP_ERROR, err);
+  }
+
+  struct RObject* const cls = (struct RObject*)mrb_class_get(mrb, "OnigRegexp");
+  mrb_obj_iv_set(mrb, cls, mrb_intern_lit(mrb, "@last_match"), match_value);
+
+  if (result != ONIG_MISMATCH &&
+      mrb_class_get(mrb, "Regexp") == (struct RClass*)cls &&
+      mrb_bool(mrb_obj_iv_get(mrb, (struct RObject*)cls, mrb_intern_lit(mrb, "@set_global_variables"))))
+  {
+    mrb_gv_set(mrb, mrb_intern_lit(mrb, "$~"), match_value);
+    mrb_gv_set(mrb, mrb_intern_lit(mrb, "$&"),
+               mrb_funcall(mrb, match_value, "[]", 1, mrb_fixnum_value(0)));
+    mrb_gv_set(mrb, mrb_intern_lit(mrb, "$`"), mrb_funcall(mrb, match_value, "pre_match", 0));
+    mrb_gv_set(mrb, mrb_intern_lit(mrb, "$'"), mrb_funcall(mrb, match_value, "post_match", 0));
+    mrb_gv_set(mrb, mrb_intern_lit(mrb, "$+"),
+               mrb_funcall(mrb, match_value, "[]", 1, mrb_fixnum_value(match->num_regs - 1)));
+
+    // $1 to $9
+    int idx = 1;
+    int const idx_max = match->num_regs > 10? 10 : match->num_regs;
+    for(; idx < idx_max; ++idx) {
+      char const n[] = { '$', '0' + idx };
+      mrb_gv_set(mrb, mrb_intern(mrb, n, 2),
+                 mrb_funcall(mrb, match_value, "[]", 1, mrb_fixnum_value(idx)));
+    }
+
+    for(; idx < 10; ++idx) {
+      char const n[] = { '$', '0' + idx };
+      mrb_gv_remove(mrb, mrb_intern(mrb, n, 2));
+    }
+  }
+
+  return result;
+}
+
+static mrb_value
+onig_regexp_match(mrb_state *mrb, mrb_value self) {
+  mrb_value str = mrb_nil_value();
+  OnigRegex reg;
+  mrb_int pos = 0;
+
+  mrb_get_args(mrb, "o|i", &str, &pos);
+  if (pos < 0 || (pos > 0 && pos >= RSTRING_LEN(str))) {
+    return mrb_nil_value();
+  }
+
+  if (mrb_nil_p(str)) {
+    return mrb_nil_value();
+  }
+  str = mrb_string_type(mrb, str);
+
+  Data_Get_Struct(mrb, self, &mrb_onig_regexp_type, reg);
+
+  mrb_value const ret = create_onig_region(mrb, str, self);
+  return (onig_match_common(mrb, reg, ret, str, pos) == ONIG_MISMATCH)
+      ? mrb_nil_value() : ret;
+}
+
+static mrb_value
+onig_regexp_equal(mrb_state *mrb, mrb_value self) {
+  mrb_value other;
+  OnigRegex self_reg, other_reg;
+
+  mrb_get_args(mrb, "o", &other);
+  if (mrb_obj_equal(mrb, self, other)){
+    return mrb_true_value();
+  }
+  if (mrb_nil_p(other)) {
+    return mrb_false_value();
+  }
+  if (!mrb_obj_is_kind_of(mrb, other, mrb_class_get(mrb, "OnigRegexp"))) {
+    return mrb_false_value();
+  }
+  Data_Get_Struct(mrb, self, &mrb_onig_regexp_type, self_reg);
+  Data_Get_Struct(mrb, other, &mrb_onig_regexp_type, other_reg);
+
+  if (!self_reg || !other_reg){
+      mrb_raise(mrb, E_RUNTIME_ERROR, "Invalid OnigRegexp");
+  }
+  if (onig_get_options(self_reg) != onig_get_options(other_reg)){
+      return mrb_false_value();
+  }
+  return mrb_str_equal(mrb, mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@source")), mrb_iv_get(mrb, other, mrb_intern_lit(mrb, "@source"))) ?
+      mrb_true_value() : mrb_false_value();
+}
+
+static mrb_value
+onig_regexp_casefold_p(mrb_state *mrb, mrb_value self) {
+  OnigRegex reg;
+
+  Data_Get_Struct(mrb, self, &mrb_onig_regexp_type, reg);
+  return (onig_get_options(reg) & ONIG_OPTION_IGNORECASE) ? mrb_true_value() : mrb_false_value();
+}
+
+static mrb_value
+onig_regexp_options(mrb_state *mrb, mrb_value self) {
+  OnigRegex reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_regexp_type, reg);
+  return mrb_fixnum_value(onig_get_options(reg));
+}
+
+static char *
+option_to_str(char str[4], int options) {
+  char *p = str;
+  if (options & ONIG_OPTION_MULTILINE) *p++ = 'm';
+  if (options & ONIG_OPTION_IGNORECASE) *p++ = 'i';
+  if (options & ONIG_OPTION_EXTEND) *p++ = 'x';
+  *p = 0;
+  return str;
+}
+
+static mrb_value
+regexp_expr_str(mrb_state *mrb, mrb_value str, const char *p, int len) {
+  const char *pend;
+  char buf[5];
+
+  pend = (const char *) p + len;
+  for (;p < pend; p++) {
+    unsigned char c, cc;
+
+    c = *p;
+    if (c == '/'|| c == '\\') {
+      buf[0] = '\\'; buf[1] = c;
+      mrb_str_cat(mrb, str, buf, 2);
+      continue;
+    }
+    if (ISPRINT(c)) {
+      buf[0] = c;
+      mrb_str_cat(mrb, str, buf, 1);
+      continue;
+    }
+    switch (c) {
+      case '\n': cc = 'n'; break;
+      case '\r': cc = 'r'; break;
+      case '\t': cc = 't'; break;
+      default: cc = 0; break;
+    }
+    if (cc) {
+      buf[0] = '\\';
+      buf[1] = (char)cc;
+      mrb_str_cat(mrb, str, buf, 2);
+      continue;
+    }
+    else {
+      buf[0] = '\\';
+      buf[3] = '0' + c % 8; c /= 8;
+      buf[2] = '0' + c % 8; c /= 8;
+      buf[1] = '0' + c % 8;
+      mrb_str_cat(mrb, str, buf, 4);
+      continue;
+    }
+  }
+  return str;
+}
+
+static mrb_value
+onig_regexp_inspect(mrb_state *mrb, mrb_value self) {
+  OnigRegex reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_regexp_type, reg);
+  mrb_value str = mrb_str_new_lit(mrb, "/");
+  mrb_value src = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@source"));
+  regexp_expr_str(mrb, str, (const char *)RSTRING_PTR(src), RSTRING_LEN(src));
+  mrb_str_cat_lit(mrb, str, "/");
+  char opts[4];
+  if (*option_to_str(opts, onig_get_options(reg))) {
+    mrb_str_cat_cstr(mrb, str, opts);
+  }
+  if (onig_get_encoding(reg) == ONIG_ENCODING_ASCII) {
+    mrb_str_cat_lit(mrb, str, "n");
+  }
+  return str;
+}
+
+static mrb_value
+onig_regexp_to_s(mrb_state *mrb, mrb_value self) {
+  int options;
+  const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
+  long len;
+  const char* ptr;
+  mrb_value str = mrb_str_new_lit(mrb, "(?");
+  char optbuf[5];
+
+  OnigRegex reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_regexp_type, reg);
+  options = onig_get_options(reg);
+  mrb_value src = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@source"));
+  ptr = RSTRING_PTR(src);
+  len = RSTRING_LEN(src);
+
+ again:
+  if (len >= 4 && ptr[0] == '(' && ptr[1] == '?') {
+	int err = 1;
+	ptr += 2;
+	if ((len -= 2) > 0) {
+      do {
+        if(strchr(ptr, 'i')) { options |= ONIG_OPTION_IGNORECASE; }
+        if(strchr(ptr, 'x')) { options |= ONIG_OPTION_EXTEND; }
+        if(strchr(ptr, 'm')) { options |= ONIG_OPTION_MULTILINE; }
+		++ptr;
+      } while (--len > 0);
+	}
+	if (len > 1 && *ptr == '-') {
+      ++ptr;
+      --len;
+      do {
+        if(strchr(ptr, 'i')) { options &= ~ONIG_OPTION_IGNORECASE; }
+        if(strchr(ptr, 'x')) { options &= ~ONIG_OPTION_EXTEND; }
+        if(strchr(ptr, 'm')) { options &= ~ONIG_OPTION_MULTILINE; }
+		++ptr;
+      } while (--len > 0);
+	}
+	if (*ptr == ')') {
+      --len;
+      ++ptr;
+      goto again;
+	}
+	if (*ptr == ':' && ptr[len-1] == ')') {
+      OnigRegex rp;
+      ++ptr;
+      len -= 2;
+      err = onig_new(&rp, (OnigUChar*)ptr, (OnigUChar*)ptr + len, ONIG_OPTION_DEFAULT,
+                     ONIG_ENCODING_UTF8, OnigDefaultSyntax, NULL);
+      onig_free(rp);
+	}
+	if (err) {
+      options = onig_get_options(reg);
+      ptr = RSTRING_PTR(src);
+      len = RSTRING_LEN(src);
+	}
+  }
+
+  if (*option_to_str(optbuf, options)) mrb_str_cat_cstr(mrb, str, optbuf);
+
+  if ((options & embeddable) != embeddable) {
+	optbuf[0] = '-';
+	option_to_str(optbuf + 1, ~options);
+	mrb_str_cat_cstr(mrb, str, optbuf);
+  }
+
+  mrb_str_cat_cstr(mrb, str, ":");
+  regexp_expr_str(mrb, str, ptr, len);
+  mrb_str_cat_cstr(mrb, str, ")");
+  return str;
+}
+
+
+static mrb_value
+onig_regexp_version(mrb_state* mrb, mrb_value self) {
+  (void)self;
+  return mrb_str_new_cstr(mrb, onig_version());
+}
+
+static mrb_value
+match_data_to_a(mrb_state* mrb, mrb_value self);
+
+static mrb_int
+match_data_actual_index(mrb_state* mrb, mrb_value self, mrb_value idx_value) {
+  if(mrb_fixnum_p(idx_value)) { return mrb_fixnum(idx_value); }
+
+  char const* name = NULL;
+  char const* name_end = NULL;
+  if(mrb_symbol_p(idx_value)) {
+    mrb_int sym_len;
+    name = mrb_sym2name_len(mrb, mrb_symbol(idx_value), &sym_len);
+    name_end = name + sym_len;
+  } else if(mrb_string_p(idx_value)) {
+    name = mrb_string_value_ptr(mrb, idx_value);
+    name_end = name + strlen(name);
+  } else { mrb_assert(FALSE); }
+  mrb_assert(name && name_end);
+
+  mrb_value const regexp = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "regexp"));
+  mrb_assert(!mrb_nil_p(regexp));
+  mrb_assert(DATA_TYPE(regexp) == &mrb_onig_regexp_type);
+  mrb_assert(DATA_TYPE(self) == &mrb_onig_region_type);
+  int const idx = onig_name_to_backref_number(
+      (OnigRegex)DATA_PTR(regexp), (OnigUChar const*)name, (OnigUChar const*)name_end,
+      (OnigRegion*)DATA_PTR(self));
+  if (idx < 0) {
+    mrb_raisef(mrb, E_INDEX_ERROR, "undefined group name reference: %S", idx_value);
+  }
+  return idx;
+}
+
+// ISO 15.2.16.3.1
+static mrb_value
+match_data_index(mrb_state* mrb, mrb_value self) {
+  mrb_value src;
+  mrb_int argc; mrb_value *argv;
+
+  mrb_get_args(mrb, "*", &argv, &argc);
+
+  src = match_data_to_a(mrb, self);
+
+  if (argc == 1) {
+    switch (mrb_type(argv[0])) {
+    case MRB_TT_FIXNUM:
+    case MRB_TT_SYMBOL:
+    case MRB_TT_STRING:
+      return mrb_ary_entry(src, match_data_actual_index(mrb, self, argv[0]));
+    default: break;
+    }
+  }
+
+  return mrb_funcall_argv(mrb, src, mrb_intern_lit(mrb, "[]"), argc, argv);
+}
+
+#define match_data_check_index(idx) \
+  if(idx < 0 || reg->num_regs <= idx) \
+    mrb_raisef(mrb, E_INDEX_ERROR, "index %S out of matches", mrb_fixnum_value(idx)) \
+
+// ISO 15.2.16.3.2
+static mrb_value
+match_data_begin(mrb_state* mrb, mrb_value self) {
+  mrb_value idx_value;
+  mrb_get_args(mrb, "o", &idx_value);
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+  mrb_int const idx = match_data_actual_index(mrb, self, idx_value);
+  match_data_check_index(idx);
+  return mrb_fixnum_value(reg->beg[idx]);
+}
+
+// ISO 15.2.16.3.3
+static mrb_value
+match_data_captures(mrb_state* mrb, mrb_value self) {
+  mrb_value ary = match_data_to_a(mrb, self);
+  return mrb_ary_new_from_values(mrb, RARRAY_LEN(ary) - 1, RARRAY_PTR(ary) + 1);
+}
+
+// ISO 15.2.16.3.4
+static mrb_value
+match_data_end(mrb_state* mrb, mrb_value self) {
+  mrb_value idx_value;
+  mrb_get_args(mrb, "o", &idx_value);
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+  mrb_int const idx = match_data_actual_index(mrb, self, idx_value);
+  match_data_check_index(idx);
+  return mrb_fixnum_value(reg->end[idx]);
+}
+
+// ISO 15.2.16.3.5
+static mrb_value
+match_data_copy(mrb_state* mrb, mrb_value self) {
+  mrb_value src_val;
+  mrb_get_args(mrb, "o", &src_val);
+
+  OnigRegion* src;
+  Data_Get_Struct(mrb, src_val, &mrb_onig_region_type, src);
+
+  OnigRegion* dst = onig_region_new();
+  onig_region_copy(dst, src);
+
+  DATA_PTR(self) = dst;
+  DATA_TYPE(self) = &mrb_onig_region_type;
+  mrb_iv_set(mrb, self, mrb_intern_lit(mrb, "string"), mrb_iv_get(mrb, src_val, mrb_intern_lit(mrb, "string")));
+  mrb_iv_set(mrb, self, mrb_intern_lit(mrb, "regexp"), mrb_iv_get(mrb, src_val, mrb_intern_lit(mrb, "regexp")));
+  return self;
+}
+
+// ISO 15.2.16.3.6
+// ISO 15.2.16.3.10
+static mrb_value
+match_data_length(mrb_state* mrb, mrb_value self) {
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+  return mrb_fixnum_value(reg->num_regs);
+}
+
+// ISO 15.2.16.3.7
+static mrb_value
+match_data_offset(mrb_state* mrb, mrb_value self) {
+  mrb_value idx_value;
+  mrb_get_args(mrb, "o", &idx_value);
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+  mrb_int const idx = match_data_actual_index(mrb, self, idx_value);
+  match_data_check_index(idx);
+  mrb_value ret = mrb_ary_new_capa(mrb, 2);
+  mrb_ary_push(mrb, ret, mrb_fixnum_value(reg->beg[idx]));
+  mrb_ary_push(mrb, ret, mrb_fixnum_value(reg->end[idx]));
+  return ret;
+}
+
+// ISO 15.2.16.3.8
+static mrb_value
+match_data_post_match(mrb_state* mrb, mrb_value self) {
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+  mrb_value str = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "string"));
+  return mrb_str_substr(mrb, str, reg->end[0], RSTRING_LEN(str) - reg->end[0]);
+}
+
+// ISO 15.2.16.3.9
+static mrb_value
+match_data_pre_match(mrb_state* mrb, mrb_value self) {
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+  mrb_value str = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "string"));
+  return mrb_str_substr(mrb, str, 0, reg->beg[0]);
+}
+
+// ISO 15.2.16.3.11
+static mrb_value
+match_data_string(mrb_state* mrb, mrb_value self) {
+  return mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "string"));
+}
+
+static mrb_value
+match_data_regexp(mrb_state* mrb, mrb_value self) {
+  return mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "regexp"));
+}
+
+// ISO 15.2.16.3.12
+static mrb_value
+match_data_to_a(mrb_state* mrb, mrb_value self) {
+  mrb_value cache = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "cache"));
+  if(!mrb_nil_p(cache)) {
+    return cache;
+  }
+
+  mrb_value str = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "string"));
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+
+  mrb_value ret = mrb_ary_new_capa(mrb, reg->num_regs);
+  int i, ai = mrb_gc_arena_save(mrb);
+  for(i = 0; i < reg->num_regs; ++i) {
+    if(reg->beg[i] == ONIG_REGION_NOTPOS) {
+      mrb_ary_push(mrb, ret, mrb_nil_value());
+    } else {
+      mrb_ary_push(mrb, ret, mrb_str_substr(mrb, str, reg->beg[i], reg->end[i] - reg->beg[i]));
+    }
+    mrb_gc_arena_restore(mrb, ai);
+  }
+  return ret;
+}
+
+// ISO 15.2.16.3.13
+static mrb_value
+match_data_to_s(mrb_state* mrb, mrb_value self) {
+  mrb_value str = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "string"));
+  OnigRegion* reg;
+  Data_Get_Struct(mrb, self, &mrb_onig_region_type, reg);
+  return mrb_str_substr(mrb, str, reg->beg[0], reg->end[0] - reg->beg[0]);
+}
+
+static void
+append_replace_str(mrb_state* mrb, mrb_value result, mrb_value replace,
+                   mrb_value src, OnigRegex reg, OnigRegion* match)
+{
+  mrb_assert(mrb_string_p(replace));
+  char const* ch;
+  char const* const end = RSTRING_PTR(replace) + RSTRING_LEN(replace);
+  for(ch = RSTRING_PTR(replace); ch < end; ++ch) {
+    if (*ch != '\\' || (ch + 1) >= end) {
+      mrb_str_cat(mrb, result, ch, 1);
+      continue;
+    }
+
+    switch(*(++ch)) { // skip back slash and get next char
+      case 'k': { // group name
+        if ((ch + 2) >= end || ch[1] != '<') { goto replace_expr_error; }
+        char const* name_beg = ch += 2;
+        while (*ch != '>') { if(++ch == end) { goto replace_expr_error; } }
+        mrb_assert(ch < end);
+        mrb_assert(*ch == '>');
+        int const idx = onig_name_to_backref_number(
+            reg, (OnigUChar const*)name_beg, (OnigUChar const*)ch, match);
+        if (idx < 0) {
+          mrb_raisef(mrb, E_INDEX_ERROR, "undefined group name reference: %S",
+                     mrb_str_substr(mrb, replace, name_beg - RSTRING_PTR(replace), ch - name_beg));
+        }
+        mrb_str_cat(mrb, result, RSTRING_PTR(src) + match->beg[idx], match->end[idx] - match->beg[idx]);
+      } break;
+
+      case '\\': // escaped back slash
+        mrb_str_cat(mrb, result, ch, 1);
+        break;
+
+      default:
+        if (isdigit(*ch)) { // group number 0-9
+          int const idx = *ch - '0';
+          if (idx >= match->num_regs) {
+            mrb_raisef(mrb, E_INDEX_ERROR, "undefined group number reference: %S (max: %S)",
+                       mrb_fixnum_value(idx), mrb_fixnum_value(match->num_regs));
+          }
+          mrb_str_cat(mrb, result, RSTRING_PTR(src) + match->beg[idx], match->end[idx] - match->beg[idx]);
+        } else {
+          char const str[] = { '\\', *ch };
+          mrb_str_cat(mrb, result, str, 2);
+        }
+        break;
+    }
+  }
+
+  if(ch == end) { return; }
+
+replace_expr_error:
+  mrb_raisef(mrb, E_REGEXP_ERROR, "invalid replace expression: %S", replace);
+}
+
+// ISO 15.2.10.5.18
+static mrb_value
+string_gsub(mrb_state* mrb, mrb_value self) {
+  mrb_value blk, match_expr, replace_expr = mrb_nil_value();
+  int const argc = mrb_get_args(mrb, "&o|S", &blk, &match_expr, &replace_expr);
+
+  if(mrb_string_p(match_expr)) {
+    mrb_value argv[] = { match_expr, replace_expr };
+    return mrb_funcall_with_block(mrb, self, mrb_intern_lit(mrb, "string_gsub"), argc, argv, blk);
+  }
+
+  if(!mrb_nil_p(blk) && !mrb_nil_p(replace_expr)) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "both block and replace expression must not be passed");
+  }
+
+  OnigRegex reg;
+  Data_Get_Struct(mrb, match_expr, &mrb_onig_regexp_type, reg);
+  mrb_value const result = mrb_str_new(mrb, NULL, 0);
+  mrb_value const match_value = create_onig_region(mrb, self, match_expr);
+  OnigRegion* const match = (OnigRegion*)DATA_PTR(match_value);
+  int last_end_pos = 0;
+
+  while(1) {
+    if(onig_match_common(mrb, reg, match_value, self, last_end_pos) == ONIG_MISMATCH) { break; }
+
+    mrb_str_cat(mrb, result, RSTRING_PTR(self) + last_end_pos, match->beg[0] - last_end_pos);
+
+    if(mrb_nil_p(blk)) {
+      append_replace_str(mrb, result, replace_expr, self, reg, match);
+    } else {
+      mrb_value const tmp_str = mrb_str_to_str(mrb, mrb_yield(mrb, blk, mrb_str_substr(
+          mrb, self, match->beg[0], match->end[0] - match->beg[0])));
+      mrb_assert(mrb_string_p(tmp_str));
+      mrb_str_concat(mrb, result, tmp_str);
+    }
+
+    last_end_pos = match->end[0];
+  }
+
+  mrb_str_cat(mrb, result, RSTRING_PTR(self) + last_end_pos, RSTRING_LEN(self) - last_end_pos);
+  return result;
+}
+
+// ISO 15.2.10.5.32
+static mrb_value
+string_scan(mrb_state* mrb, mrb_value self) {
+  mrb_value blk, match_expr;
+  mrb_get_args(mrb, "&o", &blk, &match_expr);
+
+  if(mrb_string_p(match_expr)) {
+    return mrb_funcall_with_block(mrb, self, mrb_intern_lit(mrb, "string_scan"),
+                                  1, &match_expr, blk);
+  }
+
+  OnigRegex reg;
+  Data_Get_Struct(mrb, match_expr, &mrb_onig_regexp_type, reg);
+  mrb_value const result = mrb_nil_p(blk)? mrb_ary_new(mrb) : self;
+  mrb_value m_value = create_onig_region(mrb, self, match_expr);
+  OnigRegion* const m = (OnigRegion*)DATA_PTR(m_value);
+  int last_end_pos = 0;
+  int i;
+
+  while (1) {
+    if(onig_match_common(mrb, reg, m_value, self, last_end_pos) == ONIG_MISMATCH) { break; }
+
+    if(mrb_nil_p(blk)) {
+      mrb_assert(mrb_array_p(result));
+      if(m->num_regs == 1) {
+        mrb_ary_push(mrb, result, mrb_str_substr(mrb, self, m->beg[0], m->end[0] - m->beg[0]));
+      } else {
+        mrb_value const elem = mrb_ary_new_capa(mrb, m->num_regs - 1);
+        for(i = 1; i < m->num_regs; ++i) {
+          mrb_ary_push(mrb, elem, mrb_str_substr(mrb, self, m->beg[i], m->end[i] - m->beg[i]));
+        }
+        mrb_ary_push(mrb, result, elem);
+      }
+    } else { // call block
+      mrb_assert(mrb_string_p(result));
+      if(m->num_regs == 1) {
+        mrb_yield(mrb, blk, mrb_str_substr(mrb, self, m->beg[0], m->end[0] - m->beg[0]));
+      } else {
+        mrb_value argv = mrb_ary_new_capa(mrb, m->num_regs - 1);
+        for(i = 1; i < m->num_regs; ++i) {
+          mrb_ary_push(mrb, argv, mrb_str_substr(mrb, self, m->beg[i], m->end[i] - m->beg[i]));
+        }
+        mrb_yield(mrb, blk, argv);
+      }
+    }
+
+    last_end_pos = m->end[0];
+  }
+
+  return result;
+}
+
+// ISO 15.2.10.5.35
+static mrb_value
+string_split(mrb_state* mrb, mrb_value self) {
+  mrb_value pattern = mrb_nil_value(); mrb_int limit = 0;
+  int argc = mrb_get_args(mrb, "|oi", &pattern, &limit);
+
+  if(argc == 0) { // check $; global variable
+    pattern = mrb_gv_get(mrb, mrb_intern_lit(mrb, "$;"));
+    if(!mrb_nil_p(pattern)) { argc = 1; }
+  }
+
+  if(mrb_nil_p(pattern) || mrb_string_p(pattern)) {
+    return mrb_funcall(mrb, self, "string_split", argc, pattern, mrb_fixnum_value(limit));
+  }
+
+  mrb_value const result = mrb_ary_new(mrb);
+  if(RSTRING_LEN(self) == 0) { return result; }
+
+  OnigRegex reg;
+  Data_Get_Struct(mrb, pattern, &mrb_onig_regexp_type, reg);
+  mrb_value const match_value = create_onig_region(mrb, self, pattern);
+  OnigRegion* const match = (OnigRegion*)DATA_PTR(match_value);
+  int last_end_pos = 0, next_match_pos = 0;
+  mrb_int num_matches = 0;
+
+  while (limit <= 0 || (limit - 1) > num_matches) {
+    int i;
+    if(next_match_pos >= RSTRING_LEN(self) ||
+       onig_match_common(mrb, reg, match_value, self, next_match_pos) == ONIG_MISMATCH) { break; }
+
+    if (last_end_pos == match->end[0]) {
+      ++next_match_pos;
+      // Remove this loop if not using UTF-8
+      for (; next_match_pos < RSTRING_LEN(self) && (RSTRING_PTR(self)[next_match_pos] & 0xC0) == 0x80;
+          ++next_match_pos) {}
+    } else {
+      mrb_ary_push(mrb, result, mrb_str_substr(
+          mrb, self, last_end_pos, match->beg[0] - last_end_pos));
+      // If there are captures, add them to the array
+      for (i = 1; i < match->num_regs; ++i) {
+        mrb_ary_push(mrb, result, mrb_str_substr(
+            mrb, self, match->beg[i], match->end[i] - match->beg[i]));
+      }
+      last_end_pos = match->end[0];
+      next_match_pos = last_end_pos;
+      ++num_matches;
+    }
+  }
+  if (last_end_pos <= RSTRING_LEN(self)) {
+    mrb_ary_push(mrb, result, mrb_str_substr(
+        mrb, self, last_end_pos, RSTRING_LEN(self) - last_end_pos));
+  }
+
+  if (limit == 0) { // remove empty trailing elements
+    int count = 0, i;
+    for (i = RARRAY_LEN(result); i > 0; --i) {
+      mrb_assert(mrb_string_p(RARRAY_PTR(result)[i - 1]));
+      if (RSTRING_LEN(RARRAY_PTR(result)[i - 1]) != 0) { break; }
+      else { ++count; }
+    }
+    if(count > 0) {
+      return mrb_ary_new_from_values(mrb, RARRAY_LEN(result) - count, RARRAY_PTR(result));
+    }
+  }
+
+  return result;
+}
+
+// ISO 15.2.10.5.36
+static mrb_value
+string_sub(mrb_state* mrb, mrb_value self) {
+  mrb_value blk, match_expr, replace_expr = mrb_nil_value();
+  int const argc = mrb_get_args(mrb, "&o|S", &blk, &match_expr, &replace_expr);
+
+  if(mrb_string_p(match_expr)) {
+    mrb_value argv[] = { match_expr, replace_expr };
+    return mrb_funcall_with_block(mrb, self, mrb_intern_lit(mrb, "string_sub"), argc, argv, blk);
+  }
+
+  if(!mrb_nil_p(blk) && !mrb_nil_p(replace_expr)) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "both block and replace expression must not be passed");
+  }
+
+  OnigRegex reg;
+  Data_Get_Struct(mrb, match_expr, &mrb_onig_regexp_type, reg);
+  mrb_value const result = mrb_str_new(mrb, NULL, 0);
+  mrb_value const match_value = create_onig_region(mrb, self, match_expr);
+  OnigRegion* const match = (OnigRegion*)DATA_PTR(match_value);
+
+  int const onig_result = onig_match_common(mrb, reg, match_value, self, 0);
+  if(onig_result == ONIG_MISMATCH) { return self; }
+
+  mrb_str_cat(mrb, result, RSTRING_PTR(self), match->beg[0]);
+
+  if(mrb_nil_p(blk)) {
+    append_replace_str(mrb, result, replace_expr, self, reg, match);
+  } else {
+    mrb_value const tmp_str = mrb_str_to_str(mrb, mrb_yield(mrb, blk, mrb_str_substr(
+        mrb, self, match->beg[0], match->end[0] - match->beg[0])));
+    mrb_assert(mrb_string_p(tmp_str));
+    mrb_str_concat(mrb, result, tmp_str);
+  }
+
+  int const last_end_pos = match->end[0];
+  mrb_str_cat(mrb, result, RSTRING_PTR(self) + last_end_pos, RSTRING_LEN(self) - last_end_pos);
+
+  return result;
+}
+
+static mrb_value
+onig_regexp_clear_global_variables(mrb_state* mrb, mrb_value self) {
+  mrb_gv_remove(mrb, mrb_intern_lit(mrb, "$~"));
+  mrb_gv_remove(mrb, mrb_intern_lit(mrb, "$&"));
+  mrb_gv_remove(mrb, mrb_intern_lit(mrb, "$`"));
+  mrb_gv_remove(mrb, mrb_intern_lit(mrb, "$'"));
+  mrb_gv_remove(mrb, mrb_intern_lit(mrb, "$+"));
+
+  int idx;
+  for(idx = 1; idx < 10; ++idx) {
+    char const n[] = { '$', '0' + idx };
+    mrb_gv_remove(mrb, mrb_intern(mrb, n, 2));
+  }
+
+  return self;
+}
+
+static mrb_value
+onig_regexp_does_set_global_variables(mrb_state* mrb, mrb_value self) {
+  (void)self;
+  return mrb_obj_iv_get(mrb, (struct RObject*)mrb_class_get(mrb, "OnigRegexp"),
+                        mrb_intern_lit(mrb, "@set_global_variables"));
+}
+static mrb_value
+onig_regexp_set_set_global_variables(mrb_state* mrb, mrb_value self) {
+  mrb_value arg;
+  mrb_get_args(mrb, "o", &arg);
+  mrb_value const ret = mrb_bool_value(mrb_bool(arg));
+  mrb_obj_iv_set(mrb, (struct RObject*)mrb_class_get(mrb, "OnigRegexp"),
+                 mrb_intern_lit(mrb, "@set_global_variables"), ret);
+  onig_regexp_clear_global_variables(mrb, self);
+  return ret;
+}
+
+// ISO 15.2.15.6.2
+static mrb_value
+onig_regexp_escape(mrb_state* mrb, mrb_value self) {
+  char* str_begin; mrb_args_int str_len;
+  mrb_get_args(mrb, "s", &str_begin, &str_len);
+
+  mrb_value const ret = mrb_str_new(mrb, NULL, 0);
+  char escaped_char = 0;
+  int substr_count = 0;
+  char const* str = str_begin;
+
+  for(; str < (str_begin + str_len); ++str) {
+    switch(*str) {
+      case '\n': escaped_char = 'n'; break;
+      case '\t': escaped_char = 't'; break;
+      case '\r': escaped_char = 'r'; break;
+      case '\f': escaped_char = 'f'; break;
+
+      case ' ':
+      case '#':
+      case '$':
+      case '(':
+      case ')':
+      case '*':
+      case '+':
+      case '-':
+      case '.':
+      case '?':
+      case '[':
+      case '\\':
+      case ']':
+      case '^':
+      case '{':
+      case '|':
+      case '}':
+        escaped_char = *str; break;
+
+      default: ++substr_count; continue;
+    }
+
+    mrb_str_cat(mrb, ret, str - substr_count, substr_count);
+    substr_count = 0;
+
+    char const c[] = { '\\', escaped_char };
+    mrb_str_cat(mrb, ret, c, 2);
+  }
+  mrb_str_cat(mrb, ret, str - substr_count, substr_count);
+  return ret;
+}
+
+void
+mrb_mruby_onig_regexp_gem_init(mrb_state* mrb) {
+  struct RClass *clazz;
+
+  clazz = mrb_define_class(mrb, "OnigRegexp", mrb->object_class);
+  MRB_SET_INSTANCE_TT(clazz, MRB_TT_DATA);
+
+  // enable global variables setting in onig_match_common by default
+  mrb_obj_iv_set(mrb, (struct RObject*)clazz, mrb_intern_lit(mrb, "@set_global_variables"), mrb_true_value());
+
+  mrb_define_const(mrb, clazz, "IGNORECASE", mrb_fixnum_value(ONIG_OPTION_IGNORECASE));
+  mrb_define_const(mrb, clazz, "EXTENDED", mrb_fixnum_value(ONIG_OPTION_EXTEND));
+  mrb_define_const(mrb, clazz, "MULTILINE", mrb_fixnum_value(ONIG_OPTION_MULTILINE));
+  mrb_define_const(mrb, clazz, "SINGLELINE", mrb_fixnum_value(ONIG_OPTION_SINGLELINE));
+  mrb_define_const(mrb, clazz, "FIND_LONGEST", mrb_fixnum_value(ONIG_OPTION_FIND_LONGEST));
+  mrb_define_const(mrb, clazz, "FIND_NOT_EMPTY", mrb_fixnum_value(ONIG_OPTION_FIND_NOT_EMPTY));
+  mrb_define_const(mrb, clazz, "NEGATE_SINGLELINE", mrb_fixnum_value(ONIG_OPTION_NEGATE_SINGLELINE));
+  mrb_define_const(mrb, clazz, "DONT_CAPTURE_GROUP", mrb_fixnum_value(ONIG_OPTION_DONT_CAPTURE_GROUP));
+  mrb_define_const(mrb, clazz, "CAPTURE_GROUP", mrb_fixnum_value(ONIG_OPTION_CAPTURE_GROUP));
+  mrb_define_const(mrb, clazz, "NOTBOL", mrb_fixnum_value(ONIG_OPTION_NOTBOL));
+  mrb_define_const(mrb, clazz, "NOTEOL", mrb_fixnum_value(ONIG_OPTION_NOTEOL));
+  mrb_define_const(mrb, clazz, "POSIX_REGION", mrb_fixnum_value(ONIG_OPTION_POSIX_REGION));
+#ifdef ONIG_OPTION_ASCII_RANGE
+  mrb_define_const(mrb, clazz, "ASCII_RANGE", mrb_fixnum_value(ONIG_OPTION_ASCII_RANGE));
+#endif
+#ifdef ONIG_OPTION_POSIX_BRACKET_ALL_RANGE
+  mrb_define_const(mrb, clazz, "POSIX_BRACKET_ALL_RANGE", mrb_fixnum_value(ONIG_OPTION_POSIX_BRACKET_ALL_RANGE));
+#endif
+#ifdef ONIG_OPTION_WORD_BOUND_ALL_RANGE
+  mrb_define_const(mrb, clazz, "WORD_BOUND_ALL_RANGE", mrb_fixnum_value(ONIG_OPTION_WORD_BOUND_ALL_RANGE));
+#endif
+#ifdef ONIG_OPTION_NEWLINE_CRLF
+  mrb_define_const(mrb, clazz, "NEWLINE_CRLF", mrb_fixnum_value(ONIG_OPTION_NEWLINE_CRLF));
+#endif
+#ifdef ONIG_OPTION_NOTBOS
+  mrb_define_const(mrb, clazz, "NOTBOS", mrb_fixnum_value(ONIG_OPTION_NOTBOS));
+#endif
+#ifdef ONIG_OPTION_NOTEOS
+  mrb_define_const(mrb, clazz, "NOTEOS", mrb_fixnum_value(ONIG_OPTION_NOTEOS));
+#endif
+
+  mrb_define_method(mrb, clazz, "initialize", onig_regexp_initialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(2));
+  mrb_define_method(mrb, clazz, "==", onig_regexp_equal, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, clazz, "match", onig_regexp_match, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
+  mrb_define_method(mrb, clazz, "casefold?", onig_regexp_casefold_p, MRB_ARGS_NONE());
+
+  mrb_define_method(mrb, clazz, "options", onig_regexp_options, MRB_ARGS_NONE());
+  mrb_define_method(mrb, clazz, "inspect", onig_regexp_inspect, MRB_ARGS_NONE());
+  mrb_define_method(mrb, clazz, "to_s", onig_regexp_to_s, MRB_ARGS_NONE());
+
+  mrb_define_module_function(mrb, clazz, "escape", onig_regexp_escape, MRB_ARGS_REQ(1));
+  mrb_define_module_function(mrb, clazz, "quote", onig_regexp_escape, MRB_ARGS_REQ(1));
+  mrb_define_module_function(mrb, clazz, "version", onig_regexp_version, MRB_ARGS_NONE());
+  mrb_define_module_function(mrb, clazz, "set_global_variables?", onig_regexp_does_set_global_variables, MRB_ARGS_NONE());
+  mrb_define_module_function(mrb, clazz, "set_global_variables=", onig_regexp_set_set_global_variables, MRB_ARGS_REQ(1));
+  mrb_define_module_function(mrb, clazz, "clear_global_variables", onig_regexp_clear_global_variables, MRB_ARGS_NONE());
+
+  struct RClass* match_data = mrb_define_class(mrb, "OnigMatchData", mrb->object_class);
+  MRB_SET_INSTANCE_TT(clazz, MRB_TT_DATA);
+  mrb_undef_class_method(mrb, match_data, "new");
+
+  // mrb_define_method(mrb, match_data, "==", &match_data_eq);
+  mrb_define_method(mrb, match_data, "[]", &match_data_index, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, match_data, "begin", &match_data_begin, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, match_data, "captures", &match_data_captures, MRB_ARGS_NONE());
+  mrb_define_method(mrb, match_data, "end", &match_data_end, MRB_ARGS_REQ(1));
+  // mrb_define_method(mrb, match_data, "eql?", &match_data_eq);
+  // mrb_define_method(mrb, match_data, "hash", &match_data_hash);
+  mrb_define_method(mrb, match_data, "initialize_copy", &match_data_copy, MRB_ARGS_REQ(1));
+  // mrb_define_method(mrb, match_data, "inspect", &match_data_inspect);
+  mrb_define_method(mrb, match_data, "length", &match_data_length, MRB_ARGS_NONE());
+  // mrb_define_method(mrb, match_data, "names", &match_data_names);
+  mrb_define_method(mrb, match_data, "offset", &match_data_offset, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, match_data, "post_match", &match_data_post_match, MRB_ARGS_NONE());
+  mrb_define_method(mrb, match_data, "pre_match", &match_data_pre_match, MRB_ARGS_NONE());
+  mrb_define_method(mrb, match_data, "regexp", &match_data_regexp, MRB_ARGS_NONE());
+  mrb_define_method(mrb, match_data, "size", &match_data_length, MRB_ARGS_NONE());
+  mrb_define_method(mrb, match_data, "string", &match_data_string, MRB_ARGS_NONE());
+  mrb_define_method(mrb, match_data, "to_a", &match_data_to_a, MRB_ARGS_NONE());
+  mrb_define_method(mrb, match_data, "to_s", &match_data_to_s, MRB_ARGS_NONE());
+  // mrb_define_method(mrb, match_data, "values_at", &match_data_values_at);
+
+  mrb_define_method(mrb, mrb->string_class, "onig_regexp_gsub", &string_gsub, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1) | MRB_ARGS_BLOCK());
+  mrb_define_method(mrb, mrb->string_class, "onig_regexp_sub", &string_sub, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1) | MRB_ARGS_BLOCK());
+  mrb_define_method(mrb, mrb->string_class, "onig_regexp_split", &string_split, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, mrb->string_class, "onig_regexp_scan", &string_scan, MRB_ARGS_REQ(1) | MRB_ARGS_BLOCK());
+}
+
+void
+mrb_mruby_onig_regexp_gem_final(mrb_state* mrb) {
+  (void)mrb;
+}
+
+// vim:set et:
Index: /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/test/mruby_onig_regexp.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/test/mruby_onig_regexp.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-onig-regexp/test/mruby_onig_regexp.rb	(revision 279)
@@ -0,0 +1,396 @@
+
+# Constant
+assert("OnigRegexp::CONSTANT") do
+  OnigRegexp::IGNORECASE == 1 and OnigRegexp::EXTENDED == 2 and OnigRegexp::MULTILINE == 4
+end
+
+
+# Class method
+assert('OnigRgexp.compile', '15.2.15.6.2') do
+  assert_equal OnigRegexp.compile('.*'), OnigRegexp.compile('.*')
+end
+
+assert('OnigRegexp.escape', '15.2.15.6.2') do
+  escaping_chars = "\n\t\r\f #$()*+-.?[\\]^{|}"
+  assert_equal '\n\t\r\f\\ \#\$\(\)\*\+\-\.\?\[\\\\\]\^\{\|\}', OnigRegexp.escape(escaping_chars)
+  assert_equal 'cute\nmruby\tcute', OnigRegexp.escape("cute\nmruby\tcute")
+end
+
+assert('OnigRegexp.last_match', '15.2.15.6.3') do
+  OnigRegexp.new('.*') =~ 'ginka'
+  assert_equal 'ginka', OnigRegexp.last_match[0]
+end
+
+assert('OnigRegexp.quote', '15.2.15.6.4') do
+  assert_equal '\n', OnigRegexp.quote("\n")
+end
+
+# Instance method
+assert('OnigRegexp#initialize', '15.2.15.7.1') do
+  OnigRegexp.new(".*") and OnigRegexp.new(".*", OnigRegexp::MULTILINE)
+end
+
+assert('OnigRegexp#initialize_copy', '15.2.15.7.2') do
+  r1 = OnigRegexp.new(".*")
+  r2 = r1.dup
+  assert_equal r1, r2
+  assert_equal 'kawa', r2.match('kawa')[0]
+end
+
+assert("OnigRegexp#==", '15.2.15.7.3') do
+  reg1 = reg2 = OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+")
+  reg3 = OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+")
+  reg4 = OnigRegexp.new("(https://[^/]+)[-a-zA-Z0-9./]+")
+
+  assert_true(reg1 == reg2 && reg1 == reg3 && !(reg1 == reg4))
+
+  assert_false(OnigRegexp.new("a") == "a")
+end
+
+assert("OnigRegexp#===", '15.2.15.7.4') do
+  reg = OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+")
+  assert_true reg === "http://example.com"
+  assert_false reg === "htt://example.com"
+end
+
+assert('OnigRegexp#=~', '15.2.15.7.5') do
+  assert_equal(0) { OnigRegexp.new('.*') =~ 'akari' }
+  assert_equal(nil) { OnigRegexp.new('t') =~ 'akari' }
+end
+
+assert("OnigRegexp#casefold?", '15.2.15.7.6') do
+  assert_false OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+", OnigRegexp::MULTILINE).casefold?
+  assert_true OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+", OnigRegexp::IGNORECASE | OnigRegexp::EXTENDED).casefold?
+  assert_true OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+", OnigRegexp::MULTILINE | OnigRegexp::IGNORECASE).casefold?
+  assert_false OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+").casefold?
+  assert_true OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+", true).casefold?
+end
+
+assert("OnigRegexp#match", '15.2.15.7.7') do
+  reg = OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+")
+  assert_false reg.match("http://masamitsu-murase.12345/hoge.html").nil?
+  assert_nil reg.match("http:///masamitsu-murase.12345/hoge.html")
+end
+
+assert("OnigRegexp#source", '15.2.15.7.8') do
+  str = "(https?://[^/]+)[-a-zA-Z0-9./]+"
+  reg = OnigRegexp.new(str)
+
+  reg.source == str
+end
+
+if OnigRegexp.const_defined? :ASCII_RANGE
+  assert('OnigRegexp#options (no options)') do
+    assert_equal OnigRegexp::ASCII_RANGE | OnigRegexp::POSIX_BRACKET_ALL_RANGE | OnigRegexp::WORD_BOUND_ALL_RANGE, OnigRegexp.new(".*").options
+  end
+
+  assert('OnigRegexp#options (multiline)') do
+    assert_equal OnigRegexp::MULTILINE | OnigRegexp::ASCII_RANGE | OnigRegexp::POSIX_BRACKET_ALL_RANGE | OnigRegexp::WORD_BOUND_ALL_RANGE, OnigRegexp.new(".*", OnigRegexp::MULTILINE).options
+  end
+end
+
+assert("OnigRegexp#inspect") do
+  reg = OnigRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+")
+
+  assert_equal '/(https?:\/\/[^\/]+)[-a-zA-Z0-9.\/]+/', reg.inspect
+  assert_equal '/abc\nd\te/mi', OnigRegexp.new("abc\nd\te", OnigRegexp::MULTILINE | OnigRegexp::IGNORECASE).inspect
+  assert_equal '/abc/min', OnigRegexp.new("abc", OnigRegexp::MULTILINE | OnigRegexp::IGNORECASE, "none").inspect
+end
+
+assert("OnigRegexp#to_s") do
+  assert_equal '(?-mix:ab+c)', OnigRegexp.new("ab+c").to_s
+  assert_equal '(?-mix:ab+c)', /ab+c/.to_s
+  assert_equal '(?mx-i:ab+c)', OnigRegexp.new("ab+c", OnigRegexp::MULTILINE | OnigRegexp::EXTENDED).to_s
+  assert_equal '(?mi-x:ab+c)', /ab+c/im.to_s
+  assert_equal '(?mi-x:ab+c)', /ab+c/imn.to_s
+end
+
+assert("OnigRegexp#to_s (composition)") do
+  re1 = OnigRegexp.new("ab+c")
+  re2 = OnigRegexp.new("xy#{re1}z")
+  assert_equal '(?-mix:xy(?-mix:ab+c)z)', re2.to_s
+
+  re3 = OnigRegexp.new("ab.+c", OnigRegexp::MULTILINE)
+  re4 = OnigRegexp.new("xy#{re3}z", OnigRegexp::IGNORECASE)
+  assert_equal '(?i-mx:xy(?m-ix:ab.+c)z)', re4.to_s
+end
+
+# Extended patterns.
+assert("OnigRegexp#match (no flags)") do
+  [
+    [ ".*", "abcd\nefg", "abcd" ],
+    [ "^a.", "abcd\naefg", "ab" ],
+    [ "^a.", "bacd\naefg", "ae" ],
+    [ ".$", "bacd\naefg", "d" ]
+  ].each do |reg, str, result|
+    m = OnigRegexp.new(reg).match(str)
+    assert_equal result, m[0] if assert_false m.nil?
+  end
+end
+
+assert("OnigRegexp#match (multiline)") do
+  patterns = [
+    [ OnigRegexp.new(".*", OnigRegexp::MULTILINE), "abcd\nefg", "abcd\nefg" ]
+  ]
+
+  patterns.all?{ |reg, str, result| reg.match(str)[0] == result }
+end
+
+assert("OnigRegexp#match (ignorecase)") do
+  [
+    [ "aBcD", "00AbcDef", "AbcD" ],
+    [ "0x[a-f]+", "00XaBCdefG", "0XaBCdef" ],
+    [ "0x[^c-f]+", "00XaBCdefG", "0XaB" ]
+  ].each do |reg, str, result|
+    m = OnigRegexp.new(reg, OnigRegexp::IGNORECASE|OnigRegexp::EXTENDED).match(str)
+    assert_equal result, m[0] if assert_false m.nil?
+  end
+end
+
+assert("OnigRegexp#match (none encoding)") do
+  assert_equal 2, /\x82/n =~ "ã"
+end
+
+assert('OnigRegexp.version') do
+  OnigRegexp.version.kind_of? String
+end
+
+def onig_match_data_example
+  OnigRegexp.new('(\w+)(\w)').match('+aaabb-')
+end
+
+assert('OnigMatchData.new') do
+  assert_raise(NoMethodError) { OnigMatchData.new('aaa', 'i') }
+end
+
+assert('OnigMatchData#[]', '15.2.16.3.1') do
+  m = onig_match_data_example
+  assert_equal 'aaabb', m[0]
+  assert_equal 'aaab', m[1]
+  assert_equal 'b', m[2]
+  assert_nil m[3]
+
+  m = OnigRegexp.new('(?<name>\w\w)').match('aba')
+  assert_raise(TypeError) { m[[]] }
+  assert_raise(IndexError) { m['nam'] }
+  assert_equal 'ab', m[:name]
+  assert_equal 'ab', m['name']
+  assert_equal 'ab', m[1]
+
+  m = OnigRegexp.new('(\w) (\w) (\w) (\w)').match('a b c d')
+  assert_equal %w(a b c d), m[1..-1]
+end
+
+assert('OnigMatchData#begin', '15.2.16.3.2') do
+  m = onig_match_data_example
+  assert_equal 1, m.begin(0)
+  assert_equal 1, m.begin(1)
+  assert_raise(IndexError) { m.begin 3 }
+end
+
+assert('OnigMatchData#captures', '15.2.16.3.3') do
+  m = onig_match_data_example
+  assert_equal ['aaab', 'b'], m.captures
+
+  m = OnigRegexp.new('(\w+)(\d)?').match('+aaabb-')
+  assert_equal ['aaabb', nil], m.captures
+end
+
+assert('OnigMatchData#end', '15.2.16.3.4') do
+  m = onig_match_data_example
+  assert_equal 6, m.end(0)
+  assert_equal 5, m.end(1)
+  assert_raise(IndexError) { m.end 3 }
+end
+
+assert('OnigMatchData#initialize_copy', '15.2.16.3.5') do
+  m = onig_match_data_example
+  c = m.dup
+  assert_equal m.to_a, c.to_a
+end
+
+assert('OnigMatchData#length', '15.2.16.3.6') do
+  assert_equal 3, onig_match_data_example.length
+end
+
+assert('OnigMatchData#offset', '15.2.16.3.7') do
+  assert_equal [1, 6], onig_match_data_example.offset(0)
+  assert_equal [1, 5], onig_match_data_example.offset(1)
+end
+
+assert('OnigMatchData#post_match', '15.2.16.3.8') do
+  assert_equal '-', onig_match_data_example.post_match
+end
+
+assert('OnigMatchData#pre_match', '15.2.16.3.9') do
+  assert_equal '+', onig_match_data_example.pre_match
+end
+
+assert('OnigMatchData#size', '15.2.16.3.10') do
+  assert_equal 3, onig_match_data_example.length
+end
+
+assert('OnigMatchData#string', '15.2.16.3.11') do
+  assert_equal '+aaabb-', onig_match_data_example.string
+end
+
+assert('OnigMatchData#to_a', '15.2.16.3.12') do
+  assert_equal ['aaabb', 'aaab', 'b'], onig_match_data_example.to_a
+end
+
+assert('OnigMatchData#to_s', '15.2.16.3.13') do
+  assert_equal 'aaabb', onig_match_data_example.to_s
+end
+
+assert('OnigMatchData#regexp') do
+  assert_equal '(\w+)(\w)', onig_match_data_example.regexp.source
+end
+
+assert('Invalid regexp') do
+  assert_raise(ArgumentError) { OnigRegexp.new '[aio' }
+end
+
+assert('String#onig_regexp_gsub') do
+  test_str = 'hello mruby'
+  assert_equal 'h*ll* mr*by', test_str.onig_regexp_gsub(OnigRegexp.new('[aeiou]'), '*')
+  assert_equal 'h<e>ll<o> mr<u>by', test_str.onig_regexp_gsub(OnigRegexp.new('([aeiou])'), '<\1>')
+  assert_equal 'h e l l o  m r u b y ', test_str.onig_regexp_gsub(OnigRegexp.new('\w')) { |v| v + ' ' }
+  assert_equal 'h{e}ll{o} mr{u}by', test_str.onig_regexp_gsub(OnigRegexp.new('(?<hoge>[aeiou])'), '{\k<hoge>}')
+  assert_raise(IndexError) { test_str.onig_regexp_gsub(OnigRegexp.new('(mruby)'), '<\2>') }
+end
+
+assert('String#onig_regexp_scan') do
+  test_str = 'mruby world'
+  assert_equal ['mruby', 'world'], test_str.onig_regexp_scan(OnigRegexp.new('\w+'))
+  assert_equal ['mru', 'by ', 'wor'], test_str.onig_regexp_scan(OnigRegexp.new('...'))
+  assert_equal [['mru'], ['by '], ['wor']], test_str.onig_regexp_scan(OnigRegexp.new('(...)'))
+  assert_equal [['mr', 'ub'], ['y ', 'wo']], test_str.onig_regexp_scan(OnigRegexp.new('(..)(..)'))
+
+  result = []
+  assert_equal test_str, test_str.onig_regexp_scan(OnigRegexp.new('\w+')) { |v| result << "<<#{v}>>" }
+  assert_equal ['<<mruby>>', '<<world>>'], result
+
+  result = ''
+  assert_equal test_str, test_str.onig_regexp_scan(OnigRegexp.new('(.)(.)')) { |x, y| result += y; result += x }
+  assert_equal 'rmbu yowlr', result
+end
+
+assert('String#onig_regexp_sub') do
+  test_str = 'hello mruby'
+  assert_equal 'h*llo mruby', test_str.onig_regexp_sub(OnigRegexp.new('[aeiou]'), '*')
+  assert_equal 'h<e>llo mruby', test_str.onig_regexp_sub(OnigRegexp.new('([aeiou])'), '<\1>')
+  assert_equal 'h ello mruby', test_str.onig_regexp_sub(OnigRegexp.new('\w')) { |v| v + ' ' }
+  assert_equal 'h{e}llo mruby', test_str.onig_regexp_sub(OnigRegexp.new('(?<hoge>[aeiou])'), '{\k<hoge>}')
+end
+
+assert('String#onig_regexp_split') do
+  test_str = 'cute mruby cute'
+  assert_equal ['cute', 'mruby', 'cute'], test_str.onig_regexp_split
+  assert_equal ['cute', 'mruby', 'cute'], test_str.onig_regexp_split(OnigRegexp.new(' '))
+
+  prev_splitter = $;
+  $; = OnigRegexp.new ' \w'
+  assert_equal ['cute', 'ruby', 'ute'], test_str.onig_regexp_split
+  $; = 't'
+  assert_equal ['cu', 'e mruby cu', 'e'], test_str.onig_regexp_split
+  $; = prev_splitter
+
+  assert_equal ['h', 'e', 'l', 'l', 'o'], 'hello'.onig_regexp_split(OnigRegexp.new(''))
+  assert_equal ['h', 'e', 'llo'], 'hello'.onig_regexp_split(OnigRegexp.new(''), 3)
+  assert_equal ['h', 'i', 'd', 'a', 'd'], 'hi dad'.onig_regexp_split(OnigRegexp.new('\s*'))
+
+  test_str = '1, 2, 3, 4, 5,, 6'
+  assert_equal ['1', '2', '3', '4', '5', '', '6'], test_str.onig_regexp_split(OnigRegexp.new(',\s*'))
+
+  test_str = '1,,2,3,,4,,'
+  assert_equal ['1', '', '2', '3', '', '4'], test_str.onig_regexp_split(OnigRegexp.new(','))
+  assert_equal ['1', '', '2', '3,,4,,'], test_str.onig_regexp_split(OnigRegexp.new(','), 4)
+  assert_equal ['1', '', '2', '3', '', '4', '', ''], test_str.onig_regexp_split(OnigRegexp.new(','), -4)
+
+  assert_equal [], ''.onig_regexp_split(OnigRegexp.new(','), -1)
+end
+
+assert('String#index') do
+  assert_equal 0, 'abc'.index('a')
+  assert_nil 'abc'.index('d')
+  assert_equal 3, 'abcabc'.index('a', 1)
+  assert_equal 1, "hello".index(?e)
+
+  assert_equal 0, 'abcabc'.index(/a/)
+  assert_nil 'abc'.index(/d/)
+  assert_equal 3, 'abcabc'.index(/a/, 1)
+  assert_equal 4, "hello".index(/[aeiou]/, -3)
+  assert_equal 3, "regexpindex".index(/e.*x/, 2)
+end
+
+prev_regexp = Regexp
+
+Regexp = OnigRegexp
+
+# global variables
+assert('$~') do
+  m = onig_match_data_example
+  assert_equal m[0], $~[0]
+end
+
+assert('$&') do
+  m = onig_match_data_example
+  assert_equal m[0], $&
+end
+
+assert('$`') do
+  m = onig_match_data_example
+  assert_equal m.pre_match, $`
+end
+
+assert('$\'') do
+  m = onig_match_data_example
+  assert_equal m.post_match, $'
+end
+
+assert('$+') do
+  m = onig_match_data_example
+  assert_equal m[-1], $+
+end
+
+assert('$1 to $9') do
+  onig_match_data_example
+  assert_equal 'aaab', $1
+  assert_equal 'b', $2
+  assert_nil $3
+  assert_nil $4
+  assert_nil $5
+  assert_nil $6
+  assert_nil $7
+  assert_nil $8
+  assert_nil $9
+end
+
+assert('default OnigRegexp.set_global_variables?') do
+  assert_true OnigRegexp.set_global_variables?
+end
+
+assert('change set_global_variables') do
+  m = onig_match_data_example
+  assert_equal m[0], $~[0]
+
+  OnigRegexp.set_global_variables = false
+  assert_false OnigRegexp.set_global_variables?
+
+  # global variables must be cleared when OnigRegexp.set_global_variables gets change
+  assert_nil $~
+
+  onig_match_data_example
+  assert_nil $~
+
+  OnigRegexp.set_global_variables = true
+end
+
+Regexp = Object
+
+assert('OnigRegexp not default') do
+  onig_match_data_example
+  assert_nil $~
+end
+
+Regexp = prev_regexp
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/.gitignore
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/.gitignore	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/.gitignore	(revision 279)
@@ -0,0 +1,5 @@
+gem_*
+gem-*
+mrb-*.a
+src/*.o
+/tmp
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/.travis.yml
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/.travis.yml	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/.travis.yml	(revision 279)
@@ -0,0 +1,2 @@
+script:
+  - "ruby run_test.rb all test"
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/README.md
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/README.md	(revision 279)
@@ -0,0 +1,67 @@
+mruby-pack (pack / unpack)
+=========
+
+mruby-pack provides `Array#pack` and `String#unpack` for mruby.
+
+
+## Installation
+Add the line below into your `build_config.rb`:
+
+```
+  conf.gem :github => 'iij/mruby-pack'
+```
+
+There is no dependency on other mrbgems.
+
+
+## Supported template string
+ - A : arbitrary binary string (space padded, count is width)
+ - a : arbitrary binary string (null padded, count is width)
+ - C : 8-bit unsigned (unsigned char)
+ - c : 8-bit signed (signed char)
+ - D, d: 64-bit float, native format
+ - E : 64-bit float, little endian byte order
+ - e : 32-bit float, little endian byte order
+ - F, f: 32-bit float, native format
+ - G : 64-bit float, network (big-endian) byte order
+ - g : 32-bit float, network (big-endian) byte order
+ - H : hex string (high nibble first)
+ - h : hex string (low nibble first)
+ - I : unsigned integer, native endian (`unsigned int` in C)
+ - i : signed integer, native endian (`int` in C)
+ - L : 32-bit unsigned, native endian (`uint32_t`)
+ - l : 32-bit signed, native endian (`int32_t`)
+ - m : base64 encoded string (see RFC 2045, count is width)
+ - N : 32-bit unsigned, network (big-endian) byte order
+ - n : 16-bit unsigned, network (big-endian) byte order
+ - Q : 64-bit unsigned, native endian (`uint64_t`)
+ - q : 64-bit signed, native endian (`int64_t`)
+ - S : 16-bit unsigned, native endian (`uint16_t`)
+ - s : 16-bit signed, native endian (`int16_t`)
+ - V : 32-bit unsigned, VAX (little-endian) byte order
+ - v : 16-bit unsigned, VAX (little-endian) byte order
+ - Z : same as "a", except that null is added with *
+
+
+## License
+
+Copyright (c) 2012 Internet Initiative Japan Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a 
+copy of this software and associated documentation files (the "Software"), 
+to deal in the Software without restriction, including without limitation 
+the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+and/or sell copies of the Software, and to permit persons to whom the 
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in 
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+DEALINGS IN THE SOFTWARE.
+
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/mrbgem.rake	(revision 279)
@@ -0,0 +1,6 @@
+MRuby::Gem::Specification.new('mruby-pack') do |spec|
+  spec.license = 'MIT'
+  spec.authors = 'Internet Initiative Japan Inc.'
+
+  spec.cc.include_paths << "#{build.root}/src"
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/packtest.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/packtest.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/packtest.rb	(revision 279)
@@ -0,0 +1,157 @@
+# encoding: ascii
+
+# a = Array, s = String, t = Template
+
+def packtest(a, s, t)
+  begin
+    r = a.pack(t)
+    return if r == s
+    puts "#{a.inspect}.pack(#{t.inspect}) -> #{r.inspect} should be #{s.inspect}"
+  rescue => r
+    unless r.is_a? s
+      puts "#{a.inspect}.pack(#{t.inspect}) -> #{r.inspect} should be #{s.inspect}"
+    end
+  end
+end
+
+def unpacktest(a, s, t)
+  r = s.unpack(t)
+  return if r == a
+  puts "#{s.inspect}.unpack(#{t.inspect}) -> #{r.inspect} should be #{a.inspect}"
+end
+
+def pptest(a, s, t)
+  packtest(a, s, t)
+  unpacktest(a, s, t)
+end
+
+pptest [1], "\x01", "C"
+
+packtest [1.1], "\x01", "C"
+packtest [-1], "\xff", "C"
+packtest [1,2], "\x01\x02", "C2"
+#packtest [1], "X", ArgumentError
+
+unpacktest [48, nil], "0", "CC"
+unpacktest [160, -96], "\xa0\xa0", "Cc"
+unpacktest [49, 50, 51], "123", "C*"
+
+pptest [12849], "12", "S"
+unpacktest [nil], "0", "S"
+unpacktest [12849, nil], "123", "SS"
+unpacktest [12849], "123", "S*"
+
+pptest [10000], "\x27\x10", "s>"
+pptest [-10000], "\xd8\xf0", "s>"
+pptest [50000], "\xc3\x50", "S>"
+
+pptest [10000], "\x10\x27", "s<"
+pptest [-10000], "\xf0\xd8", "s<"
+pptest [50000], "\x50\xc3", "S<"
+
+pptest [1000000000], "\x3b\x9a\xca\x00", "l>"
+pptest [-1000000000], "\xc4\x65\x36\x00", "l>"
+
+pptest [1], "\x01\x00\x00\x00", "L<"
+pptest [258], "\x02\x01\x00\x00", "L<"
+pptest [66051], "\x03\x02\x01\x00", "L<"
+pptest [16909060], "\x04\x03\x02\x01", "L<"
+pptest [16909060], "\x01\x02\x03\x04", "L>"
+
+packtest [-1], "\xff\xff\xff\xff", "L<"
+
+pptest [1000000000], "\x00\x00\x00\x00\x3b\x9a\xca\x00", "q>"
+pptest [-1000000000], "\xff\xff\xff\xff\xc4\x65\x36\x00", "q>"
+
+if (2**33).is_a? Fixnum
+  pptest [81985529216486895],    "\x01\x23\x45\x67\x89\xab\xcd\xef", "q>"
+  pptest [-1167088121787636991], "\x01\x23\x45\x67\x89\xab\xcd\xef", "q<"
+end
+
+pptest [16909060], "\x01\x02\x03\x04", "N"
+pptest [258], "\x01\x02", "n"
+pptest [32769], "\x80\x01", "n"
+
+pptest [16909060], "\x04\x03\x02\x01", "V"
+pptest [258], "\x02\x01", "v"
+
+packtest [""], "", "m"
+packtest ["a"], "YQ==\n", "m"
+packtest ["ab"], "YWI=\n", "m"
+packtest ["abc"], "YWJj\n", "m"
+packtest ["abcd"], "YWJjZA==\n", "m"
+
+unpacktest [""], "", "m"
+unpacktest ["a"], "YQ==\n", "m"
+unpacktest ["ab"], "YWI=\n", "m"
+unpacktest ["abc"], "YWJj\n", "m"
+unpacktest ["abcd"], "YWJjZA==\n", "m"
+
+packtest [""], "\0", "H"
+packtest ["3"], "0", "H"
+packtest ["34"], "", "H0"
+packtest ["34"], "0", "H"
+packtest ["34"], "4", "H2"
+packtest ["34"], "4\0", "H3"
+packtest ["3456"], "4P", "H3"
+packtest ["34563"], "4V0", "H*"
+packtest ["5a"], "Z", "H*"
+packtest ["5A"], "Z", "H*"
+
+unpacktest [""], "", "H"
+unpacktest [""], "0", "H0"
+unpacktest ["3"], "0", "H"
+unpacktest ["30"], "0", "H2"
+unpacktest ["30"], "0", "H3"
+unpacktest ["303"], "01", "H3"
+unpacktest ["303132"], "012", "H*"
+unpacktest ["3031", 50], "012", "H4C"
+unpacktest ["5a"], "Z", "H*"
+
+packtest [""], "\0", "h"
+packtest ["3"], "\03", "h"
+packtest ["34"], "", "h0"
+packtest ["34"], "\03", "h"
+packtest ["34"], "C", "h2"
+packtest ["34"], "C\0", "h3"
+packtest ["3456"], "C\05", "h3"
+packtest ["34563"], "Ce\03", "h*"
+
+packtest   [""],    " ",   "A"
+unpacktest [""],    "",    "A"
+pptest     ["1"],   "1",   "A"
+pptest     ["1"],   "1 ",  "A2"
+unpacktest ["1"],   "1",   "A2"
+unpacktest ["1"],   "1 ",  "A2"
+unpacktest ["1"],   "1\0", "A2"
+packtest   ["12"],  "1",   "A"
+unpacktest ["1"],   "12",  "A"
+pptest     ["123"], "123", "A*"
+packtest   ["1","2"], "2", "A0A"
+unpacktest ["","2"],  "2", "A0A"
+
+packtest   [""],    "\0",  "a"
+unpacktest [""],    "",    "a"
+pptest     ["1"],   "1",   "a"
+pptest     ["1 "],  "1 ",  "a2"
+pptest     ["1\0"], "1\0", "a2"
+packtest   ["1"],   "1\0", "a2"
+pptest     ["123"], "123", "a*"
+
+packtest   [""],    "\0",    "Z"
+unpacktest [""],    "",      "Z"
+pptest     ["1"],   "1",     "Z"
+pptest     ["1"],   "1\0",   "Z2"
+pptest     ["1 "],  "1 ",    "Z2"
+pptest     ["123"], "123\0", "Z*"
+pptest     ["1","2"], "12",      "ZZ"
+pptest     ["1","2"], "1\0002",  "Z*Z"
+unpacktest ["1","3"], "1\00023", "Z3Z"
+
+packtest   [1, 2], "\x01\x02", "CyC"
+
+packtest   [65], "A", 'U'
+packtest   [59411], "\xEE\xA0\x93", 'U'
+
+pptest     [1], "\x00\x01", "xC"
+unpacktest [2], "\xcc\x02", "xC"
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/run_test.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/run_test.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/run_test.rb	(revision 279)
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# mrbgems test runner
+#
+
+gemname = File.basename(File.dirname(File.expand_path __FILE__))
+
+if __FILE__ == $0
+  repository, dir = 'https://github.com/mruby/mruby.git', 'tmp/mruby'
+  build_args = ARGV
+  build_args = ['all', 'test']  if build_args.nil? or build_args.empty?
+
+  Dir.mkdir 'tmp'  unless File.exist?('tmp')
+  unless File.exist?(dir)
+    system "git clone #{repository} #{dir}"
+  end
+
+  exit system(%Q[cd #{dir}; MRUBY_CONFIG=#{File.expand_path __FILE__} ruby minirake #{build_args.join(' ')}])
+end
+
+MRuby::Build.new do |conf|
+  toolchain :gcc
+  conf.gembox 'default'
+
+  conf.gem File.expand_path(File.dirname(__FILE__))
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/src/pack.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/src/pack.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/src/pack.c	(revision 279)
@@ -0,0 +1,1173 @@
+/*
+ ** pack.c - Array#pack, String#unpack
+ */
+
+#include "mruby.h"
+#include "error.h"
+#include "mruby/array.h"
+#include "mruby/class.h"
+#include "mruby/numeric.h"
+#include "mruby/string.h"
+#include "mruby/variable.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+
+struct tmpl {
+  mrb_value str;
+  int idx;
+};
+
+enum {
+  PACK_DIR_CHAR,      /* C */
+  PACK_DIR_SHORT,     /* S */
+  PACK_DIR_LONG,      /* L */
+  PACK_DIR_QUAD,      /* Q */
+  //PACK_DIR_INT,     /* i */
+  //PACK_DIR_VAX,
+  PACK_DIR_UTF8,      /* U */
+  //PACK_DIR_BER,
+  PACK_DIR_DOUBLE,    /* E */
+  PACK_DIR_FLOAT,     /* f */
+  PACK_DIR_STR,       /* A */
+  PACK_DIR_HEX,       /* h */
+  PACK_DIR_BASE64,    /* m */
+  PACK_DIR_NUL,       /* x */
+  PACK_DIR_INVALID
+};
+
+enum {
+  PACK_TYPE_INTEGER,
+  PACK_TYPE_FLOAT,
+  PACK_TYPE_STRING,
+  PACK_TYPE_NONE
+};
+
+#define PACK_FLAG_s             0x00000001	/* native size ("_" "!") */
+#define PACK_FLAG_a             0x00000002	/* null padding ("a") */
+#define PACK_FLAG_Z             0x00000004	/* append nul char ("z") */
+#define PACK_FLAG_SIGNED        0x00000008	/* native size ("_" "!") */
+#define PACK_FLAG_GT            0x00000010	/* big endian (">") */
+#define PACK_FLAG_LT            0x00000020	/* little endian ("<") */
+#define PACK_FLAG_WIDTH         0x00000040	/* "count" is "width" */
+#define PACK_FLAG_LSB           0x00000080	/* LSB / low nibble first */
+#define PACK_FLAG_COUNT2        0x00000100	/* "count" is special... */
+#define PACK_FLAG_LITTLEENDIAN  0x00000200	/* little endian actually */
+
+#define PACK_BASE64_IGNORE	0xff
+#define PACK_BASE64_PADDING	0xfe
+
+static int littleendian = 0;
+
+const static unsigned char base64chars[] =
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static signed char base64_dec_tab[128];
+
+
+static int
+check_little_endian(void)
+{
+  unsigned int n = 1;
+  return (*(unsigned char *)&n == 1);
+}
+
+static unsigned int
+hex2int(unsigned char ch)
+{
+  if (ch >= '0' && ch <= '9') 
+    return ch - '0';
+  else if (ch >= 'A' && ch <= 'F')
+    return 10 + (ch - 'A');
+  else if (ch >= 'a' && ch <= 'f')
+    return 10 + (ch - 'a');
+  else
+    return 0;
+}
+
+static void
+make_base64_dec_tab(void)
+{
+  int i;
+  memset(base64_dec_tab, PACK_BASE64_IGNORE, sizeof(base64_dec_tab));
+  for (i = 0; i < 26; i++)
+    base64_dec_tab['A' + i] = i;
+  for (i = 0; i < 26; i++)
+    base64_dec_tab['a' + i] = i + 26;
+  for (i = 0; i < 10; i++)
+    base64_dec_tab['0' + i] = i + 52;
+  base64_dec_tab['+'] = 62;
+  base64_dec_tab['/'] = 63;
+  base64_dec_tab['='] = PACK_BASE64_PADDING;
+}
+
+static mrb_value
+str_len_ensure(mrb_state *mrb, mrb_value str, int len)
+{
+  int n = RSTRING_LEN(str);
+  if (len > n) {
+    do {
+      n *= 2;
+    } while (len > n);
+    str = mrb_str_resize(mrb, str, n);
+  }
+  return str;
+}
+
+
+static int
+pack_c(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int flags)
+{
+  str = str_len_ensure(mrb, str, sidx + 1);
+  RSTRING_PTR(str)[sidx] = mrb_fixnum(o);
+  return 1;
+}
+
+static int
+unpack_c(mrb_state *mrb, const void *src, int srclen, mrb_value ary, unsigned int flags)
+{
+  if (flags & PACK_FLAG_SIGNED)
+    mrb_ary_push(mrb, ary, mrb_fixnum_value(*(signed char *)src));
+  else
+    mrb_ary_push(mrb, ary, mrb_fixnum_value(*(unsigned char *)src));
+  return 1;
+}
+
+static int
+pack_s(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int flags)
+{
+  unsigned short n;
+
+  str = str_len_ensure(mrb, str, sidx + 2);
+  n = mrb_fixnum(o);
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+    RSTRING_PTR(str)[sidx+0] = n % 256;
+    RSTRING_PTR(str)[sidx+1] = n / 256;
+  } else {
+    RSTRING_PTR(str)[sidx+0] = n / 256;
+    RSTRING_PTR(str)[sidx+1] = n % 256;
+  }
+  return 2;
+}
+
+static int
+unpack_s(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, unsigned int flags)
+{
+  int n;
+
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+    n = src[1] * 256 + src[0];
+  } else {
+    n = src[0] * 256 + src[1];
+  }
+  if ((flags & PACK_FLAG_SIGNED) && (n >= 0x8000)) {
+    n -= 0x10000;
+  }
+  mrb_ary_push(mrb, ary, mrb_fixnum_value(n));
+  return 2;
+}
+
+static int
+pack_l(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int flags)
+{
+  unsigned long n;
+  str = str_len_ensure(mrb, str, sidx + 4);
+  n = mrb_fixnum(o);
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+    RSTRING_PTR(str)[sidx+0] = n & 0xff;
+    RSTRING_PTR(str)[sidx+1] = n >> 8;
+    RSTRING_PTR(str)[sidx+2] = n >> 16;
+    RSTRING_PTR(str)[sidx+3] = n >> 24;
+  } else {
+    RSTRING_PTR(str)[sidx+0] = n >> 24;
+    RSTRING_PTR(str)[sidx+1] = n >> 16;
+    RSTRING_PTR(str)[sidx+2] = n >> 8;
+    RSTRING_PTR(str)[sidx+3] = n & 0xff;
+  }
+  return 4;
+}
+
+static int
+unpack_l(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, unsigned int flags)
+{
+  char msg[60];
+  uint32_t ul;
+  mrb_int n;
+
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+    ul = (uint32_t)src[3] * 256*256*256;
+    ul += (uint32_t)src[2] *256*256;
+    ul += (uint32_t)src[1] *256;
+    ul += (uint32_t)src[0];
+  } else {
+    ul = (uint32_t)src[0] * 256*256*256;
+    ul += (uint32_t)src[1] *256*256;
+    ul += (uint32_t)src[2] *256;
+    ul += (uint32_t)src[3];
+  }
+  if (flags & PACK_FLAG_SIGNED) {
+    int32_t sl = ul;
+    if (!FIXABLE(sl)) {
+      snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %ld", (long)sl);
+      mrb_raise(mrb, E_RANGE_ERROR, msg);
+    }
+    n = sl;
+  } else {
+    if (!POSFIXABLE(ul)) {
+      snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %lu", (unsigned long)ul);
+      mrb_raise(mrb, E_RANGE_ERROR, msg);
+    }
+    n = ul;
+  }
+  mrb_ary_push(mrb, ary, mrb_fixnum_value(n));
+  return 4;
+}
+
+static int
+pack_q(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int flags)
+{
+  unsigned long long n;
+  str = str_len_ensure(mrb, str, sidx + 8);
+  n = mrb_fixnum(o);
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+    RSTRING_PTR(str)[sidx+0] = n & 0xff;
+    RSTRING_PTR(str)[sidx+1] = n >> 8;
+    RSTRING_PTR(str)[sidx+2] = n >> 16;
+    RSTRING_PTR(str)[sidx+3] = n >> 24;
+    RSTRING_PTR(str)[sidx+4] = n >> 32;
+    RSTRING_PTR(str)[sidx+5] = n >> 40;
+    RSTRING_PTR(str)[sidx+6] = n >> 48;
+    RSTRING_PTR(str)[sidx+7] = n >> 56;
+  } else {
+    RSTRING_PTR(str)[sidx+0] = n >> 56;
+    RSTRING_PTR(str)[sidx+1] = n >> 48;
+    RSTRING_PTR(str)[sidx+2] = n >> 40;
+    RSTRING_PTR(str)[sidx+3] = n >> 32;
+    RSTRING_PTR(str)[sidx+4] = n >> 24;
+    RSTRING_PTR(str)[sidx+5] = n >> 16;
+    RSTRING_PTR(str)[sidx+6] = n >> 8;
+    RSTRING_PTR(str)[sidx+7] = n & 0xff;
+  }
+  return 8;
+}
+
+static int
+unpack_q(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, unsigned int flags)
+{
+  char msg[60];
+  uint64_t ull;
+  int i, pos, step;
+  mrb_int n;
+
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+    pos  = 7;
+    step = -1;
+  } else {
+    pos  = 0;
+    step = 1;
+  }
+  ull = 0;
+  for (i = 0; i < 8; i++) {
+    ull = ull * 256 + (uint64_t)src[pos];
+    pos += step;
+  }
+  if (flags & PACK_FLAG_SIGNED) {
+    int64_t sll = ull;
+    if (!FIXABLE(sll)) {
+      snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %lld", (long long)sll);
+      mrb_raise(mrb, E_RANGE_ERROR, msg);
+    }
+    n = sll;
+  } else {
+    if (!POSFIXABLE(ull)) {
+      snprintf(msg, sizeof(msg), "cannot unpack to Fixnum: %llu", (unsigned long long)ull);
+      mrb_raise(mrb, E_RANGE_ERROR, msg);
+    }
+    n = ull;
+  }
+  mrb_ary_push(mrb, ary, mrb_fixnum_value(n));
+  return 8;
+}
+
+static int
+pack_double(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int flags)
+{
+  int i;
+  double d;
+  uint8_t *buffer = (uint8_t *)&d;
+  str = str_len_ensure(mrb, str, sidx + 8);
+  d = mrb_float(o);
+
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+#ifdef MRB_ENDIAN_BIG
+    for (i = 0; i < 8; ++i) {
+      RSTRING_PTR(str)[sidx + i] = buffer[8 - i - 1];
+    }
+#else
+    memcpy(RSTRING_PTR(str) + sidx, buffer, 8);
+#endif
+  } else {
+#ifdef MRB_ENDIAN_BIG
+    memcpy(RSTRING_PTR(str) + sidx, buffer, 8);
+#else
+    for (i = 0; i < 8; ++i) {
+      RSTRING_PTR(str)[sidx + i] = buffer[8 - i - 1];
+    }
+#endif
+  }
+
+  return 8;
+}
+
+static int
+unpack_double(mrb_state *mrb, const unsigned char * src, int srclen, mrb_value ary, unsigned int flags)
+{
+  int i;
+  double d;
+  uint8_t *buffer = (uint8_t *)&d;
+
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+#ifdef MRB_ENDIAN_BIG
+    for (i = 0; i < 8; ++i) {
+      buffer[8 - i - 1] = src[i];
+    }
+#else
+    memcpy(buffer, src, 8);
+#endif
+  } else {
+#ifdef MRB_ENDIAN_BIG
+    memcpy(buffer, src, 8);
+#else
+    for (i = 0; i < 8; ++i) {
+      buffer[8 - i - 1] = src[i];
+    }
+#endif
+  }
+  mrb_ary_push(mrb, ary, mrb_float_value(mrb, d));
+
+  return 8;
+}
+
+static int
+pack_float(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, unsigned int flags)
+{
+  int i;
+  float f;
+  uint8_t *buffer = (uint8_t *)&f;
+  str = str_len_ensure(mrb, str, sidx + 4);
+  f = mrb_float(o);
+
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+#ifdef MRB_ENDIAN_BIG
+    for (i = 0; i < 4; ++i) {
+      RSTRING_PTR(str)[sidx + i] = buffer[4 - i - 1];
+    }
+#else
+    memcpy(RSTRING_PTR(str) + sidx, buffer, 4);
+#endif
+  } else {
+#ifdef MRB_ENDIAN_BIG
+    memcpy(RSTRING_PTR(str) + sidx, buffer, 4);
+#else
+    for (i = 0; i < 4; ++i) {
+      RSTRING_PTR(str)[sidx + i] = buffer[4 - i - 1];
+    }
+#endif
+  }
+
+  return 4;
+}
+
+static int
+unpack_float(mrb_state *mrb, const unsigned char * src, int srclen, mrb_value ary, unsigned int flags)
+{
+  int i;
+  float f;
+  uint8_t *buffer = (uint8_t *)&f;
+
+  if (flags & PACK_FLAG_LITTLEENDIAN) {
+#ifdef MRB_ENDIAN_BIG
+    for (i = 0; i < 4; ++i) {
+      buffer[4 - i - 1] = src[i];
+    }
+#else
+    memcpy(buffer, src, 4);
+#endif
+  } else {
+#ifdef MRB_ENDIAN_BIG
+    memcpy(buffer, src, 4);
+#else
+    for (i = 0; i < 4; ++i) {
+      buffer[4 - i - 1] = src[i];
+    }
+#endif
+  }
+  mrb_ary_push(mrb, ary, mrb_float_value(mrb, f));
+
+  return 4;
+}
+
+static int
+pack_utf8(mrb_state *mrb, mrb_value o, mrb_value str, mrb_int sidx, long count, unsigned int flags)
+{
+  char utf8[4];
+  int len;
+  
+  unsigned long c = mrb_fixnum(o);
+
+  /* Unicode character */
+  /* from mruby-compiler gem */
+  if (c < 0x80) {
+    utf8[0] = (char)c;
+    len = 1;
+  }
+  else if (c < 0x800) {
+    utf8[0] = (char)(0xC0 | (c >> 6));
+    utf8[1] = (char)(0x80 | (c & 0x3F));
+    len = 2;
+  }
+  else if (c < 0x10000) {
+    utf8[0] = (char)(0xE0 |  (c >> 12)        );
+    utf8[1] = (char)(0x80 | ((c >>  6) & 0x3F));
+    utf8[2] = (char)(0x80 | ( c        & 0x3F));
+    len = 3;
+  }
+  else {
+    utf8[0] = (char)(0xF0 |  (c >> 18)        );
+    utf8[1] = (char)(0x80 | ((c >> 12) & 0x3F));
+    utf8[2] = (char)(0x80 | ((c >>  6) & 0x3F));
+    utf8[3] = (char)(0x80 | ( c        & 0x3F));
+    len = 4;
+  }
+  
+  str = str_len_ensure(mrb, str, sidx + len);
+  memcpy(RSTRING_PTR(str) + sidx, utf8, len);
+  
+  return len;
+}
+
+static int
+pack_a(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, long count, unsigned int flags)
+{
+  int copylen, slen, padlen;
+  char *dptr, *dptr0, pad, *sptr;
+
+  sptr = RSTRING_PTR(src);
+  slen = RSTRING_LEN(src);
+
+  if ((flags & PACK_FLAG_a) || (flags & PACK_FLAG_Z))
+    pad = '\0';
+  else
+    pad = ' ';
+
+  if (count == 0) {
+    return 0;
+  } else if (count == -1) {
+    copylen = slen;
+    padlen = (flags & PACK_FLAG_Z) ? 1 : 0;
+  } else if (count < slen) {
+    copylen = count;
+    padlen = 0;
+  } else {
+    copylen = slen;
+    padlen = count - slen;
+  }
+
+  dst = str_len_ensure(mrb, dst, didx + copylen + padlen);
+  dptr0 = dptr = RSTRING_PTR(dst) + didx;
+  memcpy(dptr, sptr, copylen);
+  dptr += copylen;
+  while (padlen-- > 0) {
+    *dptr++ = pad;
+  }
+ 
+  return dptr - dptr0;
+}
+
+static int
+unpack_a(mrb_state *mrb, const void *src, int slen, mrb_value ary, long count, unsigned int flags)
+{
+  mrb_value dst;
+  const char *cp, *sptr;
+  long copylen;
+
+  sptr = (const char *)src;
+  if (count != -1 && count < slen)  {
+    slen = count;
+  }
+  copylen = slen;
+
+  if (flags & PACK_FLAG_Z) {  /* "Z" */
+    if ((cp = (const char *)memchr(sptr, '\0', slen)) != NULL) {
+      copylen = cp - sptr;
+      if (count == -1) {
+        slen = copylen + 1;
+      }
+    }
+  } else if (!(flags & PACK_FLAG_a)) {  /* "A" */
+    while (copylen > 0 && (sptr[copylen - 1] == '\0' || isspace(sptr[copylen - 1]))) {
+      copylen--;
+    }
+  }
+
+  dst = mrb_str_new(mrb, sptr, copylen);
+  mrb_ary_push(mrb, ary, dst);
+  return slen;
+}
+
+
+static int
+pack_h(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, long count, unsigned int flags)
+{
+  unsigned int a, ashift, b, bshift;
+  int slen;
+  char *dptr, *dptr0, *sptr;
+
+  sptr = RSTRING_PTR(src);
+  slen = RSTRING_LEN(src);
+
+  if (flags & PACK_FLAG_LSB) {
+    ashift = 0;
+    bshift = 4;
+  } else {
+    ashift = 4;
+    bshift = 0;
+  }
+
+  if (count == -1) {
+    count = slen;
+  } else if (slen > count) {
+    slen = count;
+  }
+    
+  dst = str_len_ensure(mrb, dst, didx + count);
+  dptr = RSTRING_PTR(dst) + didx;
+
+  dptr0 = dptr;
+  for (; count > 0; count -= 2) {
+    a = b = 0;
+    if (slen > 0) {
+      a = hex2int(*sptr++);
+      slen--;
+    }
+    if (slen > 0) {
+      b = hex2int(*sptr++);
+      slen--;
+    }
+    *dptr++ = (a << ashift) + (b << bshift);
+  }
+
+  return dptr - dptr0;
+}
+
+static int
+unpack_h(mrb_state *mrb, const void *src, int slen, mrb_value ary, int count, unsigned int flags)
+{
+  mrb_value dst;
+  int a, ashift, b, bshift;
+  const char *sptr, *sptr0;
+  char *dptr, *dptr0;
+  const char hexadecimal[] = "0123456789abcdef";
+
+  if (flags & PACK_FLAG_LSB) {
+    ashift = 0;
+    bshift = 4;
+  } else {
+    ashift = 4;
+    bshift = 0;
+  }
+
+  sptr = (const char *)src;
+
+  if (count == -1)
+    count = slen * 2;
+
+  dst = mrb_str_new(mrb, NULL, count);
+  dptr = RSTRING_PTR(dst);
+
+  sptr0 = sptr;
+  dptr0 = dptr;
+  while (slen > 0 && count > 0) {
+    a = (*sptr >> ashift) & 0x0f;
+    b = (*sptr >> bshift) & 0x0f;
+    sptr++;
+    slen--;
+
+    *dptr++ = hexadecimal[a];
+    count--;
+
+    if (count > 0) {
+      *dptr++ = hexadecimal[b];
+      count--;
+    }
+  }
+
+  dst = mrb_str_resize(mrb, dst, dptr - dptr0);
+  mrb_ary_push(mrb, ary, dst);
+  return sptr - sptr0;
+}
+
+
+static int
+pack_m(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, long count, unsigned int flags)
+{
+  mrb_int dstlen;
+  unsigned long l;
+  int column, srclen;
+  char *srcptr, *dstptr, *dstptr0;
+
+  srcptr = RSTRING_PTR(src);
+  srclen = RSTRING_LEN(src);
+
+  if (srclen == 0)  /* easy case */
+    return 0;
+
+  if (count != 0 && count < 3) {  /* -1, 1 or 2 */
+    count = 45;
+  } else if (count >= 3) {
+    count -= count % 3;
+  }
+
+  dstlen = srclen / 3 * 4;
+  if (count > 0) {
+    dstlen += (srclen / count) + ((srclen % count) == 0 ? 0 : 1);
+  }
+  dst = str_len_ensure(mrb, dst, didx + dstlen);
+  dstptr = RSTRING_PTR(dst) + didx;
+
+  dstptr0 = dstptr;
+  for (column = 3; srclen >= 3; srclen -= 3, column += 3) {
+    l = (unsigned char)*srcptr++ << 16;
+    l += (unsigned char)*srcptr++ << 8;
+    l += (unsigned char)*srcptr++;
+
+    *dstptr++ = base64chars[(l >> 18) & 0x3f];
+    *dstptr++ = base64chars[(l >> 12) & 0x3f];
+    *dstptr++ = base64chars[(l >>  6) & 0x3f];
+    *dstptr++ = base64chars[ l        & 0x3f];
+
+    if (column == count) {
+      *dstptr++ = '\n';
+      column = 0;
+    }
+  }
+  if (srclen == 1) {
+    l = (unsigned char)*srcptr++ << 16;
+    *dstptr++ = base64chars[(l >> 18) & 0x3f];
+    *dstptr++ = base64chars[(l >> 12) & 0x3f];
+    *dstptr++ = '=';
+    *dstptr++ = '=';
+    column += 3;
+  } else if (srclen == 2) {
+    l = (unsigned char)*srcptr++ << 16;
+    l += (unsigned char)*srcptr++ << 8;
+    *dstptr++ = base64chars[(l >> 18) & 0x3f];
+    *dstptr++ = base64chars[(l >> 12) & 0x3f];
+    *dstptr++ = base64chars[(l >>  6) & 0x3f];
+    *dstptr++ = '=';
+    column += 3;
+  }
+  if (column > 0 && count > 0) {
+    *dstptr++ = '\n';
+  }
+
+  return dstptr - dstptr0;
+}
+
+static int
+unpack_m(mrb_state *mrb, const void *src, int slen, mrb_value ary, unsigned int flags)
+{
+  mrb_value dst;
+  int dlen;
+  unsigned long l;
+  int i, padding;
+  unsigned char c, ch[4];
+  const char *sptr, *sptr0;
+  char *dptr, *dptr0;
+
+  sptr0 = sptr = (const char *)src;
+
+  dlen = slen / 4 * 3;  /* an estimated value - may be shorter */
+  dst = mrb_str_new(mrb, NULL, dlen);
+  dptr0 = dptr = RSTRING_PTR(dst);
+
+  padding = 0;
+  while (slen >= 4) {
+    for (i = 0; i < 4; i++) {
+      do {
+        if (slen-- == 0)
+          goto done;
+        c = *sptr++;
+	if (c >= sizeof(base64_dec_tab))
+	  continue;
+	ch[i] = base64_dec_tab[c];
+	if (ch[i] == PACK_BASE64_PADDING) {
+	  ch[i] = 0;
+	  padding++;
+	}
+      } while (ch[i] == PACK_BASE64_IGNORE);
+    }
+
+    l = (ch[0] << 18) + (ch[1] << 12) + (ch[2] << 6) + ch[3];
+
+    if (padding == 0) {
+      *dptr++ = (l >> 16) & 0xff;
+      *dptr++ = (l >> 8) & 0xff;
+      *dptr++ = l & 0xff;
+    } else if (padding == 1) {
+      *dptr++ = (l >> 16) & 0xff;
+      *dptr++ = (l >> 8) & 0xff;
+      break;
+    } else {
+      *dptr++ = (l >> 16) & 0xff;
+      break;
+    }
+  }
+
+done:
+  dst = mrb_str_resize(mrb, dst, dptr - dptr0);
+  mrb_ary_push(mrb, ary, dst);
+  return sptr - sptr0;
+}
+
+static int
+pack_x(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, long count, unsigned int flags)
+{
+  long i;
+
+  dst = str_len_ensure(mrb, dst, didx + count);
+  for (i = 0; i < count; i++) {
+    RSTRING_PTR(dst)[didx] = '\0';
+  }
+  return count;
+}
+
+static int
+unpack_x(mrb_state *mrb, const void *src, int slen, mrb_value ary, int count, unsigned int flags)
+{
+  if (slen < count) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "x outside of string");
+  }
+  return count;
+}
+
+static void
+prepare_tmpl(mrb_state *mrb, struct tmpl *tmpl)
+{
+  mrb_get_args(mrb, "S", &tmpl->str);
+  tmpl->idx = 0;
+}
+
+static int
+has_tmpl(const struct tmpl *tmpl)
+{
+  return (tmpl->idx < RSTRING_LEN(tmpl->str));
+}
+
+static void
+read_tmpl(mrb_state *mrb, struct tmpl *tmpl, int *dirp, int *typep, int *sizep, long *countp, unsigned int *flagsp)
+{
+  int ch, dir, t, tlen, type;
+  int size = 0;
+  long count = 1;
+  unsigned int flags = 0;
+  const char *tptr;
+
+  tptr = RSTRING_PTR(tmpl->str);
+  tlen = RSTRING_LEN(tmpl->str);
+
+  t = tptr[tmpl->idx++];
+alias:
+  switch (t) {
+  case 'A':
+    dir = PACK_DIR_STR;
+    type = PACK_TYPE_STRING;
+    flags |= PACK_FLAG_WIDTH | PACK_FLAG_COUNT2;
+    break;
+  case 'a':
+    dir = PACK_DIR_STR;
+    type = PACK_TYPE_STRING;
+    flags |= PACK_FLAG_WIDTH | PACK_FLAG_COUNT2 | PACK_FLAG_a;
+    break;
+  case 'C':
+    dir = PACK_DIR_CHAR;
+    type = PACK_TYPE_INTEGER;
+    size = 1;
+    break;
+  case 'c':
+    dir = PACK_DIR_CHAR;
+    type = PACK_TYPE_INTEGER;
+    size = 1;
+    flags |= PACK_FLAG_SIGNED;
+    break;
+  case 'D': case 'd':
+    dir = PACK_DIR_DOUBLE;
+    type = PACK_TYPE_FLOAT;
+    size = 8;
+    flags |= PACK_FLAG_SIGNED;
+    break;
+  case 'F': case 'f':
+    dir = PACK_DIR_FLOAT;
+    type = PACK_TYPE_FLOAT;
+    size = 4;
+    flags |= PACK_FLAG_SIGNED;
+    break;
+  case 'E':
+    dir = PACK_DIR_DOUBLE;
+    type = PACK_TYPE_FLOAT;
+    size = 8;
+    flags |= PACK_FLAG_SIGNED | PACK_FLAG_LT;
+    break;
+  case 'e':
+    dir = PACK_DIR_FLOAT;
+    type = PACK_TYPE_FLOAT;
+    size = 4;
+    flags |= PACK_FLAG_SIGNED | PACK_FLAG_LT;
+    break;
+  case 'G':
+    dir = PACK_DIR_DOUBLE;
+    type = PACK_TYPE_FLOAT;
+    size = 8;
+    flags |= PACK_FLAG_SIGNED | PACK_FLAG_GT;
+    break;
+  case 'g':
+    dir = PACK_DIR_FLOAT;
+    type = PACK_TYPE_FLOAT;
+    size = 4;
+    flags |= PACK_FLAG_SIGNED | PACK_FLAG_GT;
+    break;
+  case 'H':
+    dir = PACK_DIR_HEX;
+    type = PACK_TYPE_STRING;
+    flags |= PACK_FLAG_COUNT2;
+    break;
+  case 'h':
+    dir = PACK_DIR_HEX;
+    type = PACK_TYPE_STRING;
+    flags |= PACK_FLAG_COUNT2 | PACK_FLAG_LSB;
+    break;
+  case 'I':
+    switch (sizeof(int)) {
+      case 2: t = 'S'; goto alias;
+      case 4: t = 'L'; goto alias;
+      case 8: t = 'Q'; goto alias;
+      default:
+        mrb_raisef(mrb, E_RUNTIME_ERROR, "mruby-pack does not support sizeof(int) == %S", mrb_fixnum_value(sizeof(int)));
+    }
+    break;
+  case 'i':
+    switch (sizeof(int)) {
+      case 2: t = 's'; goto alias;
+      case 4: t = 'l'; goto alias;
+      case 8: t = 'q'; goto alias;
+      default:
+        mrb_raisef(mrb, E_RUNTIME_ERROR, "mruby-pack does not support sizeof(int) == %S", mrb_fixnum_value(sizeof(int)));
+    }
+    break;
+  case 'L':
+    dir = PACK_DIR_LONG;
+    type = PACK_TYPE_INTEGER;
+    size = 4;
+    break;
+  case 'l':
+    dir = PACK_DIR_LONG;
+    type = PACK_TYPE_INTEGER;
+    size = 4;
+    flags |= PACK_FLAG_SIGNED;
+    break;
+  case 'm':
+    dir = PACK_DIR_BASE64;
+    type = PACK_TYPE_STRING;
+    flags |= PACK_FLAG_WIDTH;
+    break;
+  case 'N':  /* = "L>" */
+    dir = PACK_DIR_LONG;
+    type = PACK_TYPE_INTEGER;
+    size = 4;
+    flags |= PACK_FLAG_GT;
+    break;
+  case 'n':  /* = "S>" */
+    dir = PACK_DIR_SHORT;
+    type = PACK_TYPE_INTEGER;
+    size = 2;
+    flags |= PACK_FLAG_GT;
+    break;
+  case 'Q':
+    dir = PACK_DIR_QUAD;
+    type = PACK_TYPE_INTEGER;
+    size = 8;
+    break;
+  case 'q':
+    dir = PACK_DIR_QUAD;
+    type = PACK_TYPE_INTEGER;
+    size = 8;
+    flags |= PACK_FLAG_SIGNED;
+    break;
+  case 'S':
+    dir = PACK_DIR_SHORT;
+    type = PACK_TYPE_INTEGER;
+    size = 2;
+    break;
+  case 's':
+    dir = PACK_DIR_SHORT;
+    type = PACK_TYPE_INTEGER;
+    size = 2;
+    flags |= PACK_FLAG_SIGNED;
+    break;
+  case 'U':
+    dir = PACK_DIR_UTF8;
+    type = PACK_TYPE_INTEGER;
+    break;
+  case 'V':  /* = "L<" */
+    dir = PACK_DIR_LONG;
+    type = PACK_TYPE_INTEGER;
+    size = 4;
+    flags |= PACK_FLAG_LT;
+    break;
+  case 'v':  /* = "S<" */
+    dir = PACK_DIR_SHORT;
+    type = PACK_TYPE_INTEGER;
+    size = 2;
+    flags |= PACK_FLAG_LT;
+    break;
+  case 'x':
+    dir = PACK_DIR_NUL;
+    type = PACK_TYPE_NONE;
+    break;
+  case 'Z':
+    dir = PACK_DIR_STR;
+    type = PACK_TYPE_STRING;
+    flags |= PACK_FLAG_WIDTH | PACK_FLAG_COUNT2 | PACK_FLAG_Z;
+    break;
+  default:
+    dir = PACK_DIR_INVALID;
+    type = PACK_TYPE_NONE;
+    break;
+  }
+
+  /* read suffix [0-9*_!<>] */
+  while (tmpl->idx < tlen) {
+    ch = tptr[tmpl->idx++];
+    if (isdigit(ch)) {
+      count = ch - '0';
+      while (tmpl->idx < tlen && isdigit(tptr[tmpl->idx])) {
+        count = count * 10 + (tptr[tmpl->idx++] - '0');
+      }
+      continue;  /* special case */
+    } else if (ch == '*')  {
+      count = -1;
+    } else if (ch == '_' || ch == '!' || ch == '<' || ch == '>') {
+      if (strchr("sSiIlLqQ", t) == NULL) {
+        char ch_str = ch;
+        mrb_raisef(mrb, E_ARGUMENT_ERROR, "'%S' allowed only after types sSiIlLqQ", mrb_str_new(mrb, &ch_str, 1));
+      }
+      if (ch == '_' || ch == '!') {
+        flags |= PACK_FLAG_s;
+      } else if (ch == '<') {
+        flags |= PACK_FLAG_LT;
+      } else if (ch == '>') {
+        flags |= PACK_FLAG_GT;
+      }
+    } else {
+      tmpl->idx--;
+      break;
+    }
+  }
+
+  if ((flags & PACK_FLAG_LT) || (!(flags & PACK_FLAG_GT) && littleendian)) {
+    flags |= PACK_FLAG_LITTLEENDIAN;
+  }
+
+  *dirp = dir;
+  *typep = type;
+  *sizep = size;
+  *countp = count;
+  *flagsp = flags;
+}
+
+static mrb_value
+mrb_pack_pack(mrb_state *mrb, mrb_value ary)
+{
+  mrb_value o, result;
+  mrb_int aidx;
+  struct tmpl tmpl;
+  long count;
+  unsigned int flags;
+  int dir, ridx, size, type;
+
+  prepare_tmpl(mrb, &tmpl);
+
+  result = mrb_str_new(mrb, NULL, 128);  /* allocate initial buffer */
+  aidx = 0;
+  ridx = 0;
+  while (has_tmpl(&tmpl)) {
+    read_tmpl(mrb, &tmpl, &dir, &type, &size, &count, &flags);
+
+    if (dir == PACK_DIR_INVALID)
+      continue;
+    else if (dir == PACK_DIR_NUL) {
+        ridx += pack_x(mrb, mrb_nil_value(), result, ridx, count, flags);
+        continue;
+    }
+
+    for (; aidx < RARRAY_LEN(ary); aidx++) {
+      if (count == 0 && !(flags & PACK_FLAG_WIDTH))
+        break;
+
+      o = mrb_ary_ref(mrb, ary, aidx);
+      if (type == PACK_TYPE_INTEGER) {
+        o = mrb_to_int(mrb, o);
+      } else if (type == PACK_TYPE_FLOAT) {
+        if (!mrb_float_p(o)) {
+          o = mrb_funcall(mrb, o, "to_f", 0);
+        }
+      } else if (type == PACK_TYPE_STRING) {
+        if (!mrb_string_p(o)) {
+          mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %S into String", mrb_class_path(mrb, mrb_obj_class(mrb, o)));
+        }
+      }
+
+      switch (dir) {
+      case PACK_DIR_CHAR:
+        ridx += pack_c(mrb, o, result, ridx, flags);
+        break;
+      case PACK_DIR_SHORT:
+        ridx += pack_s(mrb, o, result, ridx, flags);
+        break;
+      case PACK_DIR_LONG:
+        ridx += pack_l(mrb, o, result, ridx, flags);
+        break;
+      case PACK_DIR_QUAD:
+        ridx += pack_q(mrb, o, result, ridx, flags);
+        break;
+      case PACK_DIR_BASE64:
+        ridx += pack_m(mrb, o, result, ridx, count, flags);
+        break;
+      case PACK_DIR_HEX:
+        ridx += pack_h(mrb, o, result, ridx, count, flags);
+        break;
+      case PACK_DIR_STR:
+        ridx += pack_a(mrb, o, result, ridx, count, flags);
+        break;
+      case PACK_DIR_DOUBLE:
+        ridx += pack_double(mrb, o, result, ridx, flags);
+        break;
+      case PACK_DIR_FLOAT:
+        ridx += pack_float(mrb, o, result, ridx, flags);
+        break;
+      case PACK_DIR_UTF8:
+        ridx += pack_utf8(mrb, o, result, ridx, count, flags);
+        break;
+      default:
+        break;
+      }
+      if (dir == PACK_DIR_STR) { /* always consumes 1 entry */
+        aidx++;
+        break;
+      }
+      if (count > 0) {
+        count--;
+      }
+    }
+  }
+
+  mrb_str_resize(mrb, result, ridx);
+  return result;
+}
+
+static mrb_value
+mrb_pack_unpack(mrb_state *mrb, mrb_value str)
+{
+  mrb_value result;
+  struct tmpl tmpl;
+  long count;
+  unsigned int flags;
+  int dir, size, srcidx, srclen, type;
+  const unsigned char *sptr;
+
+  prepare_tmpl(mrb, &tmpl);
+
+  srcidx = 0;
+  srclen = RSTRING_LEN(str);
+
+  result = mrb_ary_new(mrb);
+  while (has_tmpl(&tmpl)) {
+    read_tmpl(mrb, &tmpl, &dir, &type, &size, &count, &flags);
+
+    if (dir == PACK_DIR_INVALID)
+      continue;
+    else if (dir == PACK_DIR_NUL) {
+      srcidx += unpack_x(mrb, sptr, srclen - srcidx, result, count, flags);
+      continue;
+    }
+
+    if (flags & PACK_FLAG_COUNT2) {
+      sptr = (const unsigned char *)RSTRING_PTR(str) + srcidx;
+      switch (dir) {
+      case PACK_DIR_HEX:
+        srcidx += unpack_h(mrb, sptr, srclen - srcidx, result, count, flags);
+        break;
+      case PACK_DIR_STR:
+        srcidx += unpack_a(mrb, sptr, srclen - srcidx, result, count, flags);
+        break;
+      }
+      continue;
+    }
+
+    while (count != 0) {
+      if (srclen - srcidx < size) {
+        while (count-- > 0) {
+          mrb_ary_push(mrb, result, mrb_nil_value());
+        }
+        break;
+      }
+
+      sptr = (const unsigned char *)RSTRING_PTR(str) + srcidx;
+      switch (dir) {
+      case PACK_DIR_CHAR:
+        srcidx += unpack_c(mrb, sptr, srclen - srcidx, result, flags);
+        break;
+      case PACK_DIR_SHORT:
+        srcidx += unpack_s(mrb, sptr, srclen - srcidx, result, flags);
+        break;
+      case PACK_DIR_LONG:
+        srcidx += unpack_l(mrb, sptr, srclen - srcidx, result, flags);
+        break;
+      case PACK_DIR_QUAD:
+        srcidx += unpack_q(mrb, sptr, srclen - srcidx, result, flags);
+        break;
+      case PACK_DIR_BASE64:
+        srcidx += unpack_m(mrb, sptr, srclen - srcidx, result, flags);
+        break;
+      case PACK_DIR_FLOAT:
+        srcidx += unpack_float(mrb, sptr, srclen - srcidx, result, flags);
+        break;
+      case PACK_DIR_DOUBLE:
+        srcidx += unpack_double(mrb, sptr, srclen - srcidx, result, flags);
+        break;
+      }
+      if (count > 0) {
+        count--;
+      }
+    }
+  }
+
+  return result;
+}
+
+void
+mrb_mruby_pack_gem_init(mrb_state *mrb)
+{
+  littleendian = check_little_endian();
+  make_base64_dec_tab();
+
+  mrb_define_method(mrb, mrb->array_class, "pack", mrb_pack_pack, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, mrb->string_class, "unpack", mrb_pack_unpack, MRB_ARGS_REQ(1));
+}
+
+void
+mrb_mruby_pack_gem_final(mrb_state *mrb)
+{
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-pack/test/pack.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-pack/test/pack.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-pack/test/pack.rb	(revision 279)
@@ -0,0 +1,147 @@
+# pack & unpack 'm' (base64)
+assert('[""].pack("m")') do
+  ary = ""
+  str = ""
+  [ary].pack("m") == str and
+  str.unpack("m") == [ary]
+end
+
+assert('["\0"].pack("m")') do
+  ary = "\0"
+  str = "AA==\n"
+  [ary].pack("m") == str and
+  str.unpack("m") == [ary]
+end
+
+assert('["\0\0"].pack("m")') do
+  ary = "\0\0"
+  str = "AAA=\n"
+  [ary].pack("m") == str and
+  str.unpack("m") == [ary]
+end
+
+assert('["\0\0\0"].pack("m")') do
+  ary = "\0\0\0"
+  str = "AAAA\n"
+  [ary].pack("m") == str and
+  str.unpack("m") == [ary]
+end
+
+assert('["abc..xyzABC..XYZ"].pack("m")') do
+  ["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].pack("m") == "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJT\nVFVWV1hZWg==\n"
+end
+
+assert('"YWJ...".unpack("m") should "abc..xyzABC..XYZ"') do
+  str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+  "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJT\nVFVWV1hZWg==\n".unpack("m") == [str] and
+  "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWg==\n".unpack("m") == [str]
+end
+
+# pack & unpack 'H'
+assert('["3031"].pack("H*")') do
+  ary = "3031"
+  str = "01"
+  [ary].pack("H*") == str and
+  str.unpack("H*") == [ary]
+end
+
+assert('["10"].pack("H*")') do
+  ary = "10"
+  str = "\020"
+  [ary].pack("H*") == str and
+  str.unpack("H*") == [ary]
+end
+
+assert('[0,1,127,128,255].pack("C*")') do
+ ary = [ 0, 1, 127, 128, 255 ]
+ str = "\x00\x01\x7F\x80\xFF"
+ ary.pack("C*") == str and str.unpack("C*") == ary
+end
+
+# pack "a"
+assert('["abc"].pack("a")') do
+  ["abc"].pack("a") == "a" and
+  ["abc"].pack("a*") == "abc" and
+  ["abc"].pack("a4") == "abc\0"
+end
+
+# upack "a"
+assert('["abc"].pack("a")') do
+  "abc\0".unpack("a4") == ["abc\0"] and
+  "abc ".unpack("a4") == ["abc "]
+end
+
+# pack "A"
+assert('["abc"].pack("A")') do
+  ["abc"].pack("A") == "a" and
+  ["abc"].pack("A*") == "abc" and
+  ["abc"].pack("A4") == "abc "
+end
+
+# upack "A"
+assert('["abc"].pack("A")') do
+  "abc\0".unpack("A4") == ["abc"] and
+  "abc ".unpack("A4") == ["abc"]
+end
+
+# regression tests
+assert('issue #1') do
+  [1, 2].pack("nn") == "\000\001\000\002"
+end
+
+def assert_pack tmpl, packed, unpacked
+  assert_equal packed, unpacked.pack(tmpl)
+  assert_equal unpacked, packed.unpack(tmpl)
+end
+
+PACK_IS_LITTLE_ENDIAN = "\x01\00".unpack('S')[0] == 0x01
+
+assert 'pack float' do
+  assert_pack 'e', "\x00\x00@@", [3.0]
+  assert_pack 'g', "@@\x00\x00", [3.0]
+
+  if PACK_IS_LITTLE_ENDIAN
+    assert_pack 'f', "\x00\x00@@", [3.0]
+    assert_pack 'F', "\x00\x00@@", [3.0]
+  else
+    assert_pack 'f', "@@\x00\x00", [3.0]
+    assert_pack 'F', "@@\x00\x00", [3.0]
+  end
+end
+
+assert 'pack double' do
+  assert_pack 'E', "\x00\x00\x00\x00\x00\x00\b@", [3.0]
+  assert_pack 'G', "@\b\x00\x00\x00\x00\x00\x00", [3.0]
+
+  if PACK_IS_LITTLE_ENDIAN
+    assert_pack 'd', "\x00\x00\x00\x00\x00\x00\b@", [3.0]
+    assert_pack 'D', "\x00\x00\x00\x00\x00\x00\b@", [3.0]
+  else
+    assert_pack 'd', "@\b\x00\x00\x00\x00\x00\x00", [3.0]
+    assert_pack 'D', "@\b\x00\x00\x00\x00\x00\x00", [3.0]
+  end
+end
+
+assert 'pack/unpack "i"' do
+  int_size = [0].pack('i').size
+  raise "pack('i').size is too small (#{int_size})" if int_size < 2
+
+  if PACK_IS_LITTLE_ENDIAN
+    str = "\xC7\xCF" + "\xFF" * (int_size-2)
+  else
+    str = "\xFF" * (int_size-2) + "\xC7\xCF"
+  end
+  assert_pack 'i', str, [-12345]
+end
+
+assert 'pack/unpack "I"' do
+  uint_size = [0].pack('I').size
+  raise "pack('I').size is too small (#{uint_size})" if uint_size < 2
+
+  if PACK_IS_LITTLE_ENDIAN
+    str = "\x39\x30" + "\0" * (uint_size-2)
+  else
+    str = "\0" * (uint_size-2) + "\x39\x30"
+  end
+  assert_pack 'I', str, [12345]
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/.travis.yml
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/.travis.yml	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/.travis.yml	(revision 279)
@@ -0,0 +1,4 @@
+language: c
+sudo: false
+script:
+  - "ruby run_test.rb all test"
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/README.md
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/README.md	(revision 279)
@@ -0,0 +1,55 @@
+mruby-socket
+============
+
+"mruby-socket" mrbgem provides BSD socket interface for mruby.
+API is compatible with CRuby's "socket" library.
+
+
+## Example
+```sh
+% vi kame.rb
+s = TCPSocket.open("www.kame.net", 80)
+s.write("GET / HTTP/1.0\r\n\r\n")
+puts s.read
+s.close
+
+% mruby kame.rb
+HTTP/1.1 200 OK
+Date: Tue, 21 May 2013 04:31:30 GMT
+...
+```
+
+## Requirement
+- [iij/mruby-io](https://github.com/iij/mruby-io) mrbgem
+- [iij/mruby-mtest](https://github.com/iij/mruby-mtest) mrgbem to run tests
+- system must have RFC3493 basic socket interface
+- and some POSIX API...
+
+## TODO
+- add missing methods
+- write more tests
+- fix possible descriptor leakage (see XXX comments)
+- `UNIXSocket#recv_io` `UNIXSocket#send_io`
+
+
+## License
+
+Copyright (c) 2013 Internet Initiative Japan Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a 
+copy of this software and associated documentation files (the "Software"), 
+to deal in the Software without restriction, including without limitation 
+the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+and/or sell copies of the Software, and to permit persons to whom the 
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in 
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+DEALINGS IN THE SOFTWARE.
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/mrbgem.rake	(revision 279)
@@ -0,0 +1,16 @@
+MRuby::Gem::Specification.new('mruby-socket') do |spec|
+  spec.license = 'MIT'
+  spec.authors = 'Internet Initiative Japan'
+
+  spec.cc.include_paths << "#{build.root}/src"
+  
+  # If Windows, use winsock
+  if ( /mswin|mingw|win32/ =~ RUBY_PLATFORM ) then
+    spec.linker.libraries << "wsock32"
+    spec.linker.libraries << "ws2_32"
+  end
+
+  spec.add_dependency('mruby-io')
+  spec.add_dependency('mruby-pack')
+  # spec.add_dependency('mruby-mtest')
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/mrblib/socket.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/mrblib/socket.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/mrblib/socket.rb	(revision 279)
@@ -0,0 +1,621 @@
+class Addrinfo
+  def initialize(sockaddr, family=Socket::PF_UNSPEC, socktype=0, protocol=0)
+    @hostname = nil
+    if sockaddr.is_a? Array
+      sary = sockaddr
+      if sary[0] == 'AF_INET' || sary[0] == 'AF_INET6'
+        @sockaddr = Socket.sockaddr_in(sary[1], sary[3])
+        @hostname = sary[2]
+      elsif sary[0] == 'AF_UNIX'
+        @sockaddr = Socket.sockaddr_un(sary[1])
+      end
+    else
+      @sockaddr = sockaddr.dup
+    end
+    if family == Socket::PF_UNSPEC or family == nil
+      @family = Socket._sockaddr_family(@sockaddr)
+    else
+      @family = family
+    end
+    @socktype = socktype
+    @protocol = protocol
+    @canonname = nil
+  end
+
+  def self.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=0, &block)
+    a = self.getaddrinfo(nodename, service, family, socktype, protocol, flags)
+    a.each { |ai| block.call(ai) }
+    a
+  end
+
+  def self.ip(host)
+    Addrinfo.new(Socket.sockaddr_in(0, host))
+  end
+
+  def self.tcp(host, port)
+    Addrinfo.getaddrinfo(host, port, nil, Socket::SOCK_STREAM, Socket::IPPROTO_TCP)[0]
+  end
+
+  def self.udp(host, port)
+    Addrinfo.getaddrinfo(host, port, nil, Socket::SOCK_DGRAM, Socket::IPPROTO_UDP)[0]
+  end
+
+  def self.unix(path, socktype=Socket::SOCK_STREAM)
+    Addrinfo.new(Socket.sockaddr_un(path), Socket::AF_UNIX, socktype)
+  end
+
+  def afamily
+    @family
+  end
+
+  #def bind
+
+  attr_reader :canonname
+
+  #def connect
+  #def connect_from
+  #def connect_to
+
+  #def family_addrinfo(host, port=nil)
+  #def getnameinfo(flags=0)
+  #  Socket.getnameinfo
+  #end
+
+  def inspect
+    if ipv4? or ipv6?
+      if @protocol == Socket::IPPROTO_TCP or (@socktype == Socket::SOCK_STREAM and @protocol == 0)
+        proto = 'TCP'
+      elsif @protocol == Socket::IPPROTO_UDP or (@socktype == Socket::SOCK_DGRAM and @protocol == 0)
+        proto = 'UDP'
+      else
+        proto = '???'
+      end
+      "#<Addrinfo: #{inspect_sockaddr} #{proto}>"
+    else
+      "#<Addrinfo: #{self.unix_path} SOCK_STREAM>"
+    end
+  end
+
+  def inspect_sockaddr
+    if ipv4?
+      a, p = ip_unpack
+      "#{a}:#{p}"
+    elsif ipv6?
+      a, p = ip_unpack
+      "[#{a}]:#{p}"
+    elsif unix?
+      unix_path
+    else
+      '???'
+    end
+  end
+
+  def ip?
+    ipv4? or ipv6?
+  end
+
+  def ip_address
+    ip_unpack[0]
+  end
+
+  def ip_port
+    ip_unpack[1]
+  end
+
+  def ip_unpack
+    h, p = getnameinfo(Socket::NI_NUMERICHOST|Socket::NI_NUMERICSERV)
+    [ h, p.to_i ]
+  end
+
+  def ipv4?
+    @family == Socket::AF_INET
+  end
+
+  #def ipv4_loopback?
+  #def ipv4_multicast?
+  #def ipv4_private?
+
+  def ipv6?
+    @family == Socket::AF_INET6
+  end
+
+  #def ipv6_loopback?
+  #def ipv6_mc_global?
+  #def ipv6_mc_linklocal?
+  #def ipv6_mc_nodelocal?
+  #def ipv6_mc_orilocal?
+  #def ipv6_mc_sitelocal?
+  #def ipv6_multicast?
+  #def ipv6_to_ipv4
+  #def ipv6_unspecified
+  #def ipv6_v4compat?
+  #def ipv6_v4mapped?
+  #def listen(backlog=5)
+
+  def pfamily
+    @family
+  end
+
+  attr_reader :protocol
+  attr_reader :socktype
+
+  def _to_array
+    case @family
+    when Socket::AF_INET
+      s = "AF_INET"
+    when Socket::AF_INET6
+      s = "AF_INET6"
+    when Socket::AF_UNIX
+      s = "AF_UNIX"
+    else
+      s = "(unknown AF)"
+    end
+    addr, port = self.getnameinfo(Socket::NI_NUMERICHOST|Socket::NI_NUMERICSERV)
+    [ s, port.to_i, addr, addr ]
+  end
+
+  def to_sockaddr 
+    @sockaddr
+  end
+
+  alias to_s to_sockaddr
+
+  def unix?
+    @family == Socket::AF_UNIX
+  end
+end
+
+class BasicSocket
+  @@do_not_reverse_lookup = true
+
+  def self.do_not_reverse_lookup
+    @@do_not_reverse_lookup
+  end
+
+  def self.do_not_reverse_lookup=(val)
+    @@do_not_reverse_lookup = val ? true : false
+  end
+
+  def initialize(*args)
+    super(*args)
+    @do_not_reverse_lookup = @@do_not_reverse_lookup
+  end
+
+  def self.for_fd(fd)
+    super(fd, "r+")
+  end
+
+  #def connect_address
+
+  def local_address
+    Addrinfo.new self.getsockname
+  end
+
+  def recv_nonblock(maxlen, flags=0)
+    begin
+      _setnonblock(true)
+      recv(maxlen, flags)
+    ensure
+      _setnonblock(false)
+    end
+  end
+
+  def remote_address
+    Addrinfo.new self.getpeername
+  end
+
+  attr_accessor :do_not_reverse_lookup
+end
+
+class IPSocket
+  def self.getaddress(host)
+    Addrinfo.ip(host).ip_address
+  end
+
+  def addr
+    Addrinfo.new(self.getsockname)._to_array
+  end
+
+  def peeraddr
+    Addrinfo.new(self.getpeername)._to_array
+  end
+
+  def recvfrom(maxlen, flags=0)
+    msg, sa = _recvfrom(maxlen, flags)
+    [ msg, Addrinfo.new(sa)._to_array ]
+  end
+end
+
+class TCPSocket
+  def initialize(host, service, local_host=nil, local_service=nil)
+    if @init_with_fd
+      super(host, service)
+    else
+      s = nil
+      e = SocketError
+      Addrinfo.foreach(host, service) { |ai|
+        begin
+          s = Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0)
+          if local_host or local_service
+            local_host ||= (ai.afamily == Socket::AF_INET) ? "0.0.0.0" : "::"
+            local_service ||= "0"
+            bi = Addrinfo.getaddrinfo(local_host, local_service, ai.afamily, ai.socktype)[0]
+            Socket._bind(s, bi.to_sockaddr)
+          end
+          Socket._connect(s, ai.to_sockaddr)
+          super(s, "r+")
+          return
+        rescue => e0
+          e = e0
+        end
+      }
+      raise e
+    end
+  end
+
+  def self.new_with_prelude pre, *args
+    o = self._allocate
+    o.instance_eval(&pre)
+    o.initialize(*args)
+    o
+  end
+
+  #def self.gethostbyname(host)
+end
+
+class TCPServer
+  def initialize(host=nil, service)
+    ai = Addrinfo.getaddrinfo(host, service, nil, nil, nil, Socket::AI_PASSIVE)[0]
+    @init_with_fd = true
+    super(Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0), "r+")
+    if Socket.const_defined?(:SO_REUSEADDR)
+      self.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
+    end
+    Socket._bind(self.fileno, ai.to_sockaddr)
+    listen(5)
+    self
+  end
+
+  def accept
+    fd = self.sysaccept
+    begin
+      proc = Proc.new { @init_with_fd = true }
+      TCPSocket.new_with_prelude(proc, fd, "r+")
+    rescue
+      IO._sysclose(fd) rescue nil
+      raise
+    end
+  end
+
+  def accept_nonblock
+    begin
+      self._setnonblock(true)
+      self.accept
+    ensure
+      self._setnonblock(false)
+    end
+  end
+
+  def listen(backlog)
+    Socket._listen(self.fileno, backlog)
+    0
+  end
+
+  def sysaccept
+    Socket._accept(self.fileno)[0]
+  end
+end
+
+class UDPSocket
+  def initialize(af=Socket::AF_INET)
+    super(Socket._socket(af, Socket::SOCK_DGRAM, 0), "r+")
+    @af = af
+    self
+  end
+
+  def bind(host, port)
+    Socket._bind(self.fileno, _sockaddr_in(port, host))
+    0
+  end
+
+  def connect(host, port)
+    Socket._connect(self.fileno, _sockaddr_in(port, host))
+    0
+  end
+
+  def recvfrom_nonblock(*args)
+    s = self
+    begin
+      self._setnonblock(true)
+      self.recvfrom(*args)
+    ensure
+      # XXX: self is a SystemcallException here! (should be bug)
+      s._setnonblock(false)
+    end
+  end
+
+  def send(mesg, flags, host=nil, port=nil)
+    if port
+      super(mesg, flags, _sockaddr_in(port, host))
+    elsif host
+      super(mesg, flags, host)
+    else
+      super(mesg, flags)
+    end
+  end
+
+  def _sockaddr_in(port, host)
+    ai = Addrinfo.getaddrinfo(host, port, @af, Socket::SOCK_DGRAM)[0]
+    ai.to_sockaddr
+  end
+end
+
+class Socket
+  def initialize(domain, type, protocol=0)
+    super(Socket._socket(domain, type, protocol), "r+")
+  end
+
+  #def self.accept_loop
+
+  def self.getaddrinfo(nodename, servname, family=nil, socktype=nil, protocol=nil, flags=0)
+    Addrinfo.getaddrinfo(nodename, servname, family, socktype, protocol, flags).map { |ai|
+      ary = ai._to_array
+      ary[2] = nodename
+      ary[4] = ai.afamily
+      ary[5] = ai.socktype
+      ary[6] = ai.protocol
+      ary
+    }
+  end
+
+  #def self.getnameinfo
+  #def self.ip_address_list
+
+  def self.open(*args)
+    new(args)
+  end
+
+  def self.sockaddr_in(port, host)
+    ai = Addrinfo.getaddrinfo(host, port, nil, Socket::SOCK_DGRAM)[0]
+    ai.to_sockaddr
+  end
+
+  #def self.tcp
+  #def self.tcp_server_loop
+  #def self.tcp_server_sockets
+  #def self.udp_server_loop
+  #def self.udp_server_loop_on
+  #def self.udp_server_recv
+  #def self.udp_server_sockets
+  #def self.unix(path)
+  #def self.unix_server_loop
+  #def self.unix_server_socket
+
+  def self.unpack_sockaddr_in(sa)
+    Addrinfo.new(sa).ip_unpack.reverse
+  end
+
+  def self.unpack_sockaddr_un(sa)
+    Addrinfo.new(sa).unix_path
+  end
+
+  class << self
+    alias pack_sockaddr_in sockaddr_in
+    alias pack_sockaddr_un sockaddr_un
+    alias pair socketpair
+  end
+
+  def accept
+    fd, addr = self.sysaccept
+    [ Socket.for_fd(fd), addr ]
+  end
+
+  def accept_nonblock
+    begin
+      self._setnonblock(true)
+      self.accept
+    ensure
+      self._setnonblock(false)
+    end
+  end
+
+  def bind(sockaddr)
+    sockaddr = sockaddr.to_sockaddr if sockaddr.is_a? Addrinfo
+    Socket._bind(self.fileno, sockaddr)
+    0
+  end
+
+  def connect(sockaddr)
+    sockaddr = sockaddr.to_sockaddr if sockaddr.is_a? Addrinfo
+    Socket._connect(self.fileno, sockaddr)
+    0
+  end
+
+  def connect_nonblock(sockaddr)
+    begin
+      self._setnonblock(true)
+      self.connect(sockaddr)
+    ensure
+      self._setnonblock(false)
+    end
+  end
+
+  #def ipv6only!
+
+  def listen(backlog)
+    Socket._listen(self.fileno, backlog)
+    0
+  end
+
+  def recvfrom(maxlen, flags=0)
+    msg, sa = _recvfrom(maxlen, flags)
+    socktype = self.getsockopt(Socket::SOL_SOCKET, Socket::SO_TYPE).int
+    [ msg, Addrinfo.new(sa, Socket::PF_UNSPEC, socktype) ]
+  end
+
+  def recvfrom_nonblock(*args)
+    begin
+      self._setnonblock(true)
+      self._recvfrom(*args)
+    ensure
+      self._setnonblock(false)
+    end
+  end
+
+  def sysaccept
+    Socket._accept(self.fileno)[0]
+  end
+end
+
+class UNIXSocket < BasicSocket
+  def initialize(path, &block)
+    if self.is_a? UNIXServer
+      super(path, "r")
+    else
+      super(Socket._socket(Socket::AF_UNIX, Socket::SOCK_STREAM, 0), "r+")
+      Socket._connect(self.fileno, Socket.sockaddr_un(path))
+
+      if block_given?
+        begin
+          yield self
+        ensure
+          begin
+            self.close unless self.closed?
+          rescue StandardError
+          end
+        end
+      end
+    end
+  end
+
+  def self.socketpair(type=Socket::SOCK_STREAM, protocol=0)
+    a = Socket.socketpair(Socket::AF_UNIX, type, protocol)
+    [ UNIXSocket.for_fd(a[0]), UNIXSocket.for_fd(a[1]) ]
+  end
+
+  class << self
+    alias pair socketpair
+  end
+
+  def addr
+    [ "AF_UNIX", path ]
+  end
+
+  def path
+    Addrinfo.new(self.getsockname).unix_path
+  end
+
+  def peeraddr
+    [ "AF_UNIX", Addrinfo.new(self.getpeername).unix_path ]
+  end
+
+  #def recv_io
+
+  def recvfrom(maxlen, flags=0)
+    msg, sa = _recvfrom(maxlen, flags)
+    path = (sa.size > 0) ? Addrinfo.new(sa).unix_path : ""
+    [ msg, [ "AF_UNIX", path ] ]
+  end
+
+  #def send_io
+end
+
+class UNIXServer < UNIXSocket
+  def initialize(path)
+    fd = Socket._socket(Socket::AF_UNIX, Socket::SOCK_STREAM, 0)
+    begin
+      super(fd)
+      Socket._bind(fd, Socket.pack_sockaddr_un(path))
+      self.listen(5)
+    rescue => e
+      IO._sysclose(fd) rescue nil
+      raise e
+    end
+
+    if block_given?
+      begin
+        yield self
+      ensure
+        self.close rescue nil unless self.closed?
+      end
+    end
+  end
+
+  def accept
+    fd = self.sysaccept
+    begin
+      sock = UNIXSocket.for_fd(fd)
+    rescue
+      IO._sysclose(fd) rescue nil
+    end
+    sock
+  end
+
+  def accept_nonblock
+    begin
+      self._setnonblock(true)
+      self.accept
+    ensure
+      self._setnonblock(false)
+    end
+  end
+
+  def listen(backlog)
+    Socket._listen(self.fileno, backlog)
+    0
+  end
+
+  def sysaccept
+    Socket._accept(self.fileno)[0]
+  end
+end
+
+class Socket
+  include Constants
+end
+
+class Socket
+  class Option
+    def initialize(family, level, optname, data)
+      @family  = family
+      @level   = level
+      @optname = optname
+      @data    = data
+    end
+
+    def self.bool(family, level, optname, bool)
+      self.new(family, level, optname, [(bool ? 1 : 0)].pack('i'))
+    end
+
+    def self.int(family, level, optname, integer)
+      self.new(family, level, optname, [integer].pack('i'))
+    end
+
+    #def self.linger(family, level, optname, integer)
+    #end
+
+    attr_reader :data, :family, :level, :optname
+
+    def bool
+      @data.unpack('i')[0] != 0
+    end
+
+    def inspect
+      "#<Socket::Option: family:#{@family} level:#{@level} optname:#{@optname} #{@data.inspect}>"
+    end
+
+    def int
+      @data.unpack('i')[0]
+    end
+
+    def linger
+      raise NotImplementedError.new
+    end
+
+    def unpack(template)
+      raise NotImplementedError.new
+    end
+  end
+end
+
+class SocketError < StandardError; end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/run_test.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/run_test.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/run_test.rb	(revision 279)
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+#
+# mrbgems test runner
+#
+
+if __FILE__ == $0
+  repository, dir = 'https://github.com/mruby/mruby.git', 'tmp/mruby'
+  build_args = ARGV
+
+  Dir.mkdir 'tmp'  unless File.exist?('tmp')
+  unless File.exist?(dir)
+    system "git clone #{repository} #{dir}"
+  end
+
+  exit system(%Q[cd #{dir}; MRUBY_CONFIG=#{File.expand_path __FILE__} ruby minirake #{build_args.join(' ')}])
+end
+
+MRuby::Build.new do |conf|
+  toolchain :gcc
+  conf.gembox 'default'
+
+  conf.gem :git => 'https://github.com/iij/mruby-mtest.git'
+  conf.gem :git => 'https://github.com/iij/mruby-io.git'
+  conf.gem :git => 'https://github.com/iij/mruby-pack.git'
+
+  conf.gem File.expand_path(File.dirname(__FILE__))
+  conf.enable_test
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/const.cstub
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/const.cstub	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/const.cstub	(revision 279)
@@ -0,0 +1,453 @@
+#ifdef AF_INET
+  define_const(AF_INET);
+#endif
+#ifdef PF_INET
+  define_const(PF_INET);
+#endif
+#ifdef AF_INET6
+  define_const(AF_INET6);
+#endif
+#ifdef PF_INET6
+  define_const(PF_INET6);
+#endif
+#ifdef AF_LINK
+  define_const(AF_LINK);
+#endif
+#ifdef PF_LINK
+  define_const(PF_LINK);
+#endif
+#ifdef AF_LOCAL
+  define_const(AF_LOCAL);
+#endif
+#ifdef PF_LOCAL
+  define_const(PF_LOCAL);
+#endif
+#ifdef AF_UNIX
+  define_const(AF_UNIX);
+#endif
+#ifdef PF_UNIX
+  define_const(PF_UNIX);
+#endif
+#ifdef AF_MAX
+  define_const(AF_MAX);
+#endif
+#ifdef AF_UNSPEC
+  define_const(AF_UNSPEC);
+#endif
+#ifdef PF_UNSPEC
+  define_const(PF_UNSPEC);
+#endif
+#ifdef AF_ROUTE
+  define_const(AF_ROUTE);
+#endif
+#ifdef PF_ROUTE
+  define_const(PF_ROUTE);
+#endif
+#ifdef AI_CANONNAME
+  define_const(AI_CANONNAME);
+#endif
+#ifdef AI_FQDN
+  define_const(AI_FQDN);
+#endif
+#ifdef AI_NUMERICHOST
+  define_const(AI_NUMERICHOST);
+#endif
+#ifdef AI_NUMERICSERV
+  define_const(AI_NUMERICSERV);
+#endif
+#ifdef AI_PASSIVE
+  define_const(AI_PASSIVE);
+#endif
+#ifdef IP_ADD_MEMBERSHIP
+  define_const(IP_ADD_MEMBERSHIP);
+#endif
+#ifdef IP_ADD_SOURCE_MEMBERSHIP
+  define_const(IP_ADD_SOURCE_MEMBERSHIP);
+#endif
+#ifdef IP_BLOCK_SOURCE
+  define_const(IP_BLOCK_SOURCE);
+#endif
+#ifdef IP_DROP_MEMBERSHIP
+  define_const(IP_DROP_MEMBERSHIP);
+#endif
+#ifdef IP_DROP_SOURCE_MEMBERSHIP
+  define_const(IP_DROP_SOURCE_MEMBERSHIP);
+#endif
+#ifdef IP_FREEBIND
+  define_const(IP_FREEBIND);
+#endif
+#ifdef IP_HDRINCL
+  define_const(IP_HDRINCL);
+#endif
+#ifdef IP_IPSEC_POLICY
+  define_const(IP_IPSEC_POLICY);
+#endif
+#ifdef IP_MINTTL
+  define_const(IP_MINTTL);
+#endif
+#ifdef IP_MSFILTER
+  define_const(IP_MSFILTER);
+#endif
+#ifdef IP_MTU
+  define_const(IP_MTU);
+#endif
+#ifdef IP_MTU_DISCOVER
+  define_const(IP_MTU_DISCOVER);
+#endif
+#ifdef IP_MULTICAST_ALL
+  define_const(IP_MULTICAST_ALL);
+#endif
+#ifdef IP_MULTICAST_IF
+  define_const(IP_MULTICAST_IF);
+#endif
+#ifdef IP_MULTICAST_LOOP
+  define_const(IP_MULTICAST_LOOP);
+#endif
+#ifdef IP_MULTICAST_TTL
+  define_const(IP_MULTICAST_TTL);
+#endif
+#ifdef IP_OPTIONS
+  define_const(IP_OPTIONS);
+#endif
+#ifdef IP_ORIGDSTADDR
+  define_const(IP_ORIGDSTADDR);
+#endif
+#ifdef IP_PASSSEC
+  define_const(IP_PASSSEC);
+#endif
+#ifdef IP_PKTINFO
+  define_const(IP_PKTINFO);
+#endif
+#ifdef IP_PKTOPTIONS
+  define_const(IP_PKTOPTIONS);
+#endif
+#ifdef IP_PMTUDISC_DO
+  define_const(IP_PMTUDISC_DO);
+#endif
+#ifdef IP_PMTUDISC_DONT
+  define_const(IP_PMTUDISC_DONT);
+#endif
+#ifdef IP_PMTUDISC_PROBE
+  define_const(IP_PMTUDISC_PROBE);
+#endif
+#ifdef IP_PMTUDISC_WANT
+  define_const(IP_PMTUDISC_WANT);
+#endif
+#ifdef IP_RECVDSTADDR
+  define_const(IP_RECVDSTADDR);
+#endif
+#ifdef IP_RECVERR
+  define_const(IP_RECVERR);
+#endif
+#ifdef IP_RECVOPTS
+  define_const(IP_RECVOPTS);
+#endif
+#ifdef IP_RECVORIGDSTADDR
+  define_const(IP_RECVORIGDSTADDR);
+#endif
+#ifdef IP_RECVRETOPTS
+  define_const(IP_RECVRETOPTS);
+#endif
+#ifdef IP_RECVTOS
+  define_const(IP_RECVTOS);
+#endif
+#ifdef IP_RECVTTL
+  define_const(IP_RECVTTL);
+#endif
+#ifdef IP_RETOPTS
+  define_const(IP_RETOPTS);
+#endif
+#ifdef IP_ROUTER_ALERT
+  define_const(IP_ROUTER_ALERT);
+#endif
+#ifdef IP_TOS
+  define_const(IP_TOS);
+#endif
+#ifdef IP_TRANSPARENT
+  define_const(IP_TRANSPARENT);
+#endif
+#ifdef IP_TTL
+  define_const(IP_TTL);
+#endif
+#ifdef IP_UNBLOCK_SOURCE
+  define_const(IP_UNBLOCK_SOURCE);
+#endif
+#ifdef IP_XFRM_POLICY
+  define_const(IP_XFRM_POLICY);
+#endif
+#ifdef IPV6_JOIN_GROUP
+  define_const(IPV6_JOIN_GROUP);
+#endif
+#ifdef IPV6_LEAVE_GROUP
+  define_const(IPV6_LEAVE_GROUP);
+#endif
+#ifdef IPV6_MULTICAST_HOPS
+  define_const(IPV6_MULTICAST_HOPS);
+#endif
+#ifdef IPV6_MULTICAST_IF
+  define_const(IPV6_MULTICAST_IF);
+#endif
+#ifdef IPV6_MULTICAST_LOOP
+  define_const(IPV6_MULTICAST_LOOP);
+#endif
+#ifdef IPV6_UNICAST_HOPS
+  define_const(IPV6_UNICAST_HOPS);
+#endif
+#ifdef IPV6_V6ONLY
+  define_const(IPV6_V6ONLY);
+#endif
+#ifdef IPPROTO_AH
+  define_const(IPPROTO_AH);
+#endif
+#ifdef IPPROTO_DSTOPTS
+  define_const(IPPROTO_DSTOPTS);
+#endif
+#ifdef IPPROTO_ESP
+  define_const(IPPROTO_ESP);
+#endif
+#ifdef IPPROTO_FRAGMENT
+  define_const(IPPROTO_FRAGMENT);
+#endif
+#ifdef IPPROTO_ICMP
+  define_const(IPPROTO_ICMP);
+#endif
+#ifdef IPPROTO_ICMPV6
+  define_const(IPPROTO_ICMPV6);
+#endif
+#ifdef IPPROTO_IP
+  define_const(IPPROTO_IP);
+#endif
+#ifdef IPPROTO_IPV6
+  define_const(IPPROTO_IPV6);
+#endif
+#ifdef IPPROTO_NONE
+  define_const(IPPROTO_NONE);
+#endif
+#ifdef IPPROTO_RAW
+  define_const(IPPROTO_RAW);
+#endif
+#ifdef IPPROTO_ROUTING
+  define_const(IPPROTO_ROUTING);
+#endif
+#ifdef IPPROTO_TCP
+  define_const(IPPROTO_TCP);
+#endif
+#ifdef IPPROTO_UDP
+  define_const(IPPROTO_UDP);
+#endif
+#ifdef MCAST_BLOCK_SOURCE
+  define_const(MCAST_BLOCK_SOURCE);
+#endif
+#ifdef MCAST_JOIN_GROUP
+  define_const(MCAST_JOIN_GROUP);
+#endif
+#ifdef MCAST_JOIN_SOURCE_GROUP
+  define_const(MCAST_JOIN_SOURCE_GROUP);
+#endif
+#ifdef MCAST_LEAVE_GROUP
+  define_const(MCAST_LEAVE_GROUP);
+#endif
+#ifdef MCAST_LEAVE_SOURCE_GROUP
+  define_const(MCAST_LEAVE_SOURCE_GROUP);
+#endif
+#ifdef MCAST_MSFILTER
+  define_const(MCAST_MSFILTER);
+#endif
+#ifdef MCAST_UNBLOCK_SOURCE
+  define_const(MCAST_UNBLOCK_SOURCE);
+#endif
+#ifdef MSG_BCAST
+  define_const(MSG_BCAST);
+#endif
+#ifdef MSG_CTRUNC
+  define_const(MSG_CTRUNC);
+#endif
+#ifdef MSG_DONTROUTE
+  define_const(MSG_DONTROUTE);
+#endif
+#ifdef MSG_DONTWAIT
+  define_const(MSG_DONTWAIT);
+#endif
+#ifdef MSG_EOR
+  define_const(MSG_EOR);
+#endif
+#ifdef MSG_MCAST
+  define_const(MSG_MCAST);
+#endif
+#ifdef MSG_NOSIGNAL
+  define_const(MSG_NOSIGNAL);
+#endif
+#ifdef MSG_OOB
+  define_const(MSG_OOB);
+#endif
+#ifdef MSG_PEEK
+  define_const(MSG_PEEK);
+#endif
+#ifdef MSG_TRUNC
+  define_const(MSG_TRUNC);
+#endif
+#ifdef MSG_WAITALL
+  define_const(MSG_WAITALL);
+#endif
+#ifdef NI_DGRAM
+  define_const(NI_DGRAM);
+#endif
+#ifdef NI_MAXHOST
+  define_const(NI_MAXHOST);
+#endif
+#ifdef NI_MAXSERV
+  define_const(NI_MAXSERV);
+#endif
+#ifdef NI_NAMEREQD
+  define_const(NI_NAMEREQD);
+#endif
+#ifdef NI_NOFQDN
+  define_const(NI_NOFQDN);
+#endif
+#ifdef NI_NUMERICHOST
+  define_const(NI_NUMERICHOST);
+#endif
+#ifdef NI_NUMERICSERV
+  define_const(NI_NUMERICSERV);
+#endif
+#ifdef SHUT_RD
+  define_const(SHUT_RD);
+#endif
+#ifdef SHUT_WR
+  define_const(SHUT_WR);
+#endif
+#ifdef SHUT_RDWR
+  define_const(SHUT_RDWR);
+#endif
+#ifdef SO_BINDANY
+  define_const(SO_BINDANY);
+#endif
+#ifdef SO_BROADCAST
+  define_const(SO_BROADCAST);
+#endif
+#ifdef SO_DEBUG
+  define_const(SO_DEBUG);
+#endif
+#ifdef SO_DONTROUTE
+  define_const(SO_DONTROUTE);
+#endif
+#ifdef SO_ERROR
+  define_const(SO_ERROR);
+#endif
+#ifdef SO_KEEPALIVE
+  define_const(SO_KEEPALIVE);
+#endif
+#ifdef SO_LINGER
+  define_const(SO_LINGER);
+#endif
+#ifdef SO_NOSIGPIPE
+  define_const(SO_NOSIGPIPE);
+#endif
+#ifdef SO_OOBINLINE
+  define_const(SO_OOBINLINE);
+#endif
+#ifdef SO_PEERCRED
+  define_const(SO_PEERCRED);
+#endif
+#ifdef SO_RCVBUF
+  define_const(SO_RCVBUF);
+#endif
+#ifdef SO_RCVLOWAT
+  define_const(SO_RCVLOWAT);
+#endif
+#ifdef SO_RCVTIMEO
+  define_const(SO_RCVTIMEO);
+#endif
+#ifdef SO_REUSEADDR
+  define_const(SO_REUSEADDR);
+#endif
+#ifdef SO_REUSEPORT
+  define_const(SO_REUSEPORT);
+#endif
+#ifdef SO_RTABLE
+  define_const(SO_RTABLE);
+#endif
+#ifdef SO_SNDBUF
+  define_const(SO_SNDBUF);
+#endif
+#ifdef SO_SNDLOWAT
+  define_const(SO_SNDLOWAT);
+#endif
+#ifdef SO_SNDTIMEO
+  define_const(SO_SNDTIMEO);
+#endif
+#ifdef SO_SPLICE
+  define_const(SO_SPLICE);
+#endif
+#ifdef SO_TIMESTAMP
+  define_const(SO_TIMESTAMP);
+#endif
+#ifdef SO_TYPE
+  define_const(SO_TYPE);
+#endif
+#ifdef SOCK_DGRAM
+  define_const(SOCK_DGRAM);
+#endif
+#ifdef SOCK_RAW
+  define_const(SOCK_RAW);
+#endif
+#ifdef SOCK_SEQPACKET
+  define_const(SOCK_SEQPACKET);
+#endif
+#ifdef SOCK_STREAM
+  define_const(SOCK_STREAM);
+#endif
+#ifdef SOL_SOCKET
+  define_const(SOL_SOCKET);
+#endif
+#ifdef TCP_CONGCTL
+  define_const(TCP_CONGCTL);
+#endif
+#ifdef TCP_CONGESTION
+  define_const(TCP_CONGESTION);
+#endif
+#ifdef TCP_CORK
+  define_const(TCP_CORK);
+#endif
+#ifdef TCP_DEFER_ACCEPT
+  define_const(TCP_DEFER_ACCEPT);
+#endif
+#ifdef TCP_INFO
+  define_const(TCP_INFO);
+#endif
+#ifdef TCP_KEEPCNT
+  define_const(TCP_KEEPCNT);
+#endif
+#ifdef TCP_KEEPIDLE
+  define_const(TCP_KEEPIDLE);
+#endif
+#ifdef TCP_KEEPINIT
+  define_const(TCP_KEEPINIT);
+#endif
+#ifdef TCP_KEEPINTVL
+  define_const(TCP_KEEPINTVL);
+#endif
+#ifdef TCP_LINGER2
+  define_const(TCP_LINGER2);
+#endif
+#ifdef TCP_MAXSEG
+  define_const(TCP_MAXSEG);
+#endif
+#ifdef TCP_MD5SIG
+  define_const(TCP_MD5SIG);
+#endif
+#ifdef TCP_NODELAY
+  define_const(TCP_NODELAY);
+#endif
+#ifdef TCP_QUICKACK
+  define_const(TCP_QUICKACK);
+#endif
+#ifdef TCP_SACK_ENABLE
+  define_const(TCP_SACK_ENABLE);
+#endif
+#ifdef TCP_SYNCNT
+  define_const(TCP_SYNCNT);
+#endif
+#ifdef TCP_WINDOW_CLAMP
+  define_const(TCP_WINDOW_CLAMP);
+#endif
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/const.def
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/const.def	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/const.def	(revision 279)
@@ -0,0 +1,163 @@
+AF_INET
+PF_INET
+AF_INET6
+PF_INET6
+AF_LINK
+PF_LINK
+AF_LOCAL
+PF_LOCAL
+AF_UNIX
+PF_UNIX
+AF_MAX
+AF_UNSPEC
+PF_UNSPEC
+AF_ROUTE
+PF_ROUTE
+
+AI_CANONNAME
+AI_FQDN
+AI_NUMERICHOST
+AI_NUMERICSERV
+AI_PASSIVE
+
+IP_ADD_MEMBERSHIP
+IP_ADD_SOURCE_MEMBERSHIP
+IP_BLOCK_SOURCE
+IP_DROP_MEMBERSHIP
+IP_DROP_SOURCE_MEMBERSHIP
+IP_FREEBIND
+IP_HDRINCL
+IP_IPSEC_POLICY
+IP_MINTTL
+IP_MSFILTER
+IP_MTU
+IP_MTU_DISCOVER
+IP_MULTICAST_ALL
+IP_MULTICAST_IF
+IP_MULTICAST_LOOP
+IP_MULTICAST_TTL
+IP_OPTIONS
+IP_ORIGDSTADDR
+IP_PASSSEC
+IP_PKTINFO
+IP_PKTOPTIONS
+IP_PMTUDISC_DO
+IP_PMTUDISC_DONT
+IP_PMTUDISC_PROBE
+IP_PMTUDISC_WANT
+IP_RECVDSTADDR
+IP_RECVERR
+IP_RECVOPTS
+IP_RECVORIGDSTADDR
+IP_RECVRETOPTS
+IP_RECVTOS
+IP_RECVTTL
+IP_RETOPTS
+IP_ROUTER_ALERT
+IP_TOS
+IP_TRANSPARENT
+IP_TTL
+IP_UNBLOCK_SOURCE
+IP_XFRM_POLICY
+
+IPV6_JOIN_GROUP
+IPV6_LEAVE_GROUP
+IPV6_MULTICAST_HOPS
+IPV6_MULTICAST_IF
+IPV6_MULTICAST_LOOP
+IPV6_UNICAST_HOPS
+IPV6_V6ONLY
+
+IPPROTO_AH
+IPPROTO_DSTOPTS
+IPPROTO_ESP
+IPPROTO_FRAGMENT
+IPPROTO_ICMP
+IPPROTO_ICMPV6
+IPPROTO_IP
+IPPROTO_IPV6
+IPPROTO_NONE
+IPPROTO_RAW
+IPPROTO_ROUTING
+IPPROTO_TCP
+IPPROTO_UDP
+
+MCAST_BLOCK_SOURCE
+MCAST_JOIN_GROUP
+MCAST_JOIN_SOURCE_GROUP
+MCAST_LEAVE_GROUP
+MCAST_LEAVE_SOURCE_GROUP
+MCAST_MSFILTER
+MCAST_UNBLOCK_SOURCE
+
+MSG_BCAST
+MSG_CTRUNC
+MSG_DONTROUTE
+MSG_DONTWAIT
+MSG_EOR
+MSG_MCAST
+MSG_NOSIGNAL
+MSG_OOB
+MSG_PEEK
+MSG_TRUNC
+MSG_WAITALL
+
+NI_DGRAM
+NI_MAXHOST
+NI_MAXSERV
+NI_NAMEREQD
+NI_NOFQDN
+NI_NUMERICHOST
+NI_NUMERICSERV
+
+SHUT_RD
+SHUT_WR
+SHUT_RDWR
+
+SO_BINDANY
+SO_BROADCAST
+SO_DEBUG
+SO_DONTROUTE
+SO_ERROR
+SO_KEEPALIVE
+SO_LINGER
+SO_NOSIGPIPE
+SO_OOBINLINE
+SO_PEERCRED
+SO_RCVBUF
+SO_RCVLOWAT
+SO_RCVTIMEO
+SO_REUSEADDR
+SO_REUSEPORT
+SO_RTABLE
+SO_SNDBUF
+SO_SNDLOWAT
+SO_SNDTIMEO
+SO_SPLICE
+SO_TIMESTAMP
+SO_TYPE
+
+SOCK_DGRAM
+SOCK_RAW
+SOCK_SEQPACKET
+SOCK_STREAM
+
+SOL_SOCKET
+
+TCP_CONGCTL
+TCP_CONGESTION
+TCP_CORK
+TCP_DEFER_ACCEPT
+TCP_INFO
+TCP_KEEPCNT
+TCP_KEEPIDLE
+TCP_KEEPINIT
+TCP_KEEPINTVL
+TCP_LINGER2
+TCP_MAXSEG
+TCP_MD5SIG
+TCP_NODELAY
+TCP_QUICKACK
+TCP_SACK_ENABLE
+TCP_SYNCNT
+TCP_WINDOW_CLAMP
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/gen.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/gen.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/gen.rb	(revision 279)
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname($0))
+
+f = File.open("const.cstub", "w")
+
+IO.readlines("const.def").each { |name|
+  name.sub(/^#.*/, "")
+  name.strip!
+  next if name.empty?
+
+  f.write <<CODE
+#ifdef #{name}
+  define_const(#{name});
+#endif
+CODE
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/socket.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/socket.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/src/socket.c	(revision 279)
@@ -0,0 +1,776 @@
+/*
+** socket.c - Socket module
+**
+** See Copyright Notice in mruby.h
+*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <string.h>
+
+/*#include <unistd.h>*/
+extern int gethostname(char *name, size_t len);
+
+#include "mruby.h"
+#include "mruby/array.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/string.h"
+#include "mruby/variable.h"
+#include "error.h"
+
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 255
+#endif
+#ifndef NI_MAXSERV
+#define NI_MAXSERV 32
+#endif
+#define E_SOCKET_ERROR             (mrb_class_get(mrb, "SocketError"))
+
+#if !defined(mrb_cptr)
+#define mrb_cptr_value(m,p) mrb_voidp_value((m),(p))
+#define mrb_cptr(o) mrb_voidp(o)
+#define mrb_cptr_p(o) mrb_voidp_p(o)
+#endif
+
+//#ifdef _WIN32
+const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
+{
+    if (af == AF_INET)
+    {
+	struct sockaddr_in in;
+	memset(&in, 0, sizeof(in));
+	in.sin_family = AF_INET;
+	memcpy(&in.sin_addr, src, sizeof(struct in_addr));
+	getnameinfo((struct sockaddr *)&in, sizeof(struct
+		    sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST);
+	return dst;
+    }
+    else if (af == AF_INET6)
+    {
+	struct sockaddr_in6 in;
+	memset(&in, 0, sizeof(in));
+	in.sin6_family = AF_INET6;
+	memcpy(&in.sin6_addr, src, sizeof(struct in6_addr));
+	getnameinfo((struct sockaddr *)&in, sizeof(struct
+		    sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST);
+	return dst;
+    }
+    return NULL;
+}
+
+int inet_pton(int af, const char *src, void *dst)
+{
+    struct addrinfo hints, *res, *ressave;
+
+    memset(&hints, 0, sizeof(struct addrinfo));
+    hints.ai_family = af;
+
+    if (getaddrinfo(src, NULL, &hints, &res) != 0)
+    {
+	printf("Couldn't resolve host %s\n", src);
+	return -1;
+    }
+
+    ressave = res;
+
+    while (res)
+    {
+	memcpy(dst, res->ai_addr, res->ai_addrlen);
+	res = res->ai_next;
+    }
+
+    freeaddrinfo(ressave);
+    return 0;
+}
+
+//#endif
+
+static mrb_value
+mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
+{
+  struct addrinfo hints, *res0, *res;
+  mrb_value ai, ary, family, lastai, nodename, protocol, sa, service, socktype;
+  mrb_int flags;
+  int arena_idx, error;
+  const char *hostname = NULL, *servname = NULL;
+
+  ary = mrb_ary_new(mrb);
+  arena_idx = mrb_gc_arena_save(mrb);  /* ary must be on arena! */
+
+  family = socktype = protocol = mrb_nil_value();
+  flags = 0;
+  mrb_get_args(mrb, "oo|oooi", &nodename, &service, &family, &socktype, &protocol, &flags);
+
+  if (mrb_string_p(nodename)) {
+    hostname = mrb_str_to_cstr(mrb, nodename);
+  } else if (mrb_nil_p(nodename)) {
+    hostname = NULL;
+  } else {
+    mrb_raise(mrb, E_TYPE_ERROR, "nodename must be String or nil");
+  }
+
+  if (mrb_string_p(service)) {
+    servname = mrb_str_to_cstr(mrb, service);
+  } else if (mrb_fixnum_p(service)) {
+    servname = mrb_str_to_cstr(mrb, mrb_funcall(mrb, service, "to_s", 0));
+  } else if (mrb_nil_p(service)) {
+    servname = NULL;
+  } else {
+    mrb_raise(mrb, E_TYPE_ERROR, "service must be String, Fixnum, or nil");
+  }
+
+  memset(&hints, 0, sizeof(hints));
+  hints.ai_flags = flags;
+
+  if (mrb_fixnum_p(family)) {
+    hints.ai_family = mrb_fixnum(family);
+  }
+
+  if (mrb_fixnum_p(socktype)) {
+    hints.ai_socktype = mrb_fixnum(socktype);
+  }
+
+  lastai = mrb_cv_get(mrb, klass, mrb_intern_lit(mrb, "_lastai"));
+  if (mrb_cptr_p(lastai)) {
+    freeaddrinfo(mrb_cptr(lastai));
+    mrb_cv_set(mrb, klass, mrb_intern_lit(mrb, "_lastai"), mrb_nil_value());
+  }
+
+  error = getaddrinfo(hostname, servname, &hints, &res0);
+  if (error) {
+    mrb_raisef(mrb, E_SOCKET_ERROR, "getaddrinfo: %S", mrb_str_new_cstr(mrb, gai_strerror(error)));
+  }
+  mrb_cv_set(mrb, klass, mrb_intern_lit(mrb, "_lastai"), mrb_cptr_value(mrb, res0));
+
+  for (res = res0; res != NULL; res = res->ai_next) {
+    sa = mrb_str_new(mrb, (void *)res->ai_addr, res->ai_addrlen);
+    ai = mrb_funcall(mrb, klass, "new", 4, sa, mrb_fixnum_value(res->ai_family), mrb_fixnum_value(res->ai_socktype), mrb_fixnum_value(res->ai_protocol));
+    mrb_ary_push(mrb, ary, ai);
+    mrb_gc_arena_restore(mrb, arena_idx);
+  }
+
+  freeaddrinfo(res0);
+  mrb_cv_set(mrb, klass, mrb_intern_lit(mrb, "_lastai"), mrb_nil_value());
+
+  return ary;
+}
+
+static mrb_value
+mrb_addrinfo_getnameinfo(mrb_state *mrb, mrb_value self)
+{
+  mrb_int flags;
+  mrb_value ary, host, sastr, serv;
+  int error;
+
+  flags = 0;
+  mrb_get_args(mrb, "|i", &flags);
+  host = mrb_str_buf_new(mrb, NI_MAXHOST);
+  serv = mrb_str_buf_new(mrb, NI_MAXSERV);
+
+  sastr = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@sockaddr"));
+  if (!mrb_string_p(sastr)) {
+    mrb_raise(mrb, E_SOCKET_ERROR, "invalid sockaddr");
+  }
+  error = getnameinfo((struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr), RSTRING_PTR(host), NI_MAXHOST, RSTRING_PTR(serv), NI_MAXSERV, flags);
+  if (error != 0) {
+    mrb_raisef(mrb, E_SOCKET_ERROR, "getnameinfo: %s", gai_strerror(error));
+  }
+  ary = mrb_ary_new_capa(mrb, 2);
+  mrb_str_resize(mrb, host, strlen(RSTRING_PTR(host)));
+  mrb_ary_push(mrb, ary, host);
+  mrb_str_resize(mrb, serv, strlen(RSTRING_PTR(serv)));
+  mrb_ary_push(mrb, ary, serv);
+  return ary;
+}
+
+static mrb_value
+mrb_addrinfo_unix_path(mrb_state *mrb, mrb_value self)
+{
+  mrb_value sastr;
+
+  sastr = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@sockaddr"));
+  if (((struct sockaddr *)RSTRING_PTR(sastr))->sa_family != AF_UNIX)
+    mrb_raise(mrb, E_SOCKET_ERROR, "need AF_UNIX address");
+  return mrb_str_new_cstr(mrb, ((struct sockaddr_un *)RSTRING_PTR(sastr))->sun_path);
+}
+
+static mrb_value
+sa2addrlist(mrb_state *mrb, const struct sockaddr *sa, socklen_t salen)
+{
+  mrb_value ary, host;
+  unsigned short port;
+  const char *afstr;
+
+  switch (sa->sa_family) {
+  case AF_INET:
+    afstr = "AF_INET";
+    port = ((struct sockaddr_in *)sa)->sin_port;
+    break;
+  case AF_INET6:
+    afstr = "AF_INET6";
+    port = ((struct sockaddr_in6 *)sa)->sin6_port;
+    break;
+  default:
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "bad af");
+    return mrb_nil_value();
+  }
+  port = ntohs(port);
+  host = mrb_str_buf_new(mrb, NI_MAXHOST);
+  if (getnameinfo(sa, salen, RSTRING_PTR(host), NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == -1)
+    mrb_sys_fail(mrb, "getnameinfo");
+  mrb_str_resize(mrb, host, strlen(RSTRING_PTR(host)));
+  ary = mrb_ary_new_capa(mrb, 4);
+  mrb_ary_push(mrb, ary, mrb_str_new_cstr(mrb, afstr));
+  mrb_ary_push(mrb, ary, mrb_fixnum_value(port));
+  mrb_ary_push(mrb, ary, host);
+  mrb_ary_push(mrb, ary, host);
+  return ary;
+}
+
+static int
+socket_fd(mrb_state *mrb, mrb_value sock)
+{
+  return mrb_fixnum(mrb_funcall(mrb, sock, "fileno", 0));
+}
+
+static int
+socket_family(int s)
+{
+  struct sockaddr_storage ss;
+  socklen_t salen;
+
+  salen = sizeof(ss);
+  if (getsockname(s, (struct sockaddr *)&ss, &salen) == -1)
+    return AF_UNSPEC;
+  return ss.ss_family;
+}
+
+static mrb_value
+mrb_basicsocket_getpeereid(mrb_state *mrb, mrb_value self)
+{ 
+#ifdef HAVE_GETPEEREID
+  mrb_value ary;
+  gid_t egid;
+  uid_t euid;
+  int s;
+  
+  s = socket_fd(mrb, self);
+  if (getpeereid(s, &euid, &egid) != 0)
+    mrb_sys_fail(mrb, "getpeereid");
+
+  ary = mrb_ary_new_capa(mrb, 2);
+  mrb_ary_push(mrb, ary, mrb_fixnum_value((mrb_int)euid));
+  mrb_ary_push(mrb, ary, mrb_fixnum_value((mrb_int)egid));
+  return ary;
+#else
+  mrb_raise(mrb, E_RUNTIME_ERROR, "getpeereid is not avaialble on this system");
+  return mrb_nil_value();
+#endif
+}
+
+static mrb_value
+mrb_basicsocket_getpeername(mrb_state *mrb, mrb_value self)
+{ 
+  struct sockaddr_storage ss;
+  socklen_t salen;
+  
+  salen = sizeof(ss);
+  if (getpeername(socket_fd(mrb, self), (struct sockaddr *)&ss, &salen) != 0)
+    mrb_sys_fail(mrb, "getpeername");
+
+  return mrb_str_new(mrb, (void *)&ss, salen);
+}
+
+static mrb_value
+mrb_basicsocket_getsockname(mrb_state *mrb, mrb_value self)
+{ 
+  struct sockaddr_storage ss;
+  socklen_t salen;
+  
+  salen = sizeof(ss);
+  if (getsockname(socket_fd(mrb, self), (struct sockaddr *)&ss, &salen) != 0)
+    mrb_sys_fail(mrb, "getsockname");
+
+  return mrb_str_new(mrb, (void *)&ss, salen);
+}
+
+static mrb_value
+mrb_basicsocket_getsockopt(mrb_state *mrb, mrb_value self)
+{ 
+  char opt[8];
+  int s;
+  mrb_int family, level, optname;
+  mrb_value c, data;
+  socklen_t optlen;
+
+  mrb_get_args(mrb, "ii", &level, &optname);
+  s = socket_fd(mrb, self);
+  optlen = sizeof(opt);
+  if (getsockopt(s, level, optname, opt, &optlen) == -1)
+    mrb_sys_fail(mrb, "getsockopt");
+  c = mrb_const_get(mrb, mrb_obj_value(mrb_class_get(mrb, "Socket")), mrb_intern_lit(mrb, "Option"));
+  family = socket_family(s);
+  data = mrb_str_new(mrb, opt, optlen);
+  return mrb_funcall(mrb, c, "new", 4, mrb_fixnum_value(family), mrb_fixnum_value(level), mrb_fixnum_value(optname), data);
+}
+
+static mrb_value
+mrb_basicsocket_recv(mrb_state *mrb, mrb_value self)
+{ 
+  int n;
+  mrb_int maxlen, flags = 0;
+  mrb_value buf;
+
+  mrb_get_args(mrb, "i|i", &maxlen, &flags);
+  buf = mrb_str_buf_new(mrb, maxlen);
+  n = recv(socket_fd(mrb, self), RSTRING_PTR(buf), maxlen, flags);
+  if (n == -1)
+    mrb_sys_fail(mrb, "recv");
+  mrb_str_resize(mrb, buf, n);
+  return buf;
+}
+
+static mrb_value
+mrb_basicsocket_recvfrom(mrb_state *mrb, mrb_value self)
+{ 
+  int n;
+  mrb_int maxlen, flags = 0;
+  mrb_value ary, buf, sa;
+  socklen_t socklen;
+
+  mrb_get_args(mrb, "i|i", &maxlen, &flags);
+  buf = mrb_str_buf_new(mrb, maxlen);
+  socklen = sizeof(struct sockaddr_storage);
+  sa = mrb_str_buf_new(mrb, socklen);
+  n = recvfrom(socket_fd(mrb, self), RSTRING_PTR(buf), maxlen, flags, (struct sockaddr *)RSTRING_PTR(sa), &socklen);
+  if (n == -1)
+    mrb_sys_fail(mrb, "recvfrom");
+  mrb_str_resize(mrb, buf, n);
+  mrb_str_resize(mrb, sa, socklen);
+  ary = mrb_ary_new_capa(mrb, 2);
+  mrb_ary_push(mrb, ary, buf);
+  mrb_ary_push(mrb, ary, sa);
+  return ary;
+}
+
+static mrb_value
+mrb_basicsocket_send(mrb_state *mrb, mrb_value self)
+{ 
+  int n;
+  mrb_int flags;
+  mrb_value dest, mesg;
+
+  dest = mrb_nil_value();
+  mrb_get_args(mrb, "Si|S", &mesg, &flags, &dest);
+  if (mrb_nil_p(dest)) {
+    n = send(socket_fd(mrb, self), RSTRING_PTR(mesg), RSTRING_LEN(mesg), flags);
+  } else {
+    n = sendto(socket_fd(mrb, self), RSTRING_PTR(mesg), RSTRING_LEN(mesg), flags, (const void *)RSTRING_PTR(dest), RSTRING_LEN(dest));
+  }
+  if (n == -1)
+    mrb_sys_fail(mrb, "send");
+  return mrb_fixnum_value(n);
+}
+
+static mrb_value
+mrb_basicsocket_setnonblock(mrb_state *mrb, mrb_value self)
+{ 
+  int fd, flags;
+  mrb_value bool;
+
+  mrb_get_args(mrb, "o", &bool);
+  fd = socket_fd(mrb, self);
+  flags = fcntl(fd, F_GETFL, 0);
+  if (flags == 1)
+    mrb_sys_fail(mrb, "fcntl");
+  if (mrb_test(bool))
+    flags |= O_NONBLOCK;
+  else
+    flags &= ~O_NONBLOCK;
+  if (fcntl(fd, F_SETFL, flags) == -1)
+    mrb_sys_fail(mrb, "fcntl");
+  return mrb_nil_value();
+}
+
+static mrb_value
+mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
+{ 
+  int argc, s;
+  mrb_int level = 0, optname;
+  mrb_value optval, so;
+
+  argc = mrb_get_args(mrb, "o|io", &so, &optname, &optval);
+  if (argc == 3) {
+    if (!mrb_fixnum_p(so)) {
+      mrb_raise(mrb, E_ARGUMENT_ERROR, "level is not an integer");
+    }
+    level = mrb_fixnum(so);
+    if (mrb_string_p(optval)) {
+      /* that's good */
+    } else if (mrb_type(optval) == MRB_TT_TRUE || mrb_type(optval) == MRB_TT_FALSE) {
+      mrb_int i = mrb_test(optval) ? 1 : 0;
+      optval = mrb_str_new(mrb, (char *)&i, sizeof(i));
+    } else if (mrb_fixnum_p(optval)) {
+      mrb_int i = mrb_fixnum(optval);
+      optval = mrb_str_new(mrb, (char *)&i, sizeof(i));
+    } else {
+      mrb_raise(mrb, E_ARGUMENT_ERROR, "optval should be true, false, an integer, or a string");
+    }
+  } else if (argc == 1) {
+    if (strcmp(mrb_obj_classname(mrb, so), "Socket::Option") != 0)
+      mrb_raisef(mrb, E_ARGUMENT_ERROR, "not an instance of Socket::Option");
+    level = mrb_fixnum(mrb_funcall(mrb, so, "level", 0));
+    optname = mrb_fixnum(mrb_funcall(mrb, so, "optname", 0));
+    optval = mrb_funcall(mrb, so, "data", 0);
+  } else {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 3)", argc);
+  }
+
+  s = socket_fd(mrb, self);
+  if (setsockopt(s, level, optname, RSTRING_PTR(optval), RSTRING_LEN(optval)) == -1)
+    mrb_sys_fail(mrb, "setsockopt");
+  return mrb_fixnum_value(0);
+}
+
+static mrb_value
+mrb_basicsocket_shutdown(mrb_state *mrb, mrb_value self)
+{ 
+  mrb_int how = SHUT_RDWR;
+
+  mrb_get_args(mrb, "|i", &how);
+  if (shutdown(socket_fd(mrb, self), how) != 0)
+    mrb_sys_fail(mrb, "shutdown");
+  return mrb_fixnum_value(0);
+}
+
+static mrb_value
+mrb_ipsocket_ntop(mrb_state *mrb, mrb_value klass)
+{ 
+  mrb_int af, n;
+  char *addr, buf[50];
+
+  mrb_get_args(mrb, "is", &af, &addr, &n);
+  if ((af == AF_INET && n != 4) || (af == AF_INET6 && n != 16))
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid address");
+  if (inet_ntop(af, addr, buf, sizeof(buf)) == NULL)
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid address");
+  return mrb_str_new_cstr(mrb, buf);
+}
+
+static mrb_value
+mrb_ipsocket_pton(mrb_state *mrb, mrb_value klass)
+{ 
+  mrb_int af, n;
+  char *bp, buf[50];
+
+  mrb_get_args(mrb, "is", &af, &bp, &n);
+  if (n > sizeof(buf) - 1)
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid address");
+  memcpy(buf, bp, n);
+  buf[n] = '\0';
+
+  if (af == AF_INET) {
+    struct in_addr in;
+    if (inet_pton(AF_INET, buf, (void *)&in.s_addr) != 1)
+      goto invalid;
+    return mrb_str_new(mrb, (char *)&in.s_addr, 4);
+  } else if (af == AF_INET6) {
+    struct in6_addr in6;
+    if (inet_pton(AF_INET6, buf, (void *)&in6.s6_addr) != 1)
+      goto invalid;
+    return mrb_str_new(mrb, (char *)&in6.s6_addr, 16);
+  } else
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "unsupported address family");
+
+invalid:
+  mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid address");
+  return mrb_nil_value(); /* dummy */
+}
+
+static mrb_value
+mrb_ipsocket_recvfrom(mrb_state *mrb, mrb_value self)
+{ 
+  struct sockaddr_storage ss;
+  socklen_t socklen;
+  mrb_value a, buf, pair;
+  mrb_int flags, maxlen, n;
+  int fd;
+
+  fd = socket_fd(mrb, self);
+  flags = 0;
+  mrb_get_args(mrb, "i|i", &maxlen, &flags);
+  buf = mrb_str_buf_new(mrb, maxlen);
+  socklen = sizeof(ss);
+  n = recvfrom(fd, RSTRING_PTR(buf), maxlen, flags,
+  	       (struct sockaddr *)&ss, &socklen);
+  if (n == -1) {
+    mrb_sys_fail(mrb, "recvfrom");
+  }
+  mrb_str_resize(mrb, buf, n);
+  a = sa2addrlist(mrb, (struct sockaddr *)&ss, socklen);
+  pair = mrb_ary_new_capa(mrb, 2);
+  mrb_ary_push(mrb, pair, buf);
+  mrb_ary_push(mrb, pair, a);
+  return pair;
+}
+
+static mrb_value
+mrb_socket_gethostname(mrb_state *mrb, mrb_value cls)
+{
+  mrb_value buf;
+  size_t bufsize;
+  
+#ifdef HOST_NAME_MAX
+  bufsize = HOST_NAME_MAX + 1;
+#else
+  bufsize = 256;
+#endif
+  buf = mrb_str_buf_new(mrb, bufsize);
+  if (gethostname(RSTRING_PTR(buf), bufsize) != 0)
+    mrb_sys_fail(mrb, "gethostname");
+  mrb_str_resize(mrb, buf, strlen(RSTRING_PTR(buf)));
+  return buf;
+}
+
+static mrb_value
+mrb_socket_accept(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value ary, sastr;
+  int s1;
+  mrb_int s0;
+  socklen_t socklen;
+
+  mrb_get_args(mrb, "i", &s0);
+  socklen = sizeof(struct sockaddr_storage);
+  sastr = mrb_str_buf_new(mrb, socklen);
+  s1 = accept(s0, (struct sockaddr *)RSTRING_PTR(sastr), &socklen);
+  if (s1 == -1) {
+    mrb_sys_fail(mrb, "accept");
+  }
+  // XXX: possible descriptor leakage here!
+  mrb_str_resize(mrb, sastr, socklen);
+  ary = mrb_ary_new_capa(mrb, 2);
+  mrb_ary_push(mrb, ary, mrb_fixnum_value(s1));
+  mrb_ary_push(mrb, ary, sastr);
+  return ary;
+}
+
+static mrb_value
+mrb_socket_bind(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value sastr;
+  int s;
+
+  mrb_get_args(mrb, "iS", &s, &sastr);
+  if (bind(s, (struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr)) == -1) {
+    mrb_sys_fail(mrb, "bind");
+  }
+  return mrb_nil_value();
+}
+
+static mrb_value
+mrb_socket_connect(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value sastr;
+  int s;
+
+  mrb_get_args(mrb, "iS", &s, &sastr);
+  if (connect(s, (struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr)) == -1) {
+    mrb_sys_fail(mrb, "connect");
+  }
+  return mrb_nil_value();
+}
+
+static mrb_value
+mrb_socket_listen(mrb_state *mrb, mrb_value klass)
+{
+  int backlog, s;
+
+  mrb_get_args(mrb, "ii", &s, &backlog);
+  if (listen(s, backlog) == -1) {
+    mrb_sys_fail(mrb, "listen");
+  }
+  return mrb_nil_value();
+}
+
+static mrb_value
+mrb_socket_sockaddr_family(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value sa;
+
+  mrb_get_args(mrb, "S", &sa);
+#ifdef __linux__
+  if (RSTRING_LEN(sa) < offsetof(struct sockaddr, sa_family) + sizeof(sa_family_t)) {
+    mrb_raisef(mrb, E_SOCKET_ERROR, "invalid sockaddr (too short)");
+  }
+#else
+  if (RSTRING_LEN(sa) < sizeof(struct sockaddr)) {
+    mrb_raisef(mrb, E_SOCKET_ERROR, "invalid sockaddr (too short)");
+  }
+#endif
+  return mrb_fixnum_value(((struct sockaddr *)RSTRING_PTR(sa))->sa_family);
+}
+
+static mrb_value
+mrb_socket_sockaddr_un(mrb_state *mrb, mrb_value klass)
+{
+  struct sockaddr_un *sunp;
+  mrb_value path, s;
+  
+  mrb_get_args(mrb, "S", &path);
+  if (RSTRING_LEN(path) > sizeof(sunp->sun_path) - 1) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "too long unix socket path (max: %ubytes)", (unsigned int)sizeof(sunp->sun_path) - 1);
+  }
+  s = mrb_str_buf_new(mrb, sizeof(struct sockaddr_un));
+  sunp = (struct sockaddr_un *)RSTRING_PTR(s);
+  sunp->sun_family = AF_UNIX;
+  memcpy(sunp->sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
+  sunp->sun_path[RSTRING_LEN(path)] = '\0';
+  mrb_str_resize(mrb, s, sizeof(struct sockaddr_un));
+  return s;
+}
+
+static mrb_value
+mrb_socket_socketpair(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value ary;
+  mrb_int domain, type, protocol;
+  int sv[2];
+
+  mrb_get_args(mrb, "iii", &domain, &type, &protocol);
+  if (socketpair(domain, type, protocol, sv) == -1) {
+    mrb_sys_fail(mrb, "socketpair");
+  }
+  // XXX: possible descriptor leakage here!
+  ary = mrb_ary_new_capa(mrb, 2);
+  mrb_ary_push(mrb, ary, mrb_fixnum_value(sv[0]));
+  mrb_ary_push(mrb, ary, mrb_fixnum_value(sv[1]));
+  return ary;
+}
+
+static mrb_value
+mrb_socket_socket(mrb_state *mrb, mrb_value klass)
+{
+  mrb_int domain, type, protocol;
+  int s;
+
+  mrb_get_args(mrb, "iii", &domain, &type, &protocol);
+  s = socket(domain, type, protocol);
+  if (s == -1)
+    mrb_sys_fail(mrb, "socket");
+  return mrb_fixnum_value(s);
+}
+
+static mrb_value
+mrb_tcpsocket_allocate(mrb_state *mrb, mrb_value klass)
+{
+  struct RClass *c = mrb_class_ptr(klass);
+  enum mrb_vtype ttype = MRB_INSTANCE_TT(c);
+
+  /* copied from mrb_instance_alloc() */
+  if (ttype == 0) ttype = MRB_TT_OBJECT;
+  return mrb_obj_value((struct RObject*)mrb_obj_alloc(mrb, ttype, c));
+}
+
+/* Windows overrides for IO methods on BasicSocket objects.
+ * This is because sockets on Windows are not the same as file
+ * descriptors, and thus functions which operate on file descriptors
+ * will break on socket descriptors.
+ */
+
+void
+mrb_mruby_socket_gem_init(mrb_state* mrb)
+{
+  struct RClass *io, *ai, *sock, *bsock, *ipsock, *tcpsock;
+  struct RClass *constants;
+
+  struct RClass *usock;
+
+  ai = mrb_define_class(mrb, "Addrinfo", mrb->object_class);
+  mrb_mod_cv_set(mrb, ai, mrb_intern_lit(mrb, "_lastai"), mrb_nil_value());
+  mrb_define_class_method(mrb, ai, "getaddrinfo", mrb_addrinfo_getaddrinfo, MRB_ARGS_REQ(2)|MRB_ARGS_OPT(4));
+  mrb_define_method(mrb, ai, "getnameinfo", mrb_addrinfo_getnameinfo, MRB_ARGS_OPT(1));
+  mrb_define_method(mrb, ai, "unix_path", mrb_addrinfo_unix_path, MRB_ARGS_NONE());
+
+  io = mrb_class_get(mrb, "IO");
+
+  bsock = mrb_define_class(mrb, "BasicSocket", io);
+  mrb_define_method(mrb, bsock, "_recvfrom", mrb_basicsocket_recvfrom, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  mrb_define_method(mrb, bsock, "_setnonblock", mrb_basicsocket_setnonblock, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, bsock, "getpeereid", mrb_basicsocket_getpeereid, MRB_ARGS_NONE());
+  mrb_define_method(mrb, bsock, "getpeername", mrb_basicsocket_getpeername, MRB_ARGS_NONE());
+  mrb_define_method(mrb, bsock, "getsockname", mrb_basicsocket_getsockname, MRB_ARGS_NONE());
+  mrb_define_method(mrb, bsock, "getsockopt", mrb_basicsocket_getsockopt, MRB_ARGS_REQ(2));
+  mrb_define_method(mrb, bsock, "recv", mrb_basicsocket_recv, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  // #recvmsg(maxlen, flags=0)
+  mrb_define_method(mrb, bsock, "send", mrb_basicsocket_send, MRB_ARGS_REQ(2)|MRB_ARGS_OPT(1));
+  // #sendmsg
+  // #sendmsg_nonblock
+  mrb_define_method(mrb, bsock, "setsockopt", mrb_basicsocket_setsockopt, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(2));
+  mrb_define_method(mrb, bsock, "shutdown", mrb_basicsocket_shutdown, MRB_ARGS_OPT(1));
+
+  ipsock = mrb_define_class(mrb, "IPSocket", bsock);
+  mrb_define_class_method(mrb, ipsock, "ntop", mrb_ipsocket_ntop, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, ipsock, "pton", mrb_ipsocket_pton, MRB_ARGS_REQ(2));
+  mrb_define_method(mrb, ipsock, "recvfrom", mrb_ipsocket_recvfrom, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+
+  tcpsock = mrb_define_class(mrb, "TCPSocket", ipsock);
+  mrb_define_class_method(mrb, tcpsock, "_allocate", mrb_tcpsocket_allocate, MRB_ARGS_NONE());
+  mrb_define_class(mrb, "TCPServer", tcpsock);
+
+  mrb_define_class(mrb, "UDPSocket", ipsock);
+  //#recvfrom_nonblock
+
+  sock = mrb_define_class(mrb, "Socket", bsock);
+  mrb_define_class_method(mrb, sock, "_accept", mrb_socket_accept, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, sock, "_bind", mrb_socket_bind, MRB_ARGS_REQ(3));
+  mrb_define_class_method(mrb, sock, "_connect", mrb_socket_connect, MRB_ARGS_REQ(3));
+  mrb_define_class_method(mrb, sock, "_listen", mrb_socket_listen, MRB_ARGS_REQ(2));
+  mrb_define_class_method(mrb, sock, "_sockaddr_family", mrb_socket_sockaddr_family, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, sock, "_socket", mrb_socket_socket, MRB_ARGS_REQ(3));
+  //mrb_define_class_method(mrb, sock, "gethostbyaddr", mrb_socket_gethostbyaddr, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  //mrb_define_class_method(mrb, sock, "gethostbyname", mrb_socket_gethostbyname, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  mrb_define_class_method(mrb, sock, "gethostname", mrb_socket_gethostname, MRB_ARGS_NONE());
+  //mrb_define_class_method(mrb, sock, "getservbyname", mrb_socket_getservbyname, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  //mrb_define_class_method(mrb, sock, "getservbyport", mrb_socket_getservbyport, MRB_ARGS_REQ(1)|MRB_ARGS_OPT(1));
+  mrb_define_class_method(mrb, sock, "sockaddr_un", mrb_socket_sockaddr_un, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, sock, "socketpair", mrb_socket_socketpair, MRB_ARGS_REQ(3));
+  //mrb_define_method(mrb, sock, "sysaccept", mrb_socket_accept, MRB_ARGS_NONE());
+
+  usock = mrb_define_class(mrb, "UNIXSocket", bsock);
+  //mrb_define_class_method(mrb, usock, "pair", mrb_unixsocket_open, MRB_ARGS_OPT(2));
+  //mrb_define_class_method(mrb, usock, "socketpair", mrb_unixsocket_open, MRB_ARGS_OPT(2));
+
+  //mrb_define_method(mrb, usock, "recv_io", mrb_unixsocket_peeraddr, MRB_ARGS_NONE());
+  //mrb_define_method(mrb, usock, "recvfrom", mrb_unixsocket_peeraddr, MRB_ARGS_NONE());
+  //mrb_define_method(mrb, usock, "send_io", mrb_unixsocket_peeraddr, MRB_ARGS_NONE());
+
+  /* Windows IO Method Overrides on BasicSocket */
+
+  constants = mrb_define_module_under(mrb, sock, "Constants");
+
+#define define_const(SYM) \
+  do {								\
+    mrb_define_const(mrb, constants, #SYM, mrb_fixnum_value(SYM));	\
+  } while (0)
+
+#include "const.cstub"
+}
+
+void
+mrb_mruby_socket_gem_final(mrb_state* mrb)
+{
+  mrb_value ai;
+  ai = mrb_mod_cv_get(mrb, mrb_class_get(mrb, "Addrinfo"), mrb_intern_lit(mrb, "_lastai"));
+  if (mrb_cptr_p(ai)) {
+    freeaddrinfo(mrb_cptr(ai));
+  }
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/addrinfo.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/addrinfo.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/addrinfo.rb	(revision 279)
@@ -0,0 +1,89 @@
+assert('Addrinfo') do
+  assert_equal(Class, Addrinfo.class)
+end
+
+assert('super class of Addrinfo') do
+  assert_equal(Object, Addrinfo.superclass)
+end
+
+assert('Addrinfo.getaddrinfo') do
+  ary = Addrinfo.getaddrinfo("localhost", "domain", Socket::AF_INET, Socket::SOCK_STREAM)
+  assert_true(ary.size >= 1)
+  ai = ary[0]
+  assert_equal(ai.afamily, Socket::AF_INET)
+  assert_equal(ai.pfamily, Socket::PF_INET)
+  assert_equal(ai.socktype, Socket::SOCK_STREAM)
+  assert_equal(ai.ip_address, '127.0.0.1')
+  assert_equal(ai.ip_port, 53)
+end
+
+assert('Addrinfo.foreach') do
+  # assume Addrinfo.getaddrinfo works well
+  a = Addrinfo.getaddrinfo("localhost", "domain")
+  b = []
+  Addrinfo.foreach("localhost", "domain") { |ai| b << ai }
+  assert_equal(a.size, b.size)
+end
+
+assert('Addrinfo.ip') do
+  ai = Addrinfo.ip('127.0.0.1')
+  assert_equal('127.0.0.1', ai.ip_address)
+  assert_equal(Socket::AF_INET, ai.afamily)
+  assert_equal(0, ai.ip_port)
+  assert_equal(0, ai.socktype)
+  assert_equal(0, ai.protocol)
+end
+
+assert('Addrinfo.tcp') do
+  ai = Addrinfo.tcp('127.0.0.1', 'smtp')
+  assert_equal('127.0.0.1', ai.ip_address)
+  assert_equal(Socket::AF_INET, ai.afamily)
+  assert_equal(25, ai.ip_port)
+  assert_equal(Socket::SOCK_STREAM, ai.socktype)
+  assert_equal(Socket::IPPROTO_TCP, ai.protocol)
+end
+
+assert('Addrinfo.udp') do
+  ai = Addrinfo.udp('127.0.0.1', 'domain')
+  assert_equal('127.0.0.1', ai.ip_address)
+  assert_equal(Socket::AF_INET, ai.afamily)
+  assert_equal(53, ai.ip_port)
+  assert_equal(Socket::SOCK_DGRAM, ai.socktype)
+  assert_equal(Socket::IPPROTO_UDP, ai.protocol)
+end
+
+assert('Addrinfo.unix') do
+  a1 = Addrinfo.unix('/tmp/sock')
+  assert_true(a1.unix?)
+  assert_equal('/tmp/sock', a1.unix_path)
+  assert_equal(Socket::SOCK_STREAM, a1.socktype)
+  a2 = Addrinfo.unix('/tmp/sock', Socket::SOCK_DGRAM)
+  assert_equal(Socket::SOCK_DGRAM, a2.socktype)
+end
+
+assert('Addrinfo#afamily') do
+  ai4 = Addrinfo.new(Socket.sockaddr_in(1, '127.0.0.1'))
+  ai6 = Addrinfo.new(Socket.sockaddr_in(1, '::1'))
+  aiu = Addrinfo.new(Socket.sockaddr_un('/tmp/sock'))
+  assert_equal(Socket::AF_INET, ai4.afamily)
+  assert_equal(Socket::AF_INET6, ai6.afamily)
+  assert_equal(Socket::AF_UNIX, aiu.afamily)
+end
+
+# assert('Addrinfo#canonname') do
+
+# #getnameinfo
+# assert('Addrinfo#inspect') do
+# assert('Addrinfo#inspect_socket') do
+# assert('Addrinfo#ip?') do
+# assert('Addrinfo#ip_address') do
+# assert('Addrinfo#ip_port') do
+# assert('Addrinfo#ip_unpack') do
+# assert('Addrinfo#ipv4?') do
+# assert('Addrinfo#ipv6?') do
+# assert('Addrinfo#pfamily') do
+# assert('Addrinfo#protocol') do
+# assert('Addrinfo#socktype') do
+# assert('Addrinfo#to_sockaddr') do
+# assert('Addrinfo#unix?') do
+# #unix_path
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/basicsocket.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/basicsocket.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/basicsocket.rb	(revision 279)
@@ -0,0 +1,17 @@
+assert('BasicSocket') do
+  assert_equal(Class, BasicSocket.class)
+end
+
+assert('super class of BasicSocket') do
+  assert_equal(IO, BasicSocket.superclass)
+end
+
+assert('BasicSocket.do_not_reverse_lookup') do
+  assert_equal(BasicSocket.do_not_reverse_lookup, true)
+end
+
+assert('BasicSocket.do_not_reverse_lookup=') do
+  BasicSocket.do_not_reverse_lookup = false
+  assert_equal(BasicSocket.do_not_reverse_lookup, false)
+  BasicSocket.do_not_reverse_lookup = true
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/ipsocket.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/ipsocket.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/ipsocket.rb	(revision 279)
@@ -0,0 +1,40 @@
+# Note: most of tests below will fail if UDPSocket is broken.
+
+assert('IPSocket.getaddress') do
+  l = IPSocket.getaddress("localhost")
+  assert_true (l == "127.0.0.1" or l == "::1")
+end
+
+assert('IPSocket.addr') do
+  localhost = "127.0.0.1"
+  s = UDPSocket.new
+  s.bind(localhost, 0)
+  port = Addrinfo.new(s.getsockname).ip_port
+
+  a = s.addr
+  assert_equal "AF_INET", a[0]
+  assert_equal port,      a[1]
+  assert_equal localhost, a[2]
+  assert_equal localhost, a[3]
+  s.close
+  true
+end
+
+assert('IPSocket.peeraddr') do
+  localhost = "127.0.0.1"
+  server = UDPSocket.new
+  server.bind(localhost, 0)
+  port = server.local_address.ip_port
+
+  client = UDPSocket.new
+  client.connect(localhost, port)
+
+  a = client.peeraddr
+  assert_equal "AF_INET", a[0]
+  assert_equal port,      a[1]
+  assert_equal localhost, a[2]
+  assert_equal localhost, a[3]
+  client.close
+  server.close
+  true
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/socket.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/socket.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/socket.rb	(revision 279)
@@ -0,0 +1,34 @@
+assert('Socket.gethostname') do
+  assert_true(Socket.gethostname.is_a? String)
+end
+
+assert('Socket::getaddrinfo') do
+  ret = Socket.getaddrinfo("localhost", "domain", Socket::AF_INET, Socket::SOCK_DGRAM)
+  assert_true ret.size >= 1
+  a = ret[0]
+  assert_equal "AF_INET",           a[0]
+  assert_equal 53,                  a[1]
+  # documents says it's a hostname but CRuby returns an address
+  #assert_equal "127.0.0.1",         a[2]
+  assert_equal "127.0.0.1",         a[3]
+  assert_equal Socket::AF_INET,     a[4]
+  assert_equal Socket::SOCK_DGRAM,  a[5]
+  assert_equal Socket::IPPROTO_UDP, a[6]
+end
+
+assert('Socket#recvfrom') do
+  begin
+    sstr = "abcdefg"
+    s = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
+    c = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
+    s.bind(Socket.sockaddr_in(0, "127.0.0.1"))
+    c.send sstr, 0, s.getsockname
+    rstr, ai = s.recvfrom sstr.size
+
+    assert_equal sstr, rstr
+    assert_true "127.0.0.1", ai.ip_address
+  ensure
+    s.close rescue nil
+    c.close rescue nil
+  end
+end
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/sockettest.c
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/sockettest.c	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/sockettest.c	(revision 279)
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "mruby.h"
+
+mrb_value
+mrb_sockettest_tmppath(mrb_state *mrb, mrb_value klass)
+{
+  return mrb_str_new_cstr(mrb, tempnam(NULL, "mruby-socket"));
+}
+
+void
+mrb_mruby_socket_gem_test(mrb_state* mrb)
+{
+  struct RClass *c = mrb_define_module(mrb, "SocketTest");
+  mrb_define_class_method(mrb, c, "tmppath", mrb_sockettest_tmppath, MRB_ARGS_NONE());
+}
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/tcpsocket.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/tcpsocket.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/tcpsocket.rb	(revision 279)
@@ -0,0 +1,4 @@
+#assert('TCPSocket.gethostbyname') do
+#assert('TCPSocket.new') do
+#assert('TCPSocket#close') do
+#assert('TCPSocket#write') do
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/udpsocket.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/udpsocket.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/udpsocket.rb	(revision 279)
@@ -0,0 +1,16 @@
+assert('UDPSocket.new') do
+  s = UDPSocket.new
+  assert_true(s.is_a? UDPSocket)
+  s.close
+  s = UDPSocket.new(Socket::AF_INET6)
+  assert_true(s.is_a? UDPSocket)
+  s.close
+  true
+end
+
+#assert('UDPSocket#connect') do
+#assert('UDPSocket#send') do
+#assert('UDPSocket#recv') do
+
+#assert('UDPSocket#bind') do
+#assert('UDPSocket#recvfrom_nonblock') do
Index: /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/unix.rb
===================================================================
--- /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/unix.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mrbgems/mruby-socket/test/unix.rb	(revision 279)
@@ -0,0 +1,126 @@
+def unixserver_test_block
+  path = SocketTest.tmppath
+  File.unlink path rescue nil
+  begin
+    result = yield path
+  ensure
+    File.unlink path rescue nil
+  end
+  result
+end
+
+def with_unix_server
+  unixserver_test_block do |path|
+    UNIXServer.open(path) { |server|
+      yield path, server
+    }
+  end
+end
+
+def with_unix_client
+  with_unix_server do |path, server|
+    UNIXSocket.open(path) do |csock|
+      ssock = server.accept
+      begin
+        yield path, server, ssock, csock
+      ensure
+        ssock.close unless ssock.closed? rescue nil
+      end
+    end
+  end
+end
+
+assert('UNIXServer.new') do
+  unixserver_test_block do |path|
+    server = UNIXServer.new(path)
+    assert_true server.is_a? UNIXServer
+    server.close
+    File.unlink path
+
+    s2 = nil
+    result = UNIXServer.open(path) { |s1|
+      assert_true s1.is_a? UNIXServer
+      s2 = s1
+      1234
+    }
+    assert_equal 1234, result
+    assert_true s2.is_a? UNIXServer
+    assert_true s2.closed?
+  end
+end
+
+# assert('UNIXServer#accept_nonblock') - would block if fails
+
+assert('UNIXServer#addr') do
+  with_unix_server do |path, server|
+    assert_equal [ "AF_UNIX", path], server.addr
+  end
+end
+
+assert('UNIXServer#path') do
+  with_unix_server do |path, server|
+    assert_equal path, server.path
+  end
+end
+
+# assert('UNIXServer#peeraddr') - will raise a runtime exception
+
+assert('UNIXServer#listen') do
+  with_unix_server do |path, server|
+    assert_equal 0, server.listen(1)
+  end
+end
+
+assert('UNIXServer#sysaccept') do
+  with_unix_server do |path, server|
+    UNIXSocket.open(path) do |csock|
+      begin
+        fd = server.sysaccept
+        assert_true fd.kind_of? Integer
+      ensure
+        IO._sysclose(fd) rescue nil
+      end
+    end
+  end
+end
+
+assert('UNIXSocket.new') do
+  with_unix_server do |path, server|
+    c = UNIXSocket.new(path)
+    assert_true c.is_a? UNIXSocket
+    c.close
+    true
+  end
+end
+
+assert('UNIXSocket#addr') do
+  with_unix_client do |path, server, ssock, csock|
+    assert_equal [ "AF_UNIX", path ], ssock.addr
+    assert_equal [ "AF_UNIX", "" ],   csock.addr
+  end
+end
+
+assert('UNIXSocket#path') do
+  with_unix_client do |path, server, ssock, csock|
+    assert_equal path, ssock.path
+    assert_equal "",   csock.path
+  end
+end
+
+assert('UNIXSocket#peeraddr') do
+  with_unix_client do |path, server, ssock, csock|
+    assert_equal [ "AF_UNIX", ""   ], ssock.peeraddr
+    assert_equal [ "AF_UNIX", path ], csock.peeraddr
+  end
+end
+
+assert('UNIXSocket#recvfrom') do
+  with_unix_client do |path, server, ssock, csock|
+    str = "0123456789"
+    ssock.send str, 0
+    a = csock.recvfrom(8)
+    assert_equal str[0, 8], a[0]
+    assert_equal "AF_UNIX", a[1][0]
+    # a[1][1] would be "" or something
+  end
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/.cproject
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/.cproject	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/.cproject	(revision 279)
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="com.renesas.cdt.rz.debug.win32.configuration.Id.1552447583">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.renesas.cdt.rz.debug.win32.configuration.Id.1552447583" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactName="mruby" buildArtefactType="com.renesas.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=com.renesas.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf *.lst *.lis *.lpp *.map libgcc.a" description="" id="com.renesas.cdt.rz.debug.win32.configuration.Id.1552447583" name="Debug" parent="com.renesas.cdt.rz.debug.win32.configuration.Id">
+					<folderInfo id="com.renesas.cdt.rz.debug.win32.configuration.Id.1552447583." name="/" resourcePath="">
+						<toolChain id="com.renesas.cdt.rz.debug.win32.toolchain.Id.87786683" name="KPIT GNUARM-NONE-EABI Toolchain" superClass="com.renesas.cdt.rz.debug.win32.toolchain.Id">
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.PE" id="com.renesas.cdt.rz.debug.win32.targetplatform.Id.1600182357" name="Target Platform" osList="all" superClass="com.renesas.cdt.rz.debug.win32.targetplatform.Id"/>
+							<builder buildPath="${workspace_loc:/mruby-1.2.0}" id="com.renesas.cdt.rz.debug.win32.builder.Id.1846611762" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Builder" superClass="com.renesas.cdt.rz.debug.win32.builder.Id"/>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.libgen.Id.1116635171" name="Library Generator" superClass="com.renesas.cdt.rz.debug.win32.tool.libgen.Id">
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.ctype.458951408" name="ctype.h : æå­ãæ±ããã§ãã¯ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.ctype" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.math.1642753503" name="math.h : ä¸è§é¢æ°ãªã©æ°å¤ã®è¨ç®ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.math" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdio.961659227" name="stdio.h : å
+¥å/åºåãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdio" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdlib.509673709" name="stdlib.h : æ ¼ç´é åã®ç®¡çãªã© C ãã­ã°ã©ã ã®æ¨æºå¦çãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdlib" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.string.1550848672" name="string.h : æå­åã®æ¯è¼ã¨ã³ãã¼ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.string" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary.422121936" name="ã©ã¤ãã©ãªã¼ã®é¸æ" superClass="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary" value="com.renesas.core.LibraryGenerator.option.selectLibrary.newLib" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.libraryType.1589977374" name="ã©ã¤ãã©ãªã¼å" superClass="com.renesas.cdt.core.LibraryGenerator.option.libraryType" value="com.renesas.cdt.core.LibraryGenerator.option.libraryType.projectBuilt" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc9.1198648676" name="åé¢æ°ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-ffunction-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc9" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc14.1587684955" name="é¢æ°ã®ã¢ãã¬ã¹ãã¬ã¸ã¹ã¿ã¼ã«ç½®ããªã (-fno-function-cse)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc14" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc36.1213035210" name="Parse the whole compilation unit before starting to produce code ( -funit-at-a-time)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc36" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc10.1626842453" name="åãã¼ã¿ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-fdata-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc10" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc37.476113883" name="Align branch targets to a power-of-two boundary (-falign-jumps)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc37" value="true" valueType="boolean"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.compiler.Id.2114772705" name="Compiler" superClass="com.renesas.cdt.rz.debug.win32.tool.compiler.Id">
+								<option defaultValue="true" id="com.renesas.cdt.core.Compiler.option.misc2.2071139574" name="æ¨æºã·ã¹ãã ã»ãã£ã¬ã¯ããªã¼ã§ãããã¼ã»ãã¡ã¤ã«ãæ¤ç´¢ããªã (-nostdinc)" superClass="com.renesas.cdt.core.Compiler.option.misc2" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.architecture.712090671" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Compiler.option.architecture" value="com.renesas.cdt.rz.Debug.Compiler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.1792387458" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.cpuType" value="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.1830244232" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.1447259851" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.instructionset" value="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.interworking.260043818" name="ã¤ã³ã¿ã¼ã»ã¯ã¼ã­ã³ã° (-mthumb-interwork)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.interworking" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.367057389" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu" value="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.1426976645" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.soft" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warnStackSize.1147490000" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.core.Compiler.option.warnStackSize" value="100" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.CPUSeries.1824596418" name="CPU ã·ãªã¼ãº" superClass="com.renesas.cdt.core.Compiler.option.CPUSeries" value="RZ/A" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.device.961121392" name="Device" superClass="com.renesas.cdt.core.Compiler.option.device" value="R7S721001" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.deviceShortName.635132041" name="DeviceShortName" superClass="com.renesas.cdt.core.Compiler.option.deviceShortName" value="R7S721001" valueType="string"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines.57380421" name="ãã¯ã­å®ç¾©" superClass="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="SIMULATOR_DEBUG"/>
+									<listOptionValue builtIn="false" value="CPPAPP"/>
+								</option>
+								<inputType id="%Base.Compiler.C.InputType.Id.379655366" name="C å
+¥å" superClass="%Base.Compiler.C.InputType.Id"/>
+								<inputType id="Base.Compiler.CPP.InputType.Id.1101890027" name="C++ å
+¥å" superClass="Base.Compiler.CPP.InputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.assembler.Id.1166037999" name="Assembler" superClass="com.renesas.cdt.rz.debug.win32.tool.assembler.Id">
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.architecture.1178720663" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Assembler.option.architecture" value="com.renesas.cdt.rz.Debug.Assembler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.1700798679" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.cpuType" value="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.835685972" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.1591801771" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.instructionset" value="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu.1672411105" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu" value="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu.vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.1400638226" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.soft" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Assembler.option.includeFileDirectories.1632699435" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Assembler.option.includeFileDirectories" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/src&quot;"/>
+								</option>
+								<inputType id="%Base.Assembler.inputType.Id.1006307562" name="ã¢ã»ã³ãã©ã¼å
+¥åã¿ã¤ã" superClass="%Base.Assembler.inputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.linker.Id.497903742" name="Linker" superClass="com.renesas.cdt.rz.debug.win32.tool.linker.Id">
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories.2062570669" name="ã¢ã¼ã«ã¤ãæ¤ç´¢ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;${CONFIGDIR}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/lib/gcc/arm-none-eabi/${GCC_VERSION}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/arm-none-eabi/lib&quot;"/>
+								</option>
+								<option id="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.718941051" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Linker.option.dataEndian" value="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.little" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles.6194456" name="ã¢ã¼ã«ã¤ã ( ã©ã¤ãã©ãªã¼ ) ãã¡ã¤ã«" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles" valueType="stringList">
+									<listOptionValue builtIn="false" value="${BuildArtifactFileBaseName}"/>
+									<listOptionValue builtIn="false" value="gcc"/>
+									<listOptionValue builtIn="false" value="stdc++"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.userDefinedOptions.947383497" name="ã¦ã¼ã¶ã¼å®ç¾©ãªãã·ã§ã³" superClass="com.renesas.cdt.core.Linker.option.userDefinedOptions" valueType="stringList">
+									<listOptionValue builtIn="false" value="-e_PowerON_Reset"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.linkOrderList.298210254" name="" superClass="com.renesas.cdt.core.Linker.option.linkOrderList" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;.\src\hardware_setup.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\interrupt_handlers.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\mruby.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\reset_program.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\vector_table.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\libmruby.a&quot;"/>
+								</option>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id.1923834783" name="Objcopy" superClass="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="mruby.com.renesas.cdt.rz.projectType.win32.Id.3696189" name="Executable (Renesas)" projectType="com.renesas.cdt.rz.projectType.win32.Id"/>
+	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+	<storageModule moduleId="refreshScope" versionNumber="2">
+		<configuration configurationName="Debug">
+			<resource resourceType="PROJECT" workspacePath="/mruby"/>
+		</configuration>
+	</storageModule>
+</cproject>
Index: /EcnlProtoTool/trunk/mruby-1.2.0/.info
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/.info	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/.info	(revision 279)
@@ -0,0 +1,7 @@
+TOOL_CHAIN=KPIT GNUARM-NONE-EABI Toolchain
+VERSION=v16.01
+TC_INSTALL=C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\
+GCC_STRING=5.2-GNUARM-NONE_v16.01
+VERSION_IDE=
+E2STUDIO_VERSION=5.3.1.002
+ACTIVE_CONFIGURATION=Debug
Index: /EcnlProtoTool/trunk/mruby-1.2.0/.project
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/.project	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/.project	(revision 279)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>mruby-1.2.0</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+			<triggers>clean,full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>org.eclipse.cdt.core.ccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>
Index: /EcnlProtoTool/trunk/mruby-1.2.0/Makefile
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/Makefile	(revision 278)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/Makefile	(revision 279)
@@ -3,5 +3,5 @@
 # codebase.
 
-RAKE = ruby ./minirake
+RAKE = ruby -Eutf-8 ./minirake
 
 all :
Index: /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_ao_render.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_ao_render.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_ao_render.rb	(revision 279)
@@ -0,0 +1,314 @@
+# AO render benchmark
+# Original program (C) Syoyo Fujita in Javascript (and other languages)
+#      https://code.google.com/p/aobench/
+# Ruby(yarv2llvm) version by Hideki Miura
+# mruby version by Hideki Miura
+#
+
+IMAGE_WIDTH = 64
+IMAGE_HEIGHT = 64
+NSUBSAMPLES = 2
+NAO_SAMPLES = 8
+
+module Rand
+  # Use xorshift
+  @@x = 123456789
+  @@y = 362436069
+  @@z = 521288629
+  @@w = 88675123
+  BNUM = 1 << 29
+  BNUMF = BNUM.to_f
+  def self.rand
+    x = @@x
+    t = x ^ ((x & 0xfffff) << 11)
+    w = @@w
+    @@x, @@y, @@z = @@y, @@z, w
+    w = @@w = (w ^ (w >> 19) ^ (t ^ (t >> 8)))
+    (w % BNUM) / BNUMF
+  end
+end
+
+class Vec
+  def initialize(x, y, z)
+    @x = x
+    @y = y
+    @z = z
+  end
+
+  def x=(v); @x = v; end
+  def y=(v); @y = v; end
+  def z=(v); @z = v; end
+  def x; @x; end
+  def y; @y; end
+  def z; @z; end
+
+  def vadd(b)
+    Vec.new(@x + b.x, @y + b.y, @z + b.z)
+  end
+
+  def vsub(b)
+    Vec.new(@x - b.x, @y - b.y, @z - b.z)
+  end
+
+  def vcross(b)
+    Vec.new(@y * b.z - @z * b.y,
+            @z * b.x - @x * b.z,
+            @x * b.y - @y * b.x)
+  end
+
+  def vdot(b)
+    r = @x * b.x + @y * b.y + @z * b.z
+    r
+  end
+
+  def vlength
+    Math.sqrt(@x * @x + @y * @y + @z * @z)
+  end
+
+  def vnormalize
+    len = vlength
+    v = Vec.new(@x, @y, @z)
+    if len > 1.0e-17 then
+      v.x = v.x / len
+      v.y = v.y / len
+      v.z = v.z / len
+    end
+    v
+  end
+end
+
+
+class Sphere
+  def initialize(center, radius)
+    @center = center
+    @radius = radius
+  end
+
+  def center; @center; end
+  def radius; @radius; end
+
+  def intersect(ray, isect)
+    rs = ray.org.vsub(@center)
+    b = rs.vdot(ray.dir)
+    c = rs.vdot(rs) - (@radius * @radius)
+    d = b * b - c
+    if d > 0.0 then
+      t = - b - Math.sqrt(d)
+
+      if t > 0.0 and t < isect.t then
+        isect.t = t
+        isect.hit = true
+        isect.pl = Vec.new(ray.org.x + ray.dir.x * t,
+                          ray.org.y + ray.dir.y * t,
+                          ray.org.z + ray.dir.z * t)
+        n = isect.pl.vsub(@center)
+        isect.n = n.vnormalize
+      end
+    end
+  end
+end
+
+class Plane
+  def initialize(p, n)
+    @p = p
+    @n = n
+  end
+
+  def intersect(ray, isect)
+    d = -@p.vdot(@n)
+    v = ray.dir.vdot(@n)
+    v0 = v
+    if v < 0.0 then
+      v0 = -v
+    end
+    if v0 < 1.0e-17 then
+      return
+    end
+
+    t = -(ray.org.vdot(@n) + d) / v
+
+    if t > 0.0 and t < isect.t then
+      isect.hit = true
+      isect.t = t
+      isect.n = @n
+      isect.pl = Vec.new(ray.org.x + t * ray.dir.x,
+                        ray.org.y + t * ray.dir.y,
+                        ray.org.z + t * ray.dir.z)
+    end
+  end
+end
+
+class Ray
+  def initialize(org, dir)
+    @org = org
+    @dir = dir
+  end
+
+  def org; @org; end
+  def org=(v); @org = v; end
+  def dir; @dir; end
+  def dir=(v); @dir = v; end
+end
+
+class Isect
+  def initialize
+    @t = 10000000.0
+    @hit = false
+    @pl = Vec.new(0.0, 0.0, 0.0)
+    @n = Vec.new(0.0, 0.0, 0.0)
+  end
+
+  def t; @t; end
+  def t=(v); @t = v; end
+  def hit; @hit; end
+  def hit=(v); @hit = v; end
+  def pl; @pl; end
+  def pl=(v); @pl = v; end
+  def n; @n; end
+  def n=(v); @n = v; end
+end
+
+def clamp(f)
+  i = f * 255.5
+  if i > 255.0 then
+    i = 255.0
+  end
+  if i < 0.0 then
+    i = 0.0
+  end
+  i.to_i
+end
+
+def otherBasis(basis, n)
+  basis[2] = Vec.new(n.x, n.y, n.z)
+  basis[1] = Vec.new(0.0, 0.0, 0.0)
+
+  if n.x < 0.6 and n.x > -0.6 then
+    basis[1].x = 1.0
+  elsif n.y < 0.6 and n.y > -0.6 then
+    basis[1].y = 1.0
+  elsif n.z < 0.6 and n.z > -0.6 then
+    basis[1].z = 1.0
+  else
+    basis[1].x = 1.0
+  end
+
+  basis[0] = basis[1].vcross(basis[2])
+  basis[0] = basis[0].vnormalize
+
+  basis[1] = basis[2].vcross(basis[0])
+  basis[1] = basis[1].vnormalize
+end
+
+class Scene
+  def initialize
+    @spheres = Array.new
+    @spheres[0] = Sphere.new(Vec.new(-2.0, 0.0, -3.5), 0.5)
+    @spheres[1] = Sphere.new(Vec.new(-0.5, 0.0, -3.0), 0.5)
+    @spheres[2] = Sphere.new(Vec.new(1.0, 0.0, -2.2), 0.5)
+    @plane = Plane.new(Vec.new(0.0, -0.5, 0.0), Vec.new(0.0, 1.0, 0.0))
+  end
+
+  def ambient_occlusion(isect)
+    basis = Array.new(3)
+    otherBasis(basis, isect.n)
+
+    ntheta    = NAO_SAMPLES
+    nphi      = NAO_SAMPLES
+    eps       = 0.0001
+    occlusion = 0.0
+
+    p0 = Vec.new(isect.pl.x + eps * isect.n.x,
+                isect.pl.y + eps * isect.n.y,
+                isect.pl.z + eps * isect.n.z)
+    nphi.times do |j|
+      ntheta.times do |i|
+        r = Rand::rand
+        phi = 2.0 * 3.14159265 * Rand::rand
+        x = Math.cos(phi) * Math.sqrt(1.0 - r)
+        y = Math.sin(phi) * Math.sqrt(1.0 - r)
+        z = Math.sqrt(r)
+
+        rx = x * basis[0].x + y * basis[1].x + z * basis[2].x
+        ry = x * basis[0].y + y * basis[1].y + z * basis[2].y
+        rz = x * basis[0].z + y * basis[1].z + z * basis[2].z
+
+        raydir = Vec.new(rx, ry, rz)
+        ray = Ray.new(p0, raydir)
+
+        occisect = Isect.new
+        @spheres[0].intersect(ray, occisect)
+        @spheres[1].intersect(ray, occisect)
+        @spheres[2].intersect(ray, occisect)
+        @plane.intersect(ray, occisect)
+        if occisect.hit then
+          occlusion = occlusion + 1.0
+        else
+          0.0
+        end
+      end
+    end
+
+    occlusion = (ntheta.to_f * nphi.to_f - occlusion) / (ntheta.to_f * nphi.to_f)
+    Vec.new(occlusion, occlusion, occlusion)
+  end
+
+  def render(w, h, nsubsamples)
+    cnt = 0
+    nsf = nsubsamples.to_f
+    h.times do |y|
+      w.times do |x|
+        rad = Vec.new(0.0, 0.0, 0.0)
+
+        # Subsmpling
+        nsubsamples.times do |v|
+          nsubsamples.times do |u|
+            cnt = cnt + 1
+            wf = w.to_f
+            hf = h.to_f
+            xf = x.to_f
+            yf = y.to_f
+            uf = u.to_f
+            vf = v.to_f
+
+            px = (xf + (uf / nsf) - (wf / 2.0)) / (wf / 2.0)
+            py = -(yf + (vf / nsf) - (hf / 2.0)) / (hf / 2.0)
+
+            eye = Vec.new(px, py, -1.0).vnormalize
+
+            ray = Ray.new(Vec.new(0.0, 0.0, 0.0), eye)
+
+            isect = Isect.new
+            @spheres[0].intersect(ray, isect)
+            @spheres[1].intersect(ray, isect)
+            @spheres[2].intersect(ray, isect)
+            @plane.intersect(ray, isect)
+            if isect.hit then
+              col = ambient_occlusion(isect)
+              rad.x = rad.x + col.x
+              rad.y = rad.y + col.y
+              rad.z = rad.z + col.z
+            else
+              0.0
+            end
+          end
+        end
+
+        r = rad.x / (nsf * nsf)
+        g = rad.y / (nsf * nsf)
+        b = rad.z / (nsf * nsf)
+        printf("%c", clamp(r))
+        printf("%c", clamp(g))
+        printf("%c", clamp(b))
+      end
+    end
+  end
+end
+
+# File.open("ao.ppm", "w") do |fp|
+  printf("P6\n")
+  printf("%d %d\n", IMAGE_WIDTH, IMAGE_HEIGHT)
+  printf("255\n", IMAGE_WIDTH, IMAGE_HEIGHT)
+  Scene.new.render(IMAGE_WIDTH, IMAGE_HEIGHT, NSUBSAMPLES)
+#  Scene.new.render(256, 256, 2)
+# end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_app_lc_fizzbuzz.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_app_lc_fizzbuzz.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_app_lc_fizzbuzz.rb	(revision 279)
@@ -0,0 +1,52 @@
+#
+# FizzBuzz program using only lambda calculus
+#
+# This program is quoted from
+#   "Understanding Computation" by Tom Stuart
+#   http://computationbook.com/
+#
+# You can understand why this program works fine by reading this book.
+#
+
+solution = -> k { -> f { -> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> l { -> x { -> g { -> b { b }[-> p { p[-> x { -> y { x } }] }[l]][x][-> y { g[f[-> l { -> p { p[-> x { -> y { y } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][x][g]][-> l { -> p { p[-> x { -> y { x } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][y] }] } } } }][k][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> l { -> x { -> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[l][f[x]] } }] } }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[m][n]][-> x { -> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[f[-> n { -> p { -> x { p[n[p][x]] } } }[m]][n]][m][x] }][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]] } } }][-> p { -> x { p[x] } }][-> p { -> x { p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] } }]][-> n { -> b { b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> p { -> x { p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[x]]]]]]]]]]]]]]] } }]]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]][-> b { b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> p { -> x { p[p[p[x]]] } }]]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]][-> b { b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> n { -> l { -> x { -> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> l { -> x { -> g { -> b { b }[-> p { p[-> x { -> y { x } }] }[l]][x][-> y { g[f[-> l { -> p { p[-> x { -> y { y } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][x][g]][-> l { -> p { p[-> x { -> y { x } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][y] }] } } } }][l][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][x]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }] } }[-> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> x { f[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { -> n { -> p { -> x { p[n[p][x]] } } }[f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n]][x] }][-> p { -> x { x } }] } } }][n][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][x] }]][-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]] } }][n]]]] }]
+
+FIRST     = -> l { LEFT[RIGHT[l]] }
+IF        = -> b { b }
+LEFT      = -> p { p[-> x { -> y { x } } ] }
+RIGHT     = -> p { p[-> x { -> y { y } } ] }
+IS_EMPTY  = LEFT
+REST      = -> l { RIGHT[RIGHT[l]] }
+
+def to_integer(proc)
+  proc[-> n { n + 1 }][0]
+end
+
+def to_boolean(proc)
+  IF[proc][true][false]
+end
+
+def to_array(proc)
+  array = []
+
+  until to_boolean(IS_EMPTY[proc])
+    array.push(FIRST[proc])
+    proc = REST[proc]
+  end
+
+  array
+end
+
+def to_char(c)
+  '0123456789BFiuz'.slice(to_integer(c))
+end
+
+def to_string(s)
+  to_array(s).map { |c| to_char(c) }.join
+end
+
+answer = to_array(solution).map do |p|
+  to_string(p)
+end
+
+answer_str = answer.to_a
+# puts answer_str
Index: /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_fib.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_fib.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_fib.rb	(revision 279)
@@ -0,0 +1,7 @@
+
+def fib n
+  return n if n < 2
+  fib(n-2) + fib(n-1)
+end
+
+puts fib(37)
Index: /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_so_lists.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_so_lists.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/bm_so_lists.rb	(revision 279)
@@ -0,0 +1,47 @@
+#from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
+
+NUM = 300
+SIZE = 10000
+
+def test_lists()
+  # create a list of integers (Li1) from 1 to SIZE
+  li1 = (1..SIZE).to_a
+  # copy the list to li2 (not by individual items)
+  li2 = li1.dup
+  # remove each individual item from left side of li2 and
+  # append to right side of li3 (preserving order)
+  li3 = Array.new
+  while (not li2.empty?)
+    li3.push(li2.shift)
+  end
+  # li2 must now be empty
+  # remove each individual item from right side of li3 and
+  # append to right side of li2 (reversing list)
+  while (not li3.empty?)
+    li2.push(li3.pop)
+  end
+  # li3 must now be empty
+  # reverse li1 in place
+  li1.reverse!
+  # check that first item is now SIZE
+  if li1[0] != SIZE then
+    p "not SIZE"
+    0
+  else
+    # compare li1 and li2 for equality
+    if li1 != li2 then
+      return(0)
+    else
+      # return the length of the list
+      li1.length
+    end
+  end
+end
+
+i = 0
+while i<NUM
+  i += 1
+  result = test_lists()
+end
+
+result
Index: /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/build_config_boxing.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/build_config_boxing.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/build_config_boxing.rb	(revision 279)
@@ -0,0 +1,28 @@
+MRuby::Build.new do |conf|
+  toolchain :gcc
+end
+
+MRuby::Build.new('no_boxing') do |conf|
+  toolchain :gcc
+
+  conf.gembox 'default'
+end
+
+MRuby::Build.new('word_boxing') do |conf|
+  toolchain :gcc
+
+  conf.gembox 'default'
+  conf.compilers.each do |c|
+    c.defines += %w(MRB_WORD_BOXING)
+  end
+end
+
+MRuby::Build.new('nan_boxing') do |conf|
+  toolchain :gcc
+
+  conf.gembox 'default'
+  conf.compilers.each do |c|
+    c.defines += %w(MRB_NAN_BOXING)
+  end
+end
+
Index: /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/build_config_cc.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/build_config_cc.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/build_config_cc.rb	(revision 279)
@@ -0,0 +1,13 @@
+MRuby::Build.new do |conf|
+  toolchain :gcc
+end
+
+MRuby::Build.new('gcc') do |conf|
+  toolchain :gcc
+  conf.gembox 'default'
+end
+
+MRuby::Build.new('clang') do |conf|
+  toolchain :clang
+  conf.gembox 'default'
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/plot.gpl
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/plot.gpl	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/benchmark/plot.gpl	(revision 279)
@@ -0,0 +1,5 @@
+set yrange [0:]
+set terminal pngcairo font 'Sans, 8' lw 1 size 1400,1024
+set xtics rotate by -45
+set style histogram errorbars gap 2 lw 1
+set style fill solid border -1
Index: /EcnlProtoTool/trunk/mruby-1.2.0/build_config.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/build_config.rb	(revision 278)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/build_config.rb	(revision 279)
@@ -152,19 +152,23 @@
   conf.cc.defines << %w(MRB_GC_STRESS)
   #conf.cc.defines << %w(DISABLE_STDIO)
+  conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)
 
   conf.build_mrbtest_lib_only
 
+  conf.gem "#{root}/mrbgems/mruby-compiler"
   conf.gem "#{root}/mrbgems/mruby-numeric-ext"
   conf.gem "#{root}/mrbgems/mruby-string-ext"
+  conf.gem '../mrbgems/mruby-onig-regexp'  do |g|
+    g.cc.include_paths  << "../onigmo-5.15.0/src"
+  end
   conf.gem "#{root}/../mrbgems/mruby-blockly"
-  conf.gem "#{root}/../mrbgems/gr_peach" do |g|
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/api"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/hal"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc/iodefines"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H"
+  conf.gem "#{root}/../mrbgems/mruby-io"
+  conf.gem "#{root}/../mrbgems/mruby-dir" do |g|
+    g.cc.defines = %w(__NEWLIB__=2)
+    g.cc.include_paths << "#{g.dir}/../../musl-1.1.12/include"
+  end
+  conf.gem "#{root}/../mrbgems/mruby-pack"
+  conf.gem "#{root}/../mrbgems/mruby-socket" do |g|
+    g.cc.include_paths << "#{g.dir}/../../musl-1.1.12/include"
   end
   conf.gem "#{root}/../mrbgems/mruby-arduino" do |g|
@@ -177,5 +181,6 @@
     g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H"
     g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H"
-    g.cc.include_paths << "#{g.dir}/../../mrbgems/gr_peach/src"
+    g.cc.include_paths << "#{g.dir}/../../sample/gr_peach"
+    g.cc.include_paths << "#{g.dir}/../../prototool/src"
   end
   conf.gem "#{root}/../mrbgems/mruby-ecnl"
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/README.md
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/README.md	(revision 279)
@@ -0,0 +1,4 @@
+C and Ruby Extension Example
+=========
+
+This is an example gem which implements a C and Ruby extension.
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake	(revision 279)
@@ -0,0 +1,23 @@
+MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
+  spec.license = 'MIT'
+  spec.author  = 'mruby developers'
+
+  # Add compile flags
+  # spec.cc.flags << ''
+
+  # Add cflags to all
+  # spec.mruby.cc.flags << '-g'
+
+  # Add libraries
+  # spec.linker.libraries << 'external_lib'
+
+  # Default build files
+  # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
+  # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
+  # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
+  # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
+  # spec.test_preload = 'test/assert.rb'
+
+  # Values accessible as TEST_ARGS inside test scripts
+  # spec.test_args = {'tmp_dir' => Dir::tmpdir}
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb	(revision 279)
@@ -0,0 +1,5 @@
+module CRubyExtension
+  def CRubyExtension.ruby_method
+    puts "A Ruby Extension"
+  end
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/src/example.c
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/src/example.c	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/src/example.c	(revision 279)
@@ -0,0 +1,20 @@
+#include <mruby.h>
+#include <stdio.h>
+
+static mrb_value
+mrb_c_method(mrb_state *mrb, mrb_value self)
+{
+  puts("A C Extension");
+  return self;
+}
+
+void
+mrb_c_and_ruby_extension_example_gem_init(mrb_state* mrb) {
+  struct RClass *class_cextension = mrb_define_module(mrb, "CRubyExtension");
+  mrb_define_class_method(mrb, class_cextension, "c_method", mrb_c_method, MRB_ARGS_NONE());
+}
+
+void
+mrb_c_and_ruby_extension_example_gem_final(mrb_state* mrb) {
+  /* finalizer */
+}
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/test/example.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/test/example.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_and_ruby_extension_example/test/example.rb	(revision 279)
@@ -0,0 +1,7 @@
+assert('C and Ruby Extension Example 1') do
+  CRubyExtension.respond_to? :c_method
+end
+
+assert('C and Ruby Extension Example 2') do
+  CRubyExtension.respond_to? :ruby_method
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/README.md
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/README.md	(revision 279)
@@ -0,0 +1,4 @@
+C Extension Example
+=========
+
+This is an example gem which implements a C extension.
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/mrbgem.rake	(revision 279)
@@ -0,0 +1,23 @@
+MRuby::Gem::Specification.new('c_extension_example') do |spec|
+  spec.license = 'MIT'
+  spec.author  = 'mruby developers'
+
+  # Add compile flags
+  # spec.cc.flags << '-g'
+
+  # Add cflags to all
+  # spec.mruby.cc.flags << '-g'
+
+  # Add libraries
+  # spec.linker.libraries << 'external_lib'
+
+  # Default build files
+  # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
+  # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
+  # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
+  # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
+  # spec.test_preload = 'test/assert.rb'
+
+  # Values accessible as TEST_ARGS inside test scripts
+  # spec.test_args = {'tmp_dir' => Dir::tmpdir}
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/src/example.c
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/src/example.c	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/src/example.c	(revision 279)
@@ -0,0 +1,20 @@
+#include <mruby.h>
+#include <stdio.h>
+
+static mrb_value
+mrb_c_method(mrb_state *mrb, mrb_value self)
+{
+  puts("A C Extension");
+  return self;
+}
+
+void
+mrb_c_extension_example_gem_init(mrb_state* mrb) {
+  struct RClass *class_cextension = mrb_define_module(mrb, "CExtension");
+  mrb_define_class_method(mrb, class_cextension, "c_method", mrb_c_method, MRB_ARGS_NONE());
+}
+
+void
+mrb_c_extension_example_gem_final(mrb_state* mrb) {
+  /* finalizer */
+}
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/test/example.c
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/test/example.c	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/test/example.c	(revision 279)
@@ -0,0 +1,7 @@
+#include <mruby.h>
+
+void
+mrb_c_extension_example_gem_test(mrb_state *mrb)
+{
+  /* test initializer in C */
+}
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/test/example.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/test/example.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/c_extension_example/test/example.rb	(revision 279)
@@ -0,0 +1,3 @@
+assert('C Extension Example') do
+  CExtension.respond_to? :c_method
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/README.md
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/README.md	(revision 279)
@@ -0,0 +1,4 @@
+Pure Ruby Extension Example
+=========
+
+This is an example gem which implements a pure Ruby extension.
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/mrbgem.rake
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/mrbgem.rake	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/mrbgem.rake	(revision 279)
@@ -0,0 +1,23 @@
+MRuby::Gem::Specification.new('ruby_extension_example') do |spec|
+  spec.license = 'MIT'
+  spec.author  = 'mruby developers'
+
+  # Add compile flags
+  # spec.cc.flags << ''
+
+  # Add cflags to all
+  # spec.mruby.cc.flags << '-g'
+
+  # Add libraries
+  # spec.linker.libraries << 'external_lib'
+
+  # Default build files
+  # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
+  # spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
+  # spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
+  # spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
+  # spec.test_preload = 'test/assert.rb'
+
+  # Values accessible as TEST_ARGS inside test scripts
+  # spec.test_args = {'tmp_dir' => Dir::tmpdir}
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/mrblib/example.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/mrblib/example.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/mrblib/example.rb	(revision 279)
@@ -0,0 +1,5 @@
+class RubyExtension
+  def RubyExtension.ruby_method
+    puts "A Ruby Extension"
+  end
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/test/example.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/test/example.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/test/example.rb	(revision 279)
@@ -0,0 +1,3 @@
+assert('Ruby Extension Example') do
+  RubyExtension.respond_to? :ruby_method
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_ArduinoDue.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_ArduinoDue.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_ArduinoDue.rb	(revision 279)
@@ -0,0 +1,91 @@
+MRuby::Build.new do |conf|
+
+  # Gets set by the VS command prompts.
+  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
+    toolchain :visualcpp
+  else
+    toolchain :gcc
+  end
+
+  enable_debug
+
+  # include the default GEMs
+  conf.gembox 'default'
+
+end
+
+# Cross Compiling configuration for Arduino Due
+# http://arduino.cc/en/Main/ArduinoBoardDue
+#
+# Requires Arduino IDE >= 1.5
+MRuby::CrossBuild.new("ArduinoDue") do |conf|
+  toolchain :gcc
+
+  # Mac OS X, Arduino IDE <= 1.5.6
+  # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Resources/Java'
+  # Mac OS X, Arduino IDE >= 1.5.7
+  # ARDUINO_PATH = '/Applications/Arduino.app/Contents/Java'
+  # GNU Linux
+  ARDUINO_PATH = '/opt/arduino'
+   # Arduino IDE <= 1.5.6
+  BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/g++_arm_none_eabi/bin"
+  # Arduino IDE >= 1.5.7
+  # BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin"
+  SAM_PATH = "#{ARDUINO_PATH}/hardware/arduino/sam"
+  TARGET_PATH = "#{SAM_PATH}/variants/arduino_due_x"
+
+  conf.cc do |cc|
+    cc.command = "#{BIN_PATH}/arm-none-eabi-gcc"
+    cc.include_paths << ["#{SAM_PATH}/system/libsam", "#{SAM_PATH}/system/CMSIS/CMSIS/Include/",
+                        "#{SAM_PATH}/system/CMSIS/Device/ATMEL/",
+                        "#{SAM_PATH}/cores/arduino", "#{SAM_PATH}/libraries","#{TARGET_PATH}"]
+    cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
+                -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM
+                -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due")
+    cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
+
+    #configuration for low memory environment
+    cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
+    cc.defines << %w(MRB_USE_IV_SEGLIST)
+    cc.defines << %w(KHASH_DEFAULT_SIZE=8)
+    cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
+    cc.defines << %w(MRB_GC_STRESS)
+    #cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
+    #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
+  end
+
+  conf.cxx do |cxx|
+    cxx.command = conf.cc.command.dup
+    cxx.include_paths = conf.cc.include_paths.dup
+    cxx.flags = conf.cc.flags.dup
+    cxx.flags << %w(-fno-rtti -fno-exceptions)
+    cxx.defines = conf.cc.defines.dup
+    cxx.compile_options = conf.cc.compile_options.dup
+  end
+
+  conf.archiver do |archiver|
+    archiver.command = "#{BIN_PATH}/arm-none-eabi-ar"
+    archiver.archive_options = 'rcs %{outfile} %{objs}'
+  end
+
+  #no executables
+  conf.bins = []
+
+  #do not build executable test
+  conf.build_mrbtest_lib_only
+
+  #disable C++ exception
+  conf.disable_cxx_exception
+
+  #gems from core
+  conf.gem :core => "mruby-print"
+  conf.gem :core => "mruby-math"
+  conf.gem :core => "mruby-enum-ext"
+
+  #light-weight regular expression
+  conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
+
+  #Arduino API
+  #conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
+
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_IntelGalileo.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_IntelGalileo.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_IntelGalileo.rb	(revision 279)
@@ -0,0 +1,106 @@
+MRuby::Build.new do |conf|
+
+  # Gets set by the VS command prompts.
+  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
+    toolchain :visualcpp
+  else
+    toolchain :gcc
+  end
+
+  enable_debug
+
+  # include the default GEMs
+  conf.gembox 'default'
+
+end
+
+
+# Cross Compiling configuration for Intel Galileo on Arduino environment
+# http://arduino.cc/en/ArduinoCertified/IntelGalileo
+#
+# Requires Arduino IDE for Intel Galileo
+MRuby::CrossBuild.new("Galileo") do |conf|
+  toolchain :gcc
+
+  # Mac OS X
+  # Assume you renamed Arduino.app to Arduino_Galileo.app
+  GALILEO_ARDUINO_PATH = '/Applications/Arduino_Galileo.app/Contents/Resources/Java'
+  # GNU Linux
+  #ARDUINO_GALILEO_PATH = '/opt/arduino'
+
+  GALILEO_BIN_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i386-pokysdk-darwin/usr/bin/i586-poky-linux-uclibc"
+  GALILEO_SYSROOT =  "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc"
+  GALILEO_X86_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/arduino/x86"
+
+
+  conf.cc do |cc|
+    cc.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-gcc"
+    cc.include_paths << ["#{GALILEO_X86_PATH}/cores/arduino", "#{GALILEO_X86_PATH}/variants/galileo_fab_d"]
+    cc.flags = %w(-m32 -march=i586 -c -g -Os -w
+              -ffunction-sections -fdata-sections -MMD -DARDUINO=153)
+    cc.flags << "--sysroot=#{GALILEO_SYSROOT}"
+    cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
+  end
+
+  conf.cxx do |cxx|
+    cxx.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++"
+    cxx.include_paths = conf.cc.include_paths.dup
+    cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++"
+    cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++/i586-poky-linux-uclibc"
+    cxx.flags = conf.cc.flags.dup
+    cxx.defines = conf.cc.defines.dup
+    cxx.compile_options = conf.cc.compile_options.dup
+  end
+
+  conf.archiver do |archiver|
+    archiver.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-ar"
+    archiver.archive_options = 'rcs %{outfile} %{objs}'
+  end
+
+  conf.linker do |linker|
+    linker.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++"
+    linker.flags = %w(-m32 -march=i586)
+    linker.flags << "--sysroot=#{GALILEO_SYSROOT}"
+    linker.flags << %w(-Os -Wl,--gc-sections)
+    linker.libraries = %w(m pthread)
+  end
+
+  #no executables
+  conf.bins = []
+
+  #do not build executable test
+  conf.build_mrbtest_lib_only
+
+  #official mrbgems
+  conf.gem :core => "mruby-sprintf"
+  conf.gem :core => "mruby-print"
+  conf.gem :core => "mruby-math"
+  conf.gem :core => "mruby-time"
+  conf.gem :core => "mruby-struct"
+  conf.gem :core => "mruby-enum-ext"
+  conf.gem :core => "mruby-string-ext"
+  conf.gem :core => "mruby-numeric-ext"
+  conf.gem :core => "mruby-array-ext"
+  conf.gem :core => "mruby-hash-ext"
+  conf.gem :core => "mruby-range-ext"
+  conf.gem :core => "mruby-proc-ext"
+  conf.gem :core => "mruby-symbol-ext"
+  conf.gem :core => "mruby-random"
+  conf.gem :core => "mruby-object-ext"
+  conf.gem :core => "mruby-objectspace"
+  conf.gem :core => "mruby-fiber"
+  conf.gem :core => "mruby-toplevel-ext"
+
+  #lightweigh regular expression
+  conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
+
+  #Arduino API
+  #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" do |g|
+  #  g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Wire"
+  #  g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Servo"
+
+    #enable unsupported Servo class
+  #  g.cxx.defines << "MRUBY_ARDUINO_GALILEO_ENABLE_SERVO"
+  #end
+
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_chipKITMax32.rb
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_chipKITMax32.rb	(revision 279)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/examples/targets/build_config_chipKITMax32.rb	(revision 279)
@@ -0,0 +1,87 @@
+MRuby::Build.new do |conf|
+
+  # Gets set by the VS command prompts.
+  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
+    toolchain :visualcpp
+  else
+    toolchain :gcc
+  end
+
+  enable_debug
+
+  # include the default GEMs
+  conf.gembox 'default'
+
+end
+
+# Cross Compiling configuration for Digilent chipKIT Max32
+# http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
+#
+# Requires MPIDE (https://github.com/chipKIT32/chipKIT32-MAX)
+#
+# This configuration is based on @kyab's version
+# http://d.hatena.ne.jp/kyab/20130201
+MRuby::CrossBuild.new("chipKITMax32") do |conf|
+  toolchain :gcc
+
+  # Mac OS X
+  # MPIDE_PATH = '/Applications/Mpide.app/Contents/Resources/Java'
+  # GNU Linux
+  MPIDE_PATH = '/opt/mpide-0023-linux-20120903'
+
+  PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32"
+
+  conf.cc do |cc|
+    cc.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-gcc"
+    cc.include_paths << ["#{PIC32_PATH}/cores/pic32",
+                        "#{PIC32_PATH}/variants/Max32",
+                        "#{PIC32_PATH}/libraries"]
+    cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align
+                -fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_
+                -DMPIDEVER=0x01000202 -DMPIDE=23)
+    cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
+
+    #configuration for low memory environment
+    cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
+    cc.defines << %w(MRB_USE_IV_SEGLIST)
+    cc.defines << %w(KHASH_DEFAULT_SIZE=8)
+    cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
+    cc.defines << %w(MRB_GC_STRESS)
+    #cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
+    #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
+  end
+
+  conf.cxx do |cxx|
+    cxx.command = conf.cc.command.dup
+    cxx.include_paths = conf.cc.include_paths.dup
+    cxx.flags = conf.cc.flags.dup
+    cxx.defines = conf.cc.defines.dup
+    cxx.compile_options = conf.cc.compile_options.dup
+  end
+
+  conf.archiver do |archiver|
+    archiver.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-ar"
+    archiver.archive_options = 'rcs %{outfile} %{objs}'
+  end
+
+  #no executables
+  conf.bins = []
+
+  #do not build test executable
+  conf.build_mrbtest_lib_only
+
+  #disable C++ exception
+  conf.disable_cxx_exception
+
+  #gems from core
+  conf.gem :core => "mruby-print"
+  conf.gem :core => "mruby-math"
+  conf.gem :core => "mruby-enum-ext"
+
+  #light-weight regular expression
+  conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
+
+  #Arduino API
+  #conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
+
+end
Index: /EcnlProtoTool/trunk/mruby-1.2.0/include/mruby.h
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/include/mruby.h	(revision 278)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/include/mruby.h	(revision 279)
@@ -859,5 +859,5 @@
  *      Pointer to the newly created mrb_state.
  */
-MRB_API mrb_state* mrb_open_allocf(mrb_allocf f, void *ud);
+MRB_API mrb_state* mrb_open_allocf(mrb_allocf f, void *ud, mrb_bool disable_gems);
 
 /**
Index: /EcnlProtoTool/trunk/mruby-1.2.0/src/state.c
===================================================================
--- /EcnlProtoTool/trunk/mruby-1.2.0/src/state.c	(revision 278)
+++ /EcnlProtoTool/trunk/mruby-1.2.0/src/state.c	(revision 279)
@@ -97,5 +97,5 @@
 mrb_open(void)
 {
-  mrb_state *mrb = mrb_open_allocf(mrb_default_allocf, NULL);
+  mrb_state *mrb = mrb_open_allocf(mrb_default_allocf, NULL, FALSE);
 
   return mrb;
@@ -103,5 +103,5 @@
 
 MRB_API mrb_state*
-mrb_open_allocf(mrb_allocf f, void *ud)
+mrb_open_allocf(mrb_allocf f, void *ud, mrb_bool disable_gems)
 {
   mrb_state *mrb = mrb_open_core(f, ud);
@@ -111,8 +111,8 @@
   }
 
-#ifndef DISABLE_GEMS
-  mrb_init_mrbgems(mrb);
-  mrb_gc_arena_restore(mrb, 0);
-#endif
+  if (!disable_gems) {
+    mrb_init_mrbgems(mrb);
+    mrb_gc_arena_restore(mrb, 0);
+  }
   return mrb;
 }
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/_dirent.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/_dirent.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/_dirent.h	(revision 279)
@@ -0,0 +1,81 @@
+#ifndef	_DIRENT_H
+#define	_DIRENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*#include <features.h>
+
+#define __NEED_ino_t
+#define __NEED_off_t
+#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
+#define __NEED_size_t
+#endif
+
+#include <bits/alltypes.h>*/
+#define MAXPATHLEN 256
+int chroot(const char *);
+
+typedef struct __dirstream DIR;
+
+struct dirent
+{
+	ino_t d_ino;
+	off_t d_off;
+	unsigned short d_reclen;
+	unsigned char d_type;
+	char d_name[256];
+};
+
+#define d_fileno d_ino
+
+int            closedir(DIR *);
+DIR           *fdopendir(int);
+DIR           *opendir(const char *);
+struct dirent *readdir(DIR *);
+int            readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
+void           rewinddir(DIR *);
+void           seekdir(DIR *, long);
+long           telldir(DIR *);
+int            dirfd(DIR *);
+
+int alphasort(const struct dirent **, const struct dirent **);
+int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
+#define IFTODT(x) ((x)>>12 & 017)
+#define DTTOIF(x) ((x)<<12)
+int getdents(int, struct dirent *, size_t);
+#endif
+
+#ifdef _GNU_SOURCE
+int versionsort(const struct dirent **, const struct dirent **);
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define dirent64 dirent
+#define readdir64 readdir
+#define readdir64_r readdir_r
+#define scandir64 scandir
+#define alphasort64 alphasort
+#define versionsort64 versionsort
+#define off64_t off_t
+#define ino64_t ino_t
+#define getdents64 getdents
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/_termios.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/_termios.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/_termios.h	(revision 279)
@@ -0,0 +1,46 @@
+#ifndef	_TERMIOS_H
+#define	_TERMIOS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*#include <features.h>
+
+#define __NEED_pid_t
+
+#include <bits/alltypes.h>*/
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 32
+
+#include "../../../musl-1.1.12/include/bits/termios.h"
+
+speed_t cfgetospeed (const struct termios *);
+speed_t cfgetispeed (const struct termios *);
+int cfsetospeed (struct termios *, speed_t);
+int cfsetispeed (struct termios *, speed_t);
+
+int tcgetattr (int, struct termios *);
+int tcsetattr (int, int, const struct termios *);
+
+int tcsendbreak (int, int);
+int tcdrain (int);
+int tcflush (int, int);
+int tcflow (int, int);
+
+pid_t tcgetsid (int);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+void cfmakeraw(struct termios *);
+int cfsetspeed(struct termios *, speed_t);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/ftp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/ftp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/ftp.h	(revision 279)
@@ -0,0 +1,35 @@
+#ifndef _ARPA_FTP_H
+#define _ARPA_FTP_H
+#define PRELIM 1
+#define COMPLETE 2
+#define CONTINUE 3
+#define TRANSIENT 4
+#define ERROR 5
+#define TYPE_A 1
+#define TYPE_E 2
+#define TYPE_I 3
+#define TYPE_L 4
+#define FORM_N 1
+#define FORM_T 2
+#define FORM_C 3
+#define STRU_F 1
+#define STRU_R 2
+#define STRU_P 3
+#define MODE_S 1
+#define MODE_B 2
+#define MODE_C 3
+#define REC_ESC '\377'
+#define REC_EOR '\001'
+#define REC_EOF '\002'
+#define BLK_EOR 0x80
+#define BLK_EOF 0x40
+#define BLK_ERRORS 0x20
+#define BLK_RESTART 0x10
+#define BLK_BYTECOUNT 2
+#ifdef FTP_NAMES
+char *modenames[] =  {"0", "Stream", "Block", "Compressed" };
+char *strunames[] =  {"0", "File", "Record", "Page" };
+char *typenames[] =  {"0", "ASCII", "EBCDIC", "Image", "Local" };
+char *formnames[] =  {"0", "Nonprint", "Telnet", "Carriage-control" };
+#endif
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/inet.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/inet.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/inet.h	(revision 279)
@@ -0,0 +1,36 @@
+#ifndef _ARPA_INET_H
+#define	_ARPA_INET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <netinet/in.h>
+
+//uint32_t htonl(uint32_t);
+//uint16_t htons(uint16_t);
+uint32_t ntohl(uint32_t);
+uint16_t ntohs(uint16_t);
+
+in_addr_t inet_addr (const char *);
+in_addr_t inet_network (const char *);
+char *inet_ntoa (struct in_addr);
+int inet_pton (int, const char *__restrict, void *__restrict);
+const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t);
+
+int inet_aton (const char *, struct in_addr *);
+struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
+in_addr_t inet_lnaof(struct in_addr);
+in_addr_t inet_netof(struct in_addr);
+
+#undef INET_ADDRSTRLEN
+#undef INET6_ADDRSTRLEN
+#define INET_ADDRSTRLEN  16
+#define INET6_ADDRSTRLEN 46
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/nameser.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/nameser.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/nameser.h	(revision 279)
@@ -0,0 +1,455 @@
+#ifndef _ARPA_NAMESER_H
+#define _ARPA_NAMESER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+#include <stdint.h>
+
+#define __NAMESER	19991006
+#define NS_PACKETSZ	512
+#define NS_MAXDNAME	1025
+#define NS_MAXMSG	65535
+#define NS_MAXCDNAME	255
+#define NS_MAXLABEL	63
+#define NS_HFIXEDSZ	12
+#define NS_QFIXEDSZ	4
+#define NS_RRFIXEDSZ	10
+#define NS_INT32SZ	4
+#define NS_INT16SZ	2
+#define NS_INT8SZ	1
+#define NS_INADDRSZ	4
+#define NS_IN6ADDRSZ	16
+#define NS_CMPRSFLGS	0xc0
+#define NS_DEFAULTPORT	53
+
+typedef enum __ns_sect {
+	ns_s_qd = 0,
+	ns_s_zn = 0,
+	ns_s_an = 1,
+	ns_s_pr = 1,
+	ns_s_ns = 2,
+	ns_s_ud = 2,
+	ns_s_ar = 3,
+	ns_s_max = 4
+} ns_sect;
+
+typedef struct __ns_msg {
+	const unsigned char *_msg, *_eom;
+	uint16_t _id, _flags, _counts[ns_s_max];
+	const unsigned char *_sections[ns_s_max];
+	ns_sect _sect;
+	int _rrnum;
+	const unsigned char *_msg_ptr;
+} ns_msg;
+
+struct _ns_flagdata {  int mask, shift;  };
+extern const struct _ns_flagdata _ns_flagdata[];
+
+#define ns_msg_id(handle) ((handle)._id + 0)
+#define ns_msg_base(handle) ((handle)._msg + 0)
+#define ns_msg_end(handle) ((handle)._eom + 0)
+#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
+#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
+#define ns_msg_getflag(handle, flag) \
+	(((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
+
+typedef	struct __ns_rr {
+	char		name[NS_MAXDNAME];
+	uint16_t	type;
+	uint16_t	rr_class;
+	uint32_t	ttl;
+	uint16_t	rdlength;
+	const unsigned char *rdata;
+} ns_rr;
+
+#define ns_rr_name(rr)	(((rr).name[0] != '\0') ? (rr).name : ".")
+#define ns_rr_type(rr)	((ns_type)((rr).type + 0))
+#define ns_rr_class(rr)	((ns_class)((rr).rr_class + 0))
+#define ns_rr_ttl(rr)	((rr).ttl + 0)
+#define ns_rr_rdlen(rr)	((rr).rdlength + 0)
+#define ns_rr_rdata(rr)	((rr).rdata + 0)
+
+typedef enum __ns_flag {
+	ns_f_qr,
+	ns_f_opcode,
+	ns_f_aa,
+	ns_f_tc,
+	ns_f_rd,
+	ns_f_ra,
+	ns_f_z,
+	ns_f_ad,
+	ns_f_cd,
+	ns_f_rcode,
+	ns_f_max
+} ns_flag;
+
+typedef enum __ns_opcode {
+	ns_o_query = 0,
+	ns_o_iquery = 1,
+	ns_o_status = 2,
+	ns_o_notify = 4,
+	ns_o_update = 5,
+	ns_o_max = 6
+} ns_opcode;
+
+typedef	enum __ns_rcode {
+	ns_r_noerror = 0,
+	ns_r_formerr = 1,
+	ns_r_servfail = 2,
+	ns_r_nxdomain = 3,
+	ns_r_notimpl = 4,
+	ns_r_refused = 5,
+	ns_r_yxdomain = 6,
+	ns_r_yxrrset = 7,
+	ns_r_nxrrset = 8,
+	ns_r_notauth = 9,
+	ns_r_notzone = 10,
+	ns_r_max = 11,
+	ns_r_badvers = 16,
+	ns_r_badsig = 16,
+	ns_r_badkey = 17,
+	ns_r_badtime = 18
+} ns_rcode;
+
+typedef enum __ns_update_operation {
+	ns_uop_delete = 0,
+	ns_uop_add = 1,
+	ns_uop_max = 2
+} ns_update_operation;
+
+struct ns_tsig_key {
+        char name[NS_MAXDNAME], alg[NS_MAXDNAME];
+        unsigned char *data;
+        int len;
+};
+typedef struct ns_tsig_key ns_tsig_key;
+
+struct ns_tcp_tsig_state {
+	int counter;
+	struct dst_key *key;
+	void *ctx;
+	unsigned char sig[NS_PACKETSZ];
+	int siglen;
+};
+typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
+
+#define NS_TSIG_FUDGE 300
+#define NS_TSIG_TCP_COUNT 100
+#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
+
+#define NS_TSIG_ERROR_NO_TSIG -10
+#define NS_TSIG_ERROR_NO_SPACE -11
+#define NS_TSIG_ERROR_FORMERR -12
+
+typedef enum __ns_type {
+	ns_t_invalid = 0,
+	ns_t_a = 1,
+	ns_t_ns = 2,
+	ns_t_md = 3,
+	ns_t_mf = 4,
+	ns_t_cname = 5,
+	ns_t_soa = 6,
+	ns_t_mb = 7,
+	ns_t_mg = 8,
+	ns_t_mr = 9,
+	ns_t_null = 10,
+	ns_t_wks = 11,
+	ns_t_ptr = 12,
+	ns_t_hinfo = 13,
+	ns_t_minfo = 14,
+	ns_t_mx = 15,
+	ns_t_txt = 16,
+	ns_t_rp = 17,
+	ns_t_afsdb = 18,
+	ns_t_x25 = 19,
+	ns_t_isdn = 20,
+	ns_t_rt = 21,
+	ns_t_nsap = 22,
+	ns_t_nsap_ptr = 23,
+	ns_t_sig = 24,
+	ns_t_key = 25,
+	ns_t_px = 26,
+	ns_t_gpos = 27,
+	ns_t_aaaa = 28,
+	ns_t_loc = 29,
+	ns_t_nxt = 30,
+	ns_t_eid = 31,
+	ns_t_nimloc = 32,
+	ns_t_srv = 33,
+	ns_t_atma = 34,
+	ns_t_naptr = 35,
+	ns_t_kx = 36,
+	ns_t_cert = 37,
+	ns_t_a6 = 38,
+	ns_t_dname = 39,
+	ns_t_sink = 40,
+	ns_t_opt = 41,
+	ns_t_apl = 42,
+	ns_t_tkey = 249,
+	ns_t_tsig = 250,
+	ns_t_ixfr = 251,
+	ns_t_axfr = 252,
+	ns_t_mailb = 253,
+	ns_t_maila = 254,
+	ns_t_any = 255,
+	ns_t_zxfr = 256,
+	ns_t_max = 65536
+} ns_type;
+
+#define	ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
+		      (t) == ns_t_mailb || (t) == ns_t_maila)
+#define	ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
+#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
+#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
+#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
+		       (t) == ns_t_zxfr)
+
+typedef enum __ns_class {
+	ns_c_invalid = 0,
+	ns_c_in = 1,
+	ns_c_2 = 2,
+	ns_c_chaos = 3,
+	ns_c_hs = 4,
+	ns_c_none = 254,
+	ns_c_any = 255,
+	ns_c_max = 65536
+} ns_class;
+
+typedef enum __ns_key_types {
+	ns_kt_rsa = 1,
+	ns_kt_dh  = 2,
+	ns_kt_dsa = 3,
+	ns_kt_private = 254
+} ns_key_types;
+
+typedef enum __ns_cert_types {
+	cert_t_pkix = 1,
+	cert_t_spki = 2,
+	cert_t_pgp  = 3,
+	cert_t_url  = 253,
+	cert_t_oid  = 254
+} ns_cert_types;
+
+#define	NS_KEY_TYPEMASK		0xC000
+#define	NS_KEY_TYPE_AUTH_CONF	0x0000
+#define	NS_KEY_TYPE_CONF_ONLY	0x8000
+#define	NS_KEY_TYPE_AUTH_ONLY	0x4000
+#define	NS_KEY_TYPE_NO_KEY	0xC000
+#define	NS_KEY_NO_AUTH		0x8000
+#define	NS_KEY_NO_CONF		0x4000
+#define	NS_KEY_RESERVED2	0x2000
+#define	NS_KEY_EXTENDED_FLAGS	0x1000
+#define	NS_KEY_RESERVED4	0x0800
+#define	NS_KEY_RESERVED5	0x0400
+#define	NS_KEY_NAME_TYPE	0x0300
+#define	NS_KEY_NAME_USER	0x0000
+#define	NS_KEY_NAME_ENTITY	0x0200
+#define	NS_KEY_NAME_ZONE	0x0100
+#define	NS_KEY_NAME_RESERVED	0x0300
+#define	NS_KEY_RESERVED8	0x0080
+#define	NS_KEY_RESERVED9	0x0040
+#define	NS_KEY_RESERVED10	0x0020
+#define	NS_KEY_RESERVED11	0x0010
+#define	NS_KEY_SIGNATORYMASK	0x000F
+#define	NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
+				  NS_KEY_RESERVED4 | \
+				  NS_KEY_RESERVED5 | \
+				  NS_KEY_RESERVED8 | \
+				  NS_KEY_RESERVED9 | \
+				  NS_KEY_RESERVED10 | \
+				  NS_KEY_RESERVED11 )
+#define NS_KEY_RESERVED_BITMASK2 0xFFFF
+#define	NS_ALG_MD5RSA		1
+#define	NS_ALG_DH               2
+#define	NS_ALG_DSA              3
+#define	NS_ALG_DSS              NS_ALG_DSA
+#define	NS_ALG_EXPIRE_ONLY	253
+#define	NS_ALG_PRIVATE_OID	254
+
+#define NS_KEY_PROT_TLS         1
+#define NS_KEY_PROT_EMAIL       2
+#define NS_KEY_PROT_DNSSEC      3
+#define NS_KEY_PROT_IPSEC       4
+#define NS_KEY_PROT_ANY		255
+
+#define	NS_MD5RSA_MIN_BITS	 512
+#define	NS_MD5RSA_MAX_BITS	4096
+#define	NS_MD5RSA_MAX_BYTES	((NS_MD5RSA_MAX_BITS+7/8)*2+3)
+#define	NS_MD5RSA_MAX_BASE64	(((NS_MD5RSA_MAX_BYTES+2)/3)*4)
+#define NS_MD5RSA_MIN_SIZE	((NS_MD5RSA_MIN_BITS+7)/8)
+#define NS_MD5RSA_MAX_SIZE	((NS_MD5RSA_MAX_BITS+7)/8)
+
+#define NS_DSA_SIG_SIZE         41
+#define NS_DSA_MIN_SIZE         213
+#define NS_DSA_MAX_BYTES        405
+
+#define	NS_SIG_TYPE	0
+#define	NS_SIG_ALG	2
+#define	NS_SIG_LABELS	3
+#define	NS_SIG_OTTL	4
+#define	NS_SIG_EXPIR	8
+#define	NS_SIG_SIGNED	12
+#define	NS_SIG_FOOT	16
+#define	NS_SIG_SIGNER	18
+#define	NS_NXT_BITS 8
+#define	NS_NXT_BIT_SET(  n,p) (p[(n)/NS_NXT_BITS] |=  (0x80>>((n)%NS_NXT_BITS)))
+#define	NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
+#define	NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] &   (0x80>>((n)%NS_NXT_BITS)))
+#define NS_NXT_MAX 127
+
+#define NS_OPT_DNSSEC_OK        0x8000U
+#define NS_OPT_NSID		3
+
+#define NS_GET16(s, cp) (void)((s) = ns_get16(((cp)+=2)-2))
+#define NS_GET32(l, cp) (void)((l) = ns_get32(((cp)+=4)-4))
+#define NS_PUT16(s, cp) ns_put16((s), ((cp)+=2)-2)
+#define NS_PUT32(l, cp) ns_put32((l), ((cp)+=4)-4)
+
+unsigned ns_get16(const unsigned char *);
+unsigned long ns_get32(const unsigned char *);
+void ns_put16(unsigned, unsigned char *);
+void ns_put32(unsigned long, unsigned char *);
+
+int ns_initparse(const unsigned char *, int, ns_msg *);
+int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
+int ns_skiprr(const unsigned char *, const unsigned char *, ns_sect, int);
+int ns_name_uncompress(const unsigned char *, const unsigned char *, const unsigned char *, char *, size_t);
+
+
+#define	__BIND		19950621
+
+typedef struct {
+	unsigned	id :16;
+#if __BYTE_ORDER == __BIG_ENDIAN
+	unsigned	qr: 1;
+	unsigned	opcode: 4;
+	unsigned	aa: 1;
+	unsigned	tc: 1;
+	unsigned	rd: 1;
+	unsigned	ra: 1;
+	unsigned	unused :1;
+	unsigned	ad: 1;
+	unsigned	cd: 1;
+	unsigned	rcode :4;
+#else
+	unsigned	rd :1;
+	unsigned	tc :1;
+	unsigned	aa :1;
+	unsigned	opcode :4;
+	unsigned	qr :1;
+	unsigned	rcode :4;
+	unsigned	cd: 1;
+	unsigned	ad: 1;
+	unsigned	unused :1;
+	unsigned	ra :1;
+#endif
+	unsigned	qdcount :16;
+	unsigned	ancount :16;
+	unsigned	nscount :16;
+	unsigned	arcount :16;
+} HEADER;
+
+#define PACKETSZ	NS_PACKETSZ
+#define MAXDNAME	NS_MAXDNAME
+#define MAXCDNAME	NS_MAXCDNAME
+#define MAXLABEL	NS_MAXLABEL
+#define	HFIXEDSZ	NS_HFIXEDSZ
+#define QFIXEDSZ	NS_QFIXEDSZ
+#define RRFIXEDSZ	NS_RRFIXEDSZ
+#define	INT32SZ		NS_INT32SZ
+#define	INT16SZ		NS_INT16SZ
+#define INT8SZ		NS_INT8SZ
+#define	INADDRSZ	NS_INADDRSZ
+#define	IN6ADDRSZ	NS_IN6ADDRSZ
+#define	INDIR_MASK	NS_CMPRSFLGS
+#define NAMESERVER_PORT	NS_DEFAULTPORT
+
+#define S_ZONE		ns_s_zn
+#define S_PREREQ	ns_s_pr
+#define S_UPDATE	ns_s_ud
+#define S_ADDT		ns_s_ar
+
+#define QUERY		ns_o_query
+#define IQUERY		ns_o_iquery
+#define STATUS		ns_o_status
+#define	NS_NOTIFY_OP	ns_o_notify
+#define	NS_UPDATE_OP	ns_o_update
+
+#define NOERROR		ns_r_noerror
+#define FORMERR		ns_r_formerr
+#define SERVFAIL	ns_r_servfail
+#define NXDOMAIN	ns_r_nxdomain
+#define NOTIMP		ns_r_notimpl
+#define REFUSED		ns_r_refused
+#define YXDOMAIN	ns_r_yxdomain
+#define YXRRSET		ns_r_yxrrset
+#define NXRRSET		ns_r_nxrrset
+#define NOTAUTH		ns_r_notauth
+#define NOTZONE		ns_r_notzone
+
+#define DELETE		ns_uop_delete
+#define ADD		ns_uop_add
+
+#define T_A		ns_t_a
+#define T_NS		ns_t_ns
+#define T_MD		ns_t_md
+#define T_MF		ns_t_mf
+#define T_CNAME		ns_t_cname
+#define T_SOA		ns_t_soa
+#define T_MB		ns_t_mb
+#define T_MG		ns_t_mg
+#define T_MR		ns_t_mr
+#define T_NULL		ns_t_null
+#define T_WKS		ns_t_wks
+#define T_PTR		ns_t_ptr
+#define T_HINFO		ns_t_hinfo
+#define T_MINFO		ns_t_minfo
+#define T_MX		ns_t_mx
+#define T_TXT		ns_t_txt
+#define	T_RP		ns_t_rp
+#define T_AFSDB		ns_t_afsdb
+#define T_X25		ns_t_x25
+#define T_ISDN		ns_t_isdn
+#define T_RT		ns_t_rt
+#define T_NSAP		ns_t_nsap
+#define T_NSAP_PTR	ns_t_nsap_ptr
+#define	T_SIG		ns_t_sig
+#define	T_KEY		ns_t_key
+#define	T_PX		ns_t_px
+#define	T_GPOS		ns_t_gpos
+#define	T_AAAA		ns_t_aaaa
+#define	T_LOC		ns_t_loc
+#define	T_NXT		ns_t_nxt
+#define	T_EID		ns_t_eid
+#define	T_NIMLOC	ns_t_nimloc
+#define	T_SRV		ns_t_srv
+#define T_ATMA		ns_t_atma
+#define T_NAPTR		ns_t_naptr
+#define T_A6		ns_t_a6
+#define T_DNAME		ns_t_dname
+#define	T_TSIG		ns_t_tsig
+#define	T_IXFR		ns_t_ixfr
+#define T_AXFR		ns_t_axfr
+#define T_MAILB		ns_t_mailb
+#define T_MAILA		ns_t_maila
+#define T_ANY		ns_t_any
+
+#define C_IN		ns_c_in
+#define C_CHAOS		ns_c_chaos
+#define C_HS		ns_c_hs
+#define C_NONE		ns_c_none
+#define C_ANY		ns_c_any
+
+#define	GETSHORT		NS_GET16
+#define	GETLONG			NS_GET32
+#define	PUTSHORT		NS_PUT16
+#define	PUTLONG			NS_PUT32
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/nameser_compat.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/nameser_compat.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/nameser_compat.h	(revision 279)
@@ -0,0 +1,2 @@
+#include <arpa/nameser.h>
+
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/telnet.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/telnet.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/telnet.h	(revision 279)
@@ -0,0 +1,251 @@
+#ifndef _ARPA_TELNET_H
+#define	_ARPA_TELNET_H
+
+#define	IAC	255
+#define	DONT	254
+#define	DO	253
+#define	WONT	252
+#define	WILL	251
+#define	SB	250
+#define	GA	249
+#define	EL	248
+#define	EC	247
+#define	AYT	246
+#define	AO	245
+#define	IP	244
+#define	BREAK	243
+#define	DM	242
+#define	NOP	241
+#define	SE	240
+#define EOR     239
+#define	ABORT	238
+#define	SUSP	237
+#define	xEOF	236
+
+#define SYNCH	242
+
+#define telcmds ((char [][6]){ "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 })
+
+#define	TELCMD_FIRST	xEOF
+#define	TELCMD_LAST	IAC
+#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
+			 (unsigned int)(x) >= TELCMD_FIRST)
+#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
+
+#define TELOPT_BINARY	0
+#define TELOPT_ECHO	1
+#define	TELOPT_RCP	2
+#define	TELOPT_SGA	3
+#define	TELOPT_NAMS	4
+#define	TELOPT_STATUS	5
+#define	TELOPT_TM	6
+#define	TELOPT_RCTE	7
+#define TELOPT_NAOL 	8
+#define TELOPT_NAOP 	9
+#define TELOPT_NAOCRD	10
+#define TELOPT_NAOHTS	11
+#define TELOPT_NAOHTD	12
+#define TELOPT_NAOFFD	13
+#define TELOPT_NAOVTS	14
+#define TELOPT_NAOVTD	15
+#define TELOPT_NAOLFD	16
+#define TELOPT_XASCII	17
+#define	TELOPT_LOGOUT	18
+#define	TELOPT_BM	19
+#define	TELOPT_DET	20
+#define	TELOPT_SUPDUP	21
+#define	TELOPT_SUPDUPOUTPUT 22
+#define	TELOPT_SNDLOC	23
+#define	TELOPT_TTYPE	24
+#define	TELOPT_EOR	25
+#define	TELOPT_TUID	26
+#define	TELOPT_OUTMRK	27
+#define	TELOPT_TTYLOC	28
+#define	TELOPT_3270REGIME 29
+#define	TELOPT_X3PAD	30
+#define	TELOPT_NAWS	31
+#define	TELOPT_TSPEED	32
+#define	TELOPT_LFLOW	33
+#define TELOPT_LINEMODE	34
+#define TELOPT_XDISPLOC	35
+#define TELOPT_OLD_ENVIRON 36
+#define	TELOPT_AUTHENTICATION 37/* Authenticate */
+#define	TELOPT_ENCRYPT	38
+#define TELOPT_NEW_ENVIRON 39
+#define	TELOPT_EXOPL	255
+
+
+#define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
+#ifdef TELOPTS
+char *telopts[NTELOPTS+1] = {
+	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
+	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
+	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
+	"ENCRYPT", "NEW-ENVIRON",
+	0,
+};
+#define	TELOPT_FIRST	TELOPT_BINARY
+#define	TELOPT_LAST	TELOPT_NEW_ENVIRON
+#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
+#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
+#endif
+
+#define	TELQUAL_IS	0
+#define	TELQUAL_SEND	1
+#define	TELQUAL_INFO	2
+#define	TELQUAL_REPLY	2
+#define	TELQUAL_NAME	3
+
+#define	LFLOW_OFF		0
+#define	LFLOW_ON		1
+#define	LFLOW_RESTART_ANY	2
+#define	LFLOW_RESTART_XON	3
+
+
+#define	LM_MODE		1
+#define	LM_FORWARDMASK	2
+#define	LM_SLC		3
+
+#define	MODE_EDIT	0x01
+#define	MODE_TRAPSIG	0x02
+#define	MODE_ACK	0x04
+#define MODE_SOFT_TAB	0x08
+#define MODE_LIT_ECHO	0x10
+
+#define	MODE_MASK	0x1f
+
+#define MODE_FLOW		0x0100
+#define MODE_ECHO		0x0200
+#define MODE_INBIN		0x0400
+#define MODE_OUTBIN		0x0800
+#define MODE_FORCE		0x1000
+
+#define	SLC_SYNCH	1
+#define	SLC_BRK		2
+#define	SLC_IP		3
+#define	SLC_AO		4
+#define	SLC_AYT		5
+#define	SLC_EOR		6
+#define	SLC_ABORT	7
+#define	SLC_EOF		8
+#define	SLC_SUSP	9
+#define	SLC_EC		10
+#define	SLC_EL		11
+#define	SLC_EW		12
+#define	SLC_RP		13
+#define	SLC_LNEXT	14
+#define	SLC_XON		15
+#define	SLC_XOFF	16
+#define	SLC_FORW1	17
+#define	SLC_FORW2	18
+
+#define	NSLC		18
+
+#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+			"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
+#ifdef	SLC_NAMES
+char *slc_names[] = {
+	SLC_NAMELIST
+};
+#else
+extern char *slc_names[];
+#define	SLC_NAMES SLC_NAMELIST
+#endif
+
+#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
+#define SLC_NAME(x)	slc_names[x]
+
+#define	SLC_NOSUPPORT	0
+#define	SLC_CANTCHANGE	1
+#define	SLC_VARIABLE	2
+#define	SLC_DEFAULT	3
+#define	SLC_LEVELBITS	0x03
+
+#define	SLC_FUNC	0
+#define	SLC_FLAGS	1
+#define	SLC_VALUE	2
+
+#define	SLC_ACK		0x80
+#define	SLC_FLUSHIN	0x40
+#define	SLC_FLUSHOUT	0x20
+
+#define	OLD_ENV_VAR	1
+#define	OLD_ENV_VALUE	0
+#define	NEW_ENV_VAR	0
+#define	NEW_ENV_VALUE	1
+#define	ENV_ESC		2
+#define ENV_USERVAR	3
+
+#define	AUTH_WHO_CLIENT		0
+#define	AUTH_WHO_SERVER		1
+#define	AUTH_WHO_MASK		1
+
+#define	AUTH_HOW_ONE_WAY	0
+#define	AUTH_HOW_MUTUAL		2
+#define	AUTH_HOW_MASK		2
+
+#define	AUTHTYPE_NULL		0
+#define	AUTHTYPE_KERBEROS_V4	1
+#define	AUTHTYPE_KERBEROS_V5	2
+#define	AUTHTYPE_SPX		3
+#define	AUTHTYPE_MINK		4
+#define	AUTHTYPE_CNT		5
+
+#define	AUTHTYPE_TEST		99
+
+#ifdef	AUTH_NAMES
+char *authtype_names[] = {
+	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
+#define	AUTHTYPE_NAME(x)	authtype_names[x]
+
+#define	ENCRYPT_IS		0
+#define	ENCRYPT_SUPPORT		1
+#define	ENCRYPT_REPLY		2
+#define	ENCRYPT_START		3
+#define	ENCRYPT_END		4
+#define	ENCRYPT_REQSTART	5
+#define	ENCRYPT_REQEND		6
+#define	ENCRYPT_ENC_KEYID	7
+#define	ENCRYPT_DEC_KEYID	8
+#define	ENCRYPT_CNT		9
+
+#define	ENCTYPE_ANY		0
+#define	ENCTYPE_DES_CFB64	1
+#define	ENCTYPE_DES_OFB64	2
+#define	ENCTYPE_CNT		3
+
+#ifdef	ENCRYPT_NAMES
+char *encrypt_names[] = {
+	"IS", "SUPPORT", "REPLY", "START", "END",
+	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+	0,
+};
+char *enctype_names[] = {
+	"ANY", "DES_CFB64",  "DES_OFB64",  0,
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+
+#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
+#define	ENCRYPT_NAME(x)		encrypt_names[x]
+
+#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
+#define	ENCTYPE_NAME(x)		enctype_names[x]
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/tftp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/tftp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/arpa/tftp.h	(revision 279)
@@ -0,0 +1,31 @@
+#ifndef _ARPA_TFTP_H
+#define _ARPA_TFTP_H
+#define SEGSIZE 512
+#define RRQ 01
+#define WRQ 02
+#define DATA 03
+#define ACK 04
+#define ERROR 05
+struct tftphdr {
+	short th_opcode;
+	union {
+		unsigned short tu_block;
+		short tu_code;
+		char tu_stuff[1];
+	} th_u;
+	char th_data[1];
+};
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+#define EUNDEF 0
+#define ENOTFOUND 1
+#define EACCESS 2
+#define ENOSPACE 3
+#define EBADOP 4
+#define EBADID 5
+#define EEXISTS 6
+#define ENOUSER 7
+#endif
+
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/bits/alltypes.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/bits/alltypes.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/bits/alltypes.h	(revision 279)
@@ -0,0 +1,386 @@
+#define _Addr int
+#define _Int64 long long
+#define _Reg int
+
+#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
+typedef __builtin_va_list __gnuc_va_list; 
+typedef __gnuc_va_list va_list;
+#define __DEFINED_va_list
+#endif
+
+#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
+typedef char* __isoc_va_list;
+#define __DEFINED___isoc_va_list
+#endif
+
+
+#ifndef __cplusplus
+#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
+typedef unsigned short wchar_t;
+#define __DEFINED_wchar_t
+#endif
+
+#endif
+
+#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
+typedef float float_t;
+#define __DEFINED_float_t
+#endif
+
+#if defined(__NEED_double_t) && !defined(__DEFINED_double_t)
+typedef double double_t;
+#define __DEFINED_double_t
+#endif
+
+
+#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
+typedef struct { long long __ll; long double __ld; } max_align_t;
+#define __DEFINED_max_align_t
+#endif
+
+
+#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
+typedef long time_t;
+#define __DEFINED_time_t
+#endif
+
+#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
+typedef long suseconds_t;
+#define __DEFINED_suseconds_t
+#endif
+
+
+#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
+typedef struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+#define __DEFINED_pthread_attr_t
+#endif
+
+#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
+typedef struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+#define __DEFINED_pthread_mutex_t
+#endif
+
+#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t)
+typedef struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+#define __DEFINED_mtx_t
+#endif
+
+#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
+typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+#define __DEFINED_pthread_cond_t
+#endif
+
+#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t)
+typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+#define __DEFINED_cnd_t
+#endif
+
+#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
+typedef struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+#define __DEFINED_pthread_rwlock_t
+#endif
+
+#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
+typedef struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
+#define __DEFINED_pthread_barrier_t
+#endif
+
+#if defined(__NEED_size_t) && !defined(__DEFINED_size_t)
+typedef unsigned _Addr size_t;
+#define __DEFINED_size_t
+#endif
+
+#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t)
+typedef unsigned _Addr uintptr_t;
+#define __DEFINED_uintptr_t
+#endif
+
+#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t)
+typedef _Addr ptrdiff_t;
+#define __DEFINED_ptrdiff_t
+#endif
+
+#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t)
+typedef _Addr ssize_t;
+#define __DEFINED_ssize_t
+#endif
+
+#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t)
+typedef _Addr intptr_t;
+#define __DEFINED_intptr_t
+#endif
+
+#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t)
+typedef _Addr regoff_t;
+#define __DEFINED_regoff_t
+#endif
+
+#if defined(__NEED_register_t) && !defined(__DEFINED_register_t)
+typedef _Reg register_t;
+#define __DEFINED_register_t
+#endif
+
+
+#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t)
+typedef signed char     int8_t;
+#define __DEFINED_int8_t
+#endif
+
+#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t)
+typedef short           int16_t;
+#define __DEFINED_int16_t
+#endif
+
+#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t)
+typedef int             int32_t;
+#define __DEFINED_int32_t
+#endif
+
+#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t)
+typedef _Int64          int64_t;
+#define __DEFINED_int64_t
+#endif
+
+#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t)
+typedef _Int64          intmax_t;
+#define __DEFINED_intmax_t
+#endif
+
+#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t)
+typedef unsigned char   uint8_t;
+#define __DEFINED_uint8_t
+#endif
+
+#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t)
+typedef unsigned short  uint16_t;
+#define __DEFINED_uint16_t
+#endif
+
+#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t)
+typedef unsigned int    uint32_t;
+#define __DEFINED_uint32_t
+#endif
+
+#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t)
+typedef unsigned _Int64 uint64_t;
+#define __DEFINED_uint64_t
+#endif
+
+#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t)
+typedef unsigned _Int64 u_int64_t;
+#define __DEFINED_u_int64_t
+#endif
+
+#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t)
+typedef unsigned _Int64 uintmax_t;
+#define __DEFINED_uintmax_t
+#endif
+
+
+#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t)
+typedef unsigned mode_t;
+#define __DEFINED_mode_t
+#endif
+
+#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t)
+typedef unsigned _Reg nlink_t;
+#define __DEFINED_nlink_t
+#endif
+
+#if defined(__NEED_off_t) && !defined(__DEFINED_off_t)
+typedef int off_t;
+#define __DEFINED_off_t
+#endif
+
+#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t)
+typedef unsigned short ino_t;
+#define __DEFINED_ino_t
+#endif
+
+#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t)
+typedef unsigned int dev_t;
+#define __DEFINED_dev_t
+#endif
+
+#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t)
+typedef long blksize_t;
+#define __DEFINED_blksize_t
+#endif
+
+#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t)
+typedef int blkcnt_t;
+#define __DEFINED_blkcnt_t
+#endif
+
+#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
+typedef unsigned int fsblkcnt_t;
+#define __DEFINED_fsblkcnt_t
+#endif
+
+#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
+typedef unsigned int fsfilcnt_t;
+#define __DEFINED_fsfilcnt_t
+#endif
+
+
+#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
+typedef unsigned wint_t;
+#define __DEFINED_wint_t
+#endif
+
+#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t)
+typedef unsigned long wctype_t;
+#define __DEFINED_wctype_t
+#endif
+
+
+#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t)
+typedef void * timer_t;
+#define __DEFINED_timer_t
+#endif
+
+#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t)
+typedef int clockid_t;
+#define __DEFINED_clockid_t
+#endif
+
+#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
+typedef long clock_t;
+#define __DEFINED_clock_t
+#endif
+
+#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
+//struct timeval { time_t tv_sec; suseconds_t tv_usec; };
+#define __DEFINED_struct_timeval
+#endif
+
+#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
+struct timespec { time_t tv_sec; long tv_nsec; };
+#define __DEFINED_struct_timespec
+#endif
+
+
+#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t)
+typedef int pid_t;
+#define __DEFINED_pid_t
+#endif
+
+#if defined(__NEED_id_t) && !defined(__DEFINED_id_t)
+typedef unsigned id_t;
+#define __DEFINED_id_t
+#endif
+
+#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t)
+typedef unsigned uid_t;
+#define __DEFINED_uid_t
+#endif
+
+#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t)
+typedef unsigned gid_t;
+#define __DEFINED_gid_t
+#endif
+
+#if defined(__NEED_key_t) && !defined(__DEFINED_key_t)
+typedef int key_t;
+#define __DEFINED_key_t
+#endif
+
+#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t)
+typedef unsigned useconds_t;
+#define __DEFINED_useconds_t
+#endif
+
+
+#ifdef __cplusplus
+#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
+typedef unsigned long pthread_t;
+#define __DEFINED_pthread_t
+#endif
+
+#else
+#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
+typedef struct __pthread * pthread_t;
+#define __DEFINED_pthread_t
+#endif
+
+#endif
+#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t)
+typedef int pthread_once_t;
+#define __DEFINED_pthread_once_t
+#endif
+
+#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t)
+typedef unsigned pthread_key_t;
+#define __DEFINED_pthread_key_t
+#endif
+
+#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t)
+typedef int pthread_spinlock_t;
+#define __DEFINED_pthread_spinlock_t
+#endif
+
+#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t)
+typedef struct { unsigned __attr; } pthread_mutexattr_t;
+#define __DEFINED_pthread_mutexattr_t
+#endif
+
+#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t)
+typedef struct { unsigned __attr; } pthread_condattr_t;
+#define __DEFINED_pthread_condattr_t
+#endif
+
+#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t)
+typedef struct { unsigned __attr; } pthread_barrierattr_t;
+#define __DEFINED_pthread_barrierattr_t
+#endif
+
+#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t)
+typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
+#define __DEFINED_pthread_rwlockattr_t
+#endif
+
+
+#if defined(__NEED_FILE) && !defined(__DEFINED_FILE)
+typedef __FILE FILE;
+#define __DEFINED_FILE
+#endif
+
+
+#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t)
+typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
+#define __DEFINED_mbstate_t
+#endif
+
+
+#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t)
+typedef struct __locale_struct * locale_t;
+#define __DEFINED_locale_t
+#endif
+
+
+#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
+typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
+#define __DEFINED_sigset_t
+#endif
+
+
+#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
+struct iovec { void *iov_base; size_t iov_len; };
+#define __DEFINED_struct_iovec
+#endif
+
+
+#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t)
+typedef unsigned socklen_t;
+#define __DEFINED_socklen_t
+#endif
+
+#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t)
+typedef unsigned short sa_family_t;
+#define __DEFINED_sa_family_t
+#endif
+
+
+#undef _Addr
+#undef _Int64
+#undef _Reg
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/bits/ioctl.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/bits/ioctl.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/bits/ioctl.h	(revision 279)
@@ -0,0 +1,197 @@
+#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) )
+#define _IOC_NONE  0U
+#define _IOC_WRITE 1U
+#define _IOC_READ  2U
+
+#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+
+#define TCGETS		0x5401
+#define TCSETS		0x5402
+#define TCSETSW		0x5403
+#define TCSETSF		0x5404
+#define TCGETA		0x5405
+#define TCSETA		0x5406
+#define TCSETAW		0x5407
+#define TCSETAF		0x5408
+#define TCSBRK		0x5409
+#define TCXONC		0x540A
+#define TCFLSH		0x540B
+#define TIOCEXCL	0x540C
+#define TIOCNXCL	0x540D
+#define TIOCSCTTY	0x540E
+#define TIOCGPGRP	0x540F
+#define TIOCSPGRP	0x5410
+#define TIOCOUTQ	0x5411
+#define TIOCSTI		0x5412
+#define TIOCGWINSZ	0x5413
+#define TIOCSWINSZ	0x5414
+#define TIOCMGET	0x5415
+#define TIOCMBIS	0x5416
+#define TIOCMBIC	0x5417
+#define TIOCMSET	0x5418
+#define TIOCGSOFTCAR	0x5419
+#define TIOCSSOFTCAR	0x541A
+#define FIONREAD	0x541B
+#define TIOCINQ		FIONREAD
+#define TIOCLINUX	0x541C
+#define TIOCCONS	0x541D
+#define TIOCGSERIAL	0x541E
+#define TIOCSSERIAL	0x541F
+#define TIOCPKT		0x5420
+#define FIONBIO		0x5421
+#define TIOCNOTTY	0x5422
+#define TIOCSETD	0x5423
+#define TIOCGETD	0x5424
+#define TCSBRKP		0x5425
+#define TIOCTTYGSTRUCT	0x5426
+#define TIOCSBRK	0x5427
+#define TIOCCBRK	0x5428
+#define TIOCGSID	0x5429
+#define TIOCGPTN	0x80045430
+#define TIOCSPTLCK	0x40045431
+#define TCGETX		0x5432
+#define TCSETX		0x5433
+#define TCSETXF		0x5434
+#define TCSETXW		0x5435
+
+#define FIONCLEX	0x5450
+#define FIOCLEX		0x5451
+#define FIOASYNC	0x5452
+#define TIOCSERCONFIG	0x5453
+#define TIOCSERGWILD	0x5454
+#define TIOCSERSWILD	0x5455
+#define TIOCGLCKTRMIOS	0x5456
+#define TIOCSLCKTRMIOS	0x5457
+#define TIOCSERGSTRUCT	0x5458
+#define TIOCSERGETLSR   0x5459
+#define TIOCSERGETMULTI 0x545A
+#define TIOCSERSETMULTI 0x545B
+
+#define TIOCMIWAIT	0x545C
+#define TIOCGICOUNT	0x545D
+#define TIOCGHAYESESP   0x545E
+#define TIOCSHAYESESP   0x545F
+#define FIOQSIZE	0x5460
+
+#define TIOCPKT_DATA		 0
+#define TIOCPKT_FLUSHREAD	 1
+#define TIOCPKT_FLUSHWRITE	 2
+#define TIOCPKT_STOP		 4
+#define TIOCPKT_START		 8
+#define TIOCPKT_NOSTOP		16
+#define TIOCPKT_DOSTOP		32
+#define TIOCPKT_IOCTL		64
+
+#define TIOCSER_TEMT    0x01
+
+struct winsize {
+	unsigned short ws_row;
+	unsigned short ws_col;
+	unsigned short ws_xpixel;
+	unsigned short ws_ypixel;
+};
+
+#define TIOCM_LE        0x001
+#define TIOCM_DTR       0x002
+#define TIOCM_RTS       0x004
+#define TIOCM_ST        0x008
+#define TIOCM_SR        0x010
+#define TIOCM_CTS       0x020
+#define TIOCM_CAR       0x040
+#define TIOCM_RNG       0x080
+#define TIOCM_DSR       0x100
+#define TIOCM_CD        TIOCM_CAR
+#define TIOCM_RI        TIOCM_RNG
+#define TIOCM_OUT1      0x2000
+#define TIOCM_OUT2      0x4000
+#define TIOCM_LOOP      0x8000
+#define TIOCM_MODEM_BITS TIOCM_OUT2
+
+#define N_TTY           0
+#define N_SLIP          1
+#define N_MOUSE         2
+#define N_PPP           3
+#define N_STRIP         4
+#define N_AX25          5
+#define N_X25           6
+#define N_6PACK         7
+#define N_MASC          8
+#define N_R3964         9
+#define N_PROFIBUS_FDL  10
+#define N_IRDA          11
+#define N_SMSBLOCK      12
+#define N_HDLC          13
+#define N_SYNC_PPP      14
+#define N_HCI           15
+
+#define FIOSETOWN       0x8901
+#define SIOCSPGRP       0x8902
+#define FIOGETOWN       0x8903
+#define SIOCGPGRP       0x8904
+#define SIOCATMARK      0x8905
+#define SIOCGSTAMP      0x8906
+
+#define SIOCADDRT       0x890B
+#define SIOCDELRT       0x890C
+#define SIOCRTMSG       0x890D
+
+#define SIOCGIFNAME     0x8910
+#define SIOCSIFLINK     0x8911
+#define SIOCGIFCONF     0x8912
+#define SIOCGIFFLAGS    0x8913
+#define SIOCSIFFLAGS    0x8914
+#define SIOCGIFADDR     0x8915
+#define SIOCSIFADDR     0x8916
+#define SIOCGIFDSTADDR  0x8917
+#define SIOCSIFDSTADDR  0x8918
+#define SIOCGIFBRDADDR  0x8919
+#define SIOCSIFBRDADDR  0x891a
+#define SIOCGIFNETMASK  0x891b
+#define SIOCSIFNETMASK  0x891c
+#define SIOCGIFMETRIC   0x891d
+#define SIOCSIFMETRIC   0x891e
+#define SIOCGIFMEM      0x891f
+#define SIOCSIFMEM      0x8920
+#define SIOCGIFMTU      0x8921
+#define SIOCSIFMTU      0x8922
+#define SIOCSIFHWADDR   0x8924
+#define SIOCGIFENCAP    0x8925
+#define SIOCSIFENCAP    0x8926
+#define SIOCGIFHWADDR   0x8927
+#define SIOCGIFSLAVE    0x8929
+#define SIOCSIFSLAVE    0x8930
+#define SIOCADDMULTI    0x8931
+#define SIOCDELMULTI    0x8932
+#define SIOCGIFINDEX    0x8933
+#define SIOGIFINDEX     SIOCGIFINDEX
+#define SIOCSIFPFLAGS   0x8934
+#define SIOCGIFPFLAGS   0x8935
+#define SIOCDIFADDR     0x8936
+#define SIOCSIFHWBROADCAST 0x8937
+#define SIOCGIFCOUNT    0x8938
+
+#define SIOCGIFBR       0x8940
+#define SIOCSIFBR       0x8941
+
+#define SIOCGIFTXQLEN   0x8942
+#define SIOCSIFTXQLEN   0x8943
+
+#define SIOCDARP        0x8953
+#define SIOCGARP        0x8954
+#define SIOCSARP        0x8955
+
+#define SIOCDRARP       0x8960
+#define SIOCGRARP       0x8961
+#define SIOCSRARP       0x8962
+
+#define SIOCGIFMAP      0x8970
+#define SIOCSIFMAP      0x8971
+
+#define SIOCADDDLCI     0x8980
+#define SIOCDELDLCI     0x8981
+
+#define SIOCDEVPRIVATE		0x89F0
+#define SIOCPROTOPRIVATE	0x89E0
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/bits/mman.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/bits/mman.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/bits/mman.h	(revision 279)
@@ -0,0 +1,58 @@
+#define MAP_FAILED ((void *) -1)
+
+#define	PROT_NONE      0
+#define	PROT_READ      1
+#define	PROT_WRITE     2
+#define	PROT_EXEC      4
+#define	PROT_GROWSDOWN 0x01000000
+#define	PROT_GROWSUP   0x02000000
+
+#define	MAP_SHARED     0x01
+#define	MAP_PRIVATE    0x02
+#define	MAP_FIXED      0x10
+
+#define MAP_TYPE       0x0f
+#define MAP_FILE       0x00
+#define MAP_ANON       0x20
+#define MAP_ANONYMOUS  MAP_ANON
+#define MAP_NORESERVE  0x4000
+#define MAP_GROWSDOWN  0x0100
+#define MAP_DENYWRITE  0x0800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED     0x2000
+#define MAP_POPULATE   0x8000
+#define MAP_NONBLOCK   0x10000
+#define MAP_STACK      0x20000
+#define MAP_HUGETLB    0x40000
+
+#define POSIX_MADV_NORMAL       0
+#define POSIX_MADV_RANDOM       1
+#define POSIX_MADV_SEQUENTIAL   2
+#define POSIX_MADV_WILLNEED     3
+#define POSIX_MADV_DONTNEED     0
+
+#define MS_ASYNC        1
+#define MS_INVALIDATE   2
+#define MS_SYNC         4
+
+#define MCL_CURRENT     1
+#define MCL_FUTURE      2
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define MADV_NORMAL      0
+#define MADV_RANDOM      1
+#define MADV_SEQUENTIAL  2
+#define MADV_WILLNEED    3
+#define MADV_DONTNEED    4
+#define MADV_REMOVE      9
+#define MADV_DONTFORK    10
+#define MADV_DOFORK      11
+#define MADV_MERGEABLE   12
+#define MADV_UNMERGEABLE 13
+#define MADV_HUGEPAGE    14
+#define MADV_NOHUGEPAGE  15
+#define MADV_DONTDUMP    16
+#define MADV_DODUMP      17
+#define MADV_HWPOISON    100
+#define MADV_SOFT_OFFLINE 101
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/bits/socket.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/bits/socket.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/bits/socket.h	(revision 279)
@@ -0,0 +1,17 @@
+struct msghdr
+{
+	void *msg_name;
+	socklen_t msg_namelen;
+	struct iovec *msg_iov;
+	int msg_iovlen;
+	void *msg_control;
+	socklen_t msg_controllen;
+	int msg_flags;
+};
+
+struct cmsghdr
+{
+	socklen_t cmsg_len;
+	int cmsg_level;
+	int cmsg_type;
+};
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/bits/statfs.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/bits/statfs.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/bits/statfs.h	(revision 279)
@@ -0,0 +1,7 @@
+struct statfs {
+	unsigned long f_type, f_bsize;
+	fsblkcnt_t f_blocks, f_bfree, f_bavail;
+	fsfilcnt_t f_files, f_ffree;
+	fsid_t f_fsid;
+	unsigned long f_namelen, f_frsize, f_flags, f_spare[4];
+};
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/bits/termios.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/bits/termios.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/bits/termios.h	(revision 279)
@@ -0,0 +1,160 @@
+struct termios
+{
+	tcflag_t c_iflag;
+	tcflag_t c_oflag;
+	tcflag_t c_cflag;
+	tcflag_t c_lflag;
+	cc_t c_line;
+	cc_t c_cc[NCCS];
+	speed_t __c_ispeed;
+	speed_t __c_ospeed;
+};
+
+#define VINTR     0
+#define VQUIT     1
+#define VERASE    2
+#define VKILL     3
+#define VEOF      4
+#define VTIME     5
+#define VMIN      6
+#define VSWTC     7
+#define VSTART    8
+#define VSTOP     9
+#define VSUSP    10
+#define VEOL     11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE  14
+#define VLNEXT   15
+#define VEOL2    16
+
+#define IGNBRK  0000001
+#define BRKINT  0000002
+#define IGNPAR  0000004
+#define PARMRK  0000010
+#define INPCK   0000020
+#define ISTRIP  0000040
+#define INLCR   0000100
+#define IGNCR   0000200
+#define ICRNL   0000400
+#define IUCLC   0001000
+#define IXON    0002000
+#define IXANY   0004000
+#define IXOFF   0010000
+#define IMAXBEL 0020000
+#define IUTF8   0040000
+
+#define OPOST  0000001
+#define OLCUC  0000002
+#define ONLCR  0000004
+#define OCRNL  0000010
+#define ONOCR  0000020
+#define ONLRET 0000040
+#define OFILL  0000100
+#define OFDEL  0000200
+#define NLDLY  0000400
+#define NL0    0000000
+#define NL1    0000400
+#define CRDLY  0003000
+#define CR0    0000000
+#define CR1    0001000
+#define CR2    0002000
+#define CR3    0003000
+#define TABDLY 0014000
+#define TAB0   0000000
+#define TAB1   0004000
+#define TAB2   0010000
+#define TAB3   0014000
+#define BSDLY  0020000
+#define BS0    0000000
+#define BS1    0020000
+#define FFDLY  0100000
+#define FF0    0000000
+#define FF1    0100000
+
+#define VTDLY  0040000
+#define VT0    0000000
+#define VT1    0040000
+
+#define B0       0000000
+#define B50      0000001
+#define B75      0000002
+#define B110     0000003
+#define B134     0000004
+#define B150     0000005
+#define B200     0000006
+#define B300     0000007
+#define B600     0000010
+#define B1200    0000011
+#define B1800    0000012
+#define B2400    0000013
+#define B4800    0000014
+#define B9600    0000015
+#define B19200   0000016
+#define B38400   0000017
+
+#define B57600   0010001
+#define B115200  0010002
+#define B230400  0010003
+#define B460800  0010004
+#define B500000  0010005
+#define B576000  0010006
+#define B921600  0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+
+#define CBAUD    0010017
+
+#define CSIZE  0000060
+#define CS5    0000000
+#define CS6    0000020
+#define CS7    0000040
+#define CS8    0000060
+#define CSTOPB 0000100
+#define CREAD  0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL  0002000
+#define CLOCAL 0004000
+
+#define ISIG   0000001
+#define ICANON 0000002
+#define ECHO   0000010
+#define ECHOE  0000020
+#define ECHOK  0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#define IEXTEN 0100000
+
+#define ECHOCTL 0001000
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
+#define FLUSHO 0010000
+#define PENDIN 0040000
+
+#define TCOOFF 0
+#define TCOON  1
+#define TCIOFF 2
+#define TCION  3
+
+#define TCIFLUSH  0
+#define TCOFLUSH  1
+#define TCIOFLUSH 2
+
+#define TCSANOW   0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define CBAUDEX 0010000
+#define CRTSCTS  020000000000
+#define EXTPROC 0200000
+#define XTABS  0014000
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/byteswap.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/byteswap.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/byteswap.h	(revision 279)
@@ -0,0 +1,26 @@
+#ifndef _BYTESWAP_H
+#define _BYTESWAP_H
+
+#include <features.h>
+#include <stdint.h>
+
+static __inline uint16_t __bswap_16(uint16_t __x)
+{
+	return __x<<8 | __x>>8;
+}
+
+static __inline uint32_t __bswap_32(uint32_t __x)
+{
+	return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
+}
+
+static __inline uint64_t __bswap_64(uint64_t __x)
+{
+	return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32);
+}
+
+#define bswap_16(x) __bswap_16(x)
+#define bswap_32(x) __bswap_32(x)
+#define bswap_64(x) __bswap_64(x)
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/endian.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/endian.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/endian.h	(revision 279)
@@ -0,0 +1,82 @@
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <features.h>
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#if defined(__GNUC__) && defined(__BYTE_ORDER__)
+#define __BYTE_ORDER __BYTE_ORDER__
+#else
+#include <bits/endian.h>
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#define BIG_ENDIAN __BIG_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#include <stdint.h>
+
+static __inline uint16_t __bswap16(uint16_t __x)
+{
+	return (uint16_t)(__x<<8 | __x>>8);
+}
+
+static __inline uint32_t __bswap32(uint32_t __x)
+{
+	return (uint32_t)(__x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24);
+}
+
+static __inline uint64_t __bswap64(uint64_t __x)
+{
+	return __bswap32(((uint32_t)__x)+0ULL)<<32 | __bswap32((uint32_t)(__x>>32));
+}
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define htobe16(x) __bswap16(x)
+#define be16toh(x) __bswap16(x)
+#define betoh16(x) __bswap16(x)
+#define htobe32(x) __bswap32(x)
+#define be32toh(x) __bswap32(x)
+#define betoh32(x) __bswap32(x)
+#define htobe64(x) __bswap64(x)
+#define be64toh(x) __bswap64(x)
+#define betoh64(x) __bswap64(x)
+#define htole16(x) (uint16_t)(x)
+#define le16toh(x) (uint16_t)(x)
+#define letoh16(x) (uint16_t)(x)
+#define htole32(x) (uint32_t)(x)
+#define le32toh(x) (uint32_t)(x)
+#define letoh32(x) (uint32_t)(x)
+#define htole64(x) (uint64_t)(x)
+#define le64toh(x) (uint64_t)(x)
+#define letoh64(x) (uint64_t)(x)
+#else
+#define htobe16(x) (uint16_t)(x)
+#define be16toh(x) (uint16_t)(x)
+#define betoh16(x) (uint16_t)(x)
+#define htobe32(x) (uint32_t)(x)
+#define be32toh(x) (uint32_t)(x)
+#define betoh32(x) (uint32_t)(x)
+#define htobe64(x) (uint64_t)(x)
+#define be64toh(x) (uint64_t)(x)
+#define betoh64(x) (uint64_t)(x)
+#define htole16(x) __bswap16(x)
+#define le16toh(x) __bswap16(x)
+#define letoh16(x) __bswap16(x)
+#define htole32(x) __bswap32(x)
+#define le32toh(x) __bswap32(x)
+#define letoh32(x) __bswap32(x)
+#define htole64(x) __bswap64(x)
+#define le64toh(x) __bswap64(x)
+#define letoh64(x) __bswap64(x)
+#endif
+
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/features.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/features.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/features.h	(revision 279)
@@ -0,0 +1,36 @@
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
+#define _GNU_SOURCE 1
+#endif
+
+#if defined(_DEFAULT_SOURCE) && !defined(_BSD_SOURCE)
+#define _BSD_SOURCE 1
+#endif
+
+#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
+ && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
+ && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
+#define _BSD_SOURCE 1
+#define _XOPEN_SOURCE 700
+#endif
+
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
+#define __inline inline
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#elif defined(__GNUC__)
+#define _Noreturn __attribute__((__noreturn__))
+#else
+#define _Noreturn
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/mntent.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/mntent.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/mntent.h	(revision 279)
@@ -0,0 +1,44 @@
+#ifndef _MNTENT_H
+#define _MNTENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_FILE
+#include <bits/alltypes.h>
+
+#define MOUNTED "/etc/mtab"
+
+#define MNTTYPE_IGNORE	"ignore"
+#define MNTTYPE_NFS	"nfs"
+#define MNTTYPE_SWAP	"swap"
+#define MNTOPT_DEFAULTS	"defaults"
+#define MNTOPT_RO	"ro"
+#define MNTOPT_RW	"rw"
+#define MNTOPT_SUID	"suid"
+#define MNTOPT_NOSUID	"nosuid"
+#define MNTOPT_NOAUTO	"noauto"
+
+struct mntent
+{
+	char *mnt_fsname;
+	char *mnt_dir;
+	char *mnt_type;
+	char *mnt_opts;
+	int mnt_freq;
+	int mnt_passno;
+};
+
+FILE *setmntent(const char *, const char *);
+int endmntent(FILE *);
+struct mntent *getmntent(FILE *);
+struct mntent *getmntent_r(FILE *, struct mntent *, char *, int);
+int addmntent(FILE *, const struct mntent *);
+char *hasmntopt(const struct mntent *, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/net/ethernet.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/net/ethernet.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/net/ethernet.h	(revision 279)
@@ -0,0 +1,55 @@
+#ifndef _NET_ETHERNET_H
+#define _NET_ETHERNET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <netinet/if_ether.h>
+
+struct ether_addr {
+	uint8_t ether_addr_octet[ETH_ALEN];
+};
+
+struct ether_header {
+	uint8_t  ether_dhost[ETH_ALEN];
+	uint8_t  ether_shost[ETH_ALEN];
+	uint16_t ether_type;
+};
+
+#define	ETHERTYPE_PUP		0x0200
+#define ETHERTYPE_SPRITE	0x0500
+#define	ETHERTYPE_IP		0x0800
+#define	ETHERTYPE_ARP		0x0806
+#define	ETHERTYPE_REVARP	0x8035
+#define ETHERTYPE_AT		0x809B
+#define ETHERTYPE_AARP		0x80F3
+#define	ETHERTYPE_VLAN		0x8100
+#define ETHERTYPE_IPX		0x8137
+#define	ETHERTYPE_IPV6		0x86dd
+#define ETHERTYPE_LOOPBACK	0x9000
+
+
+#define	ETHER_ADDR_LEN	ETH_ALEN
+#define	ETHER_TYPE_LEN	2
+#define	ETHER_CRC_LEN	4
+#define	ETHER_HDR_LEN	ETH_HLEN
+#define	ETHER_MIN_LEN	(ETH_ZLEN + ETHER_CRC_LEN)
+#define	ETHER_MAX_LEN	(ETH_FRAME_LEN + ETHER_CRC_LEN)
+
+#define	ETHER_IS_VALID_LEN(foo)	\
+	((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
+
+#define	ETHERTYPE_TRAIL		0x1000
+#define	ETHERTYPE_NTRAILER	16
+
+#define	ETHERMTU	ETH_DATA_LEN
+#define	ETHERMIN	(ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/net/if.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/net/if.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/net/if.h	(revision 279)
@@ -0,0 +1,135 @@
+#ifndef _NET_IF_H
+#define _NET_IF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define IF_NAMESIZE 16
+
+struct if_nameindex
+{
+	unsigned int if_index;
+	char *if_name;
+};
+
+unsigned int if_nametoindex (const char *);
+char *if_indextoname (unsigned int, char *);
+struct if_nameindex *if_nameindex (void);
+void if_freenameindex (struct if_nameindex *);
+
+
+
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#include <sys/socket.h>
+
+#define IFF_UP	0x1
+#define IFF_BROADCAST 0x2
+#define IFF_DEBUG 0x4
+#define IFF_LOOPBACK 0x8
+#define IFF_POINTOPOINT 0x10
+#define IFF_NOTRAILERS 0x20
+#define IFF_RUNNING 0x40
+#define IFF_NOARP 0x80
+#define IFF_PROMISC 0x100
+#define IFF_ALLMULTI 0x200
+#define IFF_MASTER 0x400
+#define IFF_SLAVE 0x800
+#define IFF_MULTICAST 0x1000
+#define IFF_PORTSEL 0x2000
+#define IFF_AUTOMEDIA 0x4000
+#define IFF_DYNAMIC 0x8000
+#define IFF_LOWER_UP 0x10000
+#define IFF_DORMANT 0x20000
+#define IFF_ECHO 0x40000
+#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST| \
+        IFF_ECHO|IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
+
+struct ifaddr {
+	struct sockaddr ifa_addr;
+	union {
+		struct sockaddr	ifu_broadaddr;
+		struct sockaddr	ifu_dstaddr;
+	} ifa_ifu;
+	struct iface *ifa_ifp;
+	struct ifaddr *ifa_next;
+};
+
+#define ifa_broadaddr	ifa_ifu.ifu_broadaddr
+#define ifa_dstaddr	ifa_ifu.ifu_dstaddr
+
+struct ifmap {
+	unsigned long int mem_start;
+	unsigned long int mem_end;
+	unsigned short int base_addr;
+	unsigned char irq;
+	unsigned char dma;
+	unsigned char port;
+};
+
+#define IFHWADDRLEN	6
+#define IFNAMSIZ	IF_NAMESIZE
+
+struct ifreq {
+	union {
+		char ifrn_name[IFNAMSIZ];
+	} ifr_ifrn;
+	union {
+		struct sockaddr ifru_addr;
+		struct sockaddr ifru_dstaddr;
+		struct sockaddr ifru_broadaddr;
+		struct sockaddr ifru_netmask;
+		struct sockaddr ifru_hwaddr;
+		short int ifru_flags;
+		int ifru_ivalue;
+		int ifru_mtu;
+		struct ifmap ifru_map;
+		char ifru_slave[IFNAMSIZ];
+		char ifru_newname[IFNAMSIZ];
+		void *ifru_data;
+	} ifr_ifru;
+};
+
+#define ifr_name	ifr_ifrn.ifrn_name
+#define ifr_hwaddr	ifr_ifru.ifru_hwaddr
+#define ifr_addr	ifr_ifru.ifru_addr
+#define ifr_dstaddr	ifr_ifru.ifru_dstaddr
+#define ifr_broadaddr	ifr_ifru.ifru_broadaddr
+#define ifr_netmask	ifr_ifru.ifru_netmask
+#define ifr_flags	ifr_ifru.ifru_flags
+#define ifr_metric	ifr_ifru.ifru_ivalue
+#define ifr_mtu		ifr_ifru.ifru_mtu
+#define ifr_map		ifr_ifru.ifru_map
+#define ifr_slave	ifr_ifru.ifru_slave
+#define ifr_data	ifr_ifru.ifru_data
+#define ifr_ifindex	ifr_ifru.ifru_ivalue
+#define ifr_bandwidth	ifr_ifru.ifru_ivalue
+#define ifr_qlen	ifr_ifru.ifru_ivalue
+#define ifr_newname	ifr_ifru.ifru_newname
+#define _IOT_ifreq	_IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
+#define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
+#define _IOT_ifreq_int	_IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
+
+struct ifconf {
+	int ifc_len;		
+	union {
+		void *ifcu_buf;
+		struct ifreq *ifcu_req;
+	} ifc_ifcu;
+};
+
+#define ifc_buf		ifc_ifcu.ifcu_buf
+#define ifc_req		ifc_ifcu.ifcu_req
+#define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0)
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/net/if_arp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/net/if_arp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/net/if_arp.h	(revision 279)
@@ -0,0 +1,139 @@
+/* Nonstandard header */
+#ifndef _NET_IF_ARP_H
+#define _NET_IF_ARP_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#define MAX_ADDR_LEN	7
+
+#define	ARPOP_REQUEST	1
+#define	ARPOP_REPLY	2
+#define	ARPOP_RREQUEST	3
+#define	ARPOP_RREPLY	4
+#define	ARPOP_InREQUEST	8
+#define	ARPOP_InREPLY	9
+#define	ARPOP_NAK	10
+
+struct arphdr {
+	uint16_t ar_hrd;
+	uint16_t ar_pro;
+	uint8_t ar_hln;
+	uint8_t ar_pln;
+	uint16_t ar_op;
+};
+
+
+#define ARPHRD_NETROM	0
+#define ARPHRD_ETHER 	1
+#define	ARPHRD_EETHER	2
+#define	ARPHRD_AX25	3
+#define	ARPHRD_PRONET	4
+#define	ARPHRD_CHAOS	5
+#define	ARPHRD_IEEE802	6
+#define	ARPHRD_ARCNET	7
+#define	ARPHRD_APPLETLK	8
+#define	ARPHRD_DLCI	15
+#define	ARPHRD_ATM	19
+#define	ARPHRD_METRICOM	23
+#define ARPHRD_IEEE1394	24
+#define ARPHRD_EUI64		27
+#define ARPHRD_INFINIBAND	32
+#define ARPHRD_SLIP	256
+#define ARPHRD_CSLIP	257
+#define ARPHRD_SLIP6	258
+#define ARPHRD_CSLIP6	259
+#define ARPHRD_RSRVD	260
+#define ARPHRD_ADAPT	264
+#define ARPHRD_ROSE	270
+#define ARPHRD_X25	271
+#define ARPHRD_HWX25	272
+#define ARPHRD_CAN	280
+#define ARPHRD_PPP	512
+#define ARPHRD_CISCO	513
+#define ARPHRD_HDLC	ARPHRD_CISCO
+#define ARPHRD_LAPB	516
+#define ARPHRD_DDCMP	517
+#define	ARPHRD_RAWHDLC	518
+
+#define ARPHRD_TUNNEL	768
+#define ARPHRD_TUNNEL6	769
+#define ARPHRD_FRAD	770
+#define ARPHRD_SKIP	771
+#define ARPHRD_LOOPBACK	772
+#define ARPHRD_LOCALTLK 773
+#define ARPHRD_FDDI	774
+#define ARPHRD_BIF	775
+#define ARPHRD_SIT	776
+#define ARPHRD_IPDDP	777
+#define ARPHRD_IPGRE	778
+#define ARPHRD_PIMREG	779
+#define ARPHRD_HIPPI	780
+#define ARPHRD_ASH	781
+#define ARPHRD_ECONET	782
+#define ARPHRD_IRDA	783
+#define ARPHRD_FCPP	784
+#define ARPHRD_FCAL	785
+#define ARPHRD_FCPL	786
+#define ARPHRD_FCFABRIC 787
+#define ARPHRD_IEEE802_TR 800
+#define ARPHRD_IEEE80211 801
+#define ARPHRD_IEEE80211_PRISM 802
+#define ARPHRD_IEEE80211_RADIOTAP 803
+#define ARPHRD_IEEE802154 804
+#define ARPHRD_IEEE802154_MONITOR 805
+#define ARPHRD_PHONET 820
+#define ARPHRD_PHONET_PIPE 821
+#define ARPHRD_CAIF 822
+#define ARPHRD_IP6GRE 823
+#define ARPHRD_NETLINK 824
+
+#define ARPHRD_VOID	  0xFFFF
+#define ARPHRD_NONE	  0xFFFE
+
+struct arpreq {
+	struct sockaddr arp_pa;
+	struct sockaddr arp_ha;
+	int arp_flags;
+	struct sockaddr arp_netmask;
+	char arp_dev[16];
+};
+
+struct arpreq_old {
+	struct sockaddr arp_pa;
+	struct sockaddr arp_ha;
+	int arp_flags;
+	struct sockaddr arp_netmask;
+};
+
+#define ATF_COM		0x02
+#define	ATF_PERM	0x04
+#define	ATF_PUBL	0x08
+#define	ATF_USETRAILERS	0x10
+#define ATF_NETMASK     0x20
+#define ATF_DONTPUB	0x40
+#define ATF_MAGIC	0x80
+
+#define ARPD_UPDATE	0x01
+#define ARPD_LOOKUP	0x02
+#define ARPD_FLUSH	0x03
+
+struct arpd_request {
+	unsigned short req;
+	uint32_t ip;
+	unsigned long dev;
+	unsigned long stamp;
+	unsigned long updated;
+	unsigned char ha[MAX_ADDR_LEN];
+};
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/net/route.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/net/route.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/net/route.h	(revision 279)
@@ -0,0 +1,124 @@
+#ifndef _NET_ROUTE_H
+#define _NET_ROUTE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+
+struct rtentry {
+	unsigned long int rt_pad1;
+	struct sockaddr rt_dst;
+	struct sockaddr rt_gateway;
+	struct sockaddr rt_genmask;
+	unsigned short int rt_flags;
+	short int rt_pad2;
+	unsigned long int rt_pad3;
+	unsigned char rt_tos;
+	unsigned char rt_class;
+	short int rt_pad4[sizeof(long)/2-1];
+	short int rt_metric;
+	char *rt_dev;
+	unsigned long int rt_mtu;
+	unsigned long int rt_window;
+	unsigned short int rt_irtt;
+};
+
+#define rt_mss	rt_mtu
+
+
+struct in6_rtmsg {
+	struct in6_addr rtmsg_dst;
+	struct in6_addr rtmsg_src;
+	struct in6_addr rtmsg_gateway;
+	uint32_t rtmsg_type;
+	uint16_t rtmsg_dst_len;
+	uint16_t rtmsg_src_len;
+	uint32_t rtmsg_metric;
+	unsigned long int rtmsg_info;
+	uint32_t rtmsg_flags;
+	int rtmsg_ifindex;
+};
+
+
+#define	RTF_UP		0x0001
+#define	RTF_GATEWAY	0x0002
+
+#define	RTF_HOST	0x0004
+#define RTF_REINSTATE	0x0008
+#define	RTF_DYNAMIC	0x0010
+#define	RTF_MODIFIED	0x0020
+#define RTF_MTU		0x0040
+#define RTF_MSS		RTF_MTU
+#define RTF_WINDOW	0x0080
+#define RTF_IRTT	0x0100
+#define RTF_REJECT	0x0200
+#define	RTF_STATIC	0x0400
+#define	RTF_XRESOLVE	0x0800
+#define RTF_NOFORWARD   0x1000
+#define RTF_THROW	0x2000
+#define RTF_NOPMTUDISC  0x4000
+
+#define RTF_DEFAULT	0x00010000
+#define RTF_ALLONLINK	0x00020000
+#define RTF_ADDRCONF	0x00040000
+
+#define RTF_LINKRT	0x00100000
+#define RTF_NONEXTHOP	0x00200000
+
+#define RTF_CACHE	0x01000000
+#define RTF_FLOW	0x02000000
+#define RTF_POLICY	0x04000000
+
+#define RTCF_VALVE	0x00200000
+#define RTCF_MASQ	0x00400000
+#define RTCF_NAT	0x00800000
+#define RTCF_DOREDIRECT 0x01000000
+#define RTCF_LOG	0x02000000
+#define RTCF_DIRECTSRC	0x04000000
+
+#define RTF_LOCAL	0x80000000
+#define RTF_INTERFACE	0x40000000
+#define RTF_MULTICAST	0x20000000
+#define RTF_BROADCAST	0x10000000
+#define RTF_NAT		0x08000000
+
+#define RTF_ADDRCLASSMASK	0xF8000000
+#define RT_ADDRCLASS(flags)	((uint32_t) flags >> 23)
+
+#define RT_TOS(tos)		((tos) & IPTOS_TOS_MASK)
+
+#define RT_LOCALADDR(flags)	((flags & RTF_ADDRCLASSMASK) \
+				 == (RTF_LOCAL|RTF_INTERFACE))
+
+#define RT_CLASS_UNSPEC		0
+#define RT_CLASS_DEFAULT	253
+
+#define RT_CLASS_MAIN		254
+#define RT_CLASS_LOCAL		255
+#define RT_CLASS_MAX		255
+
+
+#define RTMSG_ACK		NLMSG_ACK
+#define RTMSG_OVERRUN		NLMSG_OVERRUN
+
+#define RTMSG_NEWDEVICE		0x11
+#define RTMSG_DELDEVICE		0x12
+#define RTMSG_NEWROUTE		0x21
+#define RTMSG_DELROUTE		0x22
+#define RTMSG_NEWRULE		0x31
+#define RTMSG_DELRULE		0x32
+#define RTMSG_CONTROL		0x40
+
+#define RTMSG_AR_FAILED		0x51
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netdb.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netdb.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netdb.h	(revision 279)
@@ -0,0 +1,160 @@
+#ifndef	_NETDB_H
+#define	_NETDB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <netinet/in.h>
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_size_t
+#include <bits/alltypes.h>
+#endif
+
+struct addrinfo
+{
+	int ai_flags;
+	int ai_family;
+	int ai_socktype;
+	int ai_protocol;
+	socklen_t ai_addrlen;
+	struct sockaddr *ai_addr;
+	char *ai_canonname;
+	struct addrinfo *ai_next;
+};
+
+#define IPPORT_RESERVED 1024
+
+#define AI_PASSIVE      0x01
+#define AI_CANONNAME    0x02
+#define AI_NUMERICHOST  0x04
+#define AI_V4MAPPED     0x08
+#define AI_ALL          0x10
+#define AI_ADDRCONFIG   0x20
+#define AI_NUMERICSERV  0x400
+
+
+#define NI_NUMERICHOST  0x01
+#define NI_NUMERICSERV  0x02
+#define NI_NOFQDN       0x04
+#define NI_NAMEREQD     0x08
+#define NI_DGRAM        0x10
+#define NI_NUMERICSCOPE 0x100
+
+#define EAI_BADFLAGS   -1
+#define EAI_NONAME     -2
+#define EAI_AGAIN      -3
+#define EAI_FAIL       -4
+#define EAI_FAMILY     -6
+#define EAI_SOCKTYPE   -7
+#define EAI_SERVICE    -8
+#define EAI_MEMORY     -10
+#define EAI_SYSTEM     -11
+#define EAI_OVERFLOW   -12
+
+int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
+void freeaddrinfo (struct addrinfo *);
+int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
+const char *gai_strerror(int);
+
+
+/* Legacy functions follow (marked OBsolete in SUS) */
+
+struct netent
+{
+	char *n_name;
+	char **n_aliases;
+	int n_addrtype;
+	uint32_t n_net;
+};
+
+struct hostent
+{
+	char *h_name;
+	char **h_aliases;
+	int h_addrtype;
+	int h_length;
+	char **h_addr_list;
+};
+#define h_addr h_addr_list[0]
+
+struct servent
+{
+	char *s_name;
+	char **s_aliases;
+	int s_port;
+	char *s_proto;
+};
+
+struct protoent
+{
+	char *p_name;
+	char **p_aliases;
+	int p_proto;
+};
+
+void sethostent (int);
+void endhostent (void);
+struct hostent *gethostent (void);
+
+void setnetent (int);
+void endnetent (void);
+struct netent *getnetent (void);
+struct netent *getnetbyaddr (uint32_t, int);
+struct netent *getnetbyname (const char *);
+
+void setservent (int);
+void endservent (void);
+struct servent *getservent (void);
+struct servent *getservbyname (const char *, const char *);
+struct servent *getservbyport (int, const char *);
+
+void setprotoent (int);
+void endprotoent (void);
+struct protoent *getprotoent (void);
+struct protoent *getprotobyname (const char *);
+struct protoent *getprotobynumber (int);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
+ || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
+ || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
+struct hostent *gethostbyname (const char *);
+struct hostent *gethostbyaddr (const void *, socklen_t, int);
+int *__h_errno_location(void);
+#define h_errno (*__h_errno_location())
+#define HOST_NOT_FOUND 1
+#define TRY_AGAIN      2
+#define NO_RECOVERY    3
+#define NO_DATA        4
+#define NO_ADDRESS     NO_DATA
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+void herror(const char *);
+const char *hstrerror(int);
+int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
+int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
+struct hostent *gethostbyname2(const char *, int);
+int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
+int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
+int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
+#define EAI_NODATA     -5
+#define EAI_ADDRFAMILY -9
+#define EAI_INPROGRESS -100
+#define EAI_CANCELED   -101
+#define EAI_NOTCANCELED -102
+#define EAI_ALLDONE    -103
+#define EAI_INTR       -104
+#define EAI_IDN_ENCODE -105
+#define NI_MAXHOST 255
+#define NI_MAXSERV 32
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ether.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ether.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ether.h	(revision 279)
@@ -0,0 +1,22 @@
+#ifndef _NETINET_ETHER_H
+#define _NETINET_ETHER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <netinet/if_ether.h>
+
+char *ether_ntoa (const struct ether_addr *);
+struct ether_addr *ether_aton (const char *);
+char *ether_ntoa_r (const struct ether_addr *, char *);
+struct ether_addr *ether_aton_r (const char *, struct ether_addr *);
+int ether_line(const char *, struct ether_addr *, char *);
+int ether_ntohost(char *, const struct ether_addr *);
+int ether_hostton(const char *, struct ether_addr *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/icmp6.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/icmp6.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/icmp6.h	(revision 279)
@@ -0,0 +1,305 @@
+#ifndef _NETINET_ICMP6_H
+#define _NETINET_ICMP6_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <string.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#define ICMP6_FILTER 1
+
+#define ICMP6_FILTER_BLOCK		1
+#define ICMP6_FILTER_PASS		2
+#define ICMP6_FILTER_BLOCKOTHERS	3
+#define ICMP6_FILTER_PASSONLY		4
+
+struct icmp6_filter {
+	uint32_t icmp6_filt[8];
+};
+
+struct icmp6_hdr {
+	uint8_t     icmp6_type;
+	uint8_t     icmp6_code;
+	uint16_t    icmp6_cksum;
+	union {
+		uint32_t  icmp6_un_data32[1];
+		uint16_t  icmp6_un_data16[2];
+		uint8_t   icmp6_un_data8[4];
+	} icmp6_dataun;
+};
+
+#define icmp6_data32    icmp6_dataun.icmp6_un_data32
+#define icmp6_data16    icmp6_dataun.icmp6_un_data16
+#define icmp6_data8     icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr      icmp6_data32[0]
+#define icmp6_mtu       icmp6_data32[0]
+#define icmp6_id        icmp6_data16[0]
+#define icmp6_seq       icmp6_data16[1]
+#define icmp6_maxdelay  icmp6_data16[0]
+
+#define ICMP6_DST_UNREACH             1
+#define ICMP6_PACKET_TOO_BIG          2
+#define ICMP6_TIME_EXCEEDED           3
+#define ICMP6_PARAM_PROB              4
+
+#define ICMP6_INFOMSG_MASK  0x80
+
+#define ICMP6_ECHO_REQUEST          128
+#define ICMP6_ECHO_REPLY            129
+#define MLD_LISTENER_QUERY          130
+#define MLD_LISTENER_REPORT         131
+#define MLD_LISTENER_REDUCTION      132
+
+#define ICMP6_DST_UNREACH_NOROUTE     0
+#define ICMP6_DST_UNREACH_ADMIN       1
+#define ICMP6_DST_UNREACH_BEYONDSCOPE 2
+#define ICMP6_DST_UNREACH_ADDR        3
+#define ICMP6_DST_UNREACH_NOPORT      4
+
+#define ICMP6_TIME_EXCEED_TRANSIT     0
+#define ICMP6_TIME_EXCEED_REASSEMBLY  1
+
+#define ICMP6_PARAMPROB_HEADER        0
+#define ICMP6_PARAMPROB_NEXTHEADER    1
+#define ICMP6_PARAMPROB_OPTION        2
+
+#define ICMP6_FILTER_WILLPASS(type, filterp) \
+	((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
+
+#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
+	((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
+
+#define ICMP6_FILTER_SETPASS(type, filterp) \
+	((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
+
+#define ICMP6_FILTER_SETBLOCK(type, filterp) \
+	((((filterp)->icmp6_filt[(type) >> 5]) |=  (1 << ((type) & 31))))
+
+#define ICMP6_FILTER_SETPASSALL(filterp) \
+	memset (filterp, 0, sizeof (struct icmp6_filter));
+
+#define ICMP6_FILTER_SETBLOCKALL(filterp) \
+	memset (filterp, 0xFF, sizeof (struct icmp6_filter));
+
+#define ND_ROUTER_SOLICIT           133
+#define ND_ROUTER_ADVERT            134
+#define ND_NEIGHBOR_SOLICIT         135
+#define ND_NEIGHBOR_ADVERT          136
+#define ND_REDIRECT                 137
+
+struct nd_router_solicit {
+	struct icmp6_hdr  nd_rs_hdr;
+};
+
+#define nd_rs_type               nd_rs_hdr.icmp6_type
+#define nd_rs_code               nd_rs_hdr.icmp6_code
+#define nd_rs_cksum              nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved           nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert {
+	struct icmp6_hdr  nd_ra_hdr;
+	uint32_t   nd_ra_reachable;
+	uint32_t   nd_ra_retransmit;
+};
+
+#define nd_ra_type               nd_ra_hdr.icmp6_type
+#define nd_ra_code               nd_ra_hdr.icmp6_code
+#define nd_ra_cksum              nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit        nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved     nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED       0x80
+#define ND_RA_FLAG_OTHER         0x40
+#define ND_RA_FLAG_HOME_AGENT    0x20
+#define nd_ra_router_lifetime    nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit {
+	struct icmp6_hdr  nd_ns_hdr;
+	struct in6_addr   nd_ns_target;
+};
+
+#define nd_ns_type               nd_ns_hdr.icmp6_type
+#define nd_ns_code               nd_ns_hdr.icmp6_code
+#define nd_ns_cksum              nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved           nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert {
+	struct icmp6_hdr  nd_na_hdr;
+	struct in6_addr   nd_na_target;
+};
+
+#define nd_na_type               nd_na_hdr.icmp6_type
+#define nd_na_code               nd_na_hdr.icmp6_code
+#define nd_na_cksum              nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved     nd_na_hdr.icmp6_data32[0]
+#if     __BYTE_ORDER == __BIG_ENDIAN
+#define ND_NA_FLAG_ROUTER        0x80000000
+#define ND_NA_FLAG_SOLICITED     0x40000000
+#define ND_NA_FLAG_OVERRIDE      0x20000000
+#else
+#define ND_NA_FLAG_ROUTER        0x00000080
+#define ND_NA_FLAG_SOLICITED     0x00000040
+#define ND_NA_FLAG_OVERRIDE      0x00000020
+#endif
+
+struct nd_redirect {
+	struct icmp6_hdr  nd_rd_hdr;
+	struct in6_addr   nd_rd_target;
+	struct in6_addr   nd_rd_dst;
+};
+
+#define nd_rd_type               nd_rd_hdr.icmp6_type
+#define nd_rd_code               nd_rd_hdr.icmp6_code
+#define nd_rd_cksum              nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved           nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr {
+	uint8_t  nd_opt_type;
+	uint8_t  nd_opt_len;
+};
+
+#define ND_OPT_SOURCE_LINKADDR		1
+#define ND_OPT_TARGET_LINKADDR		2
+#define ND_OPT_PREFIX_INFORMATION	3
+#define ND_OPT_REDIRECTED_HEADER	4
+#define ND_OPT_MTU			5
+#define ND_OPT_RTR_ADV_INTERVAL		7
+#define ND_OPT_HOME_AGENT_INFO		8
+
+struct nd_opt_prefix_info {
+	uint8_t   nd_opt_pi_type;
+	uint8_t   nd_opt_pi_len;
+	uint8_t   nd_opt_pi_prefix_len;
+	uint8_t   nd_opt_pi_flags_reserved;
+	uint32_t  nd_opt_pi_valid_time;
+	uint32_t  nd_opt_pi_preferred_time;
+	uint32_t  nd_opt_pi_reserved2;
+	struct in6_addr  nd_opt_pi_prefix;
+};
+
+#define ND_OPT_PI_FLAG_ONLINK	0x80
+#define ND_OPT_PI_FLAG_AUTO	0x40
+#define ND_OPT_PI_FLAG_RADDR	0x20
+
+struct nd_opt_rd_hdr {
+	uint8_t   nd_opt_rh_type;
+	uint8_t   nd_opt_rh_len;
+	uint16_t  nd_opt_rh_reserved1;
+	uint32_t  nd_opt_rh_reserved2;
+};
+
+struct nd_opt_mtu {
+	uint8_t   nd_opt_mtu_type;
+	uint8_t   nd_opt_mtu_len;
+	uint16_t  nd_opt_mtu_reserved;
+	uint32_t  nd_opt_mtu_mtu;
+};
+
+struct mld_hdr {
+	struct icmp6_hdr    mld_icmp6_hdr;
+	struct in6_addr     mld_addr;
+};
+
+#define mld_type        mld_icmp6_hdr.icmp6_type
+#define mld_code        mld_icmp6_hdr.icmp6_code
+#define mld_cksum       mld_icmp6_hdr.icmp6_cksum
+#define mld_maxdelay    mld_icmp6_hdr.icmp6_data16[0]
+#define mld_reserved    mld_icmp6_hdr.icmp6_data16[1]
+
+#define ICMP6_ROUTER_RENUMBERING    138
+
+struct icmp6_router_renum {
+	struct icmp6_hdr    rr_hdr;
+	uint8_t             rr_segnum;
+	uint8_t             rr_flags;
+	uint16_t            rr_maxdelay;
+	uint32_t            rr_reserved;
+};
+
+#define rr_type		rr_hdr.icmp6_type
+#define rr_code         rr_hdr.icmp6_code
+#define rr_cksum        rr_hdr.icmp6_cksum
+#define rr_seqnum       rr_hdr.icmp6_data32[0]
+
+#define ICMP6_RR_FLAGS_TEST             0x80
+#define ICMP6_RR_FLAGS_REQRESULT        0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY       0x20
+#define ICMP6_RR_FLAGS_SPECSITE         0x10
+#define ICMP6_RR_FLAGS_PREVDONE         0x08
+
+struct rr_pco_match {
+	uint8_t             rpm_code;
+	uint8_t             rpm_len;
+	uint8_t             rpm_ordinal;
+	uint8_t             rpm_matchlen;
+	uint8_t             rpm_minlen;
+	uint8_t             rpm_maxlen;
+	uint16_t            rpm_reserved;
+	struct in6_addr     rpm_prefix;
+};
+
+#define RPM_PCO_ADD             1
+#define RPM_PCO_CHANGE          2
+#define RPM_PCO_SETGLOBAL       3
+
+struct rr_pco_use {
+	uint8_t             rpu_uselen;
+	uint8_t             rpu_keeplen;
+	uint8_t             rpu_ramask;
+	uint8_t             rpu_raflags;
+	uint32_t            rpu_vltime;
+	uint32_t            rpu_pltime;
+	uint32_t            rpu_flags;
+	struct in6_addr     rpu_prefix;
+};
+
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK  0x20
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO    0x10
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
+#else
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
+#endif
+
+struct rr_result {
+	uint16_t            rrr_flags;
+	uint8_t             rrr_ordinal;
+	uint8_t             rrr_matchedlen;
+	uint32_t            rrr_ifid;
+	struct in6_addr     rrr_prefix;
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB       0x0002
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
+#else
+#define ICMP6_RR_RESULT_FLAGS_OOB       0x0200
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
+#endif
+
+struct nd_opt_adv_interval {
+	uint8_t   nd_opt_adv_interval_type;
+	uint8_t   nd_opt_adv_interval_len;
+	uint16_t  nd_opt_adv_interval_reserved;
+	uint32_t  nd_opt_adv_interval_ival;
+};
+
+struct nd_opt_home_agent_info {
+	uint8_t   nd_opt_home_agent_info_type;
+	uint8_t   nd_opt_home_agent_info_len;
+	uint16_t  nd_opt_home_agent_info_reserved;
+	uint16_t  nd_opt_home_agent_info_preference;
+	uint16_t  nd_opt_home_agent_info_lifetime;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/if_ether.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/if_ether.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/if_ether.h	(revision 279)
@@ -0,0 +1,129 @@
+#ifndef _NETINET_IF_ETHER_H
+#define _NETINET_IF_ETHER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#define ETH_ALEN	6
+#define ETH_HLEN	14
+#define ETH_ZLEN	60
+#define ETH_DATA_LEN	1500
+#define ETH_FRAME_LEN	1514
+#define ETH_FCS_LEN	4
+
+#define ETH_P_LOOP	0x0060
+#define ETH_P_PUP	0x0200
+#define ETH_P_PUPAT	0x0201
+#define ETH_P_IP	0x0800
+#define ETH_P_X25	0x0805
+#define ETH_P_ARP	0x0806
+#define	ETH_P_BPQ	0x08FF
+#define ETH_P_IEEEPUP	0x0a00
+#define ETH_P_IEEEPUPAT	0x0a01
+#define ETH_P_BATMAN	0x4305
+#define ETH_P_DEC       0x6000
+#define ETH_P_DNA_DL    0x6001
+#define ETH_P_DNA_RC    0x6002
+#define ETH_P_DNA_RT    0x6003
+#define ETH_P_LAT       0x6004
+#define ETH_P_DIAG      0x6005
+#define ETH_P_CUST      0x6006
+#define ETH_P_SCA       0x6007
+#define ETH_P_TEB	0x6558
+#define ETH_P_RARP      0x8035
+#define ETH_P_ATALK	0x809B
+#define ETH_P_AARP	0x80F3
+#define ETH_P_8021Q	0x8100
+#define ETH_P_IPX	0x8137
+#define ETH_P_IPV6	0x86DD
+#define ETH_P_PAUSE	0x8808
+#define ETH_P_SLOW	0x8809
+#define ETH_P_WCCP	0x883E
+#define ETH_P_MPLS_UC	0x8847
+#define ETH_P_MPLS_MC	0x8848
+#define ETH_P_ATMMPOA	0x884c
+#define ETH_P_PPP_DISC	0x8863
+#define ETH_P_PPP_SES	0x8864
+#define ETH_P_LINK_CTL	0x886c
+#define ETH_P_ATMFATE	0x8884
+#define ETH_P_PAE	0x888E
+#define ETH_P_AOE	0x88A2
+#define ETH_P_8021AD	0x88A8
+#define ETH_P_802_EX1	0x88B5
+#define ETH_P_TIPC	0x88CA
+#define ETH_P_8021AH	0x88E7
+#define ETH_P_MVRP	0x88F5
+#define ETH_P_1588	0x88F7
+#define ETH_P_PRP	0x88FB
+#define ETH_P_FCOE	0x8906
+#define ETH_P_TDLS	0x890D
+#define ETH_P_FIP	0x8914
+#define ETH_P_80221	0x8917
+#define ETH_P_LOOPBACK	0x9000
+#define ETH_P_QINQ1	0x9100
+#define ETH_P_QINQ2	0x9200
+#define ETH_P_QINQ3	0x9300
+#define ETH_P_EDSA	0xDADA
+#define ETH_P_AF_IUCV	0xFBFB
+
+#define ETH_P_802_3_MIN	0x0600
+
+#define ETH_P_802_3	0x0001
+#define ETH_P_AX25	0x0002
+#define ETH_P_ALL	0x0003
+#define ETH_P_802_2	0x0004
+#define ETH_P_SNAP	0x0005
+#define ETH_P_DDCMP     0x0006
+#define ETH_P_WAN_PPP   0x0007
+#define ETH_P_PPP_MP    0x0008
+#define ETH_P_LOCALTALK 0x0009
+#define ETH_P_CAN	0x000C
+#define ETH_P_CANFD	0x000D
+#define ETH_P_PPPTALK	0x0010
+#define ETH_P_TR_802_2	0x0011
+#define ETH_P_MOBITEX	0x0015
+#define ETH_P_CONTROL	0x0016
+#define ETH_P_IRDA	0x0017
+#define ETH_P_ECONET	0x0018
+#define ETH_P_HDLC	0x0019
+#define ETH_P_ARCNET	0x001A
+#define ETH_P_DSA	0x001B
+#define ETH_P_TRAILER	0x001C
+#define ETH_P_PHONET	0x00F5
+#define ETH_P_IEEE802154 0x00F6
+#define ETH_P_CAIF	0x00F7
+
+struct ethhdr {
+	uint8_t h_dest[ETH_ALEN];
+	uint8_t h_source[ETH_ALEN];
+	uint16_t h_proto;
+};
+
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+
+struct	ether_arp {
+	struct	arphdr ea_hdr;
+	uint8_t arp_sha[ETH_ALEN];
+	uint8_t arp_spa[4];
+	uint8_t arp_tha[ETH_ALEN];
+	uint8_t arp_tpa[4];
+};
+#define	arp_hrd	ea_hdr.ar_hrd
+#define	arp_pro	ea_hdr.ar_pro
+#define	arp_hln	ea_hdr.ar_hln
+#define	arp_pln	ea_hdr.ar_pln
+#define	arp_op	ea_hdr.ar_op
+
+#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
+do { \
+	(enaddr)[0] = 0x01; \
+	(enaddr)[1] = 0x00; \
+	(enaddr)[2] = 0x5e; \
+	(enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \
+	(enaddr)[4] = ((uint8_t *)ipaddr)[2]; \
+	(enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
+} while(0)
+
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/igmp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/igmp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/igmp.h	(revision 279)
@@ -0,0 +1,45 @@
+#ifndef _NETINET_IGMP_H
+#define _NETINET_IGMP_H
+
+#include <stdint.h>
+#include <netinet/in.h>
+
+struct igmp {
+	uint8_t igmp_type;
+	uint8_t igmp_code;
+	uint16_t igmp_cksum;
+	struct in_addr igmp_group;
+};
+
+#define IGMP_MINLEN			8
+
+#define IGMP_MEMBERSHIP_QUERY   	0x11
+#define IGMP_V1_MEMBERSHIP_REPORT	0x12
+#define IGMP_V2_MEMBERSHIP_REPORT	0x16
+#define IGMP_V2_LEAVE_GROUP		0x17
+
+#define IGMP_DVMRP			0x13
+#define IGMP_PIM			0x14
+#define IGMP_TRACE			0x15
+
+#define IGMP_MTRACE_RESP		0x1e
+#define IGMP_MTRACE			0x1f
+
+#define IGMP_MAX_HOST_REPORT_DELAY	10
+#define IGMP_TIMER_SCALE		10
+
+#define IGMP_DELAYING_MEMBER	1
+#define IGMP_IDLE_MEMBER	2
+#define IGMP_LAZY_MEMBER	3
+#define IGMP_SLEEPING_MEMBER	4
+#define IGMP_AWAKENING_MEMBER	5
+
+#define IGMP_v1_ROUTER		1
+#define IGMP_v2_ROUTER		2
+
+#define IGMP_HOST_MEMBERSHIP_QUERY	IGMP_MEMBERSHIP_QUERY
+#define IGMP_HOST_MEMBERSHIP_REPORT	IGMP_V1_MEMBERSHIP_REPORT
+#define IGMP_HOST_NEW_MEMBERSHIP_REPORT	IGMP_V2_MEMBERSHIP_REPORT
+#define IGMP_HOST_LEAVE_MESSAGE		IGMP_V2_LEAVE_GROUP
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/in.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/in.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/in.h	(revision 279)
@@ -0,0 +1,399 @@
+#ifndef	_NETINET_IN_H
+#define	_NETINET_IN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <inttypes.h>
+#include <sys/socket.h>
+
+typedef uint16_t in_port_t;
+typedef uint32_t in_addr_t;
+struct in_addr { in_addr_t s_addr; };
+
+struct sockaddr_in
+{
+	sa_family_t sin_family;
+	in_port_t sin_port;
+	struct in_addr sin_addr;
+	uint8_t sin_zero[8];
+};
+
+struct in6_addr
+{
+	union {
+		uint8_t __s6_addr[16];
+		uint16_t __s6_addr16[8];
+		uint32_t __s6_addr32[4];
+	} __in6_union;
+};
+#define s6_addr __in6_union.__s6_addr
+#define s6_addr16 __in6_union.__s6_addr16
+#define s6_addr32 __in6_union.__s6_addr32
+
+struct sockaddr_in6
+{
+	sa_family_t     sin6_family;
+	in_port_t       sin6_port;
+	uint32_t        sin6_flowinfo;
+	struct in6_addr sin6_addr;
+	uint32_t        sin6_scope_id;
+};
+
+struct ipv6_mreq
+{
+	struct in6_addr ipv6mr_multiaddr;
+	unsigned        ipv6mr_interface;
+};
+
+#define INADDR_ANY        ((in_addr_t) 0x00000000)
+#define INADDR_BROADCAST  ((in_addr_t) 0xffffffff)
+#define INADDR_NONE       ((in_addr_t) 0xffffffff)
+#define INADDR_LOOPBACK   ((in_addr_t) 0x7f000001)
+
+#define INADDR_UNSPEC_GROUP     ((in_addr_t) 0xe0000000)
+#define INADDR_ALLHOSTS_GROUP   ((in_addr_t) 0xe0000001)
+#define INADDR_ALLRTRS_GROUP    ((in_addr_t) 0xe0000002)
+#define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff)
+
+#define IN6ADDR_ANY_INIT      { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+
+extern const struct in6_addr in6addr_any, in6addr_loopback;
+
+#undef INET_ADDRSTRLEN
+#undef INET6_ADDRSTRLEN
+#define INET_ADDRSTRLEN  16
+#define INET6_ADDRSTRLEN 46
+
+uint32_t htonl(uint32_t);
+uint16_t htons(uint16_t);
+uint32_t ntohl(uint32_t);
+uint16_t ntohs(uint16_t);
+
+#define IPPROTO_IP       0
+#define IPPROTO_HOPOPTS  0
+#define IPPROTO_ICMP     1
+#define IPPROTO_IGMP     2
+#define IPPROTO_IPIP     4
+#define IPPROTO_TCP      6
+#define IPPROTO_EGP      8
+#define IPPROTO_PUP      12
+#define IPPROTO_UDP      17
+#define IPPROTO_IDP      22
+#define IPPROTO_TP       29
+#define IPPROTO_DCCP     33
+#define IPPROTO_IPV6     41
+#define IPPROTO_ROUTING  43
+#define IPPROTO_FRAGMENT 44
+#define IPPROTO_RSVP     46
+#define IPPROTO_GRE      47
+#define IPPROTO_ESP      50
+#define IPPROTO_AH       51
+#define IPPROTO_ICMPV6   58
+#define IPPROTO_NONE     59
+#define IPPROTO_DSTOPTS  60
+#define IPPROTO_MTP      92
+#define IPPROTO_BEETPH   94
+#define IPPROTO_ENCAP    98
+#define IPPROTO_PIM      103
+#define IPPROTO_COMP     108
+#define IPPROTO_SCTP     132
+#define IPPROTO_MH       135
+#define IPPROTO_UDPLITE  136
+#define IPPROTO_RAW      255
+#define IPPROTO_MAX      256
+
+#define IN6_IS_ADDR_UNSPECIFIED(a) \
+        (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+         ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == 0)
+
+#define IN6_IS_ADDR_LOOPBACK(a) \
+        (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+         ((uint32_t *) (a))[2] == 0 && \
+         ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && \
+         ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 )
+
+#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
+
+#define IN6_IS_ADDR_LINKLOCAL(a) \
+        ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80)
+
+#define IN6_IS_ADDR_SITELOCAL(a) \
+        ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0xc0)
+
+#define IN6_IS_ADDR_V4MAPPED(a) \
+        (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+         ((uint8_t *) (a))[8] == 0 && ((uint8_t *) (a))[9] == 0 && \
+         ((uint8_t *) (a))[10] == 0xff && ((uint8_t *) (a))[11] == 0xff)
+
+#define IN6_IS_ADDR_V4COMPAT(a) \
+        (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
+         ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[15] > 1)
+
+#define IN6_IS_ADDR_MC_NODELOCAL(a) \
+        (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x1))
+
+#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
+        (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x2))
+
+#define IN6_IS_ADDR_MC_SITELOCAL(a) \
+        (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x5))
+
+#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
+        (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x8))
+
+#define IN6_IS_ADDR_MC_GLOBAL(a) \
+        (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0xe))
+
+#define __ARE_4_EQUAL(a,b) \
+	(!( (0[a]-0[b]) | (1[a]-1[b]) | (2[a]-2[b]) | (3[a]-3[b]) ))
+#define IN6_ARE_ADDR_EQUAL(a,b) \
+	__ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
+
+#define	IN_CLASSA(a)		((((in_addr_t)(a)) & 0x80000000) == 0)
+#define	IN_CLASSA_NET		0xff000000
+#define	IN_CLASSA_NSHIFT	24
+#define	IN_CLASSA_HOST		(0xffffffff & ~IN_CLASSA_NET)
+#define	IN_CLASSA_MAX		128
+#define	IN_CLASSB(a)		((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
+#define	IN_CLASSB_NET		0xffff0000
+#define	IN_CLASSB_NSHIFT	16
+#define	IN_CLASSB_HOST		(0xffffffff & ~IN_CLASSB_NET)
+#define	IN_CLASSB_MAX		65536
+#define	IN_CLASSC(a)		((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
+#define	IN_CLASSC_NET		0xffffff00
+#define	IN_CLASSC_NSHIFT	8
+#define	IN_CLASSC_HOST		(0xffffffff & ~IN_CLASSC_NET)
+#define	IN_CLASSD(a)		((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
+#define	IN_MULTICAST(a)		IN_CLASSD(a)
+#define	IN_EXPERIMENTAL(a)	((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
+#define	IN_BADCLASS(a)		((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
+
+#define IN_LOOPBACKNET 127
+
+
+#define IP_TOS             1
+#define IP_TTL             2
+#define IP_HDRINCL         3
+#define IP_OPTIONS         4
+#define IP_ROUTER_ALERT    5
+#define IP_RECVOPTS        6
+#define IP_RETOPTS         7
+#define IP_PKTINFO         8
+#define IP_PKTOPTIONS      9
+#define IP_PMTUDISC        10
+#define IP_MTU_DISCOVER    10
+#define IP_RECVERR         11
+#define IP_RECVTTL         12
+#define IP_RECVTOS         13
+#define IP_MTU             14
+#define IP_FREEBIND        15
+#define IP_IPSEC_POLICY    16
+#define IP_XFRM_POLICY     17
+#define IP_PASSSEC         18
+#define IP_TRANSPARENT     19
+#define IP_ORIGDSTADDR     20
+#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
+#define IP_MINTTL          21
+#define IP_NODEFRAG        22
+#define IP_CHECKSUM        23
+#define IP_MULTICAST_IF    32
+#define IP_MULTICAST_TTL   33
+#define IP_MULTICAST_LOOP  34
+#define IP_ADD_MEMBERSHIP  35
+#define IP_DROP_MEMBERSHIP 36
+#define IP_UNBLOCK_SOURCE  37
+#define IP_BLOCK_SOURCE    38
+#define IP_ADD_SOURCE_MEMBERSHIP  39
+#define IP_DROP_SOURCE_MEMBERSHIP 40
+#define IP_MSFILTER        41
+#define IP_MULTICAST_ALL   49
+#define IP_UNICAST_IF      50
+
+#define IP_RECVRETOPTS IP_RETOPTS
+
+#define IP_PMTUDISC_DONT   0
+#define IP_PMTUDISC_WANT   1
+#define IP_PMTUDISC_DO     2
+#define IP_PMTUDISC_PROBE  3
+#define IP_PMTUDISC_INTERFACE 4
+#define IP_PMTUDISC_OMIT   5
+
+#define IP_DEFAULT_MULTICAST_TTL        1
+#define IP_DEFAULT_MULTICAST_LOOP       1
+#define IP_MAX_MEMBERSHIPS              20
+
+struct ip_opts
+{
+	struct in_addr ip_dst;
+	char ip_opts[40];
+};
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#define MCAST_JOIN_GROUP   42
+#define MCAST_BLOCK_SOURCE 43
+#define MCAST_UNBLOCK_SOURCE      44
+#define MCAST_LEAVE_GROUP  45
+#define MCAST_JOIN_SOURCE_GROUP   46
+#define MCAST_LEAVE_SOURCE_GROUP  47
+#define MCAST_MSFILTER     48
+
+#define MCAST_EXCLUDE 0
+#define MCAST_INCLUDE 1
+
+struct ip_mreq
+{
+	struct in_addr imr_multiaddr;
+	struct in_addr imr_interface;
+};
+
+struct ip_mreqn
+{
+	struct in_addr imr_multiaddr;
+	struct in_addr imr_address;
+	int imr_ifindex;
+};
+
+struct ip_mreq_source {
+	struct in_addr imr_multiaddr;
+	struct in_addr imr_interface;
+	struct in_addr imr_sourceaddr;
+};
+
+struct ip_msfilter {
+	struct in_addr imsf_multiaddr;
+	struct in_addr imsf_interface;
+	uint32_t imsf_fmode;
+	uint32_t imsf_numsrc;
+	struct in_addr imsf_slist[1];
+};
+#define IP_MSFILTER_SIZE(numsrc) \
+	(sizeof(struct ip_msfilter) - sizeof(struct in_addr) \
+	+ (numsrc) * sizeof(struct in_addr))
+
+struct group_req {
+	uint32_t gr_interface;
+	struct sockaddr_storage gr_group;
+};
+
+struct group_source_req {
+	uint32_t gsr_interface;
+	struct sockaddr_storage gsr_group;
+	struct sockaddr_storage gsr_source;
+};
+
+struct group_filter {
+	uint32_t gf_interface;
+	struct sockaddr_storage gf_group;
+	uint32_t gf_fmode;
+	uint32_t gf_numsrc;
+	struct sockaddr_storage gf_slist[1];
+};
+#define GROUP_FILTER_SIZE(numsrc) \
+	(sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \
+	+ (numsrc) * sizeof(struct sockaddr_storage))
+
+struct in_pktinfo
+{
+	int ipi_ifindex;
+	struct in_addr ipi_spec_dst;
+	struct in_addr ipi_addr;
+};
+
+struct in6_pktinfo
+{
+	struct in6_addr ipi6_addr;
+	unsigned ipi6_ifindex;
+};
+
+struct ip6_mtuinfo
+{
+	struct sockaddr_in6 ip6m_addr;
+	uint32_t ip6m_mtu;
+};
+#endif
+
+#define IPV6_ADDRFORM           1
+#define IPV6_2292PKTINFO        2
+#define IPV6_2292HOPOPTS        3
+#define IPV6_2292DSTOPTS        4
+#define IPV6_2292RTHDR          5
+#define IPV6_2292PKTOPTIONS     6
+#define IPV6_CHECKSUM           7
+#define IPV6_2292HOPLIMIT       8
+#define IPV6_NEXTHOP            9
+#define IPV6_AUTHHDR            10
+#define IPV6_UNICAST_HOPS       16
+#define IPV6_MULTICAST_IF       17
+#define IPV6_MULTICAST_HOPS     18
+#define IPV6_MULTICAST_LOOP     19
+#define IPV6_JOIN_GROUP         20
+#define IPV6_LEAVE_GROUP        21
+#define IPV6_ROUTER_ALERT       22
+#define IPV6_MTU_DISCOVER       23
+#define IPV6_MTU                24
+#define IPV6_RECVERR            25
+#define IPV6_V6ONLY             26
+#define IPV6_JOIN_ANYCAST       27
+#define IPV6_LEAVE_ANYCAST      28
+#define IPV6_IPSEC_POLICY       34
+#define IPV6_XFRM_POLICY        35
+
+#define IPV6_RECVPKTINFO        49
+#define IPV6_PKTINFO            50
+#define IPV6_RECVHOPLIMIT       51
+#define IPV6_HOPLIMIT           52
+#define IPV6_RECVHOPOPTS        53
+#define IPV6_HOPOPTS            54
+#define IPV6_RTHDRDSTOPTS       55
+#define IPV6_RECVRTHDR          56
+#define IPV6_RTHDR              57
+#define IPV6_RECVDSTOPTS        58
+#define IPV6_DSTOPTS            59
+#define IPV6_RECVPATHMTU        60
+#define IPV6_PATHMTU            61
+#define IPV6_DONTFRAG           62
+#define IPV6_RECVTCLASS         66
+#define IPV6_TCLASS             67
+#define IPV6_AUTOFLOWLABEL      70
+#define IPV6_ADDR_PREFERENCES   72
+#define IPV6_MINHOPCOUNT        73
+#define IPV6_ORIGDSTADDR        74
+#define IPV6_RECVORIGDSTADDR    IPV6_ORIGDSTADDR
+#define IPV6_TRANSPARENT        75
+#define IPV6_UNICAST_IF         76
+
+#define IPV6_ADD_MEMBERSHIP     IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP    IPV6_LEAVE_GROUP
+#define IPV6_RXHOPOPTS          IPV6_HOPOPTS
+#define IPV6_RXDSTOPTS          IPV6_DSTOPTS
+
+#define IPV6_PMTUDISC_DONT      0
+#define IPV6_PMTUDISC_WANT      1
+#define IPV6_PMTUDISC_DO        2
+#define IPV6_PMTUDISC_PROBE     3
+#define IPV6_PMTUDISC_INTERFACE 4
+#define IPV6_PMTUDISC_OMIT      5
+
+#define IPV6_PREFER_SRC_TMP            0x0001
+#define IPV6_PREFER_SRC_PUBLIC         0x0002
+#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
+#define IPV6_PREFER_SRC_COA            0x0004
+#define IPV6_PREFER_SRC_HOME           0x0400
+#define IPV6_PREFER_SRC_CGA            0x0008
+#define IPV6_PREFER_SRC_NONCGA         0x0800
+
+#define IPV6_RTHDR_LOOSE        0
+#define IPV6_RTHDR_STRICT       1
+
+#define IPV6_RTHDR_TYPE_0       0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/in_systm.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/in_systm.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/in_systm.h	(revision 279)
@@ -0,0 +1,9 @@
+#ifndef _NETINET_IN_SYSTM_H
+#define _NETINET_IN_SYSTM_H
+
+#include <stdint.h>
+
+typedef uint16_t n_short;
+typedef uint32_t n_long, n_time;
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip.h	(revision 279)
@@ -0,0 +1,198 @@
+#ifndef _NETINET_IP_H
+#define _NETINET_IP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <netinet/in.h>
+#include <endian.h>
+
+struct timestamp {
+	uint8_t len;
+	uint8_t ptr;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+	unsigned int flags:4;
+	unsigned int overflow:4;
+#else
+	unsigned int overflow:4;
+	unsigned int flags:4;
+#endif
+	uint32_t data[9];
+  };
+
+struct iphdr {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+	unsigned int ihl:4;
+	unsigned int version:4;
+#else
+	unsigned int version:4;
+	unsigned int ihl:4;
+#endif
+	uint8_t tos;
+	uint16_t tot_len;
+	uint16_t id;
+	uint16_t frag_off;
+	uint8_t ttl;
+	uint8_t protocol;
+	uint16_t check;
+	uint32_t saddr;
+	uint32_t daddr;
+};
+
+struct ip {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+	unsigned int ip_hl:4;
+	unsigned int ip_v:4;
+#else
+	unsigned int ip_v:4;
+	unsigned int ip_hl:4;
+#endif
+	uint8_t ip_tos;
+	uint16_t ip_len;
+	uint16_t ip_id;
+	uint16_t ip_off;
+	uint8_t ip_ttl;
+	uint8_t ip_p;
+	uint16_t ip_sum;
+	struct in_addr ip_src, ip_dst;
+};
+
+#define	IP_RF 0x8000
+#define	IP_DF 0x4000
+#define	IP_MF 0x2000
+#define	IP_OFFMASK 0x1fff
+
+struct ip_timestamp {
+	uint8_t ipt_code;
+	uint8_t ipt_len;
+	uint8_t ipt_ptr;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+	unsigned int ipt_flg:4;
+	unsigned int ipt_oflw:4;
+#else
+	unsigned int ipt_oflw:4;
+	unsigned int ipt_flg:4;
+#endif
+	uint32_t data[9];
+};
+
+#define	IPVERSION	4
+#define	IP_MAXPACKET	65535
+
+#define	IPTOS_ECN_MASK		0x03
+#define	IPTOS_ECN(x)		((x) & IPTOS_ECN_MASK)
+#define	IPTOS_ECN_NOT_ECT	0x00
+#define	IPTOS_ECN_ECT1		0x01
+#define	IPTOS_ECN_ECT0		0x02
+#define	IPTOS_ECN_CE		0x03
+
+#define	IPTOS_DSCP_MASK		0xfc
+#define	IPTOS_DSCP(x)		((x) & IPTOS_DSCP_MASK)
+#define	IPTOS_DSCP_AF11		0x28
+#define	IPTOS_DSCP_AF12		0x30
+#define	IPTOS_DSCP_AF13		0x38
+#define	IPTOS_DSCP_AF21		0x48
+#define	IPTOS_DSCP_AF22		0x50
+#define	IPTOS_DSCP_AF23		0x58
+#define	IPTOS_DSCP_AF31		0x68
+#define	IPTOS_DSCP_AF32		0x70
+#define	IPTOS_DSCP_AF33		0x78
+#define	IPTOS_DSCP_AF41		0x88
+#define	IPTOS_DSCP_AF42		0x90
+#define	IPTOS_DSCP_AF43		0x98
+#define	IPTOS_DSCP_EF		0xb8
+
+#define	IPTOS_CLASS_MASK	0xe0
+#define	IPTOS_CLASS(x)		((x) & IPTOS_CLASS_MASK)
+#define	IPTOS_CLASS_CS0		0x00
+#define	IPTOS_CLASS_CS1		0x20
+#define	IPTOS_CLASS_CS2		0x40
+#define	IPTOS_CLASS_CS3		0x60
+#define	IPTOS_CLASS_CS4		0x80
+#define	IPTOS_CLASS_CS5		0xa0
+#define	IPTOS_CLASS_CS6		0xc0
+#define	IPTOS_CLASS_CS7		0xe0
+#define	IPTOS_CLASS_DEFAULT	IPTOS_CLASS_CS0
+
+#define	IPTOS_TOS_MASK		0x1E
+#define	IPTOS_TOS(tos)		((tos) & IPTOS_TOS_MASK)
+#define	IPTOS_LOWDELAY		0x10
+#define	IPTOS_THROUGHPUT	0x08
+#define	IPTOS_RELIABILITY	0x04
+#define	IPTOS_LOWCOST		0x02
+#define	IPTOS_MINCOST		IPTOS_LOWCOST
+
+#define	IPTOS_PREC_MASK			0xe0
+#define	IPTOS_PREC(tos)                ((tos) & IPTOS_PREC_MASK)
+#define	IPTOS_PREC_NETCONTROL		0xe0
+#define	IPTOS_PREC_INTERNETCONTROL	0xc0
+#define	IPTOS_PREC_CRITIC_ECP		0xa0
+#define	IPTOS_PREC_FLASHOVERRIDE	0x80
+#define	IPTOS_PREC_FLASH		0x60
+#define	IPTOS_PREC_IMMEDIATE		0x40
+#define	IPTOS_PREC_PRIORITY		0x20
+#define	IPTOS_PREC_ROUTINE		0x00
+
+#define	IPOPT_COPY		0x80
+#define	IPOPT_CLASS_MASK	0x60
+#define	IPOPT_NUMBER_MASK	0x1f
+
+#define	IPOPT_COPIED(o)		((o) & IPOPT_COPY)
+#define	IPOPT_CLASS(o)		((o) & IPOPT_CLASS_MASK)
+#define	IPOPT_NUMBER(o)		((o) & IPOPT_NUMBER_MASK)
+
+#define	IPOPT_CONTROL		0x00
+#define	IPOPT_RESERVED1		0x20
+#define	IPOPT_DEBMEAS		0x40
+#define	IPOPT_MEASUREMENT       IPOPT_DEBMEAS
+#define	IPOPT_RESERVED2		0x60
+
+#define	IPOPT_EOL		0
+#define	IPOPT_END		IPOPT_EOL
+#define	IPOPT_NOP		1
+#define	IPOPT_NOOP		IPOPT_NOP
+
+#define	IPOPT_RR		7
+#define	IPOPT_TS		68
+#define	IPOPT_TIMESTAMP		IPOPT_TS
+#define	IPOPT_SECURITY		130
+#define	IPOPT_SEC		IPOPT_SECURITY
+#define	IPOPT_LSRR		131
+#define	IPOPT_SATID		136
+#define	IPOPT_SID		IPOPT_SATID
+#define	IPOPT_SSRR		137
+#define	IPOPT_RA		148
+
+#define	IPOPT_OPTVAL		0
+#define	IPOPT_OLEN		1
+#define	IPOPT_OFFSET		2
+#define	IPOPT_MINOFF		4
+
+#define	MAX_IPOPTLEN		40
+
+#define	IPOPT_TS_TSONLY		0
+#define	IPOPT_TS_TSANDADDR	1
+#define	IPOPT_TS_PRESPEC	3
+
+#define	IPOPT_SECUR_UNCLASS	0x0000
+#define	IPOPT_SECUR_CONFID	0xf135
+#define	IPOPT_SECUR_EFTO	0x789a
+#define	IPOPT_SECUR_MMMM	0xbc4d
+#define	IPOPT_SECUR_RESTR	0xaf13
+#define	IPOPT_SECUR_SECRET	0xd788
+#define	IPOPT_SECUR_TOPSECRET	0x6bc5
+
+#define	MAXTTL		255
+#define	IPDEFTTL	64
+#define	IPFRAGTTL	60
+#define	IPTTLDEC	1
+
+#define	IP_MSS		576
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip6.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip6.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip6.h	(revision 279)
@@ -0,0 +1,142 @@
+#ifndef _NETINET_IP6_H
+#define _NETINET_IP6_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <netinet/in.h>
+#include <endian.h>
+
+struct ip6_hdr {
+	union {
+		struct ip6_hdrctl {
+			uint32_t ip6_un1_flow;
+			uint16_t ip6_un1_plen;
+			uint8_t  ip6_un1_nxt;
+			uint8_t  ip6_un1_hlim;
+		} ip6_un1;
+		uint8_t ip6_un2_vfc;
+	} ip6_ctlun;
+	struct in6_addr ip6_src;
+	struct in6_addr ip6_dst;
+};
+
+#define ip6_vfc   ip6_ctlun.ip6_un2_vfc
+#define ip6_flow  ip6_ctlun.ip6_un1.ip6_un1_flow
+#define ip6_plen  ip6_ctlun.ip6_un1.ip6_un1_plen
+#define ip6_nxt   ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_hlim  ip6_ctlun.ip6_un1.ip6_un1_hlim
+#define ip6_hops  ip6_ctlun.ip6_un1.ip6_un1_hlim
+
+struct ip6_ext {
+	uint8_t  ip6e_nxt;
+	uint8_t  ip6e_len;
+};
+
+struct ip6_hbh {
+	uint8_t  ip6h_nxt;
+	uint8_t  ip6h_len;
+};
+
+struct ip6_dest {
+	uint8_t  ip6d_nxt;
+	uint8_t  ip6d_len;
+};
+
+struct ip6_rthdr {
+	uint8_t  ip6r_nxt;
+	uint8_t  ip6r_len;
+	uint8_t  ip6r_type;
+	uint8_t  ip6r_segleft;
+};
+
+struct ip6_rthdr0 {
+	uint8_t  ip6r0_nxt;
+	uint8_t  ip6r0_len;
+	uint8_t  ip6r0_type;
+	uint8_t  ip6r0_segleft;
+	uint8_t  ip6r0_reserved;
+	uint8_t  ip6r0_slmap[3];
+	struct in6_addr ip6r0_addr[];
+};
+
+struct ip6_frag {
+	uint8_t   ip6f_nxt;
+	uint8_t   ip6f_reserved;
+	uint16_t  ip6f_offlg;
+	uint32_t  ip6f_ident;
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define IP6F_OFF_MASK       0xfff8
+#define IP6F_RESERVED_MASK  0x0006
+#define IP6F_MORE_FRAG      0x0001
+#else
+#define IP6F_OFF_MASK       0xf8ff
+#define IP6F_RESERVED_MASK  0x0600
+#define IP6F_MORE_FRAG      0x0100
+#endif
+
+struct ip6_opt {
+	uint8_t  ip6o_type;
+	uint8_t  ip6o_len;
+};
+
+#define IP6OPT_TYPE(o)		((o) & 0xc0)
+#define IP6OPT_TYPE_SKIP	0x00
+#define IP6OPT_TYPE_DISCARD	0x40
+#define IP6OPT_TYPE_FORCEICMP	0x80
+#define IP6OPT_TYPE_ICMP	0xc0
+#define IP6OPT_TYPE_MUTABLE	0x20
+
+#define IP6OPT_PAD1	0
+#define IP6OPT_PADN	1
+
+#define IP6OPT_JUMBO		0xc2
+#define IP6OPT_NSAP_ADDR	0xc3
+#define IP6OPT_TUNNEL_LIMIT	0x04
+#define IP6OPT_ROUTER_ALERT	0x05
+
+struct ip6_opt_jumbo {
+	uint8_t  ip6oj_type;
+	uint8_t  ip6oj_len;
+	uint8_t  ip6oj_jumbo_len[4];
+};
+#define IP6OPT_JUMBO_LEN	6
+
+struct ip6_opt_nsap {
+	uint8_t  ip6on_type;
+	uint8_t  ip6on_len;
+	uint8_t  ip6on_src_nsap_len;
+	uint8_t  ip6on_dst_nsap_len;
+};
+
+struct ip6_opt_tunnel {
+	uint8_t  ip6ot_type;
+	uint8_t  ip6ot_len;
+	uint8_t  ip6ot_encap_limit;
+};
+
+struct ip6_opt_router {
+	uint8_t  ip6or_type;
+	uint8_t  ip6or_len;
+	uint8_t  ip6or_value[2];
+};
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define IP6_ALERT_MLD	0x0000
+#define IP6_ALERT_RSVP	0x0001
+#define IP6_ALERT_AN	0x0002
+#else
+#define IP6_ALERT_MLD	0x0000
+#define IP6_ALERT_RSVP	0x0100
+#define IP6_ALERT_AN	0x0200
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip_icmp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip_icmp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/ip_icmp.h	(revision 279)
@@ -0,0 +1,192 @@
+#ifndef _NETINET_IP_ICMP_H
+#define _NETINET_IP_ICMP_H
+
+#include <stdint.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct icmphdr {
+	uint8_t type;
+	uint8_t code;
+	uint16_t checksum;
+	union {
+		struct {
+			uint16_t id;
+			uint16_t sequence;
+		} echo;
+		uint32_t gateway;
+		struct {
+			uint16_t __unused;
+			uint16_t mtu;
+		} frag;
+	} un;
+};
+
+#define ICMP_ECHOREPLY		0
+#define ICMP_DEST_UNREACH	3
+#define ICMP_SOURCE_QUENCH	4
+#define ICMP_REDIRECT		5
+#define ICMP_ECHO		8
+#define ICMP_TIME_EXCEEDED	11
+#define ICMP_PARAMETERPROB	12
+#define ICMP_TIMESTAMP		13
+#define ICMP_TIMESTAMPREPLY	14
+#define ICMP_INFO_REQUEST	15
+#define ICMP_INFO_REPLY		16
+#define ICMP_ADDRESS		17
+#define ICMP_ADDRESSREPLY	18
+#define NR_ICMP_TYPES		18
+
+
+#define ICMP_NET_UNREACH	0
+#define ICMP_HOST_UNREACH	1
+#define ICMP_PROT_UNREACH	2
+#define ICMP_PORT_UNREACH	3
+#define ICMP_FRAG_NEEDED	4
+#define ICMP_SR_FAILED		5
+#define ICMP_NET_UNKNOWN	6
+#define ICMP_HOST_UNKNOWN	7
+#define ICMP_HOST_ISOLATED	8
+#define ICMP_NET_ANO		9
+#define ICMP_HOST_ANO		10
+#define ICMP_NET_UNR_TOS	11
+#define ICMP_HOST_UNR_TOS	12
+#define ICMP_PKT_FILTERED	13
+#define ICMP_PREC_VIOLATION	14
+#define ICMP_PREC_CUTOFF	15
+#define NR_ICMP_UNREACH		15
+
+#define ICMP_REDIR_NET		0
+#define ICMP_REDIR_HOST		1
+#define ICMP_REDIR_NETTOS	2
+#define ICMP_REDIR_HOSTTOS	3
+
+#define ICMP_EXC_TTL		0
+#define ICMP_EXC_FRAGTIME	1
+
+
+struct icmp_ra_addr {
+	uint32_t ira_addr;
+	uint32_t ira_preference;
+};
+
+struct icmp {
+	uint8_t  icmp_type;
+	uint8_t  icmp_code;
+	uint16_t icmp_cksum;
+	union {
+		uint8_t ih_pptr;
+		struct in_addr ih_gwaddr;
+		struct ih_idseq {
+			uint16_t icd_id;
+			uint16_t icd_seq;
+		} ih_idseq;
+		uint32_t ih_void;
+
+		struct ih_pmtu {
+			uint16_t ipm_void;
+			uint16_t ipm_nextmtu;
+		} ih_pmtu;
+
+		struct ih_rtradv {
+			uint8_t irt_num_addrs;
+			uint8_t irt_wpa;
+			uint16_t irt_lifetime;
+		} ih_rtradv;
+	} icmp_hun;
+	union {
+		struct {
+			uint32_t its_otime;
+			uint32_t its_rtime;
+			uint32_t its_ttime;
+		} id_ts;
+		struct {
+			struct ip idi_ip;
+		} id_ip;
+		struct icmp_ra_addr id_radv;
+		uint32_t   id_mask;
+		uint8_t    id_data[1];
+	} icmp_dun;
+};
+
+#define	icmp_pptr	icmp_hun.ih_pptr
+#define	icmp_gwaddr	icmp_hun.ih_gwaddr
+#define	icmp_id		icmp_hun.ih_idseq.icd_id
+#define	icmp_seq	icmp_hun.ih_idseq.icd_seq
+#define	icmp_void	icmp_hun.ih_void
+#define	icmp_pmvoid	icmp_hun.ih_pmtu.ipm_void
+#define	icmp_nextmtu	icmp_hun.ih_pmtu.ipm_nextmtu
+#define	icmp_num_addrs	icmp_hun.ih_rtradv.irt_num_addrs
+#define	icmp_wpa	icmp_hun.ih_rtradv.irt_wpa
+#define	icmp_lifetime	icmp_hun.ih_rtradv.irt_lifetime
+#define	icmp_otime	icmp_dun.id_ts.its_otime
+#define	icmp_rtime	icmp_dun.id_ts.its_rtime
+#define	icmp_ttime	icmp_dun.id_ts.its_ttime
+#define	icmp_ip		icmp_dun.id_ip.idi_ip
+#define	icmp_radv	icmp_dun.id_radv
+#define	icmp_mask	icmp_dun.id_mask
+#define	icmp_data	icmp_dun.id_data
+
+#define	ICMP_MINLEN	8
+#define	ICMP_TSLEN	(8 + 3 * sizeof (n_time))
+#define	ICMP_MASKLEN	12
+#define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)
+#define	ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
+
+#define	ICMP_UNREACH		3
+#define	ICMP_SOURCEQUENCH	4
+#define	ICMP_ROUTERADVERT	9
+#define	ICMP_ROUTERSOLICIT	10
+#define	ICMP_TIMXCEED		11
+#define	ICMP_PARAMPROB		12
+#define	ICMP_TSTAMP		13
+#define	ICMP_TSTAMPREPLY	14
+#define	ICMP_IREQ		15
+#define	ICMP_IREQREPLY		16
+#define	ICMP_MASKREQ		17
+#define	ICMP_MASKREPLY		18
+#define	ICMP_MAXTYPE		18
+
+#define	ICMP_UNREACH_NET	        0
+#define	ICMP_UNREACH_HOST	        1
+#define	ICMP_UNREACH_PROTOCOL	        2
+#define	ICMP_UNREACH_PORT	        3
+#define	ICMP_UNREACH_NEEDFRAG	        4
+#define	ICMP_UNREACH_SRCFAIL	        5
+#define	ICMP_UNREACH_NET_UNKNOWN        6
+#define	ICMP_UNREACH_HOST_UNKNOWN       7
+#define	ICMP_UNREACH_ISOLATED	        8
+#define	ICMP_UNREACH_NET_PROHIB	        9
+#define	ICMP_UNREACH_HOST_PROHIB        10
+#define	ICMP_UNREACH_TOSNET	        11
+#define	ICMP_UNREACH_TOSHOST	        12
+#define	ICMP_UNREACH_FILTER_PROHIB      13
+#define	ICMP_UNREACH_HOST_PRECEDENCE    14
+#define	ICMP_UNREACH_PRECEDENCE_CUTOFF  15
+
+#define	ICMP_REDIRECT_NET	0
+#define	ICMP_REDIRECT_HOST	1
+#define	ICMP_REDIRECT_TOSNET	2
+#define	ICMP_REDIRECT_TOSHOST	3
+
+#define	ICMP_TIMXCEED_INTRANS	0
+#define	ICMP_TIMXCEED_REASS	1
+
+#define	ICMP_PARAMPROB_OPTABSENT 1
+
+#define	ICMP_INFOTYPE(type) \
+	((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
+	(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
+	(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
+	(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
+	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/tcp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/tcp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/tcp.h	(revision 279)
@@ -0,0 +1,182 @@
+#ifndef _NETINET_TCP_H
+#define _NETINET_TCP_H
+
+#include <features.h>
+
+#define TCP_NODELAY 1
+#define TCP_MAXSEG	 2
+#define TCP_CORK	 3
+#define TCP_KEEPIDLE	 4
+#define TCP_KEEPINTVL	 5
+#define TCP_KEEPCNT	 6
+#define TCP_SYNCNT	 7
+#define TCP_LINGER2	 8
+#define TCP_DEFER_ACCEPT 9
+#define TCP_WINDOW_CLAMP 10
+#define TCP_INFO	 11
+#define	TCP_QUICKACK	 12
+#define TCP_CONGESTION	 13
+#define TCP_MD5SIG	 14
+#define TCP_THIN_LINEAR_TIMEOUTS 16
+#define TCP_THIN_DUPACK  17
+#define TCP_USER_TIMEOUT 18
+#define TCP_REPAIR       19
+#define TCP_REPAIR_QUEUE 20
+#define TCP_QUEUE_SEQ    21
+#define TCP_REPAIR_OPTIONS 22
+#define TCP_FASTOPEN     23
+#define TCP_TIMESTAMP    24
+#define TCP_NOTSENT_LOWAT 25
+
+#define TCP_ESTABLISHED  1
+#define TCP_SYN_SENT     2
+#define TCP_SYN_RECV     3
+#define TCP_FIN_WAIT1    4
+#define TCP_FIN_WAIT2    5
+#define TCP_TIME_WAIT    6
+#define TCP_CLOSE        7
+#define TCP_CLOSE_WAIT   8
+#define TCP_LAST_ACK     9
+#define TCP_LISTEN       10
+#define TCP_CLOSING      11
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define SOL_TCP 6
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdint.h>
+#include <endian.h>
+
+typedef uint32_t tcp_seq;
+
+#define TH_FIN 0x01
+#define TH_SYN 0x02
+#define TH_RST 0x04
+#define TH_PUSH 0x08
+#define TH_ACK 0x10
+#define TH_URG 0x20
+
+struct tcphdr {
+#ifdef _GNU_SOURCE
+#ifdef __GNUC__
+	__extension__
+#endif
+	union { struct {
+
+	uint16_t source;
+	uint16_t dest;
+	uint32_t seq;
+	uint32_t ack_seq;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+	uint16_t res1:4;
+	uint16_t doff:4;
+	uint16_t fin:1;
+	uint16_t syn:1;
+	uint16_t rst:1;
+	uint16_t psh:1;
+	uint16_t ack:1;
+	uint16_t urg:1;
+	uint16_t res2:2;
+#else
+	uint16_t doff:4;
+	uint16_t res1:4;
+	uint16_t res2:2;
+	uint16_t urg:1;
+	uint16_t ack:1;
+	uint16_t psh:1;
+	uint16_t rst:1;
+	uint16_t syn:1;
+	uint16_t fin:1;
+#endif
+	uint16_t window;
+	uint16_t check;
+	uint16_t urg_ptr;
+
+	}; struct {
+#endif
+
+	uint16_t th_sport;
+	uint16_t th_dport;
+	uint32_t th_seq;
+	uint32_t th_ack;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+	uint8_t th_x2:4;
+	uint8_t th_off:4;
+#else
+	uint8_t th_off:4;
+	uint8_t th_x2:4;
+#endif
+	uint8_t th_flags;
+	uint16_t th_win;
+	uint16_t th_sum;
+	uint16_t th_urp;
+
+#ifdef _GNU_SOURCE
+	}; };
+#endif
+};
+#endif
+
+#ifdef _GNU_SOURCE
+#define TCPI_OPT_TIMESTAMPS	1
+#define TCPI_OPT_SACK		2
+#define TCPI_OPT_WSCALE		4
+#define TCPI_OPT_ECN		8
+
+#define TCP_CA_Open		0
+#define TCP_CA_Disorder		1
+#define TCP_CA_CWR		2
+#define TCP_CA_Recovery		3
+#define TCP_CA_Loss		4
+
+struct tcp_info
+{
+	uint8_t tcpi_state;
+	uint8_t tcpi_ca_state;
+	uint8_t tcpi_retransmits;
+	uint8_t tcpi_probes;
+	uint8_t tcpi_backoff;
+	uint8_t tcpi_options;
+	uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
+	uint32_t tcpi_rto;
+	uint32_t tcpi_ato;
+	uint32_t tcpi_snd_mss;
+	uint32_t tcpi_rcv_mss;
+	uint32_t tcpi_unacked;
+	uint32_t tcpi_sacked;
+	uint32_t tcpi_lost;
+	uint32_t tcpi_retrans;
+	uint32_t tcpi_fackets;
+	uint32_t tcpi_last_data_sent;
+	uint32_t tcpi_last_ack_sent;
+	uint32_t tcpi_last_data_recv;
+	uint32_t tcpi_last_ack_recv;
+	uint32_t tcpi_pmtu;
+	uint32_t tcpi_rcv_ssthresh;
+	uint32_t tcpi_rtt;
+	uint32_t tcpi_rttvar;
+	uint32_t tcpi_snd_ssthresh;
+	uint32_t tcpi_snd_cwnd;
+	uint32_t tcpi_advmss;
+	uint32_t tcpi_reordering;
+	uint32_t tcpi_rcv_rtt;
+	uint32_t tcpi_rcv_space;
+	uint32_t tcpi_total_retrans;
+	uint64_t tcpi_pacing_rate;
+	uint64_t tcpi_max_pacing_rate;
+};
+
+#define TCP_MD5SIG_MAXKEYLEN    80
+
+struct tcp_md5sig
+{
+	struct sockaddr_storage tcpm_addr;
+	uint16_t __tcpm_pad1;
+	uint16_t tcpm_keylen;
+	uint32_t __tcpm_pad2;
+	uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
+};
+
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/udp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/udp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netinet/udp.h	(revision 279)
@@ -0,0 +1,38 @@
+#ifndef _NETINET_UDP_H
+#define _NETINET_UDP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <stdint.h>
+
+#ifdef _GNU_SOURCE
+#define uh_sport source
+#define uh_dport dest
+#define uh_ulen len
+#define uh_sum check
+#endif
+
+struct udphdr {
+	uint16_t uh_sport;
+	uint16_t uh_dport;
+	uint16_t uh_ulen;
+	uint16_t uh_sum;
+};
+
+#define UDP_CORK	1
+#define UDP_ENCAP	100
+
+#define UDP_ENCAP_ESPINUDP_NON_IKE 1
+#define UDP_ENCAP_ESPINUDP	2
+#define UDP_ENCAP_L2TPINUDP	3
+
+#define SOL_UDP            17
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/netpacket/packet.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/netpacket/packet.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/netpacket/packet.h	(revision 279)
@@ -0,0 +1,44 @@
+#ifndef _NETPACKET_PACKET_H
+#define _NETPACKET_PACKET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct sockaddr_ll {
+	unsigned short sll_family, sll_protocol;
+	int sll_ifindex;
+	unsigned short sll_hatype;
+	unsigned char sll_pkttype, sll_halen;
+	unsigned char sll_addr[8];
+};
+
+struct packet_mreq {
+	int mr_ifindex;
+	unsigned short int mr_type,  mr_alen;
+	unsigned char mr_address[8];
+};
+
+#define PACKET_HOST		0
+#define PACKET_BROADCAST	1
+#define PACKET_MULTICAST	2
+#define PACKET_OTHERHOST	3
+#define PACKET_OUTGOING		4
+#define PACKET_LOOPBACK		5
+#define PACKET_FASTROUTE	6
+
+#define PACKET_ADD_MEMBERSHIP		1
+#define PACKET_DROP_MEMBERSHIP		2
+#define	PACKET_RECV_OUTPUT		3
+#define	PACKET_RX_RING			5
+#define	PACKET_STATISTICS		6
+
+#define PACKET_MR_MULTICAST	0
+#define PACKET_MR_PROMISC	1
+#define PACKET_MR_ALLMULTI	2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/poll.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/poll.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/poll.h	(revision 279)
@@ -0,0 +1,52 @@
+#ifndef	_POLL_H
+#define	_POLL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "../../../musl-1.1.12/include/features.h"
+
+#include "../../../musl-1.1.12/include/bits/poll.h"
+
+#define POLLIN     0x001
+#define POLLPRI    0x002
+#define POLLOUT    0x004
+#define POLLERR    0x008
+#define POLLHUP    0x010
+#define POLLNVAL   0x020
+#define POLLRDNORM 0x040
+#define POLLRDBAND 0x080
+#ifndef POLLWRNORM
+#define POLLWRNORM 0x100
+#define POLLWRBAND 0x200
+#endif
+#ifndef POLLMSG
+#define POLLMSG    0x400
+#define POLLRDHUP  0x2000
+#endif
+
+typedef unsigned long nfds_t;
+
+struct pollfd
+{
+	int fd;
+	short events;
+	short revents;
+};
+
+int poll (struct pollfd *, nfds_t, int);
+
+#ifdef _GNU_SOURCE
+#define __NEED_time_t
+#define __NEED_struct_timespec
+#define __NEED_sigset_t
+#include <bits/alltypes.h>
+int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/ioctl.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/ioctl.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/ioctl.h	(revision 279)
@@ -0,0 +1,14 @@
+#ifndef	_SYS_IOCTL_H
+#define	_SYS_IOCTL_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/ioctl.h>
+
+int ioctl (int, int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/mman.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/mman.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/mman.h	(revision 279)
@@ -0,0 +1,57 @@
+#ifndef	_SYS_MMAN_H
+#define	_SYS_MMAN_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_mode_t
+#define __NEED_size_t
+/*#define __NEED_off_t*/
+
+#if defined(_GNU_SOURCE)
+#define __NEED_ssize_t
+#endif
+
+#include <bits/alltypes.h>
+
+#include <bits/mman.h>
+
+void *mmap (void *, size_t, int, int, int, off_t);
+int munmap (void *, size_t);
+
+int mprotect (void *, size_t, int);
+int msync (void *, size_t, int);
+
+int posix_madvise (void *, size_t, int);
+
+int mlock (const void *, size_t);
+int munlock (const void *, size_t);
+int mlockall (int);
+int munlockall (void);
+
+#ifdef _GNU_SOURCE
+#define MREMAP_MAYMOVE 1
+#define MREMAP_FIXED 2
+void *mremap (void *, size_t, size_t, int, ...);
+int remap_file_pages (void *, size_t, int, size_t, int);
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+int madvise (void *, size_t, int);
+int mincore (void *, size_t, unsigned char *);
+#endif
+
+int shm_open (const char *, int, mode_t);
+int shm_unlink (const char *);
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define mmap64 mmap
+#define off64_t off_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/socket.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/socket.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/socket.h	(revision 279)
@@ -0,0 +1,319 @@
+#ifndef	_SYS_SOCKET_H
+#define	_SYS_SOCKET_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_socklen_t
+#define __NEED_sa_family_t
+#define __NEED_size_t
+#define __NEED_ssize_t
+/*#define __NEED_uid_t*/
+#define __NEED_pid_t
+/*#define __NEED_gid_t*/
+#define __NEED_struct_iovec
+
+#include <bits/alltypes.h>
+
+#include <bits/socket.h>
+
+#ifdef _GNU_SOURCE
+struct ucred
+{
+	pid_t pid;
+	uid_t uid;
+	gid_t gid;
+};
+
+struct mmsghdr
+{
+	struct msghdr msg_hdr;
+	unsigned int  msg_len;
+};
+
+struct timespec;
+
+int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int);
+int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *);
+#endif
+
+struct linger
+{
+	int l_onoff;
+	int l_linger;
+};
+
+#define SHUT_RD 0
+#define SHUT_WR 1
+#define SHUT_RDWR 2
+
+#ifndef SOCK_STREAM
+#define SOCK_STREAM    1
+#define SOCK_DGRAM     2
+#endif
+
+#define SOCK_RAW       3
+#define SOCK_RDM       4
+#define SOCK_SEQPACKET 5
+#define SOCK_DCCP      6
+#define SOCK_PACKET    10
+
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC   02000000
+#define SOCK_NONBLOCK  04000
+#endif
+
+#define PF_UNSPEC       0
+#define PF_LOCAL        1
+#define PF_UNIX         PF_LOCAL
+#define PF_FILE         PF_LOCAL
+#define PF_INET         2
+#define PF_AX25         3
+#define PF_IPX          4
+#define PF_APPLETALK    5
+#define PF_NETROM       6
+#define PF_BRIDGE       7
+#define PF_ATMPVC       8
+#define PF_X25          9
+#define PF_INET6        10
+#define PF_ROSE         11
+#define PF_DECnet       12
+#define PF_NETBEUI      13
+#define PF_SECURITY     14
+#define PF_KEY          15
+#define PF_NETLINK      16
+#define PF_ROUTE        PF_NETLINK
+#define PF_PACKET       17
+#define PF_ASH          18
+#define PF_ECONET       19
+#define PF_ATMSVC       20
+#define PF_RDS          21
+#define PF_SNA          22
+#define PF_IRDA         23
+#define PF_PPPOX        24
+#define PF_WANPIPE      25
+#define PF_LLC          26
+#define PF_IB           27
+#define PF_CAN          29
+#define PF_TIPC         30
+#define PF_BLUETOOTH    31
+#define PF_IUCV         32
+#define PF_RXRPC        33
+#define PF_ISDN         34
+#define PF_PHONET       35
+#define PF_IEEE802154   36
+#define PF_CAIF         37
+#define PF_ALG          38
+#define PF_NFC          39
+#define PF_VSOCK        40
+#define PF_MAX          41
+
+#define AF_UNSPEC       PF_UNSPEC
+#define AF_LOCAL        PF_LOCAL
+#define AF_UNIX         AF_LOCAL
+#define AF_FILE         AF_LOCAL
+#define AF_INET         PF_INET
+#define AF_AX25         PF_AX25
+#define AF_IPX          PF_IPX
+#define AF_APPLETALK    PF_APPLETALK
+#define AF_NETROM       PF_NETROM
+#define AF_BRIDGE       PF_BRIDGE
+#define AF_ATMPVC       PF_ATMPVC
+#define AF_X25          PF_X25
+#define AF_INET6        PF_INET6
+#define AF_ROSE         PF_ROSE
+#define AF_DECnet       PF_DECnet
+#define AF_NETBEUI      PF_NETBEUI
+#define AF_SECURITY     PF_SECURITY
+#define AF_KEY          PF_KEY
+#define AF_NETLINK      PF_NETLINK
+#define AF_ROUTE        PF_ROUTE
+#define AF_PACKET       PF_PACKET
+#define AF_ASH          PF_ASH
+#define AF_ECONET       PF_ECONET
+#define AF_ATMSVC       PF_ATMSVC
+#define AF_RDS          PF_RDS
+#define AF_SNA          PF_SNA
+#define AF_IRDA         PF_IRDA
+#define AF_PPPOX        PF_PPPOX
+#define AF_WANPIPE      PF_WANPIPE
+#define AF_LLC          PF_LLC
+#define AF_IB           PF_IB
+#define AF_CAN          PF_CAN
+#define AF_TIPC         PF_TIPC
+#define AF_BLUETOOTH    PF_BLUETOOTH
+#define AF_IUCV         PF_IUCV
+#define AF_RXRPC        PF_RXRPC
+#define AF_ISDN         PF_ISDN
+#define AF_PHONET       PF_PHONET
+#define AF_IEEE802154   PF_IEEE802154
+#define AF_CAIF         PF_CAIF
+#define AF_ALG          PF_ALG
+#define AF_NFC          PF_NFC
+#define AF_VSOCK        PF_VSOCK
+#define AF_MAX          PF_MAX
+
+#ifndef SO_DEBUG
+#define SO_DEBUG        1
+#define SO_REUSEADDR    2
+#define SO_TYPE         3
+#define SO_ERROR        4
+#define SO_DONTROUTE    5
+#define SO_BROADCAST    6
+#define SO_SNDBUF       7
+#define SO_RCVBUF       8
+#define SO_KEEPALIVE    9
+#define SO_OOBINLINE    10
+#define SO_NO_CHECK     11
+#define SO_PRIORITY     12
+#define SO_LINGER       13
+#define SO_BSDCOMPAT    14
+#define SO_REUSEPORT    15
+#define SO_PASSCRED     16
+#define SO_PEERCRED     17
+#define SO_RCVLOWAT     18
+#define SO_SNDLOWAT     19
+#define SO_RCVTIMEO     20
+#define SO_SNDTIMEO     21
+#define SO_ACCEPTCONN   30
+#define SO_SNDBUFFORCE  32
+#define SO_RCVBUFFORCE  33
+#define SO_PROTOCOL     38
+#define SO_DOMAIN       39
+#endif
+
+#define SO_SECURITY_AUTHENTICATION              22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT        23
+#define SO_SECURITY_ENCRYPTION_NETWORK          24
+
+#define SO_BINDTODEVICE 25
+
+#define SO_ATTACH_FILTER        26
+#define SO_DETACH_FILTER        27
+#define SO_GET_FILTER           SO_ATTACH_FILTER
+
+#define SO_PEERNAME             28
+#define SO_TIMESTAMP            29
+#define SCM_TIMESTAMP           SO_TIMESTAMP
+
+#define SO_PEERSEC              31
+#define SO_PASSSEC              34
+#define SO_TIMESTAMPNS          35
+#define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
+#define SO_MARK                 36
+#define SO_TIMESTAMPING         37
+#define SCM_TIMESTAMPING        SO_TIMESTAMPING
+#define SO_RXQ_OVFL             40
+#define SO_WIFI_STATUS          41
+#define SCM_WIFI_STATUS         SO_WIFI_STATUS
+#define SO_PEEK_OFF             42
+#define SO_NOFCS                43
+#define SO_LOCK_FILTER          44
+#define SO_SELECT_ERR_QUEUE     45
+#define SO_BUSY_POLL            46
+#define SO_MAX_PACING_RATE      47
+#define SO_BPF_EXTENSIONS       48
+#define SO_INCOMING_CPU         49
+#define SO_ATTACH_BPF           50
+#define SO_DETACH_BPF           SO_DETACH_FILTER
+
+
+#ifndef SOL_SOCKET
+#define SOL_SOCKET      1
+#endif
+
+#define SOL_IP          0
+#define SOL_IPV6        41
+#define SOL_ICMPV6      58
+
+#define SOL_RAW         255
+#define SOL_DECNET      261
+#define SOL_X25         262
+#define SOL_PACKET      263
+#define SOL_ATM         264
+#define SOL_AAL         265
+#define SOL_IRDA        266
+
+#define SOMAXCONN       128
+
+#define MSG_OOB       0x0001
+#define MSG_PEEK      0x0002
+#define MSG_DONTROUTE 0x0004
+#define MSG_CTRUNC    0x0008
+#define MSG_PROXY     0x0010
+#define MSG_TRUNC     0x0020
+#define MSG_DONTWAIT  0x0040
+#define MSG_EOR       0x0080
+#define MSG_WAITALL   0x0100
+#define MSG_FIN       0x0200
+#define MSG_SYN       0x0400
+#define MSG_CONFIRM   0x0800
+#define MSG_RST       0x1000
+#define MSG_ERRQUEUE  0x2000
+#define MSG_NOSIGNAL  0x4000
+#define MSG_MORE      0x8000
+#define MSG_WAITFORONE 0x10000
+#define MSG_CMSG_CLOEXEC 0x40000000
+
+#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
+#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
+#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
+
+#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
+#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) ? (struct cmsghdr *)0 : \
+        (__CMSG_NEXT(cmsg) + sizeof (struct cmsghdr) >= __MHDR_END(mhdr) ? (struct cmsghdr *)0 : \
+        ((struct cmsghdr *)__CMSG_NEXT(cmsg))))
+#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
+
+#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
+#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
+#define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+
+#define SCM_RIGHTS      0x01
+#define SCM_CREDENTIALS 0x02
+
+struct sockaddr
+{
+	sa_family_t sa_family;
+	char sa_data[14];
+};
+
+struct sockaddr_storage
+{
+	sa_family_t ss_family;
+	unsigned long __ss_align;
+	char __ss_padding[128-2*sizeof(unsigned long)];
+};
+
+int socket (int, int, int);
+int socketpair (int, int, int, int [2]);
+
+int shutdown (int, int);
+
+int bind (int, const struct sockaddr *, socklen_t);
+int connect (int, const struct sockaddr *, socklen_t);
+int listen (int, int);
+int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
+int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
+
+int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
+int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
+
+ssize_t send (int, const void *, size_t, int);
+ssize_t recv (int, void *, size_t, int);
+ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
+ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
+ssize_t sendmsg (int, const struct msghdr *, int);
+ssize_t recvmsg (int, struct msghdr *, int);
+
+int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
+int setsockopt (int, int, int, const void *, socklen_t);
+
+int sockatmark (int);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/statfs.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/statfs.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/statfs.h	(revision 279)
@@ -0,0 +1,32 @@
+#ifndef	_SYS_STATFS_H
+#define	_SYS_STATFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#include <sys/statvfs.h>
+
+typedef struct __fsid_t {
+	int __val[2];
+} fsid_t;
+
+#include <bits/statfs.h>
+
+int statfs (const char *, struct statfs *);
+int fstatfs (int, struct statfs *);
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define statfs64 statfs
+#define fstatfs64 fstatfs
+#define fsblkcnt64_t fsblkcnt_t
+#define fsfilcnt64_t fsfilcnt_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/statvfs.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/statvfs.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/statvfs.h	(revision 279)
@@ -0,0 +1,57 @@
+#ifndef	_SYS_STATVFS_H
+#define	_SYS_STATVFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_fsblkcnt_t
+#define __NEED_fsfilcnt_t
+#include <bits/alltypes.h>
+
+#include <endian.h>
+
+struct statvfs {
+	unsigned long f_bsize, f_frsize;
+	fsblkcnt_t f_blocks, f_bfree, f_bavail;
+	fsfilcnt_t f_files, f_ffree, f_favail;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+	unsigned long f_fsid;
+	unsigned :8*(2*sizeof(int)-sizeof(long));
+#else
+	unsigned :8*(2*sizeof(int)-sizeof(long));
+	unsigned long f_fsid;
+#endif
+	unsigned long f_flag, f_namemax;
+	int __reserved[6];
+};
+
+int statvfs (const char *__restrict, struct statvfs *__restrict);
+int fstatvfs (int, struct statvfs *);
+
+#define ST_RDONLY 1
+#define ST_NOSUID 2
+#define ST_NODEV  4
+#define ST_NOEXEC 8
+#define ST_SYNCHRONOUS 16
+#define ST_MANDLOCK    64
+#define ST_WRITE       128
+#define ST_APPEND      256
+#define ST_IMMUTABLE   512
+#define ST_NOATIME     1024
+#define ST_NODIRATIME  2048
+
+#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
+#define statvfs64 statvfs
+#define fstatvfs64 fstatvfs
+#define fsblkcnt64_t fsblkcnt_t
+#define fsfilcnt64_t fsfilcnt_t
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/sysmacros.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/sysmacros.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/sysmacros.h	(revision 279)
@@ -0,0 +1,15 @@
+#ifndef _SYS_SYSMACROS_H
+#define _SYS_SYSMACROS_H
+
+#define major(x) \
+	((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) ))
+#define minor(x) \
+	((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) ))
+
+#define makedev(x,y) ( \
+        (((x)&0xfffff000ULL) << 32) | \
+	(((x)&0x00000fffULL) << 8) | \
+        (((y)&0xffffff00ULL) << 12) | \
+	(((y)&0x000000ffULL)) )
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/termios.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/termios.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/termios.h	(revision 279)
@@ -0,0 +1,2 @@
+#warning redirecting incorrect #include <sys/termios.h> to <termios.h>
+#include <termios.h>
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/sys/un.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/sys/un.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/sys/un.h	(revision 279)
@@ -0,0 +1,32 @@
+#ifndef	_SYS_UN_H
+#define	_SYS_UN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_sa_family_t
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define __NEED_size_t
+#endif
+
+#include <bits/alltypes.h>
+
+struct sockaddr_un
+{
+	sa_family_t sun_family;
+	char sun_path[108];
+};
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+size_t strlen(const char *);
+#define SUN_LEN(s) (2+strlen((s)->sun_path))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/syslog.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/syslog.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/syslog.h	(revision 279)
@@ -0,0 +1,100 @@
+#ifndef _SYSLOG_H
+#define _SYSLOG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define LOG_EMERG   0
+#define LOG_ALERT   1
+#define LOG_CRIT    2
+#define LOG_ERR     3
+#define LOG_WARNING 4
+#define LOG_NOTICE  5
+#define LOG_INFO    6
+#define LOG_DEBUG   7
+
+#define LOG_PRIMASK 7
+#define LOG_PRI(p) ((p)&LOG_PRIMASK)
+#define	LOG_MAKEPRI(f, p) (((f)<<3)|(p))
+
+#define LOG_MASK(p) (1<<(p))
+#define LOG_UPTO(p) ((1<<((p)+1))-1)
+
+#define LOG_KERN     (0<<3)
+#define LOG_USER     (1<<3)
+#define LOG_MAIL     (2<<3)
+#define LOG_DAEMON   (3<<3)
+#define LOG_AUTH     (4<<3)
+#define LOG_SYSLOG   (5<<3)
+#define LOG_LPR      (6<<3)
+#define LOG_NEWS     (7<<3)
+#define LOG_UUCP     (8<<3)
+#define LOG_CRON     (9<<3)
+#define	LOG_AUTHPRIV (10<<3)
+#define	LOG_FTP      (11<<3)
+
+#define LOG_LOCAL0   (16<<3)
+#define LOG_LOCAL1   (17<<3)
+#define LOG_LOCAL2   (18<<3)
+#define LOG_LOCAL3   (19<<3)
+#define LOG_LOCAL4   (20<<3)
+#define LOG_LOCAL5   (21<<3)
+#define LOG_LOCAL6   (22<<3)
+#define LOG_LOCAL7   (23<<3)
+
+#define LOG_NFACILITIES 24
+#define LOG_FACMASK 0x3f8
+#define LOG_FAC(p) (((p)&LOG_FACMASK)>>3)
+
+#define LOG_PID    0x01
+#define LOG_CONS   0x02
+#define LOG_ODELAY 0x04
+#define LOG_NDELAY 0x08
+#define LOG_NOWAIT 0x10
+#define LOG_PERROR 0x20
+
+void closelog (void);
+void openlog (const char *, int, int);
+int setlogmask (int);
+void syslog (int, const char *, ...);
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define _PATH_LOG "/dev/log"
+#define __NEED_va_list
+#include <bits/alltypes.h>
+void vsyslog (int, const char *, va_list);
+#if defined(SYSLOG_NAMES)
+#define	INTERNAL_NOPRI 0x10
+#define	INTERNAL_MARK (LOG_NFACILITIES<<3)
+typedef struct {
+	char *c_name;
+	int c_val;
+} CODE;
+#define prioritynames ((CODE *)(const CODE []){ \
+	{ "alert", LOG_ALERT }, { "crit", LOG_CRIT }, { "debug", LOG_DEBUG }, \
+	{ "emerg", LOG_EMERG }, { "err", LOG_ERR }, { "error", LOG_ERR }, \
+	{ "info", LOG_INFO }, { "none", INTERNAL_NOPRI }, \
+	{ "notice", LOG_NOTICE }, { "panic", LOG_EMERG }, \
+	{ "warn", LOG_WARNING }, { "warning", LOG_WARNING }, { 0, -1 } })
+#define facilitynames ((CODE *)(const CODE []){ \
+	{ "auth", LOG_AUTH }, { "authpriv", LOG_AUTHPRIV }, \
+	{ "cron", LOG_CRON }, { "daemon", LOG_DAEMON }, { "ftp", LOG_FTP }, \
+	{ "kern", LOG_KERN }, { "lpr", LOG_LPR }, { "mail", LOG_MAIL }, \
+	{ "mark", INTERNAL_MARK }, { "news", LOG_NEWS }, \
+	{ "security", LOG_AUTH }, { "syslog", LOG_SYSLOG }, \
+	{ "user", LOG_USER }, { "uucp", LOG_UUCP }, \
+	{ "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, \
+	{ "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, \
+	{ "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, \
+	{ "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }, { 0, -1 } })
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/utmp.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/utmp.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/utmp.h	(revision 279)
@@ -0,0 +1,52 @@
+#ifndef _UTMP_H
+#define _UTMP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <utmpx.h>
+
+#define ACCOUNTING 9
+#define UT_NAMESIZE 32
+#define UT_HOSTSIZE 256
+#define UT_LINESIZE 32
+
+struct lastlog {
+	time_t ll_time;
+	char ll_line[UT_LINESIZE];
+	char ll_host[UT_HOSTSIZE];
+};
+
+#define ut_time ut_tv.tv_sec
+#define ut_name ut_user
+#define ut_addr ut_addr_v6[0]
+#define utmp utmpx
+#define utmpname(x) (-1)
+#define e_exit __e_exit
+#define e_termination __e_termination
+
+void         endutent(void);
+struct utmp *getutent(void);
+struct utmp *getutid(const struct utmp *);
+struct utmp *getutline(const struct utmp *);
+struct utmp *pututline(const struct utmp *);
+void         setutent(void);
+
+void updwtmp(const char *, const struct utmp *);
+
+int login_tty(int);
+
+#define _PATH_UTMP "/dev/null/utmp"
+#define _PATH_WTMP "/dev/null/wtmp"
+
+#define UTMP_FILE _PATH_UTMP
+#define WTMP_FILE _PATH_WTMP
+#define UTMP_FILENAME _PATH_UTMP
+#define WTMP_FILENAME _PATH_WTMP
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/musl-1.1.12/include/utmpx.h
===================================================================
--- /EcnlProtoTool/trunk/musl-1.1.12/include/utmpx.h	(revision 279)
+++ /EcnlProtoTool/trunk/musl-1.1.12/include/utmpx.h	(revision 279)
@@ -0,0 +1,62 @@
+#ifndef _UTMPX_H
+#define _UTMPX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+#define __NEED_pid_t
+#define __NEED_time_t
+#define __NEED_suseconds_t
+#define __NEED_struct_timeval
+
+#include <bits/alltypes.h>
+
+struct utmpx
+{
+	short ut_type;
+	pid_t ut_pid;
+	char ut_line[32];
+	char ut_id[4];
+	char ut_user[32];
+	char ut_host[256];
+	struct {
+		short __e_termination;
+		short __e_exit;
+	} ut_exit;
+	long ut_session;
+	struct timeval ut_tv;
+	unsigned ut_addr_v6[4];
+	char __unused__[20];
+};
+
+void          endutxent(void);
+struct utmpx *getutxent(void);
+struct utmpx *getutxid(const struct utmpx *);
+struct utmpx *getutxline(const struct utmpx *);
+struct utmpx *pututxline(const struct utmpx *);
+void          setutxent(void);
+
+#if defined(_BSD_SOURCE) | defined(_GNU_SOURCE)
+#define e_exit __e_exit
+#define e_termination __e_termination
+void updwtmpx(const char *, const struct utmpx *);
+#endif
+
+#define EMPTY           0
+#define RUN_LVL         1
+#define BOOT_TIME       2
+#define NEW_TIME        3
+#define OLD_TIME        4
+#define INIT_PROCESS    5
+#define LOGIN_PROCESS   6
+#define USER_PROCESS    7
+#define DEAD_PROCESS    8
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/ntshell/.Debuglinker
===================================================================
--- /EcnlProtoTool/trunk/ntshell/.Debuglinker	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/.Debuglinker	(revision 279)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="ASCII"?>
+<com.renesas.linkersection.model:SectionContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:com.renesas.linkersection.model="http:///LinkerSection.ecore">
+  <sections name=".fvectors" isKeep="true">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="537001984"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".fvectors"/>
+  </sections>
+  <sections name=".text">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="537002240"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".text"/>
+  </sections>
+  <sections name=".rvectors" isKeep="true">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.1"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_rvectors_start"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".rvectors"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_rvectors_end"/>
+  </sections>
+  <sections name=".init">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.2"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".init"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE_HIDDEN (__exidx_start = .)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE_HIDDEN (__exidx_end = .)"/>
+  </sections>
+  <sections name=".fini">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.3"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".fini"/>
+  </sections>
+  <sections name=".got">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.4"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".got"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".got.plt"/>
+  </sections>
+  <sections name=".rodata">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.5"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".rodata"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".rodata.*"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_erodata"/>
+  </sections>
+  <sections name=".eh_frame_hdr">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.6"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".eh_frame_hdr"/>
+  </sections>
+  <sections name=".eh_frame">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.7"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".eh_frame"/>
+  </sections>
+  <sections name=".jcr">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.8"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".jcr"/>
+  </sections>
+  <sections name=".tors">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.9"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__CTOR_LIST__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text=". = ALIGN(2)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__ctors"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".ctors"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__ctors_end"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__CTOR_END__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__DTOR_LIST__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="___dtors"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".dtors"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="___dtors_end"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__DTOR_END__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text=". = ALIGN(2)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_mdata"/>
+  </sections>
+  <sections name=".data">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="537264384"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_data"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".data"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_edata"/>
+    <reservedMemAddress xsi:type="com.renesas.linkersection.model:ReferencedLabelAddress" label="//@sections.10/@contents.12"/>
+  </sections>
+  <sections name=".bss">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.11"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE(__bss_start__ = .)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_bss"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".bss"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".bss.**"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name="COMMON"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE(__bss_end__ = .)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_ebss"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_end"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE(end = .)"/>
+  </sections>
+  <sections name=".stack" isNoLoad="true">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="537268480"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_stack"/>
+  </sections>
+</com.renesas.linkersection.model:SectionContainer>
Index: /EcnlProtoTool/trunk/ntshell/.cproject
===================================================================
--- /EcnlProtoTool/trunk/ntshell/.cproject	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/.cproject	(revision 279)
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="com.renesas.cdt.rz.debug.win32.configuration.Id.1970447541">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.renesas.cdt.rz.debug.win32.configuration.Id.1970447541" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactName="ntshell" buildArtefactType="com.renesas.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=com.renesas.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf *.lst *.lis *.lpp *.map libgcc.a" description="" id="com.renesas.cdt.rz.debug.win32.configuration.Id.1970447541" name="Debug" parent="com.renesas.cdt.rz.debug.win32.configuration.Id">
+					<folderInfo id="com.renesas.cdt.rz.debug.win32.configuration.Id.1970447541." name="/" resourcePath="">
+						<toolChain id="com.renesas.cdt.rz.debug.win32.toolchain.Id.1907999695" name="KPIT GNUARM-NONE-EABI Toolchain" superClass="com.renesas.cdt.rz.debug.win32.toolchain.Id">
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.PE" id="com.renesas.cdt.rz.debug.win32.targetplatform.Id.408835336" name="Target Platform" osList="all" superClass="com.renesas.cdt.rz.debug.win32.targetplatform.Id"/>
+							<builder buildPath="${workspace_loc:/ntshell}/Debug" id="com.renesas.cdt.rz.debug.win32.builder.Id.947208893" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Builder" superClass="com.renesas.cdt.rz.debug.win32.builder.Id"/>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.libgen.Id.763747626" name="Library Generator" superClass="com.renesas.cdt.rz.debug.win32.tool.libgen.Id">
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.ctype.1918511962" name="ctype.h : æå­ãæ±ããã§ãã¯ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.ctype" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.math.157552822" name="math.h : ä¸è§é¢æ°ãªã©æ°å¤ã®è¨ç®ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.math" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdio.973427400" name="stdio.h : å
+¥å/åºåãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdio" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdlib.1344168669" name="stdlib.h : æ ¼ç´é åã®ç®¡çãªã© C ãã­ã°ã©ã ã®æ¨æºå¦çãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdlib" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.string.252926687" name="string.h : æå­åã®æ¯è¼ã¨ã³ãã¼ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.string" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary.1454362058" name="ã©ã¤ãã©ãªã¼ã®é¸æ" superClass="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary" value="com.renesas.core.LibraryGenerator.option.selectLibrary.newLib" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.libraryType.1825440103" name="ã©ã¤ãã©ãªã¼å" superClass="com.renesas.cdt.core.LibraryGenerator.option.libraryType" value="com.renesas.cdt.core.LibraryGenerator.option.libraryType.projectBuilt" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc9.838682729" name="åé¢æ°ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-ffunction-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc9" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc14.849083341" name="é¢æ°ã®ã¢ãã¬ã¹ãã¬ã¸ã¹ã¿ã¼ã«ç½®ããªã (-fno-function-cse)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc14" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc36.2135621817" name="Parse the whole compilation unit before starting to produce code ( -funit-at-a-time)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc36" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc10.1922562819" name="åãã¼ã¿ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-fdata-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc10" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc37.304831421" name="Align branch targets to a power-of-two boundary (-falign-jumps)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc37" value="true" valueType="boolean"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.compiler.Id.1253383679" name="Compiler" superClass="com.renesas.cdt.rz.debug.win32.tool.compiler.Id">
+								<option defaultValue="true" id="com.renesas.cdt.core.Compiler.option.misc2.456149237" name="æ¨æºã·ã¹ãã ã»ãã£ã¬ã¯ããªã¼ã§ãããã¼ã»ãã¡ã¤ã«ãæ¤ç´¢ããªã (-nostdinc)" superClass="com.renesas.cdt.core.Compiler.option.misc2" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.architecture.276423772" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Compiler.option.architecture" value="com.renesas.cdt.rz.Debug.Compiler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.309771844" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.cpuType" value="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.420621560" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.1949489138" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.instructionset" value="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.interworking.1659726822" name="ã¤ã³ã¿ã¼ã»ã¯ã¼ã­ã³ã° (-mthumb-interwork)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.interworking" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.1301959251" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu" value="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.311785603" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.soft" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warnStackSize.1468097781" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.core.Compiler.option.warnStackSize" value="100" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.CPUSeries.1305202887" name="CPU ã·ãªã¼ãº" superClass="com.renesas.cdt.core.Compiler.option.CPUSeries" value="RZ/A" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.device.2055189613" name="Device" superClass="com.renesas.cdt.core.Compiler.option.device" value="R7S721001" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.deviceShortName.470114009" name="DeviceShortName" superClass="com.renesas.cdt.core.Compiler.option.deviceShortName" value="R7S721001" valueType="string"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines.1916097340" name="ãã¯ã­å®ç¾©" superClass="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="SIMULATOR_DEBUG"/>
+									<listOptionValue builtIn="false" value="CPPAPP"/>
+									<listOptionValue builtIn="false" value="TOPPERS_EXECUTE_ON_ROM"/>
+									<listOptionValue builtIn="false" value="__TARGET_ARCH_ARM=7"/>
+									<listOptionValue builtIn="false" value="TARGET_RZ_A1H"/>
+									<listOptionValue builtIn="false" value="TARGET_MBRZA1H"/>
+									<listOptionValue builtIn="false" value="TOOLCHAIN_GCC_ARM"/>
+									<listOptionValue builtIn="false" value="TOOLCHAIN_GCC"/>
+									<listOptionValue builtIn="false" value="TARGET_CORTEX_A"/>
+									<listOptionValue builtIn="false" value="MBED_BUILD_TIMESTAMP=1460441486.52"/>
+									<listOptionValue builtIn="false" value="TARGET_RENESAS"/>
+									<listOptionValue builtIn="false" value="__FPU_PRESENT"/>
+									<listOptionValue builtIn="false" value="TARGET_KERNEL_ASP"/>
+									<listOptionValue builtIn="false" value="SUPPORT_INET4"/>
+									<listOptionValue builtIn="false" value="SUPPORT_ETHER"/>
+									<listOptionValue builtIn="false" value="SUPPORT_TCP"/>
+									<listOptionValue builtIn="false" value="SUPPORT_UDP"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Compiler.option.includeFileDir.926492212" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Compiler.option.includeFileDir" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/include}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/target/gr_peach_gcc}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/arch/arm_gcc/rza1}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/arch/arm_gcc/common}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/arch/gcc}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/api}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/hal}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc/iodefines}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mruby-1.2.0/include}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ntshell/src}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/tinet/netdev/if_mbed}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/tinet}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/tecs_kernel}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ntshell/Debug}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ntshell/Debug/gen}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../webserver&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../gr_peach&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mrbgems/gr_peach/src}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../ntshell&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../ntshell/core&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/../ntshell/util&quot;"/>
+								</option>
+								<inputType id="%Base.Compiler.C.InputType.Id.312108612" name="C å
+¥å" superClass="%Base.Compiler.C.InputType.Id"/>
+								<inputType id="Base.Compiler.CPP.InputType.Id.978811450" name="C++ å
+¥å" superClass="Base.Compiler.CPP.InputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.assembler.Id.1960517010" name="Assembler" superClass="com.renesas.cdt.rz.debug.win32.tool.assembler.Id">
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.architecture.21595859" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Assembler.option.architecture" value="com.renesas.cdt.rz.Debug.Assembler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.1757814314" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.cpuType" value="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.862194071" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.965973474" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.instructionset" value="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu.2092155258" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu" value="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu.vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.534133882" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.soft" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Assembler.option.includeFileDirectories.1217360429" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Assembler.option.includeFileDirectories" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/src&quot;"/>
+								</option>
+								<inputType id="%Base.Assembler.inputType.Id.100478517" name="ã¢ã»ã³ãã©ã¼å
+¥åã¿ã¤ã" superClass="%Base.Assembler.inputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.linker.Id.1641698267" name="Linker" superClass="com.renesas.cdt.rz.debug.win32.tool.linker.Id">
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories.933303826" name="ã¢ã¼ã«ã¤ãæ¤ç´¢ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;${CONFIGDIR}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/lib/gcc/arm-none-eabi/${GCC_VERSION}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/arm-none-eabi/lib&quot;"/>
+								</option>
+								<option id="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.1743607303" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Linker.option.dataEndian" value="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.little" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles.1697871089" name="ã¢ã¼ã«ã¤ã ( ã©ã¤ãã©ãªã¼ ) ãã¡ã¤ã«" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles" valueType="stringList">
+									<listOptionValue builtIn="false" value="${BuildArtifactFileBaseName}"/>
+									<listOptionValue builtIn="false" value="gcc"/>
+									<listOptionValue builtIn="false" value="stdc++"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.userDefinedOptions.1395686154" name="ã¦ã¼ã¶ã¼å®ç¾©ãªãã·ã§ã³" superClass="com.renesas.cdt.core.Linker.option.userDefinedOptions" valueType="stringList">
+									<listOptionValue builtIn="false" value="-e_PowerON_Reset"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.linkOrderList.1409322238" name="" superClass="com.renesas.cdt.core.Linker.option.linkOrderList" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;.\src\interrupt_handlers.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\ntshell.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\vector_table.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\libntshell.a&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\hardware_setup.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\reset_program.o&quot;"/>
+								</option>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id.1528478689" name="Objcopy" superClass="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="ntshell.com.renesas.cdt.rz.projectType.win32.Id.1802081777" name="Executable (Renesas)" projectType="com.renesas.cdt.rz.projectType.win32.Id"/>
+	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+	<storageModule moduleId="refreshScope" versionNumber="2">
+		<configuration configurationName="Debug">
+			<resource resourceType="PROJECT" workspacePath="/ntshell"/>
+		</configuration>
+	</storageModule>
+</cproject>
Index: /EcnlProtoTool/trunk/ntshell/.info
===================================================================
--- /EcnlProtoTool/trunk/ntshell/.info	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/.info	(revision 279)
@@ -0,0 +1,7 @@
+TOOL_CHAIN=KPIT GNUARM-NONE-EABI Toolchain
+VERSION=v16.01
+TC_INSTALL=C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\
+GCC_STRING=5.2-GNUARM-NONE_v16.01
+VERSION_IDE=
+E2STUDIO_VERSION=5.3.1.002
+ACTIVE_CONFIGURATION=Debug
Index: /EcnlProtoTool/trunk/ntshell/.project
===================================================================
--- /EcnlProtoTool/trunk/ntshell/.project	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/.project	(revision 279)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ntshell</name>
+	<comment></comment>
+	<projects>
+		<project>asp3_dcre</project>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.renesas.cdt.core.genmakebuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>com.renesas.cdt.core.kpitcnature</nature>
+		<nature>com.renesas.cdt.core.kpitccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>
Index: /EcnlProtoTool/trunk/ntshell/Debug/Makefile
===================================================================
--- /EcnlProtoTool/trunk/ntshell/Debug/Makefile	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/Debug/Makefile	(revision 279)
@@ -0,0 +1,632 @@
+#
+#  TOPPERS/ASP Kernel
+#      Toyohashi Open Platform for Embedded Real-Time Systems/
+#      Advanced Standard Profile Kernel
+# 
+#  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: Makefile 735 2016-04-03 14:11:07Z ertl-hiro $
+# 
+
+#
+#  ã¿ã¼ã²ããã®æå®ï¼Makefile.targetã§ä¸æ¸ããããã®ãé²ãããï¼
+#
+all:
+
+#
+#  ã¿ã¼ã²ããç¥ç§°ã®å®ç¾©
+#
+TARGET = gr_peach_gcc
+
+#
+#  ãã­ã°ã©ãã³ã°è¨èªã®å®ç¾©
+#
+SRCLANG = c
+ifeq ($(SRCLANG),c)
+	LIBS = -lm -lc
+endif
+ifeq ($(SRCLANG),c++)
+	USE_CXX = true
+	CXXLIBS = -lstdc++ -lm -lc
+	CXXRTS = cxxrt.o newlibrt.o
+endif
+
+#
+#  ã½ã¼ã¹ãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+SRCDIR = ../../asp3_dcre
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®æ¡å¼µå­ã®è¨­å®
+#
+OBJEXT = elf
+
+#
+#  ã«ã¼ãã«ã©ã¤ãã©ãªï¼libkernel.aï¼ã®ãã£ã¬ã¯ããªå
+#  ï¼ã«ã¼ãã«ã©ã¤ãã©ãªãmakeå¯¾è±¡ã«ããæã¯ï¼ç©ºã«å®ç¾©ããï¼
+#
+KERNEL_LIB = ../../asp3_dcre/Debug
+
+#
+#  ã«ã¼ãã«ãé¢æ°åä½ã§ã³ã³ãã¤ã«ãããã©ããã®å®ç¾©
+#
+KERNEL_FUNCOBJS = 
+
+#
+#  TECSãå¤ããã©ããã®å®ç¾©
+#
+OMIT_TECS = 
+
+#
+#  ãã¬ã¼ã¹ã­ã°ãåå¾ãããã©ããã®å®ç¾©
+#
+ENABLE_TRACE = 
+
+#
+#  éçºãã¼ã«ï¼ã³ã³ãã¤ã©ç­ï¼ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+DEVTOOLDIR = 
+
+#
+#  ã¦ã¼ãã£ãªãã£ãã­ã°ã©ã ã®åç§°
+#
+CFG = ruby -Eutf-8 $(SRCDIR)/cfg/cfg.rb
+TECSGEN = ruby -Eutf-8 $(SRCDIR)/tecsgen/tecsgen.rb
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®å®ç¾©
+#
+OBJNAME = ntshell
+ifdef OBJEXT
+	OBJFILE = $(OBJNAME).$(OBJEXT)
+	CFG1_OUT = cfg1_out.$(OBJEXT)
+else
+	OBJFILE = $(OBJNAME)
+	CFG1_OUT = cfg1_out
+endif
+
+#
+#  ä¾å­é¢ä¿ãã¡ã¤ã«ãç½®ããã£ã¬ã¯ããªã®å®ç¾©
+#
+DEPDIR = deps
+
+#
+#  ã¿ã¼ã²ããä¾å­é¨ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+TARGETDIR = $(SRCDIR)/target/$(TARGET)
+
+#
+#  ã¿ã¼ã²ããä¾å­ã®å®ç¾©ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(TARGETDIR)/Makefile.target
+
+#
+#  TECSçæãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+TECSGENDIR = ./gen
+ifndef OMIT_TECS
+	TECSGEN_TIMESTAMP = $(TECSGENDIR)/tecsgen.timestamp
+	INIT_TECS_COBJ = init_tecs.o
+endif
+
+#
+#  TECSãçæããå®ç¾©ã®ã¤ã³ã¯ã«ã¼ã
+#
+ifndef OMIT_TECS
+	GEN_DIR = $(TECSGENDIR)
+	-include $(TECSGENDIR)/Makefile.tecsgen
+endif
+
+#
+#  mbedãµã¼ãã¹ã®å®ç¾©
+#
+
+include $(SRCDIR)/mbed/Makefile.mbed
+
+#
+#  å
+±éã³ã³ãã¤ã«ãªãã·ã§ã³ã®å®ç¾©
+#
+COPTS := -g -std=gnu99 $(COPTS)
+ifndef OMIT_WARNING_ALL
+	COPTS := -Wall $(COPTS)
+endif
+ifndef OMIT_OPTIMIZATION
+	COPTS := -Og $(COPTS)
+endif
+ifdef OMIT_TECS
+	CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
+endif
+CDEFS := $(CDEFS) -DFD_SETSIZE=32
+INCLUDES := -I. -I$(SRCDIR)/include $(INCLUDES) -I$(SRCDIR)
+LDFLAGS := $(LDFLAGS) -L. -Wl,-Map=$(OBJNAME).map,--cref
+LIBS := $(LIBS) $(CXXLIBS)
+CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
+
+#
+#  ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ã«é¢ããå®ç¾©
+#
+APPLNAME = ntshell
+APPLDIRS = ../src ../tlsf ../fatfs ../webserver ../ntshell ../ntshell/core ../ntshell/util
+APPL_CFG = main.cfg
+APPL_CDL = main.cdl
+
+APPL_DIRS := $(APPLDIRS) $(SRCDIR)/library
+APPL_ASMOBJS :=
+ifdef USE_CXX
+	APPL_CXXOBJS := main.o
+	APPL_COBJS := fdtable.o io_stub.o socket_stub.o ffarch.o time.o tlsf.o diskio.o ff.o sdfs.o ccsbcs.o base64.o http-strings.o http_parser.o httpd.o httpd-fs.o sha1.o websocket.o websocket_fbs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntstdio.o ntopt.o shellif.o
+else
+	APPL_COBJS := main.o fdtable.o io_stub.o socket_stub.o ffarch.o time.o tlsf.o diskio.o ff.o sdfs.o ccsbcs.o base64.o http-strings.o http_parser.o httpd.o httpd-fs.o sha1.o websocket.o websocket_fbs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntstdio.o ntopt.o shellif.o
+endif
+APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o
+APPL_BINOBJS := httpd_fs.o
+APPL_CFLAGS := $(APPL_CFLAGS)
+ifdef APPLDIRS
+	INCLUDES := $(INCLUDES) $(foreach dir,$(APPLDIRS),-I$(dir))
+endif
+
+#
+#  ãããã¯ã¼ã¯ãµã¼ãã¹ã®å®ç¾©
+#
+
+NO_USE_TINET_LIBRARY = true
+
+#  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãä½ããä¸ã¤é¸æããã
+
+NET_IF = ether
+
+#  ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ãã®é¸æ
+
+NET_DEV = if_mbed
+
+#  ãããã¯ã¼ã¯å±¤ã®é¸æ
+
+#SUPPORT_INET6 = true
+SUPPORT_INET4 = true
+
+#  API ã«çµè¾¼ãæ©è½ã®é¸æ
+
+#API_CFG_IP4MAPPED_ADDR = true
+
+#  ãã©ã³ã¹ãã¼ãå±¤ã®é¸æ
+
+SUPPORT_TCP = true
+SUPPORT_UDP = true
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/tinet/Makefile.tinet
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã«é¢ããå®ç¾©
+#
+SYSSVC_DIRS := $(TECSGENDIR) $(SRCDIR)/tecs_kernel \
+				$(SYSSVC_DIRS) $(SRCDIR)/syssvc
+SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)
+SYSSVC_COBJS := $(INIT_TECS_COBJ) $(TECS_COBJS) $(SYSSVC_COBJS) \
+				 $(CXXRTS)
+SYSSVC_CFLAGS := $(SYSSVC_CFLAGS)
+INCLUDES := $(INCLUDES) -I$(TECSGENDIR) -I$(SRCDIR)/tecs_kernel
+
+#
+#  ã¿ã¼ã²ãããã¡ã¤ã«
+#
+.PHONY: all
+ifndef OMIT_TECS
+all: tecs
+#	@$(MAKE) check
+	@$(MAKE) check $(OBJNAME).bin
+#	@$(MAKE) check $(OBJNAME).srec
+else
+#all: check
+all: check $(OBJNAME).bin
+#all: check $(OBJNAME).srec
+endif
+	ruby ../shellif.rb
+	$(OBJCOPY) -B arm -I binary -O elf32-littlearm --rename-section .data=.boot $(OBJNAME).bin $(OBJNAME)_bin.o
+
+##### ä»¥ä¸ã¯ç·¨éããªããã¨ #####
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã«é¢ããå®ç¾©
+#
+CFG_TABS := --api-table $(SRCDIR)/tinet/tcpip_api.def:tcpip \
+			--api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
+			--symval-table $(SRCDIR)/tinet/tcpip_sym.def \
+			--symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
+CFG_ASMOBJS := $(CFG_ASMOBJS)
+CFG_COBJS := kernel_cfg.o $(CFG_COBJS)
+CFG_OBJS := $(CFG_ASMOBJS) $(CFG_COBJS)
+CFG2_OUT_SRCS := kernel_cfg.h kernel_cfg.c $(CFG2_OUT_SRCS)
+CFG_CFLAGS := -DTOPPERS_CB_TYPE_ONLY $(CFG_CFLAGS)
+
+#
+#  ã«ã¼ãã«ã«é¢ããå®ç¾©
+#
+#  KERNEL_ASMOBJS: ã«ã¼ãã«ã©ã¤ãã©ãªã«å«ããï¼ã½ã¼ã¹ãã¢ã»ã³ããªè¨èªã®
+#				   ãªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#  KERNEL_COBJS: ã«ã¼ãã«ã®ã©ã¤ãã©ãªã«å«ããï¼ã½ã¼ã¹ãCè¨èªã§ï¼ã½ã¼ã¹
+#				 ãã¡ã¤ã«ã¨1å¯¾1ã«å¯¾å¿ãããªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#  KERNEL_LCSRCS: ã«ã¼ãã«ã®ã©ã¤ãã©ãªã«å«ããCè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ã§ï¼
+#				  1ã¤ã®ã½ã¼ã¹ãã¡ã¤ã«ããè¤æ°ã®ãªãã¸ã§ã¯ããã¡ã¤ã«ãç
+#				  æãããã®ï¼
+#  KERNEL_LCOBJS: ä¸ã®ã½ã¼ã¹ãã¡ã¤ã«ããçæããããªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#
+KERNEL_DIRS := $(KERNEL_DIRS) $(SRCDIR)/kernel
+KERNEL_ASMOBJS := $(KERNEL_ASMOBJS)
+KERNEL_COBJS := $(KERNEL_COBJS)
+KERNEL_CFLAGS := $(KERNEL_CFLAGS) -I$(SRCDIR)/kernel
+
+#
+#  ã«ã¼ãã«ã®ãã¡ã¤ã«æ§æã®å®ç¾©
+#
+include $(SRCDIR)/kernel/Makefile.kernel
+ifdef KERNEL_FUNCOBJS
+	KERNEL_LCSRCS := $(KERNEL_FCSRCS)
+	KERNEL_LCOBJS := $(foreach file,$(KERNEL_FCSRCS),$($(file:.c=)))
+else
+	KERNEL_CFLAGS := -DALLFUNC $(KERNEL_CFLAGS)
+	KERNEL_COBJS := $(KERNEL_COBJS) \
+					$(foreach file,$(KERNEL_FCSRCS),$(file:.c=.o))
+endif
+ifdef OMIT_OFFSET_H
+	OFFSET_H =
+else
+	OFFSET_H = offset.h
+endif
+ifndef TARGET_OFFSET_TRB
+	TARGET_OFFSET_TRB := $(TARGETDIR)/target_offset.trb
+endif
+ifndef TARGET_KERNEL_TRB
+	TARGET_KERNEL_TRB := $(TARGETDIR)/target_kernel.trb
+endif
+ifndef TARGET_CHECK_TRB
+	TARGET_CHECK_TRB := $(TARGETDIR)/target_check.trb
+endif
+ifndef TARGET_KERNEL_CFG
+	TARGET_KERNEL_CFG := $(TARGETDIR)/target_kernel.cfg
+endif
+ifndef TARGET_TCPIP_TRB
+	TARGET_TCPIP_TRB := $(SRCDIR)/tinet/tinet.trb
+endif
+
+#
+#  ã½ã¼ã¹ãã¡ã¤ã«ã®ãããã£ã¬ã¯ããªã«é¢ããå®ç¾©
+#
+vpath %.c $(KERNEL_DIRS) $(SYSSVC_DIRS) $(APPL_DIRS)
+vpath %.S $(KERNEL_DIRS) $(SYSSVC_DIRS) $(APPL_DIRS)
+vpath %.cfg $(APPL_DIRS)
+vpath %.cdl $(APPL_DIRS)
+vpath %.bin $(APPL_DIRS)
+
+#
+#  ã³ã³ãã¤ã«ã®ããã®å¤æ°ã®å®ç¾©
+#
+KERNEL_LIB_OBJS = $(KERNEL_ASMOBJS) $(KERNEL_COBJS) $(KERNEL_LCOBJS)
+SYSSVC_OBJS = $(SYSSVC_ASMOBJS) $(SYSSVC_COBJS)
+APPL_OBJS = $(APPL_ASMOBJS) $(APPL_COBJS) $(APPL_CXXOBJS) $(APPL_BINOBJS)
+ALL_OBJS = $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
+											$(END_OBJS) $(HIDDEN_OBJS)
+ALL_LIBS = -lkernel $(LIBS)
+ifdef KERNEL_LIB
+	LIBS_DEP = $(KERNEL_LIB)/libkernel.a $(filter %.a,$(LIBS))
+	OBJ_LDFLAGS := $(OBJ_LDFLAGS) -L$(KERNEL_LIB)
+	REALCLEAN_FILES := libkernel.a $(REALCLEAN_FILES)
+else
+	LIBS_DEP = libkernel.a $(filter %.a,$(LIBS))
+	OBJ_LDFLAGS := $(OBJ_LDFLAGS) -L.
+endif
+
+ifdef TEXT_START_ADDRESS
+	LDFLAGS := $(LDFLAGS) -Wl,-Ttext,$(TEXT_START_ADDRESS)
+endif
+ifdef DATA_START_ADDRESS
+	LDFLAGS := $(LDFLAGS) -Wl,-Tdata,$(DATA_START_ADDRESS)
+endif
+ifdef LDSCRIPT
+	LDFLAGS := $(LDFLAGS) -T $(LDSCRIPT)
+endif
+
+#
+#  tecsgenããCããªãã­ã»ããµãå¼ã³åºãéã®ãªãã·ã§ã³ã®å®ç¾©
+#
+TECS_CPP = $(CC) $(CDEFS) $(INCLUDES) $(SYSSVC_CFLAGS) -D TECSGEN -E
+
+#
+#  tecsgenã®å¼åºã
+#
+.PHONY: tecs
+tecs $(TECSGEN_SRCS) $(TECS_HEADERS): $(TECSGEN_TIMESTAMP) ;
+$(TECSGEN_TIMESTAMP): $(APPL_CDL) $(TECS_IMPORTS)
+	$(TECSGEN) $< -R $(INCLUDES) --cpp "$(TECS_CPP)" -g $(TECSGENDIR)
+
+#
+#  ã«ã¼ãã«ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®çæ
+#
+cfg1_out.c cfg1_out.db: cfg1_out.timestamp ;
+cfg1_out.timestamp: $(APPL_CFG) $(TECSGEN_TIMESTAMP)
+	$(CFG) --pass 1 --kernel asp $(INCLUDES) $(CFG_TABS) \
+						-M $(DEPDIR)/cfg1_out_c.d $(TARGET_KERNEL_CFG) $<
+
+$(CFG1_OUT): $(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS) $(HIDDEN_OBJS)
+	$(LINK) $(CFLAGS) $(LDFLAGS) $(CFG1_OUT_LDFLAGS) -o $(CFG1_OUT) \
+						$(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS)
+
+cfg1_out.syms: $(CFG1_OUT)
+	$(NM) -n $(CFG1_OUT) > cfg1_out.syms
+
+cfg1_out.srec: $(CFG1_OUT)
+	$(OBJCOPY) -O srec -S $(CFG1_OUT) cfg1_out.srec
+
+$(CFG2_OUT_SRCS) cfg2_out.db: kernel_cfg.timestamp ;
+kernel_cfg.timestamp: cfg1_out.db cfg1_out.syms cfg1_out.srec
+	$(CFG) --pass 2 --kernel asp $(INCLUDES) -T $(TARGET_TCPIP_TRB):tcpip -T $(TARGET_KERNEL_TRB):kernel
+
+#
+#  ãªãã»ãããã¡ã¤ã«ï¼offset.hï¼ã®çæè¦å
+#
+$(OFFSET_H): offset.timestamp ;
+offset.timestamp: cfg1_out.db cfg1_out.syms cfg1_out.srec
+	$(CFG) --pass 2 -O --kernel asp $(INCLUDES) -T $(TARGET_OFFSET_TRB) \
+				--rom-symbol cfg1_out.syms --rom-image cfg1_out.srec
+
+#
+#  ã«ã¼ãã«ã©ã¤ãã©ãªãã¡ã¤ã«ã®çæ
+#
+libkernel.a: $(OFFSET_H) $(KERNEL_LIB_OBJS)
+	rm -f libkernel.a
+	$(AR) -rcs libkernel.a $(KERNEL_LIB_OBJS)
+	$(RANLIB) libkernel.a
+
+#
+#  ç¹å¥ãªä¾å­é¢ä¿ã®å®ç¾©
+#
+tBannerMain.o: $(filter-out tBannerMain.o,$(ALL_OBJS)) $(LIBS_DEP)
+
+#
+#  å
+¨ä½ã®ãªã³ã¯
+#
+$(OBJFILE): $(ALL_OBJS) $(LIBS_DEP)
+	$(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \
+			$(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
+			$(ALL_LIBS) $(END_OBJS)
+
+#
+#  ã·ã³ãã«ãã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).syms: $(OBJFILE)
+	$(NM) -n $(OBJFILE) > $(OBJNAME).syms
+
+#
+#  ãã¤ããªãã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).bin: $(OBJFILE)
+	$(OBJCOPY) -O binary -R .nc_bss -S $(OBJFILE) $(OBJNAME).bin
+	$(OBJDUMP) -h $(OBJFILE)
+	$(SIZE) $(OBJFILE)
+
+#
+#  Sã¬ã³ã¼ããã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).srec: $(OBJFILE)
+	$(OBJCOPY) -O srec -S $(OBJFILE) $(OBJNAME).srec
+
+#
+#  ã¨ã©ã¼ãã§ãã¯å¦ç
+#
+.PHONY: check
+check: check.timestamp ;
+check.timestamp: cfg2_out.db $(OBJNAME).syms $(OBJNAME).srec
+	$(CFG) --pass 3 --kernel asp -O $(INCLUDES) -T $(TARGET_CHECK_TRB) \
+				--rom-symbol $(OBJNAME).syms --rom-image $(OBJNAME).srec
+	@echo "configuration check passed"
+
+#
+#  ã³ã³ãã¤ã«çµæã®æ¶å»
+#
+.PHONY: clean
+clean:
+	rm -f \#* *~ *.o $(DEPDIR)/*.d $(CLEAN_FILES) check.timestamp
+	rm -f $(OBJFILE) $(OBJNAME).syms $(OBJNAME).srec $(OBJNAME).bin
+	rm -f kernel_cfg.timestamp $(CFG2_OUT_SRCS) cfg2_out.db
+	rm -f offset.timestamp $(OFFSET_H)
+	rm -f cfg1_out.syms cfg1_out.srec $(CFG1_OUT)
+	rm -f cfg1_out.timestamp cfg1_out.c cfg1_out.db
+	rm -f $(TECSGENDIR)/*
+ifndef KERNEL_LIB
+	rm -f libkernel.a
+endif
+
+.PHONY: cleankernel
+cleankernel:
+	rm -f $(OFFSET_H) $(KERNEL_LIB_OBJS)
+	rm -f $(KERNEL_LIB_OBJS:%.o=$(DEPDIR)/%.d)
+
+.PHONY: realclean
+realclean: clean
+	rm -f $(REALCLEAN_FILES)
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãçæãããã¡ã¤ã«ã®ã³ã³ãã¤ã«ã«ã¼ã«ã®å®ç¾©
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãçæãããã¡ã¤ã«ã¯ï¼å
+±éã®ã³ã³ãã¤ã«ãªãã·ã§ã³
+#  ã®ã¿ãä»ãã¦ã³ã³ãã¤ã«ããï¼
+#
+ALL_CFG_COBJS = $(CFG_COBJS) cfg1_out.o
+ALL_CFG_ASMOBJS = $(CFG_ASMOBJS)
+
+$(ALL_CFG_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(CFG_CFLAGS) $<
+
+$(ALL_CFG_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(CFG_CFLAGS) $<
+
+$(ALL_CFG_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(CFG_CFLAGS) $<
+
+#
+#  ä¾å­é¢ä¿ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+#
+-include $(DEPDIR)/*.d
+
+#
+#  éçºãã¼ã«ã®ã³ãã³ãåã®å®ç¾©
+#
+ifeq ($(TOOL),gcc)
+	#
+	#  GNUéçºç°å¢ç¨
+	#
+	ifdef GCC_TARGET
+		GCC_TARGET_PREFIX = $(GCC_TARGET)-
+	else
+		GCC_TARGET_PREFIX =
+	endif
+	CC := $(GCC_TARGET_PREFIX)gcc
+	CXX := $(GCC_TARGET_PREFIX)g++
+	AS := $(GCC_TARGET_PREFIX)as
+	LD := $(GCC_TARGET_PREFIX)ld
+	AR := $(GCC_TARGET_PREFIX)ar
+	NM := $(GCC_TARGET_PREFIX)nm
+	RANLIB := $(GCC_TARGET_PREFIX)ranlib
+	OBJCOPY := $(GCC_TARGET_PREFIX)objcopy
+	OBJDUMP := $(GCC_TARGET_PREFIX)objdump
+	SIZE := $(GCC_TARGET_PREFIX)size
+endif
+
+ifdef DEVTOOLDIR
+	CC := $(DEVTOOLDIR)/$(CC)
+	CXX := $(DEVTOOLDIR)/$(CXX)
+	AS := $(DEVTOOLDIR)/$(AS)
+	LD := $(DEVTOOLDIR)/$(LD)
+	AR := $(DEVTOOLDIR)/$(AR)
+	NM := $(DEVTOOLDIR)/$(NM)
+	RANLIB := $(DEVTOOLDIR)/$(RANLIB)
+	OBJCOPY := $(DEVTOOLDIR)/$(OBJCOPY)
+	OBJDUMP := $(DEVTOOLDIR)/$(OBJDUMP)
+endif
+
+ifdef USE_CXX
+	LINK = $(CXX)
+else
+	LINK = $(CC)
+endif
+
+#
+#  ã³ã³ãã¤ã«ã«ã¼ã«ã®å®ç¾©
+#
+$(KERNEL_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_LCOBJS): %.o:
+	$(CC) -DTOPPERS_$(*F) -o $@ -c -MD -MP -MF $(DEPDIR)/$*.d \
+									$(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_LCOBJS:.o=.s): %.s:
+	$(CC) -DTOPPERS_$(*F) -o $@ -S $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(SYSSVC_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(SYSSVC_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(SYSSVC_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(APPL_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_CXXOBJS): %.o: %.cpp
+	$(CXX) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_CXXOBJS:.o=.s): %.s: %.cpp
+	$(CXX) -S $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_BINOBJS): %.o: %.bin
+	$(OBJCOPY) -B arm -I binary -O elf32-littlearm --rename-section .data=.rodata $< $*.o
+
+#
+#  ããã©ã«ãã³ã³ãã¤ã«ã«ã¼ã«ãä¸æ¸ã
+#
+%.o: %.c
+	@echo "*** Default compile rules should not be used."
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
+
+%.s: %.c
+	@echo "*** Default compile rules should not be used."
+	$(CC) -S $(CFLAGS) $<
+
+%.o: %.cpp
+	@echo "*** Default compile rules should not be used."
+	$(CXX) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
+
+%.s: %.cpp
+	@echo "*** Default compile rules should not be used."
+	$(CXX) -S $(CFLAGS) $<
+
+%.o: %.S
+	@echo "*** Default compile rules should not be used."
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
Index: /EcnlProtoTool/trunk/ntshell/fatfs/ccsbcs.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/ccsbcs.c	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/ccsbcs.c	(revision 279)
@@ -266,5 +266,5 @@
 
 
-#if !_TBLDEF || !_USE_LFN
+#if _CODE_PAGE != 65001 && (!_TBLDEF || !_USE_LFN)
 #error This file is not needed at current configuration. Remove from the project.
 #endif
@@ -272,5 +272,5 @@
 
 
-
+#if _CODE_PAGE != 65001
 WCHAR ff_convert (	/* Converted character, Returns zero on error */
 	WCHAR	chr,	/* Character code to be converted */
@@ -298,5 +298,5 @@
 	return c;
 }
-
+#endif
 
 
Index: /EcnlProtoTool/trunk/ntshell/fatfs/diskio.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/diskio.c	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/diskio.c	(revision 279)
@@ -15,5 +15,6 @@
 #define MAX_DRIVES	1	/* Max number of physical drives to be used */
 
-unsigned char RamDisk[SZ_RAMDISK * 1024];
+#define RamDisk _binary____webserver_httpd_fs_bin_start
+extern unsigned char RamDisk[];
 
 typedef struct {
Index: /EcnlProtoTool/trunk/ntshell/fatfs/ff.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/ff.c	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/ff.c	(revision 279)
@@ -314,4 +314,92 @@
 #endif
 #define _DF1S	0
+
+#elif _CODE_PAGE == 65001 /* UTF-8 */
+#if _LFN_UNICODE
+#error Cannot use LFN_UNICODE feature without valid code page.
+#endif
+#define _DF1S	0
+
+void Utf16_to_Utf8(unsigned char *ret_code, int *ret_size, UINT chr)
+{
+	ret_code[0] = ret_code[1] = ret_code[2] = ret_code[3] = 0;
+
+	if (chr <= 0x7f) {  // ASCIIäºæ
+		ret_code[0] = chr;
+		*ret_size = 1;
+		return;
+	}
+
+	if (chr <= 0x7ff) {
+		ret_code[1] = (0x80 | (chr & 0x3f));
+		ret_code[0] = (0xc0 | (chr >> 6));
+		*ret_size = 2;
+		return;
+	}
+
+	if (chr <= 0xffff) {
+		ret_code[2] = (0x80 | (chr & 0x3f));
+		ret_code[1] = (0x80 | ((chr >> 6) & 0x3f));
+		ret_code[0] = (0xe0 | ((chr >> 12) & 0x0f));
+		*ret_size = 3;
+		return;
+	}
+
+	if (chr <= 0x1fffff) {
+		ret_code[3] = (0x80 | (chr & 0x3f));
+		ret_code[2] = (0x80 | ((chr >> 6) & 0x3f));
+		ret_code[1] = (0x80 | ((chr >> 12) & 0x3f));
+		ret_code[0] = (0xf0 | ((chr >> 18) & 0x07));
+		*ret_size = 4;
+		return;
+	}
+
+	if (chr <= 0x3ffffff) {
+		ret_code[4] = (0x80 | (chr & 0x3f));
+		ret_code[3] = (0x80 | ((chr >> 6) & 0x3f));
+		ret_code[2] = (0x80 | ((chr >> 12) & 0x3f));
+		ret_code[1] = (0x80 | ((chr >> 18) & 0x3f));
+		ret_code[0] = (0xf8 | ((chr >> 24) & 0x03));
+		*ret_size = 5;
+		return;
+	}
+
+	ret_code[5] = (0x80 | (chr & 0x3f));
+	ret_code[4] = (0x80 | ((chr >> 6) & 0x3f));
+	ret_code[3] = (0x80 | ((chr >> 12) & 0x3f));
+	ret_code[2] = (0x80 | ((chr >> 18) & 0x3f));
+	ret_code[1] = (0x80 | ((chr >> 24) & 0x3f));
+	ret_code[0] = (0xfc | ((chr >> 30) & 0x01));
+	*ret_size = 6;
+	return;
+}
+
+//2ãã¤ãã®UTF-16ã³ã¼ããå¾ããã
+WCHAR Utf8_to_Utf16(const char *src, int *code_size)
+{
+	int i;
+	unsigned int uc = 0;
+	unsigned char len = 0;
+
+	len = 0;
+	if ((src[0] & 0x80) == 0) { uc = src[0] & 0x7F; len = 0; }
+	else if ((src[0] & 0xE0) == 0xC0) { uc = src[0] & 0x1F; len = 1; }
+	else if ((src[0] & 0xF0) == 0xE0) { uc = src[0] & 0x0F; len = 2; }
+	else if ((src[0] & 0xF8) == 0xF0) { uc = src[0] & 0x07; len = 3; }
+	else if ((src[0] & 0xFC) == 0xF8) { uc = src[0] & 0x03; len = 4; }
+	else if ((src[0] & 0xFE) == 0xFC) { uc = src[0] & 0x01; len = 5; }
+
+	i = 1;
+	while ((i <= len) && ((src[i] & 0xC0) == 0x80)) {
+		uc = (uc << 6) | (src[i] & 0x3F);
+		i++;
+	}
+
+	//æ¶è²»æå­æ°è¨­å®
+	*code_size = i;
+
+	//ç¾ç¶ã2ãã¤ãéå®
+	return uc;
+}
 
 #else
@@ -1712,4 +1800,8 @@
 	WCHAR w, *lfn;
 #endif
+#if _CODE_PAGE == 65001
+	unsigned char utf8_code[6];
+	int code_size;
+#endif
 
 	p = fno->fname;
@@ -1748,4 +1840,11 @@
 			while ((w = *lfn++) != 0) {		/* Get an LFN character */
 #if !_LFN_UNICODE
+#if _CODE_PAGE == 65001
+				Utf16_to_Utf8(utf8_code, &code_size, w);
+				for (int j = 0; j < code_size - 1; j++) {
+					p[i++] = utf8_code[j];
+				}
+				w = utf8_code[code_size - 1];
+#else
 				w = ff_convert(w, 0);		/* Unicode -> OEM */
 				if (!w) { i = 0; break; }	/* No LFN if it could not be converted */
@@ -1753,4 +1852,5 @@
 					p[i++] = (TCHAR)(w >> 8);
 #endif
+#endif
 				if (i >= fno->lfsize - 1) { i = 0; break; }	/* No LFN if buffer overflow */
 				p[i++] = (TCHAR)w;
@@ -1778,8 +1878,14 @@
 
 #if !_LFN_UNICODE
+#if _CODE_PAGE == 65001
+	int code_size;
+	chr = Utf8_to_Utf16(*ptr, &code_size);
+	(*ptr) += code_size;
+#else
 	chr = (BYTE)*(*ptr)++;					/* Get a byte */
 	if (IsLower(chr)) chr -= 0x20;			/* To upper ASCII char */
 	if (IsDBCS1(chr) && IsDBCS2(**ptr))		/* Get DBC 2nd byte if needed */
 		chr = chr << 8 | (BYTE)*(*ptr)++;
+#endif
 #ifdef _EXCVT
 	if (chr >= 0x80) chr = ExCvt[chr - 0x80];	/* To upper SBCS extended char */
@@ -1851,5 +1957,8 @@
 	UINT i, ni, si, di;
 	const TCHAR *p;
-
+#if _CODE_PAGE == 65001
+	char utf8_code[6];
+	int code_size;
+#endif
 	/* Create LFN in Unicode */
 	for (p = *path; *p == '/' || *p == '\\'; p++) ;	/* Strip duplicated separator */
@@ -1862,4 +1971,8 @@
 			return FR_INVALID_NAME;
 #if !_LFN_UNICODE
+#if _CODE_PAGE == 65001
+		w = Utf8_to_Utf16(&p[si - 1], &code_size);
+		si += code_size - 1;
+#else
 		w &= 0xFF;
 		if (IsDBCS1(w)) {				/* Check if it is a DBC 1st byte (always false on SBCS cfg) */
@@ -1871,4 +1984,5 @@
 		w = ff_convert(w, 1);			/* Convert ANSI/OEM to Unicode */
 		if (!w) return FR_INVALID_NAME;	/* Reject invalid code */
+#endif
 #endif
 		if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */
@@ -1925,9 +2039,43 @@
 			if (w) w = ExCvt[w - 0x80];	/* Convert extended character to upper (SBCS) */
 #else
+#if _CODE_PAGE == 65001
+			Utf16_to_Utf8(utf8_code, &code_size, ff_wtoupper(w));
+#else
 			w = ff_convert(ff_wtoupper(w), 0);	/* Upper converted Unicode -> OEM code */
 #endif
+#endif
 			cf |= NS_LFN;				/* Force create LFN entry */
 		}
-
+#if _CODE_PAGE == 65001
+		else
+			code_size = 1;
+#endif
+
+#if _CODE_PAGE == 65001
+		if (code_size > 1) {		/* Is this DBC? (always false at SBCS cfg) */
+			if (i >= ni - 1) {
+				cf |= NS_LOSS | NS_LFN; i = ni; continue;
+			}
+			for (int j = 0; j < code_size; j++) {
+				dp->fn[i++] = (BYTE)utf8_code[j];
+			}
+		}
+		else {						/* SBC */
+			if (!w || chk_chr("+,;=[]", w)) {	/* Replace illegal characters for SFN */
+				w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */
+			}
+			else {
+				if (IsUpper(w)) {		/* ASCII large capital */
+					b |= 2;
+				}
+				else {
+					if (IsLower(w)) {	/* ASCII small capital */
+						b |= 1; w -= 0x20;
+					}
+				}
+			}
+			dp->fn[i++] = (BYTE)w;
+		}
+#else
 		if (_DF1S && w >= 0x100) {		/* Is this DBC? (always false at SBCS cfg) */
 			if (i >= ni - 1) {
@@ -1949,4 +2097,5 @@
 		}
 		dp->fn[i++] = (BYTE)w;
+#endif
 	}
 
@@ -3178,5 +3327,17 @@
 }
 
-
+FRESULT f_seek(FIL* fp, DWORD ofs, BYTE mode)
+{
+  switch (mode) {
+  case F_SEEK_SET:
+    return f_lseek((fp), ofs);
+  case F_SEEK_CUR:
+    return f_lseek((fp), (fp)->fptr + ofs);
+  case F_SEEK_END:
+    return f_lseek((fp), (fp)->fsize - ofs);
+  default:
+    return FR_INVALID_PARAMETER;
+  }
+}
 
 #if _FS_MINIMIZE <= 1
@@ -3719,4 +3880,5 @@
 	DWORD dw;
 	DEFINE_NAMEBUF;
+	TCHAR *temp_new_path = 0;
 
 
@@ -3742,5 +3904,13 @@
 				else
 					res = FR_INVALID_DRIVE;
-				if (res == FR_OK) res = FR_EXIST;		/* The new object name is already existing */
+				if (res == FR_OK) {
+					res = FR_EXIST;		/* The new object name is already existing */
+					dir = djn.dir;
+					if (dir[DIR_Attr] & AM_DIR) {	/* The new object is a directory */
+						temp_new_path = (TCHAR *)ff_memalloc((_MAX_LFN + 1) * sizeof(WCHAR));
+						snprintf(temp_new_path, _MAX_LFN, "%s/%s", path_new, basename((char *)path_old));
+						res = follow_path(&djn, temp_new_path);
+					}
+				}
 				if (res == FR_NO_FILE) { 				/* It is a valid path and no name collision */
 					res = dir_register(&djn);			/* Register the new entry */
@@ -3777,4 +3947,6 @@
 	}
 
+	if (temp_new_path != 0)	ff_memfree(temp_new_path);
+
 	LEAVE_FF(djo.fs, res);
 }
@@ -3912,5 +4084,8 @@
 	WCHAR w;
 	DWORD tm;
-
+#if _CODE_PAGE == 65001
+	int code_size;
+	char utf8_code[6];
+#endif
 
 	/* Get logical drive number */
@@ -3925,4 +4100,13 @@
 		i = j = 0;
 		do {
+#if _CODE_PAGE == 65001
+			w = ff_wtoupper(Utf8_to_Utf16(&label[i], &code_size));
+			i += code_size;
+			Utf16_to_Utf8(utf8_code, &code_size, w);
+			if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= sizeof(vn) - code_size) /* Reject invalid characters for volume label */
+				LEAVE_FF(dj.fs, FR_INVALID_NAME);
+			for (int k = 0; k < code_size; k++)
+				vn[j++] = utf8_code[k];
+#else
 #if _USE_LFN && _LFN_UNICODE
 			w = ff_convert(ff_wtoupper(label[i++]), 0);
@@ -3946,4 +4130,5 @@
 			if (w >= 0x100) vn[j++] = (BYTE)(w >> 8);
 			vn[j++] = (BYTE)w;
+#endif
 		} while (i < sl);
 		while (j < 11) vn[j++] = ' ';	/* Fill remaining name field */
Index: /EcnlProtoTool/trunk/ntshell/fatfs/ff.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/ff.h	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/ff.h	(revision 279)
@@ -143,5 +143,5 @@
 /* Directory object structure (DIR) */
 
-typedef struct {
+typedef struct __dirstream {
 	FATFS*	fs;				/* Pointer to the owner file system object (**do not change order**) */
 	WORD	id;				/* Owner file system mount ID (**do not change order**) */
@@ -162,4 +162,5 @@
 	const TCHAR*	pat;	/* Pointer to the name matching pattern */
 #endif
+	struct dirent *dirent;
 } DIR;
 
@@ -252,22 +253,10 @@
 #define f_rewind(fp) f_lseek((fp), 0)
 #define f_rewinddir(dp) f_readdir((dp), 0)
-#define f_flush(fp)
+#define f_flush(fp) (FR_OK)
 
 #define F_SEEK_SET 1
 #define F_SEEK_CUR 2
 #define F_SEEK_END 3
-static FRESULT f_seek(FIL* fp, DWORD ofs, BYTE mode)
-{
-  switch (mode) {
-  case F_SEEK_SET:
-    return f_lseek((fp), ofs);
-  case F_SEEK_CUR:
-    return f_lseek((fp), (fp)->fptr + ofs);
-  case F_SEEK_END:
-    return f_lseek((fp), (fp)->fsize - ofs);
-  default:
-    return FR_INVALID_PARAMETER;
-  }
-}
+FRESULT f_seek(FIL* fp, DWORD ofs, BYTE mode);
 
 #ifndef EOF
Index: /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.c	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.c	(revision 279)
@@ -56,8 +56,7 @@
 #include <kernel.h>
 #include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
 #include <string.h>
 #include "t_stdlib.h"
+#include "syssvc/serial.h"
 #include "syssvc/syslog.h"
 #include "kernel_cfg.h"
@@ -65,4 +64,16 @@
 #include "sdfs.h"
 #include "ff.h"
+#include "tlsf.h"
+#include "ntstdio.h"
+
+#define SIO_PORTID 1
+extern ntstdio_t ntstdio;
+
+static tlsf_t sys_tlsf;
+static pool_t sys_pool;
+
+uint32_t  __HeapBase;
+uint32_t  __HeapLimit;
+FATFS RomDisk;
 
 gpio_t ins;
@@ -70,12 +81,20 @@
 #define WP() false
 
-extern FATFS RomDisk;
-extern unsigned char RamDisk[SZ_RAMDISK * 1024];
-
+typedef struct SD {
+	DSTATUS dst;
+	BYTE type;
+	FATFS FatFs;
+} SD;
+SD Sd;
+
+void sys_init(void);
 bool_t romdisk_init();
+bool_t SD_begin();
 
 int mruby_arduino_init()
 {
 	int result = -1;
+
+	sys_init();
 
 	/* SD_CD */
@@ -85,26 +104,65 @@
 	sdfs_init(&sdfs, P8_5, P8_6, P8_3, P8_4, "sd");
 
-	SD_begin();
-
-	FIL fd;
-	UINT rlen = 0;
-	memset(&fd, 0, sizeof(fd));
-	if (f_open(&fd, "1:/httpd-fs.bin", FA_OPEN_EXISTING | FA_READ) == FR_OK) {
-		f_read(&fd, RamDisk, SZ_RAMDISK * 1024, &rlen);
-		f_close(&fd);
-		if (romdisk_init())
-			result = 0;
-	}
-
+	result = SD_begin() ? 0 : -1;
 	if (result == 0) {
-		syslog(LOG_NOTICE, "ramdisk ok!");
+		ntstdio_printf(&ntstdio, "SD card (1:) OK!\n");
 	}
 	else {
-		syslog(LOG_NOTICE, "ramdisk ng!");
-	}
-
-	arduino_init();
+		ntstdio_printf(&ntstdio, "SD card (1:) NG!\n");
+	}
+	sta_cyc(SDFS_CYC);
+
+	if (romdisk_init())
+		result = 0;
+
+	if (result == 0) {
+		ntstdio_printf(&ntstdio, "ROM disk (0:) OK!\n");
+	}
+	else {
+		ntstdio_printf(&ntstdio, "ROM disk (0:) NG!\n");
+	}
+
+	/* uploadãã£ã¬ã¯ããªãä½æãã¦ãã */
+	f_mkdir("1:/upload");
+
+	serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
 
 	return result;
+}
+
+void sys_init(void)
+{
+	sys_tlsf = tlsf_create(&__HeapBase);
+	if (sys_tlsf == NULL)
+		return;
+
+	sys_pool = tlsf_add_pool(sys_tlsf, ((uint8_t *)&__HeapBase) + tlsf_size(), ((size_t)&__HeapLimit - (size_t)&__HeapBase) - tlsf_size());
+}
+
+void sys_fini(void)
+{
+	tlsf_destroy(sys_tlsf);
+}
+
+void *sys_malloc(size_t size)
+{
+	return tlsf_malloc(sys_tlsf, size);
+}
+
+void *sys_calloc(size_t size, size_t count)
+{
+	void *result = tlsf_malloc(sys_tlsf, count * size);
+	memset(result, 0, count * size);
+	return result;
+}
+
+void *sys_realloc(void *ptr, size_t size)
+{
+	return tlsf_realloc(sys_tlsf, ptr, size);
+}
+
+void sys_free(void *ptr)
+{
+	tlsf_free(sys_tlsf, ptr);
 }
 
@@ -122,4 +180,33 @@
 
 	if ((res = f_mount(&RomDisk, "0:", 1)) != FR_OK) {
+		return false;
+	}
+
+	return true;
+}
+
+bool_t SD_begin()
+{
+	DSTATUS dst;
+	FRESULT res;
+	BYTE pdrv = 1, type;
+
+	if (Sd.FatFs.fs_type != 0)
+		return true;
+
+	if ((dst = disk_initialize(pdrv)) != RES_OK) {
+		return false;
+	}
+
+	if ((dst = disk_ioctl(pdrv, MMC_GET_TYPE, &type)) != RES_OK) {
+		Sd.dst = dst;
+		Sd.type = 0;
+	}
+	else {
+		Sd.dst = RES_OK;
+		Sd.type = type;
+	}
+
+	if ((res = f_mount(&Sd.FatFs, "1:", 1)) != FR_OK) {
 		return false;
 	}
@@ -207,122 +294,33 @@
 }
 
-static int lock[TNUM_TSKID];
-static int stack_pos[TNUM_TSKID];
-
-void __malloc_lock(struct _reent *a)
-{
-	ID tskid;
+int ff_cre_syncobj(BYTE vol, _SYNC_t* sobj)
+{
+	return 1;
+}
+
+int ff_req_grant(_SYNC_t sobj)
+{
 	ER ret;
-	int count, sp;
-
-	ret = get_tid(&tskid);
-	if (ret != E_OK) {
-		/*syslog(LOG_DEBUG, "get_tid %s", itron_strerror(ret));*/
-		Asm("bkpt #0");
-	}
-
-	Asm("mov %0, sp" : "=r"(sp) :);
-	if ((stack_pos[tskid - 1] == 0) || (stack_pos[tskid - 1] < sp))
-		stack_pos[tskid - 1] = sp;
-
-	count = ++lock[tskid - 1];
-	if (count != 1)
-		return;
-
-	ret = wai_sem(SEM_MALLOC);
-	if (ret != E_OK) {
-		/*syslog(LOG_DEBUG, "wai_sem %s", itron_strerror(ret));*/
-		Asm("bkpt #0");
-	}
-}
-
-void __malloc_unlock(struct _reent *a)
-{
-	ID tskid;
-	ER ret;
-	int count;
-
-	ret = get_tid(&tskid);
-	if (ret != E_OK) {
-		/*syslog(LOG_DEBUG, "get_tid %s", itron_strerror(ret));*/
-		Asm("bkpt #0");
-	}
-
-	count = --lock[tskid - 1];
-	if(count != 0)
-		return;
-
-	ret = sig_sem(SEM_MALLOC);
-	if (ret != E_OK) {
-		/*syslog(LOG_DEBUG, "sig_sem %s", itron_strerror(ret));*/
-		Asm("bkpt #0");
-	}
-}
-
-// Provide implementation of _sbrk (low-level dynamic memory allocation
-// routine) for GCC_ARM which compares new heap pointer with MSP instead of
-// SP.  This make it compatible with RTX RTOS thread stacks.
-
-// Linker defined symbol used by _sbrk to indicate where heap should start.
-int __end__;
-uint32_t  __HeapLimit;
-
-// Turn off the errno macro and use actual global variable instead.
-#undef errno
-int errno;
-
-static unsigned char* heap = (unsigned char*)&__end__;
-
-// Dynamic memory allocation related syscall.
-caddr_t _sbrk(int incr) {
-	unsigned char*        prev_heap = heap;
-	unsigned char*        new_heap = heap + incr;
-
-	if (new_heap >= (unsigned char*)&__HeapLimit) {     /* __HeapLimit is end of heap section */
-		errno = ENOMEM;
-		return (caddr_t)-1;
-	}
-
-	heap = new_heap;
-	return (caddr_t) prev_heap;
-}
-
-void reset_heap()
-{
-	// .data
-	extern uint8_t __malloc_av_[0x408];
-	extern uint8_t __malloc_sbrk_base[0x4];
-	extern uint8_t __malloc_trim_threshold[0x4];
-	// .bss
-	extern uint8_t __malloc_top_pad[0x4];
-	extern uint8_t __malloc_current_mallinfo[0x28];
-	extern uint8_t __malloc_max_sbrked_mem[0x4];
-	extern uint8_t __malloc_max_total_mem[0x4];
-	//
-	extern void *__etext;
-	extern void *__data_start__;
-
-	int offset = (int)&__etext - (int)&__data_start__;
-
-	__malloc_lock(_REENT);
-
-	memcpy(__malloc_av_, &__malloc_av_[offset], sizeof(__malloc_av_));
-	memcpy(__malloc_sbrk_base, &__malloc_sbrk_base[offset], sizeof(__malloc_sbrk_base));
-	memcpy(__malloc_trim_threshold, &__malloc_trim_threshold[offset], sizeof(__malloc_trim_threshold));
-
-	memset(__malloc_top_pad, 0, sizeof(__malloc_top_pad));
-	memset(__malloc_current_mallinfo, 0, sizeof(__malloc_current_mallinfo));
-	memset(__malloc_max_sbrked_mem, 0, sizeof(__malloc_max_sbrked_mem));
-	memset(__malloc_max_total_mem, 0, sizeof(__malloc_max_total_mem));
-
-	heap = (unsigned char*)&__end__;
-
-	__malloc_unlock(_REENT);
-}
-
-void exit(int return_code) {
-	Asm("bkpt #0");
-	reset_heap();
-	ext_tsk();
-	for(;;);
-}
+	ret = wai_sem(SEM_FILESYSTEM);
+	return ret == E_OK;
+}
+
+void ff_rel_grant(_SYNC_t sobj)
+{
+	sig_sem(SEM_FILESYSTEM);
+}
+
+int ff_del_syncobj(_SYNC_t sobj)
+{
+	return 1;
+}
+
+void* ff_memalloc (UINT msize)
+{
+	return sys_malloc(msize);
+}
+
+void ff_memfree (void* mblock)
+{
+	sys_free(mblock);
+}
Index: /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.cfg
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.cfg	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.cfg	(revision 279)
@@ -51,7 +51,7 @@
  */
 
-#include "mruby_arduino.h"
+#include "ffarch.h"
 
-CRE_CYC(SDFS_CYC, { TA_NULL, { TNFY_HANDLER, 0, sdfs_cychdr }, 1000, 0 });
+CRE_CYC(SDFS_CYC, { TA_NULL, { TNFY_HANDLER, 0, sdfs_cychdr }, 1000000, 0 });
 
 CRE_SEM(SEM_MALLOC, { TA_TPRI, 1, 1 });
Index: /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.h	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/ffarch.h	(revision 279)
@@ -54,5 +54,4 @@
 
 int mruby_arduino_init();
-void reset_heap();
 void sdfs_cychdr(intptr_t exinf);
 
Index: /EcnlProtoTool/trunk/ntshell/fatfs/ffconf.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/ffconf.h	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/ffconf.h	(revision 279)
@@ -62,5 +62,5 @@
 /---------------------------------------------------------------------------*/
 
-#define _CODE_PAGE 437
+#define _CODE_PAGE 65001
 /* This option specifies the OEM code page to be used on the target system.
 /  Incorrect setting of the code page can cause a file open failure.
@@ -91,5 +91,5 @@
 
 
-#define	_USE_LFN	1
+#define	_USE_LFN	3
 #define	_MAX_LFN	255
 /* The _USE_LFN option switches the LFN feature.
@@ -227,7 +227,7 @@
 
 
-#define _FS_REENTRANT	0
+#define _FS_REENTRANT	1
 #define _FS_TIMEOUT		1000
-#define	_SYNC_t			HANDLE
+#define	_SYNC_t			unsigned int
 /* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
 /  module itself. Note that regardless of this option, file access to different
Index: /EcnlProtoTool/trunk/ntshell/fatfs/time.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/fatfs/time.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/fatfs/time.c	(revision 279)
@@ -0,0 +1,269 @@
+/* musl-1.1.12/src/time/*.c */
+/* musl as a whole is licensed under the following standard MIT license:
+*
+* ----------------------------------------------------------------------
+* Copyright (C) 2005-2014 Rich Felker, et al.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to deal in the Software without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to
+* permit persons to whom the Software is furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+* ----------------------------------------------------------------------*/
+#include <string.h>
+#include <limits.h>
+#include <time.h>
+#include <errno.h>
+#include "ff.h"
+
+/* 2000-03-01 (mod 400 year, immediately after feb29 */
+#define LEAPOCH (946684800LL + 86400*(31+29))
+
+#define DAYS_PER_400Y (365*400 + 97)
+#define DAYS_PER_100Y (365*100 + 24)
+#define DAYS_PER_4Y   (365*4   + 1)
+
+int __secs_to_tm(long long t, struct tm* tm)
+{
+	long long days, secs, years;
+	int remdays, remsecs, remyears;
+	int qc_cycles, c_cycles, q_cycles;
+	int months;
+	int wday, yday, leap;
+	static const char days_in_month[] = {31,30,31,30,31,31,30,31,30,31,31,29};
+
+	/* Reject time_t values whose year would overflow int */
+	if (t < INT_MIN * 31622400LL || t > INT_MAX * 31622400LL)
+		return -1;
+
+	secs = t - LEAPOCH;
+	days = secs / 86400;
+	remsecs = secs % 86400;
+	if (remsecs < 0) {
+		remsecs += 86400;
+		days--;
+	}
+
+	wday = (3 + days) % 7;
+	if (wday < 0) wday += 7;
+
+	qc_cycles = days / DAYS_PER_400Y;
+	remdays = days % DAYS_PER_400Y;
+	if (remdays < 0) {
+		remdays += DAYS_PER_400Y;
+		qc_cycles--;
+	}
+
+	c_cycles = remdays / DAYS_PER_100Y;
+	if (c_cycles == 4) c_cycles--;
+	remdays -= c_cycles * DAYS_PER_100Y;
+
+	q_cycles = remdays / DAYS_PER_4Y;
+	if (q_cycles == 25) q_cycles--;
+	remdays -= q_cycles * DAYS_PER_4Y;
+
+	remyears = remdays / 365;
+	if (remyears == 4) remyears--;
+	remdays -= remyears * 365;
+
+	leap = !remyears && (q_cycles || !c_cycles);
+	yday = remdays + 31 + 28 + leap;
+	if (yday >= 365 + leap) yday -= 365 + leap;
+
+	years = remyears + 4 * q_cycles + 100 * c_cycles + 400LL * qc_cycles;
+
+	for (months = 0; days_in_month[months] <= remdays; months++)
+		remdays -= days_in_month[months];
+
+	if (years + 100 > INT_MAX || years + 100 < INT_MIN)
+		return -1;
+
+	tm->tm_year = years + 100;
+	tm->tm_mon = months + 2;
+	if (tm->tm_mon >= 12) {
+		tm->tm_mon -= 12;
+		tm->tm_year++;
+	}
+	tm->tm_mday = remdays + 1;
+	tm->tm_wday = wday;
+	tm->tm_yday = yday;
+
+	tm->tm_hour = remsecs / 3600;
+	tm->tm_min = remsecs / 60 % 60;
+	tm->tm_sec = remsecs % 60;
+
+	return 0;
+}
+
+long long __year_to_secs(long long year, int *is_leap)
+{
+	if (year - 2ULL <= 136) {
+		int y = year;
+		int leaps = (y - 68) >> 2;
+		if (!((y - 68) & 3)) {
+			leaps--;
+			if (is_leap) *is_leap = 1;
+		}
+		else if (is_leap) *is_leap = 0;
+		return 31536000 * (y - 70) + 86400 * leaps;
+	}
+
+	int cycles, centuries, leaps, rem;
+
+	if (!is_leap) is_leap = &(int) { 0 };
+	cycles = (year - 100) / 400;
+	rem = (year - 100) % 400;
+	if (rem < 0) {
+		cycles--;
+		rem += 400;
+	}
+	if (!rem) {
+		*is_leap = 1;
+		centuries = 0;
+		leaps = 0;
+	}
+	else {
+		if (rem >= 200) {
+			if (rem >= 300) centuries = 3, rem -= 300;
+			else centuries = 2, rem -= 200;
+		}
+		else {
+			if (rem >= 100) centuries = 1, rem -= 100;
+			else centuries = 0;
+		}
+		if (!rem) {
+			*is_leap = 0;
+			leaps = 0;
+		}
+		else {
+			leaps = rem / 4U;
+			rem %= 4U;
+			*is_leap = !rem;
+		}
+	}
+
+	leaps += 97 * cycles + 24 * centuries - *is_leap;
+
+	return (year - 100) * 31536000LL + leaps * 86400LL + 946684800 + 86400;
+}
+
+int __month_to_secs(int month, int is_leap)
+{
+	static const int secs_through_month[] = {
+		0, 31 * 86400, 59 * 86400, 90 * 86400,
+		120 * 86400, 151 * 86400, 181 * 86400, 212 * 86400,
+		243 * 86400, 273 * 86400, 304 * 86400, 334 * 86400};
+	int t = secs_through_month[month];
+	if (is_leap && month >= 2) t += 86400;
+	return t;
+}
+
+long long __tm_to_secs(const struct tm *tm)
+{
+	int is_leap;
+	long long year = tm->tm_year;
+	int month = tm->tm_mon;
+	if (month >= 12 || month < 0) {
+		int adj = month / 12;
+		month %= 12;
+		if (month < 0) {
+			adj--;
+			month += 12;
+		}
+		year += adj;
+	}
+	long long t = __year_to_secs(year, &is_leap);
+	t += __month_to_secs(month, is_leap);
+	t += 86400LL * (tm->tm_mday - 1);
+	t += 3600LL * tm->tm_hour;
+	t += 60LL * tm->tm_min;
+	t += tm->tm_sec;
+	return t;
+}
+
+struct tm *localtime_r(const time_t *t, struct tm *tm)
+{
+	/* Reject time_t values whose year would overflow int because
+	* __secs_to_zone cannot safely handle them. */
+	if (*t < INT_MIN * 31622400LL || *t > INT_MAX * 31622400LL) {
+		errno = EOVERFLOW;
+		return 0;
+	}
+	//TODO:__secs_to_zone(*t, 0, &tm->tm_isdst, &tm->__tm_gmtoff, 0, &tm->__tm_zone);
+	if (__secs_to_tm((long long)*t /*+ tm->__tm_gmtoff*/, tm) < 0) {
+		errno = EOVERFLOW;
+		return 0;
+	}
+	return tm;
+}
+
+struct tm *localtime(const time_t *time)
+{
+	static struct tm tm;
+	return localtime_r(time, &tm);
+}
+
+struct tm *gmtime_r(const time_t *t, struct tm *tm)
+{
+	if (__secs_to_tm(*t, tm) < 0) {
+		errno = EOVERFLOW;
+		return 0;
+	}
+	tm->tm_isdst = 0;
+	/*tm->__tm_gmtoff = 0;
+	tm->__tm_zone = NULL;//__gmt;*/
+	return tm;
+}
+
+/* There is no other implemented value than TIME_UTC; all other values
+ * are considered erroneous. */
+/*int timespec_get(struct timespec * ts, int base)
+{
+	if (base != TIME_UTC) return 0;
+	int ret = __clock_gettime(CLOCK_REALTIME, ts);
+	return ret < 0 ? 0 : base;
+}*/
+time_t mktime(struct tm *tm)
+{
+	struct tm new;
+	long opp;
+	long long t = __tm_to_secs(tm);
+
+	if (__secs_to_tm(t, &new) < 0) goto error;
+
+	*tm = new;
+	return t;
+
+error:
+	errno = EOVERFLOW;
+	return -1;
+}
+
+DWORD get_fattime(void)
+{
+	time_t temp;
+	struct tm _tm;
+
+	time(&temp);
+	gmtime_r(&temp, &_tm);
+
+	return	  ((DWORD)(_tm.tm_year - 1980) << 25)
+		| ((DWORD)_tm.tm_mon << 21)
+		| ((DWORD)_tm.tm_mday << 16)
+		| ((DWORD)_tm.tm_hour << 11)
+		| ((DWORD)_tm.tm_min << 5)
+		| ((DWORD)_tm.tm_sec >> 1);
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/ntconf.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/ntconf.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/ntconf.h	(revision 279)
@@ -0,0 +1,52 @@
+/**
+ * @file ntconf.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef NTCONF_H
+#define NTCONF_H
+
+/**
+ * @note
+ * This file provides internal definitions for inner modules.
+ */
+
+/**
+ * @brief Maximum length for the editor module.
+ */
+#define NTCONF_EDITOR_MAXLEN    (256)
+
+/**
+ * @brief Maximum depth for the history module.
+ */
+#define NTCONF_HISTORY_DEPTH    (8)
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/ntint.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/ntint.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/ntint.h	(revision 279)
@@ -0,0 +1,55 @@
+/**
+ * @file ntint.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef NTINT_H
+#define NTINT_H
+
+/**
+ * @note
+ * This file provides integer definitions.
+ * You can use #include <stdint.h> if your tool chain have the header.
+ */
+
+#if 1
+#   include <stdint.h>
+#else
+    typedef unsigned char uint8_t;
+    typedef unsigned short uint16_t;
+    typedef unsigned int uint32_t;
+    typedef char int8_t;
+    typedef short int16_t;
+    typedef int int32_t;
+    typedef unsigned int size_t;
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.c	(revision 279)
@@ -0,0 +1,258 @@
+/**
+ * @file ntlibc.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "ntlibc.h"
+
+int ntlibc_strlen(const char *s)
+{
+	const char *p = s;
+	int cnt = 0;
+	while (*p) {
+		cnt++;
+		p++;
+	}
+	return cnt;
+}
+
+char *ntlibc_strcpy(char *des, const char *src)
+{
+	char *d = des;
+	const char *s = src;
+	while (*s) {
+		*d = *s;
+		d++;
+		s++;
+	}
+	*d = '\0';
+	return des;
+}
+
+char *ntlibc_strcat(char *des, const char *src)
+{
+	char *d = des;
+	const char *s = src;
+	while (*d) {
+		d++;
+	}
+	while (*s) {
+		*d = *s;
+		d++;
+		s++;
+	}
+	*d = '\0';
+	return des;
+}
+
+int ntlibc_strcmp(const char *s1, const char *s2)
+{
+	char *p1 = (char *)s1;
+	char *p2 = (char *)s2;
+	while (*p1 || *p2) {
+		if (*p1 != *p2) {
+			return (*p1 < *p2) ? -1 : 1;
+		}
+		p1++;
+		p2++;
+	}
+	if (*p1 == *p2) {
+		return 0;
+	}
+	else {
+		return (*p1 < *p2) ? -1 : 1;
+	}
+}
+
+int ntlibc_stricmp(const char *s1, const char *s2)
+{
+	char *p1 = (char *)s1;
+	char *p2 = (char *)s2;
+	while (*p1 || *p2) {
+		if (ntlibc_toupper(*p1) != ntlibc_toupper(*p2)) {
+			return (*p1 < *p2) ? -1 : 1;
+		}
+		p1++;
+		p2++;
+	}
+	if (*p1 == *p2) {
+		return 0;
+	}
+	else {
+		return (*p1 < *p2) ? -1 : 1;
+	}
+}
+
+int ntlibc_strncmp(const char *s1, const char *s2, int n)
+{
+	char *p1 = (char *)s1;
+	char *p2 = (char *)s2;
+	int len = 0;
+	while (*p1 || *p2) {
+		if (n <= len) {
+			break;
+		}
+		if (*p1 != *p2) {
+			return (*p1 < *p2) ? -1 : 1;
+		}
+		p1++;
+		p2++;
+		len++;
+	}
+	return 0;
+}
+
+int ntlibc_isdigit(int c)
+{
+	if (('0' <= c) && (c <= '9')) {
+		return 1;
+	}
+	return 0;
+}
+
+int ntlibc_isalpha(int c)
+{
+	if (('A' <= c) && (c <= 'Z')) {
+		return 1;
+	}
+	if (('a' <= c) && (c <= 'z')) {
+		return 1;
+	}
+	return 0;
+}
+
+int ntlibc_iscntrl(int c)
+{
+	if (c == 0x07) { return 0; }
+	if (c == 0x08) { return 0; }
+	if (c == 0x09) { return 0; }
+	if (c == 0x0a) { return 0; }
+	if (c == 0x0b) { return 0; }
+	if (c == 0x0c) { return 0; }
+	if (c == 0x0d) { return 0; }
+	if ((0x00 <= c) && (c <= 0x1f)) {
+		return 1;
+	}
+	return 0;
+}
+
+int ntlibc_toupper(int c)
+{
+	if (('a' <= c) && (c <= 'z')) {
+		int diff = 'a' - 'A';
+		return c - diff;
+	}
+	return c;
+}
+
+int ntlibc_tolower(int c)
+{
+	if (('A' <= c) && (c <= 'Z')) {
+		int diff = 'a' - 'A';
+		return c + diff;
+	}
+	return c;
+}
+
+int ntlibc_atoi(const char *nptr)
+{
+	int cnt;
+	int num = 0;
+	int ofs = 0;
+	int sign = 0;
+	int scnt = 0;
+	char *p = (char *)nptr;
+	while (*p != '\0') {
+		if (!ntlibc_isdigit(*p)) {
+			if (*p == ' ') {
+				ofs++;
+			}
+			if (*p == '+') {
+				sign = 0;
+				ofs++;
+				if (scnt++ > 0) {
+					return 0;
+				}
+			}
+			if (*p == '-') {
+				sign = 1;
+				ofs++;
+				if (scnt++ > 0) {
+					return 0;
+				}
+			}
+		}
+		p++;
+	}
+	for (cnt = ofs; (nptr[cnt] >= '0') && (nptr[cnt] <= '9'); cnt++) {
+		num = 10 * num + (nptr[cnt] - '0');
+	}
+	if (sign) {
+		return -num;
+	}
+	else {
+		return num;
+	}
+}
+
+char *ntlibc_strchr(const char *s, int c)
+{
+	char *p = (char *)s;
+	for (;;) {
+		if (*p == c) {
+			return p;
+		}
+		if (!*p)
+			break;
+		p++;
+	}
+	return 0;
+}
+
+char *ntlibc_utoa(unsigned int value, char *s, int radix)
+{
+	char *s1 = s;
+	char *s2 = s;
+
+	do {
+		*s2++ = "0123456789abcdefghijklmnopqrstuvwxyz"[value % radix];
+		value /= radix;
+	} while (value > 0);
+
+	*s2-- = '\0';
+
+	while (s1 < s2) {
+		char c = *s1;
+		*s1++ = *s2;
+		*s2-- = c;
+	}
+
+	return s;
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/ntlibc.h	(revision 279)
@@ -0,0 +1,60 @@
+/**
+ * @file ntlibc.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef NTLIBC_H
+#define NTLIBC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ntlibc_strlen(const char *s);
+char *ntlibc_strcpy(char *des, const char *src);
+char *ntlibc_strcat(char *des, const char *src);
+int ntlibc_strcmp(const char *s1, const char *s2);
+int ntlibc_stricmp(const char *s1, const char *s2);
+int ntlibc_strncmp(const char *s1, const char *s2, int n);
+int ntlibc_isdigit(int c);
+int ntlibc_isalpha(int c);
+int ntlibc_iscntrl(int c);
+int ntlibc_toupper(int c);
+int ntlibc_tolower(int c);
+int ntlibc_atoi(const char *nptr);
+char *ntlibc_strchr(const char *s, int c);
+char *ntlibc_utoa(unsigned int value, char *s, int radix);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c	(revision 279)
@@ -0,0 +1,683 @@
+/**
+ * @file ntshell.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include "ntshell.h"
+
+int ntshell_exit;
+
+#define VERSION_MAJOR   (0) /**< Major number. */
+#define VERSION_MINOR   (3) /**< Minor number. */
+#define VERSION_RELEASE (1) /**< Release number. */
+
+/**
+ * @brief Initialization code.
+ */
+#define INITCODE    (0x4367)
+
+/**
+ * @brief Unused variable wrapper.
+ *
+ * @param N A variable.
+ */
+#define UNUSED_VARIABLE(N)  do { (void)(N); } while (0)
+
+/**
+ * @brief Index number of the suggestion.
+ *
+ * @param HANDLE A pointer of the handle.
+ */
+#define SUGGEST_INDEX(HANDLE)   ((HANDLE)->suggest_index)
+
+/**
+ * @brief Source text string of the suggestion.
+ *
+ * @param HANDLE A pointer of the handle.
+ */
+#define SUGGEST_SOURCE(HANDLE)  ((HANDLE)->suggest_source)
+
+/**
+ * @brief Get the text editor.
+ *
+ * @param HANDLE A pointer of the handle.
+ */
+#define GET_EDITOR(HANDLE)      (&((HANDLE)->editor))
+
+/**
+ * @brief Get the text history.
+ *
+ * @param HANDLE A pointer of the handle.
+ */
+#define GET_HISTORY(HANDLE)     (&((HANDLE)->history))
+
+/**
+ * @brief Read from the serial port.
+ *
+ * @param HANDLE A pointer of the handle.
+ * @param BUF A pointer to the buffer.
+ * @param CNT Read length.
+ *
+ * @return The number of bytes read.
+ */
+#define SERIAL_READ(HANDLE, BUF, CNT)   ((HANDLE)->func_read(BUF, CNT, (HANDLE)->extobj))
+
+/**
+ * @brief Write to the serial port.
+ *
+ * @param HANDLE A pointer of the handle.
+ * @param BUF A pointer to the buffer.
+ * @param CNT Write length.
+ *
+ * @return The number of bytes written.
+ */
+#define SERIAL_WRITE(HANDLE, BUF, CNT)  ((HANDLE)->func_write(BUF, CNT, (HANDLE)->extobj))
+
+/**
+ * @brief Write the prompt to the serial port.
+ *
+ * @param HANDLE A pointer of the handle.
+ */
+#define PROMPT_WRITE(HANDLE)            SERIAL_WRITE((HANDLE), (HANDLE)->prompt, strlen((HANDLE)->prompt))
+
+/**
+ * @brief Write the newline to the serial port.
+ *
+ * @param HANDLE A pointer of the handle.
+ */
+#define PROMPT_NEWLINE(HANDLE)          SERIAL_WRITE((HANDLE), NTSHELL_PROMPT_NEWLINE, strlen(NTSHELL_PROMPT_NEWLINE))
+
+/**
+ * @brief Call the user callback function.
+ *
+ * @param HANDLE A pointer of the handle.
+ * @param TEXT A text string for the callback function.
+ */
+#define CALLBACK(HANDLE, TEXT)          ((HANDLE)->func_callback((TEXT), (HANDLE)->extobj))
+
+#define VTSEND_ERASE_LINE(HANDLE)       (vtsend_erase_line(&((HANDLE)->vtsend)))
+#define VTSEND_CURSOR_HEAD(HANDLE)      (vtsend_cursor_backward(&((HANDLE)->vtsend), 80))
+#define VTSEND_CURSOR_PREV(HANDLE)      (vtsend_cursor_backward(&((HANDLE)->vtsend), 1))
+#define VTSEND_CURSOR_PREVS(HANDLE,n)   (vtsend_cursor_backward(&((HANDLE)->vtsend), n))
+#define VTSEND_CURSOR_NEXT(HANDLE)      (vtsend_cursor_forward(&((HANDLE)->vtsend), 1))
+
+/**
+ * @brief Search a previous input text on the history module.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_history_prev(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	if (text_history_read_point_prev(GET_HISTORY(ntshell))) {
+		char txt[TEXTHISTORY_MAXLEN];
+		int n = text_history_read(GET_HISTORY(ntshell), &txt[0], sizeof(txt));
+		if (0 < n) {
+			VTSEND_ERASE_LINE(ntshell);
+			VTSEND_CURSOR_HEAD(ntshell);
+			PROMPT_WRITE(ntshell);
+			SERIAL_WRITE(ntshell, txt, n);
+			text_editor_set_text(GET_EDITOR(ntshell), txt);
+		}
+	}
+}
+
+/**
+ * @brief Search a next input text on the history module.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_history_next(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	if (text_history_read_point_next(GET_HISTORY(ntshell))) {
+		char txt[TEXTHISTORY_MAXLEN];
+		int n = text_history_read(GET_HISTORY(ntshell), &txt[0], sizeof(txt));
+		if (0 < n) {
+			VTSEND_ERASE_LINE(ntshell);
+			VTSEND_CURSOR_HEAD(ntshell);
+			PROMPT_WRITE(ntshell);
+			SERIAL_WRITE(ntshell, txt, n);
+			text_editor_set_text(GET_EDITOR(ntshell), txt);
+		}
+	}
+}
+
+/**
+ * @brief Move the cursor to left.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_cursor_left(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	if (text_editor_cursor_left(GET_EDITOR(ntshell))) {
+		VTSEND_CURSOR_PREV(ntshell);
+	}
+}
+
+/**
+ * @brief Move the cursor to right.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_cursor_right(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	if (text_editor_cursor_right(GET_EDITOR(ntshell))) {
+		VTSEND_CURSOR_NEXT(ntshell);
+	}
+}
+
+/**
+ * @brief Process for the enter action.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_enter(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	char txt[TEXTEDITOR_MAXLEN];
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	text_editor_get_text(GET_EDITOR(ntshell), &txt[0], sizeof(txt));
+	text_editor_clear(GET_EDITOR(ntshell));
+	text_history_write(GET_HISTORY(ntshell), txt);
+	PROMPT_NEWLINE(ntshell);
+	CALLBACK(ntshell, txt);
+	PROMPT_WRITE(ntshell);
+}
+
+/**
+ * @brief Process for the cancel action.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @note
+ * The CTRL+C operation in the general OS uses a signal.
+ * In this cancel action, It simulate only the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_cancel(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	text_editor_clear(GET_EDITOR(ntshell));
+	SERIAL_WRITE(ntshell, "^C", 2);
+	PROMPT_NEWLINE(ntshell);
+	PROMPT_WRITE(ntshell);
+}
+
+/**
+ * @brief Process for the insert action.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_insert(ntshell_t *ntshell, vtrecv_action_t action, unsigned int ch)
+{
+	char utf8[6];
+	int len8;
+
+	UNUSED_VARIABLE(action);
+
+	/*
+	 * Reject the suggestion index number if an input action occurred.
+	 */
+	SUGGEST_INDEX(ntshell) = -1;
+
+	/*
+	 * Insert the input character using the logical text editor.
+	 * Update the view.
+	 */
+	if ((len8 = text_editor_insert(GET_EDITOR(ntshell), ch, utf8)) > 0) {
+		char txt[TEXTEDITOR_MAXLEN];
+		int len = text_editor_get_text(GET_EDITOR(ntshell), &txt[0], sizeof(txt));
+		int pos = text_editor_cursor_get_position(GET_EDITOR(ntshell));
+		int n = len - pos;
+		SERIAL_WRITE(ntshell, utf8, len8);
+		if (n > 0) {
+			int i;
+			SERIAL_WRITE(ntshell, txt + pos, len - pos);
+			for (i = 0; i < n; i++) {
+				VTSEND_CURSOR_PREV(ntshell);
+			}
+		}
+	}
+}
+
+/**
+ * @brief Process for the backspace action.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_backspace(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	int bs_char_num;
+
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	bs_char_num = text_editor_backspace(GET_EDITOR(ntshell));
+	if (bs_char_num) {
+		char txt[TEXTEDITOR_MAXLEN];
+		int len = text_editor_get_text(GET_EDITOR(ntshell), &txt[0], sizeof(txt));
+		int pos = text_editor_cursor_get_position(GET_EDITOR(ntshell));
+		int n = len - pos;
+		VTSEND_CURSOR_PREV(ntshell);
+		if (n > 0) {
+			int i;
+			SERIAL_WRITE(ntshell, txt + pos, n);
+			SERIAL_WRITE(ntshell, " ", 1);
+			for (i = 0; i < n + 1; i++) {
+				VTSEND_CURSOR_PREV(ntshell);
+			}
+		}
+		else {
+			SERIAL_WRITE(ntshell, " ", 1);
+			VTSEND_CURSOR_PREVS(ntshell, bs_char_num);
+			SERIAL_WRITE(ntshell, " ", 1);
+			VTSEND_CURSOR_PREV(ntshell);
+		}
+	}
+}
+
+/**
+ * @brief Process for the delete action.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_delete(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	if (text_editor_delete(GET_EDITOR(ntshell))) {
+		char txt[TEXTEDITOR_MAXLEN];
+		int len = text_editor_get_text(GET_EDITOR(ntshell), &txt[0], sizeof(txt));
+		int pos = text_editor_cursor_get_position(GET_EDITOR(ntshell));
+		int n = len - pos;
+		if (n > 0) {
+			int i;
+			SERIAL_WRITE(ntshell, txt + pos, n);
+			SERIAL_WRITE(ntshell, " ", 1);
+			for (i = 0; i < n + 1; i++) {
+				VTSEND_CURSOR_PREV(ntshell);
+			}
+		}
+		else {
+			SERIAL_WRITE(ntshell, " ", 1);
+			VTSEND_CURSOR_PREV(ntshell);
+		}
+	}
+}
+
+/**
+ * @brief Process for the suggestion action.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_suggest(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	char buf[TEXTEDITOR_MAXLEN];
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	if (SUGGEST_INDEX(ntshell) < 0) {
+		/*
+		 * Enter the input suggestion mode.
+		 * Get the suggested text string with the current text string.
+		 */
+		if (text_editor_get_text(
+			GET_EDITOR(ntshell),
+			SUGGEST_SOURCE(ntshell),
+			sizeof(SUGGEST_SOURCE(ntshell))) > 0) {
+			SUGGEST_INDEX(ntshell) = 0;
+			if (text_history_find(
+				GET_HISTORY(ntshell),
+				SUGGEST_INDEX(ntshell),
+				SUGGEST_SOURCE(ntshell),
+				buf,
+				sizeof(buf)) == 0) {
+				/*
+				 * Found the suggestion.
+				 */
+				int n = strlen((const char *)buf);
+				VTSEND_ERASE_LINE(ntshell);
+				VTSEND_CURSOR_HEAD(ntshell);
+				PROMPT_WRITE(ntshell);
+				SERIAL_WRITE(ntshell, buf, n);
+				text_editor_set_text(GET_EDITOR(ntshell), buf);
+			}
+			else {
+				/*
+				 * Not found the suggestion.
+				 */
+				SUGGEST_INDEX(ntshell) = -1;
+			}
+		}
+	}
+	else {
+		/*
+		 * Already the input suggestion mode.
+		 * Search the next suggestion text string.
+		 */
+		SUGGEST_INDEX(ntshell) = SUGGEST_INDEX(ntshell) + 1;
+		if (text_history_find(
+			GET_HISTORY(ntshell),
+			SUGGEST_INDEX(ntshell),
+			SUGGEST_SOURCE(ntshell),
+			buf,
+			sizeof(buf)) == 0) {
+			/*
+			 * Found the suggestion.
+			 */
+			int n = strlen((const char *)buf);
+			VTSEND_ERASE_LINE(ntshell);
+			VTSEND_CURSOR_HEAD(ntshell);
+			PROMPT_WRITE(ntshell);
+			SERIAL_WRITE(ntshell, buf, n);
+			text_editor_set_text(GET_EDITOR(ntshell), buf);
+		}
+		else {
+			/*
+			 * Not found the suggestion.
+			 * Recall the previous input text string.
+			 */
+			int n = strlen(SUGGEST_SOURCE(ntshell));
+			VTSEND_ERASE_LINE(ntshell);
+			VTSEND_CURSOR_HEAD(ntshell);
+			PROMPT_WRITE(ntshell);
+			SERIAL_WRITE(ntshell, SUGGEST_SOURCE(ntshell), n);
+			text_editor_set_text(GET_EDITOR(ntshell), SUGGEST_SOURCE(ntshell));
+			SUGGEST_INDEX(ntshell) = -1;
+		}
+	}
+}
+
+/**
+ * @brief Move the cursor to the head of the line.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_cursor_head(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	VTSEND_CURSOR_HEAD(ntshell);
+	PROMPT_WRITE(ntshell);
+	text_editor_cursor_head(GET_EDITOR(ntshell));
+}
+
+/**
+ * @brief Move the cursor to the tail of the line.
+ * @details This function change the state of the logical text editor and the view.
+ *
+ * @param ntshell A handler of the NT-Shell.
+ * @param action An action.
+ * @param ch A input character.
+ */
+static void actfunc_cursor_tail(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch)
+{
+	char buf[TEXTEDITOR_MAXLEN];
+	int len;
+	UNUSED_VARIABLE(action);
+	UNUSED_VARIABLE(ch);
+	text_editor_get_text(GET_EDITOR(ntshell), buf, sizeof(buf));
+	len = strlen((const char *)buf);
+	VTSEND_CURSOR_HEAD(ntshell);
+	PROMPT_WRITE(ntshell);
+	SERIAL_WRITE(ntshell, buf, len);
+	text_editor_cursor_tail(GET_EDITOR(ntshell));
+}
+
+/**
+ * @brief The data structure of the action table.
+ * @details
+ * The action consists from the state and the input character.
+ * This definition also have the callback function.
+ */
+typedef struct {
+	vtrecv_action_t action;
+	unsigned char ch;
+	void(*func)(ntshell_t *ntshell, vtrecv_action_t action, unsigned char ch);
+} ntshell_action_table_t;
+
+/**
+ * @brief Process function table for the actions.
+ * @details
+ * The action codes depends on the virtual terminals.
+ * So you should check some virtual terminal softwares and the environments.
+ *
+ * <table>
+ *   <th>
+ *     <td>Platform</td>
+ *     <td>Tools</td>
+ *   </th>
+ *   <tr>
+ *     <td>Windows</td>
+ *     <td>Hyper Terminal, Poderossa, TeraTerm</td>
+ *   </tr>
+ *   <tr>
+ *     <td>Linux</td>
+ *     <td>minicom, screen, kermit</td>
+ *   </tr>
+ * </table>
+ */
+static const ntshell_action_table_t action_table[] = {
+	{VTRECV_ACTION_EXECUTE, 0x01, actfunc_cursor_head},
+	{VTRECV_ACTION_EXECUTE, 0x02, actfunc_cursor_left},
+	{VTRECV_ACTION_EXECUTE, 0x03, actfunc_cancel},
+	{VTRECV_ACTION_EXECUTE, 0x04, actfunc_delete},
+	{VTRECV_ACTION_EXECUTE, 0x05, actfunc_cursor_tail},
+	{VTRECV_ACTION_EXECUTE, 0x06, actfunc_cursor_right},
+	{VTRECV_ACTION_EXECUTE, 0x08, actfunc_backspace},
+	{VTRECV_ACTION_EXECUTE, 0x09, actfunc_suggest},
+	{VTRECV_ACTION_EXECUTE, 0x0d, actfunc_enter},
+	{VTRECV_ACTION_EXECUTE, 0x0e, actfunc_history_next},
+	{VTRECV_ACTION_EXECUTE, 0x10, actfunc_history_prev},
+	{VTRECV_ACTION_CSI_DISPATCH, 0x41, actfunc_history_prev},
+	{VTRECV_ACTION_CSI_DISPATCH, 0x42, actfunc_history_next},
+	{VTRECV_ACTION_CSI_DISPATCH, 0x43, actfunc_cursor_right},
+	{VTRECV_ACTION_CSI_DISPATCH, 0x44, actfunc_cursor_left},
+	{VTRECV_ACTION_CSI_DISPATCH, 0x7e, actfunc_delete},
+	{VTRECV_ACTION_PRINT, 0x7f, actfunc_backspace},
+};
+
+/**
+ * @brief The callback function for the vtrecv module.
+ *
+ * @param vtrecv The vtrecv.
+ * @param action An action.
+ * @param ch A character.
+ */
+void vtrecv_callback(vtrecv_t *vtrecv, vtrecv_action_t action, unsigned int ch)
+{
+	ntshell_action_table_t *p;
+	int i;
+	const int ACTTBLSIZ = sizeof(action_table) / sizeof(action_table[0]);
+
+	/*
+	 * Search the process function for the control codes.
+	 */
+	p = (ntshell_action_table_t *)action_table;
+	for (i = 0; i < ACTTBLSIZ; i++) {
+		if ((p->action == action) && (p->ch == ch)) {
+			p->func(vtrecv->user_data, action, ch);
+			return;
+		}
+		p++;
+	}
+
+	/*
+	 * A general character is the input character.
+	 */
+	if (VTRECV_ACTION_PRINT == action) {
+		actfunc_insert(vtrecv->user_data, action, ch);
+		return;
+	}
+
+	/*
+	 * Other cases, there is no defined process function for the input codes.
+	 * If you need to support the input action, you should update the action table.
+	 */
+}
+
+/**
+ * @brief Initialize the NT-Shell.
+ *
+ * @param p A pointer to the handler of NT-Shell.
+ * @param func_read Serial read function.
+ * @param func_write Serial write function.
+ * @param func_callback Callback function.
+ * @param extobj An external object for the callback function.
+ */
+void ntshell_init(ntshell_t *p,
+	NTSHELL_SERIAL_READ func_read,
+	NTSHELL_SERIAL_WRITE func_write,
+	NTSHELL_USER_CALLBACK func_callback,
+	void *extobj)
+{
+	/*
+	 * The vtrecv module provides a pointer interface to an external object.
+	 * NT-Shell uses the text editor, text history, read function, write function with the pointer interface.
+	 */
+	p->func_read = func_read;
+	p->func_write = func_write;
+	p->func_callback = func_callback;
+	p->extobj = extobj;
+	strcpy(p->prompt, NTSHELL_PROMPT_DEFAULT);
+
+	p->vtrecv.user_data = p;
+
+	/*
+	 * Initialize the modules.
+	 */
+	vtsend_init(&(p->vtsend), func_write, extobj);
+	vtrecv_init(&(p->vtrecv), vtrecv_callback);
+	text_editor_init(GET_EDITOR(p));
+	text_history_init(GET_HISTORY(p));
+	SUGGEST_INDEX(p) = -1;
+
+	/*
+	 * Set the initialization code.
+	 */
+	p->initcode = INITCODE;
+}
+
+/**
+ * @brief Execute the NT-Shell.
+ * @details Never return from this function.
+ *
+ * @param p A pointer to the handler of the NT-Shell.
+ */
+void ntshell_execute(ntshell_t *p)
+{
+	/*
+	 * Check the initialization code.
+	 */
+	if (p->initcode != INITCODE) {
+		return;
+	}
+
+	/*
+	 * User input loop.
+	 */
+	PROMPT_WRITE(p);
+	while (ntshell_exit == 0) {
+		unsigned char ch;
+		SERIAL_READ(p, (char *)&ch, sizeof(ch));
+		vtrecv_execute(&(p->vtrecv), &ch, sizeof(ch));
+	}
+}
+
+/**
+ * @brief Set up the prompt of the NT-Shell.
+ *
+ * @param p A pointer to the handler of the NT-Shell.
+ * @param prompt A text string.
+ */
+void ntshell_set_prompt(ntshell_t *p, const char *prompt)
+{
+	/*
+	 * Check the initialization code.
+	 */
+	if (p->initcode != INITCODE) {
+		return;
+	}
+
+	strcpy(p->prompt, prompt);
+}
+
+/**
+ * @brief Get the version.
+ *
+ * @param major Major number.
+ * @param minor Minor number.
+ * @param release Release number.
+ */
+void ntshell_version(int *major, int *minor, int *release)
+{
+	*major = VERSION_MAJOR;
+	*minor = VERSION_MINOR;
+	*release = VERSION_RELEASE;
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.h	(revision 279)
@@ -0,0 +1,90 @@
+/**
+ * @file ntshell.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef NTSHELL_H
+#define NTSHELL_H
+
+#include "vtrecv.h"
+#include "vtsend.h"
+#include "text_editor.h"
+#include "text_history.h"
+
+#define NTSHELL_PROMPT_MAXLEN   (32)
+#define NTSHELL_PROMPT_DEFAULT  ">"
+#define NTSHELL_PROMPT_NEWLINE  "\r\n"
+
+typedef int (*NTSHELL_SERIAL_READ)(char *buf, int cnt, void *extobj);
+typedef int (*NTSHELL_SERIAL_WRITE)(const char *buf, int cnt, void *extobj);
+typedef int (*NTSHELL_USER_CALLBACK)(const char *text, void *extobj);
+
+/**
+ * @brief The handler of NT-Shell.
+ * @details
+ * The best way to provide a handler, We should hide the implementation from the library users.
+ * But some small embedded environments can not use memory allocation dynamically.
+ * So this implementation open the fields of the handler in this header.
+ * You can use this handler on the stacks.
+ */
+typedef struct {
+    unsigned int initcode;  /**< Initialization flag. */
+    vtsend_t vtsend;        /**< The handler of vtsend. */
+    vtrecv_t vtrecv;        /**< The handler of vtrecv. */
+    text_editor_t editor;   /**< The handler of text_editor. */
+    text_history_t history; /**< The handler of text_history. */
+    int suggest_index;
+    char suggest_source[TEXTEDITOR_MAXLEN];
+    NTSHELL_SERIAL_READ func_read;
+    NTSHELL_SERIAL_WRITE func_write;
+    NTSHELL_USER_CALLBACK func_callback;
+    void *extobj;
+    char prompt[NTSHELL_PROMPT_MAXLEN];
+} ntshell_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ntshell_init(ntshell_t *p,
+    NTSHELL_SERIAL_READ func_read,
+    NTSHELL_SERIAL_WRITE func_write,
+    NTSHELL_USER_CALLBACK func_callback,
+    void *extobj);
+void ntshell_execute(ntshell_t *p);
+void ntshell_set_prompt(ntshell_t *p, const char *prompt);
+void ntshell_version(int *major, int *minor, int *release);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/text_editor.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/text_editor.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/text_editor.c	(revision 279)
@@ -0,0 +1,345 @@
+/**
+ * @file text_editor.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "text_editor.h"
+
+/**
+ * @brief Initialize the text editor module.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+void text_editor_init(text_editor_t *p)
+{
+	p->pos = 0;
+	p->len = 0;
+	p->buffer[p->len] = '\0';
+}
+
+/**
+ * @brief Insert a character.
+ *
+ * @param p A pointer to the text editor handler.
+ * @param c A character.
+ */
+int text_editor_insert(text_editor_t *p, unsigned int ch, char *utf8)
+{
+	int len;
+
+	if (ch < 0x80) {
+		utf8[0] = ch & 0x7F;
+		len = 1;
+	}
+	else if (ch < 0x00000800) {
+		utf8[1] = (0x80 | (ch & 0x3F));
+		utf8[0] = (0xC0 | (ch >> 6));
+		len = 2;
+	}
+	else if (ch < 0x00010000) {
+		utf8[2] = (0x80 | (ch & 0x3F));
+		utf8[1] = (0x80 | ((ch >> 6) & 0x3F));
+		utf8[0] = (0xE0 | (ch >> 12));
+		len = 3;
+	}
+	else if (ch < 0x00200000) {
+		utf8[3] = (0x80 | (ch & 0x3F));
+		utf8[2] = (0x80 | ((ch >> 6) & 0x3F));
+		utf8[1] = (0x80 | ((ch >> 12) & 0x3F));
+		utf8[0] = (0xF0 | (ch >> 18));
+		len = 4;
+	}
+	else if (ch < 0x04000000) {
+		utf8[4] = (0x80 | (ch & 0x3F));
+		utf8[3] = (0x80 | ((ch >> 6) & 0x3F));
+		utf8[2] = (0x80 | ((ch >> 12) & 0x3F));
+		utf8[1] = (0x80 | ((ch >> 18) & 0x3F));
+		utf8[0] = (0xF8 | (ch >> 24));
+		len = 5;
+	}
+	else if (ch < 0x80000000) {
+		utf8[5] = (0x80 | (ch & 0x3F));
+		utf8[4] = (0x80 | ((ch >> 6) & 0x3F));
+		utf8[3] = (0x80 | ((ch >> 12) & 0x3F));
+		utf8[2] = (0x80 | ((ch >> 18) & 0x3F));
+		utf8[1] = (0x80 | ((ch >> 24) & 0x3F));
+		utf8[0] = (0xFC | (ch >> 30));
+		len = 6;
+	}
+	else {
+		return 0;
+	}
+
+	if (p->len >= (int)sizeof(p->buffer) - len)
+		return 0;
+
+	int n = p->len - p->pos + len;
+	char *src = p->buffer + p->len + 0;
+	char *des = p->buffer + p->len + len;
+	for (int i = 0; i < n; i++) {
+		*des = *src;
+		des--;
+		src--;
+	}
+
+	for (int i = 0; i < len; i++) {
+		p->buffer[p->pos] = utf8[i];
+		p->pos++;
+		p->len++;
+	}
+	p->buffer[p->len] = '\0';
+	return len;
+}
+
+/**
+* @brief count bytes of a deleted character by backspace.
+*
+* @param str A pointer to the text.
+* @param pos The end of the text.
+*/
+int bs_char_count(char *str, int pos)
+{
+	int num = 1, local_pos = pos;
+	char *c;
+
+	while (1) {
+		c = str + local_pos;
+
+		if ((*c & 0x80) != 0x80)
+			return num;
+
+		if (((*c & 0xE0) == 0xC0) && (num == 2)) {
+			return num;
+		}
+		else if (((*c & 0xF0) == 0xE0) && (num == 3)) {
+			return num;
+		}
+		else if (((*c & 0xF8) == 0xF0) && (num == 4)) {
+			return num;
+		}
+		else if (((*c & 0xFC) == 0xF8) && (num == 5)) {
+			return num;
+		}
+		else if (((*c & 0xFE) == 0xFC) && (num == 6)) {
+			return num;
+		}
+		else {
+			if (local_pos > 0) {
+				local_pos--;
+				num++;
+			}
+			else
+				return 0;
+		}
+	}
+
+	return 0;
+}
+
+/**
+ * @brief Delete a character.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+int text_editor_backspace(text_editor_t *p)
+{
+	int bs_char_num;
+
+	if (0 < p->pos) {
+		int n = p->len - p->pos;
+		int i;
+		char *src = p->buffer + p->pos - 0;
+		char *des = p->buffer + p->pos - 1;
+
+		bs_char_num = bs_char_count(p->buffer, p->pos - 1);
+		p->pos -= bs_char_num;
+		p->len -= bs_char_num;
+
+		for (i = 0; i < n; i++) {
+			*des = *src;
+			des++;
+			src++;
+		}
+		*(p->buffer + p->len) = '\0';
+		return (bs_char_num > 2 ? 2 : 1);
+	}
+	return 0;
+}
+
+/**
+ * @brief Delete a character.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+int text_editor_delete(text_editor_t *p)
+{
+	if (p->pos < p->len) {
+		int n = p->len - p->pos - 1;
+		int i;
+		char *src = p->buffer + p->pos + 1;
+		char *des = p->buffer + p->pos + 0;
+		p->len--;
+		for (i = 0; i < n; i++) {
+			*des = *src;
+			des++;
+			src++;
+		}
+		*(p->buffer + p->len) = '\0';
+		return 1;
+	}
+	return 0;
+}
+
+/**
+ * @brief Get the cursor position.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+int text_editor_cursor_get_position(text_editor_t *p)
+{
+	return p->pos;
+}
+
+/**
+ * @brief Move to the cursor to the head of the line.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+int text_editor_cursor_head(text_editor_t *p)
+{
+	if (0 < p->pos) {
+		p->pos = 0;
+		return 1;
+	}
+	return 0;
+}
+
+/**
+ * @brief Move to the cursor to the tail of the line.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+int text_editor_cursor_tail(text_editor_t *p)
+{
+	if (p->pos < p->len) {
+		p->pos = p->len;
+		return 1;
+	}
+	return 0;
+}
+
+/**
+ * @brief Move to the cursor to left.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+int text_editor_cursor_left(text_editor_t *p)
+{
+	if (0 < p->pos) {
+		p->pos--;
+		return 1;
+	}
+	return 0;
+}
+
+/**
+ * @brief Move to the cursor to right.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+int text_editor_cursor_right(text_editor_t *p)
+{
+	if (p->pos < p->len) {
+		p->pos++;
+		return 1;
+	}
+	return 0;
+}
+
+/**
+ * @brief Set the edit line.
+ *
+ * @param p A pointer to the text editor handler.
+ * @param buf A text string.
+ */
+int text_editor_set_text(text_editor_t *p, char *buf)
+{
+	char *src = buf;
+	char *des = p->buffer;
+	int n = 0;
+	while (*src) {
+		*des = *src;
+		des++;
+		src++;
+		n++;
+		if ((int)sizeof(p->buffer) <= n - 1) {
+			break;
+		}
+	}
+	*des = '\0';
+	p->len = n;
+	p->pos = p->len;
+	return n;
+}
+
+/**
+ * @brief Get the edit line.
+ *
+ * @param p A pointer to the text editor handler.
+ * @param buf A text string.
+ * @param siz Size of the text string buffer.
+ */
+int text_editor_get_text(text_editor_t *p, char *buf, int siz)
+{
+	char *src = p->buffer;
+	char *des = buf;
+	int n = 0;
+	while (*src) {
+		*des++ = *src++;
+		n++;
+		if (siz <= n) {
+			break;
+		}
+	}
+	*des = '\0';
+	return n;
+}
+
+/**
+ * @brief Clear the text string.
+ *
+ * @param p A pointer to the text editor handler.
+ */
+void text_editor_clear(text_editor_t *p)
+{
+	p->pos = 0;
+	p->len = 0;
+	p->buffer[p->len] = '\0';
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/text_editor.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/text_editor.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/text_editor.h	(revision 279)
@@ -0,0 +1,74 @@
+/**
+ * @file text_editor.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef TEXT_EDITOR_H
+#define TEXT_EDITOR_H
+
+#include "ntconf.h"
+
+/**
+ * @brief Maximum length of the text string.
+ */
+#define TEXTEDITOR_MAXLEN   (NTCONF_EDITOR_MAXLEN)
+
+/**
+ * @brief Text editor handler.
+ */
+typedef struct {
+    char buffer[TEXTEDITOR_MAXLEN]; /**< Buffer for the text string. */
+    int pos;                        /**< Position of the logical cursor. */
+    int len;                        /**< Length of the text string. */
+} text_editor_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void text_editor_init(text_editor_t *p);
+int text_editor_insert(text_editor_t *p, unsigned int ch, char *utf8);
+int text_editor_backspace(text_editor_t *p);
+int text_editor_delete(text_editor_t *p);
+int text_editor_cursor_get_position(text_editor_t *p);
+int text_editor_cursor_head(text_editor_t *p);
+int text_editor_cursor_tail(text_editor_t *p);
+int text_editor_cursor_left(text_editor_t *p);
+int text_editor_cursor_right(text_editor_t *p);
+int text_editor_set_text(text_editor_t *p, char *buf);
+int text_editor_get_text(text_editor_t *p, char *buf, int siz);
+void text_editor_clear(text_editor_t *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c	(revision 279)
@@ -0,0 +1,169 @@
+/**
+ * @file text_history.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include "text_history.h"
+
+/**
+ * @brief Initialize this module.
+ *
+ * @param p A pointer to the handler.
+ */
+void text_history_init(text_history_t *p)
+{
+	int i;
+	p->rp = 0;
+	p->wp = 0;
+	for (i = 0; i < (int)sizeof(p->history); i++) {
+		p->history[i] = 0;
+	}
+}
+
+/**
+ * @brief Write to the history.
+ *
+ * @param p A pointer to the handler.
+ * @param buf A pointer to the buffer.
+ */
+int text_history_write(text_history_t *p, char *buf)
+{
+	char *sp = p->history + (TEXTHISTORY_MAXLEN * p->wp);
+	if (buf[0] == '\0') {
+		return 0;
+	}
+	while (*buf) {
+		*sp = *buf;
+		sp++;
+		buf++;
+	}
+	*sp = '\0';
+	p->wp = (p->wp + 1) % TEXTHISTORY_DEPTH;
+	p->rp = p->wp;
+	return 1;
+}
+
+/**
+ * @brief Read from the history.
+ *
+ * @param p A pointer to the handler.
+ * @param buf A pointer to the buffer.
+ * @param siz A size of the buffer.
+ */
+int text_history_read(text_history_t *p, char *buf, const int siz)
+{
+	char *sp = p->history + (TEXTHISTORY_MAXLEN * p->rp);
+	int n = 0;
+	while (*sp) {
+		*buf = *sp;
+		buf++;
+		sp++;
+		n++;
+		if (siz - 1 <= n) {
+			break;
+		}
+	}
+	*buf = '\0';
+	return n;
+}
+
+/**
+ * @brief Change the pointing location to the next.
+ *
+ * @param p A pointer to the handler.
+ */
+int text_history_read_point_next(text_history_t *p)
+{
+	int n = (p->rp + 1) % TEXTHISTORY_DEPTH;
+	if (n != p->wp) {
+		p->rp = n;
+		return 1;
+	}
+	return 0;
+}
+
+/**
+ * @brief Change the pointing location to the previous.
+ *
+ * @param p A pointer to the handler.
+ */
+int text_history_read_point_prev(text_history_t *p)
+{
+	int n = (p->rp == 0) ? (TEXTHISTORY_DEPTH - 1) : (p->rp - 1);
+	if (n != p->wp) {
+		char *sp = p->history + (TEXTHISTORY_MAXLEN * n);
+		if (*sp != '\0') {
+			p->rp = n;
+			return 1;
+		}
+	}
+	return 0;
+}
+
+/**
+ * @brief Find the given text string from the text history.
+ *
+ * @param p A pointer to the handler.
+ * @param index An index number of the history.
+ * @param text The target text string.
+ * @param buf A pointer to the buffer.
+ * @param siz A size of the buffer.
+ *
+ * @retval 0 Success.
+ * @retval !0 Failure.
+ */
+int text_history_find(text_history_t *p,
+	const int index, const char *text,
+	char *buf, const int siz)
+{
+	const int text_len = strlen((const char *)text);
+	int found = 0;
+	int i;
+	for (i = 0; i < TEXTHISTORY_DEPTH; i++) {
+		int target = (p->rp + i) % TEXTHISTORY_DEPTH;
+		char *txtp = p->history + (TEXTHISTORY_MAXLEN * target);
+		const int target_len = strlen((const char *)txtp);
+		int comp_len = (target_len < text_len) ? target_len : text_len;
+		if ((strncmp(
+			(const char *)txtp,
+			(const char *)text, comp_len) == 0) && (comp_len > 0)) {
+			if (found == index) {
+				if (siz <= strlen(txtp)) {
+					return -1;
+				}
+				strcpy((char *)buf, (char *)txtp);
+				return 0;
+			}
+			found++;
+		}
+	}
+	return -1;
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.h	(revision 279)
@@ -0,0 +1,84 @@
+/**
+ * @file text_history.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef TEXT_HISTORY_H
+#define TEXT_HISTORY_H
+
+#include "ntconf.h"
+
+/**
+ * @brief Maximum length per a history.
+ */
+#define TEXTHISTORY_MAXLEN  (NTCONF_EDITOR_MAXLEN)
+
+/**
+ * @brief Depth of the history.
+ */
+#define TEXTHISTORY_DEPTH   (NTCONF_HISTORY_DEPTH)
+
+/**
+ * @brief Structure of the text history module.
+ */
+typedef struct {
+    /**
+     * @brief History buffer.
+     */
+    char history[TEXTHISTORY_MAXLEN * TEXTHISTORY_DEPTH];
+
+    /**
+     * @brief Read pointer.
+     */
+    int rp;
+
+    /**
+     * @brief Write pointer.
+     */
+    int wp;
+} text_history_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void text_history_init(text_history_t *p);
+int text_history_write(text_history_t *p, char *buf);
+int text_history_read(text_history_t *p, char *buf, const int siz);
+int text_history_read_point_next(text_history_t *p);
+int text_history_read_point_prev(text_history_t *p);
+int text_history_find(text_history_t *p, const int index, const char *text, char *buf, const int siz);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/vtrecv.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/vtrecv.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/vtrecv.c	(revision 279)
@@ -0,0 +1,2884 @@
+/**
+ * @file vtrecv.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * @note
+ * An implementation of Paul Williams' DEC compatible state machine parser.
+ * This code is in the public domain.
+ *
+ * @author Joshua Haberman <joshua@reverberate.org>
+ * @author Shinichiro Nakamura : Modified for Natural Tiny Shell (NT-Shell)
+ */
+
+#include "vtrecv.h"
+
+static state_change_t GET_STATE_TABLE(const int state, const int ch);
+static vtrecv_action_t GET_ENTRY_ACTIONS(const int state);
+static vtrecv_action_t GET_EXIT_ACTIONS(const int state);
+
+#if (USE_ORIGINAL_LUT==1)
+static const state_change_t STATE_TABLE[14][256] = {
+	{	/* VTRECV_STATE_CSI_ENTRY = 0 */
+		/*0  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*1  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*2  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*3  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*4  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*5  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*6  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*7  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*8  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*9  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*10 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*11 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*12 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*13 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*14 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*15 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*16 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*17 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*18 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*19 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*20 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*21 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*22 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*23 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*29 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*30 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*31 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*48 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*49 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*50 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*51 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*52 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*53 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*54 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*55 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*56 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*57 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*58 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*59 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4),
+		/*60 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_PARAM << 4),
+		/*61 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_PARAM << 4),
+		/*62 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_PARAM << 4),
+		/*63 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_PARAM << 4),
+		/*64 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*65 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*66 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*67 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*68 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*69 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*70 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*71 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*72 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*73 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*74 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*75 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*76 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*77 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*78 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*79 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*80 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*81 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*82 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*83 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*84 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*85 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*86 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*87 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*88 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*89 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*90 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*91 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*92 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*93 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*94 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*95 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*96 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*97 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*98 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*99 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*100*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*101*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*102*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*103*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*104*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*105*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*106*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*107*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*108*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*109*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*110*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*111*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*112*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*113*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*114*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*115*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*116*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*117*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*118*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*119*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*120*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*121*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*122*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*123*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*124*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*125*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*126*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_CSI_IGNORE = 1 */
+		/*0  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*1  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*2  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*3  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*4  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*5  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*6  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*7  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*8  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*9  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*10 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*11 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*12 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*13 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*14 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*15 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*16 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*17 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*18 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*19 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*20 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*21 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*22 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*23 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*29 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*30 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*31 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*32 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*33 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*34 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*35 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*36 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*37 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*38 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*39 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*40 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*41 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*42 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*43 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*44 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*45 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*46 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*47 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*48 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*49 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*50 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*51 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*52 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*53 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*54 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*55 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*56 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*57 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*58 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*59 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*60 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*61 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*62 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*63 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*64 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*65 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*66 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*67 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*68 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*69 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*70 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*71 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*72 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*73 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*74 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*75 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*76 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*77 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*78 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*79 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*80 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*81 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*82 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*83 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*84 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*85 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*86 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*87 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*88 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*89 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*90 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*91 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*92 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*93 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*94 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*95 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*96 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*97 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*98 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*99 */  0 | (VTRECV_STATE_GROUND << 4),
+		/*100*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*101*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*102*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*103*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*104*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*105*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*106*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*107*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*108*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*109*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*110*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*111*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*112*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*113*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*114*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*115*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*116*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*117*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*118*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*119*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*120*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*121*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*122*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*123*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*124*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*125*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*126*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_CSI_INTERMEDIATE = 2 */
+		/*0  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*1  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*2  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*3  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*4  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*5  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*6  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*7  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*8  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*9  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*10 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*11 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*12 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*13 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*14 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*15 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*16 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*17 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*18 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*19 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*20 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*21 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*22 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*23 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*29 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*30 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*31 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*48 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*49 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*50 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*51 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*52 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*53 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*54 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*55 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*56 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*57 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*58 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*59 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*60 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*61 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*62 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*63 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*64 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*65 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*66 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*67 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*68 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*69 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*70 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*71 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*72 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*73 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*74 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*75 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*76 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*77 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*78 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*79 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*80 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*81 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*82 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*83 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*84 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*85 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*86 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*87 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*88 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*89 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*90 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*91 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*92 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*93 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*94 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*95 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*96 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*97 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*98 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*99 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*100*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*101*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*102*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*103*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*104*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*105*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*106*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*107*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*108*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*109*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*110*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*111*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*112*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*113*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*114*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*115*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*116*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*117*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*118*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*119*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*120*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*121*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*122*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*123*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*124*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*125*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*126*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_CSI_PARAM = 3 */
+		/*0  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*1  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*2  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*3  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*4  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*5  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*6  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*7  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*8  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*9  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*10 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*11 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*12 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*13 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*14 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*15 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*16 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*17 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*18 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*19 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*20 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*21 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*22 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*23 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*29 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*30 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*31 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4),
+		/*48 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*49 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*50 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*51 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*52 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*53 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*54 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*55 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*56 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*57 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*58 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*59 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*60 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*61 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*62 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*63 */  0 | (VTRECV_STATE_CSI_IGNORE << 4),
+		/*64 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*65 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*66 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*67 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*68 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*69 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*70 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*71 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*72 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*73 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*74 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*75 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*76 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*77 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*78 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*79 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*80 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*81 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*82 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*83 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*84 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*85 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*86 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*87 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*88 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*89 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*90 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*91 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*92 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*93 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*94 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*95 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*96 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*97 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*98 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*99 */  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*100*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*101*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*102*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*103*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*104*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*105*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*106*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*107*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*108*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*109*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*110*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*111*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*112*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*113*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*114*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*115*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*116*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*117*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*118*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*119*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*120*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*121*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*122*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*123*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*124*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*125*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*126*/  VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_DCS_ENTRY = 4 */
+		/*0  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*1  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*2  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*3  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*4  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*5  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*6  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*7  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*8  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*9  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*10 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*11 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*12 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*13 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*14 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*15 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*16 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*17 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*18 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*19 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*20 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*21 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*22 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*23 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*29 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*30 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*31 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*48 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*49 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*50 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*51 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*52 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*53 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*54 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*55 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*56 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*57 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*58 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*59 */  VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4),
+		/*60 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_PARAM << 4),
+		/*61 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_PARAM << 4),
+		/*62 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_PARAM << 4),
+		/*63 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_PARAM << 4),
+		/*64 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*65 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*66 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*67 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*68 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*69 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*70 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*71 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*72 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*73 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*74 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*75 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*76 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*77 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*78 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*79 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*80 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*81 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*82 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*83 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*84 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*85 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*86 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*87 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*88 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*89 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*90 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*91 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*92 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*93 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*94 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*95 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*96 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*97 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*98 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*99 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*100*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*101*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*102*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*103*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*104*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*105*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*106*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*107*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*108*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*109*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*110*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*111*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*112*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*113*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*114*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*115*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*116*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*117*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*118*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*119*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*120*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*121*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*122*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*123*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*124*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*125*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*126*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_DCS_IGNORE = 5 */
+		/*0  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*1  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*2  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*3  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*4  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*5  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*6  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*7  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*8  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*9  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*10 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*11 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*12 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*13 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*14 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*15 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*16 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*17 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*18 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*19 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*20 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*21 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*22 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*23 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*29 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*30 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*31 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*32 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*33 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*34 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*35 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*36 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*37 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*38 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*39 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*40 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*41 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*42 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*43 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*44 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*45 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*46 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*47 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*48 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*49 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*50 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*51 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*52 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*53 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*54 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*55 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*56 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*57 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*58 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*59 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*60 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*61 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*62 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*63 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*64 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*65 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*66 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*67 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*68 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*69 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*70 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*71 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*72 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*73 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*74 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*75 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*76 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*77 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*78 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*79 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*80 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*81 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*82 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*83 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*84 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*85 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*86 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*87 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*88 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*89 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*90 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*91 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*92 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*93 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*94 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*95 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*96 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*97 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*98 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*99 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*100*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*101*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*102*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*103*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*104*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*105*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*106*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*107*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*108*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*109*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*110*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*111*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*112*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*113*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*114*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*115*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*116*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*117*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*118*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*119*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*120*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*121*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*122*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*123*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*124*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*125*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*126*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_DCS_INTERMEDIATE = 6 */
+		/*0  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*1  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*2  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*3  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*4  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*5  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*6  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*7  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*8  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*9  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*10 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*11 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*12 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*13 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*14 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*15 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*16 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*17 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*18 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*19 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*20 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*21 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*22 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*23 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*29 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*30 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*31 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*48 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*49 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*50 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*51 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*52 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*53 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*54 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*55 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*56 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*57 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*58 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*59 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*60 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*61 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*62 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*63 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*64 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*65 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*66 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*67 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*68 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*69 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*70 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*71 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*72 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*73 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*74 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*75 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*76 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*77 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*78 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*79 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*80 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*81 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*82 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*83 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*84 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*85 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*86 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*87 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*88 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*89 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*90 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*91 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*92 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*93 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*94 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*95 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*96 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*97 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*98 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*99 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*100*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*101*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*102*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*103*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*104*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*105*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*106*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*107*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*108*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*109*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*110*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*111*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*112*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*113*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*114*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*115*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*116*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*117*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*118*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*119*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*120*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*121*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*122*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*123*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*124*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*125*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*126*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_DCS_PARAM = 7 */
+		/*0  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*1  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*2  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*3  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*4  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*5  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*6  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*7  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*8  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*9  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*10 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*11 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*12 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*13 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*14 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*15 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*16 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*17 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*18 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*19 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*20 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*21 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*22 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*23 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*29 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*30 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*31 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4),
+		/*48 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*49 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*50 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*51 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*52 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*53 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*54 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*55 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*56 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*57 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*58 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*59 */  VTRECV_ACTION_PARAM | (0 << 4),
+		/*60 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*61 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*62 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*63 */  0 | (VTRECV_STATE_DCS_IGNORE << 4),
+		/*64 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*65 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*66 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*67 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*68 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*69 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*70 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*71 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*72 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*73 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*74 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*75 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*76 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*77 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*78 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*79 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*80 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*81 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*82 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*83 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*84 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*85 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*86 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*87 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*88 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*89 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*90 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*91 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*92 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*93 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*94 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*95 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*96 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*97 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*98 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*99 */  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*100*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*101*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*102*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*103*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*104*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*105*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*106*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*107*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*108*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*109*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*110*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*111*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*112*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*113*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*114*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*115*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*116*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*117*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*118*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*119*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*120*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*121*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*122*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*123*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*124*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*125*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*126*/  0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_DCS_PASSTHROUGH = 8 */
+		/*0  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*1  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*2  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*3  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*4  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*5  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*6  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*7  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*8  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*9  */  VTRECV_ACTION_PUT | (0 << 4),
+		/*10 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*11 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*12 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*13 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*14 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*15 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*16 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*17 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*18 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*19 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*20 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*21 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*22 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*23 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*29 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*30 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*31 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*32 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*33 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*34 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*35 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*36 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*37 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*38 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*39 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*40 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*41 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*42 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*43 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*44 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*45 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*46 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*47 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*48 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*49 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*50 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*51 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*52 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*53 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*54 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*55 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*56 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*57 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*58 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*59 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*60 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*61 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*62 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*63 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*64 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*65 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*66 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*67 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*68 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*69 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*70 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*71 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*72 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*73 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*74 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*75 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*76 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*77 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*78 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*79 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*80 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*81 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*82 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*83 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*84 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*85 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*86 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*87 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*88 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*89 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*90 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*91 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*92 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*93 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*94 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*95 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*96 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*97 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*98 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*99 */  VTRECV_ACTION_PUT | (0 << 4),
+		/*100*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*101*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*102*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*103*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*104*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*105*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*106*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*107*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*108*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*109*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*110*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*111*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*112*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*113*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*114*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*115*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*116*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*117*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*118*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*119*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*120*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*121*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*122*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*123*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*124*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*125*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*126*/  VTRECV_ACTION_PUT | (0 << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_ESCAPE = 9 */
+		/*0  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*1  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*2  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*3  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*4  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*5  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*6  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*7  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*8  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*9  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*10 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*11 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*12 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*13 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*14 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*15 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*16 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*17 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*18 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*19 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*20 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*21 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*22 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*23 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*29 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*30 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*31 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4),
+		/*48 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*49 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*50 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*51 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*52 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*53 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*54 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*55 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*56 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*57 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*58 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*59 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*60 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*61 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*62 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*63 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*64 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*65 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*66 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*67 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*68 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*69 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*70 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*71 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*72 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*73 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*74 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*75 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*76 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*77 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*78 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*79 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*80 */  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*81 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*82 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*83 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*84 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*85 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*86 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*87 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*88 */  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*89 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*90 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*91 */  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*92 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*93 */  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*94 */  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*95 */  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*96 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*97 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*98 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*99 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*100*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*101*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*102*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*103*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*104*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*105*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*106*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*107*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*108*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*109*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*110*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*111*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*112*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*113*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*114*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*115*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*116*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*117*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*118*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*119*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*120*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*121*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*122*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*123*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*124*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*125*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*126*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_ESCAPE_INTERMEDIATE = 10 */
+		/*0  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*1  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*2  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*3  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*4  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*5  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*6  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*7  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*8  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*9  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*10 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*11 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*12 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*13 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*14 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*15 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*16 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*17 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*18 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*19 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*20 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*21 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*22 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*23 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*29 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*30 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*31 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*32 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*33 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*34 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*35 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*36 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*37 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*38 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*39 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*40 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*41 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*42 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*43 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*44 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*45 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*46 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*47 */  VTRECV_ACTION_COLLECT | (0 << 4),
+		/*48 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*49 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*50 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*51 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*52 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*53 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*54 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*55 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*56 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*57 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*58 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*59 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*60 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*61 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*62 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*63 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*64 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*65 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*66 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*67 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*68 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*69 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*70 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*71 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*72 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*73 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*74 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*75 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*76 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*77 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*78 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*79 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*80 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*81 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*82 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*83 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*84 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*85 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*86 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*87 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*88 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*89 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*90 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*91 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*92 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*93 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*94 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*95 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*96 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*97 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*98 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*99 */  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*100*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*101*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*102*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*103*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*104*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*105*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*106*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*107*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*108*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*109*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*110*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*111*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*112*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*113*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*114*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*115*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*116*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*117*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*118*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*119*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*120*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*121*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*122*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*123*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*124*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*125*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*126*/  VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_GROUND = 11 */
+		/*0  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*1  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*2  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*3  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*4  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*5  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*6  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*7  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*8  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*9  */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*10 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*11 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*12 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*13 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*14 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*15 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*16 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*17 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*18 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*19 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*20 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*21 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*22 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*23 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*29 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*30 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*31 */  VTRECV_ACTION_EXECUTE | (0 << 4),
+		/*32 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*33 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*34 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*35 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*36 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*37 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*38 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*39 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*40 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*41 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*42 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*43 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*44 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*45 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*46 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*47 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*48 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*49 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*50 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*51 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*52 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*53 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*54 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*55 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*56 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*57 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*58 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*59 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*60 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*61 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*62 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*63 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*64 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*65 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*66 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*67 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*68 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*69 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*70 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*71 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*72 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*73 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*74 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*75 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*76 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*77 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*78 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*79 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*80 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*81 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*82 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*83 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*84 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*85 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*86 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*87 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*88 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*89 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*90 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*91 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*92 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*93 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*94 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*95 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*96 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*97 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*98 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*99 */  VTRECV_ACTION_PRINT | (0 << 4),
+		/*100*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*101*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*102*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*103*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*104*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*105*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*106*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*107*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*108*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*109*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*110*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*111*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*112*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*113*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*114*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*115*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*116*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*117*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*118*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*119*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*120*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*121*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*122*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*123*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*124*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*125*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*126*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*127*/  VTRECV_ACTION_PRINT | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_OSC_STRING = 12 */
+		/*0  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*1  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*2  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*3  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*4  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*5  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*6  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*7  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*8  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*9  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*10 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*11 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*12 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*13 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*14 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*15 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*16 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*17 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*18 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*19 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*20 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*21 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*22 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*23 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*29 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*30 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*31 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*32 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*33 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*34 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*35 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*36 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*37 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*38 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*39 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*40 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*41 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*42 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*43 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*44 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*45 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*46 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*47 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*48 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*49 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*50 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*51 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*52 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*53 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*54 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*55 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*56 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*57 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*58 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*59 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*60 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*61 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*62 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*63 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*64 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*65 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*66 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*67 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*68 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*69 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*70 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*71 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*72 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*73 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*74 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*75 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*76 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*77 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*78 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*79 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*80 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*81 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*82 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*83 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*84 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*85 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*86 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*87 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*88 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*89 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*90 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*91 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*92 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*93 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*94 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*95 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*96 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*97 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*98 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*99 */  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*100*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*101*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*102*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*103*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*104*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*105*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*106*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*107*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*108*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*109*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*110*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*111*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*112*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*113*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*114*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*115*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*116*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*117*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*118*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*119*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*120*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*121*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*122*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*123*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*124*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*125*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*126*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*127*/  VTRECV_ACTION_OSC_PUT | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+	{	/* VTRECV_STATE_SOS_PM_APC_STRING = 13 */
+		/*0  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*1  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*2  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*3  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*4  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*5  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*6  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*7  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*8  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*9  */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*10 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*11 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*12 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*13 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*14 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*15 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*16 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*17 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*18 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*19 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*20 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*21 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*22 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*23 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*24 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*25 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*26 */  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*27 */  0 | (VTRECV_STATE_ESCAPE << 4),
+		/*28 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*29 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*30 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*31 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*32 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*33 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*34 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*35 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*36 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*37 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*38 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*39 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*40 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*41 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*42 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*43 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*44 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*45 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*46 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*47 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*48 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*49 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*50 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*51 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*52 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*53 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*54 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*55 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*56 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*57 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*58 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*59 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*60 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*61 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*62 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*63 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*64 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*65 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*66 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*67 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*68 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*69 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*70 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*71 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*72 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*73 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*74 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*75 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*76 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*77 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*78 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*79 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*80 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*81 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*82 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*83 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*84 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*85 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*86 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*87 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*88 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*89 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*90 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*91 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*92 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*93 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*94 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*95 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*96 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*97 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*98 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*99 */  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*100*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*101*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*102*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*103*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*104*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*105*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*106*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*107*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*108*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*109*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*110*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*111*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*112*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*113*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*114*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*115*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*116*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*117*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*118*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*119*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*120*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*121*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*122*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*123*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*124*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*125*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*126*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*127*/  VTRECV_ACTION_IGNORE | (0 << 4),
+		/*128*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*129*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*130*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*131*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*132*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*133*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*134*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*135*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*136*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*137*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*138*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*139*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*140*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*141*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*142*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*143*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*144*/  0 | (VTRECV_STATE_DCS_ENTRY << 4),
+		/*145*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*146*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*147*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*148*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*149*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*150*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*151*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*152*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*153*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*154*/  VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4),
+		/*155*/  0 | (VTRECV_STATE_CSI_ENTRY << 4),
+		/*156*/  0 | (VTRECV_STATE_GROUND << 4),
+		/*157*/  0 | (VTRECV_STATE_OSC_STRING << 4),
+		/*158*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+		/*159*/  0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4),
+	},
+};
+#else
+typedef struct
+{
+	int state;
+	unsigned char code_start;
+	unsigned char code_end;
+	state_change_t state_change;
+} state_table_t;
+
+static const state_table_t table[] = {
+	/*
+	 */
+	{  VTRECV_STATE_CSI_ENTRY,   0,  23, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  25,  25, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  28,  31, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  32,  47, VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  48,  57, VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  58,  58, 0 | (VTRECV_STATE_CSI_IGNORE << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  59,  59, VTRECV_ACTION_PARAM | (VTRECV_STATE_CSI_PARAM << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  60,  63, VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_PARAM << 4) },
+	{  VTRECV_STATE_CSI_ENTRY,  64, 126, VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_CSI_ENTRY, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_CSI_IGNORE,   0,  23, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_IGNORE,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_IGNORE,  25,  25, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_IGNORE,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_IGNORE,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_CSI_IGNORE,  28,  31, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_IGNORE,  32,  63, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_CSI_IGNORE,  64, 126, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_CSI_IGNORE, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_CSI_INTERMEDIATE,   0,  23, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  25,  25, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  28,  31, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  32,  47, VTRECV_ACTION_COLLECT | (0 << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  48,  63, 0 | (VTRECV_STATE_CSI_IGNORE << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE,  64, 126, VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_CSI_INTERMEDIATE, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_CSI_PARAM,   0,  23, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  25,  25, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  28,  31, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  32,  47, VTRECV_ACTION_COLLECT | (VTRECV_STATE_CSI_INTERMEDIATE << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  48,  57, VTRECV_ACTION_PARAM | (0 << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  58,  58, 0 | (VTRECV_STATE_CSI_IGNORE << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  59,  59, VTRECV_ACTION_PARAM | (0 << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  60,  63, 0 | (VTRECV_STATE_CSI_IGNORE << 4) },
+	{  VTRECV_STATE_CSI_PARAM,  64, 126, VTRECV_ACTION_CSI_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_CSI_PARAM, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_DCS_ENTRY,   0,  23, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  25,  25, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  28,  31, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  32,  47, VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  48,  57, VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  58,  58, 0 | (VTRECV_STATE_DCS_IGNORE << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  59,  59, VTRECV_ACTION_PARAM | (VTRECV_STATE_DCS_PARAM << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  60,  63, VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_PARAM << 4) },
+	{  VTRECV_STATE_DCS_ENTRY,  64, 126, 0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_DCS_ENTRY, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_DCS_IGNORE,   0,  23, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_IGNORE,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_IGNORE,  25,  25, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_IGNORE,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_IGNORE,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_DCS_IGNORE,  28, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_DCS_IGNORE, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_DCS_INTERMEDIATE,   0,  23, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  25,  25, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  28,  31, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  32,  47, VTRECV_ACTION_COLLECT | (0 << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  48,  63, 0 | (VTRECV_STATE_DCS_IGNORE << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE,  64, 126, 0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_DCS_INTERMEDIATE, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_DCS_PARAM,   0,  23, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  25,  25, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  28,  31, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  32,  47, VTRECV_ACTION_COLLECT | (VTRECV_STATE_DCS_INTERMEDIATE << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  48,  57, VTRECV_ACTION_PARAM | (0 << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  58,  58, 0 | (VTRECV_STATE_DCS_IGNORE << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  59,  59, VTRECV_ACTION_PARAM | (0 << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  60,  63, 0 | (VTRECV_STATE_DCS_IGNORE << 4) },
+	{  VTRECV_STATE_DCS_PARAM,  64, 126, 0 | (VTRECV_STATE_DCS_PASSTHROUGH << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_DCS_PARAM, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_DCS_PASSTHROUGH,   0,  23, VTRECV_ACTION_PUT | (0 << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH,  25,  25, VTRECV_ACTION_PUT | (0 << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH,  28, 126, VTRECV_ACTION_PUT | (0 << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_DCS_PASSTHROUGH, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_ESCAPE,   0,  23, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE,  25,  25, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_ESCAPE,  28,  31, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE,  32,  47, VTRECV_ACTION_COLLECT | (VTRECV_STATE_ESCAPE_INTERMEDIATE << 4) },
+	{  VTRECV_STATE_ESCAPE,  48,  79, VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE,  80,  80, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_ESCAPE,  81,  87, VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE,  88,  88, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_ESCAPE,  89,  90, VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE,  91,  91, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_ESCAPE,  92,  92, VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE,  93,  93, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_ESCAPE,  94,  95, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_ESCAPE,  96, 126, VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_ESCAPE, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_ESCAPE, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_ESCAPE, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_ESCAPE, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,   0,  23, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,  25,  25, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,  28,  31, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,  32,  47, VTRECV_ACTION_COLLECT | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE,  48, 126, VTRECV_ACTION_ESC_DISPATCH | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 127, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_ESCAPE_INTERMEDIATE, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_GROUND,   0,  23, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_GROUND,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_GROUND,  25,  25, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_GROUND,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_GROUND,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_GROUND,  28,  31, VTRECV_ACTION_EXECUTE | (0 << 4) },
+	{  VTRECV_STATE_GROUND,  32, 127, VTRECV_ACTION_PRINT | (0 << 4) },
+	{  VTRECV_STATE_GROUND, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_GROUND, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_GROUND, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_GROUND, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_GROUND, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_GROUND, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_GROUND, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_GROUND, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_GROUND, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_OSC_STRING,   0,  23, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_OSC_STRING,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_OSC_STRING,  25,  25, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_OSC_STRING,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_OSC_STRING,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_OSC_STRING,  28,  31, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_OSC_STRING,  32, 127, VTRECV_ACTION_OSC_PUT | (0 << 4) },
+	{  VTRECV_STATE_OSC_STRING, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_OSC_STRING, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_OSC_STRING, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_OSC_STRING, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_OSC_STRING, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_OSC_STRING, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_OSC_STRING, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_OSC_STRING, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_OSC_STRING, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	/*
+	 */
+	{  VTRECV_STATE_SOS_PM_APC_STRING,   0,  23, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING,  24,  24, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING,  25,  25, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING,  26,  26, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING,  27,  27, 0 | (VTRECV_STATE_ESCAPE << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING,  28, 127, VTRECV_ACTION_IGNORE | (0 << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 128, 143, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 144, 144, 0 | (VTRECV_STATE_DCS_ENTRY << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 145, 151, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 152, 152, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 153, 154, VTRECV_ACTION_EXECUTE | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 155, 155, 0 | (VTRECV_STATE_CSI_ENTRY << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 156, 156, 0 | (VTRECV_STATE_GROUND << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 157, 157, 0 | (VTRECV_STATE_OSC_STRING << 4) },
+	{  VTRECV_STATE_SOS_PM_APC_STRING, 158, 159, 0 | (VTRECV_STATE_SOS_PM_APC_STRING << 4) },
+};
+#endif
+
+static const vtrecv_action_t ENTRY_ACTIONS[] = {
+   VTRECV_ACTION_CLEAR, /* CSI_ENTRY */
+   0  /* none for CSI_IGNORE */,
+   0  /* none for CSI_INTERMEDIATE */,
+   0  /* none for CSI_PARAM */,
+   VTRECV_ACTION_CLEAR, /* DCS_ENTRY */
+   0  /* none for DCS_IGNORE */,
+   0  /* none for DCS_INTERMEDIATE */,
+   0  /* none for DCS_PARAM */,
+   VTRECV_ACTION_HOOK, /* DCS_PASSTHROUGH */
+   VTRECV_ACTION_CLEAR, /* ESCAPE */
+   0  /* none for ESCAPE_INTERMEDIATE */,
+   0  /* none for GROUND */,
+   VTRECV_ACTION_OSC_START, /* OSC_STRING */
+   0  /* none for SOS_PM_APC_STRING */,
+};
+
+static const vtrecv_action_t EXIT_ACTIONS[] = {
+   0  /* none for CSI_ENTRY */,
+   0  /* none for CSI_IGNORE */,
+   0  /* none for CSI_INTERMEDIATE */,
+   0  /* none for CSI_PARAM */,
+   0  /* none for DCS_ENTRY */,
+   0  /* none for DCS_IGNORE */,
+   0  /* none for DCS_INTERMEDIATE */,
+   0  /* none for DCS_PARAM */,
+   VTRECV_ACTION_UNHOOK, /* DCS_PASSTHROUGH */
+   0  /* none for ESCAPE */,
+   0  /* none for ESCAPE_INTERMEDIATE */,
+   0  /* none for GROUND */,
+   VTRECV_ACTION_OSC_END, /* OSC_STRING */
+   0  /* none for SOS_PM_APC_STRING */,
+};
+
+state_change_t GET_STATE_TABLE(const int state, const int ch)
+{
+	if ((state == VTRECV_STATE_GROUND) && (((ch >= 32) && (ch <= 127)) || (ch >= 160))) {
+		return VTRECV_ACTION_PRINT | (0 << 4);
+	}
+#if (USE_ORIGINAL_LUT==1)
+	/*
+	 * ãã¼ãã«åç
+§ã«ããå®ç¾ã
+	 * åºå®æéã§åä½ããããã³ã¼ããµã¤ãºã¯æ¯è¼çå¤§ããã
+	 */
+	return STATE_TABLE[state - 1][ch];
+#else
+	/*
+	 * ãã­ã°ã©ã ã«ããç·å½¢æ¢ç´¢ãã¼ã¸ã§ã³ã
+	 * ãã¼ãã«ã®å¾æ¹ã«ãããã¼ã¿ã«ãªãã»ã©åä½ã¯é
+ãã
+	 * ã³ã¼ããµã¤ãºã¯ãã¼ãã«åç
+§ãããå°ããã
+	 */
+	const int N = sizeof(table) / sizeof(table[0]);
+	const state_table_t *tp = &table[0];
+	int i;
+	for (i = 0; i < N; i++) {
+		if (tp->state == state) {
+			if ((tp->code_start <= ch) && (ch <= tp->code_end)) {
+				return tp->state_change;
+			}
+		}
+		tp++;
+	}
+	return 0;
+#endif
+}
+
+vtrecv_action_t GET_ENTRY_ACTIONS(const int state)
+{
+	return ENTRY_ACTIONS[state];
+}
+
+vtrecv_action_t GET_EXIT_ACTIONS(const int state)
+{
+	return EXIT_ACTIONS[state];
+}
+
+void vtrecv_init(vtrecv_t *parser, vtrecv_callback_t cb)
+{
+	parser->utf8_state = 0;
+	parser->ch = 0;
+	parser->state = VTRECV_STATE_GROUND;
+	parser->num_intermediate_chars = 0;
+	parser->num_params = 0;
+	parser->ignore_flagged = 0;
+	parser->cb = cb;
+}
+
+static void do_action(vtrecv_t *parser, vtrecv_action_t action, unsigned int ch)
+{
+	/* Some actions we handle internally (like parsing parameters), others
+	 * we hand to our client for processing */
+
+	switch (action) {
+	case VTRECV_ACTION_PRINT:
+	case VTRECV_ACTION_EXECUTE:
+	case VTRECV_ACTION_HOOK:
+	case VTRECV_ACTION_PUT:
+	case VTRECV_ACTION_OSC_START:
+	case VTRECV_ACTION_OSC_PUT:
+	case VTRECV_ACTION_OSC_END:
+	case VTRECV_ACTION_UNHOOK:
+	case VTRECV_ACTION_CSI_DISPATCH:
+	case VTRECV_ACTION_ESC_DISPATCH:
+		parser->cb(parser, action, ch);
+		break;
+
+	case VTRECV_ACTION_IGNORE:
+		/* do nothing */
+		break;
+
+	case VTRECV_ACTION_COLLECT:
+	{
+		/* Append the character to the intermediate params */
+		if (parser->num_intermediate_chars + 1 > MAX_INTERMEDIATE_CHARS) {
+			parser->ignore_flagged = 1;
+		}
+		else {
+			parser->intermediate_chars[parser->num_intermediate_chars++] = ch;
+		}
+
+		break;
+	}
+
+	case VTRECV_ACTION_PARAM:
+	{
+		/* process the param character */
+		if (ch == ';') {
+			parser->num_params += 1;
+			parser->params[parser->num_params - 1] = 0;
+		}
+		else {
+			/* the character is a digit */
+			int current_param;
+
+			if (parser->num_params == 0) {
+				parser->num_params = 1;
+				parser->params[0] = 0;
+			}
+
+			current_param = parser->num_params - 1;
+			parser->params[current_param] *= 10;
+			parser->params[current_param] += (ch - '0');
+		}
+
+		break;
+	}
+
+	case VTRECV_ACTION_CLEAR:
+		parser->num_intermediate_chars = 0;
+		parser->num_params = 0;
+		parser->ignore_flagged = 0;
+		break;
+
+	default:
+		parser->cb(parser, VTRECV_ACTION_ERROR, 0);
+		break;
+	}
+}
+
+static void do_state_change(vtrecv_t *parser, state_change_t change, unsigned int ch)
+{
+	/* A state change is an action and/or a new state to transition to. */
+
+	vtrecv_state_t new_state = STATE(change);
+	vtrecv_action_t action = ACTION(change);
+
+	if (new_state) {
+		/*
+		 * Perform up to three actions:
+		 *   1. the exit action of the old state
+		 *   2. the action associated with the transition
+		 *   3. the entry action of the new state
+		 */
+
+		vtrecv_action_t exit_action = GET_EXIT_ACTIONS(parser->state - 1);
+		vtrecv_action_t entry_action = GET_ENTRY_ACTIONS(new_state - 1);
+
+		if (exit_action) {
+			do_action(parser, exit_action, 0);
+		}
+
+		if (action) {
+			do_action(parser, action, ch);
+		}
+
+		if (entry_action) {
+			do_action(parser, entry_action, 0);
+		}
+
+		parser->state = new_state;
+	}
+	else {
+		do_action(parser, action, ch);
+	}
+}
+
+void vtrecv_execute(vtrecv_t *parser, unsigned char *data, int len)
+{
+	int i;
+	for (i = 0; i < len; i++) {
+		unsigned char c = data[i];
+		/* UTF-8 => UNICODE */
+		switch (parser->utf8_state) {
+		case 0:
+			if (c <= 0x7F) {
+				parser->ch = c;
+				break;
+			}
+			else if ((c & 0xE0) == 0xC0) {
+				parser->ch = (c & 0x1F) << 6;
+				parser->utf8_state = 1;
+				continue;
+			}
+			else if ((c & 0xF0) == 0xE0) {
+				parser->ch = (c & 0x0F) << 12;
+				parser->utf8_state = 2;
+				continue;
+			}
+			else if ((c & 0xF8) == 0xF0) {
+				parser->ch = (c & 0x07) << 18;
+				parser->utf8_state = 3;
+				continue;
+			}
+			else if ((c & 0xFC) == 0xF8) {
+				parser->ch = (c & 0x03) << 24;
+				parser->utf8_state = 4;
+				continue;
+			}
+			else if ((c & 0xFE) == 0xFC) {
+				parser->ch = (c & 0x01) << 30;
+				parser->utf8_state = 5;
+				continue;
+			}
+			else if (c == 0xFF) {
+				return;
+			}
+		default:
+			if ((c & 0xC0) == 0x80) {
+				parser->utf8_state--;
+				parser->ch |= (c & 0x3F) << (6 * parser->utf8_state);
+				if (parser->utf8_state != 0)
+					continue;
+			}
+			/* UTF-8 Error */
+			else {
+				i--;
+				parser->utf8_state = 0;
+			}
+			break;
+		}
+		state_change_t change = GET_STATE_TABLE(parser->state, parser->ch);
+		do_state_change(parser, change, parser->ch);
+		parser->ch = 0;
+	}
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/vtrecv.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/vtrecv.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/vtrecv.h	(revision 279)
@@ -0,0 +1,143 @@
+/**
+ * @file vtrecv.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * @note
+ * An implementation of Paul Williams' DEC compatible state machine parser.
+ * This code is in the public domain.
+ *
+ * @author Joshua Haberman <joshua@reverberate.org>
+ * @author Shinichiro Nakamura : Modified for Natural Tiny Shell (NT-Shell)
+ */
+
+#ifndef VTRECV_H
+#define VTRECV_H
+
+/**
+ * @brief ãªãªã¸ãã«ã«å«ã¾ããLUTãä½¿ããã©ãããæ±ºå®ããã
+ * @details
+ * ãªãªã¸ãã«ã§ã¯ãã·ã¼ã±ã³ã¹ã®é·ç§»ããã¼ãã«åç
+§ã§å®è£
+ãã¦ãã£ãã
+ * 15ã®ã¹ãã¼ãã§åããã256ãã¿ã¼ã³ã®å
+¥åãå
+¨ç¶²ç¾
+ãããã¼ãã«ã§ããã
+ * ããã¯3840åã®ãã¼ãã«ãã¼ã¿ãæã¤ãã¨ã«ãªãã
+ *
+ * ãã¼ãã«åç
+§ã¯ã¡ã¢ãªã«å¯¾ãã¦ãªãã¢ã¢ã¯ã»ã¹å¯è½ãªãã­ã»ããµã«ããã¦
+ * åºå®æéã§åä½ããããã¼ãã«åç
+§ã®ã¡ãªããã¯åºå®æéã§ã®å¦çã§ããã
+ *
+ * ä¸æ¹ãæ°ãã«å®è£
+ããæ¹æ³ã¯ãéè¤ãããã¼ã¿ãå¤æ°å­å¨ããäºã«çç®ãã
+ * ãã®ã§ãåºéæ¯ã«é©ç¨ããã·ã¼ã±ã³ã¹ãå®ç¾©ãããã¼ãã«ãç¨ããã
+ * ããã¯ãã¼ãã«ãç·å½¢æ¢ç´¢ããããå¾æ¹ã«ãããã¼ã¿ã«ãªãã»ã©åä½ã¯é
+ãã
+ * ããããã³ã¼ããµã¤ãºã¯ãªãªã¸ãã«ã®å
+¨ç¶²ç¾
+å½¢å¼ã®ãã¼ãã«ãããå°ããã
+ *
+ * @retval 0 ä½¿ããªãã
+ * @retval 1 ä½¿ãã
+ */
+#define USE_ORIGINAL_LUT (0)
+
+#define MAX_INTERMEDIATE_CHARS 2
+#define ACTION(state_change) (vtrecv_action_t)((state_change & 0x0F) >> 0)
+#define STATE(state_change)  (vtrecv_state_t)((state_change & 0xF0) >> 4)
+
+typedef enum {
+	VTRECV_STATE_CSI_ENTRY = 1,
+	VTRECV_STATE_CSI_IGNORE = 2,
+	VTRECV_STATE_CSI_INTERMEDIATE = 3,
+	VTRECV_STATE_CSI_PARAM = 4,
+	VTRECV_STATE_DCS_ENTRY = 5,
+	VTRECV_STATE_DCS_IGNORE = 6,
+	VTRECV_STATE_DCS_INTERMEDIATE = 7,
+	VTRECV_STATE_DCS_PARAM = 8,
+	VTRECV_STATE_DCS_PASSTHROUGH = 9,
+	VTRECV_STATE_ESCAPE = 10,
+	VTRECV_STATE_ESCAPE_INTERMEDIATE = 11,
+	VTRECV_STATE_GROUND = 12,
+	VTRECV_STATE_OSC_STRING = 13,
+	VTRECV_STATE_SOS_PM_APC_STRING = 14,
+} vtrecv_state_t;
+
+typedef enum {
+	VTRECV_ACTION_CLEAR = 1,
+	VTRECV_ACTION_COLLECT = 2,
+	VTRECV_ACTION_CSI_DISPATCH = 3,
+	VTRECV_ACTION_ESC_DISPATCH = 4,
+	VTRECV_ACTION_EXECUTE = 5,
+	VTRECV_ACTION_HOOK = 6,
+	VTRECV_ACTION_IGNORE = 7,
+	VTRECV_ACTION_OSC_END = 8,
+	VTRECV_ACTION_OSC_PUT = 9,
+	VTRECV_ACTION_OSC_START = 10,
+	VTRECV_ACTION_PARAM = 11,
+	VTRECV_ACTION_PRINT = 12,
+	VTRECV_ACTION_PUT = 13,
+	VTRECV_ACTION_UNHOOK = 14,
+	VTRECV_ACTION_ERROR = 15,
+} vtrecv_action_t;
+
+typedef unsigned char state_change_t;
+struct vtrecv;
+typedef void (*vtrecv_callback_t)(struct vtrecv*, vtrecv_action_t, unsigned int);
+typedef struct vtrecv {
+	int                utf8_state;
+	unsigned int       ch;
+	vtrecv_state_t     state;
+	vtrecv_callback_t  cb;
+	unsigned char      intermediate_chars[MAX_INTERMEDIATE_CHARS+1];
+	int                num_intermediate_chars;
+	char               ignore_flagged;
+	int                params[16];
+	int                num_params;
+	void*              user_data;
+} vtrecv_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void vtrecv_init(vtrecv_t *parser, vtrecv_callback_t cb);
+void vtrecv_execute(vtrecv_t *parser, unsigned char *data, int len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/vtsend.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/vtsend.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/vtsend.c	(revision 279)
@@ -0,0 +1,270 @@
+/**
+ * @file vtsend.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "vtsend.h"
+
+#define ESC (0x1B)
+#define UART_WRITE(P, BUF, SIZ)   (P)->uart_write(BUF, SIZ, (P)->extobj)
+
+int vtsend_init(vtsend_t *p, VTSEND_SERIAL_WRITE uart_write, void *extobj)
+{
+	p->uart_write = uart_write;
+	p->extobj = extobj;
+	return 0;
+}
+
+int vtsend_cursor_position(vtsend_t *p, const int column, const int line)
+{
+	char buf[8];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + (line / 10);
+	buf[3] = '0' + (line % 10);
+	buf[4] = ';';
+	buf[5] = '0' + (column / 10);
+	buf[6] = '0' + (column % 10);
+	buf[7] = 'H';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_cursor_up(vtsend_t *p, const int n)
+{
+	char buf[5];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + (n / 10);
+	buf[3] = '0' + (n % 10);
+	buf[4] = 'A';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_cursor_down(vtsend_t *p, const int n)
+{
+	char buf[5];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + (n / 10);
+	buf[3] = '0' + (n % 10);
+	buf[4] = 'B';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_cursor_forward(vtsend_t *p, const int n)
+{
+	char buf[5];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + (n / 10);
+	buf[3] = '0' + (n % 10);
+	buf[4] = 'C';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_cursor_backward(vtsend_t *p, const int n)
+{
+	char buf[5];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + (n / 10);
+	buf[3] = '0' + (n % 10);
+	buf[4] = 'D';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_cursor_position_save(vtsend_t *p)
+{
+	char buf[3];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = 's';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_cursor_position_restore(vtsend_t *p)
+{
+	char buf[3];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = 'u';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_erase_display(vtsend_t *p)
+{
+	char buf[4];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '2';
+	buf[3] = 'J';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_erase_line(vtsend_t *p)
+{
+	char buf[4];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '2';
+	buf[3] = 'K';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_set_color_foreground(vtsend_t *p, const int color)
+{
+	char buf[5];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + ((30 + color) / 10);
+	buf[3] = '0' + ((30 + color) % 10);
+	buf[4] = 'm';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_set_color_background(vtsend_t *p, const int color)
+{
+	char buf[5];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + ((40 + color) / 10);
+	buf[3] = '0' + ((40 + color) % 10);
+	buf[4] = 'm';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_set_attribute(vtsend_t *p, const int attr)
+{
+	char buf[5];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + ((attr) / 10);
+	buf[3] = '0' + ((attr) % 10);
+	buf[4] = 'm';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_set_scroll_region(vtsend_t *p, const int top, const int bottom)
+{
+	char buf[8];
+	buf[0] = ESC;
+	buf[1] = '[';
+	buf[2] = '0' + (top / 10);
+	buf[3] = '0' + (top % 10);
+	buf[4] = ';';
+	buf[5] = '0' + (bottom / 10);
+	buf[6] = '0' + (bottom % 10);
+	buf[7] = 'r';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_set_cursor(vtsend_t *p, const int visible)
+{
+	if (visible) {
+		char buf[6];
+		buf[0] = ESC;
+		buf[1] = '[';
+		buf[2] = '?';
+		buf[3] = '2';
+		buf[4] = '5';
+		buf[5] = 'h';
+		UART_WRITE(p, buf, sizeof(buf));
+	}
+	else {
+		char buf[6];
+		buf[0] = ESC;
+		buf[1] = '[';
+		buf[2] = '?';
+		buf[3] = '2';
+		buf[4] = '5';
+		buf[5] = 'l';
+		UART_WRITE(p, buf, sizeof(buf));
+	}
+	return 0;
+}
+
+int vtsend_reset(vtsend_t *p)
+{
+	char buf[2];
+	buf[0] = ESC;
+	buf[1] = 'c';
+	UART_WRITE(p, buf, sizeof(buf));
+	return 0;
+}
+
+int vtsend_draw_box(
+	vtsend_t *p,
+	const int x1, const int y1, const int x2, const int y2)
+{
+	int i;
+
+	vtsend_cursor_position(p, x1, y1);
+	for (i = x1; i <= x2; i++) {
+		UART_WRITE(p, " ", 1);
+	}
+	vtsend_cursor_position(p, x1, y2);
+	for (i = x1; i <= x2; i++) {
+		UART_WRITE(p, " ", 1);
+	}
+	for (i = y1; i <= y2; i++) {
+		vtsend_cursor_position(p, x1, i);
+		UART_WRITE(p, " ", 1);
+		vtsend_cursor_position(p, x2, i);
+		UART_WRITE(p, " ", 1);
+	}
+	return 0;
+}
+
+int vtsend_fill_box(
+	vtsend_t *p,
+	const int x1, const int y1, const int x2, const int y2)
+{
+	int i, j;
+	for (i = y1; i <= y2; i++) {
+		vtsend_cursor_position(p, x1, i);
+		for (j = x1; j <= x2; j++) {
+			UART_WRITE(p, " ", 1);
+		}
+	}
+	return 0;
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/core/vtsend.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/core/vtsend.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/core/vtsend.h	(revision 279)
@@ -0,0 +1,92 @@
+/**
+ * @file vtsend.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VTSEND_H
+#define VTSEND_H
+
+#define VTSEND_COLOR_BLACK      (0)
+#define VTSEND_COLOR_RED        (1)
+#define VTSEND_COLOR_GREEN      (2)
+#define VTSEND_COLOR_YELLOW     (3)
+#define VTSEND_COLOR_BLUE       (4)
+#define VTSEND_COLOR_MAGENTA    (5)
+#define VTSEND_COLOR_CYAN       (6)
+#define VTSEND_COLOR_WHITE      (7)
+
+#define VTSEND_ATTR_OFF             (0)
+#define VTSEND_ATTR_BOLD_ON         (1)
+#define VTSEND_ATTR_UNDERSCORE      (4)
+#define VTSEND_ATTR_BLINK_ON        (5)
+#define VTSEND_ATTR_REVERSE         (7)
+#define VTSEND_ATTR_CONCEALED_ON    (8)
+
+typedef int (*VTSEND_SERIAL_WRITE)(const char *buf, const int siz, void *extobj);
+
+typedef struct {
+    VTSEND_SERIAL_WRITE uart_write;
+    void *extobj;
+} vtsend_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int vtsend_init(vtsend_t *p, VTSEND_SERIAL_WRITE uart_write, void *extobj);
+int vtsend_cursor_position(vtsend_t *p, const int column, const int line);
+int vtsend_cursor_up(vtsend_t *p, const int n);
+int vtsend_cursor_down(vtsend_t *p, const int n);
+int vtsend_cursor_forward(vtsend_t *p, const int n);
+int vtsend_cursor_backward(vtsend_t *p, const int n);
+int vtsend_cursor_position_save(vtsend_t *p);
+int vtsend_cursor_position_restore(vtsend_t *p);
+int vtsend_erase_display(vtsend_t *p);
+int vtsend_erase_line(vtsend_t *p);
+int vtsend_set_color_foreground(vtsend_t *p, const int color);
+int vtsend_set_color_background(vtsend_t *p, const int color);
+int vtsend_set_attribute(vtsend_t *p, const int attr);
+int vtsend_set_scroll_region(vtsend_t *p, const int top, const int bottom);
+int vtsend_set_cursor(vtsend_t *p, const int visible);
+int vtsend_reset(vtsend_t *p);
+
+int vtsend_draw_box(
+        vtsend_t *p,
+        const int x1, const int y1, const int x2, const int y2);
+int vtsend_fill_box(
+        vtsend_t *p,
+        const int x1, const int y1, const int x2, const int y2);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 279)
@@ -0,0 +1,608 @@
+/**
+ * @file usrcmd.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include <sil.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include "syssvc/syslog.h"
+#include "kernel_cfg.h"
+#include "main.h"
+#include "rza1.h"
+#include "ffarch.h"
+#include "ff.h"
+#include "usrcmd.h"
+#include "ntstdio.h"
+#include "ntshell.h"
+
+extern ntstdio_t ntstdio;
+extern int ntshell_exit;
+
+int shell_kill(int pid, int sig)
+{
+	asm("bkpt #0");
+	return -1;
+}
+
+int shell_gettimeofday(struct timeval *tv, void *tzvp)
+{
+	SYSTIM time;
+	if (!tv) return 0;
+	get_tim(&time);
+	tv->tv_sec = time / 1000000;
+	tv->tv_usec = time - (tv->tv_sec * 1000000);
+	return 0;
+}
+
+void put_rc(const char *func, FRESULT rc)
+{
+	const char *p =
+		"OK\0DISK_ERR\0INT_ERR\0NOT_READY\0NO_FILE\0NO_PATH\0INVALID_NAME\0"
+		"DENIED\0EXIST\0INVALID_OBJECT\0WRITE_PROTECTED\0INVALID_DRIVE\0"
+		"NOT_ENABLED\0NO_FILE_SYSTEM\0MKFS_ABORTED\0TIMEOUT\0LOCKED\0"
+		"NOT_ENOUGH_CORE\0TOO_MANY_OPEN_FILES\0";
+	FRESULT i;
+
+	for (i = 0; i != rc && *p; i++) {
+		while (*p++);
+	}
+	ntstdio_printf(&ntstdio, "%s() =>%u FR_%s\n", func, (UINT)rc, p);
+}
+
+void put_drc(const char *func, DRESULT rc)
+{
+	const char *p =
+		"Successful\0R/W Error\0Write Protected\0Not Ready\0Invalid Parameter\0";
+	DRESULT i;
+
+	for (i = 0; i != rc && *p; i++) {
+		while (*p++);
+	}
+	ntstdio_printf(&ntstdio, "%s() =>%u %s\n", func, (UINT)rc, p);
+}
+
+char *basename(char *s)
+{
+	size_t i, j;
+	if (!s || !*s) return ".";
+	i = strlen(s) - 1;
+	for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
+	for (; i&&s[i] == '/'; i--) s[i] = 0;
+	for (; i&&s[i - 1] != '/'; i--);
+	return s + i;
+}
+
+char *dirname(char *_s)
+{
+	char *s = _s;
+	size_t i, j;
+	if (!s || !*s) return ".";
+	i = strlen(s) - 1;
+	for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
+	for (; s[i] == '/'; i--) if (!i) return (s == _s) ? "/" : _s;
+	for (; s[i] != '/'; i--) if (!i) return (s == _s) ? "." : _s;
+	for (; s[i] == '/'; i--) if (!i) if (s == _s) return "/"; else break;
+	s[i + 1] = 0;
+	return _s;
+}
+
+int usrcmd_cd(int argc, char **argv)
+{
+	FRESULT res;
+
+	if (argc == 2) {
+		if ((res = f_chdir(argv[1])) != FR_OK) {
+			put_rc("f_chdir", res);
+			return 0;
+		}
+		if ((res = f_chdrive(argv[1]) != FR_OK)) {
+			put_rc("f_chdrive", res);
+			return 0;
+		}
+	}
+
+	char path[256];
+	if ((res = f_getcwd(path, sizeof(path))) != FR_OK) {
+		put_rc("f_getcwd", res);
+		return 0;
+	}
+
+	strlcat(path, "\n", sizeof(path));
+	ntstdio_printf(&ntstdio, path);
+
+	return 0;
+}
+
+#define LS_ALL	0x01
+#define LS_LONG	0x02
+/* lsã³ãã³ã 1è¡è¡¨ç¤º */
+void print_one_list(FILINFO *fno, BYTE list_option)
+{
+	char *fn;
+
+#if _USE_LFN
+	fn = *fno->lfname ? fno->lfname : fno->fname;
+#else
+	fn = fno->fname;
+#endif
+	if (!(list_option & LS_ALL)) {
+		if ((fno->fattrib & AM_HID) || (fn[0] == '.'))
+			return;
+	}
+
+	if (list_option & LS_LONG) {
+		ntstdio_printf(&ntstdio, "%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
+			(fno->fattrib & AM_DIR) ? 'd' : '-',
+			(fno->fattrib & AM_RDO) ? 'r' : '-',
+			(fno->fattrib & AM_HID) ? 'h' : '-',
+			(fno->fattrib & AM_SYS) ? 's' : '-',
+			(fno->fattrib & AM_ARC) ? 'a' : '-',
+			((fno->fdate & 0xFE00) >> 9) + 1980,
+			((fno->fdate & 0x01E0) >> 5),
+			( fno->fdate & 0x001F),
+			((fno->ftime & 0xF800) >> 11),
+			((fno->ftime & 0x07E0) >> 5),
+			( fno->ftime & 0x001F));
+
+		if (fno->fattrib & AM_DIR) {                    /* It is a directory */
+			ntstdio_printf(&ntstdio, "%10S ", " ");
+		}
+		else {
+			ntstdio_printf(&ntstdio, "%10d ", fno->fsize);
+		}
+	}
+
+	if (fno->fattrib & AM_DIR) {                    /* It is a directory */
+		ntstdio_printf(&ntstdio, "\x1B[32m%s\x1B[0m\n", fn);
+	}
+	else {
+		ntstdio_printf(&ntstdio, "%s\n", fn);
+	}
+}
+
+#define LFN_BUF_SIZE (_MAX_LFN + 1)
+/* lsã³ãã³ã dirå
+ è¡¨ç¤º */
+void print_ls(char *path_p, char *pattern_p, BYTE list_option)
+{
+	FRESULT res;
+	FILINFO fno;
+	DIR dir;
+	char *fn;   /* This function assumes non-Unicode configuration */
+
+	if ((pattern_p != NULL) && (pattern_p[0] == '\0'))
+		pattern_p = NULL;
+
+	char *path_backup = NULL;
+	path_backup = ff_memalloc(LFN_BUF_SIZE);
+	if (path_backup == NULL) {
+		ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
+		return;
+	}
+
+#if _USE_LFN
+	char *lfn = NULL;
+	lfn = ff_memalloc(LFN_BUF_SIZE);
+	if (lfn == NULL) {
+		ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
+		ff_memfree(path_backup);
+		return;
+	}
+	fno.lfname = lfn;
+	fno.lfsize = LFN_BUF_SIZE;
+#endif
+
+	if ((path_p != NULL) && (pattern_p == NULL)) {
+		if ((res = f_opendir(&dir, path_p)) != FR_OK)
+			put_rc("f_opendir", res);
+		res = f_readdir(&dir, &fno);
+	}
+	else {
+		res = f_findfirst(&dir, &fno, path_p, pattern_p);
+	}
+
+	while ((res == FR_OK) && (fno.fname[0] != 0)) {
+		if (pattern_p != NULL && (fno.fattrib & AM_DIR) && ((fno.fname[0] == '.') ? (pattern_p[0] == '.') : 1)) {/* DIR ã¨ãã¿ã¼ã³ããããã¦ããå ´åã¯ DIR å
+é¨ã ls ãã */
+#if _USE_LFN
+			fn = *fno.lfname ? fno.lfname : fno.fname;
+#else
+			fn = fno->fname;
+#endif
+			if ((res = f_getcwd(path_backup, LFN_BUF_SIZE)) != FR_OK) {
+				put_rc("f_getcwd", res);
+			}
+
+			if ((res = f_chdrive(path_p)) != RES_OK) {
+				put_rc("f_chdrive", res);
+			}
+
+			if ((res = f_chdir(path_p)) != RES_OK) {
+				put_rc("f_chdir", res);
+			}
+
+			ntstdio_printf(&ntstdio, "\n%s/%s:\n", path_p, fn);
+
+			print_ls(fn, NULL, list_option);
+
+			ntstdio_printf(&ntstdio, "\n");
+
+			if ((res = f_chdrive(path_backup)) != RES_OK) {
+				put_rc("f_chdrive", res);
+			}
+
+			if ((res = f_chdir(path_backup)) != RES_OK) {
+				put_rc("f_chdir", res);
+			}
+		}
+		else {
+			print_one_list(&fno, list_option);
+		}
+
+		if (pattern_p == NULL)
+			res = f_readdir(&dir, &fno);	/* all */
+		else
+			res = f_findnext(&dir, &fno);	/* pattern matching */
+	}
+
+	f_closedir(&dir);
+
+	if (lfn			!= NULL) ff_memfree(lfn);
+	if (path_backup != NULL) ff_memfree(path_backup);
+}
+
+int usrcmd_ls(int argc, char **argv)
+{
+	char *pattern_p = NULL, *basename_p = NULL, *dirname_p = NULL;
+	char default_pattern[_MAX_LFN] = "";
+	int i;
+	BYTE list_option = 0;
+
+	for (i = 1; i < argc; i++) {
+		if (argv[i][0] == '-') {
+			if (argv[i][1] == 'a') {
+				list_option |= LS_ALL;
+			}
+			else if (argv[i][1] == 'l') {
+				list_option |= LS_LONG;
+			}
+			continue;
+		}
+		if (argv[i][0] != '\0') {	/* pattern matching ? */
+			pattern_p = &argv[i][0];
+			break;
+		}
+	}
+
+	if (pattern_p != NULL)
+		strlcpy(default_pattern, pattern_p, sizeof(default_pattern));
+	basename_p = basename(pattern_p);
+	dirname_p = dirname(default_pattern);
+	if (((dirname_p[0] == '/') && (basename_p[0] == '/')) ||
+		(!strncmp(dirname_p, ".", strlen(dirname_p)) && !strncmp(basename_p, ".", strlen(basename_p))))
+	{
+		basename_p = NULL;
+	}
+	print_ls(dirname_p, basename_p, list_option);
+
+	return 0;
+}
+
+int usrcmd_cp(int argc, char **argv)
+{
+	char *src_str_p = NULL, *dst_str_p = NULL;
+	unsigned char i;
+	FRESULT res;
+	FILINFO fno;
+	FIL src_fp, dst_fp;
+	size_t read_size, write_size;
+	char *lfn = NULL, *local_buff = NULL, *dst_mod_str_p = NULL;
+	char *src_basename_p;
+
+	if (argc < 2)
+		return 0;
+
+	/* å¼æ°ãã§ãã¯ */
+	for (i = 1; i < argc; i++) {
+		if (argv[i][0] == '-')
+			continue;
+		if (argv[i][0] != '\0') {
+			if (src_str_p == NULL)
+				src_str_p = &argv[i][0];
+			else {
+				dst_str_p = &argv[i][0];
+				break;
+			}
+		}
+	}
+	if ((src_str_p == NULL) || (dst_str_p == NULL))
+		return 0;
+
+#if _USE_LFN
+	/* LFN buffer alloc */
+	lfn = ff_memalloc(LFN_BUF_SIZE);
+	if (lfn == NULL) {
+		ntstdio_printf(&ntstdio, "alloc err.\n");
+		goto cp_end;
+	}
+	fno.lfname = lfn;
+	fno.lfsize = LFN_BUF_SIZE;
+#endif
+
+	/* copy buffer alloc */
+	local_buff = ff_memalloc(64);
+	if (local_buff == NULL) {
+		ntstdio_printf(&ntstdio, "alloc err.\n");
+		goto cp_end;
+	}
+
+	/*************/
+	/* src check */
+	/*************/
+	res = f_stat(src_str_p, &fno);
+	if (res != FR_OK) {
+		if (res == FR_NO_FILE)
+			ntstdio_printf(&ntstdio, "src no file.\n", res);
+		else
+			ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
+		goto cp_end;
+	}
+	if (fno.fattrib & AM_DIR) {	/* src is dir */
+		/*******************************************************/	/* from dir */ /* æªå®è£
+ */
+	}
+	else {						/* src is file */
+		res = f_open(&src_fp, src_str_p, (FA_OPEN_EXISTING | FA_READ));
+		if (res != FR_OK) {
+			ntstdio_printf(&ntstdio, "src open err(%d).\n", res);
+			goto cp_end;
+		}
+	}
+
+	/*************/
+	/* dst check */
+	/*************/
+	res = f_stat(dst_str_p, &fno);
+	if (res != FR_NO_FILE) {
+		if (res == FR_OK) {
+			if (fno.fattrib & AM_DIR) {	/* dst is dir */
+				src_basename_p = basename(src_str_p);
+				dst_mod_str_p = ff_memalloc(LFN_BUF_SIZE);
+				if (dst_mod_str_p == NULL) {
+					ntstdio_printf(&ntstdio, "alloc err.\n");
+					goto cp_end;
+				}
+				ntstdio_snprintf(dst_mod_str_p, LFN_BUF_SIZE, "%s/%s\0", dst_str_p, src_basename_p);
+				dst_str_p = dst_mod_str_p;
+			}
+			else {
+				ntstdio_printf(&ntstdio, "dst file exists.\n");
+				goto cp_end_1;
+			}
+		}
+		else {
+			ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
+			goto cp_end_1;
+		}
+	}
+	res = f_open(&dst_fp, dst_str_p, (FA_CREATE_NEW | FA_WRITE));
+	if (res != FR_OK) {
+		ntstdio_printf(&ntstdio, "dst open err(%d).\n", res);
+		goto cp_end_1;
+	}
+
+	/********/
+	/* copy */
+	/********/
+	do {
+		/* read from src */
+		res = f_read(&src_fp, local_buff, sizeof(local_buff), &read_size);
+		if (res != FR_OK) {
+			ntstdio_printf(&ntstdio, "src read err(%d).\n", res);
+			goto cp_end_2;
+		}
+
+		/* write to dst */
+		res = f_write(&dst_fp, local_buff, read_size, &write_size);
+		if (res != FR_OK) {
+			ntstdio_printf(&ntstdio, "dst write err(%d).\n", res);
+			goto cp_end_2;
+		}
+		if (read_size != write_size) {
+			ntstdio_printf(&ntstdio, "dst write err(disk full).\n", res);
+			goto cp_end_2;
+		}
+	} while (read_size == sizeof(local_buff));
+
+cp_end_2:
+	f_close(&dst_fp);
+cp_end_1:
+	f_close(&src_fp);
+cp_end:
+	if(dst_mod_str_p != NULL) ff_memfree(dst_mod_str_p);
+	if(local_buff	 != NULL) ff_memfree(local_buff);
+	if(lfn			 != NULL) ff_memfree(lfn);
+
+	return 0;
+}
+
+int usrcmd_rm(int argc, char **argv)
+{
+	FRESULT res;
+
+	if (argc == 2) {
+		if ((res = f_unlink(argv[1])) != FR_OK) {
+			put_rc("f_unlink", res);
+			return 0;
+		}
+	}
+
+	return 0;
+}
+
+int usrcmd_mv(int argc, char **argv)
+{
+	FRESULT res;
+
+	if (argc == 3) {
+		if ((res = f_rename(argv[1], argv[2])) != FR_OK) {
+			put_rc("f_rename", res);
+			return 0;
+		}
+	}
+
+	return 0;
+}
+
+int usrcmd_mkdir(int argc, char **argv)
+{
+	FRESULT res;
+
+	if (argc == 2) {
+		if ((res = f_mkdir(argv[1])) != FR_OK) {
+			put_rc("f_mkdir", res);
+			return 0;
+		}
+	}
+
+	return 0;
+}
+
+int usrcmd_hexdump(int argc, char **argv)
+{
+	FRESULT res;
+	FIL fsrc;
+	unsigned char data[16 + 1];
+	unsigned char ascii[sizeof("\x1B[31m0\x1B[0m\x1B[31m1\x1B[0m\x1B[31m2\x1B[0m\x1B[31m3\x1B[0m\x1B[31m4\x1B[0m\x1B[31m5\x1B[0m\x1B[31m6\x1B[0m\x1B[31m7\x1B[0m\x1B[31m8\x1B[0m\x1B[31m9\x1B[0m\x1B[31ma\x1B[0m\x1B[31mb\x1B[0m\x1B[31mc\x1B[0m\x1B[31md\x1B[0m\x1B[31me\x1B[0m\x1B[31mf\x1B[0m")];
+	char line[sizeof("00000000: 00 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 00 : \n") + sizeof(ascii)];
+
+	if (argc != 2) {
+		ntstdio_printf(&ntstdio, "hexdump file\n");
+	}
+
+	if ((res = f_open(&fsrc, argv[1], FA_OPEN_EXISTING | FA_READ)) != FR_OK) {
+		put_rc("f_open", res);
+		return 0;
+	}
+
+	for (int i = 0; i < fsrc.fsize; i += 16) {
+		ascii[0] = '\0';
+		line[0] = '\0';
+		char *pos = line;
+		int rst = sizeof(line);
+		int len = ntstdio_snprintf(pos, rst, "%08X: ", i);
+		pos += len;
+		rst -= len;
+
+		UINT br = 0;
+		if ((res = f_read(&fsrc, data, 16, &br)) != FR_OK) {
+			put_rc("f_read", res);
+			f_close(&fsrc);
+			return 0;
+		}
+		data[16] = '\0';
+
+		char *apos = ascii;
+		int arst = sizeof(ascii);
+		for (int j = 0; j < br; j++) {
+			unsigned char c = data[j];
+			if (j != 7)
+				len = ntstdio_snprintf(pos, rst, "%02X ", c);
+			else
+				len = ntstdio_snprintf(pos, rst, "%02X-", c);
+			pos += len;
+			rst -= len;
+
+			if (c < 0x20) {
+				len = ntstdio_snprintf(apos, arst , "\x1B[31m%c\x1B[0m", c + 0x40);
+			}
+			else if (c == 0xFF) {
+				len = ntstdio_snprintf(apos, arst, "\x1B[32m%c\x1B[0m", 'E');
+			}
+			else {
+				len = ntstdio_snprintf(apos, arst, "%c", c);
+			}
+			apos += len;
+			arst -= len;
+		}
+
+		for (int j = br; j < 16; j++) {
+			if (j != 7)
+				len = ntstdio_snprintf(pos, rst, "   ");
+			else
+				len = ntstdio_snprintf(pos, rst, "  -");
+			pos += len;
+			rst -= len;
+		}
+
+		len = ntstdio_snprintf(pos, rst, ": %s\n", ascii);
+		pos += len;
+		rst -= len;
+
+		ntstdio_printf(&ntstdio, line);
+	}
+
+	f_close(&fsrc);
+	return 0;
+}
+
+int usrcmd_info(int argc, char **argv)
+{
+	if (argc != 2) {
+		ntstdio_printf(&ntstdio, "info sys\n");
+		ntstdio_printf(&ntstdio, "info ver\n");
+		return 0;
+	}
+	if (strcmp(argv[1], "sys") == 0) {
+		ntstdio_printf(&ntstdio, "GR-PEACH Monitor\n");
+		return 0;
+	}
+	if (strcmp(argv[1], "ver") == 0) {
+		int mj, mn, bd;
+		ntshell_version(&mj, &mn, &bd);
+		ntstdio_printf(&ntstdio, "Version %d.%d.%d\n", mj, mn, bd);
+		return 0;
+	}
+	ntstdio_printf(&ntstdio, "Unknown sub command found\n");
+	return -1;
+}
+
+int usrcmd_exit(int argc, char **argv)
+{
+	ntshell_exit = 1;
+
+	return 0;
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h	(revision 279)
@@ -0,0 +1,63 @@
+/**
+ * @file usrcmd.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef USRCMD_H
+#define USRCMD_H
+
+typedef int(*USRCMDFUNC)(int argc, char **argv);
+
+typedef struct
+{
+	const char *cmd;
+	const char *desc;
+	USRCMDFUNC func;
+} cmd_table_t;
+
+extern int usrcmd_cd(int argc, char **argv);
+extern int usrcmd_ls(int argc, char **argv);
+extern int usrcmd_cp(int argc, char **argv);
+extern int usrcmd_rm(int argc, char **argv);
+extern int usrcmd_mv(int argc, char **argv);
+extern int usrcmd_mkdir(int argc, char **argv);
+extern int usrcmd_hexdump(int argc, char **argv);
+
+extern int usrcmd_help(int argc, char **argv);
+extern int usrcmd_info(int argc, char **argv);
+extern int usrcmd_exit(int argc, char **argv);
+
+extern void shell_abort();
+extern void shell_exit(int exitcd);
+extern int shell_kill(int pid, int sig);
+extern int shell_gettimeofday(struct timeval * tp, void * tzvp);
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.c	(revision 279)
@@ -0,0 +1,160 @@
+/**
+ * @file ntopt.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include "ntopt.h"
+
+ /**
+  * @brief Is the character delimiter?
+  * @param c The character.
+  * @retval true It's a delimiter.
+  * @retval false It's not a delimiter.
+  */
+#define IS_DELIM(c) \
+    (((c) == '\r') || ((c) == '\n') || ((c) == '\t') || ((c) == '\0') || ((c) == ' '))
+
+static int ntopt_get_count(const char *str);
+static char *ntopt_get_text(
+	const char *str, const int n, char *buf, int siz, int *len);
+
+/**
+ * @brief Get the sentence count of the given text string.
+ * @param str A text string.
+ * @return Count of the given sentence.
+ */
+static int ntopt_get_count(const char *str)
+{
+	int cnt = 0;
+	int wc = 0;
+	char *p = (char *)str;
+	while (*p) {
+		if (!IS_DELIM(*p)) {
+			wc++;
+			if (wc == 1) {
+				cnt++;
+			}
+		}
+		else {
+			wc = 0;
+		}
+		p++;
+	}
+	return cnt;
+}
+
+/**
+ * @brief Get the sentence of the given text string.
+ * @param str A text string.
+ * @param n Index number. (0 to ntopt-get_count(str) - 1)
+ * @param buf The pointer to a stored buffer.
+ * @param siz The size of the stored buffer.
+ * @param len The stored string length.
+ * @retval !NULL Success. The pointer to the buffer.
+ * @retval NULL Failure.
+ */
+static char *ntopt_get_text(
+	const char *str, const int n, char *buf, int siz, int *len)
+{
+	int cnt = 0;
+	int wc = 0;
+	char *p = (char *)str;
+	*len = 0;
+	while (*p) {
+		if (!IS_DELIM(*p)) {
+			wc++;
+			if (wc == 1) {
+				if (cnt == n) {
+					char *des = buf;
+					int cc = 0;
+					while (!IS_DELIM(*p)) {
+						cc++;
+						if (siz <= cc) {
+							break;
+						}
+						*des = *p;
+						des++;
+						p++;
+					}
+					*des = '\0';
+					*len = cc;
+					return buf;
+				}
+				cnt++;
+			}
+		}
+		else {
+			wc = 0;
+		}
+		p++;
+	}
+	return (char *)0;
+}
+
+/**
+ * @brief Parse the given text string.
+ * @param str A text string.
+ * @param func The callback function.
+ * @param extobj An external object for the callback function.
+ * @return The return value from the callback.
+ */
+int ntopt_parse(const char *str, NTOPT_CALLBACK func, void *extobj)
+{
+	int argc;
+	char argv[NTOPT_TEXT_MAXLEN];
+	char *argvp[NTOPT_TEXT_MAXARGS];
+	int i;
+	int total;
+	char *p;
+
+	argc = ntopt_get_count(str);
+	if (NTOPT_TEXT_MAXARGS <= argc) {
+		argc = NTOPT_TEXT_MAXARGS;
+	}
+
+	memset(argvp, 0, sizeof(argvp));
+	total = 0;
+	p = &argv[0];
+	for (i = 0; i < argc; i++) {
+		int len;
+		argvp[i] = ntopt_get_text(
+			str, i, p, NTOPT_TEXT_MAXLEN - total, &len);
+		if (total + len + 1 < NTOPT_TEXT_MAXLEN) {
+			p += len + 1;
+			total += len + 1;
+		}
+		else {
+			break;
+		}
+	}
+
+	return func(argc, &argvp[0], extobj);
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/util/ntopt.h	(revision 279)
@@ -0,0 +1,70 @@
+/**
+ * @file ntopt.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef NTOPT_H
+#define NTOPT_H
+
+#include "core/ntconf.h"
+
+/**
+ * @brief The text maximum length.
+ */
+#define NTOPT_TEXT_MAXLEN   (NTCONF_EDITOR_MAXLEN)
+
+/**
+ * @brief The text maximum arguments.
+ */
+#define NTOPT_TEXT_MAXARGS  (NTCONF_EDITOR_MAXLEN / 2)
+
+/**
+ * @brief The callback function.
+ *
+ * @param argc The number of the parameters.
+ * @param argv The pointer to the parameters.
+ * @param extobj The external object.
+ *
+ * @return A return value.
+ */
+typedef int (*NTOPT_CALLBACK)(int argc, char **argv, void *extobj);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ntopt_parse(const char *str, NTOPT_CALLBACK func, void *extobj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c	(revision 279)
@@ -0,0 +1,413 @@
+/**
+ * @file ntstdio.c
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*------------------------------------------------------------------------/
+/  Universal string handler for user console interface
+/-------------------------------------------------------------------------/
+/
+/  Copyright (C) 2011, ChaN, all right reserved.
+/
+/ * This software is a free software and there is NO WARRANTY.
+/ * No restriction on use. You can use, modify and redistribute it for
+/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+/ * Redistributions of source code must retain the above copyright notice.
+/
+/-------------------------------------------------------------------------*/
+
+#include <stdarg.h>
+#include "ntstdio.h"
+
+#define FLAG_ZERO_PADDED    (1 << 0)
+#define FLAG_LEFT_JUSTIFIED (1 << 1)
+#define FLAG_SIZE_LONG_INT  (1 << 2)
+#define FLAG_SIGNED_DECIMAL (1 << 3)
+#define FLAG_SIZE_HALF_INT  (1 << 4)
+
+/*
+ * ntstdio_printf("%d", 1234);            "1234"
+ * ntstdio_printf("%6d,%3d%%", -200, 5);  "  -200,  5%"
+ * ntstdio_printf("%-6u", 100);           "100   "
+ * ntstdio_printf("%ld", 12345678L);      "12345678"
+ * ntstdio_printf("%04x", 0xA3);          "00a3"
+ * ntstdio_printf("%08LX", 0x123ABC);     "00123ABC"
+ * ntstdio_printf("%016b", 0x550F);       "0101010100001111"
+ * ntstdio_printf("%s", "String");        "String"
+ * ntstdio_printf("%-4s", "abc");         "abc "
+ * ntstdio_printf("%4s", "abc");          " abc"
+ * ntstdio_printf("%c", 'a');             "a"
+ * ntstdio_printf("%f", 10.0);            <ntstdio_printf lacks floating point support>
+ */
+
+static int xvprintf(ntstdio_t *handle, const char *fmt, va_list arp)
+{
+	unsigned int i, j;
+	unsigned int flag, radix, width;
+	unsigned long value;
+	char s[16], c, d, *p;
+
+	while (1) {
+		/*
+		 * Get a character.
+		 */
+		c = *fmt++;
+		if (!c) {
+			/*
+			 * End of the format.
+			 */
+			break;
+		}
+		if (c != '%') {
+			/*
+			 * Pass through it if not a % sequense
+			 */
+			ntstdio_putc(handle, c);
+			continue;
+		}
+
+		/*
+		 * Reset the flag.
+		 */
+		flag = 0;
+
+		/*
+		 * Get the first character of the sequense.
+		 */
+		c = *fmt++;
+		if (c == '0') {
+			flag = FLAG_ZERO_PADDED;
+			c = *fmt++;
+		}
+		else {
+			if (c == '-') {
+				flag = FLAG_LEFT_JUSTIFIED;
+				c = *fmt++;
+			}
+		}
+		/*
+		 * Calculate the minimum width.
+		 */
+		for (width = 0; (c >= '0') && (c <= '9'); c = *fmt++) {
+			width = (width * 10) + (c - '0');
+		}
+		if ((c == 'l') || (c == 'L')) {
+			flag |= FLAG_SIZE_LONG_INT;
+			c = *fmt++;
+		}
+		else if (c == 'h') {	/* Prefix: Size is short int */
+			flag |= FLAG_SIZE_HALF_INT;
+			c = *fmt++;
+		}
+		if (!c) {
+			/*
+			 * End of the format.
+			 */
+			break;
+		}
+		d = c;
+		if (d >= 'a') {
+			d -= 0x20;
+		}
+		/* Type is... */
+		switch (d) {
+		case 'S':
+			/* String */
+			p = va_arg(arp, char*);
+			for (j = 0; p[j]; j++) {
+			}
+			while (!(flag & FLAG_LEFT_JUSTIFIED) && (j++ < width)) {
+				ntstdio_putc(handle, ' ');
+			}
+			ntstdio_puts(handle, p);
+			while (j++ < width) {
+				ntstdio_putc(handle, ' ');
+			}
+			continue;
+		case 'C':
+			/* Character */
+			ntstdio_putc(handle, (char)va_arg(arp, int));
+			continue;
+		case 'B':
+			/* Binary */
+			radix = 2;
+			break;
+		case 'O':
+			/* Octal */
+			radix = 8;
+			break;
+		case 'D':
+			/* Signed decimal */
+			radix = 10;
+			break;
+		case 'U':
+			/* Unsigned decimal */
+			radix = 10;
+			break;
+		case 'X':
+			/* Hexdecimal */
+			radix = 16;
+			break;
+		default:
+			/* Unknown type (passthrough) */
+			ntstdio_putc(handle, c);
+			continue;
+		}
+
+		/*
+		 * Get an argument and put it in numeral.
+		 */
+		value = (flag & FLAG_SIZE_LONG_INT) ? va_arg(arp, long)
+			: (flag & FLAG_SIZE_HALF_INT) ? ((d == 'D') ? (long)va_arg(arp, short) : (long)va_arg(arp, unsigned short))
+				: ((d == 'D') ? (long)va_arg(arp, int) : (long)va_arg(arp, unsigned int));
+		if ((d == 'D') && (value & 0x80000000)) {
+			value = 0 - value;
+			flag |= FLAG_SIGNED_DECIMAL;
+		}
+		i = 0;
+		do {
+			d = (char)(value % radix);
+			value /= radix;
+			if (d > 9) {
+				d += (c == 'x') ? 0x27 : 0x07;
+			}
+			s[i++] = d + '0';
+		} while (value && (i < sizeof(s)));
+		if (flag & FLAG_SIGNED_DECIMAL) {
+			s[i++] = '-';
+		}
+		j = i;
+		d = (flag & FLAG_ZERO_PADDED) ? '0' : ' ';
+		while (!(flag & FLAG_LEFT_JUSTIFIED) && (j++ < width)) {
+			ntstdio_putc(handle, d);
+		}
+		do {
+			ntstdio_putc(handle, s[--i]);
+		} while (i);
+		while (j++ < width) {
+			ntstdio_putc(handle, ' ');
+		}
+	}
+
+	return handle->pos;
+}
+
+void ntstdio_init(ntstdio_t *handle, unsigned int option, NTSTDIO_XI xi, NTSTDIO_XO xo)
+{
+	handle->xi = xi;
+	handle->xo = xo;
+	handle->outptr = 0;
+	handle->len = 0;
+	handle->pos = 0;
+	handle->option = option;
+}
+
+static void _putc(ntstdio_t *handle, char c)
+{
+	if (handle->outptr) {
+		if ((handle->pos + 1) >= handle->len)
+			return;
+		handle->outptr[handle->pos] = (unsigned char)c;
+		handle->pos++;
+		return;
+	}
+
+	if (handle->xo) {
+		handle->xo((unsigned char)c);
+	}
+	handle->pos++;
+}
+
+void ntstdio_putc(ntstdio_t *handle, char c)
+{
+	if ((handle->option & NTSTDIO_OPTION_LF_CRLF) && (c == '\n')) {
+		_putc(handle, '\r');
+		_putc(handle, '\n');
+	}
+	else{
+		_putc(handle, c);
+	}
+}
+
+void ntstdio_puts(ntstdio_t *handle, const char *str)
+{
+	while (*str) {
+		ntstdio_putc(handle, *str++);
+	}
+}
+
+void ntstdio_fputs(ntstdio_t *handle, NTSTDIO_XO xo, const char *str)
+{
+	void(*pf)(unsigned char);
+
+	/* Save current output device */
+	pf = handle->xo;
+	/* Switch output to specified device */
+	handle->xo = xo;
+
+	while (*str) {
+		ntstdio_putc(handle, *str++);
+	}
+
+	/* Restore output device */
+	handle->xo = pf;
+}
+
+int ntstdio_printf(ntstdio_t *handle, const char *fmt, ...)
+{
+	int result;
+	va_list arp;
+	va_start(arp, fmt);
+	result = xvprintf(handle, fmt, arp);
+	va_end(arp);
+	return result;
+}
+
+int ntstdio_snprintf(char *buf, int len, const char *fmt, ...)
+{
+	int result;
+	ntstdio_t handle;
+	va_list arp;
+	/* Switch destination for memory */
+	handle.option = 0;
+	handle.outptr = buf;
+	handle.len = len;
+	handle.pos = 0;
+	va_start(arp, fmt);
+	result = xvprintf(&handle, fmt, arp);
+	va_end(arp);
+
+	/* Terminate output string with a \0 */
+	handle.outptr[handle.pos] = '\0';
+	return result;
+}
+
+int ntstdio_fprintf(ntstdio_t *handle, NTSTDIO_XO xo, const char *fmt, ...)
+{
+	int result;
+	va_list arp;
+	void(*pf)(unsigned char);
+
+	/* Save current output device */
+	pf = handle->xo;
+	/* Switch output to specified device */
+	handle->xo = xo;
+
+	va_start(arp, fmt);
+	result = xvprintf(handle, fmt, arp);
+	va_end(arp);
+
+	/* Restore output device */
+	handle->xo = pf;
+	return result;
+}
+
+int ntstdio_getc(ntstdio_t *handle)
+{
+	extern void shell_exit(int cd);
+
+	int c = handle->xi();
+	if (handle->option & NTSTDIO_OPTION_LF_CR) {
+		if (c == '\r')
+			c = '\n';
+	}
+	if (handle->option & NTSTDIO_OPTION_CANON) {
+		if (c == 0x03)
+			shell_exit(-1);
+	}
+	if (handle->option & NTSTDIO_OPTION_LINE_ECHO) {
+		ntstdio_putc(handle, c);
+	}
+	return c;
+}
+
+/* 0:End of stream, 1:A line arrived */
+int ntstdio_gets(ntstdio_t *handle, char *buf, int len)
+{
+	int c, i;
+
+	if (!handle->xi) {
+		/* No input function specified */
+		return 0;
+	}
+
+	i = 0;
+	for (;;) {
+		/* Get a char from the incoming stream */
+		c = handle->xi();
+		if (!c) {
+			/* End of stream */
+			return 0;
+		}
+		if (c == '\r') {
+			/* End of line */
+			break;
+		}
+		if ((c == '\b') && i) {
+			/* Back space */
+			i--;
+			if (handle->option & NTSTDIO_OPTION_LINE_ECHO) {
+				ntstdio_putc(handle, c);
+			}
+			continue;
+		}
+		if ((c >= ' ') && (i < len - 1)) {
+			/* Visible chars */
+			buf[i++] = c;
+			if (handle->option & NTSTDIO_OPTION_LINE_ECHO) {
+				ntstdio_putc(handle, c);
+			}
+		}
+	}
+	buf[i] = 0;
+	/* Terminate with a \0 */
+	if (handle->option & NTSTDIO_OPTION_LINE_ECHO) {
+		ntstdio_putc(handle, '\n');
+	}
+	return 1;
+}
+
+/* 0:End of stream, 1:A line arrived */
+int ntstdio_fgets(ntstdio_t *handle, NTSTDIO_XI xi, char *buf, int len)
+{
+	unsigned char(*pf)(void);
+	int n;
+
+	/* Save current input device */
+	pf = handle->xi;
+	/* Switch input to specified device */
+	handle->xi = xi;
+	/* Get a line */
+	n = ntstdio_gets(handle, buf, len);
+	/* Restore input device */
+	handle->xi = pf;
+
+	return n;
+}
Index: /EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h	(revision 279)
@@ -0,0 +1,95 @@
+/**
+ * @file ntstdio.h
+ * @author CuBeatSystems
+ * @author Shinichiro Nakamura
+ * @copyright
+ * ===============================================================
+ * Natural Tiny Shell (NT-Shell) Version 0.3.1
+ * ===============================================================
+ * Copyright (c) 2010-2016 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*------------------------------------------------------------------------/
+/  Universal string handler for user console interface
+/-------------------------------------------------------------------------/
+/
+/  Copyright (C) 2011, ChaN, all right reserved.
+/
+/ * This software is a free software and there is NO WARRANTY.
+/ * No restriction on use. You can use, modify and redistribute it for
+/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+/ * Redistributions of source code must retain the above copyright notice.
+/
+/-------------------------------------------------------------------------*/
+
+#ifndef NTSTDIO_H
+#define NTSTDIO_H
+
+/**
+ * 1: Convert \n ==> \r\n in the output char.
+ */
+#define NTSTDIO_OPTION_LF_CRLF      (1 << 0)
+
+/**
+ * 1: Echo back input chars in ntstdio_gets function.
+ */
+#define NTSTDIO_OPTION_LINE_ECHO    (1 << 1)
+
+/**
+ * 1: canonical mode.
+ */
+#define NTSTDIO_OPTION_CANON        (1 << 2)
+
+/**
+ * 1: Convert \r ==> \n in ntstdio_getc function.
+ */
+#define NTSTDIO_OPTION_LF_CR        (1 << 3)
+
+typedef unsigned char (*NTSTDIO_XI)(void);
+typedef void (*NTSTDIO_XO)(unsigned char c);
+
+typedef struct {
+    NTSTDIO_XI xi;
+    NTSTDIO_XO xo;
+    char *outptr;
+	int len;
+	int pos;
+    unsigned int option;
+} ntstdio_t;
+
+void ntstdio_init(ntstdio_t *handle, unsigned int option, NTSTDIO_XI xi, NTSTDIO_XO xo);
+
+void ntstdio_putc(ntstdio_t *handle, char c);
+void ntstdio_puts(ntstdio_t *handle, const char *str);
+void ntstdio_fputs(ntstdio_t *handle, NTSTDIO_XO xo, const char *str);
+int ntstdio_printf(ntstdio_t *handle, const char *fmt, ...);
+int ntstdio_snprintf(char *buf, int len, const char *fmt, ...);
+int ntstdio_fprintf(ntstdio_t *handle, NTSTDIO_XO xo, const char *fmt, ...);
+
+int ntstdio_getc(ntstdio_t *handle);
+int ntstdio_gets(ntstdio_t *handle, char *buf, int len);
+int ntstdio_fgets(ntstdio_t *handle, NTSTDIO_XI xi, char *buf, int len);
+
+#endif
+
Index: /EcnlProtoTool/trunk/ntshell/shellif.rb
===================================================================
--- /EcnlProtoTool/trunk/ntshell/shellif.rb	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/shellif.rb	(revision 279)
@@ -0,0 +1,57 @@
+
+def ReadSymbolFile(symbolFileName)
+  begin
+    symbolFile = File.open(symbolFileName)
+  rescue Errno::ENOENT, Errno::EACCES => ex
+    abort(ex.message)
+  end
+
+  symbolAddress = {}
+  symbolFile.each do |line|
+    # ã¹ãã¼ã¹åºåãã§åè§£
+    fields = line.split(/\s+/)
+
+    # 3åã«ãªã£ã¦ããªãè¡ã¯é¤å¤
+    if fields.size == 3 && fields[2].start_with?("__exp_")
+      symbolAddress[fields[2].gsub("__exp_", "")] = fields[0].hex
+    end
+  end
+  symbolFile.close
+  return(symbolAddress)
+end
+
+symbolsInfo = ReadSymbolFile("ntshell.syms")
+
+begin
+  outFile = File.open("../ntshell/shellif.h", "w")
+rescue Errno::ENOENT, Errno::EACCES => ex
+  abort(ex.message)
+end
+
+symbolsInfo.each do |k, v|
+  outFile.printf("#define __imp_%s ((%s_t)0x%08x)\n", k, k, v)
+end
+
+outFile.close
+
+begin
+  outFile = File.open("../ntshell/shellif_stub.c", "w")
+rescue Errno::ENOENT, Errno::EACCES => ex
+  abort(ex.message)
+end
+
+symbolsInfo.each do |k, v|
+  outFile.printf("typedef int (*%s_t)(void);\n", k)
+end
+
+outFile.print("\n")
+
+symbolsInfo.each do |k, v|
+  outFile.printf("int %s(void)\n", k)
+  outFile.print("{\n")
+  outFile.printf("\treturn __imp_%s();\n", k)
+  outFile.print("}\n")
+  outFile.print("\n")
+end
+
+outFile.close
Index: /EcnlProtoTool/trunk/ntshell/src/fdtable.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/fdtable.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/fdtable.c	(revision 279)
@@ -0,0 +1,507 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/unistd.h>
+#include <limits.h>
+#include <kernel.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include <sil.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include "../../../musl-1.1.12/include/poll.h"
+#include "syssvc/serial.h"
+#include "syssvc/syslog.h"
+#include <tinet_config.h>
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <tinet_nic_defs.h>
+#include <tinet_cfg.h>
+#include <netinet/in_var.h>
+#include <net/ethernet.h>
+#include <net/if6_var.h>
+#include <net/net.h>
+#include <net/if_var.h>
+#include <netinet/udp_var.h>
+#include <ethernet_api.h>
+#include "ff.h"
+#include "socket_stub.h"
+#include "kernel_cfg.h"
+
+#define SIO_PORTID 1
+
+#define IO_TYPE_FREE	0
+#define IO_TYPE_SIO		1
+#define IO_TYPE_FILE	2
+#define IO_TYPE_TCP		3
+#define IO_TYPE_UDP		4
+
+static struct _IO_FILE fd_table[8 * sizeof(FLGPTN)] = {
+	{ 0, IO_TYPE_SIO, 0, stdio_close, stdin_read, stdio_write },
+	{ 1, IO_TYPE_SIO, 0, stdio_close, stdio_read, stdout_write },
+	{ 2, IO_TYPE_SIO, 0, stdio_close, stdio_read, stderr_write },
+};
+#define fd_table_count (sizeof(fd_table) / sizeof(fd_table[0]))
+
+static int new_fd(int type, int id)
+{
+	for (int fd = 3; fd < fd_table_count; fd++) {
+		struct _IO_FILE *fp = &fd_table[fd];
+		if (fp->type != IO_TYPE_FREE)
+			continue;
+
+		fp->fd = fd;
+		fp->type = type;
+		fp->handle = id;
+		return fd;
+	}
+
+	return -1;
+}
+
+static struct _IO_FILE *id_to_fd(int type, int id)
+{
+	for (int fd = 3; fd < fd_table_count; fd++) {
+		struct _IO_FILE *fp = &fd_table[fd];
+		if ((fp->type == type) && (fp->handle == id))
+			return fp;
+	}
+
+	return NULL;
+}
+
+static int delete_fd(int type, int id)
+{
+	struct _IO_FILE *fp = id_to_fd(type, id);
+	if (fp == NULL)
+		return -1;
+
+	memset(fp, 0, sizeof(struct _IO_FILE));
+
+	return 0;
+}
+
+struct _IO_FILE *fd_to_fp(int fd)
+{
+	if ((fd < 0) || (fd >= fd_table_count))
+		return NULL;
+	return &fd_table[fd];
+}
+
+struct _IO_FILE *new_sio_fd(int sioid)
+{
+	int fd = new_fd(IO_TYPE_SIO, sioid);
+	if ((fd < 0) || (fd >= fd_table_count))
+		return NULL;
+
+	struct _IO_FILE *fp = &fd_table[fd];
+	fp->close = sio_close;
+	fp->read = sio_read;
+	fp->write = sio_write;
+
+	return fp;
+}
+
+int delete_sio_fd(int sioid)
+{
+	return delete_fd(IO_TYPE_SIO, sioid);
+}
+
+struct _IO_FILE *sioid_to_fd(int sioid)
+{
+	return id_to_fd(IO_TYPE_SIO, sioid);
+}
+
+struct _IO_FILE *new_file_fd(int fileid)
+{
+	int fd = new_fd(IO_TYPE_FILE, fileid);
+	if ((fd < 0) || (fd >= fd_table_count))
+		return NULL;
+
+	struct _IO_FILE *fp = &fd_table[fd];
+	fp->close = file_close;
+	fp->read = file_read;
+	fp->write = file_write;
+
+	return fp;
+}
+
+int delete_file_fd(int fileid)
+{
+	return delete_fd(IO_TYPE_FILE, fileid);
+}
+
+struct _IO_FILE *fileid_to_fd(int fileid)
+{
+	return id_to_fd(IO_TYPE_FILE, fileid);
+}
+
+struct _IO_FILE *new_tcp_fd(int tcpid)
+{
+	int fd = new_fd(IO_TYPE_TCP, tcpid);
+	if ((fd < 0) || (fd >= fd_table_count))
+		return NULL;
+
+	struct _IO_FILE *fp = &fd_table[fd];
+	fp->close = tcp_fd_close;
+	fp->read = tcp_fd_read;
+	fp->write = tcp_fd_write;
+
+	return fp;
+}
+
+int delete_tcp_fd(int tcpid)
+{
+	return delete_fd(IO_TYPE_TCP, tcpid);
+}
+
+struct _IO_FILE *tcpid_to_fd(int tcpid)
+{
+	return id_to_fd(IO_TYPE_TCP, tcpid);
+}
+
+struct _IO_FILE *new_udp_fd(int udpid)
+{
+	int fd = new_fd(IO_TYPE_UDP, udpid);
+	if ((fd < 0) || (fd >= fd_table_count))
+		return NULL;
+
+	struct _IO_FILE *fp = &fd_table[fd];
+	fp->close = udp_fd_close;
+	fp->read = udp_fd_read;
+	fp->write = udp_fd_write;
+
+	return fp;
+}
+
+int delete_udp_fd(int udpid)
+{
+	return delete_fd(IO_TYPE_UDP, udpid);
+}
+
+struct _IO_FILE *udpid_to_fd(int udpid)
+{
+	return id_to_fd(IO_TYPE_UDP, udpid);
+}
+
+int shell_isatty(int fd)
+{
+	if ((fd < 0) || (fd >= fd_table_count))
+		return 0;
+
+	struct _IO_FILE *fp = &fd_table[fd];
+	if (fp->type == IO_TYPE_SIO)
+		return 1;
+
+	return 0;
+}
+
+struct fd_events {
+	int count;
+	fd_set readfds;
+	fd_set writefds;
+	fd_set errorfds;
+};
+
+ER shell_get_evts(struct fd_events *evts, TMO tmout);
+
+#define TMO_MAX INT_MAX
+
+int select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+{
+	ER ret;
+	TMO tmout = TMO_FEVR;
+	struct fd_events evts;
+
+	if (tv != NULL) {
+		if (tv->tv_sec < (TMO_MAX / 1000000))
+			tmout = tv->tv_sec * 1000000 + tv->tv_usec;
+		else
+			tmout = TMO_MAX;
+	}
+
+	memcpy(&evts.readfds, rfds, sizeof(fd_set));
+	memcpy(&evts.writefds, wfds, sizeof(fd_set));
+	memcpy(&evts.errorfds, efds, sizeof(fd_set));
+	evts.count = 0;
+
+	ret = shell_get_evts(&evts, tmout);
+	if (ret == E_OK) {
+		memcpy(rfds, &evts.readfds, sizeof(fd_set));
+		memcpy(wfds, &evts.writefds, sizeof(fd_set));
+		memcpy(efds, &evts.errorfds, sizeof(fd_set));
+		return evts.count;
+	}
+	if (ret == E_TMOUT) {
+		memset(rfds, 0, sizeof(fd_set));
+		memset(wfds, 0, sizeof(fd_set));
+		memset(efds, 0, sizeof(fd_set));
+		return 0;
+	}
+
+	return -1;
+}
+
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+	ER ret;
+	TMO tmout;
+	struct fd_events evts;
+
+	if(timeout < 0)
+		tmout = TMO_FEVR;
+	else if (timeout < (TMO_MAX / 1000))
+		tmout = timeout * 1000;
+	else
+		tmout = TMO_MAX;
+
+	memset(&evts, 0, sizeof(evts));
+
+	for (int i = 0; i < nfds; i++) {
+		struct pollfd *pfd = &fds[i];
+		int fd = pfd->fd;
+		if ((fd < 0) || (fd >= fd_table_count))
+			continue;
+
+		if (pfd->events & POLLIN)
+			FD_SET(fd, &evts.readfds);
+		if (pfd->events & POLLOUT)
+			FD_SET(fd, &evts.writefds);
+		if (pfd->events & POLLERR)
+			FD_SET(fd, &evts.errorfds);
+		pfd->revents = 0;
+	}
+
+	ret = shell_get_evts(&evts, tmout);
+	if (ret == E_OK) {
+		int result = 0;
+		for (int i = 0; i < nfds; i++) {
+			struct pollfd *pfd = &fds[i];
+			int fd = pfd->fd;
+			if ((fd < 0) || (fd >= fd_table_count))
+				continue;
+
+			if (FD_ISSET(fd, &evts.readfds))
+				pfd->revents |= POLLIN;
+			if (FD_ISSET(fd, &evts.writefds))
+				pfd->revents |= POLLOUT;
+			if (FD_ISSET(fd, &evts.errorfds))
+				pfd->revents |= POLLERR;
+			if (pfd->revents != 0)
+				result++;
+		}
+		return result;
+	}
+	if (ret == E_TMOUT) {
+		return 0;
+	}
+
+	return -1;
+}
+
+void stdio_update_evts()
+{
+	int fd = STDIN_FILENO;
+	struct _IO_FILE *fp = &fd_table[fd];
+	T_SERIAL_RPOR rpor;
+	FLGPTN flgptn = 0;
+
+	ER ret = serial_ref_por(SIO_PORTID, &rpor);
+	if (ret != E_OK)
+		return;
+
+	if (rpor.reacnt != 0) {
+		if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
+
+		FD_SET(fd, (fd_set *)&flgptn);
+	}
+	if (rpor.wricnt != 0) {
+		if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
+
+		FD_SET(fd, (fd_set *)&flgptn);
+	}
+
+	if (flgptn != 0) {
+		set_flg(FLG_SELECT_WAIT, flgptn);
+	}
+}
+
+void stdio_flgptn(FLGPTN *flgptn)
+{
+	int fd = STDIN_FILENO;
+	struct _IO_FILE *fp = &fd_table[fd];
+	T_SERIAL_RPOR rpor;
+	*flgptn = 0;
+
+	ER ret = serial_ref_por(SIO_PORTID, &rpor);
+	if (ret != E_OK)
+		return;
+
+	if (rpor.reacnt != 0) {
+		if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
+
+		FD_SET(fd, (fd_set *)flgptn);
+	}
+	if (rpor.wricnt != 0) {
+		if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
+
+		FD_SET(fd, (fd_set *)flgptn);
+	}
+}
+
+ER socket_tcp_callback(ID cepid, FN fncd, void *p_parblk)
+{
+	struct _IO_FILE *fp = tcpid_to_fd(cepid);
+	FLGPTN flgptn = 0;
+
+	if (fp == NULL)
+		return E_PAR;
+
+	int fd = fp->fd;
+	FD_SET(fd, (fd_set *)&flgptn);
+
+	switch (fncd) {
+	case TFN_TCP_RCV_DAT:
+		if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
+
+		set_flg(FLG_SELECT_WAIT, flgptn);
+		return E_OK;
+
+	case TFN_TCP_SND_DAT:
+		if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
+
+		set_flg(FLG_SELECT_WAIT, flgptn);
+		return E_OK;
+
+	case TFN_TCP_CAN_CEP:
+		if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
+
+		set_flg(FLG_SELECT_WAIT, flgptn);
+		return E_OK;
+
+	case TFN_TCP_DEL_REP:
+		delete_tcp_rep(cepid);
+		return E_OK;
+
+	case TFN_TCP_DEL_CEP:
+		delete_tcp_fd(cepid);
+		return E_OK;
+
+	default:
+		return E_OK;
+	}
+}
+
+ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk)
+{
+	struct _IO_FILE *fp = udpid_to_fd(cepid);
+	FLGPTN flgptn = 0;
+
+	if (fp == NULL)
+		return E_PAR;
+
+	int fd = fp->fd;
+	FD_SET(fd, (fd_set *)&flgptn);
+
+	switch (fncd) {
+	case TFN_UDP_CRE_CEP:
+	case TFN_UDP_RCV_DAT:
+		if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
+
+		set_flg(FLG_SELECT_WAIT, flgptn);
+		return E_OK;
+
+	case TFN_UDP_SND_DAT:
+		if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
+
+		set_flg(FLG_SELECT_WAIT, flgptn);
+		return E_OK;
+
+	case TFN_UDP_CAN_CEP:
+		if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
+
+		set_flg(FLG_SELECT_WAIT, flgptn);
+		return E_OK;
+
+	case TFN_UDP_DEL_CEP:
+		delete_udp_fd(cepid);
+		return E_OK;
+
+	default:
+		return E_OK;
+	}
+}
+
+ER shell_get_evts(struct fd_events *evts, TMO tmout)
+{
+	ER ret;
+	FLGPTN waitptn, flgptn = 0;
+
+	stdio_update_evts();
+
+	waitptn = *((FLGPTN *)&evts->readfds) | *((FLGPTN *)&evts->writefds) | *((FLGPTN *)&evts->errorfds);
+	memset(evts, 0, sizeof(*evts));
+
+	/* ã¤ãã³ãå¾
+ã¡ */
+	ret = twai_flg(FLG_SELECT_WAIT, waitptn, TWF_ORW, &flgptn, tmout);
+	if (ret != E_OK) {
+		if (ret != E_TMOUT) {
+			syslog(LOG_ERROR, "twai_flg => %d", ret);
+			return ret;
+		}
+
+		stdio_flgptn(&flgptn);
+
+		if (flgptn == 0)
+			return E_TMOUT;
+	}
+	flgptn &= waitptn;
+
+	/* åãåã£ããã©ã°ã®ã¿ã¯ãªã¢ */
+	ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
+	if (ret != E_OK) {
+		syslog(LOG_ERROR, "clr_flg => %d", ret);
+	}
+
+	struct _IO_FILE *fp = NULL;
+	for (int fd = 0; fd < fd_table_count; fd++) {
+		if (!FD_ISSET(fd, (fd_set *)&flgptn))
+			continue;
+
+		fp = &fd_table[fd];
+
+		if (fp->readevt_w != fp->readevt_r) {
+			fp->readevt_r++;
+			FD_SET(fd, &evts->readfds);
+			evts->count++;
+		}
+		if (fp->writeevt_w != fp->writeevt_r) {
+			fp->writeevt_r++;
+			FD_SET(fd, &evts->writefds);
+			evts->count++;
+		}
+		if (fp->errorevt_w != fp->errorevt_r) {
+			fp->errorevt_r++;
+			FD_SET(fd, &evts->errorfds);
+			evts->count++;
+		}
+	}
+
+	return E_OK;
+}
+
+void clean_fd()
+{
+	struct _IO_FILE *fp = NULL;
+	for (int fd = 3; fd < fd_table_count; fd++) {
+		fp = &fd_table[fd];
+		if ((fp->type == 0) || (fp->fd == 0))
+			continue;
+
+		fp->close(fp);
+
+		memset(fp, 0, sizeof(*fp));
+	}
+}
Index: /EcnlProtoTool/trunk/ntshell/src/io_stub.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/io_stub.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/io_stub.c	(revision 279)
@@ -0,0 +1,490 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include "ff.h"
+#include <kernel.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include <sil.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include "syssvc/syslog.h"
+#include <tinet_config.h>
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <tinet_nic_defs.h>
+#include <tinet_cfg.h>
+#include <netinet/in_var.h>
+#include <net/ethernet.h>
+#include <net/if6_var.h>
+#include <net/net.h>
+#include <net/if_var.h>
+#include <netinet/udp_var.h>
+#include <ethernet_api.h>
+#include "ff.h"
+#include "socket_stub.h"
+#include "../../../musl-1.1.12/include/_dirent.h"
+#include "../../../musl-1.1.12/include/_termios.h"
+#include "ntstdio.h"
+
+int shell_open(const char * path, int flags)
+{
+	FRESULT res;
+
+	struct _IO_FILE *fp = new_file_fd(0);
+	if (fp == NULL)
+		return -1;
+
+	BYTE fmd = 0;
+	switch (flags & O_ACCMODE) {
+	case O_RDONLY:
+		fmd = FA_READ;
+		break;
+	case O_WRONLY:
+		fmd = FA_WRITE;
+		break;
+	default:
+		fmd = FA_READ | FA_WRITE;
+		break;
+	}
+	/* ãã¡ã¤ã«ãä½æ */
+	if (flags & O_CREAT) {
+		/* æ¢å­ã®å
+å®¹ã¯æ¶ã */
+		if (flags & O_TRUNC) {
+			fmd |= FA_CREATE_ALWAYS;
+		}
+		/* æ°è¦ä½æã®ä¿é */
+		else if (flags & O_EXCL) {
+			fmd |= FA_CREATE_NEW;
+		}
+		else {
+			fmd |= FA_OPEN_ALWAYS;
+		}
+	}
+	/* ããå ´åã¯éã */
+	else {
+		/* æ¢å­ã®å
+å®¹ã¯æ¶ã */
+		if (flags & O_TRUNC) {
+			fmd |= FA_CREATE_ALWAYS;
+		}
+	}
+
+	if ((res = f_open(&fp->file, path, fmd)) == FR_OK) {
+		fp->handle = fp->fd;
+		return fp->fd;
+	}
+
+	return -1;
+}
+
+int file_close(struct _IO_FILE *fp)
+{
+	FRESULT res;
+
+	if ((res = f_close(&fp->file)) == FR_OK) {
+		return 0;
+	}
+
+	return -1;
+}
+
+size_t file_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
+{
+	unsigned int ret = 0;
+	FRESULT res;
+
+	if ((res = f_read(&fp->file, data, len, &ret)) != FR_OK)
+		return -1;
+
+	return ret;
+}
+
+size_t file_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
+{
+	unsigned int ret = 0;
+	FRESULT res;
+
+	if ((res = f_write(&fp->file, data, len, &ret)) != FR_OK)
+		return -1;
+
+	return ret;
+}
+
+int shell_close(int fd)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+
+	return fp->close(fp);
+}
+
+int shell_read(int fd, char *data, int len)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+
+	return fp->read(fp, (unsigned char *)data, len);
+}
+
+int shell_write(int fd, char *data, int len)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+
+	return fp->write(fp, (unsigned char *)data, len);
+}
+
+int shell_lseek(int fd, int ptr, int dir)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+
+	FRESULT res;
+	if ((res = f_seek(&fp->file, ptr, dir)) != FR_OK)
+		return -1;
+
+	return fp->file.fptr;
+}
+
+int shell_fstat(int fd, struct stat * st)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+
+	memset(st, 0, sizeof(*st));
+	st->st_mode = S_IFCHR;
+	//st->st_blksize = 1024;
+	return 0;
+}
+
+int fsync(int fd)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+	return -1;
+}
+
+int ftruncate(int fd, off_t length)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+
+	FRESULT res;
+	if ((res = f_truncate(&fp->file)) != FR_OK)
+		return -1;
+
+	return 0;
+}
+
+int ioctl(int fd, int request, va_list ap)
+{
+	struct _IO_FILE *fp = fd_to_fp(fd);
+	if (fp == NULL)
+		return -1;
+	return -1;
+}
+
+int tcgetattr(int fd, struct termios *termios)
+{
+	extern ntstdio_t ntstdio;
+
+	if (fd == STDIN_FILENO) {
+		memset(termios, 0, sizeof(*termios));
+
+		if (ntstdio.option & NTSTDIO_OPTION_LINE_ECHO) {
+			termios->c_lflag |= ECHO;
+		}
+		else {
+			termios->c_lflag &= ~ECHO;
+		}
+		if (ntstdio.option & NTSTDIO_OPTION_CANON) {
+			termios->c_lflag |= ICANON;
+		}
+		else {
+			termios->c_lflag &= ~ICANON;
+		}
+		if (ntstdio.option & NTSTDIO_OPTION_LF_CR) {
+			termios->c_iflag |= INLCR;
+		}
+		else {
+			termios->c_iflag &= ~INLCR;
+		}
+		if (ntstdio.option & NTSTDIO_OPTION_LF_CRLF) {
+			termios->c_oflag |= ONLCR;
+		}
+		else {
+			termios->c_oflag &= ~ONLCR;
+		}
+		return 0;
+	}
+	abort();
+	return 0;
+}
+
+int tcsetattr(int fd, int optional_actions, const struct termios *termios)
+{
+	extern ntstdio_t ntstdio;
+
+	if ((fd == STDIN_FILENO) && (optional_actions == TCSANOW)) {
+		if (termios->c_lflag & ECHO) {
+			ntstdio.option |= NTSTDIO_OPTION_LINE_ECHO;
+		}
+		else {
+			ntstdio.option &= ~NTSTDIO_OPTION_LINE_ECHO;
+		}
+		if (termios->c_lflag & ICANON) {
+			ntstdio.option |= NTSTDIO_OPTION_CANON;
+		}
+		else {
+			ntstdio.option &= ~NTSTDIO_OPTION_CANON;
+		}
+		if (termios->c_iflag & INLCR) {
+			ntstdio.option |= NTSTDIO_OPTION_LF_CR;
+		}
+		else{
+			ntstdio.option &= ~NTSTDIO_OPTION_LF_CR;
+		}
+		if (termios->c_oflag & ONLCR) {
+			ntstdio.option |= NTSTDIO_OPTION_LF_CRLF;
+		}
+		else {
+			ntstdio.option &= ~NTSTDIO_OPTION_LF_CRLF;
+		}
+		return 0;
+	}
+	abort();
+	return 0;
+}
+
+int shell_stat(const char *path, struct stat *st)
+{
+	FILINFO fi;
+	FRESULT ret;
+#if _USE_LFN
+	static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
+	fi.lfname = lfn;
+	fi.lfsize = sizeof lfn;
+#endif
+	if (strcmp(path, ".") == 0) {
+		char cwd[_MAX_LFN];
+		if ((ret = f_getcwd(cwd, sizeof(cwd))) != FR_OK) {
+		return -1;
+		}
+		int l = strlen(cwd);
+		// ã«ã¼ããã£ã¬ã¯ããªã®å ´å
+		if (cwd[l - 2] == ':' && cwd[l - 1] == '/') {
+			st->st_size = 0;
+			st->st_mtime = 0;
+			st->st_mode = S_IFDIR;
+			return 0;
+		}
+		if ((ret = f_stat(cwd, &fi)) != FR_OK) {
+			return -1;
+		}
+	}
+	else if ((ret = f_stat(path, &fi)) != FR_OK) {
+		return -1;
+	}
+
+	st->st_size = fi.fsize;
+	st->st_mtime = fi.fdate + fi.ftime;
+	st->st_mode  = (S_IRUSR | S_IRGRP | S_IROTH);
+	st->st_mode |= (fi.fattrib & AM_RDO) ? 0 : (S_IWUSR | S_IWGRP | S_IWOTH);
+	st->st_mode |= (fi.fattrib & (AM_DIR | AM_VOL)) ? S_IFDIR : S_IFREG;
+
+	return 0;
+}
+
+int shell_link(void)
+{
+	return -1;
+}
+
+int shell_unlink(const char *path)
+{
+	FRESULT res;
+
+	if ((res = f_unlink(path)) != FR_OK)
+		return -1;
+
+	return 0;
+}
+
+int rmdir(const char *path)
+{
+	FRESULT res;
+
+	if ((res = f_unlink(path)) != FR_OK)
+		return -1;
+
+	return 0;
+}
+
+int shell_rename(const char *oldpath, const char *newpath)
+{
+	FRESULT res;
+
+	if ((res = f_rename(oldpath, newpath)) != FR_OK)
+		return -1;
+	return 0;
+}
+
+int mkdir(const char *path, mode_t mode)
+{
+	FRESULT res;
+
+	if ((res = f_mkdir(path)) != FR_OK)
+		return -1;
+
+	BYTE attr = 0;
+	BYTE mask = AM_RDO | AM_SYS; // AM_ARC, AM_HID
+
+	if(mode & S_IREAD) {
+		if((mode & S_IWRITE) == 0) {
+			attr |= AM_RDO;
+		}
+	}
+	else {
+		attr |= AM_SYS;
+	}
+
+	if((res = f_chmod(path, attr, mask)) != FR_OK) {
+		return -1;
+	}
+
+	return 0;
+}
+
+int chmod(const char *path, mode_t mode)
+{
+	FRESULT ret;
+	BYTE attr = 0;
+	BYTE mask = AM_RDO | AM_SYS; // AM_ARC, AM_HID
+
+	if(mode & S_IREAD) {
+		if((mode & S_IWRITE) == 0) {
+			attr |= AM_RDO;
+		}
+	}
+	else {
+		attr |= AM_SYS;
+	}
+
+	if((ret = f_chmod(path, attr, mask)) != FR_OK) {
+		return -1;
+	}
+
+	return 0;
+}
+
+char *getcwd(char *buf, size_t size)
+{
+	FRESULT ret;
+	if((ret = f_getcwd(buf, size)) != FR_OK) {
+		return NULL;
+	}
+
+	return buf;
+}
+
+int chdir(const char *path)
+{
+	FRESULT ret;
+	if ((ret = f_chdir(path)) != FR_OK) {
+		return -1;
+	}
+
+	return 0;
+}
+
+int chroot(const char *path)
+{
+	abort();
+	return -1;
+}
+
+DIR *opendir(const char *path)
+{
+	DIR *dir = malloc(sizeof(DIR) + sizeof(struct dirent));
+	FRESULT ret;
+	if ((ret = f_opendir(dir, path)) != FR_OK) {
+		free(dir);
+		return NULL;
+	}
+
+	dir->dirent = &dir[1];
+	return dir;
+}
+
+int closedir(DIR *dir)
+{
+	FRESULT ret;
+	if ((ret = f_closedir(dir)) != FR_OK) {
+		free(dir);
+		return -1;
+	}
+
+	free(dir);
+	return 0;
+}
+
+struct dirent *readdir(DIR *dir)
+{
+	struct dirent *de = dir->dirent;
+	FILINFO fno;
+#if _USE_LFN
+	static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
+	fno.lfname = lfn;
+	fno.lfsize = sizeof lfn;
+#endif
+	FRESULT ret;
+	if ((ret = f_readdir(dir, &fno)) != FR_OK || fno.fname[0] == '\0') {
+		return NULL;
+	}
+
+	memset(de, 0, sizeof(*de));
+#if _USE_LFN
+	strlcpy(de->d_name, *fno.lfname ? fno.lfname : fno.fname, sizeof(de->d_name));
+#else
+	strlcpy(de->d_name, fno.fname, sizeof(de->d_name));
+#endif
+
+	return de;
+}
+
+void rewinddir(DIR *dir)
+{
+	FRESULT ret;
+	if ((ret = f_rewinddir(dir)) != FR_OK) {
+		return;
+	}
+}
+
+void seekdir(DIR *dir, long pos)
+{
+	abort();
+}
+
+long telldir(DIR *dir)
+{
+	abort();
+	return 0;
+}
+
+int shell_getpid(int n)
+{
+	return 1;
+}
Index: /EcnlProtoTool/trunk/ntshell/src/main.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/main.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/main.c	(revision 279)
@@ -0,0 +1,537 @@
+/*
+ *  TOPPERS ECHONET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2014-2017 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãµã³ãã«ãã­ã°ã©ã (1)ã®æ¬ä½
+ */
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include <sil.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include "syssvc/serial.h"
+#include "syssvc/syslog.h"
+#include "kernel_cfg.h"
+#include "main.h"
+#include "rza1.h"
+#include <tinet_config.h>
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <tinet_nic_defs.h>
+#include <tinet_cfg.h>
+#include <netinet/in_var.h>
+#include <net/ethernet.h>
+#include <net/if6_var.h>
+#include <net/net.h>
+#include <net/if_var.h>
+#include <netinet/udp_var.h>
+#include <ethernet_api.h>
+#include "ffarch.h"
+#include "gpio_api.h"
+#include "ff.h"
+#include "websocket_fbs.h"
+#include "ntshell.h"
+#include "ntstdio.h"
+#include "usrcmd.h"
+#include "ntopt.h"
+
+#ifndef _MSC_VER
+void strcpy_s(char *dst, int size, const char *src);
+#endif
+
+ID ws_api_mailboxid = MAIN_DATAQUEUE;
+ID ws_mempoolid = MPF_NET_BUF_256;
+
+#define SIO_PORTID 1
+
+char command[NTOPT_TEXT_MAXLEN];
+ntstdio_t ntstdio;
+
+const uint8_t mac_addr[6] = {0x00, 0x30, 0x13, 0x06, 0x62, 0xC0};
+const char host_name[] = "GR-PEACH";
+
+static void netif_link_callback(T_IFNET *ether);
+extern int execute_command(int wait);
+
+enum main_state_t {
+	main_state_start,
+	main_state_idle,
+};
+
+struct main_t {
+	TMO timer;
+	enum main_state_t state;
+	SYSTIM prev, now;
+	WS_FBS_ID rcvmsg;
+	T_WS_FBS_QUEUE wbs_queue;
+	WS_FBS_ID sndmsg;
+};
+struct main_t main_obj;
+
+static void main_initialize();
+static TMO main_get_timer();
+static void main_progress(TMO interval);
+static void main_timeout();
+
+int uart_read(char *buf, int cnt, void *extobj)
+{
+	return serial_rea_dat(SIO_PORTID, (char *)buf, cnt);
+#if 0
+	int result = cnt;
+	ER ret;
+	bool_t tmo = false;
+
+	while (cnt > 0) {
+		/* ã¿ã¤ã ã¢ã¦ãå¦ç */
+		if (tmo) {
+			tmo = false;
+			main_timeout();
+		}
+
+		if (main_obj.rcvmsg.ptr == NULL) {
+			ER ret2;
+			TMO timer;
+			WS_FBS_ID msg;
+
+			main_obj.prev = main_obj.now;
+
+			timer = main_get_timer();
+
+			ret = trcv_dtq(MAIN_DATAQUEUE, (intptr_t *)&msg, timer);
+			if ((ret != E_OK) && (ret != E_TMOUT)) {
+				syslog(LOG_ERROR, "trcv_dtq => %d", ret);
+				ext_tsk();
+				return 0;
+			}
+
+			ret2 = get_tim(&main_obj.now);
+			if (ret2 != E_OK) {
+				syslog(LOG_ERROR, "get_tim");
+				ext_tsk();
+				return 0;
+			}
+
+			/* æéçµé */
+			main_progress(main_obj.now - main_obj.prev);
+
+			if (ret == E_OK) {
+				/* ã¡ãã»ã¼ã¸åä¿¡å¦ç */
+				if (main_obj.rcvmsg.ptr == NULL) {
+					main_obj.rcvmsg = msg;
+				}
+				else {
+					ws_fbs_enqueue(&main_obj.wbs_queue, msg.ptr);
+				}
+			}
+
+			tmo = true;
+		}
+		else {
+			WS_FBS_SSIZE_T len, slen;
+
+			len = _ws_fbs_get_datalen(main_obj.rcvmsg);
+			if (len > cnt)
+				len = cnt;
+
+			ret = _ws_fbs_get_data(main_obj.rcvmsg, buf, len, &slen);
+			if (ret != E_OK) {
+				syslog(LOG_ERROR, "_ws_fbs_get_data msg = %p, type = %d, result = %d", main_obj.rcvmsg.ptr, main_obj.rcvmsg.ptr->hdr.type, ret);
+				ext_tsk();
+			}
+			cnt -= slen;
+
+			/* ãã¼ã¿ãç©ºã®å ´å */
+			if (!_ws_fbs_exist_data(main_obj.rcvmsg)) {
+				ret = _ws_fbs_del(main_obj.rcvmsg);
+				if (ret != E_OK) {
+					syslog(LOG_ERROR, "trcv_dtq msg = %p, type = %d, result = %d", main_obj.rcvmsg.ptr, main_obj.rcvmsg.ptr->hdr.type, ret);
+					ext_tsk();
+				}
+
+				main_obj.rcvmsg.ptr = NULL;
+
+				/* ã­ã¥ã¼ãããã¼ã¿ãåå¾ */
+				ret = ws_fbs_dequeue(&main_obj.wbs_queue, &main_obj.rcvmsg.ptr);
+			}
+		}
+	}
+
+	return result;
+#endif
+}
+
+int uart_write(const char *buf, int cnt, void *extobj)
+{
+	return serial_wri_dat(SIO_PORTID, buf, cnt);
+#if 0
+	int result = cnt;
+	ER ret;
+
+	while (cnt > 0) {
+		_ws_fbs_cre(cnt, &main_obj.sndmsg);
+
+		//((ID *)main_obj.sndmsg.ptr->_gap)[0] = wbsid;
+		_ws_fbs_add_data(main_obj.sndmsg, buf, cnt);
+
+		ret = psnd_dtq(WEBSOCKET_MBXID, (intptr_t)main_obj.sndmsg.ptr);
+		if (ret != E_OK) {
+			syslog(LOG_ERROR, "psnd_dtq(WEBSOCKET_MBXID) : result=%d", ret);
+			_ws_fbs_del(main_obj.sndmsg);
+			return ret;
+		}
+	}
+
+	return result;
+#endif
+}
+
+unsigned char ntstdio_xi(struct ntstdio_t *handle)
+{
+	char buf[1];
+	if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)
+		return -1;
+	return buf[0];
+}
+
+void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
+{
+	char buf[1];
+	buf[0] = c;
+	serial_wri_dat(SIO_PORTID, buf, 1);
+}
+
+ntshell_t ntshell;
+static int cmd_execute(const char *text, void *extobj);
+
+/*
+ * ã¡ã¤ã³ã¿ã¹ã¯
+ */
+void main_task(intptr_t exinf)
+{
+	main_initialize();
+
+	ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
+	ntshell_set_prompt(&ntshell, "NTShell>");
+	ntshell_execute(&ntshell);
+}
+
+/*
+ * åæå
+ */
+static void main_initialize()
+{
+	FILINFO fno;
+#if _USE_LFN
+	char lfn[_MAX_LFN + 1];
+	fno.lfname = lfn;
+	fno.lfsize = _MAX_LFN + 1;
+#endif
+	ER ret2;
+
+	ntstdio_init(&ntstdio, NTSTDIO_OPTION_LINE_ECHO | NTSTDIO_OPTION_CANON | NTSTDIO_OPTION_LF_CRLF | NTSTDIO_OPTION_LF_CR, ntstdio_xi, ntstdio_xo);
+
+	main_obj.timer = TMO_FEVR;
+	main_obj.state = main_state_start;
+
+	gpio_t led_blue, led_green, led_red, sw;
+	gpio_init_out(&led_blue, LED_BLUE);
+	gpio_init_out(&led_green, LED_GREEN);
+	gpio_init_out(&led_red, LED_RED);
+	gpio_init_in(&sw, USER_BUTTON0);
+
+	bool_t exec = gpio_read(&sw) == 1;
+
+	gpio_write(&led_blue, 1);
+	gpio_write(&led_green, exec ? 1 : 0);
+	gpio_write(&led_red, 0);
+
+	ether_set_link_callback(netif_link_callback);
+
+	/* åæå */
+	if (mruby_arduino_init() == 0) {
+		gpio_write(&led_blue, 0);
+	}
+	else {
+		gpio_write(&led_blue, 0);
+		gpio_write(&led_red, 1);
+	}
+
+	gpio_write(&led_green, 0);
+
+	act_tsk(HTTPD1_TASK);
+	act_tsk(HTTPD2_TASK);
+
+	if (f_stat("1:/upload/main.mrb", &fno) != FR_OK) {
+		exec = false;
+	}
+
+	if (exec) {
+		strcpy_s(command, sizeof(command), "mruby -b 1:/upload/main.mrb");
+
+		execute_command(1);
+	}
+
+	ret2 = get_tim(&main_obj.now);
+	if (ret2 != E_OK) {
+		syslog(LOG_ERROR, "get_tim");
+		ext_tsk();
+		return;
+	}
+}
+
+/*
+ * ã¿ã¤ãã¼åå¾
+ */
+static TMO main_get_timer()
+{
+	TMO timer = main_obj.timer;
+
+	return timer;
+}
+
+/*
+ * æéçµé
+ */
+static void main_progress(TMO interval)
+{
+	if (main_obj.timer != TMO_FEVR) {
+		main_obj.timer -= interval;
+		if (main_obj.timer < 0) {
+			main_obj.timer = 0;
+		}
+	}
+}
+
+/*
+ * ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+static void main_timeout()
+{
+	//if (main_obj.timer == 0) {
+	//}
+}
+
+/* MACã¢ãã¬ã¹ã®è¨­å®æã«å¼ã°ãã */
+void mbed_mac_address(char *mac)
+{
+	memcpy(mac, mac_addr, 6);
+}
+
+static void netif_link_callback(T_IFNET *ether)
+{
+	FLGPTN flgptn;
+	T_RTSK rtsk;
+	ER ret;
+
+	ret = ref_tsk(MRUBY_TASK, &rtsk);
+	if ((ret != E_OK) || (rtsk.tskstat == TTS_DMT))
+		return;
+
+	FD_SET(0, (fd_set *)&flgptn);
+
+	set_flg(FLG_SELECT_WAIT, flgptn);
+}
+
+int gethostname(char *name, size_t len)
+{
+	return strlcpy(name, host_name, len);
+}
+
+static int usrcmd_ntopt_callback(int argc, char **argv, void *extobj);
+int mruby_exit_code;
+volatile int mruby_state;
+typedef void (*PowerOn_Reset_t)(int argc, char **argv);
+jmp_buf process_exit;
+
+/*
+ *  mrubyå®è¡ã¿ã¹ã¯
+ */
+void mruby_task(intptr_t exinf)
+{
+	mruby_state = 1;
+	mruby_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL);
+	mruby_state = 2;
+}
+
+static int usrcmd_ntopt_callback(int argc, char **argv, void *extobj)
+{
+	if (setjmp(process_exit) == 0) {
+		(*((PowerOn_Reset_t *)0x18200000))(argc, argv);
+	}
+	clean_fd();
+	return 0;
+}
+
+void shellif_into()
+{
+	/* ã¡ã¤ã³ã¿ã¹ã¯ã®åªå
+åº¦ããé«ããã */
+	chg_pri(MRUBY_PRIORITY, MAIN_PRIORITY + 1);
+}
+
+void shellif_outof()
+{
+	/* mrubyå®è¡ã¿ã¹ã¯ã®åªå
+åº¦ã«æ»ã */
+	chg_pri(MRUBY_PRIORITY, MRUBY_PRIORITY);
+}
+
+void shell_abort()
+{
+	asm("bkpt #0");
+
+	mruby_exit_code = -1;
+	longjmp(process_exit, 1);
+}
+
+void shell_exit(int exitcd)
+{
+	mruby_exit_code = exitcd;
+	longjmp(process_exit, 1);
+}
+
+int execute_command(int wait)
+{
+	ER ret;
+
+	ret = ter_tsk(MRUBY_TASK);
+	if ((ret != E_OK) && (ret != E_OBJ)) {
+		syslog(LOG_ERROR, "ter_tsk => %d", ret);
+	}
+
+	tslp_tsk(100000);
+
+	clean_fd();
+
+	mruby_state = 0;
+	ret = act_tsk(MRUBY_TASK);
+	if (ret != E_OK) {
+		syslog(LOG_ERROR, "act_tsk => %d", ret);
+	}
+
+	if (wait == 0)
+		return 0;
+
+	do {
+		tslp_tsk(100000);
+	} while(mruby_state == 1);
+
+	return mruby_exit_code;
+}
+
+static int cmd_execute(const char *text, void *extobj)
+{
+	strlcpy(command, text, sizeof(command));
+	return execute_command(1);
+}
+
+int stdio_close(struct _IO_FILE *fp)
+{
+	return -1;
+}
+
+size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
+{
+	return -1;
+}
+
+size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
+{
+	return -1;
+}
+
+size_t stdin_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
+{
+	int i = 0;
+	while (i < len) {
+		int c = ntstdio_getc(&ntstdio);
+		data[i++] = c;
+		if ((c == EOF) || (c == '\n'))
+			break;
+	}
+	return i;
+}
+
+size_t stdout_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
+{
+	for (int i = 0; i < len; i++) {
+		ntstdio_putc(&ntstdio, data[i]);
+	}
+	return len;
+}
+
+size_t stderr_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
+{
+	for (int i = 0; i < len; i++) {
+		ntstdio_putc(&ntstdio, data[i]);
+	}
+	return len;
+}
+
+int sio_close(struct _IO_FILE *fp)
+{
+	return -1;
+}
+
+size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
+{
+	return -1;
+}
+
+size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
+{
+	return -1;
+}
Index: /EcnlProtoTool/trunk/ntshell/src/main.cdl
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/main.cdl	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/main.cdl	(revision 279)
@@ -0,0 +1,125 @@
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ *
+ *  $Id$
+ */
+/*
+ *  ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å®ç¾©
+ */
+import(<kernel.cdl>);
+
+/*
+ *  ã¿ã¼ã²ããéä¾å­ã®ã»ã«ã¿ã¤ãã®å®ç¾©
+ */
+import("syssvc/tSerialPort.cdl");
+import("syssvc/tSerialAdapter.cdl");
+import("syssvc/tSysLog.cdl");
+import("syssvc/tSysLogAdapter.cdl");
+import("syssvc/tLogTask.cdl");
+import("syssvc/tBanner.cdl");
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨ã®åãè¾¼ã¿
+ */
+import("target.cdl");
+
+/*
+ *  ãã»ã«ã®çµä¸ãè¨è¿°ãã¨ã¯ï¼"cell"ã§å§ã¾ãè¡ããï¼ããã«å¯¾å¿ãã"};"
+ *  ã®è¡ã¾ã§ã®ãã¨ãè¨ãï¼
+ */
+
+/*
+ *  ã·ã¹ãã ã­ã°æ©è½ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãï¼ã³
+ *  ã³ãã¤ã«ãªãã·ã§ã³ã«-DTOPPERS_OMIT_SYSLOGãè¿½å ããã°ããï¼ãã ãï¼
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ã¹ãã ã­ã°æ©è½ãä½¿ç¨ããããï¼ãããå¤ããã¨
+ *  ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ã¹ãã ã­ã°æ©è½ã®ã¢ããã¿ãå¤ããªããã°ãªããª
+ *  ãï¼tecsgenãè­¦åã¡ãã»ã¼ã¸ãåºããï¼ç¡è¦ãã¦ããï¼
+ */
+cell tSysLog SysLog {
+	logBufferSize = 32;					/* ã­ã°ãããã¡ã®ãµã¤ãº */
+	initLogMask = C_EXP("LOG_UPTO(LOG_NOTICE)");
+										/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
+	initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)");
+									   	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ã¹ãã ã­ã°æ©è½
+ *  ãå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ã®ãµã¼ãã¹ã³ã¼ã«ï¼syslogé¢æ°ã¨syslog_0é¢æ°ï½syslog_5
+ *  é¢æ°ä»¥å¤ã®ãã®ï¼ã«ãCè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºããª
+ *  ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ããã°ããï¼
+ */
+cell tSysLogAdapter SysLogAdapter {
+	cSysLog = SysLog.eSysLog;
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®çµä¸ãè¨è¿°
+ *
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ããå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨
+ *  è¿°ãåé¤ããã°ããï¼ãã ãï¼ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼
+ *  ã¹ãã©ã¤ããä½¿ç¨ããããï¼ãããå¤ããã¨ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ãªã¢
+ *  ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¢ããã¿ãå¤ããªããã°ãªããªãï¼
+ */
+cell tSerialPort SerialPort1 {
+	receiveBufferSize = 256;			/* åä¿¡ãããã¡ã®ãµã¤ãº */
+	sendBufferSize    = 256;			/* éä¿¡ãããã¡ã®ãµã¤ãº */
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã¨ã®çµå */
+	cSIOPort = SIOPortTarget1.eSIOPort;
+	eiSIOCBR <= SIOPortTarget1.ciSIOCBR;	/* ã³ã¼ã«ããã¯ */
+};
+
+/*
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ãªã¢ã«ã¤ã³ã¿
+ *  ãã§ã¼ã¹ãã©ã¤ããå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ãµã¼ãã¹ã³ã¼ã«ãCè¨èªã§è¨è¿°ãããã¢
+ *  ããªã±ã¼ã·ã§ã³ããå¼ã³åºããªãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãå
+ *  é¤ããã°ããï¼
+ */
+cell tSerialAdapter SerialAdapter {
+	cSerialPort[0] = SerialPort1.eSerialPort;
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãã
+ *  ã°ããï¼
+ */
+cell tLogTask LogTask {
+	priority  = 3;					/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®åªå
+åº¦ */
+	stackSize = LogTaskStackSize;	/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+	/* ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨ã®çµå */
+	cSerialPort        = SerialPort1.eSerialPort;
+	cnSerialPortManage = SerialPort1.enSerialPortManage;
+
+	/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®çµå */
+	cSysLog = SysLog.eSysLog;
+
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåã®çµä¸ãè¨è¿°
+ *
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸ã®åºåãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°
+ *  ãåé¤ããã°ããï¼
+ */
+cell tBanner Banner {
+	/* å±æ§ã®è¨­å® */
+	targetName      = BannerTargetName;
+	copyrightNotice = BannerCopyrightNotice;
+};
Index: /EcnlProtoTool/trunk/ntshell/src/main.cfg
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/main.cfg	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/main.cfg	(revision 279)
@@ -0,0 +1,79 @@
+/*
+ *  TOPPERS ECHONET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2014-2016 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãµã³ãã«ãã­ã°ã©ã (1)ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+#include "main.h"
+#include <tinet_config.h>
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <tinet_nic_defs.h>
+#include <netinet/in_var.h>
+#include <net/ethernet.h>
+#include <net/if6_var.h>
+
+INCLUDE("tecsgen.cfg");
+INCLUDE("tinet/tinet_asp.cfg");
+INCLUDE("tinet_main.cfg");
+/*#include "netapp/dhcp4_cli.h"*/
+/*INCLUDE("netapp/dhcp4_cli_asp.cfg");*/
+INCLUDE("ffarch.cfg");
+INCLUDE("httpd.cfg");
+INCLUDE("websocket.cfg");
+
+CRE_TSK(MAIN_TASK, { TA_ACT, 0, main_task, MAIN_PRIORITY, MAIN_STACK_SIZE, NULL });
+CRE_DTQ(MAIN_DATAQUEUE, { TA_TFIFO, NUM_MAIN_DATAQUEUE, NULL });
+CRE_SEM(SEM_FILESYSTEM, { TA_TPRI, 1, 1 });
+
+CRE_TSK(MRUBY_TASK, { TA_NULL, 0, mruby_task, MRUBY_PRIORITY, MRUBY_STACK_SIZE, (void *)0x20600000 });
+CRE_FLG(FLG_SELECT_WAIT, { TA_WMUL, 0x00 });
Index: /EcnlProtoTool/trunk/ntshell/src/main.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/main.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/main.h	(revision 279)
@@ -0,0 +1,101 @@
+/*
+ *  TOPPERS ECHONET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2014-2017 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _MAIN_H_
+#define _MAIN_H_
+
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ããããã¡ã¤ã«
+ */
+
+/*
+ *  ã¿ã¼ã²ããä¾å­ã®å®ç¾©
+ */
+#include <kernel.h>
+
+/*
+ *  åã¿ã¹ã¯ã®åªå
+åº¦ã®å®ç¾©
+ */
+
+#define MAIN_PRIORITY	5		/* ã¡ã¤ã³ã¿ã¹ã¯ã®åªå
+åº¦ */
+#define MRUBY_PRIORITY	4		/* mrubyå®è¡ã¿ã¹ã¯ã®åªå
+åº¦ */
+
+#define MAIN_STACK_SIZE		2048	/* ã¡ã¤ã³ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®ãµã¤ãº */
+#define MRUBY_STACK_SIZE	0x100000	/* mrubyå®è¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®ãµã¤ãº */
+
+#define NUM_MAIN_DATAQUEUE	1	/* ã¡ã¤ã³ã¿ã¹ã¯ã§å¾
+ã¡åãã¦ãããã¼ã¿ã­ã¥ã¼ã®ãµã¤ãº */
+#define NUM_MRUBY_DATAQUEUE	1	/* mrubyå®è¡ã¿ã¹ã¯ã§å¾
+ã¡åãã¦ãããã¼ã¿ã­ã¥ã¼ã®ãµã¤ãº */
+
+/*
+ *  é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+/* ã¡ã¤ã³ã¿ã¹ã¯ */
+extern void main_task(intptr_t exinf);
+
+/* mrubyå®è¡ã¿ã¹ã¯ */
+extern void mruby_task(intptr_t exinf);
+
+/* 
+ * ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+extern ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk);
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#endif	/* of #ifndef _MAIN_H_ */
Index: /EcnlProtoTool/trunk/ntshell/src/route_cfg.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/route_cfg.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/route_cfg.c	(revision 279)
@@ -0,0 +1,113 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ã«ã¼ãã£ã³ã°è¡¨
+ */
+
+#include <kernel.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_INET4
+
+#ifdef SUPPORT_LOOP
+
+T_IN4_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = {
+	{ 0, 0, 0 },
+	};
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_PPP
+
+T_IN4_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = {
+	{ 0, 0, 0 },
+	};
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+T_IN4_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = {
+
+	/* ç°ãªã LANãdefault gateway ã«ããéæ¥é
+é	*/
+	{ 0,			0,			IPV4_ADDR_DEFAULT_GW	},
+
+	/* åä¸ LAN å
+ãç´æ¥é
+é				*/
+	{ IPV4_ADDR_LOCAL &
+	  IPV4_ADDR_LOCAL_MASK,	IPV4_ADDR_LOCAL_MASK,	0			},
+
+	/* åä¸ LAN å
+ã¸ã®ãã­ã¼ãã­ã£ã¹ããç´æ¥é
+é	*/
+	{ 0xffffffff,		0xffffffff,		0			},
+
+	};
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_INET6
+
+#if NUM_ROUTE_ENTRY > 0
+
+T_IN6_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = { };
+
+#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
Index: /EcnlProtoTool/trunk/ntshell/src/shellif.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/shellif.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/shellif.c	(revision 279)
@@ -0,0 +1,789 @@
+#include <setjmp.h>
+#include <sys/time.h>
+#include <stdarg.h>
+#include "../../../musl-1.1.12/include/poll.h"
+#include "analogin_api.h"
+#include "gpio_api.h"
+#include "i2c_api.h"
+#include "pwmout_api.h"
+#include "rtc_api.h"
+#include "serial_api.h"
+#include "us_ticker_api.h"
+#include "wait_api.h"
+#include "usrcmd.h"
+#include "ff.h"
+#include <kernel.h>
+#include "socket_stub.h"
+
+void shellif_into();
+void shellif_outof();
+
+void __exp_analogin_init(analogin_t *obj, PinName pin)
+{
+	shellif_into();
+	analogin_init(obj, pin);
+	shellif_outof();
+}
+
+uint16_t __exp_analogin_read_u16(analogin_t *obj)
+{
+	uint16_t result;
+	shellif_into();
+	result = analogin_read_u16(obj);
+	shellif_outof();
+	return result;
+}
+
+void __exp_gpio_init(gpio_t *obj, PinName pin)
+{
+	shellif_into();
+	gpio_init(obj, pin);
+	shellif_outof();
+}
+
+void __exp_gpio_dir(gpio_t *obj, PinDirection direction)
+{
+	shellif_into();
+	gpio_dir(obj, direction);
+	shellif_outof();
+}
+
+int __exp_i2c_start(i2c_t *obj)
+{
+	int result;
+	shellif_into();
+	result = i2c_start(obj);
+	shellif_outof();
+	return result;
+}
+
+int __exp_i2c_stop(i2c_t *obj)
+{
+	int result;
+	shellif_into();
+	result = i2c_stop(obj);
+	shellif_outof();
+	return result;
+}
+
+void __exp_i2c_init(i2c_t *obj, PinName sda, PinName scl)
+{
+	shellif_into();
+	i2c_init(obj, sda, scl);
+	shellif_outof();
+}
+
+int __exp_i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
+{
+	int result;
+	shellif_into();
+	result = i2c_read(obj, address, data, length, stop);
+	shellif_outof();
+	return result;
+}
+
+int __exp_i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
+{
+	int result;
+	shellif_into();
+	result = i2c_write(obj, address, data, length, stop);
+	shellif_outof();
+	return result;
+}
+
+int __exp_i2c_byte_read(i2c_t *obj, int last)
+{
+	int result;
+	shellif_into();
+	result = i2c_byte_read(obj, last);
+	shellif_outof();
+	return result;
+}
+
+int __exp_i2c_byte_write(i2c_t *obj, int data)
+{
+	int result;
+	shellif_into();
+	result = i2c_byte_write(obj, data);
+	shellif_outof();
+	return result;
+}
+
+void __exp_pwmout_free(pwmout_t* obj)
+{
+	shellif_into();
+	pwmout_free(obj);
+	shellif_outof();
+}
+
+void __exp_pwmout_init(pwmout_t* obj, PinName pin)
+{
+	shellif_into();
+	pwmout_init(obj, pin);
+	shellif_outof();
+}
+
+void __exp_pwmout_pulsewidth_us(pwmout_t* obj, int us)
+{
+	shellif_into();
+	pwmout_pulsewidth_us(obj, us);
+	shellif_outof();
+}
+
+void __exp_rtc_init(void)
+{
+	shellif_into();
+	rtc_init();
+	shellif_outof();
+}
+
+void __exp_rtc_free(void)
+{
+	shellif_into();
+	rtc_free();
+	shellif_outof();
+}
+
+int __exp_rtc_isenabled(void)
+{
+	int result;
+	shellif_into();
+	result = rtc_isenabled();
+	shellif_outof();
+	return result;
+}
+
+time_t __exp_rtc_read(void)
+{
+	time_t result;
+	shellif_into();
+	result = rtc_read();
+	shellif_outof();
+	return result;
+}
+
+void __exp_rtc_write(time_t t)
+{
+	shellif_into();
+	rtc_write(t);
+	shellif_outof();
+}
+
+void __exp_serial_baud(serial_t *obj, int baudrate)
+{
+	shellif_into();
+	serial_baud(obj, baudrate);
+	shellif_outof();
+}
+
+void __exp_serial_init(serial_t *obj, PinName tx, PinName rx)
+{
+	shellif_into();
+	serial_init(obj, tx, rx);
+	shellif_outof();
+}
+
+int __exp_serial_readable(serial_t *obj)
+{
+	int result;
+	shellif_into();
+	result = serial_readable(obj);
+	shellif_outof();
+	return result;
+}
+
+int __exp_serial_getc(serial_t *obj)
+{
+	int result;
+	shellif_into();
+	result = serial_getc(obj);
+	shellif_outof();
+	return result;
+}
+
+void __exp_serial_putc(serial_t *obj, int c)
+{
+	shellif_into();
+	serial_putc(obj, c);
+	shellif_outof();
+}
+
+uint32_t __exp_us_ticker_read(void)
+{
+	int result;
+	shellif_into();
+	result = us_ticker_read();
+	shellif_outof();
+	return result;
+}
+
+void __exp_wait_ms(int ms)
+{
+	shellif_into();
+	wait_ms(ms);
+	shellif_outof();
+}
+
+bool __exp_SD_begin()
+{
+	bool result;
+	shellif_into();
+	result = SD_begin();
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_cd(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_cd(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_ls(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_ls(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_cp(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_cp(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_rm(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_rm(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_mv(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_mv(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_mkdir(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_mkdir(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_hexdump(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_hexdump(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_info(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_info(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_usrcmd_exit(int argc, char **argv)
+{
+	int result;
+	shellif_into();
+	result = usrcmd_exit(argc, argv);
+	shellif_outof();
+	return result;
+}
+
+void __exp_shell_abort()
+{
+	shellif_into();
+	shell_abort();
+	shellif_outof();
+}
+
+void __exp_shell_exit(int exitcd)
+{
+	shellif_into();
+	shell_exit(exitcd);
+	shellif_outof();
+}
+
+int __exp_shell_kill(int pid, int sig)
+{
+	int result;
+	shellif_into();
+	result = shell_kill(pid, sig);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_gettimeofday(struct timeval * tp, void * tzvp)
+{
+	int result;
+	shellif_into();
+	result = shell_gettimeofday(tp, tzvp);
+	shellif_outof();
+	return result;
+}
+
+void __exp_vsyslog(int priority, const char *format, va_list ap)
+{
+	shellif_into();
+	vsyslog(priority, format, ap);
+	shellif_outof();
+}
+
+int __exp_shell_open(const char * path, int flags)
+{
+	int result;
+	shellif_into();
+	result = shell_open(path, flags);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_close(int fd)
+{
+	int result;
+	shellif_into();
+	result = shell_close(fd);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_read(int fd, char *data, int len)
+{
+	int result;
+	shellif_into();
+	result = shell_read(fd, data, len);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_write(int fd, char *data, int len)
+{
+	int result;
+	shellif_into();
+	result = shell_write(fd, data, len);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_lseek(int fd, int ptr, int dir)
+{
+	int result;
+	shellif_into();
+	result = shell_lseek(fd, ptr, dir);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_fstat(int fd, struct stat * st)
+{
+	int result;
+	shellif_into();
+	result = shell_fstat(fd, st);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_stat(const char *fname, struct stat *st)
+{
+	int result;
+	shellif_into();
+	result = shell_stat(fname, st);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_link(void)
+{
+	int result;
+	shellif_into();
+	result = shell_link();
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_unlink(const char *path)
+{
+	int result;
+	shellif_into();
+	result = shell_unlink(path);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_isatty(int fd)
+{
+	int result;
+	shellif_into();
+	result = shell_isatty(fd);
+	shellif_outof();
+	return result;
+}
+
+int __exp_fsync(int fd)
+{
+	int result;
+	shellif_into();
+	result = fsync(fd);
+	shellif_outof();
+	return result;
+}
+
+int __exp_ftruncate(int fd, off_t length)
+{
+	int result;
+	shellif_into();
+	result = ftruncate(fd, length);
+	shellif_outof();
+	return result;
+}
+
+int __exp_ioctl(int fd, int request, va_list ap)
+{
+	int result;
+	shellif_into();
+	result = ioctl(fd, request, ap);
+	shellif_outof();
+	return result;
+}
+
+int __exp_tcgetattr(int fd, struct termios *termios_p)
+{
+	int result;
+	shellif_into();
+	result = tcgetattr(fd, termios_p);
+	shellif_outof();
+	return result;
+}
+
+int __exp_tcsetattr(int fd, int optional_actions, const struct termios *termios_p)
+{
+	int result;
+	shellif_into();
+	result = tcsetattr(fd, optional_actions, termios_p);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_rename(const char *oldpath, const char *newpath)
+{
+	int result;
+	shellif_into();
+	result = shell_rename(oldpath, newpath);
+	shellif_outof();
+	return result;
+}
+
+int __exp_rmdir(const char *path)
+{
+	int result;
+	shellif_into();
+	result = rmdir(path);
+	shellif_outof();
+	return result;
+}
+
+int __exp_mkdir(const char *path, mode_t mode)
+{
+	int result;
+	shellif_into();
+	result = mkdir(path, mode);
+	shellif_outof();
+	return result;
+}
+
+int __exp_chmod(const char *path, mode_t mode)
+{
+	int result;
+	shellif_into();
+	result = chmod(path, mode);
+	shellif_outof();
+	return result;
+}
+
+char *__exp_getcwd(char *buf, size_t size)
+{
+	char *result;
+	shellif_into();
+	result = getcwd(buf, size);
+	shellif_outof();
+	return result;
+}
+
+int __exp_chdir(const char *path)
+{
+	int result;
+	shellif_into();
+	result = chdir(path);
+	shellif_outof();
+	return result;
+}
+
+int __exp_chroot(const char *path)
+{
+	int result;
+	shellif_into();
+	result = chroot(path);
+	shellif_outof();
+	return result;
+}
+
+int __exp_closedir(DIR *dir)
+{
+	int result;
+	shellif_into();
+	result = closedir(dir);
+	shellif_outof();
+	return result;
+}
+
+DIR *__exp_opendir(const char *path)
+{
+	DIR *result;
+	shellif_into();
+	result = opendir(path);
+	shellif_outof();
+	return result;
+}
+
+struct dirent *__exp_readdir(DIR *dir)
+{
+	struct dirent *result;
+	shellif_into();
+	result = readdir(dir);
+	shellif_outof();
+	return result;
+}
+
+void __exp_rewinddir(DIR *dir)
+{
+	shellif_into();
+	rewinddir(dir);
+	shellif_outof();
+}
+
+void __exp_seekdir(DIR *dir, long pos)
+{
+	shellif_into();
+	seekdir(dir, pos);
+	shellif_outof();
+}
+
+long __exp_telldir(DIR *dir)
+{
+	long result;
+	shellif_into();
+	result = telldir(dir);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shell_getpid()
+{
+	int result;
+	shellif_into();
+	result = shell_getpid();
+	shellif_outof();
+	return result;
+}
+
+int __exp_socket(int family, int type, int protocol)
+{
+	int result;
+	shellif_into();
+	result = socket(family, type, protocol);
+	shellif_outof();
+	return result;
+}
+
+int __exp_bind(int fd, const struct sockaddr *addr, socklen_t len)
+{
+	int result;
+	shellif_into();
+	result = bind(fd, addr, len);
+	shellif_outof();
+	return result;
+}
+
+int __exp_listen(int fd, int backlog)
+{
+	int result;
+	shellif_into();
+	result = listen(fd, backlog);
+	shellif_outof();
+	return result;
+}
+
+int __exp_connect(int fd, const struct sockaddr *addr, socklen_t len)
+{
+	int result;
+	shellif_into();
+	result = connect(fd, addr, len);
+	shellif_outof();
+	return result;
+}
+
+int __exp_accept(int fd, struct sockaddr *addr, socklen_t *len)
+{
+	int result;
+	shellif_into();
+	result = accept(fd, addr, len);
+	shellif_outof();
+	return result;
+}
+
+ssize_t __exp_send(int fd, const void *buf, size_t len, int flags)
+{
+	ssize_t result;
+	shellif_into();
+	result = send(fd, buf, len, flags);
+	shellif_outof();
+	return result;
+}
+
+ssize_t __exp_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
+{
+	ssize_t result;
+	shellif_into();
+	result = sendto(fd, buf, len, flags, addr, alen);
+	shellif_outof();
+	return result;
+}
+
+ssize_t __exp_recv(int fd, void *buf, size_t len, int flags)
+{
+	ssize_t result;
+	shellif_into();
+	result = recv(fd, buf, len, flags);
+	shellif_outof();
+	return result;
+}
+
+ssize_t __exp_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen)
+{
+	ssize_t result;
+	shellif_into();
+	result = recvfrom(fd, buf, len, flags, addr, alen);
+	shellif_outof();
+	return result;
+}
+
+int __exp_shutdown(int fd, int how)
+{
+	int result;
+	shellif_into();
+	result = shutdown(fd, how);
+	shellif_outof();
+	return result;
+}
+
+int __exp_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen)
+{
+	int result;
+	shellif_into();
+	result = getsockopt(fd, level, optname, optval, optlen);
+	shellif_outof();
+	return result;
+}
+
+int __exp_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
+{
+	int result;
+	shellif_into();
+	result = setsockopt(fd, level, optname, optval, optlen);
+	shellif_outof();
+	return result;
+}
+
+int __exp_select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+{
+	int result;
+	shellif_into();
+	result = select(n, rfds, wfds, efds, tv);
+	shellif_outof();
+	return result;
+}
+
+int __exp_poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+	int result;
+	shellif_into();
+	result = poll(fds, nfds, timeout);
+	shellif_outof();
+	return result;
+}
+
+int __exp_gethostname(char *name, size_t len)
+{
+	int result;
+	shellif_into();
+	result = gethostname(name, len);
+	shellif_outof();
+	return result;
+}
+
+int __exp_getnameinfo(const struct sockaddr *sa, socklen_t sl,
+	char *node, socklen_t nodelen,
+	char *serv, socklen_t servlen,
+	int flags)
+{
+	int result;
+	shellif_into();
+	shell_abort();
+	result = 0;
+	shellif_outof();
+	return result;
+}
+
+int __exp_getpeername(int fd, struct sockaddr *addr, socklen_t *len)
+{
+	int result;
+	shellif_into();
+	shell_abort();
+	result = 0;
+	shellif_outof();
+	return result;
+}
+
+int __exp_getsockname(int fd, struct sockaddr *addr, socklen_t *len)
+{
+	int result;
+	shellif_into();
+	shell_abort();
+	result = 0;
+	shellif_outof();
+	return result;
+}
+
+int __exp_socketpair(int family, int type, int protocol, int fd[2])
+{
+	int result;
+	shellif_into();
+	shell_abort();
+	result = 0;
+	shellif_outof();
+	return result;
+}
Index: /EcnlProtoTool/trunk/ntshell/src/socket_stub.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/socket_stub.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/socket_stub.c	(revision 279)
@@ -0,0 +1,856 @@
+#include <sys/types.h>
+#include <stdint.h>
+#if 0
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#endif
+#include <fcntl.h>
+#include "sys/unistd.h"
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+#include <kernel.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include <sil.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include "syssvc/syslog.h"
+#include <tinet_config.h>
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <tinet_nic_defs.h>
+#include <tinet_cfg.h>
+#include <netinet/in_var.h>
+#include <net/ethernet.h>
+#include <net/if6_var.h>
+#include <net/net.h>
+#include <net/if_var.h>
+#include <netinet/udp_var.h>
+//#include <netinet/tcp_var.h>
+extern const ID tmax_tcp_cepid;
+#include "ff.h"
+#include "socket_stub.h"
+#define SO_REUSEADDR    2
+
+typedef struct id_table_t {
+	int used;
+	ID id;
+} id_table_t;
+
+id_table_t tcp_repid_table[] = {
+	{0, USR_TCP_REP1}, {0, USR_TCP_REP2}, {0, USR_TCP_REP3}, {0, USR_TCP_REP4}
+};
+#define tcp_repid_table_count (sizeof(tcp_repid_table) / sizeof(tcp_repid_table[0]))
+
+id_table_t tcp_cepid_table[] = {
+	{0, USR_TCP_CEP1}, {0, USR_TCP_CEP2}, {0, USR_TCP_CEP3}, {0, USR_TCP_CEP4}, {0, USR_TCP_CEP5}, {0, USR_TCP_CEP6}, {0, USR_TCP_CEP7}, {0, USR_TCP_CEP8}
+};
+#define tcp_cepid_table_count (sizeof(tcp_cepid_table) / sizeof(tcp_cepid_table[0]))
+
+id_table_t udp_cepid_table[] = {
+	{0, USR_UDP_CEP1}, {0, USR_UDP_CEP2}, {0, USR_UDP_CEP3}, {0, USR_UDP_CEP4}
+};
+#define udp_cepid_table_count (sizeof(udp_cepid_table) / sizeof(udp_cepid_table[0]))
+
+ID new_id(id_table_t *table, int count)
+{
+	for (int i = 0; i < count; i++) {
+		id_table_t *item = &table[i];
+		if (item->used != 0)
+			continue;
+
+		item->used = 1;
+		return item->id;
+}
+
+	return -1;
+}
+
+int delete_id(id_table_t *table, int count, ID id)
+{
+	for (int i = 0; i < count; i++) {
+		id_table_t *item = &table[i];
+		if ((item->used == 0) || (item->id != id))
+			continue;
+
+		item->used = 0;
+		return 0;
+	}
+	return -1;
+}
+
+int delete_tcp_rep(int repid)
+{
+	delete_tcp_fd(tmax_tcp_cepid + repid);
+}
+
+unsigned char tcp_buf[tcp_cepid_table_count][2 * 512];
+
+unsigned char *id_to_buff(ID id)
+{
+	for (int i = 0; i < tcp_cepid_table_count; i++) {
+		id_table_t *item = &tcp_cepid_table[i];
+		if ((item->used == 0) || (item->id != id))
+			continue;
+
+		return tcp_buf[i];
+	}
+
+	return NULL;
+}
+
+typedef struct _IO_FILE SOCKET;
+
+int socket(int family, int type, int protocol)
+{
+	SOCKET *fp;
+
+	switch (family) {
+	case AF_INET:
+	case AF_INET6:
+		break;
+	default:
+		return -1;
+	}
+
+	switch (type) {
+	case SOCK_STREAM:
+		fp = new_tcp_fd(0);
+		break;
+	case SOCK_DGRAM:
+		fp = new_udp_fd(0);
+		break;
+	default:
+		return -1;
+	}
+
+	if (fp == NULL) {
+		return -1;
+	}
+
+	fp->socket.family = family;
+	fp->socket.type = type;
+	fp->socket.protocol = protocol;
+
+	return fp->fd;
+}
+
+int bind(int fd, const struct sockaddr *addr, socklen_t len)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	if (fp->socket.family != addr->sa_family) {
+		return -1;
+	}
+
+	ER ret;
+	switch (addr->sa_family) {
+	case AF_INET: {
+		if (len < 8) {
+			return -1;
+		}
+		struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
+		memcpy(&fp->socket.laddr4, addr, len);
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			ID cepid = new_id(tcp_cepid_table, tcp_cepid_table_count);
+			if (cepid < 0)
+				return -1;
+
+			fp->socket.buf_size = 512 + 512;
+			fp->socket.buf = id_to_buff(cepid);
+			T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, socket_tcp_callback };
+			ret = tcp_cre_cep(cepid, &ccep);
+			if (ret != E_OK) {
+				delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
+				return -1;
+			}
+			fp->handle = cepid;
+			fp->socket.cepid = cepid;
+			break;
+		}
+		case SOCK_DGRAM: {
+			ID cepid = new_id(udp_cepid_table, udp_cepid_table_count);
+			if (cepid < 0)
+				return -1;
+
+			T_UDP_CCEP ccep = { 0, {ntohl(addr_in->sin_addr.s_addr), ntohs(addr_in->sin_port)}, socket_udp_callback };
+			ret = udp_cre_cep(cepid, &ccep);
+			if (ret != E_OK) {
+				delete_id(udp_cepid_table, udp_cepid_table_count, cepid);
+				return -1;
+			}
+			fp->handle = cepid;
+			fp->socket.cepid = cepid;
+			break;
+		}
+		default:
+			return -1;
+		}
+		break;
+	}
+	case AF_INET6: {
+		if (len < 20) {
+			return -1;
+		}
+		memcpy(&fp->socket.laddr4, addr, len);
+		break;
+	}
+	}
+
+	return 0;
+}
+
+int listen(int fd, int backlog)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if ((fp == NULL) || (fp->socket.type != SOCK_STREAM)) {
+		return -1;
+	}
+
+	fp->socket.backlog = backlog;
+
+	ER ret;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		ID repid = new_id(tcp_repid_table, tcp_repid_table_count);
+		if (repid < 0)
+			return -1;
+
+		struct sockaddr_in *laddr = &fp->socket.laddr4;
+		T_TCP_CREP crep = { 0, {ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port)} };
+		ret = tcp_cre_rep(repid, &crep);
+		if (ret != E_OK) {
+			delete_id(tcp_repid_table, tcp_repid_table_count, repid);
+			return -1;
+		}
+		fp->socket.repid = repid;
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return 0;
+}
+
+int connect(int fd, const struct sockaddr *addr, socklen_t len)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if ((fp == NULL) || (fp->socket.type != SOCK_STREAM)) {
+		return -1;
+	}
+
+	ER ret;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		if (len < 8) {
+			return -1;
+		}
+		if (fp->socket.cepid == 0) {
+			ID cepid = new_id(tcp_cepid_table, tcp_cepid_table_count);
+			if (cepid < 0)
+				return -1;
+
+			fp->socket.buf_size = 512 + 512;
+			fp->socket.buf = id_to_buff(cepid);
+			T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, socket_tcp_callback };
+			ret = tcp_cre_cep(cepid, &ccep);
+			if (ret != E_OK) {
+				delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
+				return -1;
+			}
+			fp->handle = cepid;
+			fp->socket.cepid = cepid;
+		}
+		struct sockaddr_in *laddr = &fp->socket.laddr4;
+		struct sockaddr_in *raddr = &fp->socket.raddr4;
+		memset(raddr, 0, sizeof(*raddr));
+		memcpy(raddr, addr, len);
+		T_IPV4EP lep = { ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port) };
+		T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
+		ret = tcp_con_cep(fp->socket.cepid, &lep, &rep, TMO_FEVR);
+		if (ret < 0) {
+			return -1;
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return 0;
+}
+
+int accept(int fd, struct sockaddr *addr, socklen_t *len)
+{
+	SOCKET *lfp = fd_to_fp(fd);
+	if ((lfp == NULL) || (lfp->socket.type != SOCK_STREAM)) {
+		return -1;
+	}
+
+	SOCKET *fp = new_tcp_fd(0);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	memcpy(&fp->socket, &lfp->socket, sizeof(fp->socket));
+
+	ER ret;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		ID cepid;
+		if (fp->socket.cepid == 0) {
+			cepid = new_id(tcp_cepid_table, tcp_cepid_table_count);
+			if (cepid < 0)
+				return -1;
+
+			fp->socket.buf_size = 512 + 512;
+			fp->socket.buf = id_to_buff(cepid);
+			T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, socket_tcp_callback };
+			ret = tcp_cre_cep(cepid, &ccep);
+			if (ret != E_OK) {
+				delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
+				return -1;
+			}
+			fp->handle = cepid;
+			fp->socket.cepid = cepid;
+		}
+		else {
+			cepid = lfp->socket.cepid;
+			lfp->handle = tmax_tcp_cepid + lfp->socket.repid;
+			lfp->socket.cepid = 0;
+			lfp->socket.buf_size = 0;
+			lfp->socket.buf = 0;
+		}
+		T_IPV4EP rep = { 0, 0 };
+		ret = tcp_acp_cep(fp->socket.cepid, fp->socket.repid, &rep, TMO_FEVR);
+		if (ret < 0) {
+			return -1;
+		}
+		struct sockaddr_in *raddr = &fp->socket.raddr4;
+		memset(raddr, 0, sizeof(*raddr));
+		raddr->sin_family = AF_INET;
+		raddr->sin_port = htons(rep.portno);
+		raddr->sin_addr.s_addr = htonl(rep.ipaddr);
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	if (addr != NULL && len != NULL) {
+		int sz = *len;
+		if (sz < 8) {
+			return -1;
+		}
+		struct sockaddr_in *raddr = &fp->socket.raddr4;
+		if (sz > sizeof(*raddr))
+			sz = sizeof(*raddr);
+		memcpy(addr, raddr, sz);
+		*len = sizeof(*raddr);
+	}
+
+	return fp->fd;
+}
+
+ssize_t send(int fd, const void *buf, size_t len, int flags)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	int ret = 0;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			if (flags & MSG_OOB) {
+				ret = tcp_snd_oob(fp->socket.cepid, (void *)buf, len, TMO_FEVR);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			else {
+				ret = tcp_snd_dat(fp->socket.cepid, (void *)buf, len, TMO_FEVR);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			break;
+		}
+		case SOCK_DGRAM: {
+			return -1;
+		}
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return ret;
+}
+
+ssize_t sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	int ret = 0;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			if ((addr != NULL) && (alen != 0)) {
+				return -1;
+			}
+
+			if (flags & MSG_OOB) {
+				ret = tcp_snd_oob(fp->socket.cepid, (void *)buf, len, TMO_FEVR);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			else {
+				ret = tcp_snd_dat(fp->socket.cepid, (void *)buf, len, TMO_FEVR);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			break;
+		}
+		case SOCK_DGRAM: {
+			int sz = alen;
+			if (sz < 8) {
+				return -1;
+			}
+			struct sockaddr_in *raddr = &fp->socket.raddr4;
+			memset(raddr, 0, sizeof(*raddr));
+			memcpy(raddr, addr, sz);
+			T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
+			ret = udp_snd_dat(fp->socket.cepid, &rep, (void *)buf, len, TMO_FEVR);
+			if (ret < 0) {
+				return -1;
+			}
+			break;
+		}
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return ret;
+}
+
+ssize_t recv(int fd, void *buf, size_t len, int flags)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	int ret = 0;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			if (flags & MSG_OOB) {
+				ret = tcp_rcv_oob(fp->socket.cepid, buf, len);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			else {
+				ret = tcp_rcv_dat(fp->socket.cepid, buf, len, TMO_FEVR);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			break;
+		}
+		case SOCK_DGRAM: {
+			T_IPV4EP rep = { 0, 0 };
+			ret = udp_rcv_dat(fp->socket.cepid, &rep, buf, len, TMO_FEVR);
+			if (ret < 0) {
+				return -1;
+			}
+		}
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return ret;
+}
+
+ssize_t recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	int ret = 0;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			if (flags & MSG_OOB) {
+				ret = tcp_rcv_oob(fp->socket.cepid, buf, len);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			else {
+				ret = tcp_rcv_dat(fp->socket.cepid, buf, len, TMO_FEVR);
+				if (ret < 0) {
+					return -1;
+				}
+			}
+			break;
+		}
+		case SOCK_DGRAM: {
+			T_IPV4EP rep = { 0, 0 };
+			ret = udp_rcv_dat(fp->socket.cepid, &rep, buf, len, TMO_FEVR);
+			if (ret < 0) {
+				return -1;
+			}
+			int sz = *alen;
+			struct sockaddr_in raddr;
+			memset(&raddr, 0, sizeof(raddr));
+			raddr.sin_family = AF_INET;
+			raddr.sin_port = htons(rep.portno);
+			raddr.sin_addr.s_addr = htonl(rep.ipaddr);
+			if (sz > sizeof(raddr))
+				sz = sizeof(raddr);
+			memcpy(addr, &raddr, sz);
+		}
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return ret;
+}
+
+int shutdown(int fd, int how)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	ER ret;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			ret = tcp_sht_cep(fp->socket.cepid);
+			if (ret < 0) {
+				return -1;
+			}
+			break;
+		}
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return 0;
+}
+
+int getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	ER ret;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			switch (optname) {
+			case SO_REUSEADDR:
+				if (fp->socket.flags & SO_REUSEADDR) {
+					*(bool *)optval = true;
+				}
+				else {
+					*(bool *)optval = false;
+				}
+				break;
+			default:
+				ret = tcp_get_opt(fp->socket.cepid, optname, (void *)optval, *optlen);
+				if (ret < 0) {
+					return -1;
+				}
+				*optlen = ret;
+				break;
+			}
+			break;
+		}
+		case SOCK_DGRAM: {
+			ret = udp_get_opt(fp->socket.cepid, optname, (void *)optval, *optlen);
+			if (ret < 0) {
+				return -1;
+			}
+			*optlen = ret;
+			break;
+		}
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return 0;
+}
+
+int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
+{
+	SOCKET *fp = fd_to_fp(fd);
+	if (fp == NULL) {
+		return -1;
+	}
+
+	ER ret;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		switch (fp->socket.type) {
+		case SOCK_STREAM: {
+			switch (optname) {
+			case SO_REUSEADDR:
+				if (*(bool *)optval) {
+					fp->socket.flags |= SO_REUSEADDR;
+				}
+				else {
+					fp->socket.flags &= ~SO_REUSEADDR;
+				}
+				break;
+			default:
+				ret = tcp_set_opt(fp->socket.cepid, optname, (void *)optval, optlen);
+				if (ret < 0) {
+					return -1;
+				}
+				break;
+			}
+			break;
+		}
+		case SOCK_DGRAM: {
+			ret = udp_set_opt(fp->socket.cepid, optname, (void *)optval, optlen);
+			if (ret < 0) {
+				return -1;
+			}
+			break;
+		}
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return 0;
+}
+
+int tcp_fd_close(struct _IO_FILE *fp)
+{
+	ER ret;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		if (fp->socket.cepid != 0) {
+			ID cepid = fp->socket.cepid;
+			ret = tcp_sht_cep(cepid);
+			if (ret < 0) {
+				//return -1;
+			}
+			ret = tcp_cls_cep(cepid, TMO_FEVR);
+			if (ret < 0) {
+				//return -1;
+			}
+			ret = tcp_del_cep(cepid);
+			delete_tcp_fd(cepid);
+			delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
+			if (ret < 0) {
+				return -1;
+			}
+		}
+		else if (fp->socket.repid != 0) {
+			ID repid = fp->socket.repid;
+			ret = tcp_del_rep(repid);
+			delete_tcp_fd(tmax_tcp_cepid + repid);
+			delete_id(tcp_repid_table, tcp_repid_table_count, repid);
+			if (ret < 0) {
+				return -1;
+			}
+		}
+		else {
+			return -1;
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return 0;
+}
+
+size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz)
+{
+	return recv(fp->fd, dst, dstsz, 0);
+}
+
+size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz)
+{
+	return send(fp->fd, src, srcsz, 0);
+}
+
+off_t tcp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org)
+{
+	return -1;
+}
+
+int udp_fd_close(struct _IO_FILE *fp)
+{
+	ER ret;
+	ID cepid;
+	switch (fp->socket.family) {
+	case AF_INET: {
+		cepid = fp->socket.cepid;
+		ret = udp_del_cep(cepid);
+		delete_udp_fd(cepid);
+		delete_id(udp_cepid_table, udp_cepid_table_count, cepid);
+		if (ret < 0) {
+			return -1;
+		}
+		break;
+	}
+	case AF_INET6: {
+		break;
+	}
+	}
+
+	return 0;
+}
+
+size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz)
+{
+	return recv(fp->fd, dst, dstsz, 0);
+}
+
+size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz)
+{
+	return send(fp->fd, src, srcsz, 0);
+}
+
+off_t udp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org)
+{
+	return -1;
+}
+
+#ifndef TCP_CFG_EXTENTIONS
+ER tcp_cre_rep(ID repid, T_TCP_CREP *pk_crep)
+{
+	syslog(LOG_ERROR, "tcp_cre_rep not implement");
+	shell_abort();
+	return E_SYS;
+}
+
+ER tcp_cre_cep(ID cepid, T_TCP_CCEP *pk_ccep)
+{
+	syslog(LOG_ERROR, "tcp_cre_cep not implement");
+	shell_abort();
+	return E_SYS;
+}
+#endif
+
+#ifndef UDP_CFG_EXTENTIONS
+ER udp_cre_cep(ID cepid, T_UDP_CCEP *pk_ccep)
+{
+	syslog(LOG_ERROR, "udp_cre_cep not implement");
+	shell_abort();
+	return E_SYS;
+}
+#endif
+
+#ifndef TCP_CFG_EXTENTIONS
+ER_UINT tcp_snd_oob(ID cepid, void *data, int_t len, TMO tmout)
+{
+	syslog(LOG_ERROR, "tcp_snd_oob not implement");
+	shell_abort();
+	return E_SYS;
+}
+
+ER_UINT tcp_rcv_oob(ID cepid, void *data, int_t len)
+{
+	syslog(LOG_ERROR, "tcp_rcv_oob not implement");
+	shell_abort();
+	return E_SYS;
+}
+
+ER tcp_set_opt(ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	syslog(LOG_ERROR, "tcp_set_opt not implement");
+	shell_abort();
+	return E_SYS;
+}
+
+ER tcp_get_opt(ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	syslog(LOG_ERROR, "tcp_get_opt not implement");
+	shell_abort();
+	return E_SYS;
+}
+#endif
+
+#ifndef UDP_CFG_EXTENTIONS
+ER udp_get_opt(ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	syslog(LOG_ERROR, "udp_get_opt not implement");
+	shell_abort();
+	return E_SYS;
+}
+
+ER udp_set_opt(ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	syslog(LOG_ERROR, "udp_set_opt not implement");
+	shell_abort();
+	return E_SYS;
+}
+#endif
Index: /EcnlProtoTool/trunk/ntshell/src/socket_stub.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/socket_stub.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/socket_stub.h	(revision 279)
@@ -0,0 +1,160 @@
+
+#ifndef SOCKET_STUB_H
+#define SOCKET_STUB_H
+
+typedef unsigned socklen_t;
+typedef unsigned short sa_family_t;
+
+struct sockaddr {
+	sa_family_t sa_family;
+	char sa_data[14];
+};
+
+struct addrinfo {
+	int ai_flags;
+	int ai_family;
+	int ai_socktype;
+	int ai_protocol;
+	socklen_t ai_addrlen;
+	struct sockaddr *ai_addr;
+	char *ai_canonname;
+	struct addrinfo *ai_next;
+};
+
+#define AF_INET		2
+#define AF_INET6	10
+
+#define SOCK_STREAM	1
+#define SOCK_DGRAM	2
+
+typedef uint16_t in_port_t;
+typedef uint32_t in_addr_t;
+struct in_addr { in_addr_t s_addr; };
+
+struct sockaddr_in {
+	sa_family_t sin_family;
+	in_port_t sin_port;
+	struct in_addr sin_addr;
+	uint8_t sin_zero[8];
+};
+
+struct in6_addr
+{
+	union {
+		uint8_t __s6_addr[16];
+		uint16_t __s6_addr16[8];
+		uint32_t __s6_addr32[4];
+	} __in6_union;
+};
+#define s6_addr __in6_union.__s6_addr
+#define s6_addr16 __in6_union.__s6_addr16
+#define s6_addr32 __in6_union.__s6_addr32
+
+struct sockaddr_in6
+{
+	sa_family_t     sin6_family;
+	in_port_t       sin6_port;
+	uint32_t        sin6_flowinfo;
+	struct in6_addr sin6_addr;
+	uint32_t        sin6_scope_id;
+};
+
+#define MSG_OOB       0x0001
+
+typedef struct socket_t {
+	int family;
+	int type;
+	int protocol;
+	int cepid;
+	int repid;
+	int backlog;
+	unsigned int flags;
+	union {
+		struct sockaddr_in laddr4;
+		struct sockaddr_in6 laddr6;
+	};
+	union {
+		struct sockaddr_in raddr4;
+		struct sockaddr_in6 raddr6;
+	};
+	int buf_size;
+	unsigned char *buf;
+} socket_t;
+
+struct _IO_FILE {
+	int fd;
+	int type;
+	int handle;
+	int (*close)(struct _IO_FILE *);
+	size_t (*read)(struct _IO_FILE *, unsigned char *, size_t);
+	size_t (*write)(struct _IO_FILE *, const unsigned char *, size_t);
+	int readevt_r;
+	int readevt_w;
+	int writeevt_r;
+	int writeevt_w;
+	int errorevt_r;
+	int errorevt_w;
+	union {
+		FIL file;
+		socket_t socket;
+	};
+};
+
+#ifndef bool
+#define bool int
+#endif
+#ifndef true
+#define true 1
+#endif
+#ifndef false
+#define false 0
+#endif
+
+extern int stdio_close(struct _IO_FILE *fp);
+extern size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
+extern size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+extern size_t stdin_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
+extern size_t stdout_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+extern size_t stderr_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+
+extern int sio_close(struct _IO_FILE *fp);
+extern size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
+extern size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+
+extern int file_close(struct _IO_FILE *fp);
+extern size_t file_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
+extern size_t file_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+
+extern int tcp_fd_close(struct _IO_FILE *fp);
+extern size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
+extern size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+
+extern int udp_fd_close(struct _IO_FILE *fp);
+extern size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
+extern size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+
+struct _IO_FILE *fd_to_fp(int fd);
+
+struct _IO_FILE *new_sio_fd(int sioid);
+int delete_sio_fd(int sioid);
+struct _IO_FILE *sioid_to_fd(int sioid);
+
+struct _IO_FILE *new_file_fd(int fileid);
+int delete_file_fd(int fileid);
+struct _IO_FILE *fileid_to_fd(int fileid);
+
+struct _IO_FILE *new_tcp_fd(int tcpid);
+int delete_tcp_fd(int tcpid);
+struct _IO_FILE *tcpid_to_fd(int tcpid);
+
+struct _IO_FILE *new_udp_fd(int udpid);
+int delete_udp_fd(int udpid);
+struct _IO_FILE *udpid_to_fd(int udpid);
+
+int delete_tcp_rep(int repid);
+void clean_fd();
+
+ER socket_tcp_callback(ID cepid, FN fncd, void *p_parblk);
+ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk);
+
+#endif // !SOCKET_STUB_H
Index: /EcnlProtoTool/trunk/ntshell/src/tinet_app_config.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/tinet_app_config.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/tinet_app_config.h	(revision 279)
@@ -0,0 +1,682 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_APP_CONFIG_H_
+#define _TINET_APP_CONFIG_H_
+
+/*
+ *  ã¤ã³ã¿ã¼ããããã­ãã³ã«ãã¡ããªã¼ã®ãµãã¼ã
+ *
+ *    Makefile ã§æå®ãã¦ãè¯ã
+ */
+
+/*#define SUPPORT_INET4		TCP/IP,IPv4		*/
+/*#define SUPPORT_INET6		TCP/IP,IPv6		*/
+/*#define SUPPORT_TCP		TCP			*/
+/*#define SUPPORT_UDP		UDP			*/
+
+/*ãã¼ã¿ãªã³ã¯å±¤ã®ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ãé¸æãã	*/
+/*ããããä¸ã¤ã ãé¸æã§ããã				*/
+
+/*#define SUPPORT_PPP		PointtoPointProtocol	*/
+/*#define SUPPORT_LOOP		LocalLoopBack		*/
+/*#define SUPPORT_ETHER		Ethernet		*/
+
+/*#define SUPPORT_MIB		MIB(SNMP)		*/
+
+/*
+ *  TCP/IP ã«é¢ããå®ç¾©
+ */
+
+/* TCP ã«é¢ããå®ç¾© */
+
+/*
+ *  TCPã®è½åãªã¼ãã³ã®ã¿ãµãã¼ããããã¨ãæå®ããã
+ */
+
+#ifdef UNDEF_TCP_CFG_PASSIVE_OPEN
+#undef TCP_CFG_PASSIVE_OPEN
+#endif
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+ *    æ³¨æ: Makefile ã§æå®ãã¦ããã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_RWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã
+ *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æå¤§ã¨ã³ããªæ°ã
+ *  ãã ããæ­£å¸¸ã«åä¿¡ããã»ã°ã¡ã³ããç ´æ£ãããããåéåæ°ãå¢å ããã
+ *  ã¾ããæå®ããªãã¨å¶éããªãã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_MAX_QUEUES	2*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã§ã
+ *  éä¿¡ã¦ã£ã³ããããã¡ã«ä½¿ç¨ãããããã¯ã¼ã¯ãããã¡ã®ãµã¤ãºã
+ */
+#define USE_TCP_MSS_SEG
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef SUPPORT_INET4
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IP4_MSS)		/* æå¤§ãµã¤ãº */
+#endif
+
+#ifdef SUPPORT_INET6
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IPV6_MMTU)	/* æå¤§ãµã¤ãº */
+#endif
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	IF_PDU_SIZE			/* æå¤§ãµã¤ãº */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MIN_SIZE	0				/* æå°ãµã¤ãº */
+
+/*
+ *  TCP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_TCP_CFG_NON_BLOCKING
+#undef TCP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  MAX_TCP_SND_SEG: éä¿¡ã»ã°ã¡ã³ããµã¤ãºã®æå¤§å¤
+ *
+ *    ç¸æãã MSS ãªãã·ã§ã³ã§ã»ã°ã¡ã³ããµã¤ãºãæå®ããã¦ãã
+ *    ãã®å¤ã§ãã»ã°ã¡ã³ããµã¤ãºãå¶éã§ããã
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef MAX_TCP_SND_SEG
+#undef MAX_TCP_SND_SEG
+#endif
+
+#ifdef SUPPORT_INET4
+#define MAX_TCP_SND_SEG			TCP_MSS
+#endif
+
+#ifdef SUPPORT_INET6
+#define MAX_TCP_SND_SEG			TCP6_MSS
+#endif
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  DEF_TCP_RCV_SEG: åä¿¡ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef DEF_TCP_RCV_SEG
+#undef DEF_TCP_RCV_SEG
+#endif
+
+#ifdef SUPPORT_INET4
+#define DEF_TCP_RCV_SEG			TCP_MSS
+#endif
+
+#ifdef SUPPORT_INET6
+#define DEF_TCP_RCV_SEG			TCP6_MSS
+#endif
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  ã¿ã¹ã¯ããã® Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹åé¢æ©è½
+ *
+ *  Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ã®ã¨ã³ããªæ°ãæå®ããã
+ *  æå®ããªããã0 ãæå®ããã¨ã
+ *  ã¿ã¹ã¯ãã Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ãåé¢ããæ©è½ã¯çµè¾¼ã¾ãªãã
+ */
+#if !defined(SUPPORT_TCP)
+#define NUM_TCP_TW_CEP_ENTRY		0
+#elif defined(USE_TCP_MSS_SEG)
+#define NUM_TCP_TW_CEP_ENTRY		3
+#else
+#define NUM_TCP_TW_CEP_ENTRY		6
+#endif
+
+/*
+ *  TCP ãããã®ãã¬ã¼ã¹åºåæ©è½
+ */
+//#define TCP_CFG_TRACE
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã® IPv4 ã¢ãã¬ã¹
+ *  IPV4_ADDRANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¹ããå¯¾è±¡ã¨ããã
+ */
+#define TCP_CFG_TRACE_IPV4_RADDR	IPV4_ADDRANY
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_RPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_RPORTNO		UINT_C(7)
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ã­ã¼ã«ã«ãã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_LPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_LPORTNO		UINT_C(7)
+
+/*
+ *  ITRON TCP/IP APIãTCP ã®æ¡å¼µæ©è½
+ */
+#define TCP_CFG_EXTENTIONS
+
+/*
+ *  TCP_CFG_URG_OFFSET: ç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®ãªãã»ãã
+ *
+ *    -1: BSD ã®å®è£
+ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®æ¬¡ã®ãã¤ããå·®ãã
+ *     0: RFC1122 ã®è¦å®ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ããå·®ãã
+ */
+
+//#define TCP_CFG_URG_OFFSET	-1
+//#define TCP_CFG_URG_OFFSET	0
+
+/* UDP ã«é¢ããå®ç¾© */
+
+/*
+ *  UDP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_UDP_CFG_NON_BLOCKING
+#undef UDP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  ITRON TCP/IP APIãUDP ã®æ¡å¼µæ©è½
+ */
+#define UDP_CFG_EXTENTIONS
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_INET4
+
+#ifdef SUPPORT_PPP
+
+#if 1
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(192,168,1,21)
+#else
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#if 1
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(192,168,1,31)
+#else
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#define NUM_STATIC_ROUTE_ENTRY		1
+#define NUM_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+#ifdef DHCP_CFG
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(0,0,0,0)
+
+#else	/* of #ifdef DHCP_CFG */
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(192,168,137,110)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(255,255,255,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(192,168,137,1)
+
+#endif	/* of #ifdef DHCP_CFG */
+
+#define NUM_STATIC_ROUTE_ENTRY		3
+#define NUM_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_STATIC_ROUTE_ENTRY		1
+#define NUM_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_INET6
+
+#ifdef SUPPORT_PPP
+
+#define NUM_STATIC_ROUTE_ENTRY		0
+#define NUM_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_STATIC_ROUTE_ENTRY		0
+#define NUM_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_ETHER
+
+#define NUM_STATIC_ROUTE_ENTRY		0
+#define NUM_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/*
+ *  ãã¼ã¿ãªã³ã¯å±¤ (ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹) ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  ã¤ã¼ãµãããã«é¢ããå®ç¾©
+ */
+
+/*
+ *  PPP ã«é¢ããå®ç¾©
+ */
+
+#define HDLC_PORTID			1	/* HDLC(PPP)ã«ç¨ããã·ãªã¢ã«ãã¼ãçªå·	*/
+
+/*#define PPP_IDLE_TIMEOUT		(180*NET_TIMER_HZ)*/
+					/* åæ­ã¾ã§ã®ã¢ã¤ãã«æéã		*/
+					/* åæ­ããªãå ´åã¯ã³ã¡ã³ãã¢ã¦ãããã	*/
+
+/*#define PPP_CFG_MODEM			 ã¢ãã æ¥ç¶ã®å ´åã¯ã³ã¡ã³ããå¤ãã	*/
+
+#define MODEM_CFG_INIT			"ATE1&D0&S0\\V0\\Q1S0=1"
+					/* ã¢ãã åæåæå­å			*/
+					/* NTT DoComo ã¢ãã¤ã«ã¢ããã¿ 96F ç¨	*/
+					/*   E1: ã¨ã³ã¼ããã¯ãã			*/
+					/*  &D0: ERä¿¡å·ç¡è¦			*/
+					/*  &S0: DRä¿¡å·å¸¸æ ON			*/
+					/*  \V0: ãªã¶ã«ãã³ã¼ã TYPE 1		*/
+					/*  \Q1: XON/XOFF ãã­ã¼å¶å¾¡		*/
+					/* S0=1: èªåçä¿¡ãªã³ã°åæ° = 1 å	*/
+
+#define MODEM_CFG_PHONE_NUMBER		"090-xxxx-9242"
+
+					/* èªæ§ææ
+å ±ã®è¦å®å¤			*/
+#define DEF_LCP_LOCAL_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+					/* ç¸æã«è¨±ãæ§ææ
+å ±ã®è¦å®å¤		*/
+#define DEF_LCP_REMOTE_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+/*
+ *  èªè¨¼ã«é¢ããå®ç¾©
+ */
+
+#define AUTH_CFG_CLIENT		   	/* èªè¨¼ã¯ã©ã¤ã¢ã³ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã	*/
+#define AUTH_CFG_SERVER			/* èªè¨¼ãµã¼ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã		*/
+
+#define AUTH_LOCAL_USER			"h8"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å	*/
+#define AUTH_LOCAL_PASSWD		"3048f"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã	*/
+#define AUTH_REMOTE_USER		"pen3"		/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å		*/
+#define AUTH_REMOTE_PASSWD		"600MHz"	/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã		*/
+
+/*
+ *  ARP ã«é¢ããå®ç¾©
+ */
+
+/*#define ARP_CFG_CALLBACK_DUPLICATED*/	/* IP ã¢ãã¬ã¹éè¤æ¤åºã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã		*/
+
+/*
+ *  ICMPv4/v6 ã«é¢ããå®ç¾©
+ */
+
+#ifdef USE_PING
+
+#define ICMP_CFG_CALLBACK_ECHO_REPLY	/* ICMP ECHO å¿ç­ãåä¿¡ããã¨ãå¼åºãã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã			*/
+
+#endif	/* of #ifdef USE_PING */
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡ã«é¢ããå®ç¾©
+ */
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  ã¤ã¼ãµãããã®å ´åã®ãããã¯ã¼ã¯ãããã¡æ°ã®å²ãå½ã¦
+ */
+
+/*
+ *  64 ãªã¯ããã
+ *
+ *    IPv4 ã§ã®ã¿å²ãå½ã¦ãã
+ *
+ *    IPv6 ã§ã¯ãTCP å¶å¾¡ã»ã°ã¡ã³ãï¼CSEGãSDU ãªãï¼ãµã¤ãºã®
+ *    ãããã¯ã¼ã¯ãããã¡ï¼IF + IPv6 + TCP = 74ï¼ä»¥ä¸ã®
+ *    ãããã¯ã¼ã¯ãããã¡ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_64
+#undef NUM_MPF_NET_BUF_64
+#endif
+
+#ifdef SUPPORT_INET4
+#define NUM_MPF_NET_BUF_64		4
+#else
+#define NUM_MPF_NET_BUF_64		0
+#endif
+
+/*
+ *  CSEGï¼IF + IP + TCPï¼
+ *
+ *    IPv6 ã§ã®ã¿å²ãå½ã¦ãã
+ *
+ *    RX62N Ethernet Controler ã®ãã£ãã¤ã¹ãã©ã¤ãï¼if_rx62nï¼ã®æä½å²å½ã¦é·ã¯ã
+ *    ã¤ã¼ãµããããã¬ã¼ã ã®æç­é·ã§ãã 60ï¼CRC ã® 4 ãªã¯ããããé¤ãã
+ *    æ´ã«ã¢ã©ã¤ã³ãã¦ 62ï¼ãªã¯ãããã§ããã
+ *    å¾ã£ã¦ãIPv4 ã§ã¯ãCSEG ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ *   ï¼IF + IPv4 + TCP = 54ï¼ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_CSEG
+#undef NUM_MPF_NET_BUF_CSEG
+#endif
+
+#ifdef SUPPORT_INET6
+#define NUM_MPF_NET_BUF_CSEG		4
+#else
+#define NUM_MPF_NET_BUF_CSEG		0
+#endif
+
+/*
+ *  128 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    128 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_128
+#undef NUM_MPF_NET_BUF_128
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_128		0
+#else
+#define NUM_MPF_NET_BUF_128		2
+#endif
+
+/*
+ *  256 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    256 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_256
+#undef NUM_MPF_NET_BUF_256
+#endif
+
+/*#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_256		0
+#else
+#define NUM_MPF_NET_BUF_256		2
+#endif*/
+#define NUM_MPF_NET_BUF_256		10
+
+/*
+ *  512 ãªã¯ããã	
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    512 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_512
+#undef NUM_MPF_NET_BUF_512
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_512		0
+#else
+#define NUM_MPF_NET_BUF_512		2
+#endif
+
+/*
+ *  TCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼
+ *
+ *   ã»IPv4 ã§ã®ã¿å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IP_MSS
+#undef NUM_MPF_NET_BUF_IP_MSS
+#endif
+
+#if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG)
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IP_MSS		6
+#else
+#define NUM_MPF_NET_BUF_IP_MSS		4	/* IF + 576 ãªã¯ããã	*/
+#endif
+
+#else	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+#define NUM_MPF_NET_BUF_IP_MSS		0	/* IF + 576 ãªã¯ããã	*/
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+/*
+ *  1024 ãªã¯ããã	
+ *
+ *    TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    1024 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_1024
+#undef NUM_MPF_NET_BUF_1024
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_1024		0	/* 1024 ãªã¯ããã	*/
+#else
+#define NUM_MPF_NET_BUF_1024		2	/* 1024 ãªã¯ããã	*/
+#endif
+
+/*
+ *  TCP MSSï¼IPV6 MMTUãIF + 1280 ãªã¯ãããï¼
+ *
+ *   ã»IPv6 ã§ã®ã¿å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IPV6_MMTU
+#undef NUM_MPF_NET_BUF_IPV6_MMTU
+#endif
+
+#if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU))
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IPV6_MMTU	6	/* IF + 1280	*/
+#else
+#define NUM_MPF_NET_BUF_IPV6_MMTU	4	/* IF + 1280	*/
+#endif
+
+#else	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+#define NUM_MPF_NET_BUF_IPV6_MMTU	0	/* IF + 1280	*/
+
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+/*
+ *  IF æå¤§ PDU ãµã¤ãº
+ *
+ *   ã»TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *     IF æå¤§ PDU ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IF_PDU
+#undef NUM_MPF_NET_BUF_IF_PDU
+#endif
+
+#ifdef USE_TCP_MSS_SEG
+
+#define NUM_MPF_NET_BUF_IF_PDU		0
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#if (defined(TCP_CFG_RWBUF_CSAVE) || defined(TCP_CFG_SWBUF_CSAVE)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IF_PDU		12
+#else
+#define NUM_MPF_NET_BUF_IF_PDU		10
+#endif
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  65536 ãªã¯ããã
+ *
+ *  ã»NET_BUF_CFG_LONG_LEN ãå®ç¾©ããã¨ãã®ã¿å²ãå½ã¦ãã
+ */
+
+#ifdef NET_BUF_CFG_LONG_LEN
+
+/* IPv6 ç¨ */
+
+#ifdef NUM_MPF_NET_BUF6_65536
+#undef NUM_MPF_NET_BUF6_65536
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF6_65536	0
+#else
+#define NUM_MPF_NET_BUF6_65536	4
+#endif
+
+#else	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#define NUM_MPF_NET_BUF6_65536	0
+
+#endif	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/*
+ *  DNS ãµã¼ãã«é¢ããå®ç¾©
+ */
+
+/* DNS ãµã¼ãã® IP ã¢ãã¬ã¹ */
+
+#if !defined(DHCP6_CLI_CFG)
+
+#define IPV6_ADDR_DNS_INIT	\
+	{{{ UINT_C(0xfd), UINT_C(0x90), UINT_C(0xcc), UINT_C(0xe5), \
+	    UINT_C(0x25), UINT_C(0xf6), UINT_C(0xff), UINT_C(0x81), \
+	    UINT_C(0x02), UINT_C(0xa0), UINT_C(0x24), UINT_C(0xff), \
+	    UINT_C(0xfe), UINT_C(0x56), UINT_C(0xc5), UINT_C(0xd6) }}}
+
+#endif	/* of #if !defined(DHCP6_CLI_CFG) */
+
+#if !defined(DHCP4_CLI_CFG)
+#define IPV4_ADDR_DNS		MAKE_IPV4_ADDR(192,168,2,1)
+#endif
+
+/* DOMAIN å */
+
+#if !(defined(DHCP4_CLI_CFG) || defined(DHCP6_CLI_CFG))
+#define RSLV_CFG_DNS_DOMAIN_NAME_STR	"jo.tomakomai-ct.ac.jp"
+#endif
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã«é¢ããå®ç¾©
+ */
+
+/* DHCPv6 ã®åä½ã¢ã¼ãã®è¨­å® */
+
+#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATELESS
+//#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATEFULL
+
+#define ETHER_OUTPUT_PRIORITY	7	/* Ethernet åºåã¿ã¹ã¯ã®åªå
+åº¦		*/
+#define TCP_OUT_TASK_PRIORITY	6	/* TCP åºåã¿ã¹ã¯ã®åªå
+åº¦			*/
+#define NUM_DTQ_ETHER_OUTPUT	16	/* Ethernet åºåãã¼ã¿ã­ã¥ã¼ãµã¤ãº	*/
+
+#endif /* _TINET_APP_CONFIG_H_ */
Index: /EcnlProtoTool/trunk/ntshell/src/tinet_main.cfg
===================================================================
--- /EcnlProtoTool/trunk/ntshell/src/tinet_main.cfg	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/src/tinet_main.cfg	(revision 279)
@@ -0,0 +1,111 @@
+/*
+ *  TOPPERS ECHONET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ main.c ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*#include "netapp/dhcp4_cli.h"*/
+#include "main.h"
+
+/* DHCP ã¯ã©ã¤ã¢ã³ã */
+/*INCLUDE("netapp/tinet_dhcp4_cli.cfg");*/
+INCLUDE("tinet_httpd.cfg");
+
+/* ECHONET Lite UDP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET4
+
+VRID_TCP4_REP (USR_TCP_REP1);
+VRID_TCP4_REP (USR_TCP_REP2);
+VRID_TCP4_REP (USR_TCP_REP3);
+VRID_TCP4_REP (USR_TCP_REP4);
+
+VRID_TCP4_CEP (USR_TCP_CEP1);
+VRID_TCP4_CEP (USR_TCP_CEP2);
+VRID_TCP4_CEP (USR_TCP_CEP3);
+VRID_TCP4_CEP (USR_TCP_CEP4);
+VRID_TCP4_CEP (USR_TCP_CEP5);
+VRID_TCP4_CEP (USR_TCP_CEP6);
+VRID_TCP4_CEP (USR_TCP_CEP7);
+VRID_TCP4_CEP (USR_TCP_CEP8);
+
+VRID_UDP4_CEP (USR_UDP_CEP1);
+VRID_UDP4_CEP (USR_UDP_CEP2);
+VRID_UDP4_CEP (USR_UDP_CEP3);
+VRID_UDP4_CEP (USR_UDP_CEP4);
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#ifdef SUPPORT_INET6
+
+VRID_TCP6_REP (USR_TCP_REP1);
+VRID_TCP6_REP (USR_TCP_REP2);
+VRID_TCP6_REP (USR_TCP_REP3);
+VRID_TCP6_REP (USR_TCP_REP4);
+
+VRID_TCP6_CEP (USR_TCP_CEP1);
+VRID_TCP6_CEP (USR_TCP_CEP2);
+VRID_TCP6_CEP (USR_TCP_CEP3);
+VRID_TCP6_CEP (USR_TCP_CEP4);
+VRID_TCP6_CEP (USR_TCP_CEP5);
+VRID_TCP6_CEP (USR_TCP_CEP6);
+VRID_TCP6_CEP (USR_TCP_CEP7);
+VRID_TCP6_CEP (USR_TCP_CEP8);
+
+VRID_UDP6_CEP (USR_UDP_CEP1);
+VRID_UDP6_CEP (USR_UDP_CEP2);
+VRID_UDP6_CEP (USR_UDP_CEP3);
+VRID_UDP6_CEP (USR_UDP_CEP4);
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
Index: /EcnlProtoTool/trunk/ntshell/tlsf/README.md
===================================================================
--- /EcnlProtoTool/trunk/ntshell/tlsf/README.md	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/tlsf/README.md	(revision 279)
@@ -0,0 +1,92 @@
+# tlsf
+Two-Level Segregated Fit memory allocator implementation.
+Written by Matthew Conte (matt@baisoku.org).
+Released under the BSD license.
+
+Features
+--------
+  * O(1) cost for malloc, free, realloc, memalign
+  * Extremely low overhead per allocation (4 bytes)
+  * Low overhead per TLSF management of pools (~3kB)
+  * Low fragmentation
+  * Compiles to only a few kB of code and data
+  * Support for adding and removing memory pool regions on the fly
+
+Caveats
+-------
+  * Currently, assumes architecture can make 4-byte aligned accesses
+  * Not designed to be thread safe; the user must provide this
+
+Notes
+-----
+This code was based on the TLSF 1.4 spec and documentation found at:
+
+	http://www.gii.upv.es/tlsf/main/docs
+
+It also leverages the TLSF 2.0 improvement to shrink the per-block overhead from 8 to 4 bytes.
+
+History
+-------
+2016/04/10 - v3.1
+  * Code moved to github
+  * tlsfbits.h rolled into tlsf.c
+  * License changed to BSD
+
+2014/02/08 - v3.0
+  * This version is based on improvements from 3DInteractive GmbH
+  * Interface changed to allow more than one memory pool
+  * Separated pool handling from control structure (adding, removing, debugging)
+  * Control structure and pools can still be constructed in the same memory block
+  * Memory blocks for control structure and pools are checked for alignment
+  * Added functions to retrieve control structure size, alignment size, min and max block size, overhead of pool structure, and overhead of a single allocation
+  * Minimal Pool size is tlsf_block_size_min() + tlsf_pool_overhead()
+  * Pool must be empty when it is removed, in order to allow O(1) removal
+
+2011/10/20 - v2.0
+  * 64-bit support
+  * More compiler intrinsics for ffs/fls
+  * ffs/fls verification during TLSF creation in debug builds
+
+2008/04/04 - v1.9
+  * Add tlsf_heap_check, a heap integrity check
+  * Support a predefined tlsf_assert macro
+  * Fix realloc case where block should shrink; if adjacent block is in use, execution would go down the slow path
+
+2007/02/08 - v1.8
+  * Fix for unnecessary reallocation in tlsf_realloc
+
+2007/02/03 - v1.7
+  * tlsf_heap_walk takes a callback
+  * tlsf_realloc now returns NULL on failure
+  * tlsf_memalign optimization for 4-byte alignment
+  * Usage of size_t where appropriate
+
+2006/11/21 - v1.6
+  * ffs/fls broken out into tlsfbits.h
+  * tlsf_overhead queries per-pool overhead
+
+2006/11/07 - v1.5
+  * Smart realloc implementation
+  * Smart memalign implementation
+
+2006/10/11 - v1.4
+  * Add some ffs/fls implementations
+  * Minor code footprint reduction
+
+2006/09/14 - v1.3
+  * Profiling indicates heavy use of blocks of size 1-128, so implement small block handling
+  * Reduce pool overhead by about 1kb
+  * Reduce minimum block size from 32 to 12 bytes
+  * Realloc bug fix
+
+2006/09/09 - v1.2
+  * Add tlsf_block_size
+  * Static assertion mechanism for invariants
+  * Minor bugfixes 
+
+2006/09/01 - v1.1
+  * Add tlsf_realloc
+  * Add tlsf_walk_heap
+
+2006/08/25 - v1.0
+  * First release
Index: /EcnlProtoTool/trunk/ntshell/tlsf/tlsf.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/tlsf/tlsf.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/tlsf/tlsf.c	(revision 279)
@@ -0,0 +1,1252 @@
+#include <assert.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "syssvc/syslog.h"
+
+#include "tlsf.h"
+
+#undef _MSC_VER
+
+#if defined(__cplusplus)
+#define tlsf_decl inline
+#else
+#define tlsf_decl static
+#endif
+
+/*
+** Architecture-specific bit manipulation routines.
+**
+** TLSF achieves O(1) cost for malloc and free operations by limiting
+** the search for a free block to a free list of guaranteed size
+** adequate to fulfill the request, combined with efficient free list
+** queries using bitmasks and architecture-specific bit-manipulation
+** routines.
+**
+** Most modern processors provide instructions to count leading zeroes
+** in a word, find the lowest and highest set bit, etc. These
+** specific implementations will be used when available, falling back
+** to a reasonably efficient generic implementation.
+**
+** NOTE: TLSF spec relies on ffs/fls returning value 0..31.
+** ffs/fls return 1-32 by default, returning 0 for error.
+*/
+
+/*
+** Detect whether or not we are building for a 32- or 64-bit (LP/LLP)
+** architecture. There is no reliable portable method at compile-time.
+*/
+#if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) \
+	|| defined (_WIN64) || defined (__LP64__) || defined (__LLP64__)
+#define TLSF_64BIT
+#endif
+
+/*
+** gcc 3.4 and above have builtin support, specialized for architecture.
+** Some compilers masquerade as gcc; patchlevel test filters them out.
+*/
+#if defined (__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) \
+	&& defined (__GNUC_PATCHLEVEL__)
+
+#if defined (__SNC__)
+/* SNC for Playstation 3. */
+
+tlsf_decl int tlsf_ffs(unsigned int word)
+{
+	const unsigned int reverse = word & (~word + 1);
+	const int bit = 32 - __builtin_clz(reverse);
+	return bit - 1;
+}
+
+#else
+
+tlsf_decl int tlsf_ffs(unsigned int word)
+{
+	return __builtin_ffs(word) - 1;
+}
+
+#endif
+
+tlsf_decl int tlsf_fls(unsigned int word)
+{
+	const int bit = word ? 32 - __builtin_clz(word) : 0;
+	return bit - 1;
+}
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1400) && (defined (_M_IX86) || defined (_M_X64))
+/* Microsoft Visual C++ support on x86/X64 architectures. */
+
+#include <intrin.h>
+
+#pragma intrinsic(_BitScanReverse)
+#pragma intrinsic(_BitScanForward)
+
+tlsf_decl int tlsf_fls(unsigned int word)
+{
+	unsigned long index;
+	return _BitScanReverse(&index, word) ? index : -1;
+}
+
+tlsf_decl int tlsf_ffs(unsigned int word)
+{
+	unsigned long index;
+	return _BitScanForward(&index, word) ? index : -1;
+}
+
+#elif defined (_MSC_VER) && defined (_M_PPC)
+/* Microsoft Visual C++ support on PowerPC architectures. */
+
+#include <ppcintrinsics.h>
+
+tlsf_decl int tlsf_fls(unsigned int word)
+{
+	const int bit = 32 - _CountLeadingZeros(word);
+	return bit - 1;
+}
+
+tlsf_decl int tlsf_ffs(unsigned int word)
+{
+	const unsigned int reverse = word & (~word + 1);
+	const int bit = 32 - _CountLeadingZeros(reverse);
+	return bit - 1;
+}
+
+#elif defined (__ARMCC_VERSION)
+/* RealView Compilation Tools for ARM */
+
+tlsf_decl int tlsf_ffs(unsigned int word)
+{
+	const unsigned int reverse = word & (~word + 1);
+	const int bit = 32 - __clz(reverse);
+	return bit - 1;
+}
+
+tlsf_decl int tlsf_fls(unsigned int word)
+{
+	const int bit = word ? 32 - __clz(word) : 0;
+	return bit - 1;
+}
+
+#elif defined (__ghs__)
+/* Green Hills support for PowerPC */
+
+#include <ppc_ghs.h>
+
+tlsf_decl int tlsf_ffs(unsigned int word)
+{
+	const unsigned int reverse = word & (~word + 1);
+	const int bit = 32 - __CLZ32(reverse);
+	return bit - 1;
+}
+
+tlsf_decl int tlsf_fls(unsigned int word)
+{
+	const int bit = word ? 32 - __CLZ32(word) : 0;
+	return bit - 1;
+}
+
+#else
+/* Fall back to generic implementation. */
+
+tlsf_decl int tlsf_fls_generic(unsigned int word)
+{
+	int bit = 32;
+
+	if (!word) bit -= 1;
+	if (!(word & 0xffff0000)) { word <<= 16; bit -= 16; }
+	if (!(word & 0xff000000)) { word <<= 8; bit -= 8; }
+	if (!(word & 0xf0000000)) { word <<= 4; bit -= 4; }
+	if (!(word & 0xc0000000)) { word <<= 2; bit -= 2; }
+	if (!(word & 0x80000000)) { word <<= 1; bit -= 1; }
+
+	return bit;
+}
+
+/* Implement ffs in terms of fls. */
+tlsf_decl int tlsf_ffs(unsigned int word)
+{
+	return tlsf_fls_generic(word & (~word + 1)) - 1;
+}
+
+tlsf_decl int tlsf_fls(unsigned int word)
+{
+	return tlsf_fls_generic(word) - 1;
+}
+
+#endif
+
+/* Possibly 64-bit version of tlsf_fls. */
+#if defined (TLSF_64BIT)
+tlsf_decl int tlsf_fls_sizet(size_t size)
+{
+	int high = (int)(size >> 32);
+	int bits = 0;
+	if (high)
+	{
+		bits = 32 + tlsf_fls(high);
+	}
+	else
+	{
+		bits = tlsf_fls((int)size & 0xffffffff);
+
+	}
+	return bits;
+}
+#else
+#define tlsf_fls_sizet tlsf_fls
+#endif
+
+#undef tlsf_decl
+
+/*
+** Constants.
+*/
+
+/* Public constants: may be modified. */
+enum tlsf_public
+{
+	/* log2 of number of linear subdivisions of block sizes. Larger
+	** values require more memory in the control structure. Values of
+	** 4 or 5 are typical.
+	*/
+	SL_INDEX_COUNT_LOG2 = 5,
+};
+
+/* Private constants: do not modify. */
+enum tlsf_private
+{
+#if defined (TLSF_64BIT)
+	/* All allocation sizes and addresses are aligned to 8 bytes. */
+	ALIGN_SIZE_LOG2 = 3,
+#else
+	/* All allocation sizes and addresses are aligned to 4 bytes. */
+	ALIGN_SIZE_LOG2 = 2,
+#endif
+	ALIGN_SIZE = (1 << ALIGN_SIZE_LOG2),
+
+	/*
+	** We support allocations of sizes up to (1 << FL_INDEX_MAX) bits.
+	** However, because we linearly subdivide the second-level lists, and
+	** our minimum size granularity is 4 bytes, it doesn't make sense to
+	** create first-level lists for sizes smaller than SL_INDEX_COUNT * 4,
+	** or (1 << (SL_INDEX_COUNT_LOG2 + 2)) bytes, as there we will be
+	** trying to split size ranges into more slots than we have available.
+	** Instead, we calculate the minimum threshold size, and place all
+	** blocks below that size into the 0th first-level list.
+	*/
+
+#if defined (TLSF_64BIT)
+	/*
+	** TODO: We can increase this to support larger sizes, at the expense
+	** of more overhead in the TLSF structure.
+	*/
+	FL_INDEX_MAX = 32,
+#else
+	FL_INDEX_MAX = 30,
+#endif
+	SL_INDEX_COUNT = (1 << SL_INDEX_COUNT_LOG2),
+	FL_INDEX_SHIFT = (SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2),
+	FL_INDEX_COUNT = (FL_INDEX_MAX - FL_INDEX_SHIFT + 1),
+
+	SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT),
+};
+
+/*
+** Cast and min/max macros.
+*/
+
+#define tlsf_cast(t, exp)	((t) (exp))
+#define tlsf_min(a, b)		((a) < (b) ? (a) : (b))
+#define tlsf_max(a, b)		((a) > (b) ? (a) : (b))
+
+/*
+** Set assert macro, if it has not been provided by the user.
+*/
+#if !defined (tlsf_assert)
+#define tlsf_assert assert
+#endif
+
+/*
+** Static assertion mechanism.
+*/
+
+#define _tlsf_glue2(x, y) x ## y
+#define _tlsf_glue(x, y) _tlsf_glue2(x, y)
+#define tlsf_static_assert(exp) \
+	typedef char _tlsf_glue(static_assert, __LINE__) [(exp) ? 1 : -1]
+
+/* This code has been tested on 32- and 64-bit (LP/LLP) architectures. */
+tlsf_static_assert(sizeof(int) * CHAR_BIT == 32);
+tlsf_static_assert(sizeof(size_t) * CHAR_BIT >= 32);
+tlsf_static_assert(sizeof(size_t) * CHAR_BIT <= 64);
+
+/* SL_INDEX_COUNT must be <= number of bits in sl_bitmap's storage type. */
+tlsf_static_assert(sizeof(unsigned int) * CHAR_BIT >= SL_INDEX_COUNT);
+
+/* Ensure we've properly tuned our sizes. */
+tlsf_static_assert(ALIGN_SIZE == SMALL_BLOCK_SIZE / SL_INDEX_COUNT);
+
+/*
+** Data structures and associated constants.
+*/
+
+/*
+** Block header structure.
+**
+** There are several implementation subtleties involved:
+** - The prev_phys_block field is only valid if the previous block is free.
+** - The prev_phys_block field is actually stored at the end of the
+**   previous block. It appears at the beginning of this structure only to
+**   simplify the implementation.
+** - The next_free / prev_free fields are only valid if the block is free.
+*/
+typedef struct block_header_t
+{
+	/* Points to the previous physical block. */
+	struct block_header_t* prev_phys_block;
+
+	/* The size of this block, excluding the block header. */
+	size_t size;
+
+	/* Next and previous free blocks. */
+	struct block_header_t* next_free;
+	struct block_header_t* prev_free;
+} block_header_t;
+
+/*
+** Since block sizes are always at least a multiple of 4, the two least
+** significant bits of the size field are used to store the block status:
+** - bit 0: whether block is busy or free
+** - bit 1: whether previous block is busy or free
+*/
+static const size_t block_header_free_bit = 1 << 0;
+static const size_t block_header_prev_free_bit = 1 << 1;
+
+/*
+** The size of the block header exposed to used blocks is the size field.
+** The prev_phys_block field is stored *inside* the previous free block.
+*/
+static const size_t block_header_overhead = sizeof(size_t);
+
+/* User data starts directly after the size field in a used block. */
+static const size_t block_start_offset =
+	offsetof(block_header_t, size) + sizeof(size_t);
+
+/*
+** A free block must be large enough to store its header minus the size of
+** the prev_phys_block field, and no larger than the number of addressable
+** bits for FL_INDEX.
+*/
+static const size_t block_size_min = 
+	sizeof(block_header_t) - sizeof(block_header_t*);
+static const size_t block_size_max = tlsf_cast(size_t, 1) << FL_INDEX_MAX;
+
+
+/* The TLSF control structure. */
+typedef struct control_t
+{
+	/* Empty lists point at this block to indicate they are free. */
+	block_header_t block_null;
+
+	/* Bitmaps for free lists. */
+	unsigned int fl_bitmap;
+	unsigned int sl_bitmap[FL_INDEX_COUNT];
+
+	/* Head of free lists. */
+	block_header_t* blocks[FL_INDEX_COUNT][SL_INDEX_COUNT];
+} control_t;
+
+/* A type used for casting when doing pointer arithmetic. */
+typedef ptrdiff_t tlsfptr_t;
+
+/*
+** block_header_t member functions.
+*/
+
+static size_t block_size(const block_header_t* block)
+{
+	return block->size & ~(block_header_free_bit | block_header_prev_free_bit);
+}
+
+static void block_set_size(block_header_t* block, size_t size)
+{
+	const size_t oldsize = block->size;
+	block->size = size | (oldsize & (block_header_free_bit | block_header_prev_free_bit));
+}
+
+static int block_is_last(const block_header_t* block)
+{
+	return block_size(block) == 0;
+}
+
+static int block_is_free(const block_header_t* block)
+{
+	return tlsf_cast(int, block->size & block_header_free_bit);
+}
+
+static void block_set_free(block_header_t* block)
+{
+	block->size |= block_header_free_bit;
+}
+
+static void block_set_used(block_header_t* block)
+{
+	block->size &= ~block_header_free_bit;
+}
+
+static int block_is_prev_free(const block_header_t* block)
+{
+	return tlsf_cast(int, block->size & block_header_prev_free_bit);
+}
+
+static void block_set_prev_free(block_header_t* block)
+{
+	block->size |= block_header_prev_free_bit;
+}
+
+static void block_set_prev_used(block_header_t* block)
+{
+	block->size &= ~block_header_prev_free_bit;
+}
+
+static block_header_t* block_from_ptr(const void* ptr)
+{
+	return tlsf_cast(block_header_t*,
+		tlsf_cast(unsigned char*, ptr) - block_start_offset);
+}
+
+static void* block_to_ptr(const block_header_t* block)
+{
+	return tlsf_cast(void*,
+		tlsf_cast(unsigned char*, block) + block_start_offset);
+}
+
+/* Return location of next block after block of given size. */
+static block_header_t* offset_to_block(const void* ptr, size_t size)
+{
+	return tlsf_cast(block_header_t*, tlsf_cast(tlsfptr_t, ptr) + size);
+}
+
+/* Return location of previous block. */
+static block_header_t* block_prev(const block_header_t* block)
+{
+	tlsf_assert(block_is_prev_free(block) && "previous block must be free");
+	return block->prev_phys_block;
+}
+
+/* Return location of next existing block. */
+static block_header_t* block_next(const block_header_t* block)
+{
+	block_header_t* next = offset_to_block(block_to_ptr(block),
+		block_size(block) - block_header_overhead);
+	tlsf_assert(!block_is_last(block));
+	return next;
+}
+
+/* Link a new block with its physical neighbor, return the neighbor. */
+static block_header_t* block_link_next(block_header_t* block)
+{
+	block_header_t* next = block_next(block);
+	next->prev_phys_block = block;
+	return next;
+}
+
+static void block_mark_as_free(block_header_t* block)
+{
+	/* Link the block to the next block, first. */
+	block_header_t* next = block_link_next(block);
+	block_set_prev_free(next);
+	block_set_free(block);
+}
+
+static void block_mark_as_used(block_header_t* block)
+{
+	block_header_t* next = block_next(block);
+	block_set_prev_used(next);
+	block_set_used(block);
+}
+
+static size_t align_up(size_t x, size_t align)
+{
+	tlsf_assert(0 == (align & (align - 1)) && "must align to a power of two");
+	return (x + (align - 1)) & ~(align - 1);
+}
+
+static size_t align_down(size_t x, size_t align)
+{
+	tlsf_assert(0 == (align & (align - 1)) && "must align to a power of two");
+	return x - (x & (align - 1));
+}
+
+static void* align_ptr(const void* ptr, size_t align)
+{
+	const tlsfptr_t aligned =
+		(tlsf_cast(tlsfptr_t, ptr) + (align - 1)) & ~(align - 1);
+	tlsf_assert(0 == (align & (align - 1)) && "must align to a power of two");
+	return tlsf_cast(void*, aligned);
+}
+
+/*
+** Adjust an allocation size to be aligned to word size, and no smaller
+** than internal minimum.
+*/
+static size_t adjust_request_size(size_t size, size_t align)
+{
+	size_t adjust = 0;
+	if (size && size < block_size_max)
+	{
+		const size_t aligned = align_up(size, align);
+		adjust = tlsf_max(aligned, block_size_min);
+	}
+	return adjust;
+}
+
+/*
+** TLSF utility functions. In most cases, these are direct translations of
+** the documentation found in the white paper.
+*/
+
+static void mapping_insert(size_t size, int* fli, int* sli)
+{
+	int fl, sl;
+	if (size < SMALL_BLOCK_SIZE)
+	{
+		/* Store small blocks in first list. */
+		fl = 0;
+		sl = tlsf_cast(int, size) / (SMALL_BLOCK_SIZE / SL_INDEX_COUNT);
+	}
+	else
+	{
+		fl = tlsf_fls_sizet(size);
+		sl = tlsf_cast(int, size >> (fl - SL_INDEX_COUNT_LOG2)) ^ (1 << SL_INDEX_COUNT_LOG2);
+		fl -= (FL_INDEX_SHIFT - 1);
+	}
+	*fli = fl;
+	*sli = sl;
+}
+
+/* This version rounds up to the next block size (for allocations) */
+static void mapping_search(size_t size, int* fli, int* sli)
+{
+	if (size >= SMALL_BLOCK_SIZE)
+	{
+		const size_t round = (1 << (tlsf_fls_sizet(size) - SL_INDEX_COUNT_LOG2)) - 1;
+		size += round;
+	}
+	mapping_insert(size, fli, sli);
+}
+
+static block_header_t* search_suitable_block(control_t* control, int* fli, int* sli)
+{
+	int fl = *fli;
+	int sl = *sli;
+
+	/*
+	** First, search for a block in the list associated with the given
+	** fl/sl index.
+	*/
+	unsigned int sl_map = control->sl_bitmap[fl] & (~0U << sl);
+	if (!sl_map)
+	{
+		/* No block exists. Search in the next largest first-level list. */
+		const unsigned int fl_map = control->fl_bitmap & (~0U << (fl + 1));
+		if (!fl_map)
+		{
+			/* No free blocks available, memory has been exhausted. */
+			return 0;
+		}
+
+		fl = tlsf_ffs(fl_map);
+		*fli = fl;
+		sl_map = control->sl_bitmap[fl];
+	}
+	tlsf_assert(sl_map && "internal error - second level bitmap is null");
+	sl = tlsf_ffs(sl_map);
+	*sli = sl;
+
+	/* Return the first block in the free list. */
+	return control->blocks[fl][sl];
+}
+
+/* Remove a free block from the free list.*/
+static void remove_free_block(control_t* control, block_header_t* block, int fl, int sl)
+{
+	block_header_t* prev = block->prev_free;
+	block_header_t* next = block->next_free;
+	tlsf_assert(prev && "prev_free field can not be null");
+	tlsf_assert(next && "next_free field can not be null");
+	next->prev_free = prev;
+	prev->next_free = next;
+
+	/* If this block is the head of the free list, set new head. */
+	if (control->blocks[fl][sl] == block)
+	{
+		control->blocks[fl][sl] = next;
+
+		/* If the new head is null, clear the bitmap. */
+		if (next == &control->block_null)
+		{
+			control->sl_bitmap[fl] &= ~(1 << sl);
+
+			/* If the second bitmap is now empty, clear the fl bitmap. */
+			if (!control->sl_bitmap[fl])
+			{
+				control->fl_bitmap &= ~(1 << fl);
+			}
+		}
+	}
+}
+
+/* Insert a free block into the free block list. */
+static void insert_free_block(control_t* control, block_header_t* block, int fl, int sl)
+{
+	block_header_t* current = control->blocks[fl][sl];
+	tlsf_assert(current && "free list cannot have a null entry");
+	tlsf_assert(block && "cannot insert a null entry into the free list");
+	block->next_free = current;
+	block->prev_free = &control->block_null;
+	current->prev_free = block;
+
+	tlsf_assert(block_to_ptr(block) == align_ptr(block_to_ptr(block), ALIGN_SIZE)
+		&& "block not aligned properly");
+	/*
+	** Insert the new block at the head of the list, and mark the first-
+	** and second-level bitmaps appropriately.
+	*/
+	control->blocks[fl][sl] = block;
+	control->fl_bitmap |= (1 << fl);
+	control->sl_bitmap[fl] |= (1 << sl);
+}
+
+/* Remove a given block from the free list. */
+static void block_remove(control_t* control, block_header_t* block)
+{
+	int fl, sl;
+	mapping_insert(block_size(block), &fl, &sl);
+	remove_free_block(control, block, fl, sl);
+}
+
+/* Insert a given block into the free list. */
+static void block_insert(control_t* control, block_header_t* block)
+{
+	int fl, sl;
+	mapping_insert(block_size(block), &fl, &sl);
+	insert_free_block(control, block, fl, sl);
+}
+
+static int block_can_split(block_header_t* block, size_t size)
+{
+	return block_size(block) >= sizeof(block_header_t) + size;
+}
+
+/* Split a block into two, the second of which is free. */
+static block_header_t* block_split(block_header_t* block, size_t size)
+{
+	/* Calculate the amount of space left in the remaining block. */
+	block_header_t* remaining =
+		offset_to_block(block_to_ptr(block), size - block_header_overhead);
+
+	const size_t remain_size = block_size(block) - (size + block_header_overhead);
+
+	tlsf_assert(block_to_ptr(remaining) == align_ptr(block_to_ptr(remaining), ALIGN_SIZE)
+		&& "remaining block not aligned properly");
+
+	tlsf_assert(block_size(block) == remain_size + size + block_header_overhead);
+	block_set_size(remaining, remain_size);
+	tlsf_assert(block_size(remaining) >= block_size_min && "block split with invalid size");
+
+	block_set_size(block, size);
+	block_mark_as_free(remaining);
+
+	return remaining;
+}
+
+/* Absorb a free block's storage into an adjacent previous free block. */
+static block_header_t* block_absorb(block_header_t* prev, block_header_t* block)
+{
+	tlsf_assert(!block_is_last(prev) && "previous block can't be last");
+	/* Note: Leaves flags untouched. */
+	prev->size += block_size(block) + block_header_overhead;
+	block_link_next(prev);
+	return prev;
+}
+
+/* Merge a just-freed block with an adjacent previous free block. */
+static block_header_t* block_merge_prev(control_t* control, block_header_t* block)
+{
+	if (block_is_prev_free(block))
+	{
+		block_header_t* prev = block_prev(block);
+		tlsf_assert(prev && "prev physical block can't be null");
+		tlsf_assert(block_is_free(prev) && "prev block is not free though marked as such");
+		block_remove(control, prev);
+		block = block_absorb(prev, block);
+	}
+
+	return block;
+}
+
+/* Merge a just-freed block with an adjacent free block. */
+static block_header_t* block_merge_next(control_t* control, block_header_t* block)
+{
+	block_header_t* next = block_next(block);
+	tlsf_assert(next && "next physical block can't be null");
+
+	if (block_is_free(next))
+	{
+		tlsf_assert(!block_is_last(block) && "previous block can't be last");
+		block_remove(control, next);
+		block = block_absorb(block, next);
+	}
+
+	return block;
+}
+
+/* Trim any trailing block space off the end of a block, return to pool. */
+static void block_trim_free(control_t* control, block_header_t* block, size_t size)
+{
+	tlsf_assert(block_is_free(block) && "block must be free");
+	if (block_can_split(block, size))
+	{
+		block_header_t* remaining_block = block_split(block, size);
+		block_link_next(block);
+		block_set_prev_free(remaining_block);
+		block_insert(control, remaining_block);
+	}
+}
+
+/* Trim any trailing block space off the end of a used block, return to pool. */
+static void block_trim_used(control_t* control, block_header_t* block, size_t size)
+{
+	tlsf_assert(!block_is_free(block) && "block must be used");
+	if (block_can_split(block, size))
+	{
+		/* If the next block is free, we must coalesce. */
+		block_header_t* remaining_block = block_split(block, size);
+		block_set_prev_used(remaining_block);
+
+		remaining_block = block_merge_next(control, remaining_block);
+		block_insert(control, remaining_block);
+	}
+}
+
+static block_header_t* block_trim_free_leading(control_t* control, block_header_t* block, size_t size)
+{
+	block_header_t* remaining_block = block;
+	if (block_can_split(block, size))
+	{
+		/* We want the 2nd block. */
+		remaining_block = block_split(block, size - block_header_overhead);
+		block_set_prev_free(remaining_block);
+
+		block_link_next(block);
+		block_insert(control, block);
+	}
+
+	return remaining_block;
+}
+
+static block_header_t* block_locate_free(control_t* control, size_t size)
+{
+	int fl = 0, sl = 0;
+	block_header_t* block = 0;
+
+	if (size)
+	{
+		mapping_search(size, &fl, &sl);
+		block = search_suitable_block(control, &fl, &sl);
+	}
+
+	if (block)
+	{
+		tlsf_assert(block_size(block) >= size);
+		remove_free_block(control, block, fl, sl);
+	}
+
+	return block;
+}
+
+static void* block_prepare_used(control_t* control, block_header_t* block, size_t size)
+{
+	void* p = 0;
+	if (block)
+	{
+		tlsf_assert(size && "size must be non-zero");
+		block_trim_free(control, block, size);
+		block_mark_as_used(block);
+		p = block_to_ptr(block);
+	}
+	return p;
+}
+
+/* Clear structure and point all empty lists at the null block. */
+static void control_construct(control_t* control)
+{
+	int i, j;
+
+	control->block_null.next_free = &control->block_null;
+	control->block_null.prev_free = &control->block_null;
+
+	control->fl_bitmap = 0;
+	for (i = 0; i < FL_INDEX_COUNT; ++i)
+	{
+		control->sl_bitmap[i] = 0;
+		for (j = 0; j < SL_INDEX_COUNT; ++j)
+		{
+			control->blocks[i][j] = &control->block_null;
+		}
+	}
+}
+
+/*
+** Debugging utilities.
+*/
+
+typedef struct integrity_t
+{
+	int prev_status;
+	int status;
+} integrity_t;
+
+#define tlsf_insist(x) { tlsf_assert(x); if (!(x)) { status--; } }
+
+static void integrity_walker(void* ptr, size_t size, int used, void* user)
+{
+	block_header_t* block = block_from_ptr(ptr);
+	integrity_t* integ = tlsf_cast(integrity_t*, user);
+	const int this_prev_status = block_is_prev_free(block) ? 1 : 0;
+	const int this_status = block_is_free(block) ? 1 : 0;
+	const size_t this_block_size = block_size(block);
+
+	int status = 0;
+	(void)used;
+	tlsf_insist(integ->prev_status == this_prev_status && "prev status incorrect");
+	tlsf_insist(size == this_block_size && "block size incorrect");
+
+	integ->prev_status = this_status;
+	integ->status += status;
+}
+
+int tlsf_check(tlsf_t tlsf)
+{
+	int i, j;
+
+	control_t* control = tlsf_cast(control_t*, tlsf);
+	int status = 0;
+
+	/* Check that the free lists and bitmaps are accurate. */
+	for (i = 0; i < FL_INDEX_COUNT; ++i)
+	{
+		for (j = 0; j < SL_INDEX_COUNT; ++j)
+		{
+			const int fl_map = control->fl_bitmap & (1 << i);
+			const int sl_list = control->sl_bitmap[i];
+			const int sl_map = sl_list & (1 << j);
+			const block_header_t* block = control->blocks[i][j];
+
+			/* Check that first- and second-level lists agree. */
+			if (!fl_map)
+			{
+				tlsf_insist(!sl_map && "second-level map must be null");
+			}
+
+			if (!sl_map)
+			{
+				tlsf_insist(block == &control->block_null && "block list must be null");
+				continue;
+			}
+
+			/* Check that there is at least one free block. */
+			tlsf_insist(sl_list && "no free blocks in second-level map");
+			tlsf_insist(block != &control->block_null && "block should not be null");
+
+			while (block != &control->block_null)
+			{
+				int fli, sli;
+				tlsf_insist(block_is_free(block) && "block should be free");
+				tlsf_insist(!block_is_prev_free(block) && "blocks should have coalesced");
+				tlsf_insist(!block_is_free(block_next(block)) && "blocks should have coalesced");
+				tlsf_insist(block_is_prev_free(block_next(block)) && "block should be free");
+				tlsf_insist(block_size(block) >= block_size_min && "block not minimum size");
+
+				mapping_insert(block_size(block), &fli, &sli);
+				tlsf_insist(fli == i && sli == j && "block size indexed in wrong list");
+				block = block->next_free;
+			}
+		}
+	}
+
+	return status;
+}
+
+#undef tlsf_insist
+
+static void default_walker(void* ptr, size_t size, int used, void* user)
+{
+	(void)user;
+	syslog(LOG_INFO, "\t%p %s size: %x (%p)\n", ptr, used ? "used" : "free", (unsigned int)size, block_from_ptr(ptr));
+}
+
+void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void* user)
+{
+	tlsf_walker pool_walker = walker ? walker : default_walker;
+	block_header_t* block =
+		offset_to_block(pool, -(int)block_header_overhead);
+
+	while (block && !block_is_last(block))
+	{
+		pool_walker(
+			block_to_ptr(block),
+			block_size(block),
+			!block_is_free(block),
+			user);
+		block = block_next(block);
+	}
+}
+
+size_t tlsf_block_size(void* ptr)
+{
+	size_t size = 0;
+	if (ptr)
+	{
+		const block_header_t* block = block_from_ptr(ptr);
+		size = block_size(block);
+	}
+	return size;
+}
+
+int tlsf_check_pool(pool_t pool)
+{
+	/* Check that the blocks are physically correct. */
+	integrity_t integ = { 0, 0 };
+	tlsf_walk_pool(pool, integrity_walker, &integ);
+
+	return integ.status;
+}
+
+/*
+** Size of the TLSF structures in a given memory block passed to
+** tlsf_create, equal to the size of a control_t
+*/
+size_t tlsf_size(void)
+{
+	return sizeof(control_t);
+}
+
+size_t tlsf_align_size(void)
+{
+	return ALIGN_SIZE;
+}
+
+size_t tlsf_block_size_min(void)
+{
+	return block_size_min;
+}
+
+size_t tlsf_block_size_max(void)
+{
+	return block_size_max;
+}
+
+/*
+** Overhead of the TLSF structures in a given memory block passed to
+** tlsf_add_pool, equal to the overhead of a free block and the
+** sentinel block.
+*/
+size_t tlsf_pool_overhead(void)
+{
+	return 2 * block_header_overhead;
+}
+
+size_t tlsf_alloc_overhead(void)
+{
+	return block_header_overhead;
+}
+
+pool_t tlsf_add_pool(tlsf_t tlsf, void* mem, size_t bytes)
+{
+	block_header_t* block;
+	block_header_t* next;
+
+	const size_t pool_overhead = tlsf_pool_overhead();
+	const size_t pool_bytes = align_down(bytes - pool_overhead, ALIGN_SIZE);
+
+	if (((ptrdiff_t)mem % ALIGN_SIZE) != 0)
+	{
+		syslog(LOG_INFO, "tlsf_add_pool: Memory must be aligned by %u bytes.\n",
+			(unsigned int)ALIGN_SIZE);
+		return 0;
+	}
+
+	if (pool_bytes < block_size_min || pool_bytes > block_size_max)
+	{
+#if defined (TLSF_64BIT)
+		syslog(LOG_INFO, "tlsf_add_pool: Memory size must be between 0x%x and 0x%x00 bytes.\n", 
+			(unsigned int)(pool_overhead + block_size_min),
+			(unsigned int)((pool_overhead + block_size_max) / 256));
+#else
+		syslog(LOG_INFO, "tlsf_add_pool: Memory size must be between %u and %u bytes.\n", 
+			(unsigned int)(pool_overhead + block_size_min),
+			(unsigned int)(pool_overhead + block_size_max));
+#endif
+		return 0;
+	}
+
+	/*
+	** Create the main free block. Offset the start of the block slightly
+	** so that the prev_phys_block field falls outside of the pool -
+	** it will never be used.
+	*/
+	block = offset_to_block(mem, -(tlsfptr_t)block_header_overhead);
+	block_set_size(block, pool_bytes);
+	block_set_free(block);
+	block_set_prev_used(block);
+	block_insert(tlsf_cast(control_t*, tlsf), block);
+
+	/* Split the block to create a zero-size sentinel block. */
+	next = block_link_next(block);
+	block_set_size(next, 0);
+	block_set_used(next);
+	block_set_prev_free(next);
+
+	return mem;
+}
+
+void tlsf_remove_pool(tlsf_t tlsf, pool_t pool)
+{
+	control_t* control = tlsf_cast(control_t*, tlsf);
+	block_header_t* block = offset_to_block(pool, -(int)block_header_overhead);
+
+	int fl = 0, sl = 0;
+
+	tlsf_assert(block_is_free(block) && "block should be free");
+	tlsf_assert(!block_is_free(block_next(block)) && "next block should not be free");
+	tlsf_assert(block_size(block_next(block)) == 0 && "next block size should be zero");
+
+	mapping_insert(block_size(block), &fl, &sl);
+	remove_free_block(control, block, fl, sl);
+}
+
+/*
+** TLSF main interface.
+*/
+
+#if _DEBUG
+int test_ffs_fls()
+{
+	/* Verify ffs/fls work properly. */
+	int rv = 0;
+	rv += (tlsf_ffs(0) == -1) ? 0 : 0x1;
+	rv += (tlsf_fls(0) == -1) ? 0 : 0x2;
+	rv += (tlsf_ffs(1) == 0) ? 0 : 0x4;
+	rv += (tlsf_fls(1) == 0) ? 0 : 0x8;
+	rv += (tlsf_ffs(0x80000000) == 31) ? 0 : 0x10;
+	rv += (tlsf_ffs(0x80008000) == 15) ? 0 : 0x20;
+	rv += (tlsf_fls(0x80000008) == 31) ? 0 : 0x40;
+	rv += (tlsf_fls(0x7FFFFFFF) == 30) ? 0 : 0x80;
+
+#if defined (TLSF_64BIT)
+	rv += (tlsf_fls_sizet(0x80000000) == 31) ? 0 : 0x100;
+	rv += (tlsf_fls_sizet(0x100000000) == 32) ? 0 : 0x200;
+	rv += (tlsf_fls_sizet(0xffffffffffffffff) == 63) ? 0 : 0x400;
+#endif
+
+	if (rv)
+	{
+		syslog(LOG_INFO, "test_ffs_fls: %x ffs/fls tests failed.\n", rv);
+	}
+	return rv;
+}
+#endif
+
+tlsf_t tlsf_create(void* mem)
+{
+#if _DEBUG
+	if (test_ffs_fls())
+	{
+		return 0;
+	}
+#endif
+
+	if (((tlsfptr_t)mem % ALIGN_SIZE) != 0)
+	{
+		syslog(LOG_INFO, "tlsf_create: Memory must be aligned to %u bytes.\n",
+			(unsigned int)ALIGN_SIZE);
+		return 0;
+	}
+
+	control_construct(tlsf_cast(control_t*, mem));
+
+	return tlsf_cast(tlsf_t, mem);
+}
+
+tlsf_t tlsf_create_with_pool(void* mem, size_t bytes)
+{
+	tlsf_t tlsf = tlsf_create(mem);
+	tlsf_add_pool(tlsf, (char*)mem + tlsf_size(), bytes - tlsf_size());
+	return tlsf;
+}
+
+void tlsf_destroy(tlsf_t tlsf)
+{
+	/* Nothing to do. */
+	(void)tlsf;
+}
+
+pool_t tlsf_get_pool(tlsf_t tlsf)
+{
+	return tlsf_cast(pool_t, (char*)tlsf + tlsf_size());
+}
+
+void* tlsf_malloc(tlsf_t tlsf, size_t size)
+{
+	control_t* control = tlsf_cast(control_t*, tlsf);
+	const size_t adjust = adjust_request_size(size, ALIGN_SIZE);
+	block_header_t* block = block_locate_free(control, adjust);
+	return block_prepare_used(control, block, adjust);
+}
+
+void* tlsf_memalign(tlsf_t tlsf, size_t align, size_t size)
+{
+	control_t* control = tlsf_cast(control_t*, tlsf);
+	const size_t adjust = adjust_request_size(size, ALIGN_SIZE);
+
+	/*
+	** We must allocate an additional minimum block size bytes so that if
+	** our free block will leave an alignment gap which is smaller, we can
+	** trim a leading free block and release it back to the pool. We must
+	** do this because the previous physical block is in use, therefore
+	** the prev_phys_block field is not valid, and we can't simply adjust
+	** the size of that block.
+	*/
+	const size_t gap_minimum = sizeof(block_header_t);
+	const size_t size_with_gap = adjust_request_size(adjust + align + gap_minimum, align);
+
+	/*
+	** If alignment is less than or equals base alignment, we're done.
+	** If we requested 0 bytes, return null, as tlsf_malloc(0) does.
+	*/
+	const size_t aligned_size = (adjust && align > ALIGN_SIZE) ? size_with_gap : adjust;
+
+	block_header_t* block = block_locate_free(control, aligned_size);
+
+	/* This can't be a static assert. */
+	tlsf_assert(sizeof(block_header_t) == block_size_min + block_header_overhead);
+
+	if (block)
+	{
+		void* ptr = block_to_ptr(block);
+		void* aligned = align_ptr(ptr, align);
+		size_t gap = tlsf_cast(size_t,
+			tlsf_cast(tlsfptr_t, aligned) - tlsf_cast(tlsfptr_t, ptr));
+
+		/* If gap size is too small, offset to next aligned boundary. */
+		if (gap && gap < gap_minimum)
+		{
+			const size_t gap_remain = gap_minimum - gap;
+			const size_t offset = tlsf_max(gap_remain, align);
+			const void* next_aligned = tlsf_cast(void*,
+				tlsf_cast(tlsfptr_t, aligned) + offset);
+
+			aligned = align_ptr(next_aligned, align);
+			gap = tlsf_cast(size_t,
+				tlsf_cast(tlsfptr_t, aligned) - tlsf_cast(tlsfptr_t, ptr));
+		}
+
+		if (gap)
+		{
+			tlsf_assert(gap >= gap_minimum && "gap size too small");
+			block = block_trim_free_leading(control, block, gap);
+		}
+	}
+
+	return block_prepare_used(control, block, adjust);
+}
+
+void tlsf_free(tlsf_t tlsf, void* ptr)
+{
+	/* Don't attempt to free a NULL pointer. */
+	if (ptr)
+	{
+		control_t* control = tlsf_cast(control_t*, tlsf);
+		block_header_t* block = block_from_ptr(ptr);
+		tlsf_assert(!block_is_free(block) && "block already marked as free");
+		block_mark_as_free(block);
+		block = block_merge_prev(control, block);
+		block = block_merge_next(control, block);
+		block_insert(control, block);
+	}
+}
+
+/*
+** The TLSF block information provides us with enough information to
+** provide a reasonably intelligent implementation of realloc, growing or
+** shrinking the currently allocated block as required.
+**
+** This routine handles the somewhat esoteric edge cases of realloc:
+** - a non-zero size with a null pointer will behave like malloc
+** - a zero size with a non-null pointer will behave like free
+** - a request that cannot be satisfied will leave the original buffer
+**   untouched
+** - an extended buffer size will leave the newly-allocated area with
+**   contents undefined
+*/
+void* tlsf_realloc(tlsf_t tlsf, void* ptr, size_t size)
+{
+	control_t* control = tlsf_cast(control_t*, tlsf);
+	void* p = 0;
+
+	/* Zero-size requests are treated as free. */
+	if (ptr && size == 0)
+	{
+		tlsf_free(tlsf, ptr);
+	}
+	/* Requests with NULL pointers are treated as malloc. */
+	else if (!ptr)
+	{
+		p = tlsf_malloc(tlsf, size);
+	}
+	else
+	{
+		block_header_t* block = block_from_ptr(ptr);
+		block_header_t* next = block_next(block);
+
+		const size_t cursize = block_size(block);
+		const size_t combined = cursize + block_size(next) + block_header_overhead;
+		const size_t adjust = adjust_request_size(size, ALIGN_SIZE);
+
+		tlsf_assert(!block_is_free(block) && "block already marked as free");
+
+		/*
+		** If the next block is used, or when combined with the current
+		** block, does not offer enough space, we must reallocate and copy.
+		*/
+		if (adjust > cursize && (!block_is_free(next) || adjust > combined))
+		{
+			p = tlsf_malloc(tlsf, size);
+			if (p)
+			{
+				const size_t minsize = tlsf_min(cursize, size);
+				memcpy(p, ptr, minsize);
+				tlsf_free(tlsf, ptr);
+			}
+		}
+		else
+		{
+			/* Do we need to expand to the next block? */
+			if (adjust > cursize)
+			{
+				block_merge_next(control, block);
+				block_mark_as_used(block);
+			}
+
+			/* Trim the resulting block and return the original pointer. */
+			block_trim_used(control, block, adjust);
+			p = ptr;
+		}
+	}
+
+	return p;
+}
Index: /EcnlProtoTool/trunk/ntshell/tlsf/tlsf.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/tlsf/tlsf.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/tlsf/tlsf.h	(revision 279)
@@ -0,0 +1,90 @@
+#ifndef INCLUDED_tlsf
+#define INCLUDED_tlsf
+
+/*
+** Two Level Segregated Fit memory allocator, version 3.1.
+** Written by Matthew Conte
+**	http://tlsf.baisoku.org
+**
+** Based on the original documentation by Miguel Masmano:
+**	http://www.gii.upv.es/tlsf/main/docs
+**
+** This implementation was written to the specification
+** of the document, therefore no GPL restrictions apply.
+** 
+** Copyright (c) 2006-2016, Matthew Conte
+** All rights reserved.
+** 
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are met:
+**     * Redistributions of source code must retain the above copyright
+**       notice, this list of conditions and the following disclaimer.
+**     * Redistributions in binary form must reproduce the above copyright
+**       notice, this list of conditions and the following disclaimer in the
+**       documentation and/or other materials provided with the distribution.
+**     * Neither the name of the copyright holder nor the
+**       names of its contributors may be used to endorse or promote products
+**       derived from this software without specific prior written permission.
+** 
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+** DISCLAIMED. IN NO EVENT SHALL MATTHEW CONTE BE LIABLE FOR ANY
+** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stddef.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* tlsf_t: a TLSF structure. Can contain 1 to N pools. */
+/* pool_t: a block of memory that TLSF can manage. */
+typedef void* tlsf_t;
+typedef void* pool_t;
+
+/* Create/destroy a memory pool. */
+tlsf_t tlsf_create(void* mem);
+tlsf_t tlsf_create_with_pool(void* mem, size_t bytes);
+void tlsf_destroy(tlsf_t tlsf);
+pool_t tlsf_get_pool(tlsf_t tlsf);
+
+/* Add/remove memory pools. */
+pool_t tlsf_add_pool(tlsf_t tlsf, void* mem, size_t bytes);
+void tlsf_remove_pool(tlsf_t tlsf, pool_t pool);
+
+/* malloc/memalign/realloc/free replacements. */
+void* tlsf_malloc(tlsf_t tlsf, size_t bytes);
+void* tlsf_memalign(tlsf_t tlsf, size_t align, size_t bytes);
+void* tlsf_realloc(tlsf_t tlsf, void* ptr, size_t size);
+void tlsf_free(tlsf_t tlsf, void* ptr);
+
+/* Returns internal block size, not original request size */
+size_t tlsf_block_size(void* ptr);
+
+/* Overheads/limits of internal structures. */
+size_t tlsf_size(void);
+size_t tlsf_align_size(void);
+size_t tlsf_block_size_min(void);
+size_t tlsf_block_size_max(void);
+size_t tlsf_pool_overhead(void);
+size_t tlsf_alloc_overhead(void);
+
+/* Debugging. */
+typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
+void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void* user);
+/* Returns nonzero if any internal consistency check fails. */
+int tlsf_check(tlsf_t tlsf);
+int tlsf_check_pool(pool_t pool);
+
+#if defined(__cplusplus)
+};
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/ntshell/webserver/http-strings
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/http-strings	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/http-strings	(revision 279)
Index: /EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c	(revision 279)
@@ -60,5 +60,5 @@
 #include "kernel_cfg.h"
 #include "syssvc/syslog.h"
-#include "arduino.h"
+#include "ntstdio.h"
 
 #ifndef _MSC_VER
@@ -96,5 +96,5 @@
 			fn = fno.fname;
 			if (fno.fattrib & AM_DIR) {
-				sprintf(&path[i], "0:/%s", fn);
+				ntstdio_sprintf(&path[i], "0:/%s", fn);
 				res = scan_files(path, size);
 				if (res != FR_OK) break;
@@ -112,5 +112,5 @@
 /*-----------------------------------------------------------------------------------*/
 int
-httpd_fs_open_ul(char *name, int len, struct httpd_fs_file *file)
+httpd_fs_open(char *name, int len, struct httpd_fs_file *file)
 {
 	FRESULT res;
@@ -157,20 +157,7 @@
 }
 
-int
-httpd_fs_open(char *name, int len, struct httpd_fs_file *file)
-{
-	int result;
-
-	wai_sem(SEM_FILESYSTEM);
-
-	result = httpd_fs_open_ul(name, len, file);
-
-	sig_sem(SEM_FILESYSTEM);
-
-	return result;
-}
-/*-----------------------------------------------------------------------------------*/
-int
-httpd_fs_create_ul(char *name, struct httpd_fs_file *file)
+/*-----------------------------------------------------------------------------------*/
+int
+httpd_fs_create(char *name, struct httpd_fs_file *file)
 {
 	FRESULT res;
@@ -196,20 +183,7 @@
 }
 
-int
-httpd_fs_create(char *name, struct httpd_fs_file *file)
-{
-	int result;
-
-	wai_sem(SEM_FILESYSTEM);
-
-	result = httpd_fs_create_ul(name, file);
-
-	sig_sem(SEM_FILESYSTEM);
-
-	return result;
-}
-/*-----------------------------------------------------------------------------------*/
-int
-httpd_fs_read_ul(struct httpd_fs_file *file, void *dst, int len)
+/*-----------------------------------------------------------------------------------*/
+int
+httpd_fs_read(struct httpd_fs_file *file, void *dst, int len)
 {
 	FRESULT ret;
@@ -236,20 +210,7 @@
 }
 
-int
-httpd_fs_read(struct httpd_fs_file *file, void *dst, int len)
-{
-	int result;
-
-	wai_sem(SEM_FILESYSTEM);
-
-	result = httpd_fs_read_ul(file, dst, len);
-
-	sig_sem(SEM_FILESYSTEM);
-
-	return result;
-}
-/*-----------------------------------------------------------------------------------*/
-int
-httpd_fs_write_ul(struct httpd_fs_file *file, const void *src, int len)
+/*-----------------------------------------------------------------------------------*/
+int
+httpd_fs_write(struct httpd_fs_file *file, const void *src, int len)
 {
 	FRESULT ret;
@@ -279,19 +240,6 @@
 }
 
-int
-httpd_fs_write(struct httpd_fs_file *file, const void *src, int len)
-{
-	int result;
-
-	wai_sem(SEM_FILESYSTEM);
-
-	result = httpd_fs_write_ul(file, src, len);
-
-	sig_sem(SEM_FILESYSTEM);
-
-	return result;
-}
-/*-----------------------------------------------------------------------------------*/
-int httpd_fs_close_ul(struct httpd_fs_file *file)
+/*-----------------------------------------------------------------------------------*/
+int httpd_fs_close(struct httpd_fs_file *file)
 {
 	FRESULT ret;
@@ -307,15 +255,2 @@
 	return 1;
 }
-
-int httpd_fs_close(struct httpd_fs_file *file)
-{
-	int result;
-
-	wai_sem(SEM_FILESYSTEM);
-
-	result = httpd_fs_close_ul(file);
-
-	sig_sem(SEM_FILESYSTEM);
-
-	return result;
-}
Index: /EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.h	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.h	(revision 279)
@@ -4,36 +4,47 @@
  *  Copyright (C) 2017 Cores Co., Ltd. Japan
  *
- *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
- *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
- *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
- *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
- *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
- *      XR[hÉÜÜêÄ¢é±ÆD
- *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
-gip
- *      Ò}j
-AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
- *      Ì³ÛØKèðfÚ·é±ÆD
- *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
- *      ÆD
- *    (a) ÄzzÉº¤hL
-gipÒ}j
-AÈÇjÉCãLÌ
- *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
- *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
- *        ñ·é±ÆD
- *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
- *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
- *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
- *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
- *      ÆÓ·é±ÆD
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
  *
- *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
- *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
- *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
- *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
- *  ÌÓCðíÈ¢D
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
  *
  *  @(#) $Id$
Index: /EcnlProtoTool/trunk/ntshell/webserver/httpd.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/httpd.c	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/httpd.c	(revision 279)
@@ -54,11 +54,45 @@
 #include <string.h>
 #include <stdlib.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
 #include "syssvc/syslog.h"
 #include "http-strings.h"
 #include "netinet/in.h"
-#include "arduino.h"
+#include "netinet/in_var.h"
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "http-strings.h"
+#include "base64.h"
+#include "sha1.h"
+#include "ntstdio.h"
 
 #define TRUE 1
 #define FALSE 0
+
+extern ntstdio_t ntstdio;
+SYSTIM httpd_time;
+struct httpd_state *uploding;
+extern char command[256];
+
+extern int execute_command(int wait);
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+uint8_t tcp_swbuf1[TCP_SWBUF_SIZE];
+uint8_t tcp_rwbuf1[TCP_RWBUF_SIZE];
+uint8_t tcp_swbuf2[TCP_SWBUF_SIZE];
+uint8_t tcp_rwbuf2[TCP_RWBUF_SIZE];
+
+#define ISO_nl      0x0a
+#define ISO_space   0x20
+#define ISO_bang    0x21
+#define ISO_percent 0x25
+#define ISO_period  0x2e
+#define ISO_slash   0x2f
+#define ISO_colon   0x3a
+
+struct httpd_state httpd_state[2] = {
+	{ HTTPD1_TASK, TCP_CEPID1 },
+	{ HTTPD2_TASK, TCP_CEPID2 },
+};
 
 #ifndef _MSC_VER
@@ -147,6 +181,4 @@
 	return ncpy;
 }
-
-extern struct httpd_state *uploding;
 
 int websvr_message_begin(http_parser *p)
@@ -306,5 +338,5 @@
 ã¯SDã«ã¼ã
 			s->filename[0] = '1';
-			syslog(LOG_NOTICE, "create:    %s.%d %s", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+			ntstdio_printf(&ntstdio, "create:    %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 			if (!httpd_fs_create(s->filename, &s->file)) {
 				goto error;
@@ -314,5 +346,5 @@
 		}
 		else if (strcmp(s->filename, uploding->filename) == 0) {
-			syslog(LOG_NOTICE, "collision: %s.%d %s", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+			ntstdio_printf(&ntstdio, "collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 			goto error;
 		}
@@ -359,9 +391,10 @@
 
 	if (s->message.body_is_final) {
-		syslog(LOG_NOTICE, "close:     %s.%d %s", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+		ntstdio_printf(&ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
 		httpd_fs_close(&s->file);
 		memset(&s->file, 0, sizeof(s->file));
 
-		strcpy_s(RubyFilename, sizeof(RubyFilename), s->filename);
+		strcpy_s(command, sizeof(command), "mruby -b ");
+		strcat_s(command, sizeof(command), s->filename);
 		s->reset = 1;
 
@@ -413,2 +446,552 @@
 	websvr_message_complete,
 };
+
+/*
+ *  ãããã¯ã¼ã¯å±¤ã®é¸æ
+ */
+
+#ifdef SUPPORT_INET6
+
+#define TCP_ACP_CEP(c,r,d,t)	tcp6_acp_cep(c,r,d,t)
+#define IP2STR(s,a)		ipv62str(s,a)
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#define TCP_ACP_CEP(c,r,d,t)	tcp_acp_cep(c,r,d,t)
+#define IP2STR(s,a)		ip2str(s,a)
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+struct httpd_state *get_httpd(ID cepid)
+{
+	for (int i = 0; i < 2; i++) {
+		if (httpd_state[i].cepid != cepid)
+			continue;
+
+		return &httpd_state[i];
+	}
+	return NULL;
+}
+
+struct websocket *websocket_getws(ID wbsid)
+{
+	for (int i = 0; i < 2; i++) {
+		if (httpd_state[i].websocket.wbsid != wbsid)
+			continue;
+
+		return &httpd_state[i].websocket;
+	}
+	return NULL;
+}
+
+void send_file(struct httpd_state *s)
+{
+	char *buf;
+	int len, slen;
+
+	while (s->file.len > 0) {
+		slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
+		if (slen < 0) {
+			syslog(LOG_ERROR, "send_file#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			s->state = STATE_CLOSING;
+			break;
+		}
+		if (slen == 0)
+			return;
+
+		len = s->file.len;
+		if (len > slen)
+			len = slen;
+
+		len = httpd_fs_read(&s->file, buf, len);
+		if (len <= 0) {
+			syslog(LOG_ERROR, "send_file#httpd_fs_read(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
+			break;
+		}
+
+		s->file.len -= len;
+		s->file.pos += len;
+
+		if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
+			syslog(LOG_ERROR, "send_file#tcp_snd_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			s->state = STATE_CLOSING;
+			break;
+		}
+	}
+
+	ntstdio_printf(&ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+	httpd_fs_close(&s->file);
+	s->file.len = 0;
+	s->file.pos = 0;
+
+	s->out.state = OUT_STATE_SEND_END;
+}
+
+void send_data(struct httpd_state *s)
+{
+	char *buf;
+	int len, slen;
+
+	while (s->response_len > 0) {
+		slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
+		if (slen < 0) {
+			syslog(LOG_ERROR, "send_data#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			s->state = STATE_CLOSING;
+			break;
+		}
+		if (slen == 0)
+			return;
+
+		len = s->response_len;
+		if (len > slen)
+			len = slen;
+
+		memcpy(buf, &s->response_body[s->response_pos], len);
+
+		s->response_len -= len;
+		s->response_pos += len;
+
+		if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
+			syslog(LOG_ERROR, "send_data#tcp_snd_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+			s->state = STATE_CLOSING;
+			break;
+		}
+	}
+
+	s->response_body = NULL;
+	s->response_len = 0;
+	s->response_pos = 0;
+
+	s->out.state = OUT_STATE_SEND_END;
+}
+
+void send_headers(struct httpd_state *s, const char *statushdr)
+{
+	int len;
+	char *ptr;
+
+	len = strlen(statushdr);
+	tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
+
+	if ((s->filename[0] == '0') && (s->file.len > 0)) {
+		len = sizeof(http_content_encoding_gzip) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_encoding_gzip, len, TMO_FEVR);
+	}
+
+	if (s->file.redirect) {
+		len = sizeof(http_location) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_location, len, TMO_FEVR);
+		if (s->filename[0] == '1') {
+			len = 2;
+			tcp_snd_dat(s->cepid, "/~", len, TMO_FEVR);
+		}
+		len = strlen(s->filename);
+		tcp_snd_dat(s->cepid, s->filename, len, TMO_FEVR);
+		if (s->query != NULL) {
+			tcp_snd_dat(s->cepid, "?", 1, TMO_FEVR);
+			len = strlen(s->query);
+			tcp_snd_dat(s->cepid, s->query, len, TMO_FEVR);
+		}
+		len = 2;
+		tcp_snd_dat(s->cepid, "\r", len, TMO_FEVR);
+	}
+
+	ptr = strrchr(s->filename, ISO_period);
+	if (ptr == NULL) {
+		len = sizeof(http_content_type_binary) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_binary, len, TMO_FEVR);
+	}
+	else if (strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 ||
+		strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) {
+		len = sizeof(http_content_type_html) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_html, len, TMO_FEVR);
+	}
+	else if (strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) {
+		len = sizeof(http_content_type_css) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_css, len, TMO_FEVR);
+	}
+	else if (strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) {
+		len = sizeof(http_content_type_js) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_js, len, TMO_FEVR);
+	}
+	else if (strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) {
+		len = sizeof(http_content_type_json) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_json, len, TMO_FEVR);
+	}
+	else if (strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) {
+		len = sizeof(http_content_type_png) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_png, len, TMO_FEVR);
+	}
+	else if (strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) {
+		len = sizeof(http_content_type_gif) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_gif, len, TMO_FEVR);
+	}
+	else if (strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) {
+		len = sizeof(http_content_type_jpg) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_jpg, len, TMO_FEVR);
+	}
+	else if (strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) {
+		len = sizeof(http_content_type_svg) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_svg, len, TMO_FEVR);
+	}
+	else if (strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) {
+		len = sizeof(http_content_type_text) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_text, len, TMO_FEVR);
+	}
+	else if (strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) {
+		len = sizeof(http_content_type_eot) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_eot, len, TMO_FEVR);
+	}
+	else if (strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) {
+		len = sizeof(http_content_type_ttf) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_ttf, len, TMO_FEVR);
+	}
+	else if (strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) {
+		len = sizeof(http_content_type_woff) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_woff, len, TMO_FEVR);
+	}
+	else if (strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) {
+		len = sizeof(http_content_type_woff2) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_woff2, len, TMO_FEVR);
+	}
+	else if (strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) {
+		len = sizeof(http_content_type_ico) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_ico, len, TMO_FEVR);
+	}
+	else {
+		len = sizeof(http_content_type_plain) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_type_plain, len, TMO_FEVR);
+	}
+
+	if (s->file.len > 0) {
+		len = sizeof(http_content_length) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_content_length, len, TMO_FEVR);
+		ntstdio_snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len);
+		tcp_snd_dat(s->cepid, (void *)s->temp, strlen(s->temp), TMO_FEVR);
+	}
+
+	if (s->message.should_keep_alive && s->reset == 0) {
+		len = sizeof(http_connection_keep_alive) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_connection_keep_alive, len, TMO_FEVR);
+	}
+	else {
+		len = sizeof(http_connection_close) - 1;
+		tcp_snd_dat(s->cepid, (void *)http_connection_close, len, TMO_FEVR);
+	}
+
+	tcp_snd_dat(s->cepid, (void *)http_crnl, 2, TMO_FEVR);
+
+	if (s->filename != NULL) {
+		s->out.state = OUT_STATE_SEND_FILE;
+	}
+	else {
+		s->out.state = OUT_STATE_SEND_DATA;
+	}
+}
+
+void handle_output(struct httpd_state *s)
+{
+	s->out.wait = false;
+
+	switch (s->out.state) {
+	case OUT_STATE_WAIT_REQUEST:
+		s->out.wait = true;
+		break;
+	case OUT_STATE_OPEN_GET_FILE:
+		ntstdio_printf(&ntstdio, "open:      %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
+		if (!httpd_fs_open(s->filename, sizeof(s->message.request_url), &s->file)) {
+			s->filename = NULL;
+			s->response_body = http_content_404;
+			s->response_pos = 0;
+			s->response_len = sizeof(http_content_403) - 1;
+			s->out.statushdr = http_header_404;
+		}
+		else {
+			s->out.statushdr = s->file.redirect ? http_header_301 : http_header_200;
+		}
+		s->out.state = OUT_STATE_SEND_HEADER;
+		break;
+	case OUT_STATE_WAIT_POST_BODY:
+		s->out.wait = true;
+		break;
+	case OUT_STATE_BODY_RECEIVED:
+		s->out.statushdr = http_header_200;
+		s->out.state = OUT_STATE_SEND_HEADER;
+		break;
+	case OUT_STATE_SEND_HEADER:
+		send_headers(s, s->out.statushdr);
+		break;
+	case OUT_STATE_SEND_FILE:
+		send_file(s);
+		break;
+	case OUT_STATE_SEND_DATA:
+		send_data(s);
+		break;
+	case OUT_STATE_SEND_END:
+		s->out.wait = true;
+		if (s->message.should_keep_alive && s->reset == 0) {
+			s->out.state = OUT_STATE_WAIT_REQUEST;
+		}
+		else {
+			s->state = STATE_CLOSING;
+		}
+		break;
+	}
+}
+
+void send_ws_headers(struct httpd_state *s, const char *statushdr)
+{
+	int len;
+
+	len = strlen(statushdr);
+	tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
+
+	len = sizeof(http_upgrade) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_upgrade, len, TMO_FEVR);
+	len = strlen(s->message.upgrade);
+	tcp_snd_dat(s->cepid, s->message.upgrade, len, TMO_FEVR);
+	len = sizeof(http_crnl) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
+
+	len = sizeof(http_connection) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_connection, len, TMO_FEVR);
+	len = strlen(s->message.connection);
+	tcp_snd_dat(s->cepid, s->message.connection, len, TMO_FEVR);
+	len = sizeof(http_crnl) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
+
+	len = sizeof(http_sec_websocket_accept) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_sec_websocket_accept, len, TMO_FEVR);
+	len = strlen(s->message.response_key);
+	tcp_snd_dat(s->cepid, s->message.response_key, len, TMO_FEVR);
+	len = sizeof(http_crnl) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
+
+	len = sizeof(http_sec_websocket_protocol) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_sec_websocket_protocol, len, TMO_FEVR);
+	len = strlen(s->message.sec_websocket_protocol);
+	tcp_snd_dat(s->cepid, s->message.sec_websocket_protocol, len, TMO_FEVR);
+	len = sizeof(http_crnl) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
+
+	len = sizeof(http_crnl) - 1;
+	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
+}
+
+void send_ws_data(struct httpd_state *s)
+{
+	char *buf;
+	int slen;
+
+	slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
+	if (slen < 0) {
+		syslog(LOG_ERROR, "send_ws_data#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
+		return;
+	}
+
+	websocket_output(&s->websocket, buf, slen);
+}
+
+void handle_ws_output(struct httpd_state *s)
+{
+	char shaHash[20];
+	SHA_CTX sha1;
+	int len;
+
+	strlncat(s->message.response_key, sizeof(s->message.response_key),
+		s->message.sec_websocket_key, sizeof(s->message.sec_websocket_key));
+	len = strlncat(s->message.response_key, sizeof(s->message.response_key),
+		http_websocket_guid, sizeof(http_websocket_guid));
+	memset(shaHash, 0, sizeof(shaHash));
+	SHA1_Init(&sha1);
+	SHA1_Update(&sha1, (sha1_byte *)s->message.response_key, len);
+	SHA1_Final((sha1_byte *)shaHash, &sha1);
+	base64_encode((unsigned char *)s->message.response_key,
+		sizeof(s->message.response_key), (unsigned char *)shaHash, sizeof(shaHash));
+
+	send_ws_headers(s, http_header_101);
+
+	s->message.response_key[0] = '\0';
+
+	do {
+		while (!websocket_newdata(&s->websocket))
+			slp_tsk();
+
+		send_ws_data(s);
+	} while ((s->state == STATE_CONNECTED) && (!s->close_req));
+	s->state = STATE_DISCONNECTED;
+	websocket_destroy(&s->websocket);
+	s->close_req = 0;
+
+	s->state = STATE_CLOSING;
+}
+
+void handle_input(struct httpd_state *s)
+{
+	size_t done;
+	int len;
+
+	s->in.wait = false;
+
+	switch (s->in.state) {
+	case IN_STATE_START:
+		http_parser_init(&s->parser, HTTP_REQUEST);
+		s->in.state = IN_STATE_REQUEST;
+		break;
+	case IN_STATE_REQUEST:
+	case IN_STATE_RESPONSE:
+	case IN_STATE_UPLOAD:
+		if ((len = tcp_rcv_buf(s->cepid, (void **)&s->in.data, TMO_POL)) <= 0) {
+			if ((len == E_TMOUT) || (len == 0)) {
+				// 3ç§ã¯å¾
+ã¤
+				//if (httpd_time - s->in.timer < 30000000) {
+					s->in.wait = true;
+					break;
+				//}
+			}
+			syslog(LOG_ERROR, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
+			uploding = NULL;
+			s->state = STATE_CLOSING;
+			return;
+		}
+		done = http_parser_execute(&s->parser, &websvr_settings, s->in.data, len);
+		tcp_rel_buf(s->cepid, done);
+		if (s->parser.http_errno != HPE_OK) {
+			syslog(LOG_ERROR, "http_parser error %s.%d => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
+			uploding = NULL;
+			s->state = STATE_CLOSING;
+			return;
+		}
+
+		s->parse_pos = done;
+		s->parse_len = len - done;
+		break;
+	case IN_STATE_UPLOAD_WAIT:
+		if (uploding != NULL) {
+			s->in.wait = true;
+		}
+		else {
+			uploding = s;
+			s->in.state = IN_STATE_UPLOAD;
+		}
+		break;
+	case IN_STATE_WEBSOCKET:
+		if (s->parse_len <= 0) {
+			if ((len = tcp_rcv_buf(s->cepid, (void **)&s->in.data, TMO_POL)) <= 0) {
+				if ((len == E_TMOUT) || (len == 0)) {
+					s->in.wait = true;
+					break;
+				}
+				syslog(LOG_ERROR, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
+				s->state = STATE_CLOSING;
+				break;
+			}
+
+			s->parse_pos = 0;
+			s->parse_len = len;
+		}
+		else
+			len = s->parse_len;
+		done = websocket_input(&s->websocket, (void *)s->in.data, s->parse_len);
+		tcp_rel_buf(s->cepid, done);
+		if ((done != 0) || (s->websocket.rstate.opecode == connection_close)) {
+			s->close_req = 1;
+			s->state = STATE_CLOSING;
+			break;
+		}
+		s->parse_pos = done;
+		s->parse_len -= done;
+		break;
+	case IN_STATE_END:
+		s->in.wait = true;
+		break;
+	default:
+		s->state = STATE_CLOSING;
+		break;
+	}
+}
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+ER
+callback_nblk_tcp(ID cepid, FN fncd, void *p_parblk)
+{
+	struct httpd_state *s = get_httpd(cepid);
+
+	if (s == NULL)
+		ntstdio_printf(&ntstdio, "callback_nblk_tcp(%d, %d)\n", fncd, cepid);
+	else
+		ntstdio_printf(&ntstdio, "callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
+
+	return E_PAR;
+}
+
+/*
+ * HTTPãµã¼ãã¼ã¿ã¹ã¯
+ */
+void httpd_task(intptr_t exinf)
+{
+	ER ret, ret2;
+	struct httpd_state *s = &httpd_state[exinf];
+
+	for (;;) {
+		ret2 = get_tim(&httpd_time);
+		if (ret2 != E_OK) {
+			syslog(LOG_ERROR, "get_tim");
+			return;
+		}
+
+		switch (s->state) {
+		case STATE_DISCONNECTED:
+			memset(&s->dst, 0, sizeof(s->dst));
+			if ((ret = TCP_ACP_CEP(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) {
+				syslog(LOG_ERROR, "tcp_acp_cep(%d) => %d", s->cepid, ret);
+				tslp_tsk(100);	// TODO
+				s->state = STATE_CLOSING;
+				break;
+			}
+			IP2STR(s->addr, &((T_IPV4EP *)s->dst)->ipaddr);
+			ntstdio_printf(&ntstdio, "connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
+			memset(&s->in, 0, sizeof(s->in));
+			memset(&s->out, 0, sizeof(s->out));
+			s->in.timer = httpd_time;
+			s->state = STATE_CONNECTED;
+			break;
+		case STATE_CONNECTED:
+			handle_input(s);
+			handle_output(s);
+			break;
+		case STATE_WEBSOCKET:
+			handle_input(s);
+			handle_ws_output(s);
+			break;
+		case STATE_CLOSING:
+			ntstdio_printf(&ntstdio, "close:     %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
+			tcp_sht_cep(s->cepid);
+			tcp_cls_cep(s->cepid, TMO_FEVR);
+
+			if (s->reset) {
+				s->reset = 0;
+				s->state = STATE_RESET;
+			}
+			else {
+				s->state = STATE_DISCONNECTED;
+			}
+			break;
+		case STATE_RESET:
+			execute_command(0);
+			s->state = STATE_DISCONNECTED;
+			break;
+		}
+
+		if (s->in.wait && s->out.wait) {
+			tslp_tsk(100);
+		}
+	}
+}
Index: /EcnlProtoTool/trunk/ntshell/webserver/httpd.cfg
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/httpd.cfg	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/webserver/httpd.cfg	(revision 279)
@@ -0,0 +1,59 @@
+/*
+ *  TOPPERS ECHONET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2017 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  HTTPãµã¼ãã¼ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+#include "httpd.h"
+
+CRE_TSK(HTTPD1_TASK, { TA_NULL, 0, httpd_task, HTTPD_PRIORITY, HTTPD_STACK_SIZE, NULL });
+CRE_TSK(HTTPD2_TASK, { TA_NULL, 1, httpd_task, HTTPD_PRIORITY, HTTPD_STACK_SIZE, NULL });
Index: /EcnlProtoTool/trunk/ntshell/webserver/httpd.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/httpd.h	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/httpd.h	(revision 279)
@@ -4,36 +4,47 @@
  *  Copyright (C) 2017 Cores Co., Ltd. Japan
  *
- *  ãLì ÒÍCÈºÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
- *  Ai{\tgEFAðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»Eü
- *  ÏEÄzziÈºCpÆÄÔj·é±Æð³Åø·éD
- *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
- *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
- *      XR[hÉÜÜêÄ¢é±ÆD
- *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
-gip
- *      Ò}j
-AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
- *      Ì³ÛØKèðfÚ·é±ÆD
- *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
- *      ÆD
- *    (a) ÄzzÉº¤hL
-gipÒ}j
-AÈÇjÉCãLÌ
- *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
- *    (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
- *        ñ·é±ÆD
- *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
- *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
- *      Ü½C{\tgEFAÌ[UÜ½ÍGh[U©çÌ¢©Èé
- *      RÉîÃ­¿©çàCãLì Ò¨æÑTOPPERSvWFNgð
- *      ÆÓ·é±ÆD
- *
- *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
- *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
- *  ÉÎ·éK«àÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEF
- *  AÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»
- *  ÌÓCðíÈ¢D
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
  *
  *  @(#) $Id$
@@ -43,7 +54,41 @@
 #define __HTTPD_H__
 
+/*
+ *  ã¿ã¼ã²ããä¾å­ã®å®ç¾©
+ */
+#include <kernel.h>
 #include "httpd-fs.h"
 #include "http_parser.h"
 #include "websocket.h"
+
+/*
+ *  åã¿ã¹ã¯ã®åªå
+åº¦ã®å®ç¾©
+ */
+
+#define HTTPD_PRIORITY	5		/* HTTPãµã¼ãã¼ã¿ã¹ã¯ã®åªå
+åº¦ */
+
+#define HTTPD_STACK_SIZE		1024	/* HTTPãµã¼ãã¼ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®ãµã¤ãº */
+
+ /*  TCP éåä¿¡ã¦ã£ã³ããããã¡ãµã¤ãº  */
+
+#define TCP_SWBUF_SIZE	512
+#define TCP_RWBUF_SIZE	512
+
+/*
+ *  é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+ /*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+
+extern uint8_t tcp_swbuf1[];
+extern uint8_t tcp_rwbuf1[];
+extern uint8_t tcp_swbuf2[];
+extern uint8_t tcp_rwbuf2[];
+
+/* HTTPãµã¼ãã¼ã¿ã¹ã¯ */
+extern void httpd_task(intptr_t exinf);
 
 #define MAX_ELEMENT_SIZE 256
@@ -81,9 +126,9 @@
 
 typedef enum httpd_state_t {
-	STATE_DISCONNECTED,		/* Øf */
-	STATE_CONNECTED,		/* Ú± */
-	STATE_WEBSOCKET,		/* WebSocketÊM */
-	STATE_CLOSING,			/* Øf */
-	STATE_RESET,			/* mrubyN®Ì½ßÌZbg */
+	STATE_DISCONNECTED,		/* åæ­ä¸­ */
+	STATE_CONNECTED,		/* æ¥ç¶ä¸­ */
+	STATE_WEBSOCKET,		/* WebSocketéä¿¡ä¸­ */
+	STATE_CLOSING,			/* åæ­å¦çä¸­ */
+	STATE_RESET,			/* mrubyèµ·åã®ããã®ãªã»ãã */
 } httpd_state_t;
 
@@ -155,3 +200,10 @@
 #define get_context(p) (struct httpd_state *)((intptr_t)p - (intptr_t)&((struct httpd_state *)0)->parser)
 
+/* 
+ * ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+extern ER callback_nblk_tcp(ID cepid, FN fncd, void *p_parblk);
+
+#endif /* TOPPERS_MACRO_ONLY */
+
 #endif /* __HTTPD_H__ */
Index: /EcnlProtoTool/trunk/ntshell/webserver/makestrings
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/makestrings	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/makestrings	(revision 279)
Index: /EcnlProtoTool/trunk/ntshell/webserver/tinet_httpd.cfg
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/tinet_httpd.cfg	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/webserver/tinet_httpd.cfg	(revision 279)
@@ -0,0 +1,117 @@
+/*
+ *  TOPPERS ECHONET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2016 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ main.c ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "httpd.h"
+
+/* TCP åä»å£ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_REP (TCP_REPID, { 0, { IPV6_ADDRANY, 80 } } );
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_REP (TCP_REPID,	 { 0, { IPV4_ADDRANY, 80 } } );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_CEP (TCP_CEPID1, {
+	0,
+	tcp_swbuf1,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf1,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+TCP6_CRE_CEP (TCP_CEPID2, {
+	0,
+	tcp_swbuf2,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf2,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_CEP (TCP_CEPID1, {
+	0,
+	tcp_swbuf1,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf1,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+TCP_CRE_CEP (TCP_CEPID2, {
+	0,
+	tcp_swbuf2,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf2,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
Index: /EcnlProtoTool/trunk/ntshell/webserver/websocket.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/websocket.c	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/websocket.c	(revision 279)
@@ -57,5 +57,5 @@
 #include "syssvc/syslog.h"
 
-static ECN_FBS_ID cur_out_msg;
+static WS_FBS_ID cur_out_msg;
 
 void websocket_init(struct websocket *ws, ID wbsid)
@@ -69,10 +69,10 @@
 	if ((cur_out_msg.ptr != NULL) && (((ID *)cur_out_msg.ptr->_gap)[0] == ws->wbsid))
 	{
-		_ecn_fbs_del(cur_out_msg);
+		_ws_fbs_del(cur_out_msg);
 		memset(&cur_out_msg, 0, sizeof(cur_out_msg));
 	}
 
 	if (ws->cur_in_msg.ptr != NULL) {
-		_ecn_fbs_del(ws->cur_in_msg);
+		_ws_fbs_del(ws->cur_in_msg);
 		memset(&ws->cur_in_msg, 0, sizeof(ws->cur_in_msg));
 	}
@@ -136,5 +136,5 @@
 			}
 			else {
-				_ecn_fbs_cre(1, &ws->cur_in_msg);
+				_ws_fbs_cre(1, &ws->cur_in_msg);
 				s->state++;
 			}
@@ -143,5 +143,5 @@
 		default:
 			if(ws->cur_in_msg.ptr != NULL)
-				_ecn_fbs_poke(ws->cur_in_msg, s->data_pos, *pos ^ s->masking_key[s->data_pos % 4]);
+				_ws_fbs_poke(ws->cur_in_msg, s->data_pos, *pos ^ s->masking_key[s->data_pos % 4]);
 
 			s->data_pos++;
@@ -152,8 +152,8 @@
 				if (ws->cur_in_msg.ptr != NULL) {
 					((ID *)ws->cur_in_msg.ptr->_gap)[0] = ws->wbsid;
-					ret = psnd_dtq(ecn_api_mailboxid, (intptr_t)ws->cur_in_msg.ptr);
+					ret = psnd_dtq(ws_api_mailboxid, (intptr_t)ws->cur_in_msg.ptr);
 					if (ret != E_OK) {
-						syslog(LOG_WARNING, "websocket_input() : psnd_dtq(%d) result = %d", ecn_api_mailboxid, ret);
-						_ecn_fbs_del(ws->cur_in_msg);
+						syslog(LOG_WARNING, "websocket_input() : psnd_dtq(%d) result = %d", ws_api_mailboxid, ret);
+						_ws_fbs_del(ws->cur_in_msg);
 					}
 				}
@@ -172,5 +172,5 @@
 	struct websocket *mws;
 	ER ret;
-	ECN_FBS_ID data;
+	WS_FBS_ID data;
 	ID wbsid;
 
@@ -196,5 +196,5 @@
 			break;
 
-		_ecn_fbs_del(cur_out_msg);
+		_ws_fbs_del(cur_out_msg);
 	}
 
@@ -217,5 +217,5 @@
 				return (intptr_t)pos - (intptr_t)data;
 
-			s->payload_len = _ecn_fbs_get_datalen(cur_out_msg);
+			s->payload_len = _ws_fbs_get_datalen(cur_out_msg);
 			if(s->payload_len == 0){
 				goto next;
@@ -281,5 +281,5 @@
 		// Payload buffer
 		default:
-			*pos = _ecn_fbs_peek(cur_out_msg, s->data_pos) ^ s->masking_key[s->data_pos % 4];
+			*pos = _ws_fbs_peek(cur_out_msg, s->data_pos) ^ s->masking_key[s->data_pos % 4];
 
 			s->data_pos++;
@@ -289,5 +289,5 @@
 			break;
 		next:
-			_ecn_fbs_del(cur_out_msg);
+			_ws_fbs_del(cur_out_msg);
 			memset(&cur_out_msg, 0, sizeof(cur_out_msg));
 			s->state = 0;
Index: /EcnlProtoTool/trunk/ntshell/webserver/websocket.cfg
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/websocket.cfg	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/webserver/websocket.cfg	(revision 279)
@@ -0,0 +1,58 @@
+/*
+ *  TOPPERS ECHONET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2017 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  WebSocketã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+#include "websocket.h"
+
+CRE_DTQ(WEBSOCKET_MBXID, { TA_TFIFO, NUM_WEBSOCKET_MBXID, NULL });
Index: /EcnlProtoTool/trunk/ntshell/webserver/websocket.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/websocket.h	(revision 278)
+++ /EcnlProtoTool/trunk/ntshell/webserver/websocket.h	(revision 279)
@@ -58,89 +58,10 @@
 #include "t_stddef.h"
 
-#define NUM_ECHONET_MEMPOOL_BLOCK (60)		/* é»æç¨ã¡ã¢ãªãã­ãã¯ã®æ° */
-#define ECHONET_MEMPOOL_BLOCK_SIZE (256)	/* é»æç¨ã¡ã¢ãªãã­ãã¯ã®ãµã¤ãº */
+#define NUM_WEBSOCKET_MBXID	2
 
-/* T_EDATAç®¡çé åãµã¤ãº */
-#define DEF_ECN_EDT_HDR_LEN (sizeof(intptr_t))
+#ifndef TOPPERS_MACRO_ONLY
+#include "websocket_fbs.h"
 
-/* ç®¡çé åãµã¤ãº(64byte - sizeof(T_MSG)) */
-/* #define DEF_ECN_FBS_LIB_HDR_LEN ((ECHONET_MEMPOOL_BLOCK_SIZE + sizeof(int) - 1)>> 2) // */
-#define DEF_ECN_FBS_LIB_HDR_LEN (64 - DEF_ECN_EDT_HDR_LEN)
-
-/* ç®¡çé åãå«ããã­ãã¯ã«ä¿æãããã¼ã¿ãµã¤ãº */
-#define DEF_ECN_FBS_FST_DAT_LEN (64)
-
-/* ãªã³ã¯ãã¤ã³ã¿é
-åã®ãµã¤ãº(byte) */
-#define DEF_ECN_FBS_LNK_LEN (ECHONET_MEMPOOL_BLOCK_SIZE - DEF_ECN_EDT_HDR_LEN - DEF_ECN_FBS_LIB_HDR_LEN - DEF_ECN_FBS_FST_DAT_LEN)
-
-/* åºå®é·ãããã¡æå¤§ãµã¤ãº */
-#define DEF_ECN_FBS_BUF_MAXLEN ((DEF_ECN_FBS_LNK_LEN / sizeof(void *)) * ECHONET_MEMPOOL_BLOCK_SIZE + DEF_ECN_FBS_FST_DAT_LEN)
-
-/* å­è¦ç´ ãããã¡ã®ãµã¤ãº */
-#define DEF_ECN_FBS_SUB_BUF_LEN ECHONET_MEMPOOL_BLOCK_SIZE
-
-/* ãªã³ã¯ãã¤ã³ã¿é
-åã«åæããããå­è¦ç´ ãããã¡ */
-typedef struct {
-	uint8_t	payload[ECHONET_MEMPOOL_BLOCK_SIZE];
-} T_ECN_SUB_BLK;
-
-/* ãªã³ã¯ãã¤ã³ã¿é
-å */
-typedef union {
-	T_ECN_SUB_BLK	*p_sub[DEF_ECN_FBS_LNK_LEN / sizeof(T_ECN_SUB_BLK *)];
-	uint8_t			bin[DEF_ECN_FBS_LNK_LEN];
-} T_ECN_FBS_LNK;
-
-/* ç®¡çé å(64byte - sizeof(T_MSG)) */
-typedef struct {
-	uint16_t	length;			/* ã¡ãã»ã¼ã¸é· */
-	uint16_t	type;			/* ã¡ãã»ã¼ã¸ã¿ã¤ã */
-	union {
-		ID mbxid;				/* éä¿¡å
-ã¡ã¼ã«ããã¯ã¹IDï¼å
-é¨ã¡ãã»ã¼ã¸ï¼ */
-	}sender;
-	union {
-		ID mbxid;				/* éä¿¡å
-ã¡ã¼ã«ããã¯ã¹IDï¼å
-é¨ã¡ãã»ã¼ã¸ï¼ */
-	}target;
-	union {
-		ID mbxid;				/* è¿ä¿¡å
-ã¡ã¼ã«ããã¯ã¹IDï¼å
-é¨ã¡ãã»ã¼ã¸ï¼ */
-	}reply;
-
-	int			rd;				/*	èª­ã¿åããããæ
-å ±	*/
-	int			wr;				/*	æ¸ãè¾¼ã¿ãããæ
-å ±	*/
-} T_ECN_FBS_HDR;
-
-/* ç®¡çé åãå«ããã­ãã¯ã®æ§é  */
-typedef struct {
-	uint8_t	_msg[DEF_ECN_EDT_HDR_LEN];	/* T_MSG */
-	T_ECN_FBS_HDR	hdr;	/*	ç®¡çé å  64byte  - sizeof(T_MSG)	*/
-	uint8_t			_gap[DEF_ECN_FBS_LIB_HDR_LEN - sizeof(T_ECN_FBS_HDR)];
-	T_ECN_FBS_LNK	lnk;	/*	ãªã³ã¯ãã¤ã³ã¿é
-å	128byte			*/
-	uint8_t			payload[DEF_ECN_FBS_FST_DAT_LEN];
-} T_ECN_FST_BLK;
-
-/* FBS-ID */
-typedef struct ecn_fbs_id_strc {
-	T_ECN_FST_BLK	*ptr;
-} ECN_FBS_ID;
-
-ER _ecn_fbs_cre(size_t fa_req_size, ECN_FBS_ID *fp_id);
-ER _ecn_fbs_del(ECN_FBS_ID fa_id);
-size_t _ecn_fbs_get_datalen(ECN_FBS_ID fa_id);
-int _ecn_fbs_peek(ECN_FBS_ID fa_id, size_t fa_seek);
-ER _ecn_fbs_poke(ECN_FBS_ID fa_id, size_t fa_seek, int fa_val);
-
-extern ID ecn_api_mailboxid;
-extern ID WEBSOCKET_MBXID;
+extern ID ws_api_mailboxid;
 
 typedef struct ws_state
@@ -168,5 +89,5 @@
 	ws_state_t wstate;
 	ws_state_t rstate;
-	ECN_FBS_ID cur_in_msg;
+	WS_FBS_ID cur_in_msg;
 };
 
@@ -179,3 +100,5 @@
 int websocket_output(struct websocket *ws, void *data, int len);
 
+#endif /* TOPPERS_MACRO_ONLY */
+
 #endif  /* WEBSOCKET_H */
Index: /EcnlProtoTool/trunk/ntshell/webserver/websocket_fbs.c
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/websocket_fbs.c	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/webserver/websocket_fbs.c	(revision 279)
@@ -0,0 +1,455 @@
+/*
+ *  TOPPERS WEBSOCKET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2017 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * åºå®é·ãããã¡å¯å¤é·ã¹ããªã¼ã 
+ */
+
+#include <kernel.h>
+#include <string.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include "kernel_cfg.h"
+#include "websocket_fbs.h"
+
+static ER get_message(T_WS_FST_BLK **ppk_msg, int size)
+{
+	void * blk;
+	ER ret;
+
+	*ppk_msg = NULL;
+
+	if ((size <= 0) || (size > DEF_WS_FBS_BUF_MAXLEN))
+		return E_PAR;
+
+	ret = tget_mpf(ws_mempoolid, &blk, WEBSOCKET_MEMPOOL_GET_TMO);
+	if (ret != E_OK)
+		return ret;
+
+	memset(blk, 0, WEBSOCKET_MEMPOOL_BLOCK_SIZE);
+	*ppk_msg = (T_WS_FST_BLK *)(blk);
+	(*ppk_msg)->hdr.length = (uint16_t)size;
+
+	return E_OK;
+}
+
+static ER iget_message(T_WS_FST_BLK **ppk_msg, int size)
+{
+	void * blk;
+	ER ret;
+
+	*ppk_msg = NULL;
+
+	if ((size <= 0) || (size > DEF_WS_FBS_BUF_MAXLEN))
+		return E_PAR;
+
+	ret = pget_mpf(ws_mempoolid, &blk);
+	if (ret != E_OK)
+		return ret;
+
+	memset(blk, 0, WEBSOCKET_MEMPOOL_BLOCK_SIZE);
+	*ppk_msg = (T_WS_FST_BLK *)(blk);
+	(*ppk_msg)->hdr.length = (uint16_t)size;
+
+	return E_OK;
+}
+
+static void *get_block(T_WS_FST_BLK *pk_msg, int pos, bool_t exp, int *size)
+{
+	ER ret;
+	void * buf;
+	void * blk;
+	int no;
+	T_WS_SUB_BLK *mblk;
+	int temp;
+
+	if ((pos < 0) || (!exp && (pos >= pk_msg->hdr.length))) {
+		return NULL;
+	}
+
+	if (pos < DEF_WS_FBS_FST_DAT_LEN) {
+		buf = (void *)&pk_msg->payload[pos];
+		temp = DEF_WS_FBS_FST_DAT_LEN - pos;
+		if (temp < *size) {
+			*size = temp;
+		}
+	}
+	else {
+		pos -= DEF_WS_FBS_FST_DAT_LEN;
+		no = pos / DEF_WS_FBS_SUB_BUF_LEN;
+
+		mblk = pk_msg->lnk.p_sub[no];
+
+		pos -= no * DEF_WS_FBS_SUB_BUF_LEN;
+		temp = DEF_WS_FBS_SUB_BUF_LEN - pos;
+		if (temp < *size) {
+			*size = temp;
+		}
+		if (exp) {
+			if (mblk == NULL) {
+				ret = get_mpf(ws_mempoolid, &blk);
+				if (ret != E_OK)
+					return NULL;
+
+				mblk = (T_WS_SUB_BLK *)(blk);
+
+				pk_msg->lnk.p_sub[no] = mblk;
+			}
+
+			temp = pos + *size + no * DEF_WS_FBS_SUB_BUF_LEN + DEF_WS_FBS_FST_DAT_LEN;
+			if (pk_msg->hdr.length < temp) {
+				pk_msg->hdr.length = (uint16_t)temp;
+			}
+		}
+
+		buf = &mblk->payload[pos];
+	}
+
+	return buf;
+}
+
+static ER release_message(T_WS_FST_BLK *pk_msg)
+{
+	ER ret;
+	int i;
+
+	for (i = 0; i < 32; i++) {
+		void * blk = pk_msg->lnk.p_sub[i];
+		if (blk == NULL)
+			continue;
+
+		ret = rel_mpf(ws_mempoolid, blk);
+		if (ret != E_OK)
+			return ret;
+	}
+
+	return rel_mpf(ws_mempoolid, pk_msg);
+}
+
+static int read_message(T_WS_FST_BLK *pk_msg, int pos, void * dst, int size)
+{
+	int len, rest = size;
+	void * buf;
+
+	if (size <= 0)
+		return 0;
+
+	len = rest;
+	buf = get_block(pk_msg, pos, false, &len);
+	if ((buf == NULL) || (len <= 0))
+		return 0;
+
+	if((pos + len) > pk_msg->hdr.length)
+		len = pk_msg->hdr.length - pos;
+
+	for (; ; ) {
+		memcpy(dst, buf, len);
+		dst = (void *)((intptr_t)dst + len);
+		rest -= len;
+		pos += len;
+
+		if (rest <= 0)
+			break;
+
+		len = rest;
+		buf = get_block(pk_msg, pos, false, &len);
+		if ((buf == NULL) || (len <= 0))
+			return size - rest;
+	}
+
+	return size;
+}
+
+static int write_message(const void * src, T_WS_FST_BLK *pk_msg, int pos, int size)
+{
+	int len, rest = size;
+	void * buf;
+
+	if (size <= 0)
+		return 0;
+
+	len = rest;
+	buf = get_block(pk_msg, pos, true, &len);
+	if ((buf == NULL) || (len <= 0))
+		return 0;
+
+	for (; ; ) {
+		memcpy(buf, src, len);
+		src = (void *)((intptr_t)src +len);
+		rest -= len;
+		pos += len;
+
+		if (rest <= 0)
+			break;
+
+		len = rest;
+		buf = get_block(pk_msg, pos, true, &len);
+		if ((buf == NULL) || (len <= 0))
+			return size - rest;
+	}
+
+	if (pk_msg->hdr.length < pos)
+		pk_msg->hdr.length = (uint16_t)pos;
+
+	return size;
+}
+
+static int copy_message(T_WS_FST_BLK *pk_src, int spos, T_WS_FST_BLK *pk_dst, int dpos, int size)
+{
+	int dlen, slen, len, rest = size;
+	void * dbuf, *sbuf;
+
+	if (size <= 0)
+		return 0;
+
+	dlen = rest;
+	dbuf = get_block(pk_dst, dpos, true, &dlen);
+	if (dbuf == NULL)
+		return 0;
+
+	slen = rest;
+	sbuf = get_block(pk_src, spos, false, &slen);
+	if (sbuf == NULL)
+		return 0;
+
+	for (; ; ) {
+		len = (dlen < slen) ? dlen : slen;
+
+		if (len == 0)
+			return size - rest;
+
+		memcpy(dbuf, sbuf, len);
+
+		dpos += len;
+		spos += len;
+		rest -= len;
+
+		if (rest <= 0)
+			break;
+
+		dlen = rest;
+		dbuf = get_block(pk_dst, dpos, true, &dlen);
+		if (dbuf == NULL)
+			return size - rest;
+
+		slen = rest;
+		sbuf = get_block(pk_src, spos, false, &slen);
+		if (sbuf == NULL)
+			return size - rest;
+	}
+
+	return size;
+}
+
+/* ã¡ã¢ãªãã­ãã¯åå¾ ok:ãã¤ã³ã¿ NG:NULL */
+void *_ws_fbs_mbx_get(WS_FBS_SIZE_T fa_req_size)
+{
+	void *result;
+	ER ret;
+
+	if ((fa_req_size <= 0) || (fa_req_size > WEBSOCKET_MEMPOOL_BLOCK_SIZE))
+		return NULL;
+
+	ret = get_mpf(ws_mempoolid, &result);
+	if (ret != E_OK)
+		return NULL;
+
+	memset(result, 0, WEBSOCKET_MEMPOOL_BLOCK_SIZE);
+
+	return result;
+}
+
+/* ã¡ã¢ãªãã­ãã¯è§£æ¾ */
+ER _ws_fbs_mbx_rel(void *p)
+{
+	return rel_mpf(ws_mempoolid, p);
+}
+
+/* é åç¢ºä¿ */
+ER _ws_fbs_cre(WS_FBS_SIZE_T fa_req_size, WS_FBS_ID *fp_id)
+{
+	return get_message(&fp_id->ptr, fa_req_size);
+}
+
+/* é åè§£æ¾ */
+ER _ws_fbs_del(WS_FBS_ID fa_id)
+{
+	return release_message(fa_id.ptr);
+}
+
+/* ä¿æãã¼ã¿ã®æç¡ */
+bool_t _ws_fbs_exist_data(WS_FBS_ID fa_id)
+{
+	return fa_id.ptr->hdr.length > fa_id.ptr->hdr.wr;
+}
+
+/* ä¿æãã¼ã¿é·ã®åå¾ */
+WS_FBS_SSIZE_T _ws_fbs_get_datalen(WS_FBS_ID fa_id)
+{
+	return fa_id.ptr->hdr.length;
+}
+
+/* èª­ã¿åãã«ã¼ã½ã«ã®ä½ç½®åå¾ */
+WS_FBS_SSIZE_T _ws_fbs_get_rpos(WS_FBS_ID fa_id)
+{
+	return fa_id.ptr->hdr.rd;
+}
+
+/* èª­ã¿åãã«ã¼ã½ã«ã®ä½ç½®è¨­å® */
+ER _ws_fbs_set_rpos(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_pos)
+{
+	if (fa_id.ptr->hdr.length <= (unsigned int)fa_pos)	/* ä½ç½®æå®ãå¤§ãããã */
+		return E_PAR;
+
+	fa_id.ptr->hdr.rd = fa_pos;
+
+	return E_OK;
+}
+
+/* èª­ã¿åãã«ã¼ã½ã«ã®ä½ç½®ç§»å */
+ER _ws_fbs_seek_rpos(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_seek)
+{
+	fa_id.ptr->hdr.rd += fa_seek;
+	if (fa_id.ptr->hdr.rd > fa_id.ptr->hdr.length)
+		fa_id.ptr->hdr.rd = fa_id.ptr->hdr.length;
+
+	return E_OK;
+}
+
+/* ä»»ææå®ä½ç½®ã®1byteèª­ã¿åã */
+int _ws_fbs_peek(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_seek)
+{
+	uint8_t result = 0;
+	int ret;
+
+	ret = read_message(fa_id.ptr, fa_seek, &result, 1);
+
+	return (ret == 1) ? result : -1;
+}
+
+/* ä»»ææå®ä½ç½®ã®1byteæ¸ãè¾¼ã¿ */
+ER _ws_fbs_poke(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_seek, int fa_val)
+{
+	uint8_t result = fa_val;
+	int ret;
+
+	ret = write_message(&result, fa_id.ptr, fa_seek, 1);
+
+	return (ret == 1) ? E_OK : E_PAR;
+}
+
+/* ãã¼ã¿è¿½å  */
+ER _ws_fbs_add_data(WS_FBS_ID fa_id, const void *fa_dat, WS_FBS_SSIZE_T fa_len)
+{
+	if((fa_id.ptr->hdr.wr + fa_len) > fa_id.ptr->hdr.length)
+		return E_PAR;
+
+	fa_id.ptr->hdr.wr += write_message(fa_dat, fa_id.ptr, fa_id.ptr->hdr.wr, fa_len);
+	return E_OK;
+}
+
+/* ãã¼ã¿è¿½å (é åãèªåçã«æ¡å¼µãã) */
+ER _ws_fbs_add_data_ex(WS_FBS_ID fa_id, const void *fa_dat, WS_FBS_SSIZE_T fa_len)
+{
+	fa_id.ptr->hdr.wr += write_message(fa_dat, fa_id.ptr, fa_id.ptr->hdr.wr, fa_len);
+	return E_OK;
+}
+
+/* ãã¼ã¿åå¾ */
+ER _ws_fbs_get_data(WS_FBS_ID fa_id, void *fa_buf, WS_FBS_SSIZE_T fa_maxlen, WS_FBS_SSIZE_T *p_len)
+{
+	int ret;
+	
+	ret = read_message(fa_id.ptr, fa_id.ptr->hdr.rd, fa_buf, fa_maxlen);
+	fa_id.ptr->hdr.rd += ret;
+	*p_len = ret;
+
+	return E_OK;
+}
+
+ER ws_fbs_enqueue(T_WS_FBS_QUEUE *pk_queue, T_WS_FST_BLK *pk_buf)
+{
+	loc_cpu();
+
+	*((T_WS_FST_BLK **)pk_buf->_msg) = NULL;
+	if (pk_queue->pk_head != NULL) {
+		*((T_WS_FST_BLK **)pk_queue->pk_last->_msg) = pk_buf;
+	}
+	else {
+		pk_queue->pk_head = pk_buf;
+	}
+	pk_queue->pk_last = pk_buf;
+
+	unl_cpu();
+
+	return E_OK;
+}
+
+ER ws_fbs_dequeue(T_WS_FBS_QUEUE *pk_queue, T_WS_FST_BLK **ppk_buf)
+{
+	ER ercd;
+
+	loc_cpu();
+
+	if (pk_queue->pk_head != NULL) {
+		*ppk_buf = pk_queue->pk_head;
+		pk_queue->pk_head = *((T_WS_FST_BLK **)(*ppk_buf)->_msg);
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+
+	unl_cpu();
+
+	return ercd;
+}
Index: /EcnlProtoTool/trunk/ntshell/webserver/websocket_fbs.h
===================================================================
--- /EcnlProtoTool/trunk/ntshell/webserver/websocket_fbs.h	(revision 279)
+++ /EcnlProtoTool/trunk/ntshell/webserver/websocket_fbs.h	(revision 279)
@@ -0,0 +1,308 @@
+/*
+ *  TOPPERS WEBSOCKET Lite Communication Middleware
+ * 
+ *  Copyright (C) 2017 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * åºå®é·ãããã¡å¯å¤é·ã¹ããªã¼ã 
+ */
+
+#ifndef _WEBSOCKET_FBS_H_
+#define _WEBSOCKET_FBS_H_
+
+#include <kernel.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef WEBSOCKET_MEMPOOL_GET_TMO
+#define WEBSOCKET_MEMPOOL_GET_TMO	(0)			/* ã¡ã¢ãªãã¼ã«åå¾æã®ã¿ã¤ã ã¢ã¦ãæå® */
+#endif /* WEBSOCKET_MEMPOOL_GET_TMO */
+
+#ifndef NUM_WEBSOCKET_MEMPOOL_BLOCK
+#define NUM_WEBSOCKET_MEMPOOL_BLOCK (60)		/* é»æç¨ã¡ã¢ãªãã­ãã¯ã®æ° */
+#endif /* NUM_WEBSOCKET_MEMPOOL_BLOCK */
+
+#ifndef WEBSOCKET_MEMPOOL_BLOCK_SIZE
+#define WEBSOCKET_MEMPOOL_BLOCK_SIZE (256)	/* é»æç¨ã¡ã¢ãªãã­ãã¯ã®ãµã¤ãº */
+#endif /* WEBSOCKET_MEMPOOL_BLOCK_SIZE */
+
+typedef unsigned int WS_FBS_SIZE_T;	/* size_tç¸å½  */
+typedef int WS_FBS_SSIZE_T;			/* ssize_tç¸å½ */
+
+/* T_WS_FST_BLKç®¡çé åãµã¤ãº */
+#define DEF_WS_EDT_HDR_LEN (sizeof(intptr_t))
+
+/* ç®¡çé åãµã¤ãº(64byte - sizeof(T_MSG)) */
+/* #define DEF_WS_FBS_LIB_HDR_LEN ((WEBSOCKET_MEMPOOL_BLOCK_SIZE + sizeof(int) - 1)>> 2) // */
+#define DEF_WS_FBS_LIB_HDR_LEN (64 - DEF_WS_EDT_HDR_LEN)
+
+/* ç®¡çé åãå«ããã­ãã¯ã«ä¿æãããã¼ã¿ãµã¤ãº */
+#define DEF_WS_FBS_FST_DAT_LEN (64)
+
+/* ãªã³ã¯ãã¤ã³ã¿é
+åã®ãµã¤ãº(byte) */
+#define DEF_WS_FBS_LNK_LEN (WEBSOCKET_MEMPOOL_BLOCK_SIZE - DEF_WS_EDT_HDR_LEN - DEF_WS_FBS_LIB_HDR_LEN - DEF_WS_FBS_FST_DAT_LEN)
+
+/* åºå®é·ãããã¡æå¤§ãµã¤ãº */
+#define DEF_WS_FBS_BUF_MAXLEN ((DEF_WS_FBS_LNK_LEN / sizeof(void *)) * WEBSOCKET_MEMPOOL_BLOCK_SIZE + DEF_WS_FBS_FST_DAT_LEN)
+
+/* å­è¦ç´ ãããã¡ã®ãµã¤ãº */
+#define DEF_WS_FBS_SUB_BUF_LEN WEBSOCKET_MEMPOOL_BLOCK_SIZE
+
+/* é»æã®ç¨®å¥(å
+å®¹ã¯ä»®) */
+typedef enum
+{
+	WS_FBS_TYPE_BLANK		=	0,		/* æªä½¿ç¨ã¹ããªã¼ã  */
+	WS_FBS_TYPE_INTERNAL	=	1,		/* å
+é¨ã¡ãã»ã¼ã¸ */
+	WS_FBS_TYPE_WEBSOCKET	=	2		/* WEBSOCKETé»æ */
+} TA_WS_MSG_TYPE;
+
+/* ãªã³ã¯ãã¤ã³ã¿é
+åã«åæããããå­è¦ç´ ãããã¡ */
+typedef struct
+{
+	uint8_t	payload[WEBSOCKET_MEMPOOL_BLOCK_SIZE];
+} T_WS_SUB_BLK;
+
+/* ãªã³ã¯ãã¤ã³ã¿é
+å */
+typedef union
+{
+	T_WS_SUB_BLK	*p_sub[DEF_WS_FBS_LNK_LEN / sizeof(T_WS_SUB_BLK *)];
+	uint8_t			bin[DEF_WS_FBS_LNK_LEN];
+} T_WS_FBS_LNK;
+
+/* ç®¡çé å(64byte - sizeof(T_MSG)) */
+typedef struct
+{
+	uint16_t	length;			/* ã¡ãã»ã¼ã¸é· */
+	uint16_t	type;			/* ã¡ãã»ã¼ã¸ã¿ã¤ã */
+	union{
+		ID mbxid;				/* éä¿¡å
+ã¡ã¼ã«ããã¯ã¹IDï¼å
+é¨ã¡ãã»ã¼ã¸ï¼ */
+	}sender;
+	union{
+		ID mbxid;				/* éä¿¡å
+ã¡ã¼ã«ããã¯ã¹IDï¼å
+é¨ã¡ãã»ã¼ã¸ï¼ */
+	}target;
+	union{
+		ID mbxid;				/* è¿ä¿¡å
+ã¡ã¼ã«ããã¯ã¹IDï¼å
+é¨ã¡ãã»ã¼ã¸ï¼ */
+	}reply;
+
+	int			rd;				/*	èª­ã¿åããããæ
+å ±	*/
+	int			wr;				/*	æ¸ãè¾¼ã¿ãããæ
+å ±	*/
+} T_WS_FBS_HDR;
+
+/* ç®¡çé åãå«ããã­ãã¯ã®æ§é  */
+typedef struct
+{
+	uint8_t	_msg[DEF_WS_EDT_HDR_LEN];	/* T_MSG */
+	T_WS_FBS_HDR	hdr;	/*	ç®¡çé å  64byte  - sizeof(T_MSG)	*/
+	uint8_t			_gap[DEF_WS_FBS_LIB_HDR_LEN - sizeof(T_WS_FBS_HDR)];
+	T_WS_FBS_LNK	lnk;	/*	ãªã³ã¯ãã¤ã³ã¿é
+å	128byte			*/
+	uint8_t			payload[DEF_WS_FBS_FST_DAT_LEN];
+} T_WS_FST_BLK;
+
+/* FBS-ID */
+typedef struct ws_fbs_id_strc
+{
+	T_WS_FST_BLK	*ptr;
+} WS_FBS_ID;
+
+/* ã¡ãã»ã¼ã¸ã­ã¥ã¼ */
+typedef struct ws_fbs_queue
+{
+	T_WS_FST_BLK	*pk_head;		/* å
+é ­ã®ã¡ãã»ã¼ã¸ */
+	T_WS_FST_BLK	*pk_last;		/* æ«å°¾ã®ã¡ãã»ã¼ã¸ */
+} T_WS_FBS_QUEUE;
+
+extern ID ws_mempoolid;
+
+/* ã¡ã¢ãªãã­ãã¯åå¾ ok:ãã¤ã³ã¿ NG:NULL */
+void *_ws_fbs_mbx_get(WS_FBS_SIZE_T fa_req_size);
+
+/* ã¡ã¢ãªãã­ãã¯è§£æ¾ ok:0 NG:é0 */
+ER _ws_fbs_mbx_rel(void *p);
+
+/*
+ * é åç¢ºä¿
+ *	å¼æ°
+ *		WS_FBS_SIZE_T	fa_req_size		è¦æ±ãããã¡ãµã¤ãº(byte)
+ *										max: DEF_WS_FBS_BUF_MAXLEN
+ *		WS_FBS_ID		*fp_id			ç¢ºä¿ããFBS-IDã®æ ¼ç´å
+
+ *	æ»ãå¤
+ *		ER				0:ok é0:NG
+ */
+ER _ws_fbs_cre(WS_FBS_SIZE_T fa_req_size, WS_FBS_ID *fp_id);
+
+/*
+ * é åè§£æ¾
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *	æ»ãå¤
+ *		ER				0:ok, é0:NG
+ */
+ER _ws_fbs_del(WS_FBS_ID fa_id);
+
+/*
+ * ä¿æãã¼ã¿ã®æç¡
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *	æ»ãå¤
+ *		bool_t			0:ç¡ã, 1:ãã
+ */
+bool_t _ws_fbs_exist_data(WS_FBS_ID fa_id);
+
+/*
+ * ä¿æãã¼ã¿é·ã®åå¾
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *	æ»ãå¤
+ *		WS_FBS_SSIZE_T	ä¿æãã¦ãããã¼ã¿ã®é·ã(byte) -1:NG
+ */
+WS_FBS_SSIZE_T _ws_fbs_get_datalen(WS_FBS_ID fa_id);
+
+/*
+ * èª­ã¿åãã«ã¼ã½ã«ã®ä½ç½®åå¾
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *	æ»ãå¤
+ *		WS_FBS_SIZE_T	å
+é ­ããã®çµ¶å¯¾ä½ç½® -1:NG
+ */
+WS_FBS_SSIZE_T _ws_fbs_get_rpos(WS_FBS_ID fa_id);
+
+/*
+ * èª­ã¿åãã«ã¼ã½ã«ã®ä½ç½®è¨­å®
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *		WS_FBS_SIZE_T	fa_pos	è¨­å®ããä½ç½®(å
+é ­ããã®çµ¶å¯¾ä½ç½®)
+ *	æ»ãå¤
+ *		ER				0:ok, é0:NG
+ */
+ER _ws_fbs_set_rpos(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_pos);
+
+/*
+ * èª­ã¿åãã«ã¼ã½ã«ã®ä½ç½®ç§»å
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *		WS_FBS_SIZE_T	fa_seek	ç§»åé(ç¾ç¶ãåé²ã®ã¿)
+ *	æ»ãå¤
+ *		ER				0:ok, é0:NG
+ */
+ER _ws_fbs_seek_rpos(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_seek);
+
+/*
+ * ä»»ææå®ä½ç½®ã®1byteèª­ã¿åã
+ */
+int _ws_fbs_peek(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_seek);
+
+/*
+ * ä»»ææå®ä½ç½®ã®1byteæ¸ãè¾¼ã¿
+ */
+ER _ws_fbs_poke(WS_FBS_ID fa_id, WS_FBS_SSIZE_T fa_seek, int fa_val);
+
+/*
+ * ãã¼ã¿è¿½å 
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *		const void *	fa_dat	è¿½å ãããã¼ã¿
+ *		WS_FBS_SSIZE_T	fa_len	è¿½å ããé·ã(byte)
+ *	æ»ãå¤
+ *		ER				0:ok, é0:NG
+ */
+ER _ws_fbs_add_data(WS_FBS_ID fa_id, const void *fa_dat, WS_FBS_SSIZE_T fa_len);
+
+/*
+ * ãã¼ã¿è¿½å (é åãèªåçã«æ¡å¼µãã)
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *		const void *	fa_dat	è¿½å ãããã¼ã¿
+ *		WS_FBS_SSIZE_T	fa_len	è¿½å ããé·ã(byte)
+ *	æ»ãå¤
+ *		ER				0:ok, é0:NG
+ */
+ER _ws_fbs_add_data_ex(WS_FBS_ID fa_id, const void *fa_dat, WS_FBS_SSIZE_T fa_len);
+
+/*
+ * ãã¼ã¿åå¾
+ *	å¼æ°
+ *		ws_fbs_idå	ç¢ºä¿ããFBS-ID
+ *		void *			fa_buf		åå¾ãããããã¡
+ *		WS_FBS_SSIZE_T	fa_maxlen	åå¾ããé·ã(byte)
+ *		WS_FBS_SSIZE_T	*p_len		åå¾ããé·ã(byte)
+ *	æ»ãå¤
+ *		ER				0:ok, é0:NG
+ */
+ER _ws_fbs_get_data(WS_FBS_ID fa_id, void *fa_buf, WS_FBS_SSIZE_T fa_maxlen,
+	WS_FBS_SSIZE_T *p_len);
+
+ER ws_fbs_enqueue(T_WS_FBS_QUEUE *pk_queue, T_WS_FST_BLK *pk_buf);
+ER ws_fbs_dequeue(T_WS_FBS_QUEUE *pk_queue, T_WS_FST_BLK **ppk_buf);
+
+#ifdef __cplusplus
+}   /* extern "C" */
+#endif
+
+#endif /* #ifndef _WEBSOCKET_FBS_H_ */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/.cproject
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/.cproject	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/.cproject	(revision 279)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.599453217">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.599453217" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactExtension="a" artifactName="onigmo" buildArtefactType="com.renesas.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=com.renesas.cdt.build.core.buildArtefactType.staticLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf *.lst *.lis *.lpp *.map" description="" id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.599453217" name="Debug" parent="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id">
+					<folderInfo id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.599453217." name="/" resourcePath="">
+						<toolChain id="com.renesas.cdt.library.rz.debug.win32.toolchain.Id.1686505726" name="KPIT GNUARM-NONE-EABI Toolchain" superClass="com.renesas.cdt.library.rz.debug.win32.toolchain.Id">
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.PE" id="com.renesas.cdt.rz.libraryProject.debug.win32.targetplatform.Id.904923015" name="Target Platform" osList="win32,linux" superClass="com.renesas.cdt.rz.libraryProject.debug.win32.targetplatform.Id"/>
+							<builder buildPath="${workspace_loc:/onigmo}/Debug" id="com.renesas.cdt.rz.library.project.debug.win32.builder.Id.648387239" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.rz.library.project.debug.win32.builder.Id"/>
+							<tool id="com.renesas.cdt.rz.libraryProject.debug.win32.tool.compiler.Id.1403906573" name="Compiler" superClass="com.renesas.cdt.rz.libraryProject.debug.win32.tool.compiler.Id">
+								<option defaultValue="true" id="com.renesas.cdt.core.Compiler.option.misc2.893295126" name="æ¨æºã·ã¹ãã ã»ãã£ã¬ã¯ããªã¼ã§ãããã¼ã»ãã¡ã¤ã«ãæ¤ç´¢ããªã (-nostdinc)" superClass="com.renesas.cdt.core.Compiler.option.misc2" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.dataEndian.830168116" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.dataEndian" value="Little-endian" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.instructionset.181932475" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.instructionset" value="ARM" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.interworking.1734700906" name="ã¤ã³ã¿ã¼ã»ã¯ã¼ã­ã³ã°" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.interworking" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.targetfpu.294263703" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.targetfpu" value="vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.floatingpointabi.1157903482" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.floatingpointabi" value="Hard" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warnStackSize.1359091351" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.core.Compiler.option.warnStackSize" value="100" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.CPUSeries.2092668987" name="CPU ã·ãªã¼ãº" superClass="com.renesas.cdt.core.Compiler.option.CPUSeries" value="RZ/A" valueType="string"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.architecture.2113164712" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.architecture" value="armv7-a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.cpuType.1970460770" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.cpuType" value="cortex-a9" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.stackSizeInDecimal.79407894" name="Decimal representation of '-Wsatck-usage'" superClass="com.renesas.cdt.core.Compiler.option.stackSizeInDecimal" value="256" valueType="string"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Compiler.option.library.macroDefines.614908404" name="ãã¯ã­å®ç¾©" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.macroDefines" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="ONIG_EXTERN=extern"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Compiler.option.includeFileDir.46425275" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Compiler.option.includeFileDir" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src}&quot;"/>
+								</option>
+								<inputType id="%Base.Compiler.C.InputType.Id.884982235" name="C å
+¥å" superClass="%Base.Compiler.C.InputType.Id"/>
+								<inputType id="Base.Compiler.CPP.InputType.Id.468221844" name="C++ å
+¥å" superClass="Base.Compiler.CPP.InputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.library.rz.Debug.win32.tool.assembler.Id.1308609704" name="Assembler" superClass="com.renesas.cdt.library.rz.Debug.win32.tool.assembler.Id">
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.dataEndian.671886442" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.dataEndian" value="Little-endian" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.instructionset.753533557" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.instructionset" value="ARM" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.targetfpu.816721656" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.targetfpu" value="vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.floatingpointabi.631007521" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.floatingpointabi" value="Hard" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.architecture.739518456" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.architecture" value="armv7-a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.cpuType.1106302179" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.cpuType" value="cortex-a9" valueType="enumerated"/>
+								<inputType id="%Base.Assembler.inputType.Id.1061608568" name="ã¢ã»ã³ãã©ã¼å
+¥åã¿ã¤ã" superClass="%Base.Assembler.inputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.library.rz.debug.win32.tool.archive.Id.1640450029" name="Archive Generator" superClass="com.renesas.cdt.library.rz.debug.win32.tool.archive.Id"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="onigmo.com.renesas.cdt.rz.library.projectType.Id.158908142" name="Static Library (Renesas)" projectType="com.renesas.cdt.rz.library.projectType.Id"/>
+	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+	<storageModule moduleId="refreshScope"/>
+</cproject>
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/.info
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/.info	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/.info	(revision 279)
@@ -0,0 +1,7 @@
+TOOL_CHAIN=KPIT GNUARM-NONE-EABI Toolchain
+VERSION=v16.01
+TC_INSTALL=C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\
+GCC_STRING=5.2-GNUARM-NONE_v16.01
+VERSION_IDE=
+E2STUDIO_VERSION=5.3.1.002
+ACTIVE_CONFIGURATION=Debug
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/.project
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/.project	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/.project	(revision 279)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>onigmo-5.15.0</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.renesas.cdt.core.genmakebuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>com.renesas.cdt.core.kpitcnature</nature>
+		<nature>com.renesas.cdt.core.kpitccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/COPYING
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/COPYING	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/COPYING	(revision 279)
@@ -0,0 +1,87 @@
+Onigmo (Oniguruma-mod) LICENSE
+------------------------------
+
+/*-
+ * Copyright (c) 2002-2009  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+
+Oniguruma LICENSE
+-----------------
+
+/*-
+ * Copyright (c) 2002-2009  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+
+Ruby BSDL
+---------
+Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/README
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/README	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/README	(revision 279)
@@ -0,0 +1,249 @@
+README  2014/07/18
+
+Onigmo (Oniguruma-mod)  --  (C) K.Takata <kentkt AT csc DOT jp>
+
+https://github.com/k-takata/Onigmo
+
+Onigmo is a regular expressions library forked from Oniguruma.
+Some of new features introduced in Perl 5.10+ can be used.
+
+Some patches are merged from Ruby 2.x.
+
+See also the Wiki page:
+https://github.com/k-takata/Onigmo/wiki
+
+
+Main New features:
+  Regular Expressions (depends on the syntax):
+    \K, \R, \X, (?(cond)yes|no)
+    (?adlu), \g{name}, \g{n}, (?&name), (?n), (?R), (?0)
+    (?P<name>...), (?P=name), (?P>name)
+
+  API:
+    onig_search_gpos (for Perl-compatible \G)
+
+  Encoding:
+    CP932
+
+  Syntax:
+    Python
+
+
+New Source Files:
+  enc/cp932.c                   CP932 encoding.
+  enc/jis/props.h               JIS character properties data.
+  enc/jis/props.kwd             JIS character properties data.
+  enc/unicode/casefold.h        Unicode case folding data.
+  enc/unicode/name2ctype.h      Unicode properties data.
+
+  onig.py                       onig.dll/libonig.so loader.
+  testpy.py                     test program.
+
+  tool/download-ucd.sh          downloads Unicode Character Database (UCD).
+  tool/case-folding.rb          generates casefold.h from UCD.
+  tool/convert-jis-props.sh     converts props.kwd to props.h.
+  tool/convert-name2ctype.sh    converts name2ctype.kwd to name2ctypes.h.
+  tool/enc-unicode.rb           generates name2ctype.kwd from UCD.
+
+  win32/Makefile.mingw          Makefile for Win32 (MinGW)
+  win32/makedef.py              creates onig.def.
+  win32/onig.rc                 resource file for onig.dll.
+
+
+ToDo:
+  * Reduce the size of Unicode Character Data.
+  * (?|...)
+  * Improve (?(cond)yes|no). (support look-ahead/behind assertions.)
+
+
+Oniguruma's README follows:
+======================================================================
+README  2007/05/31
+
+Oniguruma  ----   (C) K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+
+http://www.geocities.jp/kosako3/oniguruma/
+
+Oniguruma is a regular expressions library.
+The characteristics of this library is that different character encoding
+for every regular expression object can be specified.
+
+Supported character encodings:
+
+  ASCII, UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE,
+  EUC-JP, EUC-TW, EUC-KR, EUC-CN,
+  Shift_JIS, Big5, GB18030, KOI8-R, CP1251,
+  ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5,
+  ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10,
+  ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16
+
+* GB18030: contributed by KUBO Takehiro
+* CP1251:  contributed by Byte
+------------------------------------------------------------
+
+License
+
+   BSD license.
+
+
+Install
+
+ Case 1: Unix and Cygwin platform
+
+   1. ./configure
+   2. make
+   3. make install
+
+   * uninstall
+
+     make uninstall
+
+   * test (ASCII/EUC-JP)
+
+     make atest
+
+   * configuration check
+
+     onig-config --cflags
+     onig-config --libs
+     onig-config --prefix
+     onig-config --exec-prefix
+
+
+
+ Case 2: Win32 platform (VC++)
+
+   1. copy win32\Makefile Makefile
+   2. copy win32\config.h config.h
+   3. nmake
+
+      onig_s.lib:  static link library
+      onig.dll:    dynamic link library
+
+  * test (ASCII/Shift_JIS)
+   4. copy win32\testc.c testc.c
+   5. nmake ctest
+
+
+
+Regular Expressions
+
+  See doc/RE (or doc/RE.ja for Japanese).
+
+
+Usage
+
+  Include oniguruma.h in your program. (Oniguruma API)
+  See doc/API for Oniguruma API.
+
+  If you want to disable UChar type (== unsigned char) definition
+  in oniguruma.h, define ONIG_ESCAPE_UCHAR_COLLISION and then
+  include oniguruma.h.
+
+  If you want to disable regex_t type definition in oniguruma.h,
+  define ONIG_ESCAPE_REGEX_T_COLLISION and then include oniguruma.h.
+
+  Example of the compiling/linking command line in Unix or Cygwin,
+  (prefix == /usr/local case)
+
+    cc sample.c -L/usr/local/lib -lonig
+
+
+  If you want to use static link library(onig_s.lib) in Win32,
+  add option -DONIG_EXTERN=extern to C compiler.
+
+
+
+Sample Programs
+
+  sample/simple.c    example of the minimum (Oniguruma API)
+  sample/names.c     example of the named group callback.
+  sample/encode.c    example of some encodings.
+  sample/listcap.c   example of the capture history.
+  sample/posix.c     POSIX API sample.
+  sample/sql.c       example of the variable meta characters.
+                     (SQL-like pattern matching)
+
+Test Programs
+  sample/syntax.c    Perl, Java and ASIS syntax test.
+  sample/crnl.c      --enable-crnl-as-line-terminator test
+
+
+Source Files
+
+  oniguruma.h        Oniguruma API header file. (public)
+  onig-config.in     configuration check program template.
+
+  regenc.h           character encodings framework header file.
+  regint.h           internal definitions
+  regparse.h         internal definitions for regparse.c and regcomp.c
+  regcomp.c          compiling and optimization functions
+  regenc.c           character encodings framework.
+  regerror.c         error message function
+  regext.c           extended API functions. (deluxe version API)
+  regexec.c          search and match functions
+  regparse.c         parsing functions.
+  regsyntax.c        pattern syntax functions and built-in syntax definitions.
+  regtrav.c          capture history tree data traverse functions.
+  regversion.c       version info function.
+  st.h               hash table functions header file
+  st.c               hash table functions
+
+  oniggnu.h          GNU regex API header file. (public)
+  reggnu.c           GNU regex API functions
+
+  onigposix.h        POSIX API header file. (public)
+  regposerr.c        POSIX error message function.
+  regposix.c         POSIX API functions.
+
+  enc/mktable.c      character type table generator.
+  enc/ascii.c        ASCII encoding.
+  enc/euc_jp.c       EUC-JP encoding.
+  enc/euc_tw.c       EUC-TW encoding.
+  enc/euc_kr.c       EUC-KR, EUC-CN encoding.
+  enc/sjis.c         Shift_JIS encoding.
+  enc/big5.c         Big5      encoding.
+  enc/gb18030.c      GB18030   encoding.
+  enc/koi8.c         KOI8      encoding.
+  enc/koi8_r.c       KOI8-R    encoding.
+  enc/cp1251.c       CP1251    encoding.
+  enc/iso8859_1.c    ISO-8859-1  encoding. (Latin-1)
+  enc/iso8859_2.c    ISO-8859-2  encoding. (Latin-2)
+  enc/iso8859_3.c    ISO-8859-3  encoding. (Latin-3)
+  enc/iso8859_4.c    ISO-8859-4  encoding. (Latin-4)
+  enc/iso8859_5.c    ISO-8859-5  encoding. (Cyrillic)
+  enc/iso8859_6.c    ISO-8859-6  encoding. (Arabic)
+  enc/iso8859_7.c    ISO-8859-7  encoding. (Greek)
+  enc/iso8859_8.c    ISO-8859-8  encoding. (Hebrew)
+  enc/iso8859_9.c    ISO-8859-9  encoding. (Latin-5 or Turkish)
+  enc/iso8859_10.c   ISO-8859-10 encoding. (Latin-6 or Nordic)
+  enc/iso8859_11.c   ISO-8859-11 encoding. (Thai)
+  enc/iso8859_13.c   ISO-8859-13 encoding. (Latin-7 or Baltic Rim)
+  enc/iso8859_14.c   ISO-8859-14 encoding. (Latin-8 or Celtic)
+  enc/iso8859_15.c   ISO-8859-15 encoding. (Latin-9 or West European with Euro)
+  enc/iso8859_16.c   ISO-8859-16 encoding.
+                     (Latin-10 or South-Eastern European with Euro)
+  enc/utf8.c         UTF-8    encoding.
+  enc/utf16_be.c     UTF-16BE encoding.
+  enc/utf16_le.c     UTF-16LE encoding.
+  enc/utf32_be.c     UTF-32BE encoding.
+  enc/utf32_le.c     UTF-32LE encoding.
+  enc/unicode.c      Unicode information data.
+
+  win32/Makefile     Makefile for Win32 (VC++)
+  win32/config.h     config.h for Win32
+
+
+
+ToDo
+
+  ? case fold flag: Katakana <-> Hiragana.
+  ? add ONIG_OPTION_NOTBOS/NOTEOS. (\A, \z, \Z)
+ ?? \X (== \PM\pM*)
+ ?? implement syntax behavior ONIG_SYN_CONTEXT_INDEP_ANCHORS.
+ ?? transmission stopper. (return ONIG_STOP from match_at())
+
+and I'm thankful to Akinori MUSHA.
+
+
+Mail Address: K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/config.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/config.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/config.h	(revision 279)
@@ -0,0 +1,137 @@
+/* config.h.in.  Generated from configure.in by autoheader.  */
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#define HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#define HAVE_LIBPTHREAD
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H
+
+/* Define if compilerr supports prototypes */
+#define HAVE_PROTOTYPES
+
+/* Define to 1 if you have the <pthread.h> header file. */
+#define HAVE_PTHREAD_H
+
+/* Define if compiler supports stdarg prototypes */
+#define HAVE_STDARG_PROTOTYPES
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/times.h> header file. */
+#define HAVE_SYS_TIMES_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#undef LT_OBJDIR
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of `int', as computed by sizeof. */
+#undef SIZEOF_INT
+#define SIZEOF_INT sizeof(int)
+
+/* The size of `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+#define SIZEOF_LONG sizeof(long)
+
+/* The size of `short', as computed by sizeof. */
+#undef SIZEOF_SHORT
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define if combination explosion check */
+#undef USE_COMBINATION_EXPLOSION_CHECK
+
+/* Define if enable CR+NL as line terminator */
+#undef USE_CRNL_AS_LINE_TERMINATOR
+
+/* Define if enable the default multithread system */
+#undef USE_DEFAULT_MULTI_THREAD_SYSTEM
+
+/* Define if enbale multithread support */
+#undef USE_MULTI_THREAD_SYSTEM
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/ascii.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/ascii.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/ascii.c	(revision 279)
@@ -0,0 +1,51 @@
+/**********************************************************************
+  ascii.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2006  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regenc.h"
+
+OnigEncodingType OnigEncodingASCII = {
+  onigenc_single_byte_mbc_enc_len,
+  "US-ASCII",  /* name */
+  1,           /* max byte length */
+  1,           /* min byte length */
+  onigenc_is_mbc_newline_0x0a,
+  onigenc_single_byte_mbc_to_code,
+  onigenc_single_byte_code_to_mbclen,
+  onigenc_single_byte_code_to_mbc,
+  onigenc_ascii_mbc_case_fold,
+  onigenc_ascii_apply_all_case_fold,
+  onigenc_ascii_get_case_fold_codes_by_str,
+  onigenc_minimum_property_name_to_ctype,
+  onigenc_ascii_is_code_ctype,
+  onigenc_not_support_get_ctype_code_range,
+  onigenc_single_byte_left_adjust_char_head,
+  onigenc_always_true_is_allowed_reverse_match,
+  ONIGENC_FLAG_NONE,
+};
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode.c	(revision 279)
@@ -0,0 +1,605 @@
+/**********************************************************************
+  unicode.c -  Oniguruma (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2013  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+#define ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code,ctype) \
+  ((EncUNICODE_ISO_8859_1_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
+#if 0
+#define ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(code,cbit) \
+  ((EncUNICODE_ISO_8859_1_CtypeTable[code] & (cbit)) != 0)
+#endif
+
+static const unsigned short EncUNICODE_ISO_8859_1_CtypeTable[256] = {
+  0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
+  0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
+  0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
+  0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
+  0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
+  0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
+  0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
+  0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
+  0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
+  0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
+  0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
+  0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
+  0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
+  0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
+  0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
+  0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
+  0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0288, 0x0008, 0x0008,
+  0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
+  0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
+  0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
+  0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
+  0x00a0, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x00a8, 0x00a0, 0x00a0,
+  0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0,
+  0x00a0, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0,
+  0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
+  0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
+  0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
+  0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
+  0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
+  0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
+  0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
+  0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
+};
+
+typedef struct {
+  int n;
+  OnigCodePoint code[3];
+} CodePointList3;
+
+typedef struct {
+  OnigCodePoint  from;
+  CodePointList3 to;
+} CaseFold_11_Type;
+
+typedef struct {
+  OnigCodePoint  from;
+  CodePointList3 to;
+} CaseUnfold_11_Type;
+
+typedef struct {
+  int n;
+  OnigCodePoint code[2];
+} CodePointList2;
+
+typedef struct {
+  OnigCodePoint  from[2];
+  CodePointList2 to;
+} CaseUnfold_12_Type;
+
+typedef struct {
+  OnigCodePoint  from[3];
+  CodePointList2 to;
+} CaseUnfold_13_Type;
+
+static inline int
+bits_of(const OnigCodePoint c, const int n)
+{
+  return (c >> (2 - n) * 7) & 127;
+}
+
+static inline int
+bits_at(const OnigCodePoint *c, const int n)
+{
+  return bits_of(c[n / 3], n % 3);
+}
+
+static int
+code1_equal(const OnigCodePoint x, const OnigCodePoint y)
+{
+  if (x != y) return 0;
+  return 1;
+}
+
+static int
+code2_equal(const OnigCodePoint *x, const OnigCodePoint *y)
+{
+  if (x[0] != y[0]) return 0;
+  if (x[1] != y[1]) return 0;
+  return 1;
+}
+
+static int
+code3_equal(const OnigCodePoint *x, const OnigCodePoint *y)
+{
+  if (x[0] != y[0]) return 0;
+  if (x[1] != y[1]) return 0;
+  if (x[2] != y[2]) return 0;
+  return 1;
+}
+
+#include "enc/unicode/casefold.h"
+
+#include "enc/unicode/name2ctype.h"
+
+#define CODE_RANGES_NUM numberof(CodeRanges)
+
+extern int
+onigenc_unicode_is_code_ctype(OnigCodePoint code, unsigned int ctype)
+{
+  if (
+#ifdef USE_UNICODE_PROPERTIES
+      ctype <= ONIGENC_MAX_STD_CTYPE &&
+#endif
+      code < 256) {
+    return ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code, ctype);
+  }
+
+  if (ctype >= CODE_RANGES_NUM) {
+    return ONIGERR_TYPE_BUG;
+  }
+
+  return onig_is_in_code_range((UChar* )CodeRanges[ctype], code);
+}
+
+
+extern int
+onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
+{
+  if (ctype >= CODE_RANGES_NUM) {
+    return ONIGERR_TYPE_BUG;
+  }
+
+  *ranges = CodeRanges[ctype];
+
+  return 0;
+}
+
+extern int
+onigenc_utf16_32_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,
+                                      const OnigCodePoint* ranges[])
+{
+  *sb_out = 0x00;
+  return onigenc_unicode_ctype_code_range(ctype, ranges);
+}
+
+#include "st.h"
+
+#define PROPERTY_NAME_MAX_SIZE    (MAX_WORD_LENGTH + 1)
+
+extern int
+onigenc_unicode_property_name_to_ctype(OnigEncoding enc, UChar* name, UChar* end)
+{
+  int len;
+  int ctype;
+  UChar buf[PROPERTY_NAME_MAX_SIZE];
+  UChar *p;
+  OnigCodePoint code;
+
+  len = 0;
+  for (p = name; p < end; p += enclen(enc, p)) {
+    code = ONIGENC_MBC_TO_CODE(enc, p, end);
+    if (code == ' ' || code == '-' || code == '_')
+      continue;
+    if (code >= 0x80)
+      return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
+
+    buf[len++] = ONIGENC_ASCII_CODE_TO_LOWER_CASE(code);
+    if (len >= PROPERTY_NAME_MAX_SIZE)
+      return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
+  }
+
+  buf[len] = 0;
+
+  if ((ctype = uniname2ctype(buf, len)) < 0) {
+    return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
+  }
+
+  return ctype;
+}
+
+#define onigenc_unicode_fold_lookup onigenc_unicode_CaseFold_11_lookup
+#define onigenc_unicode_unfold1_lookup onigenc_unicode_CaseUnfold_11_lookup
+#define onigenc_unicode_unfold2_lookup onigenc_unicode_CaseUnfold_12_lookup
+#define onigenc_unicode_unfold3_lookup onigenc_unicode_CaseUnfold_13_lookup
+
+extern int
+onigenc_unicode_mbc_case_fold(OnigEncoding enc,
+    OnigCaseFoldType flag ARG_UNUSED, const UChar** pp, const UChar* end,
+    UChar* fold)
+{
+  const CodePointList3 *to;
+  OnigCodePoint code;
+  int i, len, rlen;
+  const UChar *p = *pp;
+
+  code = ONIGENC_MBC_TO_CODE(enc, p, end);
+  len = enclen(enc, p);
+  *pp += len;
+
+#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
+  if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
+    if (code == 0x0049) {
+      return ONIGENC_CODE_TO_MBC(enc, 0x0131, fold);
+    }
+    else if (code == 0x0130) {
+      return ONIGENC_CODE_TO_MBC(enc, 0x0069, fold);
+    }
+  }
+#endif
+
+  if ((to = onigenc_unicode_fold_lookup(code)) != 0) {
+    if (to->n == 1) {
+      return ONIGENC_CODE_TO_MBC(enc, to->code[0], fold);
+    }
+#if 0
+    /* NO NEEDS TO CHECK */
+    else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0)
+#else
+    else
+#endif
+    {
+      rlen = 0;
+      for (i = 0; i < to->n; i++) {
+	len = ONIGENC_CODE_TO_MBC(enc, to->code[i], fold);
+	fold += len;
+	rlen += len;
+      }
+      return rlen;
+    }
+  }
+
+  for (i = 0; i < len; i++) {
+    *fold++ = *p++;
+  }
+  return len;
+}
+
+extern int
+onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
+				    OnigApplyAllCaseFoldFunc f, void* arg)
+{
+  const CaseUnfold_11_Type* p11;
+  OnigCodePoint code;
+  int i, j, k, r;
+
+  for (i = 0; i < numberof(CaseUnfold_11); i++) {
+    p11 = &CaseUnfold_11[i];
+    for (j = 0; j < p11->to.n; j++) {
+      code = p11->from;
+      r = (*f)(p11->to.code[j], &code, 1, arg);
+      if (r != 0) return r;
+
+      code = p11->to.code[j];
+      r = (*f)(p11->from, &code, 1, arg);
+      if (r != 0) return r;
+
+      for (k = 0; k < j; k++) {
+	r = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]), 1, arg);
+	if (r != 0) return r;
+
+	r = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]), 1, arg);
+	if (r != 0) return r;
+      }
+    }
+  }
+
+#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
+  if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
+    code = 0x0131;
+    r = (*f)(0x0049, &code, 1, arg);
+    if (r != 0) return r;
+    code = 0x0049;
+    r = (*f)(0x0131, &code, 1, arg);
+    if (r != 0) return r;
+
+    code = 0x0130;
+    r = (*f)(0x0069, &code, 1, arg);
+    if (r != 0) return r;
+    code = 0x0069;
+    r = (*f)(0x0130, &code, 1, arg);
+    if (r != 0) return r;
+  }
+  else {
+#endif
+    for (i = 0; i < numberof(CaseUnfold_11_Locale); i++) {
+      p11 = &CaseUnfold_11_Locale[i];
+      for (j = 0; j < p11->to.n; j++) {
+	code = p11->from;
+	r = (*f)(p11->to.code[j], &code, 1, arg);
+	if (r != 0) return r;
+
+	code = p11->to.code[j];
+	r = (*f)(p11->from, &code, 1, arg);
+	if (r != 0) return r;
+
+	for (k = 0; k < j; k++) {
+	  r = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]),
+		   1, arg);
+	  if (r != 0) return r;
+
+	  r = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]),
+		   1, arg);
+	  if (r != 0) return r;
+	}
+      }
+    }
+#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
+  }
+#endif
+
+  if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
+    for (i = 0; i < numberof(CaseUnfold_12); i++) {
+      for (j = 0; j < CaseUnfold_12[i].to.n; j++) {
+	r = (*f)(CaseUnfold_12[i].to.code[j],
+		 (OnigCodePoint* )CaseUnfold_12[i].from, 2, arg);
+	if (r != 0) return r;
+
+	for (k = 0; k < CaseUnfold_12[i].to.n; k++) {
+	  if (k == j) continue;
+
+	  r = (*f)(CaseUnfold_12[i].to.code[j],
+		   (OnigCodePoint* )(&CaseUnfold_12[i].to.code[k]), 1, arg);
+	  if (r != 0) return r;
+	}
+      }
+    }
+
+#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
+    if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) == 0) {
+#endif
+      for (i = 0; i < numberof(CaseUnfold_12_Locale); i++) {
+	for (j = 0; j < CaseUnfold_12_Locale[i].to.n; j++) {
+	  r = (*f)(CaseUnfold_12_Locale[i].to.code[j],
+		   (OnigCodePoint* )CaseUnfold_12_Locale[i].from, 2, arg);
+	  if (r != 0) return r;
+
+	  for (k = 0; k < CaseUnfold_12_Locale[i].to.n; k++) {
+	    if (k == j) continue;
+
+	    r = (*f)(CaseUnfold_12_Locale[i].to.code[j],
+		     (OnigCodePoint* )(&CaseUnfold_12_Locale[i].to.code[k]),
+		     1, arg);
+	    if (r != 0) return r;
+	  }
+	}
+      }
+#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
+    }
+#endif
+
+    for (i = 0; i < numberof(CaseUnfold_13); i++) {
+      for (j = 0; j < CaseUnfold_13[i].to.n; j++) {
+	r = (*f)(CaseUnfold_13[i].to.code[j],
+		 (OnigCodePoint* )CaseUnfold_13[i].from, 3, arg);
+	if (r != 0) return r;
+
+	for (k = 0; k < CaseUnfold_13[i].to.n; k++) {
+	  if (k == j) continue;
+
+	  r = (*f)(CaseUnfold_13[i].to.code[j],
+		   (OnigCodePoint* )(&CaseUnfold_13[i].to.code[k]), 1, arg);
+	  if (r != 0) return r;
+	}
+      }
+    }
+  }
+
+  return 0;
+}
+
+extern int
+onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
+    OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end,
+    OnigCaseFoldCodeItem items[])
+{
+  int n, i, j, k, len;
+  OnigCodePoint code, codes[3];
+  const CodePointList3 *to, *z3;
+  const CodePointList2 *z2;
+
+  n = 0;
+
+  code = ONIGENC_MBC_TO_CODE(enc, p, end);
+  len = enclen(enc, p);
+
+#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
+  if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
+    if (code == 0x0049) {
+      items[0].byte_len = len;
+      items[0].code_len = 1;
+      items[0].code[0]  = 0x0131;
+      return 1;
+    }
+    else if (code == 0x0130) {
+      items[0].byte_len = len;
+      items[0].code_len = 1;
+      items[0].code[0]  = 0x0069;
+      return 1;
+    }
+    else if (code == 0x0131) {
+      items[0].byte_len = len;
+      items[0].code_len = 1;
+      items[0].code[0]  = 0x0049;
+      return 1;
+    }
+    else if (code == 0x0069) {
+      items[0].byte_len = len;
+      items[0].code_len = 1;
+      items[0].code[0]  = 0x0130;
+      return 1;
+    }
+  }
+#endif
+
+  if ((to = onigenc_unicode_fold_lookup(code)) != 0) {
+    if (to->n == 1) {
+      OnigCodePoint orig_code = code;
+
+      items[0].byte_len = len;
+      items[0].code_len = 1;
+      items[0].code[0]  = to->code[0];
+      n++;
+
+      code = to->code[0];
+      if ((to = onigenc_unicode_unfold1_lookup(code)) != 0) {
+	for (i = 0; i < to->n; i++) {
+	  if (to->code[i] != orig_code) {
+	    items[n].byte_len = len;
+	    items[n].code_len = 1;
+	    items[n].code[0]  = to->code[i];
+	    n++;
+	  }
+	}
+      }
+    }
+    else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
+      OnigCodePoint cs[3][4];
+      int fn, ncs[3];
+
+      for (fn = 0; fn < to->n; fn++) {
+	cs[fn][0] = to->code[fn];
+	if ((z3 = onigenc_unicode_unfold1_lookup(cs[fn][0])) != 0) {
+	  for (i = 0; i < z3->n; i++) {
+	    cs[fn][i+1] = z3->code[i];
+	  }
+	  ncs[fn] = z3->n + 1;
+	}
+	else
+	  ncs[fn] = 1;
+      }
+
+      if (fn == 2) {
+	for (i = 0; i < ncs[0]; i++) {
+	  for (j = 0; j < ncs[1]; j++) {
+	    items[n].byte_len = len;
+	    items[n].code_len = 2;
+	    items[n].code[0]  = cs[0][i];
+	    items[n].code[1]  = cs[1][j];
+	    n++;
+	  }
+	}
+
+	if ((z2 = onigenc_unicode_unfold2_lookup(to->code)) != 0) {
+	  for (i = 0; i < z2->n; i++) {
+	    if (z2->code[i] == code) continue;
+
+	    items[n].byte_len = len;
+	    items[n].code_len = 1;
+	    items[n].code[0]  = z2->code[i];
+	    n++;
+	  }
+	}
+      }
+      else {
+	for (i = 0; i < ncs[0]; i++) {
+	  for (j = 0; j < ncs[1]; j++) {
+	    for (k = 0; k < ncs[2]; k++) {
+	      items[n].byte_len = len;
+	      items[n].code_len = 3;
+	      items[n].code[0]  = cs[0][i];
+	      items[n].code[1]  = cs[1][j];
+	      items[n].code[2]  = cs[2][k];
+	      n++;
+	    }
+	  }
+	}
+
+	if ((z2 = onigenc_unicode_unfold3_lookup(to->code)) != 0) {
+	  for (i = 0; i < z2->n; i++) {
+	    if (z2->code[i] == code) continue;
+
+	    items[n].byte_len = len;
+	    items[n].code_len = 1;
+	    items[n].code[0]  = z2->code[i];
+	    n++;
+	  }
+	}
+      }
+
+      /* multi char folded code is not head of another folded multi char */
+      flag = 0; /* DISABLE_CASE_FOLD_MULTI_CHAR(flag); */
+    }
+  }
+  else {
+    if ((to = onigenc_unicode_unfold1_lookup(code)) != 0) {
+      for (i = 0; i < to->n; i++) {
+	items[n].byte_len = len;
+	items[n].code_len = 1;
+	items[n].code[0]  = to->code[i];
+	n++;
+      }
+    }
+  }
+
+
+  if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
+    p += len;
+    if (p < end) {
+      int clen;
+
+      codes[0] = code;
+      code = ONIGENC_MBC_TO_CODE(enc, p, end);
+      if ((to = onigenc_unicode_fold_lookup(code)) != 0
+	  && to->n == 1) {
+	codes[1] = to->code[0];
+      }
+      else
+	codes[1] = code;
+
+      clen = enclen(enc, p);
+      len += clen;
+      if ((z2 = onigenc_unicode_unfold2_lookup(codes)) != 0) {
+	for (i = 0; i < z2->n; i++) {
+	  items[n].byte_len = len;
+	  items[n].code_len = 1;
+	  items[n].code[0]  = z2->code[i];
+	  n++;
+	}
+      }
+
+      p += clen;
+      if (p < end) {
+	code = ONIGENC_MBC_TO_CODE(enc, p, end);
+	if ((to = onigenc_unicode_fold_lookup(code)) != 0
+	    && to->n == 1) {
+	  codes[2] = to->code[0];
+	}
+	else
+	  codes[2] = code;
+
+	clen = enclen(enc, p);
+	len += clen;
+	if ((z2 = onigenc_unicode_unfold3_lookup(codes)) != 0) {
+	  for (i = 0; i < z2->n; i++) {
+	    items[n].byte_len = len;
+	    items[n].code_len = 1;
+	    items[n].code[0]  = z2->code[i];
+	    n++;
+	  }
+	}
+      }
+    }
+  }
+
+  return n;
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode/casefold.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode/casefold.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode/casefold.h	(revision 279)
@@ -0,0 +1,5619 @@
+/* DO NOT EDIT THIS FILE. */
+/* Generated by tool/case-folding.rb */
+
+static const CaseFold_11_Type CaseFold_11_Table[] = {
+#define CaseFold (*(CaseFold_11_Type (*)[1178])(CaseFold_11_Table+0))
+  {0x0041, {1, {0x0061}}},
+  {0x0042, {1, {0x0062}}},
+  {0x0043, {1, {0x0063}}},
+  {0x0044, {1, {0x0064}}},
+  {0x0045, {1, {0x0065}}},
+  {0x0046, {1, {0x0066}}},
+  {0x0047, {1, {0x0067}}},
+  {0x0048, {1, {0x0068}}},
+  {0x004a, {1, {0x006a}}},
+  {0x004b, {1, {0x006b}}},
+  {0x004c, {1, {0x006c}}},
+  {0x004d, {1, {0x006d}}},
+  {0x004e, {1, {0x006e}}},
+  {0x004f, {1, {0x006f}}},
+  {0x0050, {1, {0x0070}}},
+  {0x0051, {1, {0x0071}}},
+  {0x0052, {1, {0x0072}}},
+  {0x0053, {1, {0x0073}}},
+  {0x0054, {1, {0x0074}}},
+  {0x0055, {1, {0x0075}}},
+  {0x0056, {1, {0x0076}}},
+  {0x0057, {1, {0x0077}}},
+  {0x0058, {1, {0x0078}}},
+  {0x0059, {1, {0x0079}}},
+  {0x005a, {1, {0x007a}}},
+  {0x00b5, {1, {0x03bc}}},
+  {0x00c0, {1, {0x00e0}}},
+  {0x00c1, {1, {0x00e1}}},
+  {0x00c2, {1, {0x00e2}}},
+  {0x00c3, {1, {0x00e3}}},
+  {0x00c4, {1, {0x00e4}}},
+  {0x00c5, {1, {0x00e5}}},
+  {0x00c6, {1, {0x00e6}}},
+  {0x00c7, {1, {0x00e7}}},
+  {0x00c8, {1, {0x00e8}}},
+  {0x00c9, {1, {0x00e9}}},
+  {0x00ca, {1, {0x00ea}}},
+  {0x00cb, {1, {0x00eb}}},
+  {0x00cc, {1, {0x00ec}}},
+  {0x00cd, {1, {0x00ed}}},
+  {0x00ce, {1, {0x00ee}}},
+  {0x00cf, {1, {0x00ef}}},
+  {0x00d0, {1, {0x00f0}}},
+  {0x00d1, {1, {0x00f1}}},
+  {0x00d2, {1, {0x00f2}}},
+  {0x00d3, {1, {0x00f3}}},
+  {0x00d4, {1, {0x00f4}}},
+  {0x00d5, {1, {0x00f5}}},
+  {0x00d6, {1, {0x00f6}}},
+  {0x00d8, {1, {0x00f8}}},
+  {0x00d9, {1, {0x00f9}}},
+  {0x00da, {1, {0x00fa}}},
+  {0x00db, {1, {0x00fb}}},
+  {0x00dc, {1, {0x00fc}}},
+  {0x00dd, {1, {0x00fd}}},
+  {0x00de, {1, {0x00fe}}},
+  {0x00df, {2, {0x0073, 0x0073}}},
+  {0x0100, {1, {0x0101}}},
+  {0x0102, {1, {0x0103}}},
+  {0x0104, {1, {0x0105}}},
+  {0x0106, {1, {0x0107}}},
+  {0x0108, {1, {0x0109}}},
+  {0x010a, {1, {0x010b}}},
+  {0x010c, {1, {0x010d}}},
+  {0x010e, {1, {0x010f}}},
+  {0x0110, {1, {0x0111}}},
+  {0x0112, {1, {0x0113}}},
+  {0x0114, {1, {0x0115}}},
+  {0x0116, {1, {0x0117}}},
+  {0x0118, {1, {0x0119}}},
+  {0x011a, {1, {0x011b}}},
+  {0x011c, {1, {0x011d}}},
+  {0x011e, {1, {0x011f}}},
+  {0x0120, {1, {0x0121}}},
+  {0x0122, {1, {0x0123}}},
+  {0x0124, {1, {0x0125}}},
+  {0x0126, {1, {0x0127}}},
+  {0x0128, {1, {0x0129}}},
+  {0x012a, {1, {0x012b}}},
+  {0x012c, {1, {0x012d}}},
+  {0x012e, {1, {0x012f}}},
+  {0x0132, {1, {0x0133}}},
+  {0x0134, {1, {0x0135}}},
+  {0x0136, {1, {0x0137}}},
+  {0x0139, {1, {0x013a}}},
+  {0x013b, {1, {0x013c}}},
+  {0x013d, {1, {0x013e}}},
+  {0x013f, {1, {0x0140}}},
+  {0x0141, {1, {0x0142}}},
+  {0x0143, {1, {0x0144}}},
+  {0x0145, {1, {0x0146}}},
+  {0x0147, {1, {0x0148}}},
+  {0x0149, {2, {0x02bc, 0x006e}}},
+  {0x014a, {1, {0x014b}}},
+  {0x014c, {1, {0x014d}}},
+  {0x014e, {1, {0x014f}}},
+  {0x0150, {1, {0x0151}}},
+  {0x0152, {1, {0x0153}}},
+  {0x0154, {1, {0x0155}}},
+  {0x0156, {1, {0x0157}}},
+  {0x0158, {1, {0x0159}}},
+  {0x015a, {1, {0x015b}}},
+  {0x015c, {1, {0x015d}}},
+  {0x015e, {1, {0x015f}}},
+  {0x0160, {1, {0x0161}}},
+  {0x0162, {1, {0x0163}}},
+  {0x0164, {1, {0x0165}}},
+  {0x0166, {1, {0x0167}}},
+  {0x0168, {1, {0x0169}}},
+  {0x016a, {1, {0x016b}}},
+  {0x016c, {1, {0x016d}}},
+  {0x016e, {1, {0x016f}}},
+  {0x0170, {1, {0x0171}}},
+  {0x0172, {1, {0x0173}}},
+  {0x0174, {1, {0x0175}}},
+  {0x0176, {1, {0x0177}}},
+  {0x0178, {1, {0x00ff}}},
+  {0x0179, {1, {0x017a}}},
+  {0x017b, {1, {0x017c}}},
+  {0x017d, {1, {0x017e}}},
+  {0x017f, {1, {0x0073}}},
+  {0x0181, {1, {0x0253}}},
+  {0x0182, {1, {0x0183}}},
+  {0x0184, {1, {0x0185}}},
+  {0x0186, {1, {0x0254}}},
+  {0x0187, {1, {0x0188}}},
+  {0x0189, {1, {0x0256}}},
+  {0x018a, {1, {0x0257}}},
+  {0x018b, {1, {0x018c}}},
+  {0x018e, {1, {0x01dd}}},
+  {0x018f, {1, {0x0259}}},
+  {0x0190, {1, {0x025b}}},
+  {0x0191, {1, {0x0192}}},
+  {0x0193, {1, {0x0260}}},
+  {0x0194, {1, {0x0263}}},
+  {0x0196, {1, {0x0269}}},
+  {0x0197, {1, {0x0268}}},
+  {0x0198, {1, {0x0199}}},
+  {0x019c, {1, {0x026f}}},
+  {0x019d, {1, {0x0272}}},
+  {0x019f, {1, {0x0275}}},
+  {0x01a0, {1, {0x01a1}}},
+  {0x01a2, {1, {0x01a3}}},
+  {0x01a4, {1, {0x01a5}}},
+  {0x01a6, {1, {0x0280}}},
+  {0x01a7, {1, {0x01a8}}},
+  {0x01a9, {1, {0x0283}}},
+  {0x01ac, {1, {0x01ad}}},
+  {0x01ae, {1, {0x0288}}},
+  {0x01af, {1, {0x01b0}}},
+  {0x01b1, {1, {0x028a}}},
+  {0x01b2, {1, {0x028b}}},
+  {0x01b3, {1, {0x01b4}}},
+  {0x01b5, {1, {0x01b6}}},
+  {0x01b7, {1, {0x0292}}},
+  {0x01b8, {1, {0x01b9}}},
+  {0x01bc, {1, {0x01bd}}},
+  {0x01c4, {1, {0x01c6}}},
+  {0x01c5, {1, {0x01c6}}},
+  {0x01c7, {1, {0x01c9}}},
+  {0x01c8, {1, {0x01c9}}},
+  {0x01ca, {1, {0x01cc}}},
+  {0x01cb, {1, {0x01cc}}},
+  {0x01cd, {1, {0x01ce}}},
+  {0x01cf, {1, {0x01d0}}},
+  {0x01d1, {1, {0x01d2}}},
+  {0x01d3, {1, {0x01d4}}},
+  {0x01d5, {1, {0x01d6}}},
+  {0x01d7, {1, {0x01d8}}},
+  {0x01d9, {1, {0x01da}}},
+  {0x01db, {1, {0x01dc}}},
+  {0x01de, {1, {0x01df}}},
+  {0x01e0, {1, {0x01e1}}},
+  {0x01e2, {1, {0x01e3}}},
+  {0x01e4, {1, {0x01e5}}},
+  {0x01e6, {1, {0x01e7}}},
+  {0x01e8, {1, {0x01e9}}},
+  {0x01ea, {1, {0x01eb}}},
+  {0x01ec, {1, {0x01ed}}},
+  {0x01ee, {1, {0x01ef}}},
+  {0x01f0, {2, {0x006a, 0x030c}}},
+  {0x01f1, {1, {0x01f3}}},
+  {0x01f2, {1, {0x01f3}}},
+  {0x01f4, {1, {0x01f5}}},
+  {0x01f6, {1, {0x0195}}},
+  {0x01f7, {1, {0x01bf}}},
+  {0x01f8, {1, {0x01f9}}},
+  {0x01fa, {1, {0x01fb}}},
+  {0x01fc, {1, {0x01fd}}},
+  {0x01fe, {1, {0x01ff}}},
+  {0x0200, {1, {0x0201}}},
+  {0x0202, {1, {0x0203}}},
+  {0x0204, {1, {0x0205}}},
+  {0x0206, {1, {0x0207}}},
+  {0x0208, {1, {0x0209}}},
+  {0x020a, {1, {0x020b}}},
+  {0x020c, {1, {0x020d}}},
+  {0x020e, {1, {0x020f}}},
+  {0x0210, {1, {0x0211}}},
+  {0x0212, {1, {0x0213}}},
+  {0x0214, {1, {0x0215}}},
+  {0x0216, {1, {0x0217}}},
+  {0x0218, {1, {0x0219}}},
+  {0x021a, {1, {0x021b}}},
+  {0x021c, {1, {0x021d}}},
+  {0x021e, {1, {0x021f}}},
+  {0x0220, {1, {0x019e}}},
+  {0x0222, {1, {0x0223}}},
+  {0x0224, {1, {0x0225}}},
+  {0x0226, {1, {0x0227}}},
+  {0x0228, {1, {0x0229}}},
+  {0x022a, {1, {0x022b}}},
+  {0x022c, {1, {0x022d}}},
+  {0x022e, {1, {0x022f}}},
+  {0x0230, {1, {0x0231}}},
+  {0x0232, {1, {0x0233}}},
+  {0x023a, {1, {0x2c65}}},
+  {0x023b, {1, {0x023c}}},
+  {0x023d, {1, {0x019a}}},
+  {0x023e, {1, {0x2c66}}},
+  {0x0241, {1, {0x0242}}},
+  {0x0243, {1, {0x0180}}},
+  {0x0244, {1, {0x0289}}},
+  {0x0245, {1, {0x028c}}},
+  {0x0246, {1, {0x0247}}},
+  {0x0248, {1, {0x0249}}},
+  {0x024a, {1, {0x024b}}},
+  {0x024c, {1, {0x024d}}},
+  {0x024e, {1, {0x024f}}},
+  {0x0345, {1, {0x03b9}}},
+  {0x0370, {1, {0x0371}}},
+  {0x0372, {1, {0x0373}}},
+  {0x0376, {1, {0x0377}}},
+  {0x037f, {1, {0x03f3}}},
+  {0x0386, {1, {0x03ac}}},
+  {0x0388, {1, {0x03ad}}},
+  {0x0389, {1, {0x03ae}}},
+  {0x038a, {1, {0x03af}}},
+  {0x038c, {1, {0x03cc}}},
+  {0x038e, {1, {0x03cd}}},
+  {0x038f, {1, {0x03ce}}},
+  {0x0390, {3, {0x03b9, 0x0308, 0x0301}}},
+  {0x0391, {1, {0x03b1}}},
+  {0x0392, {1, {0x03b2}}},
+  {0x0393, {1, {0x03b3}}},
+  {0x0394, {1, {0x03b4}}},
+  {0x0395, {1, {0x03b5}}},
+  {0x0396, {1, {0x03b6}}},
+  {0x0397, {1, {0x03b7}}},
+  {0x0398, {1, {0x03b8}}},
+  {0x0399, {1, {0x03b9}}},
+  {0x039a, {1, {0x03ba}}},
+  {0x039b, {1, {0x03bb}}},
+  {0x039c, {1, {0x03bc}}},
+  {0x039d, {1, {0x03bd}}},
+  {0x039e, {1, {0x03be}}},
+  {0x039f, {1, {0x03bf}}},
+  {0x03a0, {1, {0x03c0}}},
+  {0x03a1, {1, {0x03c1}}},
+  {0x03a3, {1, {0x03c3}}},
+  {0x03a4, {1, {0x03c4}}},
+  {0x03a5, {1, {0x03c5}}},
+  {0x03a6, {1, {0x03c6}}},
+  {0x03a7, {1, {0x03c7}}},
+  {0x03a8, {1, {0x03c8}}},
+  {0x03a9, {1, {0x03c9}}},
+  {0x03aa, {1, {0x03ca}}},
+  {0x03ab, {1, {0x03cb}}},
+  {0x03b0, {3, {0x03c5, 0x0308, 0x0301}}},
+  {0x03c2, {1, {0x03c3}}},
+  {0x03cf, {1, {0x03d7}}},
+  {0x03d0, {1, {0x03b2}}},
+  {0x03d1, {1, {0x03b8}}},
+  {0x03d5, {1, {0x03c6}}},
+  {0x03d6, {1, {0x03c0}}},
+  {0x03d8, {1, {0x03d9}}},
+  {0x03da, {1, {0x03db}}},
+  {0x03dc, {1, {0x03dd}}},
+  {0x03de, {1, {0x03df}}},
+  {0x03e0, {1, {0x03e1}}},
+  {0x03e2, {1, {0x03e3}}},
+  {0x03e4, {1, {0x03e5}}},
+  {0x03e6, {1, {0x03e7}}},
+  {0x03e8, {1, {0x03e9}}},
+  {0x03ea, {1, {0x03eb}}},
+  {0x03ec, {1, {0x03ed}}},
+  {0x03ee, {1, {0x03ef}}},
+  {0x03f0, {1, {0x03ba}}},
+  {0x03f1, {1, {0x03c1}}},
+  {0x03f4, {1, {0x03b8}}},
+  {0x03f5, {1, {0x03b5}}},
+  {0x03f7, {1, {0x03f8}}},
+  {0x03f9, {1, {0x03f2}}},
+  {0x03fa, {1, {0x03fb}}},
+  {0x03fd, {1, {0x037b}}},
+  {0x03fe, {1, {0x037c}}},
+  {0x03ff, {1, {0x037d}}},
+  {0x0400, {1, {0x0450}}},
+  {0x0401, {1, {0x0451}}},
+  {0x0402, {1, {0x0452}}},
+  {0x0403, {1, {0x0453}}},
+  {0x0404, {1, {0x0454}}},
+  {0x0405, {1, {0x0455}}},
+  {0x0406, {1, {0x0456}}},
+  {0x0407, {1, {0x0457}}},
+  {0x0408, {1, {0x0458}}},
+  {0x0409, {1, {0x0459}}},
+  {0x040a, {1, {0x045a}}},
+  {0x040b, {1, {0x045b}}},
+  {0x040c, {1, {0x045c}}},
+  {0x040d, {1, {0x045d}}},
+  {0x040e, {1, {0x045e}}},
+  {0x040f, {1, {0x045f}}},
+  {0x0410, {1, {0x0430}}},
+  {0x0411, {1, {0x0431}}},
+  {0x0412, {1, {0x0432}}},
+  {0x0413, {1, {0x0433}}},
+  {0x0414, {1, {0x0434}}},
+  {0x0415, {1, {0x0435}}},
+  {0x0416, {1, {0x0436}}},
+  {0x0417, {1, {0x0437}}},
+  {0x0418, {1, {0x0438}}},
+  {0x0419, {1, {0x0439}}},
+  {0x041a, {1, {0x043a}}},
+  {0x041b, {1, {0x043b}}},
+  {0x041c, {1, {0x043c}}},
+  {0x041d, {1, {0x043d}}},
+  {0x041e, {1, {0x043e}}},
+  {0x041f, {1, {0x043f}}},
+  {0x0420, {1, {0x0440}}},
+  {0x0421, {1, {0x0441}}},
+  {0x0422, {1, {0x0442}}},
+  {0x0423, {1, {0x0443}}},
+  {0x0424, {1, {0x0444}}},
+  {0x0425, {1, {0x0445}}},
+  {0x0426, {1, {0x0446}}},
+  {0x0427, {1, {0x0447}}},
+  {0x0428, {1, {0x0448}}},
+  {0x0429, {1, {0x0449}}},
+  {0x042a, {1, {0x044a}}},
+  {0x042b, {1, {0x044b}}},
+  {0x042c, {1, {0x044c}}},
+  {0x042d, {1, {0x044d}}},
+  {0x042e, {1, {0x044e}}},
+  {0x042f, {1, {0x044f}}},
+  {0x0460, {1, {0x0461}}},
+  {0x0462, {1, {0x0463}}},
+  {0x0464, {1, {0x0465}}},
+  {0x0466, {1, {0x0467}}},
+  {0x0468, {1, {0x0469}}},
+  {0x046a, {1, {0x046b}}},
+  {0x046c, {1, {0x046d}}},
+  {0x046e, {1, {0x046f}}},
+  {0x0470, {1, {0x0471}}},
+  {0x0472, {1, {0x0473}}},
+  {0x0474, {1, {0x0475}}},
+  {0x0476, {1, {0x0477}}},
+  {0x0478, {1, {0x0479}}},
+  {0x047a, {1, {0x047b}}},
+  {0x047c, {1, {0x047d}}},
+  {0x047e, {1, {0x047f}}},
+  {0x0480, {1, {0x0481}}},
+  {0x048a, {1, {0x048b}}},
+  {0x048c, {1, {0x048d}}},
+  {0x048e, {1, {0x048f}}},
+  {0x0490, {1, {0x0491}}},
+  {0x0492, {1, {0x0493}}},
+  {0x0494, {1, {0x0495}}},
+  {0x0496, {1, {0x0497}}},
+  {0x0498, {1, {0x0499}}},
+  {0x049a, {1, {0x049b}}},
+  {0x049c, {1, {0x049d}}},
+  {0x049e, {1, {0x049f}}},
+  {0x04a0, {1, {0x04a1}}},
+  {0x04a2, {1, {0x04a3}}},
+  {0x04a4, {1, {0x04a5}}},
+  {0x04a6, {1, {0x04a7}}},
+  {0x04a8, {1, {0x04a9}}},
+  {0x04aa, {1, {0x04ab}}},
+  {0x04ac, {1, {0x04ad}}},
+  {0x04ae, {1, {0x04af}}},
+  {0x04b0, {1, {0x04b1}}},
+  {0x04b2, {1, {0x04b3}}},
+  {0x04b4, {1, {0x04b5}}},
+  {0x04b6, {1, {0x04b7}}},
+  {0x04b8, {1, {0x04b9}}},
+  {0x04ba, {1, {0x04bb}}},
+  {0x04bc, {1, {0x04bd}}},
+  {0x04be, {1, {0x04bf}}},
+  {0x04c0, {1, {0x04cf}}},
+  {0x04c1, {1, {0x04c2}}},
+  {0x04c3, {1, {0x04c4}}},
+  {0x04c5, {1, {0x04c6}}},
+  {0x04c7, {1, {0x04c8}}},
+  {0x04c9, {1, {0x04ca}}},
+  {0x04cb, {1, {0x04cc}}},
+  {0x04cd, {1, {0x04ce}}},
+  {0x04d0, {1, {0x04d1}}},
+  {0x04d2, {1, {0x04d3}}},
+  {0x04d4, {1, {0x04d5}}},
+  {0x04d6, {1, {0x04d7}}},
+  {0x04d8, {1, {0x04d9}}},
+  {0x04da, {1, {0x04db}}},
+  {0x04dc, {1, {0x04dd}}},
+  {0x04de, {1, {0x04df}}},
+  {0x04e0, {1, {0x04e1}}},
+  {0x04e2, {1, {0x04e3}}},
+  {0x04e4, {1, {0x04e5}}},
+  {0x04e6, {1, {0x04e7}}},
+  {0x04e8, {1, {0x04e9}}},
+  {0x04ea, {1, {0x04eb}}},
+  {0x04ec, {1, {0x04ed}}},
+  {0x04ee, {1, {0x04ef}}},
+  {0x04f0, {1, {0x04f1}}},
+  {0x04f2, {1, {0x04f3}}},
+  {0x04f4, {1, {0x04f5}}},
+  {0x04f6, {1, {0x04f7}}},
+  {0x04f8, {1, {0x04f9}}},
+  {0x04fa, {1, {0x04fb}}},
+  {0x04fc, {1, {0x04fd}}},
+  {0x04fe, {1, {0x04ff}}},
+  {0x0500, {1, {0x0501}}},
+  {0x0502, {1, {0x0503}}},
+  {0x0504, {1, {0x0505}}},
+  {0x0506, {1, {0x0507}}},
+  {0x0508, {1, {0x0509}}},
+  {0x050a, {1, {0x050b}}},
+  {0x050c, {1, {0x050d}}},
+  {0x050e, {1, {0x050f}}},
+  {0x0510, {1, {0x0511}}},
+  {0x0512, {1, {0x0513}}},
+  {0x0514, {1, {0x0515}}},
+  {0x0516, {1, {0x0517}}},
+  {0x0518, {1, {0x0519}}},
+  {0x051a, {1, {0x051b}}},
+  {0x051c, {1, {0x051d}}},
+  {0x051e, {1, {0x051f}}},
+  {0x0520, {1, {0x0521}}},
+  {0x0522, {1, {0x0523}}},
+  {0x0524, {1, {0x0525}}},
+  {0x0526, {1, {0x0527}}},
+  {0x0528, {1, {0x0529}}},
+  {0x052a, {1, {0x052b}}},
+  {0x052c, {1, {0x052d}}},
+  {0x052e, {1, {0x052f}}},
+  {0x0531, {1, {0x0561}}},
+  {0x0532, {1, {0x0562}}},
+  {0x0533, {1, {0x0563}}},
+  {0x0534, {1, {0x0564}}},
+  {0x0535, {1, {0x0565}}},
+  {0x0536, {1, {0x0566}}},
+  {0x0537, {1, {0x0567}}},
+  {0x0538, {1, {0x0568}}},
+  {0x0539, {1, {0x0569}}},
+  {0x053a, {1, {0x056a}}},
+  {0x053b, {1, {0x056b}}},
+  {0x053c, {1, {0x056c}}},
+  {0x053d, {1, {0x056d}}},
+  {0x053e, {1, {0x056e}}},
+  {0x053f, {1, {0x056f}}},
+  {0x0540, {1, {0x0570}}},
+  {0x0541, {1, {0x0571}}},
+  {0x0542, {1, {0x0572}}},
+  {0x0543, {1, {0x0573}}},
+  {0x0544, {1, {0x0574}}},
+  {0x0545, {1, {0x0575}}},
+  {0x0546, {1, {0x0576}}},
+  {0x0547, {1, {0x0577}}},
+  {0x0548, {1, {0x0578}}},
+  {0x0549, {1, {0x0579}}},
+  {0x054a, {1, {0x057a}}},
+  {0x054b, {1, {0x057b}}},
+  {0x054c, {1, {0x057c}}},
+  {0x054d, {1, {0x057d}}},
+  {0x054e, {1, {0x057e}}},
+  {0x054f, {1, {0x057f}}},
+  {0x0550, {1, {0x0580}}},
+  {0x0551, {1, {0x0581}}},
+  {0x0552, {1, {0x0582}}},
+  {0x0553, {1, {0x0583}}},
+  {0x0554, {1, {0x0584}}},
+  {0x0555, {1, {0x0585}}},
+  {0x0556, {1, {0x0586}}},
+  {0x0587, {2, {0x0565, 0x0582}}},
+  {0x10a0, {1, {0x2d00}}},
+  {0x10a1, {1, {0x2d01}}},
+  {0x10a2, {1, {0x2d02}}},
+  {0x10a3, {1, {0x2d03}}},
+  {0x10a4, {1, {0x2d04}}},
+  {0x10a5, {1, {0x2d05}}},
+  {0x10a6, {1, {0x2d06}}},
+  {0x10a7, {1, {0x2d07}}},
+  {0x10a8, {1, {0x2d08}}},
+  {0x10a9, {1, {0x2d09}}},
+  {0x10aa, {1, {0x2d0a}}},
+  {0x10ab, {1, {0x2d0b}}},
+  {0x10ac, {1, {0x2d0c}}},
+  {0x10ad, {1, {0x2d0d}}},
+  {0x10ae, {1, {0x2d0e}}},
+  {0x10af, {1, {0x2d0f}}},
+  {0x10b0, {1, {0x2d10}}},
+  {0x10b1, {1, {0x2d11}}},
+  {0x10b2, {1, {0x2d12}}},
+  {0x10b3, {1, {0x2d13}}},
+  {0x10b4, {1, {0x2d14}}},
+  {0x10b5, {1, {0x2d15}}},
+  {0x10b6, {1, {0x2d16}}},
+  {0x10b7, {1, {0x2d17}}},
+  {0x10b8, {1, {0x2d18}}},
+  {0x10b9, {1, {0x2d19}}},
+  {0x10ba, {1, {0x2d1a}}},
+  {0x10bb, {1, {0x2d1b}}},
+  {0x10bc, {1, {0x2d1c}}},
+  {0x10bd, {1, {0x2d1d}}},
+  {0x10be, {1, {0x2d1e}}},
+  {0x10bf, {1, {0x2d1f}}},
+  {0x10c0, {1, {0x2d20}}},
+  {0x10c1, {1, {0x2d21}}},
+  {0x10c2, {1, {0x2d22}}},
+  {0x10c3, {1, {0x2d23}}},
+  {0x10c4, {1, {0x2d24}}},
+  {0x10c5, {1, {0x2d25}}},
+  {0x10c7, {1, {0x2d27}}},
+  {0x10cd, {1, {0x2d2d}}},
+  {0x1e00, {1, {0x1e01}}},
+  {0x1e02, {1, {0x1e03}}},
+  {0x1e04, {1, {0x1e05}}},
+  {0x1e06, {1, {0x1e07}}},
+  {0x1e08, {1, {0x1e09}}},
+  {0x1e0a, {1, {0x1e0b}}},
+  {0x1e0c, {1, {0x1e0d}}},
+  {0x1e0e, {1, {0x1e0f}}},
+  {0x1e10, {1, {0x1e11}}},
+  {0x1e12, {1, {0x1e13}}},
+  {0x1e14, {1, {0x1e15}}},
+  {0x1e16, {1, {0x1e17}}},
+  {0x1e18, {1, {0x1e19}}},
+  {0x1e1a, {1, {0x1e1b}}},
+  {0x1e1c, {1, {0x1e1d}}},
+  {0x1e1e, {1, {0x1e1f}}},
+  {0x1e20, {1, {0x1e21}}},
+  {0x1e22, {1, {0x1e23}}},
+  {0x1e24, {1, {0x1e25}}},
+  {0x1e26, {1, {0x1e27}}},
+  {0x1e28, {1, {0x1e29}}},
+  {0x1e2a, {1, {0x1e2b}}},
+  {0x1e2c, {1, {0x1e2d}}},
+  {0x1e2e, {1, {0x1e2f}}},
+  {0x1e30, {1, {0x1e31}}},
+  {0x1e32, {1, {0x1e33}}},
+  {0x1e34, {1, {0x1e35}}},
+  {0x1e36, {1, {0x1e37}}},
+  {0x1e38, {1, {0x1e39}}},
+  {0x1e3a, {1, {0x1e3b}}},
+  {0x1e3c, {1, {0x1e3d}}},
+  {0x1e3e, {1, {0x1e3f}}},
+  {0x1e40, {1, {0x1e41}}},
+  {0x1e42, {1, {0x1e43}}},
+  {0x1e44, {1, {0x1e45}}},
+  {0x1e46, {1, {0x1e47}}},
+  {0x1e48, {1, {0x1e49}}},
+  {0x1e4a, {1, {0x1e4b}}},
+  {0x1e4c, {1, {0x1e4d}}},
+  {0x1e4e, {1, {0x1e4f}}},
+  {0x1e50, {1, {0x1e51}}},
+  {0x1e52, {1, {0x1e53}}},
+  {0x1e54, {1, {0x1e55}}},
+  {0x1e56, {1, {0x1e57}}},
+  {0x1e58, {1, {0x1e59}}},
+  {0x1e5a, {1, {0x1e5b}}},
+  {0x1e5c, {1, {0x1e5d}}},
+  {0x1e5e, {1, {0x1e5f}}},
+  {0x1e60, {1, {0x1e61}}},
+  {0x1e62, {1, {0x1e63}}},
+  {0x1e64, {1, {0x1e65}}},
+  {0x1e66, {1, {0x1e67}}},
+  {0x1e68, {1, {0x1e69}}},
+  {0x1e6a, {1, {0x1e6b}}},
+  {0x1e6c, {1, {0x1e6d}}},
+  {0x1e6e, {1, {0x1e6f}}},
+  {0x1e70, {1, {0x1e71}}},
+  {0x1e72, {1, {0x1e73}}},
+  {0x1e74, {1, {0x1e75}}},
+  {0x1e76, {1, {0x1e77}}},
+  {0x1e78, {1, {0x1e79}}},
+  {0x1e7a, {1, {0x1e7b}}},
+  {0x1e7c, {1, {0x1e7d}}},
+  {0x1e7e, {1, {0x1e7f}}},
+  {0x1e80, {1, {0x1e81}}},
+  {0x1e82, {1, {0x1e83}}},
+  {0x1e84, {1, {0x1e85}}},
+  {0x1e86, {1, {0x1e87}}},
+  {0x1e88, {1, {0x1e89}}},
+  {0x1e8a, {1, {0x1e8b}}},
+  {0x1e8c, {1, {0x1e8d}}},
+  {0x1e8e, {1, {0x1e8f}}},
+  {0x1e90, {1, {0x1e91}}},
+  {0x1e92, {1, {0x1e93}}},
+  {0x1e94, {1, {0x1e95}}},
+  {0x1e96, {2, {0x0068, 0x0331}}},
+  {0x1e97, {2, {0x0074, 0x0308}}},
+  {0x1e98, {2, {0x0077, 0x030a}}},
+  {0x1e99, {2, {0x0079, 0x030a}}},
+  {0x1e9a, {2, {0x0061, 0x02be}}},
+  {0x1e9b, {1, {0x1e61}}},
+  {0x1e9e, {2, {0x0073, 0x0073}}},
+  {0x1ea0, {1, {0x1ea1}}},
+  {0x1ea2, {1, {0x1ea3}}},
+  {0x1ea4, {1, {0x1ea5}}},
+  {0x1ea6, {1, {0x1ea7}}},
+  {0x1ea8, {1, {0x1ea9}}},
+  {0x1eaa, {1, {0x1eab}}},
+  {0x1eac, {1, {0x1ead}}},
+  {0x1eae, {1, {0x1eaf}}},
+  {0x1eb0, {1, {0x1eb1}}},
+  {0x1eb2, {1, {0x1eb3}}},
+  {0x1eb4, {1, {0x1eb5}}},
+  {0x1eb6, {1, {0x1eb7}}},
+  {0x1eb8, {1, {0x1eb9}}},
+  {0x1eba, {1, {0x1ebb}}},
+  {0x1ebc, {1, {0x1ebd}}},
+  {0x1ebe, {1, {0x1ebf}}},
+  {0x1ec0, {1, {0x1ec1}}},
+  {0x1ec2, {1, {0x1ec3}}},
+  {0x1ec4, {1, {0x1ec5}}},
+  {0x1ec6, {1, {0x1ec7}}},
+  {0x1ec8, {1, {0x1ec9}}},
+  {0x1eca, {1, {0x1ecb}}},
+  {0x1ecc, {1, {0x1ecd}}},
+  {0x1ece, {1, {0x1ecf}}},
+  {0x1ed0, {1, {0x1ed1}}},
+  {0x1ed2, {1, {0x1ed3}}},
+  {0x1ed4, {1, {0x1ed5}}},
+  {0x1ed6, {1, {0x1ed7}}},
+  {0x1ed8, {1, {0x1ed9}}},
+  {0x1eda, {1, {0x1edb}}},
+  {0x1edc, {1, {0x1edd}}},
+  {0x1ede, {1, {0x1edf}}},
+  {0x1ee0, {1, {0x1ee1}}},
+  {0x1ee2, {1, {0x1ee3}}},
+  {0x1ee4, {1, {0x1ee5}}},
+  {0x1ee6, {1, {0x1ee7}}},
+  {0x1ee8, {1, {0x1ee9}}},
+  {0x1eea, {1, {0x1eeb}}},
+  {0x1eec, {1, {0x1eed}}},
+  {0x1eee, {1, {0x1eef}}},
+  {0x1ef0, {1, {0x1ef1}}},
+  {0x1ef2, {1, {0x1ef3}}},
+  {0x1ef4, {1, {0x1ef5}}},
+  {0x1ef6, {1, {0x1ef7}}},
+  {0x1ef8, {1, {0x1ef9}}},
+  {0x1efa, {1, {0x1efb}}},
+  {0x1efc, {1, {0x1efd}}},
+  {0x1efe, {1, {0x1eff}}},
+  {0x1f08, {1, {0x1f00}}},
+  {0x1f09, {1, {0x1f01}}},
+  {0x1f0a, {1, {0x1f02}}},
+  {0x1f0b, {1, {0x1f03}}},
+  {0x1f0c, {1, {0x1f04}}},
+  {0x1f0d, {1, {0x1f05}}},
+  {0x1f0e, {1, {0x1f06}}},
+  {0x1f0f, {1, {0x1f07}}},
+  {0x1f18, {1, {0x1f10}}},
+  {0x1f19, {1, {0x1f11}}},
+  {0x1f1a, {1, {0x1f12}}},
+  {0x1f1b, {1, {0x1f13}}},
+  {0x1f1c, {1, {0x1f14}}},
+  {0x1f1d, {1, {0x1f15}}},
+  {0x1f28, {1, {0x1f20}}},
+  {0x1f29, {1, {0x1f21}}},
+  {0x1f2a, {1, {0x1f22}}},
+  {0x1f2b, {1, {0x1f23}}},
+  {0x1f2c, {1, {0x1f24}}},
+  {0x1f2d, {1, {0x1f25}}},
+  {0x1f2e, {1, {0x1f26}}},
+  {0x1f2f, {1, {0x1f27}}},
+  {0x1f38, {1, {0x1f30}}},
+  {0x1f39, {1, {0x1f31}}},
+  {0x1f3a, {1, {0x1f32}}},
+  {0x1f3b, {1, {0x1f33}}},
+  {0x1f3c, {1, {0x1f34}}},
+  {0x1f3d, {1, {0x1f35}}},
+  {0x1f3e, {1, {0x1f36}}},
+  {0x1f3f, {1, {0x1f37}}},
+  {0x1f48, {1, {0x1f40}}},
+  {0x1f49, {1, {0x1f41}}},
+  {0x1f4a, {1, {0x1f42}}},
+  {0x1f4b, {1, {0x1f43}}},
+  {0x1f4c, {1, {0x1f44}}},
+  {0x1f4d, {1, {0x1f45}}},
+  {0x1f50, {2, {0x03c5, 0x0313}}},
+  {0x1f52, {3, {0x03c5, 0x0313, 0x0300}}},
+  {0x1f54, {3, {0x03c5, 0x0313, 0x0301}}},
+  {0x1f56, {3, {0x03c5, 0x0313, 0x0342}}},
+  {0x1f59, {1, {0x1f51}}},
+  {0x1f5b, {1, {0x1f53}}},
+  {0x1f5d, {1, {0x1f55}}},
+  {0x1f5f, {1, {0x1f57}}},
+  {0x1f68, {1, {0x1f60}}},
+  {0x1f69, {1, {0x1f61}}},
+  {0x1f6a, {1, {0x1f62}}},
+  {0x1f6b, {1, {0x1f63}}},
+  {0x1f6c, {1, {0x1f64}}},
+  {0x1f6d, {1, {0x1f65}}},
+  {0x1f6e, {1, {0x1f66}}},
+  {0x1f6f, {1, {0x1f67}}},
+  {0x1f80, {2, {0x1f00, 0x03b9}}},
+  {0x1f81, {2, {0x1f01, 0x03b9}}},
+  {0x1f82, {2, {0x1f02, 0x03b9}}},
+  {0x1f83, {2, {0x1f03, 0x03b9}}},
+  {0x1f84, {2, {0x1f04, 0x03b9}}},
+  {0x1f85, {2, {0x1f05, 0x03b9}}},
+  {0x1f86, {2, {0x1f06, 0x03b9}}},
+  {0x1f87, {2, {0x1f07, 0x03b9}}},
+  {0x1f88, {2, {0x1f00, 0x03b9}}},
+  {0x1f89, {2, {0x1f01, 0x03b9}}},
+  {0x1f8a, {2, {0x1f02, 0x03b9}}},
+  {0x1f8b, {2, {0x1f03, 0x03b9}}},
+  {0x1f8c, {2, {0x1f04, 0x03b9}}},
+  {0x1f8d, {2, {0x1f05, 0x03b9}}},
+  {0x1f8e, {2, {0x1f06, 0x03b9}}},
+  {0x1f8f, {2, {0x1f07, 0x03b9}}},
+  {0x1f90, {2, {0x1f20, 0x03b9}}},
+  {0x1f91, {2, {0x1f21, 0x03b9}}},
+  {0x1f92, {2, {0x1f22, 0x03b9}}},
+  {0x1f93, {2, {0x1f23, 0x03b9}}},
+  {0x1f94, {2, {0x1f24, 0x03b9}}},
+  {0x1f95, {2, {0x1f25, 0x03b9}}},
+  {0x1f96, {2, {0x1f26, 0x03b9}}},
+  {0x1f97, {2, {0x1f27, 0x03b9}}},
+  {0x1f98, {2, {0x1f20, 0x03b9}}},
+  {0x1f99, {2, {0x1f21, 0x03b9}}},
+  {0x1f9a, {2, {0x1f22, 0x03b9}}},
+  {0x1f9b, {2, {0x1f23, 0x03b9}}},
+  {0x1f9c, {2, {0x1f24, 0x03b9}}},
+  {0x1f9d, {2, {0x1f25, 0x03b9}}},
+  {0x1f9e, {2, {0x1f26, 0x03b9}}},
+  {0x1f9f, {2, {0x1f27, 0x03b9}}},
+  {0x1fa0, {2, {0x1f60, 0x03b9}}},
+  {0x1fa1, {2, {0x1f61, 0x03b9}}},
+  {0x1fa2, {2, {0x1f62, 0x03b9}}},
+  {0x1fa3, {2, {0x1f63, 0x03b9}}},
+  {0x1fa4, {2, {0x1f64, 0x03b9}}},
+  {0x1fa5, {2, {0x1f65, 0x03b9}}},
+  {0x1fa6, {2, {0x1f66, 0x03b9}}},
+  {0x1fa7, {2, {0x1f67, 0x03b9}}},
+  {0x1fa8, {2, {0x1f60, 0x03b9}}},
+  {0x1fa9, {2, {0x1f61, 0x03b9}}},
+  {0x1faa, {2, {0x1f62, 0x03b9}}},
+  {0x1fab, {2, {0x1f63, 0x03b9}}},
+  {0x1fac, {2, {0x1f64, 0x03b9}}},
+  {0x1fad, {2, {0x1f65, 0x03b9}}},
+  {0x1fae, {2, {0x1f66, 0x03b9}}},
+  {0x1faf, {2, {0x1f67, 0x03b9}}},
+  {0x1fb2, {2, {0x1f70, 0x03b9}}},
+  {0x1fb3, {2, {0x03b1, 0x03b9}}},
+  {0x1fb4, {2, {0x03ac, 0x03b9}}},
+  {0x1fb6, {2, {0x03b1, 0x0342}}},
+  {0x1fb7, {3, {0x03b1, 0x0342, 0x03b9}}},
+  {0x1fb8, {1, {0x1fb0}}},
+  {0x1fb9, {1, {0x1fb1}}},
+  {0x1fba, {1, {0x1f70}}},
+  {0x1fbb, {1, {0x1f71}}},
+  {0x1fbc, {2, {0x03b1, 0x03b9}}},
+  {0x1fbe, {1, {0x03b9}}},
+  {0x1fc2, {2, {0x1f74, 0x03b9}}},
+  {0x1fc3, {2, {0x03b7, 0x03b9}}},
+  {0x1fc4, {2, {0x03ae, 0x03b9}}},
+  {0x1fc6, {2, {0x03b7, 0x0342}}},
+  {0x1fc7, {3, {0x03b7, 0x0342, 0x03b9}}},
+  {0x1fc8, {1, {0x1f72}}},
+  {0x1fc9, {1, {0x1f73}}},
+  {0x1fca, {1, {0x1f74}}},
+  {0x1fcb, {1, {0x1f75}}},
+  {0x1fcc, {2, {0x03b7, 0x03b9}}},
+  {0x1fd2, {3, {0x03b9, 0x0308, 0x0300}}},
+  {0x1fd3, {3, {0x03b9, 0x0308, 0x0301}}},
+  {0x1fd6, {2, {0x03b9, 0x0342}}},
+  {0x1fd7, {3, {0x03b9, 0x0308, 0x0342}}},
+  {0x1fd8, {1, {0x1fd0}}},
+  {0x1fd9, {1, {0x1fd1}}},
+  {0x1fda, {1, {0x1f76}}},
+  {0x1fdb, {1, {0x1f77}}},
+  {0x1fe2, {3, {0x03c5, 0x0308, 0x0300}}},
+  {0x1fe3, {3, {0x03c5, 0x0308, 0x0301}}},
+  {0x1fe4, {2, {0x03c1, 0x0313}}},
+  {0x1fe6, {2, {0x03c5, 0x0342}}},
+  {0x1fe7, {3, {0x03c5, 0x0308, 0x0342}}},
+  {0x1fe8, {1, {0x1fe0}}},
+  {0x1fe9, {1, {0x1fe1}}},
+  {0x1fea, {1, {0x1f7a}}},
+  {0x1feb, {1, {0x1f7b}}},
+  {0x1fec, {1, {0x1fe5}}},
+  {0x1ff2, {2, {0x1f7c, 0x03b9}}},
+  {0x1ff3, {2, {0x03c9, 0x03b9}}},
+  {0x1ff4, {2, {0x03ce, 0x03b9}}},
+  {0x1ff6, {2, {0x03c9, 0x0342}}},
+  {0x1ff7, {3, {0x03c9, 0x0342, 0x03b9}}},
+  {0x1ff8, {1, {0x1f78}}},
+  {0x1ff9, {1, {0x1f79}}},
+  {0x1ffa, {1, {0x1f7c}}},
+  {0x1ffb, {1, {0x1f7d}}},
+  {0x1ffc, {2, {0x03c9, 0x03b9}}},
+  {0x2126, {1, {0x03c9}}},
+  {0x212a, {1, {0x006b}}},
+  {0x212b, {1, {0x00e5}}},
+  {0x2132, {1, {0x214e}}},
+  {0x2160, {1, {0x2170}}},
+  {0x2161, {1, {0x2171}}},
+  {0x2162, {1, {0x2172}}},
+  {0x2163, {1, {0x2173}}},
+  {0x2164, {1, {0x2174}}},
+  {0x2165, {1, {0x2175}}},
+  {0x2166, {1, {0x2176}}},
+  {0x2167, {1, {0x2177}}},
+  {0x2168, {1, {0x2178}}},
+  {0x2169, {1, {0x2179}}},
+  {0x216a, {1, {0x217a}}},
+  {0x216b, {1, {0x217b}}},
+  {0x216c, {1, {0x217c}}},
+  {0x216d, {1, {0x217d}}},
+  {0x216e, {1, {0x217e}}},
+  {0x216f, {1, {0x217f}}},
+  {0x2183, {1, {0x2184}}},
+  {0x24b6, {1, {0x24d0}}},
+  {0x24b7, {1, {0x24d1}}},
+  {0x24b8, {1, {0x24d2}}},
+  {0x24b9, {1, {0x24d3}}},
+  {0x24ba, {1, {0x24d4}}},
+  {0x24bb, {1, {0x24d5}}},
+  {0x24bc, {1, {0x24d6}}},
+  {0x24bd, {1, {0x24d7}}},
+  {0x24be, {1, {0x24d8}}},
+  {0x24bf, {1, {0x24d9}}},
+  {0x24c0, {1, {0x24da}}},
+  {0x24c1, {1, {0x24db}}},
+  {0x24c2, {1, {0x24dc}}},
+  {0x24c3, {1, {0x24dd}}},
+  {0x24c4, {1, {0x24de}}},
+  {0x24c5, {1, {0x24df}}},
+  {0x24c6, {1, {0x24e0}}},
+  {0x24c7, {1, {0x24e1}}},
+  {0x24c8, {1, {0x24e2}}},
+  {0x24c9, {1, {0x24e3}}},
+  {0x24ca, {1, {0x24e4}}},
+  {0x24cb, {1, {0x24e5}}},
+  {0x24cc, {1, {0x24e6}}},
+  {0x24cd, {1, {0x24e7}}},
+  {0x24ce, {1, {0x24e8}}},
+  {0x24cf, {1, {0x24e9}}},
+  {0x2c00, {1, {0x2c30}}},
+  {0x2c01, {1, {0x2c31}}},
+  {0x2c02, {1, {0x2c32}}},
+  {0x2c03, {1, {0x2c33}}},
+  {0x2c04, {1, {0x2c34}}},
+  {0x2c05, {1, {0x2c35}}},
+  {0x2c06, {1, {0x2c36}}},
+  {0x2c07, {1, {0x2c37}}},
+  {0x2c08, {1, {0x2c38}}},
+  {0x2c09, {1, {0x2c39}}},
+  {0x2c0a, {1, {0x2c3a}}},
+  {0x2c0b, {1, {0x2c3b}}},
+  {0x2c0c, {1, {0x2c3c}}},
+  {0x2c0d, {1, {0x2c3d}}},
+  {0x2c0e, {1, {0x2c3e}}},
+  {0x2c0f, {1, {0x2c3f}}},
+  {0x2c10, {1, {0x2c40}}},
+  {0x2c11, {1, {0x2c41}}},
+  {0x2c12, {1, {0x2c42}}},
+  {0x2c13, {1, {0x2c43}}},
+  {0x2c14, {1, {0x2c44}}},
+  {0x2c15, {1, {0x2c45}}},
+  {0x2c16, {1, {0x2c46}}},
+  {0x2c17, {1, {0x2c47}}},
+  {0x2c18, {1, {0x2c48}}},
+  {0x2c19, {1, {0x2c49}}},
+  {0x2c1a, {1, {0x2c4a}}},
+  {0x2c1b, {1, {0x2c4b}}},
+  {0x2c1c, {1, {0x2c4c}}},
+  {0x2c1d, {1, {0x2c4d}}},
+  {0x2c1e, {1, {0x2c4e}}},
+  {0x2c1f, {1, {0x2c4f}}},
+  {0x2c20, {1, {0x2c50}}},
+  {0x2c21, {1, {0x2c51}}},
+  {0x2c22, {1, {0x2c52}}},
+  {0x2c23, {1, {0x2c53}}},
+  {0x2c24, {1, {0x2c54}}},
+  {0x2c25, {1, {0x2c55}}},
+  {0x2c26, {1, {0x2c56}}},
+  {0x2c27, {1, {0x2c57}}},
+  {0x2c28, {1, {0x2c58}}},
+  {0x2c29, {1, {0x2c59}}},
+  {0x2c2a, {1, {0x2c5a}}},
+  {0x2c2b, {1, {0x2c5b}}},
+  {0x2c2c, {1, {0x2c5c}}},
+  {0x2c2d, {1, {0x2c5d}}},
+  {0x2c2e, {1, {0x2c5e}}},
+  {0x2c60, {1, {0x2c61}}},
+  {0x2c62, {1, {0x026b}}},
+  {0x2c63, {1, {0x1d7d}}},
+  {0x2c64, {1, {0x027d}}},
+  {0x2c67, {1, {0x2c68}}},
+  {0x2c69, {1, {0x2c6a}}},
+  {0x2c6b, {1, {0x2c6c}}},
+  {0x2c6d, {1, {0x0251}}},
+  {0x2c6e, {1, {0x0271}}},
+  {0x2c6f, {1, {0x0250}}},
+  {0x2c70, {1, {0x0252}}},
+  {0x2c72, {1, {0x2c73}}},
+  {0x2c75, {1, {0x2c76}}},
+  {0x2c7e, {1, {0x023f}}},
+  {0x2c7f, {1, {0x0240}}},
+  {0x2c80, {1, {0x2c81}}},
+  {0x2c82, {1, {0x2c83}}},
+  {0x2c84, {1, {0x2c85}}},
+  {0x2c86, {1, {0x2c87}}},
+  {0x2c88, {1, {0x2c89}}},
+  {0x2c8a, {1, {0x2c8b}}},
+  {0x2c8c, {1, {0x2c8d}}},
+  {0x2c8e, {1, {0x2c8f}}},
+  {0x2c90, {1, {0x2c91}}},
+  {0x2c92, {1, {0x2c93}}},
+  {0x2c94, {1, {0x2c95}}},
+  {0x2c96, {1, {0x2c97}}},
+  {0x2c98, {1, {0x2c99}}},
+  {0x2c9a, {1, {0x2c9b}}},
+  {0x2c9c, {1, {0x2c9d}}},
+  {0x2c9e, {1, {0x2c9f}}},
+  {0x2ca0, {1, {0x2ca1}}},
+  {0x2ca2, {1, {0x2ca3}}},
+  {0x2ca4, {1, {0x2ca5}}},
+  {0x2ca6, {1, {0x2ca7}}},
+  {0x2ca8, {1, {0x2ca9}}},
+  {0x2caa, {1, {0x2cab}}},
+  {0x2cac, {1, {0x2cad}}},
+  {0x2cae, {1, {0x2caf}}},
+  {0x2cb0, {1, {0x2cb1}}},
+  {0x2cb2, {1, {0x2cb3}}},
+  {0x2cb4, {1, {0x2cb5}}},
+  {0x2cb6, {1, {0x2cb7}}},
+  {0x2cb8, {1, {0x2cb9}}},
+  {0x2cba, {1, {0x2cbb}}},
+  {0x2cbc, {1, {0x2cbd}}},
+  {0x2cbe, {1, {0x2cbf}}},
+  {0x2cc0, {1, {0x2cc1}}},
+  {0x2cc2, {1, {0x2cc3}}},
+  {0x2cc4, {1, {0x2cc5}}},
+  {0x2cc6, {1, {0x2cc7}}},
+  {0x2cc8, {1, {0x2cc9}}},
+  {0x2cca, {1, {0x2ccb}}},
+  {0x2ccc, {1, {0x2ccd}}},
+  {0x2cce, {1, {0x2ccf}}},
+  {0x2cd0, {1, {0x2cd1}}},
+  {0x2cd2, {1, {0x2cd3}}},
+  {0x2cd4, {1, {0x2cd5}}},
+  {0x2cd6, {1, {0x2cd7}}},
+  {0x2cd8, {1, {0x2cd9}}},
+  {0x2cda, {1, {0x2cdb}}},
+  {0x2cdc, {1, {0x2cdd}}},
+  {0x2cde, {1, {0x2cdf}}},
+  {0x2ce0, {1, {0x2ce1}}},
+  {0x2ce2, {1, {0x2ce3}}},
+  {0x2ceb, {1, {0x2cec}}},
+  {0x2ced, {1, {0x2cee}}},
+  {0x2cf2, {1, {0x2cf3}}},
+  {0xa640, {1, {0xa641}}},
+  {0xa642, {1, {0xa643}}},
+  {0xa644, {1, {0xa645}}},
+  {0xa646, {1, {0xa647}}},
+  {0xa648, {1, {0xa649}}},
+  {0xa64a, {1, {0xa64b}}},
+  {0xa64c, {1, {0xa64d}}},
+  {0xa64e, {1, {0xa64f}}},
+  {0xa650, {1, {0xa651}}},
+  {0xa652, {1, {0xa653}}},
+  {0xa654, {1, {0xa655}}},
+  {0xa656, {1, {0xa657}}},
+  {0xa658, {1, {0xa659}}},
+  {0xa65a, {1, {0xa65b}}},
+  {0xa65c, {1, {0xa65d}}},
+  {0xa65e, {1, {0xa65f}}},
+  {0xa660, {1, {0xa661}}},
+  {0xa662, {1, {0xa663}}},
+  {0xa664, {1, {0xa665}}},
+  {0xa666, {1, {0xa667}}},
+  {0xa668, {1, {0xa669}}},
+  {0xa66a, {1, {0xa66b}}},
+  {0xa66c, {1, {0xa66d}}},
+  {0xa680, {1, {0xa681}}},
+  {0xa682, {1, {0xa683}}},
+  {0xa684, {1, {0xa685}}},
+  {0xa686, {1, {0xa687}}},
+  {0xa688, {1, {0xa689}}},
+  {0xa68a, {1, {0xa68b}}},
+  {0xa68c, {1, {0xa68d}}},
+  {0xa68e, {1, {0xa68f}}},
+  {0xa690, {1, {0xa691}}},
+  {0xa692, {1, {0xa693}}},
+  {0xa694, {1, {0xa695}}},
+  {0xa696, {1, {0xa697}}},
+  {0xa698, {1, {0xa699}}},
+  {0xa69a, {1, {0xa69b}}},
+  {0xa722, {1, {0xa723}}},
+  {0xa724, {1, {0xa725}}},
+  {0xa726, {1, {0xa727}}},
+  {0xa728, {1, {0xa729}}},
+  {0xa72a, {1, {0xa72b}}},
+  {0xa72c, {1, {0xa72d}}},
+  {0xa72e, {1, {0xa72f}}},
+  {0xa732, {1, {0xa733}}},
+  {0xa734, {1, {0xa735}}},
+  {0xa736, {1, {0xa737}}},
+  {0xa738, {1, {0xa739}}},
+  {0xa73a, {1, {0xa73b}}},
+  {0xa73c, {1, {0xa73d}}},
+  {0xa73e, {1, {0xa73f}}},
+  {0xa740, {1, {0xa741}}},
+  {0xa742, {1, {0xa743}}},
+  {0xa744, {1, {0xa745}}},
+  {0xa746, {1, {0xa747}}},
+  {0xa748, {1, {0xa749}}},
+  {0xa74a, {1, {0xa74b}}},
+  {0xa74c, {1, {0xa74d}}},
+  {0xa74e, {1, {0xa74f}}},
+  {0xa750, {1, {0xa751}}},
+  {0xa752, {1, {0xa753}}},
+  {0xa754, {1, {0xa755}}},
+  {0xa756, {1, {0xa757}}},
+  {0xa758, {1, {0xa759}}},
+  {0xa75a, {1, {0xa75b}}},
+  {0xa75c, {1, {0xa75d}}},
+  {0xa75e, {1, {0xa75f}}},
+  {0xa760, {1, {0xa761}}},
+  {0xa762, {1, {0xa763}}},
+  {0xa764, {1, {0xa765}}},
+  {0xa766, {1, {0xa767}}},
+  {0xa768, {1, {0xa769}}},
+  {0xa76a, {1, {0xa76b}}},
+  {0xa76c, {1, {0xa76d}}},
+  {0xa76e, {1, {0xa76f}}},
+  {0xa779, {1, {0xa77a}}},
+  {0xa77b, {1, {0xa77c}}},
+  {0xa77d, {1, {0x1d79}}},
+  {0xa77e, {1, {0xa77f}}},
+  {0xa780, {1, {0xa781}}},
+  {0xa782, {1, {0xa783}}},
+  {0xa784, {1, {0xa785}}},
+  {0xa786, {1, {0xa787}}},
+  {0xa78b, {1, {0xa78c}}},
+  {0xa78d, {1, {0x0265}}},
+  {0xa790, {1, {0xa791}}},
+  {0xa792, {1, {0xa793}}},
+  {0xa796, {1, {0xa797}}},
+  {0xa798, {1, {0xa799}}},
+  {0xa79a, {1, {0xa79b}}},
+  {0xa79c, {1, {0xa79d}}},
+  {0xa79e, {1, {0xa79f}}},
+  {0xa7a0, {1, {0xa7a1}}},
+  {0xa7a2, {1, {0xa7a3}}},
+  {0xa7a4, {1, {0xa7a5}}},
+  {0xa7a6, {1, {0xa7a7}}},
+  {0xa7a8, {1, {0xa7a9}}},
+  {0xa7aa, {1, {0x0266}}},
+  {0xa7ab, {1, {0x025c}}},
+  {0xa7ac, {1, {0x0261}}},
+  {0xa7ad, {1, {0x026c}}},
+  {0xa7b0, {1, {0x029e}}},
+  {0xa7b1, {1, {0x0287}}},
+  {0xfb00, {2, {0x0066, 0x0066}}},
+  {0xfb01, {2, {0x0066, 0x0069}}},
+  {0xfb02, {2, {0x0066, 0x006c}}},
+  {0xfb03, {3, {0x0066, 0x0066, 0x0069}}},
+  {0xfb04, {3, {0x0066, 0x0066, 0x006c}}},
+  {0xfb05, {2, {0x0073, 0x0074}}},
+  {0xfb06, {2, {0x0073, 0x0074}}},
+  {0xfb13, {2, {0x0574, 0x0576}}},
+  {0xfb14, {2, {0x0574, 0x0565}}},
+  {0xfb15, {2, {0x0574, 0x056b}}},
+  {0xfb16, {2, {0x057e, 0x0576}}},
+  {0xfb17, {2, {0x0574, 0x056d}}},
+  {0xff21, {1, {0xff41}}},
+  {0xff22, {1, {0xff42}}},
+  {0xff23, {1, {0xff43}}},
+  {0xff24, {1, {0xff44}}},
+  {0xff25, {1, {0xff45}}},
+  {0xff26, {1, {0xff46}}},
+  {0xff27, {1, {0xff47}}},
+  {0xff28, {1, {0xff48}}},
+  {0xff29, {1, {0xff49}}},
+  {0xff2a, {1, {0xff4a}}},
+  {0xff2b, {1, {0xff4b}}},
+  {0xff2c, {1, {0xff4c}}},
+  {0xff2d, {1, {0xff4d}}},
+  {0xff2e, {1, {0xff4e}}},
+  {0xff2f, {1, {0xff4f}}},
+  {0xff30, {1, {0xff50}}},
+  {0xff31, {1, {0xff51}}},
+  {0xff32, {1, {0xff52}}},
+  {0xff33, {1, {0xff53}}},
+  {0xff34, {1, {0xff54}}},
+  {0xff35, {1, {0xff55}}},
+  {0xff36, {1, {0xff56}}},
+  {0xff37, {1, {0xff57}}},
+  {0xff38, {1, {0xff58}}},
+  {0xff39, {1, {0xff59}}},
+  {0xff3a, {1, {0xff5a}}},
+  {0x10400, {1, {0x10428}}},
+  {0x10401, {1, {0x10429}}},
+  {0x10402, {1, {0x1042a}}},
+  {0x10403, {1, {0x1042b}}},
+  {0x10404, {1, {0x1042c}}},
+  {0x10405, {1, {0x1042d}}},
+  {0x10406, {1, {0x1042e}}},
+  {0x10407, {1, {0x1042f}}},
+  {0x10408, {1, {0x10430}}},
+  {0x10409, {1, {0x10431}}},
+  {0x1040a, {1, {0x10432}}},
+  {0x1040b, {1, {0x10433}}},
+  {0x1040c, {1, {0x10434}}},
+  {0x1040d, {1, {0x10435}}},
+  {0x1040e, {1, {0x10436}}},
+  {0x1040f, {1, {0x10437}}},
+  {0x10410, {1, {0x10438}}},
+  {0x10411, {1, {0x10439}}},
+  {0x10412, {1, {0x1043a}}},
+  {0x10413, {1, {0x1043b}}},
+  {0x10414, {1, {0x1043c}}},
+  {0x10415, {1, {0x1043d}}},
+  {0x10416, {1, {0x1043e}}},
+  {0x10417, {1, {0x1043f}}},
+  {0x10418, {1, {0x10440}}},
+  {0x10419, {1, {0x10441}}},
+  {0x1041a, {1, {0x10442}}},
+  {0x1041b, {1, {0x10443}}},
+  {0x1041c, {1, {0x10444}}},
+  {0x1041d, {1, {0x10445}}},
+  {0x1041e, {1, {0x10446}}},
+  {0x1041f, {1, {0x10447}}},
+  {0x10420, {1, {0x10448}}},
+  {0x10421, {1, {0x10449}}},
+  {0x10422, {1, {0x1044a}}},
+  {0x10423, {1, {0x1044b}}},
+  {0x10424, {1, {0x1044c}}},
+  {0x10425, {1, {0x1044d}}},
+  {0x10426, {1, {0x1044e}}},
+  {0x10427, {1, {0x1044f}}},
+  {0x118a0, {1, {0x118c0}}},
+  {0x118a1, {1, {0x118c1}}},
+  {0x118a2, {1, {0x118c2}}},
+  {0x118a3, {1, {0x118c3}}},
+  {0x118a4, {1, {0x118c4}}},
+  {0x118a5, {1, {0x118c5}}},
+  {0x118a6, {1, {0x118c6}}},
+  {0x118a7, {1, {0x118c7}}},
+  {0x118a8, {1, {0x118c8}}},
+  {0x118a9, {1, {0x118c9}}},
+  {0x118aa, {1, {0x118ca}}},
+  {0x118ab, {1, {0x118cb}}},
+  {0x118ac, {1, {0x118cc}}},
+  {0x118ad, {1, {0x118cd}}},
+  {0x118ae, {1, {0x118ce}}},
+  {0x118af, {1, {0x118cf}}},
+  {0x118b0, {1, {0x118d0}}},
+  {0x118b1, {1, {0x118d1}}},
+  {0x118b2, {1, {0x118d2}}},
+  {0x118b3, {1, {0x118d3}}},
+  {0x118b4, {1, {0x118d4}}},
+  {0x118b5, {1, {0x118d5}}},
+  {0x118b6, {1, {0x118d6}}},
+  {0x118b7, {1, {0x118d7}}},
+  {0x118b8, {1, {0x118d8}}},
+  {0x118b9, {1, {0x118d9}}},
+  {0x118ba, {1, {0x118da}}},
+  {0x118bb, {1, {0x118db}}},
+  {0x118bc, {1, {0x118dc}}},
+  {0x118bd, {1, {0x118dd}}},
+  {0x118be, {1, {0x118de}}},
+  {0x118bf, {1, {0x118df}}},
+#define CaseFold_Locale (*(CaseFold_11_Type (*)[2])(CaseFold_11_Table+1178))
+  {0x0049, {1, {0x0069}}},
+  {0x0130, {2, {0x0069, 0x0307}}},
+};
+
+/* C code produced by gperf version 3.0.3 */
+/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseFold_11_hash -N onigenc_unicode_CaseFold_11_lookup -n  */
+
+/* maximum key range = 1867, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseFold_11_hash(const OnigCodePoint code)
+{
+  static const unsigned short asso_values[] =
+    {
+        12,  212,    5,  217,    6, 1878,  173,   13,    2,   11,
+       123,    5, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878,
+      1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878,
+      1878, 1878, 1878,  220, 1878, 1878, 1878, 1878, 1878, 1878,
+      1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878,  382,
+      1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878,
+         8,    4,  219,    1, 1878,  343,  607,  274, 1202,  305,
+      1362,  209,  259,  412, 1443,  174,  290,   35,  442,   21,
+      1434,   70, 1472,  105,  362,  193,  591,   51,    3,    7,
+      1414,   86, 1391,  371, 1358,  398, 1456,  149, 1266,  245,
+      1263,  135, 1231,  121, 1096,  446,  932,  323, 1033,  428,
+      1155,  466, 1084,  991, 1160,  474, 1131,  977,  298,  749,
+       990,  491, 1010,  482, 1021,  696,  161,  729,   46,  966,
+      1209,  813, 1043,  616,  848,  917, 1019,  594, 1201,  526,
+      1127,  540,  943,  900,  171,  774, 1283,  760,  626,  935,
+      1025,  554,  288,  955,  103,  788,  423, 1113,   24, 1005,
+        20,  711,    9,  573,  358,  668,    5,  885,  228,  649,
+       102,  628,  612,  515,  800,  871,   77, 1132,   17, 1072,
+         1, 1188,   47, 1276,  244, 1326,  887, 1289,  202,  740,
+       258, 1168,  222
+    };
+  return asso_values[bits_of(code, 2)+65] + asso_values[bits_of(code, 1)] + asso_values[bits_of(code, 0)];
+}
+
+#ifdef __GNUC__
+__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+static const CodePointList3 *
+onigenc_unicode_CaseFold_11_lookup(const OnigCodePoint code)
+{
+  enum
+    {
+      MIN_CODE_VALUE = 0x41,
+      MAX_CODE_VALUE = 0x118bf,
+      TOTAL_KEYWORDS = 1180,
+      MIN_WORD_LENGTH = 3,
+      MAX_WORD_LENGTH = 3,
+      MIN_HASH_VALUE = 11,
+      MAX_HASH_VALUE = 1877
+    };
+
+  static const short wordlist[] =
+    {
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1,
+      /*0x10417*/ 1129,
+      -1, -1,
+      /*0x1ff3*/ 794,
+      /*0x10418*/ 1130,
+      /*0x1f97*/ 729,
+      /*0x0417*/ 320,
+      /*0x2c17*/ 873,
+      /*0x1e97*/ 600,
+      /*0x1f98*/ 730,
+      /*0x0418*/ 321,
+      /*0x2c18*/ 874,
+      /*0x1e98*/ 601,
+      /*0x0118*/ 69,
+      /*0x0218*/ 202,
+      /*0x2c98*/ 924,
+      /*0x1e18*/ 536,
+      /*0x0397*/ 248,
+      /*0x1040e*/ 1120,
+      /*0x0498*/ 369,
+      -1,
+      /*0x0398*/ 249,
+      /*0xa798*/ 1053,
+      /*0x1f8e*/ 720,
+      /*0x040e*/ 311,
+      /*0x2c0e*/ 864,
+      /*0x1e8e*/ 595,
+      /*0x010e*/ 64,
+      /*0x020e*/ 197,
+      /*0x2c8e*/ 919,
+      /*0x1e0e*/ 531,
+      /*0x03f1*/ 288,
+      /*0x1040c*/ 1118,
+      /*0x048e*/ 364,
+      -1,
+      /*0x038e*/ 239,
+      /*0xa698*/ 1000,
+      /*0x1f8c*/ 718,
+      /*0x040c*/ 309,
+      /*0x2c0c*/ 862,
+      /*0x1e8c*/ 594,
+      /*0x010c*/ 63,
+      /*0x020c*/ 196,
+      /*0x2c8c*/ 918,
+      /*0x1e0c*/ 530,
+      -1, -1,
+      /*0x048c*/ 363,
+      /*0x10416*/ 1128,
+      /*0x038c*/ 238,
+      /*0xa68e*/ 995,
+      /*0x2c75*/ 909,
+      /*0x013f*/ 87,
+      /*0x1f96*/ 728,
+      /*0x0416*/ 319,
+      /*0x2c16*/ 872,
+      /*0x1e96*/ 599,
+      /*0x0116*/ 68,
+      /*0x0216*/ 201,
+      /*0x2c96*/ 923,
+      /*0x1e16*/ 535,
+      /*0x03f5*/ 290,
+      -1,
+      /*0x0496*/ 368,
+      /*0xa68c*/ 994,
+      /*0x0396*/ 247,
+      /*0xa796*/ 1052,
+      /*0x10410*/ 1122,
+      -1, -1, -1, -1,
+      /*0x1f90*/ 722,
+      /*0x0410*/ 313,
+      /*0x2c10*/ 866,
+      /*0x1e90*/ 596,
+      /*0x0110*/ 65,
+      /*0x0210*/ 198,
+      /*0x2c90*/ 920,
+      /*0x1e10*/ 532,
+      /*0xa696*/ 999,
+      /*0x2c6f*/ 906,
+      /*0x0490*/ 365,
+      /*0x1041a*/ 1132,
+      /*0x0390*/ 241,
+      /*0xa790*/ 1050,
+      -1, -1,
+      /*0x1f9a*/ 732,
+      /*0x041a*/ 323,
+      /*0x2c1a*/ 876,
+      /*0x1e9a*/ 603,
+      /*0x011a*/ 70,
+      /*0x021a*/ 203,
+      /*0x2c9a*/ 925,
+      /*0x1e1a*/ 537,
+      -1, -1,
+      /*0x049a*/ 370,
+      /*0xa690*/ 996,
+      /*0x039a*/ 251,
+      /*0xa79a*/ 1054,
+      /*0x10412*/ 1124,
+      -1,
+      /*0x1fe9*/ 789,
+      /*0x1fd9*/ 780,
+      /*0x2c69*/ 902,
+      /*0x1f92*/ 724,
+      /*0x0412*/ 315,
+      /*0x2c12*/ 868,
+      /*0x1e92*/ 597,
+      /*0x0112*/ 66,
+      /*0x0212*/ 199,
+      /*0x2c92*/ 921,
+      /*0x1e12*/ 533,
+      /*0xa69a*/ 1001,
+      /*0x0059*/ 23,
+      /*0x0492*/ 366,
+      /*0x10426*/ 1144,
+      /*0x0392*/ 243,
+      /*0xa792*/ 1051,
+      -1, -1,
+      /*0x1fa6*/ 744,
+      /*0x0426*/ 335,
+      /*0x2c26*/ 888,
+      /*0x1ea6*/ 609,
+      /*0x0126*/ 76,
+      /*0x0226*/ 209,
+      /*0x2ca6*/ 931,
+      /*0x1e26*/ 543,
+      /*0x0518*/ 433,
+      /*0x10424*/ 1142,
+      /*0x04a6*/ 376,
+      /*0xa692*/ 997,
+      /*0x03a6*/ 262,
+      /*0xa7a6*/ 1060,
+      /*0x1fa4*/ 742,
+      /*0x0424*/ 333,
+      /*0x2c24*/ 886,
+      /*0x1ea4*/ 608,
+      /*0x0124*/ 75,
+      /*0x0224*/ 208,
+      /*0x2ca4*/ 930,
+      /*0x1e24*/ 542,
+      /*0x050e*/ 428,
+      /*0x10420*/ 1138,
+      /*0x04a4*/ 375,
+      -1,
+      /*0x03a4*/ 260,
+      /*0xa7a4*/ 1059,
+      /*0x1fa0*/ 738,
+      /*0x0420*/ 329,
+      /*0x2c20*/ 882,
+      /*0x1ea0*/ 606,
+      /*0x0120*/ 73,
+      /*0x0220*/ 206,
+      /*0x2ca0*/ 928,
+      /*0x1e20*/ 540,
+      /*0x050c*/ 427,
+      -1,
+      /*0x04a0*/ 373,
+      -1,
+      /*0x03a0*/ 257,
+      /*0xa7a0*/ 1057,
+      -1, -1,
+      /*0x013d*/ 86,
+      /*0x023d*/ 218,
+      -1,
+      /*0x053f*/ 459,
+      /*0x1040a*/ 1116,
+      -1, -1, -1,
+      /*0x0516*/ 432,
+      /*0x1f8a*/ 716,
+      /*0x040a*/ 307,
+      /*0x2c0a*/ 860,
+      /*0x1e8a*/ 593,
+      /*0x010a*/ 62,
+      /*0x020a*/ 195,
+      /*0x2c8a*/ 917,
+      /*0x1e0a*/ 529,
+      /*0x004f*/ 13,
+      /*0x03cf*/ 270,
+      /*0x048a*/ 362,
+      -1,
+      /*0x038a*/ 237,
+      -1,
+      /*0x10414*/ 1126,
+      -1, -1, -1,
+      /*0x0510*/ 429,
+      /*0x1f94*/ 726,
+      /*0x0414*/ 317,
+      /*0x2c14*/ 870,
+      /*0x1e94*/ 598,
+      /*0x0114*/ 67,
+      /*0x0214*/ 200,
+      /*0x2c94*/ 922,
+      /*0x1e14*/ 534,
+      /*0xa68a*/ 993,
+      /*0x1ffb*/ 801,
+      /*0x0494*/ 367,
+      /*0x10406*/ 1112,
+      /*0x0394*/ 245,
+      /*0x017b*/ 118,
+      -1,
+      /*0x051a*/ 434,
+      /*0x1f86*/ 712,
+      /*0x0406*/ 303,
+      /*0x2c06*/ 856,
+      /*0x1e86*/ 591,
+      /*0x0106*/ 60,
+      /*0x0206*/ 193,
+      /*0x2c86*/ 915,
+      /*0x1e06*/ 527,
+      -1, -1,
+      /*0x0197*/ 136,
+      /*0xa694*/ 998,
+      /*0x0386*/ 234,
+      /*0xa786*/ 1047,
+      /*0x0198*/ 137,
+      /*0x2c7f*/ 911,
+      /*0x1f18*/ 662,
+      /*0x017f*/ 120,
+      /*0x0512*/ 430,
+      /*0x1fe7*/ 787,
+      -1,
+      /*0x2c67*/ 901,
+      /*0x00df*/ 56,
+      -1,
+      /*0x01f1*/ 181,
+      /*0x03ff*/ 296,
+      /*0x00dd*/ 54,
+      /*0xa686*/ 991,
+      /*0x018e*/ 129,
+      /*0x1f5f*/ 697,
+      /*0x1f0e*/ 660,
+      /*0x10422*/ 1140,
+      -1,
+      /*0x1f5d*/ 696,
+      /*0x0526*/ 440,
+      /*0x1ff7*/ 797,
+      /*0x1fa2*/ 740,
+      /*0x0422*/ 331,
+      /*0x2c22*/ 884,
+      /*0x1ea2*/ 607,
+      /*0x0122*/ 74,
+      /*0x0222*/ 207,
+      /*0x2ca2*/ 929,
+      /*0x1e22*/ 541,
+      /*0x1f0c*/ 658,
+      /*0x10407*/ 1113,
+      /*0x04a2*/ 374,
+      /*0x03f7*/ 291,
+      /*0x0524*/ 439,
+      /*0xa7a2*/ 1058,
+      /*0x1f87*/ 713,
+      /*0x0407*/ 304,
+      /*0x2c07*/ 857,
+      /*0x017d*/ 119,
+      /*0x0587*/ 483,
+      /*0x1f3f*/ 683,
+      /*0x10bf*/ 515,
+      -1,
+      /*0x0196*/ 135,
+      -1,
+      /*0x10402*/ 1108,
+      /*0x03fd*/ 294,
+      /*0x0520*/ 437,
+      -1, -1,
+      /*0x1f82*/ 708,
+      /*0x0402*/ 299,
+      /*0x2c02*/ 852,
+      /*0x1e82*/ 589,
+      /*0x0102*/ 58,
+      /*0x0202*/ 191,
+      /*0x2c82*/ 913,
+      /*0x1e02*/ 525,
+      -1,
+      /*0x053d*/ 457,
+      -1,
+      /*0x1040b*/ 1117,
+      /*0x0190*/ 131,
+      /*0xa782*/ 1045,
+      /*0x1fd7*/ 778,
+      -1,
+      /*0x1f8b*/ 717,
+      /*0x040b*/ 308,
+      /*0x2c0b*/ 861,
+      /*0x054f*/ 475,
+      -1,
+      /*0x1f6f*/ 705,
+      /*0x050a*/ 426,
+      -1, -1,
+      /*0x0057*/ 21,
+      /*0x10404*/ 1110,
+      /*0xa682*/ 989,
+      -1,
+      /*0xa78b*/ 1048,
+      /*0x1f1a*/ 664,
+      /*0x1f84*/ 710,
+      /*0x0404*/ 301,
+      /*0x2c04*/ 854,
+      /*0x1e84*/ 590,
+      /*0x0104*/ 59,
+      /*0x0204*/ 192,
+      /*0x2c84*/ 914,
+      /*0x1e04*/ 526,
+      -1,
+      /*0x00d9*/ 50,
+      /*0x0514*/ 431,
+      -1, -1,
+      /*0xa784*/ 1046,
+      /*0x01d9*/ 169,
+      /*0x1f69*/ 699,
+      /*0x1f59*/ 694,
+      -1,
+      /*0x1faa*/ 748,
+      /*0x042a*/ 339,
+      /*0x2c2a*/ 892,
+      /*0x1eaa*/ 611,
+      /*0x012a*/ 78,
+      /*0x022a*/ 211,
+      /*0x2caa*/ 933,
+      /*0x1e2a*/ 545,
+      /*0x0506*/ 424,
+      /*0xa684*/ 990,
+      /*0x04aa*/ 378,
+      -1,
+      /*0x03aa*/ 266,
+      /*0xa7aa*/ 1062,
+      /*0x01a6*/ 144,
+      /*0x10400*/ 1106,
+      -1,
+      /*0x10a6*/ 490,
+      -1, -1,
+      /*0x1f80*/ 706,
+      /*0x0400*/ 297,
+      /*0x2c00*/ 850,
+      /*0x1e80*/ 588,
+      /*0x0100*/ 57,
+      /*0x0200*/ 190,
+      /*0x2c80*/ 912,
+      /*0x1e00*/ 524,
+      /*0x01a4*/ 143,
+      -1,
+      /*0x0480*/ 361,
+      /*0x10a4*/ 488,
+      -1,
+      /*0xa780*/ 1044,
+      /*0x10413*/ 1125,
+      /*0x1fe3*/ 784,
+      -1,
+      /*0x2c63*/ 899,
+      -1,
+      /*0x1f93*/ 725,
+      /*0x0413*/ 316,
+      /*0x2c13*/ 869,
+      /*0x01a0*/ 141,
+      /*0x1041c*/ 1134,
+      /*0x0522*/ 438,
+      /*0x10a0*/ 484,
+      -1,
+      /*0xa680*/ 988,
+      /*0x1f9c*/ 734,
+      /*0x041c*/ 325,
+      /*0x2c1c*/ 878,
+      /*0x0393*/ 244,
+      /*0x011c*/ 71,
+      /*0x021c*/ 204,
+      /*0x2c9c*/ 926,
+      /*0x1e1c*/ 538,
+      /*0x1f3d*/ 681,
+      /*0x10bd*/ 513,
+      /*0x049c*/ 371,
+      /*0x00cf*/ 41,
+      /*0x039c*/ 253,
+      /*0xa79c*/ 1055,
+      -1, -1,
+      /*0x01cf*/ 164,
+      -1, -1,
+      /*0x018a*/ 127,
+      -1,
+      /*0x1f0a*/ 656,
+      /*0x1041e*/ 1136,
+      /*0x037f*/ 233,
+      -1,
+      /*0x0502*/ 422,
+      -1,
+      /*0x1f9e*/ 736,
+      /*0x041e*/ 327,
+      /*0x2c1e*/ 880,
+      /*0x1e9e*/ 605,
+      /*0x011e*/ 72,
+      /*0x021e*/ 205,
+      /*0x2c9e*/ 927,
+      /*0x1e1e*/ 539,
+      -1,
+      /*0x10408*/ 1114,
+      /*0x049e*/ 372,
+      /*0x0194*/ 134,
+      /*0x039e*/ 255,
+      /*0xa79e*/ 1056,
+      /*0x1f88*/ 714,
+      /*0x0408*/ 305,
+      /*0x2c08*/ 858,
+      /*0x1e88*/ 592,
+      /*0x0108*/ 61,
+      /*0x0208*/ 194,
+      /*0x2c88*/ 916,
+      /*0x1e08*/ 528,
+      /*0x0535*/ 449,
+      /*0x118bf*/ 1177,
+      -1,
+      /*0x1fdb*/ 782,
+      /*0x0388*/ 235,
+      /*0x0186*/ 124,
+      -1,
+      /*0x0504*/ 423,
+      /*0x1fac*/ 750,
+      /*0x042c*/ 341,
+      /*0x2c2c*/ 894,
+      /*0x1eac*/ 612,
+      /*0x012c*/ 79,
+      /*0x022c*/ 212,
+      /*0x2cac*/ 934,
+      /*0x1e2c*/ 546,
+      -1,
+      /*0x1040d*/ 1119,
+      /*0x04ac*/ 379,
+      /*0xa688*/ 992,
+      -1,
+      /*0xa7ac*/ 1064,
+      /*0x1f8d*/ 719,
+      /*0x040d*/ 310,
+      /*0x2c0d*/ 863,
+      /*0x052a*/ 442,
+      /*0x1fa8*/ 746,
+      /*0x0428*/ 337,
+      /*0x2c28*/ 890,
+      /*0x1ea8*/ 610,
+      /*0x0128*/ 77,
+      /*0x0228*/ 210,
+      /*0x2ca8*/ 932,
+      /*0x1e28*/ 544,
+      -1,
+      /*0xa78d*/ 1049,
+      /*0x04a8*/ 377,
+      /*0x24bf*/ 833,
+      /*0x03a8*/ 264,
+      /*0xa7a8*/ 1061,
+      /*0x01f7*/ 185,
+      /*0x01a2*/ 142,
+      -1, -1,
+      /*0x10a2*/ 486,
+      /*0x0500*/ 421,
+      /*0x1fae*/ 752,
+      /*0x042e*/ 343,
+      /*0x2c2e*/ 896,
+      /*0x1eae*/ 613,
+      /*0x012e*/ 80,
+      /*0x022e*/ 213,
+      /*0x2cae*/ 935,
+      /*0x1e2e*/ 547,
+      /*0x1fb2*/ 754,
+      /*0x0187*/ 125,
+      /*0x04ae*/ 380,
+      /*0x1eb2*/ 615,
+      /*0x0132*/ 81,
+      /*0x0232*/ 215,
+      /*0x2cb2*/ 937,
+      /*0x1e32*/ 549,
+      /*0x1fba*/ 761,
+      -1,
+      /*0x04b2*/ 382,
+      /*0x1eba*/ 619,
+      /*0xff26*/ 1085,
+      /*0x023a*/ 216,
+      /*0x2cba*/ 941,
+      /*0x1e3a*/ 553,
+      /*0x0182*/ 122,
+      /*0x1fb8*/ 759,
+      /*0x04ba*/ 386,
+      /*0x051c*/ 435,
+      /*0x1eb8*/ 618,
+      -1,
+      /*0x118a6*/ 1152,
+      /*0x2cb8*/ 940,
+      /*0x1e38*/ 552,
+      -1,
+      /*0xff24*/ 1083,
+      /*0x04b8*/ 385,
+      -1, -1,
+      /*0x01d7*/ 168,
+      /*0xfb17*/ 1079,
+      /*0x018b*/ 128,
+      -1,
+      /*0x1f0b*/ 657,
+      /*0x00b5*/ 25,
+      /*0x118a4*/ 1150,
+      -1, -1, -1,
+      /*0x01b5*/ 153,
+      /*0x1fec*/ 792,
+      /*0x046c*/ 351,
+      /*0x10b5*/ 505,
+      /*0x1eec*/ 644,
+      /*0x016c*/ 110,
+      /*0x051e*/ 436,
+      /*0x0184*/ 123,
+      /*0x1e6c*/ 578,
+      -1,
+      /*0x118a0*/ 1146,
+      /*0x04ec*/ 411,
+      /*0x1fca*/ 772,
+      /*0x03ec*/ 285,
+      -1,
+      /*0x1eca*/ 627,
+      /*0x014a*/ 93,
+      /*0x024a*/ 226,
+      /*0x2cca*/ 949,
+      /*0x1e4a*/ 561,
+      /*0x0508*/ 425,
+      -1,
+      /*0x118bd*/ 1175,
+      /*0x004a*/ 8,
+      -1, -1,
+      /*0x1fcc*/ 774,
+      /*0x1f2a*/ 670,
+      /*0x10aa*/ 494,
+      /*0x1ecc*/ 628,
+      /*0x014c*/ 94,
+      /*0x024c*/ 227,
+      /*0x2ccc*/ 950,
+      /*0x1e4c*/ 562,
+      -1, -1,
+      /*0x052c*/ 443,
+      /*0x004c*/ 10,
+      -1,
+      /*0xfb16*/ 1078,
+      /*0x1fd6*/ 777,
+      /*0xa726*/ 1004,
+      -1,
+      /*0x1ed6*/ 633,
+      /*0x0156*/ 99,
+      -1,
+      /*0x2cd6*/ 955,
+      /*0x1e56*/ 567,
+      -1, -1,
+      /*0x04d6*/ 400,
+      /*0x0056*/ 20,
+      /*0x03d6*/ 274,
+      -1,
+      /*0x0528*/ 441,
+      /*0xa724*/ 1003,
+      -1, -1,
+      /*0x24bd*/ 831,
+      /*0x1fe2*/ 783,
+      /*0x0462*/ 346,
+      /*0x2c62*/ 898,
+      /*0x1ee2*/ 639,
+      /*0x0162*/ 105,
+      /*0x0193*/ 133,
+      /*0x2ce2*/ 961,
+      /*0x1e62*/ 573,
+      -1,
+      /*0x24cf*/ 849,
+      /*0x04e2*/ 406,
+      -1,
+      /*0x03e2*/ 280,
+      /*0x10415*/ 1127,
+      /*0x019c*/ 138,
+      /*0x052e*/ 444,
+      /*0x1f1c*/ 666,
+      -1,
+      /*0x1f95*/ 727,
+      /*0x0415*/ 318,
+      /*0x2c15*/ 871,
+      /*0x1fc8*/ 770,
+      -1,
+      /*0x0532*/ 446,
+      /*0x1ec8*/ 626,
+      -1,
+      /*0x0248*/ 225,
+      /*0x2cc8*/ 948,
+      /*0x1e48*/ 560,
+      /*0x10401*/ 1107,
+      /*0x0395*/ 246,
+      /*0x053a*/ 454,
+      /*0x0048*/ 7,
+      -1,
+      /*0x1f81*/ 707,
+      /*0x0401*/ 298,
+      /*0x2c01*/ 851,
+      /*0xff22*/ 1081,
+      /*0x2165*/ 812,
+      /*0x1feb*/ 791,
+      /*0x0538*/ 452,
+      /*0x2c6b*/ 903,
+      /*0x2161*/ 808,
+      /*0x1fc4*/ 767,
+      -1,
+      /*0x2ceb*/ 962,
+      /*0x1ec4*/ 624,
+      /*0x118a2*/ 1148,
+      /*0x0244*/ 222,
+      /*0x2cc4*/ 946,
+      /*0x1e44*/ 558,
+      -1, -1,
+      /*0x1fd3*/ 776,
+      /*0x0044*/ 3,
+      /*0x1fea*/ 790,
+      /*0x046a*/ 350,
+      /*0x1f08*/ 654,
+      /*0x1eea*/ 643,
+      /*0x016a*/ 109,
+      -1,
+      /*0x00db*/ 52,
+      /*0x1e6a*/ 577,
+      /*0xa77b*/ 1041,
+      /*0x0053*/ 17,
+      /*0x04ea*/ 410,
+      /*0x01db*/ 170,
+      /*0x03ea*/ 284,
+      /*0x1f5b*/ 695,
+      -1, -1,
+      /*0x01ac*/ 147,
+      -1,
+      /*0x1f2c*/ 672,
+      /*0x10ac*/ 496,
+      /*0x054a*/ 470,
+      /*0x1fe8*/ 788,
+      /*0x0468*/ 349,
+      -1,
+      /*0x1ee8*/ 642,
+      /*0x0168*/ 108,
+      -1, -1,
+      /*0x1e68*/ 576,
+      -1, -1,
+      /*0x04e8*/ 409,
+      /*0x1f0d*/ 659,
+      /*0x03e8*/ 283,
+      /*0x054c*/ 472,
+      /*0xff35*/ 1100,
+      /*0x1f28*/ 668,
+      /*0x10a8*/ 492,
+      -1, -1,
+      /*0x1fe4*/ 785,
+      /*0x0464*/ 347,
+      /*0x2c64*/ 900,
+      /*0x1ee4*/ 640,
+      /*0x0164*/ 106,
+      /*0x118b5*/ 1167,
+      -1,
+      /*0x1e64*/ 574,
+      /*0x0556*/ 482,
+      -1,
+      /*0x04e4*/ 407,
+      /*0xa722*/ 1002,
+      /*0x03e4*/ 281,
+      -1,
+      /*0x01ae*/ 148,
+      /*0x216f*/ 822,
+      /*0x1f2e*/ 674,
+      /*0x10ae*/ 498,
+      -1, -1,
+      /*0xff2a*/ 1089,
+      -1,
+      /*0x01b2*/ 151,
+      -1,
+      /*0xa77d*/ 1042,
+      /*0x10b2*/ 502,
+      -1,
+      /*0xfb14*/ 1076,
+      /*0x1fbc*/ 763,
+      -1,
+      /*0x118aa*/ 1156,
+      /*0x1ebc*/ 620,
+      /*0x1f3a*/ 678,
+      /*0x10ba*/ 510,
+      /*0x2cbc*/ 942,
+      /*0x1e3c*/ 554,
+      -1, -1,
+      /*0x04bc*/ 387,
+      /*0x01b8*/ 155,
+      /*0x2169*/ 816,
+      /*0x1f38*/ 676,
+      /*0x10b8*/ 508,
+      /*0xfb06*/ 1074,
+      /*0x0460*/ 345,
+      /*0x2c60*/ 897,
+      /*0x1ee0*/ 638,
+      /*0x0160*/ 104,
+      /*0x0548*/ 468,
+      /*0x2ce0*/ 960,
+      /*0x1e60*/ 572,
+      -1, -1,
+      /*0x04e0*/ 405,
+      -1,
+      /*0x03e0*/ 279,
+      -1, -1, -1,
+      /*0x2126*/ 803,
+      -1,
+      /*0x1fbe*/ 764,
+      -1,
+      /*0x01ec*/ 178,
+      /*0x1ebe*/ 621,
+      /*0x1f6c*/ 702,
+      /*0x023e*/ 219,
+      /*0x2cbe*/ 943,
+      /*0x1e3e*/ 555,
+      /*0x00ca*/ 36,
+      /*0x0544*/ 464,
+      /*0x04be*/ 388,
+      /*0x1ffc*/ 802,
+      /*0x047c*/ 359,
+      /*0x01ca*/ 161,
+      /*0x1efc*/ 652,
+      /*0x1f4a*/ 686,
+      -1, -1,
+      /*0x1e7c*/ 586,
+      /*0x0553*/ 479,
+      /*0x1fb6*/ 757,
+      /*0x04fc*/ 419,
+      /*0x00cc*/ 38,
+      /*0x1eb6*/ 617,
+      /*0x0136*/ 83,
+      -1,
+      /*0x2cb6*/ 939,
+      /*0x1e36*/ 551,
+      /*0xa72a*/ 1006,
+      /*0x1f4c*/ 688,
+      /*0x04b6*/ 384,
+      /*0x1fd2*/ 775,
+      -1, -1,
+      /*0x1ed2*/ 631,
+      /*0x0152*/ 97,
+      /*0x00d6*/ 48,
+      /*0x2cd2*/ 953,
+      /*0x1e52*/ 565,
+      -1, -1,
+      /*0x04d2*/ 398,
+      /*0x0052*/ 16,
+      /*0x1f56*/ 693,
+      -1, -1, -1,
+      /*0xfb02*/ 1070,
+      /*0x1ed0*/ 630,
+      /*0x0150*/ 96,
+      -1,
+      /*0x2cd0*/ 952,
+      /*0x1e50*/ 564,
+      -1, -1,
+      /*0x04d0*/ 397,
+      /*0x0050*/ 14,
+      /*0x03d0*/ 271,
+      -1,
+      /*0x1fda*/ 781,
+      /*0x01e2*/ 173,
+      -1,
+      /*0x1eda*/ 635,
+      /*0x015a*/ 101,
+      /*0xff2c*/ 1091,
+      /*0x2cda*/ 957,
+      /*0x1e5a*/ 569,
+      -1,
+      /*0xa66c*/ 987,
+      /*0x04da*/ 402,
+      /*0x005a*/ 24,
+      /*0x03da*/ 276,
+      -1,
+      /*0x2c6d*/ 904,
+      /*0x118ac*/ 1158,
+      -1,
+      /*0x00c8*/ 34,
+      /*0x2ced*/ 963,
+      /*0xfb04*/ 1072,
+      /*0xa64a*/ 970,
+      -1,
+      /*0x01c8*/ 160,
+      /*0xff28*/ 1087,
+      /*0x1f48*/ 684,
+      /*0x1fc2*/ 765,
+      -1, -1,
+      /*0x1ec2*/ 623,
+      -1,
+      /*0x053c*/ 456,
+      /*0x2cc2*/ 945,
+      /*0x1e42*/ 557,
+      /*0x118a8*/ 1154,
+      /*0xa64c*/ 971,
+      /*0x0181*/ 121,
+      /*0x0042*/ 1,
+      /*0x03c2*/ 269,
+      -1,
+      /*0x00c4*/ 30,
+      -1, -1,
+      /*0x1f6b*/ 701,
+      /*0xff2e*/ 1093,
+      /*0x01c4*/ 157,
+      -1,
+      /*0x2167*/ 814,
+      /*0x10c4*/ 520,
+      /*0xa656*/ 976,
+      /*0x00d3*/ 45,
+      -1,
+      /*0xff32*/ 1097,
+      -1,
+      /*0x118ae*/ 1160,
+      /*0x01d3*/ 166,
+      -1,
+      /*0x01ea*/ 177,
+      /*0xfb00*/ 1068,
+      /*0x1f6a*/ 700,
+      /*0xff3a*/ 1105,
+      -1,
+      /*0x118b2*/ 1164,
+      -1,
+      /*0x053e*/ 458,
+      /*0x0145*/ 90,
+      /*0x0245*/ 223,
+      -1,
+      /*0xa662*/ 982,
+      /*0xff38*/ 1103,
+      /*0x118ba*/ 1172,
+      /*0x04c5*/ 392,
+      /*0x0045*/ 4,
+      -1, -1,
+      /*0xa72c*/ 1007,
+      -1,
+      /*0xfb13*/ 1075,
+      /*0x01e8*/ 176,
+      /*0x118b8*/ 1170,
+      /*0x1f68*/ 698,
+      -1, -1, -1,
+      /*0x0536*/ 450,
+      /*0x046e*/ 352,
+      /*0x2c6e*/ 905,
+      /*0x1eee*/ 645,
+      /*0x016e*/ 111,
+      /*0xa648*/ 969,
+      -1,
+      /*0x1e6e*/ 579,
+      -1,
+      /*0xa728*/ 1005,
+      /*0x04ee*/ 412,
+      /*0x0552*/ 478,
+      /*0x03ee*/ 286,
+      /*0x01e4*/ 174,
+      /*0x1fe6*/ 786,
+      /*0x0466*/ 348,
+      /*0x1ff9*/ 799,
+      /*0x1ee6*/ 641,
+      /*0x0166*/ 107,
+      -1,
+      /*0x0179*/ 117,
+      /*0x1e66*/ 575,
+      /*0x24ba*/ 828,
+      -1,
+      /*0x04e6*/ 408,
+      /*0x0550*/ 476,
+      /*0x03e6*/ 282,
+      /*0xa644*/ 967,
+      /*0x03f9*/ 292,
+      /*0xa72e*/ 1008,
+      -1,
+      /*0x24b8*/ 826,
+      /*0x1ece*/ 629,
+      /*0x014e*/ 95,
+      /*0x024e*/ 228,
+      /*0x2cce*/ 951,
+      /*0x1e4e*/ 563,
+      /*0xa732*/ 1009,
+      -1,
+      /*0xa66a*/ 986,
+      /*0x004e*/ 12,
+      /*0x01bc*/ 156,
+      -1,
+      /*0x1f3c*/ 680,
+      /*0x10bc*/ 512,
+      /*0xa73a*/ 1013,
+      /*0x1fc6*/ 768,
+      -1, -1,
+      /*0x1ec6*/ 625,
+      -1,
+      /*0x0246*/ 224,
+      /*0x2cc6*/ 947,
+      /*0x1e46*/ 559,
+      /*0xa738*/ 1012,
+      -1,
+      /*0x01e0*/ 172,
+      /*0x0046*/ 5,
+      /*0x212a*/ 804,
+      -1,
+      /*0xa668*/ 985,
+      /*0x1fa9*/ 747,
+      /*0x0429*/ 338,
+      /*0x2c29*/ 891,
+      /*0x0542*/ 462,
+      -1,
+      /*0x24ca*/ 844,
+      /*0x1ed4*/ 632,
+      /*0x0154*/ 98,
+      -1,
+      /*0x2cd4*/ 954,
+      /*0x1e54*/ 566,
+      -1,
+      /*0x03a9*/ 265,
+      /*0x04d4*/ 399,
+      /*0x0054*/ 18,
+      /*0x1f3e*/ 682,
+      /*0x10be*/ 514,
+      /*0xa76c*/ 1038,
+      /*0xa664*/ 983,
+      /*0x24cc*/ 846,
+      -1,
+      /*0x04cd*/ 396,
+      /*0x004d*/ 11,
+      /*0x1fd8*/ 779,
+      /*0x01fc*/ 188,
+      -1,
+      /*0x1ed8*/ 634,
+      /*0x0158*/ 100,
+      /*0xa74a*/ 1021,
+      /*0x2cd8*/ 956,
+      /*0x1e58*/ 568,
+      -1,
+      /*0x2163*/ 810,
+      /*0x04d8*/ 401,
+      /*0x0058*/ 22,
+      /*0x03d8*/ 275,
+      /*0x10b6*/ 506,
+      /*0x1ec0*/ 622,
+      /*0x0545*/ 465,
+      /*0x00d2*/ 44,
+      /*0x2cc0*/ 944,
+      /*0x1e40*/ 556,
+      /*0xa74c*/ 1022,
+      -1,
+      /*0x04c0*/ 389,
+      /*0x1fb4*/ 756,
+      /*0x1f52*/ 691,
+      -1,
+      /*0x1eb4*/ 616,
+      /*0x0134*/ 82,
+      -1,
+      /*0x2cb4*/ 938,
+      /*0x1e34*/ 550,
+      /*0x00d0*/ 42,
+      -1,
+      /*0x04b4*/ 383,
+      /*0xa756*/ 1027,
+      -1,
+      /*0x1fb7*/ 758,
+      -1,
+      /*0x1f50*/ 690,
+      /*0xa660*/ 981,
+      /*0x1eb0*/ 614,
+      /*0x0130*/ 1179,
+      /*0x0230*/ 214,
+      /*0x2cb0*/ 936,
+      /*0x1e30*/ 548,
+      /*0x00da*/ 51,
+      -1,
+      /*0x04b0*/ 381,
+      -1,
+      /*0x03b0*/ 268,
+      /*0xa7b0*/ 1066,
+      /*0x24c8*/ 842,
+      -1,
+      /*0xa762*/ 1033,
+      /*0x1ede*/ 637,
+      /*0x015e*/ 103,
+      /*0x1fb9*/ 760,
+      /*0x2cde*/ 959,
+      /*0x1e5e*/ 571,
+      -1,
+      /*0x0139*/ 84,
+      /*0x04de*/ 404,
+      -1,
+      /*0x03de*/ 278,
+      /*0x1f6d*/ 703,
+      /*0x1fc7*/ 769,
+      /*0x0345*/ 229,
+      /*0x1fbb*/ 762,
+      /*0x054e*/ 474,
+      /*0x0147*/ 91,
+      /*0x00c2*/ 28,
+      /*0x013b*/ 85,
+      /*0x023b*/ 217,
+      /*0x24c4*/ 838,
+      /*0xa748*/ 1020,
+      /*0x04c7*/ 393,
+      /*0x0047*/ 6,
+      -1,
+      /*0x10c2*/ 518,
+      /*0x1fab*/ 749,
+      /*0x042b*/ 340,
+      /*0x2c2b*/ 893,
+      /*0x0055*/ 19,
+      /*0x03d5*/ 273,
+      -1,
+      /*0x0546*/ 466,
+      -1, -1,
+      /*0xa652*/ 974,
+      /*0x1fc3*/ 766,
+      -1,
+      /*0x03ab*/ 267,
+      /*0xa7ab*/ 1063,
+      /*0x0143*/ 89,
+      /*0x0243*/ 221,
+      -1,
+      /*0xa744*/ 1018,
+      -1, -1,
+      /*0x04c3*/ 391,
+      /*0x0043*/ 2,
+      -1,
+      /*0xa650*/ 973,
+      /*0x0554*/ 480,
+      -1,
+      /*0x00c5*/ 31,
+      -1, -1,
+      /*0xa76a*/ 1037,
+      -1,
+      /*0x01c5*/ 158,
+      /*0x054d*/ 473,
+      -1,
+      /*0x10c5*/ 521,
+      -1, -1,
+      /*0xa65a*/ 978,
+      /*0x118bc*/ 1174,
+      /*0x1ff2*/ 793,
+      /*0x0472*/ 354,
+      /*0x2c72*/ 908,
+      /*0x1ef2*/ 647,
+      /*0x0172*/ 113,
+      -1,
+      /*0x2cf2*/ 964,
+      /*0x1e72*/ 581,
+      /*0x2132*/ 806,
+      -1,
+      /*0x04f2*/ 414,
+      /*0xa768*/ 1036,
+      /*0x1faf*/ 753,
+      /*0x042f*/ 344,
+      -1,
+      /*0x01ee*/ 179,
+      /*0x0540*/ 460,
+      /*0x1f6e*/ 704,
+      -1,
+      /*0x10427*/ 1145,
+      -1,
+      /*0xfb15*/ 1077,
+      -1,
+      /*0xa642*/ 966,
+      /*0x1fa7*/ 745,
+      /*0x0427*/ 336,
+      /*0x2c27*/ 889,
+      /*0x0534*/ 448,
+      -1,
+      /*0x01e6*/ 175,
+      /*0xa764*/ 1034,
+      -1,
+      /*0x118be*/ 1176,
+      -1, -1,
+      /*0x24bc*/ 830,
+      /*0x03a7*/ 263,
+      /*0xfb01*/ 1069,
+      -1,
+      /*0x00ce*/ 40,
+      /*0x0537*/ 451,
+      -1,
+      /*0xff36*/ 1101,
+      -1,
+      /*0x1edc*/ 636,
+      /*0x015c*/ 102,
+      -1,
+      /*0x2cdc*/ 958,
+      /*0x1e5c*/ 570,
+      /*0x216c*/ 819,
+      -1,
+      /*0x04dc*/ 403,
+      /*0x118b6*/ 1168,
+      /*0x03dc*/ 277,
+      -1,
+      /*0x1fcb*/ 773,
+      /*0x00c6*/ 32,
+      -1,
+      /*0xa73c*/ 1014,
+      /*0x1fb3*/ 755,
+      /*0x0539*/ 453,
+      /*0x0470*/ 353,
+      /*0x2c70*/ 907,
+      /*0x1ef0*/ 646,
+      /*0x0170*/ 112,
+      /*0x04cb*/ 395,
+      /*0x004b*/ 9,
+      /*0x1e70*/ 580,
+      /*0x24be*/ 832,
+      /*0x0547*/ 467,
+      /*0x04f0*/ 413,
+      /*0x053b*/ 455,
+      /*0x03f0*/ 287,
+      /*0xa760*/ 1032,
+      /*0x00d4*/ 46,
+      /*0x0555*/ 481,
+      /*0x01a9*/ 146,
+      -1,
+      /*0x1f29*/ 669,
+      /*0x10a9*/ 493,
+      -1,
+      /*0x1f54*/ 692,
+      /*0x00cd*/ 39,
+      /*0x1fad*/ 751,
+      /*0x042d*/ 342,
+      /*0x2c2d*/ 895,
+      -1,
+      /*0x01cd*/ 163,
+      /*0x24b6*/ 824,
+      /*0x1f4d*/ 689,
+      /*0x10cd*/ 523,
+      /*0xa73e*/ 1015,
+      -1,
+      /*0x0543*/ 463,
+      /*0x00d8*/ 49,
+      /*0xa666*/ 984,
+      /*0xa7ad*/ 1065,
+      /*0x047e*/ 360,
+      /*0x2c7e*/ 910,
+      /*0x1efe*/ 653,
+      -1,
+      /*0xa7b1*/ 1067,
+      -1,
+      /*0x1e7e*/ 587,
+      -1,
+      /*0x00c0*/ 26,
+      /*0x04fe*/ 420,
+      /*0x2162*/ 809,
+      /*0x03fe*/ 295,
+      -1,
+      /*0xa64e*/ 972,
+      /*0xa736*/ 1011,
+      -1,
+      /*0x10c0*/ 516,
+      -1, -1,
+      /*0x1ff4*/ 795,
+      /*0x0474*/ 355,
+      -1,
+      /*0x1ef4*/ 648,
+      /*0x0174*/ 114,
+      -1,
+      /*0xa752*/ 1025,
+      /*0x1e74*/ 582,
+      /*0x10b4*/ 504,
+      /*0x10403*/ 1109,
+      /*0x04f4*/ 415,
+      /*0xa646*/ 968,
+      /*0x03f4*/ 289,
+      /*0x1fc9*/ 771,
+      /*0x1f83*/ 709,
+      /*0x0403*/ 300,
+      /*0x2c03*/ 853,
+      /*0x0149*/ 92,
+      /*0x01b7*/ 154,
+      -1,
+      /*0xa750*/ 1024,
+      /*0x10b7*/ 507,
+      /*0x10b0*/ 500,
+      /*0x04c9*/ 394,
+      /*0x0049*/ 1178,
+      /*0x0141*/ 88,
+      /*0x0241*/ 220,
+      -1,
+      /*0x00de*/ 55,
+      /*0xa654*/ 975,
+      /*0x216b*/ 818,
+      /*0x04c1*/ 390,
+      /*0x0041*/ 0,
+      /*0x01de*/ 171,
+      /*0xa75a*/ 1029,
+      -1,
+      /*0x24c2*/ 836,
+      -1,
+      /*0x10425*/ 1143,
+      -1,
+      /*0x1f39*/ 677,
+      /*0x10b9*/ 509,
+      /*0x00c7*/ 33,
+      /*0x1fa5*/ 743,
+      /*0x0425*/ 334,
+      /*0x2c25*/ 887,
+      /*0x216a*/ 817,
+      /*0x01c7*/ 159,
+      /*0x00d5*/ 47,
+      /*0xa658*/ 977,
+      /*0x10c7*/ 522,
+      /*0x1f3b*/ 679,
+      /*0x10bb*/ 511,
+      /*0x01d5*/ 167,
+      -1,
+      /*0x03a5*/ 261,
+      /*0x0372*/ 231,
+      -1, -1,
+      /*0xa742*/ 1017,
+      /*0xa640*/ 965,
+      /*0x054b*/ 471,
+      -1,
+      /*0x1f2b*/ 671,
+      /*0x10ab*/ 495,
+      /*0x0533*/ 447,
+      /*0x00c3*/ 29,
+      /*0x2168*/ 815,
+      -1, -1,
+      /*0x10423*/ 1141,
+      /*0x24c5*/ 839,
+      -1,
+      /*0x10421*/ 1139,
+      /*0x10c3*/ 519,
+      /*0x1fa3*/ 741,
+      /*0x0423*/ 332,
+      /*0x2c23*/ 885,
+      /*0x1fa1*/ 739,
+      /*0x0421*/ 330,
+      /*0x2c21*/ 883,
+      -1, -1, -1, -1, -1,
+      /*0x2164*/ 811,
+      /*0x03a3*/ 259,
+      /*0x1ff6*/ 796,
+      /*0x0476*/ 356,
+      /*0x03a1*/ 258,
+      /*0x1ef6*/ 649,
+      /*0x0176*/ 115,
+      -1,
+      /*0x0531*/ 445,
+      /*0x1e76*/ 583,
+      -1, -1,
+      /*0x04f6*/ 416,
+      /*0xa65e*/ 980,
+      /*0x01f2*/ 182,
+      /*0x1ffa*/ 800,
+      /*0x047a*/ 358,
+      -1,
+      /*0x1efa*/ 651,
+      -1,
+      /*0x0051*/ 15,
+      /*0x03d1*/ 272,
+      /*0x1e7a*/ 585,
+      /*0xff29*/ 1088,
+      -1,
+      /*0x04fa*/ 418,
+      /*0x01af*/ 149,
+      /*0x03fa*/ 293,
+      /*0x1f2f*/ 675,
+      /*0x10af*/ 499,
+      /*0x0370*/ 230,
+      /*0xa76e*/ 1039,
+      -1,
+      /*0x118a9*/ 1155,
+      -1, -1, -1,
+      /*0x24ce*/ 848,
+      /*0x01a7*/ 145,
+      -1, -1,
+      /*0x10a7*/ 491,
+      -1,
+      /*0x2160*/ 807,
+      -1,
+      /*0xa766*/ 1035,
+      -1,
+      /*0xa779*/ 1040,
+      -1,
+      /*0x0549*/ 469,
+      /*0x00dc*/ 53,
+      -1,
+      /*0x1ff8*/ 798,
+      /*0x0478*/ 357,
+      /*0x24c6*/ 840,
+      /*0x1ef8*/ 650,
+      /*0x0178*/ 116,
+      /*0x0541*/ 461,
+      -1,
+      /*0x1e78*/ 584,
+      /*0xa74e*/ 1023,
+      -1,
+      /*0x04f8*/ 417,
+      -1,
+      /*0x00cb*/ 37,
+      -1, -1, -1,
+      /*0xff34*/ 1099,
+      /*0x01cb*/ 162,
+      -1,
+      /*0x1f4b*/ 687,
+      -1,
+      /*0x01b3*/ 152,
+      /*0x01f0*/ 180,
+      -1,
+      /*0x10b3*/ 503,
+      /*0xa746*/ 1019,
+      /*0x118b4*/ 1166,
+      /*0x1041d*/ 1135,
+      /*0x24cd*/ 847,
+      /*0xff37*/ 1102,
+      /*0xff30*/ 1095,
+      /*0x10405*/ 1111,
+      /*0x1f9d*/ 735,
+      /*0x041d*/ 326,
+      /*0x2c1d*/ 879,
+      -1,
+      /*0x1f85*/ 711,
+      /*0x0405*/ 302,
+      /*0x2c05*/ 855,
+      /*0x118b7*/ 1169,
+      /*0x118b0*/ 1162,
+      -1, -1,
+      /*0xa754*/ 1026,
+      /*0x039d*/ 254,
+      -1, -1,
+      /*0x1f2d*/ 673,
+      /*0x10ad*/ 497,
+      /*0xff39*/ 1104,
+      /*0x01b1*/ 150,
+      /*0x24c0*/ 834,
+      -1,
+      /*0x10b1*/ 501,
+      -1, -1, -1, -1,
+      /*0x01fe*/ 189,
+      /*0x118b9*/ 1171,
+      /*0x1041b*/ 1133,
+      -1, -1,
+      /*0xa758*/ 1028,
+      -1,
+      /*0x1f9b*/ 733,
+      /*0x041b*/ 324,
+      /*0x2c1b*/ 877,
+      /*0x1e9b*/ 604,
+      /*0xa65c*/ 979,
+      /*0x118bb*/ 1173,
+      -1,
+      /*0xff2b*/ 1090,
+      -1,
+      /*0xa740*/ 1016,
+      /*0x24b7*/ 825,
+      -1,
+      /*0x039b*/ 252,
+      /*0x01f4*/ 183,
+      /*0x0551*/ 477,
+      /*0x216d*/ 820,
+      -1,
+      /*0x118ab*/ 1157,
+      /*0x10419*/ 1131,
+      -1,
+      /*0xa734*/ 1010,
+      /*0x00c9*/ 35,
+      -1,
+      /*0x1f99*/ 731,
+      /*0x0419*/ 322,
+      /*0x2c19*/ 875,
+      /*0x1e99*/ 602,
+      -1,
+      /*0x1f49*/ 685,
+      /*0x00c1*/ 27,
+      /*0x24b9*/ 827,
+      -1, -1, -1, -1,
+      /*0x0399*/ 250,
+      -1,
+      /*0x10c1*/ 517,
+      /*0x1040f*/ 1121,
+      /*0x24c7*/ 841,
+      -1,
+      /*0x24bb*/ 829,
+      -1,
+      /*0x1f8f*/ 721,
+      /*0x040f*/ 312,
+      /*0x2c0f*/ 865,
+      -1,
+      /*0x10409*/ 1115,
+      /*0xa75e*/ 1031,
+      -1, -1, -1,
+      /*0x1f89*/ 715,
+      /*0x0409*/ 306,
+      /*0x2c09*/ 859,
+      /*0x038f*/ 240,
+      -1,
+      /*0x0376*/ 232,
+      /*0xff2f*/ 1094,
+      /*0x10a5*/ 489,
+      /*0x1041f*/ 1137,
+      -1, -1,
+      /*0x24c3*/ 837,
+      /*0x0389*/ 236,
+      /*0x1f9f*/ 737,
+      /*0x041f*/ 328,
+      /*0x2c1f*/ 881,
+      /*0x118af*/ 1161,
+      -1,
+      /*0xff27*/ 1086,
+      -1, -1, -1, -1, -1,
+      /*0x10411*/ 1123,
+      /*0x039f*/ 256,
+      -1, -1,
+      /*0x118a7*/ 1153,
+      /*0x1f91*/ 723,
+      /*0x0411*/ 314,
+      /*0x2c11*/ 867,
+      /*0x2183*/ 823,
+      -1,
+      /*0x216e*/ 821,
+      -1, -1, -1, -1,
+      /*0x10a3*/ 487,
+      -1,
+      /*0x0391*/ 242,
+      /*0x10a1*/ 485,
+      -1, -1, -1, -1, -1,
+      /*0x2166*/ 813,
+      /*0x01f6*/ 184,
+      -1,
+      /*0x00d1*/ 43,
+      -1,
+      /*0xff33*/ 1098,
+      -1, -1,
+      /*0x01d1*/ 165,
+      -1, -1, -1, -1, -1,
+      /*0x01fa*/ 187,
+      /*0x118b3*/ 1165,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0xff2d*/ 1092,
+      -1, -1, -1, -1,
+      /*0xff31*/ 1096,
+      -1, -1, -1, -1,
+      /*0x118ad*/ 1159,
+      -1, -1, -1, -1,
+      /*0x118b1*/ 1163,
+      -1, -1,
+      /*0x24cb*/ 845,
+      -1, -1, -1,
+      /*0x01f8*/ 186,
+      -1, -1, -1, -1,
+      /*0xa75c*/ 1030,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0x019d*/ 139,
+      -1,
+      /*0x1f1d*/ 667,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0xff25*/ 1084,
+      -1, -1, -1, -1, -1,
+      /*0xa77e*/ 1043,
+      -1, -1, -1,
+      /*0x118a5*/ 1151,
+      -1, -1,
+      /*0x1f1b*/ 665,
+      -1, -1,
+      /*0x24c9*/ 843,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0x24c1*/ 835,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0xff23*/ 1082,
+      -1, -1,
+      /*0xff21*/ 1080,
+      /*0x1f19*/ 663,
+      -1, -1, -1, -1, -1,
+      /*0x118a3*/ 1149,
+      /*0x212b*/ 805,
+      -1,
+      /*0x118a1*/ 1147,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0x018f*/ 130,
+      -1,
+      /*0x1f0f*/ 661,
+      -1, -1, -1, -1, -1, -1,
+      /*0x0189*/ 126,
+      -1,
+      /*0x1f09*/ 655,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1,
+      /*0x019f*/ 140,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0x0191*/ 132,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0xfb03*/ 1071,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0xfb05*/ 1073
+    };
+
+  if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
+    {
+      register int key = onigenc_unicode_CaseFold_11_hash(code);
+
+      if (key <= MAX_HASH_VALUE && key >= 0)
+        {
+          register short s = wordlist[key];
+
+          if (s >= 0 && code1_equal(code, CaseFold_11_Table[s].from))
+            return &CaseFold_11_Table[s].to;
+        }
+    }
+  return 0;
+}
+
+static const CaseUnfold_11_Type CaseUnfold_11_Table[] = {
+#define CaseUnfold_11 (*(CaseUnfold_11_Type (*)[1054])(CaseUnfold_11_Table+0))
+  {0x0061, {1, {0x0041}}},
+  {0x0062, {1, {0x0042}}},
+  {0x0063, {1, {0x0043}}},
+  {0x0064, {1, {0x0044}}},
+  {0x0065, {1, {0x0045}}},
+  {0x0066, {1, {0x0046}}},
+  {0x0067, {1, {0x0047}}},
+  {0x0068, {1, {0x0048}}},
+  {0x006a, {1, {0x004a}}},
+  {0x006b, {2, {0x004b, 0x212a}}},
+  {0x006c, {1, {0x004c}}},
+  {0x006d, {1, {0x004d}}},
+  {0x006e, {1, {0x004e}}},
+  {0x006f, {1, {0x004f}}},
+  {0x0070, {1, {0x0050}}},
+  {0x0071, {1, {0x0051}}},
+  {0x0072, {1, {0x0052}}},
+  {0x0073, {2, {0x0053, 0x017f}}},
+  {0x0074, {1, {0x0054}}},
+  {0x0075, {1, {0x0055}}},
+  {0x0076, {1, {0x0056}}},
+  {0x0077, {1, {0x0057}}},
+  {0x0078, {1, {0x0058}}},
+  {0x0079, {1, {0x0059}}},
+  {0x007a, {1, {0x005a}}},
+  {0x00e0, {1, {0x00c0}}},
+  {0x00e1, {1, {0x00c1}}},
+  {0x00e2, {1, {0x00c2}}},
+  {0x00e3, {1, {0x00c3}}},
+  {0x00e4, {1, {0x00c4}}},
+  {0x00e5, {2, {0x00c5, 0x212b}}},
+  {0x00e6, {1, {0x00c6}}},
+  {0x00e7, {1, {0x00c7}}},
+  {0x00e8, {1, {0x00c8}}},
+  {0x00e9, {1, {0x00c9}}},
+  {0x00ea, {1, {0x00ca}}},
+  {0x00eb, {1, {0x00cb}}},
+  {0x00ec, {1, {0x00cc}}},
+  {0x00ed, {1, {0x00cd}}},
+  {0x00ee, {1, {0x00ce}}},
+  {0x00ef, {1, {0x00cf}}},
+  {0x00f0, {1, {0x00d0}}},
+  {0x00f1, {1, {0x00d1}}},
+  {0x00f2, {1, {0x00d2}}},
+  {0x00f3, {1, {0x00d3}}},
+  {0x00f4, {1, {0x00d4}}},
+  {0x00f5, {1, {0x00d5}}},
+  {0x00f6, {1, {0x00d6}}},
+  {0x00f8, {1, {0x00d8}}},
+  {0x00f9, {1, {0x00d9}}},
+  {0x00fa, {1, {0x00da}}},
+  {0x00fb, {1, {0x00db}}},
+  {0x00fc, {1, {0x00dc}}},
+  {0x00fd, {1, {0x00dd}}},
+  {0x00fe, {1, {0x00de}}},
+  {0x00ff, {1, {0x0178}}},
+  {0x0101, {1, {0x0100}}},
+  {0x0103, {1, {0x0102}}},
+  {0x0105, {1, {0x0104}}},
+  {0x0107, {1, {0x0106}}},
+  {0x0109, {1, {0x0108}}},
+  {0x010b, {1, {0x010a}}},
+  {0x010d, {1, {0x010c}}},
+  {0x010f, {1, {0x010e}}},
+  {0x0111, {1, {0x0110}}},
+  {0x0113, {1, {0x0112}}},
+  {0x0115, {1, {0x0114}}},
+  {0x0117, {1, {0x0116}}},
+  {0x0119, {1, {0x0118}}},
+  {0x011b, {1, {0x011a}}},
+  {0x011d, {1, {0x011c}}},
+  {0x011f, {1, {0x011e}}},
+  {0x0121, {1, {0x0120}}},
+  {0x0123, {1, {0x0122}}},
+  {0x0125, {1, {0x0124}}},
+  {0x0127, {1, {0x0126}}},
+  {0x0129, {1, {0x0128}}},
+  {0x012b, {1, {0x012a}}},
+  {0x012d, {1, {0x012c}}},
+  {0x012f, {1, {0x012e}}},
+  {0x0133, {1, {0x0132}}},
+  {0x0135, {1, {0x0134}}},
+  {0x0137, {1, {0x0136}}},
+  {0x013a, {1, {0x0139}}},
+  {0x013c, {1, {0x013b}}},
+  {0x013e, {1, {0x013d}}},
+  {0x0140, {1, {0x013f}}},
+  {0x0142, {1, {0x0141}}},
+  {0x0144, {1, {0x0143}}},
+  {0x0146, {1, {0x0145}}},
+  {0x0148, {1, {0x0147}}},
+  {0x014b, {1, {0x014a}}},
+  {0x014d, {1, {0x014c}}},
+  {0x014f, {1, {0x014e}}},
+  {0x0151, {1, {0x0150}}},
+  {0x0153, {1, {0x0152}}},
+  {0x0155, {1, {0x0154}}},
+  {0x0157, {1, {0x0156}}},
+  {0x0159, {1, {0x0158}}},
+  {0x015b, {1, {0x015a}}},
+  {0x015d, {1, {0x015c}}},
+  {0x015f, {1, {0x015e}}},
+  {0x0161, {1, {0x0160}}},
+  {0x0163, {1, {0x0162}}},
+  {0x0165, {1, {0x0164}}},
+  {0x0167, {1, {0x0166}}},
+  {0x0169, {1, {0x0168}}},
+  {0x016b, {1, {0x016a}}},
+  {0x016d, {1, {0x016c}}},
+  {0x016f, {1, {0x016e}}},
+  {0x0171, {1, {0x0170}}},
+  {0x0173, {1, {0x0172}}},
+  {0x0175, {1, {0x0174}}},
+  {0x0177, {1, {0x0176}}},
+  {0x017a, {1, {0x0179}}},
+  {0x017c, {1, {0x017b}}},
+  {0x017e, {1, {0x017d}}},
+  {0x0180, {1, {0x0243}}},
+  {0x0183, {1, {0x0182}}},
+  {0x0185, {1, {0x0184}}},
+  {0x0188, {1, {0x0187}}},
+  {0x018c, {1, {0x018b}}},
+  {0x0192, {1, {0x0191}}},
+  {0x0195, {1, {0x01f6}}},
+  {0x0199, {1, {0x0198}}},
+  {0x019a, {1, {0x023d}}},
+  {0x019e, {1, {0x0220}}},
+  {0x01a1, {1, {0x01a0}}},
+  {0x01a3, {1, {0x01a2}}},
+  {0x01a5, {1, {0x01a4}}},
+  {0x01a8, {1, {0x01a7}}},
+  {0x01ad, {1, {0x01ac}}},
+  {0x01b0, {1, {0x01af}}},
+  {0x01b4, {1, {0x01b3}}},
+  {0x01b6, {1, {0x01b5}}},
+  {0x01b9, {1, {0x01b8}}},
+  {0x01bd, {1, {0x01bc}}},
+  {0x01bf, {1, {0x01f7}}},
+  {0x01c6, {2, {0x01c4, 0x01c5}}},
+  {0x01c9, {2, {0x01c7, 0x01c8}}},
+  {0x01cc, {2, {0x01ca, 0x01cb}}},
+  {0x01ce, {1, {0x01cd}}},
+  {0x01d0, {1, {0x01cf}}},
+  {0x01d2, {1, {0x01d1}}},
+  {0x01d4, {1, {0x01d3}}},
+  {0x01d6, {1, {0x01d5}}},
+  {0x01d8, {1, {0x01d7}}},
+  {0x01da, {1, {0x01d9}}},
+  {0x01dc, {1, {0x01db}}},
+  {0x01dd, {1, {0x018e}}},
+  {0x01df, {1, {0x01de}}},
+  {0x01e1, {1, {0x01e0}}},
+  {0x01e3, {1, {0x01e2}}},
+  {0x01e5, {1, {0x01e4}}},
+  {0x01e7, {1, {0x01e6}}},
+  {0x01e9, {1, {0x01e8}}},
+  {0x01eb, {1, {0x01ea}}},
+  {0x01ed, {1, {0x01ec}}},
+  {0x01ef, {1, {0x01ee}}},
+  {0x01f3, {2, {0x01f1, 0x01f2}}},
+  {0x01f5, {1, {0x01f4}}},
+  {0x01f9, {1, {0x01f8}}},
+  {0x01fb, {1, {0x01fa}}},
+  {0x01fd, {1, {0x01fc}}},
+  {0x01ff, {1, {0x01fe}}},
+  {0x0201, {1, {0x0200}}},
+  {0x0203, {1, {0x0202}}},
+  {0x0205, {1, {0x0204}}},
+  {0x0207, {1, {0x0206}}},
+  {0x0209, {1, {0x0208}}},
+  {0x020b, {1, {0x020a}}},
+  {0x020d, {1, {0x020c}}},
+  {0x020f, {1, {0x020e}}},
+  {0x0211, {1, {0x0210}}},
+  {0x0213, {1, {0x0212}}},
+  {0x0215, {1, {0x0214}}},
+  {0x0217, {1, {0x0216}}},
+  {0x0219, {1, {0x0218}}},
+  {0x021b, {1, {0x021a}}},
+  {0x021d, {1, {0x021c}}},
+  {0x021f, {1, {0x021e}}},
+  {0x0223, {1, {0x0222}}},
+  {0x0225, {1, {0x0224}}},
+  {0x0227, {1, {0x0226}}},
+  {0x0229, {1, {0x0228}}},
+  {0x022b, {1, {0x022a}}},
+  {0x022d, {1, {0x022c}}},
+  {0x022f, {1, {0x022e}}},
+  {0x0231, {1, {0x0230}}},
+  {0x0233, {1, {0x0232}}},
+  {0x023c, {1, {0x023b}}},
+  {0x023f, {1, {0x2c7e}}},
+  {0x0240, {1, {0x2c7f}}},
+  {0x0242, {1, {0x0241}}},
+  {0x0247, {1, {0x0246}}},
+  {0x0249, {1, {0x0248}}},
+  {0x024b, {1, {0x024a}}},
+  {0x024d, {1, {0x024c}}},
+  {0x024f, {1, {0x024e}}},
+  {0x0250, {1, {0x2c6f}}},
+  {0x0251, {1, {0x2c6d}}},
+  {0x0252, {1, {0x2c70}}},
+  {0x0253, {1, {0x0181}}},
+  {0x0254, {1, {0x0186}}},
+  {0x0256, {1, {0x0189}}},
+  {0x0257, {1, {0x018a}}},
+  {0x0259, {1, {0x018f}}},
+  {0x025b, {1, {0x0190}}},
+  {0x025c, {1, {0xa7ab}}},
+  {0x0260, {1, {0x0193}}},
+  {0x0261, {1, {0xa7ac}}},
+  {0x0263, {1, {0x0194}}},
+  {0x0265, {1, {0xa78d}}},
+  {0x0266, {1, {0xa7aa}}},
+  {0x0268, {1, {0x0197}}},
+  {0x0269, {1, {0x0196}}},
+  {0x026b, {1, {0x2c62}}},
+  {0x026c, {1, {0xa7ad}}},
+  {0x026f, {1, {0x019c}}},
+  {0x0271, {1, {0x2c6e}}},
+  {0x0272, {1, {0x019d}}},
+  {0x0275, {1, {0x019f}}},
+  {0x027d, {1, {0x2c64}}},
+  {0x0280, {1, {0x01a6}}},
+  {0x0283, {1, {0x01a9}}},
+  {0x0287, {1, {0xa7b1}}},
+  {0x0288, {1, {0x01ae}}},
+  {0x0289, {1, {0x0244}}},
+  {0x028a, {1, {0x01b1}}},
+  {0x028b, {1, {0x01b2}}},
+  {0x028c, {1, {0x0245}}},
+  {0x0292, {1, {0x01b7}}},
+  {0x029e, {1, {0xa7b0}}},
+  {0x0371, {1, {0x0370}}},
+  {0x0373, {1, {0x0372}}},
+  {0x0377, {1, {0x0376}}},
+  {0x037b, {1, {0x03fd}}},
+  {0x037c, {1, {0x03fe}}},
+  {0x037d, {1, {0x03ff}}},
+  {0x03ac, {1, {0x0386}}},
+  {0x03ad, {1, {0x0388}}},
+  {0x03ae, {1, {0x0389}}},
+  {0x03af, {1, {0x038a}}},
+  {0x03b1, {1, {0x0391}}},
+  {0x03b2, {2, {0x0392, 0x03d0}}},
+  {0x03b3, {1, {0x0393}}},
+  {0x03b4, {1, {0x0394}}},
+  {0x03b5, {2, {0x0395, 0x03f5}}},
+  {0x03b6, {1, {0x0396}}},
+  {0x03b7, {1, {0x0397}}},
+  {0x03b8, {3, {0x0398, 0x03d1, 0x03f4}}},
+  {0x03b9, {3, {0x0345, 0x0399, 0x1fbe}}},
+  {0x03ba, {2, {0x039a, 0x03f0}}},
+  {0x03bb, {1, {0x039b}}},
+  {0x03bc, {2, {0x00b5, 0x039c}}},
+  {0x03bd, {1, {0x039d}}},
+  {0x03be, {1, {0x039e}}},
+  {0x03bf, {1, {0x039f}}},
+  {0x03c0, {2, {0x03a0, 0x03d6}}},
+  {0x03c1, {2, {0x03a1, 0x03f1}}},
+  {0x03c3, {2, {0x03a3, 0x03c2}}},
+  {0x03c4, {1, {0x03a4}}},
+  {0x03c5, {1, {0x03a5}}},
+  {0x03c6, {2, {0x03a6, 0x03d5}}},
+  {0x03c7, {1, {0x03a7}}},
+  {0x03c8, {1, {0x03a8}}},
+  {0x03c9, {2, {0x03a9, 0x2126}}},
+  {0x03ca, {1, {0x03aa}}},
+  {0x03cb, {1, {0x03ab}}},
+  {0x03cc, {1, {0x038c}}},
+  {0x03cd, {1, {0x038e}}},
+  {0x03ce, {1, {0x038f}}},
+  {0x03d7, {1, {0x03cf}}},
+  {0x03d9, {1, {0x03d8}}},
+  {0x03db, {1, {0x03da}}},
+  {0x03dd, {1, {0x03dc}}},
+  {0x03df, {1, {0x03de}}},
+  {0x03e1, {1, {0x03e0}}},
+  {0x03e3, {1, {0x03e2}}},
+  {0x03e5, {1, {0x03e4}}},
+  {0x03e7, {1, {0x03e6}}},
+  {0x03e9, {1, {0x03e8}}},
+  {0x03eb, {1, {0x03ea}}},
+  {0x03ed, {1, {0x03ec}}},
+  {0x03ef, {1, {0x03ee}}},
+  {0x03f2, {1, {0x03f9}}},
+  {0x03f3, {1, {0x037f}}},
+  {0x03f8, {1, {0x03f7}}},
+  {0x03fb, {1, {0x03fa}}},
+  {0x0430, {1, {0x0410}}},
+  {0x0431, {1, {0x0411}}},
+  {0x0432, {1, {0x0412}}},
+  {0x0433, {1, {0x0413}}},
+  {0x0434, {1, {0x0414}}},
+  {0x0435, {1, {0x0415}}},
+  {0x0436, {1, {0x0416}}},
+  {0x0437, {1, {0x0417}}},
+  {0x0438, {1, {0x0418}}},
+  {0x0439, {1, {0x0419}}},
+  {0x043a, {1, {0x041a}}},
+  {0x043b, {1, {0x041b}}},
+  {0x043c, {1, {0x041c}}},
+  {0x043d, {1, {0x041d}}},
+  {0x043e, {1, {0x041e}}},
+  {0x043f, {1, {0x041f}}},
+  {0x0440, {1, {0x0420}}},
+  {0x0441, {1, {0x0421}}},
+  {0x0442, {1, {0x0422}}},
+  {0x0443, {1, {0x0423}}},
+  {0x0444, {1, {0x0424}}},
+  {0x0445, {1, {0x0425}}},
+  {0x0446, {1, {0x0426}}},
+  {0x0447, {1, {0x0427}}},
+  {0x0448, {1, {0x0428}}},
+  {0x0449, {1, {0x0429}}},
+  {0x044a, {1, {0x042a}}},
+  {0x044b, {1, {0x042b}}},
+  {0x044c, {1, {0x042c}}},
+  {0x044d, {1, {0x042d}}},
+  {0x044e, {1, {0x042e}}},
+  {0x044f, {1, {0x042f}}},
+  {0x0450, {1, {0x0400}}},
+  {0x0451, {1, {0x0401}}},
+  {0x0452, {1, {0x0402}}},
+  {0x0453, {1, {0x0403}}},
+  {0x0454, {1, {0x0404}}},
+  {0x0455, {1, {0x0405}}},
+  {0x0456, {1, {0x0406}}},
+  {0x0457, {1, {0x0407}}},
+  {0x0458, {1, {0x0408}}},
+  {0x0459, {1, {0x0409}}},
+  {0x045a, {1, {0x040a}}},
+  {0x045b, {1, {0x040b}}},
+  {0x045c, {1, {0x040c}}},
+  {0x045d, {1, {0x040d}}},
+  {0x045e, {1, {0x040e}}},
+  {0x045f, {1, {0x040f}}},
+  {0x0461, {1, {0x0460}}},
+  {0x0463, {1, {0x0462}}},
+  {0x0465, {1, {0x0464}}},
+  {0x0467, {1, {0x0466}}},
+  {0x0469, {1, {0x0468}}},
+  {0x046b, {1, {0x046a}}},
+  {0x046d, {1, {0x046c}}},
+  {0x046f, {1, {0x046e}}},
+  {0x0471, {1, {0x0470}}},
+  {0x0473, {1, {0x0472}}},
+  {0x0475, {1, {0x0474}}},
+  {0x0477, {1, {0x0476}}},
+  {0x0479, {1, {0x0478}}},
+  {0x047b, {1, {0x047a}}},
+  {0x047d, {1, {0x047c}}},
+  {0x047f, {1, {0x047e}}},
+  {0x0481, {1, {0x0480}}},
+  {0x048b, {1, {0x048a}}},
+  {0x048d, {1, {0x048c}}},
+  {0x048f, {1, {0x048e}}},
+  {0x0491, {1, {0x0490}}},
+  {0x0493, {1, {0x0492}}},
+  {0x0495, {1, {0x0494}}},
+  {0x0497, {1, {0x0496}}},
+  {0x0499, {1, {0x0498}}},
+  {0x049b, {1, {0x049a}}},
+  {0x049d, {1, {0x049c}}},
+  {0x049f, {1, {0x049e}}},
+  {0x04a1, {1, {0x04a0}}},
+  {0x04a3, {1, {0x04a2}}},
+  {0x04a5, {1, {0x04a4}}},
+  {0x04a7, {1, {0x04a6}}},
+  {0x04a9, {1, {0x04a8}}},
+  {0x04ab, {1, {0x04aa}}},
+  {0x04ad, {1, {0x04ac}}},
+  {0x04af, {1, {0x04ae}}},
+  {0x04b1, {1, {0x04b0}}},
+  {0x04b3, {1, {0x04b2}}},
+  {0x04b5, {1, {0x04b4}}},
+  {0x04b7, {1, {0x04b6}}},
+  {0x04b9, {1, {0x04b8}}},
+  {0x04bb, {1, {0x04ba}}},
+  {0x04bd, {1, {0x04bc}}},
+  {0x04bf, {1, {0x04be}}},
+  {0x04c2, {1, {0x04c1}}},
+  {0x04c4, {1, {0x04c3}}},
+  {0x04c6, {1, {0x04c5}}},
+  {0x04c8, {1, {0x04c7}}},
+  {0x04ca, {1, {0x04c9}}},
+  {0x04cc, {1, {0x04cb}}},
+  {0x04ce, {1, {0x04cd}}},
+  {0x04cf, {1, {0x04c0}}},
+  {0x04d1, {1, {0x04d0}}},
+  {0x04d3, {1, {0x04d2}}},
+  {0x04d5, {1, {0x04d4}}},
+  {0x04d7, {1, {0x04d6}}},
+  {0x04d9, {1, {0x04d8}}},
+  {0x04db, {1, {0x04da}}},
+  {0x04dd, {1, {0x04dc}}},
+  {0x04df, {1, {0x04de}}},
+  {0x04e1, {1, {0x04e0}}},
+  {0x04e3, {1, {0x04e2}}},
+  {0x04e5, {1, {0x04e4}}},
+  {0x04e7, {1, {0x04e6}}},
+  {0x04e9, {1, {0x04e8}}},
+  {0x04eb, {1, {0x04ea}}},
+  {0x04ed, {1, {0x04ec}}},
+  {0x04ef, {1, {0x04ee}}},
+  {0x04f1, {1, {0x04f0}}},
+  {0x04f3, {1, {0x04f2}}},
+  {0x04f5, {1, {0x04f4}}},
+  {0x04f7, {1, {0x04f6}}},
+  {0x04f9, {1, {0x04f8}}},
+  {0x04fb, {1, {0x04fa}}},
+  {0x04fd, {1, {0x04fc}}},
+  {0x04ff, {1, {0x04fe}}},
+  {0x0501, {1, {0x0500}}},
+  {0x0503, {1, {0x0502}}},
+  {0x0505, {1, {0x0504}}},
+  {0x0507, {1, {0x0506}}},
+  {0x0509, {1, {0x0508}}},
+  {0x050b, {1, {0x050a}}},
+  {0x050d, {1, {0x050c}}},
+  {0x050f, {1, {0x050e}}},
+  {0x0511, {1, {0x0510}}},
+  {0x0513, {1, {0x0512}}},
+  {0x0515, {1, {0x0514}}},
+  {0x0517, {1, {0x0516}}},
+  {0x0519, {1, {0x0518}}},
+  {0x051b, {1, {0x051a}}},
+  {0x051d, {1, {0x051c}}},
+  {0x051f, {1, {0x051e}}},
+  {0x0521, {1, {0x0520}}},
+  {0x0523, {1, {0x0522}}},
+  {0x0525, {1, {0x0524}}},
+  {0x0527, {1, {0x0526}}},
+  {0x0529, {1, {0x0528}}},
+  {0x052b, {1, {0x052a}}},
+  {0x052d, {1, {0x052c}}},
+  {0x052f, {1, {0x052e}}},
+  {0x0561, {1, {0x0531}}},
+  {0x0562, {1, {0x0532}}},
+  {0x0563, {1, {0x0533}}},
+  {0x0564, {1, {0x0534}}},
+  {0x0565, {1, {0x0535}}},
+  {0x0566, {1, {0x0536}}},
+  {0x0567, {1, {0x0537}}},
+  {0x0568, {1, {0x0538}}},
+  {0x0569, {1, {0x0539}}},
+  {0x056a, {1, {0x053a}}},
+  {0x056b, {1, {0x053b}}},
+  {0x056c, {1, {0x053c}}},
+  {0x056d, {1, {0x053d}}},
+  {0x056e, {1, {0x053e}}},
+  {0x056f, {1, {0x053f}}},
+  {0x0570, {1, {0x0540}}},
+  {0x0571, {1, {0x0541}}},
+  {0x0572, {1, {0x0542}}},
+  {0x0573, {1, {0x0543}}},
+  {0x0574, {1, {0x0544}}},
+  {0x0575, {1, {0x0545}}},
+  {0x0576, {1, {0x0546}}},
+  {0x0577, {1, {0x0547}}},
+  {0x0578, {1, {0x0548}}},
+  {0x0579, {1, {0x0549}}},
+  {0x057a, {1, {0x054a}}},
+  {0x057b, {1, {0x054b}}},
+  {0x057c, {1, {0x054c}}},
+  {0x057d, {1, {0x054d}}},
+  {0x057e, {1, {0x054e}}},
+  {0x057f, {1, {0x054f}}},
+  {0x0580, {1, {0x0550}}},
+  {0x0581, {1, {0x0551}}},
+  {0x0582, {1, {0x0552}}},
+  {0x0583, {1, {0x0553}}},
+  {0x0584, {1, {0x0554}}},
+  {0x0585, {1, {0x0555}}},
+  {0x0586, {1, {0x0556}}},
+  {0x1d79, {1, {0xa77d}}},
+  {0x1d7d, {1, {0x2c63}}},
+  {0x1e01, {1, {0x1e00}}},
+  {0x1e03, {1, {0x1e02}}},
+  {0x1e05, {1, {0x1e04}}},
+  {0x1e07, {1, {0x1e06}}},
+  {0x1e09, {1, {0x1e08}}},
+  {0x1e0b, {1, {0x1e0a}}},
+  {0x1e0d, {1, {0x1e0c}}},
+  {0x1e0f, {1, {0x1e0e}}},
+  {0x1e11, {1, {0x1e10}}},
+  {0x1e13, {1, {0x1e12}}},
+  {0x1e15, {1, {0x1e14}}},
+  {0x1e17, {1, {0x1e16}}},
+  {0x1e19, {1, {0x1e18}}},
+  {0x1e1b, {1, {0x1e1a}}},
+  {0x1e1d, {1, {0x1e1c}}},
+  {0x1e1f, {1, {0x1e1e}}},
+  {0x1e21, {1, {0x1e20}}},
+  {0x1e23, {1, {0x1e22}}},
+  {0x1e25, {1, {0x1e24}}},
+  {0x1e27, {1, {0x1e26}}},
+  {0x1e29, {1, {0x1e28}}},
+  {0x1e2b, {1, {0x1e2a}}},
+  {0x1e2d, {1, {0x1e2c}}},
+  {0x1e2f, {1, {0x1e2e}}},
+  {0x1e31, {1, {0x1e30}}},
+  {0x1e33, {1, {0x1e32}}},
+  {0x1e35, {1, {0x1e34}}},
+  {0x1e37, {1, {0x1e36}}},
+  {0x1e39, {1, {0x1e38}}},
+  {0x1e3b, {1, {0x1e3a}}},
+  {0x1e3d, {1, {0x1e3c}}},
+  {0x1e3f, {1, {0x1e3e}}},
+  {0x1e41, {1, {0x1e40}}},
+  {0x1e43, {1, {0x1e42}}},
+  {0x1e45, {1, {0x1e44}}},
+  {0x1e47, {1, {0x1e46}}},
+  {0x1e49, {1, {0x1e48}}},
+  {0x1e4b, {1, {0x1e4a}}},
+  {0x1e4d, {1, {0x1e4c}}},
+  {0x1e4f, {1, {0x1e4e}}},
+  {0x1e51, {1, {0x1e50}}},
+  {0x1e53, {1, {0x1e52}}},
+  {0x1e55, {1, {0x1e54}}},
+  {0x1e57, {1, {0x1e56}}},
+  {0x1e59, {1, {0x1e58}}},
+  {0x1e5b, {1, {0x1e5a}}},
+  {0x1e5d, {1, {0x1e5c}}},
+  {0x1e5f, {1, {0x1e5e}}},
+  {0x1e61, {2, {0x1e60, 0x1e9b}}},
+  {0x1e63, {1, {0x1e62}}},
+  {0x1e65, {1, {0x1e64}}},
+  {0x1e67, {1, {0x1e66}}},
+  {0x1e69, {1, {0x1e68}}},
+  {0x1e6b, {1, {0x1e6a}}},
+  {0x1e6d, {1, {0x1e6c}}},
+  {0x1e6f, {1, {0x1e6e}}},
+  {0x1e71, {1, {0x1e70}}},
+  {0x1e73, {1, {0x1e72}}},
+  {0x1e75, {1, {0x1e74}}},
+  {0x1e77, {1, {0x1e76}}},
+  {0x1e79, {1, {0x1e78}}},
+  {0x1e7b, {1, {0x1e7a}}},
+  {0x1e7d, {1, {0x1e7c}}},
+  {0x1e7f, {1, {0x1e7e}}},
+  {0x1e81, {1, {0x1e80}}},
+  {0x1e83, {1, {0x1e82}}},
+  {0x1e85, {1, {0x1e84}}},
+  {0x1e87, {1, {0x1e86}}},
+  {0x1e89, {1, {0x1e88}}},
+  {0x1e8b, {1, {0x1e8a}}},
+  {0x1e8d, {1, {0x1e8c}}},
+  {0x1e8f, {1, {0x1e8e}}},
+  {0x1e91, {1, {0x1e90}}},
+  {0x1e93, {1, {0x1e92}}},
+  {0x1e95, {1, {0x1e94}}},
+  {0x1ea1, {1, {0x1ea0}}},
+  {0x1ea3, {1, {0x1ea2}}},
+  {0x1ea5, {1, {0x1ea4}}},
+  {0x1ea7, {1, {0x1ea6}}},
+  {0x1ea9, {1, {0x1ea8}}},
+  {0x1eab, {1, {0x1eaa}}},
+  {0x1ead, {1, {0x1eac}}},
+  {0x1eaf, {1, {0x1eae}}},
+  {0x1eb1, {1, {0x1eb0}}},
+  {0x1eb3, {1, {0x1eb2}}},
+  {0x1eb5, {1, {0x1eb4}}},
+  {0x1eb7, {1, {0x1eb6}}},
+  {0x1eb9, {1, {0x1eb8}}},
+  {0x1ebb, {1, {0x1eba}}},
+  {0x1ebd, {1, {0x1ebc}}},
+  {0x1ebf, {1, {0x1ebe}}},
+  {0x1ec1, {1, {0x1ec0}}},
+  {0x1ec3, {1, {0x1ec2}}},
+  {0x1ec5, {1, {0x1ec4}}},
+  {0x1ec7, {1, {0x1ec6}}},
+  {0x1ec9, {1, {0x1ec8}}},
+  {0x1ecb, {1, {0x1eca}}},
+  {0x1ecd, {1, {0x1ecc}}},
+  {0x1ecf, {1, {0x1ece}}},
+  {0x1ed1, {1, {0x1ed0}}},
+  {0x1ed3, {1, {0x1ed2}}},
+  {0x1ed5, {1, {0x1ed4}}},
+  {0x1ed7, {1, {0x1ed6}}},
+  {0x1ed9, {1, {0x1ed8}}},
+  {0x1edb, {1, {0x1eda}}},
+  {0x1edd, {1, {0x1edc}}},
+  {0x1edf, {1, {0x1ede}}},
+  {0x1ee1, {1, {0x1ee0}}},
+  {0x1ee3, {1, {0x1ee2}}},
+  {0x1ee5, {1, {0x1ee4}}},
+  {0x1ee7, {1, {0x1ee6}}},
+  {0x1ee9, {1, {0x1ee8}}},
+  {0x1eeb, {1, {0x1eea}}},
+  {0x1eed, {1, {0x1eec}}},
+  {0x1eef, {1, {0x1eee}}},
+  {0x1ef1, {1, {0x1ef0}}},
+  {0x1ef3, {1, {0x1ef2}}},
+  {0x1ef5, {1, {0x1ef4}}},
+  {0x1ef7, {1, {0x1ef6}}},
+  {0x1ef9, {1, {0x1ef8}}},
+  {0x1efb, {1, {0x1efa}}},
+  {0x1efd, {1, {0x1efc}}},
+  {0x1eff, {1, {0x1efe}}},
+  {0x1f00, {1, {0x1f08}}},
+  {0x1f01, {1, {0x1f09}}},
+  {0x1f02, {1, {0x1f0a}}},
+  {0x1f03, {1, {0x1f0b}}},
+  {0x1f04, {1, {0x1f0c}}},
+  {0x1f05, {1, {0x1f0d}}},
+  {0x1f06, {1, {0x1f0e}}},
+  {0x1f07, {1, {0x1f0f}}},
+  {0x1f10, {1, {0x1f18}}},
+  {0x1f11, {1, {0x1f19}}},
+  {0x1f12, {1, {0x1f1a}}},
+  {0x1f13, {1, {0x1f1b}}},
+  {0x1f14, {1, {0x1f1c}}},
+  {0x1f15, {1, {0x1f1d}}},
+  {0x1f20, {1, {0x1f28}}},
+  {0x1f21, {1, {0x1f29}}},
+  {0x1f22, {1, {0x1f2a}}},
+  {0x1f23, {1, {0x1f2b}}},
+  {0x1f24, {1, {0x1f2c}}},
+  {0x1f25, {1, {0x1f2d}}},
+  {0x1f26, {1, {0x1f2e}}},
+  {0x1f27, {1, {0x1f2f}}},
+  {0x1f30, {1, {0x1f38}}},
+  {0x1f31, {1, {0x1f39}}},
+  {0x1f32, {1, {0x1f3a}}},
+  {0x1f33, {1, {0x1f3b}}},
+  {0x1f34, {1, {0x1f3c}}},
+  {0x1f35, {1, {0x1f3d}}},
+  {0x1f36, {1, {0x1f3e}}},
+  {0x1f37, {1, {0x1f3f}}},
+  {0x1f40, {1, {0x1f48}}},
+  {0x1f41, {1, {0x1f49}}},
+  {0x1f42, {1, {0x1f4a}}},
+  {0x1f43, {1, {0x1f4b}}},
+  {0x1f44, {1, {0x1f4c}}},
+  {0x1f45, {1, {0x1f4d}}},
+  {0x1f51, {1, {0x1f59}}},
+  {0x1f53, {1, {0x1f5b}}},
+  {0x1f55, {1, {0x1f5d}}},
+  {0x1f57, {1, {0x1f5f}}},
+  {0x1f60, {1, {0x1f68}}},
+  {0x1f61, {1, {0x1f69}}},
+  {0x1f62, {1, {0x1f6a}}},
+  {0x1f63, {1, {0x1f6b}}},
+  {0x1f64, {1, {0x1f6c}}},
+  {0x1f65, {1, {0x1f6d}}},
+  {0x1f66, {1, {0x1f6e}}},
+  {0x1f67, {1, {0x1f6f}}},
+  {0x1f70, {1, {0x1fba}}},
+  {0x1f71, {1, {0x1fbb}}},
+  {0x1f72, {1, {0x1fc8}}},
+  {0x1f73, {1, {0x1fc9}}},
+  {0x1f74, {1, {0x1fca}}},
+  {0x1f75, {1, {0x1fcb}}},
+  {0x1f76, {1, {0x1fda}}},
+  {0x1f77, {1, {0x1fdb}}},
+  {0x1f78, {1, {0x1ff8}}},
+  {0x1f79, {1, {0x1ff9}}},
+  {0x1f7a, {1, {0x1fea}}},
+  {0x1f7b, {1, {0x1feb}}},
+  {0x1f7c, {1, {0x1ffa}}},
+  {0x1f7d, {1, {0x1ffb}}},
+  {0x1fb0, {1, {0x1fb8}}},
+  {0x1fb1, {1, {0x1fb9}}},
+  {0x1fd0, {1, {0x1fd8}}},
+  {0x1fd1, {1, {0x1fd9}}},
+  {0x1fe0, {1, {0x1fe8}}},
+  {0x1fe1, {1, {0x1fe9}}},
+  {0x1fe5, {1, {0x1fec}}},
+  {0x214e, {1, {0x2132}}},
+  {0x2170, {1, {0x2160}}},
+  {0x2171, {1, {0x2161}}},
+  {0x2172, {1, {0x2162}}},
+  {0x2173, {1, {0x2163}}},
+  {0x2174, {1, {0x2164}}},
+  {0x2175, {1, {0x2165}}},
+  {0x2176, {1, {0x2166}}},
+  {0x2177, {1, {0x2167}}},
+  {0x2178, {1, {0x2168}}},
+  {0x2179, {1, {0x2169}}},
+  {0x217a, {1, {0x216a}}},
+  {0x217b, {1, {0x216b}}},
+  {0x217c, {1, {0x216c}}},
+  {0x217d, {1, {0x216d}}},
+  {0x217e, {1, {0x216e}}},
+  {0x217f, {1, {0x216f}}},
+  {0x2184, {1, {0x2183}}},
+  {0x24d0, {1, {0x24b6}}},
+  {0x24d1, {1, {0x24b7}}},
+  {0x24d2, {1, {0x24b8}}},
+  {0x24d3, {1, {0x24b9}}},
+  {0x24d4, {1, {0x24ba}}},
+  {0x24d5, {1, {0x24bb}}},
+  {0x24d6, {1, {0x24bc}}},
+  {0x24d7, {1, {0x24bd}}},
+  {0x24d8, {1, {0x24be}}},
+  {0x24d9, {1, {0x24bf}}},
+  {0x24da, {1, {0x24c0}}},
+  {0x24db, {1, {0x24c1}}},
+  {0x24dc, {1, {0x24c2}}},
+  {0x24dd, {1, {0x24c3}}},
+  {0x24de, {1, {0x24c4}}},
+  {0x24df, {1, {0x24c5}}},
+  {0x24e0, {1, {0x24c6}}},
+  {0x24e1, {1, {0x24c7}}},
+  {0x24e2, {1, {0x24c8}}},
+  {0x24e3, {1, {0x24c9}}},
+  {0x24e4, {1, {0x24ca}}},
+  {0x24e5, {1, {0x24cb}}},
+  {0x24e6, {1, {0x24cc}}},
+  {0x24e7, {1, {0x24cd}}},
+  {0x24e8, {1, {0x24ce}}},
+  {0x24e9, {1, {0x24cf}}},
+  {0x2c30, {1, {0x2c00}}},
+  {0x2c31, {1, {0x2c01}}},
+  {0x2c32, {1, {0x2c02}}},
+  {0x2c33, {1, {0x2c03}}},
+  {0x2c34, {1, {0x2c04}}},
+  {0x2c35, {1, {0x2c05}}},
+  {0x2c36, {1, {0x2c06}}},
+  {0x2c37, {1, {0x2c07}}},
+  {0x2c38, {1, {0x2c08}}},
+  {0x2c39, {1, {0x2c09}}},
+  {0x2c3a, {1, {0x2c0a}}},
+  {0x2c3b, {1, {0x2c0b}}},
+  {0x2c3c, {1, {0x2c0c}}},
+  {0x2c3d, {1, {0x2c0d}}},
+  {0x2c3e, {1, {0x2c0e}}},
+  {0x2c3f, {1, {0x2c0f}}},
+  {0x2c40, {1, {0x2c10}}},
+  {0x2c41, {1, {0x2c11}}},
+  {0x2c42, {1, {0x2c12}}},
+  {0x2c43, {1, {0x2c13}}},
+  {0x2c44, {1, {0x2c14}}},
+  {0x2c45, {1, {0x2c15}}},
+  {0x2c46, {1, {0x2c16}}},
+  {0x2c47, {1, {0x2c17}}},
+  {0x2c48, {1, {0x2c18}}},
+  {0x2c49, {1, {0x2c19}}},
+  {0x2c4a, {1, {0x2c1a}}},
+  {0x2c4b, {1, {0x2c1b}}},
+  {0x2c4c, {1, {0x2c1c}}},
+  {0x2c4d, {1, {0x2c1d}}},
+  {0x2c4e, {1, {0x2c1e}}},
+  {0x2c4f, {1, {0x2c1f}}},
+  {0x2c50, {1, {0x2c20}}},
+  {0x2c51, {1, {0x2c21}}},
+  {0x2c52, {1, {0x2c22}}},
+  {0x2c53, {1, {0x2c23}}},
+  {0x2c54, {1, {0x2c24}}},
+  {0x2c55, {1, {0x2c25}}},
+  {0x2c56, {1, {0x2c26}}},
+  {0x2c57, {1, {0x2c27}}},
+  {0x2c58, {1, {0x2c28}}},
+  {0x2c59, {1, {0x2c29}}},
+  {0x2c5a, {1, {0x2c2a}}},
+  {0x2c5b, {1, {0x2c2b}}},
+  {0x2c5c, {1, {0x2c2c}}},
+  {0x2c5d, {1, {0x2c2d}}},
+  {0x2c5e, {1, {0x2c2e}}},
+  {0x2c61, {1, {0x2c60}}},
+  {0x2c65, {1, {0x023a}}},
+  {0x2c66, {1, {0x023e}}},
+  {0x2c68, {1, {0x2c67}}},
+  {0x2c6a, {1, {0x2c69}}},
+  {0x2c6c, {1, {0x2c6b}}},
+  {0x2c73, {1, {0x2c72}}},
+  {0x2c76, {1, {0x2c75}}},
+  {0x2c81, {1, {0x2c80}}},
+  {0x2c83, {1, {0x2c82}}},
+  {0x2c85, {1, {0x2c84}}},
+  {0x2c87, {1, {0x2c86}}},
+  {0x2c89, {1, {0x2c88}}},
+  {0x2c8b, {1, {0x2c8a}}},
+  {0x2c8d, {1, {0x2c8c}}},
+  {0x2c8f, {1, {0x2c8e}}},
+  {0x2c91, {1, {0x2c90}}},
+  {0x2c93, {1, {0x2c92}}},
+  {0x2c95, {1, {0x2c94}}},
+  {0x2c97, {1, {0x2c96}}},
+  {0x2c99, {1, {0x2c98}}},
+  {0x2c9b, {1, {0x2c9a}}},
+  {0x2c9d, {1, {0x2c9c}}},
+  {0x2c9f, {1, {0x2c9e}}},
+  {0x2ca1, {1, {0x2ca0}}},
+  {0x2ca3, {1, {0x2ca2}}},
+  {0x2ca5, {1, {0x2ca4}}},
+  {0x2ca7, {1, {0x2ca6}}},
+  {0x2ca9, {1, {0x2ca8}}},
+  {0x2cab, {1, {0x2caa}}},
+  {0x2cad, {1, {0x2cac}}},
+  {0x2caf, {1, {0x2cae}}},
+  {0x2cb1, {1, {0x2cb0}}},
+  {0x2cb3, {1, {0x2cb2}}},
+  {0x2cb5, {1, {0x2cb4}}},
+  {0x2cb7, {1, {0x2cb6}}},
+  {0x2cb9, {1, {0x2cb8}}},
+  {0x2cbb, {1, {0x2cba}}},
+  {0x2cbd, {1, {0x2cbc}}},
+  {0x2cbf, {1, {0x2cbe}}},
+  {0x2cc1, {1, {0x2cc0}}},
+  {0x2cc3, {1, {0x2cc2}}},
+  {0x2cc5, {1, {0x2cc4}}},
+  {0x2cc7, {1, {0x2cc6}}},
+  {0x2cc9, {1, {0x2cc8}}},
+  {0x2ccb, {1, {0x2cca}}},
+  {0x2ccd, {1, {0x2ccc}}},
+  {0x2ccf, {1, {0x2cce}}},
+  {0x2cd1, {1, {0x2cd0}}},
+  {0x2cd3, {1, {0x2cd2}}},
+  {0x2cd5, {1, {0x2cd4}}},
+  {0x2cd7, {1, {0x2cd6}}},
+  {0x2cd9, {1, {0x2cd8}}},
+  {0x2cdb, {1, {0x2cda}}},
+  {0x2cdd, {1, {0x2cdc}}},
+  {0x2cdf, {1, {0x2cde}}},
+  {0x2ce1, {1, {0x2ce0}}},
+  {0x2ce3, {1, {0x2ce2}}},
+  {0x2cec, {1, {0x2ceb}}},
+  {0x2cee, {1, {0x2ced}}},
+  {0x2cf3, {1, {0x2cf2}}},
+  {0x2d00, {1, {0x10a0}}},
+  {0x2d01, {1, {0x10a1}}},
+  {0x2d02, {1, {0x10a2}}},
+  {0x2d03, {1, {0x10a3}}},
+  {0x2d04, {1, {0x10a4}}},
+  {0x2d05, {1, {0x10a5}}},
+  {0x2d06, {1, {0x10a6}}},
+  {0x2d07, {1, {0x10a7}}},
+  {0x2d08, {1, {0x10a8}}},
+  {0x2d09, {1, {0x10a9}}},
+  {0x2d0a, {1, {0x10aa}}},
+  {0x2d0b, {1, {0x10ab}}},
+  {0x2d0c, {1, {0x10ac}}},
+  {0x2d0d, {1, {0x10ad}}},
+  {0x2d0e, {1, {0x10ae}}},
+  {0x2d0f, {1, {0x10af}}},
+  {0x2d10, {1, {0x10b0}}},
+  {0x2d11, {1, {0x10b1}}},
+  {0x2d12, {1, {0x10b2}}},
+  {0x2d13, {1, {0x10b3}}},
+  {0x2d14, {1, {0x10b4}}},
+  {0x2d15, {1, {0x10b5}}},
+  {0x2d16, {1, {0x10b6}}},
+  {0x2d17, {1, {0x10b7}}},
+  {0x2d18, {1, {0x10b8}}},
+  {0x2d19, {1, {0x10b9}}},
+  {0x2d1a, {1, {0x10ba}}},
+  {0x2d1b, {1, {0x10bb}}},
+  {0x2d1c, {1, {0x10bc}}},
+  {0x2d1d, {1, {0x10bd}}},
+  {0x2d1e, {1, {0x10be}}},
+  {0x2d1f, {1, {0x10bf}}},
+  {0x2d20, {1, {0x10c0}}},
+  {0x2d21, {1, {0x10c1}}},
+  {0x2d22, {1, {0x10c2}}},
+  {0x2d23, {1, {0x10c3}}},
+  {0x2d24, {1, {0x10c4}}},
+  {0x2d25, {1, {0x10c5}}},
+  {0x2d27, {1, {0x10c7}}},
+  {0x2d2d, {1, {0x10cd}}},
+  {0xa641, {1, {0xa640}}},
+  {0xa643, {1, {0xa642}}},
+  {0xa645, {1, {0xa644}}},
+  {0xa647, {1, {0xa646}}},
+  {0xa649, {1, {0xa648}}},
+  {0xa64b, {1, {0xa64a}}},
+  {0xa64d, {1, {0xa64c}}},
+  {0xa64f, {1, {0xa64e}}},
+  {0xa651, {1, {0xa650}}},
+  {0xa653, {1, {0xa652}}},
+  {0xa655, {1, {0xa654}}},
+  {0xa657, {1, {0xa656}}},
+  {0xa659, {1, {0xa658}}},
+  {0xa65b, {1, {0xa65a}}},
+  {0xa65d, {1, {0xa65c}}},
+  {0xa65f, {1, {0xa65e}}},
+  {0xa661, {1, {0xa660}}},
+  {0xa663, {1, {0xa662}}},
+  {0xa665, {1, {0xa664}}},
+  {0xa667, {1, {0xa666}}},
+  {0xa669, {1, {0xa668}}},
+  {0xa66b, {1, {0xa66a}}},
+  {0xa66d, {1, {0xa66c}}},
+  {0xa681, {1, {0xa680}}},
+  {0xa683, {1, {0xa682}}},
+  {0xa685, {1, {0xa684}}},
+  {0xa687, {1, {0xa686}}},
+  {0xa689, {1, {0xa688}}},
+  {0xa68b, {1, {0xa68a}}},
+  {0xa68d, {1, {0xa68c}}},
+  {0xa68f, {1, {0xa68e}}},
+  {0xa691, {1, {0xa690}}},
+  {0xa693, {1, {0xa692}}},
+  {0xa695, {1, {0xa694}}},
+  {0xa697, {1, {0xa696}}},
+  {0xa699, {1, {0xa698}}},
+  {0xa69b, {1, {0xa69a}}},
+  {0xa723, {1, {0xa722}}},
+  {0xa725, {1, {0xa724}}},
+  {0xa727, {1, {0xa726}}},
+  {0xa729, {1, {0xa728}}},
+  {0xa72b, {1, {0xa72a}}},
+  {0xa72d, {1, {0xa72c}}},
+  {0xa72f, {1, {0xa72e}}},
+  {0xa733, {1, {0xa732}}},
+  {0xa735, {1, {0xa734}}},
+  {0xa737, {1, {0xa736}}},
+  {0xa739, {1, {0xa738}}},
+  {0xa73b, {1, {0xa73a}}},
+  {0xa73d, {1, {0xa73c}}},
+  {0xa73f, {1, {0xa73e}}},
+  {0xa741, {1, {0xa740}}},
+  {0xa743, {1, {0xa742}}},
+  {0xa745, {1, {0xa744}}},
+  {0xa747, {1, {0xa746}}},
+  {0xa749, {1, {0xa748}}},
+  {0xa74b, {1, {0xa74a}}},
+  {0xa74d, {1, {0xa74c}}},
+  {0xa74f, {1, {0xa74e}}},
+  {0xa751, {1, {0xa750}}},
+  {0xa753, {1, {0xa752}}},
+  {0xa755, {1, {0xa754}}},
+  {0xa757, {1, {0xa756}}},
+  {0xa759, {1, {0xa758}}},
+  {0xa75b, {1, {0xa75a}}},
+  {0xa75d, {1, {0xa75c}}},
+  {0xa75f, {1, {0xa75e}}},
+  {0xa761, {1, {0xa760}}},
+  {0xa763, {1, {0xa762}}},
+  {0xa765, {1, {0xa764}}},
+  {0xa767, {1, {0xa766}}},
+  {0xa769, {1, {0xa768}}},
+  {0xa76b, {1, {0xa76a}}},
+  {0xa76d, {1, {0xa76c}}},
+  {0xa76f, {1, {0xa76e}}},
+  {0xa77a, {1, {0xa779}}},
+  {0xa77c, {1, {0xa77b}}},
+  {0xa77f, {1, {0xa77e}}},
+  {0xa781, {1, {0xa780}}},
+  {0xa783, {1, {0xa782}}},
+  {0xa785, {1, {0xa784}}},
+  {0xa787, {1, {0xa786}}},
+  {0xa78c, {1, {0xa78b}}},
+  {0xa791, {1, {0xa790}}},
+  {0xa793, {1, {0xa792}}},
+  {0xa797, {1, {0xa796}}},
+  {0xa799, {1, {0xa798}}},
+  {0xa79b, {1, {0xa79a}}},
+  {0xa79d, {1, {0xa79c}}},
+  {0xa79f, {1, {0xa79e}}},
+  {0xa7a1, {1, {0xa7a0}}},
+  {0xa7a3, {1, {0xa7a2}}},
+  {0xa7a5, {1, {0xa7a4}}},
+  {0xa7a7, {1, {0xa7a6}}},
+  {0xa7a9, {1, {0xa7a8}}},
+  {0xff41, {1, {0xff21}}},
+  {0xff42, {1, {0xff22}}},
+  {0xff43, {1, {0xff23}}},
+  {0xff44, {1, {0xff24}}},
+  {0xff45, {1, {0xff25}}},
+  {0xff46, {1, {0xff26}}},
+  {0xff47, {1, {0xff27}}},
+  {0xff48, {1, {0xff28}}},
+  {0xff49, {1, {0xff29}}},
+  {0xff4a, {1, {0xff2a}}},
+  {0xff4b, {1, {0xff2b}}},
+  {0xff4c, {1, {0xff2c}}},
+  {0xff4d, {1, {0xff2d}}},
+  {0xff4e, {1, {0xff2e}}},
+  {0xff4f, {1, {0xff2f}}},
+  {0xff50, {1, {0xff30}}},
+  {0xff51, {1, {0xff31}}},
+  {0xff52, {1, {0xff32}}},
+  {0xff53, {1, {0xff33}}},
+  {0xff54, {1, {0xff34}}},
+  {0xff55, {1, {0xff35}}},
+  {0xff56, {1, {0xff36}}},
+  {0xff57, {1, {0xff37}}},
+  {0xff58, {1, {0xff38}}},
+  {0xff59, {1, {0xff39}}},
+  {0xff5a, {1, {0xff3a}}},
+  {0x10428, {1, {0x10400}}},
+  {0x10429, {1, {0x10401}}},
+  {0x1042a, {1, {0x10402}}},
+  {0x1042b, {1, {0x10403}}},
+  {0x1042c, {1, {0x10404}}},
+  {0x1042d, {1, {0x10405}}},
+  {0x1042e, {1, {0x10406}}},
+  {0x1042f, {1, {0x10407}}},
+  {0x10430, {1, {0x10408}}},
+  {0x10431, {1, {0x10409}}},
+  {0x10432, {1, {0x1040a}}},
+  {0x10433, {1, {0x1040b}}},
+  {0x10434, {1, {0x1040c}}},
+  {0x10435, {1, {0x1040d}}},
+  {0x10436, {1, {0x1040e}}},
+  {0x10437, {1, {0x1040f}}},
+  {0x10438, {1, {0x10410}}},
+  {0x10439, {1, {0x10411}}},
+  {0x1043a, {1, {0x10412}}},
+  {0x1043b, {1, {0x10413}}},
+  {0x1043c, {1, {0x10414}}},
+  {0x1043d, {1, {0x10415}}},
+  {0x1043e, {1, {0x10416}}},
+  {0x1043f, {1, {0x10417}}},
+  {0x10440, {1, {0x10418}}},
+  {0x10441, {1, {0x10419}}},
+  {0x10442, {1, {0x1041a}}},
+  {0x10443, {1, {0x1041b}}},
+  {0x10444, {1, {0x1041c}}},
+  {0x10445, {1, {0x1041d}}},
+  {0x10446, {1, {0x1041e}}},
+  {0x10447, {1, {0x1041f}}},
+  {0x10448, {1, {0x10420}}},
+  {0x10449, {1, {0x10421}}},
+  {0x1044a, {1, {0x10422}}},
+  {0x1044b, {1, {0x10423}}},
+  {0x1044c, {1, {0x10424}}},
+  {0x1044d, {1, {0x10425}}},
+  {0x1044e, {1, {0x10426}}},
+  {0x1044f, {1, {0x10427}}},
+  {0x118c0, {1, {0x118a0}}},
+  {0x118c1, {1, {0x118a1}}},
+  {0x118c2, {1, {0x118a2}}},
+  {0x118c3, {1, {0x118a3}}},
+  {0x118c4, {1, {0x118a4}}},
+  {0x118c5, {1, {0x118a5}}},
+  {0x118c6, {1, {0x118a6}}},
+  {0x118c7, {1, {0x118a7}}},
+  {0x118c8, {1, {0x118a8}}},
+  {0x118c9, {1, {0x118a9}}},
+  {0x118ca, {1, {0x118aa}}},
+  {0x118cb, {1, {0x118ab}}},
+  {0x118cc, {1, {0x118ac}}},
+  {0x118cd, {1, {0x118ad}}},
+  {0x118ce, {1, {0x118ae}}},
+  {0x118cf, {1, {0x118af}}},
+  {0x118d0, {1, {0x118b0}}},
+  {0x118d1, {1, {0x118b1}}},
+  {0x118d2, {1, {0x118b2}}},
+  {0x118d3, {1, {0x118b3}}},
+  {0x118d4, {1, {0x118b4}}},
+  {0x118d5, {1, {0x118b5}}},
+  {0x118d6, {1, {0x118b6}}},
+  {0x118d7, {1, {0x118b7}}},
+  {0x118d8, {1, {0x118b8}}},
+  {0x118d9, {1, {0x118b9}}},
+  {0x118da, {1, {0x118ba}}},
+  {0x118db, {1, {0x118bb}}},
+  {0x118dc, {1, {0x118bc}}},
+  {0x118dd, {1, {0x118bd}}},
+  {0x118de, {1, {0x118be}}},
+  {0x118df, {1, {0x118bf}}},
+#define CaseUnfold_11_Locale (*(CaseUnfold_11_Type (*)[1])(CaseUnfold_11_Table+1054))
+  {0x0069, {1, {0x0049}}},
+};
+
+/* C code produced by gperf version 3.0.3 */
+/* Command-line: gperf -7 -k1,2,3 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_11_hash -N onigenc_unicode_CaseUnfold_11_lookup -n  */
+
+/* maximum key range = 1907, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_11_hash(const OnigCodePoint code)
+{
+  static const unsigned short asso_values[] =
+    {
+         1, 1915,    4,   12,  199,  716,    4,  230,    6,  134,
+       355,  116,    9,    3,    7,   13, 1915, 1915, 1915, 1915,
+      1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915,
+      1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915,
+      1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915,
+      1915, 1915, 1915,   40, 1915, 1915, 1915, 1915, 1915, 1915,
+      1915, 1915,   21, 1915,    2,    1,   11,   49,   50,  667,
+       131,  651,   26,  872,  251, 1136,   24,   42,  295, 1145,
+       111,   27,   47,   12,  812,  806,  107,  786,   21, 1070,
+        13,  967,   41,    5,  523, 1152,   71, 1077,   73,  948,
+        14,  601,   10,  575,   15,  764,    1,  929,   27, 1057,
+        23,  498,   15,  918, 1208,  753, 1211,  512, 1180,  736,
+      1082,  711,  441,  898,  410, 1028,  277,  887,  238,  684,
+       336,  425,  740,  406, 1016,  360,  972,  382, 1006,  354,
+      1168,  302,  999,  286,  901,  252,  546,  106, 1159,  148,
+      1121,  224, 1061,  132, 1152,  182,  871,  210, 1163,  235,
+      1183,  371, 1197,   64,  954,   90,  339,   79,  604,  168,
+       982,  159,  448,  328,  525,  634,  195,  620,  261,  852,
+       934,  312,  210,  836,  668,  983,  586,  823,  460,  955,
+      1176,  697,  119,  998
+    };
+  return asso_values[bits_of(code, 2)+66] + asso_values[bits_of(code, 1)+4] + asso_values[bits_of(code, 0)];
+}
+
+#ifdef __GNUC__
+__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+static const CodePointList3 *
+onigenc_unicode_CaseUnfold_11_lookup(const OnigCodePoint code)
+{
+  enum
+    {
+      MIN_CODE_VALUE = 0x61,
+      MAX_CODE_VALUE = 0x118df,
+      TOTAL_KEYWORDS = 1055,
+      MIN_WORD_LENGTH = 3,
+      MAX_WORD_LENGTH = 3,
+      MIN_HASH_VALUE = 8,
+      MAX_HASH_VALUE = 1914
+    };
+
+  static const short wordlist[] =
+    {
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0x1e1b*/ 490,
+      /*0x049b*/ 362,
+      /*0x011b*/ 69,
+      /*0x2c9b*/ 781,
+      /*0x021b*/ 178,
+      /*0x051b*/ 426,
+      /*0x1e91*/ 549,
+      /*0x1e11*/ 485,
+      /*0x0491*/ 357,
+      /*0x0111*/ 64,
+      /*0x2c91*/ 776,
+      /*0x0211*/ 173,
+      /*0x0511*/ 421,
+      /*0xa79b*/ 948,
+      /*0x1f24*/ 618,
+      /*0x1f00*/ 600,
+      /*0x1f11*/ 609,
+      /*0x0580*/ 468,
+      /*0x1f22*/ 616,
+      /*0x1f26*/ 620,
+      /*0xa791*/ 944,
+      /*0x1e8f*/ 548,
+      /*0x1e0f*/ 484,
+      /*0x048f*/ 356,
+      /*0x010f*/ 63,
+      /*0x2c8f*/ 775,
+      /*0x020f*/ 172,
+      /*0x050f*/ 420,
+      /*0xa69b*/ 897,
+      -1,
+      /*0x1f06*/ 606,
+      -1,
+      /*0x0586*/ 474,
+      -1, -1,
+      /*0xa691*/ 892,
+      /*0x1e8b*/ 546,
+      /*0x1e0b*/ 482,
+      /*0x048b*/ 354,
+      /*0x010b*/ 61,
+      /*0x2c8b*/ 773,
+      /*0x020b*/ 170,
+      /*0x050b*/ 418,
+      /*0x1e81*/ 541,
+      /*0x1e01*/ 477,
+      /*0x0481*/ 353,
+      /*0x0101*/ 56,
+      /*0x2c81*/ 768,
+      /*0x0201*/ 165,
+      /*0x0501*/ 413,
+      /*0xa68f*/ 891,
+      /*0x1f10*/ 608,
+      -1,
+      /*0x1f01*/ 601,
+      /*0x1f02*/ 602,
+      /*0x0581*/ 469,
+      /*0x0582*/ 470,
+      /*0xa781*/ 939,
+      /*0x1ee1*/ 584,
+      /*0x1e61*/ 525,
+      /*0x04e1*/ 397,
+      /*0x0161*/ 102,
+      /*0x2ce1*/ 816,
+      /*0x0261*/ 210,
+      /*0x0561*/ 437,
+      /*0xa68b*/ 889,
+      /*0x0461*/ 337,
+      -1,
+      /*0x1f61*/ 641,
+      -1, -1, -1,
+      /*0xa681*/ 884,
+      /*0x1ee5*/ 586,
+      /*0x1e65*/ 527,
+      /*0x04e5*/ 399,
+      /*0x0165*/ 104,
+      /*0x1f20*/ 614,
+      /*0x0265*/ 212,
+      /*0x0565*/ 441,
+      -1,
+      /*0x0465*/ 339,
+      -1,
+      /*0x1f65*/ 645,
+      /*0x1ee3*/ 585,
+      /*0x1e63*/ 526,
+      /*0x04e3*/ 398,
+      /*0x0163*/ 103,
+      /*0x2ce3*/ 817,
+      /*0x0263*/ 211,
+      /*0x0563*/ 439,
+      -1,
+      /*0x0463*/ 338,
+      -1,
+      /*0x1f63*/ 643,
+      -1, -1, -1,
+      /*0x2c61*/ 760,
+      /*0x24e1*/ 704,
+      /*0x1ed1*/ 576,
+      /*0x1e51*/ 517,
+      /*0x04d1*/ 389,
+      /*0x0151*/ 94,
+      /*0x2cd1*/ 808,
+      /*0x0251*/ 200,
+      /*0x1fe1*/ 667,
+      /*0xa761*/ 928,
+      /*0x0451*/ 322,
+      -1,
+      /*0x1f51*/ 636,
+      /*0x1f14*/ 612,
+      -1,
+      /*0x2c65*/ 761,
+      /*0x24e5*/ 708,
+      -1,
+      /*0x017e*/ 116,
+      -1, -1,
+      /*0x057e*/ 466,
+      -1,
+      /*0x1fe5*/ 668,
+      /*0xa765*/ 930,
+      -1,
+      /*0x03ae*/ 241,
+      /*0x24e3*/ 706,
+      /*0x1ed7*/ 579,
+      /*0x1e57*/ 520,
+      /*0x04d7*/ 392,
+      /*0x0157*/ 97,
+      /*0x2cd7*/ 811,
+      /*0x0257*/ 205,
+      /*0x03ac*/ 239,
+      /*0xa763*/ 929,
+      /*0x0457*/ 328,
+      /*0x1f04*/ 604,
+      /*0x1f57*/ 639,
+      /*0x0584*/ 472,
+      /*0x0280*/ 223,
+      -1,
+      /*0x2c51*/ 746,
+      /*0x24d1*/ 688,
+      /*0x1ed3*/ 577,
+      /*0x1e53*/ 518,
+      /*0x04d3*/ 390,
+      /*0x0153*/ 95,
+      /*0x2cd3*/ 809,
+      /*0x0253*/ 202,
+      /*0x1fd1*/ 665,
+      /*0xa751*/ 920,
+      /*0x0453*/ 324,
+      /*0x028a*/ 228,
+      /*0x1f53*/ 637,
+      /*0x1ee9*/ 588,
+      /*0x1e69*/ 529,
+      /*0x04e9*/ 401,
+      /*0x0169*/ 106,
+      -1,
+      /*0x0269*/ 215,
+      /*0x0569*/ 445,
+      -1,
+      /*0x0469*/ 341,
+      /*0x1ee7*/ 587,
+      /*0x1e67*/ 528,
+      /*0x04e7*/ 400,
+      /*0x0167*/ 105,
+      /*0x2c57*/ 752,
+      /*0x24d7*/ 694,
+      /*0x0567*/ 443,
+      /*0x028b*/ 229,
+      /*0x0467*/ 340,
+      /*0xa661*/ 877,
+      /*0x1f67*/ 647,
+      /*0x03e1*/ 277,
+      -1,
+      /*0xa757*/ 923,
+      /*0x1ed9*/ 580,
+      /*0x1e59*/ 521,
+      /*0x04d9*/ 393,
+      /*0x0159*/ 98,
+      /*0x2cd9*/ 812,
+      /*0x0259*/ 206,
+      /*0x2c53*/ 748,
+      /*0x24d3*/ 690,
+      /*0x0459*/ 330,
+      -1,
+      /*0xa665*/ 879,
+      -1,
+      /*0x03e5*/ 279,
+      -1, -1,
+      /*0xa753*/ 921,
+      -1,
+      /*0x2cee*/ 819,
+      /*0x24e9*/ 712,
+      /*0x056e*/ 450,
+      -1,
+      /*0xa663*/ 878,
+      /*0x029e*/ 232,
+      /*0x03e3*/ 278,
+      -1,
+      /*0x10428*/ 982,
+      /*0xa769*/ 932,
+      /*0x24e7*/ 710,
+      /*0x1edb*/ 581,
+      /*0x1e5b*/ 522,
+      /*0x04db*/ 394,
+      /*0x015b*/ 99,
+      /*0x2cdb*/ 813,
+      /*0x025b*/ 207,
+      /*0x0574*/ 456,
+      /*0xa767*/ 931,
+      /*0x045b*/ 332,
+      /*0xa651*/ 869,
+      /*0x1f74*/ 652,
+      /*0x1042e*/ 988,
+      /*0x2c59*/ 754,
+      /*0x24d9*/ 696,
+      /*0x1ed5*/ 578,
+      /*0x1e55*/ 519,
+      /*0x04d5*/ 391,
+      /*0x0155*/ 96,
+      /*0x2cd5*/ 810,
+      /*0x1042c*/ 986,
+      /*0x01a8*/ 130,
+      /*0xa759*/ 924,
+      /*0x0455*/ 326,
+      /*0x1042a*/ 984,
+      /*0x1f55*/ 638,
+      /*0x1edd*/ 582,
+      /*0x1e5d*/ 523,
+      /*0x04dd*/ 395,
+      /*0x015d*/ 100,
+      /*0x2cdd*/ 814,
+      /*0x0180*/ 117,
+      /*0x013e*/ 85,
+      -1,
+      /*0x045d*/ 334,
+      -1,
+      /*0xa657*/ 872,
+      /*0x043e*/ 303,
+      /*0x03d7*/ 272,
+      -1,
+      /*0x217e*/ 684,
+      /*0x2c5b*/ 756,
+      /*0x24db*/ 698,
+      /*0x1ecf*/ 575,
+      /*0x1e4f*/ 516,
+      /*0x04cf*/ 388,
+      /*0x014f*/ 93,
+      /*0x2ccf*/ 807,
+      /*0x024f*/ 198,
+      -1,
+      /*0xa75b*/ 925,
+      /*0x044f*/ 320,
+      /*0xa653*/ 870,
+      /*0x0061*/ 0,
+      -1,
+      /*0x2c55*/ 750,
+      /*0x24d5*/ 692,
+      -1,
+      /*0x0570*/ 452,
+      -1, -1,
+      /*0x019a*/ 125,
+      /*0x1f70*/ 648,
+      /*0xa669*/ 881,
+      /*0xa755*/ 922,
+      /*0x03e9*/ 281,
+      /*0x2c5d*/ 758,
+      /*0x24dd*/ 700,
+      /*0x0065*/ 4,
+      /*0x2c3e*/ 727,
+      -1,
+      /*0x013c*/ 84,
+      /*0xa667*/ 880,
+      /*0x023c*/ 190,
+      /*0x03e7*/ 280,
+      /*0xa75d*/ 926,
+      /*0x043c*/ 301,
+      /*0x1ecd*/ 574,
+      /*0x1e4d*/ 515,
+      /*0x0063*/ 2,
+      /*0x014d*/ 92,
+      /*0x2ccd*/ 806,
+      /*0x024d*/ 197,
+      /*0x2c4f*/ 744,
+      /*0x01e1*/ 151,
+      /*0x044d*/ 318,
+      /*0xa659*/ 873,
+      -1,
+      /*0x03d9*/ 273,
+      -1, -1,
+      /*0x019e*/ 126,
+      /*0xa74f*/ 919,
+      /*0x1ecb*/ 573,
+      /*0x1e4b*/ 514,
+      -1,
+      /*0x014b*/ 91,
+      /*0x2ccb*/ 805,
+      /*0x024b*/ 196,
+      /*0x01e5*/ 153,
+      /*0xa78c*/ 943,
+      /*0x044b*/ 316,
+      -1,
+      /*0x1ef3*/ 593,
+      /*0x1e73*/ 534,
+      /*0x04f3*/ 406,
+      /*0x0173*/ 111,
+      /*0x2cf3*/ 820,
+      /*0x2c3c*/ 725,
+      /*0x0573*/ 455,
+      /*0x01e3*/ 152,
+      /*0x0473*/ 346,
+      -1,
+      /*0x1f73*/ 651,
+      /*0xa65b*/ 874,
+      -1,
+      /*0x03db*/ 274,
+      /*0x2c4d*/ 742,
+      -1,
+      /*0x1eeb*/ 589,
+      /*0x1e6b*/ 530,
+      /*0x04eb*/ 402,
+      /*0x016b*/ 107,
+      -1,
+      /*0x026b*/ 216,
+      /*0x056b*/ 447,
+      /*0xa74d*/ 918,
+      /*0x046b*/ 342,
+      /*0xa655*/ 871,
+      -1,
+      /*0x0140*/ 86,
+      /*0x2174*/ 674,
+      /*0x0240*/ 192,
+      /*0x2c4b*/ 740,
+      /*0x118d1*/ 1039,
+      /*0x0440*/ 305,
+      /*0x0564*/ 440,
+      /*0x1f40*/ 630,
+      -1,
+      /*0xa65d*/ 875,
+      /*0x1f64*/ 644,
+      /*0x03dd*/ 275,
+      /*0xa74b*/ 917,
+      /*0x2c73*/ 766,
+      /*0x03be*/ 256,
+      /*0x1ec9*/ 572,
+      /*0x1e49*/ 513,
+      -1,
+      /*0x0069*/ 1054,
+      /*0x2cc9*/ 804,
+      /*0x0249*/ 195,
+      /*0x1ec5*/ 570,
+      /*0x1e45*/ 511,
+      /*0x0449*/ 314,
+      -1,
+      /*0x2cc5*/ 802,
+      /*0xa64f*/ 868,
+      /*0x0067*/ 6,
+      -1,
+      /*0x0445*/ 310,
+      /*0x118d7*/ 1045,
+      /*0x1f45*/ 635,
+      /*0x1edf*/ 583,
+      /*0x1e5f*/ 524,
+      /*0x04df*/ 396,
+      /*0x015f*/ 101,
+      /*0x2cdf*/ 815,
+      /*0x2c40*/ 729,
+      /*0xa76b*/ 933,
+      -1,
+      /*0x045f*/ 336,
+      /*0x24e4*/ 707,
+      -1,
+      /*0x1ec7*/ 571,
+      /*0x1e47*/ 512,
+      /*0x0288*/ 226,
+      /*0x118d3*/ 1041,
+      /*0x2cc7*/ 803,
+      /*0x0247*/ 194,
+      /*0x01e9*/ 155,
+      -1,
+      /*0x0447*/ 312,
+      /*0x2170*/ 670,
+      /*0x03bc*/ 254,
+      /*0x006e*/ 12,
+      /*0x2c49*/ 738,
+      -1, -1,
+      /*0x01e7*/ 154,
+      -1,
+      /*0xa64d*/ 867,
+      /*0x2c45*/ 734,
+      /*0x03cd*/ 270,
+      -1,
+      /*0xa749*/ 916,
+      -1, -1,
+      /*0x1ec3*/ 569,
+      /*0x1e43*/ 510,
+      /*0x0074*/ 18,
+      /*0xa745*/ 914,
+      /*0x2cc3*/ 801,
+      -1,
+      /*0x24df*/ 702,
+      /*0x013a*/ 83,
+      /*0x0443*/ 308,
+      /*0xa64b*/ 866,
+      /*0x1f43*/ 633,
+      /*0x03cb*/ 268,
+      /*0x043a*/ 299,
+      /*0x118d9*/ 1047,
+      /*0xa75f*/ 927,
+      -1,
+      /*0x2c47*/ 736,
+      -1, -1,
+      /*0x1ec1*/ 568,
+      /*0x1e41*/ 509,
+      /*0x03f3*/ 286,
+      /*0x028c*/ 230,
+      /*0x2cc1*/ 800,
+      -1,
+      /*0xa747*/ 915,
+      -1,
+      /*0x0441*/ 306,
+      -1,
+      /*0x1f41*/ 631,
+      -1, -1, -1, -1, -1,
+      /*0xa66b*/ 882,
+      /*0x2173*/ 673,
+      /*0x03eb*/ 282,
+      /*0x1043e*/ 1004,
+      -1,
+      /*0x2c43*/ 732,
+      /*0x118db*/ 1049,
+      -1,
+      /*0x0438*/ 297,
+      /*0x2c3a*/ 723,
+      /*0x03c0*/ 258,
+      /*0xff51*/ 972,
+      -1,
+      /*0x056a*/ 446,
+      /*0xa743*/ 913,
+      -1, -1,
+      /*0x1044f*/ 1021,
+      /*0x0070*/ 14,
+      -1,
+      /*0x118d5*/ 1043,
+      -1,
+      /*0x017a*/ 114,
+      /*0x01dd*/ 149,
+      /*0x2c41*/ 730,
+      /*0x057a*/ 462,
+      /*0xa649*/ 865,
+      -1,
+      /*0x03c9*/ 266,
+      /*0x1f7a*/ 658,
+      -1,
+      /*0x118dd*/ 1051,
+      /*0xa645*/ 863,
+      /*0xa741*/ 912,
+      /*0x03c5*/ 262,
+      -1, -1,
+      /*0xff57*/ 978,
+      -1,
+      /*0x0188*/ 120,
+      /*0x2c38*/ 721,
+      -1,
+      /*0x1043c*/ 1002,
+      /*0xa65f*/ 876,
+      -1,
+      /*0x03df*/ 276,
+      -1,
+      /*0x2c6a*/ 764,
+      /*0x118cf*/ 1037,
+      -1, -1,
+      /*0x1044d*/ 1019,
+      -1,
+      /*0xff53*/ 974,
+      /*0xa647*/ 864,
+      -1,
+      /*0x03c7*/ 264,
+      /*0x1ead*/ 558,
+      /*0x1e2d*/ 499,
+      /*0x04ad*/ 371,
+      /*0x012d*/ 78,
+      /*0x2cad*/ 790,
+      /*0x022d*/ 186,
+      /*0x052d*/ 435,
+      -1, -1, -1,
+      /*0x1044b*/ 1017,
+      /*0xa77a*/ 936,
+      /*0x0073*/ 17,
+      -1,
+      /*0x1eb3*/ 561,
+      /*0x1e33*/ 502,
+      /*0x04b3*/ 374,
+      /*0x0133*/ 80,
+      /*0x2cb3*/ 793,
+      /*0x0233*/ 189,
+      -1,
+      /*0xa643*/ 862,
+      /*0x0433*/ 292,
+      /*0x03c3*/ 260,
+      /*0x1f33*/ 625,
+      /*0x118cd*/ 1035,
+      /*0x018c*/ 121,
+      /*0x03ba*/ 252,
+      /*0x006b*/ 9,
+      /*0x2d1b*/ 848,
+      /*0xff59*/ 980,
+      /*0x2cec*/ 818,
+      /*0x026c*/ 217,
+      /*0x056c*/ 448,
+      /*0x2d24*/ 857,
+      /*0x2d00*/ 821,
+      /*0x2d11*/ 838,
+      /*0x2d18*/ 845,
+      /*0x2d22*/ 855,
+      /*0x0064*/ 3,
+      /*0xa641*/ 861,
+      /*0x118cb*/ 1033,
+      /*0x03c1*/ 259,
+      /*0x01f3*/ 159,
+      /*0x10440*/ 1006,
+      /*0x2d16*/ 843,
+      -1, -1,
+      /*0x2d0a*/ 831,
+      /*0xa72d*/ 903,
+      /*0x2d06*/ 827,
+      /*0x2d0f*/ 836,
+      -1,
+      /*0x0250*/ 199,
+      /*0x2c33*/ 716,
+      -1,
+      /*0x0450*/ 321,
+      -1,
+      /*0x03b8*/ 250,
+      /*0x01eb*/ 156,
+      -1, -1,
+      /*0x10449*/ 1015,
+      /*0xa733*/ 905,
+      -1,
+      /*0x2d1a*/ 847,
+      /*0x2d0b*/ 832,
+      /*0x2c6c*/ 765,
+      /*0x10445*/ 1011,
+      -1, -1,
+      /*0x2d10*/ 837,
+      /*0xff55*/ 976,
+      /*0x2d01*/ 822,
+      /*0x2d02*/ 823,
+      /*0x118c0*/ 1022,
+      -1,
+      /*0x1ea5*/ 554,
+      /*0x1e25*/ 495,
+      /*0x04a5*/ 367,
+      /*0x0125*/ 74,
+      /*0x2ca5*/ 786,
+      /*0x0225*/ 182,
+      /*0x0525*/ 431,
+      -1,
+      /*0x01c9*/ 139,
+      -1,
+      /*0x1f25*/ 619,
+      /*0x2c50*/ 745,
+      /*0x24d0*/ 687,
+      /*0x10447*/ 1013,
+      /*0xa7a5*/ 953,
+      /*0x217a*/ 680,
+      /*0x118c9*/ 1031,
+      /*0x0578*/ 460,
+      /*0x2d1e*/ 851,
+      /*0x1fd0*/ 664,
+      /*0x2d20*/ 853,
+      /*0x1f78*/ 656,
+      /*0x118c5*/ 1027,
+      /*0xff4f*/ 970,
+      -1,
+      /*0x01df*/ 150,
+      /*0x1ea3*/ 553,
+      /*0x1e23*/ 494,
+      /*0x04a3*/ 366,
+      /*0x0123*/ 73,
+      /*0x2ca3*/ 785,
+      /*0x0223*/ 181,
+      /*0x0523*/ 430,
+      /*0x118df*/ 1053,
+      /*0x0266*/ 213,
+      /*0x0566*/ 442,
+      /*0x1f23*/ 617,
+      /*0x10443*/ 1009,
+      /*0x03ad*/ 240,
+      /*0x1f66*/ 646,
+      /*0xa7a3*/ 952,
+      /*0x1043a*/ 1000,
+      -1, -1,
+      /*0x118c7*/ 1029,
+      /*0x1eef*/ 591,
+      /*0x1e6f*/ 532,
+      /*0x04ef*/ 404,
+      /*0x016f*/ 109,
+      /*0xa725*/ 899,
+      /*0x026f*/ 218,
+      /*0x056f*/ 451,
+      /*0x03b3*/ 245,
+      /*0x046f*/ 344,
+      /*0x2d14*/ 841,
+      -1,
+      /*0x10441*/ 1007,
+      /*0xff4d*/ 968,
+      /*0x2d0e*/ 835,
+      /*0x1eed*/ 590,
+      /*0x1e6d*/ 531,
+      /*0x04ed*/ 403,
+      /*0x016d*/ 108,
+      -1, -1,
+      /*0x056d*/ 449,
+      -1,
+      /*0x046d*/ 343,
+      /*0x118c3*/ 1025,
+      /*0x2c66*/ 762,
+      /*0x24e6*/ 709,
+      /*0x006a*/ 8,
+      /*0x10438*/ 998,
+      /*0xff4b*/ 966,
+      -1,
+      /*0xa723*/ 898,
+      /*0x1e85*/ 543,
+      /*0x1e05*/ 479,
+      /*0x2d04*/ 825,
+      /*0x0105*/ 58,
+      /*0x2c85*/ 770,
+      /*0x0205*/ 167,
+      /*0x0505*/ 415,
+      /*0x007a*/ 24,
+      -1, -1,
+      /*0x1f05*/ 605,
+      /*0x118c1*/ 1023,
+      /*0x0585*/ 473,
+      -1,
+      /*0xa785*/ 941,
+      /*0x0373*/ 234,
+      /*0x1e83*/ 542,
+      /*0x1e03*/ 478,
+      /*0xa76f*/ 935,
+      /*0x0103*/ 57,
+      /*0x2c83*/ 769,
+      /*0x0203*/ 166,
+      /*0x0503*/ 414,
+      /*0x0576*/ 458,
+      -1, -1,
+      /*0x1f03*/ 603,
+      /*0x1f76*/ 654,
+      /*0x0583*/ 471,
+      /*0xa685*/ 886,
+      /*0xa783*/ 940,
+      -1,
+      /*0xa76d*/ 934,
+      /*0x1ebf*/ 567,
+      /*0x1e3f*/ 508,
+      /*0x04bf*/ 380,
+      -1,
+      /*0x2cbf*/ 799,
+      /*0x023f*/ 191,
+      -1, -1,
+      /*0x043f*/ 304,
+      -1, -1, -1,
+      /*0xa683*/ 885,
+      /*0x1efd*/ 598,
+      /*0x1e7d*/ 539,
+      /*0x04fd*/ 411,
+      /*0xff49*/ 964,
+      /*0x03f8*/ 287,
+      /*0x027d*/ 222,
+      /*0x057d*/ 465,
+      /*0x1042d*/ 987,
+      /*0x047d*/ 351,
+      /*0xff45*/ 960,
+      /*0x1f7d*/ 661,
+      /*0x2c76*/ 767,
+      -1, -1,
+      /*0x1eb7*/ 563,
+      /*0x1e37*/ 504,
+      /*0x04b7*/ 376,
+      /*0x0137*/ 82,
+      /*0x2cb7*/ 795,
+      /*0x2178*/ 678,
+      /*0x1d7d*/ 476,
+      /*0x10433*/ 993,
+      /*0x0437*/ 296,
+      -1,
+      /*0x1f37*/ 629,
+      -1,
+      /*0x006c*/ 10,
+      /*0x2c3f*/ 728,
+      -1, -1,
+      /*0x01ad*/ 131,
+      /*0xff47*/ 962,
+      -1, -1, -1, -1,
+      /*0xa73f*/ 911,
+      -1,
+      /*0x03ef*/ 284,
+      /*0x1eb5*/ 562,
+      /*0x1e35*/ 503,
+      /*0x04b5*/ 375,
+      /*0x0135*/ 81,
+      /*0x2cb5*/ 794,
+      -1,
+      /*0x04c2*/ 381,
+      /*0x0142*/ 87,
+      /*0x0435*/ 294,
+      /*0x0242*/ 193,
+      /*0x1f35*/ 627,
+      /*0xa66d*/ 883,
+      /*0x0442*/ 307,
+      /*0x03ed*/ 283,
+      /*0x1f42*/ 632,
+      /*0x2c37*/ 720,
+      /*0xff43*/ 958,
+      /*0x1eb1*/ 560,
+      /*0x1e31*/ 501,
+      /*0x04b1*/ 373,
+      -1,
+      /*0x2cb1*/ 792,
+      /*0x0231*/ 188,
+      -1,
+      /*0xa737*/ 907,
+      /*0x0431*/ 290,
+      -1,
+      /*0x1f31*/ 623,
+      /*0x1ea7*/ 555,
+      /*0x1e27*/ 496,
+      /*0x04a7*/ 368,
+      /*0x0127*/ 75,
+      /*0x2ca7*/ 787,
+      /*0x0227*/ 183,
+      /*0x0527*/ 432,
+      /*0xff41*/ 956,
+      -1,
+      /*0x2d08*/ 829,
+      /*0x1f27*/ 621,
+      /*0x01d0*/ 142,
+      /*0x2c35*/ 718,
+      -1,
+      /*0xa7a7*/ 954,
+      /*0x00e1*/ 26,
+      /*0x2c42*/ 731,
+      /*0x2184*/ 686,
+      -1,
+      /*0x118d0*/ 1038,
+      /*0x0078*/ 22,
+      /*0xa735*/ 906,
+      /*0x1e95*/ 551,
+      /*0x1e15*/ 487,
+      /*0x0495*/ 359,
+      /*0x0115*/ 66,
+      /*0x2c95*/ 778,
+      /*0x0215*/ 175,
+      /*0x0515*/ 423,
+      /*0x2c31*/ 714,
+      /*0x00e5*/ 30,
+      -1,
+      /*0x1f15*/ 613,
+      -1,
+      /*0x2176*/ 676,
+      /*0x03bf*/ 257,
+      /*0x0283*/ 224,
+      /*0x1fb1*/ 663,
+      /*0x0066*/ 5,
+      -1,
+      /*0x01a5*/ 129,
+      /*0x00e3*/ 28,
+      /*0x1e93*/ 550,
+      /*0x1e13*/ 486,
+      /*0x0493*/ 358,
+      /*0x0113*/ 65,
+      /*0x2c93*/ 777,
+      /*0x0213*/ 174,
+      /*0x0513*/ 422,
+      /*0xa727*/ 900,
+      -1,
+      /*0xa695*/ 894,
+      /*0x1f13*/ 611,
+      /*0x2d0c*/ 833,
+      /*0x006f*/ 13,
+      -1,
+      /*0xa793*/ 945,
+      -1,
+      /*0x1f12*/ 610,
+      /*0x1ef9*/ 596,
+      /*0x1e79*/ 537,
+      /*0x04f9*/ 409,
+      /*0x03b7*/ 249,
+      /*0x217d*/ 683,
+      -1,
+      /*0x0579*/ 461,
+      /*0x01a3*/ 128,
+      /*0x0479*/ 349,
+      /*0x006d*/ 11,
+      /*0x1f79*/ 657,
+      /*0x00fe*/ 54,
+      /*0xa693*/ 893,
+      /*0x1ef5*/ 594,
+      /*0x1e75*/ 535,
+      /*0x04f5*/ 407,
+      /*0x0175*/ 112,
+      -1,
+      /*0x0275*/ 221,
+      /*0x0575*/ 457,
+      /*0x1d79*/ 475,
+      /*0x0475*/ 347,
+      -1,
+      /*0x1f75*/ 653,
+      -1, -1,
+      /*0x01ef*/ 158,
+      -1,
+      /*0x03b5*/ 247,
+      /*0x1ef1*/ 592,
+      /*0x1e71*/ 533,
+      /*0x04f1*/ 405,
+      /*0x0171*/ 110,
+      -1,
+      /*0x0271*/ 219,
+      /*0x0571*/ 453,
+      -1,
+      /*0x0471*/ 345,
+      -1,
+      /*0x1f71*/ 649,
+      /*0x01ed*/ 157,
+      -1, -1,
+      /*0x0076*/ 20,
+      -1,
+      /*0x03b1*/ 243,
+      -1, -1, -1,
+      /*0x1e87*/ 544,
+      /*0x1e07*/ 480,
+      /*0x00e9*/ 34,
+      /*0x0107*/ 59,
+      /*0x2c87*/ 771,
+      /*0x0207*/ 168,
+      /*0x0507*/ 416,
+      /*0x045a*/ 331,
+      /*0x0185*/ 119,
+      -1,
+      /*0x1f07*/ 607,
+      /*0x00e7*/ 32,
+      -1, -1,
+      /*0xa787*/ 942,
+      /*0x1ebd*/ 566,
+      /*0x1e3d*/ 507,
+      /*0x04bd*/ 379,
+      /*0x1043f*/ 1005,
+      /*0x2cbd*/ 798,
+      /*0xff50*/ 971,
+      -1, -1,
+      /*0x043d*/ 302,
+      /*0x0183*/ 118,
+      -1,
+      /*0x1eb9*/ 564,
+      /*0x1e39*/ 505,
+      /*0x04b9*/ 377,
+      /*0xa687*/ 887,
+      /*0x2cb9*/ 796,
+      /*0x04ce*/ 387,
+      -1, -1,
+      /*0x0439*/ 298,
+      -1, -1,
+      /*0x044e*/ 319,
+      /*0x00ee*/ 39,
+      /*0x2c5a*/ 755,
+      /*0x24da*/ 697,
+      /*0x01bf*/ 137,
+      -1, -1, -1,
+      /*0x10437*/ 997,
+      /*0x1eaf*/ 559,
+      /*0x1e2f*/ 500,
+      /*0x04af*/ 372,
+      /*0x012f*/ 79,
+      /*0x2caf*/ 791,
+      /*0x022f*/ 187,
+      /*0x052f*/ 436,
+      /*0x00f4*/ 45,
+      /*0x01fd*/ 163,
+      /*0x2c3d*/ 726,
+      -1,
+      /*0x1ea9*/ 556,
+      /*0x1e29*/ 497,
+      /*0x04a9*/ 369,
+      /*0x0129*/ 76,
+      /*0x2ca9*/ 788,
+      /*0x0229*/ 184,
+      /*0x0529*/ 433,
+      /*0xa73d*/ 910,
+      -1,
+      /*0x2c39*/ 722,
+      /*0x0272*/ 220,
+      /*0x0572*/ 454,
+      /*0x2c4e*/ 743,
+      /*0x10435*/ 995,
+      /*0xa7a9*/ 955,
+      /*0x1f72*/ 650,
+      /*0x0292*/ 231,
+      /*0x10442*/ 1008,
+      /*0xa739*/ 908,
+      /*0x1ea1*/ 552,
+      /*0x1e21*/ 493,
+      /*0x04a1*/ 365,
+      /*0x0121*/ 72,
+      /*0x2ca1*/ 784,
+      /*0x2179*/ 679,
+      /*0x0521*/ 429,
+      /*0x1efb*/ 597,
+      /*0x1e7b*/ 538,
+      /*0x04fb*/ 410,
+      /*0x1f21*/ 615,
+      /*0x10431*/ 991,
+      /*0x0562*/ 438,
+      /*0x057b*/ 463,
+      /*0xa7a1*/ 951,
+      /*0x047b*/ 350,
+      /*0x1f62*/ 642,
+      /*0x1f7b*/ 659,
+      /*0x2175*/ 675,
+      /*0xa72f*/ 904,
+      /*0x1e19*/ 489,
+      /*0x0499*/ 361,
+      /*0x0119*/ 68,
+      /*0x2c99*/ 780,
+      /*0x0219*/ 177,
+      /*0x0519*/ 425,
+      /*0x04c6*/ 383,
+      /*0x0146*/ 89,
+      /*0x00f0*/ 41,
+      /*0x118c2*/ 1024,
+      /*0xa729*/ 901,
+      -1,
+      /*0x0446*/ 311,
+      /*0xa799*/ 947,
+      /*0x2171*/ 671,
+      /*0x1ef7*/ 595,
+      /*0x1e77*/ 536,
+      /*0x04f7*/ 408,
+      /*0x0177*/ 113,
+      /*0x0268*/ 214,
+      /*0x0568*/ 444,
+      /*0x0577*/ 459,
+      -1,
+      /*0x0477*/ 348,
+      -1,
+      /*0x1f77*/ 655,
+      -1,
+      /*0x24e2*/ 705,
+      /*0xa699*/ 896,
+      -1,
+      /*0x1eff*/ 599,
+      /*0x1e7f*/ 540,
+      /*0x04ff*/ 412,
+      /*0x04cc*/ 386,
+      /*0x03bd*/ 255,
+      -1,
+      /*0x057f*/ 467,
+      /*0x0287*/ 225,
+      /*0x047f*/ 352,
+      /*0x044c*/ 317,
+      /*0x04c8*/ 384,
+      /*0x0148*/ 90,
+      -1, -1,
+      /*0x2c46*/ 735,
+      /*0x03b9*/ 251,
+      /*0x0448*/ 313,
+      /*0x0195*/ 123,
+      /*0x03ce*/ 271,
+      -1,
+      /*0x04c4*/ 382,
+      /*0x0144*/ 88,
+      /*0x2d2d*/ 860,
+      /*0x0079*/ 23,
+      /*0x2c68*/ 763,
+      /*0x24e8*/ 711,
+      /*0x0444*/ 309,
+      -1,
+      /*0x1f44*/ 634,
+      /*0x00f3*/ 44,
+      /*0x1ebb*/ 565,
+      /*0x1e3b*/ 506,
+      /*0x04bb*/ 378,
+      /*0x214e*/ 669,
+      /*0x2cbb*/ 797,
+      /*0x03af*/ 242,
+      /*0x0075*/ 19,
+      -1,
+      /*0x043b*/ 300,
+      -1, -1,
+      /*0x2c4c*/ 741,
+      -1,
+      /*0x0192*/ 122,
+      -1,
+      /*0x00eb*/ 36,
+      -1,
+      /*0x2d1c*/ 849,
+      /*0x2c48*/ 737,
+      /*0xa77f*/ 938,
+      -1,
+      /*0x03f2*/ 285,
+      /*0x0071*/ 15,
+      /*0x037d*/ 238,
+      /*0x01f9*/ 161,
+      -1,
+      /*0x00e4*/ 29,
+      -1,
+      /*0x2c44*/ 733,
+      /*0x1eab*/ 557,
+      /*0x1e2b*/ 498,
+      /*0x04ab*/ 370,
+      /*0x012b*/ 77,
+      /*0x2cab*/ 789,
+      /*0x022b*/ 185,
+      /*0x052b*/ 434,
+      /*0x2172*/ 672,
+      /*0x01f5*/ 160,
+      /*0x0256*/ 204,
+      -1,
+      /*0x2c3b*/ 724,
+      /*0x0456*/ 327,
+      /*0x03fb*/ 288,
+      /*0x1e17*/ 488,
+      /*0x0497*/ 360,
+      /*0x0117*/ 67,
+      /*0x2c97*/ 779,
+      /*0x0217*/ 176,
+      /*0x0517*/ 424,
+      /*0xa73b*/ 909,
+      /*0x1e1f*/ 492,
+      /*0x049f*/ 364,
+      /*0x011f*/ 71,
+      /*0x2c9f*/ 783,
+      /*0x021f*/ 180,
+      /*0x051f*/ 428,
+      /*0xa797*/ 946,
+      /*0x217b*/ 681,
+      /*0xff42*/ 957,
+      /*0x03c6*/ 263,
+      -1, -1,
+      /*0x0436*/ 295,
+      /*0xa79f*/ 950,
+      /*0x1f36*/ 628,
+      /*0x1043d*/ 1003,
+      -1, -1, -1,
+      /*0x2d25*/ 858,
+      -1,
+      /*0xa697*/ 895,
+      /*0x01da*/ 147,
+      /*0x2c56*/ 751,
+      /*0x24d6*/ 693,
+      -1,
+      /*0x10439*/ 999,
+      -1,
+      /*0xa72b*/ 902,
+      /*0x1044e*/ 1020,
+      /*0x118da*/ 1048,
+      -1, -1, -1, -1,
+      /*0x2177*/ 677,
+      /*0x03cc*/ 269,
+      -1,
+      /*0x01bd*/ 136,
+      -1, -1, -1, -1,
+      /*0x03c8*/ 265,
+      /*0x2c36*/ 719,
+      /*0x2d23*/ 856,
+      /*0x1042f*/ 989,
+      -1,
+      /*0x0254*/ 203,
+      /*0x01b9*/ 135,
+      /*0x217f*/ 685,
+      /*0x0454*/ 325,
+      /*0x01ce*/ 141,
+      /*0x03c4*/ 261,
+      /*0x0072*/ 16,
+      -1, -1,
+      /*0x10429*/ 983,
+      /*0x1e89*/ 545,
+      /*0x1e09*/ 481,
+      /*0x118ce*/ 1036,
+      /*0x0109*/ 60,
+      /*0x2c89*/ 772,
+      /*0x0209*/ 169,
+      /*0x0509*/ 417,
+      /*0x03bb*/ 253,
+      -1,
+      /*0x1e8d*/ 547,
+      /*0x1e0d*/ 483,
+      /*0x048d*/ 355,
+      /*0x010d*/ 62,
+      /*0x2c8d*/ 774,
+      /*0x020d*/ 171,
+      /*0x050d*/ 419,
+      /*0x0062*/ 1,
+      /*0x1e1d*/ 491,
+      /*0x049d*/ 363,
+      /*0x011d*/ 70,
+      /*0x2c9d*/ 782,
+      /*0x021d*/ 179,
+      /*0x051d*/ 427,
+      -1,
+      /*0x0458*/ 329,
+      /*0x2c54*/ 749,
+      /*0x24d4*/ 691,
+      /*0x00ea*/ 35,
+      /*0x0252*/ 201,
+      /*0xa689*/ 888,
+      /*0xa79d*/ 949,
+      /*0x0452*/ 323,
+      /*0x025c*/ 208,
+      -1,
+      /*0x04ca*/ 385,
+      /*0x045c*/ 333,
+      -1,
+      /*0x2d05*/ 826,
+      /*0xa68d*/ 890,
+      /*0x00fa*/ 50,
+      /*0x044a*/ 315,
+      /*0x01a1*/ 127,
+      /*0x10446*/ 1012,
+      /*0x017c*/ 115,
+      /*0x0068*/ 7,
+      /*0x0077*/ 21,
+      /*0x057c*/ 464,
+      -1,
+      /*0x01fb*/ 162,
+      -1,
+      /*0x1f7c*/ 660,
+      -1,
+      /*0x0434*/ 293,
+      /*0x2d03*/ 824,
+      /*0x1f34*/ 626,
+      /*0x045e*/ 335,
+      /*0x2c58*/ 753,
+      /*0x24d8*/ 695,
+      -1, -1,
+      /*0x0199*/ 124,
+      /*0x03b6*/ 248,
+      -1,
+      /*0x2c52*/ 747,
+      /*0x24d2*/ 689,
+      /*0x01c6*/ 138,
+      /*0x0260*/ 209,
+      /*0x2c5c*/ 757,
+      /*0x24dc*/ 699,
+      /*0x1044c*/ 1018,
+      /*0x0371*/ 233,
+      /*0x1f60*/ 640,
+      /*0x2c4a*/ 739,
+      /*0x118c6*/ 1028,
+      -1, -1,
+      /*0x10448*/ 1014,
+      -1, -1, -1,
+      /*0x0430*/ 289,
+      /*0xff5a*/ 981,
+      /*0x1f30*/ 622,
+      /*0x0432*/ 291,
+      /*0x2c34*/ 717,
+      /*0x1f32*/ 624,
+      /*0x10444*/ 1010,
+      /*0x2c5e*/ 759,
+      /*0x24de*/ 701,
+      /*0xa77c*/ 937,
+      -1,
+      /*0x01ff*/ 164,
+      /*0x01cc*/ 140,
+      -1, -1, -1, -1, -1,
+      /*0x1043b*/ 1001,
+      -1,
+      /*0x118cc*/ 1034,
+      -1,
+      /*0x24e0*/ 703,
+      -1,
+      /*0x00ec*/ 37,
+      -1, -1,
+      /*0x118c8*/ 1030,
+      -1,
+      /*0x1fe0*/ 666,
+      -1,
+      /*0xff4e*/ 969,
+      /*0x2c30*/ 713,
+      -1, -1,
+      /*0x2c32*/ 715,
+      -1,
+      /*0x118c4*/ 1026,
+      -1, -1,
+      /*0x1fb0*/ 662,
+      -1, -1, -1, -1, -1, -1,
+      /*0x1042b*/ 985,
+      -1, -1, -1, -1, -1,
+      /*0x0289*/ 227,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0x03ca*/ 267,
+      -1, -1,
+      /*0x2d27*/ 859,
+      -1,
+      /*0x10436*/ 996,
+      -1,
+      /*0x01d6*/ 145,
+      -1, -1, -1, -1,
+      /*0x03b4*/ 246,
+      -1, -1,
+      /*0x118d6*/ 1044,
+      -1, -1,
+      /*0x00f8*/ 48,
+      -1, -1, -1, -1,
+      /*0x217c*/ 682,
+      -1,
+      /*0x2d15*/ 842,
+      /*0x037b*/ 236,
+      -1,
+      /*0x01b6*/ 134,
+      -1, -1, -1, -1, -1, -1,
+      /*0xff46*/ 961,
+      /*0x00e6*/ 31,
+      -1, -1, -1, -1, -1, -1,
+      /*0x03b2*/ 244,
+      -1,
+      /*0x2d13*/ 840,
+      -1, -1, -1, -1, -1,
+      /*0x2d12*/ 839,
+      /*0x00ef*/ 40,
+      -1,
+      /*0x0377*/ 235,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0xff4c*/ 967,
+      -1, -1, -1,
+      /*0x00ed*/ 38,
+      /*0x01d4*/ 144,
+      -1,
+      /*0xff48*/ 963,
+      -1, -1, -1, -1, -1,
+      /*0x118d4*/ 1042,
+      -1, -1, -1,
+      /*0xff44*/ 959,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1,
+      /*0x1044a*/ 1016,
+      -1, -1, -1, -1, -1, -1,
+      /*0x01d8*/ 146,
+      -1,
+      /*0x00f6*/ 47,
+      -1, -1,
+      /*0x10434*/ 994,
+      -1,
+      /*0x01d2*/ 143,
+      /*0x118d8*/ 1046,
+      -1, -1,
+      /*0x01dc*/ 148,
+      -1,
+      /*0x2d07*/ 828,
+      -1,
+      /*0x118d2*/ 1040,
+      -1, -1, -1,
+      /*0x118dc*/ 1050,
+      -1, -1, -1, -1,
+      /*0x118ca*/ 1032,
+      -1,
+      /*0xff56*/ 977,
+      -1,
+      /*0x01b4*/ 133,
+      -1, -1,
+      /*0x00fd*/ 53,
+      -1,
+      /*0x10430*/ 990,
+      -1, -1,
+      /*0x10432*/ 992,
+      -1, -1,
+      /*0x118de*/ 1052,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1,
+      /*0x01b0*/ 132,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1,
+      /*0xff54*/ 975,
+      -1, -1,
+      /*0x2d21*/ 854,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      /*0x2d19*/ 846,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0xff58*/ 979,
+      -1, -1, -1, -1, -1, -1,
+      /*0xff52*/ 973,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0xff4a*/ 965,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0x037c*/ 237,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0x00f9*/ 49,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      /*0x00f5*/ 46,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0x00f1*/ 42,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      /*0x2d17*/ 844,
+      -1, -1, -1, -1, -1, -1,
+      /*0x2d1f*/ 852,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1,
+      /*0x00f2*/ 43,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0x2d09*/ 830,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0x2d0d*/ 834,
+      -1,
+      /*0x00e2*/ 27,
+      /*0x00fb*/ 51,
+      -1, -1, -1,
+      /*0x2d1d*/ 850,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1,
+      /*0x00e8*/ 33,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0x00ff*/ 55,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0x00fc*/ 52,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1,
+      /*0x00e0*/ 25
+    };
+
+  if (code <= MAX_CODE_VALUE && code >= MIN_CODE_VALUE)
+    {
+      register int key = onigenc_unicode_CaseUnfold_11_hash(code);
+
+      if (key <= MAX_HASH_VALUE && key >= 0)
+        {
+          register short s = wordlist[key];
+
+          if (s >= 0 && code1_equal(code, CaseUnfold_11_Table[s].from))
+            return &CaseUnfold_11_Table[s].to;
+        }
+    }
+  return 0;
+}
+
+static const CaseUnfold_12_Type CaseUnfold_12_Table[] = {
+#define CaseUnfold_12 (*(CaseUnfold_12_Type (*)[58])(CaseUnfold_12_Table+0))
+  {{0x0061, 0x02be}, {1, {0x1e9a}}},
+  {{0x0066, 0x0066}, {1, {0xfb00}}},
+  {{0x0066, 0x0069}, {1, {0xfb01}}},
+  {{0x0066, 0x006c}, {1, {0xfb02}}},
+  {{0x0068, 0x0331}, {1, {0x1e96}}},
+  {{0x006a, 0x030c}, {1, {0x01f0}}},
+  {{0x0073, 0x0073}, {2, {0x00df, 0x1e9e}}},
+  {{0x0073, 0x0074}, {2, {0xfb05, 0xfb06}}},
+  {{0x0074, 0x0308}, {1, {0x1e97}}},
+  {{0x0077, 0x030a}, {1, {0x1e98}}},
+  {{0x0079, 0x030a}, {1, {0x1e99}}},
+  {{0x02bc, 0x006e}, {1, {0x0149}}},
+  {{0x03ac, 0x03b9}, {1, {0x1fb4}}},
+  {{0x03ae, 0x03b9}, {1, {0x1fc4}}},
+  {{0x03b1, 0x0342}, {1, {0x1fb6}}},
+  {{0x03b1, 0x03b9}, {2, {0x1fb3, 0x1fbc}}},
+  {{0x03b7, 0x0342}, {1, {0x1fc6}}},
+  {{0x03b7, 0x03b9}, {2, {0x1fc3, 0x1fcc}}},
+  {{0x03b9, 0x0342}, {1, {0x1fd6}}},
+  {{0x03c1, 0x0313}, {1, {0x1fe4}}},
+  {{0x03c5, 0x0313}, {1, {0x1f50}}},
+  {{0x03c5, 0x0342}, {1, {0x1fe6}}},
+  {{0x03c9, 0x0342}, {1, {0x1ff6}}},
+  {{0x03c9, 0x03b9}, {2, {0x1ff3, 0x1ffc}}},
+  {{0x03ce, 0x03b9}, {1, {0x1ff4}}},
+  {{0x0565, 0x0582}, {1, {0x0587}}},
+  {{0x0574, 0x0565}, {1, {0xfb14}}},
+  {{0x0574, 0x056b}, {1, {0xfb15}}},
+  {{0x0574, 0x056d}, {1, {0xfb17}}},
+  {{0x0574, 0x0576}, {1, {0xfb13}}},
+  {{0x057e, 0x0576}, {1, {0xfb16}}},
+  {{0x1f00, 0x03b9}, {2, {0x1f80, 0x1f88}}},
+  {{0x1f01, 0x03b9}, {2, {0x1f81, 0x1f89}}},
+  {{0x1f02, 0x03b9}, {2, {0x1f82, 0x1f8a}}},
+  {{0x1f03, 0x03b9}, {2, {0x1f83, 0x1f8b}}},
+  {{0x1f04, 0x03b9}, {2, {0x1f84, 0x1f8c}}},
+  {{0x1f05, 0x03b9}, {2, {0x1f85, 0x1f8d}}},
+  {{0x1f06, 0x03b9}, {2, {0x1f86, 0x1f8e}}},
+  {{0x1f07, 0x03b9}, {2, {0x1f87, 0x1f8f}}},
+  {{0x1f20, 0x03b9}, {2, {0x1f90, 0x1f98}}},
+  {{0x1f21, 0x03b9}, {2, {0x1f91, 0x1f99}}},
+  {{0x1f22, 0x03b9}, {2, {0x1f92, 0x1f9a}}},
+  {{0x1f23, 0x03b9}, {2, {0x1f93, 0x1f9b}}},
+  {{0x1f24, 0x03b9}, {2, {0x1f94, 0x1f9c}}},
+  {{0x1f25, 0x03b9}, {2, {0x1f95, 0x1f9d}}},
+  {{0x1f26, 0x03b9}, {2, {0x1f96, 0x1f9e}}},
+  {{0x1f27, 0x03b9}, {2, {0x1f97, 0x1f9f}}},
+  {{0x1f60, 0x03b9}, {2, {0x1fa0, 0x1fa8}}},
+  {{0x1f61, 0x03b9}, {2, {0x1fa1, 0x1fa9}}},
+  {{0x1f62, 0x03b9}, {2, {0x1fa2, 0x1faa}}},
+  {{0x1f63, 0x03b9}, {2, {0x1fa3, 0x1fab}}},
+  {{0x1f64, 0x03b9}, {2, {0x1fa4, 0x1fac}}},
+  {{0x1f65, 0x03b9}, {2, {0x1fa5, 0x1fad}}},
+  {{0x1f66, 0x03b9}, {2, {0x1fa6, 0x1fae}}},
+  {{0x1f67, 0x03b9}, {2, {0x1fa7, 0x1faf}}},
+  {{0x1f70, 0x03b9}, {1, {0x1fb2}}},
+  {{0x1f74, 0x03b9}, {1, {0x1fc2}}},
+  {{0x1f7c, 0x03b9}, {1, {0x1ff2}}},
+#define CaseUnfold_12_Locale (*(CaseUnfold_12_Type (*)[1])(CaseUnfold_12_Table+58))
+  {{0x0069, 0x0307}, {1, {0x0130}}},
+};
+
+/* C code produced by gperf version 3.0.3 */
+/* Command-line: gperf -7 -k1,2,3,4,5,6 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_12_hash -N onigenc_unicode_CaseUnfold_12_lookup -n  */
+
+/* maximum key range = 71, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_12_hash(const OnigCodePoint *codes)
+{
+  static const unsigned char asso_values[] =
+    {
+       3, 58, 54, 57, 56, 16,  8,  2, 43, 82,
+       3,  1, 23, 82, 82, 82, 82, 82, 82,  4,
+      82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+      82, 82, 52, 51, 50, 49, 48, 47, 46, 45,
+      82, 82, 82, 82, 43, 82, 42, 82, 82, 13,
+      82, 82, 82, 82, 82, 11, 82,  1, 82, 82,
+      14, 82,  1, 82, 82, 31,  3, 82, 82, 30,
+      82, 82, 82, 10, 82, 82, 82, 82, 37, 82,
+      82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+      82, 82, 82, 82, 82, 82, 37, 15, 36, 35,
+      34, 17,  1, 33, 12,  4, 23, 23, 26, 21,
+      13, 82, 27, 82, 82,  2,  5, 82, 11, 16,
+      82, 15, 82, 82, 23, 82,  8, 82
+    };
+  return asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
+}
+
+#ifdef __GNUC__
+__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+static const CodePointList2 *
+onigenc_unicode_CaseUnfold_12_lookup(const OnigCodePoint *codes)
+{
+  enum
+    {
+      MIN_CODE_VALUE = 0x61,
+      MAX_CODE_VALUE = 0x1f7c,
+      TOTAL_KEYWORDS = 59,
+      MIN_WORD_LENGTH = 6,
+      MAX_WORD_LENGTH = 6,
+      MIN_HASH_VALUE = 11,
+      MAX_HASH_VALUE = 81
+    };
+
+  static const short wordlist[] =
+    {
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1,
+      /*0x1f66,0x03b9*/ 53,
+      /*0x1f07,0x03b9*/ 38,
+      /*0x1f00,0x03b9*/ 31,
+      /*0x0066,0x0066*/ 1,
+      /*0x1f74,0x03b9*/ 56,
+      /*0x0073,0x0073*/ 6,
+      /*0x0066,0x0069*/ 2,
+      /*0x1f06,0x03b9*/ 37,
+      /*0x0073,0x0074*/ 7,
+      /*0x03b9,0x0342*/ 18,
+      /*0x03c9,0x03b9*/ 23,
+      /*0x03b7,0x03b9*/ 17,
+      /*0x0069,0x0307*/ 58,
+      /*0x03b1,0x03b9*/ 15,
+      /*0x1f61,0x03b9*/ 48,
+      /*0x1f05,0x03b9*/ 36,
+      /*0x1f65,0x03b9*/ 52,
+      /*0x0574,0x0576*/ 29,
+      /*0x03c9,0x0342*/ 22,
+      /*0x03b7,0x0342*/ 16,
+      /*0x057e,0x0576*/ 30,
+      /*0x03b1,0x0342*/ 14,
+      /*0x1f7c,0x03b9*/ 57,
+      /*0x0574,0x0565*/ 26,
+      /*0x0079,0x030a*/ 10,
+      /*0x0077,0x030a*/ 9,
+      /*0x1f70,0x03b9*/ 55,
+      /*0x0574,0x056d*/ 28,
+      /*0x0066,0x006c*/ 3,
+      /*0x0574,0x056b*/ 27,
+      /*0x0061,0x02be*/ 0,
+      /*0x0068,0x0331*/ 4,
+      /*0x1f67,0x03b9*/ 54,
+      /*0x1f64,0x03b9*/ 51,
+      /*0x1f63,0x03b9*/ 50,
+      /*0x1f62,0x03b9*/ 49,
+      /*0x1f60,0x03b9*/ 47,
+      /*0x03ce,0x03b9*/ 24,
+      /*0x03c5,0x0342*/ 21,
+      /*0x03c5,0x0313*/ 20,
+      /*0x03c1,0x0313*/ 19,
+      /*0x02bc,0x006e*/ 11,
+      /*0x03ae,0x03b9*/ 13,
+      /*0x03ac,0x03b9*/ 12,
+      /*0x1f27,0x03b9*/ 46,
+      /*0x1f26,0x03b9*/ 45,
+      /*0x1f25,0x03b9*/ 44,
+      /*0x1f24,0x03b9*/ 43,
+      /*0x1f23,0x03b9*/ 42,
+      /*0x1f22,0x03b9*/ 41,
+      /*0x1f21,0x03b9*/ 40,
+      /*0x1f20,0x03b9*/ 39,
+      /*0x006a,0x030c*/ 5,
+      /*0x1f02,0x03b9*/ 33,
+      /*0x0074,0x0308*/ 8,
+      /*0x1f04,0x03b9*/ 35,
+      /*0x1f03,0x03b9*/ 34,
+      /*0x1f01,0x03b9*/ 32,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      /*0x0565,0x0582*/ 25
+    };
+
+  if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
+      codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE)
+    {
+      register int key = onigenc_unicode_CaseUnfold_12_hash(codes);
+
+      if (key <= MAX_HASH_VALUE && key >= 0)
+        {
+          register short s = wordlist[key];
+
+          if (s >= 0 && code2_equal(codes, CaseUnfold_12_Table[s].from))
+            return &CaseUnfold_12_Table[s].to;
+        }
+    }
+  return 0;
+}
+
+static const CaseUnfold_13_Type CaseUnfold_13_Table[] = {
+#define CaseUnfold_13 (*(CaseUnfold_13_Type (*)[14])(CaseUnfold_13_Table+0))
+  {{0x0066, 0x0066, 0x0069}, {1, {0xfb03}}},
+  {{0x0066, 0x0066, 0x006c}, {1, {0xfb04}}},
+  {{0x03b1, 0x0342, 0x03b9}, {1, {0x1fb7}}},
+  {{0x03b7, 0x0342, 0x03b9}, {1, {0x1fc7}}},
+  {{0x03b9, 0x0308, 0x0300}, {1, {0x1fd2}}},
+  {{0x03b9, 0x0308, 0x0301}, {2, {0x0390, 0x1fd3}}},
+  {{0x03b9, 0x0308, 0x0342}, {1, {0x1fd7}}},
+  {{0x03c5, 0x0308, 0x0300}, {1, {0x1fe2}}},
+  {{0x03c5, 0x0308, 0x0301}, {2, {0x03b0, 0x1fe3}}},
+  {{0x03c5, 0x0308, 0x0342}, {1, {0x1fe7}}},
+  {{0x03c5, 0x0313, 0x0300}, {1, {0x1f52}}},
+  {{0x03c5, 0x0313, 0x0301}, {1, {0x1f54}}},
+  {{0x03c5, 0x0313, 0x0342}, {1, {0x1f56}}},
+  {{0x03c9, 0x0342, 0x03b9}, {1, {0x1ff7}}},
+};
+
+/* C code produced by gperf version 3.0.3 */
+/* Command-line: gperf -7 -k1,2,3,4,5,6,7,8,9 -F,-1 -c -j1 -i1 -t -T -E -C -H onigenc_unicode_CaseUnfold_13_hash -N onigenc_unicode_CaseUnfold_13_lookup -n  */
+
+/* maximum key range = 20, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+/*ARGSUSED*/
+static unsigned int
+onigenc_unicode_CaseUnfold_13_hash(const OnigCodePoint *codes)
+{
+  static const unsigned char asso_values[] =
+    {
+       7,  4, 47, 47, 47, 47,  1,  1,  2, 47,
+      47, 47, 47, 47, 47, 47, 47, 47, 47,  1,
+      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+      47, 47, 47, 47, 47, 47, 47, 47, 47, 11,
+      47, 47, 47, 47, 47, 10, 47,  2, 47, 47,
+      47, 47, 47, 47, 47, 47,  1, 47, 47,  1,
+      47, 47, 47,  9, 47, 47, 47, 47, 47, 47,
+      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+      47, 47,  1, 47, 47,  2, 47, 47,  1, 47,
+      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
+      47, 47, 47, 47, 47, 47, 47, 47
+    };
+  return asso_values[bits_at(codes, 8)] + asso_values[bits_at(codes, 7)] + asso_values[bits_at(codes, 6)] + asso_values[bits_at(codes, 5)] + asso_values[bits_at(codes, 4)] + asso_values[bits_at(codes, 3)] + asso_values[bits_at(codes, 2)] + asso_values[bits_at(codes, 1)] + asso_values[bits_at(codes, 0)];
+}
+
+#ifdef __GNUC__
+__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+static const CodePointList2 *
+onigenc_unicode_CaseUnfold_13_lookup(const OnigCodePoint *codes)
+{
+  enum
+    {
+      MIN_CODE_VALUE = 0x66,
+      MAX_CODE_VALUE = 0x3c9,
+      TOTAL_KEYWORDS = 14,
+      MIN_WORD_LENGTH = 9,
+      MAX_WORD_LENGTH = 9,
+      MIN_HASH_VALUE = 27,
+      MAX_HASH_VALUE = 46
+    };
+
+  static const short wordlist[] =
+    {
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1, -1, -1, -1,
+      -1, -1, -1,
+      /*0x03c5,0x0313,0x0342*/ 12,
+      /*0x03c5,0x0308,0x0342*/ 9,
+      /*0x03b9,0x0308,0x0342*/ 6,
+      /*0x03c5,0x0313,0x0301*/ 11,
+      /*0x03c5,0x0308,0x0301*/ 8,
+      /*0x03b9,0x0308,0x0301*/ 5,
+      /*0x03c5,0x0313,0x0300*/ 10,
+      /*0x03c5,0x0308,0x0300*/ 7,
+      /*0x03b9,0x0308,0x0300*/ 4,
+      /*0x03c9,0x0342,0x03b9*/ 13,
+      /*0x03b7,0x0342,0x03b9*/ 3,
+      /*0x03b1,0x0342,0x03b9*/ 2,
+      -1, -1, -1, -1, -1, -1,
+      /*0x0066,0x0066,0x006c*/ 1,
+      /*0x0066,0x0066,0x0069*/ 0
+    };
+
+  if (codes[0] <= MAX_CODE_VALUE && codes[0] >= MIN_CODE_VALUE &&
+      codes[1] <= MAX_CODE_VALUE && codes[1] >= MIN_CODE_VALUE &&
+      codes[2] <= MAX_CODE_VALUE && codes[2] >= MIN_CODE_VALUE)
+    {
+      register int key = onigenc_unicode_CaseUnfold_13_hash(codes);
+
+      if (key <= MAX_HASH_VALUE && key >= 0)
+        {
+          register short s = wordlist[key];
+
+          if (s >= 0 && code3_equal(codes, CaseUnfold_13_Table[s].from))
+            return &CaseUnfold_13_Table[s].to;
+        }
+    }
+  return 0;
+}
+
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode/name2ctype.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode/name2ctype.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/unicode/name2ctype.h	(revision 279)
@@ -0,0 +1,32679 @@
+/* C code produced by gperf version 3.0.3 */
+/* Command-line: gperf -7 -c -j1 -i1 -t -C -P -T -H uniname2ctype_hash -Q uniname2ctype_pool -N uniname2ctype_p  */
+#ifndef USE_UNICODE_PROPERTIES
+/* Computed positions: -k'1,3' */
+#else /* USE_UNICODE_PROPERTIES */
+/* Computed positions: -k'1-3,5-6,12,16,$' */
+#endif /* USE_UNICODE_PROPERTIES */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+      && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+      && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+      && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+      && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+      && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+      && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+      && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+      && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+      && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+      && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+      && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+      && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+      && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+      && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+      && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+      && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+      && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+      && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+      && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+      && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+      && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+      && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646.  */
+error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
+#endif
+
+
+#define long size_t
+
+/* 'NEWLINE': [[:NEWLINE:]] */
+static const OnigCodePoint CR_NEWLINE[] = {
+	1,
+	0x000a, 0x000a,
+}; /* CR_NEWLINE */
+
+/* 'Alpha': [[:Alpha:]] */
+static const OnigCodePoint CR_Alpha[] = {
+	600,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0345, 0x0345,
+	0x0370, 0x0374,
+	0x0376, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x05b0, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0610, 0x061a,
+	0x0620, 0x0657,
+	0x0659, 0x065f,
+	0x066e, 0x06d3,
+	0x06d5, 0x06dc,
+	0x06e1, 0x06e8,
+	0x06ed, 0x06ef,
+	0x06fa, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x073f,
+	0x074d, 0x07b1,
+	0x07ca, 0x07ea,
+	0x07f4, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x0817,
+	0x081a, 0x082c,
+	0x0840, 0x0858,
+	0x08a0, 0x08b2,
+	0x08e4, 0x08e9,
+	0x08f0, 0x093b,
+	0x093d, 0x094c,
+	0x094e, 0x0950,
+	0x0955, 0x0963,
+	0x0971, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bd, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cc,
+	0x09ce, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09f0, 0x09f1,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4c,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a70, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abd, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acc,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3d, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4c,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b71, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcc,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4c,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbd, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccc,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4c,
+	0x0d4e, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d7a, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df3,
+	0x0e01, 0x0e3a,
+	0x0e40, 0x0e46,
+	0x0e4d, 0x0e4d,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ecd, 0x0ecd,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f40, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f81,
+	0x0f88, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x1000, 0x1036,
+	0x1038, 0x1038,
+	0x103b, 0x103f,
+	0x1050, 0x1062,
+	0x1065, 0x1068,
+	0x106e, 0x1086,
+	0x108e, 0x108e,
+	0x109c, 0x109d,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135f, 0x135f,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1713,
+	0x1720, 0x1733,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17b3,
+	0x17b6, 0x17c8,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dc,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x1938,
+	0x1950, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x1a00, 0x1a1b,
+	0x1a20, 0x1a5e,
+	0x1a61, 0x1a74,
+	0x1aa7, 0x1aa7,
+	0x1b00, 0x1b33,
+	0x1b35, 0x1b43,
+	0x1b45, 0x1b4b,
+	0x1b80, 0x1ba9,
+	0x1bac, 0x1baf,
+	0x1bba, 0x1be5,
+	0x1be7, 0x1bf1,
+	0x1c00, 0x1c35,
+	0x1c4d, 0x1c4f,
+	0x1c5a, 0x1c7d,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf3,
+	0x1cf5, 0x1cf6,
+	0x1d00, 0x1dbf,
+	0x1de7, 0x1df4,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x212f, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x24b6, 0x24e9,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2dff,
+	0x2e2f, 0x2e2f,
+	0x3005, 0x3007,
+	0x3021, 0x3029,
+	0x3031, 0x3035,
+	0x3038, 0x303c,
+	0x3041, 0x3096,
+	0x309d, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa61f,
+	0xa62a, 0xa62b,
+	0xa640, 0xa66e,
+	0xa674, 0xa67b,
+	0xa67f, 0xa69d,
+	0xa69f, 0xa6ef,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa801,
+	0xa803, 0xa805,
+	0xa807, 0xa80a,
+	0xa80c, 0xa827,
+	0xa840, 0xa873,
+	0xa880, 0xa8c3,
+	0xa8f2, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa90a, 0xa92a,
+	0xa930, 0xa952,
+	0xa960, 0xa97c,
+	0xa980, 0xa9b2,
+	0xa9b4, 0xa9bf,
+	0xa9cf, 0xa9cf,
+	0xa9e0, 0xa9e4,
+	0xa9e6, 0xa9ef,
+	0xa9fa, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaa7a,
+	0xaa7e, 0xaabe,
+	0xaac0, 0xaac0,
+	0xaac2, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaef,
+	0xaaf2, 0xaaf5,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabea,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0xff66, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10140, 0x10174,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031f,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x103d1, 0x103d5,
+	0x10400, 0x1049d,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae4,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11000, 0x11045,
+	0x11082, 0x110b8,
+	0x110d0, 0x110e8,
+	0x11100, 0x11132,
+	0x11150, 0x11172,
+	0x11176, 0x11176,
+	0x11180, 0x111bf,
+	0x111c1, 0x111c4,
+	0x111da, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x11234,
+	0x11237, 0x11237,
+	0x112b0, 0x112e8,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133d, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134c,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11480, 0x114c1,
+	0x114c4, 0x114c5,
+	0x114c7, 0x114c7,
+	0x11580, 0x115b5,
+	0x115b8, 0x115be,
+	0x11600, 0x1163e,
+	0x11640, 0x11640,
+	0x11644, 0x11644,
+	0x11680, 0x116b5,
+	0x118a0, 0x118df,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16ad0, 0x16aed,
+	0x16b00, 0x16b36,
+	0x16b40, 0x16b43,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f93, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9e, 0x1bc9e,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1e800, 0x1e8c4,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1f130, 0x1f149,
+	0x1f150, 0x1f169,
+	0x1f170, 0x1f189,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_Alpha */
+
+/* 'Blank': [[:Blank:]] */
+static const OnigCodePoint CR_Blank[] = {
+	8,
+	0x0009, 0x0009,
+	0x0020, 0x0020,
+	0x00a0, 0x00a0,
+	0x1680, 0x1680,
+	0x2000, 0x200a,
+	0x202f, 0x202f,
+	0x205f, 0x205f,
+	0x3000, 0x3000,
+}; /* CR_Blank */
+
+/* 'Cntrl': [[:Cntrl:]] */
+static const OnigCodePoint CR_Cntrl[] = {
+	2,
+	0x0000, 0x001f,
+	0x007f, 0x009f,
+}; /* CR_Cntrl */
+
+/* 'Digit': [[:Digit:]] */
+static const OnigCodePoint CR_Digit[] = {
+	50,
+	0x0030, 0x0039,
+	0x0660, 0x0669,
+	0x06f0, 0x06f9,
+	0x07c0, 0x07c9,
+	0x0966, 0x096f,
+	0x09e6, 0x09ef,
+	0x0a66, 0x0a6f,
+	0x0ae6, 0x0aef,
+	0x0b66, 0x0b6f,
+	0x0be6, 0x0bef,
+	0x0c66, 0x0c6f,
+	0x0ce6, 0x0cef,
+	0x0d66, 0x0d6f,
+	0x0de6, 0x0def,
+	0x0e50, 0x0e59,
+	0x0ed0, 0x0ed9,
+	0x0f20, 0x0f29,
+	0x1040, 0x1049,
+	0x1090, 0x1099,
+	0x17e0, 0x17e9,
+	0x1810, 0x1819,
+	0x1946, 0x194f,
+	0x19d0, 0x19d9,
+	0x1a80, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1b50, 0x1b59,
+	0x1bb0, 0x1bb9,
+	0x1c40, 0x1c49,
+	0x1c50, 0x1c59,
+	0xa620, 0xa629,
+	0xa8d0, 0xa8d9,
+	0xa900, 0xa909,
+	0xa9d0, 0xa9d9,
+	0xa9f0, 0xa9f9,
+	0xaa50, 0xaa59,
+	0xabf0, 0xabf9,
+	0xff10, 0xff19,
+	0x104a0, 0x104a9,
+	0x11066, 0x1106f,
+	0x110f0, 0x110f9,
+	0x11136, 0x1113f,
+	0x111d0, 0x111d9,
+	0x112f0, 0x112f9,
+	0x114d0, 0x114d9,
+	0x11650, 0x11659,
+	0x116c0, 0x116c9,
+	0x118e0, 0x118e9,
+	0x16a60, 0x16a69,
+	0x16b50, 0x16b59,
+	0x1d7ce, 0x1d7ff,
+}; /* CR_Digit */
+
+/* 'Graph': [[:Graph:]] */
+static const OnigCodePoint CR_Graph[] = {
+	605,
+	0x0021, 0x007e,
+	0x00a1, 0x0377,
+	0x037a, 0x037f,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058d, 0x058f,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x061c,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x08a0, 0x08b2,
+	0x08e4, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x167f,
+	0x1681, 0x169c,
+	0x16a0, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd0, 0x1cf6,
+	0x1cf8, 0x1cf9,
+	0x1d00, 0x1df5,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x200b, 0x2027,
+	0x202a, 0x202e,
+	0x2030, 0x205e,
+	0x2060, 0x2064,
+	0x2066, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20bd,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e42,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3001, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa69d,
+	0xa69f, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaac2,
+	0xaadb, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xe000, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe2d,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0xfffd,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018c,
+	0x10190, 0x1019b,
+	0x101a0, 0x101a0,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e0, 0x102fb,
+	0x10300, 0x10323,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x1056f, 0x1056f,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1089e,
+	0x108a7, 0x108af,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a9f,
+	0x10ac0, 0x10ae6,
+	0x10aeb, 0x10af6,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b91,
+	0x10b99, 0x10b9c,
+	0x10ba9, 0x10baf,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x1107f, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+	0x11150, 0x11176,
+	0x11180, 0x111c8,
+	0x111cd, 0x111cd,
+	0x111d0, 0x111da,
+	0x111e1, 0x111f4,
+	0x11200, 0x11211,
+	0x11213, 0x1123d,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x11480, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c9,
+	0x11600, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118f2,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x12470, 0x12474,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16a6e, 0x16a6f,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af5,
+	0x16b00, 0x16b45,
+	0x16b50, 0x16b59,
+	0x16b5b, 0x16b61,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9c, 0x1bca3,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8c7, 0x1e8d6,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f100, 0x1f10c,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xf0000, 0xffffd,
+	0x100000, 0x10fffd,
+}; /* CR_Graph */
+
+/* 'Lower': [[:Lower:]] */
+static const OnigCodePoint CR_Lower[] = {
+	633,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00df, 0x00f6,
+	0x00f8, 0x00ff,
+	0x0101, 0x0101,
+	0x0103, 0x0103,
+	0x0105, 0x0105,
+	0x0107, 0x0107,
+	0x0109, 0x0109,
+	0x010b, 0x010b,
+	0x010d, 0x010d,
+	0x010f, 0x010f,
+	0x0111, 0x0111,
+	0x0113, 0x0113,
+	0x0115, 0x0115,
+	0x0117, 0x0117,
+	0x0119, 0x0119,
+	0x011b, 0x011b,
+	0x011d, 0x011d,
+	0x011f, 0x011f,
+	0x0121, 0x0121,
+	0x0123, 0x0123,
+	0x0125, 0x0125,
+	0x0127, 0x0127,
+	0x0129, 0x0129,
+	0x012b, 0x012b,
+	0x012d, 0x012d,
+	0x012f, 0x012f,
+	0x0131, 0x0131,
+	0x0133, 0x0133,
+	0x0135, 0x0135,
+	0x0137, 0x0138,
+	0x013a, 0x013a,
+	0x013c, 0x013c,
+	0x013e, 0x013e,
+	0x0140, 0x0140,
+	0x0142, 0x0142,
+	0x0144, 0x0144,
+	0x0146, 0x0146,
+	0x0148, 0x0149,
+	0x014b, 0x014b,
+	0x014d, 0x014d,
+	0x014f, 0x014f,
+	0x0151, 0x0151,
+	0x0153, 0x0153,
+	0x0155, 0x0155,
+	0x0157, 0x0157,
+	0x0159, 0x0159,
+	0x015b, 0x015b,
+	0x015d, 0x015d,
+	0x015f, 0x015f,
+	0x0161, 0x0161,
+	0x0163, 0x0163,
+	0x0165, 0x0165,
+	0x0167, 0x0167,
+	0x0169, 0x0169,
+	0x016b, 0x016b,
+	0x016d, 0x016d,
+	0x016f, 0x016f,
+	0x0171, 0x0171,
+	0x0173, 0x0173,
+	0x0175, 0x0175,
+	0x0177, 0x0177,
+	0x017a, 0x017a,
+	0x017c, 0x017c,
+	0x017e, 0x0180,
+	0x0183, 0x0183,
+	0x0185, 0x0185,
+	0x0188, 0x0188,
+	0x018c, 0x018d,
+	0x0192, 0x0192,
+	0x0195, 0x0195,
+	0x0199, 0x019b,
+	0x019e, 0x019e,
+	0x01a1, 0x01a1,
+	0x01a3, 0x01a3,
+	0x01a5, 0x01a5,
+	0x01a8, 0x01a8,
+	0x01aa, 0x01ab,
+	0x01ad, 0x01ad,
+	0x01b0, 0x01b0,
+	0x01b4, 0x01b4,
+	0x01b6, 0x01b6,
+	0x01b9, 0x01ba,
+	0x01bd, 0x01bf,
+	0x01c6, 0x01c6,
+	0x01c9, 0x01c9,
+	0x01cc, 0x01cc,
+	0x01ce, 0x01ce,
+	0x01d0, 0x01d0,
+	0x01d2, 0x01d2,
+	0x01d4, 0x01d4,
+	0x01d6, 0x01d6,
+	0x01d8, 0x01d8,
+	0x01da, 0x01da,
+	0x01dc, 0x01dd,
+	0x01df, 0x01df,
+	0x01e1, 0x01e1,
+	0x01e3, 0x01e3,
+	0x01e5, 0x01e5,
+	0x01e7, 0x01e7,
+	0x01e9, 0x01e9,
+	0x01eb, 0x01eb,
+	0x01ed, 0x01ed,
+	0x01ef, 0x01f0,
+	0x01f3, 0x01f3,
+	0x01f5, 0x01f5,
+	0x01f9, 0x01f9,
+	0x01fb, 0x01fb,
+	0x01fd, 0x01fd,
+	0x01ff, 0x01ff,
+	0x0201, 0x0201,
+	0x0203, 0x0203,
+	0x0205, 0x0205,
+	0x0207, 0x0207,
+	0x0209, 0x0209,
+	0x020b, 0x020b,
+	0x020d, 0x020d,
+	0x020f, 0x020f,
+	0x0211, 0x0211,
+	0x0213, 0x0213,
+	0x0215, 0x0215,
+	0x0217, 0x0217,
+	0x0219, 0x0219,
+	0x021b, 0x021b,
+	0x021d, 0x021d,
+	0x021f, 0x021f,
+	0x0221, 0x0221,
+	0x0223, 0x0223,
+	0x0225, 0x0225,
+	0x0227, 0x0227,
+	0x0229, 0x0229,
+	0x022b, 0x022b,
+	0x022d, 0x022d,
+	0x022f, 0x022f,
+	0x0231, 0x0231,
+	0x0233, 0x0239,
+	0x023c, 0x023c,
+	0x023f, 0x0240,
+	0x0242, 0x0242,
+	0x0247, 0x0247,
+	0x0249, 0x0249,
+	0x024b, 0x024b,
+	0x024d, 0x024d,
+	0x024f, 0x0293,
+	0x0295, 0x02b8,
+	0x02c0, 0x02c1,
+	0x02e0, 0x02e4,
+	0x0345, 0x0345,
+	0x0371, 0x0371,
+	0x0373, 0x0373,
+	0x0377, 0x0377,
+	0x037a, 0x037d,
+	0x0390, 0x0390,
+	0x03ac, 0x03ce,
+	0x03d0, 0x03d1,
+	0x03d5, 0x03d7,
+	0x03d9, 0x03d9,
+	0x03db, 0x03db,
+	0x03dd, 0x03dd,
+	0x03df, 0x03df,
+	0x03e1, 0x03e1,
+	0x03e3, 0x03e3,
+	0x03e5, 0x03e5,
+	0x03e7, 0x03e7,
+	0x03e9, 0x03e9,
+	0x03eb, 0x03eb,
+	0x03ed, 0x03ed,
+	0x03ef, 0x03f3,
+	0x03f5, 0x03f5,
+	0x03f8, 0x03f8,
+	0x03fb, 0x03fc,
+	0x0430, 0x045f,
+	0x0461, 0x0461,
+	0x0463, 0x0463,
+	0x0465, 0x0465,
+	0x0467, 0x0467,
+	0x0469, 0x0469,
+	0x046b, 0x046b,
+	0x046d, 0x046d,
+	0x046f, 0x046f,
+	0x0471, 0x0471,
+	0x0473, 0x0473,
+	0x0475, 0x0475,
+	0x0477, 0x0477,
+	0x0479, 0x0479,
+	0x047b, 0x047b,
+	0x047d, 0x047d,
+	0x047f, 0x047f,
+	0x0481, 0x0481,
+	0x048b, 0x048b,
+	0x048d, 0x048d,
+	0x048f, 0x048f,
+	0x0491, 0x0491,
+	0x0493, 0x0493,
+	0x0495, 0x0495,
+	0x0497, 0x0497,
+	0x0499, 0x0499,
+	0x049b, 0x049b,
+	0x049d, 0x049d,
+	0x049f, 0x049f,
+	0x04a1, 0x04a1,
+	0x04a3, 0x04a3,
+	0x04a5, 0x04a5,
+	0x04a7, 0x04a7,
+	0x04a9, 0x04a9,
+	0x04ab, 0x04ab,
+	0x04ad, 0x04ad,
+	0x04af, 0x04af,
+	0x04b1, 0x04b1,
+	0x04b3, 0x04b3,
+	0x04b5, 0x04b5,
+	0x04b7, 0x04b7,
+	0x04b9, 0x04b9,
+	0x04bb, 0x04bb,
+	0x04bd, 0x04bd,
+	0x04bf, 0x04bf,
+	0x04c2, 0x04c2,
+	0x04c4, 0x04c4,
+	0x04c6, 0x04c6,
+	0x04c8, 0x04c8,
+	0x04ca, 0x04ca,
+	0x04cc, 0x04cc,
+	0x04ce, 0x04cf,
+	0x04d1, 0x04d1,
+	0x04d3, 0x04d3,
+	0x04d5, 0x04d5,
+	0x04d7, 0x04d7,
+	0x04d9, 0x04d9,
+	0x04db, 0x04db,
+	0x04dd, 0x04dd,
+	0x04df, 0x04df,
+	0x04e1, 0x04e1,
+	0x04e3, 0x04e3,
+	0x04e5, 0x04e5,
+	0x04e7, 0x04e7,
+	0x04e9, 0x04e9,
+	0x04eb, 0x04eb,
+	0x04ed, 0x04ed,
+	0x04ef, 0x04ef,
+	0x04f1, 0x04f1,
+	0x04f3, 0x04f3,
+	0x04f5, 0x04f5,
+	0x04f7, 0x04f7,
+	0x04f9, 0x04f9,
+	0x04fb, 0x04fb,
+	0x04fd, 0x04fd,
+	0x04ff, 0x04ff,
+	0x0501, 0x0501,
+	0x0503, 0x0503,
+	0x0505, 0x0505,
+	0x0507, 0x0507,
+	0x0509, 0x0509,
+	0x050b, 0x050b,
+	0x050d, 0x050d,
+	0x050f, 0x050f,
+	0x0511, 0x0511,
+	0x0513, 0x0513,
+	0x0515, 0x0515,
+	0x0517, 0x0517,
+	0x0519, 0x0519,
+	0x051b, 0x051b,
+	0x051d, 0x051d,
+	0x051f, 0x051f,
+	0x0521, 0x0521,
+	0x0523, 0x0523,
+	0x0525, 0x0525,
+	0x0527, 0x0527,
+	0x0529, 0x0529,
+	0x052b, 0x052b,
+	0x052d, 0x052d,
+	0x052f, 0x052f,
+	0x0561, 0x0587,
+	0x1d00, 0x1dbf,
+	0x1e01, 0x1e01,
+	0x1e03, 0x1e03,
+	0x1e05, 0x1e05,
+	0x1e07, 0x1e07,
+	0x1e09, 0x1e09,
+	0x1e0b, 0x1e0b,
+	0x1e0d, 0x1e0d,
+	0x1e0f, 0x1e0f,
+	0x1e11, 0x1e11,
+	0x1e13, 0x1e13,
+	0x1e15, 0x1e15,
+	0x1e17, 0x1e17,
+	0x1e19, 0x1e19,
+	0x1e1b, 0x1e1b,
+	0x1e1d, 0x1e1d,
+	0x1e1f, 0x1e1f,
+	0x1e21, 0x1e21,
+	0x1e23, 0x1e23,
+	0x1e25, 0x1e25,
+	0x1e27, 0x1e27,
+	0x1e29, 0x1e29,
+	0x1e2b, 0x1e2b,
+	0x1e2d, 0x1e2d,
+	0x1e2f, 0x1e2f,
+	0x1e31, 0x1e31,
+	0x1e33, 0x1e33,
+	0x1e35, 0x1e35,
+	0x1e37, 0x1e37,
+	0x1e39, 0x1e39,
+	0x1e3b, 0x1e3b,
+	0x1e3d, 0x1e3d,
+	0x1e3f, 0x1e3f,
+	0x1e41, 0x1e41,
+	0x1e43, 0x1e43,
+	0x1e45, 0x1e45,
+	0x1e47, 0x1e47,
+	0x1e49, 0x1e49,
+	0x1e4b, 0x1e4b,
+	0x1e4d, 0x1e4d,
+	0x1e4f, 0x1e4f,
+	0x1e51, 0x1e51,
+	0x1e53, 0x1e53,
+	0x1e55, 0x1e55,
+	0x1e57, 0x1e57,
+	0x1e59, 0x1e59,
+	0x1e5b, 0x1e5b,
+	0x1e5d, 0x1e5d,
+	0x1e5f, 0x1e5f,
+	0x1e61, 0x1e61,
+	0x1e63, 0x1e63,
+	0x1e65, 0x1e65,
+	0x1e67, 0x1e67,
+	0x1e69, 0x1e69,
+	0x1e6b, 0x1e6b,
+	0x1e6d, 0x1e6d,
+	0x1e6f, 0x1e6f,
+	0x1e71, 0x1e71,
+	0x1e73, 0x1e73,
+	0x1e75, 0x1e75,
+	0x1e77, 0x1e77,
+	0x1e79, 0x1e79,
+	0x1e7b, 0x1e7b,
+	0x1e7d, 0x1e7d,
+	0x1e7f, 0x1e7f,
+	0x1e81, 0x1e81,
+	0x1e83, 0x1e83,
+	0x1e85, 0x1e85,
+	0x1e87, 0x1e87,
+	0x1e89, 0x1e89,
+	0x1e8b, 0x1e8b,
+	0x1e8d, 0x1e8d,
+	0x1e8f, 0x1e8f,
+	0x1e91, 0x1e91,
+	0x1e93, 0x1e93,
+	0x1e95, 0x1e9d,
+	0x1e9f, 0x1e9f,
+	0x1ea1, 0x1ea1,
+	0x1ea3, 0x1ea3,
+	0x1ea5, 0x1ea5,
+	0x1ea7, 0x1ea7,
+	0x1ea9, 0x1ea9,
+	0x1eab, 0x1eab,
+	0x1ead, 0x1ead,
+	0x1eaf, 0x1eaf,
+	0x1eb1, 0x1eb1,
+	0x1eb3, 0x1eb3,
+	0x1eb5, 0x1eb5,
+	0x1eb7, 0x1eb7,
+	0x1eb9, 0x1eb9,
+	0x1ebb, 0x1ebb,
+	0x1ebd, 0x1ebd,
+	0x1ebf, 0x1ebf,
+	0x1ec1, 0x1ec1,
+	0x1ec3, 0x1ec3,
+	0x1ec5, 0x1ec5,
+	0x1ec7, 0x1ec7,
+	0x1ec9, 0x1ec9,
+	0x1ecb, 0x1ecb,
+	0x1ecd, 0x1ecd,
+	0x1ecf, 0x1ecf,
+	0x1ed1, 0x1ed1,
+	0x1ed3, 0x1ed3,
+	0x1ed5, 0x1ed5,
+	0x1ed7, 0x1ed7,
+	0x1ed9, 0x1ed9,
+	0x1edb, 0x1edb,
+	0x1edd, 0x1edd,
+	0x1edf, 0x1edf,
+	0x1ee1, 0x1ee1,
+	0x1ee3, 0x1ee3,
+	0x1ee5, 0x1ee5,
+	0x1ee7, 0x1ee7,
+	0x1ee9, 0x1ee9,
+	0x1eeb, 0x1eeb,
+	0x1eed, 0x1eed,
+	0x1eef, 0x1eef,
+	0x1ef1, 0x1ef1,
+	0x1ef3, 0x1ef3,
+	0x1ef5, 0x1ef5,
+	0x1ef7, 0x1ef7,
+	0x1ef9, 0x1ef9,
+	0x1efb, 0x1efb,
+	0x1efd, 0x1efd,
+	0x1eff, 0x1f07,
+	0x1f10, 0x1f15,
+	0x1f20, 0x1f27,
+	0x1f30, 0x1f37,
+	0x1f40, 0x1f45,
+	0x1f50, 0x1f57,
+	0x1f60, 0x1f67,
+	0x1f70, 0x1f7d,
+	0x1f80, 0x1f87,
+	0x1f90, 0x1f97,
+	0x1fa0, 0x1fa7,
+	0x1fb0, 0x1fb4,
+	0x1fb6, 0x1fb7,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fc7,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fd7,
+	0x1fe0, 0x1fe7,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ff7,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x210a, 0x210a,
+	0x210e, 0x210f,
+	0x2113, 0x2113,
+	0x212f, 0x212f,
+	0x2134, 0x2134,
+	0x2139, 0x2139,
+	0x213c, 0x213d,
+	0x2146, 0x2149,
+	0x214e, 0x214e,
+	0x2170, 0x217f,
+	0x2184, 0x2184,
+	0x24d0, 0x24e9,
+	0x2c30, 0x2c5e,
+	0x2c61, 0x2c61,
+	0x2c65, 0x2c66,
+	0x2c68, 0x2c68,
+	0x2c6a, 0x2c6a,
+	0x2c6c, 0x2c6c,
+	0x2c71, 0x2c71,
+	0x2c73, 0x2c74,
+	0x2c76, 0x2c7d,
+	0x2c81, 0x2c81,
+	0x2c83, 0x2c83,
+	0x2c85, 0x2c85,
+	0x2c87, 0x2c87,
+	0x2c89, 0x2c89,
+	0x2c8b, 0x2c8b,
+	0x2c8d, 0x2c8d,
+	0x2c8f, 0x2c8f,
+	0x2c91, 0x2c91,
+	0x2c93, 0x2c93,
+	0x2c95, 0x2c95,
+	0x2c97, 0x2c97,
+	0x2c99, 0x2c99,
+	0x2c9b, 0x2c9b,
+	0x2c9d, 0x2c9d,
+	0x2c9f, 0x2c9f,
+	0x2ca1, 0x2ca1,
+	0x2ca3, 0x2ca3,
+	0x2ca5, 0x2ca5,
+	0x2ca7, 0x2ca7,
+	0x2ca9, 0x2ca9,
+	0x2cab, 0x2cab,
+	0x2cad, 0x2cad,
+	0x2caf, 0x2caf,
+	0x2cb1, 0x2cb1,
+	0x2cb3, 0x2cb3,
+	0x2cb5, 0x2cb5,
+	0x2cb7, 0x2cb7,
+	0x2cb9, 0x2cb9,
+	0x2cbb, 0x2cbb,
+	0x2cbd, 0x2cbd,
+	0x2cbf, 0x2cbf,
+	0x2cc1, 0x2cc1,
+	0x2cc3, 0x2cc3,
+	0x2cc5, 0x2cc5,
+	0x2cc7, 0x2cc7,
+	0x2cc9, 0x2cc9,
+	0x2ccb, 0x2ccb,
+	0x2ccd, 0x2ccd,
+	0x2ccf, 0x2ccf,
+	0x2cd1, 0x2cd1,
+	0x2cd3, 0x2cd3,
+	0x2cd5, 0x2cd5,
+	0x2cd7, 0x2cd7,
+	0x2cd9, 0x2cd9,
+	0x2cdb, 0x2cdb,
+	0x2cdd, 0x2cdd,
+	0x2cdf, 0x2cdf,
+	0x2ce1, 0x2ce1,
+	0x2ce3, 0x2ce4,
+	0x2cec, 0x2cec,
+	0x2cee, 0x2cee,
+	0x2cf3, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0xa641, 0xa641,
+	0xa643, 0xa643,
+	0xa645, 0xa645,
+	0xa647, 0xa647,
+	0xa649, 0xa649,
+	0xa64b, 0xa64b,
+	0xa64d, 0xa64d,
+	0xa64f, 0xa64f,
+	0xa651, 0xa651,
+	0xa653, 0xa653,
+	0xa655, 0xa655,
+	0xa657, 0xa657,
+	0xa659, 0xa659,
+	0xa65b, 0xa65b,
+	0xa65d, 0xa65d,
+	0xa65f, 0xa65f,
+	0xa661, 0xa661,
+	0xa663, 0xa663,
+	0xa665, 0xa665,
+	0xa667, 0xa667,
+	0xa669, 0xa669,
+	0xa66b, 0xa66b,
+	0xa66d, 0xa66d,
+	0xa681, 0xa681,
+	0xa683, 0xa683,
+	0xa685, 0xa685,
+	0xa687, 0xa687,
+	0xa689, 0xa689,
+	0xa68b, 0xa68b,
+	0xa68d, 0xa68d,
+	0xa68f, 0xa68f,
+	0xa691, 0xa691,
+	0xa693, 0xa693,
+	0xa695, 0xa695,
+	0xa697, 0xa697,
+	0xa699, 0xa699,
+	0xa69b, 0xa69d,
+	0xa723, 0xa723,
+	0xa725, 0xa725,
+	0xa727, 0xa727,
+	0xa729, 0xa729,
+	0xa72b, 0xa72b,
+	0xa72d, 0xa72d,
+	0xa72f, 0xa731,
+	0xa733, 0xa733,
+	0xa735, 0xa735,
+	0xa737, 0xa737,
+	0xa739, 0xa739,
+	0xa73b, 0xa73b,
+	0xa73d, 0xa73d,
+	0xa73f, 0xa73f,
+	0xa741, 0xa741,
+	0xa743, 0xa743,
+	0xa745, 0xa745,
+	0xa747, 0xa747,
+	0xa749, 0xa749,
+	0xa74b, 0xa74b,
+	0xa74d, 0xa74d,
+	0xa74f, 0xa74f,
+	0xa751, 0xa751,
+	0xa753, 0xa753,
+	0xa755, 0xa755,
+	0xa757, 0xa757,
+	0xa759, 0xa759,
+	0xa75b, 0xa75b,
+	0xa75d, 0xa75d,
+	0xa75f, 0xa75f,
+	0xa761, 0xa761,
+	0xa763, 0xa763,
+	0xa765, 0xa765,
+	0xa767, 0xa767,
+	0xa769, 0xa769,
+	0xa76b, 0xa76b,
+	0xa76d, 0xa76d,
+	0xa76f, 0xa778,
+	0xa77a, 0xa77a,
+	0xa77c, 0xa77c,
+	0xa77f, 0xa77f,
+	0xa781, 0xa781,
+	0xa783, 0xa783,
+	0xa785, 0xa785,
+	0xa787, 0xa787,
+	0xa78c, 0xa78c,
+	0xa78e, 0xa78e,
+	0xa791, 0xa791,
+	0xa793, 0xa795,
+	0xa797, 0xa797,
+	0xa799, 0xa799,
+	0xa79b, 0xa79b,
+	0xa79d, 0xa79d,
+	0xa79f, 0xa79f,
+	0xa7a1, 0xa7a1,
+	0xa7a3, 0xa7a3,
+	0xa7a5, 0xa7a5,
+	0xa7a7, 0xa7a7,
+	0xa7a9, 0xa7a9,
+	0xa7f8, 0xa7fa,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff41, 0xff5a,
+	0x10428, 0x1044f,
+	0x118c0, 0x118df,
+	0x1d41a, 0x1d433,
+	0x1d44e, 0x1d454,
+	0x1d456, 0x1d467,
+	0x1d482, 0x1d49b,
+	0x1d4b6, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d4cf,
+	0x1d4ea, 0x1d503,
+	0x1d51e, 0x1d537,
+	0x1d552, 0x1d56b,
+	0x1d586, 0x1d59f,
+	0x1d5ba, 0x1d5d3,
+	0x1d5ee, 0x1d607,
+	0x1d622, 0x1d63b,
+	0x1d656, 0x1d66f,
+	0x1d68a, 0x1d6a5,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6e1,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d71b,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d755,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d78f,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7c9,
+	0x1d7cb, 0x1d7cb,
+}; /* CR_Lower */
+
+/* 'Print': [[:Print:]] */
+static const OnigCodePoint CR_Print[] = {
+	602,
+	0x0020, 0x007e,
+	0x00a0, 0x0377,
+	0x037a, 0x037f,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058d, 0x058f,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x061c,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x08a0, 0x08b2,
+	0x08e4, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd0, 0x1cf6,
+	0x1cf8, 0x1cf9,
+	0x1d00, 0x1df5,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2027,
+	0x202a, 0x2064,
+	0x2066, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20bd,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e42,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa69d,
+	0xa69f, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaac2,
+	0xaadb, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xe000, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe2d,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0xfffd,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018c,
+	0x10190, 0x1019b,
+	0x101a0, 0x101a0,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e0, 0x102fb,
+	0x10300, 0x10323,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x1056f, 0x1056f,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1089e,
+	0x108a7, 0x108af,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a9f,
+	0x10ac0, 0x10ae6,
+	0x10aeb, 0x10af6,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b91,
+	0x10b99, 0x10b9c,
+	0x10ba9, 0x10baf,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x1107f, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+	0x11150, 0x11176,
+	0x11180, 0x111c8,
+	0x111cd, 0x111cd,
+	0x111d0, 0x111da,
+	0x111e1, 0x111f4,
+	0x11200, 0x11211,
+	0x11213, 0x1123d,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x11480, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c9,
+	0x11600, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118f2,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x12470, 0x12474,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16a6e, 0x16a6f,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af5,
+	0x16b00, 0x16b45,
+	0x16b50, 0x16b59,
+	0x16b5b, 0x16b61,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9c, 0x1bca3,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8c7, 0x1e8d6,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f100, 0x1f10c,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xf0000, 0xffffd,
+	0x100000, 0x10fffd,
+}; /* CR_Print */
+
+/* 'Punct': [[:Punct:]] */
+static const OnigCodePoint CR_Punct[] = {
+	155,
+	0x0021, 0x0023,
+	0x0025, 0x002a,
+	0x002c, 0x002f,
+	0x003a, 0x003b,
+	0x003f, 0x0040,
+	0x005b, 0x005d,
+	0x005f, 0x005f,
+	0x007b, 0x007b,
+	0x007d, 0x007d,
+	0x00a1, 0x00a1,
+	0x00a7, 0x00a7,
+	0x00ab, 0x00ab,
+	0x00b6, 0x00b7,
+	0x00bb, 0x00bb,
+	0x00bf, 0x00bf,
+	0x037e, 0x037e,
+	0x0387, 0x0387,
+	0x055a, 0x055f,
+	0x0589, 0x058a,
+	0x05be, 0x05be,
+	0x05c0, 0x05c0,
+	0x05c3, 0x05c3,
+	0x05c6, 0x05c6,
+	0x05f3, 0x05f4,
+	0x0609, 0x060a,
+	0x060c, 0x060d,
+	0x061b, 0x061b,
+	0x061e, 0x061f,
+	0x066a, 0x066d,
+	0x06d4, 0x06d4,
+	0x0700, 0x070d,
+	0x07f7, 0x07f9,
+	0x0830, 0x083e,
+	0x085e, 0x085e,
+	0x0964, 0x0965,
+	0x0970, 0x0970,
+	0x0af0, 0x0af0,
+	0x0df4, 0x0df4,
+	0x0e4f, 0x0e4f,
+	0x0e5a, 0x0e5b,
+	0x0f04, 0x0f12,
+	0x0f14, 0x0f14,
+	0x0f3a, 0x0f3d,
+	0x0f85, 0x0f85,
+	0x0fd0, 0x0fd4,
+	0x0fd9, 0x0fda,
+	0x104a, 0x104f,
+	0x10fb, 0x10fb,
+	0x1360, 0x1368,
+	0x1400, 0x1400,
+	0x166d, 0x166e,
+	0x169b, 0x169c,
+	0x16eb, 0x16ed,
+	0x1735, 0x1736,
+	0x17d4, 0x17d6,
+	0x17d8, 0x17da,
+	0x1800, 0x180a,
+	0x1944, 0x1945,
+	0x1a1e, 0x1a1f,
+	0x1aa0, 0x1aa6,
+	0x1aa8, 0x1aad,
+	0x1b5a, 0x1b60,
+	0x1bfc, 0x1bff,
+	0x1c3b, 0x1c3f,
+	0x1c7e, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd3, 0x1cd3,
+	0x2010, 0x2027,
+	0x2030, 0x2043,
+	0x2045, 0x2051,
+	0x2053, 0x205e,
+	0x207d, 0x207e,
+	0x208d, 0x208e,
+	0x2308, 0x230b,
+	0x2329, 0x232a,
+	0x2768, 0x2775,
+	0x27c5, 0x27c6,
+	0x27e6, 0x27ef,
+	0x2983, 0x2998,
+	0x29d8, 0x29db,
+	0x29fc, 0x29fd,
+	0x2cf9, 0x2cfc,
+	0x2cfe, 0x2cff,
+	0x2d70, 0x2d70,
+	0x2e00, 0x2e2e,
+	0x2e30, 0x2e42,
+	0x3001, 0x3003,
+	0x3008, 0x3011,
+	0x3014, 0x301f,
+	0x3030, 0x3030,
+	0x303d, 0x303d,
+	0x30a0, 0x30a0,
+	0x30fb, 0x30fb,
+	0xa4fe, 0xa4ff,
+	0xa60d, 0xa60f,
+	0xa673, 0xa673,
+	0xa67e, 0xa67e,
+	0xa6f2, 0xa6f7,
+	0xa874, 0xa877,
+	0xa8ce, 0xa8cf,
+	0xa8f8, 0xa8fa,
+	0xa92e, 0xa92f,
+	0xa95f, 0xa95f,
+	0xa9c1, 0xa9cd,
+	0xa9de, 0xa9df,
+	0xaa5c, 0xaa5f,
+	0xaade, 0xaadf,
+	0xaaf0, 0xaaf1,
+	0xabeb, 0xabeb,
+	0xfd3e, 0xfd3f,
+	0xfe10, 0xfe19,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe61,
+	0xfe63, 0xfe63,
+	0xfe68, 0xfe68,
+	0xfe6a, 0xfe6b,
+	0xff01, 0xff03,
+	0xff05, 0xff0a,
+	0xff0c, 0xff0f,
+	0xff1a, 0xff1b,
+	0xff1f, 0xff20,
+	0xff3b, 0xff3d,
+	0xff3f, 0xff3f,
+	0xff5b, 0xff5b,
+	0xff5d, 0xff5d,
+	0xff5f, 0xff65,
+	0x10100, 0x10102,
+	0x1039f, 0x1039f,
+	0x103d0, 0x103d0,
+	0x1056f, 0x1056f,
+	0x10857, 0x10857,
+	0x1091f, 0x1091f,
+	0x1093f, 0x1093f,
+	0x10a50, 0x10a58,
+	0x10a7f, 0x10a7f,
+	0x10af0, 0x10af6,
+	0x10b39, 0x10b3f,
+	0x10b99, 0x10b9c,
+	0x11047, 0x1104d,
+	0x110bb, 0x110bc,
+	0x110be, 0x110c1,
+	0x11140, 0x11143,
+	0x11174, 0x11175,
+	0x111c5, 0x111c8,
+	0x111cd, 0x111cd,
+	0x11238, 0x1123d,
+	0x114c6, 0x114c6,
+	0x115c1, 0x115c9,
+	0x11641, 0x11643,
+	0x12470, 0x12474,
+	0x16a6e, 0x16a6f,
+	0x16af5, 0x16af5,
+	0x16b37, 0x16b3b,
+	0x16b44, 0x16b44,
+	0x1bc9f, 0x1bc9f,
+}; /* CR_Punct */
+
+/* 'Space': [[:Space:]] */
+static const OnigCodePoint CR_Space[] = {
+	10,
+	0x0009, 0x000d,
+	0x0020, 0x0020,
+	0x0085, 0x0085,
+	0x00a0, 0x00a0,
+	0x1680, 0x1680,
+	0x2000, 0x200a,
+	0x2028, 0x2029,
+	0x202f, 0x202f,
+	0x205f, 0x205f,
+	0x3000, 0x3000,
+}; /* CR_Space */
+
+/* 'Upper': [[:Upper:]] */
+static const OnigCodePoint CR_Upper[] = {
+	627,
+	0x0041, 0x005a,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00de,
+	0x0100, 0x0100,
+	0x0102, 0x0102,
+	0x0104, 0x0104,
+	0x0106, 0x0106,
+	0x0108, 0x0108,
+	0x010a, 0x010a,
+	0x010c, 0x010c,
+	0x010e, 0x010e,
+	0x0110, 0x0110,
+	0x0112, 0x0112,
+	0x0114, 0x0114,
+	0x0116, 0x0116,
+	0x0118, 0x0118,
+	0x011a, 0x011a,
+	0x011c, 0x011c,
+	0x011e, 0x011e,
+	0x0120, 0x0120,
+	0x0122, 0x0122,
+	0x0124, 0x0124,
+	0x0126, 0x0126,
+	0x0128, 0x0128,
+	0x012a, 0x012a,
+	0x012c, 0x012c,
+	0x012e, 0x012e,
+	0x0130, 0x0130,
+	0x0132, 0x0132,
+	0x0134, 0x0134,
+	0x0136, 0x0136,
+	0x0139, 0x0139,
+	0x013b, 0x013b,
+	0x013d, 0x013d,
+	0x013f, 0x013f,
+	0x0141, 0x0141,
+	0x0143, 0x0143,
+	0x0145, 0x0145,
+	0x0147, 0x0147,
+	0x014a, 0x014a,
+	0x014c, 0x014c,
+	0x014e, 0x014e,
+	0x0150, 0x0150,
+	0x0152, 0x0152,
+	0x0154, 0x0154,
+	0x0156, 0x0156,
+	0x0158, 0x0158,
+	0x015a, 0x015a,
+	0x015c, 0x015c,
+	0x015e, 0x015e,
+	0x0160, 0x0160,
+	0x0162, 0x0162,
+	0x0164, 0x0164,
+	0x0166, 0x0166,
+	0x0168, 0x0168,
+	0x016a, 0x016a,
+	0x016c, 0x016c,
+	0x016e, 0x016e,
+	0x0170, 0x0170,
+	0x0172, 0x0172,
+	0x0174, 0x0174,
+	0x0176, 0x0176,
+	0x0178, 0x0179,
+	0x017b, 0x017b,
+	0x017d, 0x017d,
+	0x0181, 0x0182,
+	0x0184, 0x0184,
+	0x0186, 0x0187,
+	0x0189, 0x018b,
+	0x018e, 0x0191,
+	0x0193, 0x0194,
+	0x0196, 0x0198,
+	0x019c, 0x019d,
+	0x019f, 0x01a0,
+	0x01a2, 0x01a2,
+	0x01a4, 0x01a4,
+	0x01a6, 0x01a7,
+	0x01a9, 0x01a9,
+	0x01ac, 0x01ac,
+	0x01ae, 0x01af,
+	0x01b1, 0x01b3,
+	0x01b5, 0x01b5,
+	0x01b7, 0x01b8,
+	0x01bc, 0x01bc,
+	0x01c4, 0x01c4,
+	0x01c7, 0x01c7,
+	0x01ca, 0x01ca,
+	0x01cd, 0x01cd,
+	0x01cf, 0x01cf,
+	0x01d1, 0x01d1,
+	0x01d3, 0x01d3,
+	0x01d5, 0x01d5,
+	0x01d7, 0x01d7,
+	0x01d9, 0x01d9,
+	0x01db, 0x01db,
+	0x01de, 0x01de,
+	0x01e0, 0x01e0,
+	0x01e2, 0x01e2,
+	0x01e4, 0x01e4,
+	0x01e6, 0x01e6,
+	0x01e8, 0x01e8,
+	0x01ea, 0x01ea,
+	0x01ec, 0x01ec,
+	0x01ee, 0x01ee,
+	0x01f1, 0x01f1,
+	0x01f4, 0x01f4,
+	0x01f6, 0x01f8,
+	0x01fa, 0x01fa,
+	0x01fc, 0x01fc,
+	0x01fe, 0x01fe,
+	0x0200, 0x0200,
+	0x0202, 0x0202,
+	0x0204, 0x0204,
+	0x0206, 0x0206,
+	0x0208, 0x0208,
+	0x020a, 0x020a,
+	0x020c, 0x020c,
+	0x020e, 0x020e,
+	0x0210, 0x0210,
+	0x0212, 0x0212,
+	0x0214, 0x0214,
+	0x0216, 0x0216,
+	0x0218, 0x0218,
+	0x021a, 0x021a,
+	0x021c, 0x021c,
+	0x021e, 0x021e,
+	0x0220, 0x0220,
+	0x0222, 0x0222,
+	0x0224, 0x0224,
+	0x0226, 0x0226,
+	0x0228, 0x0228,
+	0x022a, 0x022a,
+	0x022c, 0x022c,
+	0x022e, 0x022e,
+	0x0230, 0x0230,
+	0x0232, 0x0232,
+	0x023a, 0x023b,
+	0x023d, 0x023e,
+	0x0241, 0x0241,
+	0x0243, 0x0246,
+	0x0248, 0x0248,
+	0x024a, 0x024a,
+	0x024c, 0x024c,
+	0x024e, 0x024e,
+	0x0370, 0x0370,
+	0x0372, 0x0372,
+	0x0376, 0x0376,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x038f,
+	0x0391, 0x03a1,
+	0x03a3, 0x03ab,
+	0x03cf, 0x03cf,
+	0x03d2, 0x03d4,
+	0x03d8, 0x03d8,
+	0x03da, 0x03da,
+	0x03dc, 0x03dc,
+	0x03de, 0x03de,
+	0x03e0, 0x03e0,
+	0x03e2, 0x03e2,
+	0x03e4, 0x03e4,
+	0x03e6, 0x03e6,
+	0x03e8, 0x03e8,
+	0x03ea, 0x03ea,
+	0x03ec, 0x03ec,
+	0x03ee, 0x03ee,
+	0x03f4, 0x03f4,
+	0x03f7, 0x03f7,
+	0x03f9, 0x03fa,
+	0x03fd, 0x042f,
+	0x0460, 0x0460,
+	0x0462, 0x0462,
+	0x0464, 0x0464,
+	0x0466, 0x0466,
+	0x0468, 0x0468,
+	0x046a, 0x046a,
+	0x046c, 0x046c,
+	0x046e, 0x046e,
+	0x0470, 0x0470,
+	0x0472, 0x0472,
+	0x0474, 0x0474,
+	0x0476, 0x0476,
+	0x0478, 0x0478,
+	0x047a, 0x047a,
+	0x047c, 0x047c,
+	0x047e, 0x047e,
+	0x0480, 0x0480,
+	0x048a, 0x048a,
+	0x048c, 0x048c,
+	0x048e, 0x048e,
+	0x0490, 0x0490,
+	0x0492, 0x0492,
+	0x0494, 0x0494,
+	0x0496, 0x0496,
+	0x0498, 0x0498,
+	0x049a, 0x049a,
+	0x049c, 0x049c,
+	0x049e, 0x049e,
+	0x04a0, 0x04a0,
+	0x04a2, 0x04a2,
+	0x04a4, 0x04a4,
+	0x04a6, 0x04a6,
+	0x04a8, 0x04a8,
+	0x04aa, 0x04aa,
+	0x04ac, 0x04ac,
+	0x04ae, 0x04ae,
+	0x04b0, 0x04b0,
+	0x04b2, 0x04b2,
+	0x04b4, 0x04b4,
+	0x04b6, 0x04b6,
+	0x04b8, 0x04b8,
+	0x04ba, 0x04ba,
+	0x04bc, 0x04bc,
+	0x04be, 0x04be,
+	0x04c0, 0x04c1,
+	0x04c3, 0x04c3,
+	0x04c5, 0x04c5,
+	0x04c7, 0x04c7,
+	0x04c9, 0x04c9,
+	0x04cb, 0x04cb,
+	0x04cd, 0x04cd,
+	0x04d0, 0x04d0,
+	0x04d2, 0x04d2,
+	0x04d4, 0x04d4,
+	0x04d6, 0x04d6,
+	0x04d8, 0x04d8,
+	0x04da, 0x04da,
+	0x04dc, 0x04dc,
+	0x04de, 0x04de,
+	0x04e0, 0x04e0,
+	0x04e2, 0x04e2,
+	0x04e4, 0x04e4,
+	0x04e6, 0x04e6,
+	0x04e8, 0x04e8,
+	0x04ea, 0x04ea,
+	0x04ec, 0x04ec,
+	0x04ee, 0x04ee,
+	0x04f0, 0x04f0,
+	0x04f2, 0x04f2,
+	0x04f4, 0x04f4,
+	0x04f6, 0x04f6,
+	0x04f8, 0x04f8,
+	0x04fa, 0x04fa,
+	0x04fc, 0x04fc,
+	0x04fe, 0x04fe,
+	0x0500, 0x0500,
+	0x0502, 0x0502,
+	0x0504, 0x0504,
+	0x0506, 0x0506,
+	0x0508, 0x0508,
+	0x050a, 0x050a,
+	0x050c, 0x050c,
+	0x050e, 0x050e,
+	0x0510, 0x0510,
+	0x0512, 0x0512,
+	0x0514, 0x0514,
+	0x0516, 0x0516,
+	0x0518, 0x0518,
+	0x051a, 0x051a,
+	0x051c, 0x051c,
+	0x051e, 0x051e,
+	0x0520, 0x0520,
+	0x0522, 0x0522,
+	0x0524, 0x0524,
+	0x0526, 0x0526,
+	0x0528, 0x0528,
+	0x052a, 0x052a,
+	0x052c, 0x052c,
+	0x052e, 0x052e,
+	0x0531, 0x0556,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x1e00, 0x1e00,
+	0x1e02, 0x1e02,
+	0x1e04, 0x1e04,
+	0x1e06, 0x1e06,
+	0x1e08, 0x1e08,
+	0x1e0a, 0x1e0a,
+	0x1e0c, 0x1e0c,
+	0x1e0e, 0x1e0e,
+	0x1e10, 0x1e10,
+	0x1e12, 0x1e12,
+	0x1e14, 0x1e14,
+	0x1e16, 0x1e16,
+	0x1e18, 0x1e18,
+	0x1e1a, 0x1e1a,
+	0x1e1c, 0x1e1c,
+	0x1e1e, 0x1e1e,
+	0x1e20, 0x1e20,
+	0x1e22, 0x1e22,
+	0x1e24, 0x1e24,
+	0x1e26, 0x1e26,
+	0x1e28, 0x1e28,
+	0x1e2a, 0x1e2a,
+	0x1e2c, 0x1e2c,
+	0x1e2e, 0x1e2e,
+	0x1e30, 0x1e30,
+	0x1e32, 0x1e32,
+	0x1e34, 0x1e34,
+	0x1e36, 0x1e36,
+	0x1e38, 0x1e38,
+	0x1e3a, 0x1e3a,
+	0x1e3c, 0x1e3c,
+	0x1e3e, 0x1e3e,
+	0x1e40, 0x1e40,
+	0x1e42, 0x1e42,
+	0x1e44, 0x1e44,
+	0x1e46, 0x1e46,
+	0x1e48, 0x1e48,
+	0x1e4a, 0x1e4a,
+	0x1e4c, 0x1e4c,
+	0x1e4e, 0x1e4e,
+	0x1e50, 0x1e50,
+	0x1e52, 0x1e52,
+	0x1e54, 0x1e54,
+	0x1e56, 0x1e56,
+	0x1e58, 0x1e58,
+	0x1e5a, 0x1e5a,
+	0x1e5c, 0x1e5c,
+	0x1e5e, 0x1e5e,
+	0x1e60, 0x1e60,
+	0x1e62, 0x1e62,
+	0x1e64, 0x1e64,
+	0x1e66, 0x1e66,
+	0x1e68, 0x1e68,
+	0x1e6a, 0x1e6a,
+	0x1e6c, 0x1e6c,
+	0x1e6e, 0x1e6e,
+	0x1e70, 0x1e70,
+	0x1e72, 0x1e72,
+	0x1e74, 0x1e74,
+	0x1e76, 0x1e76,
+	0x1e78, 0x1e78,
+	0x1e7a, 0x1e7a,
+	0x1e7c, 0x1e7c,
+	0x1e7e, 0x1e7e,
+	0x1e80, 0x1e80,
+	0x1e82, 0x1e82,
+	0x1e84, 0x1e84,
+	0x1e86, 0x1e86,
+	0x1e88, 0x1e88,
+	0x1e8a, 0x1e8a,
+	0x1e8c, 0x1e8c,
+	0x1e8e, 0x1e8e,
+	0x1e90, 0x1e90,
+	0x1e92, 0x1e92,
+	0x1e94, 0x1e94,
+	0x1e9e, 0x1e9e,
+	0x1ea0, 0x1ea0,
+	0x1ea2, 0x1ea2,
+	0x1ea4, 0x1ea4,
+	0x1ea6, 0x1ea6,
+	0x1ea8, 0x1ea8,
+	0x1eaa, 0x1eaa,
+	0x1eac, 0x1eac,
+	0x1eae, 0x1eae,
+	0x1eb0, 0x1eb0,
+	0x1eb2, 0x1eb2,
+	0x1eb4, 0x1eb4,
+	0x1eb6, 0x1eb6,
+	0x1eb8, 0x1eb8,
+	0x1eba, 0x1eba,
+	0x1ebc, 0x1ebc,
+	0x1ebe, 0x1ebe,
+	0x1ec0, 0x1ec0,
+	0x1ec2, 0x1ec2,
+	0x1ec4, 0x1ec4,
+	0x1ec6, 0x1ec6,
+	0x1ec8, 0x1ec8,
+	0x1eca, 0x1eca,
+	0x1ecc, 0x1ecc,
+	0x1ece, 0x1ece,
+	0x1ed0, 0x1ed0,
+	0x1ed2, 0x1ed2,
+	0x1ed4, 0x1ed4,
+	0x1ed6, 0x1ed6,
+	0x1ed8, 0x1ed8,
+	0x1eda, 0x1eda,
+	0x1edc, 0x1edc,
+	0x1ede, 0x1ede,
+	0x1ee0, 0x1ee0,
+	0x1ee2, 0x1ee2,
+	0x1ee4, 0x1ee4,
+	0x1ee6, 0x1ee6,
+	0x1ee8, 0x1ee8,
+	0x1eea, 0x1eea,
+	0x1eec, 0x1eec,
+	0x1eee, 0x1eee,
+	0x1ef0, 0x1ef0,
+	0x1ef2, 0x1ef2,
+	0x1ef4, 0x1ef4,
+	0x1ef6, 0x1ef6,
+	0x1ef8, 0x1ef8,
+	0x1efa, 0x1efa,
+	0x1efc, 0x1efc,
+	0x1efe, 0x1efe,
+	0x1f08, 0x1f0f,
+	0x1f18, 0x1f1d,
+	0x1f28, 0x1f2f,
+	0x1f38, 0x1f3f,
+	0x1f48, 0x1f4d,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f5f,
+	0x1f68, 0x1f6f,
+	0x1fb8, 0x1fbb,
+	0x1fc8, 0x1fcb,
+	0x1fd8, 0x1fdb,
+	0x1fe8, 0x1fec,
+	0x1ff8, 0x1ffb,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210b, 0x210d,
+	0x2110, 0x2112,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x2130, 0x2133,
+	0x213e, 0x213f,
+	0x2145, 0x2145,
+	0x2160, 0x216f,
+	0x2183, 0x2183,
+	0x24b6, 0x24cf,
+	0x2c00, 0x2c2e,
+	0x2c60, 0x2c60,
+	0x2c62, 0x2c64,
+	0x2c67, 0x2c67,
+	0x2c69, 0x2c69,
+	0x2c6b, 0x2c6b,
+	0x2c6d, 0x2c70,
+	0x2c72, 0x2c72,
+	0x2c75, 0x2c75,
+	0x2c7e, 0x2c80,
+	0x2c82, 0x2c82,
+	0x2c84, 0x2c84,
+	0x2c86, 0x2c86,
+	0x2c88, 0x2c88,
+	0x2c8a, 0x2c8a,
+	0x2c8c, 0x2c8c,
+	0x2c8e, 0x2c8e,
+	0x2c90, 0x2c90,
+	0x2c92, 0x2c92,
+	0x2c94, 0x2c94,
+	0x2c96, 0x2c96,
+	0x2c98, 0x2c98,
+	0x2c9a, 0x2c9a,
+	0x2c9c, 0x2c9c,
+	0x2c9e, 0x2c9e,
+	0x2ca0, 0x2ca0,
+	0x2ca2, 0x2ca2,
+	0x2ca4, 0x2ca4,
+	0x2ca6, 0x2ca6,
+	0x2ca8, 0x2ca8,
+	0x2caa, 0x2caa,
+	0x2cac, 0x2cac,
+	0x2cae, 0x2cae,
+	0x2cb0, 0x2cb0,
+	0x2cb2, 0x2cb2,
+	0x2cb4, 0x2cb4,
+	0x2cb6, 0x2cb6,
+	0x2cb8, 0x2cb8,
+	0x2cba, 0x2cba,
+	0x2cbc, 0x2cbc,
+	0x2cbe, 0x2cbe,
+	0x2cc0, 0x2cc0,
+	0x2cc2, 0x2cc2,
+	0x2cc4, 0x2cc4,
+	0x2cc6, 0x2cc6,
+	0x2cc8, 0x2cc8,
+	0x2cca, 0x2cca,
+	0x2ccc, 0x2ccc,
+	0x2cce, 0x2cce,
+	0x2cd0, 0x2cd0,
+	0x2cd2, 0x2cd2,
+	0x2cd4, 0x2cd4,
+	0x2cd6, 0x2cd6,
+	0x2cd8, 0x2cd8,
+	0x2cda, 0x2cda,
+	0x2cdc, 0x2cdc,
+	0x2cde, 0x2cde,
+	0x2ce0, 0x2ce0,
+	0x2ce2, 0x2ce2,
+	0x2ceb, 0x2ceb,
+	0x2ced, 0x2ced,
+	0x2cf2, 0x2cf2,
+	0xa640, 0xa640,
+	0xa642, 0xa642,
+	0xa644, 0xa644,
+	0xa646, 0xa646,
+	0xa648, 0xa648,
+	0xa64a, 0xa64a,
+	0xa64c, 0xa64c,
+	0xa64e, 0xa64e,
+	0xa650, 0xa650,
+	0xa652, 0xa652,
+	0xa654, 0xa654,
+	0xa656, 0xa656,
+	0xa658, 0xa658,
+	0xa65a, 0xa65a,
+	0xa65c, 0xa65c,
+	0xa65e, 0xa65e,
+	0xa660, 0xa660,
+	0xa662, 0xa662,
+	0xa664, 0xa664,
+	0xa666, 0xa666,
+	0xa668, 0xa668,
+	0xa66a, 0xa66a,
+	0xa66c, 0xa66c,
+	0xa680, 0xa680,
+	0xa682, 0xa682,
+	0xa684, 0xa684,
+	0xa686, 0xa686,
+	0xa688, 0xa688,
+	0xa68a, 0xa68a,
+	0xa68c, 0xa68c,
+	0xa68e, 0xa68e,
+	0xa690, 0xa690,
+	0xa692, 0xa692,
+	0xa694, 0xa694,
+	0xa696, 0xa696,
+	0xa698, 0xa698,
+	0xa69a, 0xa69a,
+	0xa722, 0xa722,
+	0xa724, 0xa724,
+	0xa726, 0xa726,
+	0xa728, 0xa728,
+	0xa72a, 0xa72a,
+	0xa72c, 0xa72c,
+	0xa72e, 0xa72e,
+	0xa732, 0xa732,
+	0xa734, 0xa734,
+	0xa736, 0xa736,
+	0xa738, 0xa738,
+	0xa73a, 0xa73a,
+	0xa73c, 0xa73c,
+	0xa73e, 0xa73e,
+	0xa740, 0xa740,
+	0xa742, 0xa742,
+	0xa744, 0xa744,
+	0xa746, 0xa746,
+	0xa748, 0xa748,
+	0xa74a, 0xa74a,
+	0xa74c, 0xa74c,
+	0xa74e, 0xa74e,
+	0xa750, 0xa750,
+	0xa752, 0xa752,
+	0xa754, 0xa754,
+	0xa756, 0xa756,
+	0xa758, 0xa758,
+	0xa75a, 0xa75a,
+	0xa75c, 0xa75c,
+	0xa75e, 0xa75e,
+	0xa760, 0xa760,
+	0xa762, 0xa762,
+	0xa764, 0xa764,
+	0xa766, 0xa766,
+	0xa768, 0xa768,
+	0xa76a, 0xa76a,
+	0xa76c, 0xa76c,
+	0xa76e, 0xa76e,
+	0xa779, 0xa779,
+	0xa77b, 0xa77b,
+	0xa77d, 0xa77e,
+	0xa780, 0xa780,
+	0xa782, 0xa782,
+	0xa784, 0xa784,
+	0xa786, 0xa786,
+	0xa78b, 0xa78b,
+	0xa78d, 0xa78d,
+	0xa790, 0xa790,
+	0xa792, 0xa792,
+	0xa796, 0xa796,
+	0xa798, 0xa798,
+	0xa79a, 0xa79a,
+	0xa79c, 0xa79c,
+	0xa79e, 0xa79e,
+	0xa7a0, 0xa7a0,
+	0xa7a2, 0xa7a2,
+	0xa7a4, 0xa7a4,
+	0xa7a6, 0xa7a6,
+	0xa7a8, 0xa7a8,
+	0xa7aa, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xff21, 0xff3a,
+	0x10400, 0x10427,
+	0x118a0, 0x118bf,
+	0x1d400, 0x1d419,
+	0x1d434, 0x1d44d,
+	0x1d468, 0x1d481,
+	0x1d49c, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b5,
+	0x1d4d0, 0x1d4e9,
+	0x1d504, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d538, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d56c, 0x1d585,
+	0x1d5a0, 0x1d5b9,
+	0x1d5d4, 0x1d5ed,
+	0x1d608, 0x1d621,
+	0x1d63c, 0x1d655,
+	0x1d670, 0x1d689,
+	0x1d6a8, 0x1d6c0,
+	0x1d6e2, 0x1d6fa,
+	0x1d71c, 0x1d734,
+	0x1d756, 0x1d76e,
+	0x1d790, 0x1d7a8,
+	0x1d7ca, 0x1d7ca,
+	0x1f130, 0x1f149,
+	0x1f150, 0x1f169,
+	0x1f170, 0x1f189,
+}; /* CR_Upper */
+
+/* 'XDigit': [[:XDigit:]] */
+static const OnigCodePoint CR_XDigit[] = {
+	3,
+	0x0030, 0x0039,
+	0x0041, 0x0046,
+	0x0061, 0x0066,
+}; /* CR_XDigit */
+
+/* 'Word': [[:Word:]] */
+static const OnigCodePoint CR_Word[] = {
+	629,
+	0x0030, 0x0039,
+	0x0041, 0x005a,
+	0x005f, 0x005f,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0300, 0x0374,
+	0x0376, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x0483, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x0591, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0610, 0x061a,
+	0x0620, 0x0669,
+	0x066e, 0x06d3,
+	0x06d5, 0x06dc,
+	0x06df, 0x06e8,
+	0x06ea, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x082d,
+	0x0840, 0x085b,
+	0x08a0, 0x08b2,
+	0x08e4, 0x0963,
+	0x0966, 0x096f,
+	0x0971, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09f1,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b6f,
+	0x0b71, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bef,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d6f,
+	0x0d7a, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df3,
+	0x0e01, 0x0e3a,
+	0x0e40, 0x0e4e,
+	0x0e50, 0x0e59,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f18, 0x0f19,
+	0x0f20, 0x0f29,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f3e, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f84,
+	0x0f86, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fc6, 0x0fc6,
+	0x1000, 0x1049,
+	0x1050, 0x109d,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x135f,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1734,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17d3,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dd,
+	0x17e0, 0x17e9,
+	0x180b, 0x180d,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1946, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19d9,
+	0x1a00, 0x1a1b,
+	0x1a20, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa7, 0x1aa7,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b59,
+	0x1b6b, 0x1b73,
+	0x1b80, 0x1bf3,
+	0x1c00, 0x1c37,
+	0x1c40, 0x1c49,
+	0x1c4d, 0x1c7d,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1cf6,
+	0x1cf8, 0x1cf9,
+	0x1d00, 0x1df5,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x203f, 0x2040,
+	0x2054, 0x2054,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x20d0, 0x20f0,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x212f, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x24b6, 0x24e9,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2dff,
+	0x2e2f, 0x2e2f,
+	0x3005, 0x3007,
+	0x3021, 0x302f,
+	0x3031, 0x3035,
+	0x3038, 0x303c,
+	0x3041, 0x3096,
+	0x3099, 0x309a,
+	0x309d, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa62b,
+	0xa640, 0xa672,
+	0xa674, 0xa67d,
+	0xa67f, 0xa69d,
+	0xa69f, 0xa6f1,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa827,
+	0xa840, 0xa873,
+	0xa880, 0xa8c4,
+	0xa8d0, 0xa8d9,
+	0xa8e0, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa900, 0xa92d,
+	0xa930, 0xa953,
+	0xa960, 0xa97c,
+	0xa980, 0xa9c0,
+	0xa9cf, 0xa9d9,
+	0xa9e0, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaef,
+	0xaaf2, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabea,
+	0xabec, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe2d,
+	0xfe33, 0xfe34,
+	0xfe4d, 0xfe4f,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff10, 0xff19,
+	0xff21, 0xff3a,
+	0xff3f, 0xff3f,
+	0xff41, 0xff5a,
+	0xff66, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10140, 0x10174,
+	0x101fd, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e0, 0x102e0,
+	0x10300, 0x1031f,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x103d1, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a3f,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae6,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11000, 0x11046,
+	0x11066, 0x1106f,
+	0x1107f, 0x110ba,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x1113f,
+	0x11150, 0x11173,
+	0x11176, 0x11176,
+	0x11180, 0x111c4,
+	0x111d0, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x11237,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x11480, 0x114c5,
+	0x114c7, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c0,
+	0x11600, 0x11640,
+	0x11644, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118e9,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af4,
+	0x16b00, 0x16b36,
+	0x16b40, 0x16b43,
+	0x16b50, 0x16b59,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9d, 0x1bc9e,
+	0x1d165, 0x1d169,
+	0x1d16d, 0x1d172,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1d242, 0x1d244,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8d0, 0x1e8d6,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1f130, 0x1f149,
+	0x1f150, 0x1f169,
+	0x1f170, 0x1f189,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0xe0100, 0xe01ef,
+}; /* CR_Word */
+
+/* 'Alnum': [[:Alnum:]] */
+static const OnigCodePoint CR_Alnum[] = {
+	630,
+	0x0030, 0x0039,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0345, 0x0345,
+	0x0370, 0x0374,
+	0x0376, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x05b0, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0610, 0x061a,
+	0x0620, 0x0657,
+	0x0659, 0x0669,
+	0x066e, 0x06d3,
+	0x06d5, 0x06dc,
+	0x06e1, 0x06e8,
+	0x06ed, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x073f,
+	0x074d, 0x07b1,
+	0x07c0, 0x07ea,
+	0x07f4, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x0817,
+	0x081a, 0x082c,
+	0x0840, 0x0858,
+	0x08a0, 0x08b2,
+	0x08e4, 0x08e9,
+	0x08f0, 0x093b,
+	0x093d, 0x094c,
+	0x094e, 0x0950,
+	0x0955, 0x0963,
+	0x0966, 0x096f,
+	0x0971, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bd, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cc,
+	0x09ce, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09f1,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4c,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abd, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acc,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3d, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4c,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b6f,
+	0x0b71, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcc,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bef,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4c,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbd, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccc,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4c,
+	0x0d4e, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d6f,
+	0x0d7a, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df3,
+	0x0e01, 0x0e3a,
+	0x0e40, 0x0e46,
+	0x0e4d, 0x0e4d,
+	0x0e50, 0x0e59,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ecd, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f20, 0x0f29,
+	0x0f40, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f81,
+	0x0f88, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x1000, 0x1036,
+	0x1038, 0x1038,
+	0x103b, 0x1049,
+	0x1050, 0x1062,
+	0x1065, 0x1068,
+	0x106e, 0x1086,
+	0x108e, 0x108e,
+	0x1090, 0x1099,
+	0x109c, 0x109d,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135f, 0x135f,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1713,
+	0x1720, 0x1733,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17b3,
+	0x17b6, 0x17c8,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dc,
+	0x17e0, 0x17e9,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x1938,
+	0x1946, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19d9,
+	0x1a00, 0x1a1b,
+	0x1a20, 0x1a5e,
+	0x1a61, 0x1a74,
+	0x1a80, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa7, 0x1aa7,
+	0x1b00, 0x1b33,
+	0x1b35, 0x1b43,
+	0x1b45, 0x1b4b,
+	0x1b50, 0x1b59,
+	0x1b80, 0x1ba9,
+	0x1bac, 0x1be5,
+	0x1be7, 0x1bf1,
+	0x1c00, 0x1c35,
+	0x1c40, 0x1c49,
+	0x1c4d, 0x1c7d,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf3,
+	0x1cf5, 0x1cf6,
+	0x1d00, 0x1dbf,
+	0x1de7, 0x1df4,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x212f, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x24b6, 0x24e9,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2dff,
+	0x2e2f, 0x2e2f,
+	0x3005, 0x3007,
+	0x3021, 0x3029,
+	0x3031, 0x3035,
+	0x3038, 0x303c,
+	0x3041, 0x3096,
+	0x309d, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa62b,
+	0xa640, 0xa66e,
+	0xa674, 0xa67b,
+	0xa67f, 0xa69d,
+	0xa69f, 0xa6ef,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa801,
+	0xa803, 0xa805,
+	0xa807, 0xa80a,
+	0xa80c, 0xa827,
+	0xa840, 0xa873,
+	0xa880, 0xa8c3,
+	0xa8d0, 0xa8d9,
+	0xa8f2, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa900, 0xa92a,
+	0xa930, 0xa952,
+	0xa960, 0xa97c,
+	0xa980, 0xa9b2,
+	0xa9b4, 0xa9bf,
+	0xa9cf, 0xa9d9,
+	0xa9e0, 0xa9e4,
+	0xa9e6, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaa7a,
+	0xaa7e, 0xaabe,
+	0xaac0, 0xaac0,
+	0xaac2, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaef,
+	0xaaf2, 0xaaf5,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabea,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff10, 0xff19,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0xff66, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10140, 0x10174,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031f,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x103d1, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae4,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11000, 0x11045,
+	0x11066, 0x1106f,
+	0x11082, 0x110b8,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11132,
+	0x11136, 0x1113f,
+	0x11150, 0x11172,
+	0x11176, 0x11176,
+	0x11180, 0x111bf,
+	0x111c1, 0x111c4,
+	0x111d0, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x11234,
+	0x11237, 0x11237,
+	0x112b0, 0x112e8,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133d, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134c,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11480, 0x114c1,
+	0x114c4, 0x114c5,
+	0x114c7, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115be,
+	0x11600, 0x1163e,
+	0x11640, 0x11640,
+	0x11644, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b5,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118e9,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16ad0, 0x16aed,
+	0x16b00, 0x16b36,
+	0x16b40, 0x16b43,
+	0x16b50, 0x16b59,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f93, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9e, 0x1bc9e,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1f130, 0x1f149,
+	0x1f150, 0x1f169,
+	0x1f170, 0x1f189,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_Alnum */
+
+/* 'ASCII': [[:ASCII:]] */
+static const OnigCodePoint CR_ASCII[] = {
+	1,
+	0x0000, 0x007f,
+}; /* CR_ASCII */
+
+#ifdef USE_UNICODE_PROPERTIES
+/* 'Any': - */
+static const OnigCodePoint CR_Any[] = {
+	1,
+	0x0000, 0x10ffff,
+}; /* CR_Any */
+
+/* 'Assigned': - */
+static const OnigCodePoint CR_Assigned[] = {
+	600,
+	0x0000, 0x0377,
+	0x037a, 0x037f,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058d, 0x058f,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x061c,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x08a0, 0x08b2,
+	0x08e4, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd0, 0x1cf6,
+	0x1cf8, 0x1cf9,
+	0x1d00, 0x1df5,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x2066, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20bd,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e42,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa69d,
+	0xa69f, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaac2,
+	0xaadb, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xd800, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe2d,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0xfffd,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018c,
+	0x10190, 0x1019b,
+	0x101a0, 0x101a0,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e0, 0x102fb,
+	0x10300, 0x10323,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x1056f, 0x1056f,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1089e,
+	0x108a7, 0x108af,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a9f,
+	0x10ac0, 0x10ae6,
+	0x10aeb, 0x10af6,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b91,
+	0x10b99, 0x10b9c,
+	0x10ba9, 0x10baf,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x1107f, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+	0x11150, 0x11176,
+	0x11180, 0x111c8,
+	0x111cd, 0x111cd,
+	0x111d0, 0x111da,
+	0x111e1, 0x111f4,
+	0x11200, 0x11211,
+	0x11213, 0x1123d,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x11480, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c9,
+	0x11600, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118f2,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x12470, 0x12474,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16a6e, 0x16a6f,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af5,
+	0x16b00, 0x16b45,
+	0x16b50, 0x16b59,
+	0x16b5b, 0x16b61,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9c, 0x1bca3,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8c7, 0x1e8d6,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f100, 0x1f10c,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xf0000, 0xffffd,
+	0x100000, 0x10fffd,
+}; /* CR_Assigned */
+
+/* 'C': Major Category */
+static const OnigCodePoint CR_C[] = {
+	603,
+	0x0000, 0x001f,
+	0x007f, 0x009f,
+	0x00ad, 0x00ad,
+	0x0378, 0x0379,
+	0x0380, 0x0383,
+	0x038b, 0x038b,
+	0x038d, 0x038d,
+	0x03a2, 0x03a2,
+	0x0530, 0x0530,
+	0x0557, 0x0558,
+	0x0560, 0x0560,
+	0x0588, 0x0588,
+	0x058b, 0x058c,
+	0x0590, 0x0590,
+	0x05c8, 0x05cf,
+	0x05eb, 0x05ef,
+	0x05f5, 0x0605,
+	0x061c, 0x061d,
+	0x06dd, 0x06dd,
+	0x070e, 0x070f,
+	0x074b, 0x074c,
+	0x07b2, 0x07bf,
+	0x07fb, 0x07ff,
+	0x082e, 0x082f,
+	0x083f, 0x083f,
+	0x085c, 0x085d,
+	0x085f, 0x089f,
+	0x08b3, 0x08e3,
+	0x0984, 0x0984,
+	0x098d, 0x098e,
+	0x0991, 0x0992,
+	0x09a9, 0x09a9,
+	0x09b1, 0x09b1,
+	0x09b3, 0x09b5,
+	0x09ba, 0x09bb,
+	0x09c5, 0x09c6,
+	0x09c9, 0x09ca,
+	0x09cf, 0x09d6,
+	0x09d8, 0x09db,
+	0x09de, 0x09de,
+	0x09e4, 0x09e5,
+	0x09fc, 0x0a00,
+	0x0a04, 0x0a04,
+	0x0a0b, 0x0a0e,
+	0x0a11, 0x0a12,
+	0x0a29, 0x0a29,
+	0x0a31, 0x0a31,
+	0x0a34, 0x0a34,
+	0x0a37, 0x0a37,
+	0x0a3a, 0x0a3b,
+	0x0a3d, 0x0a3d,
+	0x0a43, 0x0a46,
+	0x0a49, 0x0a4a,
+	0x0a4e, 0x0a50,
+	0x0a52, 0x0a58,
+	0x0a5d, 0x0a5d,
+	0x0a5f, 0x0a65,
+	0x0a76, 0x0a80,
+	0x0a84, 0x0a84,
+	0x0a8e, 0x0a8e,
+	0x0a92, 0x0a92,
+	0x0aa9, 0x0aa9,
+	0x0ab1, 0x0ab1,
+	0x0ab4, 0x0ab4,
+	0x0aba, 0x0abb,
+	0x0ac6, 0x0ac6,
+	0x0aca, 0x0aca,
+	0x0ace, 0x0acf,
+	0x0ad1, 0x0adf,
+	0x0ae4, 0x0ae5,
+	0x0af2, 0x0b00,
+	0x0b04, 0x0b04,
+	0x0b0d, 0x0b0e,
+	0x0b11, 0x0b12,
+	0x0b29, 0x0b29,
+	0x0b31, 0x0b31,
+	0x0b34, 0x0b34,
+	0x0b3a, 0x0b3b,
+	0x0b45, 0x0b46,
+	0x0b49, 0x0b4a,
+	0x0b4e, 0x0b55,
+	0x0b58, 0x0b5b,
+	0x0b5e, 0x0b5e,
+	0x0b64, 0x0b65,
+	0x0b78, 0x0b81,
+	0x0b84, 0x0b84,
+	0x0b8b, 0x0b8d,
+	0x0b91, 0x0b91,
+	0x0b96, 0x0b98,
+	0x0b9b, 0x0b9b,
+	0x0b9d, 0x0b9d,
+	0x0ba0, 0x0ba2,
+	0x0ba5, 0x0ba7,
+	0x0bab, 0x0bad,
+	0x0bba, 0x0bbd,
+	0x0bc3, 0x0bc5,
+	0x0bc9, 0x0bc9,
+	0x0bce, 0x0bcf,
+	0x0bd1, 0x0bd6,
+	0x0bd8, 0x0be5,
+	0x0bfb, 0x0bff,
+	0x0c04, 0x0c04,
+	0x0c0d, 0x0c0d,
+	0x0c11, 0x0c11,
+	0x0c29, 0x0c29,
+	0x0c3a, 0x0c3c,
+	0x0c45, 0x0c45,
+	0x0c49, 0x0c49,
+	0x0c4e, 0x0c54,
+	0x0c57, 0x0c57,
+	0x0c5a, 0x0c5f,
+	0x0c64, 0x0c65,
+	0x0c70, 0x0c77,
+	0x0c80, 0x0c80,
+	0x0c84, 0x0c84,
+	0x0c8d, 0x0c8d,
+	0x0c91, 0x0c91,
+	0x0ca9, 0x0ca9,
+	0x0cb4, 0x0cb4,
+	0x0cba, 0x0cbb,
+	0x0cc5, 0x0cc5,
+	0x0cc9, 0x0cc9,
+	0x0cce, 0x0cd4,
+	0x0cd7, 0x0cdd,
+	0x0cdf, 0x0cdf,
+	0x0ce4, 0x0ce5,
+	0x0cf0, 0x0cf0,
+	0x0cf3, 0x0d00,
+	0x0d04, 0x0d04,
+	0x0d0d, 0x0d0d,
+	0x0d11, 0x0d11,
+	0x0d3b, 0x0d3c,
+	0x0d45, 0x0d45,
+	0x0d49, 0x0d49,
+	0x0d4f, 0x0d56,
+	0x0d58, 0x0d5f,
+	0x0d64, 0x0d65,
+	0x0d76, 0x0d78,
+	0x0d80, 0x0d81,
+	0x0d84, 0x0d84,
+	0x0d97, 0x0d99,
+	0x0db2, 0x0db2,
+	0x0dbc, 0x0dbc,
+	0x0dbe, 0x0dbf,
+	0x0dc7, 0x0dc9,
+	0x0dcb, 0x0dce,
+	0x0dd5, 0x0dd5,
+	0x0dd7, 0x0dd7,
+	0x0de0, 0x0de5,
+	0x0df0, 0x0df1,
+	0x0df5, 0x0e00,
+	0x0e3b, 0x0e3e,
+	0x0e5c, 0x0e80,
+	0x0e83, 0x0e83,
+	0x0e85, 0x0e86,
+	0x0e89, 0x0e89,
+	0x0e8b, 0x0e8c,
+	0x0e8e, 0x0e93,
+	0x0e98, 0x0e98,
+	0x0ea0, 0x0ea0,
+	0x0ea4, 0x0ea4,
+	0x0ea6, 0x0ea6,
+	0x0ea8, 0x0ea9,
+	0x0eac, 0x0eac,
+	0x0eba, 0x0eba,
+	0x0ebe, 0x0ebf,
+	0x0ec5, 0x0ec5,
+	0x0ec7, 0x0ec7,
+	0x0ece, 0x0ecf,
+	0x0eda, 0x0edb,
+	0x0ee0, 0x0eff,
+	0x0f48, 0x0f48,
+	0x0f6d, 0x0f70,
+	0x0f98, 0x0f98,
+	0x0fbd, 0x0fbd,
+	0x0fcd, 0x0fcd,
+	0x0fdb, 0x0fff,
+	0x10c6, 0x10c6,
+	0x10c8, 0x10cc,
+	0x10ce, 0x10cf,
+	0x1249, 0x1249,
+	0x124e, 0x124f,
+	0x1257, 0x1257,
+	0x1259, 0x1259,
+	0x125e, 0x125f,
+	0x1289, 0x1289,
+	0x128e, 0x128f,
+	0x12b1, 0x12b1,
+	0x12b6, 0x12b7,
+	0x12bf, 0x12bf,
+	0x12c1, 0x12c1,
+	0x12c6, 0x12c7,
+	0x12d7, 0x12d7,
+	0x1311, 0x1311,
+	0x1316, 0x1317,
+	0x135b, 0x135c,
+	0x137d, 0x137f,
+	0x139a, 0x139f,
+	0x13f5, 0x13ff,
+	0x169d, 0x169f,
+	0x16f9, 0x16ff,
+	0x170d, 0x170d,
+	0x1715, 0x171f,
+	0x1737, 0x173f,
+	0x1754, 0x175f,
+	0x176d, 0x176d,
+	0x1771, 0x1771,
+	0x1774, 0x177f,
+	0x17de, 0x17df,
+	0x17ea, 0x17ef,
+	0x17fa, 0x17ff,
+	0x180e, 0x180f,
+	0x181a, 0x181f,
+	0x1878, 0x187f,
+	0x18ab, 0x18af,
+	0x18f6, 0x18ff,
+	0x191f, 0x191f,
+	0x192c, 0x192f,
+	0x193c, 0x193f,
+	0x1941, 0x1943,
+	0x196e, 0x196f,
+	0x1975, 0x197f,
+	0x19ac, 0x19af,
+	0x19ca, 0x19cf,
+	0x19db, 0x19dd,
+	0x1a1c, 0x1a1d,
+	0x1a5f, 0x1a5f,
+	0x1a7d, 0x1a7e,
+	0x1a8a, 0x1a8f,
+	0x1a9a, 0x1a9f,
+	0x1aae, 0x1aaf,
+	0x1abf, 0x1aff,
+	0x1b4c, 0x1b4f,
+	0x1b7d, 0x1b7f,
+	0x1bf4, 0x1bfb,
+	0x1c38, 0x1c3a,
+	0x1c4a, 0x1c4c,
+	0x1c80, 0x1cbf,
+	0x1cc8, 0x1ccf,
+	0x1cf7, 0x1cf7,
+	0x1cfa, 0x1cff,
+	0x1df6, 0x1dfb,
+	0x1f16, 0x1f17,
+	0x1f1e, 0x1f1f,
+	0x1f46, 0x1f47,
+	0x1f4e, 0x1f4f,
+	0x1f58, 0x1f58,
+	0x1f5a, 0x1f5a,
+	0x1f5c, 0x1f5c,
+	0x1f5e, 0x1f5e,
+	0x1f7e, 0x1f7f,
+	0x1fb5, 0x1fb5,
+	0x1fc5, 0x1fc5,
+	0x1fd4, 0x1fd5,
+	0x1fdc, 0x1fdc,
+	0x1ff0, 0x1ff1,
+	0x1ff5, 0x1ff5,
+	0x1fff, 0x1fff,
+	0x200b, 0x200f,
+	0x202a, 0x202e,
+	0x2060, 0x206f,
+	0x2072, 0x2073,
+	0x208f, 0x208f,
+	0x209d, 0x209f,
+	0x20be, 0x20cf,
+	0x20f1, 0x20ff,
+	0x218a, 0x218f,
+	0x23fb, 0x23ff,
+	0x2427, 0x243f,
+	0x244b, 0x245f,
+	0x2b74, 0x2b75,
+	0x2b96, 0x2b97,
+	0x2bba, 0x2bbc,
+	0x2bc9, 0x2bc9,
+	0x2bd2, 0x2bff,
+	0x2c2f, 0x2c2f,
+	0x2c5f, 0x2c5f,
+	0x2cf4, 0x2cf8,
+	0x2d26, 0x2d26,
+	0x2d28, 0x2d2c,
+	0x2d2e, 0x2d2f,
+	0x2d68, 0x2d6e,
+	0x2d71, 0x2d7e,
+	0x2d97, 0x2d9f,
+	0x2da7, 0x2da7,
+	0x2daf, 0x2daf,
+	0x2db7, 0x2db7,
+	0x2dbf, 0x2dbf,
+	0x2dc7, 0x2dc7,
+	0x2dcf, 0x2dcf,
+	0x2dd7, 0x2dd7,
+	0x2ddf, 0x2ddf,
+	0x2e43, 0x2e7f,
+	0x2e9a, 0x2e9a,
+	0x2ef4, 0x2eff,
+	0x2fd6, 0x2fef,
+	0x2ffc, 0x2fff,
+	0x3040, 0x3040,
+	0x3097, 0x3098,
+	0x3100, 0x3104,
+	0x312e, 0x3130,
+	0x318f, 0x318f,
+	0x31bb, 0x31bf,
+	0x31e4, 0x31ef,
+	0x321f, 0x321f,
+	0x32ff, 0x32ff,
+	0x4db6, 0x4dbf,
+	0x9fcd, 0x9fff,
+	0xa48d, 0xa48f,
+	0xa4c7, 0xa4cf,
+	0xa62c, 0xa63f,
+	0xa69e, 0xa69e,
+	0xa6f8, 0xa6ff,
+	0xa78f, 0xa78f,
+	0xa7ae, 0xa7af,
+	0xa7b2, 0xa7f6,
+	0xa82c, 0xa82f,
+	0xa83a, 0xa83f,
+	0xa878, 0xa87f,
+	0xa8c5, 0xa8cd,
+	0xa8da, 0xa8df,
+	0xa8fc, 0xa8ff,
+	0xa954, 0xa95e,
+	0xa97d, 0xa97f,
+	0xa9ce, 0xa9ce,
+	0xa9da, 0xa9dd,
+	0xa9ff, 0xa9ff,
+	0xaa37, 0xaa3f,
+	0xaa4e, 0xaa4f,
+	0xaa5a, 0xaa5b,
+	0xaac3, 0xaada,
+	0xaaf7, 0xab00,
+	0xab07, 0xab08,
+	0xab0f, 0xab10,
+	0xab17, 0xab1f,
+	0xab27, 0xab27,
+	0xab2f, 0xab2f,
+	0xab60, 0xab63,
+	0xab66, 0xabbf,
+	0xabee, 0xabef,
+	0xabfa, 0xabff,
+	0xd7a4, 0xd7af,
+	0xd7c7, 0xd7ca,
+	0xd7fc, 0xf8ff,
+	0xfa6e, 0xfa6f,
+	0xfada, 0xfaff,
+	0xfb07, 0xfb12,
+	0xfb18, 0xfb1c,
+	0xfb37, 0xfb37,
+	0xfb3d, 0xfb3d,
+	0xfb3f, 0xfb3f,
+	0xfb42, 0xfb42,
+	0xfb45, 0xfb45,
+	0xfbc2, 0xfbd2,
+	0xfd40, 0xfd4f,
+	0xfd90, 0xfd91,
+	0xfdc8, 0xfdef,
+	0xfdfe, 0xfdff,
+	0xfe1a, 0xfe1f,
+	0xfe2e, 0xfe2f,
+	0xfe53, 0xfe53,
+	0xfe67, 0xfe67,
+	0xfe6c, 0xfe6f,
+	0xfe75, 0xfe75,
+	0xfefd, 0xff00,
+	0xffbf, 0xffc1,
+	0xffc8, 0xffc9,
+	0xffd0, 0xffd1,
+	0xffd8, 0xffd9,
+	0xffdd, 0xffdf,
+	0xffe7, 0xffe7,
+	0xffef, 0xfffb,
+	0xfffe, 0xffff,
+	0x1000c, 0x1000c,
+	0x10027, 0x10027,
+	0x1003b, 0x1003b,
+	0x1003e, 0x1003e,
+	0x1004e, 0x1004f,
+	0x1005e, 0x1007f,
+	0x100fb, 0x100ff,
+	0x10103, 0x10106,
+	0x10134, 0x10136,
+	0x1018d, 0x1018f,
+	0x1019c, 0x1019f,
+	0x101a1, 0x101cf,
+	0x101fe, 0x1027f,
+	0x1029d, 0x1029f,
+	0x102d1, 0x102df,
+	0x102fc, 0x102ff,
+	0x10324, 0x1032f,
+	0x1034b, 0x1034f,
+	0x1037b, 0x1037f,
+	0x1039e, 0x1039e,
+	0x103c4, 0x103c7,
+	0x103d6, 0x103ff,
+	0x1049e, 0x1049f,
+	0x104aa, 0x104ff,
+	0x10528, 0x1052f,
+	0x10564, 0x1056e,
+	0x10570, 0x105ff,
+	0x10737, 0x1073f,
+	0x10756, 0x1075f,
+	0x10768, 0x107ff,
+	0x10806, 0x10807,
+	0x10809, 0x10809,
+	0x10836, 0x10836,
+	0x10839, 0x1083b,
+	0x1083d, 0x1083e,
+	0x10856, 0x10856,
+	0x1089f, 0x108a6,
+	0x108b0, 0x108ff,
+	0x1091c, 0x1091e,
+	0x1093a, 0x1093e,
+	0x10940, 0x1097f,
+	0x109b8, 0x109bd,
+	0x109c0, 0x109ff,
+	0x10a04, 0x10a04,
+	0x10a07, 0x10a0b,
+	0x10a14, 0x10a14,
+	0x10a18, 0x10a18,
+	0x10a34, 0x10a37,
+	0x10a3b, 0x10a3e,
+	0x10a48, 0x10a4f,
+	0x10a59, 0x10a5f,
+	0x10aa0, 0x10abf,
+	0x10ae7, 0x10aea,
+	0x10af7, 0x10aff,
+	0x10b36, 0x10b38,
+	0x10b56, 0x10b57,
+	0x10b73, 0x10b77,
+	0x10b92, 0x10b98,
+	0x10b9d, 0x10ba8,
+	0x10bb0, 0x10bff,
+	0x10c49, 0x10e5f,
+	0x10e7f, 0x10fff,
+	0x1104e, 0x11051,
+	0x11070, 0x1107e,
+	0x110bd, 0x110bd,
+	0x110c2, 0x110cf,
+	0x110e9, 0x110ef,
+	0x110fa, 0x110ff,
+	0x11135, 0x11135,
+	0x11144, 0x1114f,
+	0x11177, 0x1117f,
+	0x111c9, 0x111cc,
+	0x111ce, 0x111cf,
+	0x111db, 0x111e0,
+	0x111f5, 0x111ff,
+	0x11212, 0x11212,
+	0x1123e, 0x112af,
+	0x112eb, 0x112ef,
+	0x112fa, 0x11300,
+	0x11304, 0x11304,
+	0x1130d, 0x1130e,
+	0x11311, 0x11312,
+	0x11329, 0x11329,
+	0x11331, 0x11331,
+	0x11334, 0x11334,
+	0x1133a, 0x1133b,
+	0x11345, 0x11346,
+	0x11349, 0x1134a,
+	0x1134e, 0x11356,
+	0x11358, 0x1135c,
+	0x11364, 0x11365,
+	0x1136d, 0x1136f,
+	0x11375, 0x1147f,
+	0x114c8, 0x114cf,
+	0x114da, 0x1157f,
+	0x115b6, 0x115b7,
+	0x115ca, 0x115ff,
+	0x11645, 0x1164f,
+	0x1165a, 0x1167f,
+	0x116b8, 0x116bf,
+	0x116ca, 0x1189f,
+	0x118f3, 0x118fe,
+	0x11900, 0x11abf,
+	0x11af9, 0x11fff,
+	0x12399, 0x123ff,
+	0x1246f, 0x1246f,
+	0x12475, 0x12fff,
+	0x1342f, 0x167ff,
+	0x16a39, 0x16a3f,
+	0x16a5f, 0x16a5f,
+	0x16a6a, 0x16a6d,
+	0x16a70, 0x16acf,
+	0x16aee, 0x16aef,
+	0x16af6, 0x16aff,
+	0x16b46, 0x16b4f,
+	0x16b5a, 0x16b5a,
+	0x16b62, 0x16b62,
+	0x16b78, 0x16b7c,
+	0x16b90, 0x16eff,
+	0x16f45, 0x16f4f,
+	0x16f7f, 0x16f8e,
+	0x16fa0, 0x1afff,
+	0x1b002, 0x1bbff,
+	0x1bc6b, 0x1bc6f,
+	0x1bc7d, 0x1bc7f,
+	0x1bc89, 0x1bc8f,
+	0x1bc9a, 0x1bc9b,
+	0x1bca0, 0x1cfff,
+	0x1d0f6, 0x1d0ff,
+	0x1d127, 0x1d128,
+	0x1d173, 0x1d17a,
+	0x1d1de, 0x1d1ff,
+	0x1d246, 0x1d2ff,
+	0x1d357, 0x1d35f,
+	0x1d372, 0x1d3ff,
+	0x1d455, 0x1d455,
+	0x1d49d, 0x1d49d,
+	0x1d4a0, 0x1d4a1,
+	0x1d4a3, 0x1d4a4,
+	0x1d4a7, 0x1d4a8,
+	0x1d4ad, 0x1d4ad,
+	0x1d4ba, 0x1d4ba,
+	0x1d4bc, 0x1d4bc,
+	0x1d4c4, 0x1d4c4,
+	0x1d506, 0x1d506,
+	0x1d50b, 0x1d50c,
+	0x1d515, 0x1d515,
+	0x1d51d, 0x1d51d,
+	0x1d53a, 0x1d53a,
+	0x1d53f, 0x1d53f,
+	0x1d545, 0x1d545,
+	0x1d547, 0x1d549,
+	0x1d551, 0x1d551,
+	0x1d6a6, 0x1d6a7,
+	0x1d7cc, 0x1d7cd,
+	0x1d800, 0x1e7ff,
+	0x1e8c5, 0x1e8c6,
+	0x1e8d7, 0x1edff,
+	0x1ee04, 0x1ee04,
+	0x1ee20, 0x1ee20,
+	0x1ee23, 0x1ee23,
+	0x1ee25, 0x1ee26,
+	0x1ee28, 0x1ee28,
+	0x1ee33, 0x1ee33,
+	0x1ee38, 0x1ee38,
+	0x1ee3a, 0x1ee3a,
+	0x1ee3c, 0x1ee41,
+	0x1ee43, 0x1ee46,
+	0x1ee48, 0x1ee48,
+	0x1ee4a, 0x1ee4a,
+	0x1ee4c, 0x1ee4c,
+	0x1ee50, 0x1ee50,
+	0x1ee53, 0x1ee53,
+	0x1ee55, 0x1ee56,
+	0x1ee58, 0x1ee58,
+	0x1ee5a, 0x1ee5a,
+	0x1ee5c, 0x1ee5c,
+	0x1ee5e, 0x1ee5e,
+	0x1ee60, 0x1ee60,
+	0x1ee63, 0x1ee63,
+	0x1ee65, 0x1ee66,
+	0x1ee6b, 0x1ee6b,
+	0x1ee73, 0x1ee73,
+	0x1ee78, 0x1ee78,
+	0x1ee7d, 0x1ee7d,
+	0x1ee7f, 0x1ee7f,
+	0x1ee8a, 0x1ee8a,
+	0x1ee9c, 0x1eea0,
+	0x1eea4, 0x1eea4,
+	0x1eeaa, 0x1eeaa,
+	0x1eebc, 0x1eeef,
+	0x1eef2, 0x1efff,
+	0x1f02c, 0x1f02f,
+	0x1f094, 0x1f09f,
+	0x1f0af, 0x1f0b0,
+	0x1f0c0, 0x1f0c0,
+	0x1f0d0, 0x1f0d0,
+	0x1f0f6, 0x1f0ff,
+	0x1f10d, 0x1f10f,
+	0x1f12f, 0x1f12f,
+	0x1f16c, 0x1f16f,
+	0x1f19b, 0x1f1e5,
+	0x1f203, 0x1f20f,
+	0x1f23b, 0x1f23f,
+	0x1f249, 0x1f24f,
+	0x1f252, 0x1f2ff,
+	0x1f32d, 0x1f32f,
+	0x1f37e, 0x1f37f,
+	0x1f3cf, 0x1f3d3,
+	0x1f3f8, 0x1f3ff,
+	0x1f4ff, 0x1f4ff,
+	0x1f54b, 0x1f54f,
+	0x1f57a, 0x1f57a,
+	0x1f5a4, 0x1f5a4,
+	0x1f643, 0x1f644,
+	0x1f6d0, 0x1f6df,
+	0x1f6ed, 0x1f6ef,
+	0x1f6f4, 0x1f6ff,
+	0x1f774, 0x1f77f,
+	0x1f7d5, 0x1f7ff,
+	0x1f80c, 0x1f80f,
+	0x1f848, 0x1f84f,
+	0x1f85a, 0x1f85f,
+	0x1f888, 0x1f88f,
+	0x1f8ae, 0x1ffff,
+	0x2a6d7, 0x2a6ff,
+	0x2b735, 0x2b73f,
+	0x2b81e, 0x2f7ff,
+	0x2fa1e, 0xe00ff,
+	0xe01f0, 0x10ffff,
+}; /* CR_C */
+
+/* 'Cc': General Category */
+#define CR_Cc CR_Cntrl
+
+/* 'Cf': General Category */
+static const OnigCodePoint CR_Cf[] = {
+	17,
+	0x00ad, 0x00ad,
+	0x0600, 0x0605,
+	0x061c, 0x061c,
+	0x06dd, 0x06dd,
+	0x070f, 0x070f,
+	0x180e, 0x180e,
+	0x200b, 0x200f,
+	0x202a, 0x202e,
+	0x2060, 0x2064,
+	0x2066, 0x206f,
+	0xfeff, 0xfeff,
+	0xfff9, 0xfffb,
+	0x110bd, 0x110bd,
+	0x1bca0, 0x1bca3,
+	0x1d173, 0x1d17a,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+}; /* CR_Cf */
+
+/* 'Cn': General Category */
+static const OnigCodePoint CR_Cn[] = {
+	600,
+	0x0378, 0x0379,
+	0x0380, 0x0383,
+	0x038b, 0x038b,
+	0x038d, 0x038d,
+	0x03a2, 0x03a2,
+	0x0530, 0x0530,
+	0x0557, 0x0558,
+	0x0560, 0x0560,
+	0x0588, 0x0588,
+	0x058b, 0x058c,
+	0x0590, 0x0590,
+	0x05c8, 0x05cf,
+	0x05eb, 0x05ef,
+	0x05f5, 0x05ff,
+	0x061d, 0x061d,
+	0x070e, 0x070e,
+	0x074b, 0x074c,
+	0x07b2, 0x07bf,
+	0x07fb, 0x07ff,
+	0x082e, 0x082f,
+	0x083f, 0x083f,
+	0x085c, 0x085d,
+	0x085f, 0x089f,
+	0x08b3, 0x08e3,
+	0x0984, 0x0984,
+	0x098d, 0x098e,
+	0x0991, 0x0992,
+	0x09a9, 0x09a9,
+	0x09b1, 0x09b1,
+	0x09b3, 0x09b5,
+	0x09ba, 0x09bb,
+	0x09c5, 0x09c6,
+	0x09c9, 0x09ca,
+	0x09cf, 0x09d6,
+	0x09d8, 0x09db,
+	0x09de, 0x09de,
+	0x09e4, 0x09e5,
+	0x09fc, 0x0a00,
+	0x0a04, 0x0a04,
+	0x0a0b, 0x0a0e,
+	0x0a11, 0x0a12,
+	0x0a29, 0x0a29,
+	0x0a31, 0x0a31,
+	0x0a34, 0x0a34,
+	0x0a37, 0x0a37,
+	0x0a3a, 0x0a3b,
+	0x0a3d, 0x0a3d,
+	0x0a43, 0x0a46,
+	0x0a49, 0x0a4a,
+	0x0a4e, 0x0a50,
+	0x0a52, 0x0a58,
+	0x0a5d, 0x0a5d,
+	0x0a5f, 0x0a65,
+	0x0a76, 0x0a80,
+	0x0a84, 0x0a84,
+	0x0a8e, 0x0a8e,
+	0x0a92, 0x0a92,
+	0x0aa9, 0x0aa9,
+	0x0ab1, 0x0ab1,
+	0x0ab4, 0x0ab4,
+	0x0aba, 0x0abb,
+	0x0ac6, 0x0ac6,
+	0x0aca, 0x0aca,
+	0x0ace, 0x0acf,
+	0x0ad1, 0x0adf,
+	0x0ae4, 0x0ae5,
+	0x0af2, 0x0b00,
+	0x0b04, 0x0b04,
+	0x0b0d, 0x0b0e,
+	0x0b11, 0x0b12,
+	0x0b29, 0x0b29,
+	0x0b31, 0x0b31,
+	0x0b34, 0x0b34,
+	0x0b3a, 0x0b3b,
+	0x0b45, 0x0b46,
+	0x0b49, 0x0b4a,
+	0x0b4e, 0x0b55,
+	0x0b58, 0x0b5b,
+	0x0b5e, 0x0b5e,
+	0x0b64, 0x0b65,
+	0x0b78, 0x0b81,
+	0x0b84, 0x0b84,
+	0x0b8b, 0x0b8d,
+	0x0b91, 0x0b91,
+	0x0b96, 0x0b98,
+	0x0b9b, 0x0b9b,
+	0x0b9d, 0x0b9d,
+	0x0ba0, 0x0ba2,
+	0x0ba5, 0x0ba7,
+	0x0bab, 0x0bad,
+	0x0bba, 0x0bbd,
+	0x0bc3, 0x0bc5,
+	0x0bc9, 0x0bc9,
+	0x0bce, 0x0bcf,
+	0x0bd1, 0x0bd6,
+	0x0bd8, 0x0be5,
+	0x0bfb, 0x0bff,
+	0x0c04, 0x0c04,
+	0x0c0d, 0x0c0d,
+	0x0c11, 0x0c11,
+	0x0c29, 0x0c29,
+	0x0c3a, 0x0c3c,
+	0x0c45, 0x0c45,
+	0x0c49, 0x0c49,
+	0x0c4e, 0x0c54,
+	0x0c57, 0x0c57,
+	0x0c5a, 0x0c5f,
+	0x0c64, 0x0c65,
+	0x0c70, 0x0c77,
+	0x0c80, 0x0c80,
+	0x0c84, 0x0c84,
+	0x0c8d, 0x0c8d,
+	0x0c91, 0x0c91,
+	0x0ca9, 0x0ca9,
+	0x0cb4, 0x0cb4,
+	0x0cba, 0x0cbb,
+	0x0cc5, 0x0cc5,
+	0x0cc9, 0x0cc9,
+	0x0cce, 0x0cd4,
+	0x0cd7, 0x0cdd,
+	0x0cdf, 0x0cdf,
+	0x0ce4, 0x0ce5,
+	0x0cf0, 0x0cf0,
+	0x0cf3, 0x0d00,
+	0x0d04, 0x0d04,
+	0x0d0d, 0x0d0d,
+	0x0d11, 0x0d11,
+	0x0d3b, 0x0d3c,
+	0x0d45, 0x0d45,
+	0x0d49, 0x0d49,
+	0x0d4f, 0x0d56,
+	0x0d58, 0x0d5f,
+	0x0d64, 0x0d65,
+	0x0d76, 0x0d78,
+	0x0d80, 0x0d81,
+	0x0d84, 0x0d84,
+	0x0d97, 0x0d99,
+	0x0db2, 0x0db2,
+	0x0dbc, 0x0dbc,
+	0x0dbe, 0x0dbf,
+	0x0dc7, 0x0dc9,
+	0x0dcb, 0x0dce,
+	0x0dd5, 0x0dd5,
+	0x0dd7, 0x0dd7,
+	0x0de0, 0x0de5,
+	0x0df0, 0x0df1,
+	0x0df5, 0x0e00,
+	0x0e3b, 0x0e3e,
+	0x0e5c, 0x0e80,
+	0x0e83, 0x0e83,
+	0x0e85, 0x0e86,
+	0x0e89, 0x0e89,
+	0x0e8b, 0x0e8c,
+	0x0e8e, 0x0e93,
+	0x0e98, 0x0e98,
+	0x0ea0, 0x0ea0,
+	0x0ea4, 0x0ea4,
+	0x0ea6, 0x0ea6,
+	0x0ea8, 0x0ea9,
+	0x0eac, 0x0eac,
+	0x0eba, 0x0eba,
+	0x0ebe, 0x0ebf,
+	0x0ec5, 0x0ec5,
+	0x0ec7, 0x0ec7,
+	0x0ece, 0x0ecf,
+	0x0eda, 0x0edb,
+	0x0ee0, 0x0eff,
+	0x0f48, 0x0f48,
+	0x0f6d, 0x0f70,
+	0x0f98, 0x0f98,
+	0x0fbd, 0x0fbd,
+	0x0fcd, 0x0fcd,
+	0x0fdb, 0x0fff,
+	0x10c6, 0x10c6,
+	0x10c8, 0x10cc,
+	0x10ce, 0x10cf,
+	0x1249, 0x1249,
+	0x124e, 0x124f,
+	0x1257, 0x1257,
+	0x1259, 0x1259,
+	0x125e, 0x125f,
+	0x1289, 0x1289,
+	0x128e, 0x128f,
+	0x12b1, 0x12b1,
+	0x12b6, 0x12b7,
+	0x12bf, 0x12bf,
+	0x12c1, 0x12c1,
+	0x12c6, 0x12c7,
+	0x12d7, 0x12d7,
+	0x1311, 0x1311,
+	0x1316, 0x1317,
+	0x135b, 0x135c,
+	0x137d, 0x137f,
+	0x139a, 0x139f,
+	0x13f5, 0x13ff,
+	0x169d, 0x169f,
+	0x16f9, 0x16ff,
+	0x170d, 0x170d,
+	0x1715, 0x171f,
+	0x1737, 0x173f,
+	0x1754, 0x175f,
+	0x176d, 0x176d,
+	0x1771, 0x1771,
+	0x1774, 0x177f,
+	0x17de, 0x17df,
+	0x17ea, 0x17ef,
+	0x17fa, 0x17ff,
+	0x180f, 0x180f,
+	0x181a, 0x181f,
+	0x1878, 0x187f,
+	0x18ab, 0x18af,
+	0x18f6, 0x18ff,
+	0x191f, 0x191f,
+	0x192c, 0x192f,
+	0x193c, 0x193f,
+	0x1941, 0x1943,
+	0x196e, 0x196f,
+	0x1975, 0x197f,
+	0x19ac, 0x19af,
+	0x19ca, 0x19cf,
+	0x19db, 0x19dd,
+	0x1a1c, 0x1a1d,
+	0x1a5f, 0x1a5f,
+	0x1a7d, 0x1a7e,
+	0x1a8a, 0x1a8f,
+	0x1a9a, 0x1a9f,
+	0x1aae, 0x1aaf,
+	0x1abf, 0x1aff,
+	0x1b4c, 0x1b4f,
+	0x1b7d, 0x1b7f,
+	0x1bf4, 0x1bfb,
+	0x1c38, 0x1c3a,
+	0x1c4a, 0x1c4c,
+	0x1c80, 0x1cbf,
+	0x1cc8, 0x1ccf,
+	0x1cf7, 0x1cf7,
+	0x1cfa, 0x1cff,
+	0x1df6, 0x1dfb,
+	0x1f16, 0x1f17,
+	0x1f1e, 0x1f1f,
+	0x1f46, 0x1f47,
+	0x1f4e, 0x1f4f,
+	0x1f58, 0x1f58,
+	0x1f5a, 0x1f5a,
+	0x1f5c, 0x1f5c,
+	0x1f5e, 0x1f5e,
+	0x1f7e, 0x1f7f,
+	0x1fb5, 0x1fb5,
+	0x1fc5, 0x1fc5,
+	0x1fd4, 0x1fd5,
+	0x1fdc, 0x1fdc,
+	0x1ff0, 0x1ff1,
+	0x1ff5, 0x1ff5,
+	0x1fff, 0x1fff,
+	0x2065, 0x2065,
+	0x2072, 0x2073,
+	0x208f, 0x208f,
+	0x209d, 0x209f,
+	0x20be, 0x20cf,
+	0x20f1, 0x20ff,
+	0x218a, 0x218f,
+	0x23fb, 0x23ff,
+	0x2427, 0x243f,
+	0x244b, 0x245f,
+	0x2b74, 0x2b75,
+	0x2b96, 0x2b97,
+	0x2bba, 0x2bbc,
+	0x2bc9, 0x2bc9,
+	0x2bd2, 0x2bff,
+	0x2c2f, 0x2c2f,
+	0x2c5f, 0x2c5f,
+	0x2cf4, 0x2cf8,
+	0x2d26, 0x2d26,
+	0x2d28, 0x2d2c,
+	0x2d2e, 0x2d2f,
+	0x2d68, 0x2d6e,
+	0x2d71, 0x2d7e,
+	0x2d97, 0x2d9f,
+	0x2da7, 0x2da7,
+	0x2daf, 0x2daf,
+	0x2db7, 0x2db7,
+	0x2dbf, 0x2dbf,
+	0x2dc7, 0x2dc7,
+	0x2dcf, 0x2dcf,
+	0x2dd7, 0x2dd7,
+	0x2ddf, 0x2ddf,
+	0x2e43, 0x2e7f,
+	0x2e9a, 0x2e9a,
+	0x2ef4, 0x2eff,
+	0x2fd6, 0x2fef,
+	0x2ffc, 0x2fff,
+	0x3040, 0x3040,
+	0x3097, 0x3098,
+	0x3100, 0x3104,
+	0x312e, 0x3130,
+	0x318f, 0x318f,
+	0x31bb, 0x31bf,
+	0x31e4, 0x31ef,
+	0x321f, 0x321f,
+	0x32ff, 0x32ff,
+	0x4db6, 0x4dbf,
+	0x9fcd, 0x9fff,
+	0xa48d, 0xa48f,
+	0xa4c7, 0xa4cf,
+	0xa62c, 0xa63f,
+	0xa69e, 0xa69e,
+	0xa6f8, 0xa6ff,
+	0xa78f, 0xa78f,
+	0xa7ae, 0xa7af,
+	0xa7b2, 0xa7f6,
+	0xa82c, 0xa82f,
+	0xa83a, 0xa83f,
+	0xa878, 0xa87f,
+	0xa8c5, 0xa8cd,
+	0xa8da, 0xa8df,
+	0xa8fc, 0xa8ff,
+	0xa954, 0xa95e,
+	0xa97d, 0xa97f,
+	0xa9ce, 0xa9ce,
+	0xa9da, 0xa9dd,
+	0xa9ff, 0xa9ff,
+	0xaa37, 0xaa3f,
+	0xaa4e, 0xaa4f,
+	0xaa5a, 0xaa5b,
+	0xaac3, 0xaada,
+	0xaaf7, 0xab00,
+	0xab07, 0xab08,
+	0xab0f, 0xab10,
+	0xab17, 0xab1f,
+	0xab27, 0xab27,
+	0xab2f, 0xab2f,
+	0xab60, 0xab63,
+	0xab66, 0xabbf,
+	0xabee, 0xabef,
+	0xabfa, 0xabff,
+	0xd7a4, 0xd7af,
+	0xd7c7, 0xd7ca,
+	0xd7fc, 0xd7ff,
+	0xfa6e, 0xfa6f,
+	0xfada, 0xfaff,
+	0xfb07, 0xfb12,
+	0xfb18, 0xfb1c,
+	0xfb37, 0xfb37,
+	0xfb3d, 0xfb3d,
+	0xfb3f, 0xfb3f,
+	0xfb42, 0xfb42,
+	0xfb45, 0xfb45,
+	0xfbc2, 0xfbd2,
+	0xfd40, 0xfd4f,
+	0xfd90, 0xfd91,
+	0xfdc8, 0xfdef,
+	0xfdfe, 0xfdff,
+	0xfe1a, 0xfe1f,
+	0xfe2e, 0xfe2f,
+	0xfe53, 0xfe53,
+	0xfe67, 0xfe67,
+	0xfe6c, 0xfe6f,
+	0xfe75, 0xfe75,
+	0xfefd, 0xfefe,
+	0xff00, 0xff00,
+	0xffbf, 0xffc1,
+	0xffc8, 0xffc9,
+	0xffd0, 0xffd1,
+	0xffd8, 0xffd9,
+	0xffdd, 0xffdf,
+	0xffe7, 0xffe7,
+	0xffef, 0xfff8,
+	0xfffe, 0xffff,
+	0x1000c, 0x1000c,
+	0x10027, 0x10027,
+	0x1003b, 0x1003b,
+	0x1003e, 0x1003e,
+	0x1004e, 0x1004f,
+	0x1005e, 0x1007f,
+	0x100fb, 0x100ff,
+	0x10103, 0x10106,
+	0x10134, 0x10136,
+	0x1018d, 0x1018f,
+	0x1019c, 0x1019f,
+	0x101a1, 0x101cf,
+	0x101fe, 0x1027f,
+	0x1029d, 0x1029f,
+	0x102d1, 0x102df,
+	0x102fc, 0x102ff,
+	0x10324, 0x1032f,
+	0x1034b, 0x1034f,
+	0x1037b, 0x1037f,
+	0x1039e, 0x1039e,
+	0x103c4, 0x103c7,
+	0x103d6, 0x103ff,
+	0x1049e, 0x1049f,
+	0x104aa, 0x104ff,
+	0x10528, 0x1052f,
+	0x10564, 0x1056e,
+	0x10570, 0x105ff,
+	0x10737, 0x1073f,
+	0x10756, 0x1075f,
+	0x10768, 0x107ff,
+	0x10806, 0x10807,
+	0x10809, 0x10809,
+	0x10836, 0x10836,
+	0x10839, 0x1083b,
+	0x1083d, 0x1083e,
+	0x10856, 0x10856,
+	0x1089f, 0x108a6,
+	0x108b0, 0x108ff,
+	0x1091c, 0x1091e,
+	0x1093a, 0x1093e,
+	0x10940, 0x1097f,
+	0x109b8, 0x109bd,
+	0x109c0, 0x109ff,
+	0x10a04, 0x10a04,
+	0x10a07, 0x10a0b,
+	0x10a14, 0x10a14,
+	0x10a18, 0x10a18,
+	0x10a34, 0x10a37,
+	0x10a3b, 0x10a3e,
+	0x10a48, 0x10a4f,
+	0x10a59, 0x10a5f,
+	0x10aa0, 0x10abf,
+	0x10ae7, 0x10aea,
+	0x10af7, 0x10aff,
+	0x10b36, 0x10b38,
+	0x10b56, 0x10b57,
+	0x10b73, 0x10b77,
+	0x10b92, 0x10b98,
+	0x10b9d, 0x10ba8,
+	0x10bb0, 0x10bff,
+	0x10c49, 0x10e5f,
+	0x10e7f, 0x10fff,
+	0x1104e, 0x11051,
+	0x11070, 0x1107e,
+	0x110c2, 0x110cf,
+	0x110e9, 0x110ef,
+	0x110fa, 0x110ff,
+	0x11135, 0x11135,
+	0x11144, 0x1114f,
+	0x11177, 0x1117f,
+	0x111c9, 0x111cc,
+	0x111ce, 0x111cf,
+	0x111db, 0x111e0,
+	0x111f5, 0x111ff,
+	0x11212, 0x11212,
+	0x1123e, 0x112af,
+	0x112eb, 0x112ef,
+	0x112fa, 0x11300,
+	0x11304, 0x11304,
+	0x1130d, 0x1130e,
+	0x11311, 0x11312,
+	0x11329, 0x11329,
+	0x11331, 0x11331,
+	0x11334, 0x11334,
+	0x1133a, 0x1133b,
+	0x11345, 0x11346,
+	0x11349, 0x1134a,
+	0x1134e, 0x11356,
+	0x11358, 0x1135c,
+	0x11364, 0x11365,
+	0x1136d, 0x1136f,
+	0x11375, 0x1147f,
+	0x114c8, 0x114cf,
+	0x114da, 0x1157f,
+	0x115b6, 0x115b7,
+	0x115ca, 0x115ff,
+	0x11645, 0x1164f,
+	0x1165a, 0x1167f,
+	0x116b8, 0x116bf,
+	0x116ca, 0x1189f,
+	0x118f3, 0x118fe,
+	0x11900, 0x11abf,
+	0x11af9, 0x11fff,
+	0x12399, 0x123ff,
+	0x1246f, 0x1246f,
+	0x12475, 0x12fff,
+	0x1342f, 0x167ff,
+	0x16a39, 0x16a3f,
+	0x16a5f, 0x16a5f,
+	0x16a6a, 0x16a6d,
+	0x16a70, 0x16acf,
+	0x16aee, 0x16aef,
+	0x16af6, 0x16aff,
+	0x16b46, 0x16b4f,
+	0x16b5a, 0x16b5a,
+	0x16b62, 0x16b62,
+	0x16b78, 0x16b7c,
+	0x16b90, 0x16eff,
+	0x16f45, 0x16f4f,
+	0x16f7f, 0x16f8e,
+	0x16fa0, 0x1afff,
+	0x1b002, 0x1bbff,
+	0x1bc6b, 0x1bc6f,
+	0x1bc7d, 0x1bc7f,
+	0x1bc89, 0x1bc8f,
+	0x1bc9a, 0x1bc9b,
+	0x1bca4, 0x1cfff,
+	0x1d0f6, 0x1d0ff,
+	0x1d127, 0x1d128,
+	0x1d1de, 0x1d1ff,
+	0x1d246, 0x1d2ff,
+	0x1d357, 0x1d35f,
+	0x1d372, 0x1d3ff,
+	0x1d455, 0x1d455,
+	0x1d49d, 0x1d49d,
+	0x1d4a0, 0x1d4a1,
+	0x1d4a3, 0x1d4a4,
+	0x1d4a7, 0x1d4a8,
+	0x1d4ad, 0x1d4ad,
+	0x1d4ba, 0x1d4ba,
+	0x1d4bc, 0x1d4bc,
+	0x1d4c4, 0x1d4c4,
+	0x1d506, 0x1d506,
+	0x1d50b, 0x1d50c,
+	0x1d515, 0x1d515,
+	0x1d51d, 0x1d51d,
+	0x1d53a, 0x1d53a,
+	0x1d53f, 0x1d53f,
+	0x1d545, 0x1d545,
+	0x1d547, 0x1d549,
+	0x1d551, 0x1d551,
+	0x1d6a6, 0x1d6a7,
+	0x1d7cc, 0x1d7cd,
+	0x1d800, 0x1e7ff,
+	0x1e8c5, 0x1e8c6,
+	0x1e8d7, 0x1edff,
+	0x1ee04, 0x1ee04,
+	0x1ee20, 0x1ee20,
+	0x1ee23, 0x1ee23,
+	0x1ee25, 0x1ee26,
+	0x1ee28, 0x1ee28,
+	0x1ee33, 0x1ee33,
+	0x1ee38, 0x1ee38,
+	0x1ee3a, 0x1ee3a,
+	0x1ee3c, 0x1ee41,
+	0x1ee43, 0x1ee46,
+	0x1ee48, 0x1ee48,
+	0x1ee4a, 0x1ee4a,
+	0x1ee4c, 0x1ee4c,
+	0x1ee50, 0x1ee50,
+	0x1ee53, 0x1ee53,
+	0x1ee55, 0x1ee56,
+	0x1ee58, 0x1ee58,
+	0x1ee5a, 0x1ee5a,
+	0x1ee5c, 0x1ee5c,
+	0x1ee5e, 0x1ee5e,
+	0x1ee60, 0x1ee60,
+	0x1ee63, 0x1ee63,
+	0x1ee65, 0x1ee66,
+	0x1ee6b, 0x1ee6b,
+	0x1ee73, 0x1ee73,
+	0x1ee78, 0x1ee78,
+	0x1ee7d, 0x1ee7d,
+	0x1ee7f, 0x1ee7f,
+	0x1ee8a, 0x1ee8a,
+	0x1ee9c, 0x1eea0,
+	0x1eea4, 0x1eea4,
+	0x1eeaa, 0x1eeaa,
+	0x1eebc, 0x1eeef,
+	0x1eef2, 0x1efff,
+	0x1f02c, 0x1f02f,
+	0x1f094, 0x1f09f,
+	0x1f0af, 0x1f0b0,
+	0x1f0c0, 0x1f0c0,
+	0x1f0d0, 0x1f0d0,
+	0x1f0f6, 0x1f0ff,
+	0x1f10d, 0x1f10f,
+	0x1f12f, 0x1f12f,
+	0x1f16c, 0x1f16f,
+	0x1f19b, 0x1f1e5,
+	0x1f203, 0x1f20f,
+	0x1f23b, 0x1f23f,
+	0x1f249, 0x1f24f,
+	0x1f252, 0x1f2ff,
+	0x1f32d, 0x1f32f,
+	0x1f37e, 0x1f37f,
+	0x1f3cf, 0x1f3d3,
+	0x1f3f8, 0x1f3ff,
+	0x1f4ff, 0x1f4ff,
+	0x1f54b, 0x1f54f,
+	0x1f57a, 0x1f57a,
+	0x1f5a4, 0x1f5a4,
+	0x1f643, 0x1f644,
+	0x1f6d0, 0x1f6df,
+	0x1f6ed, 0x1f6ef,
+	0x1f6f4, 0x1f6ff,
+	0x1f774, 0x1f77f,
+	0x1f7d5, 0x1f7ff,
+	0x1f80c, 0x1f80f,
+	0x1f848, 0x1f84f,
+	0x1f85a, 0x1f85f,
+	0x1f888, 0x1f88f,
+	0x1f8ae, 0x1ffff,
+	0x2a6d7, 0x2a6ff,
+	0x2b735, 0x2b73f,
+	0x2b81e, 0x2f7ff,
+	0x2fa1e, 0xe0000,
+	0xe0002, 0xe001f,
+	0xe0080, 0xe00ff,
+	0xe01f0, 0xeffff,
+	0xffffe, 0xfffff,
+	0x10fffe, 0x10ffff,
+}; /* CR_Cn */
+
+/* 'Co': General Category */
+static const OnigCodePoint CR_Co[] = {
+	3,
+	0xe000, 0xf8ff,
+	0xf0000, 0xffffd,
+	0x100000, 0x10fffd,
+}; /* CR_Co */
+
+/* 'Cs': General Category */
+static const OnigCodePoint CR_Cs[] = {
+	1,
+	0xd800, 0xdfff,
+}; /* CR_Cs */
+
+/* 'L': Major Category */
+static const OnigCodePoint CR_L[] = {
+	537,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0370, 0x0374,
+	0x0376, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0620, 0x064a,
+	0x066e, 0x066f,
+	0x0671, 0x06d3,
+	0x06d5, 0x06d5,
+	0x06e5, 0x06e6,
+	0x06ee, 0x06ef,
+	0x06fa, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x0710,
+	0x0712, 0x072f,
+	0x074d, 0x07a5,
+	0x07b1, 0x07b1,
+	0x07ca, 0x07ea,
+	0x07f4, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x0815,
+	0x081a, 0x081a,
+	0x0824, 0x0824,
+	0x0828, 0x0828,
+	0x0840, 0x0858,
+	0x08a0, 0x08b2,
+	0x0904, 0x0939,
+	0x093d, 0x093d,
+	0x0950, 0x0950,
+	0x0958, 0x0961,
+	0x0971, 0x0980,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bd, 0x09bd,
+	0x09ce, 0x09ce,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e1,
+	0x09f0, 0x09f1,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a72, 0x0a74,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abd, 0x0abd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae1,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3d, 0x0b3d,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b71, 0x0b71,
+	0x0b83, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bd0, 0x0bd0,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c3d,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c61,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbd, 0x0cbd,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0cf1, 0x0cf2,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d3d,
+	0x0d4e, 0x0d4e,
+	0x0d60, 0x0d61,
+	0x0d7a, 0x0d7f,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0e01, 0x0e30,
+	0x0e32, 0x0e33,
+	0x0e40, 0x0e46,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb0,
+	0x0eb2, 0x0eb3,
+	0x0ebd, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f40, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f88, 0x0f8c,
+	0x1000, 0x102a,
+	0x103f, 0x103f,
+	0x1050, 0x1055,
+	0x105a, 0x105d,
+	0x1061, 0x1061,
+	0x1065, 0x1066,
+	0x106e, 0x1070,
+	0x1075, 0x1081,
+	0x108e, 0x108e,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16f1, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1711,
+	0x1720, 0x1731,
+	0x1740, 0x1751,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1780, 0x17b3,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dc,
+	0x1820, 0x1877,
+	0x1880, 0x18a8,
+	0x18aa, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1950, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19c1, 0x19c7,
+	0x1a00, 0x1a16,
+	0x1a20, 0x1a54,
+	0x1aa7, 0x1aa7,
+	0x1b05, 0x1b33,
+	0x1b45, 0x1b4b,
+	0x1b83, 0x1ba0,
+	0x1bae, 0x1baf,
+	0x1bba, 0x1be5,
+	0x1c00, 0x1c23,
+	0x1c4d, 0x1c4f,
+	0x1c5a, 0x1c7d,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf1,
+	0x1cf5, 0x1cf6,
+	0x1d00, 0x1dbf,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x212f, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2183, 0x2184,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2e2f, 0x2e2f,
+	0x3005, 0x3006,
+	0x3031, 0x3035,
+	0x303b, 0x303c,
+	0x3041, 0x3096,
+	0x309d, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa61f,
+	0xa62a, 0xa62b,
+	0xa640, 0xa66e,
+	0xa67f, 0xa69d,
+	0xa6a0, 0xa6e5,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa801,
+	0xa803, 0xa805,
+	0xa807, 0xa80a,
+	0xa80c, 0xa822,
+	0xa840, 0xa873,
+	0xa882, 0xa8b3,
+	0xa8f2, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa90a, 0xa925,
+	0xa930, 0xa946,
+	0xa960, 0xa97c,
+	0xa984, 0xa9b2,
+	0xa9cf, 0xa9cf,
+	0xa9e0, 0xa9e4,
+	0xa9e6, 0xa9ef,
+	0xa9fa, 0xa9fe,
+	0xaa00, 0xaa28,
+	0xaa40, 0xaa42,
+	0xaa44, 0xaa4b,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaa7a,
+	0xaa7e, 0xaaaf,
+	0xaab1, 0xaab1,
+	0xaab5, 0xaab6,
+	0xaab9, 0xaabd,
+	0xaac0, 0xaac0,
+	0xaac2, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaea,
+	0xaaf2, 0xaaf4,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabe2,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb1d,
+	0xfb1f, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0xff66, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031f,
+	0x10330, 0x10340,
+	0x10342, 0x10349,
+	0x10350, 0x10375,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x10400, 0x1049d,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a00,
+	0x10a10, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae4,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11003, 0x11037,
+	0x11083, 0x110af,
+	0x110d0, 0x110e8,
+	0x11103, 0x11126,
+	0x11150, 0x11172,
+	0x11176, 0x11176,
+	0x11183, 0x111b2,
+	0x111c1, 0x111c4,
+	0x111da, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x1122b,
+	0x112b0, 0x112de,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133d, 0x1133d,
+	0x1135d, 0x11361,
+	0x11480, 0x114af,
+	0x114c4, 0x114c5,
+	0x114c7, 0x114c7,
+	0x11580, 0x115ae,
+	0x11600, 0x1162f,
+	0x11644, 0x11644,
+	0x11680, 0x116aa,
+	0x118a0, 0x118df,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16ad0, 0x16aed,
+	0x16b00, 0x16b2f,
+	0x16b40, 0x16b43,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f50,
+	0x16f93, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1e800, 0x1e8c4,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_L */
+
+/* 'LC': General Category */
+static const OnigCodePoint CR_LC[] = {
+	117,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00b5, 0x00b5,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x01ba,
+	0x01bc, 0x01bf,
+	0x01c4, 0x0293,
+	0x0295, 0x02af,
+	0x0370, 0x0373,
+	0x0376, 0x0377,
+	0x037b, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0561, 0x0587,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x1d00, 0x1d2b,
+	0x1d6b, 0x1d77,
+	0x1d79, 0x1d9a,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x212f, 0x2134,
+	0x2139, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2183, 0x2184,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2c7b,
+	0x2c7e, 0x2ce4,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0xa640, 0xa66d,
+	0xa680, 0xa69b,
+	0xa722, 0xa76f,
+	0xa771, 0xa787,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7fa, 0xa7fa,
+	0xab30, 0xab5a,
+	0xab64, 0xab65,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0x10400, 0x1044f,
+	0x118a0, 0x118df,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+}; /* CR_LC */
+
+/* 'Ll': General Category */
+static const OnigCodePoint CR_Ll[] = {
+	625,
+	0x0061, 0x007a,
+	0x00b5, 0x00b5,
+	0x00df, 0x00f6,
+	0x00f8, 0x00ff,
+	0x0101, 0x0101,
+	0x0103, 0x0103,
+	0x0105, 0x0105,
+	0x0107, 0x0107,
+	0x0109, 0x0109,
+	0x010b, 0x010b,
+	0x010d, 0x010d,
+	0x010f, 0x010f,
+	0x0111, 0x0111,
+	0x0113, 0x0113,
+	0x0115, 0x0115,
+	0x0117, 0x0117,
+	0x0119, 0x0119,
+	0x011b, 0x011b,
+	0x011d, 0x011d,
+	0x011f, 0x011f,
+	0x0121, 0x0121,
+	0x0123, 0x0123,
+	0x0125, 0x0125,
+	0x0127, 0x0127,
+	0x0129, 0x0129,
+	0x012b, 0x012b,
+	0x012d, 0x012d,
+	0x012f, 0x012f,
+	0x0131, 0x0131,
+	0x0133, 0x0133,
+	0x0135, 0x0135,
+	0x0137, 0x0138,
+	0x013a, 0x013a,
+	0x013c, 0x013c,
+	0x013e, 0x013e,
+	0x0140, 0x0140,
+	0x0142, 0x0142,
+	0x0144, 0x0144,
+	0x0146, 0x0146,
+	0x0148, 0x0149,
+	0x014b, 0x014b,
+	0x014d, 0x014d,
+	0x014f, 0x014f,
+	0x0151, 0x0151,
+	0x0153, 0x0153,
+	0x0155, 0x0155,
+	0x0157, 0x0157,
+	0x0159, 0x0159,
+	0x015b, 0x015b,
+	0x015d, 0x015d,
+	0x015f, 0x015f,
+	0x0161, 0x0161,
+	0x0163, 0x0163,
+	0x0165, 0x0165,
+	0x0167, 0x0167,
+	0x0169, 0x0169,
+	0x016b, 0x016b,
+	0x016d, 0x016d,
+	0x016f, 0x016f,
+	0x0171, 0x0171,
+	0x0173, 0x0173,
+	0x0175, 0x0175,
+	0x0177, 0x0177,
+	0x017a, 0x017a,
+	0x017c, 0x017c,
+	0x017e, 0x0180,
+	0x0183, 0x0183,
+	0x0185, 0x0185,
+	0x0188, 0x0188,
+	0x018c, 0x018d,
+	0x0192, 0x0192,
+	0x0195, 0x0195,
+	0x0199, 0x019b,
+	0x019e, 0x019e,
+	0x01a1, 0x01a1,
+	0x01a3, 0x01a3,
+	0x01a5, 0x01a5,
+	0x01a8, 0x01a8,
+	0x01aa, 0x01ab,
+	0x01ad, 0x01ad,
+	0x01b0, 0x01b0,
+	0x01b4, 0x01b4,
+	0x01b6, 0x01b6,
+	0x01b9, 0x01ba,
+	0x01bd, 0x01bf,
+	0x01c6, 0x01c6,
+	0x01c9, 0x01c9,
+	0x01cc, 0x01cc,
+	0x01ce, 0x01ce,
+	0x01d0, 0x01d0,
+	0x01d2, 0x01d2,
+	0x01d4, 0x01d4,
+	0x01d6, 0x01d6,
+	0x01d8, 0x01d8,
+	0x01da, 0x01da,
+	0x01dc, 0x01dd,
+	0x01df, 0x01df,
+	0x01e1, 0x01e1,
+	0x01e3, 0x01e3,
+	0x01e5, 0x01e5,
+	0x01e7, 0x01e7,
+	0x01e9, 0x01e9,
+	0x01eb, 0x01eb,
+	0x01ed, 0x01ed,
+	0x01ef, 0x01f0,
+	0x01f3, 0x01f3,
+	0x01f5, 0x01f5,
+	0x01f9, 0x01f9,
+	0x01fb, 0x01fb,
+	0x01fd, 0x01fd,
+	0x01ff, 0x01ff,
+	0x0201, 0x0201,
+	0x0203, 0x0203,
+	0x0205, 0x0205,
+	0x0207, 0x0207,
+	0x0209, 0x0209,
+	0x020b, 0x020b,
+	0x020d, 0x020d,
+	0x020f, 0x020f,
+	0x0211, 0x0211,
+	0x0213, 0x0213,
+	0x0215, 0x0215,
+	0x0217, 0x0217,
+	0x0219, 0x0219,
+	0x021b, 0x021b,
+	0x021d, 0x021d,
+	0x021f, 0x021f,
+	0x0221, 0x0221,
+	0x0223, 0x0223,
+	0x0225, 0x0225,
+	0x0227, 0x0227,
+	0x0229, 0x0229,
+	0x022b, 0x022b,
+	0x022d, 0x022d,
+	0x022f, 0x022f,
+	0x0231, 0x0231,
+	0x0233, 0x0239,
+	0x023c, 0x023c,
+	0x023f, 0x0240,
+	0x0242, 0x0242,
+	0x0247, 0x0247,
+	0x0249, 0x0249,
+	0x024b, 0x024b,
+	0x024d, 0x024d,
+	0x024f, 0x0293,
+	0x0295, 0x02af,
+	0x0371, 0x0371,
+	0x0373, 0x0373,
+	0x0377, 0x0377,
+	0x037b, 0x037d,
+	0x0390, 0x0390,
+	0x03ac, 0x03ce,
+	0x03d0, 0x03d1,
+	0x03d5, 0x03d7,
+	0x03d9, 0x03d9,
+	0x03db, 0x03db,
+	0x03dd, 0x03dd,
+	0x03df, 0x03df,
+	0x03e1, 0x03e1,
+	0x03e3, 0x03e3,
+	0x03e5, 0x03e5,
+	0x03e7, 0x03e7,
+	0x03e9, 0x03e9,
+	0x03eb, 0x03eb,
+	0x03ed, 0x03ed,
+	0x03ef, 0x03f3,
+	0x03f5, 0x03f5,
+	0x03f8, 0x03f8,
+	0x03fb, 0x03fc,
+	0x0430, 0x045f,
+	0x0461, 0x0461,
+	0x0463, 0x0463,
+	0x0465, 0x0465,
+	0x0467, 0x0467,
+	0x0469, 0x0469,
+	0x046b, 0x046b,
+	0x046d, 0x046d,
+	0x046f, 0x046f,
+	0x0471, 0x0471,
+	0x0473, 0x0473,
+	0x0475, 0x0475,
+	0x0477, 0x0477,
+	0x0479, 0x0479,
+	0x047b, 0x047b,
+	0x047d, 0x047d,
+	0x047f, 0x047f,
+	0x0481, 0x0481,
+	0x048b, 0x048b,
+	0x048d, 0x048d,
+	0x048f, 0x048f,
+	0x0491, 0x0491,
+	0x0493, 0x0493,
+	0x0495, 0x0495,
+	0x0497, 0x0497,
+	0x0499, 0x0499,
+	0x049b, 0x049b,
+	0x049d, 0x049d,
+	0x049f, 0x049f,
+	0x04a1, 0x04a1,
+	0x04a3, 0x04a3,
+	0x04a5, 0x04a5,
+	0x04a7, 0x04a7,
+	0x04a9, 0x04a9,
+	0x04ab, 0x04ab,
+	0x04ad, 0x04ad,
+	0x04af, 0x04af,
+	0x04b1, 0x04b1,
+	0x04b3, 0x04b3,
+	0x04b5, 0x04b5,
+	0x04b7, 0x04b7,
+	0x04b9, 0x04b9,
+	0x04bb, 0x04bb,
+	0x04bd, 0x04bd,
+	0x04bf, 0x04bf,
+	0x04c2, 0x04c2,
+	0x04c4, 0x04c4,
+	0x04c6, 0x04c6,
+	0x04c8, 0x04c8,
+	0x04ca, 0x04ca,
+	0x04cc, 0x04cc,
+	0x04ce, 0x04cf,
+	0x04d1, 0x04d1,
+	0x04d3, 0x04d3,
+	0x04d5, 0x04d5,
+	0x04d7, 0x04d7,
+	0x04d9, 0x04d9,
+	0x04db, 0x04db,
+	0x04dd, 0x04dd,
+	0x04df, 0x04df,
+	0x04e1, 0x04e1,
+	0x04e3, 0x04e3,
+	0x04e5, 0x04e5,
+	0x04e7, 0x04e7,
+	0x04e9, 0x04e9,
+	0x04eb, 0x04eb,
+	0x04ed, 0x04ed,
+	0x04ef, 0x04ef,
+	0x04f1, 0x04f1,
+	0x04f3, 0x04f3,
+	0x04f5, 0x04f5,
+	0x04f7, 0x04f7,
+	0x04f9, 0x04f9,
+	0x04fb, 0x04fb,
+	0x04fd, 0x04fd,
+	0x04ff, 0x04ff,
+	0x0501, 0x0501,
+	0x0503, 0x0503,
+	0x0505, 0x0505,
+	0x0507, 0x0507,
+	0x0509, 0x0509,
+	0x050b, 0x050b,
+	0x050d, 0x050d,
+	0x050f, 0x050f,
+	0x0511, 0x0511,
+	0x0513, 0x0513,
+	0x0515, 0x0515,
+	0x0517, 0x0517,
+	0x0519, 0x0519,
+	0x051b, 0x051b,
+	0x051d, 0x051d,
+	0x051f, 0x051f,
+	0x0521, 0x0521,
+	0x0523, 0x0523,
+	0x0525, 0x0525,
+	0x0527, 0x0527,
+	0x0529, 0x0529,
+	0x052b, 0x052b,
+	0x052d, 0x052d,
+	0x052f, 0x052f,
+	0x0561, 0x0587,
+	0x1d00, 0x1d2b,
+	0x1d6b, 0x1d77,
+	0x1d79, 0x1d9a,
+	0x1e01, 0x1e01,
+	0x1e03, 0x1e03,
+	0x1e05, 0x1e05,
+	0x1e07, 0x1e07,
+	0x1e09, 0x1e09,
+	0x1e0b, 0x1e0b,
+	0x1e0d, 0x1e0d,
+	0x1e0f, 0x1e0f,
+	0x1e11, 0x1e11,
+	0x1e13, 0x1e13,
+	0x1e15, 0x1e15,
+	0x1e17, 0x1e17,
+	0x1e19, 0x1e19,
+	0x1e1b, 0x1e1b,
+	0x1e1d, 0x1e1d,
+	0x1e1f, 0x1e1f,
+	0x1e21, 0x1e21,
+	0x1e23, 0x1e23,
+	0x1e25, 0x1e25,
+	0x1e27, 0x1e27,
+	0x1e29, 0x1e29,
+	0x1e2b, 0x1e2b,
+	0x1e2d, 0x1e2d,
+	0x1e2f, 0x1e2f,
+	0x1e31, 0x1e31,
+	0x1e33, 0x1e33,
+	0x1e35, 0x1e35,
+	0x1e37, 0x1e37,
+	0x1e39, 0x1e39,
+	0x1e3b, 0x1e3b,
+	0x1e3d, 0x1e3d,
+	0x1e3f, 0x1e3f,
+	0x1e41, 0x1e41,
+	0x1e43, 0x1e43,
+	0x1e45, 0x1e45,
+	0x1e47, 0x1e47,
+	0x1e49, 0x1e49,
+	0x1e4b, 0x1e4b,
+	0x1e4d, 0x1e4d,
+	0x1e4f, 0x1e4f,
+	0x1e51, 0x1e51,
+	0x1e53, 0x1e53,
+	0x1e55, 0x1e55,
+	0x1e57, 0x1e57,
+	0x1e59, 0x1e59,
+	0x1e5b, 0x1e5b,
+	0x1e5d, 0x1e5d,
+	0x1e5f, 0x1e5f,
+	0x1e61, 0x1e61,
+	0x1e63, 0x1e63,
+	0x1e65, 0x1e65,
+	0x1e67, 0x1e67,
+	0x1e69, 0x1e69,
+	0x1e6b, 0x1e6b,
+	0x1e6d, 0x1e6d,
+	0x1e6f, 0x1e6f,
+	0x1e71, 0x1e71,
+	0x1e73, 0x1e73,
+	0x1e75, 0x1e75,
+	0x1e77, 0x1e77,
+	0x1e79, 0x1e79,
+	0x1e7b, 0x1e7b,
+	0x1e7d, 0x1e7d,
+	0x1e7f, 0x1e7f,
+	0x1e81, 0x1e81,
+	0x1e83, 0x1e83,
+	0x1e85, 0x1e85,
+	0x1e87, 0x1e87,
+	0x1e89, 0x1e89,
+	0x1e8b, 0x1e8b,
+	0x1e8d, 0x1e8d,
+	0x1e8f, 0x1e8f,
+	0x1e91, 0x1e91,
+	0x1e93, 0x1e93,
+	0x1e95, 0x1e9d,
+	0x1e9f, 0x1e9f,
+	0x1ea1, 0x1ea1,
+	0x1ea3, 0x1ea3,
+	0x1ea5, 0x1ea5,
+	0x1ea7, 0x1ea7,
+	0x1ea9, 0x1ea9,
+	0x1eab, 0x1eab,
+	0x1ead, 0x1ead,
+	0x1eaf, 0x1eaf,
+	0x1eb1, 0x1eb1,
+	0x1eb3, 0x1eb3,
+	0x1eb5, 0x1eb5,
+	0x1eb7, 0x1eb7,
+	0x1eb9, 0x1eb9,
+	0x1ebb, 0x1ebb,
+	0x1ebd, 0x1ebd,
+	0x1ebf, 0x1ebf,
+	0x1ec1, 0x1ec1,
+	0x1ec3, 0x1ec3,
+	0x1ec5, 0x1ec5,
+	0x1ec7, 0x1ec7,
+	0x1ec9, 0x1ec9,
+	0x1ecb, 0x1ecb,
+	0x1ecd, 0x1ecd,
+	0x1ecf, 0x1ecf,
+	0x1ed1, 0x1ed1,
+	0x1ed3, 0x1ed3,
+	0x1ed5, 0x1ed5,
+	0x1ed7, 0x1ed7,
+	0x1ed9, 0x1ed9,
+	0x1edb, 0x1edb,
+	0x1edd, 0x1edd,
+	0x1edf, 0x1edf,
+	0x1ee1, 0x1ee1,
+	0x1ee3, 0x1ee3,
+	0x1ee5, 0x1ee5,
+	0x1ee7, 0x1ee7,
+	0x1ee9, 0x1ee9,
+	0x1eeb, 0x1eeb,
+	0x1eed, 0x1eed,
+	0x1eef, 0x1eef,
+	0x1ef1, 0x1ef1,
+	0x1ef3, 0x1ef3,
+	0x1ef5, 0x1ef5,
+	0x1ef7, 0x1ef7,
+	0x1ef9, 0x1ef9,
+	0x1efb, 0x1efb,
+	0x1efd, 0x1efd,
+	0x1eff, 0x1f07,
+	0x1f10, 0x1f15,
+	0x1f20, 0x1f27,
+	0x1f30, 0x1f37,
+	0x1f40, 0x1f45,
+	0x1f50, 0x1f57,
+	0x1f60, 0x1f67,
+	0x1f70, 0x1f7d,
+	0x1f80, 0x1f87,
+	0x1f90, 0x1f97,
+	0x1fa0, 0x1fa7,
+	0x1fb0, 0x1fb4,
+	0x1fb6, 0x1fb7,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fc7,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fd7,
+	0x1fe0, 0x1fe7,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ff7,
+	0x210a, 0x210a,
+	0x210e, 0x210f,
+	0x2113, 0x2113,
+	0x212f, 0x212f,
+	0x2134, 0x2134,
+	0x2139, 0x2139,
+	0x213c, 0x213d,
+	0x2146, 0x2149,
+	0x214e, 0x214e,
+	0x2184, 0x2184,
+	0x2c30, 0x2c5e,
+	0x2c61, 0x2c61,
+	0x2c65, 0x2c66,
+	0x2c68, 0x2c68,
+	0x2c6a, 0x2c6a,
+	0x2c6c, 0x2c6c,
+	0x2c71, 0x2c71,
+	0x2c73, 0x2c74,
+	0x2c76, 0x2c7b,
+	0x2c81, 0x2c81,
+	0x2c83, 0x2c83,
+	0x2c85, 0x2c85,
+	0x2c87, 0x2c87,
+	0x2c89, 0x2c89,
+	0x2c8b, 0x2c8b,
+	0x2c8d, 0x2c8d,
+	0x2c8f, 0x2c8f,
+	0x2c91, 0x2c91,
+	0x2c93, 0x2c93,
+	0x2c95, 0x2c95,
+	0x2c97, 0x2c97,
+	0x2c99, 0x2c99,
+	0x2c9b, 0x2c9b,
+	0x2c9d, 0x2c9d,
+	0x2c9f, 0x2c9f,
+	0x2ca1, 0x2ca1,
+	0x2ca3, 0x2ca3,
+	0x2ca5, 0x2ca5,
+	0x2ca7, 0x2ca7,
+	0x2ca9, 0x2ca9,
+	0x2cab, 0x2cab,
+	0x2cad, 0x2cad,
+	0x2caf, 0x2caf,
+	0x2cb1, 0x2cb1,
+	0x2cb3, 0x2cb3,
+	0x2cb5, 0x2cb5,
+	0x2cb7, 0x2cb7,
+	0x2cb9, 0x2cb9,
+	0x2cbb, 0x2cbb,
+	0x2cbd, 0x2cbd,
+	0x2cbf, 0x2cbf,
+	0x2cc1, 0x2cc1,
+	0x2cc3, 0x2cc3,
+	0x2cc5, 0x2cc5,
+	0x2cc7, 0x2cc7,
+	0x2cc9, 0x2cc9,
+	0x2ccb, 0x2ccb,
+	0x2ccd, 0x2ccd,
+	0x2ccf, 0x2ccf,
+	0x2cd1, 0x2cd1,
+	0x2cd3, 0x2cd3,
+	0x2cd5, 0x2cd5,
+	0x2cd7, 0x2cd7,
+	0x2cd9, 0x2cd9,
+	0x2cdb, 0x2cdb,
+	0x2cdd, 0x2cdd,
+	0x2cdf, 0x2cdf,
+	0x2ce1, 0x2ce1,
+	0x2ce3, 0x2ce4,
+	0x2cec, 0x2cec,
+	0x2cee, 0x2cee,
+	0x2cf3, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0xa641, 0xa641,
+	0xa643, 0xa643,
+	0xa645, 0xa645,
+	0xa647, 0xa647,
+	0xa649, 0xa649,
+	0xa64b, 0xa64b,
+	0xa64d, 0xa64d,
+	0xa64f, 0xa64f,
+	0xa651, 0xa651,
+	0xa653, 0xa653,
+	0xa655, 0xa655,
+	0xa657, 0xa657,
+	0xa659, 0xa659,
+	0xa65b, 0xa65b,
+	0xa65d, 0xa65d,
+	0xa65f, 0xa65f,
+	0xa661, 0xa661,
+	0xa663, 0xa663,
+	0xa665, 0xa665,
+	0xa667, 0xa667,
+	0xa669, 0xa669,
+	0xa66b, 0xa66b,
+	0xa66d, 0xa66d,
+	0xa681, 0xa681,
+	0xa683, 0xa683,
+	0xa685, 0xa685,
+	0xa687, 0xa687,
+	0xa689, 0xa689,
+	0xa68b, 0xa68b,
+	0xa68d, 0xa68d,
+	0xa68f, 0xa68f,
+	0xa691, 0xa691,
+	0xa693, 0xa693,
+	0xa695, 0xa695,
+	0xa697, 0xa697,
+	0xa699, 0xa699,
+	0xa69b, 0xa69b,
+	0xa723, 0xa723,
+	0xa725, 0xa725,
+	0xa727, 0xa727,
+	0xa729, 0xa729,
+	0xa72b, 0xa72b,
+	0xa72d, 0xa72d,
+	0xa72f, 0xa731,
+	0xa733, 0xa733,
+	0xa735, 0xa735,
+	0xa737, 0xa737,
+	0xa739, 0xa739,
+	0xa73b, 0xa73b,
+	0xa73d, 0xa73d,
+	0xa73f, 0xa73f,
+	0xa741, 0xa741,
+	0xa743, 0xa743,
+	0xa745, 0xa745,
+	0xa747, 0xa747,
+	0xa749, 0xa749,
+	0xa74b, 0xa74b,
+	0xa74d, 0xa74d,
+	0xa74f, 0xa74f,
+	0xa751, 0xa751,
+	0xa753, 0xa753,
+	0xa755, 0xa755,
+	0xa757, 0xa757,
+	0xa759, 0xa759,
+	0xa75b, 0xa75b,
+	0xa75d, 0xa75d,
+	0xa75f, 0xa75f,
+	0xa761, 0xa761,
+	0xa763, 0xa763,
+	0xa765, 0xa765,
+	0xa767, 0xa767,
+	0xa769, 0xa769,
+	0xa76b, 0xa76b,
+	0xa76d, 0xa76d,
+	0xa76f, 0xa76f,
+	0xa771, 0xa778,
+	0xa77a, 0xa77a,
+	0xa77c, 0xa77c,
+	0xa77f, 0xa77f,
+	0xa781, 0xa781,
+	0xa783, 0xa783,
+	0xa785, 0xa785,
+	0xa787, 0xa787,
+	0xa78c, 0xa78c,
+	0xa78e, 0xa78e,
+	0xa791, 0xa791,
+	0xa793, 0xa795,
+	0xa797, 0xa797,
+	0xa799, 0xa799,
+	0xa79b, 0xa79b,
+	0xa79d, 0xa79d,
+	0xa79f, 0xa79f,
+	0xa7a1, 0xa7a1,
+	0xa7a3, 0xa7a3,
+	0xa7a5, 0xa7a5,
+	0xa7a7, 0xa7a7,
+	0xa7a9, 0xa7a9,
+	0xa7fa, 0xa7fa,
+	0xab30, 0xab5a,
+	0xab64, 0xab65,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff41, 0xff5a,
+	0x10428, 0x1044f,
+	0x118c0, 0x118df,
+	0x1d41a, 0x1d433,
+	0x1d44e, 0x1d454,
+	0x1d456, 0x1d467,
+	0x1d482, 0x1d49b,
+	0x1d4b6, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d4cf,
+	0x1d4ea, 0x1d503,
+	0x1d51e, 0x1d537,
+	0x1d552, 0x1d56b,
+	0x1d586, 0x1d59f,
+	0x1d5ba, 0x1d5d3,
+	0x1d5ee, 0x1d607,
+	0x1d622, 0x1d63b,
+	0x1d656, 0x1d66f,
+	0x1d68a, 0x1d6a5,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6e1,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d71b,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d755,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d78f,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7c9,
+	0x1d7cb, 0x1d7cb,
+}; /* CR_Ll */
+
+/* 'Lm': General Category */
+static const OnigCodePoint CR_Lm[] = {
+	56,
+	0x02b0, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0374, 0x0374,
+	0x037a, 0x037a,
+	0x0559, 0x0559,
+	0x0640, 0x0640,
+	0x06e5, 0x06e6,
+	0x07f4, 0x07f5,
+	0x07fa, 0x07fa,
+	0x081a, 0x081a,
+	0x0824, 0x0824,
+	0x0828, 0x0828,
+	0x0971, 0x0971,
+	0x0e46, 0x0e46,
+	0x0ec6, 0x0ec6,
+	0x10fc, 0x10fc,
+	0x17d7, 0x17d7,
+	0x1843, 0x1843,
+	0x1aa7, 0x1aa7,
+	0x1c78, 0x1c7d,
+	0x1d2c, 0x1d6a,
+	0x1d78, 0x1d78,
+	0x1d9b, 0x1dbf,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2c7c, 0x2c7d,
+	0x2d6f, 0x2d6f,
+	0x2e2f, 0x2e2f,
+	0x3005, 0x3005,
+	0x3031, 0x3035,
+	0x303b, 0x303b,
+	0x309d, 0x309e,
+	0x30fc, 0x30fe,
+	0xa015, 0xa015,
+	0xa4f8, 0xa4fd,
+	0xa60c, 0xa60c,
+	0xa67f, 0xa67f,
+	0xa69c, 0xa69d,
+	0xa717, 0xa71f,
+	0xa770, 0xa770,
+	0xa788, 0xa788,
+	0xa7f8, 0xa7f9,
+	0xa9cf, 0xa9cf,
+	0xa9e6, 0xa9e6,
+	0xaa70, 0xaa70,
+	0xaadd, 0xaadd,
+	0xaaf3, 0xaaf4,
+	0xab5c, 0xab5f,
+	0xff70, 0xff70,
+	0xff9e, 0xff9f,
+	0x16b40, 0x16b43,
+	0x16f93, 0x16f9f,
+}; /* CR_Lm */
+
+/* 'Lo': General Category */
+static const OnigCodePoint CR_Lo[] = {
+	417,
+	0x00aa, 0x00aa,
+	0x00ba, 0x00ba,
+	0x01bb, 0x01bb,
+	0x01c0, 0x01c3,
+	0x0294, 0x0294,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0620, 0x063f,
+	0x0641, 0x064a,
+	0x066e, 0x066f,
+	0x0671, 0x06d3,
+	0x06d5, 0x06d5,
+	0x06ee, 0x06ef,
+	0x06fa, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x0710,
+	0x0712, 0x072f,
+	0x074d, 0x07a5,
+	0x07b1, 0x07b1,
+	0x07ca, 0x07ea,
+	0x0800, 0x0815,
+	0x0840, 0x0858,
+	0x08a0, 0x08b2,
+	0x0904, 0x0939,
+	0x093d, 0x093d,
+	0x0950, 0x0950,
+	0x0958, 0x0961,
+	0x0972, 0x0980,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bd, 0x09bd,
+	0x09ce, 0x09ce,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e1,
+	0x09f0, 0x09f1,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a72, 0x0a74,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abd, 0x0abd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae1,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3d, 0x0b3d,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b71, 0x0b71,
+	0x0b83, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bd0, 0x0bd0,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c3d,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c61,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbd, 0x0cbd,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0cf1, 0x0cf2,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d3d,
+	0x0d4e, 0x0d4e,
+	0x0d60, 0x0d61,
+	0x0d7a, 0x0d7f,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0e01, 0x0e30,
+	0x0e32, 0x0e33,
+	0x0e40, 0x0e45,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb0,
+	0x0eb2, 0x0eb3,
+	0x0ebd, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f40, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f88, 0x0f8c,
+	0x1000, 0x102a,
+	0x103f, 0x103f,
+	0x1050, 0x1055,
+	0x105a, 0x105d,
+	0x1061, 0x1061,
+	0x1065, 0x1066,
+	0x106e, 0x1070,
+	0x1075, 0x1081,
+	0x108e, 0x108e,
+	0x10d0, 0x10fa,
+	0x10fd, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16f1, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1711,
+	0x1720, 0x1731,
+	0x1740, 0x1751,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1780, 0x17b3,
+	0x17dc, 0x17dc,
+	0x1820, 0x1842,
+	0x1844, 0x1877,
+	0x1880, 0x18a8,
+	0x18aa, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1950, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19c1, 0x19c7,
+	0x1a00, 0x1a16,
+	0x1a20, 0x1a54,
+	0x1b05, 0x1b33,
+	0x1b45, 0x1b4b,
+	0x1b83, 0x1ba0,
+	0x1bae, 0x1baf,
+	0x1bba, 0x1be5,
+	0x1c00, 0x1c23,
+	0x1c4d, 0x1c4f,
+	0x1c5a, 0x1c77,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf1,
+	0x1cf5, 0x1cf6,
+	0x2135, 0x2138,
+	0x2d30, 0x2d67,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x3006, 0x3006,
+	0x303c, 0x303c,
+	0x3041, 0x3096,
+	0x309f, 0x309f,
+	0x30a1, 0x30fa,
+	0x30ff, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa014,
+	0xa016, 0xa48c,
+	0xa4d0, 0xa4f7,
+	0xa500, 0xa60b,
+	0xa610, 0xa61f,
+	0xa62a, 0xa62b,
+	0xa66e, 0xa66e,
+	0xa6a0, 0xa6e5,
+	0xa7f7, 0xa7f7,
+	0xa7fb, 0xa801,
+	0xa803, 0xa805,
+	0xa807, 0xa80a,
+	0xa80c, 0xa822,
+	0xa840, 0xa873,
+	0xa882, 0xa8b3,
+	0xa8f2, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa90a, 0xa925,
+	0xa930, 0xa946,
+	0xa960, 0xa97c,
+	0xa984, 0xa9b2,
+	0xa9e0, 0xa9e4,
+	0xa9e7, 0xa9ef,
+	0xa9fa, 0xa9fe,
+	0xaa00, 0xaa28,
+	0xaa40, 0xaa42,
+	0xaa44, 0xaa4b,
+	0xaa60, 0xaa6f,
+	0xaa71, 0xaa76,
+	0xaa7a, 0xaa7a,
+	0xaa7e, 0xaaaf,
+	0xaab1, 0xaab1,
+	0xaab5, 0xaab6,
+	0xaab9, 0xaabd,
+	0xaac0, 0xaac0,
+	0xaac2, 0xaac2,
+	0xaadb, 0xaadc,
+	0xaae0, 0xaaea,
+	0xaaf2, 0xaaf2,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xabc0, 0xabe2,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb1d, 0xfb1d,
+	0xfb1f, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff66, 0xff6f,
+	0xff71, 0xff9d,
+	0xffa0, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031f,
+	0x10330, 0x10340,
+	0x10342, 0x10349,
+	0x10350, 0x10375,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x10450, 0x1049d,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a00,
+	0x10a10, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae4,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11003, 0x11037,
+	0x11083, 0x110af,
+	0x110d0, 0x110e8,
+	0x11103, 0x11126,
+	0x11150, 0x11172,
+	0x11176, 0x11176,
+	0x11183, 0x111b2,
+	0x111c1, 0x111c4,
+	0x111da, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x1122b,
+	0x112b0, 0x112de,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133d, 0x1133d,
+	0x1135d, 0x11361,
+	0x11480, 0x114af,
+	0x114c4, 0x114c5,
+	0x114c7, 0x114c7,
+	0x11580, 0x115ae,
+	0x11600, 0x1162f,
+	0x11644, 0x11644,
+	0x11680, 0x116aa,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16ad0, 0x16aed,
+	0x16b00, 0x16b2f,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f50,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1e800, 0x1e8c4,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_Lo */
+
+/* 'Lt': General Category */
+static const OnigCodePoint CR_Lt[] = {
+	10,
+	0x01c5, 0x01c5,
+	0x01c8, 0x01c8,
+	0x01cb, 0x01cb,
+	0x01f2, 0x01f2,
+	0x1f88, 0x1f8f,
+	0x1f98, 0x1f9f,
+	0x1fa8, 0x1faf,
+	0x1fbc, 0x1fbc,
+	0x1fcc, 0x1fcc,
+	0x1ffc, 0x1ffc,
+}; /* CR_Lt */
+
+/* 'Lu': General Category */
+static const OnigCodePoint CR_Lu[] = {
+	622,
+	0x0041, 0x005a,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00de,
+	0x0100, 0x0100,
+	0x0102, 0x0102,
+	0x0104, 0x0104,
+	0x0106, 0x0106,
+	0x0108, 0x0108,
+	0x010a, 0x010a,
+	0x010c, 0x010c,
+	0x010e, 0x010e,
+	0x0110, 0x0110,
+	0x0112, 0x0112,
+	0x0114, 0x0114,
+	0x0116, 0x0116,
+	0x0118, 0x0118,
+	0x011a, 0x011a,
+	0x011c, 0x011c,
+	0x011e, 0x011e,
+	0x0120, 0x0120,
+	0x0122, 0x0122,
+	0x0124, 0x0124,
+	0x0126, 0x0126,
+	0x0128, 0x0128,
+	0x012a, 0x012a,
+	0x012c, 0x012c,
+	0x012e, 0x012e,
+	0x0130, 0x0130,
+	0x0132, 0x0132,
+	0x0134, 0x0134,
+	0x0136, 0x0136,
+	0x0139, 0x0139,
+	0x013b, 0x013b,
+	0x013d, 0x013d,
+	0x013f, 0x013f,
+	0x0141, 0x0141,
+	0x0143, 0x0143,
+	0x0145, 0x0145,
+	0x0147, 0x0147,
+	0x014a, 0x014a,
+	0x014c, 0x014c,
+	0x014e, 0x014e,
+	0x0150, 0x0150,
+	0x0152, 0x0152,
+	0x0154, 0x0154,
+	0x0156, 0x0156,
+	0x0158, 0x0158,
+	0x015a, 0x015a,
+	0x015c, 0x015c,
+	0x015e, 0x015e,
+	0x0160, 0x0160,
+	0x0162, 0x0162,
+	0x0164, 0x0164,
+	0x0166, 0x0166,
+	0x0168, 0x0168,
+	0x016a, 0x016a,
+	0x016c, 0x016c,
+	0x016e, 0x016e,
+	0x0170, 0x0170,
+	0x0172, 0x0172,
+	0x0174, 0x0174,
+	0x0176, 0x0176,
+	0x0178, 0x0179,
+	0x017b, 0x017b,
+	0x017d, 0x017d,
+	0x0181, 0x0182,
+	0x0184, 0x0184,
+	0x0186, 0x0187,
+	0x0189, 0x018b,
+	0x018e, 0x0191,
+	0x0193, 0x0194,
+	0x0196, 0x0198,
+	0x019c, 0x019d,
+	0x019f, 0x01a0,
+	0x01a2, 0x01a2,
+	0x01a4, 0x01a4,
+	0x01a6, 0x01a7,
+	0x01a9, 0x01a9,
+	0x01ac, 0x01ac,
+	0x01ae, 0x01af,
+	0x01b1, 0x01b3,
+	0x01b5, 0x01b5,
+	0x01b7, 0x01b8,
+	0x01bc, 0x01bc,
+	0x01c4, 0x01c4,
+	0x01c7, 0x01c7,
+	0x01ca, 0x01ca,
+	0x01cd, 0x01cd,
+	0x01cf, 0x01cf,
+	0x01d1, 0x01d1,
+	0x01d3, 0x01d3,
+	0x01d5, 0x01d5,
+	0x01d7, 0x01d7,
+	0x01d9, 0x01d9,
+	0x01db, 0x01db,
+	0x01de, 0x01de,
+	0x01e0, 0x01e0,
+	0x01e2, 0x01e2,
+	0x01e4, 0x01e4,
+	0x01e6, 0x01e6,
+	0x01e8, 0x01e8,
+	0x01ea, 0x01ea,
+	0x01ec, 0x01ec,
+	0x01ee, 0x01ee,
+	0x01f1, 0x01f1,
+	0x01f4, 0x01f4,
+	0x01f6, 0x01f8,
+	0x01fa, 0x01fa,
+	0x01fc, 0x01fc,
+	0x01fe, 0x01fe,
+	0x0200, 0x0200,
+	0x0202, 0x0202,
+	0x0204, 0x0204,
+	0x0206, 0x0206,
+	0x0208, 0x0208,
+	0x020a, 0x020a,
+	0x020c, 0x020c,
+	0x020e, 0x020e,
+	0x0210, 0x0210,
+	0x0212, 0x0212,
+	0x0214, 0x0214,
+	0x0216, 0x0216,
+	0x0218, 0x0218,
+	0x021a, 0x021a,
+	0x021c, 0x021c,
+	0x021e, 0x021e,
+	0x0220, 0x0220,
+	0x0222, 0x0222,
+	0x0224, 0x0224,
+	0x0226, 0x0226,
+	0x0228, 0x0228,
+	0x022a, 0x022a,
+	0x022c, 0x022c,
+	0x022e, 0x022e,
+	0x0230, 0x0230,
+	0x0232, 0x0232,
+	0x023a, 0x023b,
+	0x023d, 0x023e,
+	0x0241, 0x0241,
+	0x0243, 0x0246,
+	0x0248, 0x0248,
+	0x024a, 0x024a,
+	0x024c, 0x024c,
+	0x024e, 0x024e,
+	0x0370, 0x0370,
+	0x0372, 0x0372,
+	0x0376, 0x0376,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x038f,
+	0x0391, 0x03a1,
+	0x03a3, 0x03ab,
+	0x03cf, 0x03cf,
+	0x03d2, 0x03d4,
+	0x03d8, 0x03d8,
+	0x03da, 0x03da,
+	0x03dc, 0x03dc,
+	0x03de, 0x03de,
+	0x03e0, 0x03e0,
+	0x03e2, 0x03e2,
+	0x03e4, 0x03e4,
+	0x03e6, 0x03e6,
+	0x03e8, 0x03e8,
+	0x03ea, 0x03ea,
+	0x03ec, 0x03ec,
+	0x03ee, 0x03ee,
+	0x03f4, 0x03f4,
+	0x03f7, 0x03f7,
+	0x03f9, 0x03fa,
+	0x03fd, 0x042f,
+	0x0460, 0x0460,
+	0x0462, 0x0462,
+	0x0464, 0x0464,
+	0x0466, 0x0466,
+	0x0468, 0x0468,
+	0x046a, 0x046a,
+	0x046c, 0x046c,
+	0x046e, 0x046e,
+	0x0470, 0x0470,
+	0x0472, 0x0472,
+	0x0474, 0x0474,
+	0x0476, 0x0476,
+	0x0478, 0x0478,
+	0x047a, 0x047a,
+	0x047c, 0x047c,
+	0x047e, 0x047e,
+	0x0480, 0x0480,
+	0x048a, 0x048a,
+	0x048c, 0x048c,
+	0x048e, 0x048e,
+	0x0490, 0x0490,
+	0x0492, 0x0492,
+	0x0494, 0x0494,
+	0x0496, 0x0496,
+	0x0498, 0x0498,
+	0x049a, 0x049a,
+	0x049c, 0x049c,
+	0x049e, 0x049e,
+	0x04a0, 0x04a0,
+	0x04a2, 0x04a2,
+	0x04a4, 0x04a4,
+	0x04a6, 0x04a6,
+	0x04a8, 0x04a8,
+	0x04aa, 0x04aa,
+	0x04ac, 0x04ac,
+	0x04ae, 0x04ae,
+	0x04b0, 0x04b0,
+	0x04b2, 0x04b2,
+	0x04b4, 0x04b4,
+	0x04b6, 0x04b6,
+	0x04b8, 0x04b8,
+	0x04ba, 0x04ba,
+	0x04bc, 0x04bc,
+	0x04be, 0x04be,
+	0x04c0, 0x04c1,
+	0x04c3, 0x04c3,
+	0x04c5, 0x04c5,
+	0x04c7, 0x04c7,
+	0x04c9, 0x04c9,
+	0x04cb, 0x04cb,
+	0x04cd, 0x04cd,
+	0x04d0, 0x04d0,
+	0x04d2, 0x04d2,
+	0x04d4, 0x04d4,
+	0x04d6, 0x04d6,
+	0x04d8, 0x04d8,
+	0x04da, 0x04da,
+	0x04dc, 0x04dc,
+	0x04de, 0x04de,
+	0x04e0, 0x04e0,
+	0x04e2, 0x04e2,
+	0x04e4, 0x04e4,
+	0x04e6, 0x04e6,
+	0x04e8, 0x04e8,
+	0x04ea, 0x04ea,
+	0x04ec, 0x04ec,
+	0x04ee, 0x04ee,
+	0x04f0, 0x04f0,
+	0x04f2, 0x04f2,
+	0x04f4, 0x04f4,
+	0x04f6, 0x04f6,
+	0x04f8, 0x04f8,
+	0x04fa, 0x04fa,
+	0x04fc, 0x04fc,
+	0x04fe, 0x04fe,
+	0x0500, 0x0500,
+	0x0502, 0x0502,
+	0x0504, 0x0504,
+	0x0506, 0x0506,
+	0x0508, 0x0508,
+	0x050a, 0x050a,
+	0x050c, 0x050c,
+	0x050e, 0x050e,
+	0x0510, 0x0510,
+	0x0512, 0x0512,
+	0x0514, 0x0514,
+	0x0516, 0x0516,
+	0x0518, 0x0518,
+	0x051a, 0x051a,
+	0x051c, 0x051c,
+	0x051e, 0x051e,
+	0x0520, 0x0520,
+	0x0522, 0x0522,
+	0x0524, 0x0524,
+	0x0526, 0x0526,
+	0x0528, 0x0528,
+	0x052a, 0x052a,
+	0x052c, 0x052c,
+	0x052e, 0x052e,
+	0x0531, 0x0556,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x1e00, 0x1e00,
+	0x1e02, 0x1e02,
+	0x1e04, 0x1e04,
+	0x1e06, 0x1e06,
+	0x1e08, 0x1e08,
+	0x1e0a, 0x1e0a,
+	0x1e0c, 0x1e0c,
+	0x1e0e, 0x1e0e,
+	0x1e10, 0x1e10,
+	0x1e12, 0x1e12,
+	0x1e14, 0x1e14,
+	0x1e16, 0x1e16,
+	0x1e18, 0x1e18,
+	0x1e1a, 0x1e1a,
+	0x1e1c, 0x1e1c,
+	0x1e1e, 0x1e1e,
+	0x1e20, 0x1e20,
+	0x1e22, 0x1e22,
+	0x1e24, 0x1e24,
+	0x1e26, 0x1e26,
+	0x1e28, 0x1e28,
+	0x1e2a, 0x1e2a,
+	0x1e2c, 0x1e2c,
+	0x1e2e, 0x1e2e,
+	0x1e30, 0x1e30,
+	0x1e32, 0x1e32,
+	0x1e34, 0x1e34,
+	0x1e36, 0x1e36,
+	0x1e38, 0x1e38,
+	0x1e3a, 0x1e3a,
+	0x1e3c, 0x1e3c,
+	0x1e3e, 0x1e3e,
+	0x1e40, 0x1e40,
+	0x1e42, 0x1e42,
+	0x1e44, 0x1e44,
+	0x1e46, 0x1e46,
+	0x1e48, 0x1e48,
+	0x1e4a, 0x1e4a,
+	0x1e4c, 0x1e4c,
+	0x1e4e, 0x1e4e,
+	0x1e50, 0x1e50,
+	0x1e52, 0x1e52,
+	0x1e54, 0x1e54,
+	0x1e56, 0x1e56,
+	0x1e58, 0x1e58,
+	0x1e5a, 0x1e5a,
+	0x1e5c, 0x1e5c,
+	0x1e5e, 0x1e5e,
+	0x1e60, 0x1e60,
+	0x1e62, 0x1e62,
+	0x1e64, 0x1e64,
+	0x1e66, 0x1e66,
+	0x1e68, 0x1e68,
+	0x1e6a, 0x1e6a,
+	0x1e6c, 0x1e6c,
+	0x1e6e, 0x1e6e,
+	0x1e70, 0x1e70,
+	0x1e72, 0x1e72,
+	0x1e74, 0x1e74,
+	0x1e76, 0x1e76,
+	0x1e78, 0x1e78,
+	0x1e7a, 0x1e7a,
+	0x1e7c, 0x1e7c,
+	0x1e7e, 0x1e7e,
+	0x1e80, 0x1e80,
+	0x1e82, 0x1e82,
+	0x1e84, 0x1e84,
+	0x1e86, 0x1e86,
+	0x1e88, 0x1e88,
+	0x1e8a, 0x1e8a,
+	0x1e8c, 0x1e8c,
+	0x1e8e, 0x1e8e,
+	0x1e90, 0x1e90,
+	0x1e92, 0x1e92,
+	0x1e94, 0x1e94,
+	0x1e9e, 0x1e9e,
+	0x1ea0, 0x1ea0,
+	0x1ea2, 0x1ea2,
+	0x1ea4, 0x1ea4,
+	0x1ea6, 0x1ea6,
+	0x1ea8, 0x1ea8,
+	0x1eaa, 0x1eaa,
+	0x1eac, 0x1eac,
+	0x1eae, 0x1eae,
+	0x1eb0, 0x1eb0,
+	0x1eb2, 0x1eb2,
+	0x1eb4, 0x1eb4,
+	0x1eb6, 0x1eb6,
+	0x1eb8, 0x1eb8,
+	0x1eba, 0x1eba,
+	0x1ebc, 0x1ebc,
+	0x1ebe, 0x1ebe,
+	0x1ec0, 0x1ec0,
+	0x1ec2, 0x1ec2,
+	0x1ec4, 0x1ec4,
+	0x1ec6, 0x1ec6,
+	0x1ec8, 0x1ec8,
+	0x1eca, 0x1eca,
+	0x1ecc, 0x1ecc,
+	0x1ece, 0x1ece,
+	0x1ed0, 0x1ed0,
+	0x1ed2, 0x1ed2,
+	0x1ed4, 0x1ed4,
+	0x1ed6, 0x1ed6,
+	0x1ed8, 0x1ed8,
+	0x1eda, 0x1eda,
+	0x1edc, 0x1edc,
+	0x1ede, 0x1ede,
+	0x1ee0, 0x1ee0,
+	0x1ee2, 0x1ee2,
+	0x1ee4, 0x1ee4,
+	0x1ee6, 0x1ee6,
+	0x1ee8, 0x1ee8,
+	0x1eea, 0x1eea,
+	0x1eec, 0x1eec,
+	0x1eee, 0x1eee,
+	0x1ef0, 0x1ef0,
+	0x1ef2, 0x1ef2,
+	0x1ef4, 0x1ef4,
+	0x1ef6, 0x1ef6,
+	0x1ef8, 0x1ef8,
+	0x1efa, 0x1efa,
+	0x1efc, 0x1efc,
+	0x1efe, 0x1efe,
+	0x1f08, 0x1f0f,
+	0x1f18, 0x1f1d,
+	0x1f28, 0x1f2f,
+	0x1f38, 0x1f3f,
+	0x1f48, 0x1f4d,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f5f,
+	0x1f68, 0x1f6f,
+	0x1fb8, 0x1fbb,
+	0x1fc8, 0x1fcb,
+	0x1fd8, 0x1fdb,
+	0x1fe8, 0x1fec,
+	0x1ff8, 0x1ffb,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210b, 0x210d,
+	0x2110, 0x2112,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x2130, 0x2133,
+	0x213e, 0x213f,
+	0x2145, 0x2145,
+	0x2183, 0x2183,
+	0x2c00, 0x2c2e,
+	0x2c60, 0x2c60,
+	0x2c62, 0x2c64,
+	0x2c67, 0x2c67,
+	0x2c69, 0x2c69,
+	0x2c6b, 0x2c6b,
+	0x2c6d, 0x2c70,
+	0x2c72, 0x2c72,
+	0x2c75, 0x2c75,
+	0x2c7e, 0x2c80,
+	0x2c82, 0x2c82,
+	0x2c84, 0x2c84,
+	0x2c86, 0x2c86,
+	0x2c88, 0x2c88,
+	0x2c8a, 0x2c8a,
+	0x2c8c, 0x2c8c,
+	0x2c8e, 0x2c8e,
+	0x2c90, 0x2c90,
+	0x2c92, 0x2c92,
+	0x2c94, 0x2c94,
+	0x2c96, 0x2c96,
+	0x2c98, 0x2c98,
+	0x2c9a, 0x2c9a,
+	0x2c9c, 0x2c9c,
+	0x2c9e, 0x2c9e,
+	0x2ca0, 0x2ca0,
+	0x2ca2, 0x2ca2,
+	0x2ca4, 0x2ca4,
+	0x2ca6, 0x2ca6,
+	0x2ca8, 0x2ca8,
+	0x2caa, 0x2caa,
+	0x2cac, 0x2cac,
+	0x2cae, 0x2cae,
+	0x2cb0, 0x2cb0,
+	0x2cb2, 0x2cb2,
+	0x2cb4, 0x2cb4,
+	0x2cb6, 0x2cb6,
+	0x2cb8, 0x2cb8,
+	0x2cba, 0x2cba,
+	0x2cbc, 0x2cbc,
+	0x2cbe, 0x2cbe,
+	0x2cc0, 0x2cc0,
+	0x2cc2, 0x2cc2,
+	0x2cc4, 0x2cc4,
+	0x2cc6, 0x2cc6,
+	0x2cc8, 0x2cc8,
+	0x2cca, 0x2cca,
+	0x2ccc, 0x2ccc,
+	0x2cce, 0x2cce,
+	0x2cd0, 0x2cd0,
+	0x2cd2, 0x2cd2,
+	0x2cd4, 0x2cd4,
+	0x2cd6, 0x2cd6,
+	0x2cd8, 0x2cd8,
+	0x2cda, 0x2cda,
+	0x2cdc, 0x2cdc,
+	0x2cde, 0x2cde,
+	0x2ce0, 0x2ce0,
+	0x2ce2, 0x2ce2,
+	0x2ceb, 0x2ceb,
+	0x2ced, 0x2ced,
+	0x2cf2, 0x2cf2,
+	0xa640, 0xa640,
+	0xa642, 0xa642,
+	0xa644, 0xa644,
+	0xa646, 0xa646,
+	0xa648, 0xa648,
+	0xa64a, 0xa64a,
+	0xa64c, 0xa64c,
+	0xa64e, 0xa64e,
+	0xa650, 0xa650,
+	0xa652, 0xa652,
+	0xa654, 0xa654,
+	0xa656, 0xa656,
+	0xa658, 0xa658,
+	0xa65a, 0xa65a,
+	0xa65c, 0xa65c,
+	0xa65e, 0xa65e,
+	0xa660, 0xa660,
+	0xa662, 0xa662,
+	0xa664, 0xa664,
+	0xa666, 0xa666,
+	0xa668, 0xa668,
+	0xa66a, 0xa66a,
+	0xa66c, 0xa66c,
+	0xa680, 0xa680,
+	0xa682, 0xa682,
+	0xa684, 0xa684,
+	0xa686, 0xa686,
+	0xa688, 0xa688,
+	0xa68a, 0xa68a,
+	0xa68c, 0xa68c,
+	0xa68e, 0xa68e,
+	0xa690, 0xa690,
+	0xa692, 0xa692,
+	0xa694, 0xa694,
+	0xa696, 0xa696,
+	0xa698, 0xa698,
+	0xa69a, 0xa69a,
+	0xa722, 0xa722,
+	0xa724, 0xa724,
+	0xa726, 0xa726,
+	0xa728, 0xa728,
+	0xa72a, 0xa72a,
+	0xa72c, 0xa72c,
+	0xa72e, 0xa72e,
+	0xa732, 0xa732,
+	0xa734, 0xa734,
+	0xa736, 0xa736,
+	0xa738, 0xa738,
+	0xa73a, 0xa73a,
+	0xa73c, 0xa73c,
+	0xa73e, 0xa73e,
+	0xa740, 0xa740,
+	0xa742, 0xa742,
+	0xa744, 0xa744,
+	0xa746, 0xa746,
+	0xa748, 0xa748,
+	0xa74a, 0xa74a,
+	0xa74c, 0xa74c,
+	0xa74e, 0xa74e,
+	0xa750, 0xa750,
+	0xa752, 0xa752,
+	0xa754, 0xa754,
+	0xa756, 0xa756,
+	0xa758, 0xa758,
+	0xa75a, 0xa75a,
+	0xa75c, 0xa75c,
+	0xa75e, 0xa75e,
+	0xa760, 0xa760,
+	0xa762, 0xa762,
+	0xa764, 0xa764,
+	0xa766, 0xa766,
+	0xa768, 0xa768,
+	0xa76a, 0xa76a,
+	0xa76c, 0xa76c,
+	0xa76e, 0xa76e,
+	0xa779, 0xa779,
+	0xa77b, 0xa77b,
+	0xa77d, 0xa77e,
+	0xa780, 0xa780,
+	0xa782, 0xa782,
+	0xa784, 0xa784,
+	0xa786, 0xa786,
+	0xa78b, 0xa78b,
+	0xa78d, 0xa78d,
+	0xa790, 0xa790,
+	0xa792, 0xa792,
+	0xa796, 0xa796,
+	0xa798, 0xa798,
+	0xa79a, 0xa79a,
+	0xa79c, 0xa79c,
+	0xa79e, 0xa79e,
+	0xa7a0, 0xa7a0,
+	0xa7a2, 0xa7a2,
+	0xa7a4, 0xa7a4,
+	0xa7a6, 0xa7a6,
+	0xa7a8, 0xa7a8,
+	0xa7aa, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xff21, 0xff3a,
+	0x10400, 0x10427,
+	0x118a0, 0x118bf,
+	0x1d400, 0x1d419,
+	0x1d434, 0x1d44d,
+	0x1d468, 0x1d481,
+	0x1d49c, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b5,
+	0x1d4d0, 0x1d4e9,
+	0x1d504, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d538, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d56c, 0x1d585,
+	0x1d5a0, 0x1d5b9,
+	0x1d5d4, 0x1d5ed,
+	0x1d608, 0x1d621,
+	0x1d63c, 0x1d655,
+	0x1d670, 0x1d689,
+	0x1d6a8, 0x1d6c0,
+	0x1d6e2, 0x1d6fa,
+	0x1d71c, 0x1d734,
+	0x1d756, 0x1d76e,
+	0x1d790, 0x1d7a8,
+	0x1d7ca, 0x1d7ca,
+}; /* CR_Lu */
+
+/* 'M': Major Category */
+static const OnigCodePoint CR_M[] = {
+	229,
+	0x0300, 0x036f,
+	0x0483, 0x0489,
+	0x0591, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x0610, 0x061a,
+	0x064b, 0x065f,
+	0x0670, 0x0670,
+	0x06d6, 0x06dc,
+	0x06df, 0x06e4,
+	0x06e7, 0x06e8,
+	0x06ea, 0x06ed,
+	0x0711, 0x0711,
+	0x0730, 0x074a,
+	0x07a6, 0x07b0,
+	0x07eb, 0x07f3,
+	0x0816, 0x0819,
+	0x081b, 0x0823,
+	0x0825, 0x0827,
+	0x0829, 0x082d,
+	0x0859, 0x085b,
+	0x08e4, 0x0903,
+	0x093a, 0x093c,
+	0x093e, 0x094f,
+	0x0951, 0x0957,
+	0x0962, 0x0963,
+	0x0981, 0x0983,
+	0x09bc, 0x09bc,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09e2, 0x09e3,
+	0x0a01, 0x0a03,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a70, 0x0a71,
+	0x0a75, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0abc, 0x0abc,
+	0x0abe, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ae2, 0x0ae3,
+	0x0b01, 0x0b03,
+	0x0b3c, 0x0b3c,
+	0x0b3e, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b62, 0x0b63,
+	0x0b82, 0x0b82,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0c00, 0x0c03,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c62, 0x0c63,
+	0x0c81, 0x0c83,
+	0x0cbc, 0x0cbc,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0ce2, 0x0ce3,
+	0x0d01, 0x0d03,
+	0x0d3e, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d62, 0x0d63,
+	0x0d82, 0x0d83,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df3,
+	0x0e31, 0x0e31,
+	0x0e34, 0x0e3a,
+	0x0e47, 0x0e4e,
+	0x0eb1, 0x0eb1,
+	0x0eb4, 0x0eb9,
+	0x0ebb, 0x0ebc,
+	0x0ec8, 0x0ecd,
+	0x0f18, 0x0f19,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f3e, 0x0f3f,
+	0x0f71, 0x0f84,
+	0x0f86, 0x0f87,
+	0x0f8d, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fc6, 0x0fc6,
+	0x102b, 0x103e,
+	0x1056, 0x1059,
+	0x105e, 0x1060,
+	0x1062, 0x1064,
+	0x1067, 0x106d,
+	0x1071, 0x1074,
+	0x1082, 0x108d,
+	0x108f, 0x108f,
+	0x109a, 0x109d,
+	0x135d, 0x135f,
+	0x1712, 0x1714,
+	0x1732, 0x1734,
+	0x1752, 0x1753,
+	0x1772, 0x1773,
+	0x17b4, 0x17d3,
+	0x17dd, 0x17dd,
+	0x180b, 0x180d,
+	0x18a9, 0x18a9,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x19b0, 0x19c0,
+	0x19c8, 0x19c9,
+	0x1a17, 0x1a1b,
+	0x1a55, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a7f,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b04,
+	0x1b34, 0x1b44,
+	0x1b6b, 0x1b73,
+	0x1b80, 0x1b82,
+	0x1ba1, 0x1bad,
+	0x1be6, 0x1bf3,
+	0x1c24, 0x1c37,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1ce8,
+	0x1ced, 0x1ced,
+	0x1cf2, 0x1cf4,
+	0x1cf8, 0x1cf9,
+	0x1dc0, 0x1df5,
+	0x1dfc, 0x1dff,
+	0x20d0, 0x20f0,
+	0x2cef, 0x2cf1,
+	0x2d7f, 0x2d7f,
+	0x2de0, 0x2dff,
+	0x302a, 0x302f,
+	0x3099, 0x309a,
+	0xa66f, 0xa672,
+	0xa674, 0xa67d,
+	0xa69f, 0xa69f,
+	0xa6f0, 0xa6f1,
+	0xa802, 0xa802,
+	0xa806, 0xa806,
+	0xa80b, 0xa80b,
+	0xa823, 0xa827,
+	0xa880, 0xa881,
+	0xa8b4, 0xa8c4,
+	0xa8e0, 0xa8f1,
+	0xa926, 0xa92d,
+	0xa947, 0xa953,
+	0xa980, 0xa983,
+	0xa9b3, 0xa9c0,
+	0xa9e5, 0xa9e5,
+	0xaa29, 0xaa36,
+	0xaa43, 0xaa43,
+	0xaa4c, 0xaa4d,
+	0xaa7b, 0xaa7d,
+	0xaab0, 0xaab0,
+	0xaab2, 0xaab4,
+	0xaab7, 0xaab8,
+	0xaabe, 0xaabf,
+	0xaac1, 0xaac1,
+	0xaaeb, 0xaaef,
+	0xaaf5, 0xaaf6,
+	0xabe3, 0xabea,
+	0xabec, 0xabed,
+	0xfb1e, 0xfb1e,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe2d,
+	0x101fd, 0x101fd,
+	0x102e0, 0x102e0,
+	0x10376, 0x1037a,
+	0x10a01, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a0f,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a3f,
+	0x10ae5, 0x10ae6,
+	0x11000, 0x11002,
+	0x11038, 0x11046,
+	0x1107f, 0x11082,
+	0x110b0, 0x110ba,
+	0x11100, 0x11102,
+	0x11127, 0x11134,
+	0x11173, 0x11173,
+	0x11180, 0x11182,
+	0x111b3, 0x111c0,
+	0x1122c, 0x11237,
+	0x112df, 0x112ea,
+	0x11301, 0x11303,
+	0x1133c, 0x1133c,
+	0x1133e, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x11362, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x114b0, 0x114c3,
+	0x115af, 0x115b5,
+	0x115b8, 0x115c0,
+	0x11630, 0x11640,
+	0x116ab, 0x116b7,
+	0x16af0, 0x16af4,
+	0x16b30, 0x16b36,
+	0x16f51, 0x16f7e,
+	0x16f8f, 0x16f92,
+	0x1bc9d, 0x1bc9e,
+	0x1d165, 0x1d169,
+	0x1d16d, 0x1d172,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1d242, 0x1d244,
+	0x1e8d0, 0x1e8d6,
+	0xe0100, 0xe01ef,
+}; /* CR_M */
+
+/* 'Mc': General Category */
+static const OnigCodePoint CR_Mc[] = {
+	147,
+	0x0903, 0x0903,
+	0x093b, 0x093b,
+	0x093e, 0x0940,
+	0x0949, 0x094c,
+	0x094e, 0x094f,
+	0x0982, 0x0983,
+	0x09be, 0x09c0,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cc,
+	0x09d7, 0x09d7,
+	0x0a03, 0x0a03,
+	0x0a3e, 0x0a40,
+	0x0a83, 0x0a83,
+	0x0abe, 0x0ac0,
+	0x0ac9, 0x0ac9,
+	0x0acb, 0x0acc,
+	0x0b02, 0x0b03,
+	0x0b3e, 0x0b3e,
+	0x0b40, 0x0b40,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4c,
+	0x0b57, 0x0b57,
+	0x0bbe, 0x0bbf,
+	0x0bc1, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcc,
+	0x0bd7, 0x0bd7,
+	0x0c01, 0x0c03,
+	0x0c41, 0x0c44,
+	0x0c82, 0x0c83,
+	0x0cbe, 0x0cbe,
+	0x0cc0, 0x0cc4,
+	0x0cc7, 0x0cc8,
+	0x0cca, 0x0ccb,
+	0x0cd5, 0x0cd6,
+	0x0d02, 0x0d03,
+	0x0d3e, 0x0d40,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4c,
+	0x0d57, 0x0d57,
+	0x0d82, 0x0d83,
+	0x0dcf, 0x0dd1,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df3,
+	0x0f3e, 0x0f3f,
+	0x0f7f, 0x0f7f,
+	0x102b, 0x102c,
+	0x1031, 0x1031,
+	0x1038, 0x1038,
+	0x103b, 0x103c,
+	0x1056, 0x1057,
+	0x1062, 0x1064,
+	0x1067, 0x106d,
+	0x1083, 0x1084,
+	0x1087, 0x108c,
+	0x108f, 0x108f,
+	0x109a, 0x109c,
+	0x17b6, 0x17b6,
+	0x17be, 0x17c5,
+	0x17c7, 0x17c8,
+	0x1923, 0x1926,
+	0x1929, 0x192b,
+	0x1930, 0x1931,
+	0x1933, 0x1938,
+	0x19b0, 0x19c0,
+	0x19c8, 0x19c9,
+	0x1a19, 0x1a1a,
+	0x1a55, 0x1a55,
+	0x1a57, 0x1a57,
+	0x1a61, 0x1a61,
+	0x1a63, 0x1a64,
+	0x1a6d, 0x1a72,
+	0x1b04, 0x1b04,
+	0x1b35, 0x1b35,
+	0x1b3b, 0x1b3b,
+	0x1b3d, 0x1b41,
+	0x1b43, 0x1b44,
+	0x1b82, 0x1b82,
+	0x1ba1, 0x1ba1,
+	0x1ba6, 0x1ba7,
+	0x1baa, 0x1baa,
+	0x1be7, 0x1be7,
+	0x1bea, 0x1bec,
+	0x1bee, 0x1bee,
+	0x1bf2, 0x1bf3,
+	0x1c24, 0x1c2b,
+	0x1c34, 0x1c35,
+	0x1ce1, 0x1ce1,
+	0x1cf2, 0x1cf3,
+	0x302e, 0x302f,
+	0xa823, 0xa824,
+	0xa827, 0xa827,
+	0xa880, 0xa881,
+	0xa8b4, 0xa8c3,
+	0xa952, 0xa953,
+	0xa983, 0xa983,
+	0xa9b4, 0xa9b5,
+	0xa9ba, 0xa9bb,
+	0xa9bd, 0xa9c0,
+	0xaa2f, 0xaa30,
+	0xaa33, 0xaa34,
+	0xaa4d, 0xaa4d,
+	0xaa7b, 0xaa7b,
+	0xaa7d, 0xaa7d,
+	0xaaeb, 0xaaeb,
+	0xaaee, 0xaaef,
+	0xaaf5, 0xaaf5,
+	0xabe3, 0xabe4,
+	0xabe6, 0xabe7,
+	0xabe9, 0xabea,
+	0xabec, 0xabec,
+	0x11000, 0x11000,
+	0x11002, 0x11002,
+	0x11082, 0x11082,
+	0x110b0, 0x110b2,
+	0x110b7, 0x110b8,
+	0x1112c, 0x1112c,
+	0x11182, 0x11182,
+	0x111b3, 0x111b5,
+	0x111bf, 0x111c0,
+	0x1122c, 0x1122e,
+	0x11232, 0x11233,
+	0x11235, 0x11235,
+	0x112e0, 0x112e2,
+	0x11302, 0x11303,
+	0x1133e, 0x1133f,
+	0x11341, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x11362, 0x11363,
+	0x114b0, 0x114b2,
+	0x114b9, 0x114b9,
+	0x114bb, 0x114be,
+	0x114c1, 0x114c1,
+	0x115af, 0x115b1,
+	0x115b8, 0x115bb,
+	0x115be, 0x115be,
+	0x11630, 0x11632,
+	0x1163b, 0x1163c,
+	0x1163e, 0x1163e,
+	0x116ac, 0x116ac,
+	0x116ae, 0x116af,
+	0x116b6, 0x116b6,
+	0x16f51, 0x16f7e,
+	0x1d165, 0x1d166,
+	0x1d16d, 0x1d172,
+}; /* CR_Mc */
+
+/* 'Me': General Category */
+static const OnigCodePoint CR_Me[] = {
+	5,
+	0x0488, 0x0489,
+	0x1abe, 0x1abe,
+	0x20dd, 0x20e0,
+	0x20e2, 0x20e4,
+	0xa670, 0xa672,
+}; /* CR_Me */
+
+/* 'Mn': General Category */
+static const OnigCodePoint CR_Mn[] = {
+	255,
+	0x0300, 0x036f,
+	0x0483, 0x0487,
+	0x0591, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x0610, 0x061a,
+	0x064b, 0x065f,
+	0x0670, 0x0670,
+	0x06d6, 0x06dc,
+	0x06df, 0x06e4,
+	0x06e7, 0x06e8,
+	0x06ea, 0x06ed,
+	0x0711, 0x0711,
+	0x0730, 0x074a,
+	0x07a6, 0x07b0,
+	0x07eb, 0x07f3,
+	0x0816, 0x0819,
+	0x081b, 0x0823,
+	0x0825, 0x0827,
+	0x0829, 0x082d,
+	0x0859, 0x085b,
+	0x08e4, 0x0902,
+	0x093a, 0x093a,
+	0x093c, 0x093c,
+	0x0941, 0x0948,
+	0x094d, 0x094d,
+	0x0951, 0x0957,
+	0x0962, 0x0963,
+	0x0981, 0x0981,
+	0x09bc, 0x09bc,
+	0x09c1, 0x09c4,
+	0x09cd, 0x09cd,
+	0x09e2, 0x09e3,
+	0x0a01, 0x0a02,
+	0x0a3c, 0x0a3c,
+	0x0a41, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a70, 0x0a71,
+	0x0a75, 0x0a75,
+	0x0a81, 0x0a82,
+	0x0abc, 0x0abc,
+	0x0ac1, 0x0ac5,
+	0x0ac7, 0x0ac8,
+	0x0acd, 0x0acd,
+	0x0ae2, 0x0ae3,
+	0x0b01, 0x0b01,
+	0x0b3c, 0x0b3c,
+	0x0b3f, 0x0b3f,
+	0x0b41, 0x0b44,
+	0x0b4d, 0x0b4d,
+	0x0b56, 0x0b56,
+	0x0b62, 0x0b63,
+	0x0b82, 0x0b82,
+	0x0bc0, 0x0bc0,
+	0x0bcd, 0x0bcd,
+	0x0c00, 0x0c00,
+	0x0c3e, 0x0c40,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c62, 0x0c63,
+	0x0c81, 0x0c81,
+	0x0cbc, 0x0cbc,
+	0x0cbf, 0x0cbf,
+	0x0cc6, 0x0cc6,
+	0x0ccc, 0x0ccd,
+	0x0ce2, 0x0ce3,
+	0x0d01, 0x0d01,
+	0x0d41, 0x0d44,
+	0x0d4d, 0x0d4d,
+	0x0d62, 0x0d63,
+	0x0dca, 0x0dca,
+	0x0dd2, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0e31, 0x0e31,
+	0x0e34, 0x0e3a,
+	0x0e47, 0x0e4e,
+	0x0eb1, 0x0eb1,
+	0x0eb4, 0x0eb9,
+	0x0ebb, 0x0ebc,
+	0x0ec8, 0x0ecd,
+	0x0f18, 0x0f19,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f71, 0x0f7e,
+	0x0f80, 0x0f84,
+	0x0f86, 0x0f87,
+	0x0f8d, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fc6, 0x0fc6,
+	0x102d, 0x1030,
+	0x1032, 0x1037,
+	0x1039, 0x103a,
+	0x103d, 0x103e,
+	0x1058, 0x1059,
+	0x105e, 0x1060,
+	0x1071, 0x1074,
+	0x1082, 0x1082,
+	0x1085, 0x1086,
+	0x108d, 0x108d,
+	0x109d, 0x109d,
+	0x135d, 0x135f,
+	0x1712, 0x1714,
+	0x1732, 0x1734,
+	0x1752, 0x1753,
+	0x1772, 0x1773,
+	0x17b4, 0x17b5,
+	0x17b7, 0x17bd,
+	0x17c6, 0x17c6,
+	0x17c9, 0x17d3,
+	0x17dd, 0x17dd,
+	0x180b, 0x180d,
+	0x18a9, 0x18a9,
+	0x1920, 0x1922,
+	0x1927, 0x1928,
+	0x1932, 0x1932,
+	0x1939, 0x193b,
+	0x1a17, 0x1a18,
+	0x1a1b, 0x1a1b,
+	0x1a56, 0x1a56,
+	0x1a58, 0x1a5e,
+	0x1a60, 0x1a60,
+	0x1a62, 0x1a62,
+	0x1a65, 0x1a6c,
+	0x1a73, 0x1a7c,
+	0x1a7f, 0x1a7f,
+	0x1ab0, 0x1abd,
+	0x1b00, 0x1b03,
+	0x1b34, 0x1b34,
+	0x1b36, 0x1b3a,
+	0x1b3c, 0x1b3c,
+	0x1b42, 0x1b42,
+	0x1b6b, 0x1b73,
+	0x1b80, 0x1b81,
+	0x1ba2, 0x1ba5,
+	0x1ba8, 0x1ba9,
+	0x1bab, 0x1bad,
+	0x1be6, 0x1be6,
+	0x1be8, 0x1be9,
+	0x1bed, 0x1bed,
+	0x1bef, 0x1bf1,
+	0x1c2c, 0x1c33,
+	0x1c36, 0x1c37,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1ce0,
+	0x1ce2, 0x1ce8,
+	0x1ced, 0x1ced,
+	0x1cf4, 0x1cf4,
+	0x1cf8, 0x1cf9,
+	0x1dc0, 0x1df5,
+	0x1dfc, 0x1dff,
+	0x20d0, 0x20dc,
+	0x20e1, 0x20e1,
+	0x20e5, 0x20f0,
+	0x2cef, 0x2cf1,
+	0x2d7f, 0x2d7f,
+	0x2de0, 0x2dff,
+	0x302a, 0x302d,
+	0x3099, 0x309a,
+	0xa66f, 0xa66f,
+	0xa674, 0xa67d,
+	0xa69f, 0xa69f,
+	0xa6f0, 0xa6f1,
+	0xa802, 0xa802,
+	0xa806, 0xa806,
+	0xa80b, 0xa80b,
+	0xa825, 0xa826,
+	0xa8c4, 0xa8c4,
+	0xa8e0, 0xa8f1,
+	0xa926, 0xa92d,
+	0xa947, 0xa951,
+	0xa980, 0xa982,
+	0xa9b3, 0xa9b3,
+	0xa9b6, 0xa9b9,
+	0xa9bc, 0xa9bc,
+	0xa9e5, 0xa9e5,
+	0xaa29, 0xaa2e,
+	0xaa31, 0xaa32,
+	0xaa35, 0xaa36,
+	0xaa43, 0xaa43,
+	0xaa4c, 0xaa4c,
+	0xaa7c, 0xaa7c,
+	0xaab0, 0xaab0,
+	0xaab2, 0xaab4,
+	0xaab7, 0xaab8,
+	0xaabe, 0xaabf,
+	0xaac1, 0xaac1,
+	0xaaec, 0xaaed,
+	0xaaf6, 0xaaf6,
+	0xabe5, 0xabe5,
+	0xabe8, 0xabe8,
+	0xabed, 0xabed,
+	0xfb1e, 0xfb1e,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe2d,
+	0x101fd, 0x101fd,
+	0x102e0, 0x102e0,
+	0x10376, 0x1037a,
+	0x10a01, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a0f,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a3f,
+	0x10ae5, 0x10ae6,
+	0x11001, 0x11001,
+	0x11038, 0x11046,
+	0x1107f, 0x11081,
+	0x110b3, 0x110b6,
+	0x110b9, 0x110ba,
+	0x11100, 0x11102,
+	0x11127, 0x1112b,
+	0x1112d, 0x11134,
+	0x11173, 0x11173,
+	0x11180, 0x11181,
+	0x111b6, 0x111be,
+	0x1122f, 0x11231,
+	0x11234, 0x11234,
+	0x11236, 0x11237,
+	0x112df, 0x112df,
+	0x112e3, 0x112ea,
+	0x11301, 0x11301,
+	0x1133c, 0x1133c,
+	0x11340, 0x11340,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x114b3, 0x114b8,
+	0x114ba, 0x114ba,
+	0x114bf, 0x114c0,
+	0x114c2, 0x114c3,
+	0x115b2, 0x115b5,
+	0x115bc, 0x115bd,
+	0x115bf, 0x115c0,
+	0x11633, 0x1163a,
+	0x1163d, 0x1163d,
+	0x1163f, 0x11640,
+	0x116ab, 0x116ab,
+	0x116ad, 0x116ad,
+	0x116b0, 0x116b5,
+	0x116b7, 0x116b7,
+	0x16af0, 0x16af4,
+	0x16b30, 0x16b36,
+	0x16f8f, 0x16f92,
+	0x1bc9d, 0x1bc9e,
+	0x1d167, 0x1d169,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1d242, 0x1d244,
+	0x1e8d0, 0x1e8d6,
+	0xe0100, 0xe01ef,
+}; /* CR_Mn */
+
+/* 'N': Major Category */
+static const OnigCodePoint CR_N[] = {
+	105,
+	0x0030, 0x0039,
+	0x00b2, 0x00b3,
+	0x00b9, 0x00b9,
+	0x00bc, 0x00be,
+	0x0660, 0x0669,
+	0x06f0, 0x06f9,
+	0x07c0, 0x07c9,
+	0x0966, 0x096f,
+	0x09e6, 0x09ef,
+	0x09f4, 0x09f9,
+	0x0a66, 0x0a6f,
+	0x0ae6, 0x0aef,
+	0x0b66, 0x0b6f,
+	0x0b72, 0x0b77,
+	0x0be6, 0x0bf2,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7e,
+	0x0ce6, 0x0cef,
+	0x0d66, 0x0d75,
+	0x0de6, 0x0def,
+	0x0e50, 0x0e59,
+	0x0ed0, 0x0ed9,
+	0x0f20, 0x0f33,
+	0x1040, 0x1049,
+	0x1090, 0x1099,
+	0x1369, 0x137c,
+	0x16ee, 0x16f0,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1810, 0x1819,
+	0x1946, 0x194f,
+	0x19d0, 0x19da,
+	0x1a80, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1b50, 0x1b59,
+	0x1bb0, 0x1bb9,
+	0x1c40, 0x1c49,
+	0x1c50, 0x1c59,
+	0x2070, 0x2070,
+	0x2074, 0x2079,
+	0x2080, 0x2089,
+	0x2150, 0x2182,
+	0x2185, 0x2189,
+	0x2460, 0x249b,
+	0x24ea, 0x24ff,
+	0x2776, 0x2793,
+	0x2cfd, 0x2cfd,
+	0x3007, 0x3007,
+	0x3021, 0x3029,
+	0x3038, 0x303a,
+	0x3192, 0x3195,
+	0x3220, 0x3229,
+	0x3248, 0x324f,
+	0x3251, 0x325f,
+	0x3280, 0x3289,
+	0x32b1, 0x32bf,
+	0xa620, 0xa629,
+	0xa6e6, 0xa6ef,
+	0xa830, 0xa835,
+	0xa8d0, 0xa8d9,
+	0xa900, 0xa909,
+	0xa9d0, 0xa9d9,
+	0xa9f0, 0xa9f9,
+	0xaa50, 0xaa59,
+	0xabf0, 0xabf9,
+	0xff10, 0xff19,
+	0x10107, 0x10133,
+	0x10140, 0x10178,
+	0x1018a, 0x1018b,
+	0x102e1, 0x102fb,
+	0x10320, 0x10323,
+	0x10341, 0x10341,
+	0x1034a, 0x1034a,
+	0x103d1, 0x103d5,
+	0x104a0, 0x104a9,
+	0x10858, 0x1085f,
+	0x10879, 0x1087f,
+	0x108a7, 0x108af,
+	0x10916, 0x1091b,
+	0x10a40, 0x10a47,
+	0x10a7d, 0x10a7e,
+	0x10a9d, 0x10a9f,
+	0x10aeb, 0x10aef,
+	0x10b58, 0x10b5f,
+	0x10b78, 0x10b7f,
+	0x10ba9, 0x10baf,
+	0x10e60, 0x10e7e,
+	0x11052, 0x1106f,
+	0x110f0, 0x110f9,
+	0x11136, 0x1113f,
+	0x111d0, 0x111d9,
+	0x111e1, 0x111f4,
+	0x112f0, 0x112f9,
+	0x114d0, 0x114d9,
+	0x11650, 0x11659,
+	0x116c0, 0x116c9,
+	0x118e0, 0x118f2,
+	0x12400, 0x1246e,
+	0x16a60, 0x16a69,
+	0x16b50, 0x16b59,
+	0x16b5b, 0x16b61,
+	0x1d360, 0x1d371,
+	0x1d7ce, 0x1d7ff,
+	0x1e8c7, 0x1e8cf,
+	0x1f100, 0x1f10c,
+}; /* CR_N */
+
+/* 'Nd': General Category */
+#define CR_Nd CR_Digit
+
+/* 'Nl': General Category */
+static const OnigCodePoint CR_Nl[] = {
+	12,
+	0x16ee, 0x16f0,
+	0x2160, 0x2182,
+	0x2185, 0x2188,
+	0x3007, 0x3007,
+	0x3021, 0x3029,
+	0x3038, 0x303a,
+	0xa6e6, 0xa6ef,
+	0x10140, 0x10174,
+	0x10341, 0x10341,
+	0x1034a, 0x1034a,
+	0x103d1, 0x103d5,
+	0x12400, 0x1246e,
+}; /* CR_Nl */
+
+/* 'No': General Category */
+static const OnigCodePoint CR_No[] = {
+	52,
+	0x00b2, 0x00b3,
+	0x00b9, 0x00b9,
+	0x00bc, 0x00be,
+	0x09f4, 0x09f9,
+	0x0b72, 0x0b77,
+	0x0bf0, 0x0bf2,
+	0x0c78, 0x0c7e,
+	0x0d70, 0x0d75,
+	0x0f2a, 0x0f33,
+	0x1369, 0x137c,
+	0x17f0, 0x17f9,
+	0x19da, 0x19da,
+	0x2070, 0x2070,
+	0x2074, 0x2079,
+	0x2080, 0x2089,
+	0x2150, 0x215f,
+	0x2189, 0x2189,
+	0x2460, 0x249b,
+	0x24ea, 0x24ff,
+	0x2776, 0x2793,
+	0x2cfd, 0x2cfd,
+	0x3192, 0x3195,
+	0x3220, 0x3229,
+	0x3248, 0x324f,
+	0x3251, 0x325f,
+	0x3280, 0x3289,
+	0x32b1, 0x32bf,
+	0xa830, 0xa835,
+	0x10107, 0x10133,
+	0x10175, 0x10178,
+	0x1018a, 0x1018b,
+	0x102e1, 0x102fb,
+	0x10320, 0x10323,
+	0x10858, 0x1085f,
+	0x10879, 0x1087f,
+	0x108a7, 0x108af,
+	0x10916, 0x1091b,
+	0x10a40, 0x10a47,
+	0x10a7d, 0x10a7e,
+	0x10a9d, 0x10a9f,
+	0x10aeb, 0x10aef,
+	0x10b58, 0x10b5f,
+	0x10b78, 0x10b7f,
+	0x10ba9, 0x10baf,
+	0x10e60, 0x10e7e,
+	0x11052, 0x11065,
+	0x111e1, 0x111f4,
+	0x118ea, 0x118f2,
+	0x16b5b, 0x16b61,
+	0x1d360, 0x1d371,
+	0x1e8c7, 0x1e8cf,
+	0x1f100, 0x1f10c,
+}; /* CR_No */
+
+/* 'P': Major Category */
+#define CR_P CR_Punct
+
+/* 'Pc': General Category */
+static const OnigCodePoint CR_Pc[] = {
+	6,
+	0x005f, 0x005f,
+	0x203f, 0x2040,
+	0x2054, 0x2054,
+	0xfe33, 0xfe34,
+	0xfe4d, 0xfe4f,
+	0xff3f, 0xff3f,
+}; /* CR_Pc */
+
+/* 'Pd': General Category */
+static const OnigCodePoint CR_Pd[] = {
+	17,
+	0x002d, 0x002d,
+	0x058a, 0x058a,
+	0x05be, 0x05be,
+	0x1400, 0x1400,
+	0x1806, 0x1806,
+	0x2010, 0x2015,
+	0x2e17, 0x2e17,
+	0x2e1a, 0x2e1a,
+	0x2e3a, 0x2e3b,
+	0x2e40, 0x2e40,
+	0x301c, 0x301c,
+	0x3030, 0x3030,
+	0x30a0, 0x30a0,
+	0xfe31, 0xfe32,
+	0xfe58, 0xfe58,
+	0xfe63, 0xfe63,
+	0xff0d, 0xff0d,
+}; /* CR_Pd */
+
+/* 'Pe': General Category */
+static const OnigCodePoint CR_Pe[] = {
+	72,
+	0x0029, 0x0029,
+	0x005d, 0x005d,
+	0x007d, 0x007d,
+	0x0f3b, 0x0f3b,
+	0x0f3d, 0x0f3d,
+	0x169c, 0x169c,
+	0x2046, 0x2046,
+	0x207e, 0x207e,
+	0x208e, 0x208e,
+	0x2309, 0x2309,
+	0x230b, 0x230b,
+	0x232a, 0x232a,
+	0x2769, 0x2769,
+	0x276b, 0x276b,
+	0x276d, 0x276d,
+	0x276f, 0x276f,
+	0x2771, 0x2771,
+	0x2773, 0x2773,
+	0x2775, 0x2775,
+	0x27c6, 0x27c6,
+	0x27e7, 0x27e7,
+	0x27e9, 0x27e9,
+	0x27eb, 0x27eb,
+	0x27ed, 0x27ed,
+	0x27ef, 0x27ef,
+	0x2984, 0x2984,
+	0x2986, 0x2986,
+	0x2988, 0x2988,
+	0x298a, 0x298a,
+	0x298c, 0x298c,
+	0x298e, 0x298e,
+	0x2990, 0x2990,
+	0x2992, 0x2992,
+	0x2994, 0x2994,
+	0x2996, 0x2996,
+	0x2998, 0x2998,
+	0x29d9, 0x29d9,
+	0x29db, 0x29db,
+	0x29fd, 0x29fd,
+	0x2e23, 0x2e23,
+	0x2e25, 0x2e25,
+	0x2e27, 0x2e27,
+	0x2e29, 0x2e29,
+	0x3009, 0x3009,
+	0x300b, 0x300b,
+	0x300d, 0x300d,
+	0x300f, 0x300f,
+	0x3011, 0x3011,
+	0x3015, 0x3015,
+	0x3017, 0x3017,
+	0x3019, 0x3019,
+	0x301b, 0x301b,
+	0x301e, 0x301f,
+	0xfd3e, 0xfd3e,
+	0xfe18, 0xfe18,
+	0xfe36, 0xfe36,
+	0xfe38, 0xfe38,
+	0xfe3a, 0xfe3a,
+	0xfe3c, 0xfe3c,
+	0xfe3e, 0xfe3e,
+	0xfe40, 0xfe40,
+	0xfe42, 0xfe42,
+	0xfe44, 0xfe44,
+	0xfe48, 0xfe48,
+	0xfe5a, 0xfe5a,
+	0xfe5c, 0xfe5c,
+	0xfe5e, 0xfe5e,
+	0xff09, 0xff09,
+	0xff3d, 0xff3d,
+	0xff5d, 0xff5d,
+	0xff60, 0xff60,
+	0xff63, 0xff63,
+}; /* CR_Pe */
+
+/* 'Pf': General Category */
+static const OnigCodePoint CR_Pf[] = {
+	10,
+	0x00bb, 0x00bb,
+	0x2019, 0x2019,
+	0x201d, 0x201d,
+	0x203a, 0x203a,
+	0x2e03, 0x2e03,
+	0x2e05, 0x2e05,
+	0x2e0a, 0x2e0a,
+	0x2e0d, 0x2e0d,
+	0x2e1d, 0x2e1d,
+	0x2e21, 0x2e21,
+}; /* CR_Pf */
+
+/* 'Pi': General Category */
+static const OnigCodePoint CR_Pi[] = {
+	11,
+	0x00ab, 0x00ab,
+	0x2018, 0x2018,
+	0x201b, 0x201c,
+	0x201f, 0x201f,
+	0x2039, 0x2039,
+	0x2e02, 0x2e02,
+	0x2e04, 0x2e04,
+	0x2e09, 0x2e09,
+	0x2e0c, 0x2e0c,
+	0x2e1c, 0x2e1c,
+	0x2e20, 0x2e20,
+}; /* CR_Pi */
+
+/* 'Po': General Category */
+static const OnigCodePoint CR_Po[] = {
+	151,
+	0x0021, 0x0023,
+	0x0025, 0x0027,
+	0x002a, 0x002a,
+	0x002c, 0x002c,
+	0x002e, 0x002f,
+	0x003a, 0x003b,
+	0x003f, 0x0040,
+	0x005c, 0x005c,
+	0x00a1, 0x00a1,
+	0x00a7, 0x00a7,
+	0x00b6, 0x00b7,
+	0x00bf, 0x00bf,
+	0x037e, 0x037e,
+	0x0387, 0x0387,
+	0x055a, 0x055f,
+	0x0589, 0x0589,
+	0x05c0, 0x05c0,
+	0x05c3, 0x05c3,
+	0x05c6, 0x05c6,
+	0x05f3, 0x05f4,
+	0x0609, 0x060a,
+	0x060c, 0x060d,
+	0x061b, 0x061b,
+	0x061e, 0x061f,
+	0x066a, 0x066d,
+	0x06d4, 0x06d4,
+	0x0700, 0x070d,
+	0x07f7, 0x07f9,
+	0x0830, 0x083e,
+	0x085e, 0x085e,
+	0x0964, 0x0965,
+	0x0970, 0x0970,
+	0x0af0, 0x0af0,
+	0x0df4, 0x0df4,
+	0x0e4f, 0x0e4f,
+	0x0e5a, 0x0e5b,
+	0x0f04, 0x0f12,
+	0x0f14, 0x0f14,
+	0x0f85, 0x0f85,
+	0x0fd0, 0x0fd4,
+	0x0fd9, 0x0fda,
+	0x104a, 0x104f,
+	0x10fb, 0x10fb,
+	0x1360, 0x1368,
+	0x166d, 0x166e,
+	0x16eb, 0x16ed,
+	0x1735, 0x1736,
+	0x17d4, 0x17d6,
+	0x17d8, 0x17da,
+	0x1800, 0x1805,
+	0x1807, 0x180a,
+	0x1944, 0x1945,
+	0x1a1e, 0x1a1f,
+	0x1aa0, 0x1aa6,
+	0x1aa8, 0x1aad,
+	0x1b5a, 0x1b60,
+	0x1bfc, 0x1bff,
+	0x1c3b, 0x1c3f,
+	0x1c7e, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd3, 0x1cd3,
+	0x2016, 0x2017,
+	0x2020, 0x2027,
+	0x2030, 0x2038,
+	0x203b, 0x203e,
+	0x2041, 0x2043,
+	0x2047, 0x2051,
+	0x2053, 0x2053,
+	0x2055, 0x205e,
+	0x2cf9, 0x2cfc,
+	0x2cfe, 0x2cff,
+	0x2d70, 0x2d70,
+	0x2e00, 0x2e01,
+	0x2e06, 0x2e08,
+	0x2e0b, 0x2e0b,
+	0x2e0e, 0x2e16,
+	0x2e18, 0x2e19,
+	0x2e1b, 0x2e1b,
+	0x2e1e, 0x2e1f,
+	0x2e2a, 0x2e2e,
+	0x2e30, 0x2e39,
+	0x2e3c, 0x2e3f,
+	0x2e41, 0x2e41,
+	0x3001, 0x3003,
+	0x303d, 0x303d,
+	0x30fb, 0x30fb,
+	0xa4fe, 0xa4ff,
+	0xa60d, 0xa60f,
+	0xa673, 0xa673,
+	0xa67e, 0xa67e,
+	0xa6f2, 0xa6f7,
+	0xa874, 0xa877,
+	0xa8ce, 0xa8cf,
+	0xa8f8, 0xa8fa,
+	0xa92e, 0xa92f,
+	0xa95f, 0xa95f,
+	0xa9c1, 0xa9cd,
+	0xa9de, 0xa9df,
+	0xaa5c, 0xaa5f,
+	0xaade, 0xaadf,
+	0xaaf0, 0xaaf1,
+	0xabeb, 0xabeb,
+	0xfe10, 0xfe16,
+	0xfe19, 0xfe19,
+	0xfe30, 0xfe30,
+	0xfe45, 0xfe46,
+	0xfe49, 0xfe4c,
+	0xfe50, 0xfe52,
+	0xfe54, 0xfe57,
+	0xfe5f, 0xfe61,
+	0xfe68, 0xfe68,
+	0xfe6a, 0xfe6b,
+	0xff01, 0xff03,
+	0xff05, 0xff07,
+	0xff0a, 0xff0a,
+	0xff0c, 0xff0c,
+	0xff0e, 0xff0f,
+	0xff1a, 0xff1b,
+	0xff1f, 0xff20,
+	0xff3c, 0xff3c,
+	0xff61, 0xff61,
+	0xff64, 0xff65,
+	0x10100, 0x10102,
+	0x1039f, 0x1039f,
+	0x103d0, 0x103d0,
+	0x1056f, 0x1056f,
+	0x10857, 0x10857,
+	0x1091f, 0x1091f,
+	0x1093f, 0x1093f,
+	0x10a50, 0x10a58,
+	0x10a7f, 0x10a7f,
+	0x10af0, 0x10af6,
+	0x10b39, 0x10b3f,
+	0x10b99, 0x10b9c,
+	0x11047, 0x1104d,
+	0x110bb, 0x110bc,
+	0x110be, 0x110c1,
+	0x11140, 0x11143,
+	0x11174, 0x11175,
+	0x111c5, 0x111c8,
+	0x111cd, 0x111cd,
+	0x11238, 0x1123d,
+	0x114c6, 0x114c6,
+	0x115c1, 0x115c9,
+	0x11641, 0x11643,
+	0x12470, 0x12474,
+	0x16a6e, 0x16a6f,
+	0x16af5, 0x16af5,
+	0x16b37, 0x16b3b,
+	0x16b44, 0x16b44,
+	0x1bc9f, 0x1bc9f,
+}; /* CR_Po */
+
+/* 'Ps': General Category */
+static const OnigCodePoint CR_Ps[] = {
+	75,
+	0x0028, 0x0028,
+	0x005b, 0x005b,
+	0x007b, 0x007b,
+	0x0f3a, 0x0f3a,
+	0x0f3c, 0x0f3c,
+	0x169b, 0x169b,
+	0x201a, 0x201a,
+	0x201e, 0x201e,
+	0x2045, 0x2045,
+	0x207d, 0x207d,
+	0x208d, 0x208d,
+	0x2308, 0x2308,
+	0x230a, 0x230a,
+	0x2329, 0x2329,
+	0x2768, 0x2768,
+	0x276a, 0x276a,
+	0x276c, 0x276c,
+	0x276e, 0x276e,
+	0x2770, 0x2770,
+	0x2772, 0x2772,
+	0x2774, 0x2774,
+	0x27c5, 0x27c5,
+	0x27e6, 0x27e6,
+	0x27e8, 0x27e8,
+	0x27ea, 0x27ea,
+	0x27ec, 0x27ec,
+	0x27ee, 0x27ee,
+	0x2983, 0x2983,
+	0x2985, 0x2985,
+	0x2987, 0x2987,
+	0x2989, 0x2989,
+	0x298b, 0x298b,
+	0x298d, 0x298d,
+	0x298f, 0x298f,
+	0x2991, 0x2991,
+	0x2993, 0x2993,
+	0x2995, 0x2995,
+	0x2997, 0x2997,
+	0x29d8, 0x29d8,
+	0x29da, 0x29da,
+	0x29fc, 0x29fc,
+	0x2e22, 0x2e22,
+	0x2e24, 0x2e24,
+	0x2e26, 0x2e26,
+	0x2e28, 0x2e28,
+	0x2e42, 0x2e42,
+	0x3008, 0x3008,
+	0x300a, 0x300a,
+	0x300c, 0x300c,
+	0x300e, 0x300e,
+	0x3010, 0x3010,
+	0x3014, 0x3014,
+	0x3016, 0x3016,
+	0x3018, 0x3018,
+	0x301a, 0x301a,
+	0x301d, 0x301d,
+	0xfd3f, 0xfd3f,
+	0xfe17, 0xfe17,
+	0xfe35, 0xfe35,
+	0xfe37, 0xfe37,
+	0xfe39, 0xfe39,
+	0xfe3b, 0xfe3b,
+	0xfe3d, 0xfe3d,
+	0xfe3f, 0xfe3f,
+	0xfe41, 0xfe41,
+	0xfe43, 0xfe43,
+	0xfe47, 0xfe47,
+	0xfe59, 0xfe59,
+	0xfe5b, 0xfe5b,
+	0xfe5d, 0xfe5d,
+	0xff08, 0xff08,
+	0xff3b, 0xff3b,
+	0xff5b, 0xff5b,
+	0xff5f, 0xff5f,
+	0xff62, 0xff62,
+}; /* CR_Ps */
+
+/* 'S': Major Category */
+static const OnigCodePoint CR_S[] = {
+	210,
+	0x0024, 0x0024,
+	0x002b, 0x002b,
+	0x003c, 0x003e,
+	0x005e, 0x005e,
+	0x0060, 0x0060,
+	0x007c, 0x007c,
+	0x007e, 0x007e,
+	0x00a2, 0x00a6,
+	0x00a8, 0x00a9,
+	0x00ac, 0x00ac,
+	0x00ae, 0x00b1,
+	0x00b4, 0x00b4,
+	0x00b8, 0x00b8,
+	0x00d7, 0x00d7,
+	0x00f7, 0x00f7,
+	0x02c2, 0x02c5,
+	0x02d2, 0x02df,
+	0x02e5, 0x02eb,
+	0x02ed, 0x02ed,
+	0x02ef, 0x02ff,
+	0x0375, 0x0375,
+	0x0384, 0x0385,
+	0x03f6, 0x03f6,
+	0x0482, 0x0482,
+	0x058d, 0x058f,
+	0x0606, 0x0608,
+	0x060b, 0x060b,
+	0x060e, 0x060f,
+	0x06de, 0x06de,
+	0x06e9, 0x06e9,
+	0x06fd, 0x06fe,
+	0x07f6, 0x07f6,
+	0x09f2, 0x09f3,
+	0x09fa, 0x09fb,
+	0x0af1, 0x0af1,
+	0x0b70, 0x0b70,
+	0x0bf3, 0x0bfa,
+	0x0c7f, 0x0c7f,
+	0x0d79, 0x0d79,
+	0x0e3f, 0x0e3f,
+	0x0f01, 0x0f03,
+	0x0f13, 0x0f13,
+	0x0f15, 0x0f17,
+	0x0f1a, 0x0f1f,
+	0x0f34, 0x0f34,
+	0x0f36, 0x0f36,
+	0x0f38, 0x0f38,
+	0x0fbe, 0x0fc5,
+	0x0fc7, 0x0fcc,
+	0x0fce, 0x0fcf,
+	0x0fd5, 0x0fd8,
+	0x109e, 0x109f,
+	0x1390, 0x1399,
+	0x17db, 0x17db,
+	0x1940, 0x1940,
+	0x19de, 0x19ff,
+	0x1b61, 0x1b6a,
+	0x1b74, 0x1b7c,
+	0x1fbd, 0x1fbd,
+	0x1fbf, 0x1fc1,
+	0x1fcd, 0x1fcf,
+	0x1fdd, 0x1fdf,
+	0x1fed, 0x1fef,
+	0x1ffd, 0x1ffe,
+	0x2044, 0x2044,
+	0x2052, 0x2052,
+	0x207a, 0x207c,
+	0x208a, 0x208c,
+	0x20a0, 0x20bd,
+	0x2100, 0x2101,
+	0x2103, 0x2106,
+	0x2108, 0x2109,
+	0x2114, 0x2114,
+	0x2116, 0x2118,
+	0x211e, 0x2123,
+	0x2125, 0x2125,
+	0x2127, 0x2127,
+	0x2129, 0x2129,
+	0x212e, 0x212e,
+	0x213a, 0x213b,
+	0x2140, 0x2144,
+	0x214a, 0x214d,
+	0x214f, 0x214f,
+	0x2190, 0x2307,
+	0x230c, 0x2328,
+	0x232b, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x249c, 0x24e9,
+	0x2500, 0x2767,
+	0x2794, 0x27c4,
+	0x27c7, 0x27e5,
+	0x27f0, 0x2982,
+	0x2999, 0x29d7,
+	0x29dc, 0x29fb,
+	0x29fe, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2ce5, 0x2cea,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3004, 0x3004,
+	0x3012, 0x3013,
+	0x3020, 0x3020,
+	0x3036, 0x3037,
+	0x303e, 0x303f,
+	0x309b, 0x309c,
+	0x3190, 0x3191,
+	0x3196, 0x319f,
+	0x31c0, 0x31e3,
+	0x3200, 0x321e,
+	0x322a, 0x3247,
+	0x3250, 0x3250,
+	0x3260, 0x327f,
+	0x328a, 0x32b0,
+	0x32c0, 0x32fe,
+	0x3300, 0x33ff,
+	0x4dc0, 0x4dff,
+	0xa490, 0xa4c6,
+	0xa700, 0xa716,
+	0xa720, 0xa721,
+	0xa789, 0xa78a,
+	0xa828, 0xa82b,
+	0xa836, 0xa839,
+	0xaa77, 0xaa79,
+	0xab5b, 0xab5b,
+	0xfb29, 0xfb29,
+	0xfbb2, 0xfbc1,
+	0xfdfc, 0xfdfd,
+	0xfe62, 0xfe62,
+	0xfe64, 0xfe66,
+	0xfe69, 0xfe69,
+	0xff04, 0xff04,
+	0xff0b, 0xff0b,
+	0xff1c, 0xff1e,
+	0xff3e, 0xff3e,
+	0xff40, 0xff40,
+	0xff5c, 0xff5c,
+	0xff5e, 0xff5e,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfffc, 0xfffd,
+	0x10137, 0x1013f,
+	0x10179, 0x10189,
+	0x1018c, 0x1018c,
+	0x10190, 0x1019b,
+	0x101a0, 0x101a0,
+	0x101d0, 0x101fc,
+	0x10877, 0x10878,
+	0x10ac8, 0x10ac8,
+	0x16b3c, 0x16b3f,
+	0x16b45, 0x16b45,
+	0x1bc9c, 0x1bc9c,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d164,
+	0x1d16a, 0x1d16c,
+	0x1d183, 0x1d184,
+	0x1d18c, 0x1d1a9,
+	0x1d1ae, 0x1d1dd,
+	0x1d200, 0x1d241,
+	0x1d245, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d6c1, 0x1d6c1,
+	0x1d6db, 0x1d6db,
+	0x1d6fb, 0x1d6fb,
+	0x1d715, 0x1d715,
+	0x1d735, 0x1d735,
+	0x1d74f, 0x1d74f,
+	0x1d76f, 0x1d76f,
+	0x1d789, 0x1d789,
+	0x1d7a9, 0x1d7a9,
+	0x1d7c3, 0x1d7c3,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+}; /* CR_S */
+
+/* 'Sc': General Category */
+static const OnigCodePoint CR_Sc[] = {
+	17,
+	0x0024, 0x0024,
+	0x00a2, 0x00a5,
+	0x058f, 0x058f,
+	0x060b, 0x060b,
+	0x09f2, 0x09f3,
+	0x09fb, 0x09fb,
+	0x0af1, 0x0af1,
+	0x0bf9, 0x0bf9,
+	0x0e3f, 0x0e3f,
+	0x17db, 0x17db,
+	0x20a0, 0x20bd,
+	0xa838, 0xa838,
+	0xfdfc, 0xfdfc,
+	0xfe69, 0xfe69,
+	0xff04, 0xff04,
+	0xffe0, 0xffe1,
+	0xffe5, 0xffe6,
+}; /* CR_Sc */
+
+/* 'Sk': General Category */
+static const OnigCodePoint CR_Sk[] = {
+	28,
+	0x005e, 0x005e,
+	0x0060, 0x0060,
+	0x00a8, 0x00a8,
+	0x00af, 0x00af,
+	0x00b4, 0x00b4,
+	0x00b8, 0x00b8,
+	0x02c2, 0x02c5,
+	0x02d2, 0x02df,
+	0x02e5, 0x02eb,
+	0x02ed, 0x02ed,
+	0x02ef, 0x02ff,
+	0x0375, 0x0375,
+	0x0384, 0x0385,
+	0x1fbd, 0x1fbd,
+	0x1fbf, 0x1fc1,
+	0x1fcd, 0x1fcf,
+	0x1fdd, 0x1fdf,
+	0x1fed, 0x1fef,
+	0x1ffd, 0x1ffe,
+	0x309b, 0x309c,
+	0xa700, 0xa716,
+	0xa720, 0xa721,
+	0xa789, 0xa78a,
+	0xab5b, 0xab5b,
+	0xfbb2, 0xfbc1,
+	0xff3e, 0xff3e,
+	0xff40, 0xff40,
+	0xffe3, 0xffe3,
+}; /* CR_Sk */
+
+/* 'Sm': General Category */
+static const OnigCodePoint CR_Sm[] = {
+	64,
+	0x002b, 0x002b,
+	0x003c, 0x003e,
+	0x007c, 0x007c,
+	0x007e, 0x007e,
+	0x00ac, 0x00ac,
+	0x00b1, 0x00b1,
+	0x00d7, 0x00d7,
+	0x00f7, 0x00f7,
+	0x03f6, 0x03f6,
+	0x0606, 0x0608,
+	0x2044, 0x2044,
+	0x2052, 0x2052,
+	0x207a, 0x207c,
+	0x208a, 0x208c,
+	0x2118, 0x2118,
+	0x2140, 0x2144,
+	0x214b, 0x214b,
+	0x2190, 0x2194,
+	0x219a, 0x219b,
+	0x21a0, 0x21a0,
+	0x21a3, 0x21a3,
+	0x21a6, 0x21a6,
+	0x21ae, 0x21ae,
+	0x21ce, 0x21cf,
+	0x21d2, 0x21d2,
+	0x21d4, 0x21d4,
+	0x21f4, 0x22ff,
+	0x2320, 0x2321,
+	0x237c, 0x237c,
+	0x239b, 0x23b3,
+	0x23dc, 0x23e1,
+	0x25b7, 0x25b7,
+	0x25c1, 0x25c1,
+	0x25f8, 0x25ff,
+	0x266f, 0x266f,
+	0x27c0, 0x27c4,
+	0x27c7, 0x27e5,
+	0x27f0, 0x27ff,
+	0x2900, 0x2982,
+	0x2999, 0x29d7,
+	0x29dc, 0x29fb,
+	0x29fe, 0x2aff,
+	0x2b30, 0x2b44,
+	0x2b47, 0x2b4c,
+	0xfb29, 0xfb29,
+	0xfe62, 0xfe62,
+	0xfe64, 0xfe66,
+	0xff0b, 0xff0b,
+	0xff1c, 0xff1e,
+	0xff5c, 0xff5c,
+	0xff5e, 0xff5e,
+	0xffe2, 0xffe2,
+	0xffe9, 0xffec,
+	0x1d6c1, 0x1d6c1,
+	0x1d6db, 0x1d6db,
+	0x1d6fb, 0x1d6fb,
+	0x1d715, 0x1d715,
+	0x1d735, 0x1d735,
+	0x1d74f, 0x1d74f,
+	0x1d76f, 0x1d76f,
+	0x1d789, 0x1d789,
+	0x1d7a9, 0x1d7a9,
+	0x1d7c3, 0x1d7c3,
+	0x1eef0, 0x1eef1,
+}; /* CR_Sm */
+
+/* 'So': General Category */
+static const OnigCodePoint CR_So[] = {
+	165,
+	0x00a6, 0x00a6,
+	0x00a9, 0x00a9,
+	0x00ae, 0x00ae,
+	0x00b0, 0x00b0,
+	0x0482, 0x0482,
+	0x058d, 0x058e,
+	0x060e, 0x060f,
+	0x06de, 0x06de,
+	0x06e9, 0x06e9,
+	0x06fd, 0x06fe,
+	0x07f6, 0x07f6,
+	0x09fa, 0x09fa,
+	0x0b70, 0x0b70,
+	0x0bf3, 0x0bf8,
+	0x0bfa, 0x0bfa,
+	0x0c7f, 0x0c7f,
+	0x0d79, 0x0d79,
+	0x0f01, 0x0f03,
+	0x0f13, 0x0f13,
+	0x0f15, 0x0f17,
+	0x0f1a, 0x0f1f,
+	0x0f34, 0x0f34,
+	0x0f36, 0x0f36,
+	0x0f38, 0x0f38,
+	0x0fbe, 0x0fc5,
+	0x0fc7, 0x0fcc,
+	0x0fce, 0x0fcf,
+	0x0fd5, 0x0fd8,
+	0x109e, 0x109f,
+	0x1390, 0x1399,
+	0x1940, 0x1940,
+	0x19de, 0x19ff,
+	0x1b61, 0x1b6a,
+	0x1b74, 0x1b7c,
+	0x2100, 0x2101,
+	0x2103, 0x2106,
+	0x2108, 0x2109,
+	0x2114, 0x2114,
+	0x2116, 0x2117,
+	0x211e, 0x2123,
+	0x2125, 0x2125,
+	0x2127, 0x2127,
+	0x2129, 0x2129,
+	0x212e, 0x212e,
+	0x213a, 0x213b,
+	0x214a, 0x214a,
+	0x214c, 0x214d,
+	0x214f, 0x214f,
+	0x2195, 0x2199,
+	0x219c, 0x219f,
+	0x21a1, 0x21a2,
+	0x21a4, 0x21a5,
+	0x21a7, 0x21ad,
+	0x21af, 0x21cd,
+	0x21d0, 0x21d1,
+	0x21d3, 0x21d3,
+	0x21d5, 0x21f3,
+	0x2300, 0x2307,
+	0x230c, 0x231f,
+	0x2322, 0x2328,
+	0x232b, 0x237b,
+	0x237d, 0x239a,
+	0x23b4, 0x23db,
+	0x23e2, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x249c, 0x24e9,
+	0x2500, 0x25b6,
+	0x25b8, 0x25c0,
+	0x25c2, 0x25f7,
+	0x2600, 0x266e,
+	0x2670, 0x2767,
+	0x2794, 0x27bf,
+	0x2800, 0x28ff,
+	0x2b00, 0x2b2f,
+	0x2b45, 0x2b46,
+	0x2b4d, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2ce5, 0x2cea,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3004, 0x3004,
+	0x3012, 0x3013,
+	0x3020, 0x3020,
+	0x3036, 0x3037,
+	0x303e, 0x303f,
+	0x3190, 0x3191,
+	0x3196, 0x319f,
+	0x31c0, 0x31e3,
+	0x3200, 0x321e,
+	0x322a, 0x3247,
+	0x3250, 0x3250,
+	0x3260, 0x327f,
+	0x328a, 0x32b0,
+	0x32c0, 0x32fe,
+	0x3300, 0x33ff,
+	0x4dc0, 0x4dff,
+	0xa490, 0xa4c6,
+	0xa828, 0xa82b,
+	0xa836, 0xa837,
+	0xa839, 0xa839,
+	0xaa77, 0xaa79,
+	0xfdfd, 0xfdfd,
+	0xffe4, 0xffe4,
+	0xffe8, 0xffe8,
+	0xffed, 0xffee,
+	0xfffc, 0xfffd,
+	0x10137, 0x1013f,
+	0x10179, 0x10189,
+	0x1018c, 0x1018c,
+	0x10190, 0x1019b,
+	0x101a0, 0x101a0,
+	0x101d0, 0x101fc,
+	0x10877, 0x10878,
+	0x10ac8, 0x10ac8,
+	0x16b3c, 0x16b3f,
+	0x16b45, 0x16b45,
+	0x1bc9c, 0x1bc9c,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d164,
+	0x1d16a, 0x1d16c,
+	0x1d183, 0x1d184,
+	0x1d18c, 0x1d1a9,
+	0x1d1ae, 0x1d1dd,
+	0x1d200, 0x1d241,
+	0x1d245, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+}; /* CR_So */
+
+/* 'Z': Major Category */
+static const OnigCodePoint CR_Z[] = {
+	8,
+	0x0020, 0x0020,
+	0x00a0, 0x00a0,
+	0x1680, 0x1680,
+	0x2000, 0x200a,
+	0x2028, 0x2029,
+	0x202f, 0x202f,
+	0x205f, 0x205f,
+	0x3000, 0x3000,
+}; /* CR_Z */
+
+/* 'Zl': General Category */
+static const OnigCodePoint CR_Zl[] = {
+	1,
+	0x2028, 0x2028,
+}; /* CR_Zl */
+
+/* 'Zp': General Category */
+static const OnigCodePoint CR_Zp[] = {
+	1,
+	0x2029, 0x2029,
+}; /* CR_Zp */
+
+/* 'Zs': General Category */
+static const OnigCodePoint CR_Zs[] = {
+	7,
+	0x0020, 0x0020,
+	0x00a0, 0x00a0,
+	0x1680, 0x1680,
+	0x2000, 0x200a,
+	0x202f, 0x202f,
+	0x205f, 0x205f,
+	0x3000, 0x3000,
+}; /* CR_Zs */
+
+/* 'Math': Derived Property */
+static const OnigCodePoint CR_Math[] = {
+	138,
+	0x002b, 0x002b,
+	0x003c, 0x003e,
+	0x005e, 0x005e,
+	0x007c, 0x007c,
+	0x007e, 0x007e,
+	0x00ac, 0x00ac,
+	0x00b1, 0x00b1,
+	0x00d7, 0x00d7,
+	0x00f7, 0x00f7,
+	0x03d0, 0x03d2,
+	0x03d5, 0x03d5,
+	0x03f0, 0x03f1,
+	0x03f4, 0x03f6,
+	0x0606, 0x0608,
+	0x2016, 0x2016,
+	0x2032, 0x2034,
+	0x2040, 0x2040,
+	0x2044, 0x2044,
+	0x2052, 0x2052,
+	0x2061, 0x2064,
+	0x207a, 0x207e,
+	0x208a, 0x208e,
+	0x20d0, 0x20dc,
+	0x20e1, 0x20e1,
+	0x20e5, 0x20e6,
+	0x20eb, 0x20ef,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2118, 0x211d,
+	0x2124, 0x2124,
+	0x2128, 0x2129,
+	0x212c, 0x212d,
+	0x212f, 0x2131,
+	0x2133, 0x2138,
+	0x213c, 0x2149,
+	0x214b, 0x214b,
+	0x2190, 0x21a7,
+	0x21a9, 0x21ae,
+	0x21b0, 0x21b1,
+	0x21b6, 0x21b7,
+	0x21bc, 0x21db,
+	0x21dd, 0x21dd,
+	0x21e4, 0x21e5,
+	0x21f4, 0x22ff,
+	0x2308, 0x230b,
+	0x2320, 0x2321,
+	0x237c, 0x237c,
+	0x239b, 0x23b5,
+	0x23b7, 0x23b7,
+	0x23d0, 0x23d0,
+	0x23dc, 0x23e2,
+	0x25a0, 0x25a1,
+	0x25ae, 0x25b7,
+	0x25bc, 0x25c1,
+	0x25c6, 0x25c7,
+	0x25ca, 0x25cb,
+	0x25cf, 0x25d3,
+	0x25e2, 0x25e2,
+	0x25e4, 0x25e4,
+	0x25e7, 0x25ec,
+	0x25f8, 0x25ff,
+	0x2605, 0x2606,
+	0x2640, 0x2640,
+	0x2642, 0x2642,
+	0x2660, 0x2663,
+	0x266d, 0x266f,
+	0x27c0, 0x27ff,
+	0x2900, 0x2aff,
+	0x2b30, 0x2b44,
+	0x2b47, 0x2b4c,
+	0xfb29, 0xfb29,
+	0xfe61, 0xfe66,
+	0xfe68, 0xfe68,
+	0xff0b, 0xff0b,
+	0xff1c, 0xff1e,
+	0xff3c, 0xff3c,
+	0xff3e, 0xff3e,
+	0xff5c, 0xff5c,
+	0xff5e, 0xff5e,
+	0xffe2, 0xffe2,
+	0xffe9, 0xffec,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+}; /* CR_Math */
+
+/* 'Alphabetic': Derived Property */
+#define CR_Alphabetic CR_Alpha
+
+/* 'Lowercase': Derived Property */
+#define CR_Lowercase CR_Lower
+
+/* 'Uppercase': Derived Property */
+#define CR_Uppercase CR_Upper
+
+/* 'Cased': Derived Property */
+static const OnigCodePoint CR_Cased[] = {
+	127,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x01ba,
+	0x01bc, 0x01bf,
+	0x01c4, 0x0293,
+	0x0295, 0x02b8,
+	0x02c0, 0x02c1,
+	0x02e0, 0x02e4,
+	0x0345, 0x0345,
+	0x0370, 0x0373,
+	0x0376, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0561, 0x0587,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x1d00, 0x1dbf,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x212d,
+	0x212f, 0x2134,
+	0x2139, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x217f,
+	0x2183, 0x2184,
+	0x24b6, 0x24e9,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0xa640, 0xa66d,
+	0xa680, 0xa69d,
+	0xa722, 0xa787,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f8, 0xa7fa,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0x10400, 0x1044f,
+	0x118a0, 0x118df,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1f130, 0x1f149,
+	0x1f150, 0x1f169,
+	0x1f170, 0x1f189,
+}; /* CR_Cased */
+
+/* 'Case_Ignorable': Derived Property */
+static const OnigCodePoint CR_Case_Ignorable[] = {
+	335,
+	0x0027, 0x0027,
+	0x002e, 0x002e,
+	0x003a, 0x003a,
+	0x005e, 0x005e,
+	0x0060, 0x0060,
+	0x00a8, 0x00a8,
+	0x00ad, 0x00ad,
+	0x00af, 0x00af,
+	0x00b4, 0x00b4,
+	0x00b7, 0x00b8,
+	0x02b0, 0x036f,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x0384, 0x0385,
+	0x0387, 0x0387,
+	0x0483, 0x0489,
+	0x0559, 0x0559,
+	0x0591, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x05f4, 0x05f4,
+	0x0600, 0x0605,
+	0x0610, 0x061a,
+	0x061c, 0x061c,
+	0x0640, 0x0640,
+	0x064b, 0x065f,
+	0x0670, 0x0670,
+	0x06d6, 0x06dd,
+	0x06df, 0x06e8,
+	0x06ea, 0x06ed,
+	0x070f, 0x070f,
+	0x0711, 0x0711,
+	0x0730, 0x074a,
+	0x07a6, 0x07b0,
+	0x07eb, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0816, 0x082d,
+	0x0859, 0x085b,
+	0x08e4, 0x0902,
+	0x093a, 0x093a,
+	0x093c, 0x093c,
+	0x0941, 0x0948,
+	0x094d, 0x094d,
+	0x0951, 0x0957,
+	0x0962, 0x0963,
+	0x0971, 0x0971,
+	0x0981, 0x0981,
+	0x09bc, 0x09bc,
+	0x09c1, 0x09c4,
+	0x09cd, 0x09cd,
+	0x09e2, 0x09e3,
+	0x0a01, 0x0a02,
+	0x0a3c, 0x0a3c,
+	0x0a41, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a70, 0x0a71,
+	0x0a75, 0x0a75,
+	0x0a81, 0x0a82,
+	0x0abc, 0x0abc,
+	0x0ac1, 0x0ac5,
+	0x0ac7, 0x0ac8,
+	0x0acd, 0x0acd,
+	0x0ae2, 0x0ae3,
+	0x0b01, 0x0b01,
+	0x0b3c, 0x0b3c,
+	0x0b3f, 0x0b3f,
+	0x0b41, 0x0b44,
+	0x0b4d, 0x0b4d,
+	0x0b56, 0x0b56,
+	0x0b62, 0x0b63,
+	0x0b82, 0x0b82,
+	0x0bc0, 0x0bc0,
+	0x0bcd, 0x0bcd,
+	0x0c00, 0x0c00,
+	0x0c3e, 0x0c40,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c62, 0x0c63,
+	0x0c81, 0x0c81,
+	0x0cbc, 0x0cbc,
+	0x0cbf, 0x0cbf,
+	0x0cc6, 0x0cc6,
+	0x0ccc, 0x0ccd,
+	0x0ce2, 0x0ce3,
+	0x0d01, 0x0d01,
+	0x0d41, 0x0d44,
+	0x0d4d, 0x0d4d,
+	0x0d62, 0x0d63,
+	0x0dca, 0x0dca,
+	0x0dd2, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0e31, 0x0e31,
+	0x0e34, 0x0e3a,
+	0x0e46, 0x0e4e,
+	0x0eb1, 0x0eb1,
+	0x0eb4, 0x0eb9,
+	0x0ebb, 0x0ebc,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0f18, 0x0f19,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f71, 0x0f7e,
+	0x0f80, 0x0f84,
+	0x0f86, 0x0f87,
+	0x0f8d, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fc6, 0x0fc6,
+	0x102d, 0x1030,
+	0x1032, 0x1037,
+	0x1039, 0x103a,
+	0x103d, 0x103e,
+	0x1058, 0x1059,
+	0x105e, 0x1060,
+	0x1071, 0x1074,
+	0x1082, 0x1082,
+	0x1085, 0x1086,
+	0x108d, 0x108d,
+	0x109d, 0x109d,
+	0x10fc, 0x10fc,
+	0x135d, 0x135f,
+	0x1712, 0x1714,
+	0x1732, 0x1734,
+	0x1752, 0x1753,
+	0x1772, 0x1773,
+	0x17b4, 0x17b5,
+	0x17b7, 0x17bd,
+	0x17c6, 0x17c6,
+	0x17c9, 0x17d3,
+	0x17d7, 0x17d7,
+	0x17dd, 0x17dd,
+	0x180b, 0x180e,
+	0x1843, 0x1843,
+	0x18a9, 0x18a9,
+	0x1920, 0x1922,
+	0x1927, 0x1928,
+	0x1932, 0x1932,
+	0x1939, 0x193b,
+	0x1a17, 0x1a18,
+	0x1a1b, 0x1a1b,
+	0x1a56, 0x1a56,
+	0x1a58, 0x1a5e,
+	0x1a60, 0x1a60,
+	0x1a62, 0x1a62,
+	0x1a65, 0x1a6c,
+	0x1a73, 0x1a7c,
+	0x1a7f, 0x1a7f,
+	0x1aa7, 0x1aa7,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b03,
+	0x1b34, 0x1b34,
+	0x1b36, 0x1b3a,
+	0x1b3c, 0x1b3c,
+	0x1b42, 0x1b42,
+	0x1b6b, 0x1b73,
+	0x1b80, 0x1b81,
+	0x1ba2, 0x1ba5,
+	0x1ba8, 0x1ba9,
+	0x1bab, 0x1bad,
+	0x1be6, 0x1be6,
+	0x1be8, 0x1be9,
+	0x1bed, 0x1bed,
+	0x1bef, 0x1bf1,
+	0x1c2c, 0x1c33,
+	0x1c36, 0x1c37,
+	0x1c78, 0x1c7d,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1ce0,
+	0x1ce2, 0x1ce8,
+	0x1ced, 0x1ced,
+	0x1cf4, 0x1cf4,
+	0x1cf8, 0x1cf9,
+	0x1d2c, 0x1d6a,
+	0x1d78, 0x1d78,
+	0x1d9b, 0x1df5,
+	0x1dfc, 0x1dff,
+	0x1fbd, 0x1fbd,
+	0x1fbf, 0x1fc1,
+	0x1fcd, 0x1fcf,
+	0x1fdd, 0x1fdf,
+	0x1fed, 0x1fef,
+	0x1ffd, 0x1ffe,
+	0x200b, 0x200f,
+	0x2018, 0x2019,
+	0x2024, 0x2024,
+	0x2027, 0x2027,
+	0x202a, 0x202e,
+	0x2060, 0x2064,
+	0x2066, 0x206f,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x20d0, 0x20f0,
+	0x2c7c, 0x2c7d,
+	0x2cef, 0x2cf1,
+	0x2d6f, 0x2d6f,
+	0x2d7f, 0x2d7f,
+	0x2de0, 0x2dff,
+	0x2e2f, 0x2e2f,
+	0x3005, 0x3005,
+	0x302a, 0x302d,
+	0x3031, 0x3035,
+	0x303b, 0x303b,
+	0x3099, 0x309e,
+	0x30fc, 0x30fe,
+	0xa015, 0xa015,
+	0xa4f8, 0xa4fd,
+	0xa60c, 0xa60c,
+	0xa66f, 0xa672,
+	0xa674, 0xa67d,
+	0xa67f, 0xa67f,
+	0xa69c, 0xa69d,
+	0xa69f, 0xa69f,
+	0xa6f0, 0xa6f1,
+	0xa700, 0xa721,
+	0xa770, 0xa770,
+	0xa788, 0xa78a,
+	0xa7f8, 0xa7f9,
+	0xa802, 0xa802,
+	0xa806, 0xa806,
+	0xa80b, 0xa80b,
+	0xa825, 0xa826,
+	0xa8c4, 0xa8c4,
+	0xa8e0, 0xa8f1,
+	0xa926, 0xa92d,
+	0xa947, 0xa951,
+	0xa980, 0xa982,
+	0xa9b3, 0xa9b3,
+	0xa9b6, 0xa9b9,
+	0xa9bc, 0xa9bc,
+	0xa9cf, 0xa9cf,
+	0xa9e5, 0xa9e6,
+	0xaa29, 0xaa2e,
+	0xaa31, 0xaa32,
+	0xaa35, 0xaa36,
+	0xaa43, 0xaa43,
+	0xaa4c, 0xaa4c,
+	0xaa70, 0xaa70,
+	0xaa7c, 0xaa7c,
+	0xaab0, 0xaab0,
+	0xaab2, 0xaab4,
+	0xaab7, 0xaab8,
+	0xaabe, 0xaabf,
+	0xaac1, 0xaac1,
+	0xaadd, 0xaadd,
+	0xaaec, 0xaaed,
+	0xaaf3, 0xaaf4,
+	0xaaf6, 0xaaf6,
+	0xab5b, 0xab5f,
+	0xabe5, 0xabe5,
+	0xabe8, 0xabe8,
+	0xabed, 0xabed,
+	0xfb1e, 0xfb1e,
+	0xfbb2, 0xfbc1,
+	0xfe00, 0xfe0f,
+	0xfe13, 0xfe13,
+	0xfe20, 0xfe2d,
+	0xfe52, 0xfe52,
+	0xfe55, 0xfe55,
+	0xfeff, 0xfeff,
+	0xff07, 0xff07,
+	0xff0e, 0xff0e,
+	0xff1a, 0xff1a,
+	0xff3e, 0xff3e,
+	0xff40, 0xff40,
+	0xff70, 0xff70,
+	0xff9e, 0xff9f,
+	0xffe3, 0xffe3,
+	0xfff9, 0xfffb,
+	0x101fd, 0x101fd,
+	0x102e0, 0x102e0,
+	0x10376, 0x1037a,
+	0x10a01, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a0f,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a3f,
+	0x10ae5, 0x10ae6,
+	0x11001, 0x11001,
+	0x11038, 0x11046,
+	0x1107f, 0x11081,
+	0x110b3, 0x110b6,
+	0x110b9, 0x110ba,
+	0x110bd, 0x110bd,
+	0x11100, 0x11102,
+	0x11127, 0x1112b,
+	0x1112d, 0x11134,
+	0x11173, 0x11173,
+	0x11180, 0x11181,
+	0x111b6, 0x111be,
+	0x1122f, 0x11231,
+	0x11234, 0x11234,
+	0x11236, 0x11237,
+	0x112df, 0x112df,
+	0x112e3, 0x112ea,
+	0x11301, 0x11301,
+	0x1133c, 0x1133c,
+	0x11340, 0x11340,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x114b3, 0x114b8,
+	0x114ba, 0x114ba,
+	0x114bf, 0x114c0,
+	0x114c2, 0x114c3,
+	0x115b2, 0x115b5,
+	0x115bc, 0x115bd,
+	0x115bf, 0x115c0,
+	0x11633, 0x1163a,
+	0x1163d, 0x1163d,
+	0x1163f, 0x11640,
+	0x116ab, 0x116ab,
+	0x116ad, 0x116ad,
+	0x116b0, 0x116b5,
+	0x116b7, 0x116b7,
+	0x16af0, 0x16af4,
+	0x16b30, 0x16b36,
+	0x16b40, 0x16b43,
+	0x16f8f, 0x16f9f,
+	0x1bc9d, 0x1bc9e,
+	0x1bca0, 0x1bca3,
+	0x1d167, 0x1d169,
+	0x1d173, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1d242, 0x1d244,
+	0x1e8d0, 0x1e8d6,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+}; /* CR_Case_Ignorable */
+
+/* 'Changes_When_Lowercased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Lowercased[] = {
+	585,
+	0x0041, 0x005a,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00de,
+	0x0100, 0x0100,
+	0x0102, 0x0102,
+	0x0104, 0x0104,
+	0x0106, 0x0106,
+	0x0108, 0x0108,
+	0x010a, 0x010a,
+	0x010c, 0x010c,
+	0x010e, 0x010e,
+	0x0110, 0x0110,
+	0x0112, 0x0112,
+	0x0114, 0x0114,
+	0x0116, 0x0116,
+	0x0118, 0x0118,
+	0x011a, 0x011a,
+	0x011c, 0x011c,
+	0x011e, 0x011e,
+	0x0120, 0x0120,
+	0x0122, 0x0122,
+	0x0124, 0x0124,
+	0x0126, 0x0126,
+	0x0128, 0x0128,
+	0x012a, 0x012a,
+	0x012c, 0x012c,
+	0x012e, 0x012e,
+	0x0130, 0x0130,
+	0x0132, 0x0132,
+	0x0134, 0x0134,
+	0x0136, 0x0136,
+	0x0139, 0x0139,
+	0x013b, 0x013b,
+	0x013d, 0x013d,
+	0x013f, 0x013f,
+	0x0141, 0x0141,
+	0x0143, 0x0143,
+	0x0145, 0x0145,
+	0x0147, 0x0147,
+	0x014a, 0x014a,
+	0x014c, 0x014c,
+	0x014e, 0x014e,
+	0x0150, 0x0150,
+	0x0152, 0x0152,
+	0x0154, 0x0154,
+	0x0156, 0x0156,
+	0x0158, 0x0158,
+	0x015a, 0x015a,
+	0x015c, 0x015c,
+	0x015e, 0x015e,
+	0x0160, 0x0160,
+	0x0162, 0x0162,
+	0x0164, 0x0164,
+	0x0166, 0x0166,
+	0x0168, 0x0168,
+	0x016a, 0x016a,
+	0x016c, 0x016c,
+	0x016e, 0x016e,
+	0x0170, 0x0170,
+	0x0172, 0x0172,
+	0x0174, 0x0174,
+	0x0176, 0x0176,
+	0x0178, 0x0179,
+	0x017b, 0x017b,
+	0x017d, 0x017d,
+	0x0181, 0x0182,
+	0x0184, 0x0184,
+	0x0186, 0x0187,
+	0x0189, 0x018b,
+	0x018e, 0x0191,
+	0x0193, 0x0194,
+	0x0196, 0x0198,
+	0x019c, 0x019d,
+	0x019f, 0x01a0,
+	0x01a2, 0x01a2,
+	0x01a4, 0x01a4,
+	0x01a6, 0x01a7,
+	0x01a9, 0x01a9,
+	0x01ac, 0x01ac,
+	0x01ae, 0x01af,
+	0x01b1, 0x01b3,
+	0x01b5, 0x01b5,
+	0x01b7, 0x01b8,
+	0x01bc, 0x01bc,
+	0x01c4, 0x01c5,
+	0x01c7, 0x01c8,
+	0x01ca, 0x01cb,
+	0x01cd, 0x01cd,
+	0x01cf, 0x01cf,
+	0x01d1, 0x01d1,
+	0x01d3, 0x01d3,
+	0x01d5, 0x01d5,
+	0x01d7, 0x01d7,
+	0x01d9, 0x01d9,
+	0x01db, 0x01db,
+	0x01de, 0x01de,
+	0x01e0, 0x01e0,
+	0x01e2, 0x01e2,
+	0x01e4, 0x01e4,
+	0x01e6, 0x01e6,
+	0x01e8, 0x01e8,
+	0x01ea, 0x01ea,
+	0x01ec, 0x01ec,
+	0x01ee, 0x01ee,
+	0x01f1, 0x01f2,
+	0x01f4, 0x01f4,
+	0x01f6, 0x01f8,
+	0x01fa, 0x01fa,
+	0x01fc, 0x01fc,
+	0x01fe, 0x01fe,
+	0x0200, 0x0200,
+	0x0202, 0x0202,
+	0x0204, 0x0204,
+	0x0206, 0x0206,
+	0x0208, 0x0208,
+	0x020a, 0x020a,
+	0x020c, 0x020c,
+	0x020e, 0x020e,
+	0x0210, 0x0210,
+	0x0212, 0x0212,
+	0x0214, 0x0214,
+	0x0216, 0x0216,
+	0x0218, 0x0218,
+	0x021a, 0x021a,
+	0x021c, 0x021c,
+	0x021e, 0x021e,
+	0x0220, 0x0220,
+	0x0222, 0x0222,
+	0x0224, 0x0224,
+	0x0226, 0x0226,
+	0x0228, 0x0228,
+	0x022a, 0x022a,
+	0x022c, 0x022c,
+	0x022e, 0x022e,
+	0x0230, 0x0230,
+	0x0232, 0x0232,
+	0x023a, 0x023b,
+	0x023d, 0x023e,
+	0x0241, 0x0241,
+	0x0243, 0x0246,
+	0x0248, 0x0248,
+	0x024a, 0x024a,
+	0x024c, 0x024c,
+	0x024e, 0x024e,
+	0x0370, 0x0370,
+	0x0372, 0x0372,
+	0x0376, 0x0376,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x038f,
+	0x0391, 0x03a1,
+	0x03a3, 0x03ab,
+	0x03cf, 0x03cf,
+	0x03d8, 0x03d8,
+	0x03da, 0x03da,
+	0x03dc, 0x03dc,
+	0x03de, 0x03de,
+	0x03e0, 0x03e0,
+	0x03e2, 0x03e2,
+	0x03e4, 0x03e4,
+	0x03e6, 0x03e6,
+	0x03e8, 0x03e8,
+	0x03ea, 0x03ea,
+	0x03ec, 0x03ec,
+	0x03ee, 0x03ee,
+	0x03f4, 0x03f4,
+	0x03f7, 0x03f7,
+	0x03f9, 0x03fa,
+	0x03fd, 0x042f,
+	0x0460, 0x0460,
+	0x0462, 0x0462,
+	0x0464, 0x0464,
+	0x0466, 0x0466,
+	0x0468, 0x0468,
+	0x046a, 0x046a,
+	0x046c, 0x046c,
+	0x046e, 0x046e,
+	0x0470, 0x0470,
+	0x0472, 0x0472,
+	0x0474, 0x0474,
+	0x0476, 0x0476,
+	0x0478, 0x0478,
+	0x047a, 0x047a,
+	0x047c, 0x047c,
+	0x047e, 0x047e,
+	0x0480, 0x0480,
+	0x048a, 0x048a,
+	0x048c, 0x048c,
+	0x048e, 0x048e,
+	0x0490, 0x0490,
+	0x0492, 0x0492,
+	0x0494, 0x0494,
+	0x0496, 0x0496,
+	0x0498, 0x0498,
+	0x049a, 0x049a,
+	0x049c, 0x049c,
+	0x049e, 0x049e,
+	0x04a0, 0x04a0,
+	0x04a2, 0x04a2,
+	0x04a4, 0x04a4,
+	0x04a6, 0x04a6,
+	0x04a8, 0x04a8,
+	0x04aa, 0x04aa,
+	0x04ac, 0x04ac,
+	0x04ae, 0x04ae,
+	0x04b0, 0x04b0,
+	0x04b2, 0x04b2,
+	0x04b4, 0x04b4,
+	0x04b6, 0x04b6,
+	0x04b8, 0x04b8,
+	0x04ba, 0x04ba,
+	0x04bc, 0x04bc,
+	0x04be, 0x04be,
+	0x04c0, 0x04c1,
+	0x04c3, 0x04c3,
+	0x04c5, 0x04c5,
+	0x04c7, 0x04c7,
+	0x04c9, 0x04c9,
+	0x04cb, 0x04cb,
+	0x04cd, 0x04cd,
+	0x04d0, 0x04d0,
+	0x04d2, 0x04d2,
+	0x04d4, 0x04d4,
+	0x04d6, 0x04d6,
+	0x04d8, 0x04d8,
+	0x04da, 0x04da,
+	0x04dc, 0x04dc,
+	0x04de, 0x04de,
+	0x04e0, 0x04e0,
+	0x04e2, 0x04e2,
+	0x04e4, 0x04e4,
+	0x04e6, 0x04e6,
+	0x04e8, 0x04e8,
+	0x04ea, 0x04ea,
+	0x04ec, 0x04ec,
+	0x04ee, 0x04ee,
+	0x04f0, 0x04f0,
+	0x04f2, 0x04f2,
+	0x04f4, 0x04f4,
+	0x04f6, 0x04f6,
+	0x04f8, 0x04f8,
+	0x04fa, 0x04fa,
+	0x04fc, 0x04fc,
+	0x04fe, 0x04fe,
+	0x0500, 0x0500,
+	0x0502, 0x0502,
+	0x0504, 0x0504,
+	0x0506, 0x0506,
+	0x0508, 0x0508,
+	0x050a, 0x050a,
+	0x050c, 0x050c,
+	0x050e, 0x050e,
+	0x0510, 0x0510,
+	0x0512, 0x0512,
+	0x0514, 0x0514,
+	0x0516, 0x0516,
+	0x0518, 0x0518,
+	0x051a, 0x051a,
+	0x051c, 0x051c,
+	0x051e, 0x051e,
+	0x0520, 0x0520,
+	0x0522, 0x0522,
+	0x0524, 0x0524,
+	0x0526, 0x0526,
+	0x0528, 0x0528,
+	0x052a, 0x052a,
+	0x052c, 0x052c,
+	0x052e, 0x052e,
+	0x0531, 0x0556,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x1e00, 0x1e00,
+	0x1e02, 0x1e02,
+	0x1e04, 0x1e04,
+	0x1e06, 0x1e06,
+	0x1e08, 0x1e08,
+	0x1e0a, 0x1e0a,
+	0x1e0c, 0x1e0c,
+	0x1e0e, 0x1e0e,
+	0x1e10, 0x1e10,
+	0x1e12, 0x1e12,
+	0x1e14, 0x1e14,
+	0x1e16, 0x1e16,
+	0x1e18, 0x1e18,
+	0x1e1a, 0x1e1a,
+	0x1e1c, 0x1e1c,
+	0x1e1e, 0x1e1e,
+	0x1e20, 0x1e20,
+	0x1e22, 0x1e22,
+	0x1e24, 0x1e24,
+	0x1e26, 0x1e26,
+	0x1e28, 0x1e28,
+	0x1e2a, 0x1e2a,
+	0x1e2c, 0x1e2c,
+	0x1e2e, 0x1e2e,
+	0x1e30, 0x1e30,
+	0x1e32, 0x1e32,
+	0x1e34, 0x1e34,
+	0x1e36, 0x1e36,
+	0x1e38, 0x1e38,
+	0x1e3a, 0x1e3a,
+	0x1e3c, 0x1e3c,
+	0x1e3e, 0x1e3e,
+	0x1e40, 0x1e40,
+	0x1e42, 0x1e42,
+	0x1e44, 0x1e44,
+	0x1e46, 0x1e46,
+	0x1e48, 0x1e48,
+	0x1e4a, 0x1e4a,
+	0x1e4c, 0x1e4c,
+	0x1e4e, 0x1e4e,
+	0x1e50, 0x1e50,
+	0x1e52, 0x1e52,
+	0x1e54, 0x1e54,
+	0x1e56, 0x1e56,
+	0x1e58, 0x1e58,
+	0x1e5a, 0x1e5a,
+	0x1e5c, 0x1e5c,
+	0x1e5e, 0x1e5e,
+	0x1e60, 0x1e60,
+	0x1e62, 0x1e62,
+	0x1e64, 0x1e64,
+	0x1e66, 0x1e66,
+	0x1e68, 0x1e68,
+	0x1e6a, 0x1e6a,
+	0x1e6c, 0x1e6c,
+	0x1e6e, 0x1e6e,
+	0x1e70, 0x1e70,
+	0x1e72, 0x1e72,
+	0x1e74, 0x1e74,
+	0x1e76, 0x1e76,
+	0x1e78, 0x1e78,
+	0x1e7a, 0x1e7a,
+	0x1e7c, 0x1e7c,
+	0x1e7e, 0x1e7e,
+	0x1e80, 0x1e80,
+	0x1e82, 0x1e82,
+	0x1e84, 0x1e84,
+	0x1e86, 0x1e86,
+	0x1e88, 0x1e88,
+	0x1e8a, 0x1e8a,
+	0x1e8c, 0x1e8c,
+	0x1e8e, 0x1e8e,
+	0x1e90, 0x1e90,
+	0x1e92, 0x1e92,
+	0x1e94, 0x1e94,
+	0x1e9e, 0x1e9e,
+	0x1ea0, 0x1ea0,
+	0x1ea2, 0x1ea2,
+	0x1ea4, 0x1ea4,
+	0x1ea6, 0x1ea6,
+	0x1ea8, 0x1ea8,
+	0x1eaa, 0x1eaa,
+	0x1eac, 0x1eac,
+	0x1eae, 0x1eae,
+	0x1eb0, 0x1eb0,
+	0x1eb2, 0x1eb2,
+	0x1eb4, 0x1eb4,
+	0x1eb6, 0x1eb6,
+	0x1eb8, 0x1eb8,
+	0x1eba, 0x1eba,
+	0x1ebc, 0x1ebc,
+	0x1ebe, 0x1ebe,
+	0x1ec0, 0x1ec0,
+	0x1ec2, 0x1ec2,
+	0x1ec4, 0x1ec4,
+	0x1ec6, 0x1ec6,
+	0x1ec8, 0x1ec8,
+	0x1eca, 0x1eca,
+	0x1ecc, 0x1ecc,
+	0x1ece, 0x1ece,
+	0x1ed0, 0x1ed0,
+	0x1ed2, 0x1ed2,
+	0x1ed4, 0x1ed4,
+	0x1ed6, 0x1ed6,
+	0x1ed8, 0x1ed8,
+	0x1eda, 0x1eda,
+	0x1edc, 0x1edc,
+	0x1ede, 0x1ede,
+	0x1ee0, 0x1ee0,
+	0x1ee2, 0x1ee2,
+	0x1ee4, 0x1ee4,
+	0x1ee6, 0x1ee6,
+	0x1ee8, 0x1ee8,
+	0x1eea, 0x1eea,
+	0x1eec, 0x1eec,
+	0x1eee, 0x1eee,
+	0x1ef0, 0x1ef0,
+	0x1ef2, 0x1ef2,
+	0x1ef4, 0x1ef4,
+	0x1ef6, 0x1ef6,
+	0x1ef8, 0x1ef8,
+	0x1efa, 0x1efa,
+	0x1efc, 0x1efc,
+	0x1efe, 0x1efe,
+	0x1f08, 0x1f0f,
+	0x1f18, 0x1f1d,
+	0x1f28, 0x1f2f,
+	0x1f38, 0x1f3f,
+	0x1f48, 0x1f4d,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f5f,
+	0x1f68, 0x1f6f,
+	0x1f88, 0x1f8f,
+	0x1f98, 0x1f9f,
+	0x1fa8, 0x1faf,
+	0x1fb8, 0x1fbc,
+	0x1fc8, 0x1fcc,
+	0x1fd8, 0x1fdb,
+	0x1fe8, 0x1fec,
+	0x1ff8, 0x1ffc,
+	0x2126, 0x2126,
+	0x212a, 0x212b,
+	0x2132, 0x2132,
+	0x2160, 0x216f,
+	0x2183, 0x2183,
+	0x24b6, 0x24cf,
+	0x2c00, 0x2c2e,
+	0x2c60, 0x2c60,
+	0x2c62, 0x2c64,
+	0x2c67, 0x2c67,
+	0x2c69, 0x2c69,
+	0x2c6b, 0x2c6b,
+	0x2c6d, 0x2c70,
+	0x2c72, 0x2c72,
+	0x2c75, 0x2c75,
+	0x2c7e, 0x2c80,
+	0x2c82, 0x2c82,
+	0x2c84, 0x2c84,
+	0x2c86, 0x2c86,
+	0x2c88, 0x2c88,
+	0x2c8a, 0x2c8a,
+	0x2c8c, 0x2c8c,
+	0x2c8e, 0x2c8e,
+	0x2c90, 0x2c90,
+	0x2c92, 0x2c92,
+	0x2c94, 0x2c94,
+	0x2c96, 0x2c96,
+	0x2c98, 0x2c98,
+	0x2c9a, 0x2c9a,
+	0x2c9c, 0x2c9c,
+	0x2c9e, 0x2c9e,
+	0x2ca0, 0x2ca0,
+	0x2ca2, 0x2ca2,
+	0x2ca4, 0x2ca4,
+	0x2ca6, 0x2ca6,
+	0x2ca8, 0x2ca8,
+	0x2caa, 0x2caa,
+	0x2cac, 0x2cac,
+	0x2cae, 0x2cae,
+	0x2cb0, 0x2cb0,
+	0x2cb2, 0x2cb2,
+	0x2cb4, 0x2cb4,
+	0x2cb6, 0x2cb6,
+	0x2cb8, 0x2cb8,
+	0x2cba, 0x2cba,
+	0x2cbc, 0x2cbc,
+	0x2cbe, 0x2cbe,
+	0x2cc0, 0x2cc0,
+	0x2cc2, 0x2cc2,
+	0x2cc4, 0x2cc4,
+	0x2cc6, 0x2cc6,
+	0x2cc8, 0x2cc8,
+	0x2cca, 0x2cca,
+	0x2ccc, 0x2ccc,
+	0x2cce, 0x2cce,
+	0x2cd0, 0x2cd0,
+	0x2cd2, 0x2cd2,
+	0x2cd4, 0x2cd4,
+	0x2cd6, 0x2cd6,
+	0x2cd8, 0x2cd8,
+	0x2cda, 0x2cda,
+	0x2cdc, 0x2cdc,
+	0x2cde, 0x2cde,
+	0x2ce0, 0x2ce0,
+	0x2ce2, 0x2ce2,
+	0x2ceb, 0x2ceb,
+	0x2ced, 0x2ced,
+	0x2cf2, 0x2cf2,
+	0xa640, 0xa640,
+	0xa642, 0xa642,
+	0xa644, 0xa644,
+	0xa646, 0xa646,
+	0xa648, 0xa648,
+	0xa64a, 0xa64a,
+	0xa64c, 0xa64c,
+	0xa64e, 0xa64e,
+	0xa650, 0xa650,
+	0xa652, 0xa652,
+	0xa654, 0xa654,
+	0xa656, 0xa656,
+	0xa658, 0xa658,
+	0xa65a, 0xa65a,
+	0xa65c, 0xa65c,
+	0xa65e, 0xa65e,
+	0xa660, 0xa660,
+	0xa662, 0xa662,
+	0xa664, 0xa664,
+	0xa666, 0xa666,
+	0xa668, 0xa668,
+	0xa66a, 0xa66a,
+	0xa66c, 0xa66c,
+	0xa680, 0xa680,
+	0xa682, 0xa682,
+	0xa684, 0xa684,
+	0xa686, 0xa686,
+	0xa688, 0xa688,
+	0xa68a, 0xa68a,
+	0xa68c, 0xa68c,
+	0xa68e, 0xa68e,
+	0xa690, 0xa690,
+	0xa692, 0xa692,
+	0xa694, 0xa694,
+	0xa696, 0xa696,
+	0xa698, 0xa698,
+	0xa69a, 0xa69a,
+	0xa722, 0xa722,
+	0xa724, 0xa724,
+	0xa726, 0xa726,
+	0xa728, 0xa728,
+	0xa72a, 0xa72a,
+	0xa72c, 0xa72c,
+	0xa72e, 0xa72e,
+	0xa732, 0xa732,
+	0xa734, 0xa734,
+	0xa736, 0xa736,
+	0xa738, 0xa738,
+	0xa73a, 0xa73a,
+	0xa73c, 0xa73c,
+	0xa73e, 0xa73e,
+	0xa740, 0xa740,
+	0xa742, 0xa742,
+	0xa744, 0xa744,
+	0xa746, 0xa746,
+	0xa748, 0xa748,
+	0xa74a, 0xa74a,
+	0xa74c, 0xa74c,
+	0xa74e, 0xa74e,
+	0xa750, 0xa750,
+	0xa752, 0xa752,
+	0xa754, 0xa754,
+	0xa756, 0xa756,
+	0xa758, 0xa758,
+	0xa75a, 0xa75a,
+	0xa75c, 0xa75c,
+	0xa75e, 0xa75e,
+	0xa760, 0xa760,
+	0xa762, 0xa762,
+	0xa764, 0xa764,
+	0xa766, 0xa766,
+	0xa768, 0xa768,
+	0xa76a, 0xa76a,
+	0xa76c, 0xa76c,
+	0xa76e, 0xa76e,
+	0xa779, 0xa779,
+	0xa77b, 0xa77b,
+	0xa77d, 0xa77e,
+	0xa780, 0xa780,
+	0xa782, 0xa782,
+	0xa784, 0xa784,
+	0xa786, 0xa786,
+	0xa78b, 0xa78b,
+	0xa78d, 0xa78d,
+	0xa790, 0xa790,
+	0xa792, 0xa792,
+	0xa796, 0xa796,
+	0xa798, 0xa798,
+	0xa79a, 0xa79a,
+	0xa79c, 0xa79c,
+	0xa79e, 0xa79e,
+	0xa7a0, 0xa7a0,
+	0xa7a2, 0xa7a2,
+	0xa7a4, 0xa7a4,
+	0xa7a6, 0xa7a6,
+	0xa7a8, 0xa7a8,
+	0xa7aa, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xff21, 0xff3a,
+	0x10400, 0x10427,
+	0x118a0, 0x118bf,
+}; /* CR_Changes_When_Lowercased */
+
+/* 'Changes_When_Uppercased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Uppercased[] = {
+	599,
+	0x0061, 0x007a,
+	0x00b5, 0x00b5,
+	0x00df, 0x00f6,
+	0x00f8, 0x00ff,
+	0x0101, 0x0101,
+	0x0103, 0x0103,
+	0x0105, 0x0105,
+	0x0107, 0x0107,
+	0x0109, 0x0109,
+	0x010b, 0x010b,
+	0x010d, 0x010d,
+	0x010f, 0x010f,
+	0x0111, 0x0111,
+	0x0113, 0x0113,
+	0x0115, 0x0115,
+	0x0117, 0x0117,
+	0x0119, 0x0119,
+	0x011b, 0x011b,
+	0x011d, 0x011d,
+	0x011f, 0x011f,
+	0x0121, 0x0121,
+	0x0123, 0x0123,
+	0x0125, 0x0125,
+	0x0127, 0x0127,
+	0x0129, 0x0129,
+	0x012b, 0x012b,
+	0x012d, 0x012d,
+	0x012f, 0x012f,
+	0x0131, 0x0131,
+	0x0133, 0x0133,
+	0x0135, 0x0135,
+	0x0137, 0x0137,
+	0x013a, 0x013a,
+	0x013c, 0x013c,
+	0x013e, 0x013e,
+	0x0140, 0x0140,
+	0x0142, 0x0142,
+	0x0144, 0x0144,
+	0x0146, 0x0146,
+	0x0148, 0x0149,
+	0x014b, 0x014b,
+	0x014d, 0x014d,
+	0x014f, 0x014f,
+	0x0151, 0x0151,
+	0x0153, 0x0153,
+	0x0155, 0x0155,
+	0x0157, 0x0157,
+	0x0159, 0x0159,
+	0x015b, 0x015b,
+	0x015d, 0x015d,
+	0x015f, 0x015f,
+	0x0161, 0x0161,
+	0x0163, 0x0163,
+	0x0165, 0x0165,
+	0x0167, 0x0167,
+	0x0169, 0x0169,
+	0x016b, 0x016b,
+	0x016d, 0x016d,
+	0x016f, 0x016f,
+	0x0171, 0x0171,
+	0x0173, 0x0173,
+	0x0175, 0x0175,
+	0x0177, 0x0177,
+	0x017a, 0x017a,
+	0x017c, 0x017c,
+	0x017e, 0x0180,
+	0x0183, 0x0183,
+	0x0185, 0x0185,
+	0x0188, 0x0188,
+	0x018c, 0x018c,
+	0x0192, 0x0192,
+	0x0195, 0x0195,
+	0x0199, 0x019a,
+	0x019e, 0x019e,
+	0x01a1, 0x01a1,
+	0x01a3, 0x01a3,
+	0x01a5, 0x01a5,
+	0x01a8, 0x01a8,
+	0x01ad, 0x01ad,
+	0x01b0, 0x01b0,
+	0x01b4, 0x01b4,
+	0x01b6, 0x01b6,
+	0x01b9, 0x01b9,
+	0x01bd, 0x01bd,
+	0x01bf, 0x01bf,
+	0x01c5, 0x01c6,
+	0x01c8, 0x01c9,
+	0x01cb, 0x01cc,
+	0x01ce, 0x01ce,
+	0x01d0, 0x01d0,
+	0x01d2, 0x01d2,
+	0x01d4, 0x01d4,
+	0x01d6, 0x01d6,
+	0x01d8, 0x01d8,
+	0x01da, 0x01da,
+	0x01dc, 0x01dd,
+	0x01df, 0x01df,
+	0x01e1, 0x01e1,
+	0x01e3, 0x01e3,
+	0x01e5, 0x01e5,
+	0x01e7, 0x01e7,
+	0x01e9, 0x01e9,
+	0x01eb, 0x01eb,
+	0x01ed, 0x01ed,
+	0x01ef, 0x01f0,
+	0x01f2, 0x01f3,
+	0x01f5, 0x01f5,
+	0x01f9, 0x01f9,
+	0x01fb, 0x01fb,
+	0x01fd, 0x01fd,
+	0x01ff, 0x01ff,
+	0x0201, 0x0201,
+	0x0203, 0x0203,
+	0x0205, 0x0205,
+	0x0207, 0x0207,
+	0x0209, 0x0209,
+	0x020b, 0x020b,
+	0x020d, 0x020d,
+	0x020f, 0x020f,
+	0x0211, 0x0211,
+	0x0213, 0x0213,
+	0x0215, 0x0215,
+	0x0217, 0x0217,
+	0x0219, 0x0219,
+	0x021b, 0x021b,
+	0x021d, 0x021d,
+	0x021f, 0x021f,
+	0x0223, 0x0223,
+	0x0225, 0x0225,
+	0x0227, 0x0227,
+	0x0229, 0x0229,
+	0x022b, 0x022b,
+	0x022d, 0x022d,
+	0x022f, 0x022f,
+	0x0231, 0x0231,
+	0x0233, 0x0233,
+	0x023c, 0x023c,
+	0x023f, 0x0240,
+	0x0242, 0x0242,
+	0x0247, 0x0247,
+	0x0249, 0x0249,
+	0x024b, 0x024b,
+	0x024d, 0x024d,
+	0x024f, 0x0254,
+	0x0256, 0x0257,
+	0x0259, 0x0259,
+	0x025b, 0x025c,
+	0x0260, 0x0261,
+	0x0263, 0x0263,
+	0x0265, 0x0266,
+	0x0268, 0x0269,
+	0x026b, 0x026c,
+	0x026f, 0x026f,
+	0x0271, 0x0272,
+	0x0275, 0x0275,
+	0x027d, 0x027d,
+	0x0280, 0x0280,
+	0x0283, 0x0283,
+	0x0287, 0x028c,
+	0x0292, 0x0292,
+	0x029e, 0x029e,
+	0x0345, 0x0345,
+	0x0371, 0x0371,
+	0x0373, 0x0373,
+	0x0377, 0x0377,
+	0x037b, 0x037d,
+	0x0390, 0x0390,
+	0x03ac, 0x03ce,
+	0x03d0, 0x03d1,
+	0x03d5, 0x03d7,
+	0x03d9, 0x03d9,
+	0x03db, 0x03db,
+	0x03dd, 0x03dd,
+	0x03df, 0x03df,
+	0x03e1, 0x03e1,
+	0x03e3, 0x03e3,
+	0x03e5, 0x03e5,
+	0x03e7, 0x03e7,
+	0x03e9, 0x03e9,
+	0x03eb, 0x03eb,
+	0x03ed, 0x03ed,
+	0x03ef, 0x03f3,
+	0x03f5, 0x03f5,
+	0x03f8, 0x03f8,
+	0x03fb, 0x03fb,
+	0x0430, 0x045f,
+	0x0461, 0x0461,
+	0x0463, 0x0463,
+	0x0465, 0x0465,
+	0x0467, 0x0467,
+	0x0469, 0x0469,
+	0x046b, 0x046b,
+	0x046d, 0x046d,
+	0x046f, 0x046f,
+	0x0471, 0x0471,
+	0x0473, 0x0473,
+	0x0475, 0x0475,
+	0x0477, 0x0477,
+	0x0479, 0x0479,
+	0x047b, 0x047b,
+	0x047d, 0x047d,
+	0x047f, 0x047f,
+	0x0481, 0x0481,
+	0x048b, 0x048b,
+	0x048d, 0x048d,
+	0x048f, 0x048f,
+	0x0491, 0x0491,
+	0x0493, 0x0493,
+	0x0495, 0x0495,
+	0x0497, 0x0497,
+	0x0499, 0x0499,
+	0x049b, 0x049b,
+	0x049d, 0x049d,
+	0x049f, 0x049f,
+	0x04a1, 0x04a1,
+	0x04a3, 0x04a3,
+	0x04a5, 0x04a5,
+	0x04a7, 0x04a7,
+	0x04a9, 0x04a9,
+	0x04ab, 0x04ab,
+	0x04ad, 0x04ad,
+	0x04af, 0x04af,
+	0x04b1, 0x04b1,
+	0x04b3, 0x04b3,
+	0x04b5, 0x04b5,
+	0x04b7, 0x04b7,
+	0x04b9, 0x04b9,
+	0x04bb, 0x04bb,
+	0x04bd, 0x04bd,
+	0x04bf, 0x04bf,
+	0x04c2, 0x04c2,
+	0x04c4, 0x04c4,
+	0x04c6, 0x04c6,
+	0x04c8, 0x04c8,
+	0x04ca, 0x04ca,
+	0x04cc, 0x04cc,
+	0x04ce, 0x04cf,
+	0x04d1, 0x04d1,
+	0x04d3, 0x04d3,
+	0x04d5, 0x04d5,
+	0x04d7, 0x04d7,
+	0x04d9, 0x04d9,
+	0x04db, 0x04db,
+	0x04dd, 0x04dd,
+	0x04df, 0x04df,
+	0x04e1, 0x04e1,
+	0x04e3, 0x04e3,
+	0x04e5, 0x04e5,
+	0x04e7, 0x04e7,
+	0x04e9, 0x04e9,
+	0x04eb, 0x04eb,
+	0x04ed, 0x04ed,
+	0x04ef, 0x04ef,
+	0x04f1, 0x04f1,
+	0x04f3, 0x04f3,
+	0x04f5, 0x04f5,
+	0x04f7, 0x04f7,
+	0x04f9, 0x04f9,
+	0x04fb, 0x04fb,
+	0x04fd, 0x04fd,
+	0x04ff, 0x04ff,
+	0x0501, 0x0501,
+	0x0503, 0x0503,
+	0x0505, 0x0505,
+	0x0507, 0x0507,
+	0x0509, 0x0509,
+	0x050b, 0x050b,
+	0x050d, 0x050d,
+	0x050f, 0x050f,
+	0x0511, 0x0511,
+	0x0513, 0x0513,
+	0x0515, 0x0515,
+	0x0517, 0x0517,
+	0x0519, 0x0519,
+	0x051b, 0x051b,
+	0x051d, 0x051d,
+	0x051f, 0x051f,
+	0x0521, 0x0521,
+	0x0523, 0x0523,
+	0x0525, 0x0525,
+	0x0527, 0x0527,
+	0x0529, 0x0529,
+	0x052b, 0x052b,
+	0x052d, 0x052d,
+	0x052f, 0x052f,
+	0x0561, 0x0587,
+	0x1d79, 0x1d79,
+	0x1d7d, 0x1d7d,
+	0x1e01, 0x1e01,
+	0x1e03, 0x1e03,
+	0x1e05, 0x1e05,
+	0x1e07, 0x1e07,
+	0x1e09, 0x1e09,
+	0x1e0b, 0x1e0b,
+	0x1e0d, 0x1e0d,
+	0x1e0f, 0x1e0f,
+	0x1e11, 0x1e11,
+	0x1e13, 0x1e13,
+	0x1e15, 0x1e15,
+	0x1e17, 0x1e17,
+	0x1e19, 0x1e19,
+	0x1e1b, 0x1e1b,
+	0x1e1d, 0x1e1d,
+	0x1e1f, 0x1e1f,
+	0x1e21, 0x1e21,
+	0x1e23, 0x1e23,
+	0x1e25, 0x1e25,
+	0x1e27, 0x1e27,
+	0x1e29, 0x1e29,
+	0x1e2b, 0x1e2b,
+	0x1e2d, 0x1e2d,
+	0x1e2f, 0x1e2f,
+	0x1e31, 0x1e31,
+	0x1e33, 0x1e33,
+	0x1e35, 0x1e35,
+	0x1e37, 0x1e37,
+	0x1e39, 0x1e39,
+	0x1e3b, 0x1e3b,
+	0x1e3d, 0x1e3d,
+	0x1e3f, 0x1e3f,
+	0x1e41, 0x1e41,
+	0x1e43, 0x1e43,
+	0x1e45, 0x1e45,
+	0x1e47, 0x1e47,
+	0x1e49, 0x1e49,
+	0x1e4b, 0x1e4b,
+	0x1e4d, 0x1e4d,
+	0x1e4f, 0x1e4f,
+	0x1e51, 0x1e51,
+	0x1e53, 0x1e53,
+	0x1e55, 0x1e55,
+	0x1e57, 0x1e57,
+	0x1e59, 0x1e59,
+	0x1e5b, 0x1e5b,
+	0x1e5d, 0x1e5d,
+	0x1e5f, 0x1e5f,
+	0x1e61, 0x1e61,
+	0x1e63, 0x1e63,
+	0x1e65, 0x1e65,
+	0x1e67, 0x1e67,
+	0x1e69, 0x1e69,
+	0x1e6b, 0x1e6b,
+	0x1e6d, 0x1e6d,
+	0x1e6f, 0x1e6f,
+	0x1e71, 0x1e71,
+	0x1e73, 0x1e73,
+	0x1e75, 0x1e75,
+	0x1e77, 0x1e77,
+	0x1e79, 0x1e79,
+	0x1e7b, 0x1e7b,
+	0x1e7d, 0x1e7d,
+	0x1e7f, 0x1e7f,
+	0x1e81, 0x1e81,
+	0x1e83, 0x1e83,
+	0x1e85, 0x1e85,
+	0x1e87, 0x1e87,
+	0x1e89, 0x1e89,
+	0x1e8b, 0x1e8b,
+	0x1e8d, 0x1e8d,
+	0x1e8f, 0x1e8f,
+	0x1e91, 0x1e91,
+	0x1e93, 0x1e93,
+	0x1e95, 0x1e9b,
+	0x1ea1, 0x1ea1,
+	0x1ea3, 0x1ea3,
+	0x1ea5, 0x1ea5,
+	0x1ea7, 0x1ea7,
+	0x1ea9, 0x1ea9,
+	0x1eab, 0x1eab,
+	0x1ead, 0x1ead,
+	0x1eaf, 0x1eaf,
+	0x1eb1, 0x1eb1,
+	0x1eb3, 0x1eb3,
+	0x1eb5, 0x1eb5,
+	0x1eb7, 0x1eb7,
+	0x1eb9, 0x1eb9,
+	0x1ebb, 0x1ebb,
+	0x1ebd, 0x1ebd,
+	0x1ebf, 0x1ebf,
+	0x1ec1, 0x1ec1,
+	0x1ec3, 0x1ec3,
+	0x1ec5, 0x1ec5,
+	0x1ec7, 0x1ec7,
+	0x1ec9, 0x1ec9,
+	0x1ecb, 0x1ecb,
+	0x1ecd, 0x1ecd,
+	0x1ecf, 0x1ecf,
+	0x1ed1, 0x1ed1,
+	0x1ed3, 0x1ed3,
+	0x1ed5, 0x1ed5,
+	0x1ed7, 0x1ed7,
+	0x1ed9, 0x1ed9,
+	0x1edb, 0x1edb,
+	0x1edd, 0x1edd,
+	0x1edf, 0x1edf,
+	0x1ee1, 0x1ee1,
+	0x1ee3, 0x1ee3,
+	0x1ee5, 0x1ee5,
+	0x1ee7, 0x1ee7,
+	0x1ee9, 0x1ee9,
+	0x1eeb, 0x1eeb,
+	0x1eed, 0x1eed,
+	0x1eef, 0x1eef,
+	0x1ef1, 0x1ef1,
+	0x1ef3, 0x1ef3,
+	0x1ef5, 0x1ef5,
+	0x1ef7, 0x1ef7,
+	0x1ef9, 0x1ef9,
+	0x1efb, 0x1efb,
+	0x1efd, 0x1efd,
+	0x1eff, 0x1f07,
+	0x1f10, 0x1f15,
+	0x1f20, 0x1f27,
+	0x1f30, 0x1f37,
+	0x1f40, 0x1f45,
+	0x1f50, 0x1f57,
+	0x1f60, 0x1f67,
+	0x1f70, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fb7,
+	0x1fbc, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fc7,
+	0x1fcc, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fd7,
+	0x1fe0, 0x1fe7,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ff7,
+	0x1ffc, 0x1ffc,
+	0x214e, 0x214e,
+	0x2170, 0x217f,
+	0x2184, 0x2184,
+	0x24d0, 0x24e9,
+	0x2c30, 0x2c5e,
+	0x2c61, 0x2c61,
+	0x2c65, 0x2c66,
+	0x2c68, 0x2c68,
+	0x2c6a, 0x2c6a,
+	0x2c6c, 0x2c6c,
+	0x2c73, 0x2c73,
+	0x2c76, 0x2c76,
+	0x2c81, 0x2c81,
+	0x2c83, 0x2c83,
+	0x2c85, 0x2c85,
+	0x2c87, 0x2c87,
+	0x2c89, 0x2c89,
+	0x2c8b, 0x2c8b,
+	0x2c8d, 0x2c8d,
+	0x2c8f, 0x2c8f,
+	0x2c91, 0x2c91,
+	0x2c93, 0x2c93,
+	0x2c95, 0x2c95,
+	0x2c97, 0x2c97,
+	0x2c99, 0x2c99,
+	0x2c9b, 0x2c9b,
+	0x2c9d, 0x2c9d,
+	0x2c9f, 0x2c9f,
+	0x2ca1, 0x2ca1,
+	0x2ca3, 0x2ca3,
+	0x2ca5, 0x2ca5,
+	0x2ca7, 0x2ca7,
+	0x2ca9, 0x2ca9,
+	0x2cab, 0x2cab,
+	0x2cad, 0x2cad,
+	0x2caf, 0x2caf,
+	0x2cb1, 0x2cb1,
+	0x2cb3, 0x2cb3,
+	0x2cb5, 0x2cb5,
+	0x2cb7, 0x2cb7,
+	0x2cb9, 0x2cb9,
+	0x2cbb, 0x2cbb,
+	0x2cbd, 0x2cbd,
+	0x2cbf, 0x2cbf,
+	0x2cc1, 0x2cc1,
+	0x2cc3, 0x2cc3,
+	0x2cc5, 0x2cc5,
+	0x2cc7, 0x2cc7,
+	0x2cc9, 0x2cc9,
+	0x2ccb, 0x2ccb,
+	0x2ccd, 0x2ccd,
+	0x2ccf, 0x2ccf,
+	0x2cd1, 0x2cd1,
+	0x2cd3, 0x2cd3,
+	0x2cd5, 0x2cd5,
+	0x2cd7, 0x2cd7,
+	0x2cd9, 0x2cd9,
+	0x2cdb, 0x2cdb,
+	0x2cdd, 0x2cdd,
+	0x2cdf, 0x2cdf,
+	0x2ce1, 0x2ce1,
+	0x2ce3, 0x2ce3,
+	0x2cec, 0x2cec,
+	0x2cee, 0x2cee,
+	0x2cf3, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0xa641, 0xa641,
+	0xa643, 0xa643,
+	0xa645, 0xa645,
+	0xa647, 0xa647,
+	0xa649, 0xa649,
+	0xa64b, 0xa64b,
+	0xa64d, 0xa64d,
+	0xa64f, 0xa64f,
+	0xa651, 0xa651,
+	0xa653, 0xa653,
+	0xa655, 0xa655,
+	0xa657, 0xa657,
+	0xa659, 0xa659,
+	0xa65b, 0xa65b,
+	0xa65d, 0xa65d,
+	0xa65f, 0xa65f,
+	0xa661, 0xa661,
+	0xa663, 0xa663,
+	0xa665, 0xa665,
+	0xa667, 0xa667,
+	0xa669, 0xa669,
+	0xa66b, 0xa66b,
+	0xa66d, 0xa66d,
+	0xa681, 0xa681,
+	0xa683, 0xa683,
+	0xa685, 0xa685,
+	0xa687, 0xa687,
+	0xa689, 0xa689,
+	0xa68b, 0xa68b,
+	0xa68d, 0xa68d,
+	0xa68f, 0xa68f,
+	0xa691, 0xa691,
+	0xa693, 0xa693,
+	0xa695, 0xa695,
+	0xa697, 0xa697,
+	0xa699, 0xa699,
+	0xa69b, 0xa69b,
+	0xa723, 0xa723,
+	0xa725, 0xa725,
+	0xa727, 0xa727,
+	0xa729, 0xa729,
+	0xa72b, 0xa72b,
+	0xa72d, 0xa72d,
+	0xa72f, 0xa72f,
+	0xa733, 0xa733,
+	0xa735, 0xa735,
+	0xa737, 0xa737,
+	0xa739, 0xa739,
+	0xa73b, 0xa73b,
+	0xa73d, 0xa73d,
+	0xa73f, 0xa73f,
+	0xa741, 0xa741,
+	0xa743, 0xa743,
+	0xa745, 0xa745,
+	0xa747, 0xa747,
+	0xa749, 0xa749,
+	0xa74b, 0xa74b,
+	0xa74d, 0xa74d,
+	0xa74f, 0xa74f,
+	0xa751, 0xa751,
+	0xa753, 0xa753,
+	0xa755, 0xa755,
+	0xa757, 0xa757,
+	0xa759, 0xa759,
+	0xa75b, 0xa75b,
+	0xa75d, 0xa75d,
+	0xa75f, 0xa75f,
+	0xa761, 0xa761,
+	0xa763, 0xa763,
+	0xa765, 0xa765,
+	0xa767, 0xa767,
+	0xa769, 0xa769,
+	0xa76b, 0xa76b,
+	0xa76d, 0xa76d,
+	0xa76f, 0xa76f,
+	0xa77a, 0xa77a,
+	0xa77c, 0xa77c,
+	0xa77f, 0xa77f,
+	0xa781, 0xa781,
+	0xa783, 0xa783,
+	0xa785, 0xa785,
+	0xa787, 0xa787,
+	0xa78c, 0xa78c,
+	0xa791, 0xa791,
+	0xa793, 0xa793,
+	0xa797, 0xa797,
+	0xa799, 0xa799,
+	0xa79b, 0xa79b,
+	0xa79d, 0xa79d,
+	0xa79f, 0xa79f,
+	0xa7a1, 0xa7a1,
+	0xa7a3, 0xa7a3,
+	0xa7a5, 0xa7a5,
+	0xa7a7, 0xa7a7,
+	0xa7a9, 0xa7a9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff41, 0xff5a,
+	0x10428, 0x1044f,
+	0x118c0, 0x118df,
+}; /* CR_Changes_When_Uppercased */
+
+/* 'Changes_When_Titlecased': Derived Property */
+static const OnigCodePoint CR_Changes_When_Titlecased[] = {
+	600,
+	0x0061, 0x007a,
+	0x00b5, 0x00b5,
+	0x00df, 0x00f6,
+	0x00f8, 0x00ff,
+	0x0101, 0x0101,
+	0x0103, 0x0103,
+	0x0105, 0x0105,
+	0x0107, 0x0107,
+	0x0109, 0x0109,
+	0x010b, 0x010b,
+	0x010d, 0x010d,
+	0x010f, 0x010f,
+	0x0111, 0x0111,
+	0x0113, 0x0113,
+	0x0115, 0x0115,
+	0x0117, 0x0117,
+	0x0119, 0x0119,
+	0x011b, 0x011b,
+	0x011d, 0x011d,
+	0x011f, 0x011f,
+	0x0121, 0x0121,
+	0x0123, 0x0123,
+	0x0125, 0x0125,
+	0x0127, 0x0127,
+	0x0129, 0x0129,
+	0x012b, 0x012b,
+	0x012d, 0x012d,
+	0x012f, 0x012f,
+	0x0131, 0x0131,
+	0x0133, 0x0133,
+	0x0135, 0x0135,
+	0x0137, 0x0137,
+	0x013a, 0x013a,
+	0x013c, 0x013c,
+	0x013e, 0x013e,
+	0x0140, 0x0140,
+	0x0142, 0x0142,
+	0x0144, 0x0144,
+	0x0146, 0x0146,
+	0x0148, 0x0149,
+	0x014b, 0x014b,
+	0x014d, 0x014d,
+	0x014f, 0x014f,
+	0x0151, 0x0151,
+	0x0153, 0x0153,
+	0x0155, 0x0155,
+	0x0157, 0x0157,
+	0x0159, 0x0159,
+	0x015b, 0x015b,
+	0x015d, 0x015d,
+	0x015f, 0x015f,
+	0x0161, 0x0161,
+	0x0163, 0x0163,
+	0x0165, 0x0165,
+	0x0167, 0x0167,
+	0x0169, 0x0169,
+	0x016b, 0x016b,
+	0x016d, 0x016d,
+	0x016f, 0x016f,
+	0x0171, 0x0171,
+	0x0173, 0x0173,
+	0x0175, 0x0175,
+	0x0177, 0x0177,
+	0x017a, 0x017a,
+	0x017c, 0x017c,
+	0x017e, 0x0180,
+	0x0183, 0x0183,
+	0x0185, 0x0185,
+	0x0188, 0x0188,
+	0x018c, 0x018c,
+	0x0192, 0x0192,
+	0x0195, 0x0195,
+	0x0199, 0x019a,
+	0x019e, 0x019e,
+	0x01a1, 0x01a1,
+	0x01a3, 0x01a3,
+	0x01a5, 0x01a5,
+	0x01a8, 0x01a8,
+	0x01ad, 0x01ad,
+	0x01b0, 0x01b0,
+	0x01b4, 0x01b4,
+	0x01b6, 0x01b6,
+	0x01b9, 0x01b9,
+	0x01bd, 0x01bd,
+	0x01bf, 0x01bf,
+	0x01c4, 0x01c4,
+	0x01c6, 0x01c7,
+	0x01c9, 0x01ca,
+	0x01cc, 0x01cc,
+	0x01ce, 0x01ce,
+	0x01d0, 0x01d0,
+	0x01d2, 0x01d2,
+	0x01d4, 0x01d4,
+	0x01d6, 0x01d6,
+	0x01d8, 0x01d8,
+	0x01da, 0x01da,
+	0x01dc, 0x01dd,
+	0x01df, 0x01df,
+	0x01e1, 0x01e1,
+	0x01e3, 0x01e3,
+	0x01e5, 0x01e5,
+	0x01e7, 0x01e7,
+	0x01e9, 0x01e9,
+	0x01eb, 0x01eb,
+	0x01ed, 0x01ed,
+	0x01ef, 0x01f1,
+	0x01f3, 0x01f3,
+	0x01f5, 0x01f5,
+	0x01f9, 0x01f9,
+	0x01fb, 0x01fb,
+	0x01fd, 0x01fd,
+	0x01ff, 0x01ff,
+	0x0201, 0x0201,
+	0x0203, 0x0203,
+	0x0205, 0x0205,
+	0x0207, 0x0207,
+	0x0209, 0x0209,
+	0x020b, 0x020b,
+	0x020d, 0x020d,
+	0x020f, 0x020f,
+	0x0211, 0x0211,
+	0x0213, 0x0213,
+	0x0215, 0x0215,
+	0x0217, 0x0217,
+	0x0219, 0x0219,
+	0x021b, 0x021b,
+	0x021d, 0x021d,
+	0x021f, 0x021f,
+	0x0223, 0x0223,
+	0x0225, 0x0225,
+	0x0227, 0x0227,
+	0x0229, 0x0229,
+	0x022b, 0x022b,
+	0x022d, 0x022d,
+	0x022f, 0x022f,
+	0x0231, 0x0231,
+	0x0233, 0x0233,
+	0x023c, 0x023c,
+	0x023f, 0x0240,
+	0x0242, 0x0242,
+	0x0247, 0x0247,
+	0x0249, 0x0249,
+	0x024b, 0x024b,
+	0x024d, 0x024d,
+	0x024f, 0x0254,
+	0x0256, 0x0257,
+	0x0259, 0x0259,
+	0x025b, 0x025c,
+	0x0260, 0x0261,
+	0x0263, 0x0263,
+	0x0265, 0x0266,
+	0x0268, 0x0269,
+	0x026b, 0x026c,
+	0x026f, 0x026f,
+	0x0271, 0x0272,
+	0x0275, 0x0275,
+	0x027d, 0x027d,
+	0x0280, 0x0280,
+	0x0283, 0x0283,
+	0x0287, 0x028c,
+	0x0292, 0x0292,
+	0x029e, 0x029e,
+	0x0345, 0x0345,
+	0x0371, 0x0371,
+	0x0373, 0x0373,
+	0x0377, 0x0377,
+	0x037b, 0x037d,
+	0x0390, 0x0390,
+	0x03ac, 0x03ce,
+	0x03d0, 0x03d1,
+	0x03d5, 0x03d7,
+	0x03d9, 0x03d9,
+	0x03db, 0x03db,
+	0x03dd, 0x03dd,
+	0x03df, 0x03df,
+	0x03e1, 0x03e1,
+	0x03e3, 0x03e3,
+	0x03e5, 0x03e5,
+	0x03e7, 0x03e7,
+	0x03e9, 0x03e9,
+	0x03eb, 0x03eb,
+	0x03ed, 0x03ed,
+	0x03ef, 0x03f3,
+	0x03f5, 0x03f5,
+	0x03f8, 0x03f8,
+	0x03fb, 0x03fb,
+	0x0430, 0x045f,
+	0x0461, 0x0461,
+	0x0463, 0x0463,
+	0x0465, 0x0465,
+	0x0467, 0x0467,
+	0x0469, 0x0469,
+	0x046b, 0x046b,
+	0x046d, 0x046d,
+	0x046f, 0x046f,
+	0x0471, 0x0471,
+	0x0473, 0x0473,
+	0x0475, 0x0475,
+	0x0477, 0x0477,
+	0x0479, 0x0479,
+	0x047b, 0x047b,
+	0x047d, 0x047d,
+	0x047f, 0x047f,
+	0x0481, 0x0481,
+	0x048b, 0x048b,
+	0x048d, 0x048d,
+	0x048f, 0x048f,
+	0x0491, 0x0491,
+	0x0493, 0x0493,
+	0x0495, 0x0495,
+	0x0497, 0x0497,
+	0x0499, 0x0499,
+	0x049b, 0x049b,
+	0x049d, 0x049d,
+	0x049f, 0x049f,
+	0x04a1, 0x04a1,
+	0x04a3, 0x04a3,
+	0x04a5, 0x04a5,
+	0x04a7, 0x04a7,
+	0x04a9, 0x04a9,
+	0x04ab, 0x04ab,
+	0x04ad, 0x04ad,
+	0x04af, 0x04af,
+	0x04b1, 0x04b1,
+	0x04b3, 0x04b3,
+	0x04b5, 0x04b5,
+	0x04b7, 0x04b7,
+	0x04b9, 0x04b9,
+	0x04bb, 0x04bb,
+	0x04bd, 0x04bd,
+	0x04bf, 0x04bf,
+	0x04c2, 0x04c2,
+	0x04c4, 0x04c4,
+	0x04c6, 0x04c6,
+	0x04c8, 0x04c8,
+	0x04ca, 0x04ca,
+	0x04cc, 0x04cc,
+	0x04ce, 0x04cf,
+	0x04d1, 0x04d1,
+	0x04d3, 0x04d3,
+	0x04d5, 0x04d5,
+	0x04d7, 0x04d7,
+	0x04d9, 0x04d9,
+	0x04db, 0x04db,
+	0x04dd, 0x04dd,
+	0x04df, 0x04df,
+	0x04e1, 0x04e1,
+	0x04e3, 0x04e3,
+	0x04e5, 0x04e5,
+	0x04e7, 0x04e7,
+	0x04e9, 0x04e9,
+	0x04eb, 0x04eb,
+	0x04ed, 0x04ed,
+	0x04ef, 0x04ef,
+	0x04f1, 0x04f1,
+	0x04f3, 0x04f3,
+	0x04f5, 0x04f5,
+	0x04f7, 0x04f7,
+	0x04f9, 0x04f9,
+	0x04fb, 0x04fb,
+	0x04fd, 0x04fd,
+	0x04ff, 0x04ff,
+	0x0501, 0x0501,
+	0x0503, 0x0503,
+	0x0505, 0x0505,
+	0x0507, 0x0507,
+	0x0509, 0x0509,
+	0x050b, 0x050b,
+	0x050d, 0x050d,
+	0x050f, 0x050f,
+	0x0511, 0x0511,
+	0x0513, 0x0513,
+	0x0515, 0x0515,
+	0x0517, 0x0517,
+	0x0519, 0x0519,
+	0x051b, 0x051b,
+	0x051d, 0x051d,
+	0x051f, 0x051f,
+	0x0521, 0x0521,
+	0x0523, 0x0523,
+	0x0525, 0x0525,
+	0x0527, 0x0527,
+	0x0529, 0x0529,
+	0x052b, 0x052b,
+	0x052d, 0x052d,
+	0x052f, 0x052f,
+	0x0561, 0x0587,
+	0x1d79, 0x1d79,
+	0x1d7d, 0x1d7d,
+	0x1e01, 0x1e01,
+	0x1e03, 0x1e03,
+	0x1e05, 0x1e05,
+	0x1e07, 0x1e07,
+	0x1e09, 0x1e09,
+	0x1e0b, 0x1e0b,
+	0x1e0d, 0x1e0d,
+	0x1e0f, 0x1e0f,
+	0x1e11, 0x1e11,
+	0x1e13, 0x1e13,
+	0x1e15, 0x1e15,
+	0x1e17, 0x1e17,
+	0x1e19, 0x1e19,
+	0x1e1b, 0x1e1b,
+	0x1e1d, 0x1e1d,
+	0x1e1f, 0x1e1f,
+	0x1e21, 0x1e21,
+	0x1e23, 0x1e23,
+	0x1e25, 0x1e25,
+	0x1e27, 0x1e27,
+	0x1e29, 0x1e29,
+	0x1e2b, 0x1e2b,
+	0x1e2d, 0x1e2d,
+	0x1e2f, 0x1e2f,
+	0x1e31, 0x1e31,
+	0x1e33, 0x1e33,
+	0x1e35, 0x1e35,
+	0x1e37, 0x1e37,
+	0x1e39, 0x1e39,
+	0x1e3b, 0x1e3b,
+	0x1e3d, 0x1e3d,
+	0x1e3f, 0x1e3f,
+	0x1e41, 0x1e41,
+	0x1e43, 0x1e43,
+	0x1e45, 0x1e45,
+	0x1e47, 0x1e47,
+	0x1e49, 0x1e49,
+	0x1e4b, 0x1e4b,
+	0x1e4d, 0x1e4d,
+	0x1e4f, 0x1e4f,
+	0x1e51, 0x1e51,
+	0x1e53, 0x1e53,
+	0x1e55, 0x1e55,
+	0x1e57, 0x1e57,
+	0x1e59, 0x1e59,
+	0x1e5b, 0x1e5b,
+	0x1e5d, 0x1e5d,
+	0x1e5f, 0x1e5f,
+	0x1e61, 0x1e61,
+	0x1e63, 0x1e63,
+	0x1e65, 0x1e65,
+	0x1e67, 0x1e67,
+	0x1e69, 0x1e69,
+	0x1e6b, 0x1e6b,
+	0x1e6d, 0x1e6d,
+	0x1e6f, 0x1e6f,
+	0x1e71, 0x1e71,
+	0x1e73, 0x1e73,
+	0x1e75, 0x1e75,
+	0x1e77, 0x1e77,
+	0x1e79, 0x1e79,
+	0x1e7b, 0x1e7b,
+	0x1e7d, 0x1e7d,
+	0x1e7f, 0x1e7f,
+	0x1e81, 0x1e81,
+	0x1e83, 0x1e83,
+	0x1e85, 0x1e85,
+	0x1e87, 0x1e87,
+	0x1e89, 0x1e89,
+	0x1e8b, 0x1e8b,
+	0x1e8d, 0x1e8d,
+	0x1e8f, 0x1e8f,
+	0x1e91, 0x1e91,
+	0x1e93, 0x1e93,
+	0x1e95, 0x1e9b,
+	0x1ea1, 0x1ea1,
+	0x1ea3, 0x1ea3,
+	0x1ea5, 0x1ea5,
+	0x1ea7, 0x1ea7,
+	0x1ea9, 0x1ea9,
+	0x1eab, 0x1eab,
+	0x1ead, 0x1ead,
+	0x1eaf, 0x1eaf,
+	0x1eb1, 0x1eb1,
+	0x1eb3, 0x1eb3,
+	0x1eb5, 0x1eb5,
+	0x1eb7, 0x1eb7,
+	0x1eb9, 0x1eb9,
+	0x1ebb, 0x1ebb,
+	0x1ebd, 0x1ebd,
+	0x1ebf, 0x1ebf,
+	0x1ec1, 0x1ec1,
+	0x1ec3, 0x1ec3,
+	0x1ec5, 0x1ec5,
+	0x1ec7, 0x1ec7,
+	0x1ec9, 0x1ec9,
+	0x1ecb, 0x1ecb,
+	0x1ecd, 0x1ecd,
+	0x1ecf, 0x1ecf,
+	0x1ed1, 0x1ed1,
+	0x1ed3, 0x1ed3,
+	0x1ed5, 0x1ed5,
+	0x1ed7, 0x1ed7,
+	0x1ed9, 0x1ed9,
+	0x1edb, 0x1edb,
+	0x1edd, 0x1edd,
+	0x1edf, 0x1edf,
+	0x1ee1, 0x1ee1,
+	0x1ee3, 0x1ee3,
+	0x1ee5, 0x1ee5,
+	0x1ee7, 0x1ee7,
+	0x1ee9, 0x1ee9,
+	0x1eeb, 0x1eeb,
+	0x1eed, 0x1eed,
+	0x1eef, 0x1eef,
+	0x1ef1, 0x1ef1,
+	0x1ef3, 0x1ef3,
+	0x1ef5, 0x1ef5,
+	0x1ef7, 0x1ef7,
+	0x1ef9, 0x1ef9,
+	0x1efb, 0x1efb,
+	0x1efd, 0x1efd,
+	0x1eff, 0x1f07,
+	0x1f10, 0x1f15,
+	0x1f20, 0x1f27,
+	0x1f30, 0x1f37,
+	0x1f40, 0x1f45,
+	0x1f50, 0x1f57,
+	0x1f60, 0x1f67,
+	0x1f70, 0x1f7d,
+	0x1f80, 0x1f87,
+	0x1f90, 0x1f97,
+	0x1fa0, 0x1fa7,
+	0x1fb0, 0x1fb4,
+	0x1fb6, 0x1fb7,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fc7,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fd7,
+	0x1fe0, 0x1fe7,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ff7,
+	0x214e, 0x214e,
+	0x2170, 0x217f,
+	0x2184, 0x2184,
+	0x24d0, 0x24e9,
+	0x2c30, 0x2c5e,
+	0x2c61, 0x2c61,
+	0x2c65, 0x2c66,
+	0x2c68, 0x2c68,
+	0x2c6a, 0x2c6a,
+	0x2c6c, 0x2c6c,
+	0x2c73, 0x2c73,
+	0x2c76, 0x2c76,
+	0x2c81, 0x2c81,
+	0x2c83, 0x2c83,
+	0x2c85, 0x2c85,
+	0x2c87, 0x2c87,
+	0x2c89, 0x2c89,
+	0x2c8b, 0x2c8b,
+	0x2c8d, 0x2c8d,
+	0x2c8f, 0x2c8f,
+	0x2c91, 0x2c91,
+	0x2c93, 0x2c93,
+	0x2c95, 0x2c95,
+	0x2c97, 0x2c97,
+	0x2c99, 0x2c99,
+	0x2c9b, 0x2c9b,
+	0x2c9d, 0x2c9d,
+	0x2c9f, 0x2c9f,
+	0x2ca1, 0x2ca1,
+	0x2ca3, 0x2ca3,
+	0x2ca5, 0x2ca5,
+	0x2ca7, 0x2ca7,
+	0x2ca9, 0x2ca9,
+	0x2cab, 0x2cab,
+	0x2cad, 0x2cad,
+	0x2caf, 0x2caf,
+	0x2cb1, 0x2cb1,
+	0x2cb3, 0x2cb3,
+	0x2cb5, 0x2cb5,
+	0x2cb7, 0x2cb7,
+	0x2cb9, 0x2cb9,
+	0x2cbb, 0x2cbb,
+	0x2cbd, 0x2cbd,
+	0x2cbf, 0x2cbf,
+	0x2cc1, 0x2cc1,
+	0x2cc3, 0x2cc3,
+	0x2cc5, 0x2cc5,
+	0x2cc7, 0x2cc7,
+	0x2cc9, 0x2cc9,
+	0x2ccb, 0x2ccb,
+	0x2ccd, 0x2ccd,
+	0x2ccf, 0x2ccf,
+	0x2cd1, 0x2cd1,
+	0x2cd3, 0x2cd3,
+	0x2cd5, 0x2cd5,
+	0x2cd7, 0x2cd7,
+	0x2cd9, 0x2cd9,
+	0x2cdb, 0x2cdb,
+	0x2cdd, 0x2cdd,
+	0x2cdf, 0x2cdf,
+	0x2ce1, 0x2ce1,
+	0x2ce3, 0x2ce3,
+	0x2cec, 0x2cec,
+	0x2cee, 0x2cee,
+	0x2cf3, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0xa641, 0xa641,
+	0xa643, 0xa643,
+	0xa645, 0xa645,
+	0xa647, 0xa647,
+	0xa649, 0xa649,
+	0xa64b, 0xa64b,
+	0xa64d, 0xa64d,
+	0xa64f, 0xa64f,
+	0xa651, 0xa651,
+	0xa653, 0xa653,
+	0xa655, 0xa655,
+	0xa657, 0xa657,
+	0xa659, 0xa659,
+	0xa65b, 0xa65b,
+	0xa65d, 0xa65d,
+	0xa65f, 0xa65f,
+	0xa661, 0xa661,
+	0xa663, 0xa663,
+	0xa665, 0xa665,
+	0xa667, 0xa667,
+	0xa669, 0xa669,
+	0xa66b, 0xa66b,
+	0xa66d, 0xa66d,
+	0xa681, 0xa681,
+	0xa683, 0xa683,
+	0xa685, 0xa685,
+	0xa687, 0xa687,
+	0xa689, 0xa689,
+	0xa68b, 0xa68b,
+	0xa68d, 0xa68d,
+	0xa68f, 0xa68f,
+	0xa691, 0xa691,
+	0xa693, 0xa693,
+	0xa695, 0xa695,
+	0xa697, 0xa697,
+	0xa699, 0xa699,
+	0xa69b, 0xa69b,
+	0xa723, 0xa723,
+	0xa725, 0xa725,
+	0xa727, 0xa727,
+	0xa729, 0xa729,
+	0xa72b, 0xa72b,
+	0xa72d, 0xa72d,
+	0xa72f, 0xa72f,
+	0xa733, 0xa733,
+	0xa735, 0xa735,
+	0xa737, 0xa737,
+	0xa739, 0xa739,
+	0xa73b, 0xa73b,
+	0xa73d, 0xa73d,
+	0xa73f, 0xa73f,
+	0xa741, 0xa741,
+	0xa743, 0xa743,
+	0xa745, 0xa745,
+	0xa747, 0xa747,
+	0xa749, 0xa749,
+	0xa74b, 0xa74b,
+	0xa74d, 0xa74d,
+	0xa74f, 0xa74f,
+	0xa751, 0xa751,
+	0xa753, 0xa753,
+	0xa755, 0xa755,
+	0xa757, 0xa757,
+	0xa759, 0xa759,
+	0xa75b, 0xa75b,
+	0xa75d, 0xa75d,
+	0xa75f, 0xa75f,
+	0xa761, 0xa761,
+	0xa763, 0xa763,
+	0xa765, 0xa765,
+	0xa767, 0xa767,
+	0xa769, 0xa769,
+	0xa76b, 0xa76b,
+	0xa76d, 0xa76d,
+	0xa76f, 0xa76f,
+	0xa77a, 0xa77a,
+	0xa77c, 0xa77c,
+	0xa77f, 0xa77f,
+	0xa781, 0xa781,
+	0xa783, 0xa783,
+	0xa785, 0xa785,
+	0xa787, 0xa787,
+	0xa78c, 0xa78c,
+	0xa791, 0xa791,
+	0xa793, 0xa793,
+	0xa797, 0xa797,
+	0xa799, 0xa799,
+	0xa79b, 0xa79b,
+	0xa79d, 0xa79d,
+	0xa79f, 0xa79f,
+	0xa7a1, 0xa7a1,
+	0xa7a3, 0xa7a3,
+	0xa7a5, 0xa7a5,
+	0xa7a7, 0xa7a7,
+	0xa7a9, 0xa7a9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff41, 0xff5a,
+	0x10428, 0x1044f,
+	0x118c0, 0x118df,
+}; /* CR_Changes_When_Titlecased */
+
+/* 'Changes_When_Casefolded': Derived Property */
+static const OnigCodePoint CR_Changes_When_Casefolded[] = {
+	596,
+	0x0041, 0x005a,
+	0x00b5, 0x00b5,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00df,
+	0x0100, 0x0100,
+	0x0102, 0x0102,
+	0x0104, 0x0104,
+	0x0106, 0x0106,
+	0x0108, 0x0108,
+	0x010a, 0x010a,
+	0x010c, 0x010c,
+	0x010e, 0x010e,
+	0x0110, 0x0110,
+	0x0112, 0x0112,
+	0x0114, 0x0114,
+	0x0116, 0x0116,
+	0x0118, 0x0118,
+	0x011a, 0x011a,
+	0x011c, 0x011c,
+	0x011e, 0x011e,
+	0x0120, 0x0120,
+	0x0122, 0x0122,
+	0x0124, 0x0124,
+	0x0126, 0x0126,
+	0x0128, 0x0128,
+	0x012a, 0x012a,
+	0x012c, 0x012c,
+	0x012e, 0x012e,
+	0x0130, 0x0130,
+	0x0132, 0x0132,
+	0x0134, 0x0134,
+	0x0136, 0x0136,
+	0x0139, 0x0139,
+	0x013b, 0x013b,
+	0x013d, 0x013d,
+	0x013f, 0x013f,
+	0x0141, 0x0141,
+	0x0143, 0x0143,
+	0x0145, 0x0145,
+	0x0147, 0x0147,
+	0x0149, 0x014a,
+	0x014c, 0x014c,
+	0x014e, 0x014e,
+	0x0150, 0x0150,
+	0x0152, 0x0152,
+	0x0154, 0x0154,
+	0x0156, 0x0156,
+	0x0158, 0x0158,
+	0x015a, 0x015a,
+	0x015c, 0x015c,
+	0x015e, 0x015e,
+	0x0160, 0x0160,
+	0x0162, 0x0162,
+	0x0164, 0x0164,
+	0x0166, 0x0166,
+	0x0168, 0x0168,
+	0x016a, 0x016a,
+	0x016c, 0x016c,
+	0x016e, 0x016e,
+	0x0170, 0x0170,
+	0x0172, 0x0172,
+	0x0174, 0x0174,
+	0x0176, 0x0176,
+	0x0178, 0x0179,
+	0x017b, 0x017b,
+	0x017d, 0x017d,
+	0x017f, 0x017f,
+	0x0181, 0x0182,
+	0x0184, 0x0184,
+	0x0186, 0x0187,
+	0x0189, 0x018b,
+	0x018e, 0x0191,
+	0x0193, 0x0194,
+	0x0196, 0x0198,
+	0x019c, 0x019d,
+	0x019f, 0x01a0,
+	0x01a2, 0x01a2,
+	0x01a4, 0x01a4,
+	0x01a6, 0x01a7,
+	0x01a9, 0x01a9,
+	0x01ac, 0x01ac,
+	0x01ae, 0x01af,
+	0x01b1, 0x01b3,
+	0x01b5, 0x01b5,
+	0x01b7, 0x01b8,
+	0x01bc, 0x01bc,
+	0x01c4, 0x01c5,
+	0x01c7, 0x01c8,
+	0x01ca, 0x01cb,
+	0x01cd, 0x01cd,
+	0x01cf, 0x01cf,
+	0x01d1, 0x01d1,
+	0x01d3, 0x01d3,
+	0x01d5, 0x01d5,
+	0x01d7, 0x01d7,
+	0x01d9, 0x01d9,
+	0x01db, 0x01db,
+	0x01de, 0x01de,
+	0x01e0, 0x01e0,
+	0x01e2, 0x01e2,
+	0x01e4, 0x01e4,
+	0x01e6, 0x01e6,
+	0x01e8, 0x01e8,
+	0x01ea, 0x01ea,
+	0x01ec, 0x01ec,
+	0x01ee, 0x01ee,
+	0x01f1, 0x01f2,
+	0x01f4, 0x01f4,
+	0x01f6, 0x01f8,
+	0x01fa, 0x01fa,
+	0x01fc, 0x01fc,
+	0x01fe, 0x01fe,
+	0x0200, 0x0200,
+	0x0202, 0x0202,
+	0x0204, 0x0204,
+	0x0206, 0x0206,
+	0x0208, 0x0208,
+	0x020a, 0x020a,
+	0x020c, 0x020c,
+	0x020e, 0x020e,
+	0x0210, 0x0210,
+	0x0212, 0x0212,
+	0x0214, 0x0214,
+	0x0216, 0x0216,
+	0x0218, 0x0218,
+	0x021a, 0x021a,
+	0x021c, 0x021c,
+	0x021e, 0x021e,
+	0x0220, 0x0220,
+	0x0222, 0x0222,
+	0x0224, 0x0224,
+	0x0226, 0x0226,
+	0x0228, 0x0228,
+	0x022a, 0x022a,
+	0x022c, 0x022c,
+	0x022e, 0x022e,
+	0x0230, 0x0230,
+	0x0232, 0x0232,
+	0x023a, 0x023b,
+	0x023d, 0x023e,
+	0x0241, 0x0241,
+	0x0243, 0x0246,
+	0x0248, 0x0248,
+	0x024a, 0x024a,
+	0x024c, 0x024c,
+	0x024e, 0x024e,
+	0x0345, 0x0345,
+	0x0370, 0x0370,
+	0x0372, 0x0372,
+	0x0376, 0x0376,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x038f,
+	0x0391, 0x03a1,
+	0x03a3, 0x03ab,
+	0x03c2, 0x03c2,
+	0x03cf, 0x03d1,
+	0x03d5, 0x03d6,
+	0x03d8, 0x03d8,
+	0x03da, 0x03da,
+	0x03dc, 0x03dc,
+	0x03de, 0x03de,
+	0x03e0, 0x03e0,
+	0x03e2, 0x03e2,
+	0x03e4, 0x03e4,
+	0x03e6, 0x03e6,
+	0x03e8, 0x03e8,
+	0x03ea, 0x03ea,
+	0x03ec, 0x03ec,
+	0x03ee, 0x03ee,
+	0x03f0, 0x03f1,
+	0x03f4, 0x03f5,
+	0x03f7, 0x03f7,
+	0x03f9, 0x03fa,
+	0x03fd, 0x042f,
+	0x0460, 0x0460,
+	0x0462, 0x0462,
+	0x0464, 0x0464,
+	0x0466, 0x0466,
+	0x0468, 0x0468,
+	0x046a, 0x046a,
+	0x046c, 0x046c,
+	0x046e, 0x046e,
+	0x0470, 0x0470,
+	0x0472, 0x0472,
+	0x0474, 0x0474,
+	0x0476, 0x0476,
+	0x0478, 0x0478,
+	0x047a, 0x047a,
+	0x047c, 0x047c,
+	0x047e, 0x047e,
+	0x0480, 0x0480,
+	0x048a, 0x048a,
+	0x048c, 0x048c,
+	0x048e, 0x048e,
+	0x0490, 0x0490,
+	0x0492, 0x0492,
+	0x0494, 0x0494,
+	0x0496, 0x0496,
+	0x0498, 0x0498,
+	0x049a, 0x049a,
+	0x049c, 0x049c,
+	0x049e, 0x049e,
+	0x04a0, 0x04a0,
+	0x04a2, 0x04a2,
+	0x04a4, 0x04a4,
+	0x04a6, 0x04a6,
+	0x04a8, 0x04a8,
+	0x04aa, 0x04aa,
+	0x04ac, 0x04ac,
+	0x04ae, 0x04ae,
+	0x04b0, 0x04b0,
+	0x04b2, 0x04b2,
+	0x04b4, 0x04b4,
+	0x04b6, 0x04b6,
+	0x04b8, 0x04b8,
+	0x04ba, 0x04ba,
+	0x04bc, 0x04bc,
+	0x04be, 0x04be,
+	0x04c0, 0x04c1,
+	0x04c3, 0x04c3,
+	0x04c5, 0x04c5,
+	0x04c7, 0x04c7,
+	0x04c9, 0x04c9,
+	0x04cb, 0x04cb,
+	0x04cd, 0x04cd,
+	0x04d0, 0x04d0,
+	0x04d2, 0x04d2,
+	0x04d4, 0x04d4,
+	0x04d6, 0x04d6,
+	0x04d8, 0x04d8,
+	0x04da, 0x04da,
+	0x04dc, 0x04dc,
+	0x04de, 0x04de,
+	0x04e0, 0x04e0,
+	0x04e2, 0x04e2,
+	0x04e4, 0x04e4,
+	0x04e6, 0x04e6,
+	0x04e8, 0x04e8,
+	0x04ea, 0x04ea,
+	0x04ec, 0x04ec,
+	0x04ee, 0x04ee,
+	0x04f0, 0x04f0,
+	0x04f2, 0x04f2,
+	0x04f4, 0x04f4,
+	0x04f6, 0x04f6,
+	0x04f8, 0x04f8,
+	0x04fa, 0x04fa,
+	0x04fc, 0x04fc,
+	0x04fe, 0x04fe,
+	0x0500, 0x0500,
+	0x0502, 0x0502,
+	0x0504, 0x0504,
+	0x0506, 0x0506,
+	0x0508, 0x0508,
+	0x050a, 0x050a,
+	0x050c, 0x050c,
+	0x050e, 0x050e,
+	0x0510, 0x0510,
+	0x0512, 0x0512,
+	0x0514, 0x0514,
+	0x0516, 0x0516,
+	0x0518, 0x0518,
+	0x051a, 0x051a,
+	0x051c, 0x051c,
+	0x051e, 0x051e,
+	0x0520, 0x0520,
+	0x0522, 0x0522,
+	0x0524, 0x0524,
+	0x0526, 0x0526,
+	0x0528, 0x0528,
+	0x052a, 0x052a,
+	0x052c, 0x052c,
+	0x052e, 0x052e,
+	0x0531, 0x0556,
+	0x0587, 0x0587,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x1e00, 0x1e00,
+	0x1e02, 0x1e02,
+	0x1e04, 0x1e04,
+	0x1e06, 0x1e06,
+	0x1e08, 0x1e08,
+	0x1e0a, 0x1e0a,
+	0x1e0c, 0x1e0c,
+	0x1e0e, 0x1e0e,
+	0x1e10, 0x1e10,
+	0x1e12, 0x1e12,
+	0x1e14, 0x1e14,
+	0x1e16, 0x1e16,
+	0x1e18, 0x1e18,
+	0x1e1a, 0x1e1a,
+	0x1e1c, 0x1e1c,
+	0x1e1e, 0x1e1e,
+	0x1e20, 0x1e20,
+	0x1e22, 0x1e22,
+	0x1e24, 0x1e24,
+	0x1e26, 0x1e26,
+	0x1e28, 0x1e28,
+	0x1e2a, 0x1e2a,
+	0x1e2c, 0x1e2c,
+	0x1e2e, 0x1e2e,
+	0x1e30, 0x1e30,
+	0x1e32, 0x1e32,
+	0x1e34, 0x1e34,
+	0x1e36, 0x1e36,
+	0x1e38, 0x1e38,
+	0x1e3a, 0x1e3a,
+	0x1e3c, 0x1e3c,
+	0x1e3e, 0x1e3e,
+	0x1e40, 0x1e40,
+	0x1e42, 0x1e42,
+	0x1e44, 0x1e44,
+	0x1e46, 0x1e46,
+	0x1e48, 0x1e48,
+	0x1e4a, 0x1e4a,
+	0x1e4c, 0x1e4c,
+	0x1e4e, 0x1e4e,
+	0x1e50, 0x1e50,
+	0x1e52, 0x1e52,
+	0x1e54, 0x1e54,
+	0x1e56, 0x1e56,
+	0x1e58, 0x1e58,
+	0x1e5a, 0x1e5a,
+	0x1e5c, 0x1e5c,
+	0x1e5e, 0x1e5e,
+	0x1e60, 0x1e60,
+	0x1e62, 0x1e62,
+	0x1e64, 0x1e64,
+	0x1e66, 0x1e66,
+	0x1e68, 0x1e68,
+	0x1e6a, 0x1e6a,
+	0x1e6c, 0x1e6c,
+	0x1e6e, 0x1e6e,
+	0x1e70, 0x1e70,
+	0x1e72, 0x1e72,
+	0x1e74, 0x1e74,
+	0x1e76, 0x1e76,
+	0x1e78, 0x1e78,
+	0x1e7a, 0x1e7a,
+	0x1e7c, 0x1e7c,
+	0x1e7e, 0x1e7e,
+	0x1e80, 0x1e80,
+	0x1e82, 0x1e82,
+	0x1e84, 0x1e84,
+	0x1e86, 0x1e86,
+	0x1e88, 0x1e88,
+	0x1e8a, 0x1e8a,
+	0x1e8c, 0x1e8c,
+	0x1e8e, 0x1e8e,
+	0x1e90, 0x1e90,
+	0x1e92, 0x1e92,
+	0x1e94, 0x1e94,
+	0x1e9a, 0x1e9b,
+	0x1e9e, 0x1e9e,
+	0x1ea0, 0x1ea0,
+	0x1ea2, 0x1ea2,
+	0x1ea4, 0x1ea4,
+	0x1ea6, 0x1ea6,
+	0x1ea8, 0x1ea8,
+	0x1eaa, 0x1eaa,
+	0x1eac, 0x1eac,
+	0x1eae, 0x1eae,
+	0x1eb0, 0x1eb0,
+	0x1eb2, 0x1eb2,
+	0x1eb4, 0x1eb4,
+	0x1eb6, 0x1eb6,
+	0x1eb8, 0x1eb8,
+	0x1eba, 0x1eba,
+	0x1ebc, 0x1ebc,
+	0x1ebe, 0x1ebe,
+	0x1ec0, 0x1ec0,
+	0x1ec2, 0x1ec2,
+	0x1ec4, 0x1ec4,
+	0x1ec6, 0x1ec6,
+	0x1ec8, 0x1ec8,
+	0x1eca, 0x1eca,
+	0x1ecc, 0x1ecc,
+	0x1ece, 0x1ece,
+	0x1ed0, 0x1ed0,
+	0x1ed2, 0x1ed2,
+	0x1ed4, 0x1ed4,
+	0x1ed6, 0x1ed6,
+	0x1ed8, 0x1ed8,
+	0x1eda, 0x1eda,
+	0x1edc, 0x1edc,
+	0x1ede, 0x1ede,
+	0x1ee0, 0x1ee0,
+	0x1ee2, 0x1ee2,
+	0x1ee4, 0x1ee4,
+	0x1ee6, 0x1ee6,
+	0x1ee8, 0x1ee8,
+	0x1eea, 0x1eea,
+	0x1eec, 0x1eec,
+	0x1eee, 0x1eee,
+	0x1ef0, 0x1ef0,
+	0x1ef2, 0x1ef2,
+	0x1ef4, 0x1ef4,
+	0x1ef6, 0x1ef6,
+	0x1ef8, 0x1ef8,
+	0x1efa, 0x1efa,
+	0x1efc, 0x1efc,
+	0x1efe, 0x1efe,
+	0x1f08, 0x1f0f,
+	0x1f18, 0x1f1d,
+	0x1f28, 0x1f2f,
+	0x1f38, 0x1f3f,
+	0x1f48, 0x1f4d,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f5f,
+	0x1f68, 0x1f6f,
+	0x1f80, 0x1faf,
+	0x1fb2, 0x1fb4,
+	0x1fb7, 0x1fbc,
+	0x1fc2, 0x1fc4,
+	0x1fc7, 0x1fcc,
+	0x1fd8, 0x1fdb,
+	0x1fe8, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff7, 0x1ffc,
+	0x2126, 0x2126,
+	0x212a, 0x212b,
+	0x2132, 0x2132,
+	0x2160, 0x216f,
+	0x2183, 0x2183,
+	0x24b6, 0x24cf,
+	0x2c00, 0x2c2e,
+	0x2c60, 0x2c60,
+	0x2c62, 0x2c64,
+	0x2c67, 0x2c67,
+	0x2c69, 0x2c69,
+	0x2c6b, 0x2c6b,
+	0x2c6d, 0x2c70,
+	0x2c72, 0x2c72,
+	0x2c75, 0x2c75,
+	0x2c7e, 0x2c80,
+	0x2c82, 0x2c82,
+	0x2c84, 0x2c84,
+	0x2c86, 0x2c86,
+	0x2c88, 0x2c88,
+	0x2c8a, 0x2c8a,
+	0x2c8c, 0x2c8c,
+	0x2c8e, 0x2c8e,
+	0x2c90, 0x2c90,
+	0x2c92, 0x2c92,
+	0x2c94, 0x2c94,
+	0x2c96, 0x2c96,
+	0x2c98, 0x2c98,
+	0x2c9a, 0x2c9a,
+	0x2c9c, 0x2c9c,
+	0x2c9e, 0x2c9e,
+	0x2ca0, 0x2ca0,
+	0x2ca2, 0x2ca2,
+	0x2ca4, 0x2ca4,
+	0x2ca6, 0x2ca6,
+	0x2ca8, 0x2ca8,
+	0x2caa, 0x2caa,
+	0x2cac, 0x2cac,
+	0x2cae, 0x2cae,
+	0x2cb0, 0x2cb0,
+	0x2cb2, 0x2cb2,
+	0x2cb4, 0x2cb4,
+	0x2cb6, 0x2cb6,
+	0x2cb8, 0x2cb8,
+	0x2cba, 0x2cba,
+	0x2cbc, 0x2cbc,
+	0x2cbe, 0x2cbe,
+	0x2cc0, 0x2cc0,
+	0x2cc2, 0x2cc2,
+	0x2cc4, 0x2cc4,
+	0x2cc6, 0x2cc6,
+	0x2cc8, 0x2cc8,
+	0x2cca, 0x2cca,
+	0x2ccc, 0x2ccc,
+	0x2cce, 0x2cce,
+	0x2cd0, 0x2cd0,
+	0x2cd2, 0x2cd2,
+	0x2cd4, 0x2cd4,
+	0x2cd6, 0x2cd6,
+	0x2cd8, 0x2cd8,
+	0x2cda, 0x2cda,
+	0x2cdc, 0x2cdc,
+	0x2cde, 0x2cde,
+	0x2ce0, 0x2ce0,
+	0x2ce2, 0x2ce2,
+	0x2ceb, 0x2ceb,
+	0x2ced, 0x2ced,
+	0x2cf2, 0x2cf2,
+	0xa640, 0xa640,
+	0xa642, 0xa642,
+	0xa644, 0xa644,
+	0xa646, 0xa646,
+	0xa648, 0xa648,
+	0xa64a, 0xa64a,
+	0xa64c, 0xa64c,
+	0xa64e, 0xa64e,
+	0xa650, 0xa650,
+	0xa652, 0xa652,
+	0xa654, 0xa654,
+	0xa656, 0xa656,
+	0xa658, 0xa658,
+	0xa65a, 0xa65a,
+	0xa65c, 0xa65c,
+	0xa65e, 0xa65e,
+	0xa660, 0xa660,
+	0xa662, 0xa662,
+	0xa664, 0xa664,
+	0xa666, 0xa666,
+	0xa668, 0xa668,
+	0xa66a, 0xa66a,
+	0xa66c, 0xa66c,
+	0xa680, 0xa680,
+	0xa682, 0xa682,
+	0xa684, 0xa684,
+	0xa686, 0xa686,
+	0xa688, 0xa688,
+	0xa68a, 0xa68a,
+	0xa68c, 0xa68c,
+	0xa68e, 0xa68e,
+	0xa690, 0xa690,
+	0xa692, 0xa692,
+	0xa694, 0xa694,
+	0xa696, 0xa696,
+	0xa698, 0xa698,
+	0xa69a, 0xa69a,
+	0xa722, 0xa722,
+	0xa724, 0xa724,
+	0xa726, 0xa726,
+	0xa728, 0xa728,
+	0xa72a, 0xa72a,
+	0xa72c, 0xa72c,
+	0xa72e, 0xa72e,
+	0xa732, 0xa732,
+	0xa734, 0xa734,
+	0xa736, 0xa736,
+	0xa738, 0xa738,
+	0xa73a, 0xa73a,
+	0xa73c, 0xa73c,
+	0xa73e, 0xa73e,
+	0xa740, 0xa740,
+	0xa742, 0xa742,
+	0xa744, 0xa744,
+	0xa746, 0xa746,
+	0xa748, 0xa748,
+	0xa74a, 0xa74a,
+	0xa74c, 0xa74c,
+	0xa74e, 0xa74e,
+	0xa750, 0xa750,
+	0xa752, 0xa752,
+	0xa754, 0xa754,
+	0xa756, 0xa756,
+	0xa758, 0xa758,
+	0xa75a, 0xa75a,
+	0xa75c, 0xa75c,
+	0xa75e, 0xa75e,
+	0xa760, 0xa760,
+	0xa762, 0xa762,
+	0xa764, 0xa764,
+	0xa766, 0xa766,
+	0xa768, 0xa768,
+	0xa76a, 0xa76a,
+	0xa76c, 0xa76c,
+	0xa76e, 0xa76e,
+	0xa779, 0xa779,
+	0xa77b, 0xa77b,
+	0xa77d, 0xa77e,
+	0xa780, 0xa780,
+	0xa782, 0xa782,
+	0xa784, 0xa784,
+	0xa786, 0xa786,
+	0xa78b, 0xa78b,
+	0xa78d, 0xa78d,
+	0xa790, 0xa790,
+	0xa792, 0xa792,
+	0xa796, 0xa796,
+	0xa798, 0xa798,
+	0xa79a, 0xa79a,
+	0xa79c, 0xa79c,
+	0xa79e, 0xa79e,
+	0xa7a0, 0xa7a0,
+	0xa7a2, 0xa7a2,
+	0xa7a4, 0xa7a4,
+	0xa7a6, 0xa7a6,
+	0xa7a8, 0xa7a8,
+	0xa7aa, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff21, 0xff3a,
+	0x10400, 0x10427,
+	0x118a0, 0x118bf,
+}; /* CR_Changes_When_Casefolded */
+
+/* 'Changes_When_Casemapped': Derived Property */
+static const OnigCodePoint CR_Changes_When_Casemapped[] = {
+	107,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00b5, 0x00b5,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x0137,
+	0x0139, 0x018c,
+	0x018e, 0x019a,
+	0x019c, 0x01a9,
+	0x01ac, 0x01b9,
+	0x01bc, 0x01bd,
+	0x01bf, 0x01bf,
+	0x01c4, 0x0220,
+	0x0222, 0x0233,
+	0x023a, 0x0254,
+	0x0256, 0x0257,
+	0x0259, 0x0259,
+	0x025b, 0x025c,
+	0x0260, 0x0261,
+	0x0263, 0x0263,
+	0x0265, 0x0266,
+	0x0268, 0x0269,
+	0x026b, 0x026c,
+	0x026f, 0x026f,
+	0x0271, 0x0272,
+	0x0275, 0x0275,
+	0x027d, 0x027d,
+	0x0280, 0x0280,
+	0x0283, 0x0283,
+	0x0287, 0x028c,
+	0x0292, 0x0292,
+	0x029e, 0x029e,
+	0x0345, 0x0345,
+	0x0370, 0x0373,
+	0x0376, 0x0377,
+	0x037b, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03d1,
+	0x03d5, 0x03f5,
+	0x03f7, 0x03fb,
+	0x03fd, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0561, 0x0587,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x1d79, 0x1d79,
+	0x1d7d, 0x1d7d,
+	0x1e00, 0x1e9b,
+	0x1e9e, 0x1e9e,
+	0x1ea0, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2126, 0x2126,
+	0x212a, 0x212b,
+	0x2132, 0x2132,
+	0x214e, 0x214e,
+	0x2160, 0x217f,
+	0x2183, 0x2184,
+	0x24b6, 0x24e9,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2c70,
+	0x2c72, 0x2c73,
+	0x2c75, 0x2c76,
+	0x2c7e, 0x2ce3,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0xa640, 0xa66d,
+	0xa680, 0xa69b,
+	0xa722, 0xa72f,
+	0xa732, 0xa76f,
+	0xa779, 0xa787,
+	0xa78b, 0xa78d,
+	0xa790, 0xa793,
+	0xa796, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0x10400, 0x1044f,
+	0x118a0, 0x118df,
+}; /* CR_Changes_When_Casemapped */
+
+/* 'ID_Start': Derived Property */
+static const OnigCodePoint CR_ID_Start[] = {
+	538,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0370, 0x0374,
+	0x0376, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0620, 0x064a,
+	0x066e, 0x066f,
+	0x0671, 0x06d3,
+	0x06d5, 0x06d5,
+	0x06e5, 0x06e6,
+	0x06ee, 0x06ef,
+	0x06fa, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x0710,
+	0x0712, 0x072f,
+	0x074d, 0x07a5,
+	0x07b1, 0x07b1,
+	0x07ca, 0x07ea,
+	0x07f4, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x0815,
+	0x081a, 0x081a,
+	0x0824, 0x0824,
+	0x0828, 0x0828,
+	0x0840, 0x0858,
+	0x08a0, 0x08b2,
+	0x0904, 0x0939,
+	0x093d, 0x093d,
+	0x0950, 0x0950,
+	0x0958, 0x0961,
+	0x0971, 0x0980,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bd, 0x09bd,
+	0x09ce, 0x09ce,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e1,
+	0x09f0, 0x09f1,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a72, 0x0a74,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abd, 0x0abd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae1,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3d, 0x0b3d,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b71, 0x0b71,
+	0x0b83, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bd0, 0x0bd0,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c3d,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c61,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbd, 0x0cbd,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0cf1, 0x0cf2,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d3d,
+	0x0d4e, 0x0d4e,
+	0x0d60, 0x0d61,
+	0x0d7a, 0x0d7f,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0e01, 0x0e30,
+	0x0e32, 0x0e33,
+	0x0e40, 0x0e46,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb0,
+	0x0eb2, 0x0eb3,
+	0x0ebd, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f40, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f88, 0x0f8c,
+	0x1000, 0x102a,
+	0x103f, 0x103f,
+	0x1050, 0x1055,
+	0x105a, 0x105d,
+	0x1061, 0x1061,
+	0x1065, 0x1066,
+	0x106e, 0x1070,
+	0x1075, 0x1081,
+	0x108e, 0x108e,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1711,
+	0x1720, 0x1731,
+	0x1740, 0x1751,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1780, 0x17b3,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dc,
+	0x1820, 0x1877,
+	0x1880, 0x18a8,
+	0x18aa, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1950, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19c1, 0x19c7,
+	0x1a00, 0x1a16,
+	0x1a20, 0x1a54,
+	0x1aa7, 0x1aa7,
+	0x1b05, 0x1b33,
+	0x1b45, 0x1b4b,
+	0x1b83, 0x1ba0,
+	0x1bae, 0x1baf,
+	0x1bba, 0x1be5,
+	0x1c00, 0x1c23,
+	0x1c4d, 0x1c4f,
+	0x1c5a, 0x1c7d,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf1,
+	0x1cf5, 0x1cf6,
+	0x1d00, 0x1dbf,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2118, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x3005, 0x3007,
+	0x3021, 0x3029,
+	0x3031, 0x3035,
+	0x3038, 0x303c,
+	0x3041, 0x3096,
+	0x309b, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa61f,
+	0xa62a, 0xa62b,
+	0xa640, 0xa66e,
+	0xa67f, 0xa69d,
+	0xa6a0, 0xa6ef,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa801,
+	0xa803, 0xa805,
+	0xa807, 0xa80a,
+	0xa80c, 0xa822,
+	0xa840, 0xa873,
+	0xa882, 0xa8b3,
+	0xa8f2, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa90a, 0xa925,
+	0xa930, 0xa946,
+	0xa960, 0xa97c,
+	0xa984, 0xa9b2,
+	0xa9cf, 0xa9cf,
+	0xa9e0, 0xa9e4,
+	0xa9e6, 0xa9ef,
+	0xa9fa, 0xa9fe,
+	0xaa00, 0xaa28,
+	0xaa40, 0xaa42,
+	0xaa44, 0xaa4b,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaa7a,
+	0xaa7e, 0xaaaf,
+	0xaab1, 0xaab1,
+	0xaab5, 0xaab6,
+	0xaab9, 0xaabd,
+	0xaac0, 0xaac0,
+	0xaac2, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaea,
+	0xaaf2, 0xaaf4,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabe2,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb1d,
+	0xfb1f, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0xff66, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10140, 0x10174,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031f,
+	0x10330, 0x1034a,
+	0x10350, 0x10375,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x103d1, 0x103d5,
+	0x10400, 0x1049d,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a00,
+	0x10a10, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae4,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11003, 0x11037,
+	0x11083, 0x110af,
+	0x110d0, 0x110e8,
+	0x11103, 0x11126,
+	0x11150, 0x11172,
+	0x11176, 0x11176,
+	0x11183, 0x111b2,
+	0x111c1, 0x111c4,
+	0x111da, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x1122b,
+	0x112b0, 0x112de,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133d, 0x1133d,
+	0x1135d, 0x11361,
+	0x11480, 0x114af,
+	0x114c4, 0x114c5,
+	0x114c7, 0x114c7,
+	0x11580, 0x115ae,
+	0x11600, 0x1162f,
+	0x11644, 0x11644,
+	0x11680, 0x116aa,
+	0x118a0, 0x118df,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16ad0, 0x16aed,
+	0x16b00, 0x16b2f,
+	0x16b40, 0x16b43,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f50,
+	0x16f93, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1e800, 0x1e8c4,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_ID_Start */
+
+/* 'ID_Continue': Derived Property */
+static const OnigCodePoint CR_ID_Continue[] = {
+	626,
+	0x0030, 0x0039,
+	0x0041, 0x005a,
+	0x005f, 0x005f,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00b7, 0x00b7,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0300, 0x0374,
+	0x0376, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x0483, 0x0487,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x0591, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0610, 0x061a,
+	0x0620, 0x0669,
+	0x066e, 0x06d3,
+	0x06d5, 0x06dc,
+	0x06df, 0x06e8,
+	0x06ea, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x082d,
+	0x0840, 0x085b,
+	0x08a0, 0x08b2,
+	0x08e4, 0x0963,
+	0x0966, 0x096f,
+	0x0971, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09f1,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b6f,
+	0x0b71, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bef,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d6f,
+	0x0d7a, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df3,
+	0x0e01, 0x0e3a,
+	0x0e40, 0x0e4e,
+	0x0e50, 0x0e59,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f18, 0x0f19,
+	0x0f20, 0x0f29,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f3e, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f84,
+	0x0f86, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fc6, 0x0fc6,
+	0x1000, 0x1049,
+	0x1050, 0x109d,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x135f,
+	0x1369, 0x1371,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1734,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17d3,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dd,
+	0x17e0, 0x17e9,
+	0x180b, 0x180d,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1946, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x1a00, 0x1a1b,
+	0x1a20, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa7, 0x1aa7,
+	0x1ab0, 0x1abd,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b59,
+	0x1b6b, 0x1b73,
+	0x1b80, 0x1bf3,
+	0x1c00, 0x1c37,
+	0x1c40, 0x1c49,
+	0x1c4d, 0x1c7d,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1cf6,
+	0x1cf8, 0x1cf9,
+	0x1d00, 0x1df5,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x203f, 0x2040,
+	0x2054, 0x2054,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x20d0, 0x20dc,
+	0x20e1, 0x20e1,
+	0x20e5, 0x20f0,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2118, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2dff,
+	0x3005, 0x3007,
+	0x3021, 0x302f,
+	0x3031, 0x3035,
+	0x3038, 0x303c,
+	0x3041, 0x3096,
+	0x3099, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa62b,
+	0xa640, 0xa66f,
+	0xa674, 0xa67d,
+	0xa67f, 0xa69d,
+	0xa69f, 0xa6f1,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa827,
+	0xa840, 0xa873,
+	0xa880, 0xa8c4,
+	0xa8d0, 0xa8d9,
+	0xa8e0, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa900, 0xa92d,
+	0xa930, 0xa953,
+	0xa960, 0xa97c,
+	0xa980, 0xa9c0,
+	0xa9cf, 0xa9d9,
+	0xa9e0, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaef,
+	0xaaf2, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabea,
+	0xabec, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe2d,
+	0xfe33, 0xfe34,
+	0xfe4d, 0xfe4f,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff10, 0xff19,
+	0xff21, 0xff3a,
+	0xff3f, 0xff3f,
+	0xff41, 0xff5a,
+	0xff66, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10140, 0x10174,
+	0x101fd, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e0, 0x102e0,
+	0x10300, 0x1031f,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x103d1, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a3f,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae6,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11000, 0x11046,
+	0x11066, 0x1106f,
+	0x1107f, 0x110ba,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x1113f,
+	0x11150, 0x11173,
+	0x11176, 0x11176,
+	0x11180, 0x111c4,
+	0x111d0, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x11237,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x11480, 0x114c5,
+	0x114c7, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c0,
+	0x11600, 0x11640,
+	0x11644, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118e9,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af4,
+	0x16b00, 0x16b36,
+	0x16b40, 0x16b43,
+	0x16b50, 0x16b59,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9d, 0x1bc9e,
+	0x1d165, 0x1d169,
+	0x1d16d, 0x1d172,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1d242, 0x1d244,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8d0, 0x1e8d6,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0xe0100, 0xe01ef,
+}; /* CR_ID_Continue */
+
+/* 'XID_Start': Derived Property */
+static const OnigCodePoint CR_XID_Start[] = {
+	545,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0370, 0x0374,
+	0x0376, 0x0377,
+	0x037b, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0620, 0x064a,
+	0x066e, 0x066f,
+	0x0671, 0x06d3,
+	0x06d5, 0x06d5,
+	0x06e5, 0x06e6,
+	0x06ee, 0x06ef,
+	0x06fa, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x0710,
+	0x0712, 0x072f,
+	0x074d, 0x07a5,
+	0x07b1, 0x07b1,
+	0x07ca, 0x07ea,
+	0x07f4, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x0815,
+	0x081a, 0x081a,
+	0x0824, 0x0824,
+	0x0828, 0x0828,
+	0x0840, 0x0858,
+	0x08a0, 0x08b2,
+	0x0904, 0x0939,
+	0x093d, 0x093d,
+	0x0950, 0x0950,
+	0x0958, 0x0961,
+	0x0971, 0x0980,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bd, 0x09bd,
+	0x09ce, 0x09ce,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e1,
+	0x09f0, 0x09f1,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a72, 0x0a74,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abd, 0x0abd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae1,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3d, 0x0b3d,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b71, 0x0b71,
+	0x0b83, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bd0, 0x0bd0,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c3d,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c61,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbd, 0x0cbd,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0cf1, 0x0cf2,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d3d,
+	0x0d4e, 0x0d4e,
+	0x0d60, 0x0d61,
+	0x0d7a, 0x0d7f,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0e01, 0x0e30,
+	0x0e32, 0x0e32,
+	0x0e40, 0x0e46,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb0,
+	0x0eb2, 0x0eb2,
+	0x0ebd, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f40, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f88, 0x0f8c,
+	0x1000, 0x102a,
+	0x103f, 0x103f,
+	0x1050, 0x1055,
+	0x105a, 0x105d,
+	0x1061, 0x1061,
+	0x1065, 0x1066,
+	0x106e, 0x1070,
+	0x1075, 0x1081,
+	0x108e, 0x108e,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1711,
+	0x1720, 0x1731,
+	0x1740, 0x1751,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1780, 0x17b3,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dc,
+	0x1820, 0x1877,
+	0x1880, 0x18a8,
+	0x18aa, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1950, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19c1, 0x19c7,
+	0x1a00, 0x1a16,
+	0x1a20, 0x1a54,
+	0x1aa7, 0x1aa7,
+	0x1b05, 0x1b33,
+	0x1b45, 0x1b4b,
+	0x1b83, 0x1ba0,
+	0x1bae, 0x1baf,
+	0x1bba, 0x1be5,
+	0x1c00, 0x1c23,
+	0x1c4d, 0x1c4f,
+	0x1c5a, 0x1c7d,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf1,
+	0x1cf5, 0x1cf6,
+	0x1d00, 0x1dbf,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2118, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x3005, 0x3007,
+	0x3021, 0x3029,
+	0x3031, 0x3035,
+	0x3038, 0x303c,
+	0x3041, 0x3096,
+	0x309d, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa61f,
+	0xa62a, 0xa62b,
+	0xa640, 0xa66e,
+	0xa67f, 0xa69d,
+	0xa6a0, 0xa6ef,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa801,
+	0xa803, 0xa805,
+	0xa807, 0xa80a,
+	0xa80c, 0xa822,
+	0xa840, 0xa873,
+	0xa882, 0xa8b3,
+	0xa8f2, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa90a, 0xa925,
+	0xa930, 0xa946,
+	0xa960, 0xa97c,
+	0xa984, 0xa9b2,
+	0xa9cf, 0xa9cf,
+	0xa9e0, 0xa9e4,
+	0xa9e6, 0xa9ef,
+	0xa9fa, 0xa9fe,
+	0xaa00, 0xaa28,
+	0xaa40, 0xaa42,
+	0xaa44, 0xaa4b,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaa7a,
+	0xaa7e, 0xaaaf,
+	0xaab1, 0xaab1,
+	0xaab5, 0xaab6,
+	0xaab9, 0xaabd,
+	0xaac0, 0xaac0,
+	0xaac2, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaea,
+	0xaaf2, 0xaaf4,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabe2,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb1d,
+	0xfb1f, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfc5d,
+	0xfc64, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdf9,
+	0xfe71, 0xfe71,
+	0xfe73, 0xfe73,
+	0xfe77, 0xfe77,
+	0xfe79, 0xfe79,
+	0xfe7b, 0xfe7b,
+	0xfe7d, 0xfe7d,
+	0xfe7f, 0xfefc,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+	0xff66, 0xff9d,
+	0xffa0, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10140, 0x10174,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031f,
+	0x10330, 0x1034a,
+	0x10350, 0x10375,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x103d1, 0x103d5,
+	0x10400, 0x1049d,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a00,
+	0x10a10, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae4,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11003, 0x11037,
+	0x11083, 0x110af,
+	0x110d0, 0x110e8,
+	0x11103, 0x11126,
+	0x11150, 0x11172,
+	0x11176, 0x11176,
+	0x11183, 0x111b2,
+	0x111c1, 0x111c4,
+	0x111da, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x1122b,
+	0x112b0, 0x112de,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133d, 0x1133d,
+	0x1135d, 0x11361,
+	0x11480, 0x114af,
+	0x114c4, 0x114c5,
+	0x114c7, 0x114c7,
+	0x11580, 0x115ae,
+	0x11600, 0x1162f,
+	0x11644, 0x11644,
+	0x11680, 0x116aa,
+	0x118a0, 0x118df,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16ad0, 0x16aed,
+	0x16b00, 0x16b2f,
+	0x16b40, 0x16b43,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f50,
+	0x16f93, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1e800, 0x1e8c4,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_XID_Start */
+
+/* 'XID_Continue': Derived Property */
+static const OnigCodePoint CR_XID_Continue[] = {
+	633,
+	0x0030, 0x0039,
+	0x0041, 0x005a,
+	0x005f, 0x005f,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00b5, 0x00b5,
+	0x00b7, 0x00b7,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02c1,
+	0x02c6, 0x02d1,
+	0x02e0, 0x02e4,
+	0x02ec, 0x02ec,
+	0x02ee, 0x02ee,
+	0x0300, 0x0374,
+	0x0376, 0x0377,
+	0x037b, 0x037d,
+	0x037f, 0x037f,
+	0x0386, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03f5,
+	0x03f7, 0x0481,
+	0x0483, 0x0487,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x0559,
+	0x0561, 0x0587,
+	0x0591, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f2,
+	0x0610, 0x061a,
+	0x0620, 0x0669,
+	0x066e, 0x06d3,
+	0x06d5, 0x06dc,
+	0x06df, 0x06e8,
+	0x06ea, 0x06fc,
+	0x06ff, 0x06ff,
+	0x0710, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07f5,
+	0x07fa, 0x07fa,
+	0x0800, 0x082d,
+	0x0840, 0x085b,
+	0x08a0, 0x08b2,
+	0x08e4, 0x0963,
+	0x0966, 0x096f,
+	0x0971, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09f1,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b6f,
+	0x0b71, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bef,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d6f,
+	0x0d7a, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df3,
+	0x0e01, 0x0e3a,
+	0x0e40, 0x0e4e,
+	0x0e50, 0x0e59,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f00,
+	0x0f18, 0x0f19,
+	0x0f20, 0x0f29,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f3e, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f84,
+	0x0f86, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fc6, 0x0fc6,
+	0x1000, 0x1049,
+	0x1050, 0x109d,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x135f,
+	0x1369, 0x1371,
+	0x1380, 0x138f,
+	0x13a0, 0x13f4,
+	0x1401, 0x166c,
+	0x166f, 0x167f,
+	0x1681, 0x169a,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1734,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17d3,
+	0x17d7, 0x17d7,
+	0x17dc, 0x17dd,
+	0x17e0, 0x17e9,
+	0x180b, 0x180d,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1946, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x1a00, 0x1a1b,
+	0x1a20, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa7, 0x1aa7,
+	0x1ab0, 0x1abd,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b59,
+	0x1b6b, 0x1b73,
+	0x1b80, 0x1bf3,
+	0x1c00, 0x1c37,
+	0x1c40, 0x1c49,
+	0x1c4d, 0x1c7d,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1cf6,
+	0x1cf8, 0x1cf9,
+	0x1d00, 0x1df5,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fbc,
+	0x1fbe, 0x1fbe,
+	0x1fc2, 0x1fc4,
+	0x1fc6, 0x1fcc,
+	0x1fd0, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fe0, 0x1fec,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffc,
+	0x203f, 0x2040,
+	0x2054, 0x2054,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x20d0, 0x20dc,
+	0x20e1, 0x20e1,
+	0x20e5, 0x20f0,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2118, 0x211d,
+	0x2124, 0x2124,
+	0x2126, 0x2126,
+	0x2128, 0x2128,
+	0x212a, 0x2139,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2ce4,
+	0x2ceb, 0x2cf3,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d6f,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2dff,
+	0x3005, 0x3007,
+	0x3021, 0x302f,
+	0x3031, 0x3035,
+	0x3038, 0x303c,
+	0x3041, 0x3096,
+	0x3099, 0x309a,
+	0x309d, 0x309f,
+	0x30a1, 0x30fa,
+	0x30fc, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x31a0, 0x31ba,
+	0x31f0, 0x31ff,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa4d0, 0xa4fd,
+	0xa500, 0xa60c,
+	0xa610, 0xa62b,
+	0xa640, 0xa66f,
+	0xa674, 0xa67d,
+	0xa67f, 0xa69d,
+	0xa69f, 0xa6f1,
+	0xa717, 0xa71f,
+	0xa722, 0xa788,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa827,
+	0xa840, 0xa873,
+	0xa880, 0xa8c4,
+	0xa8d0, 0xa8d9,
+	0xa8e0, 0xa8f7,
+	0xa8fb, 0xa8fb,
+	0xa900, 0xa92d,
+	0xa930, 0xa953,
+	0xa960, 0xa97c,
+	0xa980, 0xa9c0,
+	0xa9cf, 0xa9d9,
+	0xa9e0, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa60, 0xaa76,
+	0xaa7a, 0xaac2,
+	0xaadb, 0xaadd,
+	0xaae0, 0xaaef,
+	0xaaf2, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabea,
+	0xabec, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb28,
+	0xfb2a, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfc5d,
+	0xfc64, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdf9,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe2d,
+	0xfe33, 0xfe34,
+	0xfe4d, 0xfe4f,
+	0xfe71, 0xfe71,
+	0xfe73, 0xfe73,
+	0xfe77, 0xfe77,
+	0xfe79, 0xfe79,
+	0xfe7b, 0xfe7b,
+	0xfe7d, 0xfe7d,
+	0xfe7f, 0xfefc,
+	0xff10, 0xff19,
+	0xff21, 0xff3a,
+	0xff3f, 0xff3f,
+	0xff41, 0xff5a,
+	0xff66, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10140, 0x10174,
+	0x101fd, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e0, 0x102e0,
+	0x10300, 0x1031f,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103cf,
+	0x103d1, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10860, 0x10876,
+	0x10880, 0x1089e,
+	0x10900, 0x10915,
+	0x10920, 0x10939,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a3f,
+	0x10a60, 0x10a7c,
+	0x10a80, 0x10a9c,
+	0x10ac0, 0x10ac7,
+	0x10ac9, 0x10ae6,
+	0x10b00, 0x10b35,
+	0x10b40, 0x10b55,
+	0x10b60, 0x10b72,
+	0x10b80, 0x10b91,
+	0x10c00, 0x10c48,
+	0x11000, 0x11046,
+	0x11066, 0x1106f,
+	0x1107f, 0x110ba,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x1113f,
+	0x11150, 0x11173,
+	0x11176, 0x11176,
+	0x11180, 0x111c4,
+	0x111d0, 0x111da,
+	0x11200, 0x11211,
+	0x11213, 0x11237,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x11480, 0x114c5,
+	0x114c7, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c0,
+	0x11600, 0x11640,
+	0x11644, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118e9,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af4,
+	0x16b00, 0x16b36,
+	0x16b40, 0x16b43,
+	0x16b50, 0x16b59,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9d, 0x1bc9e,
+	0x1d165, 0x1d169,
+	0x1d16d, 0x1d172,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1d242, 0x1d244,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8d0, 0x1e8d6,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0xe0100, 0xe01ef,
+}; /* CR_XID_Continue */
+
+/* 'Default_Ignorable_Code_Point': Derived Property */
+static const OnigCodePoint CR_Default_Ignorable_Code_Point[] = {
+	17,
+	0x00ad, 0x00ad,
+	0x034f, 0x034f,
+	0x061c, 0x061c,
+	0x115f, 0x1160,
+	0x17b4, 0x17b5,
+	0x180b, 0x180e,
+	0x200b, 0x200f,
+	0x202a, 0x202e,
+	0x2060, 0x206f,
+	0x3164, 0x3164,
+	0xfe00, 0xfe0f,
+	0xfeff, 0xfeff,
+	0xffa0, 0xffa0,
+	0xfff0, 0xfff8,
+	0x1bca0, 0x1bca3,
+	0x1d173, 0x1d17a,
+	0xe0000, 0xe0fff,
+}; /* CR_Default_Ignorable_Code_Point */
+
+/* 'Grapheme_Extend': Derived Property */
+static const OnigCodePoint CR_Grapheme_Extend[] = {
+	272,
+	0x0300, 0x036f,
+	0x0483, 0x0489,
+	0x0591, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x0610, 0x061a,
+	0x064b, 0x065f,
+	0x0670, 0x0670,
+	0x06d6, 0x06dc,
+	0x06df, 0x06e4,
+	0x06e7, 0x06e8,
+	0x06ea, 0x06ed,
+	0x0711, 0x0711,
+	0x0730, 0x074a,
+	0x07a6, 0x07b0,
+	0x07eb, 0x07f3,
+	0x0816, 0x0819,
+	0x081b, 0x0823,
+	0x0825, 0x0827,
+	0x0829, 0x082d,
+	0x0859, 0x085b,
+	0x08e4, 0x0902,
+	0x093a, 0x093a,
+	0x093c, 0x093c,
+	0x0941, 0x0948,
+	0x094d, 0x094d,
+	0x0951, 0x0957,
+	0x0962, 0x0963,
+	0x0981, 0x0981,
+	0x09bc, 0x09bc,
+	0x09be, 0x09be,
+	0x09c1, 0x09c4,
+	0x09cd, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09e2, 0x09e3,
+	0x0a01, 0x0a02,
+	0x0a3c, 0x0a3c,
+	0x0a41, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a70, 0x0a71,
+	0x0a75, 0x0a75,
+	0x0a81, 0x0a82,
+	0x0abc, 0x0abc,
+	0x0ac1, 0x0ac5,
+	0x0ac7, 0x0ac8,
+	0x0acd, 0x0acd,
+	0x0ae2, 0x0ae3,
+	0x0b01, 0x0b01,
+	0x0b3c, 0x0b3c,
+	0x0b3e, 0x0b3f,
+	0x0b41, 0x0b44,
+	0x0b4d, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b62, 0x0b63,
+	0x0b82, 0x0b82,
+	0x0bbe, 0x0bbe,
+	0x0bc0, 0x0bc0,
+	0x0bcd, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0c00, 0x0c00,
+	0x0c3e, 0x0c40,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c62, 0x0c63,
+	0x0c81, 0x0c81,
+	0x0cbc, 0x0cbc,
+	0x0cbf, 0x0cbf,
+	0x0cc2, 0x0cc2,
+	0x0cc6, 0x0cc6,
+	0x0ccc, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0ce2, 0x0ce3,
+	0x0d01, 0x0d01,
+	0x0d3e, 0x0d3e,
+	0x0d41, 0x0d44,
+	0x0d4d, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d62, 0x0d63,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dcf,
+	0x0dd2, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0ddf, 0x0ddf,
+	0x0e31, 0x0e31,
+	0x0e34, 0x0e3a,
+	0x0e47, 0x0e4e,
+	0x0eb1, 0x0eb1,
+	0x0eb4, 0x0eb9,
+	0x0ebb, 0x0ebc,
+	0x0ec8, 0x0ecd,
+	0x0f18, 0x0f19,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f71, 0x0f7e,
+	0x0f80, 0x0f84,
+	0x0f86, 0x0f87,
+	0x0f8d, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fc6, 0x0fc6,
+	0x102d, 0x1030,
+	0x1032, 0x1037,
+	0x1039, 0x103a,
+	0x103d, 0x103e,
+	0x1058, 0x1059,
+	0x105e, 0x1060,
+	0x1071, 0x1074,
+	0x1082, 0x1082,
+	0x1085, 0x1086,
+	0x108d, 0x108d,
+	0x109d, 0x109d,
+	0x135d, 0x135f,
+	0x1712, 0x1714,
+	0x1732, 0x1734,
+	0x1752, 0x1753,
+	0x1772, 0x1773,
+	0x17b4, 0x17b5,
+	0x17b7, 0x17bd,
+	0x17c6, 0x17c6,
+	0x17c9, 0x17d3,
+	0x17dd, 0x17dd,
+	0x180b, 0x180d,
+	0x18a9, 0x18a9,
+	0x1920, 0x1922,
+	0x1927, 0x1928,
+	0x1932, 0x1932,
+	0x1939, 0x193b,
+	0x1a17, 0x1a18,
+	0x1a1b, 0x1a1b,
+	0x1a56, 0x1a56,
+	0x1a58, 0x1a5e,
+	0x1a60, 0x1a60,
+	0x1a62, 0x1a62,
+	0x1a65, 0x1a6c,
+	0x1a73, 0x1a7c,
+	0x1a7f, 0x1a7f,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b03,
+	0x1b34, 0x1b34,
+	0x1b36, 0x1b3a,
+	0x1b3c, 0x1b3c,
+	0x1b42, 0x1b42,
+	0x1b6b, 0x1b73,
+	0x1b80, 0x1b81,
+	0x1ba2, 0x1ba5,
+	0x1ba8, 0x1ba9,
+	0x1bab, 0x1bad,
+	0x1be6, 0x1be6,
+	0x1be8, 0x1be9,
+	0x1bed, 0x1bed,
+	0x1bef, 0x1bf1,
+	0x1c2c, 0x1c33,
+	0x1c36, 0x1c37,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1ce0,
+	0x1ce2, 0x1ce8,
+	0x1ced, 0x1ced,
+	0x1cf4, 0x1cf4,
+	0x1cf8, 0x1cf9,
+	0x1dc0, 0x1df5,
+	0x1dfc, 0x1dff,
+	0x200c, 0x200d,
+	0x20d0, 0x20f0,
+	0x2cef, 0x2cf1,
+	0x2d7f, 0x2d7f,
+	0x2de0, 0x2dff,
+	0x302a, 0x302f,
+	0x3099, 0x309a,
+	0xa66f, 0xa672,
+	0xa674, 0xa67d,
+	0xa69f, 0xa69f,
+	0xa6f0, 0xa6f1,
+	0xa802, 0xa802,
+	0xa806, 0xa806,
+	0xa80b, 0xa80b,
+	0xa825, 0xa826,
+	0xa8c4, 0xa8c4,
+	0xa8e0, 0xa8f1,
+	0xa926, 0xa92d,
+	0xa947, 0xa951,
+	0xa980, 0xa982,
+	0xa9b3, 0xa9b3,
+	0xa9b6, 0xa9b9,
+	0xa9bc, 0xa9bc,
+	0xa9e5, 0xa9e5,
+	0xaa29, 0xaa2e,
+	0xaa31, 0xaa32,
+	0xaa35, 0xaa36,
+	0xaa43, 0xaa43,
+	0xaa4c, 0xaa4c,
+	0xaa7c, 0xaa7c,
+	0xaab0, 0xaab0,
+	0xaab2, 0xaab4,
+	0xaab7, 0xaab8,
+	0xaabe, 0xaabf,
+	0xaac1, 0xaac1,
+	0xaaec, 0xaaed,
+	0xaaf6, 0xaaf6,
+	0xabe5, 0xabe5,
+	0xabe8, 0xabe8,
+	0xabed, 0xabed,
+	0xfb1e, 0xfb1e,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe2d,
+	0xff9e, 0xff9f,
+	0x101fd, 0x101fd,
+	0x102e0, 0x102e0,
+	0x10376, 0x1037a,
+	0x10a01, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a0f,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a3f,
+	0x10ae5, 0x10ae6,
+	0x11001, 0x11001,
+	0x11038, 0x11046,
+	0x1107f, 0x11081,
+	0x110b3, 0x110b6,
+	0x110b9, 0x110ba,
+	0x11100, 0x11102,
+	0x11127, 0x1112b,
+	0x1112d, 0x11134,
+	0x11173, 0x11173,
+	0x11180, 0x11181,
+	0x111b6, 0x111be,
+	0x1122f, 0x11231,
+	0x11234, 0x11234,
+	0x11236, 0x11237,
+	0x112df, 0x112df,
+	0x112e3, 0x112ea,
+	0x11301, 0x11301,
+	0x1133c, 0x1133c,
+	0x1133e, 0x1133e,
+	0x11340, 0x11340,
+	0x11357, 0x11357,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x114b0, 0x114b0,
+	0x114b3, 0x114b8,
+	0x114ba, 0x114ba,
+	0x114bd, 0x114bd,
+	0x114bf, 0x114c0,
+	0x114c2, 0x114c3,
+	0x115af, 0x115af,
+	0x115b2, 0x115b5,
+	0x115bc, 0x115bd,
+	0x115bf, 0x115c0,
+	0x11633, 0x1163a,
+	0x1163d, 0x1163d,
+	0x1163f, 0x11640,
+	0x116ab, 0x116ab,
+	0x116ad, 0x116ad,
+	0x116b0, 0x116b5,
+	0x116b7, 0x116b7,
+	0x16af0, 0x16af4,
+	0x16b30, 0x16b36,
+	0x16f8f, 0x16f92,
+	0x1bc9d, 0x1bc9e,
+	0x1d165, 0x1d165,
+	0x1d167, 0x1d169,
+	0x1d16e, 0x1d172,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1d242, 0x1d244,
+	0x1e8d0, 0x1e8d6,
+	0xe0100, 0xe01ef,
+}; /* CR_Grapheme_Extend */
+
+/* 'Grapheme_Base': Derived Property */
+static const OnigCodePoint CR_Grapheme_Base[] = {
+	724,
+	0x0020, 0x007e,
+	0x00a0, 0x00ac,
+	0x00ae, 0x02ff,
+	0x0370, 0x0377,
+	0x037a, 0x037f,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x0482,
+	0x048a, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058d, 0x058f,
+	0x05be, 0x05be,
+	0x05c0, 0x05c0,
+	0x05c3, 0x05c3,
+	0x05c6, 0x05c6,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0606, 0x060f,
+	0x061b, 0x061b,
+	0x061e, 0x064a,
+	0x0660, 0x066f,
+	0x0671, 0x06d5,
+	0x06de, 0x06de,
+	0x06e5, 0x06e6,
+	0x06e9, 0x06e9,
+	0x06ee, 0x070d,
+	0x0710, 0x0710,
+	0x0712, 0x072f,
+	0x074d, 0x07a5,
+	0x07b1, 0x07b1,
+	0x07c0, 0x07ea,
+	0x07f4, 0x07fa,
+	0x0800, 0x0815,
+	0x081a, 0x081a,
+	0x0824, 0x0824,
+	0x0828, 0x0828,
+	0x0830, 0x083e,
+	0x0840, 0x0858,
+	0x085e, 0x085e,
+	0x08a0, 0x08b2,
+	0x0903, 0x0939,
+	0x093b, 0x093b,
+	0x093d, 0x0940,
+	0x0949, 0x094c,
+	0x094e, 0x0950,
+	0x0958, 0x0961,
+	0x0964, 0x0980,
+	0x0982, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bd, 0x09bd,
+	0x09bf, 0x09c0,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cc,
+	0x09ce, 0x09ce,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e1,
+	0x09e6, 0x09fb,
+	0x0a03, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3e, 0x0a40,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a6f,
+	0x0a72, 0x0a74,
+	0x0a83, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abd, 0x0ac0,
+	0x0ac9, 0x0ac9,
+	0x0acb, 0x0acc,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae1,
+	0x0ae6, 0x0af1,
+	0x0b02, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3d, 0x0b3d,
+	0x0b40, 0x0b40,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4c,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b77,
+	0x0b83, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbf, 0x0bbf,
+	0x0bc1, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcc,
+	0x0bd0, 0x0bd0,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c3d,
+	0x0c41, 0x0c44,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbd, 0x0cbe,
+	0x0cc0, 0x0cc1,
+	0x0cc3, 0x0cc4,
+	0x0cc7, 0x0cc8,
+	0x0cca, 0x0ccb,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d3d,
+	0x0d3f, 0x0d40,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4c,
+	0x0d4e, 0x0d4e,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dd0, 0x0dd1,
+	0x0dd8, 0x0dde,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e30,
+	0x0e32, 0x0e33,
+	0x0e3f, 0x0e46,
+	0x0e4f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb0,
+	0x0eb2, 0x0eb3,
+	0x0ebd, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f17,
+	0x0f1a, 0x0f34,
+	0x0f36, 0x0f36,
+	0x0f38, 0x0f38,
+	0x0f3a, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f7f, 0x0f7f,
+	0x0f85, 0x0f85,
+	0x0f88, 0x0f8c,
+	0x0fbe, 0x0fc5,
+	0x0fc7, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x102c,
+	0x1031, 0x1031,
+	0x1038, 0x1038,
+	0x103b, 0x103c,
+	0x103f, 0x1057,
+	0x105a, 0x105d,
+	0x1061, 0x1070,
+	0x1075, 0x1081,
+	0x1083, 0x1084,
+	0x1087, 0x108c,
+	0x108e, 0x109c,
+	0x109e, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x1360, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1711,
+	0x1720, 0x1731,
+	0x1735, 0x1736,
+	0x1740, 0x1751,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1780, 0x17b3,
+	0x17b6, 0x17b6,
+	0x17be, 0x17c5,
+	0x17c7, 0x17c8,
+	0x17d4, 0x17dc,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180a,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18a8,
+	0x18aa, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1923, 0x1926,
+	0x1929, 0x192b,
+	0x1930, 0x1931,
+	0x1933, 0x1938,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a16,
+	0x1a19, 0x1a1a,
+	0x1a1e, 0x1a55,
+	0x1a57, 0x1a57,
+	0x1a61, 0x1a61,
+	0x1a63, 0x1a64,
+	0x1a6d, 0x1a72,
+	0x1a80, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1b04, 0x1b33,
+	0x1b35, 0x1b35,
+	0x1b3b, 0x1b3b,
+	0x1b3d, 0x1b41,
+	0x1b43, 0x1b4b,
+	0x1b50, 0x1b6a,
+	0x1b74, 0x1b7c,
+	0x1b82, 0x1ba1,
+	0x1ba6, 0x1ba7,
+	0x1baa, 0x1baa,
+	0x1bae, 0x1be5,
+	0x1be7, 0x1be7,
+	0x1bea, 0x1bec,
+	0x1bee, 0x1bee,
+	0x1bf2, 0x1bf3,
+	0x1bfc, 0x1c2b,
+	0x1c34, 0x1c35,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd3, 0x1cd3,
+	0x1ce1, 0x1ce1,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf3,
+	0x1cf5, 0x1cf6,
+	0x1d00, 0x1dbf,
+	0x1e00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x200a,
+	0x2010, 0x2027,
+	0x202f, 0x205f,
+	0x2070, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20bd,
+	0x2100, 0x2189,
+	0x2190, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cee,
+	0x2cf2, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2e00, 0x2e42,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x3029,
+	0x3030, 0x303f,
+	0x3041, 0x3096,
+	0x309b, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa66e,
+	0xa673, 0xa673,
+	0xa67e, 0xa69d,
+	0xa6a0, 0xa6ef,
+	0xa6f2, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa801,
+	0xa803, 0xa805,
+	0xa807, 0xa80a,
+	0xa80c, 0xa824,
+	0xa827, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c3,
+	0xa8ce, 0xa8d9,
+	0xa8f2, 0xa8fb,
+	0xa900, 0xa925,
+	0xa92e, 0xa946,
+	0xa952, 0xa953,
+	0xa95f, 0xa97c,
+	0xa983, 0xa9b2,
+	0xa9b4, 0xa9b5,
+	0xa9ba, 0xa9bb,
+	0xa9bd, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9e4,
+	0xa9e6, 0xa9fe,
+	0xaa00, 0xaa28,
+	0xaa2f, 0xaa30,
+	0xaa33, 0xaa34,
+	0xaa40, 0xaa42,
+	0xaa44, 0xaa4b,
+	0xaa4d, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa7b,
+	0xaa7d, 0xaaaf,
+	0xaab1, 0xaab1,
+	0xaab5, 0xaab6,
+	0xaab9, 0xaabd,
+	0xaac0, 0xaac0,
+	0xaac2, 0xaac2,
+	0xaadb, 0xaaeb,
+	0xaaee, 0xaaf5,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabe4,
+	0xabe6, 0xabe7,
+	0xabe9, 0xabec,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb1d,
+	0xfb1f, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfd,
+	0xfe10, 0xfe19,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xff01, 0xff9d,
+	0xffa0, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfffc, 0xfffd,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018c,
+	0x10190, 0x1019b,
+	0x101a0, 0x101a0,
+	0x101d0, 0x101fc,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e1, 0x102fb,
+	0x10300, 0x10323,
+	0x10330, 0x1034a,
+	0x10350, 0x10375,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x1056f, 0x1056f,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1089e,
+	0x108a7, 0x108af,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a00,
+	0x10a10, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a40, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a9f,
+	0x10ac0, 0x10ae4,
+	0x10aeb, 0x10af6,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b91,
+	0x10b99, 0x10b9c,
+	0x10ba9, 0x10baf,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x11000,
+	0x11002, 0x11037,
+	0x11047, 0x1104d,
+	0x11052, 0x1106f,
+	0x11082, 0x110b2,
+	0x110b7, 0x110b8,
+	0x110bb, 0x110bc,
+	0x110be, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11103, 0x11126,
+	0x1112c, 0x1112c,
+	0x11136, 0x11143,
+	0x11150, 0x11172,
+	0x11174, 0x11176,
+	0x11182, 0x111b5,
+	0x111bf, 0x111c8,
+	0x111cd, 0x111cd,
+	0x111d0, 0x111da,
+	0x111e1, 0x111f4,
+	0x11200, 0x11211,
+	0x11213, 0x1122e,
+	0x11232, 0x11233,
+	0x11235, 0x11235,
+	0x11238, 0x1123d,
+	0x112b0, 0x112de,
+	0x112e0, 0x112e2,
+	0x112f0, 0x112f9,
+	0x11302, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133d, 0x1133d,
+	0x1133f, 0x1133f,
+	0x11341, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x1135d, 0x11363,
+	0x11480, 0x114af,
+	0x114b1, 0x114b2,
+	0x114b9, 0x114b9,
+	0x114bb, 0x114bc,
+	0x114be, 0x114be,
+	0x114c1, 0x114c1,
+	0x114c4, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115ae,
+	0x115b0, 0x115b1,
+	0x115b8, 0x115bb,
+	0x115be, 0x115be,
+	0x115c1, 0x115c9,
+	0x11600, 0x11632,
+	0x1163b, 0x1163c,
+	0x1163e, 0x1163e,
+	0x11641, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116aa,
+	0x116ac, 0x116ac,
+	0x116ae, 0x116af,
+	0x116b6, 0x116b6,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118f2,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x12470, 0x12474,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16a6e, 0x16a6f,
+	0x16ad0, 0x16aed,
+	0x16af5, 0x16af5,
+	0x16b00, 0x16b2f,
+	0x16b37, 0x16b45,
+	0x16b50, 0x16b59,
+	0x16b5b, 0x16b61,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f93, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9c, 0x1bc9c,
+	0x1bc9f, 0x1bc9f,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d164,
+	0x1d166, 0x1d166,
+	0x1d16a, 0x1d16d,
+	0x1d183, 0x1d184,
+	0x1d18c, 0x1d1a9,
+	0x1d1ae, 0x1d1dd,
+	0x1d200, 0x1d241,
+	0x1d245, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8c7, 0x1e8cf,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f100, 0x1f10c,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_Grapheme_Base */
+
+/* 'Grapheme_Link': Derived Property */
+static const OnigCodePoint CR_Grapheme_Link[] = {
+	40,
+	0x094d, 0x094d,
+	0x09cd, 0x09cd,
+	0x0a4d, 0x0a4d,
+	0x0acd, 0x0acd,
+	0x0b4d, 0x0b4d,
+	0x0bcd, 0x0bcd,
+	0x0c4d, 0x0c4d,
+	0x0ccd, 0x0ccd,
+	0x0d4d, 0x0d4d,
+	0x0dca, 0x0dca,
+	0x0e3a, 0x0e3a,
+	0x0f84, 0x0f84,
+	0x1039, 0x103a,
+	0x1714, 0x1714,
+	0x1734, 0x1734,
+	0x17d2, 0x17d2,
+	0x1a60, 0x1a60,
+	0x1b44, 0x1b44,
+	0x1baa, 0x1bab,
+	0x1bf2, 0x1bf3,
+	0x2d7f, 0x2d7f,
+	0xa806, 0xa806,
+	0xa8c4, 0xa8c4,
+	0xa953, 0xa953,
+	0xa9c0, 0xa9c0,
+	0xaaf6, 0xaaf6,
+	0xabed, 0xabed,
+	0x10a3f, 0x10a3f,
+	0x11046, 0x11046,
+	0x1107f, 0x1107f,
+	0x110b9, 0x110b9,
+	0x11133, 0x11134,
+	0x111c0, 0x111c0,
+	0x11235, 0x11235,
+	0x112ea, 0x112ea,
+	0x1134d, 0x1134d,
+	0x114c2, 0x114c2,
+	0x115bf, 0x115bf,
+	0x1163f, 0x1163f,
+	0x116b6, 0x116b6,
+}; /* CR_Grapheme_Link */
+
+/* 'Common': Script */
+static const OnigCodePoint CR_Common[] = {
+	165,
+	0x0000, 0x0040,
+	0x005b, 0x0060,
+	0x007b, 0x00a9,
+	0x00ab, 0x00b9,
+	0x00bb, 0x00bf,
+	0x00d7, 0x00d7,
+	0x00f7, 0x00f7,
+	0x02b9, 0x02df,
+	0x02e5, 0x02e9,
+	0x02ec, 0x02ff,
+	0x0374, 0x0374,
+	0x037e, 0x037e,
+	0x0385, 0x0385,
+	0x0387, 0x0387,
+	0x0589, 0x0589,
+	0x0605, 0x0605,
+	0x060c, 0x060c,
+	0x061b, 0x061c,
+	0x061f, 0x061f,
+	0x0640, 0x0640,
+	0x0660, 0x0669,
+	0x06dd, 0x06dd,
+	0x0964, 0x0965,
+	0x0e3f, 0x0e3f,
+	0x0fd5, 0x0fd8,
+	0x10fb, 0x10fb,
+	0x16eb, 0x16ed,
+	0x1735, 0x1736,
+	0x1802, 0x1803,
+	0x1805, 0x1805,
+	0x1cd3, 0x1cd3,
+	0x1ce1, 0x1ce1,
+	0x1ce9, 0x1cec,
+	0x1cee, 0x1cf3,
+	0x1cf5, 0x1cf6,
+	0x2000, 0x200b,
+	0x200e, 0x2064,
+	0x2066, 0x2070,
+	0x2074, 0x207e,
+	0x2080, 0x208e,
+	0x20a0, 0x20bd,
+	0x2100, 0x2125,
+	0x2127, 0x2129,
+	0x212c, 0x2131,
+	0x2133, 0x214d,
+	0x214f, 0x215f,
+	0x2189, 0x2189,
+	0x2190, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x27ff,
+	0x2900, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2e00, 0x2e42,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x3004,
+	0x3006, 0x3006,
+	0x3008, 0x3020,
+	0x3030, 0x3037,
+	0x303c, 0x303f,
+	0x309b, 0x309c,
+	0x30a0, 0x30a0,
+	0x30fb, 0x30fc,
+	0x3190, 0x319f,
+	0x31c0, 0x31e3,
+	0x3220, 0x325f,
+	0x327f, 0x32cf,
+	0x3358, 0x33ff,
+	0x4dc0, 0x4dff,
+	0xa700, 0xa721,
+	0xa788, 0xa78a,
+	0xa830, 0xa839,
+	0xa92e, 0xa92e,
+	0xa9cf, 0xa9cf,
+	0xab5b, 0xab5b,
+	0xfd3e, 0xfd3f,
+	0xfe10, 0xfe19,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfeff, 0xfeff,
+	0xff01, 0xff20,
+	0xff3b, 0xff40,
+	0xff5b, 0xff65,
+	0xff70, 0xff70,
+	0xff9e, 0xff9f,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0xfffd,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1013f,
+	0x10190, 0x1019b,
+	0x101d0, 0x101fc,
+	0x102e1, 0x102fb,
+	0x1bca0, 0x1bca3,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d166,
+	0x1d16a, 0x1d17a,
+	0x1d183, 0x1d184,
+	0x1d18c, 0x1d1a9,
+	0x1d1ae, 0x1d1dd,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f100, 0x1f10c,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f1ff,
+	0x1f201, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+}; /* CR_Common */
+
+/* 'Latin': Script */
+static const OnigCodePoint CR_Latin[] = {
+	33,
+	0x0041, 0x005a,
+	0x0061, 0x007a,
+	0x00aa, 0x00aa,
+	0x00ba, 0x00ba,
+	0x00c0, 0x00d6,
+	0x00d8, 0x00f6,
+	0x00f8, 0x02b8,
+	0x02e0, 0x02e4,
+	0x1d00, 0x1d25,
+	0x1d2c, 0x1d5c,
+	0x1d62, 0x1d65,
+	0x1d6b, 0x1d77,
+	0x1d79, 0x1dbe,
+	0x1e00, 0x1eff,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x212a, 0x212b,
+	0x2132, 0x2132,
+	0x214e, 0x214e,
+	0x2160, 0x2188,
+	0x2c60, 0x2c7f,
+	0xa722, 0xa787,
+	0xa78b, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa7ff,
+	0xab30, 0xab5a,
+	0xab5c, 0xab5f,
+	0xab64, 0xab64,
+	0xfb00, 0xfb06,
+	0xff21, 0xff3a,
+	0xff41, 0xff5a,
+}; /* CR_Latin */
+
+/* 'Greek': Script */
+static const OnigCodePoint CR_Greek[] = {
+	36,
+	0x0370, 0x0373,
+	0x0375, 0x0377,
+	0x037a, 0x037d,
+	0x037f, 0x037f,
+	0x0384, 0x0384,
+	0x0386, 0x0386,
+	0x0388, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03e1,
+	0x03f0, 0x03ff,
+	0x1d26, 0x1d2a,
+	0x1d5d, 0x1d61,
+	0x1d66, 0x1d6a,
+	0x1dbf, 0x1dbf,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2126, 0x2126,
+	0xab65, 0xab65,
+	0x10140, 0x1018c,
+	0x101a0, 0x101a0,
+	0x1d200, 0x1d245,
+}; /* CR_Greek */
+
+/* 'Cyrillic': Script */
+static const OnigCodePoint CR_Cyrillic[] = {
+	7,
+	0x0400, 0x0484,
+	0x0487, 0x052f,
+	0x1d2b, 0x1d2b,
+	0x1d78, 0x1d78,
+	0x2de0, 0x2dff,
+	0xa640, 0xa69d,
+	0xa69f, 0xa69f,
+}; /* CR_Cyrillic */
+
+/* 'Armenian': Script */
+static const OnigCodePoint CR_Armenian[] = {
+	6,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x058a, 0x058a,
+	0x058d, 0x058f,
+	0xfb13, 0xfb17,
+}; /* CR_Armenian */
+
+/* 'Hebrew': Script */
+static const OnigCodePoint CR_Hebrew[] = {
+	9,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfb4f,
+}; /* CR_Hebrew */
+
+/* 'Arabic': Script */
+static const OnigCodePoint CR_Arabic[] = {
+	55,
+	0x0600, 0x0604,
+	0x0606, 0x060b,
+	0x060d, 0x061a,
+	0x061e, 0x061e,
+	0x0620, 0x063f,
+	0x0641, 0x064a,
+	0x0656, 0x065f,
+	0x066a, 0x066f,
+	0x0671, 0x06dc,
+	0x06de, 0x06ff,
+	0x0750, 0x077f,
+	0x08a0, 0x08b2,
+	0x08e4, 0x08ff,
+	0xfb50, 0xfbc1,
+	0xfbd3, 0xfd3d,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfd,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0x10e60, 0x10e7e,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+}; /* CR_Arabic */
+
+/* 'Syriac': Script */
+static const OnigCodePoint CR_Syriac[] = {
+	3,
+	0x0700, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x074f,
+}; /* CR_Syriac */
+
+/* 'Thaana': Script */
+static const OnigCodePoint CR_Thaana[] = {
+	1,
+	0x0780, 0x07b1,
+}; /* CR_Thaana */
+
+/* 'Devanagari': Script */
+static const OnigCodePoint CR_Devanagari[] = {
+	4,
+	0x0900, 0x0950,
+	0x0953, 0x0963,
+	0x0966, 0x097f,
+	0xa8e0, 0xa8fb,
+}; /* CR_Devanagari */
+
+/* 'Bengali': Script */
+static const OnigCodePoint CR_Bengali[] = {
+	14,
+	0x0980, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+}; /* CR_Bengali */
+
+/* 'Gurmukhi': Script */
+static const OnigCodePoint CR_Gurmukhi[] = {
+	16,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+}; /* CR_Gurmukhi */
+
+/* 'Gujarati': Script */
+static const OnigCodePoint CR_Gujarati[] = {
+	13,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+}; /* CR_Gujarati */
+
+/* 'Oriya': Script */
+static const OnigCodePoint CR_Oriya[] = {
+	14,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+}; /* CR_Oriya */
+
+/* 'Tamil': Script */
+static const OnigCodePoint CR_Tamil[] = {
+	16,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+}; /* CR_Tamil */
+
+/* 'Telugu': Script */
+static const OnigCodePoint CR_Telugu[] = {
+	13,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+}; /* CR_Telugu */
+
+/* 'Kannada': Script */
+static const OnigCodePoint CR_Kannada[] = {
+	14,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+}; /* CR_Kannada */
+
+/* 'Malayalam': Script */
+static const OnigCodePoint CR_Malayalam[] = {
+	11,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+}; /* CR_Malayalam */
+
+/* 'Sinhala': Script */
+static const OnigCodePoint CR_Sinhala[] = {
+	13,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df4,
+	0x111e1, 0x111f4,
+}; /* CR_Sinhala */
+
+/* 'Thai': Script */
+static const OnigCodePoint CR_Thai[] = {
+	2,
+	0x0e01, 0x0e3a,
+	0x0e40, 0x0e5b,
+}; /* CR_Thai */
+
+/* 'Lao': Script */
+static const OnigCodePoint CR_Lao[] = {
+	18,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+}; /* CR_Lao */
+
+/* 'Tibetan': Script */
+static const OnigCodePoint CR_Tibetan[] = {
+	7,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fd4,
+	0x0fd9, 0x0fda,
+}; /* CR_Tibetan */
+
+/* 'Myanmar': Script */
+static const OnigCodePoint CR_Myanmar[] = {
+	3,
+	0x1000, 0x109f,
+	0xa9e0, 0xa9fe,
+	0xaa60, 0xaa7f,
+}; /* CR_Myanmar */
+
+/* 'Georgian': Script */
+static const OnigCodePoint CR_Georgian[] = {
+	8,
+	0x10a0, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x10fa,
+	0x10fc, 0x10ff,
+	0x2d00, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+}; /* CR_Georgian */
+
+/* 'Hangul': Script */
+static const OnigCodePoint CR_Hangul[] = {
+	14,
+	0x1100, 0x11ff,
+	0x302e, 0x302f,
+	0x3131, 0x318e,
+	0x3200, 0x321e,
+	0x3260, 0x327e,
+	0xa960, 0xa97c,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xffa0, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+}; /* CR_Hangul */
+
+/* 'Ethiopic': Script */
+static const OnigCodePoint CR_Ethiopic[] = {
+	32,
+	0x1200, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+}; /* CR_Ethiopic */
+
+/* 'Cherokee': Script */
+static const OnigCodePoint CR_Cherokee[] = {
+	1,
+	0x13a0, 0x13f4,
+}; /* CR_Cherokee */
+
+/* 'Canadian_Aboriginal': Script */
+static const OnigCodePoint CR_Canadian_Aboriginal[] = {
+	2,
+	0x1400, 0x167f,
+	0x18b0, 0x18f5,
+}; /* CR_Canadian_Aboriginal */
+
+/* 'Ogham': Script */
+static const OnigCodePoint CR_Ogham[] = {
+	1,
+	0x1680, 0x169c,
+}; /* CR_Ogham */
+
+/* 'Runic': Script */
+static const OnigCodePoint CR_Runic[] = {
+	2,
+	0x16a0, 0x16ea,
+	0x16ee, 0x16f8,
+}; /* CR_Runic */
+
+/* 'Khmer': Script */
+static const OnigCodePoint CR_Khmer[] = {
+	4,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x19e0, 0x19ff,
+}; /* CR_Khmer */
+
+/* 'Mongolian': Script */
+static const OnigCodePoint CR_Mongolian[] = {
+	6,
+	0x1800, 0x1801,
+	0x1804, 0x1804,
+	0x1806, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+}; /* CR_Mongolian */
+
+/* 'Hiragana': Script */
+static const OnigCodePoint CR_Hiragana[] = {
+	4,
+	0x3041, 0x3096,
+	0x309d, 0x309f,
+	0x1b001, 0x1b001,
+	0x1f200, 0x1f200,
+}; /* CR_Hiragana */
+
+/* 'Katakana': Script */
+static const OnigCodePoint CR_Katakana[] = {
+	8,
+	0x30a1, 0x30fa,
+	0x30fd, 0x30ff,
+	0x31f0, 0x31ff,
+	0x32d0, 0x32fe,
+	0x3300, 0x3357,
+	0xff66, 0xff6f,
+	0xff71, 0xff9d,
+	0x1b000, 0x1b000,
+}; /* CR_Katakana */
+
+/* 'Bopomofo': Script */
+static const OnigCodePoint CR_Bopomofo[] = {
+	3,
+	0x02ea, 0x02eb,
+	0x3105, 0x312d,
+	0x31a0, 0x31ba,
+}; /* CR_Bopomofo */
+
+/* 'Han': Script */
+static const OnigCodePoint CR_Han[] = {
+	15,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x3005, 0x3005,
+	0x3007, 0x3007,
+	0x3021, 0x3029,
+	0x3038, 0x303b,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_Han */
+
+/* 'Yi': Script */
+static const OnigCodePoint CR_Yi[] = {
+	2,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+}; /* CR_Yi */
+
+/* 'Old_Italic': Script */
+static const OnigCodePoint CR_Old_Italic[] = {
+	1,
+	0x10300, 0x10323,
+}; /* CR_Old_Italic */
+
+/* 'Gothic': Script */
+static const OnigCodePoint CR_Gothic[] = {
+	1,
+	0x10330, 0x1034a,
+}; /* CR_Gothic */
+
+/* 'Deseret': Script */
+static const OnigCodePoint CR_Deseret[] = {
+	1,
+	0x10400, 0x1044f,
+}; /* CR_Deseret */
+
+/* 'Inherited': Script */
+static const OnigCodePoint CR_Inherited[] = {
+	27,
+	0x0300, 0x036f,
+	0x0485, 0x0486,
+	0x064b, 0x0655,
+	0x0670, 0x0670,
+	0x0951, 0x0952,
+	0x1ab0, 0x1abe,
+	0x1cd0, 0x1cd2,
+	0x1cd4, 0x1ce0,
+	0x1ce2, 0x1ce8,
+	0x1ced, 0x1ced,
+	0x1cf4, 0x1cf4,
+	0x1cf8, 0x1cf9,
+	0x1dc0, 0x1df5,
+	0x1dfc, 0x1dff,
+	0x200c, 0x200d,
+	0x20d0, 0x20f0,
+	0x302a, 0x302d,
+	0x3099, 0x309a,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe2d,
+	0x101fd, 0x101fd,
+	0x102e0, 0x102e0,
+	0x1d167, 0x1d169,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0xe0100, 0xe01ef,
+}; /* CR_Inherited */
+
+/* 'Tagalog': Script */
+static const OnigCodePoint CR_Tagalog[] = {
+	2,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+}; /* CR_Tagalog */
+
+/* 'Hanunoo': Script */
+static const OnigCodePoint CR_Hanunoo[] = {
+	1,
+	0x1720, 0x1734,
+}; /* CR_Hanunoo */
+
+/* 'Buhid': Script */
+static const OnigCodePoint CR_Buhid[] = {
+	1,
+	0x1740, 0x1753,
+}; /* CR_Buhid */
+
+/* 'Tagbanwa': Script */
+static const OnigCodePoint CR_Tagbanwa[] = {
+	3,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+}; /* CR_Tagbanwa */
+
+/* 'Limbu': Script */
+static const OnigCodePoint CR_Limbu[] = {
+	5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x194f,
+}; /* CR_Limbu */
+
+/* 'Tai_Le': Script */
+static const OnigCodePoint CR_Tai_Le[] = {
+	2,
+	0x1950, 0x196d,
+	0x1970, 0x1974,
+}; /* CR_Tai_Le */
+
+/* 'Linear_B': Script */
+static const OnigCodePoint CR_Linear_B[] = {
+	7,
+	0x10000, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+}; /* CR_Linear_B */
+
+/* 'Ugaritic': Script */
+static const OnigCodePoint CR_Ugaritic[] = {
+	2,
+	0x10380, 0x1039d,
+	0x1039f, 0x1039f,
+}; /* CR_Ugaritic */
+
+/* 'Shavian': Script */
+static const OnigCodePoint CR_Shavian[] = {
+	1,
+	0x10450, 0x1047f,
+}; /* CR_Shavian */
+
+/* 'Osmanya': Script */
+static const OnigCodePoint CR_Osmanya[] = {
+	2,
+	0x10480, 0x1049d,
+	0x104a0, 0x104a9,
+}; /* CR_Osmanya */
+
+/* 'Cypriot': Script */
+static const OnigCodePoint CR_Cypriot[] = {
+	6,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x1083f,
+}; /* CR_Cypriot */
+
+/* 'Braille': Script */
+static const OnigCodePoint CR_Braille[] = {
+	1,
+	0x2800, 0x28ff,
+}; /* CR_Braille */
+
+/* 'Buginese': Script */
+static const OnigCodePoint CR_Buginese[] = {
+	2,
+	0x1a00, 0x1a1b,
+	0x1a1e, 0x1a1f,
+}; /* CR_Buginese */
+
+/* 'Coptic': Script */
+static const OnigCodePoint CR_Coptic[] = {
+	3,
+	0x03e2, 0x03ef,
+	0x2c80, 0x2cf3,
+	0x2cf9, 0x2cff,
+}; /* CR_Coptic */
+
+/* 'New_Tai_Lue': Script */
+static const OnigCodePoint CR_New_Tai_Lue[] = {
+	4,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x19df,
+}; /* CR_New_Tai_Lue */
+
+/* 'Glagolitic': Script */
+static const OnigCodePoint CR_Glagolitic[] = {
+	2,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+}; /* CR_Glagolitic */
+
+/* 'Tifinagh': Script */
+static const OnigCodePoint CR_Tifinagh[] = {
+	3,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d7f,
+}; /* CR_Tifinagh */
+
+/* 'Syloti_Nagri': Script */
+static const OnigCodePoint CR_Syloti_Nagri[] = {
+	1,
+	0xa800, 0xa82b,
+}; /* CR_Syloti_Nagri */
+
+/* 'Old_Persian': Script */
+static const OnigCodePoint CR_Old_Persian[] = {
+	2,
+	0x103a0, 0x103c3,
+	0x103c8, 0x103d5,
+}; /* CR_Old_Persian */
+
+/* 'Kharoshthi': Script */
+static const OnigCodePoint CR_Kharoshthi[] = {
+	8,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+}; /* CR_Kharoshthi */
+
+/* 'Balinese': Script */
+static const OnigCodePoint CR_Balinese[] = {
+	2,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+}; /* CR_Balinese */
+
+/* 'Cuneiform': Script */
+static const OnigCodePoint CR_Cuneiform[] = {
+	3,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x12470, 0x12474,
+}; /* CR_Cuneiform */
+
+/* 'Phoenician': Script */
+static const OnigCodePoint CR_Phoenician[] = {
+	2,
+	0x10900, 0x1091b,
+	0x1091f, 0x1091f,
+}; /* CR_Phoenician */
+
+/* 'Phags_Pa': Script */
+static const OnigCodePoint CR_Phags_Pa[] = {
+	1,
+	0xa840, 0xa877,
+}; /* CR_Phags_Pa */
+
+/* 'Nko': Script */
+static const OnigCodePoint CR_Nko[] = {
+	1,
+	0x07c0, 0x07fa,
+}; /* CR_Nko */
+
+/* 'Sundanese': Script */
+static const OnigCodePoint CR_Sundanese[] = {
+	2,
+	0x1b80, 0x1bbf,
+	0x1cc0, 0x1cc7,
+}; /* CR_Sundanese */
+
+/* 'Lepcha': Script */
+static const OnigCodePoint CR_Lepcha[] = {
+	3,
+	0x1c00, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c4f,
+}; /* CR_Lepcha */
+
+/* 'Ol_Chiki': Script */
+static const OnigCodePoint CR_Ol_Chiki[] = {
+	1,
+	0x1c50, 0x1c7f,
+}; /* CR_Ol_Chiki */
+
+/* 'Vai': Script */
+static const OnigCodePoint CR_Vai[] = {
+	1,
+	0xa500, 0xa62b,
+}; /* CR_Vai */
+
+/* 'Saurashtra': Script */
+static const OnigCodePoint CR_Saurashtra[] = {
+	2,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+}; /* CR_Saurashtra */
+
+/* 'Kayah_Li': Script */
+static const OnigCodePoint CR_Kayah_Li[] = {
+	2,
+	0xa900, 0xa92d,
+	0xa92f, 0xa92f,
+}; /* CR_Kayah_Li */
+
+/* 'Rejang': Script */
+static const OnigCodePoint CR_Rejang[] = {
+	2,
+	0xa930, 0xa953,
+	0xa95f, 0xa95f,
+}; /* CR_Rejang */
+
+/* 'Lycian': Script */
+static const OnigCodePoint CR_Lycian[] = {
+	1,
+	0x10280, 0x1029c,
+}; /* CR_Lycian */
+
+/* 'Carian': Script */
+static const OnigCodePoint CR_Carian[] = {
+	1,
+	0x102a0, 0x102d0,
+}; /* CR_Carian */
+
+/* 'Lydian': Script */
+static const OnigCodePoint CR_Lydian[] = {
+	2,
+	0x10920, 0x10939,
+	0x1093f, 0x1093f,
+}; /* CR_Lydian */
+
+/* 'Cham': Script */
+static const OnigCodePoint CR_Cham[] = {
+	4,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa5f,
+}; /* CR_Cham */
+
+/* 'Tai_Tham': Script */
+static const OnigCodePoint CR_Tai_Tham[] = {
+	5,
+	0x1a20, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+}; /* CR_Tai_Tham */
+
+/* 'Tai_Viet': Script */
+static const OnigCodePoint CR_Tai_Viet[] = {
+	2,
+	0xaa80, 0xaac2,
+	0xaadb, 0xaadf,
+}; /* CR_Tai_Viet */
+
+/* 'Avestan': Script */
+static const OnigCodePoint CR_Avestan[] = {
+	2,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b3f,
+}; /* CR_Avestan */
+
+/* 'Egyptian_Hieroglyphs': Script */
+static const OnigCodePoint CR_Egyptian_Hieroglyphs[] = {
+	1,
+	0x13000, 0x1342e,
+}; /* CR_Egyptian_Hieroglyphs */
+
+/* 'Samaritan': Script */
+static const OnigCodePoint CR_Samaritan[] = {
+	2,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+}; /* CR_Samaritan */
+
+/* 'Lisu': Script */
+static const OnigCodePoint CR_Lisu[] = {
+	1,
+	0xa4d0, 0xa4ff,
+}; /* CR_Lisu */
+
+/* 'Bamum': Script */
+static const OnigCodePoint CR_Bamum[] = {
+	2,
+	0xa6a0, 0xa6f7,
+	0x16800, 0x16a38,
+}; /* CR_Bamum */
+
+/* 'Javanese': Script */
+static const OnigCodePoint CR_Javanese[] = {
+	3,
+	0xa980, 0xa9cd,
+	0xa9d0, 0xa9d9,
+	0xa9de, 0xa9df,
+}; /* CR_Javanese */
+
+/* 'Meetei_Mayek': Script */
+static const OnigCodePoint CR_Meetei_Mayek[] = {
+	3,
+	0xaae0, 0xaaf6,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+}; /* CR_Meetei_Mayek */
+
+/* 'Imperial_Aramaic': Script */
+static const OnigCodePoint CR_Imperial_Aramaic[] = {
+	2,
+	0x10840, 0x10855,
+	0x10857, 0x1085f,
+}; /* CR_Imperial_Aramaic */
+
+/* 'Old_South_Arabian': Script */
+static const OnigCodePoint CR_Old_South_Arabian[] = {
+	1,
+	0x10a60, 0x10a7f,
+}; /* CR_Old_South_Arabian */
+
+/* 'Inscriptional_Parthian': Script */
+static const OnigCodePoint CR_Inscriptional_Parthian[] = {
+	2,
+	0x10b40, 0x10b55,
+	0x10b58, 0x10b5f,
+}; /* CR_Inscriptional_Parthian */
+
+/* 'Inscriptional_Pahlavi': Script */
+static const OnigCodePoint CR_Inscriptional_Pahlavi[] = {
+	2,
+	0x10b60, 0x10b72,
+	0x10b78, 0x10b7f,
+}; /* CR_Inscriptional_Pahlavi */
+
+/* 'Old_Turkic': Script */
+static const OnigCodePoint CR_Old_Turkic[] = {
+	1,
+	0x10c00, 0x10c48,
+}; /* CR_Old_Turkic */
+
+/* 'Kaithi': Script */
+static const OnigCodePoint CR_Kaithi[] = {
+	1,
+	0x11080, 0x110c1,
+}; /* CR_Kaithi */
+
+/* 'Batak': Script */
+static const OnigCodePoint CR_Batak[] = {
+	2,
+	0x1bc0, 0x1bf3,
+	0x1bfc, 0x1bff,
+}; /* CR_Batak */
+
+/* 'Brahmi': Script */
+static const OnigCodePoint CR_Brahmi[] = {
+	3,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x1107f, 0x1107f,
+}; /* CR_Brahmi */
+
+/* 'Mandaic': Script */
+static const OnigCodePoint CR_Mandaic[] = {
+	2,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+}; /* CR_Mandaic */
+
+/* 'Chakma': Script */
+static const OnigCodePoint CR_Chakma[] = {
+	2,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+}; /* CR_Chakma */
+
+/* 'Meroitic_Cursive': Script */
+static const OnigCodePoint CR_Meroitic_Cursive[] = {
+	2,
+	0x109a0, 0x109b7,
+	0x109be, 0x109bf,
+}; /* CR_Meroitic_Cursive */
+
+/* 'Meroitic_Hieroglyphs': Script */
+static const OnigCodePoint CR_Meroitic_Hieroglyphs[] = {
+	1,
+	0x10980, 0x1099f,
+}; /* CR_Meroitic_Hieroglyphs */
+
+/* 'Miao': Script */
+static const OnigCodePoint CR_Miao[] = {
+	3,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+}; /* CR_Miao */
+
+/* 'Sharada': Script */
+static const OnigCodePoint CR_Sharada[] = {
+	3,
+	0x11180, 0x111c8,
+	0x111cd, 0x111cd,
+	0x111d0, 0x111da,
+}; /* CR_Sharada */
+
+/* 'Sora_Sompeng': Script */
+static const OnigCodePoint CR_Sora_Sompeng[] = {
+	2,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+}; /* CR_Sora_Sompeng */
+
+/* 'Takri': Script */
+static const OnigCodePoint CR_Takri[] = {
+	2,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+}; /* CR_Takri */
+
+/* 'Caucasian_Albanian': Script */
+static const OnigCodePoint CR_Caucasian_Albanian[] = {
+	2,
+	0x10530, 0x10563,
+	0x1056f, 0x1056f,
+}; /* CR_Caucasian_Albanian */
+
+/* 'Bassa_Vah': Script */
+static const OnigCodePoint CR_Bassa_Vah[] = {
+	2,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af5,
+}; /* CR_Bassa_Vah */
+
+/* 'Duployan': Script */
+static const OnigCodePoint CR_Duployan[] = {
+	5,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9c, 0x1bc9f,
+}; /* CR_Duployan */
+
+/* 'Elbasan': Script */
+static const OnigCodePoint CR_Elbasan[] = {
+	1,
+	0x10500, 0x10527,
+}; /* CR_Elbasan */
+
+/* 'Grantha': Script */
+static const OnigCodePoint CR_Grantha[] = {
+	14,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+}; /* CR_Grantha */
+
+/* 'Pahawh_Hmong': Script */
+static const OnigCodePoint CR_Pahawh_Hmong[] = {
+	5,
+	0x16b00, 0x16b45,
+	0x16b50, 0x16b59,
+	0x16b5b, 0x16b61,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+}; /* CR_Pahawh_Hmong */
+
+/* 'Khojki': Script */
+static const OnigCodePoint CR_Khojki[] = {
+	2,
+	0x11200, 0x11211,
+	0x11213, 0x1123d,
+}; /* CR_Khojki */
+
+/* 'Linear_A': Script */
+static const OnigCodePoint CR_Linear_A[] = {
+	3,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+}; /* CR_Linear_A */
+
+/* 'Mahajani': Script */
+static const OnigCodePoint CR_Mahajani[] = {
+	1,
+	0x11150, 0x11176,
+}; /* CR_Mahajani */
+
+/* 'Manichaean': Script */
+static const OnigCodePoint CR_Manichaean[] = {
+	2,
+	0x10ac0, 0x10ae6,
+	0x10aeb, 0x10af6,
+}; /* CR_Manichaean */
+
+/* 'Mende_Kikakui': Script */
+static const OnigCodePoint CR_Mende_Kikakui[] = {
+	2,
+	0x1e800, 0x1e8c4,
+	0x1e8c7, 0x1e8d6,
+}; /* CR_Mende_Kikakui */
+
+/* 'Modi': Script */
+static const OnigCodePoint CR_Modi[] = {
+	2,
+	0x11600, 0x11644,
+	0x11650, 0x11659,
+}; /* CR_Modi */
+
+/* 'Mro': Script */
+static const OnigCodePoint CR_Mro[] = {
+	3,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16a6e, 0x16a6f,
+}; /* CR_Mro */
+
+/* 'Old_North_Arabian': Script */
+static const OnigCodePoint CR_Old_North_Arabian[] = {
+	1,
+	0x10a80, 0x10a9f,
+}; /* CR_Old_North_Arabian */
+
+/* 'Nabataean': Script */
+static const OnigCodePoint CR_Nabataean[] = {
+	2,
+	0x10880, 0x1089e,
+	0x108a7, 0x108af,
+}; /* CR_Nabataean */
+
+/* 'Palmyrene': Script */
+static const OnigCodePoint CR_Palmyrene[] = {
+	1,
+	0x10860, 0x1087f,
+}; /* CR_Palmyrene */
+
+/* 'Pau_Cin_Hau': Script */
+static const OnigCodePoint CR_Pau_Cin_Hau[] = {
+	1,
+	0x11ac0, 0x11af8,
+}; /* CR_Pau_Cin_Hau */
+
+/* 'Old_Permic': Script */
+static const OnigCodePoint CR_Old_Permic[] = {
+	1,
+	0x10350, 0x1037a,
+}; /* CR_Old_Permic */
+
+/* 'Psalter_Pahlavi': Script */
+static const OnigCodePoint CR_Psalter_Pahlavi[] = {
+	3,
+	0x10b80, 0x10b91,
+	0x10b99, 0x10b9c,
+	0x10ba9, 0x10baf,
+}; /* CR_Psalter_Pahlavi */
+
+/* 'Siddham': Script */
+static const OnigCodePoint CR_Siddham[] = {
+	2,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c9,
+}; /* CR_Siddham */
+
+/* 'Khudawadi': Script */
+static const OnigCodePoint CR_Khudawadi[] = {
+	2,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+}; /* CR_Khudawadi */
+
+/* 'Tirhuta': Script */
+static const OnigCodePoint CR_Tirhuta[] = {
+	2,
+	0x11480, 0x114c7,
+	0x114d0, 0x114d9,
+}; /* CR_Tirhuta */
+
+/* 'Warang_Citi': Script */
+static const OnigCodePoint CR_Warang_Citi[] = {
+	2,
+	0x118a0, 0x118f2,
+	0x118ff, 0x118ff,
+}; /* CR_Warang_Citi */
+
+/* 'White_Space': Binary Property */
+#define CR_White_Space CR_Space
+
+/* 'Bidi_Control': Binary Property */
+static const OnigCodePoint CR_Bidi_Control[] = {
+	4,
+	0x061c, 0x061c,
+	0x200e, 0x200f,
+	0x202a, 0x202e,
+	0x2066, 0x2069,
+}; /* CR_Bidi_Control */
+
+/* 'Join_Control': Binary Property */
+static const OnigCodePoint CR_Join_Control[] = {
+	1,
+	0x200c, 0x200d,
+}; /* CR_Join_Control */
+
+/* 'Dash': Binary Property */
+static const OnigCodePoint CR_Dash[] = {
+	21,
+	0x002d, 0x002d,
+	0x058a, 0x058a,
+	0x05be, 0x05be,
+	0x1400, 0x1400,
+	0x1806, 0x1806,
+	0x2010, 0x2015,
+	0x2053, 0x2053,
+	0x207b, 0x207b,
+	0x208b, 0x208b,
+	0x2212, 0x2212,
+	0x2e17, 0x2e17,
+	0x2e1a, 0x2e1a,
+	0x2e3a, 0x2e3b,
+	0x2e40, 0x2e40,
+	0x301c, 0x301c,
+	0x3030, 0x3030,
+	0x30a0, 0x30a0,
+	0xfe31, 0xfe32,
+	0xfe58, 0xfe58,
+	0xfe63, 0xfe63,
+	0xff0d, 0xff0d,
+}; /* CR_Dash */
+
+/* 'Hyphen': Binary Property */
+static const OnigCodePoint CR_Hyphen[] = {
+	10,
+	0x002d, 0x002d,
+	0x00ad, 0x00ad,
+	0x058a, 0x058a,
+	0x1806, 0x1806,
+	0x2010, 0x2011,
+	0x2e17, 0x2e17,
+	0x30fb, 0x30fb,
+	0xfe63, 0xfe63,
+	0xff0d, 0xff0d,
+	0xff65, 0xff65,
+}; /* CR_Hyphen */
+
+/* 'Quotation_Mark': Binary Property */
+static const OnigCodePoint CR_Quotation_Mark[] = {
+	13,
+	0x0022, 0x0022,
+	0x0027, 0x0027,
+	0x00ab, 0x00ab,
+	0x00bb, 0x00bb,
+	0x2018, 0x201f,
+	0x2039, 0x203a,
+	0x2e42, 0x2e42,
+	0x300c, 0x300f,
+	0x301d, 0x301f,
+	0xfe41, 0xfe44,
+	0xff02, 0xff02,
+	0xff07, 0xff07,
+	0xff62, 0xff63,
+}; /* CR_Quotation_Mark */
+
+/* 'Terminal_Punctuation': Binary Property */
+static const OnigCodePoint CR_Terminal_Punctuation[] = {
+	86,
+	0x0021, 0x0021,
+	0x002c, 0x002c,
+	0x002e, 0x002e,
+	0x003a, 0x003b,
+	0x003f, 0x003f,
+	0x037e, 0x037e,
+	0x0387, 0x0387,
+	0x0589, 0x0589,
+	0x05c3, 0x05c3,
+	0x060c, 0x060c,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x06d4, 0x06d4,
+	0x0700, 0x070a,
+	0x070c, 0x070c,
+	0x07f8, 0x07f9,
+	0x0830, 0x083e,
+	0x085e, 0x085e,
+	0x0964, 0x0965,
+	0x0e5a, 0x0e5b,
+	0x0f08, 0x0f08,
+	0x0f0d, 0x0f12,
+	0x104a, 0x104b,
+	0x1361, 0x1368,
+	0x166d, 0x166e,
+	0x16eb, 0x16ed,
+	0x1735, 0x1736,
+	0x17d4, 0x17d6,
+	0x17da, 0x17da,
+	0x1802, 0x1805,
+	0x1808, 0x1809,
+	0x1944, 0x1945,
+	0x1aa8, 0x1aab,
+	0x1b5a, 0x1b5b,
+	0x1b5d, 0x1b5f,
+	0x1c3b, 0x1c3f,
+	0x1c7e, 0x1c7f,
+	0x203c, 0x203d,
+	0x2047, 0x2049,
+	0x2e2e, 0x2e2e,
+	0x2e3c, 0x2e3c,
+	0x2e41, 0x2e41,
+	0x3001, 0x3002,
+	0xa4fe, 0xa4ff,
+	0xa60d, 0xa60f,
+	0xa6f3, 0xa6f7,
+	0xa876, 0xa877,
+	0xa8ce, 0xa8cf,
+	0xa92f, 0xa92f,
+	0xa9c7, 0xa9c9,
+	0xaa5d, 0xaa5f,
+	0xaadf, 0xaadf,
+	0xaaf0, 0xaaf1,
+	0xabeb, 0xabeb,
+	0xfe50, 0xfe52,
+	0xfe54, 0xfe57,
+	0xff01, 0xff01,
+	0xff0c, 0xff0c,
+	0xff0e, 0xff0e,
+	0xff1a, 0xff1b,
+	0xff1f, 0xff1f,
+	0xff61, 0xff61,
+	0xff64, 0xff64,
+	0x1039f, 0x1039f,
+	0x103d0, 0x103d0,
+	0x10857, 0x10857,
+	0x1091f, 0x1091f,
+	0x10a56, 0x10a57,
+	0x10af0, 0x10af5,
+	0x10b3a, 0x10b3f,
+	0x10b99, 0x10b9c,
+	0x11047, 0x1104d,
+	0x110be, 0x110c1,
+	0x11141, 0x11143,
+	0x111c5, 0x111c6,
+	0x111cd, 0x111cd,
+	0x11238, 0x1123c,
+	0x115c2, 0x115c5,
+	0x115c9, 0x115c9,
+	0x11641, 0x11642,
+	0x12470, 0x12474,
+	0x16a6e, 0x16a6f,
+	0x16af5, 0x16af5,
+	0x16b37, 0x16b39,
+	0x16b44, 0x16b44,
+	0x1bc9f, 0x1bc9f,
+}; /* CR_Terminal_Punctuation */
+
+/* 'Other_Math': Binary Property */
+static const OnigCodePoint CR_Other_Math[] = {
+	134,
+	0x005e, 0x005e,
+	0x03d0, 0x03d2,
+	0x03d5, 0x03d5,
+	0x03f0, 0x03f1,
+	0x03f4, 0x03f5,
+	0x2016, 0x2016,
+	0x2032, 0x2034,
+	0x2040, 0x2040,
+	0x2061, 0x2064,
+	0x207d, 0x207e,
+	0x208d, 0x208e,
+	0x20d0, 0x20dc,
+	0x20e1, 0x20e1,
+	0x20e5, 0x20e6,
+	0x20eb, 0x20ef,
+	0x2102, 0x2102,
+	0x2107, 0x2107,
+	0x210a, 0x2113,
+	0x2115, 0x2115,
+	0x2119, 0x211d,
+	0x2124, 0x2124,
+	0x2128, 0x2129,
+	0x212c, 0x212d,
+	0x212f, 0x2131,
+	0x2133, 0x2138,
+	0x213c, 0x213f,
+	0x2145, 0x2149,
+	0x2195, 0x2199,
+	0x219c, 0x219f,
+	0x21a1, 0x21a2,
+	0x21a4, 0x21a5,
+	0x21a7, 0x21a7,
+	0x21a9, 0x21ad,
+	0x21b0, 0x21b1,
+	0x21b6, 0x21b7,
+	0x21bc, 0x21cd,
+	0x21d0, 0x21d1,
+	0x21d3, 0x21d3,
+	0x21d5, 0x21db,
+	0x21dd, 0x21dd,
+	0x21e4, 0x21e5,
+	0x2308, 0x230b,
+	0x23b4, 0x23b5,
+	0x23b7, 0x23b7,
+	0x23d0, 0x23d0,
+	0x23e2, 0x23e2,
+	0x25a0, 0x25a1,
+	0x25ae, 0x25b6,
+	0x25bc, 0x25c0,
+	0x25c6, 0x25c7,
+	0x25ca, 0x25cb,
+	0x25cf, 0x25d3,
+	0x25e2, 0x25e2,
+	0x25e4, 0x25e4,
+	0x25e7, 0x25ec,
+	0x2605, 0x2606,
+	0x2640, 0x2640,
+	0x2642, 0x2642,
+	0x2660, 0x2663,
+	0x266d, 0x266e,
+	0x27c5, 0x27c6,
+	0x27e6, 0x27ef,
+	0x2983, 0x2998,
+	0x29d8, 0x29db,
+	0x29fc, 0x29fd,
+	0xfe61, 0xfe61,
+	0xfe63, 0xfe63,
+	0xfe68, 0xfe68,
+	0xff3c, 0xff3c,
+	0xff3e, 0xff3e,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d6c0,
+	0x1d6c2, 0x1d6da,
+	0x1d6dc, 0x1d6fa,
+	0x1d6fc, 0x1d714,
+	0x1d716, 0x1d734,
+	0x1d736, 0x1d74e,
+	0x1d750, 0x1d76e,
+	0x1d770, 0x1d788,
+	0x1d78a, 0x1d7a8,
+	0x1d7aa, 0x1d7c2,
+	0x1d7c4, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+}; /* CR_Other_Math */
+
+/* 'Hex_Digit': Binary Property */
+static const OnigCodePoint CR_Hex_Digit[] = {
+	6,
+	0x0030, 0x0039,
+	0x0041, 0x0046,
+	0x0061, 0x0066,
+	0xff10, 0xff19,
+	0xff21, 0xff26,
+	0xff41, 0xff46,
+}; /* CR_Hex_Digit */
+
+/* 'ASCII_Hex_Digit': Binary Property */
+#define CR_ASCII_Hex_Digit CR_XDigit
+
+/* 'Other_Alphabetic': Binary Property */
+static const OnigCodePoint CR_Other_Alphabetic[] = {
+	178,
+	0x0345, 0x0345,
+	0x05b0, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c5,
+	0x05c7, 0x05c7,
+	0x0610, 0x061a,
+	0x064b, 0x0657,
+	0x0659, 0x065f,
+	0x0670, 0x0670,
+	0x06d6, 0x06dc,
+	0x06e1, 0x06e4,
+	0x06e7, 0x06e8,
+	0x06ed, 0x06ed,
+	0x0711, 0x0711,
+	0x0730, 0x073f,
+	0x07a6, 0x07b0,
+	0x0816, 0x0817,
+	0x081b, 0x0823,
+	0x0825, 0x0827,
+	0x0829, 0x082c,
+	0x08e4, 0x08e9,
+	0x08f0, 0x0903,
+	0x093a, 0x093b,
+	0x093e, 0x094c,
+	0x094e, 0x094f,
+	0x0955, 0x0957,
+	0x0962, 0x0963,
+	0x0981, 0x0983,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cc,
+	0x09d7, 0x09d7,
+	0x09e2, 0x09e3,
+	0x0a01, 0x0a03,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4c,
+	0x0a51, 0x0a51,
+	0x0a70, 0x0a71,
+	0x0a75, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0abe, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acc,
+	0x0ae2, 0x0ae3,
+	0x0b01, 0x0b03,
+	0x0b3e, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4c,
+	0x0b56, 0x0b57,
+	0x0b62, 0x0b63,
+	0x0b82, 0x0b82,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcc,
+	0x0bd7, 0x0bd7,
+	0x0c00, 0x0c03,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4c,
+	0x0c55, 0x0c56,
+	0x0c62, 0x0c63,
+	0x0c81, 0x0c83,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccc,
+	0x0cd5, 0x0cd6,
+	0x0ce2, 0x0ce3,
+	0x0d01, 0x0d03,
+	0x0d3e, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4c,
+	0x0d57, 0x0d57,
+	0x0d62, 0x0d63,
+	0x0d82, 0x0d83,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df3,
+	0x0e31, 0x0e31,
+	0x0e34, 0x0e3a,
+	0x0e4d, 0x0e4d,
+	0x0eb1, 0x0eb1,
+	0x0eb4, 0x0eb9,
+	0x0ebb, 0x0ebc,
+	0x0ecd, 0x0ecd,
+	0x0f71, 0x0f81,
+	0x0f8d, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x102b, 0x1036,
+	0x1038, 0x1038,
+	0x103b, 0x103e,
+	0x1056, 0x1059,
+	0x105e, 0x1060,
+	0x1062, 0x1062,
+	0x1067, 0x1068,
+	0x1071, 0x1074,
+	0x1082, 0x1086,
+	0x109c, 0x109d,
+	0x135f, 0x135f,
+	0x1712, 0x1713,
+	0x1732, 0x1733,
+	0x1752, 0x1753,
+	0x1772, 0x1773,
+	0x17b6, 0x17c8,
+	0x18a9, 0x18a9,
+	0x1920, 0x192b,
+	0x1930, 0x1938,
+	0x19b0, 0x19c0,
+	0x19c8, 0x19c9,
+	0x1a17, 0x1a1b,
+	0x1a55, 0x1a5e,
+	0x1a61, 0x1a74,
+	0x1b00, 0x1b04,
+	0x1b35, 0x1b43,
+	0x1b80, 0x1b82,
+	0x1ba1, 0x1ba9,
+	0x1bac, 0x1bad,
+	0x1be7, 0x1bf1,
+	0x1c24, 0x1c35,
+	0x1cf2, 0x1cf3,
+	0x1de7, 0x1df4,
+	0x24b6, 0x24e9,
+	0x2de0, 0x2dff,
+	0xa674, 0xa67b,
+	0xa69f, 0xa69f,
+	0xa823, 0xa827,
+	0xa880, 0xa881,
+	0xa8b4, 0xa8c3,
+	0xa926, 0xa92a,
+	0xa947, 0xa952,
+	0xa980, 0xa983,
+	0xa9b4, 0xa9bf,
+	0xaa29, 0xaa36,
+	0xaa43, 0xaa43,
+	0xaa4c, 0xaa4d,
+	0xaab0, 0xaab0,
+	0xaab2, 0xaab4,
+	0xaab7, 0xaab8,
+	0xaabe, 0xaabe,
+	0xaaeb, 0xaaef,
+	0xaaf5, 0xaaf5,
+	0xabe3, 0xabea,
+	0xfb1e, 0xfb1e,
+	0x10376, 0x1037a,
+	0x10a01, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a0f,
+	0x11000, 0x11002,
+	0x11038, 0x11045,
+	0x11082, 0x11082,
+	0x110b0, 0x110b8,
+	0x11100, 0x11102,
+	0x11127, 0x11132,
+	0x11180, 0x11182,
+	0x111b3, 0x111bf,
+	0x1122c, 0x11234,
+	0x11237, 0x11237,
+	0x112df, 0x112e8,
+	0x11301, 0x11303,
+	0x1133e, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134c,
+	0x11357, 0x11357,
+	0x11362, 0x11363,
+	0x114b0, 0x114c1,
+	0x115af, 0x115b5,
+	0x115b8, 0x115be,
+	0x11630, 0x1163e,
+	0x11640, 0x11640,
+	0x116ab, 0x116b5,
+	0x16b30, 0x16b36,
+	0x16f51, 0x16f7e,
+	0x1bc9e, 0x1bc9e,
+	0x1f130, 0x1f149,
+	0x1f150, 0x1f169,
+	0x1f170, 0x1f189,
+}; /* CR_Other_Alphabetic */
+
+/* 'Ideographic': Binary Property */
+static const OnigCodePoint CR_Ideographic[] = {
+	11,
+	0x3006, 0x3007,
+	0x3021, 0x3029,
+	0x3038, 0x303a,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xf900, 0xfa6d,
+	0xfa70, 0xfad9,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+}; /* CR_Ideographic */
+
+/* 'Diacritic': Binary Property */
+static const OnigCodePoint CR_Diacritic[] = {
+	145,
+	0x005e, 0x005e,
+	0x0060, 0x0060,
+	0x00a8, 0x00a8,
+	0x00af, 0x00af,
+	0x00b4, 0x00b4,
+	0x00b7, 0x00b8,
+	0x02b0, 0x034e,
+	0x0350, 0x0357,
+	0x035d, 0x0362,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x0384, 0x0385,
+	0x0483, 0x0487,
+	0x0559, 0x0559,
+	0x0591, 0x05a1,
+	0x05a3, 0x05bd,
+	0x05bf, 0x05bf,
+	0x05c1, 0x05c2,
+	0x05c4, 0x05c4,
+	0x064b, 0x0652,
+	0x0657, 0x0658,
+	0x06df, 0x06e0,
+	0x06e5, 0x06e6,
+	0x06ea, 0x06ec,
+	0x0730, 0x074a,
+	0x07a6, 0x07b0,
+	0x07eb, 0x07f5,
+	0x0818, 0x0819,
+	0x08e4, 0x08fe,
+	0x093c, 0x093c,
+	0x094d, 0x094d,
+	0x0951, 0x0954,
+	0x0971, 0x0971,
+	0x09bc, 0x09bc,
+	0x09cd, 0x09cd,
+	0x0a3c, 0x0a3c,
+	0x0a4d, 0x0a4d,
+	0x0abc, 0x0abc,
+	0x0acd, 0x0acd,
+	0x0b3c, 0x0b3c,
+	0x0b4d, 0x0b4d,
+	0x0bcd, 0x0bcd,
+	0x0c4d, 0x0c4d,
+	0x0cbc, 0x0cbc,
+	0x0ccd, 0x0ccd,
+	0x0d4d, 0x0d4d,
+	0x0dca, 0x0dca,
+	0x0e47, 0x0e4c,
+	0x0e4e, 0x0e4e,
+	0x0ec8, 0x0ecc,
+	0x0f18, 0x0f19,
+	0x0f35, 0x0f35,
+	0x0f37, 0x0f37,
+	0x0f39, 0x0f39,
+	0x0f3e, 0x0f3f,
+	0x0f82, 0x0f84,
+	0x0f86, 0x0f87,
+	0x0fc6, 0x0fc6,
+	0x1037, 0x1037,
+	0x1039, 0x103a,
+	0x1087, 0x108d,
+	0x108f, 0x108f,
+	0x109a, 0x109b,
+	0x17c9, 0x17d3,
+	0x17dd, 0x17dd,
+	0x1939, 0x193b,
+	0x1a75, 0x1a7c,
+	0x1a7f, 0x1a7f,
+	0x1ab0, 0x1abd,
+	0x1b34, 0x1b34,
+	0x1b44, 0x1b44,
+	0x1b6b, 0x1b73,
+	0x1baa, 0x1bab,
+	0x1c36, 0x1c37,
+	0x1c78, 0x1c7d,
+	0x1cd0, 0x1ce8,
+	0x1ced, 0x1ced,
+	0x1cf4, 0x1cf4,
+	0x1cf8, 0x1cf9,
+	0x1d2c, 0x1d6a,
+	0x1dc4, 0x1dcf,
+	0x1df5, 0x1df5,
+	0x1dfd, 0x1dff,
+	0x1fbd, 0x1fbd,
+	0x1fbf, 0x1fc1,
+	0x1fcd, 0x1fcf,
+	0x1fdd, 0x1fdf,
+	0x1fed, 0x1fef,
+	0x1ffd, 0x1ffe,
+	0x2cef, 0x2cf1,
+	0x2e2f, 0x2e2f,
+	0x302a, 0x302f,
+	0x3099, 0x309c,
+	0x30fc, 0x30fc,
+	0xa66f, 0xa66f,
+	0xa67c, 0xa67d,
+	0xa67f, 0xa67f,
+	0xa69c, 0xa69d,
+	0xa6f0, 0xa6f1,
+	0xa717, 0xa721,
+	0xa788, 0xa788,
+	0xa7f8, 0xa7f9,
+	0xa8c4, 0xa8c4,
+	0xa8e0, 0xa8f1,
+	0xa92b, 0xa92e,
+	0xa953, 0xa953,
+	0xa9b3, 0xa9b3,
+	0xa9c0, 0xa9c0,
+	0xa9e5, 0xa9e5,
+	0xaa7b, 0xaa7d,
+	0xaabf, 0xaac2,
+	0xaaf6, 0xaaf6,
+	0xab5b, 0xab5f,
+	0xabec, 0xabed,
+	0xfb1e, 0xfb1e,
+	0xfe20, 0xfe2d,
+	0xff3e, 0xff3e,
+	0xff40, 0xff40,
+	0xff70, 0xff70,
+	0xff9e, 0xff9f,
+	0xffe3, 0xffe3,
+	0x102e0, 0x102e0,
+	0x10ae5, 0x10ae6,
+	0x110b9, 0x110ba,
+	0x11133, 0x11134,
+	0x11173, 0x11173,
+	0x111c0, 0x111c0,
+	0x11235, 0x11236,
+	0x112e9, 0x112ea,
+	0x1133c, 0x1133c,
+	0x1134d, 0x1134d,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x114c2, 0x114c3,
+	0x115bf, 0x115c0,
+	0x1163f, 0x1163f,
+	0x116b6, 0x116b7,
+	0x16af0, 0x16af4,
+	0x16f8f, 0x16f9f,
+	0x1d167, 0x1d169,
+	0x1d16d, 0x1d172,
+	0x1d17b, 0x1d182,
+	0x1d185, 0x1d18b,
+	0x1d1aa, 0x1d1ad,
+	0x1e8d0, 0x1e8d6,
+}; /* CR_Diacritic */
+
+/* 'Extender': Binary Property */
+static const OnigCodePoint CR_Extender[] = {
+	26,
+	0x00b7, 0x00b7,
+	0x02d0, 0x02d1,
+	0x0640, 0x0640,
+	0x07fa, 0x07fa,
+	0x0e46, 0x0e46,
+	0x0ec6, 0x0ec6,
+	0x180a, 0x180a,
+	0x1843, 0x1843,
+	0x1aa7, 0x1aa7,
+	0x1c36, 0x1c36,
+	0x1c7b, 0x1c7b,
+	0x3005, 0x3005,
+	0x3031, 0x3035,
+	0x309d, 0x309e,
+	0x30fc, 0x30fe,
+	0xa015, 0xa015,
+	0xa60c, 0xa60c,
+	0xa9cf, 0xa9cf,
+	0xa9e6, 0xa9e6,
+	0xaa70, 0xaa70,
+	0xaadd, 0xaadd,
+	0xaaf3, 0xaaf4,
+	0xff70, 0xff70,
+	0x1135d, 0x1135d,
+	0x115c6, 0x115c8,
+	0x16b42, 0x16b43,
+}; /* CR_Extender */
+
+/* 'Other_Lowercase': Binary Property */
+static const OnigCodePoint CR_Other_Lowercase[] = {
+	20,
+	0x00aa, 0x00aa,
+	0x00ba, 0x00ba,
+	0x02b0, 0x02b8,
+	0x02c0, 0x02c1,
+	0x02e0, 0x02e4,
+	0x0345, 0x0345,
+	0x037a, 0x037a,
+	0x1d2c, 0x1d6a,
+	0x1d78, 0x1d78,
+	0x1d9b, 0x1dbf,
+	0x2071, 0x2071,
+	0x207f, 0x207f,
+	0x2090, 0x209c,
+	0x2170, 0x217f,
+	0x24d0, 0x24e9,
+	0x2c7c, 0x2c7d,
+	0xa69c, 0xa69d,
+	0xa770, 0xa770,
+	0xa7f8, 0xa7f9,
+	0xab5c, 0xab5f,
+}; /* CR_Other_Lowercase */
+
+/* 'Other_Uppercase': Binary Property */
+static const OnigCodePoint CR_Other_Uppercase[] = {
+	5,
+	0x2160, 0x216f,
+	0x24b6, 0x24cf,
+	0x1f130, 0x1f149,
+	0x1f150, 0x1f169,
+	0x1f170, 0x1f189,
+}; /* CR_Other_Uppercase */
+
+/* 'Noncharacter_Code_Point': Binary Property */
+static const OnigCodePoint CR_Noncharacter_Code_Point[] = {
+	18,
+	0xfdd0, 0xfdef,
+	0xfffe, 0xffff,
+	0x1fffe, 0x1ffff,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xefffe, 0xeffff,
+	0xffffe, 0xfffff,
+	0x10fffe, 0x10ffff,
+}; /* CR_Noncharacter_Code_Point */
+
+/* 'Other_Grapheme_Extend': Binary Property */
+static const OnigCodePoint CR_Other_Grapheme_Extend[] = {
+	22,
+	0x09be, 0x09be,
+	0x09d7, 0x09d7,
+	0x0b3e, 0x0b3e,
+	0x0b57, 0x0b57,
+	0x0bbe, 0x0bbe,
+	0x0bd7, 0x0bd7,
+	0x0cc2, 0x0cc2,
+	0x0cd5, 0x0cd6,
+	0x0d3e, 0x0d3e,
+	0x0d57, 0x0d57,
+	0x0dcf, 0x0dcf,
+	0x0ddf, 0x0ddf,
+	0x200c, 0x200d,
+	0x302e, 0x302f,
+	0xff9e, 0xff9f,
+	0x1133e, 0x1133e,
+	0x11357, 0x11357,
+	0x114b0, 0x114b0,
+	0x114bd, 0x114bd,
+	0x115af, 0x115af,
+	0x1d165, 0x1d165,
+	0x1d16e, 0x1d172,
+}; /* CR_Other_Grapheme_Extend */
+
+/* 'IDS_Binary_Operator': Binary Property */
+static const OnigCodePoint CR_IDS_Binary_Operator[] = {
+	2,
+	0x2ff0, 0x2ff1,
+	0x2ff4, 0x2ffb,
+}; /* CR_IDS_Binary_Operator */
+
+/* 'IDS_Trinary_Operator': Binary Property */
+static const OnigCodePoint CR_IDS_Trinary_Operator[] = {
+	1,
+	0x2ff2, 0x2ff3,
+}; /* CR_IDS_Trinary_Operator */
+
+/* 'Radical': Binary Property */
+static const OnigCodePoint CR_Radical[] = {
+	3,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+}; /* CR_Radical */
+
+/* 'Unified_Ideograph': Binary Property */
+static const OnigCodePoint CR_Unified_Ideograph[] = {
+	12,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fcc,
+	0xfa0e, 0xfa0f,
+	0xfa11, 0xfa11,
+	0xfa13, 0xfa14,
+	0xfa1f, 0xfa1f,
+	0xfa21, 0xfa21,
+	0xfa23, 0xfa24,
+	0xfa27, 0xfa29,
+	0x20000, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+}; /* CR_Unified_Ideograph */
+
+/* 'Other_Default_Ignorable_Code_Point': Binary Property */
+static const OnigCodePoint CR_Other_Default_Ignorable_Code_Point[] = {
+	11,
+	0x034f, 0x034f,
+	0x115f, 0x1160,
+	0x17b4, 0x17b5,
+	0x2065, 0x2065,
+	0x3164, 0x3164,
+	0xffa0, 0xffa0,
+	0xfff0, 0xfff8,
+	0xe0000, 0xe0000,
+	0xe0002, 0xe001f,
+	0xe0080, 0xe00ff,
+	0xe01f0, 0xe0fff,
+}; /* CR_Other_Default_Ignorable_Code_Point */
+
+/* 'Deprecated': Binary Property */
+static const OnigCodePoint CR_Deprecated[] = {
+	9,
+	0x0149, 0x0149,
+	0x0673, 0x0673,
+	0x0f77, 0x0f77,
+	0x0f79, 0x0f79,
+	0x17a3, 0x17a4,
+	0x206a, 0x206f,
+	0x2329, 0x232a,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+}; /* CR_Deprecated */
+
+/* 'Soft_Dotted': Binary Property */
+static const OnigCodePoint CR_Soft_Dotted[] = {
+	31,
+	0x0069, 0x006a,
+	0x012f, 0x012f,
+	0x0249, 0x0249,
+	0x0268, 0x0268,
+	0x029d, 0x029d,
+	0x02b2, 0x02b2,
+	0x03f3, 0x03f3,
+	0x0456, 0x0456,
+	0x0458, 0x0458,
+	0x1d62, 0x1d62,
+	0x1d96, 0x1d96,
+	0x1da4, 0x1da4,
+	0x1da8, 0x1da8,
+	0x1e2d, 0x1e2d,
+	0x1ecb, 0x1ecb,
+	0x2071, 0x2071,
+	0x2148, 0x2149,
+	0x2c7c, 0x2c7c,
+	0x1d422, 0x1d423,
+	0x1d456, 0x1d457,
+	0x1d48a, 0x1d48b,
+	0x1d4be, 0x1d4bf,
+	0x1d4f2, 0x1d4f3,
+	0x1d526, 0x1d527,
+	0x1d55a, 0x1d55b,
+	0x1d58e, 0x1d58f,
+	0x1d5c2, 0x1d5c3,
+	0x1d5f6, 0x1d5f7,
+	0x1d62a, 0x1d62b,
+	0x1d65e, 0x1d65f,
+	0x1d692, 0x1d693,
+}; /* CR_Soft_Dotted */
+
+/* 'Logical_Order_Exception': Binary Property */
+static const OnigCodePoint CR_Logical_Order_Exception[] = {
+	5,
+	0x0e40, 0x0e44,
+	0x0ec0, 0x0ec4,
+	0xaab5, 0xaab6,
+	0xaab9, 0xaab9,
+	0xaabb, 0xaabc,
+}; /* CR_Logical_Order_Exception */
+
+/* 'Other_ID_Start': Binary Property */
+static const OnigCodePoint CR_Other_ID_Start[] = {
+	3,
+	0x2118, 0x2118,
+	0x212e, 0x212e,
+	0x309b, 0x309c,
+}; /* CR_Other_ID_Start */
+
+/* 'Other_ID_Continue': Binary Property */
+static const OnigCodePoint CR_Other_ID_Continue[] = {
+	4,
+	0x00b7, 0x00b7,
+	0x0387, 0x0387,
+	0x1369, 0x1371,
+	0x19da, 0x19da,
+}; /* CR_Other_ID_Continue */
+
+/* 'STerm': Binary Property */
+static const OnigCodePoint CR_STerm[] = {
+	60,
+	0x0021, 0x0021,
+	0x002e, 0x002e,
+	0x003f, 0x003f,
+	0x0589, 0x0589,
+	0x061f, 0x061f,
+	0x06d4, 0x06d4,
+	0x0700, 0x0702,
+	0x07f9, 0x07f9,
+	0x0964, 0x0965,
+	0x104a, 0x104b,
+	0x1362, 0x1362,
+	0x1367, 0x1368,
+	0x166e, 0x166e,
+	0x1735, 0x1736,
+	0x1803, 0x1803,
+	0x1809, 0x1809,
+	0x1944, 0x1945,
+	0x1aa8, 0x1aab,
+	0x1b5a, 0x1b5b,
+	0x1b5e, 0x1b5f,
+	0x1c3b, 0x1c3c,
+	0x1c7e, 0x1c7f,
+	0x203c, 0x203d,
+	0x2047, 0x2049,
+	0x2e2e, 0x2e2e,
+	0x2e3c, 0x2e3c,
+	0x3002, 0x3002,
+	0xa4ff, 0xa4ff,
+	0xa60e, 0xa60f,
+	0xa6f3, 0xa6f3,
+	0xa6f7, 0xa6f7,
+	0xa876, 0xa877,
+	0xa8ce, 0xa8cf,
+	0xa92f, 0xa92f,
+	0xa9c8, 0xa9c9,
+	0xaa5d, 0xaa5f,
+	0xaaf0, 0xaaf1,
+	0xabeb, 0xabeb,
+	0xfe52, 0xfe52,
+	0xfe56, 0xfe57,
+	0xff01, 0xff01,
+	0xff0e, 0xff0e,
+	0xff1f, 0xff1f,
+	0xff61, 0xff61,
+	0x10a56, 0x10a57,
+	0x11047, 0x11048,
+	0x110be, 0x110c1,
+	0x11141, 0x11143,
+	0x111c5, 0x111c6,
+	0x111cd, 0x111cd,
+	0x11238, 0x11239,
+	0x1123b, 0x1123c,
+	0x115c2, 0x115c3,
+	0x115c9, 0x115c9,
+	0x11641, 0x11642,
+	0x16a6e, 0x16a6f,
+	0x16af5, 0x16af5,
+	0x16b37, 0x16b38,
+	0x16b44, 0x16b44,
+	0x1bc9f, 0x1bc9f,
+}; /* CR_STerm */
+
+/* 'Variation_Selector': Binary Property */
+static const OnigCodePoint CR_Variation_Selector[] = {
+	3,
+	0x180b, 0x180d,
+	0xfe00, 0xfe0f,
+	0xe0100, 0xe01ef,
+}; /* CR_Variation_Selector */
+
+/* 'Pattern_White_Space': Binary Property */
+static const OnigCodePoint CR_Pattern_White_Space[] = {
+	5,
+	0x0009, 0x000d,
+	0x0020, 0x0020,
+	0x0085, 0x0085,
+	0x200e, 0x200f,
+	0x2028, 0x2029,
+}; /* CR_Pattern_White_Space */
+
+/* 'Pattern_Syntax': Binary Property */
+static const OnigCodePoint CR_Pattern_Syntax[] = {
+	28,
+	0x0021, 0x002f,
+	0x003a, 0x0040,
+	0x005b, 0x005e,
+	0x0060, 0x0060,
+	0x007b, 0x007e,
+	0x00a1, 0x00a7,
+	0x00a9, 0x00a9,
+	0x00ab, 0x00ac,
+	0x00ae, 0x00ae,
+	0x00b0, 0x00b1,
+	0x00b6, 0x00b6,
+	0x00bb, 0x00bb,
+	0x00bf, 0x00bf,
+	0x00d7, 0x00d7,
+	0x00f7, 0x00f7,
+	0x2010, 0x2027,
+	0x2030, 0x203e,
+	0x2041, 0x2053,
+	0x2055, 0x205e,
+	0x2190, 0x245f,
+	0x2500, 0x2775,
+	0x2794, 0x2bff,
+	0x2e00, 0x2e7f,
+	0x3001, 0x3003,
+	0x3008, 0x3020,
+	0x3030, 0x3030,
+	0xfd3e, 0xfd3f,
+	0xfe45, 0xfe46,
+}; /* CR_Pattern_Syntax */
+
+/* 'Unknown': Script */
+static const OnigCodePoint CR_Unknown[] = {
+	598,
+	0x0378, 0x0379,
+	0x0380, 0x0383,
+	0x038b, 0x038b,
+	0x038d, 0x038d,
+	0x03a2, 0x03a2,
+	0x0530, 0x0530,
+	0x0557, 0x0558,
+	0x0560, 0x0560,
+	0x0588, 0x0588,
+	0x058b, 0x058c,
+	0x0590, 0x0590,
+	0x05c8, 0x05cf,
+	0x05eb, 0x05ef,
+	0x05f5, 0x05ff,
+	0x061d, 0x061d,
+	0x070e, 0x070e,
+	0x074b, 0x074c,
+	0x07b2, 0x07bf,
+	0x07fb, 0x07ff,
+	0x082e, 0x082f,
+	0x083f, 0x083f,
+	0x085c, 0x085d,
+	0x085f, 0x089f,
+	0x08b3, 0x08e3,
+	0x0984, 0x0984,
+	0x098d, 0x098e,
+	0x0991, 0x0992,
+	0x09a9, 0x09a9,
+	0x09b1, 0x09b1,
+	0x09b3, 0x09b5,
+	0x09ba, 0x09bb,
+	0x09c5, 0x09c6,
+	0x09c9, 0x09ca,
+	0x09cf, 0x09d6,
+	0x09d8, 0x09db,
+	0x09de, 0x09de,
+	0x09e4, 0x09e5,
+	0x09fc, 0x0a00,
+	0x0a04, 0x0a04,
+	0x0a0b, 0x0a0e,
+	0x0a11, 0x0a12,
+	0x0a29, 0x0a29,
+	0x0a31, 0x0a31,
+	0x0a34, 0x0a34,
+	0x0a37, 0x0a37,
+	0x0a3a, 0x0a3b,
+	0x0a3d, 0x0a3d,
+	0x0a43, 0x0a46,
+	0x0a49, 0x0a4a,
+	0x0a4e, 0x0a50,
+	0x0a52, 0x0a58,
+	0x0a5d, 0x0a5d,
+	0x0a5f, 0x0a65,
+	0x0a76, 0x0a80,
+	0x0a84, 0x0a84,
+	0x0a8e, 0x0a8e,
+	0x0a92, 0x0a92,
+	0x0aa9, 0x0aa9,
+	0x0ab1, 0x0ab1,
+	0x0ab4, 0x0ab4,
+	0x0aba, 0x0abb,
+	0x0ac6, 0x0ac6,
+	0x0aca, 0x0aca,
+	0x0ace, 0x0acf,
+	0x0ad1, 0x0adf,
+	0x0ae4, 0x0ae5,
+	0x0af2, 0x0b00,
+	0x0b04, 0x0b04,
+	0x0b0d, 0x0b0e,
+	0x0b11, 0x0b12,
+	0x0b29, 0x0b29,
+	0x0b31, 0x0b31,
+	0x0b34, 0x0b34,
+	0x0b3a, 0x0b3b,
+	0x0b45, 0x0b46,
+	0x0b49, 0x0b4a,
+	0x0b4e, 0x0b55,
+	0x0b58, 0x0b5b,
+	0x0b5e, 0x0b5e,
+	0x0b64, 0x0b65,
+	0x0b78, 0x0b81,
+	0x0b84, 0x0b84,
+	0x0b8b, 0x0b8d,
+	0x0b91, 0x0b91,
+	0x0b96, 0x0b98,
+	0x0b9b, 0x0b9b,
+	0x0b9d, 0x0b9d,
+	0x0ba0, 0x0ba2,
+	0x0ba5, 0x0ba7,
+	0x0bab, 0x0bad,
+	0x0bba, 0x0bbd,
+	0x0bc3, 0x0bc5,
+	0x0bc9, 0x0bc9,
+	0x0bce, 0x0bcf,
+	0x0bd1, 0x0bd6,
+	0x0bd8, 0x0be5,
+	0x0bfb, 0x0bff,
+	0x0c04, 0x0c04,
+	0x0c0d, 0x0c0d,
+	0x0c11, 0x0c11,
+	0x0c29, 0x0c29,
+	0x0c3a, 0x0c3c,
+	0x0c45, 0x0c45,
+	0x0c49, 0x0c49,
+	0x0c4e, 0x0c54,
+	0x0c57, 0x0c57,
+	0x0c5a, 0x0c5f,
+	0x0c64, 0x0c65,
+	0x0c70, 0x0c77,
+	0x0c80, 0x0c80,
+	0x0c84, 0x0c84,
+	0x0c8d, 0x0c8d,
+	0x0c91, 0x0c91,
+	0x0ca9, 0x0ca9,
+	0x0cb4, 0x0cb4,
+	0x0cba, 0x0cbb,
+	0x0cc5, 0x0cc5,
+	0x0cc9, 0x0cc9,
+	0x0cce, 0x0cd4,
+	0x0cd7, 0x0cdd,
+	0x0cdf, 0x0cdf,
+	0x0ce4, 0x0ce5,
+	0x0cf0, 0x0cf0,
+	0x0cf3, 0x0d00,
+	0x0d04, 0x0d04,
+	0x0d0d, 0x0d0d,
+	0x0d11, 0x0d11,
+	0x0d3b, 0x0d3c,
+	0x0d45, 0x0d45,
+	0x0d49, 0x0d49,
+	0x0d4f, 0x0d56,
+	0x0d58, 0x0d5f,
+	0x0d64, 0x0d65,
+	0x0d76, 0x0d78,
+	0x0d80, 0x0d81,
+	0x0d84, 0x0d84,
+	0x0d97, 0x0d99,
+	0x0db2, 0x0db2,
+	0x0dbc, 0x0dbc,
+	0x0dbe, 0x0dbf,
+	0x0dc7, 0x0dc9,
+	0x0dcb, 0x0dce,
+	0x0dd5, 0x0dd5,
+	0x0dd7, 0x0dd7,
+	0x0de0, 0x0de5,
+	0x0df0, 0x0df1,
+	0x0df5, 0x0e00,
+	0x0e3b, 0x0e3e,
+	0x0e5c, 0x0e80,
+	0x0e83, 0x0e83,
+	0x0e85, 0x0e86,
+	0x0e89, 0x0e89,
+	0x0e8b, 0x0e8c,
+	0x0e8e, 0x0e93,
+	0x0e98, 0x0e98,
+	0x0ea0, 0x0ea0,
+	0x0ea4, 0x0ea4,
+	0x0ea6, 0x0ea6,
+	0x0ea8, 0x0ea9,
+	0x0eac, 0x0eac,
+	0x0eba, 0x0eba,
+	0x0ebe, 0x0ebf,
+	0x0ec5, 0x0ec5,
+	0x0ec7, 0x0ec7,
+	0x0ece, 0x0ecf,
+	0x0eda, 0x0edb,
+	0x0ee0, 0x0eff,
+	0x0f48, 0x0f48,
+	0x0f6d, 0x0f70,
+	0x0f98, 0x0f98,
+	0x0fbd, 0x0fbd,
+	0x0fcd, 0x0fcd,
+	0x0fdb, 0x0fff,
+	0x10c6, 0x10c6,
+	0x10c8, 0x10cc,
+	0x10ce, 0x10cf,
+	0x1249, 0x1249,
+	0x124e, 0x124f,
+	0x1257, 0x1257,
+	0x1259, 0x1259,
+	0x125e, 0x125f,
+	0x1289, 0x1289,
+	0x128e, 0x128f,
+	0x12b1, 0x12b1,
+	0x12b6, 0x12b7,
+	0x12bf, 0x12bf,
+	0x12c1, 0x12c1,
+	0x12c6, 0x12c7,
+	0x12d7, 0x12d7,
+	0x1311, 0x1311,
+	0x1316, 0x1317,
+	0x135b, 0x135c,
+	0x137d, 0x137f,
+	0x139a, 0x139f,
+	0x13f5, 0x13ff,
+	0x169d, 0x169f,
+	0x16f9, 0x16ff,
+	0x170d, 0x170d,
+	0x1715, 0x171f,
+	0x1737, 0x173f,
+	0x1754, 0x175f,
+	0x176d, 0x176d,
+	0x1771, 0x1771,
+	0x1774, 0x177f,
+	0x17de, 0x17df,
+	0x17ea, 0x17ef,
+	0x17fa, 0x17ff,
+	0x180f, 0x180f,
+	0x181a, 0x181f,
+	0x1878, 0x187f,
+	0x18ab, 0x18af,
+	0x18f6, 0x18ff,
+	0x191f, 0x191f,
+	0x192c, 0x192f,
+	0x193c, 0x193f,
+	0x1941, 0x1943,
+	0x196e, 0x196f,
+	0x1975, 0x197f,
+	0x19ac, 0x19af,
+	0x19ca, 0x19cf,
+	0x19db, 0x19dd,
+	0x1a1c, 0x1a1d,
+	0x1a5f, 0x1a5f,
+	0x1a7d, 0x1a7e,
+	0x1a8a, 0x1a8f,
+	0x1a9a, 0x1a9f,
+	0x1aae, 0x1aaf,
+	0x1abf, 0x1aff,
+	0x1b4c, 0x1b4f,
+	0x1b7d, 0x1b7f,
+	0x1bf4, 0x1bfb,
+	0x1c38, 0x1c3a,
+	0x1c4a, 0x1c4c,
+	0x1c80, 0x1cbf,
+	0x1cc8, 0x1ccf,
+	0x1cf7, 0x1cf7,
+	0x1cfa, 0x1cff,
+	0x1df6, 0x1dfb,
+	0x1f16, 0x1f17,
+	0x1f1e, 0x1f1f,
+	0x1f46, 0x1f47,
+	0x1f4e, 0x1f4f,
+	0x1f58, 0x1f58,
+	0x1f5a, 0x1f5a,
+	0x1f5c, 0x1f5c,
+	0x1f5e, 0x1f5e,
+	0x1f7e, 0x1f7f,
+	0x1fb5, 0x1fb5,
+	0x1fc5, 0x1fc5,
+	0x1fd4, 0x1fd5,
+	0x1fdc, 0x1fdc,
+	0x1ff0, 0x1ff1,
+	0x1ff5, 0x1ff5,
+	0x1fff, 0x1fff,
+	0x2065, 0x2065,
+	0x2072, 0x2073,
+	0x208f, 0x208f,
+	0x209d, 0x209f,
+	0x20be, 0x20cf,
+	0x20f1, 0x20ff,
+	0x218a, 0x218f,
+	0x23fb, 0x23ff,
+	0x2427, 0x243f,
+	0x244b, 0x245f,
+	0x2b74, 0x2b75,
+	0x2b96, 0x2b97,
+	0x2bba, 0x2bbc,
+	0x2bc9, 0x2bc9,
+	0x2bd2, 0x2bff,
+	0x2c2f, 0x2c2f,
+	0x2c5f, 0x2c5f,
+	0x2cf4, 0x2cf8,
+	0x2d26, 0x2d26,
+	0x2d28, 0x2d2c,
+	0x2d2e, 0x2d2f,
+	0x2d68, 0x2d6e,
+	0x2d71, 0x2d7e,
+	0x2d97, 0x2d9f,
+	0x2da7, 0x2da7,
+	0x2daf, 0x2daf,
+	0x2db7, 0x2db7,
+	0x2dbf, 0x2dbf,
+	0x2dc7, 0x2dc7,
+	0x2dcf, 0x2dcf,
+	0x2dd7, 0x2dd7,
+	0x2ddf, 0x2ddf,
+	0x2e43, 0x2e7f,
+	0x2e9a, 0x2e9a,
+	0x2ef4, 0x2eff,
+	0x2fd6, 0x2fef,
+	0x2ffc, 0x2fff,
+	0x3040, 0x3040,
+	0x3097, 0x3098,
+	0x3100, 0x3104,
+	0x312e, 0x3130,
+	0x318f, 0x318f,
+	0x31bb, 0x31bf,
+	0x31e4, 0x31ef,
+	0x321f, 0x321f,
+	0x32ff, 0x32ff,
+	0x4db6, 0x4dbf,
+	0x9fcd, 0x9fff,
+	0xa48d, 0xa48f,
+	0xa4c7, 0xa4cf,
+	0xa62c, 0xa63f,
+	0xa69e, 0xa69e,
+	0xa6f8, 0xa6ff,
+	0xa78f, 0xa78f,
+	0xa7ae, 0xa7af,
+	0xa7b2, 0xa7f6,
+	0xa82c, 0xa82f,
+	0xa83a, 0xa83f,
+	0xa878, 0xa87f,
+	0xa8c5, 0xa8cd,
+	0xa8da, 0xa8df,
+	0xa8fc, 0xa8ff,
+	0xa954, 0xa95e,
+	0xa97d, 0xa97f,
+	0xa9ce, 0xa9ce,
+	0xa9da, 0xa9dd,
+	0xa9ff, 0xa9ff,
+	0xaa37, 0xaa3f,
+	0xaa4e, 0xaa4f,
+	0xaa5a, 0xaa5b,
+	0xaac3, 0xaada,
+	0xaaf7, 0xab00,
+	0xab07, 0xab08,
+	0xab0f, 0xab10,
+	0xab17, 0xab1f,
+	0xab27, 0xab27,
+	0xab2f, 0xab2f,
+	0xab60, 0xab63,
+	0xab66, 0xabbf,
+	0xabee, 0xabef,
+	0xabfa, 0xabff,
+	0xd7a4, 0xd7af,
+	0xd7c7, 0xd7ca,
+	0xd7fc, 0xf8ff,
+	0xfa6e, 0xfa6f,
+	0xfada, 0xfaff,
+	0xfb07, 0xfb12,
+	0xfb18, 0xfb1c,
+	0xfb37, 0xfb37,
+	0xfb3d, 0xfb3d,
+	0xfb3f, 0xfb3f,
+	0xfb42, 0xfb42,
+	0xfb45, 0xfb45,
+	0xfbc2, 0xfbd2,
+	0xfd40, 0xfd4f,
+	0xfd90, 0xfd91,
+	0xfdc8, 0xfdef,
+	0xfdfe, 0xfdff,
+	0xfe1a, 0xfe1f,
+	0xfe2e, 0xfe2f,
+	0xfe53, 0xfe53,
+	0xfe67, 0xfe67,
+	0xfe6c, 0xfe6f,
+	0xfe75, 0xfe75,
+	0xfefd, 0xfefe,
+	0xff00, 0xff00,
+	0xffbf, 0xffc1,
+	0xffc8, 0xffc9,
+	0xffd0, 0xffd1,
+	0xffd8, 0xffd9,
+	0xffdd, 0xffdf,
+	0xffe7, 0xffe7,
+	0xffef, 0xfff8,
+	0xfffe, 0xffff,
+	0x1000c, 0x1000c,
+	0x10027, 0x10027,
+	0x1003b, 0x1003b,
+	0x1003e, 0x1003e,
+	0x1004e, 0x1004f,
+	0x1005e, 0x1007f,
+	0x100fb, 0x100ff,
+	0x10103, 0x10106,
+	0x10134, 0x10136,
+	0x1018d, 0x1018f,
+	0x1019c, 0x1019f,
+	0x101a1, 0x101cf,
+	0x101fe, 0x1027f,
+	0x1029d, 0x1029f,
+	0x102d1, 0x102df,
+	0x102fc, 0x102ff,
+	0x10324, 0x1032f,
+	0x1034b, 0x1034f,
+	0x1037b, 0x1037f,
+	0x1039e, 0x1039e,
+	0x103c4, 0x103c7,
+	0x103d6, 0x103ff,
+	0x1049e, 0x1049f,
+	0x104aa, 0x104ff,
+	0x10528, 0x1052f,
+	0x10564, 0x1056e,
+	0x10570, 0x105ff,
+	0x10737, 0x1073f,
+	0x10756, 0x1075f,
+	0x10768, 0x107ff,
+	0x10806, 0x10807,
+	0x10809, 0x10809,
+	0x10836, 0x10836,
+	0x10839, 0x1083b,
+	0x1083d, 0x1083e,
+	0x10856, 0x10856,
+	0x1089f, 0x108a6,
+	0x108b0, 0x108ff,
+	0x1091c, 0x1091e,
+	0x1093a, 0x1093e,
+	0x10940, 0x1097f,
+	0x109b8, 0x109bd,
+	0x109c0, 0x109ff,
+	0x10a04, 0x10a04,
+	0x10a07, 0x10a0b,
+	0x10a14, 0x10a14,
+	0x10a18, 0x10a18,
+	0x10a34, 0x10a37,
+	0x10a3b, 0x10a3e,
+	0x10a48, 0x10a4f,
+	0x10a59, 0x10a5f,
+	0x10aa0, 0x10abf,
+	0x10ae7, 0x10aea,
+	0x10af7, 0x10aff,
+	0x10b36, 0x10b38,
+	0x10b56, 0x10b57,
+	0x10b73, 0x10b77,
+	0x10b92, 0x10b98,
+	0x10b9d, 0x10ba8,
+	0x10bb0, 0x10bff,
+	0x10c49, 0x10e5f,
+	0x10e7f, 0x10fff,
+	0x1104e, 0x11051,
+	0x11070, 0x1107e,
+	0x110c2, 0x110cf,
+	0x110e9, 0x110ef,
+	0x110fa, 0x110ff,
+	0x11135, 0x11135,
+	0x11144, 0x1114f,
+	0x11177, 0x1117f,
+	0x111c9, 0x111cc,
+	0x111ce, 0x111cf,
+	0x111db, 0x111e0,
+	0x111f5, 0x111ff,
+	0x11212, 0x11212,
+	0x1123e, 0x112af,
+	0x112eb, 0x112ef,
+	0x112fa, 0x11300,
+	0x11304, 0x11304,
+	0x1130d, 0x1130e,
+	0x11311, 0x11312,
+	0x11329, 0x11329,
+	0x11331, 0x11331,
+	0x11334, 0x11334,
+	0x1133a, 0x1133b,
+	0x11345, 0x11346,
+	0x11349, 0x1134a,
+	0x1134e, 0x11356,
+	0x11358, 0x1135c,
+	0x11364, 0x11365,
+	0x1136d, 0x1136f,
+	0x11375, 0x1147f,
+	0x114c8, 0x114cf,
+	0x114da, 0x1157f,
+	0x115b6, 0x115b7,
+	0x115ca, 0x115ff,
+	0x11645, 0x1164f,
+	0x1165a, 0x1167f,
+	0x116b8, 0x116bf,
+	0x116ca, 0x1189f,
+	0x118f3, 0x118fe,
+	0x11900, 0x11abf,
+	0x11af9, 0x11fff,
+	0x12399, 0x123ff,
+	0x1246f, 0x1246f,
+	0x12475, 0x12fff,
+	0x1342f, 0x167ff,
+	0x16a39, 0x16a3f,
+	0x16a5f, 0x16a5f,
+	0x16a6a, 0x16a6d,
+	0x16a70, 0x16acf,
+	0x16aee, 0x16aef,
+	0x16af6, 0x16aff,
+	0x16b46, 0x16b4f,
+	0x16b5a, 0x16b5a,
+	0x16b62, 0x16b62,
+	0x16b78, 0x16b7c,
+	0x16b90, 0x16eff,
+	0x16f45, 0x16f4f,
+	0x16f7f, 0x16f8e,
+	0x16fa0, 0x1afff,
+	0x1b002, 0x1bbff,
+	0x1bc6b, 0x1bc6f,
+	0x1bc7d, 0x1bc7f,
+	0x1bc89, 0x1bc8f,
+	0x1bc9a, 0x1bc9b,
+	0x1bca4, 0x1cfff,
+	0x1d0f6, 0x1d0ff,
+	0x1d127, 0x1d128,
+	0x1d1de, 0x1d1ff,
+	0x1d246, 0x1d2ff,
+	0x1d357, 0x1d35f,
+	0x1d372, 0x1d3ff,
+	0x1d455, 0x1d455,
+	0x1d49d, 0x1d49d,
+	0x1d4a0, 0x1d4a1,
+	0x1d4a3, 0x1d4a4,
+	0x1d4a7, 0x1d4a8,
+	0x1d4ad, 0x1d4ad,
+	0x1d4ba, 0x1d4ba,
+	0x1d4bc, 0x1d4bc,
+	0x1d4c4, 0x1d4c4,
+	0x1d506, 0x1d506,
+	0x1d50b, 0x1d50c,
+	0x1d515, 0x1d515,
+	0x1d51d, 0x1d51d,
+	0x1d53a, 0x1d53a,
+	0x1d53f, 0x1d53f,
+	0x1d545, 0x1d545,
+	0x1d547, 0x1d549,
+	0x1d551, 0x1d551,
+	0x1d6a6, 0x1d6a7,
+	0x1d7cc, 0x1d7cd,
+	0x1d800, 0x1e7ff,
+	0x1e8c5, 0x1e8c6,
+	0x1e8d7, 0x1edff,
+	0x1ee04, 0x1ee04,
+	0x1ee20, 0x1ee20,
+	0x1ee23, 0x1ee23,
+	0x1ee25, 0x1ee26,
+	0x1ee28, 0x1ee28,
+	0x1ee33, 0x1ee33,
+	0x1ee38, 0x1ee38,
+	0x1ee3a, 0x1ee3a,
+	0x1ee3c, 0x1ee41,
+	0x1ee43, 0x1ee46,
+	0x1ee48, 0x1ee48,
+	0x1ee4a, 0x1ee4a,
+	0x1ee4c, 0x1ee4c,
+	0x1ee50, 0x1ee50,
+	0x1ee53, 0x1ee53,
+	0x1ee55, 0x1ee56,
+	0x1ee58, 0x1ee58,
+	0x1ee5a, 0x1ee5a,
+	0x1ee5c, 0x1ee5c,
+	0x1ee5e, 0x1ee5e,
+	0x1ee60, 0x1ee60,
+	0x1ee63, 0x1ee63,
+	0x1ee65, 0x1ee66,
+	0x1ee6b, 0x1ee6b,
+	0x1ee73, 0x1ee73,
+	0x1ee78, 0x1ee78,
+	0x1ee7d, 0x1ee7d,
+	0x1ee7f, 0x1ee7f,
+	0x1ee8a, 0x1ee8a,
+	0x1ee9c, 0x1eea0,
+	0x1eea4, 0x1eea4,
+	0x1eeaa, 0x1eeaa,
+	0x1eebc, 0x1eeef,
+	0x1eef2, 0x1efff,
+	0x1f02c, 0x1f02f,
+	0x1f094, 0x1f09f,
+	0x1f0af, 0x1f0b0,
+	0x1f0c0, 0x1f0c0,
+	0x1f0d0, 0x1f0d0,
+	0x1f0f6, 0x1f0ff,
+	0x1f10d, 0x1f10f,
+	0x1f12f, 0x1f12f,
+	0x1f16c, 0x1f16f,
+	0x1f19b, 0x1f1e5,
+	0x1f203, 0x1f20f,
+	0x1f23b, 0x1f23f,
+	0x1f249, 0x1f24f,
+	0x1f252, 0x1f2ff,
+	0x1f32d, 0x1f32f,
+	0x1f37e, 0x1f37f,
+	0x1f3cf, 0x1f3d3,
+	0x1f3f8, 0x1f3ff,
+	0x1f4ff, 0x1f4ff,
+	0x1f54b, 0x1f54f,
+	0x1f57a, 0x1f57a,
+	0x1f5a4, 0x1f5a4,
+	0x1f643, 0x1f644,
+	0x1f6d0, 0x1f6df,
+	0x1f6ed, 0x1f6ef,
+	0x1f6f4, 0x1f6ff,
+	0x1f774, 0x1f77f,
+	0x1f7d5, 0x1f7ff,
+	0x1f80c, 0x1f80f,
+	0x1f848, 0x1f84f,
+	0x1f85a, 0x1f85f,
+	0x1f888, 0x1f88f,
+	0x1f8ae, 0x1ffff,
+	0x2a6d7, 0x2a6ff,
+	0x2b735, 0x2b73f,
+	0x2b81e, 0x2f7ff,
+	0x2fa1e, 0xe0000,
+	0xe0002, 0xe001f,
+	0xe0080, 0xe00ff,
+	0xe01f0, 0x10ffff,
+}; /* CR_Unknown */
+
+#ifdef USE_UNICODE_AGE_PROPERTIES
+/* 'Age_1_1': Derived Age 1.1 */
+static const OnigCodePoint CR_Age_1_1[] = {
+	288,
+	0x0000, 0x01f5,
+	0x01fa, 0x0217,
+	0x0250, 0x02a8,
+	0x02b0, 0x02de,
+	0x02e0, 0x02e9,
+	0x0300, 0x0345,
+	0x0360, 0x0361,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x03d6,
+	0x03da, 0x03da,
+	0x03dc, 0x03dc,
+	0x03de, 0x03de,
+	0x03e0, 0x03e0,
+	0x03e2, 0x03f3,
+	0x0401, 0x040c,
+	0x040e, 0x044f,
+	0x0451, 0x045c,
+	0x045e, 0x0486,
+	0x0490, 0x04c4,
+	0x04c7, 0x04c8,
+	0x04cb, 0x04cc,
+	0x04d0, 0x04eb,
+	0x04ee, 0x04f5,
+	0x04f8, 0x04f9,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x0589,
+	0x05b0, 0x05b9,
+	0x05bb, 0x05c3,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x060c, 0x060c,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x0652,
+	0x0660, 0x066d,
+	0x0670, 0x06b7,
+	0x06ba, 0x06be,
+	0x06c0, 0x06ce,
+	0x06d0, 0x06ed,
+	0x06f0, 0x06f9,
+	0x0901, 0x0903,
+	0x0905, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09bc,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a02, 0x0a02,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8b,
+	0x0a8d, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae0,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b36, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b70,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb5,
+	0x0bb7, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be7, 0x0bf2,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10f6,
+	0x10fb, 0x10fb,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1e00, 0x1e9a,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x202e,
+	0x2030, 0x2046,
+	0x206a, 0x2070,
+	0x2074, 0x208e,
+	0x20a0, 0x20aa,
+	0x20d0, 0x20e1,
+	0x2100, 0x2138,
+	0x2153, 0x2182,
+	0x2190, 0x21ea,
+	0x2200, 0x22f1,
+	0x2300, 0x2300,
+	0x2302, 0x237a,
+	0x2400, 0x2424,
+	0x2440, 0x244a,
+	0x2460, 0x24ea,
+	0x2500, 0x2595,
+	0x25a0, 0x25ef,
+	0x2600, 0x2613,
+	0x261a, 0x266f,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2767,
+	0x2776, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x3000, 0x3037,
+	0x303f, 0x303f,
+	0x3041, 0x3094,
+	0x3099, 0x309e,
+	0x30a1, 0x30fe,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x319f,
+	0x3200, 0x321c,
+	0x3220, 0x3243,
+	0x3260, 0x327b,
+	0x327f, 0x32b0,
+	0x32c0, 0x32cb,
+	0x32d0, 0x32fe,
+	0x3300, 0x3376,
+	0x337b, 0x33dd,
+	0x33e0, 0x33fe,
+	0x4e00, 0x9fa5,
+	0xe000, 0xfa2d,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1e, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe44,
+	0xfe49, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe72,
+	0xfe74, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xff5e,
+	0xff61, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfffd, 0xffff,
+}; /* CR_Age_1_1 */
+
+/* 'Age_2_0': Derived Age 2.0 */
+static const OnigCodePoint CR_Age_2_0[] = {
+	312,
+	0x0000, 0x01f5,
+	0x01fa, 0x0217,
+	0x0250, 0x02a8,
+	0x02b0, 0x02de,
+	0x02e0, 0x02e9,
+	0x0300, 0x0345,
+	0x0360, 0x0361,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x03d6,
+	0x03da, 0x03da,
+	0x03dc, 0x03dc,
+	0x03de, 0x03de,
+	0x03e0, 0x03e0,
+	0x03e2, 0x03f3,
+	0x0401, 0x040c,
+	0x040e, 0x044f,
+	0x0451, 0x045c,
+	0x045e, 0x0486,
+	0x0490, 0x04c4,
+	0x04c7, 0x04c8,
+	0x04cb, 0x04cc,
+	0x04d0, 0x04eb,
+	0x04ee, 0x04f5,
+	0x04f8, 0x04f9,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x0589,
+	0x0591, 0x05a1,
+	0x05a3, 0x05b9,
+	0x05bb, 0x05c4,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x060c, 0x060c,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x0652,
+	0x0660, 0x066d,
+	0x0670, 0x06b7,
+	0x06ba, 0x06be,
+	0x06c0, 0x06ce,
+	0x06d0, 0x06ed,
+	0x06f0, 0x06f9,
+	0x0901, 0x0903,
+	0x0905, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09bc,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a02, 0x0a02,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8b,
+	0x0a8d, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae0,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b36, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b70,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb5,
+	0x0bb7, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be7, 0x0bf2,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f69,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f95,
+	0x0f97, 0x0f97,
+	0x0f99, 0x0fad,
+	0x0fb1, 0x0fb7,
+	0x0fb9, 0x0fb9,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10f6,
+	0x10fb, 0x10fb,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1e00, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x202e,
+	0x2030, 0x2046,
+	0x206a, 0x2070,
+	0x2074, 0x208e,
+	0x20a0, 0x20ab,
+	0x20d0, 0x20e1,
+	0x2100, 0x2138,
+	0x2153, 0x2182,
+	0x2190, 0x21ea,
+	0x2200, 0x22f1,
+	0x2300, 0x2300,
+	0x2302, 0x237a,
+	0x2400, 0x2424,
+	0x2440, 0x244a,
+	0x2460, 0x24ea,
+	0x2500, 0x2595,
+	0x25a0, 0x25ef,
+	0x2600, 0x2613,
+	0x261a, 0x266f,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2767,
+	0x2776, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x3000, 0x3037,
+	0x303f, 0x303f,
+	0x3041, 0x3094,
+	0x3099, 0x309e,
+	0x30a1, 0x30fe,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x319f,
+	0x3200, 0x321c,
+	0x3220, 0x3243,
+	0x3260, 0x327b,
+	0x327f, 0x32b0,
+	0x32c0, 0x32cb,
+	0x32d0, 0x32fe,
+	0x3300, 0x3376,
+	0x337b, 0x33dd,
+	0x33e0, 0x33fe,
+	0x4e00, 0x9fa5,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1e, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe44,
+	0xfe49, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe72,
+	0xfe74, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xff5e,
+	0xff61, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfffd, 0xffff,
+	0x1fffe, 0x1ffff,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_2_0 */
+
+/* 'Age_2_1': Derived Age 2.1 */
+static const OnigCodePoint CR_Age_2_1[] = {
+	312,
+	0x0000, 0x01f5,
+	0x01fa, 0x0217,
+	0x0250, 0x02a8,
+	0x02b0, 0x02de,
+	0x02e0, 0x02e9,
+	0x0300, 0x0345,
+	0x0360, 0x0361,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x03d6,
+	0x03da, 0x03da,
+	0x03dc, 0x03dc,
+	0x03de, 0x03de,
+	0x03e0, 0x03e0,
+	0x03e2, 0x03f3,
+	0x0401, 0x040c,
+	0x040e, 0x044f,
+	0x0451, 0x045c,
+	0x045e, 0x0486,
+	0x0490, 0x04c4,
+	0x04c7, 0x04c8,
+	0x04cb, 0x04cc,
+	0x04d0, 0x04eb,
+	0x04ee, 0x04f5,
+	0x04f8, 0x04f9,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x0589,
+	0x0591, 0x05a1,
+	0x05a3, 0x05b9,
+	0x05bb, 0x05c4,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x060c, 0x060c,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x0652,
+	0x0660, 0x066d,
+	0x0670, 0x06b7,
+	0x06ba, 0x06be,
+	0x06c0, 0x06ce,
+	0x06d0, 0x06ed,
+	0x06f0, 0x06f9,
+	0x0901, 0x0903,
+	0x0905, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09bc,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a02, 0x0a02,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8b,
+	0x0a8d, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae0,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b36, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b70,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb5,
+	0x0bb7, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be7, 0x0bf2,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f69,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f95,
+	0x0f97, 0x0f97,
+	0x0f99, 0x0fad,
+	0x0fb1, 0x0fb7,
+	0x0fb9, 0x0fb9,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10f6,
+	0x10fb, 0x10fb,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1e00, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x202e,
+	0x2030, 0x2046,
+	0x206a, 0x2070,
+	0x2074, 0x208e,
+	0x20a0, 0x20ac,
+	0x20d0, 0x20e1,
+	0x2100, 0x2138,
+	0x2153, 0x2182,
+	0x2190, 0x21ea,
+	0x2200, 0x22f1,
+	0x2300, 0x2300,
+	0x2302, 0x237a,
+	0x2400, 0x2424,
+	0x2440, 0x244a,
+	0x2460, 0x24ea,
+	0x2500, 0x2595,
+	0x25a0, 0x25ef,
+	0x2600, 0x2613,
+	0x261a, 0x266f,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2767,
+	0x2776, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x3000, 0x3037,
+	0x303f, 0x303f,
+	0x3041, 0x3094,
+	0x3099, 0x309e,
+	0x30a1, 0x30fe,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x319f,
+	0x3200, 0x321c,
+	0x3220, 0x3243,
+	0x3260, 0x327b,
+	0x327f, 0x32b0,
+	0x32c0, 0x32cb,
+	0x32d0, 0x32fe,
+	0x3300, 0x3376,
+	0x337b, 0x33dd,
+	0x33e0, 0x33fe,
+	0x4e00, 0x9fa5,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1e, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe44,
+	0xfe49, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe72,
+	0xfe74, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xff5e,
+	0xff61, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfffc, 0xffff,
+	0x1fffe, 0x1ffff,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_2_1 */
+
+/* 'Age_3_0': Derived Age 3.0 */
+static const OnigCodePoint CR_Age_3_0[] = {
+	369,
+	0x0000, 0x021f,
+	0x0222, 0x0233,
+	0x0250, 0x02ad,
+	0x02b0, 0x02ee,
+	0x0300, 0x034e,
+	0x0360, 0x0362,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x03d7,
+	0x03da, 0x03f3,
+	0x0400, 0x0486,
+	0x0488, 0x0489,
+	0x048c, 0x04c4,
+	0x04c7, 0x04c8,
+	0x04cb, 0x04cc,
+	0x04d0, 0x04f5,
+	0x04f8, 0x04f9,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05a1,
+	0x05a3, 0x05b9,
+	0x05bb, 0x05c4,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x060c, 0x060c,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x0655,
+	0x0660, 0x066d,
+	0x0670, 0x06ed,
+	0x06f0, 0x06fe,
+	0x0700, 0x070d,
+	0x070f, 0x072c,
+	0x0730, 0x074a,
+	0x0780, 0x07b0,
+	0x0901, 0x0903,
+	0x0905, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09bc,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a02, 0x0a02,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8b,
+	0x0a8d, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae0,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b36, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b70,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb5,
+	0x0bb7, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be7, 0x0bf2,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6a,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fcf, 0x0fcf,
+	0x1000, 0x1021,
+	0x1023, 0x1027,
+	0x1029, 0x102a,
+	0x102c, 0x1032,
+	0x1036, 0x1039,
+	0x1040, 0x1059,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10f6,
+	0x10fb, 0x10fb,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1200, 0x1206,
+	0x1208, 0x1246,
+	0x1248, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1286,
+	0x1288, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12ae,
+	0x12b0, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12ce,
+	0x12d0, 0x12d6,
+	0x12d8, 0x12ee,
+	0x12f0, 0x130e,
+	0x1310, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x131e,
+	0x1320, 0x1346,
+	0x1348, 0x135a,
+	0x1361, 0x137c,
+	0x13a0, 0x13f4,
+	0x1401, 0x1676,
+	0x1680, 0x169c,
+	0x16a0, 0x16f0,
+	0x1780, 0x17dc,
+	0x17e0, 0x17e9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18a9,
+	0x1e00, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2046,
+	0x2048, 0x204d,
+	0x206a, 0x2070,
+	0x2074, 0x208e,
+	0x20a0, 0x20af,
+	0x20d0, 0x20e3,
+	0x2100, 0x213a,
+	0x2153, 0x2183,
+	0x2190, 0x21f3,
+	0x2200, 0x22f1,
+	0x2300, 0x237b,
+	0x237d, 0x239a,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x24ea,
+	0x2500, 0x2595,
+	0x25a0, 0x25f7,
+	0x2600, 0x2613,
+	0x2619, 0x2671,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2767,
+	0x2776, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x2800, 0x28ff,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303a,
+	0x303e, 0x303f,
+	0x3041, 0x3094,
+	0x3099, 0x309e,
+	0x30a1, 0x30fe,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x3200, 0x321c,
+	0x3220, 0x3243,
+	0x3260, 0x327b,
+	0x327f, 0x32b0,
+	0x32c0, 0x32cb,
+	0x32d0, 0x32fe,
+	0x3300, 0x3376,
+	0x337b, 0x33dd,
+	0x33e0, 0x33fe,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fa5,
+	0xa000, 0xa48c,
+	0xa490, 0xa4a1,
+	0xa4a4, 0xa4b3,
+	0xa4b5, 0xa4c0,
+	0xa4c2, 0xa4c4,
+	0xa4c6, 0xa4c6,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdf0, 0xfdfb,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe44,
+	0xfe49, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe72,
+	0xfe74, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xff5e,
+	0xff61, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0xffff,
+	0x1fffe, 0x1ffff,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_3_0 */
+
+/* 'Age_3_1': Derived Age 3.1 */
+static const OnigCodePoint CR_Age_3_1[] = {
+	402,
+	0x0000, 0x021f,
+	0x0222, 0x0233,
+	0x0250, 0x02ad,
+	0x02b0, 0x02ee,
+	0x0300, 0x034e,
+	0x0360, 0x0362,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x03d7,
+	0x03da, 0x03f5,
+	0x0400, 0x0486,
+	0x0488, 0x0489,
+	0x048c, 0x04c4,
+	0x04c7, 0x04c8,
+	0x04cb, 0x04cc,
+	0x04d0, 0x04f5,
+	0x04f8, 0x04f9,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05a1,
+	0x05a3, 0x05b9,
+	0x05bb, 0x05c4,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x060c, 0x060c,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x0655,
+	0x0660, 0x066d,
+	0x0670, 0x06ed,
+	0x06f0, 0x06fe,
+	0x0700, 0x070d,
+	0x070f, 0x072c,
+	0x0730, 0x074a,
+	0x0780, 0x07b0,
+	0x0901, 0x0903,
+	0x0905, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09bc,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a02, 0x0a02,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8b,
+	0x0a8d, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae0,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b36, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b70,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb5,
+	0x0bb7, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be7, 0x0bf2,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6a,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fcf, 0x0fcf,
+	0x1000, 0x1021,
+	0x1023, 0x1027,
+	0x1029, 0x102a,
+	0x102c, 0x1032,
+	0x1036, 0x1039,
+	0x1040, 0x1059,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10f6,
+	0x10fb, 0x10fb,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1200, 0x1206,
+	0x1208, 0x1246,
+	0x1248, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1286,
+	0x1288, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12ae,
+	0x12b0, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12ce,
+	0x12d0, 0x12d6,
+	0x12d8, 0x12ee,
+	0x12f0, 0x130e,
+	0x1310, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x131e,
+	0x1320, 0x1346,
+	0x1348, 0x135a,
+	0x1361, 0x137c,
+	0x13a0, 0x13f4,
+	0x1401, 0x1676,
+	0x1680, 0x169c,
+	0x16a0, 0x16f0,
+	0x1780, 0x17dc,
+	0x17e0, 0x17e9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18a9,
+	0x1e00, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2046,
+	0x2048, 0x204d,
+	0x206a, 0x2070,
+	0x2074, 0x208e,
+	0x20a0, 0x20af,
+	0x20d0, 0x20e3,
+	0x2100, 0x213a,
+	0x2153, 0x2183,
+	0x2190, 0x21f3,
+	0x2200, 0x22f1,
+	0x2300, 0x237b,
+	0x237d, 0x239a,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x24ea,
+	0x2500, 0x2595,
+	0x25a0, 0x25f7,
+	0x2600, 0x2613,
+	0x2619, 0x2671,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2767,
+	0x2776, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x2800, 0x28ff,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303a,
+	0x303e, 0x303f,
+	0x3041, 0x3094,
+	0x3099, 0x309e,
+	0x30a1, 0x30fe,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x3200, 0x321c,
+	0x3220, 0x3243,
+	0x3260, 0x327b,
+	0x327f, 0x32b0,
+	0x32c0, 0x32cb,
+	0x32d0, 0x32fe,
+	0x3300, 0x3376,
+	0x337b, 0x33dd,
+	0x33e0, 0x33fe,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fa5,
+	0xa000, 0xa48c,
+	0xa490, 0xa4a1,
+	0xa4a4, 0xa4b3,
+	0xa4b5, 0xa4c0,
+	0xa4c2, 0xa4c4,
+	0xa4c6, 0xa4c6,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfb,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe44,
+	0xfe49, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe72,
+	0xfe74, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xff5e,
+	0xff61, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0xffff,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10400, 0x10425,
+	0x10428, 0x1044d,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d12a, 0x1d1dd,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c0,
+	0x1d4c2, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a3,
+	0x1d6a8, 0x1d7c9,
+	0x1d7ce, 0x1d7ff,
+	0x1fffe, 0x2a6d6,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_3_1 */
+
+/* 'Age_3_2': Derived Age 3.2 */
+static const OnigCodePoint CR_Age_3_2[] = {
+	397,
+	0x0000, 0x0220,
+	0x0222, 0x0233,
+	0x0250, 0x02ad,
+	0x02b0, 0x02ee,
+	0x0300, 0x034f,
+	0x0360, 0x036f,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x03f6,
+	0x0400, 0x0486,
+	0x0488, 0x04ce,
+	0x04d0, 0x04f5,
+	0x04f8, 0x04f9,
+	0x0500, 0x050f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05a1,
+	0x05a3, 0x05b9,
+	0x05bb, 0x05c4,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x060c, 0x060c,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x0655,
+	0x0660, 0x06ed,
+	0x06f0, 0x06fe,
+	0x0700, 0x070d,
+	0x070f, 0x072c,
+	0x0730, 0x074a,
+	0x0780, 0x07b1,
+	0x0901, 0x0903,
+	0x0905, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09bc,
+	0x09be, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a02, 0x0a02,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8b,
+	0x0a8d, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae0,
+	0x0ae6, 0x0aef,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b36, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b70,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb5,
+	0x0bb7, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be7, 0x0bf2,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbe, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6a,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fcf, 0x0fcf,
+	0x1000, 0x1021,
+	0x1023, 0x1027,
+	0x1029, 0x102a,
+	0x102c, 0x1032,
+	0x1036, 0x1039,
+	0x1040, 0x1059,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10f8,
+	0x10fb, 0x10fb,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1200, 0x1206,
+	0x1208, 0x1246,
+	0x1248, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1286,
+	0x1288, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12ae,
+	0x12b0, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12ce,
+	0x12d0, 0x12d6,
+	0x12d8, 0x12ee,
+	0x12f0, 0x130e,
+	0x1310, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x131e,
+	0x1320, 0x1346,
+	0x1348, 0x135a,
+	0x1361, 0x137c,
+	0x13a0, 0x13f4,
+	0x1401, 0x1676,
+	0x1680, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dc,
+	0x17e0, 0x17e9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18a9,
+	0x1e00, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2052,
+	0x2057, 0x2057,
+	0x205f, 0x2063,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x20a0, 0x20b1,
+	0x20d0, 0x20ea,
+	0x2100, 0x213a,
+	0x213d, 0x214b,
+	0x2153, 0x2183,
+	0x2190, 0x23ce,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x24fe,
+	0x2500, 0x2613,
+	0x2616, 0x2617,
+	0x2619, 0x267d,
+	0x2680, 0x2689,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x27d0, 0x27eb,
+	0x27f0, 0x2aff,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x31f0, 0x321c,
+	0x3220, 0x3243,
+	0x3251, 0x327b,
+	0x327f, 0x32cb,
+	0x32d0, 0x32fe,
+	0x3300, 0x3376,
+	0x337b, 0x33dd,
+	0x33e0, 0x33fe,
+	0x3400, 0x4db5,
+	0x4e00, 0x9fa5,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfa30, 0xfa6a,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfc,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe46,
+	0xfe49, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0xffff,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10400, 0x10425,
+	0x10428, 0x1044d,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d12a, 0x1d1dd,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c0,
+	0x1d4c2, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a3,
+	0x1d6a8, 0x1d7c9,
+	0x1d7ce, 0x1d7ff,
+	0x1fffe, 0x2a6d6,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_3_2 */
+
+/* 'Age_4_0': Derived Age 4.0 */
+static const OnigCodePoint CR_Age_4_0[] = {
+	412,
+	0x0000, 0x0236,
+	0x0250, 0x0357,
+	0x035d, 0x036f,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x03fb,
+	0x0400, 0x0486,
+	0x0488, 0x04ce,
+	0x04d0, 0x04f5,
+	0x04f8, 0x04f9,
+	0x0500, 0x050f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05a1,
+	0x05a3, 0x05b9,
+	0x05bb, 0x05c4,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0603,
+	0x060c, 0x0615,
+	0x061b, 0x061b,
+	0x061f, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x0658,
+	0x0660, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x074f,
+	0x0780, 0x07b1,
+	0x0901, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09cd,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0af1, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb5,
+	0x0bb7, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be7, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6a,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fcf, 0x0fcf,
+	0x1000, 0x1021,
+	0x1023, 0x1027,
+	0x1029, 0x102a,
+	0x102c, 0x1032,
+	0x1036, 0x1039,
+	0x1040, 0x1059,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10f8,
+	0x10fb, 0x10fb,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1200, 0x1206,
+	0x1208, 0x1246,
+	0x1248, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1286,
+	0x1288, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12ae,
+	0x12b0, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12ce,
+	0x12d0, 0x12d6,
+	0x12d8, 0x12ee,
+	0x12f0, 0x130e,
+	0x1310, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x131e,
+	0x1320, 0x1346,
+	0x1348, 0x135a,
+	0x1361, 0x137c,
+	0x13a0, 0x13f4,
+	0x1401, 0x1676,
+	0x1680, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18a9,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x19e0, 0x19ff,
+	0x1d00, 0x1d6b,
+	0x1e00, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2054,
+	0x2057, 0x2057,
+	0x205f, 0x2063,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x20a0, 0x20b1,
+	0x20d0, 0x20ea,
+	0x2100, 0x213b,
+	0x213d, 0x214b,
+	0x2153, 0x2183,
+	0x2190, 0x23d0,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x2617,
+	0x2619, 0x267d,
+	0x2680, 0x2691,
+	0x26a0, 0x26a1,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x27d0, 0x27eb,
+	0x27f0, 0x2b0d,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x31f0, 0x321e,
+	0x3220, 0x3243,
+	0x3250, 0x327d,
+	0x327f, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fa5,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfa30, 0xfa6a,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe0f,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1013f,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x1039f,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x1083f,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d12a, 0x1d1dd,
+	0x1d300, 0x1d356,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a3,
+	0x1d6a8, 0x1d7c9,
+	0x1d7ce, 0x1d7ff,
+	0x1fffe, 0x2a6d6,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_4_0 */
+
+/* 'Age_4_1': Derived Age 4.1 */
+static const OnigCodePoint CR_Age_4_1[] = {
+	430,
+	0x0000, 0x0241,
+	0x0250, 0x036f,
+	0x0374, 0x0375,
+	0x037a, 0x037a,
+	0x037e, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x0486,
+	0x0488, 0x04ce,
+	0x04d0, 0x04f9,
+	0x0500, 0x050f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05b9,
+	0x05bb, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0603,
+	0x060b, 0x0615,
+	0x061b, 0x061b,
+	0x061e, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x065e,
+	0x0660, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x076d,
+	0x0780, 0x07b1,
+	0x0901, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x097d, 0x097d,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0af1, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce1,
+	0x0ce6, 0x0cef,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6a,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fcf, 0x0fd1,
+	0x1000, 0x1021,
+	0x1023, 0x1027,
+	0x1029, 0x102a,
+	0x102c, 0x1032,
+	0x1036, 0x1039,
+	0x1040, 0x1059,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10fc,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1200, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135f, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1401, 0x1676,
+	0x1680, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18a9,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19a9,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19d9,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a1f,
+	0x1d00, 0x1dc3,
+	0x1e00, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2063,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x2094,
+	0x20a0, 0x20b5,
+	0x20d0, 0x20eb,
+	0x2100, 0x214c,
+	0x2153, 0x2183,
+	0x2190, 0x23db,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x269c,
+	0x26a0, 0x26b1,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x27c0, 0x27c6,
+	0x27d0, 0x27eb,
+	0x27f0, 0x2b13,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c80, 0x2cea,
+	0x2cf9, 0x2d25,
+	0x2d30, 0x2d65,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2e00, 0x2e17,
+	0x2e1c, 0x2e1d,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x31c0, 0x31cf,
+	0x31f0, 0x321e,
+	0x3220, 0x3243,
+	0x3250, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fbb,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa700, 0xa716,
+	0xa800, 0xa82b,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfa30, 0xfa6a,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x1083f,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d12a, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7c9,
+	0x1d7ce, 0x1d7ff,
+	0x1fffe, 0x2a6d6,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_4_1 */
+
+/* 'Age_5_0': Derived Age 5.0 */
+static const OnigCodePoint CR_Age_5_0[] = {
+	440,
+	0x0000, 0x036f,
+	0x0374, 0x0375,
+	0x037a, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x03ce,
+	0x03d0, 0x0486,
+	0x0488, 0x0513,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0603,
+	0x060b, 0x0615,
+	0x061b, 0x061b,
+	0x061e, 0x061f,
+	0x0621, 0x063a,
+	0x0640, 0x065e,
+	0x0660, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x076d,
+	0x0780, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0901, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0970,
+	0x097b, 0x097f,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a74,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0af1, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b43,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b61,
+	0x0b66, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3e, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c60, 0x0c61,
+	0x0c66, 0x0c6f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3e, 0x0d43,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d61,
+	0x0d66, 0x0d6f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6a,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fcf, 0x0fd1,
+	0x1000, 0x1021,
+	0x1023, 0x1027,
+	0x1029, 0x102a,
+	0x102c, 0x1032,
+	0x1036, 0x1039,
+	0x1040, 0x1059,
+	0x10a0, 0x10c5,
+	0x10d0, 0x10fc,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1200, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135f, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1401, 0x1676,
+	0x1680, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18a9,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19a9,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19d9,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a1f,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1d00, 0x1dca,
+	0x1dfe, 0x1e9b,
+	0x1ea0, 0x1ef9,
+	0x1f00, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2063,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x2094,
+	0x20a0, 0x20b5,
+	0x20d0, 0x20ef,
+	0x2100, 0x214e,
+	0x2153, 0x2184,
+	0x2190, 0x23e7,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x269c,
+	0x26a0, 0x26b2,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x27c0, 0x27ca,
+	0x27d0, 0x27eb,
+	0x27f0, 0x2b1a,
+	0x2b20, 0x2b23,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2c6c,
+	0x2c74, 0x2c77,
+	0x2c80, 0x2cea,
+	0x2cf9, 0x2d25,
+	0x2d30, 0x2d65,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2e00, 0x2e17,
+	0x2e1c, 0x2e1d,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312c,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x31c0, 0x31cf,
+	0x31f0, 0x321e,
+	0x3220, 0x3243,
+	0x3250, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fbb,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa700, 0xa71a,
+	0xa720, 0xa721,
+	0xa800, 0xa82b,
+	0xa840, 0xa877,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfa30, 0xfa6a,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe23,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x1083f,
+	0x10900, 0x10919,
+	0x1091f, 0x1091f,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x12000, 0x1236e,
+	0x12400, 0x12462,
+	0x12470, 0x12473,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d12a, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1fffe, 0x2a6d6,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_5_0 */
+
+/* 'Age_5_1': Derived Age 5.1 */
+static const OnigCodePoint CR_Age_5_1[] = {
+	455,
+	0x0000, 0x0377,
+	0x037a, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x0523,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0603,
+	0x0606, 0x061b,
+	0x061e, 0x061f,
+	0x0621, 0x065e,
+	0x0660, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0901, 0x0939,
+	0x093c, 0x094d,
+	0x0950, 0x0954,
+	0x0958, 0x0972,
+	0x097b, 0x097f,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fa,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0af1, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fd4,
+	0x1000, 0x1099,
+	0x109e, 0x10c5,
+	0x10d0, 0x10fc,
+	0x1100, 0x1159,
+	0x115f, 0x11a2,
+	0x11a8, 0x11f9,
+	0x1200, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135f, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1401, 0x1676,
+	0x1680, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19a9,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19d9,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a1f,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1baa,
+	0x1bae, 0x1bb9,
+	0x1c00, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1d00, 0x1de6,
+	0x1dfe, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x2094,
+	0x20a0, 0x20b5,
+	0x20d0, 0x20f0,
+	0x2100, 0x214f,
+	0x2153, 0x2188,
+	0x2190, 0x23e7,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x269d,
+	0x26a0, 0x26bc,
+	0x26c0, 0x26c3,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x2756,
+	0x2758, 0x275e,
+	0x2761, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x27c0, 0x27ca,
+	0x27cc, 0x27cc,
+	0x27d0, 0x2b4c,
+	0x2b50, 0x2b54,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2c6f,
+	0x2c71, 0x2c7d,
+	0x2c80, 0x2cea,
+	0x2cf9, 0x2d25,
+	0x2d30, 0x2d65,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e30,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x3243,
+	0x3250, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fc3,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa500, 0xa62b,
+	0xa640, 0xa65f,
+	0xa662, 0xa673,
+	0xa67c, 0xa697,
+	0xa700, 0xa78c,
+	0xa7fb, 0xa82b,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa900, 0xa953,
+	0xa95f, 0xa95f,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa5f,
+	0xac00, 0xd7a3,
+	0xd800, 0xfa2d,
+	0xfa30, 0xfa6a,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe26,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10190, 0x1019b,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x1083f,
+	0x10900, 0x10919,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x12000, 0x1236e,
+	0x12400, 0x12462,
+	0x12470, 0x12473,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1fffe, 0x2a6d6,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_5_1 */
+
+/* 'Age_5_2': Derived Age 5.2 */
+static const OnigCodePoint CR_Age_5_2[] = {
+	495,
+	0x0000, 0x0377,
+	0x037a, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x0525,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0603,
+	0x0606, 0x061b,
+	0x061e, 0x061f,
+	0x0621, 0x065e,
+	0x0660, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0900, 0x0939,
+	0x093c, 0x094e,
+	0x0950, 0x0955,
+	0x0958, 0x0972,
+	0x0979, 0x097f,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0af1, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b71,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d28,
+	0x0d2a, 0x0d39,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4d,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f8b,
+	0x0f90, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fd8,
+	0x1000, 0x10c5,
+	0x10d0, 0x10fc,
+	0x1100, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135f, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1baa,
+	0x1bae, 0x1bb9,
+	0x1c00, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cd0, 0x1cf2,
+	0x1d00, 0x1de6,
+	0x1dfd, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x2094,
+	0x20a0, 0x20b8,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23e8,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x26cd,
+	0x26cf, 0x26e1,
+	0x26e3, 0x26e3,
+	0x26e8, 0x26ff,
+	0x2701, 0x2704,
+	0x2706, 0x2709,
+	0x270c, 0x2727,
+	0x2729, 0x274b,
+	0x274d, 0x274d,
+	0x274f, 0x2752,
+	0x2756, 0x275e,
+	0x2761, 0x2794,
+	0x2798, 0x27af,
+	0x27b1, 0x27be,
+	0x27c0, 0x27ca,
+	0x27cc, 0x27cc,
+	0x27d0, 0x2b4c,
+	0x2b50, 0x2b59,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf1,
+	0x2cf9, 0x2d25,
+	0x2d30, 0x2d65,
+	0x2d6f, 0x2d6f,
+	0x2d80, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e31,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31b7,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcb,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa65f,
+	0xa662, 0xa673,
+	0xa67c, 0xa697,
+	0xa6a0, 0xa6f7,
+	0xa700, 0xa78c,
+	0xa7fb, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9df,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa7b,
+	0xaa80, 0xaac2,
+	0xaadb, 0xaadf,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xd800, 0xfa2d,
+	0xfa30, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbb1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe26,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10190, 0x1019b,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1085f,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a7f,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b7f,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11080, 0x110c1,
+	0x12000, 0x1236e,
+	0x12400, 0x12462,
+	0x12470, 0x12473,
+	0x13000, 0x1342e,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f100, 0x1f10a,
+	0x1f110, 0x1f12e,
+	0x1f131, 0x1f131,
+	0x1f13d, 0x1f13d,
+	0x1f13f, 0x1f13f,
+	0x1f142, 0x1f142,
+	0x1f146, 0x1f146,
+	0x1f14a, 0x1f14e,
+	0x1f157, 0x1f157,
+	0x1f15f, 0x1f15f,
+	0x1f179, 0x1f179,
+	0x1f17b, 0x1f17c,
+	0x1f17f, 0x1f17f,
+	0x1f18a, 0x1f18d,
+	0x1f190, 0x1f190,
+	0x1f200, 0x1f200,
+	0x1f210, 0x1f231,
+	0x1f240, 0x1f248,
+	0x1fffe, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_5_2 */
+
+/* 'Age_6_0': Derived Age 6.0 */
+static const OnigCodePoint CR_Age_6_0[] = {
+	511,
+	0x0000, 0x0377,
+	0x037a, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x0527,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0603,
+	0x0606, 0x061b,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x0900, 0x0977,
+	0x0979, 0x097f,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0aef,
+	0x0af1, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edd,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10d0, 0x10fc,
+	0x1100, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1baa,
+	0x1bae, 0x1bb9,
+	0x1bc0, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cd0, 0x1cf2,
+	0x1d00, 0x1de6,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20b9,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23f3,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x26ff,
+	0x2701, 0x27ca,
+	0x27cc, 0x27cc,
+	0x27ce, 0x2b4c,
+	0x2b50, 0x2b59,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf1,
+	0x2cf9, 0x2d25,
+	0x2d30, 0x2d65,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e31,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcb,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa673,
+	0xa67c, 0xa697,
+	0xa6a0, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa791,
+	0xa7a0, 0xa7a9,
+	0xa7fa, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9df,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa7b,
+	0xaa80, 0xaac2,
+	0xaadb, 0xaadf,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xd800, 0xfa2d,
+	0xfa30, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe26,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10190, 0x1019b,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1085f,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a7f,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b7f,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x11080, 0x110c1,
+	0x12000, 0x1236e,
+	0x12400, 0x12462,
+	0x12470, 0x12473,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x1b000, 0x1b001,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0be,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0df,
+	0x1f100, 0x1f10a,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f169,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f320,
+	0x1f330, 0x1f335,
+	0x1f337, 0x1f37c,
+	0x1f380, 0x1f393,
+	0x1f3a0, 0x1f3c4,
+	0x1f3c6, 0x1f3ca,
+	0x1f3e0, 0x1f3f0,
+	0x1f400, 0x1f43e,
+	0x1f440, 0x1f440,
+	0x1f442, 0x1f4f7,
+	0x1f4f9, 0x1f4fc,
+	0x1f500, 0x1f53d,
+	0x1f550, 0x1f567,
+	0x1f5fb, 0x1f5ff,
+	0x1f601, 0x1f610,
+	0x1f612, 0x1f614,
+	0x1f616, 0x1f616,
+	0x1f618, 0x1f618,
+	0x1f61a, 0x1f61a,
+	0x1f61c, 0x1f61e,
+	0x1f620, 0x1f625,
+	0x1f628, 0x1f62b,
+	0x1f62d, 0x1f62d,
+	0x1f630, 0x1f633,
+	0x1f635, 0x1f640,
+	0x1f645, 0x1f64f,
+	0x1f680, 0x1f6c5,
+	0x1f700, 0x1f773,
+	0x1fffe, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_6_0 */
+
+/* 'Age_6_1': Derived Age 6.1 */
+static const OnigCodePoint CR_Age_6_1[] = {
+	549,
+	0x0000, 0x0377,
+	0x037a, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x0527,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058f, 0x058f,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0604,
+	0x0606, 0x061b,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x08a0, 0x08a0,
+	0x08a2, 0x08ac,
+	0x08e4, 0x08fe,
+	0x0900, 0x0977,
+	0x0979, 0x097f,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd0, 0x1cf6,
+	0x1d00, 0x1de6,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20b9,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23f3,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x26ff,
+	0x2701, 0x2b4c,
+	0x2b50, 0x2b59,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e3b,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa697,
+	0xa69f, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa793,
+	0xa7a0, 0xa7aa,
+	0xa7f8, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9df,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa7b,
+	0xaa80, 0xaac2,
+	0xaadb, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xd800, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe26,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10190, 0x1019b,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1085f,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a7f,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b7f,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x11080, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+	0x11180, 0x111c8,
+	0x111d0, 0x111d9,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x12000, 0x1236e,
+	0x12400, 0x12462,
+	0x12470, 0x12473,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0be,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0df,
+	0x1f100, 0x1f10a,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f320,
+	0x1f330, 0x1f335,
+	0x1f337, 0x1f37c,
+	0x1f380, 0x1f393,
+	0x1f3a0, 0x1f3c4,
+	0x1f3c6, 0x1f3ca,
+	0x1f3e0, 0x1f3f0,
+	0x1f400, 0x1f43e,
+	0x1f440, 0x1f440,
+	0x1f442, 0x1f4f7,
+	0x1f4f9, 0x1f4fc,
+	0x1f500, 0x1f53d,
+	0x1f540, 0x1f543,
+	0x1f550, 0x1f567,
+	0x1f5fb, 0x1f640,
+	0x1f645, 0x1f64f,
+	0x1f680, 0x1f6c5,
+	0x1f700, 0x1f773,
+	0x1fffe, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_6_1 */
+
+/* 'Age_6_2': Derived Age 6.2 */
+static const OnigCodePoint CR_Age_6_2[] = {
+	549,
+	0x0000, 0x0377,
+	0x037a, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x0527,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058f, 0x058f,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0604,
+	0x0606, 0x061b,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x08a0, 0x08a0,
+	0x08a2, 0x08ac,
+	0x08e4, 0x08fe,
+	0x0900, 0x0977,
+	0x0979, 0x097f,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd0, 0x1cf6,
+	0x1d00, 0x1de6,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x206a, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20ba,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23f3,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x26ff,
+	0x2701, 0x2b4c,
+	0x2b50, 0x2b59,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e3b,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa697,
+	0xa69f, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa793,
+	0xa7a0, 0xa7aa,
+	0xa7f8, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9df,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa7b,
+	0xaa80, 0xaac2,
+	0xaadb, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xd800, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe26,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10190, 0x1019b,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1085f,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a7f,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b7f,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x11080, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+	0x11180, 0x111c8,
+	0x111d0, 0x111d9,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x12000, 0x1236e,
+	0x12400, 0x12462,
+	0x12470, 0x12473,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0be,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0df,
+	0x1f100, 0x1f10a,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f320,
+	0x1f330, 0x1f335,
+	0x1f337, 0x1f37c,
+	0x1f380, 0x1f393,
+	0x1f3a0, 0x1f3c4,
+	0x1f3c6, 0x1f3ca,
+	0x1f3e0, 0x1f3f0,
+	0x1f400, 0x1f43e,
+	0x1f440, 0x1f440,
+	0x1f442, 0x1f4f7,
+	0x1f4f9, 0x1f4fc,
+	0x1f500, 0x1f53d,
+	0x1f540, 0x1f543,
+	0x1f550, 0x1f567,
+	0x1f5fb, 0x1f640,
+	0x1f645, 0x1f64f,
+	0x1f680, 0x1f6c5,
+	0x1f700, 0x1f773,
+	0x1fffe, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_6_2 */
+
+/* 'Age_6_3': Derived Age 6.3 */
+static const OnigCodePoint CR_Age_6_3[] = {
+	549,
+	0x0000, 0x0377,
+	0x037a, 0x037e,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x0527,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058f, 0x058f,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x0604,
+	0x0606, 0x061c,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x08a0, 0x08a0,
+	0x08a2, 0x08ac,
+	0x08e4, 0x08fe,
+	0x0900, 0x0977,
+	0x0979, 0x097f,
+	0x0981, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c01, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c33,
+	0x0c35, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c82, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d02, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f0,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191c,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd0, 0x1cf6,
+	0x1d00, 0x1de6,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x2066, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20ba,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23f3,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x26ff,
+	0x2701, 0x2b4c,
+	0x2b50, 0x2b59,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e3b,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa697,
+	0xa69f, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa793,
+	0xa7a0, 0xa7aa,
+	0xa7f8, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9df,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaa7b,
+	0xaa80, 0xaac2,
+	0xaadb, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xd800, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe26,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018a,
+	0x10190, 0x1019b,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x10300, 0x1031e,
+	0x10320, 0x10323,
+	0x10330, 0x1034a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1085f,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a7f,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b7f,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x11080, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+	0x11180, 0x111c8,
+	0x111d0, 0x111d9,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x12000, 0x1236e,
+	0x12400, 0x12462,
+	0x12470, 0x12473,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0be,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0df,
+	0x1f100, 0x1f10a,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f320,
+	0x1f330, 0x1f335,
+	0x1f337, 0x1f37c,
+	0x1f380, 0x1f393,
+	0x1f3a0, 0x1f3c4,
+	0x1f3c6, 0x1f3ca,
+	0x1f3e0, 0x1f3f0,
+	0x1f400, 0x1f43e,
+	0x1f440, 0x1f440,
+	0x1f442, 0x1f4f7,
+	0x1f4f9, 0x1f4fc,
+	0x1f500, 0x1f53d,
+	0x1f540, 0x1f543,
+	0x1f550, 0x1f567,
+	0x1f5fb, 0x1f640,
+	0x1f645, 0x1f64f,
+	0x1f680, 0x1f6c5,
+	0x1f700, 0x1f773,
+	0x1fffe, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_6_3 */
+
+/* 'Age_7_0': Derived Age 7.0 */
+static const OnigCodePoint CR_Age_7_0[] = {
+	610,
+	0x0000, 0x0377,
+	0x037a, 0x037f,
+	0x0384, 0x038a,
+	0x038c, 0x038c,
+	0x038e, 0x03a1,
+	0x03a3, 0x052f,
+	0x0531, 0x0556,
+	0x0559, 0x055f,
+	0x0561, 0x0587,
+	0x0589, 0x058a,
+	0x058d, 0x058f,
+	0x0591, 0x05c7,
+	0x05d0, 0x05ea,
+	0x05f0, 0x05f4,
+	0x0600, 0x061c,
+	0x061e, 0x070d,
+	0x070f, 0x074a,
+	0x074d, 0x07b1,
+	0x07c0, 0x07fa,
+	0x0800, 0x082d,
+	0x0830, 0x083e,
+	0x0840, 0x085b,
+	0x085e, 0x085e,
+	0x08a0, 0x08b2,
+	0x08e4, 0x0983,
+	0x0985, 0x098c,
+	0x098f, 0x0990,
+	0x0993, 0x09a8,
+	0x09aa, 0x09b0,
+	0x09b2, 0x09b2,
+	0x09b6, 0x09b9,
+	0x09bc, 0x09c4,
+	0x09c7, 0x09c8,
+	0x09cb, 0x09ce,
+	0x09d7, 0x09d7,
+	0x09dc, 0x09dd,
+	0x09df, 0x09e3,
+	0x09e6, 0x09fb,
+	0x0a01, 0x0a03,
+	0x0a05, 0x0a0a,
+	0x0a0f, 0x0a10,
+	0x0a13, 0x0a28,
+	0x0a2a, 0x0a30,
+	0x0a32, 0x0a33,
+	0x0a35, 0x0a36,
+	0x0a38, 0x0a39,
+	0x0a3c, 0x0a3c,
+	0x0a3e, 0x0a42,
+	0x0a47, 0x0a48,
+	0x0a4b, 0x0a4d,
+	0x0a51, 0x0a51,
+	0x0a59, 0x0a5c,
+	0x0a5e, 0x0a5e,
+	0x0a66, 0x0a75,
+	0x0a81, 0x0a83,
+	0x0a85, 0x0a8d,
+	0x0a8f, 0x0a91,
+	0x0a93, 0x0aa8,
+	0x0aaa, 0x0ab0,
+	0x0ab2, 0x0ab3,
+	0x0ab5, 0x0ab9,
+	0x0abc, 0x0ac5,
+	0x0ac7, 0x0ac9,
+	0x0acb, 0x0acd,
+	0x0ad0, 0x0ad0,
+	0x0ae0, 0x0ae3,
+	0x0ae6, 0x0af1,
+	0x0b01, 0x0b03,
+	0x0b05, 0x0b0c,
+	0x0b0f, 0x0b10,
+	0x0b13, 0x0b28,
+	0x0b2a, 0x0b30,
+	0x0b32, 0x0b33,
+	0x0b35, 0x0b39,
+	0x0b3c, 0x0b44,
+	0x0b47, 0x0b48,
+	0x0b4b, 0x0b4d,
+	0x0b56, 0x0b57,
+	0x0b5c, 0x0b5d,
+	0x0b5f, 0x0b63,
+	0x0b66, 0x0b77,
+	0x0b82, 0x0b83,
+	0x0b85, 0x0b8a,
+	0x0b8e, 0x0b90,
+	0x0b92, 0x0b95,
+	0x0b99, 0x0b9a,
+	0x0b9c, 0x0b9c,
+	0x0b9e, 0x0b9f,
+	0x0ba3, 0x0ba4,
+	0x0ba8, 0x0baa,
+	0x0bae, 0x0bb9,
+	0x0bbe, 0x0bc2,
+	0x0bc6, 0x0bc8,
+	0x0bca, 0x0bcd,
+	0x0bd0, 0x0bd0,
+	0x0bd7, 0x0bd7,
+	0x0be6, 0x0bfa,
+	0x0c00, 0x0c03,
+	0x0c05, 0x0c0c,
+	0x0c0e, 0x0c10,
+	0x0c12, 0x0c28,
+	0x0c2a, 0x0c39,
+	0x0c3d, 0x0c44,
+	0x0c46, 0x0c48,
+	0x0c4a, 0x0c4d,
+	0x0c55, 0x0c56,
+	0x0c58, 0x0c59,
+	0x0c60, 0x0c63,
+	0x0c66, 0x0c6f,
+	0x0c78, 0x0c7f,
+	0x0c81, 0x0c83,
+	0x0c85, 0x0c8c,
+	0x0c8e, 0x0c90,
+	0x0c92, 0x0ca8,
+	0x0caa, 0x0cb3,
+	0x0cb5, 0x0cb9,
+	0x0cbc, 0x0cc4,
+	0x0cc6, 0x0cc8,
+	0x0cca, 0x0ccd,
+	0x0cd5, 0x0cd6,
+	0x0cde, 0x0cde,
+	0x0ce0, 0x0ce3,
+	0x0ce6, 0x0cef,
+	0x0cf1, 0x0cf2,
+	0x0d01, 0x0d03,
+	0x0d05, 0x0d0c,
+	0x0d0e, 0x0d10,
+	0x0d12, 0x0d3a,
+	0x0d3d, 0x0d44,
+	0x0d46, 0x0d48,
+	0x0d4a, 0x0d4e,
+	0x0d57, 0x0d57,
+	0x0d60, 0x0d63,
+	0x0d66, 0x0d75,
+	0x0d79, 0x0d7f,
+	0x0d82, 0x0d83,
+	0x0d85, 0x0d96,
+	0x0d9a, 0x0db1,
+	0x0db3, 0x0dbb,
+	0x0dbd, 0x0dbd,
+	0x0dc0, 0x0dc6,
+	0x0dca, 0x0dca,
+	0x0dcf, 0x0dd4,
+	0x0dd6, 0x0dd6,
+	0x0dd8, 0x0ddf,
+	0x0de6, 0x0def,
+	0x0df2, 0x0df4,
+	0x0e01, 0x0e3a,
+	0x0e3f, 0x0e5b,
+	0x0e81, 0x0e82,
+	0x0e84, 0x0e84,
+	0x0e87, 0x0e88,
+	0x0e8a, 0x0e8a,
+	0x0e8d, 0x0e8d,
+	0x0e94, 0x0e97,
+	0x0e99, 0x0e9f,
+	0x0ea1, 0x0ea3,
+	0x0ea5, 0x0ea5,
+	0x0ea7, 0x0ea7,
+	0x0eaa, 0x0eab,
+	0x0ead, 0x0eb9,
+	0x0ebb, 0x0ebd,
+	0x0ec0, 0x0ec4,
+	0x0ec6, 0x0ec6,
+	0x0ec8, 0x0ecd,
+	0x0ed0, 0x0ed9,
+	0x0edc, 0x0edf,
+	0x0f00, 0x0f47,
+	0x0f49, 0x0f6c,
+	0x0f71, 0x0f97,
+	0x0f99, 0x0fbc,
+	0x0fbe, 0x0fcc,
+	0x0fce, 0x0fda,
+	0x1000, 0x10c5,
+	0x10c7, 0x10c7,
+	0x10cd, 0x10cd,
+	0x10d0, 0x1248,
+	0x124a, 0x124d,
+	0x1250, 0x1256,
+	0x1258, 0x1258,
+	0x125a, 0x125d,
+	0x1260, 0x1288,
+	0x128a, 0x128d,
+	0x1290, 0x12b0,
+	0x12b2, 0x12b5,
+	0x12b8, 0x12be,
+	0x12c0, 0x12c0,
+	0x12c2, 0x12c5,
+	0x12c8, 0x12d6,
+	0x12d8, 0x1310,
+	0x1312, 0x1315,
+	0x1318, 0x135a,
+	0x135d, 0x137c,
+	0x1380, 0x1399,
+	0x13a0, 0x13f4,
+	0x1400, 0x169c,
+	0x16a0, 0x16f8,
+	0x1700, 0x170c,
+	0x170e, 0x1714,
+	0x1720, 0x1736,
+	0x1740, 0x1753,
+	0x1760, 0x176c,
+	0x176e, 0x1770,
+	0x1772, 0x1773,
+	0x1780, 0x17dd,
+	0x17e0, 0x17e9,
+	0x17f0, 0x17f9,
+	0x1800, 0x180e,
+	0x1810, 0x1819,
+	0x1820, 0x1877,
+	0x1880, 0x18aa,
+	0x18b0, 0x18f5,
+	0x1900, 0x191e,
+	0x1920, 0x192b,
+	0x1930, 0x193b,
+	0x1940, 0x1940,
+	0x1944, 0x196d,
+	0x1970, 0x1974,
+	0x1980, 0x19ab,
+	0x19b0, 0x19c9,
+	0x19d0, 0x19da,
+	0x19de, 0x1a1b,
+	0x1a1e, 0x1a5e,
+	0x1a60, 0x1a7c,
+	0x1a7f, 0x1a89,
+	0x1a90, 0x1a99,
+	0x1aa0, 0x1aad,
+	0x1ab0, 0x1abe,
+	0x1b00, 0x1b4b,
+	0x1b50, 0x1b7c,
+	0x1b80, 0x1bf3,
+	0x1bfc, 0x1c37,
+	0x1c3b, 0x1c49,
+	0x1c4d, 0x1c7f,
+	0x1cc0, 0x1cc7,
+	0x1cd0, 0x1cf6,
+	0x1cf8, 0x1cf9,
+	0x1d00, 0x1df5,
+	0x1dfc, 0x1f15,
+	0x1f18, 0x1f1d,
+	0x1f20, 0x1f45,
+	0x1f48, 0x1f4d,
+	0x1f50, 0x1f57,
+	0x1f59, 0x1f59,
+	0x1f5b, 0x1f5b,
+	0x1f5d, 0x1f5d,
+	0x1f5f, 0x1f7d,
+	0x1f80, 0x1fb4,
+	0x1fb6, 0x1fc4,
+	0x1fc6, 0x1fd3,
+	0x1fd6, 0x1fdb,
+	0x1fdd, 0x1fef,
+	0x1ff2, 0x1ff4,
+	0x1ff6, 0x1ffe,
+	0x2000, 0x2064,
+	0x2066, 0x2071,
+	0x2074, 0x208e,
+	0x2090, 0x209c,
+	0x20a0, 0x20bd,
+	0x20d0, 0x20f0,
+	0x2100, 0x2189,
+	0x2190, 0x23fa,
+	0x2400, 0x2426,
+	0x2440, 0x244a,
+	0x2460, 0x2b73,
+	0x2b76, 0x2b95,
+	0x2b98, 0x2bb9,
+	0x2bbd, 0x2bc8,
+	0x2bca, 0x2bd1,
+	0x2c00, 0x2c2e,
+	0x2c30, 0x2c5e,
+	0x2c60, 0x2cf3,
+	0x2cf9, 0x2d25,
+	0x2d27, 0x2d27,
+	0x2d2d, 0x2d2d,
+	0x2d30, 0x2d67,
+	0x2d6f, 0x2d70,
+	0x2d7f, 0x2d96,
+	0x2da0, 0x2da6,
+	0x2da8, 0x2dae,
+	0x2db0, 0x2db6,
+	0x2db8, 0x2dbe,
+	0x2dc0, 0x2dc6,
+	0x2dc8, 0x2dce,
+	0x2dd0, 0x2dd6,
+	0x2dd8, 0x2dde,
+	0x2de0, 0x2e42,
+	0x2e80, 0x2e99,
+	0x2e9b, 0x2ef3,
+	0x2f00, 0x2fd5,
+	0x2ff0, 0x2ffb,
+	0x3000, 0x303f,
+	0x3041, 0x3096,
+	0x3099, 0x30ff,
+	0x3105, 0x312d,
+	0x3131, 0x318e,
+	0x3190, 0x31ba,
+	0x31c0, 0x31e3,
+	0x31f0, 0x321e,
+	0x3220, 0x32fe,
+	0x3300, 0x4db5,
+	0x4dc0, 0x9fcc,
+	0xa000, 0xa48c,
+	0xa490, 0xa4c6,
+	0xa4d0, 0xa62b,
+	0xa640, 0xa69d,
+	0xa69f, 0xa6f7,
+	0xa700, 0xa78e,
+	0xa790, 0xa7ad,
+	0xa7b0, 0xa7b1,
+	0xa7f7, 0xa82b,
+	0xa830, 0xa839,
+	0xa840, 0xa877,
+	0xa880, 0xa8c4,
+	0xa8ce, 0xa8d9,
+	0xa8e0, 0xa8fb,
+	0xa900, 0xa953,
+	0xa95f, 0xa97c,
+	0xa980, 0xa9cd,
+	0xa9cf, 0xa9d9,
+	0xa9de, 0xa9fe,
+	0xaa00, 0xaa36,
+	0xaa40, 0xaa4d,
+	0xaa50, 0xaa59,
+	0xaa5c, 0xaac2,
+	0xaadb, 0xaaf6,
+	0xab01, 0xab06,
+	0xab09, 0xab0e,
+	0xab11, 0xab16,
+	0xab20, 0xab26,
+	0xab28, 0xab2e,
+	0xab30, 0xab5f,
+	0xab64, 0xab65,
+	0xabc0, 0xabed,
+	0xabf0, 0xabf9,
+	0xac00, 0xd7a3,
+	0xd7b0, 0xd7c6,
+	0xd7cb, 0xd7fb,
+	0xd800, 0xfa6d,
+	0xfa70, 0xfad9,
+	0xfb00, 0xfb06,
+	0xfb13, 0xfb17,
+	0xfb1d, 0xfb36,
+	0xfb38, 0xfb3c,
+	0xfb3e, 0xfb3e,
+	0xfb40, 0xfb41,
+	0xfb43, 0xfb44,
+	0xfb46, 0xfbc1,
+	0xfbd3, 0xfd3f,
+	0xfd50, 0xfd8f,
+	0xfd92, 0xfdc7,
+	0xfdd0, 0xfdfd,
+	0xfe00, 0xfe19,
+	0xfe20, 0xfe2d,
+	0xfe30, 0xfe52,
+	0xfe54, 0xfe66,
+	0xfe68, 0xfe6b,
+	0xfe70, 0xfe74,
+	0xfe76, 0xfefc,
+	0xfeff, 0xfeff,
+	0xff01, 0xffbe,
+	0xffc2, 0xffc7,
+	0xffca, 0xffcf,
+	0xffd2, 0xffd7,
+	0xffda, 0xffdc,
+	0xffe0, 0xffe6,
+	0xffe8, 0xffee,
+	0xfff9, 0x1000b,
+	0x1000d, 0x10026,
+	0x10028, 0x1003a,
+	0x1003c, 0x1003d,
+	0x1003f, 0x1004d,
+	0x10050, 0x1005d,
+	0x10080, 0x100fa,
+	0x10100, 0x10102,
+	0x10107, 0x10133,
+	0x10137, 0x1018c,
+	0x10190, 0x1019b,
+	0x101a0, 0x101a0,
+	0x101d0, 0x101fd,
+	0x10280, 0x1029c,
+	0x102a0, 0x102d0,
+	0x102e0, 0x102fb,
+	0x10300, 0x10323,
+	0x10330, 0x1034a,
+	0x10350, 0x1037a,
+	0x10380, 0x1039d,
+	0x1039f, 0x103c3,
+	0x103c8, 0x103d5,
+	0x10400, 0x1049d,
+	0x104a0, 0x104a9,
+	0x10500, 0x10527,
+	0x10530, 0x10563,
+	0x1056f, 0x1056f,
+	0x10600, 0x10736,
+	0x10740, 0x10755,
+	0x10760, 0x10767,
+	0x10800, 0x10805,
+	0x10808, 0x10808,
+	0x1080a, 0x10835,
+	0x10837, 0x10838,
+	0x1083c, 0x1083c,
+	0x1083f, 0x10855,
+	0x10857, 0x1089e,
+	0x108a7, 0x108af,
+	0x10900, 0x1091b,
+	0x1091f, 0x10939,
+	0x1093f, 0x1093f,
+	0x10980, 0x109b7,
+	0x109be, 0x109bf,
+	0x10a00, 0x10a03,
+	0x10a05, 0x10a06,
+	0x10a0c, 0x10a13,
+	0x10a15, 0x10a17,
+	0x10a19, 0x10a33,
+	0x10a38, 0x10a3a,
+	0x10a3f, 0x10a47,
+	0x10a50, 0x10a58,
+	0x10a60, 0x10a9f,
+	0x10ac0, 0x10ae6,
+	0x10aeb, 0x10af6,
+	0x10b00, 0x10b35,
+	0x10b39, 0x10b55,
+	0x10b58, 0x10b72,
+	0x10b78, 0x10b91,
+	0x10b99, 0x10b9c,
+	0x10ba9, 0x10baf,
+	0x10c00, 0x10c48,
+	0x10e60, 0x10e7e,
+	0x11000, 0x1104d,
+	0x11052, 0x1106f,
+	0x1107f, 0x110c1,
+	0x110d0, 0x110e8,
+	0x110f0, 0x110f9,
+	0x11100, 0x11134,
+	0x11136, 0x11143,
+	0x11150, 0x11176,
+	0x11180, 0x111c8,
+	0x111cd, 0x111cd,
+	0x111d0, 0x111da,
+	0x111e1, 0x111f4,
+	0x11200, 0x11211,
+	0x11213, 0x1123d,
+	0x112b0, 0x112ea,
+	0x112f0, 0x112f9,
+	0x11301, 0x11303,
+	0x11305, 0x1130c,
+	0x1130f, 0x11310,
+	0x11313, 0x11328,
+	0x1132a, 0x11330,
+	0x11332, 0x11333,
+	0x11335, 0x11339,
+	0x1133c, 0x11344,
+	0x11347, 0x11348,
+	0x1134b, 0x1134d,
+	0x11357, 0x11357,
+	0x1135d, 0x11363,
+	0x11366, 0x1136c,
+	0x11370, 0x11374,
+	0x11480, 0x114c7,
+	0x114d0, 0x114d9,
+	0x11580, 0x115b5,
+	0x115b8, 0x115c9,
+	0x11600, 0x11644,
+	0x11650, 0x11659,
+	0x11680, 0x116b7,
+	0x116c0, 0x116c9,
+	0x118a0, 0x118f2,
+	0x118ff, 0x118ff,
+	0x11ac0, 0x11af8,
+	0x12000, 0x12398,
+	0x12400, 0x1246e,
+	0x12470, 0x12474,
+	0x13000, 0x1342e,
+	0x16800, 0x16a38,
+	0x16a40, 0x16a5e,
+	0x16a60, 0x16a69,
+	0x16a6e, 0x16a6f,
+	0x16ad0, 0x16aed,
+	0x16af0, 0x16af5,
+	0x16b00, 0x16b45,
+	0x16b50, 0x16b59,
+	0x16b5b, 0x16b61,
+	0x16b63, 0x16b77,
+	0x16b7d, 0x16b8f,
+	0x16f00, 0x16f44,
+	0x16f50, 0x16f7e,
+	0x16f8f, 0x16f9f,
+	0x1b000, 0x1b001,
+	0x1bc00, 0x1bc6a,
+	0x1bc70, 0x1bc7c,
+	0x1bc80, 0x1bc88,
+	0x1bc90, 0x1bc99,
+	0x1bc9c, 0x1bca3,
+	0x1d000, 0x1d0f5,
+	0x1d100, 0x1d126,
+	0x1d129, 0x1d1dd,
+	0x1d200, 0x1d245,
+	0x1d300, 0x1d356,
+	0x1d360, 0x1d371,
+	0x1d400, 0x1d454,
+	0x1d456, 0x1d49c,
+	0x1d49e, 0x1d49f,
+	0x1d4a2, 0x1d4a2,
+	0x1d4a5, 0x1d4a6,
+	0x1d4a9, 0x1d4ac,
+	0x1d4ae, 0x1d4b9,
+	0x1d4bb, 0x1d4bb,
+	0x1d4bd, 0x1d4c3,
+	0x1d4c5, 0x1d505,
+	0x1d507, 0x1d50a,
+	0x1d50d, 0x1d514,
+	0x1d516, 0x1d51c,
+	0x1d51e, 0x1d539,
+	0x1d53b, 0x1d53e,
+	0x1d540, 0x1d544,
+	0x1d546, 0x1d546,
+	0x1d54a, 0x1d550,
+	0x1d552, 0x1d6a5,
+	0x1d6a8, 0x1d7cb,
+	0x1d7ce, 0x1d7ff,
+	0x1e800, 0x1e8c4,
+	0x1e8c7, 0x1e8d6,
+	0x1ee00, 0x1ee03,
+	0x1ee05, 0x1ee1f,
+	0x1ee21, 0x1ee22,
+	0x1ee24, 0x1ee24,
+	0x1ee27, 0x1ee27,
+	0x1ee29, 0x1ee32,
+	0x1ee34, 0x1ee37,
+	0x1ee39, 0x1ee39,
+	0x1ee3b, 0x1ee3b,
+	0x1ee42, 0x1ee42,
+	0x1ee47, 0x1ee47,
+	0x1ee49, 0x1ee49,
+	0x1ee4b, 0x1ee4b,
+	0x1ee4d, 0x1ee4f,
+	0x1ee51, 0x1ee52,
+	0x1ee54, 0x1ee54,
+	0x1ee57, 0x1ee57,
+	0x1ee59, 0x1ee59,
+	0x1ee5b, 0x1ee5b,
+	0x1ee5d, 0x1ee5d,
+	0x1ee5f, 0x1ee5f,
+	0x1ee61, 0x1ee62,
+	0x1ee64, 0x1ee64,
+	0x1ee67, 0x1ee6a,
+	0x1ee6c, 0x1ee72,
+	0x1ee74, 0x1ee77,
+	0x1ee79, 0x1ee7c,
+	0x1ee7e, 0x1ee7e,
+	0x1ee80, 0x1ee89,
+	0x1ee8b, 0x1ee9b,
+	0x1eea1, 0x1eea3,
+	0x1eea5, 0x1eea9,
+	0x1eeab, 0x1eebb,
+	0x1eef0, 0x1eef1,
+	0x1f000, 0x1f02b,
+	0x1f030, 0x1f093,
+	0x1f0a0, 0x1f0ae,
+	0x1f0b1, 0x1f0bf,
+	0x1f0c1, 0x1f0cf,
+	0x1f0d1, 0x1f0f5,
+	0x1f100, 0x1f10c,
+	0x1f110, 0x1f12e,
+	0x1f130, 0x1f16b,
+	0x1f170, 0x1f19a,
+	0x1f1e6, 0x1f202,
+	0x1f210, 0x1f23a,
+	0x1f240, 0x1f248,
+	0x1f250, 0x1f251,
+	0x1f300, 0x1f32c,
+	0x1f330, 0x1f37d,
+	0x1f380, 0x1f3ce,
+	0x1f3d4, 0x1f3f7,
+	0x1f400, 0x1f4fe,
+	0x1f500, 0x1f54a,
+	0x1f550, 0x1f579,
+	0x1f57b, 0x1f5a3,
+	0x1f5a5, 0x1f642,
+	0x1f645, 0x1f6cf,
+	0x1f6e0, 0x1f6ec,
+	0x1f6f0, 0x1f6f3,
+	0x1f700, 0x1f773,
+	0x1f780, 0x1f7d4,
+	0x1f800, 0x1f80b,
+	0x1f810, 0x1f847,
+	0x1f850, 0x1f859,
+	0x1f860, 0x1f887,
+	0x1f890, 0x1f8ad,
+	0x1fffe, 0x2a6d6,
+	0x2a700, 0x2b734,
+	0x2b740, 0x2b81d,
+	0x2f800, 0x2fa1d,
+	0x2fffe, 0x2ffff,
+	0x3fffe, 0x3ffff,
+	0x4fffe, 0x4ffff,
+	0x5fffe, 0x5ffff,
+	0x6fffe, 0x6ffff,
+	0x7fffe, 0x7ffff,
+	0x8fffe, 0x8ffff,
+	0x9fffe, 0x9ffff,
+	0xafffe, 0xaffff,
+	0xbfffe, 0xbffff,
+	0xcfffe, 0xcffff,
+	0xdfffe, 0xdffff,
+	0xe0001, 0xe0001,
+	0xe0020, 0xe007f,
+	0xe0100, 0xe01ef,
+	0xefffe, 0x10ffff,
+}; /* CR_Age_7_0 */
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+
+/* 'In_Basic_Latin': Block */
+#define CR_In_Basic_Latin CR_ASCII
+
+/* 'In_Latin_1_Supplement': Block */
+static const OnigCodePoint CR_In_Latin_1_Supplement[] = {
+	1,
+	0x0080, 0x00ff,
+}; /* CR_In_Latin_1_Supplement */
+
+/* 'In_Latin_Extended_A': Block */
+static const OnigCodePoint CR_In_Latin_Extended_A[] = {
+	1,
+	0x0100, 0x017f,
+}; /* CR_In_Latin_Extended_A */
+
+/* 'In_Latin_Extended_B': Block */
+static const OnigCodePoint CR_In_Latin_Extended_B[] = {
+	1,
+	0x0180, 0x024f,
+}; /* CR_In_Latin_Extended_B */
+
+/* 'In_IPA_Extensions': Block */
+static const OnigCodePoint CR_In_IPA_Extensions[] = {
+	1,
+	0x0250, 0x02af,
+}; /* CR_In_IPA_Extensions */
+
+/* 'In_Spacing_Modifier_Letters': Block */
+static const OnigCodePoint CR_In_Spacing_Modifier_Letters[] = {
+	1,
+	0x02b0, 0x02ff,
+}; /* CR_In_Spacing_Modifier_Letters */
+
+/* 'In_Combining_Diacritical_Marks': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks[] = {
+	1,
+	0x0300, 0x036f,
+}; /* CR_In_Combining_Diacritical_Marks */
+
+/* 'In_Greek_and_Coptic': Block */
+static const OnigCodePoint CR_In_Greek_and_Coptic[] = {
+	1,
+	0x0370, 0x03ff,
+}; /* CR_In_Greek_and_Coptic */
+
+/* 'In_Cyrillic': Block */
+static const OnigCodePoint CR_In_Cyrillic[] = {
+	1,
+	0x0400, 0x04ff,
+}; /* CR_In_Cyrillic */
+
+/* 'In_Cyrillic_Supplement': Block */
+static const OnigCodePoint CR_In_Cyrillic_Supplement[] = {
+	1,
+	0x0500, 0x052f,
+}; /* CR_In_Cyrillic_Supplement */
+
+/* 'In_Armenian': Block */
+static const OnigCodePoint CR_In_Armenian[] = {
+	1,
+	0x0530, 0x058f,
+}; /* CR_In_Armenian */
+
+/* 'In_Hebrew': Block */
+static const OnigCodePoint CR_In_Hebrew[] = {
+	1,
+	0x0590, 0x05ff,
+}; /* CR_In_Hebrew */
+
+/* 'In_Arabic': Block */
+static const OnigCodePoint CR_In_Arabic[] = {
+	1,
+	0x0600, 0x06ff,
+}; /* CR_In_Arabic */
+
+/* 'In_Syriac': Block */
+static const OnigCodePoint CR_In_Syriac[] = {
+	1,
+	0x0700, 0x074f,
+}; /* CR_In_Syriac */
+
+/* 'In_Arabic_Supplement': Block */
+static const OnigCodePoint CR_In_Arabic_Supplement[] = {
+	1,
+	0x0750, 0x077f,
+}; /* CR_In_Arabic_Supplement */
+
+/* 'In_Thaana': Block */
+static const OnigCodePoint CR_In_Thaana[] = {
+	1,
+	0x0780, 0x07bf,
+}; /* CR_In_Thaana */
+
+/* 'In_NKo': Block */
+static const OnigCodePoint CR_In_NKo[] = {
+	1,
+	0x07c0, 0x07ff,
+}; /* CR_In_NKo */
+
+/* 'In_Samaritan': Block */
+static const OnigCodePoint CR_In_Samaritan[] = {
+	1,
+	0x0800, 0x083f,
+}; /* CR_In_Samaritan */
+
+/* 'In_Mandaic': Block */
+static const OnigCodePoint CR_In_Mandaic[] = {
+	1,
+	0x0840, 0x085f,
+}; /* CR_In_Mandaic */
+
+/* 'In_Arabic_Extended_A': Block */
+static const OnigCodePoint CR_In_Arabic_Extended_A[] = {
+	1,
+	0x08a0, 0x08ff,
+}; /* CR_In_Arabic_Extended_A */
+
+/* 'In_Devanagari': Block */
+static const OnigCodePoint CR_In_Devanagari[] = {
+	1,
+	0x0900, 0x097f,
+}; /* CR_In_Devanagari */
+
+/* 'In_Bengali': Block */
+static const OnigCodePoint CR_In_Bengali[] = {
+	1,
+	0x0980, 0x09ff,
+}; /* CR_In_Bengali */
+
+/* 'In_Gurmukhi': Block */
+static const OnigCodePoint CR_In_Gurmukhi[] = {
+	1,
+	0x0a00, 0x0a7f,
+}; /* CR_In_Gurmukhi */
+
+/* 'In_Gujarati': Block */
+static const OnigCodePoint CR_In_Gujarati[] = {
+	1,
+	0x0a80, 0x0aff,
+}; /* CR_In_Gujarati */
+
+/* 'In_Oriya': Block */
+static const OnigCodePoint CR_In_Oriya[] = {
+	1,
+	0x0b00, 0x0b7f,
+}; /* CR_In_Oriya */
+
+/* 'In_Tamil': Block */
+static const OnigCodePoint CR_In_Tamil[] = {
+	1,
+	0x0b80, 0x0bff,
+}; /* CR_In_Tamil */
+
+/* 'In_Telugu': Block */
+static const OnigCodePoint CR_In_Telugu[] = {
+	1,
+	0x0c00, 0x0c7f,
+}; /* CR_In_Telugu */
+
+/* 'In_Kannada': Block */
+static const OnigCodePoint CR_In_Kannada[] = {
+	1,
+	0x0c80, 0x0cff,
+}; /* CR_In_Kannada */
+
+/* 'In_Malayalam': Block */
+static const OnigCodePoint CR_In_Malayalam[] = {
+	1,
+	0x0d00, 0x0d7f,
+}; /* CR_In_Malayalam */
+
+/* 'In_Sinhala': Block */
+static const OnigCodePoint CR_In_Sinhala[] = {
+	1,
+	0x0d80, 0x0dff,
+}; /* CR_In_Sinhala */
+
+/* 'In_Thai': Block */
+static const OnigCodePoint CR_In_Thai[] = {
+	1,
+	0x0e00, 0x0e7f,
+}; /* CR_In_Thai */
+
+/* 'In_Lao': Block */
+static const OnigCodePoint CR_In_Lao[] = {
+	1,
+	0x0e80, 0x0eff,
+}; /* CR_In_Lao */
+
+/* 'In_Tibetan': Block */
+static const OnigCodePoint CR_In_Tibetan[] = {
+	1,
+	0x0f00, 0x0fff,
+}; /* CR_In_Tibetan */
+
+/* 'In_Myanmar': Block */
+static const OnigCodePoint CR_In_Myanmar[] = {
+	1,
+	0x1000, 0x109f,
+}; /* CR_In_Myanmar */
+
+/* 'In_Georgian': Block */
+static const OnigCodePoint CR_In_Georgian[] = {
+	1,
+	0x10a0, 0x10ff,
+}; /* CR_In_Georgian */
+
+/* 'In_Hangul_Jamo': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo[] = {
+	1,
+	0x1100, 0x11ff,
+}; /* CR_In_Hangul_Jamo */
+
+/* 'In_Ethiopic': Block */
+static const OnigCodePoint CR_In_Ethiopic[] = {
+	1,
+	0x1200, 0x137f,
+}; /* CR_In_Ethiopic */
+
+/* 'In_Ethiopic_Supplement': Block */
+static const OnigCodePoint CR_In_Ethiopic_Supplement[] = {
+	1,
+	0x1380, 0x139f,
+}; /* CR_In_Ethiopic_Supplement */
+
+/* 'In_Cherokee': Block */
+static const OnigCodePoint CR_In_Cherokee[] = {
+	1,
+	0x13a0, 0x13ff,
+}; /* CR_In_Cherokee */
+
+/* 'In_Unified_Canadian_Aboriginal_Syllabics': Block */
+static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics[] = {
+	1,
+	0x1400, 0x167f,
+}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics */
+
+/* 'In_Ogham': Block */
+static const OnigCodePoint CR_In_Ogham[] = {
+	1,
+	0x1680, 0x169f,
+}; /* CR_In_Ogham */
+
+/* 'In_Runic': Block */
+static const OnigCodePoint CR_In_Runic[] = {
+	1,
+	0x16a0, 0x16ff,
+}; /* CR_In_Runic */
+
+/* 'In_Tagalog': Block */
+static const OnigCodePoint CR_In_Tagalog[] = {
+	1,
+	0x1700, 0x171f,
+}; /* CR_In_Tagalog */
+
+/* 'In_Hanunoo': Block */
+static const OnigCodePoint CR_In_Hanunoo[] = {
+	1,
+	0x1720, 0x173f,
+}; /* CR_In_Hanunoo */
+
+/* 'In_Buhid': Block */
+static const OnigCodePoint CR_In_Buhid[] = {
+	1,
+	0x1740, 0x175f,
+}; /* CR_In_Buhid */
+
+/* 'In_Tagbanwa': Block */
+static const OnigCodePoint CR_In_Tagbanwa[] = {
+	1,
+	0x1760, 0x177f,
+}; /* CR_In_Tagbanwa */
+
+/* 'In_Khmer': Block */
+static const OnigCodePoint CR_In_Khmer[] = {
+	1,
+	0x1780, 0x17ff,
+}; /* CR_In_Khmer */
+
+/* 'In_Mongolian': Block */
+static const OnigCodePoint CR_In_Mongolian[] = {
+	1,
+	0x1800, 0x18af,
+}; /* CR_In_Mongolian */
+
+/* 'In_Unified_Canadian_Aboriginal_Syllabics_Extended': Block */
+static const OnigCodePoint CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended[] = {
+	1,
+	0x18b0, 0x18ff,
+}; /* CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended */
+
+/* 'In_Limbu': Block */
+static const OnigCodePoint CR_In_Limbu[] = {
+	1,
+	0x1900, 0x194f,
+}; /* CR_In_Limbu */
+
+/* 'In_Tai_Le': Block */
+static const OnigCodePoint CR_In_Tai_Le[] = {
+	1,
+	0x1950, 0x197f,
+}; /* CR_In_Tai_Le */
+
+/* 'In_New_Tai_Lue': Block */
+static const OnigCodePoint CR_In_New_Tai_Lue[] = {
+	1,
+	0x1980, 0x19df,
+}; /* CR_In_New_Tai_Lue */
+
+/* 'In_Khmer_Symbols': Block */
+static const OnigCodePoint CR_In_Khmer_Symbols[] = {
+	1,
+	0x19e0, 0x19ff,
+}; /* CR_In_Khmer_Symbols */
+
+/* 'In_Buginese': Block */
+static const OnigCodePoint CR_In_Buginese[] = {
+	1,
+	0x1a00, 0x1a1f,
+}; /* CR_In_Buginese */
+
+/* 'In_Tai_Tham': Block */
+static const OnigCodePoint CR_In_Tai_Tham[] = {
+	1,
+	0x1a20, 0x1aaf,
+}; /* CR_In_Tai_Tham */
+
+/* 'In_Combining_Diacritical_Marks_Extended': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Extended[] = {
+	1,
+	0x1ab0, 0x1aff,
+}; /* CR_In_Combining_Diacritical_Marks_Extended */
+
+/* 'In_Balinese': Block */
+static const OnigCodePoint CR_In_Balinese[] = {
+	1,
+	0x1b00, 0x1b7f,
+}; /* CR_In_Balinese */
+
+/* 'In_Sundanese': Block */
+static const OnigCodePoint CR_In_Sundanese[] = {
+	1,
+	0x1b80, 0x1bbf,
+}; /* CR_In_Sundanese */
+
+/* 'In_Batak': Block */
+static const OnigCodePoint CR_In_Batak[] = {
+	1,
+	0x1bc0, 0x1bff,
+}; /* CR_In_Batak */
+
+/* 'In_Lepcha': Block */
+static const OnigCodePoint CR_In_Lepcha[] = {
+	1,
+	0x1c00, 0x1c4f,
+}; /* CR_In_Lepcha */
+
+/* 'In_Ol_Chiki': Block */
+#define CR_In_Ol_Chiki CR_Ol_Chiki
+
+/* 'In_Sundanese_Supplement': Block */
+static const OnigCodePoint CR_In_Sundanese_Supplement[] = {
+	1,
+	0x1cc0, 0x1ccf,
+}; /* CR_In_Sundanese_Supplement */
+
+/* 'In_Vedic_Extensions': Block */
+static const OnigCodePoint CR_In_Vedic_Extensions[] = {
+	1,
+	0x1cd0, 0x1cff,
+}; /* CR_In_Vedic_Extensions */
+
+/* 'In_Phonetic_Extensions': Block */
+static const OnigCodePoint CR_In_Phonetic_Extensions[] = {
+	1,
+	0x1d00, 0x1d7f,
+}; /* CR_In_Phonetic_Extensions */
+
+/* 'In_Phonetic_Extensions_Supplement': Block */
+static const OnigCodePoint CR_In_Phonetic_Extensions_Supplement[] = {
+	1,
+	0x1d80, 0x1dbf,
+}; /* CR_In_Phonetic_Extensions_Supplement */
+
+/* 'In_Combining_Diacritical_Marks_Supplement': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_Supplement[] = {
+	1,
+	0x1dc0, 0x1dff,
+}; /* CR_In_Combining_Diacritical_Marks_Supplement */
+
+/* 'In_Latin_Extended_Additional': Block */
+static const OnigCodePoint CR_In_Latin_Extended_Additional[] = {
+	1,
+	0x1e00, 0x1eff,
+}; /* CR_In_Latin_Extended_Additional */
+
+/* 'In_Greek_Extended': Block */
+static const OnigCodePoint CR_In_Greek_Extended[] = {
+	1,
+	0x1f00, 0x1fff,
+}; /* CR_In_Greek_Extended */
+
+/* 'In_General_Punctuation': Block */
+static const OnigCodePoint CR_In_General_Punctuation[] = {
+	1,
+	0x2000, 0x206f,
+}; /* CR_In_General_Punctuation */
+
+/* 'In_Superscripts_and_Subscripts': Block */
+static const OnigCodePoint CR_In_Superscripts_and_Subscripts[] = {
+	1,
+	0x2070, 0x209f,
+}; /* CR_In_Superscripts_and_Subscripts */
+
+/* 'In_Currency_Symbols': Block */
+static const OnigCodePoint CR_In_Currency_Symbols[] = {
+	1,
+	0x20a0, 0x20cf,
+}; /* CR_In_Currency_Symbols */
+
+/* 'In_Combining_Diacritical_Marks_for_Symbols': Block */
+static const OnigCodePoint CR_In_Combining_Diacritical_Marks_for_Symbols[] = {
+	1,
+	0x20d0, 0x20ff,
+}; /* CR_In_Combining_Diacritical_Marks_for_Symbols */
+
+/* 'In_Letterlike_Symbols': Block */
+static const OnigCodePoint CR_In_Letterlike_Symbols[] = {
+	1,
+	0x2100, 0x214f,
+}; /* CR_In_Letterlike_Symbols */
+
+/* 'In_Number_Forms': Block */
+static const OnigCodePoint CR_In_Number_Forms[] = {
+	1,
+	0x2150, 0x218f,
+}; /* CR_In_Number_Forms */
+
+/* 'In_Arrows': Block */
+static const OnigCodePoint CR_In_Arrows[] = {
+	1,
+	0x2190, 0x21ff,
+}; /* CR_In_Arrows */
+
+/* 'In_Mathematical_Operators': Block */
+static const OnigCodePoint CR_In_Mathematical_Operators[] = {
+	1,
+	0x2200, 0x22ff,
+}; /* CR_In_Mathematical_Operators */
+
+/* 'In_Miscellaneous_Technical': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Technical[] = {
+	1,
+	0x2300, 0x23ff,
+}; /* CR_In_Miscellaneous_Technical */
+
+/* 'In_Control_Pictures': Block */
+static const OnigCodePoint CR_In_Control_Pictures[] = {
+	1,
+	0x2400, 0x243f,
+}; /* CR_In_Control_Pictures */
+
+/* 'In_Optical_Character_Recognition': Block */
+static const OnigCodePoint CR_In_Optical_Character_Recognition[] = {
+	1,
+	0x2440, 0x245f,
+}; /* CR_In_Optical_Character_Recognition */
+
+/* 'In_Enclosed_Alphanumerics': Block */
+static const OnigCodePoint CR_In_Enclosed_Alphanumerics[] = {
+	1,
+	0x2460, 0x24ff,
+}; /* CR_In_Enclosed_Alphanumerics */
+
+/* 'In_Box_Drawing': Block */
+static const OnigCodePoint CR_In_Box_Drawing[] = {
+	1,
+	0x2500, 0x257f,
+}; /* CR_In_Box_Drawing */
+
+/* 'In_Block_Elements': Block */
+static const OnigCodePoint CR_In_Block_Elements[] = {
+	1,
+	0x2580, 0x259f,
+}; /* CR_In_Block_Elements */
+
+/* 'In_Geometric_Shapes': Block */
+static const OnigCodePoint CR_In_Geometric_Shapes[] = {
+	1,
+	0x25a0, 0x25ff,
+}; /* CR_In_Geometric_Shapes */
+
+/* 'In_Miscellaneous_Symbols': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols[] = {
+	1,
+	0x2600, 0x26ff,
+}; /* CR_In_Miscellaneous_Symbols */
+
+/* 'In_Dingbats': Block */
+static const OnigCodePoint CR_In_Dingbats[] = {
+	1,
+	0x2700, 0x27bf,
+}; /* CR_In_Dingbats */
+
+/* 'In_Miscellaneous_Mathematical_Symbols_A': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_A[] = {
+	1,
+	0x27c0, 0x27ef,
+}; /* CR_In_Miscellaneous_Mathematical_Symbols_A */
+
+/* 'In_Supplemental_Arrows_A': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_A[] = {
+	1,
+	0x27f0, 0x27ff,
+}; /* CR_In_Supplemental_Arrows_A */
+
+/* 'In_Braille_Patterns': Block */
+#define CR_In_Braille_Patterns CR_Braille
+
+/* 'In_Supplemental_Arrows_B': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_B[] = {
+	1,
+	0x2900, 0x297f,
+}; /* CR_In_Supplemental_Arrows_B */
+
+/* 'In_Miscellaneous_Mathematical_Symbols_B': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Mathematical_Symbols_B[] = {
+	1,
+	0x2980, 0x29ff,
+}; /* CR_In_Miscellaneous_Mathematical_Symbols_B */
+
+/* 'In_Supplemental_Mathematical_Operators': Block */
+static const OnigCodePoint CR_In_Supplemental_Mathematical_Operators[] = {
+	1,
+	0x2a00, 0x2aff,
+}; /* CR_In_Supplemental_Mathematical_Operators */
+
+/* 'In_Miscellaneous_Symbols_and_Arrows': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Arrows[] = {
+	1,
+	0x2b00, 0x2bff,
+}; /* CR_In_Miscellaneous_Symbols_and_Arrows */
+
+/* 'In_Glagolitic': Block */
+static const OnigCodePoint CR_In_Glagolitic[] = {
+	1,
+	0x2c00, 0x2c5f,
+}; /* CR_In_Glagolitic */
+
+/* 'In_Latin_Extended_C': Block */
+static const OnigCodePoint CR_In_Latin_Extended_C[] = {
+	1,
+	0x2c60, 0x2c7f,
+}; /* CR_In_Latin_Extended_C */
+
+/* 'In_Coptic': Block */
+static const OnigCodePoint CR_In_Coptic[] = {
+	1,
+	0x2c80, 0x2cff,
+}; /* CR_In_Coptic */
+
+/* 'In_Georgian_Supplement': Block */
+static const OnigCodePoint CR_In_Georgian_Supplement[] = {
+	1,
+	0x2d00, 0x2d2f,
+}; /* CR_In_Georgian_Supplement */
+
+/* 'In_Tifinagh': Block */
+static const OnigCodePoint CR_In_Tifinagh[] = {
+	1,
+	0x2d30, 0x2d7f,
+}; /* CR_In_Tifinagh */
+
+/* 'In_Ethiopic_Extended': Block */
+static const OnigCodePoint CR_In_Ethiopic_Extended[] = {
+	1,
+	0x2d80, 0x2ddf,
+}; /* CR_In_Ethiopic_Extended */
+
+/* 'In_Cyrillic_Extended_A': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_A[] = {
+	1,
+	0x2de0, 0x2dff,
+}; /* CR_In_Cyrillic_Extended_A */
+
+/* 'In_Supplemental_Punctuation': Block */
+static const OnigCodePoint CR_In_Supplemental_Punctuation[] = {
+	1,
+	0x2e00, 0x2e7f,
+}; /* CR_In_Supplemental_Punctuation */
+
+/* 'In_CJK_Radicals_Supplement': Block */
+static const OnigCodePoint CR_In_CJK_Radicals_Supplement[] = {
+	1,
+	0x2e80, 0x2eff,
+}; /* CR_In_CJK_Radicals_Supplement */
+
+/* 'In_Kangxi_Radicals': Block */
+static const OnigCodePoint CR_In_Kangxi_Radicals[] = {
+	1,
+	0x2f00, 0x2fdf,
+}; /* CR_In_Kangxi_Radicals */
+
+/* 'In_Ideographic_Description_Characters': Block */
+static const OnigCodePoint CR_In_Ideographic_Description_Characters[] = {
+	1,
+	0x2ff0, 0x2fff,
+}; /* CR_In_Ideographic_Description_Characters */
+
+/* 'In_CJK_Symbols_and_Punctuation': Block */
+static const OnigCodePoint CR_In_CJK_Symbols_and_Punctuation[] = {
+	1,
+	0x3000, 0x303f,
+}; /* CR_In_CJK_Symbols_and_Punctuation */
+
+/* 'In_Hiragana': Block */
+static const OnigCodePoint CR_In_Hiragana[] = {
+	1,
+	0x3040, 0x309f,
+}; /* CR_In_Hiragana */
+
+/* 'In_Katakana': Block */
+static const OnigCodePoint CR_In_Katakana[] = {
+	1,
+	0x30a0, 0x30ff,
+}; /* CR_In_Katakana */
+
+/* 'In_Bopomofo': Block */
+static const OnigCodePoint CR_In_Bopomofo[] = {
+	1,
+	0x3100, 0x312f,
+}; /* CR_In_Bopomofo */
+
+/* 'In_Hangul_Compatibility_Jamo': Block */
+static const OnigCodePoint CR_In_Hangul_Compatibility_Jamo[] = {
+	1,
+	0x3130, 0x318f,
+}; /* CR_In_Hangul_Compatibility_Jamo */
+
+/* 'In_Kanbun': Block */
+static const OnigCodePoint CR_In_Kanbun[] = {
+	1,
+	0x3190, 0x319f,
+}; /* CR_In_Kanbun */
+
+/* 'In_Bopomofo_Extended': Block */
+static const OnigCodePoint CR_In_Bopomofo_Extended[] = {
+	1,
+	0x31a0, 0x31bf,
+}; /* CR_In_Bopomofo_Extended */
+
+/* 'In_CJK_Strokes': Block */
+static const OnigCodePoint CR_In_CJK_Strokes[] = {
+	1,
+	0x31c0, 0x31ef,
+}; /* CR_In_CJK_Strokes */
+
+/* 'In_Katakana_Phonetic_Extensions': Block */
+static const OnigCodePoint CR_In_Katakana_Phonetic_Extensions[] = {
+	1,
+	0x31f0, 0x31ff,
+}; /* CR_In_Katakana_Phonetic_Extensions */
+
+/* 'In_Enclosed_CJK_Letters_and_Months': Block */
+static const OnigCodePoint CR_In_Enclosed_CJK_Letters_and_Months[] = {
+	1,
+	0x3200, 0x32ff,
+}; /* CR_In_Enclosed_CJK_Letters_and_Months */
+
+/* 'In_CJK_Compatibility': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility[] = {
+	1,
+	0x3300, 0x33ff,
+}; /* CR_In_CJK_Compatibility */
+
+/* 'In_CJK_Unified_Ideographs_Extension_A': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_A[] = {
+	1,
+	0x3400, 0x4dbf,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_A */
+
+/* 'In_Yijing_Hexagram_Symbols': Block */
+static const OnigCodePoint CR_In_Yijing_Hexagram_Symbols[] = {
+	1,
+	0x4dc0, 0x4dff,
+}; /* CR_In_Yijing_Hexagram_Symbols */
+
+/* 'In_CJK_Unified_Ideographs': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs[] = {
+	1,
+	0x4e00, 0x9fff,
+}; /* CR_In_CJK_Unified_Ideographs */
+
+/* 'In_Yi_Syllables': Block */
+static const OnigCodePoint CR_In_Yi_Syllables[] = {
+	1,
+	0xa000, 0xa48f,
+}; /* CR_In_Yi_Syllables */
+
+/* 'In_Yi_Radicals': Block */
+static const OnigCodePoint CR_In_Yi_Radicals[] = {
+	1,
+	0xa490, 0xa4cf,
+}; /* CR_In_Yi_Radicals */
+
+/* 'In_Lisu': Block */
+#define CR_In_Lisu CR_Lisu
+
+/* 'In_Vai': Block */
+static const OnigCodePoint CR_In_Vai[] = {
+	1,
+	0xa500, 0xa63f,
+}; /* CR_In_Vai */
+
+/* 'In_Cyrillic_Extended_B': Block */
+static const OnigCodePoint CR_In_Cyrillic_Extended_B[] = {
+	1,
+	0xa640, 0xa69f,
+}; /* CR_In_Cyrillic_Extended_B */
+
+/* 'In_Bamum': Block */
+static const OnigCodePoint CR_In_Bamum[] = {
+	1,
+	0xa6a0, 0xa6ff,
+}; /* CR_In_Bamum */
+
+/* 'In_Modifier_Tone_Letters': Block */
+static const OnigCodePoint CR_In_Modifier_Tone_Letters[] = {
+	1,
+	0xa700, 0xa71f,
+}; /* CR_In_Modifier_Tone_Letters */
+
+/* 'In_Latin_Extended_D': Block */
+static const OnigCodePoint CR_In_Latin_Extended_D[] = {
+	1,
+	0xa720, 0xa7ff,
+}; /* CR_In_Latin_Extended_D */
+
+/* 'In_Syloti_Nagri': Block */
+static const OnigCodePoint CR_In_Syloti_Nagri[] = {
+	1,
+	0xa800, 0xa82f,
+}; /* CR_In_Syloti_Nagri */
+
+/* 'In_Common_Indic_Number_Forms': Block */
+static const OnigCodePoint CR_In_Common_Indic_Number_Forms[] = {
+	1,
+	0xa830, 0xa83f,
+}; /* CR_In_Common_Indic_Number_Forms */
+
+/* 'In_Phags_pa': Block */
+static const OnigCodePoint CR_In_Phags_pa[] = {
+	1,
+	0xa840, 0xa87f,
+}; /* CR_In_Phags_pa */
+
+/* 'In_Saurashtra': Block */
+static const OnigCodePoint CR_In_Saurashtra[] = {
+	1,
+	0xa880, 0xa8df,
+}; /* CR_In_Saurashtra */
+
+/* 'In_Devanagari_Extended': Block */
+static const OnigCodePoint CR_In_Devanagari_Extended[] = {
+	1,
+	0xa8e0, 0xa8ff,
+}; /* CR_In_Devanagari_Extended */
+
+/* 'In_Kayah_Li': Block */
+static const OnigCodePoint CR_In_Kayah_Li[] = {
+	1,
+	0xa900, 0xa92f,
+}; /* CR_In_Kayah_Li */
+
+/* 'In_Rejang': Block */
+static const OnigCodePoint CR_In_Rejang[] = {
+	1,
+	0xa930, 0xa95f,
+}; /* CR_In_Rejang */
+
+/* 'In_Hangul_Jamo_Extended_A': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo_Extended_A[] = {
+	1,
+	0xa960, 0xa97f,
+}; /* CR_In_Hangul_Jamo_Extended_A */
+
+/* 'In_Javanese': Block */
+static const OnigCodePoint CR_In_Javanese[] = {
+	1,
+	0xa980, 0xa9df,
+}; /* CR_In_Javanese */
+
+/* 'In_Myanmar_Extended_B': Block */
+static const OnigCodePoint CR_In_Myanmar_Extended_B[] = {
+	1,
+	0xa9e0, 0xa9ff,
+}; /* CR_In_Myanmar_Extended_B */
+
+/* 'In_Cham': Block */
+static const OnigCodePoint CR_In_Cham[] = {
+	1,
+	0xaa00, 0xaa5f,
+}; /* CR_In_Cham */
+
+/* 'In_Myanmar_Extended_A': Block */
+static const OnigCodePoint CR_In_Myanmar_Extended_A[] = {
+	1,
+	0xaa60, 0xaa7f,
+}; /* CR_In_Myanmar_Extended_A */
+
+/* 'In_Tai_Viet': Block */
+static const OnigCodePoint CR_In_Tai_Viet[] = {
+	1,
+	0xaa80, 0xaadf,
+}; /* CR_In_Tai_Viet */
+
+/* 'In_Meetei_Mayek_Extensions': Block */
+static const OnigCodePoint CR_In_Meetei_Mayek_Extensions[] = {
+	1,
+	0xaae0, 0xaaff,
+}; /* CR_In_Meetei_Mayek_Extensions */
+
+/* 'In_Ethiopic_Extended_A': Block */
+static const OnigCodePoint CR_In_Ethiopic_Extended_A[] = {
+	1,
+	0xab00, 0xab2f,
+}; /* CR_In_Ethiopic_Extended_A */
+
+/* 'In_Latin_Extended_E': Block */
+static const OnigCodePoint CR_In_Latin_Extended_E[] = {
+	1,
+	0xab30, 0xab6f,
+}; /* CR_In_Latin_Extended_E */
+
+/* 'In_Meetei_Mayek': Block */
+static const OnigCodePoint CR_In_Meetei_Mayek[] = {
+	1,
+	0xabc0, 0xabff,
+}; /* CR_In_Meetei_Mayek */
+
+/* 'In_Hangul_Syllables': Block */
+static const OnigCodePoint CR_In_Hangul_Syllables[] = {
+	1,
+	0xac00, 0xd7af,
+}; /* CR_In_Hangul_Syllables */
+
+/* 'In_Hangul_Jamo_Extended_B': Block */
+static const OnigCodePoint CR_In_Hangul_Jamo_Extended_B[] = {
+	1,
+	0xd7b0, 0xd7ff,
+}; /* CR_In_Hangul_Jamo_Extended_B */
+
+/* 'In_High_Surrogates': Block */
+static const OnigCodePoint CR_In_High_Surrogates[] = {
+	1,
+	0xd800, 0xdb7f,
+}; /* CR_In_High_Surrogates */
+
+/* 'In_High_Private_Use_Surrogates': Block */
+static const OnigCodePoint CR_In_High_Private_Use_Surrogates[] = {
+	1,
+	0xdb80, 0xdbff,
+}; /* CR_In_High_Private_Use_Surrogates */
+
+/* 'In_Low_Surrogates': Block */
+static const OnigCodePoint CR_In_Low_Surrogates[] = {
+	1,
+	0xdc00, 0xdfff,
+}; /* CR_In_Low_Surrogates */
+
+/* 'In_Private_Use_Area': Block */
+static const OnigCodePoint CR_In_Private_Use_Area[] = {
+	1,
+	0xe000, 0xf8ff,
+}; /* CR_In_Private_Use_Area */
+
+/* 'In_CJK_Compatibility_Ideographs': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs[] = {
+	1,
+	0xf900, 0xfaff,
+}; /* CR_In_CJK_Compatibility_Ideographs */
+
+/* 'In_Alphabetic_Presentation_Forms': Block */
+static const OnigCodePoint CR_In_Alphabetic_Presentation_Forms[] = {
+	1,
+	0xfb00, 0xfb4f,
+}; /* CR_In_Alphabetic_Presentation_Forms */
+
+/* 'In_Arabic_Presentation_Forms_A': Block */
+static const OnigCodePoint CR_In_Arabic_Presentation_Forms_A[] = {
+	1,
+	0xfb50, 0xfdff,
+}; /* CR_In_Arabic_Presentation_Forms_A */
+
+/* 'In_Variation_Selectors': Block */
+static const OnigCodePoint CR_In_Variation_Selectors[] = {
+	1,
+	0xfe00, 0xfe0f,
+}; /* CR_In_Variation_Selectors */
+
+/* 'In_Vertical_Forms': Block */
+static const OnigCodePoint CR_In_Vertical_Forms[] = {
+	1,
+	0xfe10, 0xfe1f,
+}; /* CR_In_Vertical_Forms */
+
+/* 'In_Combining_Half_Marks': Block */
+static const OnigCodePoint CR_In_Combining_Half_Marks[] = {
+	1,
+	0xfe20, 0xfe2f,
+}; /* CR_In_Combining_Half_Marks */
+
+/* 'In_CJK_Compatibility_Forms': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Forms[] = {
+	1,
+	0xfe30, 0xfe4f,
+}; /* CR_In_CJK_Compatibility_Forms */
+
+/* 'In_Small_Form_Variants': Block */
+static const OnigCodePoint CR_In_Small_Form_Variants[] = {
+	1,
+	0xfe50, 0xfe6f,
+}; /* CR_In_Small_Form_Variants */
+
+/* 'In_Arabic_Presentation_Forms_B': Block */
+static const OnigCodePoint CR_In_Arabic_Presentation_Forms_B[] = {
+	1,
+	0xfe70, 0xfeff,
+}; /* CR_In_Arabic_Presentation_Forms_B */
+
+/* 'In_Halfwidth_and_Fullwidth_Forms': Block */
+static const OnigCodePoint CR_In_Halfwidth_and_Fullwidth_Forms[] = {
+	1,
+	0xff00, 0xffef,
+}; /* CR_In_Halfwidth_and_Fullwidth_Forms */
+
+/* 'In_Specials': Block */
+static const OnigCodePoint CR_In_Specials[] = {
+	1,
+	0xfff0, 0xffff,
+}; /* CR_In_Specials */
+
+/* 'In_Linear_B_Syllabary': Block */
+static const OnigCodePoint CR_In_Linear_B_Syllabary[] = {
+	1,
+	0x10000, 0x1007f,
+}; /* CR_In_Linear_B_Syllabary */
+
+/* 'In_Linear_B_Ideograms': Block */
+static const OnigCodePoint CR_In_Linear_B_Ideograms[] = {
+	1,
+	0x10080, 0x100ff,
+}; /* CR_In_Linear_B_Ideograms */
+
+/* 'In_Aegean_Numbers': Block */
+static const OnigCodePoint CR_In_Aegean_Numbers[] = {
+	1,
+	0x10100, 0x1013f,
+}; /* CR_In_Aegean_Numbers */
+
+/* 'In_Ancient_Greek_Numbers': Block */
+static const OnigCodePoint CR_In_Ancient_Greek_Numbers[] = {
+	1,
+	0x10140, 0x1018f,
+}; /* CR_In_Ancient_Greek_Numbers */
+
+/* 'In_Ancient_Symbols': Block */
+static const OnigCodePoint CR_In_Ancient_Symbols[] = {
+	1,
+	0x10190, 0x101cf,
+}; /* CR_In_Ancient_Symbols */
+
+/* 'In_Phaistos_Disc': Block */
+static const OnigCodePoint CR_In_Phaistos_Disc[] = {
+	1,
+	0x101d0, 0x101ff,
+}; /* CR_In_Phaistos_Disc */
+
+/* 'In_Lycian': Block */
+static const OnigCodePoint CR_In_Lycian[] = {
+	1,
+	0x10280, 0x1029f,
+}; /* CR_In_Lycian */
+
+/* 'In_Carian': Block */
+static const OnigCodePoint CR_In_Carian[] = {
+	1,
+	0x102a0, 0x102df,
+}; /* CR_In_Carian */
+
+/* 'In_Coptic_Epact_Numbers': Block */
+static const OnigCodePoint CR_In_Coptic_Epact_Numbers[] = {
+	1,
+	0x102e0, 0x102ff,
+}; /* CR_In_Coptic_Epact_Numbers */
+
+/* 'In_Old_Italic': Block */
+static const OnigCodePoint CR_In_Old_Italic[] = {
+	1,
+	0x10300, 0x1032f,
+}; /* CR_In_Old_Italic */
+
+/* 'In_Gothic': Block */
+static const OnigCodePoint CR_In_Gothic[] = {
+	1,
+	0x10330, 0x1034f,
+}; /* CR_In_Gothic */
+
+/* 'In_Old_Permic': Block */
+static const OnigCodePoint CR_In_Old_Permic[] = {
+	1,
+	0x10350, 0x1037f,
+}; /* CR_In_Old_Permic */
+
+/* 'In_Ugaritic': Block */
+static const OnigCodePoint CR_In_Ugaritic[] = {
+	1,
+	0x10380, 0x1039f,
+}; /* CR_In_Ugaritic */
+
+/* 'In_Old_Persian': Block */
+static const OnigCodePoint CR_In_Old_Persian[] = {
+	1,
+	0x103a0, 0x103df,
+}; /* CR_In_Old_Persian */
+
+/* 'In_Deseret': Block */
+#define CR_In_Deseret CR_Deseret
+
+/* 'In_Shavian': Block */
+#define CR_In_Shavian CR_Shavian
+
+/* 'In_Osmanya': Block */
+static const OnigCodePoint CR_In_Osmanya[] = {
+	1,
+	0x10480, 0x104af,
+}; /* CR_In_Osmanya */
+
+/* 'In_Elbasan': Block */
+static const OnigCodePoint CR_In_Elbasan[] = {
+	1,
+	0x10500, 0x1052f,
+}; /* CR_In_Elbasan */
+
+/* 'In_Caucasian_Albanian': Block */
+static const OnigCodePoint CR_In_Caucasian_Albanian[] = {
+	1,
+	0x10530, 0x1056f,
+}; /* CR_In_Caucasian_Albanian */
+
+/* 'In_Linear_A': Block */
+static const OnigCodePoint CR_In_Linear_A[] = {
+	1,
+	0x10600, 0x1077f,
+}; /* CR_In_Linear_A */
+
+/* 'In_Cypriot_Syllabary': Block */
+static const OnigCodePoint CR_In_Cypriot_Syllabary[] = {
+	1,
+	0x10800, 0x1083f,
+}; /* CR_In_Cypriot_Syllabary */
+
+/* 'In_Imperial_Aramaic': Block */
+static const OnigCodePoint CR_In_Imperial_Aramaic[] = {
+	1,
+	0x10840, 0x1085f,
+}; /* CR_In_Imperial_Aramaic */
+
+/* 'In_Palmyrene': Block */
+#define CR_In_Palmyrene CR_Palmyrene
+
+/* 'In_Nabataean': Block */
+static const OnigCodePoint CR_In_Nabataean[] = {
+	1,
+	0x10880, 0x108af,
+}; /* CR_In_Nabataean */
+
+/* 'In_Phoenician': Block */
+static const OnigCodePoint CR_In_Phoenician[] = {
+	1,
+	0x10900, 0x1091f,
+}; /* CR_In_Phoenician */
+
+/* 'In_Lydian': Block */
+static const OnigCodePoint CR_In_Lydian[] = {
+	1,
+	0x10920, 0x1093f,
+}; /* CR_In_Lydian */
+
+/* 'In_Meroitic_Hieroglyphs': Block */
+#define CR_In_Meroitic_Hieroglyphs CR_Meroitic_Hieroglyphs
+
+/* 'In_Meroitic_Cursive': Block */
+static const OnigCodePoint CR_In_Meroitic_Cursive[] = {
+	1,
+	0x109a0, 0x109ff,
+}; /* CR_In_Meroitic_Cursive */
+
+/* 'In_Kharoshthi': Block */
+static const OnigCodePoint CR_In_Kharoshthi[] = {
+	1,
+	0x10a00, 0x10a5f,
+}; /* CR_In_Kharoshthi */
+
+/* 'In_Old_South_Arabian': Block */
+#define CR_In_Old_South_Arabian CR_Old_South_Arabian
+
+/* 'In_Old_North_Arabian': Block */
+#define CR_In_Old_North_Arabian CR_Old_North_Arabian
+
+/* 'In_Manichaean': Block */
+static const OnigCodePoint CR_In_Manichaean[] = {
+	1,
+	0x10ac0, 0x10aff,
+}; /* CR_In_Manichaean */
+
+/* 'In_Avestan': Block */
+static const OnigCodePoint CR_In_Avestan[] = {
+	1,
+	0x10b00, 0x10b3f,
+}; /* CR_In_Avestan */
+
+/* 'In_Inscriptional_Parthian': Block */
+static const OnigCodePoint CR_In_Inscriptional_Parthian[] = {
+	1,
+	0x10b40, 0x10b5f,
+}; /* CR_In_Inscriptional_Parthian */
+
+/* 'In_Inscriptional_Pahlavi': Block */
+static const OnigCodePoint CR_In_Inscriptional_Pahlavi[] = {
+	1,
+	0x10b60, 0x10b7f,
+}; /* CR_In_Inscriptional_Pahlavi */
+
+/* 'In_Psalter_Pahlavi': Block */
+static const OnigCodePoint CR_In_Psalter_Pahlavi[] = {
+	1,
+	0x10b80, 0x10baf,
+}; /* CR_In_Psalter_Pahlavi */
+
+/* 'In_Old_Turkic': Block */
+static const OnigCodePoint CR_In_Old_Turkic[] = {
+	1,
+	0x10c00, 0x10c4f,
+}; /* CR_In_Old_Turkic */
+
+/* 'In_Rumi_Numeral_Symbols': Block */
+static const OnigCodePoint CR_In_Rumi_Numeral_Symbols[] = {
+	1,
+	0x10e60, 0x10e7f,
+}; /* CR_In_Rumi_Numeral_Symbols */
+
+/* 'In_Brahmi': Block */
+static const OnigCodePoint CR_In_Brahmi[] = {
+	1,
+	0x11000, 0x1107f,
+}; /* CR_In_Brahmi */
+
+/* 'In_Kaithi': Block */
+static const OnigCodePoint CR_In_Kaithi[] = {
+	1,
+	0x11080, 0x110cf,
+}; /* CR_In_Kaithi */
+
+/* 'In_Sora_Sompeng': Block */
+static const OnigCodePoint CR_In_Sora_Sompeng[] = {
+	1,
+	0x110d0, 0x110ff,
+}; /* CR_In_Sora_Sompeng */
+
+/* 'In_Chakma': Block */
+static const OnigCodePoint CR_In_Chakma[] = {
+	1,
+	0x11100, 0x1114f,
+}; /* CR_In_Chakma */
+
+/* 'In_Mahajani': Block */
+static const OnigCodePoint CR_In_Mahajani[] = {
+	1,
+	0x11150, 0x1117f,
+}; /* CR_In_Mahajani */
+
+/* 'In_Sharada': Block */
+static const OnigCodePoint CR_In_Sharada[] = {
+	1,
+	0x11180, 0x111df,
+}; /* CR_In_Sharada */
+
+/* 'In_Sinhala_Archaic_Numbers': Block */
+static const OnigCodePoint CR_In_Sinhala_Archaic_Numbers[] = {
+	1,
+	0x111e0, 0x111ff,
+}; /* CR_In_Sinhala_Archaic_Numbers */
+
+/* 'In_Khojki': Block */
+static const OnigCodePoint CR_In_Khojki[] = {
+	1,
+	0x11200, 0x1124f,
+}; /* CR_In_Khojki */
+
+/* 'In_Khudawadi': Block */
+static const OnigCodePoint CR_In_Khudawadi[] = {
+	1,
+	0x112b0, 0x112ff,
+}; /* CR_In_Khudawadi */
+
+/* 'In_Grantha': Block */
+static const OnigCodePoint CR_In_Grantha[] = {
+	1,
+	0x11300, 0x1137f,
+}; /* CR_In_Grantha */
+
+/* 'In_Tirhuta': Block */
+static const OnigCodePoint CR_In_Tirhuta[] = {
+	1,
+	0x11480, 0x114df,
+}; /* CR_In_Tirhuta */
+
+/* 'In_Siddham': Block */
+static const OnigCodePoint CR_In_Siddham[] = {
+	1,
+	0x11580, 0x115ff,
+}; /* CR_In_Siddham */
+
+/* 'In_Modi': Block */
+static const OnigCodePoint CR_In_Modi[] = {
+	1,
+	0x11600, 0x1165f,
+}; /* CR_In_Modi */
+
+/* 'In_Takri': Block */
+static const OnigCodePoint CR_In_Takri[] = {
+	1,
+	0x11680, 0x116cf,
+}; /* CR_In_Takri */
+
+/* 'In_Warang_Citi': Block */
+static const OnigCodePoint CR_In_Warang_Citi[] = {
+	1,
+	0x118a0, 0x118ff,
+}; /* CR_In_Warang_Citi */
+
+/* 'In_Pau_Cin_Hau': Block */
+static const OnigCodePoint CR_In_Pau_Cin_Hau[] = {
+	1,
+	0x11ac0, 0x11aff,
+}; /* CR_In_Pau_Cin_Hau */
+
+/* 'In_Cuneiform': Block */
+static const OnigCodePoint CR_In_Cuneiform[] = {
+	1,
+	0x12000, 0x123ff,
+}; /* CR_In_Cuneiform */
+
+/* 'In_Cuneiform_Numbers_and_Punctuation': Block */
+static const OnigCodePoint CR_In_Cuneiform_Numbers_and_Punctuation[] = {
+	1,
+	0x12400, 0x1247f,
+}; /* CR_In_Cuneiform_Numbers_and_Punctuation */
+
+/* 'In_Egyptian_Hieroglyphs': Block */
+static const OnigCodePoint CR_In_Egyptian_Hieroglyphs[] = {
+	1,
+	0x13000, 0x1342f,
+}; /* CR_In_Egyptian_Hieroglyphs */
+
+/* 'In_Bamum_Supplement': Block */
+static const OnigCodePoint CR_In_Bamum_Supplement[] = {
+	1,
+	0x16800, 0x16a3f,
+}; /* CR_In_Bamum_Supplement */
+
+/* 'In_Mro': Block */
+static const OnigCodePoint CR_In_Mro[] = {
+	1,
+	0x16a40, 0x16a6f,
+}; /* CR_In_Mro */
+
+/* 'In_Bassa_Vah': Block */
+static const OnigCodePoint CR_In_Bassa_Vah[] = {
+	1,
+	0x16ad0, 0x16aff,
+}; /* CR_In_Bassa_Vah */
+
+/* 'In_Pahawh_Hmong': Block */
+static const OnigCodePoint CR_In_Pahawh_Hmong[] = {
+	1,
+	0x16b00, 0x16b8f,
+}; /* CR_In_Pahawh_Hmong */
+
+/* 'In_Miao': Block */
+static const OnigCodePoint CR_In_Miao[] = {
+	1,
+	0x16f00, 0x16f9f,
+}; /* CR_In_Miao */
+
+/* 'In_Kana_Supplement': Block */
+static const OnigCodePoint CR_In_Kana_Supplement[] = {
+	1,
+	0x1b000, 0x1b0ff,
+}; /* CR_In_Kana_Supplement */
+
+/* 'In_Duployan': Block */
+static const OnigCodePoint CR_In_Duployan[] = {
+	1,
+	0x1bc00, 0x1bc9f,
+}; /* CR_In_Duployan */
+
+/* 'In_Shorthand_Format_Controls': Block */
+static const OnigCodePoint CR_In_Shorthand_Format_Controls[] = {
+	1,
+	0x1bca0, 0x1bcaf,
+}; /* CR_In_Shorthand_Format_Controls */
+
+/* 'In_Byzantine_Musical_Symbols': Block */
+static const OnigCodePoint CR_In_Byzantine_Musical_Symbols[] = {
+	1,
+	0x1d000, 0x1d0ff,
+}; /* CR_In_Byzantine_Musical_Symbols */
+
+/* 'In_Musical_Symbols': Block */
+static const OnigCodePoint CR_In_Musical_Symbols[] = {
+	1,
+	0x1d100, 0x1d1ff,
+}; /* CR_In_Musical_Symbols */
+
+/* 'In_Ancient_Greek_Musical_Notation': Block */
+static const OnigCodePoint CR_In_Ancient_Greek_Musical_Notation[] = {
+	1,
+	0x1d200, 0x1d24f,
+}; /* CR_In_Ancient_Greek_Musical_Notation */
+
+/* 'In_Tai_Xuan_Jing_Symbols': Block */
+static const OnigCodePoint CR_In_Tai_Xuan_Jing_Symbols[] = {
+	1,
+	0x1d300, 0x1d35f,
+}; /* CR_In_Tai_Xuan_Jing_Symbols */
+
+/* 'In_Counting_Rod_Numerals': Block */
+static const OnigCodePoint CR_In_Counting_Rod_Numerals[] = {
+	1,
+	0x1d360, 0x1d37f,
+}; /* CR_In_Counting_Rod_Numerals */
+
+/* 'In_Mathematical_Alphanumeric_Symbols': Block */
+static const OnigCodePoint CR_In_Mathematical_Alphanumeric_Symbols[] = {
+	1,
+	0x1d400, 0x1d7ff,
+}; /* CR_In_Mathematical_Alphanumeric_Symbols */
+
+/* 'In_Mende_Kikakui': Block */
+static const OnigCodePoint CR_In_Mende_Kikakui[] = {
+	1,
+	0x1e800, 0x1e8df,
+}; /* CR_In_Mende_Kikakui */
+
+/* 'In_Arabic_Mathematical_Alphabetic_Symbols': Block */
+static const OnigCodePoint CR_In_Arabic_Mathematical_Alphabetic_Symbols[] = {
+	1,
+	0x1ee00, 0x1eeff,
+}; /* CR_In_Arabic_Mathematical_Alphabetic_Symbols */
+
+/* 'In_Mahjong_Tiles': Block */
+static const OnigCodePoint CR_In_Mahjong_Tiles[] = {
+	1,
+	0x1f000, 0x1f02f,
+}; /* CR_In_Mahjong_Tiles */
+
+/* 'In_Domino_Tiles': Block */
+static const OnigCodePoint CR_In_Domino_Tiles[] = {
+	1,
+	0x1f030, 0x1f09f,
+}; /* CR_In_Domino_Tiles */
+
+/* 'In_Playing_Cards': Block */
+static const OnigCodePoint CR_In_Playing_Cards[] = {
+	1,
+	0x1f0a0, 0x1f0ff,
+}; /* CR_In_Playing_Cards */
+
+/* 'In_Enclosed_Alphanumeric_Supplement': Block */
+static const OnigCodePoint CR_In_Enclosed_Alphanumeric_Supplement[] = {
+	1,
+	0x1f100, 0x1f1ff,
+}; /* CR_In_Enclosed_Alphanumeric_Supplement */
+
+/* 'In_Enclosed_Ideographic_Supplement': Block */
+static const OnigCodePoint CR_In_Enclosed_Ideographic_Supplement[] = {
+	1,
+	0x1f200, 0x1f2ff,
+}; /* CR_In_Enclosed_Ideographic_Supplement */
+
+/* 'In_Miscellaneous_Symbols_and_Pictographs': Block */
+static const OnigCodePoint CR_In_Miscellaneous_Symbols_and_Pictographs[] = {
+	1,
+	0x1f300, 0x1f5ff,
+}; /* CR_In_Miscellaneous_Symbols_and_Pictographs */
+
+/* 'In_Emoticons': Block */
+static const OnigCodePoint CR_In_Emoticons[] = {
+	1,
+	0x1f600, 0x1f64f,
+}; /* CR_In_Emoticons */
+
+/* 'In_Ornamental_Dingbats': Block */
+static const OnigCodePoint CR_In_Ornamental_Dingbats[] = {
+	1,
+	0x1f650, 0x1f67f,
+}; /* CR_In_Ornamental_Dingbats */
+
+/* 'In_Transport_and_Map_Symbols': Block */
+static const OnigCodePoint CR_In_Transport_and_Map_Symbols[] = {
+	1,
+	0x1f680, 0x1f6ff,
+}; /* CR_In_Transport_and_Map_Symbols */
+
+/* 'In_Alchemical_Symbols': Block */
+static const OnigCodePoint CR_In_Alchemical_Symbols[] = {
+	1,
+	0x1f700, 0x1f77f,
+}; /* CR_In_Alchemical_Symbols */
+
+/* 'In_Geometric_Shapes_Extended': Block */
+static const OnigCodePoint CR_In_Geometric_Shapes_Extended[] = {
+	1,
+	0x1f780, 0x1f7ff,
+}; /* CR_In_Geometric_Shapes_Extended */
+
+/* 'In_Supplemental_Arrows_C': Block */
+static const OnigCodePoint CR_In_Supplemental_Arrows_C[] = {
+	1,
+	0x1f800, 0x1f8ff,
+}; /* CR_In_Supplemental_Arrows_C */
+
+/* 'In_CJK_Unified_Ideographs_Extension_B': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_B[] = {
+	1,
+	0x20000, 0x2a6df,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_B */
+
+/* 'In_CJK_Unified_Ideographs_Extension_C': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_C[] = {
+	1,
+	0x2a700, 0x2b73f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_C */
+
+/* 'In_CJK_Unified_Ideographs_Extension_D': Block */
+static const OnigCodePoint CR_In_CJK_Unified_Ideographs_Extension_D[] = {
+	1,
+	0x2b740, 0x2b81f,
+}; /* CR_In_CJK_Unified_Ideographs_Extension_D */
+
+/* 'In_CJK_Compatibility_Ideographs_Supplement': Block */
+static const OnigCodePoint CR_In_CJK_Compatibility_Ideographs_Supplement[] = {
+	1,
+	0x2f800, 0x2fa1f,
+}; /* CR_In_CJK_Compatibility_Ideographs_Supplement */
+
+/* 'In_Tags': Block */
+static const OnigCodePoint CR_In_Tags[] = {
+	1,
+	0xe0000, 0xe007f,
+}; /* CR_In_Tags */
+
+/* 'In_Variation_Selectors_Supplement': Block */
+static const OnigCodePoint CR_In_Variation_Selectors_Supplement[] = {
+	1,
+	0xe0100, 0xe01ef,
+}; /* CR_In_Variation_Selectors_Supplement */
+
+/* 'In_Supplementary_Private_Use_Area_A': Block */
+static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_A[] = {
+	1,
+	0xf0000, 0xfffff,
+}; /* CR_In_Supplementary_Private_Use_Area_A */
+
+/* 'In_Supplementary_Private_Use_Area_B': Block */
+static const OnigCodePoint CR_In_Supplementary_Private_Use_Area_B[] = {
+	1,
+	0x100000, 0x10ffff,
+}; /* CR_In_Supplementary_Private_Use_Area_B */
+
+/* 'In_No_Block': Block */
+static const OnigCodePoint CR_In_No_Block[] = {
+	40,
+	0x0860, 0x089f,
+	0x1c80, 0x1cbf,
+	0x2fe0, 0x2fef,
+	0xab70, 0xabbf,
+	0x10200, 0x1027f,
+	0x103e0, 0x103ff,
+	0x104b0, 0x104ff,
+	0x10570, 0x105ff,
+	0x10780, 0x107ff,
+	0x108b0, 0x108ff,
+	0x10940, 0x1097f,
+	0x10aa0, 0x10abf,
+	0x10bb0, 0x10bff,
+	0x10c50, 0x10e5f,
+	0x10e80, 0x10fff,
+	0x11250, 0x112af,
+	0x11380, 0x1147f,
+	0x114e0, 0x1157f,
+	0x11660, 0x1167f,
+	0x116d0, 0x1189f,
+	0x11900, 0x11abf,
+	0x11b00, 0x11fff,
+	0x12480, 0x12fff,
+	0x13430, 0x167ff,
+	0x16a70, 0x16acf,
+	0x16b90, 0x16eff,
+	0x16fa0, 0x1afff,
+	0x1b100, 0x1bbff,
+	0x1bcb0, 0x1cfff,
+	0x1d250, 0x1d2ff,
+	0x1d380, 0x1d3ff,
+	0x1d800, 0x1e7ff,
+	0x1e8e0, 0x1edff,
+	0x1ef00, 0x1efff,
+	0x1f900, 0x1ffff,
+	0x2a6e0, 0x2a6ff,
+	0x2b820, 0x2f7ff,
+	0x2fa20, 0xdffff,
+	0xe0080, 0xe00ff,
+	0xe01f0, 0xeffff,
+}; /* CR_In_No_Block */
+#endif /* USE_UNICODE_PROPERTIES */
+
+static const OnigCodePoint* const CodeRanges[] = {
+  CR_NEWLINE,
+  CR_Alpha,
+  CR_Blank,
+  CR_Cntrl,
+  CR_Digit,
+  CR_Graph,
+  CR_Lower,
+  CR_Print,
+  CR_Punct,
+  CR_Space,
+  CR_Upper,
+  CR_XDigit,
+  CR_Word,
+  CR_Alnum,
+  CR_ASCII,
+#ifdef USE_UNICODE_PROPERTIES
+  CR_Any,
+  CR_Assigned,
+  CR_C,
+  CR_Cc,
+  CR_Cf,
+  CR_Cn,
+  CR_Co,
+  CR_Cs,
+  CR_L,
+  CR_LC,
+  CR_Ll,
+  CR_Lm,
+  CR_Lo,
+  CR_Lt,
+  CR_Lu,
+  CR_M,
+  CR_Mc,
+  CR_Me,
+  CR_Mn,
+  CR_N,
+  CR_Nd,
+  CR_Nl,
+  CR_No,
+  CR_P,
+  CR_Pc,
+  CR_Pd,
+  CR_Pe,
+  CR_Pf,
+  CR_Pi,
+  CR_Po,
+  CR_Ps,
+  CR_S,
+  CR_Sc,
+  CR_Sk,
+  CR_Sm,
+  CR_So,
+  CR_Z,
+  CR_Zl,
+  CR_Zp,
+  CR_Zs,
+  CR_Math,
+  CR_Alphabetic,
+  CR_Lowercase,
+  CR_Uppercase,
+  CR_Cased,
+  CR_Case_Ignorable,
+  CR_Changes_When_Lowercased,
+  CR_Changes_When_Uppercased,
+  CR_Changes_When_Titlecased,
+  CR_Changes_When_Casefolded,
+  CR_Changes_When_Casemapped,
+  CR_ID_Start,
+  CR_ID_Continue,
+  CR_XID_Start,
+  CR_XID_Continue,
+  CR_Default_Ignorable_Code_Point,
+  CR_Grapheme_Extend,
+  CR_Grapheme_Base,
+  CR_Grapheme_Link,
+  CR_Common,
+  CR_Latin,
+  CR_Greek,
+  CR_Cyrillic,
+  CR_Armenian,
+  CR_Hebrew,
+  CR_Arabic,
+  CR_Syriac,
+  CR_Thaana,
+  CR_Devanagari,
+  CR_Bengali,
+  CR_Gurmukhi,
+  CR_Gujarati,
+  CR_Oriya,
+  CR_Tamil,
+  CR_Telugu,
+  CR_Kannada,
+  CR_Malayalam,
+  CR_Sinhala,
+  CR_Thai,
+  CR_Lao,
+  CR_Tibetan,
+  CR_Myanmar,
+  CR_Georgian,
+  CR_Hangul,
+  CR_Ethiopic,
+  CR_Cherokee,
+  CR_Canadian_Aboriginal,
+  CR_Ogham,
+  CR_Runic,
+  CR_Khmer,
+  CR_Mongolian,
+  CR_Hiragana,
+  CR_Katakana,
+  CR_Bopomofo,
+  CR_Han,
+  CR_Yi,
+  CR_Old_Italic,
+  CR_Gothic,
+  CR_Deseret,
+  CR_Inherited,
+  CR_Tagalog,
+  CR_Hanunoo,
+  CR_Buhid,
+  CR_Tagbanwa,
+  CR_Limbu,
+  CR_Tai_Le,
+  CR_Linear_B,
+  CR_Ugaritic,
+  CR_Shavian,
+  CR_Osmanya,
+  CR_Cypriot,
+  CR_Braille,
+  CR_Buginese,
+  CR_Coptic,
+  CR_New_Tai_Lue,
+  CR_Glagolitic,
+  CR_Tifinagh,
+  CR_Syloti_Nagri,
+  CR_Old_Persian,
+  CR_Kharoshthi,
+  CR_Balinese,
+  CR_Cuneiform,
+  CR_Phoenician,
+  CR_Phags_Pa,
+  CR_Nko,
+  CR_Sundanese,
+  CR_Lepcha,
+  CR_Ol_Chiki,
+  CR_Vai,
+  CR_Saurashtra,
+  CR_Kayah_Li,
+  CR_Rejang,
+  CR_Lycian,
+  CR_Carian,
+  CR_Lydian,
+  CR_Cham,
+  CR_Tai_Tham,
+  CR_Tai_Viet,
+  CR_Avestan,
+  CR_Egyptian_Hieroglyphs,
+  CR_Samaritan,
+  CR_Lisu,
+  CR_Bamum,
+  CR_Javanese,
+  CR_Meetei_Mayek,
+  CR_Imperial_Aramaic,
+  CR_Old_South_Arabian,
+  CR_Inscriptional_Parthian,
+  CR_Inscriptional_Pahlavi,
+  CR_Old_Turkic,
+  CR_Kaithi,
+  CR_Batak,
+  CR_Brahmi,
+  CR_Mandaic,
+  CR_Chakma,
+  CR_Meroitic_Cursive,
+  CR_Meroitic_Hieroglyphs,
+  CR_Miao,
+  CR_Sharada,
+  CR_Sora_Sompeng,
+  CR_Takri,
+  CR_Caucasian_Albanian,
+  CR_Bassa_Vah,
+  CR_Duployan,
+  CR_Elbasan,
+  CR_Grantha,
+  CR_Pahawh_Hmong,
+  CR_Khojki,
+  CR_Linear_A,
+  CR_Mahajani,
+  CR_Manichaean,
+  CR_Mende_Kikakui,
+  CR_Modi,
+  CR_Mro,
+  CR_Old_North_Arabian,
+  CR_Nabataean,
+  CR_Palmyrene,
+  CR_Pau_Cin_Hau,
+  CR_Old_Permic,
+  CR_Psalter_Pahlavi,
+  CR_Siddham,
+  CR_Khudawadi,
+  CR_Tirhuta,
+  CR_Warang_Citi,
+  CR_White_Space,
+  CR_Bidi_Control,
+  CR_Join_Control,
+  CR_Dash,
+  CR_Hyphen,
+  CR_Quotation_Mark,
+  CR_Terminal_Punctuation,
+  CR_Other_Math,
+  CR_Hex_Digit,
+  CR_ASCII_Hex_Digit,
+  CR_Other_Alphabetic,
+  CR_Ideographic,
+  CR_Diacritic,
+  CR_Extender,
+  CR_Other_Lowercase,
+  CR_Other_Uppercase,
+  CR_Noncharacter_Code_Point,
+  CR_Other_Grapheme_Extend,
+  CR_IDS_Binary_Operator,
+  CR_IDS_Trinary_Operator,
+  CR_Radical,
+  CR_Unified_Ideograph,
+  CR_Other_Default_Ignorable_Code_Point,
+  CR_Deprecated,
+  CR_Soft_Dotted,
+  CR_Logical_Order_Exception,
+  CR_Other_ID_Start,
+  CR_Other_ID_Continue,
+  CR_STerm,
+  CR_Variation_Selector,
+  CR_Pattern_White_Space,
+  CR_Pattern_Syntax,
+  CR_Unknown,
+#ifdef USE_UNICODE_AGE_PROPERTIES
+  CR_Age_1_1,
+  CR_Age_2_0,
+  CR_Age_2_1,
+  CR_Age_3_0,
+  CR_Age_3_1,
+  CR_Age_3_2,
+  CR_Age_4_0,
+  CR_Age_4_1,
+  CR_Age_5_0,
+  CR_Age_5_1,
+  CR_Age_5_2,
+  CR_Age_6_0,
+  CR_Age_6_1,
+  CR_Age_6_2,
+  CR_Age_6_3,
+  CR_Age_7_0,
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+  CR_In_Basic_Latin,
+  CR_In_Latin_1_Supplement,
+  CR_In_Latin_Extended_A,
+  CR_In_Latin_Extended_B,
+  CR_In_IPA_Extensions,
+  CR_In_Spacing_Modifier_Letters,
+  CR_In_Combining_Diacritical_Marks,
+  CR_In_Greek_and_Coptic,
+  CR_In_Cyrillic,
+  CR_In_Cyrillic_Supplement,
+  CR_In_Armenian,
+  CR_In_Hebrew,
+  CR_In_Arabic,
+  CR_In_Syriac,
+  CR_In_Arabic_Supplement,
+  CR_In_Thaana,
+  CR_In_NKo,
+  CR_In_Samaritan,
+  CR_In_Mandaic,
+  CR_In_Arabic_Extended_A,
+  CR_In_Devanagari,
+  CR_In_Bengali,
+  CR_In_Gurmukhi,
+  CR_In_Gujarati,
+  CR_In_Oriya,
+  CR_In_Tamil,
+  CR_In_Telugu,
+  CR_In_Kannada,
+  CR_In_Malayalam,
+  CR_In_Sinhala,
+  CR_In_Thai,
+  CR_In_Lao,
+  CR_In_Tibetan,
+  CR_In_Myanmar,
+  CR_In_Georgian,
+  CR_In_Hangul_Jamo,
+  CR_In_Ethiopic,
+  CR_In_Ethiopic_Supplement,
+  CR_In_Cherokee,
+  CR_In_Unified_Canadian_Aboriginal_Syllabics,
+  CR_In_Ogham,
+  CR_In_Runic,
+  CR_In_Tagalog,
+  CR_In_Hanunoo,
+  CR_In_Buhid,
+  CR_In_Tagbanwa,
+  CR_In_Khmer,
+  CR_In_Mongolian,
+  CR_In_Unified_Canadian_Aboriginal_Syllabics_Extended,
+  CR_In_Limbu,
+  CR_In_Tai_Le,
+  CR_In_New_Tai_Lue,
+  CR_In_Khmer_Symbols,
+  CR_In_Buginese,
+  CR_In_Tai_Tham,
+  CR_In_Combining_Diacritical_Marks_Extended,
+  CR_In_Balinese,
+  CR_In_Sundanese,
+  CR_In_Batak,
+  CR_In_Lepcha,
+  CR_In_Ol_Chiki,
+  CR_In_Sundanese_Supplement,
+  CR_In_Vedic_Extensions,
+  CR_In_Phonetic_Extensions,
+  CR_In_Phonetic_Extensions_Supplement,
+  CR_In_Combining_Diacritical_Marks_Supplement,
+  CR_In_Latin_Extended_Additional,
+  CR_In_Greek_Extended,
+  CR_In_General_Punctuation,
+  CR_In_Superscripts_and_Subscripts,
+  CR_In_Currency_Symbols,
+  CR_In_Combining_Diacritical_Marks_for_Symbols,
+  CR_In_Letterlike_Symbols,
+  CR_In_Number_Forms,
+  CR_In_Arrows,
+  CR_In_Mathematical_Operators,
+  CR_In_Miscellaneous_Technical,
+  CR_In_Control_Pictures,
+  CR_In_Optical_Character_Recognition,
+  CR_In_Enclosed_Alphanumerics,
+  CR_In_Box_Drawing,
+  CR_In_Block_Elements,
+  CR_In_Geometric_Shapes,
+  CR_In_Miscellaneous_Symbols,
+  CR_In_Dingbats,
+  CR_In_Miscellaneous_Mathematical_Symbols_A,
+  CR_In_Supplemental_Arrows_A,
+  CR_In_Braille_Patterns,
+  CR_In_Supplemental_Arrows_B,
+  CR_In_Miscellaneous_Mathematical_Symbols_B,
+  CR_In_Supplemental_Mathematical_Operators,
+  CR_In_Miscellaneous_Symbols_and_Arrows,
+  CR_In_Glagolitic,
+  CR_In_Latin_Extended_C,
+  CR_In_Coptic,
+  CR_In_Georgian_Supplement,
+  CR_In_Tifinagh,
+  CR_In_Ethiopic_Extended,
+  CR_In_Cyrillic_Extended_A,
+  CR_In_Supplemental_Punctuation,
+  CR_In_CJK_Radicals_Supplement,
+  CR_In_Kangxi_Radicals,
+  CR_In_Ideographic_Description_Characters,
+  CR_In_CJK_Symbols_and_Punctuation,
+  CR_In_Hiragana,
+  CR_In_Katakana,
+  CR_In_Bopomofo,
+  CR_In_Hangul_Compatibility_Jamo,
+  CR_In_Kanbun,
+  CR_In_Bopomofo_Extended,
+  CR_In_CJK_Strokes,
+  CR_In_Katakana_Phonetic_Extensions,
+  CR_In_Enclosed_CJK_Letters_and_Months,
+  CR_In_CJK_Compatibility,
+  CR_In_CJK_Unified_Ideographs_Extension_A,
+  CR_In_Yijing_Hexagram_Symbols,
+  CR_In_CJK_Unified_Ideographs,
+  CR_In_Yi_Syllables,
+  CR_In_Yi_Radicals,
+  CR_In_Lisu,
+  CR_In_Vai,
+  CR_In_Cyrillic_Extended_B,
+  CR_In_Bamum,
+  CR_In_Modifier_Tone_Letters,
+  CR_In_Latin_Extended_D,
+  CR_In_Syloti_Nagri,
+  CR_In_Common_Indic_Number_Forms,
+  CR_In_Phags_pa,
+  CR_In_Saurashtra,
+  CR_In_Devanagari_Extended,
+  CR_In_Kayah_Li,
+  CR_In_Rejang,
+  CR_In_Hangul_Jamo_Extended_A,
+  CR_In_Javanese,
+  CR_In_Myanmar_Extended_B,
+  CR_In_Cham,
+  CR_In_Myanmar_Extended_A,
+  CR_In_Tai_Viet,
+  CR_In_Meetei_Mayek_Extensions,
+  CR_In_Ethiopic_Extended_A,
+  CR_In_Latin_Extended_E,
+  CR_In_Meetei_Mayek,
+  CR_In_Hangul_Syllables,
+  CR_In_Hangul_Jamo_Extended_B,
+  CR_In_High_Surrogates,
+  CR_In_High_Private_Use_Surrogates,
+  CR_In_Low_Surrogates,
+  CR_In_Private_Use_Area,
+  CR_In_CJK_Compatibility_Ideographs,
+  CR_In_Alphabetic_Presentation_Forms,
+  CR_In_Arabic_Presentation_Forms_A,
+  CR_In_Variation_Selectors,
+  CR_In_Vertical_Forms,
+  CR_In_Combining_Half_Marks,
+  CR_In_CJK_Compatibility_Forms,
+  CR_In_Small_Form_Variants,
+  CR_In_Arabic_Presentation_Forms_B,
+  CR_In_Halfwidth_and_Fullwidth_Forms,
+  CR_In_Specials,
+  CR_In_Linear_B_Syllabary,
+  CR_In_Linear_B_Ideograms,
+  CR_In_Aegean_Numbers,
+  CR_In_Ancient_Greek_Numbers,
+  CR_In_Ancient_Symbols,
+  CR_In_Phaistos_Disc,
+  CR_In_Lycian,
+  CR_In_Carian,
+  CR_In_Coptic_Epact_Numbers,
+  CR_In_Old_Italic,
+  CR_In_Gothic,
+  CR_In_Old_Permic,
+  CR_In_Ugaritic,
+  CR_In_Old_Persian,
+  CR_In_Deseret,
+  CR_In_Shavian,
+  CR_In_Osmanya,
+  CR_In_Elbasan,
+  CR_In_Caucasian_Albanian,
+  CR_In_Linear_A,
+  CR_In_Cypriot_Syllabary,
+  CR_In_Imperial_Aramaic,
+  CR_In_Palmyrene,
+  CR_In_Nabataean,
+  CR_In_Phoenician,
+  CR_In_Lydian,
+  CR_In_Meroitic_Hieroglyphs,
+  CR_In_Meroitic_Cursive,
+  CR_In_Kharoshthi,
+  CR_In_Old_South_Arabian,
+  CR_In_Old_North_Arabian,
+  CR_In_Manichaean,
+  CR_In_Avestan,
+  CR_In_Inscriptional_Parthian,
+  CR_In_Inscriptional_Pahlavi,
+  CR_In_Psalter_Pahlavi,
+  CR_In_Old_Turkic,
+  CR_In_Rumi_Numeral_Symbols,
+  CR_In_Brahmi,
+  CR_In_Kaithi,
+  CR_In_Sora_Sompeng,
+  CR_In_Chakma,
+  CR_In_Mahajani,
+  CR_In_Sharada,
+  CR_In_Sinhala_Archaic_Numbers,
+  CR_In_Khojki,
+  CR_In_Khudawadi,
+  CR_In_Grantha,
+  CR_In_Tirhuta,
+  CR_In_Siddham,
+  CR_In_Modi,
+  CR_In_Takri,
+  CR_In_Warang_Citi,
+  CR_In_Pau_Cin_Hau,
+  CR_In_Cuneiform,
+  CR_In_Cuneiform_Numbers_and_Punctuation,
+  CR_In_Egyptian_Hieroglyphs,
+  CR_In_Bamum_Supplement,
+  CR_In_Mro,
+  CR_In_Bassa_Vah,
+  CR_In_Pahawh_Hmong,
+  CR_In_Miao,
+  CR_In_Kana_Supplement,
+  CR_In_Duployan,
+  CR_In_Shorthand_Format_Controls,
+  CR_In_Byzantine_Musical_Symbols,
+  CR_In_Musical_Symbols,
+  CR_In_Ancient_Greek_Musical_Notation,
+  CR_In_Tai_Xuan_Jing_Symbols,
+  CR_In_Counting_Rod_Numerals,
+  CR_In_Mathematical_Alphanumeric_Symbols,
+  CR_In_Mende_Kikakui,
+  CR_In_Arabic_Mathematical_Alphabetic_Symbols,
+  CR_In_Mahjong_Tiles,
+  CR_In_Domino_Tiles,
+  CR_In_Playing_Cards,
+  CR_In_Enclosed_Alphanumeric_Supplement,
+  CR_In_Enclosed_Ideographic_Supplement,
+  CR_In_Miscellaneous_Symbols_and_Pictographs,
+  CR_In_Emoticons,
+  CR_In_Ornamental_Dingbats,
+  CR_In_Transport_and_Map_Symbols,
+  CR_In_Alchemical_Symbols,
+  CR_In_Geometric_Shapes_Extended,
+  CR_In_Supplemental_Arrows_C,
+  CR_In_CJK_Unified_Ideographs_Extension_B,
+  CR_In_CJK_Unified_Ideographs_Extension_C,
+  CR_In_CJK_Unified_Ideographs_Extension_D,
+  CR_In_CJK_Compatibility_Ideographs_Supplement,
+  CR_In_Tags,
+  CR_In_Variation_Selectors_Supplement,
+  CR_In_Supplementary_Private_Use_Area_A,
+  CR_In_Supplementary_Private_Use_Area_B,
+  CR_In_No_Block,
+#endif /* USE_UNICODE_PROPERTIES */
+};
+struct uniname2ctype_struct {
+  int name, ctype;
+};
+
+static const struct uniname2ctype_struct *uniname2ctype_p(const char *, unsigned int);
+
+#ifndef USE_UNICODE_PROPERTIES
+#define TOTAL_KEYWORDS 14
+#define MIN_WORD_LENGTH 4
+#define MAX_WORD_LENGTH 6
+#define MIN_HASH_VALUE 6
+#define MAX_HASH_VALUE 19
+/* maximum key range = 14, duplicates = 0 */
+#else /* USE_UNICODE_PROPERTIES */
+#ifndef USE_UNICODE_AGE_PROPERTIES
+#define TOTAL_KEYWORDS 689
+#else /* USE_UNICODE_AGE_PROPERTIES */
+#define TOTAL_KEYWORDS 705
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+#define MIN_WORD_LENGTH 1
+#define MAX_WORD_LENGTH 44
+#define MIN_HASH_VALUE 3
+#define MAX_HASH_VALUE 4322
+/* maximum key range = 4320, duplicates = 0 */
+#endif /* USE_UNICODE_PROPERTIES */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+uniname2ctype_hash (str, len)
+     register const char *str;
+     register unsigned int len;
+{
+#ifndef USE_UNICODE_PROPERTIES
+  static const unsigned char asso_values[] =
+#else /* USE_UNICODE_PROPERTIES */
+  static const unsigned short asso_values[] =
+#endif /* USE_UNICODE_PROPERTIES */
+    {
+#ifndef USE_UNICODE_PROPERTIES
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+      20, 20, 20, 20, 20, 20, 20,  3, 11,  5,
+       4, 20, 20,  9, 20,  1, 20, 20, 10, 20,
+       2, 20,  1, 20,  1,  7,  4,  6, 20,  1,
+       4, 20, 20, 20, 20, 20, 20, 20
+#else /* USE_UNICODE_PROPERTIES */
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+#ifndef USE_UNICODE_AGE_PROPERTIES
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+#else /* USE_UNICODE_AGE_PROPERTIES */
+      4323, 4323, 4323, 4323, 4323, 4323,    1, 4323,   12,    1,
+         2,    9,   18,   11,    6,   10, 4323, 4323, 4323, 4323,
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+      4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323, 4323,
+      4323, 4323, 4323, 4323, 4323, 4323, 4323,   13,  931,    6,
+       382,   25,  311,  891,  277,    4,  272, 1436,  120,    7,
+         1,  303,  456,    1,  232,   32,   65,  732, 1411,  163,
+       883, 1255,    8, 4323, 4323, 4323, 4323, 4323
+#endif /* USE_UNICODE_PROPERTIES */
+    };
+#ifndef USE_UNICODE_PROPERTIES
+  return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]];
+#else /* USE_UNICODE_PROPERTIES */
+  register int hval = len;
+
+  switch (hval)
+    {
+      default:
+        hval += asso_values[(unsigned char)str[15]];
+      /*FALLTHROUGH*/
+      case 15:
+      case 14:
+      case 13:
+      case 12:
+        hval += asso_values[(unsigned char)str[11]];
+      /*FALLTHROUGH*/
+      case 11:
+      case 10:
+      case 9:
+      case 8:
+      case 7:
+      case 6:
+        hval += asso_values[(unsigned char)str[5]];
+      /*FALLTHROUGH*/
+      case 5:
+        hval += asso_values[(unsigned char)str[4]];
+      /*FALLTHROUGH*/
+      case 4:
+      case 3:
+        hval += asso_values[(unsigned char)str[2]];
+      /*FALLTHROUGH*/
+      case 2:
+        hval += asso_values[(unsigned char)str[1]];
+      /*FALLTHROUGH*/
+      case 1:
+        hval += asso_values[(unsigned char)str[0]];
+        break;
+    }
+  return hval + asso_values[(unsigned char)str[len - 1]];
+#endif /* USE_UNICODE_PROPERTIES */
+}
+
+struct uniname2ctype_pool_t
+  {
+#ifndef USE_UNICODE_PROPERTIES
+    char uniname2ctype_pool_str6[sizeof("word")];
+    char uniname2ctype_pool_str7[sizeof("print")];
+    char uniname2ctype_pool_str8[sizeof("punct")];
+    char uniname2ctype_pool_str9[sizeof("alpha")];
+    char uniname2ctype_pool_str10[sizeof("alnum")];
+    char uniname2ctype_pool_str11[sizeof("xdigit")];
+    char uniname2ctype_pool_str12[sizeof("upper")];
+    char uniname2ctype_pool_str13[sizeof("ascii")];
+    char uniname2ctype_pool_str14[sizeof("cntrl")];
+    char uniname2ctype_pool_str15[sizeof("space")];
+    char uniname2ctype_pool_str16[sizeof("lower")];
+    char uniname2ctype_pool_str17[sizeof("graph")];
+    char uniname2ctype_pool_str18[sizeof("digit")];
+    char uniname2ctype_pool_str19[sizeof("blank")];
+#else /* USE_UNICODE_PROPERTIES */
+    char uniname2ctype_pool_str3[sizeof("n")];
+    char uniname2ctype_pool_str10[sizeof("cn")];
+    char uniname2ctype_pool_str11[sizeof("mn")];
+    char uniname2ctype_pool_str13[sizeof("c")];
+    char uniname2ctype_pool_str15[sizeof("m")];
+    char uniname2ctype_pool_str16[sizeof("ci")];
+    char uniname2ctype_pool_str17[sizeof("z")];
+    char uniname2ctype_pool_str20[sizeof("cc")];
+    char uniname2ctype_pool_str21[sizeof("mc")];
+    char uniname2ctype_pool_str29[sizeof("mani")];
+    char uniname2ctype_pool_str31[sizeof("inmanichaean")];
+    char uniname2ctype_pool_str35[sizeof("qaai")];
+    char uniname2ctype_pool_str36[sizeof("zzzz")];
+    char uniname2ctype_pool_str37[sizeof("qaac")];
+    char uniname2ctype_pool_str44[sizeof("incham")];
+    char uniname2ctype_pool_str46[sizeof("sc")];
+    char uniname2ctype_pool_str48[sizeof("sm")];
+    char uniname2ctype_pool_str51[sizeof("mandaic")];
+    char uniname2ctype_pool_str55[sizeof("incuneiform")];
+    char uniname2ctype_pool_str56[sizeof("cans")];
+    char uniname2ctype_pool_str59[sizeof("me")];
+    char uniname2ctype_pool_str61[sizeof("inarmenian")];
+    char uniname2ctype_pool_str64[sizeof("ascii")];
+    char uniname2ctype_pool_str65[sizeof("s")];
+    char uniname2ctype_pool_str69[sizeof("insamaritan")];
+    char uniname2ctype_pool_str72[sizeof("cs")];
+    char uniname2ctype_pool_str74[sizeof("zs")];
+    char uniname2ctype_pool_str85[sizeof("inavestan")];
+    char uniname2ctype_pool_str92[sizeof("incommonindicnumberforms")];
+    char uniname2ctype_pool_str96[sizeof("incuneiformnumbersandpunctuation")];
+    char uniname2ctype_pool_str97[sizeof("inthai")];
+    char uniname2ctype_pool_str98[sizeof("inipaextensions")];
+    char uniname2ctype_pool_str105[sizeof("mtei")];
+    char uniname2ctype_pool_str110[sizeof("inspecials")];
+    char uniname2ctype_pool_str114[sizeof("initialpunctuation")];
+    char uniname2ctype_pool_str115[sizeof("inancientsymbols")];
+    char uniname2ctype_pool_str117[sizeof("inthaana")];
+    char uniname2ctype_pool_str130[sizeof("inmiscellaneousmathematicalsymbolsa")];
+    char uniname2ctype_pool_str134[sizeof("lc")];
+    char uniname2ctype_pool_str135[sizeof("inmusicalsymbols")];
+    char uniname2ctype_pool_str136[sizeof("lm")];
+    char uniname2ctype_pool_str137[sizeof("taile")];
+    char uniname2ctype_pool_str141[sizeof("sterm")];
+    char uniname2ctype_pool_str142[sizeof("lina")];
+    char uniname2ctype_pool_str144[sizeof("inlycian")];
+    char uniname2ctype_pool_str147[sizeof("inmyanmarextendeda")];
+    char uniname2ctype_pool_str151[sizeof("lana")];
+    char uniname2ctype_pool_str153[sizeof("alnum")];
+    char uniname2ctype_pool_str155[sizeof("intaitham")];
+    char uniname2ctype_pool_str157[sizeof("incontrolpictures")];
+    char uniname2ctype_pool_str161[sizeof("inmiscellaneoussymbols")];
+    char uniname2ctype_pool_str163[sizeof("inmalayalam")];
+    char uniname2ctype_pool_str166[sizeof("intransportandmapsymbols")];
+    char uniname2ctype_pool_str170[sizeof("inmiscellaneoussymbolsandarrows")];
+    char uniname2ctype_pool_str173[sizeof("inlineara")];
+    char uniname2ctype_pool_str175[sizeof("inmiscellaneoussymbolsandpictographs")];
+    char uniname2ctype_pool_str183[sizeof("taiviet")];
+    char uniname2ctype_pool_str186[sizeof("cwcm")];
+    char uniname2ctype_pool_str190[sizeof("sinhala")];
+    char uniname2ctype_pool_str203[sizeof("latn")];
+    char uniname2ctype_pool_str205[sizeof("latin")];
+    char uniname2ctype_pool_str206[sizeof("ital")];
+    char uniname2ctype_pool_str208[sizeof("intamil")];
+    char uniname2ctype_pool_str209[sizeof("taml")];
+    char uniname2ctype_pool_str223[sizeof("inlatinextendedc")];
+    char uniname2ctype_pool_str226[sizeof("intaile")];
+    char uniname2ctype_pool_str227[sizeof("tale")];
+    char uniname2ctype_pool_str237[sizeof("inlatinextendeda")];
+    char uniname2ctype_pool_str239[sizeof("inlinearbideograms")];
+    char uniname2ctype_pool_str240[sizeof("newtailue")];
+    char uniname2ctype_pool_str241[sizeof("l")];
+    char uniname2ctype_pool_str243[sizeof("nl")];
+    char uniname2ctype_pool_str247[sizeof("inmeeteimayekextensions")];
+    char uniname2ctype_pool_str250[sizeof("zl")];
+    char uniname2ctype_pool_str252[sizeof("lt")];
+    char uniname2ctype_pool_str255[sizeof("inrunic")];
+    char uniname2ctype_pool_str256[sizeof("incarian")];
+    char uniname2ctype_pool_str257[sizeof("armn")];
+    char uniname2ctype_pool_str259[sizeof("cari")];
+    char uniname2ctype_pool_str260[sizeof("armi")];
+    char uniname2ctype_pool_str261[sizeof("inlatinextendede")];
+    char uniname2ctype_pool_str263[sizeof("incyrillic")];
+    char uniname2ctype_pool_str266[sizeof("armenian")];
+    char uniname2ctype_pool_str267[sizeof("inmyanmar")];
+    char uniname2ctype_pool_str270[sizeof("innewtailue")];
+    char uniname2ctype_pool_str272[sizeof("carian")];
+    char uniname2ctype_pool_str274[sizeof("merc")];
+    char uniname2ctype_pool_str280[sizeof("arabic")];
+    char uniname2ctype_pool_str284[sizeof("inmiscellaneoustechnical")];
+    char uniname2ctype_pool_str287[sizeof("insyriac")];
+    char uniname2ctype_pool_str288[sizeof("samr")];
+    char uniname2ctype_pool_str294[sizeof("zinh")];
+    char uniname2ctype_pool_str295[sizeof("han")];
+    char uniname2ctype_pool_str298[sizeof("samaritan")];
+    char uniname2ctype_pool_str299[sizeof("hani")];
+    char uniname2ctype_pool_str302[sizeof("cwt")];
+    char uniname2ctype_pool_str303[sizeof("incherokee")];
+    char uniname2ctype_pool_str304[sizeof("insharada")];
+    char uniname2ctype_pool_str307[sizeof("cham")];
+    char uniname2ctype_pool_str315[sizeof("manichaean")];
+    char uniname2ctype_pool_str316[sizeof("inmahajani")];
+    char uniname2ctype_pool_str317[sizeof("cntrl")];
+    char uniname2ctype_pool_str318[sizeof("sinh")];
+    char uniname2ctype_pool_str320[sizeof("inruminumeralsymbols")];
+    char uniname2ctype_pool_str327[sizeof("inethiopic")];
+    char uniname2ctype_pool_str330[sizeof("tamil")];
+    char uniname2ctype_pool_str331[sizeof("miao")];
+    char uniname2ctype_pool_str332[sizeof("inenclosedalphanumerics")];
+    char uniname2ctype_pool_str333[sizeof("term")];
+    char uniname2ctype_pool_str335[sizeof("chakma")];
+    char uniname2ctype_pool_str337[sizeof("insinhala")];
+    char uniname2ctype_pool_str347[sizeof("shavian")];
+    char uniname2ctype_pool_str350[sizeof("inosmanya")];
+    char uniname2ctype_pool_str353[sizeof("inlatinextendedadditional")];
+    char uniname2ctype_pool_str359[sizeof("osma")];
+    char uniname2ctype_pool_str362[sizeof("ll")];
+    char uniname2ctype_pool_str363[sizeof("thai")];
+    char uniname2ctype_pool_str366[sizeof("math")];
+    char uniname2ctype_pool_str372[sizeof("thaa")];
+    char uniname2ctype_pool_str374[sizeof("inenclosedalphanumericsupplement")];
+    char uniname2ctype_pool_str375[sizeof("ethi")];
+    char uniname2ctype_pool_str376[sizeof("connectorpunctuation")];
+    char uniname2ctype_pool_str380[sizeof("inlowsurrogates")];
+    char uniname2ctype_pool_str382[sizeof("insinhalaarchaicnumbers")];
+    char uniname2ctype_pool_str386[sizeof("taitham")];
+    char uniname2ctype_pool_str388[sizeof("thaana")];
+    char uniname2ctype_pool_str390[sizeof("lineara")];
+    char uniname2ctype_pool_str392[sizeof("di")];
+    char uniname2ctype_pool_str401[sizeof("idc")];
+    char uniname2ctype_pool_str405[sizeof("meroiticcursive")];
+    char uniname2ctype_pool_str407[sizeof("mand")];
+    char uniname2ctype_pool_str408[sizeof("inmodi")];
+    char uniname2ctype_pool_str410[sizeof("inmandaic")];
+    char uniname2ctype_pool_str412[sizeof("cwl")];
+    char uniname2ctype_pool_str414[sizeof("asciihexdigit")];
+    char uniname2ctype_pool_str415[sizeof("dia")];
+    char uniname2ctype_pool_str418[sizeof("terminalpunctuation")];
+    char uniname2ctype_pool_str419[sizeof("mend")];
+    char uniname2ctype_pool_str423[sizeof("sind")];
+    char uniname2ctype_pool_str425[sizeof("wara")];
+    char uniname2ctype_pool_str433[sizeof("inwarangciti")];
+    char uniname2ctype_pool_str439[sizeof("inideographicdescriptioncharacters")];
+    char uniname2ctype_pool_str441[sizeof("inemoticons")];
+    char uniname2ctype_pool_str453[sizeof("ids")];
+    char uniname2ctype_pool_str456[sizeof("insundanese")];
+    char uniname2ctype_pool_str466[sizeof("pi")];
+    char uniname2ctype_pool_str468[sizeof("indominotiles")];
+    char uniname2ctype_pool_str470[sizeof("pc")];
+    char uniname2ctype_pool_str476[sizeof("loe")];
+    char uniname2ctype_pool_str477[sizeof("titlecaseletter")];
+    char uniname2ctype_pool_str485[sizeof("inopticalcharacterrecognition")];
+    char uniname2ctype_pool_str487[sizeof("idst")];
+    char uniname2ctype_pool_str489[sizeof("shaw")];
+    char uniname2ctype_pool_str490[sizeof("cwcf")];
+    char uniname2ctype_pool_str493[sizeof("idcontinue")];
+    char uniname2ctype_pool_str502[sizeof("inphaistosdisc")];
+    char uniname2ctype_pool_str508[sizeof("pe")];
+    char uniname2ctype_pool_str518[sizeof("indeseret")];
+    char uniname2ctype_pool_str519[sizeof("inspacingmodifierletters")];
+    char uniname2ctype_pool_str520[sizeof("inlydian")];
+    char uniname2ctype_pool_str522[sizeof("ps")];
+    char uniname2ctype_pool_str530[sizeof("hira")];
+    char uniname2ctype_pool_str536[sizeof("whitespace")];
+    char uniname2ctype_pool_str540[sizeof("inscriptionalparthian")];
+    char uniname2ctype_pool_str544[sizeof("cher")];
+    char uniname2ctype_pool_str545[sizeof("inmathematicalalphanumericsymbols")];
+    char uniname2ctype_pool_str546[sizeof("incoptic")];
+    char uniname2ctype_pool_str550[sizeof("inhiragana")];
+    char uniname2ctype_pool_str554[sizeof("inenclosedcjklettersandmonths")];
+    char uniname2ctype_pool_str556[sizeof("space")];
+    char uniname2ctype_pool_str570[sizeof("oriya")];
+    char uniname2ctype_pool_str571[sizeof("mero")];
+    char uniname2ctype_pool_str573[sizeof("mahj")];
+    char uniname2ctype_pool_str582[sizeof("tirh")];
+    char uniname2ctype_pool_str584[sizeof("sora")];
+    char uniname2ctype_pool_str587[sizeof("inscriptionalpahlavi")];
+    char uniname2ctype_pool_str593[sizeof("inarrows")];
+    char uniname2ctype_pool_str594[sizeof("mahajani")];
+    char uniname2ctype_pool_str596[sizeof("joinc")];
+    char uniname2ctype_pool_str597[sizeof("incopticepactnumbers")];
+    char uniname2ctype_pool_str598[sizeof("hano")];
+    char uniname2ctype_pool_str600[sizeof("palm")];
+    char uniname2ctype_pool_str601[sizeof("intirhuta")];
+    char uniname2ctype_pool_str603[sizeof("patws")];
+    char uniname2ctype_pool_str604[sizeof("inolchiki")];
+    char uniname2ctype_pool_str608[sizeof("inlepcha")];
+    char uniname2ctype_pool_str609[sizeof("no")];
+    char uniname2ctype_pool_str611[sizeof("lepc")];
+    char uniname2ctype_pool_str612[sizeof("inogham")];
+    char uniname2ctype_pool_str614[sizeof("co")];
+    char uniname2ctype_pool_str617[sizeof("innko")];
+    char uniname2ctype_pool_str620[sizeof("alpha")];
+    char uniname2ctype_pool_str622[sizeof("psalterpahlavi")];
+    char uniname2ctype_pool_str623[sizeof("inmro")];
+    char uniname2ctype_pool_str624[sizeof("inpalmyrene")];
+    char uniname2ctype_pool_str627[sizeof("common")];
+    char uniname2ctype_pool_str630[sizeof("cf")];
+    char uniname2ctype_pool_str637[sizeof("inmiao")];
+    char uniname2ctype_pool_str640[sizeof("so")];
+    char uniname2ctype_pool_str650[sizeof("diacritic")];
+    char uniname2ctype_pool_str658[sizeof("insundanesesupplement")];
+    char uniname2ctype_pool_str672[sizeof("intifinagh")];
+    char uniname2ctype_pool_str679[sizeof("tifinagh")];
+    char uniname2ctype_pool_str696[sizeof("odi")];
+    char uniname2ctype_pool_str699[sizeof("oidc")];
+    char uniname2ctype_pool_str700[sizeof("modi")];
+    char uniname2ctype_pool_str703[sizeof("decimalnumber")];
+    char uniname2ctype_pool_str705[sizeof("letter")];
+    char uniname2ctype_pool_str708[sizeof("dash")];
+    char uniname2ctype_pool_str709[sizeof("insylotinagri")];
+    char uniname2ctype_pool_str711[sizeof("inolditalic")];
+    char uniname2ctype_pool_str713[sizeof("wspace")];
+    char uniname2ctype_pool_str715[sizeof("dsrt")];
+    char uniname2ctype_pool_str718[sizeof("ideo")];
+    char uniname2ctype_pool_str722[sizeof("siddham")];
+    char uniname2ctype_pool_str724[sizeof("perm")];
+    char uniname2ctype_pool_str725[sizeof("oids")];
+    char uniname2ctype_pool_str727[sizeof("inmahjongtiles")];
+    char uniname2ctype_pool_str728[sizeof("lo")];
+    char uniname2ctype_pool_str730[sizeof("lineseparator")];
+    char uniname2ctype_pool_str731[sizeof("imperialaramaic")];
+    char uniname2ctype_pool_str735[sizeof("idstart")];
+    char uniname2ctype_pool_str736[sizeof("inlao")];
+    char uniname2ctype_pool_str737[sizeof("sharada")];
+    char uniname2ctype_pool_str742[sizeof("lao")];
+    char uniname2ctype_pool_str743[sizeof("laoo")];
+    char uniname2ctype_pool_str744[sizeof("mongolian")];
+    char uniname2ctype_pool_str745[sizeof("oalpha")];
+    char uniname2ctype_pool_str749[sizeof("inimperialaramaic")];
+    char uniname2ctype_pool_str753[sizeof("nchar")];
+    char uniname2ctype_pool_str758[sizeof("inlatin1supplement")];
+    char uniname2ctype_pool_str761[sizeof("prti")];
+    char uniname2ctype_pool_str763[sizeof("cprt")];
+    char uniname2ctype_pool_str767[sizeof("nd")];
+    char uniname2ctype_pool_str768[sizeof("deseret")];
+    char uniname2ctype_pool_str772[sizeof("inoldturkic")];
+    char uniname2ctype_pool_str773[sizeof("radical")];
+    char uniname2ctype_pool_str777[sizeof("canadianaboriginal")];
+    char uniname2ctype_pool_str779[sizeof("inmodifiertoneletters")];
+    char uniname2ctype_pool_str783[sizeof("incaucasianalbanian")];
+    char uniname2ctype_pool_str787[sizeof("coptic")];
+    char uniname2ctype_pool_str796[sizeof("casedletter")];
+    char uniname2ctype_pool_str798[sizeof("sd")];
+    char uniname2ctype_pool_str803[sizeof("inphoenician")];
+    char uniname2ctype_pool_str804[sizeof("sidd")];
+    char uniname2ctype_pool_str805[sizeof("privateuse")];
+    char uniname2ctype_pool_str813[sizeof("sundanese")];
+    char uniname2ctype_pool_str815[sizeof("inancientgreekmusicalnotation")];
+    char uniname2ctype_pool_str817[sizeof("insiddham")];
+    char uniname2ctype_pool_str820[sizeof("cased")];
+    char uniname2ctype_pool_str827[sizeof("print")];
+    char uniname2ctype_pool_str830[sizeof("ininscriptionalparthian")];
+    char uniname2ctype_pool_str832[sizeof("ininscriptionalpahlavi")];
+    char uniname2ctype_pool_str834[sizeof("copt")];
+    char uniname2ctype_pool_str838[sizeof("inancientgreeknumbers")];
+    char uniname2ctype_pool_str845[sizeof("saurashtra")];
+    char uniname2ctype_pool_str848[sizeof("mro")];
+    char uniname2ctype_pool_str849[sizeof("mroo")];
+    char uniname2ctype_pool_str850[sizeof("inalphabeticpresentationforms")];
+    char uniname2ctype_pool_str858[sizeof("lowercase")];
+    char uniname2ctype_pool_str861[sizeof("phli")];
+    char uniname2ctype_pool_str864[sizeof("patternwhitespace")];
+    char uniname2ctype_pool_str866[sizeof("inenclosedideographicsupplement")];
+    char uniname2ctype_pool_str869[sizeof("spaceseparator")];
+    char uniname2ctype_pool_str871[sizeof("inmathematicaloperators")];
+    char uniname2ctype_pool_str882[sizeof("omath")];
+    char uniname2ctype_pool_str892[sizeof("lisu")];
+    char uniname2ctype_pool_str895[sizeof("inpsalterpahlavi")];
+    char uniname2ctype_pool_str898[sizeof("olditalic")];
+    char uniname2ctype_pool_str905[sizeof("hanunoo")];
+    char uniname2ctype_pool_str909[sizeof("inherited")];
+    char uniname2ctype_pool_str910[sizeof("lepcha")];
+    char uniname2ctype_pool_str913[sizeof("p")];
+    char uniname2ctype_pool_str916[sizeof("inmongolian")];
+    char uniname2ctype_pool_str922[sizeof("zp")];
+    char uniname2ctype_pool_str923[sizeof("finalpunctuation")];
+    char uniname2ctype_pool_str925[sizeof("otheridcontinue")];
+    char uniname2ctype_pool_str927[sizeof("shrd")];
+    char uniname2ctype_pool_str932[sizeof("ingrantha")];
+    char uniname2ctype_pool_str934[sizeof("talu")];
+    char uniname2ctype_pool_str936[sizeof("otheralphabetic")];
+    char uniname2ctype_pool_str938[sizeof("noncharactercodepoint")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    char uniname2ctype_pool_str939[sizeof("age=1.1")];
+    char uniname2ctype_pool_str940[sizeof("age=2.1")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    char uniname2ctype_pool_str941[sizeof("closepunctuation")];
+    char uniname2ctype_pool_str943[sizeof("letternumber")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    char uniname2ctype_pool_str944[sizeof("age=6.1")];
+    char uniname2ctype_pool_str945[sizeof("age=6.2")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    char uniname2ctype_pool_str946[sizeof("telu")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    char uniname2ctype_pool_str947[sizeof("age=3.1")];
+    char uniname2ctype_pool_str948[sizeof("age=3.2")];
+    char uniname2ctype_pool_str949[sizeof("age=5.1")];
+    char uniname2ctype_pool_str950[sizeof("age=5.2")];
+    char uniname2ctype_pool_str951[sizeof("age=2.0")];
+    char uniname2ctype_pool_str952[sizeof("age=6.3")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    char uniname2ctype_pool_str953[sizeof("inshorthandformatcontrols")];
+    char uniname2ctype_pool_str954[sizeof("inoldnortharabian")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    char uniname2ctype_pool_str955[sizeof("age=6.0")];
+    char uniname2ctype_pool_str956[sizeof("age=4.1")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    char uniname2ctype_pool_str957[sizeof("ingeneralpunctuation")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    char uniname2ctype_pool_str958[sizeof("age=3.0")];
+    char uniname2ctype_pool_str959[sizeof("age=7.0")];
+    char uniname2ctype_pool_str960[sizeof("age=5.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    char uniname2ctype_pool_str962[sizeof("innabataean")];
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    char uniname2ctype_pool_str967[sizeof("age=4.0")];
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    char uniname2ctype_pool_str970[sizeof("bamum")];
+    char uniname2ctype_pool_str972[sizeof("control")];
+    char uniname2ctype_pool_str974[sizeof("induployan")];
+    char uniname2ctype_pool_str975[sizeof("inlatinextendedd")];
+    char uniname2ctype_pool_str976[sizeof("inarabic")];
+    char uniname2ctype_pool_str982[sizeof("runic")];
+    char uniname2ctype_pool_str984[sizeof("inelbasan")];
+    char uniname2ctype_pool_str985[sizeof("inoldsoutharabian")];
+    char uniname2ctype_pool_str986[sizeof("inbasiclatin")];
+    char uniname2ctype_pool_str995[sizeof("format")];
+    char uniname2ctype_pool_str996[sizeof("innumberforms")];
+    char uniname2ctype_pool_str998[sizeof("inugaritic")];
+    char uniname2ctype_pool_str999[sizeof("separator")];
+    char uniname2ctype_pool_str1000[sizeof("idsbinaryoperator")];
+    char uniname2ctype_pool_str1004[sizeof("tagbanwa")];
+    char uniname2ctype_pool_str1012[sizeof("bass")];
+    char uniname2ctype_pool_str1013[sizeof("saur")];
+    char uniname2ctype_pool_str1014[sizeof("nbat")];
+    char uniname2ctype_pool_str1017[sizeof("intaixuanjingsymbols")];
+    char uniname2ctype_pool_str1019[sizeof("joincontrol")];
+    char uniname2ctype_pool_str1023[sizeof("otheridstart")];
+    char uniname2ctype_pool_str1027[sizeof("inbyzantinemusicalsymbols")];
+    char uniname2ctype_pool_str1031[sizeof("intags")];
+    char uniname2ctype_pool_str1033[sizeof("nabataean")];
+    char uniname2ctype_pool_str1034[sizeof("insuperscriptsandsubscripts")];
+    char uniname2ctype_pool_str1036[sizeof("intibetan")];
+    char uniname2ctype_pool_str1039[sizeof("insaurashtra")];
+    char uniname2ctype_pool_str1040[sizeof("othersymbol")];
+    char uniname2ctype_pool_str1041[sizeof("ext")];
+    char uniname2ctype_pool_str1046[sizeof("inarabicpresentationformsa")];
+    char uniname2ctype_pool_str1048[sizeof("inmiscellaneousmathematicalsymbolsb")];
+    char uniname2ctype_pool_str1049[sizeof("otherlowercase")];
+    char uniname2ctype_pool_str1052[sizeof("phoenician")];
+    char uniname2ctype_pool_str1055[sizeof("lower")];
+    char uniname2ctype_pool_str1060[sizeof("linb")];
+    char uniname2ctype_pool_str1064[sizeof("po")];
+    char uniname2ctype_pool_str1065[sizeof("inmyanmarextendedb")];
+    char uniname2ctype_pool_str1066[sizeof("limb")];
+    char uniname2ctype_pool_str1068[sizeof("inbraillepatterns")];
+    char uniname2ctype_pool_str1069[sizeof("tibt")];
+    char uniname2ctype_pool_str1070[sizeof("cuneiform")];
+    char uniname2ctype_pool_str1072[sizeof("bali")];
+    char uniname2ctype_pool_str1073[sizeof("oldpersian")];
+    char uniname2ctype_pool_str1077[sizeof("oldpermic")];
+    char uniname2ctype_pool_str1080[sizeof("pf")];
+    char uniname2ctype_pool_str1084[sizeof("word")];
+    char uniname2ctype_pool_str1086[sizeof("tibetan")];
+    char uniname2ctype_pool_str1089[sizeof("incyrillicsupplement")];
+    char uniname2ctype_pool_str1093[sizeof("elba")];
+    char uniname2ctype_pool_str1094[sizeof("insupplementalmathematicaloperators")];
+    char uniname2ctype_pool_str1095[sizeof("inbalinese")];
+    char uniname2ctype_pool_str1101[sizeof("bengali")];
+    char uniname2ctype_pool_str1104[sizeof("caseignorable")];
+    char uniname2ctype_pool_str1107[sizeof("incountingrodnumerals")];
+    char uniname2ctype_pool_str1114[sizeof("other")];
+    char uniname2ctype_pool_str1118[sizeof("tirhuta")];
+    char uniname2ctype_pool_str1121[sizeof("othernumber")];
+    char uniname2ctype_pool_str1123[sizeof("balinese")];
+    char uniname2ctype_pool_str1129[sizeof("elbasan")];
+    char uniname2ctype_pool_str1134[sizeof("inunifiedcanadianaboriginalsyllabics")];
+    char uniname2ctype_pool_str1136[sizeof("lowercaseletter")];
+    char uniname2ctype_pool_str1140[sizeof("ethiopic")];
+    char uniname2ctype_pool_str1141[sizeof("gran")];
+    char uniname2ctype_pool_str1149[sizeof("ingurmukhi")];
+    char uniname2ctype_pool_str1151[sizeof("sund")];
+    char uniname2ctype_pool_str1153[sizeof("inethiopicsupplement")];
+    char uniname2ctype_pool_str1160[sizeof("inoldpersian")];
+    char uniname2ctype_pool_str1163[sizeof("inoldpermic")];
+    char uniname2ctype_pool_str1170[sizeof("othermath")];
+    char uniname2ctype_pool_str1174[sizeof("unassigned")];
+    char uniname2ctype_pool_str1180[sizeof("hmng")];
+    char uniname2ctype_pool_str1181[sizeof("narb")];
+    char uniname2ctype_pool_str1184[sizeof("brai")];
+    char uniname2ctype_pool_str1186[sizeof("hang")];
+    char uniname2ctype_pool_str1187[sizeof("insorasompeng")];
+    char uniname2ctype_pool_str1193[sizeof("arab")];
+    char uniname2ctype_pool_str1194[sizeof("plrd")];
+    char uniname2ctype_pool_str1195[sizeof("ingujarati")];
+    char uniname2ctype_pool_str1197[sizeof("brahmi")];
+    char uniname2ctype_pool_str1201[sizeof("runr")];
+    char uniname2ctype_pool_str1202[sizeof("ahex")];
+    char uniname2ctype_pool_str1206[sizeof("mong")];
+    char uniname2ctype_pool_str1211[sizeof("pauc")];
+    char uniname2ctype_pool_str1212[sizeof("sarb")];
+    char uniname2ctype_pool_str1218[sizeof("ogam")];
+    char uniname2ctype_pool_str1221[sizeof("olower")];
+    char uniname2ctype_pool_str1222[sizeof("pd")];
+    char uniname2ctype_pool_str1235[sizeof("number")];
+    char uniname2ctype_pool_str1238[sizeof("inbrahmi")];
+    char uniname2ctype_pool_str1240[sizeof("otherletter")];
+    char uniname2ctype_pool_str1252[sizeof("ingothic")];
+    char uniname2ctype_pool_str1254[sizeof("phagspa")];
+    char uniname2ctype_pool_str1262[sizeof("inletterlikesymbols")];
+    char uniname2ctype_pool_str1265[sizeof("yi")];
+    char uniname2ctype_pool_str1269[sizeof("hangul")];
+    char uniname2ctype_pool_str1271[sizeof("yiii")];
+    char uniname2ctype_pool_str1272[sizeof("tfng")];
+    char uniname2ctype_pool_str1273[sizeof("insupplementalarrowsc")];
+    char uniname2ctype_pool_str1277[sizeof("ingreekandcoptic")];
+    char uniname2ctype_pool_str1279[sizeof("xidc")];
+    char uniname2ctype_pool_str1280[sizeof("insupplementalarrowsa")];
+    char uniname2ctype_pool_str1281[sizeof("gothic")];
+    char uniname2ctype_pool_str1283[sizeof("grext")];
+    char uniname2ctype_pool_str1285[sizeof("incombininghalfmarks")];
+    char uniname2ctype_pool_str1286[sizeof("deprecated")];
+    char uniname2ctype_pool_str1287[sizeof("inbassavah")];
+    char uniname2ctype_pool_str1305[sizeof("xids")];
+    char uniname2ctype_pool_str1308[sizeof("linearb")];
+    char uniname2ctype_pool_str1312[sizeof("ingeometricshapes")];
+    char uniname2ctype_pool_str1313[sizeof("phlp")];
+    char uniname2ctype_pool_str1314[sizeof("warangciti")];
+    char uniname2ctype_pool_str1317[sizeof("inblockelements")];
+    char uniname2ctype_pool_str1318[sizeof("modifierletter")];
+    char uniname2ctype_pool_str1321[sizeof("indingbats")];
+    char uniname2ctype_pool_str1322[sizeof("dep")];
+    char uniname2ctype_pool_str1324[sizeof("punct")];
+    char uniname2ctype_pool_str1327[sizeof("inhanunoo")];
+    char uniname2ctype_pool_str1334[sizeof("bidic")];
+    char uniname2ctype_pool_str1344[sizeof("ingreekextended")];
+    char uniname2ctype_pool_str1353[sizeof("idsb")];
+    char uniname2ctype_pool_str1359[sizeof("assigned")];
+    char uniname2ctype_pool_str1364[sizeof("otherpunctuation")];
+    char uniname2ctype_pool_str1368[sizeof("inhangulsyllables")];
+    char uniname2ctype_pool_str1373[sizeof("inarabicmathematicalalphabeticsymbols")];
+    char uniname2ctype_pool_str1385[sizeof("inornamentaldingbats")];
+    char uniname2ctype_pool_str1387[sizeof("inphagspa")];
+    char uniname2ctype_pool_str1389[sizeof("lyci")];
+    char uniname2ctype_pool_str1393[sizeof("mlym")];
+    char uniname2ctype_pool_str1399[sizeof("inarabicextendeda")];
+    char uniname2ctype_pool_str1400[sizeof("rjng")];
+    char uniname2ctype_pool_str1402[sizeof("lycian")];
+    char uniname2ctype_pool_str1403[sizeof("inalchemicalsymbols")];
+    char uniname2ctype_pool_str1409[sizeof("xdigit")];
+    char uniname2ctype_pool_str1412[sizeof("digit")];
+    char uniname2ctype_pool_str1420[sizeof("xidstart")];
+    char uniname2ctype_pool_str1421[sizeof("inrejang")];
+    char uniname2ctype_pool_str1424[sizeof("malayalam")];
+    char uniname2ctype_pool_str1425[sizeof("idstrinaryoperator")];
+    char uniname2ctype_pool_str1429[sizeof("invai")];
+    char uniname2ctype_pool_str1435[sizeof("vai")];
+    char uniname2ctype_pool_str1436[sizeof("vaii")];
+    char uniname2ctype_pool_str1438[sizeof("hiragana")];
+    char uniname2ctype_pool_str1442[sizeof("ingeorgian")];
+    char uniname2ctype_pool_str1448[sizeof("braille")];
+    char uniname2ctype_pool_str1455[sizeof("geor")];
+    char uniname2ctype_pool_str1457[sizeof("brah")];
+    char uniname2ctype_pool_str1463[sizeof("glagolitic")];
+    char uniname2ctype_pool_str1465[sizeof("inkannada")];
+    char uniname2ctype_pool_str1466[sizeof("cakm")];
+    char uniname2ctype_pool_str1467[sizeof("kana")];
+    char uniname2ctype_pool_str1469[sizeof("hebr")];
+    char uniname2ctype_pool_str1471[sizeof("inshavian")];
+    char uniname2ctype_pool_str1477[sizeof("vs")];
+    char uniname2ctype_pool_str1481[sizeof("inchakma")];
+    char uniname2ctype_pool_str1490[sizeof("ogham")];
+    char uniname2ctype_pool_str1491[sizeof("sylotinagri")];
+    char uniname2ctype_pool_str1492[sizeof("inunifiedcanadianaboriginalsyllabicsextended")];
+    char uniname2ctype_pool_str1495[sizeof("inmeroitichieroglyphs")];
+    char uniname2ctype_pool_str1498[sizeof("grantha")];
+    char uniname2ctype_pool_str1500[sizeof("graphemebase")];
+    char uniname2ctype_pool_str1502[sizeof("mathsymbol")];
+    char uniname2ctype_pool_str1505[sizeof("mymr")];
+    char uniname2ctype_pool_str1513[sizeof("insupplementaryprivateuseareaa")];
+    char uniname2ctype_pool_str1514[sizeof("mendekikakui")];
+    char uniname2ctype_pool_str1516[sizeof("incjkcompatibilityforms")];
+    char uniname2ctype_pool_str1518[sizeof("inhalfwidthandfullwidthforms")];
+    char uniname2ctype_pool_str1521[sizeof("incjkcompatibilityideographs")];
+    char uniname2ctype_pool_str1522[sizeof("inkaithi")];
+    char uniname2ctype_pool_str1525[sizeof("avst")];
+    char uniname2ctype_pool_str1526[sizeof("inarabicsupplement")];
+    char uniname2ctype_pool_str1527[sizeof("takri")];
+    char uniname2ctype_pool_str1529[sizeof("syrc")];
+    char uniname2ctype_pool_str1533[sizeof("meeteimayek")];
+    char uniname2ctype_pool_str1534[sizeof("myanmar")];
+    char uniname2ctype_pool_str1535[sizeof("avestan")];
+    char uniname2ctype_pool_str1536[sizeof("inhanguljamoextendeda")];
+    char uniname2ctype_pool_str1540[sizeof("goth")];
+    char uniname2ctype_pool_str1542[sizeof("inkatakana")];
+    char uniname2ctype_pool_str1544[sizeof("incyrillicextendeda")];
+    char uniname2ctype_pool_str1549[sizeof("alphabetic")];
+    char uniname2ctype_pool_str1550[sizeof("syriac")];
+    char uniname2ctype_pool_str1551[sizeof("ideographic")];
+    char uniname2ctype_pool_str1555[sizeof("incjkstrokes")];
+    char uniname2ctype_pool_str1557[sizeof("inlinearbsyllabary")];
+    char uniname2ctype_pool_str1558[sizeof("tavt")];
+    char uniname2ctype_pool_str1559[sizeof("intaiviet")];
+    char uniname2ctype_pool_str1564[sizeof("incjkcompatibilityideographssupplement")];
+    char uniname2ctype_pool_str1576[sizeof("inmeeteimayek")];
+    char uniname2ctype_pool_str1577[sizeof("kali")];
+    char uniname2ctype_pool_str1581[sizeof("inyiradicals")];
+    char uniname2ctype_pool_str1586[sizeof("lu")];
+    char uniname2ctype_pool_str1587[sizeof("inoriya")];
+    char uniname2ctype_pool_str1590[sizeof("hebrew")];
+    char uniname2ctype_pool_str1596[sizeof("extender")];
+    char uniname2ctype_pool_str1598[sizeof("inhighprivateusesurrogates")];
+    char uniname2ctype_pool_str1600[sizeof("limbu")];
+    char uniname2ctype_pool_str1606[sizeof("inbuhid")];
+    char uniname2ctype_pool_str1608[sizeof("inethiopicextendeda")];
+    char uniname2ctype_pool_str1609[sizeof("xidcontinue")];
+    char uniname2ctype_pool_str1611[sizeof("inyijinghexagramsymbols")];
+    char uniname2ctype_pool_str1612[sizeof("logicalorderexception")];
+    char uniname2ctype_pool_str1616[sizeof("inhebrew")];
+    char uniname2ctype_pool_str1617[sizeof("cyrl")];
+    char uniname2ctype_pool_str1618[sizeof("osmanya")];
+    char uniname2ctype_pool_str1621[sizeof("phnx")];
+    char uniname2ctype_pool_str1622[sizeof("incombiningdiacriticalmarks")];
+    char uniname2ctype_pool_str1626[sizeof("inkanasupplement")];
+    char uniname2ctype_pool_str1627[sizeof("inlisu")];
+    char uniname2ctype_pool_str1628[sizeof("changeswhencasemapped")];
+    char uniname2ctype_pool_str1632[sizeof("incombiningdiacriticalmarksforsymbols")];
+    char uniname2ctype_pool_str1636[sizeof("cwu")];
+    char uniname2ctype_pool_str1641[sizeof("phag")];
+    char uniname2ctype_pool_str1645[sizeof("insmallformvariants")];
+    char uniname2ctype_pool_str1656[sizeof("inpahawhhmong")];
+    char uniname2ctype_pool_str1661[sizeof("otheruppercase")];
+    char uniname2ctype_pool_str1662[sizeof("intelugu")];
+    char uniname2ctype_pool_str1665[sizeof("incombiningdiacriticalmarkssupplement")];
+    char uniname2ctype_pool_str1670[sizeof("ingeometricshapesextended")];
+    char uniname2ctype_pool_str1671[sizeof("xpeo")];
+    char uniname2ctype_pool_str1687[sizeof("bamu")];
+    char uniname2ctype_pool_str1689[sizeof("inbamum")];
+    char uniname2ctype_pool_str1692[sizeof("mark")];
+    char uniname2ctype_pool_str1694[sizeof("dupl")];
+    char uniname2ctype_pool_str1695[sizeof("graph")];
+    char uniname2ctype_pool_str1696[sizeof("dashpunctuation")];
+    char uniname2ctype_pool_str1700[sizeof("patternsyntax")];
+    char uniname2ctype_pool_str1705[sizeof("changeswhentitlecased")];
+    char uniname2ctype_pool_str1706[sizeof("inkharoshthi")];
+    char uniname2ctype_pool_str1712[sizeof("inkhmer")];
+    char uniname2ctype_pool_str1713[sizeof("java")];
+    char uniname2ctype_pool_str1714[sizeof("sylo")];
+    char uniname2ctype_pool_str1719[sizeof("ugaritic")];
+    char uniname2ctype_pool_str1722[sizeof("otherdefaultignorablecodepoint")];
+    char uniname2ctype_pool_str1723[sizeof("softdotted")];
+    char uniname2ctype_pool_str1729[sizeof("uideo")];
+    char uniname2ctype_pool_str1732[sizeof("inphoneticextensions")];
+    char uniname2ctype_pool_str1736[sizeof("injavanese")];
+    char uniname2ctype_pool_str1742[sizeof("invariationselectors")];
+    char uniname2ctype_pool_str1744[sizeof("kaithi")];
+    char uniname2ctype_pool_str1747[sizeof("cyrillic")];
+    char uniname2ctype_pool_str1749[sizeof("intakri")];
+    char uniname2ctype_pool_str1750[sizeof("takr")];
+    char uniname2ctype_pool_str1755[sizeof("javanese")];
+    char uniname2ctype_pool_str1757[sizeof("bidicontrol")];
+    char uniname2ctype_pool_str1758[sizeof("caucasianalbanian")];
+    char uniname2ctype_pool_str1765[sizeof("lydi")];
+    char uniname2ctype_pool_str1772[sizeof("insupplementalpunctuation")];
+    char uniname2ctype_pool_str1775[sizeof("inphoneticextensionssupplement")];
+    char uniname2ctype_pool_str1778[sizeof("lydian")];
+    char uniname2ctype_pool_str1784[sizeof("oldturkic")];
+    char uniname2ctype_pool_str1785[sizeof("invariationselectorssupplement")];
+    char uniname2ctype_pool_str1786[sizeof("kthi")];
+    char uniname2ctype_pool_str1792[sizeof("inhanguljamo")];
+    char uniname2ctype_pool_str1797[sizeof("patsyn")];
+    char uniname2ctype_pool_str1802[sizeof("inlimbu")];
+    char uniname2ctype_pool_str1804[sizeof("sorasompeng")];
+    char uniname2ctype_pool_str1807[sizeof("orya")];
+    char uniname2ctype_pool_str1822[sizeof("inkhmersymbols")];
+    char uniname2ctype_pool_str1824[sizeof("inglagolitic")];
+    char uniname2ctype_pool_str1831[sizeof("indevanagari")];
+    char uniname2ctype_pool_str1835[sizeof("deva")];
+    char uniname2ctype_pool_str1836[sizeof("knda")];
+    char uniname2ctype_pool_str1841[sizeof("inbengali")];
+    char uniname2ctype_pool_str1843[sizeof("symbol")];
+    char uniname2ctype_pool_str1846[sizeof("devanagari")];
+    char uniname2ctype_pool_str1849[sizeof("inmendekikakui")];
+    char uniname2ctype_pool_str1852[sizeof("beng")];
+    char uniname2ctype_pool_str1853[sizeof("invedicextensions")];
+    char uniname2ctype_pool_str1859[sizeof("graphemeextend")];
+    char uniname2ctype_pool_str1865[sizeof("kannada")];
+    char uniname2ctype_pool_str1866[sizeof("inbuginese")];
+    char uniname2ctype_pool_str1869[sizeof("olck")];
+    char uniname2ctype_pool_str1871[sizeof("meroitichieroglyphs")];
+    char uniname2ctype_pool_str1872[sizeof("ugar")];
+    char uniname2ctype_pool_str1874[sizeof("intagalog")];
+    char uniname2ctype_pool_str1878[sizeof("inbamumsupplement")];
+    char uniname2ctype_pool_str1880[sizeof("olchiki")];
+    char uniname2ctype_pool_str1899[sizeof("incurrencysymbols")];
+    char uniname2ctype_pool_str1904[sizeof("tagb")];
+    char uniname2ctype_pool_str1912[sizeof("inaegeannumbers")];
+    char uniname2ctype_pool_str1915[sizeof("intagbanwa")];
+    char uniname2ctype_pool_str1916[sizeof("uppercase")];
+    char uniname2ctype_pool_str1917[sizeof("defaultignorablecodepoint")];
+    char uniname2ctype_pool_str1919[sizeof("glag")];
+    char uniname2ctype_pool_str1921[sizeof("inkatakanaphoneticextensions")];
+    char uniname2ctype_pool_str1932[sizeof("changeswhencasefolded")];
+    char uniname2ctype_pool_str1942[sizeof("inpaucinhau")];
+    char uniname2ctype_pool_str1943[sizeof("inprivateusearea")];
+    char uniname2ctype_pool_str1947[sizeof("paucinhau")];
+    char uniname2ctype_pool_str1953[sizeof("spacingmark")];
+    char uniname2ctype_pool_str1956[sizeof("khmr")];
+    char uniname2ctype_pool_str1962[sizeof("khar")];
+    char uniname2ctype_pool_str1964[sizeof("inarabicpresentationformsb")];
+    char uniname2ctype_pool_str1967[sizeof("changeswhenlowercased")];
+    char uniname2ctype_pool_str1971[sizeof("tglg")];
+    char uniname2ctype_pool_str1976[sizeof("inethiopicextended")];
+    char uniname2ctype_pool_str1980[sizeof("incombiningdiacriticalmarksextended")];
+    char uniname2ctype_pool_str1986[sizeof("oupper")];
+    char uniname2ctype_pool_str1994[sizeof("incjksymbolsandpunctuation")];
+    char uniname2ctype_pool_str1997[sizeof("bopo")];
+    char uniname2ctype_pool_str1998[sizeof("punctuation")];
+    char uniname2ctype_pool_str2002[sizeof("combiningmark")];
+    char uniname2ctype_pool_str2007[sizeof("inplayingcards")];
+    char uniname2ctype_pool_str2008[sizeof("inbopomofo")];
+    char uniname2ctype_pool_str2021[sizeof("hyphen")];
+    char uniname2ctype_pool_str2028[sizeof("inkhojki")];
+    char uniname2ctype_pool_str2046[sizeof("nko")];
+    char uniname2ctype_pool_str2047[sizeof("nkoo")];
+    char uniname2ctype_pool_str2048[sizeof("enclosingmark")];
+    char uniname2ctype_pool_str2053[sizeof("openpunctuation")];
+    char uniname2ctype_pool_str2061[sizeof("currencysymbol")];
+    char uniname2ctype_pool_str2063[sizeof("inverticalforms")];
+    char uniname2ctype_pool_str2071[sizeof("hex")];
+    char uniname2ctype_pool_str2072[sizeof("modifiersymbol")];
+    char uniname2ctype_pool_str2073[sizeof("inlatinextendedb")];
+    char uniname2ctype_pool_str2075[sizeof("kharoshthi")];
+    char uniname2ctype_pool_str2080[sizeof("cherokee")];
+    char uniname2ctype_pool_str2088[sizeof("pahawhhmong")];
+    char uniname2ctype_pool_str2096[sizeof("cypriot")];
+    char uniname2ctype_pool_str2105[sizeof("incypriotsyllabary")];
+    char uniname2ctype_pool_str2110[sizeof("palmyrene")];
+    char uniname2ctype_pool_str2113[sizeof("upper")];
+    char uniname2ctype_pool_str2116[sizeof("aghb")];
+    char uniname2ctype_pool_str2123[sizeof("georgian")];
+    char uniname2ctype_pool_str2131[sizeof("gujr")];
+    char uniname2ctype_pool_str2142[sizeof("grbase")];
+    char uniname2ctype_pool_str2152[sizeof("gujarati")];
+    char uniname2ctype_pool_str2153[sizeof("hexdigit")];
+    char uniname2ctype_pool_str2189[sizeof("khmer")];
+    char uniname2ctype_pool_str2194[sizeof("uppercaseletter")];
+    char uniname2ctype_pool_str2198[sizeof("insupplementalarrowsb")];
+    char uniname2ctype_pool_str2224[sizeof("surrogate")];
+    char uniname2ctype_pool_str2227[sizeof("unifiedideograph")];
+    char uniname2ctype_pool_str2237[sizeof("nonspacingmark")];
+    char uniname2ctype_pool_str2241[sizeof("othergraphemeextend")];
+    char uniname2ctype_pool_str2242[sizeof("indevanagariextended")];
+    char uniname2ctype_pool_str2252[sizeof("orkh")];
+    char uniname2ctype_pool_str2273[sizeof("ingeorgiansupplement")];
+    char uniname2ctype_pool_str2287[sizeof("oldnortharabian")];
+    char uniname2ctype_pool_str2290[sizeof("tagalog")];
+    char uniname2ctype_pool_str2292[sizeof("khoj")];
+    char uniname2ctype_pool_str2311[sizeof("bopomofo")];
+    char uniname2ctype_pool_str2318[sizeof("rejang")];
+    char uniname2ctype_pool_str2326[sizeof("buhd")];
+    char uniname2ctype_pool_str2343[sizeof("incjkradicalssupplement")];
+    char uniname2ctype_pool_str2382[sizeof("inkanbun")];
+    char uniname2ctype_pool_str2406[sizeof("variationselector")];
+    char uniname2ctype_pool_str2417[sizeof("inkangxiradicals")];
+    char uniname2ctype_pool_str2421[sizeof("inhighsurrogates")];
+    char uniname2ctype_pool_str2431[sizeof("insupplementaryprivateuseareab")];
+    char uniname2ctype_pool_str2445[sizeof("ogrext")];
+    char uniname2ctype_pool_str2449[sizeof("batk")];
+    char uniname2ctype_pool_str2454[sizeof("inhanguljamoextendedb")];
+    char uniname2ctype_pool_str2457[sizeof("inbatak")];
+    char uniname2ctype_pool_str2462[sizeof("incyrillicextendedb")];
+    char uniname2ctype_pool_str2502[sizeof("innoblock")];
+    char uniname2ctype_pool_str2527[sizeof("any")];
+    char uniname2ctype_pool_str2534[sizeof("xsux")];
+    char uniname2ctype_pool_str2562[sizeof("bugi")];
+    char uniname2ctype_pool_str2570[sizeof("inkhudawadi")];
+    char uniname2ctype_pool_str2571[sizeof("telugu")];
+    char uniname2ctype_pool_str2579[sizeof("changeswhenuppercased")];
+    char uniname2ctype_pool_str2588[sizeof("grek")];
+    char uniname2ctype_pool_str2591[sizeof("guru")];
+    char uniname2ctype_pool_str2595[sizeof("paragraphseparator")];
+    char uniname2ctype_pool_str2613[sizeof("buginese")];
+    char uniname2ctype_pool_str2617[sizeof("inyisyllables")];
+    char uniname2ctype_pool_str2631[sizeof("egyp")];
+    char uniname2ctype_pool_str2634[sizeof("khudawadi")];
+    char uniname2ctype_pool_str2643[sizeof("unknown")];
+    char uniname2ctype_pool_str2685[sizeof("bassavah")];
+    char uniname2ctype_pool_str2689[sizeof("inegyptianhieroglyphs")];
+    char uniname2ctype_pool_str2709[sizeof("buhid")];
+    char uniname2ctype_pool_str2722[sizeof("inkayahli")];
+    char uniname2ctype_pool_str2732[sizeof("inmeroiticcursive")];
+    char uniname2ctype_pool_str2734[sizeof("incjkcompatibility")];
+    char uniname2ctype_pool_str2787[sizeof("oldsoutharabian")];
+    char uniname2ctype_pool_str2795[sizeof("quotationmark")];
+    char uniname2ctype_pool_str2889[sizeof("inhangulcompatibilityjamo")];
+    char uniname2ctype_pool_str2898[sizeof("qmark")];
+    char uniname2ctype_pool_str2902[sizeof("incjkunifiedideographsextensionc")];
+    char uniname2ctype_pool_str2906[sizeof("sk")];
+    char uniname2ctype_pool_str2909[sizeof("incjkunifiedideographsextensiona")];
+    char uniname2ctype_pool_str2918[sizeof("incjkunifiedideographs")];
+    char uniname2ctype_pool_str2984[sizeof("katakana")];
+    char uniname2ctype_pool_str3112[sizeof("kayahli")];
+    char uniname2ctype_pool_str3137[sizeof("duployan")];
+    char uniname2ctype_pool_str3278[sizeof("incjkunifiedideographsextensiond")];
+    char uniname2ctype_pool_str3360[sizeof("inbopomofoextended")];
+    char uniname2ctype_pool_str3466[sizeof("khojki")];
+    char uniname2ctype_pool_str3777[sizeof("zyyy")];
+    char uniname2ctype_pool_str3778[sizeof("egyptianhieroglyphs")];
+    char uniname2ctype_pool_str3827[sizeof("incjkunifiedideographsextensionb")];
+    char uniname2ctype_pool_str3886[sizeof("batak")];
+    char uniname2ctype_pool_str3941[sizeof("blank")];
+    char uniname2ctype_pool_str3995[sizeof("inboxdrawing")];
+    char uniname2ctype_pool_str4025[sizeof("greek")];
+    char uniname2ctype_pool_str4035[sizeof("gurmukhi")];
+    char uniname2ctype_pool_str4122[sizeof("grlink")];
+    char uniname2ctype_pool_str4322[sizeof("graphemelink")];
+#endif /* USE_UNICODE_PROPERTIES */
+  };
+static const struct uniname2ctype_pool_t uniname2ctype_pool_contents =
+  {
+#ifndef USE_UNICODE_PROPERTIES
+    "word",
+    "print",
+    "punct",
+    "alpha",
+    "alnum",
+    "xdigit",
+    "upper",
+#else /* USE_UNICODE_PROPERTIES */
+    "n",
+    "cn",
+    "mn",
+    "c",
+    "m",
+    "ci",
+    "z",
+    "cc",
+    "mc",
+    "mani",
+    "inmanichaean",
+    "qaai",
+    "zzzz",
+    "qaac",
+    "incham",
+    "sc",
+    "sm",
+    "mandaic",
+    "incuneiform",
+    "cans",
+    "me",
+    "inarmenian",
+#endif /* USE_UNICODE_PROPERTIES */
+    "ascii",
+#ifdef USE_UNICODE_PROPERTIES
+    "s",
+    "insamaritan",
+    "cs",
+    "zs",
+    "inavestan",
+    "incommonindicnumberforms",
+    "incuneiformnumbersandpunctuation",
+    "inthai",
+    "inipaextensions",
+    "mtei",
+    "inspecials",
+    "initialpunctuation",
+    "inancientsymbols",
+    "inthaana",
+    "inmiscellaneousmathematicalsymbolsa",
+    "lc",
+    "inmusicalsymbols",
+    "lm",
+    "taile",
+    "sterm",
+    "lina",
+    "inlycian",
+    "inmyanmarextendeda",
+    "lana",
+    "alnum",
+    "intaitham",
+    "incontrolpictures",
+    "inmiscellaneoussymbols",
+    "inmalayalam",
+    "intransportandmapsymbols",
+    "inmiscellaneoussymbolsandarrows",
+    "inlineara",
+    "inmiscellaneoussymbolsandpictographs",
+    "taiviet",
+    "cwcm",
+    "sinhala",
+    "latn",
+    "latin",
+    "ital",
+    "intamil",
+    "taml",
+    "inlatinextendedc",
+    "intaile",
+    "tale",
+    "inlatinextendeda",
+    "inlinearbideograms",
+    "newtailue",
+    "l",
+    "nl",
+    "inmeeteimayekextensions",
+    "zl",
+    "lt",
+    "inrunic",
+    "incarian",
+    "armn",
+    "cari",
+    "armi",
+    "inlatinextendede",
+    "incyrillic",
+    "armenian",
+    "inmyanmar",
+    "innewtailue",
+    "carian",
+    "merc",
+    "arabic",
+    "inmiscellaneoustechnical",
+    "insyriac",
+    "samr",
+    "zinh",
+    "han",
+    "samaritan",
+    "hani",
+    "cwt",
+    "incherokee",
+    "insharada",
+    "cham",
+    "manichaean",
+    "inmahajani",
+#endif /* USE_UNICODE_PROPERTIES */
+    "cntrl",
+#ifdef USE_UNICODE_PROPERTIES
+    "sinh",
+    "inruminumeralsymbols",
+    "inethiopic",
+    "tamil",
+    "miao",
+    "inenclosedalphanumerics",
+    "term",
+    "chakma",
+    "insinhala",
+    "shavian",
+    "inosmanya",
+    "inlatinextendedadditional",
+    "osma",
+    "ll",
+    "thai",
+    "math",
+    "thaa",
+    "inenclosedalphanumericsupplement",
+    "ethi",
+    "connectorpunctuation",
+    "inlowsurrogates",
+    "insinhalaarchaicnumbers",
+    "taitham",
+    "thaana",
+    "lineara",
+    "di",
+    "idc",
+    "meroiticcursive",
+    "mand",
+    "inmodi",
+    "inmandaic",
+    "cwl",
+    "asciihexdigit",
+    "dia",
+    "terminalpunctuation",
+    "mend",
+    "sind",
+    "wara",
+    "inwarangciti",
+    "inideographicdescriptioncharacters",
+    "inemoticons",
+    "ids",
+    "insundanese",
+    "pi",
+    "indominotiles",
+    "pc",
+    "loe",
+    "titlecaseletter",
+    "inopticalcharacterrecognition",
+    "idst",
+    "shaw",
+    "cwcf",
+    "idcontinue",
+    "inphaistosdisc",
+    "pe",
+    "indeseret",
+    "inspacingmodifierletters",
+    "inlydian",
+    "ps",
+    "hira",
+    "whitespace",
+    "inscriptionalparthian",
+    "cher",
+    "inmathematicalalphanumericsymbols",
+    "incoptic",
+    "inhiragana",
+    "inenclosedcjklettersandmonths",
+#endif /* USE_UNICODE_PROPERTIES */
+    "space",
+#ifdef USE_UNICODE_PROPERTIES
+    "oriya",
+    "mero",
+    "mahj",
+    "tirh",
+    "sora",
+    "inscriptionalpahlavi",
+    "inarrows",
+    "mahajani",
+    "joinc",
+    "incopticepactnumbers",
+    "hano",
+    "palm",
+    "intirhuta",
+    "patws",
+    "inolchiki",
+    "inlepcha",
+    "no",
+    "lepc",
+    "inogham",
+    "co",
+    "innko",
+    "alpha",
+    "psalterpahlavi",
+    "inmro",
+    "inpalmyrene",
+    "common",
+    "cf",
+    "inmiao",
+    "so",
+    "diacritic",
+    "insundanesesupplement",
+    "intifinagh",
+    "tifinagh",
+    "odi",
+    "oidc",
+    "modi",
+    "decimalnumber",
+    "letter",
+    "dash",
+    "insylotinagri",
+    "inolditalic",
+    "wspace",
+    "dsrt",
+    "ideo",
+    "siddham",
+    "perm",
+    "oids",
+    "inmahjongtiles",
+    "lo",
+    "lineseparator",
+    "imperialaramaic",
+    "idstart",
+    "inlao",
+    "sharada",
+    "lao",
+    "laoo",
+    "mongolian",
+    "oalpha",
+    "inimperialaramaic",
+    "nchar",
+    "inlatin1supplement",
+    "prti",
+    "cprt",
+    "nd",
+    "deseret",
+    "inoldturkic",
+    "radical",
+    "canadianaboriginal",
+    "inmodifiertoneletters",
+    "incaucasianalbanian",
+    "coptic",
+    "casedletter",
+    "sd",
+    "inphoenician",
+    "sidd",
+    "privateuse",
+    "sundanese",
+    "inancientgreekmusicalnotation",
+    "insiddham",
+    "cased",
+    "print",
+    "ininscriptionalparthian",
+    "ininscriptionalpahlavi",
+    "copt",
+    "inancientgreeknumbers",
+    "saurashtra",
+    "mro",
+    "mroo",
+    "inalphabeticpresentationforms",
+    "lowercase",
+    "phli",
+    "patternwhitespace",
+    "inenclosedideographicsupplement",
+    "spaceseparator",
+    "inmathematicaloperators",
+    "omath",
+    "lisu",
+    "inpsalterpahlavi",
+    "olditalic",
+    "hanunoo",
+    "inherited",
+    "lepcha",
+    "p",
+    "inmongolian",
+    "zp",
+    "finalpunctuation",
+    "otheridcontinue",
+    "shrd",
+    "ingrantha",
+    "talu",
+    "otheralphabetic",
+    "noncharactercodepoint",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    "age=1.1",
+    "age=2.1",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    "closepunctuation",
+    "letternumber",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    "age=6.1",
+    "age=6.2",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    "telu",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    "age=3.1",
+    "age=3.2",
+    "age=5.1",
+    "age=5.2",
+    "age=2.0",
+    "age=6.3",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    "inshorthandformatcontrols",
+    "inoldnortharabian",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    "age=6.0",
+    "age=4.1",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    "ingeneralpunctuation",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    "age=3.0",
+    "age=7.0",
+    "age=5.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    "innabataean",
+#ifdef USE_UNICODE_AGE_PROPERTIES
+    "age=4.0",
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+    "bamum",
+    "control",
+    "induployan",
+    "inlatinextendedd",
+    "inarabic",
+    "runic",
+    "inelbasan",
+    "inoldsoutharabian",
+    "inbasiclatin",
+    "format",
+    "innumberforms",
+    "inugaritic",
+    "separator",
+    "idsbinaryoperator",
+    "tagbanwa",
+    "bass",
+    "saur",
+    "nbat",
+    "intaixuanjingsymbols",
+    "joincontrol",
+    "otheridstart",
+    "inbyzantinemusicalsymbols",
+    "intags",
+    "nabataean",
+    "insuperscriptsandsubscripts",
+    "intibetan",
+    "insaurashtra",
+    "othersymbol",
+    "ext",
+    "inarabicpresentationformsa",
+    "inmiscellaneousmathematicalsymbolsb",
+    "otherlowercase",
+    "phoenician",
+#endif /* USE_UNICODE_PROPERTIES */
+    "lower",
+#ifndef USE_UNICODE_PROPERTIES
+    "graph",
+#else /* USE_UNICODE_PROPERTIES */
+    "linb",
+    "po",
+    "inmyanmarextendedb",
+    "limb",
+    "inbraillepatterns",
+    "tibt",
+    "cuneiform",
+    "bali",
+    "oldpersian",
+    "oldpermic",
+    "pf",
+    "word",
+    "tibetan",
+    "incyrillicsupplement",
+    "elba",
+    "insupplementalmathematicaloperators",
+    "inbalinese",
+    "bengali",
+    "caseignorable",
+    "incountingrodnumerals",
+    "other",
+    "tirhuta",
+    "othernumber",
+    "balinese",
+    "elbasan",
+    "inunifiedcanadianaboriginalsyllabics",
+    "lowercaseletter",
+    "ethiopic",
+    "gran",
+    "ingurmukhi",
+    "sund",
+    "inethiopicsupplement",
+    "inoldpersian",
+    "inoldpermic",
+    "othermath",
+    "unassigned",
+    "hmng",
+    "narb",
+    "brai",
+    "hang",
+    "insorasompeng",
+    "arab",
+    "plrd",
+    "ingujarati",
+    "brahmi",
+    "runr",
+    "ahex",
+    "mong",
+    "pauc",
+    "sarb",
+    "ogam",
+    "olower",
+    "pd",
+    "number",
+    "inbrahmi",
+    "otherletter",
+    "ingothic",
+    "phagspa",
+    "inletterlikesymbols",
+    "yi",
+    "hangul",
+    "yiii",
+    "tfng",
+    "insupplementalarrowsc",
+    "ingreekandcoptic",
+    "xidc",
+    "insupplementalarrowsa",
+    "gothic",
+    "grext",
+    "incombininghalfmarks",
+    "deprecated",
+    "inbassavah",
+    "xids",
+    "linearb",
+    "ingeometricshapes",
+    "phlp",
+    "warangciti",
+    "inblockelements",
+    "modifierletter",
+    "indingbats",
+    "dep",
+    "punct",
+    "inhanunoo",
+    "bidic",
+    "ingreekextended",
+    "idsb",
+    "assigned",
+    "otherpunctuation",
+    "inhangulsyllables",
+    "inarabicmathematicalalphabeticsymbols",
+    "inornamentaldingbats",
+    "inphagspa",
+    "lyci",
+    "mlym",
+    "inarabicextendeda",
+    "rjng",
+    "lycian",
+    "inalchemicalsymbols",
+    "xdigit",
+#endif /* USE_UNICODE_PROPERTIES */
+    "digit",
+#ifndef USE_UNICODE_PROPERTIES
+    "blank"
+#else /* USE_UNICODE_PROPERTIES */
+    "xidstart",
+    "inrejang",
+    "malayalam",
+    "idstrinaryoperator",
+    "invai",
+    "vai",
+    "vaii",
+    "hiragana",
+    "ingeorgian",
+    "braille",
+    "geor",
+    "brah",
+    "glagolitic",
+    "inkannada",
+    "cakm",
+    "kana",
+    "hebr",
+    "inshavian",
+    "vs",
+    "inchakma",
+    "ogham",
+    "sylotinagri",
+    "inunifiedcanadianaboriginalsyllabicsextended",
+    "inmeroitichieroglyphs",
+    "grantha",
+    "graphemebase",
+    "mathsymbol",
+    "mymr",
+    "insupplementaryprivateuseareaa",
+    "mendekikakui",
+    "incjkcompatibilityforms",
+    "inhalfwidthandfullwidthforms",
+    "incjkcompatibilityideographs",
+    "inkaithi",
+    "avst",
+    "inarabicsupplement",
+    "takri",
+    "syrc",
+    "meeteimayek",
+    "myanmar",
+    "avestan",
+    "inhanguljamoextendeda",
+    "goth",
+    "inkatakana",
+    "incyrillicextendeda",
+    "alphabetic",
+    "syriac",
+    "ideographic",
+    "incjkstrokes",
+    "inlinearbsyllabary",
+    "tavt",
+    "intaiviet",
+    "incjkcompatibilityideographssupplement",
+    "inmeeteimayek",
+    "kali",
+    "inyiradicals",
+    "lu",
+    "inoriya",
+    "hebrew",
+    "extender",
+    "inhighprivateusesurrogates",
+    "limbu",
+    "inbuhid",
+    "inethiopicextendeda",
+    "xidcontinue",
+    "inyijinghexagramsymbols",
+    "logicalorderexception",
+    "inhebrew",
+    "cyrl",
+    "osmanya",
+    "phnx",
+    "incombiningdiacriticalmarks",
+    "inkanasupplement",
+    "inlisu",
+    "changeswhencasemapped",
+    "incombiningdiacriticalmarksforsymbols",
+    "cwu",
+    "phag",
+    "insmallformvariants",
+    "inpahawhhmong",
+    "otheruppercase",
+    "intelugu",
+    "incombiningdiacriticalmarkssupplement",
+    "ingeometricshapesextended",
+    "xpeo",
+    "bamu",
+    "inbamum",
+    "mark",
+    "dupl",
+    "graph",
+    "dashpunctuation",
+    "patternsyntax",
+    "changeswhentitlecased",
+    "inkharoshthi",
+    "inkhmer",
+    "java",
+    "sylo",
+    "ugaritic",
+    "otherdefaultignorablecodepoint",
+    "softdotted",
+    "uideo",
+    "inphoneticextensions",
+    "injavanese",
+    "invariationselectors",
+    "kaithi",
+    "cyrillic",
+    "intakri",
+    "takr",
+    "javanese",
+    "bidicontrol",
+    "caucasianalbanian",
+    "lydi",
+    "insupplementalpunctuation",
+    "inphoneticextensionssupplement",
+    "lydian",
+    "oldturkic",
+    "invariationselectorssupplement",
+    "kthi",
+    "inhanguljamo",
+    "patsyn",
+    "inlimbu",
+    "sorasompeng",
+    "orya",
+    "inkhmersymbols",
+    "inglagolitic",
+    "indevanagari",
+    "deva",
+    "knda",
+    "inbengali",
+    "symbol",
+    "devanagari",
+    "inmendekikakui",
+    "beng",
+    "invedicextensions",
+    "graphemeextend",
+    "kannada",
+    "inbuginese",
+    "olck",
+    "meroitichieroglyphs",
+    "ugar",
+    "intagalog",
+    "inbamumsupplement",
+    "olchiki",
+    "incurrencysymbols",
+    "tagb",
+    "inaegeannumbers",
+    "intagbanwa",
+    "uppercase",
+    "defaultignorablecodepoint",
+    "glag",
+    "inkatakanaphoneticextensions",
+    "changeswhencasefolded",
+    "inpaucinhau",
+    "inprivateusearea",
+    "paucinhau",
+    "spacingmark",
+    "khmr",
+    "khar",
+    "inarabicpresentationformsb",
+    "changeswhenlowercased",
+    "tglg",
+    "inethiopicextended",
+    "incombiningdiacriticalmarksextended",
+    "oupper",
+    "incjksymbolsandpunctuation",
+    "bopo",
+    "punctuation",
+    "combiningmark",
+    "inplayingcards",
+    "inbopomofo",
+    "hyphen",
+    "inkhojki",
+    "nko",
+    "nkoo",
+    "enclosingmark",
+    "openpunctuation",
+    "currencysymbol",
+    "inverticalforms",
+    "hex",
+    "modifiersymbol",
+    "inlatinextendedb",
+    "kharoshthi",
+    "cherokee",
+    "pahawhhmong",
+    "cypriot",
+    "incypriotsyllabary",
+    "palmyrene",
+    "upper",
+    "aghb",
+    "georgian",
+    "gujr",
+    "grbase",
+    "gujarati",
+    "hexdigit",
+    "khmer",
+    "uppercaseletter",
+    "insupplementalarrowsb",
+    "surrogate",
+    "unifiedideograph",
+    "nonspacingmark",
+    "othergraphemeextend",
+    "indevanagariextended",
+    "orkh",
+    "ingeorgiansupplement",
+    "oldnortharabian",
+    "tagalog",
+    "khoj",
+    "bopomofo",
+    "rejang",
+    "buhd",
+    "incjkradicalssupplement",
+    "inkanbun",
+    "variationselector",
+    "inkangxiradicals",
+    "inhighsurrogates",
+    "insupplementaryprivateuseareab",
+    "ogrext",
+    "batk",
+    "inhanguljamoextendedb",
+    "inbatak",
+    "incyrillicextendedb",
+    "innoblock",
+    "any",
+    "xsux",
+    "bugi",
+    "inkhudawadi",
+    "telugu",
+    "changeswhenuppercased",
+    "grek",
+    "guru",
+    "paragraphseparator",
+    "buginese",
+    "inyisyllables",
+    "egyp",
+    "khudawadi",
+    "unknown",
+    "bassavah",
+    "inegyptianhieroglyphs",
+    "buhid",
+    "inkayahli",
+    "inmeroiticcursive",
+    "incjkcompatibility",
+    "oldsoutharabian",
+    "quotationmark",
+    "inhangulcompatibilityjamo",
+    "qmark",
+    "incjkunifiedideographsextensionc",
+    "sk",
+    "incjkunifiedideographsextensiona",
+    "incjkunifiedideographs",
+    "katakana",
+    "kayahli",
+    "duployan",
+    "incjkunifiedideographsextensiond",
+    "inbopomofoextended",
+    "khojki",
+    "zyyy",
+    "egyptianhieroglyphs",
+    "incjkunifiedideographsextensionb",
+    "batak",
+    "blank",
+    "inboxdrawing",
+    "greek",
+    "gurmukhi",
+    "grlink",
+    "graphemelink"
+#endif /* USE_UNICODE_PROPERTIES */
+  };
+#define uniname2ctype_pool ((const char *) &uniname2ctype_pool_contents)
+#ifdef __GNUC__
+__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+const struct uniname2ctype_struct *
+uniname2ctype_p (str, len)
+     register const char *str;
+     register unsigned int len;
+{
+  static const struct uniname2ctype_struct wordlist[] =
+    {
+#ifdef USE_UNICODE_PROPERTIES
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3,                                        34},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str10,                                       20},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str11,                                       33},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str13,                                        17},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str15,                                        30},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str16,                                       60},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str17,                                        51},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str20,                                       18},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str21,                                       31},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str29,                                    185},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str31,                            438},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str35,                                    114},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str36,                                    231},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str37,                                    128},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str44,                                  383},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str46,                                       47},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str48,                                       49},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str51,                                 168},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str55,                             461},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str56,                                    101},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str59,                                       32},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str61,                              258},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str64,                                    14},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str65,                                        46},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str69,                             265},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str72,                                       22},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str74,                                       54},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str85,                               439},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str92,                374},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str96,        462},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str97,                                  278},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str98,                         252},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str105,                                    159},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str110,                              406},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str114,                       43},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str115,                        411},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str117,                                263},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str130,     333},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str134,                                       24},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str135,                        473},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str136,                                       26},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str137,                                   120},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str141,                                   227},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str142,                                    183},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str144,                                413},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str147,                      384},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str151,                                    151},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str153,                                    13},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str155,                               302},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str157,                       325},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str161,                  331},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str163,                             276},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str166,                488},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str170,         339},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str173,                               426},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str175,    485},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str183,                                 152},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str186,                                     65},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str190,                                  92},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str203,                                     75},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str205,                                    75},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str206,                                    111},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str208,                                 273},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str209,                                     88},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str223,                        341},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str226,                                 298},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str227,                                    120},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str237,                        250},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str239,                      408},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str240,                               129},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str241,                                        23},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str243,                                       36},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str247,                 386},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str250,                                       52},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str252,                                       28},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str255,                                 289},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str256,                                414},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str257,                                     78},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str259,                                    148},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str260,                                    160},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str261,                        388},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str263,                              256},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str266,                                 78},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str267,                               281},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str270,                             299},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str272,                                  148},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str274,                                    170},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str280,                                   80},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str284,                324},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str287,                                261},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str288,                                    155},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str294,                                    114},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str295,                                     109},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str298,                               155},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str299,                                    109},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str302,                                      63},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str303,                              286},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str304,                               450},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str307,                                    150},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str315,                              185},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str316,                              449},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str317,                                     3},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str318,                                     92},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str320,                    444},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str327,                              284},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str330,                                    88},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str331,                                    172},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str332,                 327},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str333,                                    205},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str335,                                  169},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str337,                               277},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str347,                                 123},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str350,                               423},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str353,               314},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str359,                                    124},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str362,                                       25},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str363,                                     93},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str366,                                     55},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str372,                                     82},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str374,        483},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str375,                                     99},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str376,                     39},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str380,                         394},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str382,                 451},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str386,                                 151},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str388,                                   82},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str390,                                 183},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str392,                                       70},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str401,                                      67},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str405,                         170},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str407,                                    168},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str408,                                  457},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str410,                               266},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str412,                                      61},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str414,                           208},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str415,                                     211},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str418,                     205},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str419,                                    186},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str423,                                    196},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str425,                                    198},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str433,                            459},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str439,      350},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str441,                             486},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str453,                                      66},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str456,                             305},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str466,                                       43},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str468,                           481},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str470,                                       39},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str476,                                     224},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str477,                          28},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str485,           326},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str487,                                    218},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str489,                                    123},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str490,                                     64},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str493,                               67},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str502,                          412},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str508,                                       41},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str518,                               421},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str519,                253},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str520,                                432},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str522,                                       45},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str530,                                    106},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str536,                              199},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str540,                   162},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str544,                                    100},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str545,       477},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str546,                                342},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str550,                              352},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str554,           360},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str556,                                     9},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str570,                                    87},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str571,                                    171},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str573,                                    184},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str582,                                    197},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str584,                                    174},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str587,                    163},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str593,                                322},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str594,                                184},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str596,                                   201},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str597,                    415},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str598,                                    116},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str600,                                    191},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str601,                               455},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str603,                                   229},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str604,                               308},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str608,                                307},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str609,                                       37},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str611,                                    141},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str612,                                 288},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str614,                                       21},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str617,                                   264},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str620,                                     1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str622,                          194},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str623,                                   465},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str624,                             429},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str627,                                   74},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str630,                                       19},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str637,                                  468},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str640,                                       50},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str650,                               211},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str658,                   309},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str672,                              344},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str679,                                131},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str696,                                     221},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str699,                                    226},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str700,                                    187},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str703,                            35},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str705,                                   23},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str708,                                    202},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str709,                           373},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str711,                             416},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str713,                                  199},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str715,                                    113},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str718,                                    210},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str722,                                 195},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str724,                                    193},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str725,                                    225},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str727,                          480},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str728,                                       27},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str730,                            52},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str731,                         160},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str735,                                  66},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str736,                                   279},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str737,                                 173},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str742,                                      94},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str743,                                     94},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str744,                               105},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str745,                                  209},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str749,                       428},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str753,                                   215},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str758,                      249},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str761,                                    162},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str763,                                    125},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str767,                                       35},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str768,                                 113},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str772,                             443},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str773,                                 219},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str777,                      101},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str779,                   371},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str783,                     425},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str787,                                  128},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str796,                              24},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str798,                                      223},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str803,                            431},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str804,                                    195},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str805,                               21},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str813,                               140},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str815,           474},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str817,                               456},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str820,                                    59},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str827,                                     7},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str830,                 440},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str832,                  441},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str834,                                    128},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str838,                   410},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str845,                              144},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str848,                                     188},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str849,                                    188},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str850,           397},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str858,                                57},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str861,                                    163},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str864,                       229},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str866,         484},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str869,                           54},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str871,                 323},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str882,                                   206},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str892,                                    156},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str895,                        442},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str898,                               111},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str905,                                 116},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str909,                               114},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str910,                                  141},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str913,                                        38},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str916,                             295},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str922,                                       53},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str923,                         42},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str925,                         226},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str927,                                    173},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str932,                               454},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str934,                                    129},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str936,                         209},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str938,                   215},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+      {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str939,                                 232},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str940,                                 234},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str941,                         41},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str943,                             36},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+      {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str944,                                 244},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str945,                                 245},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str946,                                     89},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str947,                                 236},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str948,                                 237},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str949,                                 241},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str950,                                 242},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str951,                                 233},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str952,                                 246},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str953,               471},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str954,                       437},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+      {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str955,                                 243},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str956,                                 239},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str957,                    316},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+      {-1}, {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str958,                                 235},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str959,                                 247},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str960,                                 240},
+      {-1},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str962,                             430},
+#ifndef USE_UNICODE_AGE_PROPERTIES
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#else /* USE_UNICODE_AGE_PROPERTIES */
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str967,                                 238},
+      {-1}, {-1},
+#endif /* USE_UNICODE_AGE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str970,                                   157},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str972,                                  18},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str974,                              470},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str975,                        372},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str976,                                260},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str982,                                   103},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str984,                               424},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str985,                       436},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str986,                            248},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str995,                                   19},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str996,                           321},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str998,                              419},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str999,                                51},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1000,                       217},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1004,                                118},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1012,                                    177},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1013,                                    144},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1014,                                    190},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1017,                    475},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1019,                             201},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1023,                            225},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1027,               472},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1031,                                  496},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1033,                               190},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1034,             317},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1036,                               280},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1039,                            376},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1040,                              50},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1041,                                     212},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1046,              398},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1048,     337},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1049,                          213},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1052,                              137},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1055,                                     6},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1060,                                    121},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1064,                                       44},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1065,                      382},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1066,                                    119},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1068,                       335},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1069,                                     95},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1070,                               136},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1072,                                    135},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1073,                              133},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1077,                               193},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1080,                                       42},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1084,                                     12},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1086,                                  95},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1089,                    257},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1093,                                    179},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1094,     338},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1095,                              304},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1101,                                  84},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1104,                            60},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1107,                   476},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1114,                                    17},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1118,                                 197},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1121,                              37},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1123,                                135},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1129,                                 179},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1134,    287},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1136,                          25},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1140,                                 99},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1141,                                    180},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1149,                              270},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1151,                                    140},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1153,                    285},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1160,                            420},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1163,                             418},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1170,                               206},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1174,                               20},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1180,                                    181},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1181,                                    189},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1184,                                    126},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1186,                                     98},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1187,                           447},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1193,                                     80},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1194,                                    172},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1195,                              271},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1197,                                  167},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1201,                                    103},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1202,                                    208},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1206,                                    105},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1211,                                    192},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1212,                                    161},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1218,                                    102},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1221,                                  213},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1222,                                       40},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1235,                                   34},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1238,                                445},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1240,                              27},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1252,                                417},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1254,                                 138},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1262,                     320},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1265,                                      110},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1269,                                   98},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1271,                                    110},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1272,                                    131},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1273,                   491},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1277,                        255},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1279,                                     69},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1280,                   334},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1281,                                  112},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1283,                                    71},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1285,                    401},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1286,                              222},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1287,                              466},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1305,                                     68},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1308,                                 121},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1312,                       330},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1313,                                    194},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1314,                              198},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1317,                         329},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1318,                           26},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1321,                              332},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1322,                                     222},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1324,                                     8},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1327,                               291},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1334,                                   200},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1344,                         315},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1353,                                    217},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1359,                                 16},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1364,                         44},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1368,                       390},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1373,   479},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1385,                    487},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1387,                               375},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1389,                                    147},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1393,                                     91},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1399,                       267},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1400,                                    146},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1402,                                  147},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1403,                     489},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1409,                                   11},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1412,                                     4},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1420,                                 68},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1421,                                379},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1424,                                91},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1425,                      218},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1429,                                   368},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1435,                                     143},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1436,                                    143},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1438,                                106},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1442,                              282},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1448,                                 126},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1455,                                     97},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1457,                                    167},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1463,                              130},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1465,                               275},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1466,                                    169},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1467,                                    107},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1469,                                     79},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1471,                               422},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1477,                                      228},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1481,                                448},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1490,                                   102},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1491,                             132},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1492, 296},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1495,                   433},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1498,                                 180},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1500,                             72},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1502,                               49},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1505,                                     96},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1513,          498},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1514,                            186},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1516,                 402},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1518,            405},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1521,            396},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1522,                                446},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1525,                                    153},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1526,                      262},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1527,                                   175},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1529,                                     81},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1533,                             159},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1534,                                  96},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1535,                                 153},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1536,                   380},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1540,                                    112},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1542,                              353},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1544,                     346},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1549,                               56},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1550,                                   81},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1551,                             210},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1555,                            358},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1557,                      407},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1558,                                    152},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1559,                               385},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1564,  495},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1576,                           389},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1577,                                    145},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1581,                            366},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1586,                                       29},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1587,                                 272},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1590,                                   79},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1596,                                212},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1598,              393},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1600,                                   119},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1606,                                 292},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1608,                     387},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1609,                              69},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1611,                 363},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1612,                   224},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1616,                                259},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1617,                                     77},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1618,                                 124},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1621,                                    137},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1622,             254},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1626,                        469},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1627,                                  367},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1628,                    65},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1632,   319},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1636,                                      62},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1641,                                    138},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1645,                     403},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1656,                           467},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1661,                          214},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1662,                                274},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1665,   313},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1670,               490},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1671,                                    133},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1687,                                    157},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1689,                                 370},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1692,                                     30},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1694,                                    178},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1695,                                     5},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1696,                          40},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1700,                           230},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1705,                    63},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1706,                            435},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1712,                                 294},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1713,                                    158},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1714,                                    132},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1719,                                122},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1722,          221},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1723,                              223},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1729,                                   220},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1732,                    311},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1736,                              381},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1742,                    399},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1744,                                  165},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1747,                                 77},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1749,                                 458},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1750,                                    175},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1755,                                158},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1757,                             200},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1758,                       176},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1765,                                    149},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1772,               347},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1775,          312},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1778,                                  149},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1784,                               164},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1785,          497},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1786,                                    165},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1792,                            283},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1797,                                  230},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1802,                                 297},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1804,                             174},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1807,                                     87},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1822,                          300},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1824,                            340},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1831,                            268},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1835,                                     83},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1836,                                     90},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1841,                               269},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1843,                                   46},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1846,                               83},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1849,                          478},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1852,                                     84},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1853,                       310},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1859,                           71},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1865,                                  90},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1866,                              301},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1869,                                    142},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1871,                     171},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1872,                                    122},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1874,                               290},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1878,                       464},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1880,                                 142},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1899,                       318},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1904,                                    118},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1912,                         409},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1915,                              293},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1916,                                58},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1917,                70},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1919,                                    130},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1921,            359},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1932,                    64},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1942,                             460},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1943,                        395},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1947,                               192},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1953,                              31},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1956,                                    104},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1962,                                    134},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1964,              404},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1967,                    61},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1971,                                    115},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1976,                      345},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1980,     303},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1986,                                  214},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1994,              351},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1997,                                    108},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str1998,                              38},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2002,                            30},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2007,                          482},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2008,                              354},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2021,                                  203},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2028,                                452},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2046,                                     139},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2047,                                    139},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2048,                            32},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2053,                          45},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2061,                           47},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2063,                         400},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2071,                                     207},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2072,                           48},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2073,                        251},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2075,                              134},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2080,                                100},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2088,                             181},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2096,                                 125},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2105,                      427},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2110,                               191},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2113,                                    10},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2116,                                    176},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2123,                                 97},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2131,                                     86},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2142,                                   72},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2152,                                 86},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2153,                                207},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2189,                                   104},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2194,                          29},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2198,                   336},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2224,                                22},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2227,                        220},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2237,                           33},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2241,                     216},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2242,                    377},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2252,                                    164},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2273,                    343},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2287,                         189},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2290,                                 115},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2292,                                    182},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2311,                                108},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2318,                                  146},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2326,                                    117},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2343,                 348},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2382,                                356},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2406,                       228},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2417,                        349},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2421,                        392},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2431,          499},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2445,                                  216},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2449,                                    166},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2454,                   391},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2457,                                 306},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2462,                     369},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2502,                               500},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2527,                                      15},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2534,                                    136},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2562,                                    127},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2570,                             453},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2571,                                   89},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2579,                    62},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2588,                                     76},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2591,                                     85},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2595,                       53},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2613,                                127},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2617,                           365},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2631,                                    154},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2634,                               196},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2643,                                 231},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2685,                                177},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2689,                   463},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2709,                                   117},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2722,                               378},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2732,                       434},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2734,                      361},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2787,                         161},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2795,                           204},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2889,               355},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2898,                                   204},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2902,        493},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2906,                                       48},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2909,        362},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2918,                  364},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str2984,                                107},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3112,                                 145},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3137,                                178},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3278,        494},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3360,                      357},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#endif /* USE_UNICODE_PROPERTIES */
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#ifndef USE_UNICODE_PROPERTIES
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str6,                                     12},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str7,                                     7},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str8,                                     8},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str9,                                     1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str10,                                    13},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str11,                                   11},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str12,                                    10},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str13,                                    14},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str14,                                     3},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str15,                                     9},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str16,                                     6},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str17,                                     5},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str18,                                     4},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str19,                                     2}
+#else /* USE_UNICODE_PROPERTIES */
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3466,                                  182},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3777,                                     74},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3778,                     154},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3827,        492},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3886,                                   166},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3941,                                     2},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str3995,                            328},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str4025,                                    76},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str4035,                                 85},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str4122,                                   73},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+      {-1},
+      {(int)(long)&((struct uniname2ctype_pool_t *)0)->uniname2ctype_pool_str4322,                             73}
+#endif /* USE_UNICODE_PROPERTIES */
+    };
+
+  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+    {
+      register int key = uniname2ctype_hash (str, len);
+
+      if (key <= MAX_HASH_VALUE && key >= 0)
+        {
+          register int o = wordlist[key].name;
+          if (o >= 0)
+            {
+              register const char *s = o + uniname2ctype_pool;
+
+              if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+                return &wordlist[key];
+            }
+        }
+    }
+  return 0;
+}
+
+static int
+uniname2ctype(const UChar *name, unsigned int len)
+{
+  const struct uniname2ctype_struct *p = uniname2ctype_p((const char *)name, len);
+  if (p) return p->ctype;
+  return -1;
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/utf8.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/utf8.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/enc/utf8.c	(revision 279)
@@ -0,0 +1,304 @@
+/**********************************************************************
+  utf8.c -  Oniguruma (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regenc.h"
+
+#define USE_INVALID_CODE_SCHEME
+
+#ifdef USE_INVALID_CODE_SCHEME
+/* virtual codepoint values for invalid encoding byte 0xfe and 0xff */
+#define INVALID_CODE_FE   0xfffffffe
+#define INVALID_CODE_FF   0xffffffff
+#define VALID_CODE_LIMIT  0x7fffffff
+#endif
+
+#define utf8_islead(c)     ((UChar )((c) & 0xc0) != 0x80)
+
+static const int EncLen_UTF8[] = {
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+  4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1
+};
+
+static int
+mbc_enc_len(const UChar* p)
+{
+  return EncLen_UTF8[*p];
+}
+
+static int
+is_mbc_newline(const UChar* p, const UChar* end)
+{
+  if (p < end) {
+    if (*p == 0x0a) return 1;
+
+#ifdef USE_UNICODE_ALL_LINE_TERMINATORS
+    if (*p == 0x0b || *p == 0x0c || *p == 0x0d) return 1;
+    if (p + 1 < end) {
+      if (*(p+1) == 0x85 && *p == 0xc2) /* U+0085 */
+	return 1;
+      if (p + 2 < end) {
+	if ((*(p+2) == 0xa8 || *(p+2) == 0xa9)
+	    && *(p+1) == 0x80 && *p == 0xe2)  /* U+2028, U+2029 */
+	  return 1;
+      }
+    }
+#endif
+  }
+
+  return 0;
+}
+
+static OnigCodePoint
+mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
+{
+  int c, len;
+  OnigCodePoint n;
+
+  len = mbc_enc_len(p);
+  c = *p++;
+  if (len > 1) {
+    len--;
+    n = c & ((1 << (6 - len)) - 1);
+    while (len--) {
+      c = *p++;
+      n = (n << 6) | (c & ((1 << 6) - 1));
+    }
+    return n;
+  }
+  else {
+#ifdef USE_INVALID_CODE_SCHEME
+    if (c > 0xfd) {
+      return ((c == 0xfe) ? INVALID_CODE_FE : INVALID_CODE_FF);
+    }
+#endif
+    return (OnigCodePoint )c;
+  }
+}
+
+static int
+code_to_mbclen(OnigCodePoint code)
+{
+  if      ((code & 0xffffff80) == 0) return 1;
+  else if ((code & 0xfffff800) == 0) return 2;
+  else if ((code & 0xffff0000) == 0) return 3;
+  else if ((code & 0xffe00000) == 0) return 4;
+  else if ((code & 0xfc000000) == 0) return 5;
+  else if ((code & 0x80000000) == 0) return 6;
+#ifdef USE_INVALID_CODE_SCHEME
+  else if (code == INVALID_CODE_FE) return 1;
+  else if (code == INVALID_CODE_FF) return 1;
+#endif
+  else
+    return ONIGERR_INVALID_CODE_POINT_VALUE;
+}
+
+static int
+code_to_mbc(OnigCodePoint code, UChar *buf)
+{
+#define UTF8_TRAILS(code, shift) (UChar )((((code) >> (shift)) & 0x3f) | 0x80)
+#define UTF8_TRAIL0(code)        (UChar )(((code) & 0x3f) | 0x80)
+
+  if ((code & 0xffffff80) == 0) {
+    *buf = (UChar )code;
+    return 1;
+  }
+  else {
+    UChar *p = buf;
+
+    if ((code & 0xfffff800) == 0) {
+      *p++ = (UChar )(((code>>6)& 0x1f) | 0xc0);
+    }
+    else if ((code & 0xffff0000) == 0) {
+      *p++ = (UChar )(((code>>12) & 0x0f) | 0xe0);
+      *p++ = UTF8_TRAILS(code, 6);
+    }
+    else if ((code & 0xffe00000) == 0) {
+      *p++ = (UChar )(((code>>18) & 0x07) | 0xf0);
+      *p++ = UTF8_TRAILS(code, 12);
+      *p++ = UTF8_TRAILS(code,  6);
+    }
+    else if ((code & 0xfc000000) == 0) {
+      *p++ = (UChar )(((code>>24) & 0x03) | 0xf8);
+      *p++ = UTF8_TRAILS(code, 18);
+      *p++ = UTF8_TRAILS(code, 12);
+      *p++ = UTF8_TRAILS(code,  6);
+    }
+    else if ((code & 0x80000000) == 0) {
+      *p++ = (UChar )(((code>>30) & 0x01) | 0xfc);
+      *p++ = UTF8_TRAILS(code, 24);
+      *p++ = UTF8_TRAILS(code, 18);
+      *p++ = UTF8_TRAILS(code, 12);
+      *p++ = UTF8_TRAILS(code,  6);
+    }
+#ifdef USE_INVALID_CODE_SCHEME
+    else if (code == INVALID_CODE_FE) {
+      *p = 0xfe;
+      return 1;
+    }
+    else if (code == INVALID_CODE_FF) {
+      *p = 0xff;
+      return 1;
+    }
+#endif
+    else {
+      return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
+    }
+
+    *p++ = UTF8_TRAIL0(code);
+    return (int )(p - buf);
+  }
+}
+
+static int
+mbc_case_fold(OnigCaseFoldType flag, const UChar** pp,
+	      const UChar* end, UChar* fold)
+{
+  const UChar* p = *pp;
+
+  if (ONIGENC_IS_MBC_ASCII(p)) {
+#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
+    if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
+      if (*p == 0x49) {
+	*fold++ = 0xc4;
+	*fold   = 0xb1;
+	(*pp)++;
+	return 2;
+      }
+    }
+#endif
+
+    *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
+    (*pp)++;
+    return 1; /* return byte length of converted char to lower */
+  }
+  else {
+    return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF8, flag,
+					 pp, end, fold);
+  }
+}
+
+#if 0
+static int
+is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
+{
+  const UChar* p = *pp;
+
+  if (ONIGENC_IS_MBC_ASCII(p)) {
+    (*pp)++;
+    return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
+  }
+  else {
+    (*pp) += mbc_enc_len(p);
+
+    if (*p == 0xc3) {
+      int c = *(p + 1);
+      if (c >= 0x80) {
+	if (c <= (UChar )0x9e) { /* upper */
+	  if (c == (UChar )0x97) return FALSE;
+	  return TRUE;
+	}
+	else if (c >= (UChar )0xa0 && c <= (UChar )0xbe) { /* lower */
+	  if (c == (UChar )'\267') return FALSE;
+	  return TRUE;
+	}
+        else if (c == (UChar )0x9f &&
+                 (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
+	  return TRUE;
+        }
+      }
+    }
+  }
+
+  return FALSE;
+}
+#endif
+
+
+static int
+get_ctype_code_range(OnigCtype ctype, OnigCodePoint *sb_out,
+		     const OnigCodePoint* ranges[])
+{
+  *sb_out = 0x80;
+  return onigenc_unicode_ctype_code_range(ctype, ranges);
+}
+
+
+static UChar*
+left_adjust_char_head(const UChar* start, const UChar* s)
+{
+  const UChar *p;
+
+  if (s <= start) return (UChar* )s;
+  p = s;
+
+  while (!utf8_islead(*p) && p > start) p--;
+  return (UChar* )p;
+}
+
+static int
+get_case_fold_codes_by_str(OnigCaseFoldType flag,
+    const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
+{
+  return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF8,
+						    flag, p, end, items);
+}
+
+OnigEncodingType OnigEncodingUTF8 = {
+  mbc_enc_len,
+  "UTF-8",     /* name */
+  6,           /* max byte length */
+  1,           /* min byte length */
+  is_mbc_newline,
+  mbc_to_code,
+  code_to_mbclen,
+  code_to_mbc,
+  mbc_case_fold,
+  onigenc_unicode_apply_all_case_fold,
+  get_case_fold_codes_by_str,
+  onigenc_unicode_property_name_to_ctype,
+  onigenc_unicode_is_code_ctype,
+  get_ctype_code_range,
+  left_adjust_char_head,
+  onigenc_always_true_is_allowed_reverse_match,
+  ONIGENC_FLAG_UNICODE,
+};
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/oniggnu.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/oniggnu.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/oniggnu.h	(revision 279)
@@ -0,0 +1,85 @@
+#ifndef ONIGGNU_H
+#define ONIGGNU_H
+/**********************************************************************
+  oniggnu.h - Oniguruma (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2005  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "oniguruma.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RE_MBCTYPE_ASCII         0
+#define RE_MBCTYPE_EUC           1
+#define RE_MBCTYPE_SJIS          2
+#define RE_MBCTYPE_UTF8          3
+
+/* GNU regex options */
+#ifndef RE_NREGS
+#define RE_NREGS                ONIG_NREGION
+#endif
+
+#define RE_OPTION_IGNORECASE         ONIG_OPTION_IGNORECASE
+#define RE_OPTION_EXTENDED           ONIG_OPTION_EXTEND
+#define RE_OPTION_MULTILINE          ONIG_OPTION_MULTILINE
+#define RE_OPTION_SINGLELINE         ONIG_OPTION_SINGLELINE
+#define RE_OPTION_LONGEST            ONIG_OPTION_FIND_LONGEST
+#define RE_OPTION_POSIXLINE         (RE_OPTION_MULTILINE|RE_OPTION_SINGLELINE)
+#define RE_OPTION_FIND_NOT_EMPTY     ONIG_OPTION_FIND_NOT_EMPTY
+#define RE_OPTION_NEGATE_SINGLELINE  ONIG_OPTION_NEGATE_SINGLELINE
+#define RE_OPTION_DONT_CAPTURE_GROUP ONIG_OPTION_DONT_CAPTURE_GROUP
+#define RE_OPTION_CAPTURE_GROUP      ONIG_OPTION_CAPTURE_GROUP
+
+
+ONIG_EXTERN
+void re_mbcinit P_((int));
+ONIG_EXTERN
+int re_compile_pattern P_((const char*, int, struct re_pattern_buffer*, char* err_buf));
+ONIG_EXTERN
+int re_recompile_pattern P_((const char*, int, struct re_pattern_buffer*, char* err_buf));
+ONIG_EXTERN
+void re_free_pattern P_((struct re_pattern_buffer*));
+ONIG_EXTERN
+int re_adjust_startpos P_((struct re_pattern_buffer*, const char*, int, int, int));
+ONIG_EXTERN
+int re_search P_((struct re_pattern_buffer*, const char*, int, int, int, struct re_registers*));
+ONIG_EXTERN
+int re_match P_((struct re_pattern_buffer*, const char *, int, int, struct re_registers*));
+ONIG_EXTERN
+void re_set_casetable P_((const char*));
+ONIG_EXTERN
+void re_free_registers P_((struct re_registers*));
+ONIG_EXTERN
+int re_alloc_pattern P_((struct re_pattern_buffer**));  /* added */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ONIGGNU_H */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/onigposix.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/onigposix.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/onigposix.h	(revision 279)
@@ -0,0 +1,169 @@
+#ifndef ONIGPOSIX_H
+#define ONIGPOSIX_H
+/**********************************************************************
+  onigposix.h - Oniguruma (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2005  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* options */
+#define REG_ICASE          (1<<0)
+#define REG_NEWLINE        (1<<1)
+#define REG_NOTBOL         (1<<2)
+#define REG_NOTEOL         (1<<3)
+#define REG_EXTENDED       (1<<4) /* if not set, Basic Onigular Expression */
+#define REG_NOSUB          (1<<5)
+
+/* POSIX error codes */
+#define REG_NOMATCH          1
+#define REG_BADPAT           2
+#define REG_ECOLLATE         3
+#define REG_ECTYPE           4
+#define REG_EESCAPE          5
+#define REG_ESUBREG          6
+#define REG_EBRACK           7
+#define REG_EPAREN           8
+#define REG_EBRACE           9
+#define REG_BADBR           10
+#define REG_ERANGE          11
+#define REG_ESPACE          12
+#define REG_BADRPT          13
+
+/* extended error codes */
+#define REG_EONIG_INTERNAL  14
+#define REG_EONIG_BADWC     15
+#define REG_EONIG_BADARG    16
+#define REG_EONIG_THREAD    17
+
+/* character encodings (for reg_set_encoding()) */
+#define REG_POSIX_ENCODING_ASCII     0
+#define REG_POSIX_ENCODING_EUC_JP    1
+#define REG_POSIX_ENCODING_SJIS      2
+#define REG_POSIX_ENCODING_UTF8      3
+#define REG_POSIX_ENCODING_UTF16_BE  4
+#define REG_POSIX_ENCODING_UTF16_LE  5
+
+
+typedef int regoff_t;
+
+typedef struct {
+  regoff_t  rm_so;
+  regoff_t  rm_eo;
+} regmatch_t;
+
+/* POSIX regex_t */
+typedef struct {
+  void*   onig;          /* Oniguruma regex_t*  */
+  size_t  re_nsub;
+  int     comp_options;
+} regex_t;
+
+
+#ifndef P_
+#if defined(__STDC__) || defined(_WIN32)
+# define P_(args) args
+#else
+# define P_(args) ()
+#endif
+#endif
+
+#ifndef ONIG_EXTERN
+#if defined(_WIN32) && !defined(__GNUC__)
+#if defined(EXPORT)
+#define ONIG_EXTERN   extern __declspec(dllexport)
+#else
+#define ONIG_EXTERN   extern __declspec(dllimport)
+#endif
+#endif
+#endif
+
+#ifndef ONIG_EXTERN
+#define ONIG_EXTERN   extern
+#endif
+
+#ifndef ONIGURUMA_H
+typedef unsigned int        OnigOptionType;
+
+/* syntax */
+typedef struct {
+  unsigned int op;
+  unsigned int op2;
+  unsigned int behavior;
+  OnigOptionType options;    /* default option */
+} OnigSyntaxType;
+
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
+
+/* predefined syntaxes (see regsyntax.c) */
+#define ONIG_SYNTAX_POSIX_BASIC        (&OnigSyntaxPosixBasic)
+#define ONIG_SYNTAX_POSIX_EXTENDED     (&OnigSyntaxPosixExtended)
+#define ONIG_SYNTAX_EMACS              (&OnigSyntaxEmacs)
+#define ONIG_SYNTAX_GREP               (&OnigSyntaxGrep)
+#define ONIG_SYNTAX_GNU_REGEX          (&OnigSyntaxGnuRegex)
+#define ONIG_SYNTAX_JAVA               (&OnigSyntaxJava)
+#define ONIG_SYNTAX_PERL               (&OnigSyntaxPerl)
+#define ONIG_SYNTAX_RUBY               (&OnigSyntaxRuby)
+/* default syntax */
+#define ONIG_SYNTAX_DEFAULT             OnigDefaultSyntax
+
+ONIG_EXTERN OnigSyntaxType*  OnigDefaultSyntax;
+
+ONIG_EXTERN int  onig_set_default_syntax P_((OnigSyntaxType* syntax));
+ONIG_EXTERN void onig_copy_syntax P_((OnigSyntaxType* to, OnigSyntaxType* from));
+ONIG_EXTERN const char* onig_version P_((void));
+ONIG_EXTERN const char* onig_copyright P_((void));
+
+#endif /* ONIGURUMA_H */
+
+
+ONIG_EXTERN int    regcomp P_((regex_t* reg, const char* pat, int options));
+ONIG_EXTERN int    regexec P_((regex_t* reg, const char* str, size_t nmatch, regmatch_t* matches, int options));
+ONIG_EXTERN void   regfree P_((regex_t* reg));
+ONIG_EXTERN size_t regerror P_((int code, const regex_t* reg, char* buf, size_t size));
+
+/* extended API */
+ONIG_EXTERN void reg_set_encoding P_((int enc));
+ONIG_EXTERN int  reg_name_to_group_numbers P_((regex_t* reg, const unsigned char* name, const unsigned char* name_end, int** nums));
+ONIG_EXTERN int  reg_foreach_name P_((regex_t* reg, int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*), void* arg));
+ONIG_EXTERN int  reg_number_of_names P_((regex_t* reg));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ONIGPOSIX_H */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/oniguruma.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/oniguruma.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/oniguruma.h	(revision 279)
@@ -0,0 +1,870 @@
+#ifndef ONIGURUMA_H
+#define ONIGURUMA_H
+/**********************************************************************
+  oniguruma.h - Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2009  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ONIGURUMA
+#define ONIGURUMA_VERSION_MAJOR   5
+#define ONIGURUMA_VERSION_MINOR   15
+#define ONIGURUMA_VERSION_TEENY   0
+
+#ifdef __cplusplus
+# ifndef  HAVE_PROTOTYPES
+#  define HAVE_PROTOTYPES 1
+# endif
+# ifndef  HAVE_STDARG_PROTOTYPES
+#  define HAVE_STDARG_PROTOTYPES 1
+# endif
+#endif
+
+/* escape Mac OS X/Xcode 2.4/gcc 4.0.1 problem */
+#if defined(__APPLE__) && defined(__GNUC__) && __GNUC__ >= 4
+# ifndef  HAVE_STDARG_PROTOTYPES
+#  define HAVE_STDARG_PROTOTYPES 1
+# endif
+#endif
+
+#if defined(HAVE_STDARG_H) || defined(_WIN32)
+# ifndef  HAVE_STDARG_PROTOTYPES
+#  define HAVE_STDARG_PROTOTYPES 1
+# endif
+#endif
+
+#ifndef P_
+#if defined(__STDC__) || defined(_WIN32)
+# define P_(args) args
+#else
+# define P_(args) ()
+#endif
+#endif
+
+#ifndef PV_
+#ifdef HAVE_STDARG_PROTOTYPES
+# define PV_(args) args
+#else
+# define PV_(args) ()
+#endif
+#endif
+
+#ifndef ONIG_EXTERN
+#if defined(_WIN32) && !defined(__GNUC__)
+#if defined(EXPORT) || defined(RUBY_EXPORT)
+#define ONIG_EXTERN   extern __declspec(dllexport)
+#else
+#define ONIG_EXTERN   extern __declspec(dllimport)
+#endif
+#endif
+#endif
+
+#ifndef ONIG_EXTERN
+#define ONIG_EXTERN   extern
+#endif
+
+#include <stddef.h>		/* for size_t */
+
+/* PART: character encoding */
+
+#ifndef ONIG_ESCAPE_UCHAR_COLLISION
+#define UChar OnigUChar
+#endif
+
+typedef unsigned char  OnigUChar;
+typedef unsigned int   OnigCodePoint;
+typedef unsigned int   OnigCtype;
+typedef size_t         OnigDistance;
+typedef ptrdiff_t      OnigPosition;
+
+#define ONIG_INFINITE_DISTANCE  ~((OnigDistance )0)
+
+typedef unsigned int OnigCaseFoldType; /* case fold flag */
+
+ONIG_EXTERN OnigCaseFoldType OnigDefaultCaseFoldFlag;
+
+/* #define ONIGENC_CASE_FOLD_HIRAGANA_KATAKANA  (1<<1) */
+/* #define ONIGENC_CASE_FOLD_KATAKANA_WIDTH     (1<<2) */
+#define ONIGENC_CASE_FOLD_TURKISH_AZERI         (1<<20)
+#define INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR   (1<<30)
+
+#define ONIGENC_CASE_FOLD_MIN      INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR
+#define ONIGENC_CASE_FOLD_DEFAULT  OnigDefaultCaseFoldFlag
+
+
+#define ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN       3
+#define ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM      13
+/* 13 => Unicode:0x1ffc */
+
+/* code range */
+#define ONIGENC_CODE_RANGE_NUM(range)     ((int )range[0])
+#define ONIGENC_CODE_RANGE_FROM(range,i)  range[((i)*2) + 1]
+#define ONIGENC_CODE_RANGE_TO(range,i)    range[((i)*2) + 2]
+
+typedef struct {
+  int byte_len;  /* argument(original) character(s) byte length */
+  int code_len;  /* number of code */
+  OnigCodePoint code[ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN];
+} OnigCaseFoldCodeItem;
+
+typedef struct {
+  OnigCodePoint esc;
+  OnigCodePoint anychar;
+  OnigCodePoint anytime;
+  OnigCodePoint zero_or_one_time;
+  OnigCodePoint one_or_more_time;
+  OnigCodePoint anychar_anytime;
+} OnigMetaCharTableType;
+
+typedef int (*OnigApplyAllCaseFoldFunc)(OnigCodePoint from, OnigCodePoint* to, int to_len, void* arg);
+
+typedef struct OnigEncodingTypeST {
+  int    (*mbc_enc_len)(const OnigUChar* p);
+  const char*   name;
+  int           max_enc_len;
+  int           min_enc_len;
+  int    (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end);
+  OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end);
+  int    (*code_to_mbclen)(OnigCodePoint code);
+  int    (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf);
+  int    (*mbc_case_fold)(OnigCaseFoldType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to);
+  int    (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg);
+  int    (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[]);
+  int    (*property_name_to_ctype)(struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end);
+  int    (*is_code_ctype)(OnigCodePoint code, OnigCtype ctype);
+  int    (*get_ctype_code_range)(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[]);
+  OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p);
+  int    (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end);
+  unsigned int  flags;
+} OnigEncodingType;
+
+typedef OnigEncodingType* OnigEncoding;
+
+ONIG_EXTERN OnigEncodingType OnigEncodingASCII;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_1;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_2;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_3;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_4;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_5;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_6;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_7;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_8;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_9;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_10;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_11;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_13;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_14;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_15;
+ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_16;
+ONIG_EXTERN OnigEncodingType OnigEncodingUTF8;
+ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_BE;
+ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_LE;
+ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_BE;
+ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_LE;
+ONIG_EXTERN OnigEncodingType OnigEncodingEUC_JP;
+ONIG_EXTERN OnigEncodingType OnigEncodingEUC_TW;
+ONIG_EXTERN OnigEncodingType OnigEncodingEUC_KR;
+ONIG_EXTERN OnigEncodingType OnigEncodingEUC_CN;
+ONIG_EXTERN OnigEncodingType OnigEncodingSJIS;
+ONIG_EXTERN OnigEncodingType OnigEncodingCP932;
+ONIG_EXTERN OnigEncodingType OnigEncodingKOI8;
+ONIG_EXTERN OnigEncodingType OnigEncodingKOI8_R;
+ONIG_EXTERN OnigEncodingType OnigEncodingCP1251;
+ONIG_EXTERN OnigEncodingType OnigEncodingBIG5;
+ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;
+
+#define ONIG_ENCODING_ASCII        (&OnigEncodingASCII)
+#define ONIG_ENCODING_ISO_8859_1   (&OnigEncodingISO_8859_1)
+#define ONIG_ENCODING_ISO_8859_2   (&OnigEncodingISO_8859_2)
+#define ONIG_ENCODING_ISO_8859_3   (&OnigEncodingISO_8859_3)
+#define ONIG_ENCODING_ISO_8859_4   (&OnigEncodingISO_8859_4)
+#define ONIG_ENCODING_ISO_8859_5   (&OnigEncodingISO_8859_5)
+#define ONIG_ENCODING_ISO_8859_6   (&OnigEncodingISO_8859_6)
+#define ONIG_ENCODING_ISO_8859_7   (&OnigEncodingISO_8859_7)
+#define ONIG_ENCODING_ISO_8859_8   (&OnigEncodingISO_8859_8)
+#define ONIG_ENCODING_ISO_8859_9   (&OnigEncodingISO_8859_9)
+#define ONIG_ENCODING_ISO_8859_10  (&OnigEncodingISO_8859_10)
+#define ONIG_ENCODING_ISO_8859_11  (&OnigEncodingISO_8859_11)
+#define ONIG_ENCODING_ISO_8859_13  (&OnigEncodingISO_8859_13)
+#define ONIG_ENCODING_ISO_8859_14  (&OnigEncodingISO_8859_14)
+#define ONIG_ENCODING_ISO_8859_15  (&OnigEncodingISO_8859_15)
+#define ONIG_ENCODING_ISO_8859_16  (&OnigEncodingISO_8859_16)
+#define ONIG_ENCODING_UTF8         (&OnigEncodingUTF8)
+#define ONIG_ENCODING_UTF16_BE     (&OnigEncodingUTF16_BE)
+#define ONIG_ENCODING_UTF16_LE     (&OnigEncodingUTF16_LE)
+#define ONIG_ENCODING_UTF32_BE     (&OnigEncodingUTF32_BE)
+#define ONIG_ENCODING_UTF32_LE     (&OnigEncodingUTF32_LE)
+#define ONIG_ENCODING_EUC_JP       (&OnigEncodingEUC_JP)
+#define ONIG_ENCODING_EUC_TW       (&OnigEncodingEUC_TW)
+#define ONIG_ENCODING_EUC_KR       (&OnigEncodingEUC_KR)
+#define ONIG_ENCODING_EUC_CN       (&OnigEncodingEUC_CN)
+#define ONIG_ENCODING_SJIS         (&OnigEncodingSJIS)
+#define ONIG_ENCODING_CP932        (&OnigEncodingCP932)
+#define ONIG_ENCODING_KOI8         (&OnigEncodingKOI8)
+#define ONIG_ENCODING_KOI8_R       (&OnigEncodingKOI8_R)
+#define ONIG_ENCODING_CP1251       (&OnigEncodingCP1251)
+#define ONIG_ENCODING_BIG5         (&OnigEncodingBIG5)
+#define ONIG_ENCODING_GB18030      (&OnigEncodingGB18030)
+
+#define ONIG_ENCODING_UNDEF    ((OnigEncoding )0)
+
+
+/* work size */
+#define ONIGENC_CODE_TO_MBC_MAXLEN       7
+#define ONIGENC_MBC_CASE_FOLD_MAXLEN    18
+/* 18: 6(max-byte) * 3(case-fold chars) */
+
+/* character types */
+#define ONIGENC_CTYPE_NEWLINE   0
+#define ONIGENC_CTYPE_ALPHA     1
+#define ONIGENC_CTYPE_BLANK     2
+#define ONIGENC_CTYPE_CNTRL     3
+#define ONIGENC_CTYPE_DIGIT     4
+#define ONIGENC_CTYPE_GRAPH     5
+#define ONIGENC_CTYPE_LOWER     6
+#define ONIGENC_CTYPE_PRINT     7
+#define ONIGENC_CTYPE_PUNCT     8
+#define ONIGENC_CTYPE_SPACE     9
+#define ONIGENC_CTYPE_UPPER    10
+#define ONIGENC_CTYPE_XDIGIT   11
+#define ONIGENC_CTYPE_WORD     12
+#define ONIGENC_CTYPE_ALNUM    13  /* alpha || digit */
+#define ONIGENC_CTYPE_ASCII    14
+#define ONIGENC_MAX_STD_CTYPE  ONIGENC_CTYPE_ASCII
+
+/* flags */
+#define ONIGENC_FLAG_NONE       0U
+#define ONIGENC_FLAG_UNICODE    1U
+
+
+#define onig_enc_len(enc,p,end)        ONIGENC_MBC_ENC_LEN(enc,p)
+
+#define ONIGENC_IS_UNDEF(enc)          ((enc) == ONIG_ENCODING_UNDEF)
+#define ONIGENC_IS_SINGLEBYTE(enc)     (ONIGENC_MBC_MAXLEN(enc) == 1)
+#define ONIGENC_IS_MBC_HEAD(enc,p)     (ONIGENC_MBC_ENC_LEN(enc,p) != 1)
+#define ONIGENC_IS_MBC_ASCII(p)           (*(p)   < 128)
+#define ONIGENC_IS_CODE_ASCII(code)       ((code) < 128)
+#define ONIGENC_IS_MBC_WORD(enc,s,end) \
+   ONIGENC_IS_CODE_WORD(enc,ONIGENC_MBC_TO_CODE(enc,s,end))
+#define ONIGENC_IS_MBC_ASCII_WORD(enc,s,end) \
+   onigenc_ascii_is_code_ctype( \
+	ONIGENC_MBC_TO_CODE(enc,s,end),ONIGENC_CTYPE_WORD)
+#define ONIGENC_IS_UNICODE(enc)        ((enc)->flags & ONIGENC_FLAG_UNICODE)
+
+
+#define ONIGENC_NAME(enc)                      ((enc)->name)
+
+#define ONIGENC_MBC_CASE_FOLD(enc,flag,pp,end,buf) \
+  (enc)->mbc_case_fold(flag,(const OnigUChar** )pp,end,buf)
+#define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \
+        (enc)->is_allowed_reverse_match(s,end)
+#define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \
+        (enc)->left_adjust_char_head(start, s)
+#define ONIGENC_APPLY_ALL_CASE_FOLD(enc,case_fold_flag,f,arg) \
+        (enc)->apply_all_case_fold(case_fold_flag,f,arg)
+#define ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc,case_fold_flag,p,end,acs) \
+       (enc)->get_case_fold_codes_by_str(case_fold_flag,p,end,acs)
+#define ONIGENC_STEP_BACK(enc,start,s,n) \
+        onigenc_step_back((enc),(start),(s),(n))
+
+#define ONIGENC_MBC_ENC_LEN(enc,p)             (enc)->mbc_enc_len(p)
+#define ONIGENC_MBC_MAXLEN(enc)               ((enc)->max_enc_len)
+#define ONIGENC_MBC_MAXLEN_DIST(enc)           ONIGENC_MBC_MAXLEN(enc)
+#define ONIGENC_MBC_MINLEN(enc)               ((enc)->min_enc_len)
+#define ONIGENC_IS_MBC_NEWLINE(enc,p,end)      (enc)->is_mbc_newline((p),(end))
+#define ONIGENC_MBC_TO_CODE(enc,p,end)         (enc)->mbc_to_code((p),(end))
+#define ONIGENC_CODE_TO_MBCLEN(enc,code)       (enc)->code_to_mbclen(code)
+#define ONIGENC_CODE_TO_MBC(enc,code,buf)      (enc)->code_to_mbc(code,buf)
+#define ONIGENC_PROPERTY_NAME_TO_CTYPE(enc,p,end) \
+  (enc)->property_name_to_ctype(enc,p,end)
+
+#define ONIGENC_IS_CODE_CTYPE(enc,code,ctype)  (enc)->is_code_ctype(code,ctype)
+
+#define ONIGENC_IS_CODE_NEWLINE(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_NEWLINE)
+#define ONIGENC_IS_CODE_GRAPH(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_GRAPH)
+#define ONIGENC_IS_CODE_PRINT(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PRINT)
+#define ONIGENC_IS_CODE_ALNUM(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALNUM)
+#define ONIGENC_IS_CODE_ALPHA(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALPHA)
+#define ONIGENC_IS_CODE_LOWER(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_LOWER)
+#define ONIGENC_IS_CODE_UPPER(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_UPPER)
+#define ONIGENC_IS_CODE_CNTRL(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_CNTRL)
+#define ONIGENC_IS_CODE_PUNCT(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PUNCT)
+#define ONIGENC_IS_CODE_SPACE(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_SPACE)
+#define ONIGENC_IS_CODE_BLANK(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_BLANK)
+#define ONIGENC_IS_CODE_DIGIT(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_DIGIT)
+#define ONIGENC_IS_CODE_XDIGIT(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_XDIGIT)
+#define ONIGENC_IS_CODE_WORD(enc,code) \
+        ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_WORD)
+
+#define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbout,ranges) \
+        (enc)->get_ctype_code_range(ctype,sbout,ranges)
+
+ONIG_EXTERN
+OnigUChar* onigenc_step_back P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, int n));
+
+
+/* encoding API */
+ONIG_EXTERN
+int onigenc_init P_((void));
+ONIG_EXTERN
+int onigenc_set_default_encoding P_((OnigEncoding enc));
+ONIG_EXTERN
+OnigEncoding onigenc_get_default_encoding P_((void));
+ONIG_EXTERN
+void  onigenc_set_default_caseconv_table P_((const OnigUChar* table));
+ONIG_EXTERN
+OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar** prev));
+ONIG_EXTERN
+OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
+ONIG_EXTERN
+OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
+ONIG_EXTERN
+OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
+ONIG_EXTERN
+int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));
+ONIG_EXTERN
+int onigenc_strlen_null P_((OnigEncoding enc, const OnigUChar* p));
+ONIG_EXTERN
+int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p));
+
+
+
+/* PART: regular expression */
+
+/* config parameters */
+#define ONIG_NREGION                          10
+#define ONIG_MAX_BACKREF_NUM                1000
+#define ONIG_MAX_CAPTURE_GROUP_NUM         32767
+#define ONIG_MAX_REPEAT_NUM               100000
+#define ONIG_MAX_MULTI_BYTE_RANGES_NUM     10000
+/* constants */
+#define ONIG_MAX_ERROR_MESSAGE_LEN            90
+
+typedef unsigned int        OnigOptionType;
+
+#define ONIG_OPTION_DEFAULT            ONIG_OPTION_NONE
+
+/* options */
+#define ONIG_OPTION_NONE                 0U
+#define ONIG_OPTION_IGNORECASE           1U
+#define ONIG_OPTION_EXTEND               (ONIG_OPTION_IGNORECASE         << 1)
+#define ONIG_OPTION_MULTILINE            (ONIG_OPTION_EXTEND             << 1)
+#define ONIG_OPTION_DOTALL                ONIG_OPTION_MULTILINE
+#define ONIG_OPTION_SINGLELINE           (ONIG_OPTION_MULTILINE          << 1)
+#define ONIG_OPTION_FIND_LONGEST         (ONIG_OPTION_SINGLELINE         << 1)
+#define ONIG_OPTION_FIND_NOT_EMPTY       (ONIG_OPTION_FIND_LONGEST       << 1)
+#define ONIG_OPTION_NEGATE_SINGLELINE    (ONIG_OPTION_FIND_NOT_EMPTY     << 1)
+#define ONIG_OPTION_DONT_CAPTURE_GROUP   (ONIG_OPTION_NEGATE_SINGLELINE  << 1)
+#define ONIG_OPTION_CAPTURE_GROUP        (ONIG_OPTION_DONT_CAPTURE_GROUP << 1)
+/* options (search time) */
+#define ONIG_OPTION_NOTBOL               (ONIG_OPTION_CAPTURE_GROUP << 1)
+#define ONIG_OPTION_NOTEOL               (ONIG_OPTION_NOTBOL << 1)
+#define ONIG_OPTION_POSIX_REGION         (ONIG_OPTION_NOTEOL << 1)
+/* options (ctype range) */
+#define ONIG_OPTION_ASCII_RANGE          (ONIG_OPTION_POSIX_REGION << 1)
+#define ONIG_OPTION_POSIX_BRACKET_ALL_RANGE (ONIG_OPTION_ASCII_RANGE << 1)
+#define ONIG_OPTION_WORD_BOUND_ALL_RANGE    (ONIG_OPTION_POSIX_BRACKET_ALL_RANGE << 1)
+/* options (newline) */
+#define ONIG_OPTION_NEWLINE_CRLF         (ONIG_OPTION_WORD_BOUND_ALL_RANGE << 1)
+#define ONIG_OPTION_NOTBOS               (ONIG_OPTION_NEWLINE_CRLF << 1)
+#define ONIG_OPTION_NOTEOS               (ONIG_OPTION_NOTBOS << 1)
+#define ONIG_OPTION_MAXBIT               ONIG_OPTION_NOTEOS  /* limit */
+
+#define ONIG_OPTION_ON(options,regopt)      ((options) |= (regopt))
+#define ONIG_OPTION_OFF(options,regopt)     ((options) &= ~(regopt))
+#define ONIG_IS_OPTION_ON(options,option)   ((options) & (option))
+
+/* syntax */
+typedef struct {
+  unsigned int   op;
+  unsigned int   op2;
+  unsigned int   behavior;
+  OnigOptionType options;   /* default option */
+  OnigMetaCharTableType meta_char_table;
+} OnigSyntaxType;
+
+ONIG_EXTERN OnigSyntaxType OnigSyntaxASIS;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl58;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl58_NG;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
+ONIG_EXTERN OnigSyntaxType OnigSyntaxPython;
+
+/* predefined syntaxes (see regsyntax.c) */
+#define ONIG_SYNTAX_ASIS               (&OnigSyntaxASIS)
+#define ONIG_SYNTAX_POSIX_BASIC        (&OnigSyntaxPosixBasic)
+#define ONIG_SYNTAX_POSIX_EXTENDED     (&OnigSyntaxPosixExtended)
+#define ONIG_SYNTAX_EMACS              (&OnigSyntaxEmacs)
+#define ONIG_SYNTAX_GREP               (&OnigSyntaxGrep)
+#define ONIG_SYNTAX_GNU_REGEX          (&OnigSyntaxGnuRegex)
+#define ONIG_SYNTAX_JAVA               (&OnigSyntaxJava)
+#define ONIG_SYNTAX_PERL58             (&OnigSyntaxPerl58)
+#define ONIG_SYNTAX_PERL58_NG          (&OnigSyntaxPerl58_NG)
+#define ONIG_SYNTAX_PERL               (&OnigSyntaxPerl)
+#define ONIG_SYNTAX_RUBY               (&OnigSyntaxRuby)
+#define ONIG_SYNTAX_PYTHON             (&OnigSyntaxPython)
+
+/* default syntax */
+ONIG_EXTERN OnigSyntaxType*   OnigDefaultSyntax;
+#define ONIG_SYNTAX_DEFAULT   OnigDefaultSyntax
+
+/* syntax (operators) */
+#define ONIG_SYN_OP_VARIABLE_META_CHARACTERS    (1U<<0)
+#define ONIG_SYN_OP_DOT_ANYCHAR                 (1U<<1)   /* . */
+#define ONIG_SYN_OP_ASTERISK_ZERO_INF           (1U<<2)   /* * */
+#define ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF       (1U<<3)
+#define ONIG_SYN_OP_PLUS_ONE_INF                (1U<<4)   /* + */
+#define ONIG_SYN_OP_ESC_PLUS_ONE_INF            (1U<<5)
+#define ONIG_SYN_OP_QMARK_ZERO_ONE              (1U<<6)   /* ? */
+#define ONIG_SYN_OP_ESC_QMARK_ZERO_ONE          (1U<<7)
+#define ONIG_SYN_OP_BRACE_INTERVAL              (1U<<8)   /* {lower,upper} */
+#define ONIG_SYN_OP_ESC_BRACE_INTERVAL          (1U<<9)   /* \{lower,upper\} */
+#define ONIG_SYN_OP_VBAR_ALT                    (1U<<10)   /* | */
+#define ONIG_SYN_OP_ESC_VBAR_ALT                (1U<<11)  /* \| */
+#define ONIG_SYN_OP_LPAREN_SUBEXP               (1U<<12)  /* (...)   */
+#define ONIG_SYN_OP_ESC_LPAREN_SUBEXP           (1U<<13)  /* \(...\) */
+#define ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR           (1U<<14)  /* \A, \Z, \z */
+#define ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR  (1U<<15)  /* \G     */
+#define ONIG_SYN_OP_DECIMAL_BACKREF             (1U<<16)  /* \num   */
+#define ONIG_SYN_OP_BRACKET_CC                  (1U<<17)  /* [...]  */
+#define ONIG_SYN_OP_ESC_W_WORD                  (1U<<18)  /* \w, \W */
+#define ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END     (1U<<19)  /* \<. \> */
+#define ONIG_SYN_OP_ESC_B_WORD_BOUND            (1U<<20)  /* \b, \B */
+#define ONIG_SYN_OP_ESC_S_WHITE_SPACE           (1U<<21)  /* \s, \S */
+#define ONIG_SYN_OP_ESC_D_DIGIT                 (1U<<22)  /* \d, \D */
+#define ONIG_SYN_OP_LINE_ANCHOR                 (1U<<23)  /* ^, $   */
+#define ONIG_SYN_OP_POSIX_BRACKET               (1U<<24)  /* [:xxxx:] */
+#define ONIG_SYN_OP_QMARK_NON_GREEDY            (1U<<25)  /* ??,*?,+?,{n,m}? */
+#define ONIG_SYN_OP_ESC_CONTROL_CHARS           (1U<<26)  /* \n,\r,\t,\a ... */
+#define ONIG_SYN_OP_ESC_C_CONTROL               (1U<<27)  /* \cx  */
+#define ONIG_SYN_OP_ESC_OCTAL3                  (1U<<28)  /* \OOO */
+#define ONIG_SYN_OP_ESC_X_HEX2                  (1U<<29)  /* \xHH */
+#define ONIG_SYN_OP_ESC_X_BRACE_HEX8            (1U<<30)  /* \x{7HHHHHHH} */
+#define ONIG_SYN_OP_ESC_O_BRACE_OCTAL           (1U<<31)  /* \o{OOO} */ /* NOTIMPL */
+
+#define ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE        (1U<<0)  /* \Q...\E */
+#define ONIG_SYN_OP2_QMARK_GROUP_EFFECT         (1U<<1)  /* (?...) */
+#define ONIG_SYN_OP2_OPTION_PERL                (1U<<2)  /* (?imsxadlu), (?-imsx), (?^imsxalu) */
+#define ONIG_SYN_OP2_OPTION_RUBY                (1U<<3)  /* (?imxadu), (?-imx)  */
+#define ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT     (1U<<4)  /* ?+,*+,++ */
+#define ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL   (1U<<5)  /* {n,m}+   */
+#define ONIG_SYN_OP2_CCLASS_SET_OP              (1U<<6)  /* [...&&..[..]..] */
+#define ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP       (1U<<7)  /* (?<name>...) */
+#define ONIG_SYN_OP2_ESC_K_NAMED_BACKREF        (1U<<8)  /* \k<name> */
+#define ONIG_SYN_OP2_ESC_G_SUBEXP_CALL          (1U<<9)  /* \g<name>, \g<n> */
+#define ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY     (1U<<10) /* (?@..),(?@<x>..) */
+#define ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL  (1U<<11) /* \C-x */
+#define ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META     (1U<<12) /* \M-x */
+#define ONIG_SYN_OP2_ESC_V_VTAB                 (1U<<13) /* \v as VTAB */
+#define ONIG_SYN_OP2_ESC_U_HEX4                 (1U<<14) /* \uHHHH */
+#define ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR         (1U<<15) /* \`, \' */
+#define ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY  (1U<<16) /* \p{...}, \P{...} */
+#define ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT (1U<<17) /* \p{^..}, \P{^..} */
+/* #define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS (1U<<18) */
+#define ONIG_SYN_OP2_ESC_H_XDIGIT               (1U<<19) /* \h, \H */
+#define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE         (1U<<20) /* \ */
+#define ONIG_SYN_OP2_ESC_CAPITAL_R_LINEBREAK    (1U<<21) /* \R as (?>\x0D\x0A|[\x0A-\x0D\x{85}\x{2028}\x{2029}]) */
+#define ONIG_SYN_OP2_ESC_CAPITAL_X_EXTENDED_GRAPHEME_CLUSTER (1U<<22) /* \X as (?>\P{M}\p{M}*) */
+#define ONIG_SYN_OP2_ESC_V_VERTICAL_WHITESPACE   (1U<<23) /* \v, \V -- Perl */ /* NOTIMPL */
+#define ONIG_SYN_OP2_ESC_H_HORIZONTAL_WHITESPACE (1U<<24) /* \h, \H -- Perl */ /* NOTIMPL */
+#define ONIG_SYN_OP2_ESC_CAPITAL_K_KEEP         (1U<<25) /* \K */
+#define ONIG_SYN_OP2_ESC_G_BRACE_BACKREF        (1U<<26) /* \g{name}, \g{n} */
+#define ONIG_SYN_OP2_QMARK_SUBEXP_CALL          (1U<<27) /* (?&name), (?n), (?R), (?0) */
+#define ONIG_SYN_OP2_QMARK_VBAR_BRANCH_RESET    (1U<<28) /* (?|...) */         /* NOTIMPL */
+#define ONIG_SYN_OP2_QMARK_LPAREN_CONDITION     (1U<<29) /* (?(cond)yes...|no...) */
+#define ONIG_SYN_OP2_QMARK_CAPITAL_P_NAMED_GROUP (1U<<30) /* (?P<name>...), (?P=name), (?P>name) -- Python/PCRE */
+#define ONIG_SYN_OP2_OPTION_JAVA                (1U<<31) /* (?idmsux), (?-idmsux) */ /* NOTIMPL */
+
+/* syntax (behavior) */
+#define ONIG_SYN_CONTEXT_INDEP_ANCHORS           (1U<<31) /* not implemented */
+#define ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS        (1U<<0)  /* ?, *, +, {n,m} */
+#define ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS      (1U<<1)  /* error or ignore */
+#define ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP    (1U<<2)  /* ...)... */
+#define ONIG_SYN_ALLOW_INVALID_INTERVAL          (1U<<3)  /* {??? */
+#define ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV       (1U<<4)  /* {,n} => {0,n} */
+#define ONIG_SYN_STRICT_CHECK_BACKREF            (1U<<5)  /* /(\1)/,/\1()/ ..*/
+#define ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND   (1U<<6)  /* (?<=a|bc) */
+#define ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP        (1U<<7)  /* see doc/RE */
+#define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME (1U<<8)  /* (?<x>)(?<x>) */
+#define ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY   (1U<<9)  /* a{n}?=(?:a{n})? */
+#define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME_CALL (1U<<10)  /* (?<x>)(?<x>)(?&x) */
+
+/* syntax (behavior) in char class [...] */
+#define ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC      (1U<<20) /* [^...] */
+#define ONIG_SYN_BACKSLASH_ESCAPE_IN_CC          (1U<<21) /* [..\w..] etc.. */
+#define ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC         (1U<<22)
+#define ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC     (1U<<23) /* [0-9-a]=[0-9\-a] */
+/* syntax (behavior) warning */
+#define ONIG_SYN_WARN_CC_OP_NOT_ESCAPED          (1U<<24) /* [,-,] */
+#define ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT    (1U<<25) /* (?:a*)+ */
+
+/* meta character specifiers (onig_set_meta_char()) */
+#define ONIG_META_CHAR_ESCAPE               0
+#define ONIG_META_CHAR_ANYCHAR              1
+#define ONIG_META_CHAR_ANYTIME              2
+#define ONIG_META_CHAR_ZERO_OR_ONE_TIME     3
+#define ONIG_META_CHAR_ONE_OR_MORE_TIME     4
+#define ONIG_META_CHAR_ANYCHAR_ANYTIME      5
+
+#define ONIG_INEFFECTIVE_META_CHAR          0
+
+/* error codes */
+#define ONIG_IS_PATTERN_ERROR(ecode)   ((ecode) <= -100 && (ecode) > -1000)
+/* normal return */
+#define ONIG_NORMAL                                            0
+#define ONIG_MISMATCH                                         -1
+#define ONIG_NO_SUPPORT_CONFIG                                -2
+
+/* internal error */
+#define ONIGERR_MEMORY                                         -5
+#define ONIGERR_TYPE_BUG                                       -6
+#define ONIGERR_PARSER_BUG                                    -11
+#define ONIGERR_STACK_BUG                                     -12
+#define ONIGERR_UNDEFINED_BYTECODE                            -13
+#define ONIGERR_UNEXPECTED_BYTECODE                           -14
+#define ONIGERR_MATCH_STACK_LIMIT_OVER                        -15
+#define ONIGERR_DEFAULT_ENCODING_IS_NOT_SET                   -21
+#define ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR  -22
+/* general error */
+#define ONIGERR_INVALID_ARGUMENT                              -30
+/* syntax error */
+#define ONIGERR_END_PATTERN_AT_LEFT_BRACE                    -100
+#define ONIGERR_END_PATTERN_AT_LEFT_BRACKET                  -101
+#define ONIGERR_EMPTY_CHAR_CLASS                             -102
+#define ONIGERR_PREMATURE_END_OF_CHAR_CLASS                  -103
+#define ONIGERR_END_PATTERN_AT_ESCAPE                        -104
+#define ONIGERR_END_PATTERN_AT_META                          -105
+#define ONIGERR_END_PATTERN_AT_CONTROL                       -106
+#define ONIGERR_META_CODE_SYNTAX                             -108
+#define ONIGERR_CONTROL_CODE_SYNTAX                          -109
+#define ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE             -110
+#define ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE           -111
+#define ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS      -112
+#define ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED      -113
+#define ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID            -114
+#define ONIGERR_NESTED_REPEAT_OPERATOR                       -115
+#define ONIGERR_UNMATCHED_CLOSE_PARENTHESIS                  -116
+#define ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS       -117
+#define ONIGERR_END_PATTERN_IN_GROUP                         -118
+#define ONIGERR_UNDEFINED_GROUP_OPTION                       -119
+#define ONIGERR_INVALID_POSIX_BRACKET_TYPE                   -121
+#define ONIGERR_INVALID_LOOK_BEHIND_PATTERN                  -122
+#define ONIGERR_INVALID_REPEAT_RANGE_PATTERN                 -123
+#define ONIGERR_INVALID_CONDITION_PATTERN                    -124
+/* values error (syntax error) */
+#define ONIGERR_TOO_BIG_NUMBER                               -200
+#define ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE              -201
+#define ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE     -202
+#define ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS                    -203
+#define ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE          -204
+#define ONIGERR_TOO_MANY_MULTI_BYTE_RANGES                   -205
+#define ONIGERR_TOO_SHORT_MULTI_BYTE_STRING                  -206
+#define ONIGERR_TOO_BIG_BACKREF_NUMBER                       -207
+#define ONIGERR_INVALID_BACKREF                              -208
+#define ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED         -209
+#define ONIGERR_TOO_SHORT_DIGITS                             -210
+#define ONIGERR_TOO_LONG_WIDE_CHAR_VALUE                     -212
+#define ONIGERR_EMPTY_GROUP_NAME                             -214
+#define ONIGERR_INVALID_GROUP_NAME                           -215
+#define ONIGERR_INVALID_CHAR_IN_GROUP_NAME                   -216
+#define ONIGERR_UNDEFINED_NAME_REFERENCE                     -217
+#define ONIGERR_UNDEFINED_GROUP_REFERENCE                    -218
+#define ONIGERR_MULTIPLEX_DEFINED_NAME                       -219
+#define ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL               -220
+#define ONIGERR_NEVER_ENDING_RECURSION                       -221
+#define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY        -222
+#define ONIGERR_INVALID_CHAR_PROPERTY_NAME                   -223
+#define ONIGERR_TOO_MANY_CAPTURE_GROUPS                      -224
+#define ONIGERR_INVALID_CODE_POINT_VALUE                     -400
+#define ONIGERR_INVALID_WIDE_CHAR_VALUE                      -400
+#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE                      -401
+#define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION           -402
+#define ONIGERR_INVALID_COMBINATION_OF_OPTIONS               -403
+
+/* errors related to thread */
+#define ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT                -1001
+
+
+/* must be smaller than BIT_STATUS_BITS_NUM (unsigned int * 8) */
+#define ONIG_MAX_CAPTURE_HISTORY_GROUP   31
+#define ONIG_IS_CAPTURE_HISTORY_GROUP(r, i) \
+  ((i) <= ONIG_MAX_CAPTURE_HISTORY_GROUP && (r)->list && (r)->list[i])
+
+typedef struct OnigCaptureTreeNodeStruct {
+  int group;   /* group number */
+  OnigPosition beg;
+  OnigPosition end;
+  int allocated;
+  int num_childs;
+  struct OnigCaptureTreeNodeStruct** childs;
+} OnigCaptureTreeNode;
+
+/* match result region type */
+struct re_registers {
+  int  allocated;
+  int  num_regs;
+  OnigPosition* beg;
+  OnigPosition* end;
+  /* extended */
+  OnigCaptureTreeNode* history_root;  /* capture history tree root */
+};
+
+/* capture tree traverse */
+#define ONIG_TRAVERSE_CALLBACK_AT_FIRST   1
+#define ONIG_TRAVERSE_CALLBACK_AT_LAST    2
+#define ONIG_TRAVERSE_CALLBACK_AT_BOTH \
+  ( ONIG_TRAVERSE_CALLBACK_AT_FIRST | ONIG_TRAVERSE_CALLBACK_AT_LAST )
+
+
+#define ONIG_REGION_NOTPOS            -1
+
+typedef struct re_registers   OnigRegion;
+
+typedef struct {
+  OnigEncoding enc;
+  OnigUChar* par;
+  OnigUChar* par_end;
+} OnigErrorInfo;
+
+typedef struct {
+  int lower;
+  int upper;
+} OnigRepeatRange;
+
+typedef void (*OnigWarnFunc) P_((const char* s));
+extern void onig_null_warn P_((const char* s));
+#define ONIG_NULL_WARN       onig_null_warn
+
+#define ONIG_CHAR_TABLE_SIZE   256
+
+/* regex_t state */
+#define ONIG_STATE_NORMAL              0
+#define ONIG_STATE_SEARCHING           1
+#define ONIG_STATE_COMPILING          -1
+#define ONIG_STATE_MODIFY             -2
+
+#define ONIG_STATE(reg) \
+  ((reg)->state > 0 ? ONIG_STATE_SEARCHING : (reg)->state)
+
+typedef struct re_pattern_buffer {
+  /* common members of BBuf(bytes-buffer) */
+  unsigned char* p;         /* compiled pattern */
+  unsigned int used;        /* used space for p */
+  unsigned int alloc;       /* allocated space for p */
+
+  int state;                     /* normal, searching, compiling */
+  int num_mem;                   /* used memory(...) num counted from 1 */
+  int num_repeat;                /* OP_REPEAT/OP_REPEAT_NG id-counter */
+  int num_null_check;            /* OP_NULL_CHECK_START/END id counter */
+  int num_comb_exp_check;        /* combination explosion check */
+  int num_call;                  /* number of subexp call */
+  unsigned int capture_history;  /* (?@...) flag (1-31) */
+  unsigned int bt_mem_start;     /* need backtrack flag */
+  unsigned int bt_mem_end;       /* need backtrack flag */
+  int stack_pop_level;
+  int repeat_range_alloc;
+  OnigRepeatRange* repeat_range;
+
+  OnigEncoding      enc;
+  OnigOptionType    options;
+  OnigSyntaxType*   syntax;
+  OnigCaseFoldType  case_fold_flag;
+  void*             name_table;
+
+  /* optimization info (string search, char-map and anchors) */
+  int            optimize;          /* optimize flag */
+  int            threshold_len;     /* search str-length for apply optimize */
+  int            anchor;            /* BEGIN_BUF, BEGIN_POS, (SEMI_)END_BUF */
+  OnigDistance   anchor_dmin;       /* (SEMI_)END_BUF anchor distance */
+  OnigDistance   anchor_dmax;       /* (SEMI_)END_BUF anchor distance */
+  int            sub_anchor;        /* start-anchor for exact or map */
+  unsigned char *exact;
+  unsigned char *exact_end;
+  unsigned char  map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */
+  int           *int_map;                   /* BM skip for exact_len > 255 */
+  int           *int_map_backward;          /* BM skip for backward search */
+  OnigDistance   dmin;                      /* min-distance of exact or map */
+  OnigDistance   dmax;                      /* max-distance of exact or map */
+
+  /* regex_t link chain */
+  struct re_pattern_buffer* chain;  /* escape compile-conflict */
+} OnigRegexType;
+
+typedef OnigRegexType*  OnigRegex;
+
+#ifndef ONIG_ESCAPE_REGEX_T_COLLISION
+  typedef OnigRegexType  regex_t;
+#endif
+
+
+typedef struct {
+  int             num_of_elements;
+  OnigEncoding    pattern_enc;
+  OnigEncoding    target_enc;
+  OnigSyntaxType* syntax;
+  OnigOptionType  option;
+  OnigCaseFoldType   case_fold_flag;
+} OnigCompileInfo;
+
+/* Oniguruma Native API */
+ONIG_EXTERN
+int onig_init P_((void));
+ONIG_EXTERN
+int onig_error_code_to_str PV_((OnigUChar* s, OnigPosition err_code, ...));
+ONIG_EXTERN
+void onig_set_warn_func P_((OnigWarnFunc f));
+ONIG_EXTERN
+void onig_set_verb_warn_func P_((OnigWarnFunc f));
+ONIG_EXTERN
+int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
+ONIG_EXTERN
+int onig_reg_init P_((OnigRegex reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, OnigSyntaxType* syntax));
+ONIG_EXTERN
+int onig_new_without_alloc P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
+ONIG_EXTERN
+int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
+ONIG_EXTERN
+void onig_free P_((OnigRegex));
+ONIG_EXTERN
+void onig_free_body P_((OnigRegex));
+ONIG_EXTERN
+int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
+ONIG_EXTERN
+int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
+ONIG_EXTERN
+OnigPosition onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option));
+ONIG_EXTERN
+OnigPosition onig_search_gpos P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* global_pos, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option));
+ONIG_EXTERN
+OnigPosition onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option));
+ONIG_EXTERN
+OnigRegion* onig_region_new P_((void));
+ONIG_EXTERN
+void onig_region_init P_((OnigRegion* region));
+ONIG_EXTERN
+void onig_region_free P_((OnigRegion* region, int free_self));
+ONIG_EXTERN
+void onig_region_copy P_((OnigRegion* to, OnigRegion* from));
+ONIG_EXTERN
+void onig_region_clear P_((OnigRegion* region));
+ONIG_EXTERN
+int onig_region_resize P_((OnigRegion* region, int n));
+ONIG_EXTERN
+int onig_region_set P_((OnigRegion* region, int at, int beg, int end));
+ONIG_EXTERN
+int onig_name_to_group_numbers P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, int** nums));
+ONIG_EXTERN
+int onig_name_to_backref_number P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, OnigRegion *region));
+ONIG_EXTERN
+int onig_foreach_name P_((OnigRegex reg, int (*func)(const OnigUChar*, const OnigUChar*,int,int*,OnigRegex,void*), void* arg));
+ONIG_EXTERN
+int onig_number_of_names P_((OnigRegex reg));
+ONIG_EXTERN
+int onig_number_of_captures P_((OnigRegex reg));
+ONIG_EXTERN
+int onig_number_of_capture_histories P_((OnigRegex reg));
+ONIG_EXTERN
+OnigCaptureTreeNode* onig_get_capture_tree P_((OnigRegion* region));
+ONIG_EXTERN
+int onig_capture_tree_traverse P_((OnigRegion* region, int at, int(*callback_func)(int,OnigPosition,OnigPosition,int,int,void*), void* arg));
+ONIG_EXTERN
+int onig_noname_group_capture_is_active P_((OnigRegex reg));
+ONIG_EXTERN
+OnigEncoding onig_get_encoding P_((OnigRegex reg));
+ONIG_EXTERN
+OnigOptionType onig_get_options P_((OnigRegex reg));
+ONIG_EXTERN
+OnigCaseFoldType onig_get_case_fold_flag P_((OnigRegex reg));
+ONIG_EXTERN
+OnigSyntaxType* onig_get_syntax P_((OnigRegex reg));
+ONIG_EXTERN
+int onig_set_default_syntax P_((OnigSyntaxType* syntax));
+ONIG_EXTERN
+void onig_copy_syntax P_((OnigSyntaxType* to, const OnigSyntaxType* from));
+ONIG_EXTERN
+unsigned int onig_get_syntax_op P_((OnigSyntaxType* syntax));
+ONIG_EXTERN
+unsigned int onig_get_syntax_op2 P_((OnigSyntaxType* syntax));
+ONIG_EXTERN
+unsigned int onig_get_syntax_behavior P_((OnigSyntaxType* syntax));
+ONIG_EXTERN
+OnigOptionType onig_get_syntax_options P_((OnigSyntaxType* syntax));
+ONIG_EXTERN
+void onig_set_syntax_op P_((OnigSyntaxType* syntax, unsigned int op));
+ONIG_EXTERN
+void onig_set_syntax_op2 P_((OnigSyntaxType* syntax, unsigned int op2));
+ONIG_EXTERN
+void onig_set_syntax_behavior P_((OnigSyntaxType* syntax, unsigned int behavior));
+ONIG_EXTERN
+void onig_set_syntax_options P_((OnigSyntaxType* syntax, OnigOptionType options));
+ONIG_EXTERN
+int onig_set_meta_char P_((OnigSyntaxType* syntax, unsigned int what, OnigCodePoint code));
+ONIG_EXTERN
+void onig_copy_encoding P_((OnigEncoding to, OnigEncoding from));
+ONIG_EXTERN
+OnigCaseFoldType onig_get_default_case_fold_flag P_((void));
+ONIG_EXTERN
+int onig_set_default_case_fold_flag P_((OnigCaseFoldType case_fold_flag));
+ONIG_EXTERN
+unsigned int onig_get_match_stack_limit_size P_((void));
+ONIG_EXTERN
+int onig_set_match_stack_limit_size P_((unsigned int size));
+ONIG_EXTERN
+int onig_end P_((void));
+ONIG_EXTERN
+const char* onig_version P_((void));
+ONIG_EXTERN
+const char* onig_copyright P_((void));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ONIGURUMA_H */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regcomp.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regcomp.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regcomp.c	(revision 279)
@@ -0,0 +1,6747 @@
+/**********************************************************************
+  regcomp.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2013  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regparse.h"
+
+#if defined(USE_MULTI_THREAD_SYSTEM) \
+  && defined(USE_DEFAULT_MULTI_THREAD_SYSTEM)
+#ifdef _WIN32
+CRITICAL_SECTION gOnigMutex;
+#else
+pthread_mutex_t gOnigMutex;
+#endif
+#endif
+
+OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN;
+
+extern OnigCaseFoldType
+onig_get_default_case_fold_flag(void)
+{
+  return OnigDefaultCaseFoldFlag;
+}
+
+extern int
+onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag)
+{
+  OnigDefaultCaseFoldFlag = case_fold_flag;
+  return 0;
+}
+
+
+#ifndef PLATFORM_UNALIGNED_WORD_ACCESS
+static unsigned char PadBuf[WORD_ALIGNMENT_SIZE];
+#endif
+
+#if 0
+static UChar*
+str_dup(UChar* s, UChar* end)
+{
+  ptrdiff_t len = end - s;
+
+  if (len > 0) {
+    UChar* r = (UChar* )xmalloc(len + 1);
+    CHECK_NULL_RETURN(r);
+    xmemcpy(r, s, len);
+    r[len] = (UChar )0;
+    return r;
+  }
+  else return NULL;
+}
+#endif
+
+static void
+swap_node(Node* a, Node* b)
+{
+  Node c;
+  c = *a; *a = *b; *b = c;
+
+  if (NTYPE(a) == NT_STR) {
+    StrNode* sn = NSTR(a);
+    if (sn->capa == 0) {
+      size_t len = sn->end - sn->s;
+      sn->s   = sn->buf;
+      sn->end = sn->s + len;
+    }
+  }
+
+  if (NTYPE(b) == NT_STR) {
+    StrNode* sn = NSTR(b);
+    if (sn->capa == 0) {
+      size_t len = sn->end - sn->s;
+      sn->s   = sn->buf;
+      sn->end = sn->s + len;
+    }
+  }
+}
+
+static OnigDistance
+distance_add(OnigDistance d1, OnigDistance d2)
+{
+  if (d1 == ONIG_INFINITE_DISTANCE || d2 == ONIG_INFINITE_DISTANCE)
+    return ONIG_INFINITE_DISTANCE;
+  else {
+    if (d1 <= ONIG_INFINITE_DISTANCE - d2) return d1 + d2;
+    else return ONIG_INFINITE_DISTANCE;
+  }
+}
+
+static OnigDistance
+distance_multiply(OnigDistance d, int m)
+{
+  if (m == 0) return 0;
+
+  if (d < ONIG_INFINITE_DISTANCE / m)
+    return d * m;
+  else
+    return ONIG_INFINITE_DISTANCE;
+}
+
+static int
+bitset_is_empty(BitSetRef bs)
+{
+  int i;
+  for (i = 0; i < BITSET_SIZE; i++) {
+    if (bs[i] != 0) return 0;
+  }
+  return 1;
+}
+
+#ifdef ONIG_DEBUG
+static int
+bitset_on_num(BitSetRef bs)
+{
+  int i, n;
+
+  n = 0;
+  for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
+    if (BITSET_AT(bs, i)) n++;
+  }
+  return n;
+}
+#endif
+
+extern int
+onig_bbuf_init(BBuf* buf, OnigDistance size)
+{
+  if (size <= 0) {
+    size   = 0;
+    buf->p = NULL;
+  }
+  else {
+    buf->p = (UChar* )xmalloc(size);
+    if (IS_NULL(buf->p)) return(ONIGERR_MEMORY);
+  }
+
+  buf->alloc = (unsigned int )size;
+  buf->used  = 0;
+  return 0;
+}
+
+
+#ifdef USE_SUBEXP_CALL
+
+static int
+unset_addr_list_init(UnsetAddrList* uslist, int size)
+{
+  UnsetAddr* p;
+
+  p = (UnsetAddr* )xmalloc(sizeof(UnsetAddr)* size);
+  CHECK_NULL_RETURN_MEMERR(p);
+  uslist->num   = 0;
+  uslist->alloc = size;
+  uslist->us    = p;
+  return 0;
+}
+
+static void
+unset_addr_list_end(UnsetAddrList* uslist)
+{
+  if (IS_NOT_NULL(uslist->us))
+    xfree(uslist->us);
+}
+
+static int
+unset_addr_list_add(UnsetAddrList* uslist, int offset, struct _Node* node)
+{
+  UnsetAddr* p;
+  int size;
+
+  if (uslist->num >= uslist->alloc) {
+    size = uslist->alloc * 2;
+    p = (UnsetAddr* )xrealloc(uslist->us, sizeof(UnsetAddr) * size);
+    CHECK_NULL_RETURN_MEMERR(p);
+    uslist->alloc = size;
+    uslist->us    = p;
+  }
+
+  uslist->us[uslist->num].offset = offset;
+  uslist->us[uslist->num].target = node;
+  uslist->num++;
+  return 0;
+}
+#endif /* USE_SUBEXP_CALL */
+
+
+static int
+add_opcode(regex_t* reg, int opcode)
+{
+  BBUF_ADD1(reg, opcode);
+  return 0;
+}
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+static int
+add_state_check_num(regex_t* reg, int num)
+{
+  StateCheckNumType n = (StateCheckNumType )num;
+
+  BBUF_ADD(reg, &n, SIZE_STATE_CHECK_NUM);
+  return 0;
+}
+#endif
+
+static int
+add_rel_addr(regex_t* reg, int addr)
+{
+  RelAddrType ra = (RelAddrType )addr;
+
+  BBUF_ADD(reg, &ra, SIZE_RELADDR);
+  return 0;
+}
+
+static int
+add_abs_addr(regex_t* reg, int addr)
+{
+  AbsAddrType ra = (AbsAddrType )addr;
+
+  BBUF_ADD(reg, &ra, SIZE_ABSADDR);
+  return 0;
+}
+
+static int
+add_length(regex_t* reg, OnigDistance len)
+{
+  LengthType l = (LengthType )len;
+
+  BBUF_ADD(reg, &l, SIZE_LENGTH);
+  return 0;
+}
+
+static int
+add_mem_num(regex_t* reg, int num)
+{
+  MemNumType n = (MemNumType )num;
+
+  BBUF_ADD(reg, &n, SIZE_MEMNUM);
+  return 0;
+}
+
+static int
+add_pointer(regex_t* reg, void* addr)
+{
+  PointerType ptr = (PointerType )addr;
+
+  BBUF_ADD(reg, &ptr, SIZE_POINTER);
+  return 0;
+}
+
+static int
+add_option(regex_t* reg, OnigOptionType option)
+{
+  BBUF_ADD(reg, &option, SIZE_OPTION);
+  return 0;
+}
+
+static int
+add_opcode_rel_addr(regex_t* reg, int opcode, int addr)
+{
+  int r;
+
+  r = add_opcode(reg, opcode);
+  if (r) return r;
+  r = add_rel_addr(reg, addr);
+  return r;
+}
+
+static int
+add_bytes(regex_t* reg, UChar* bytes, OnigDistance len)
+{
+  BBUF_ADD(reg, bytes, len);
+  return 0;
+}
+
+static int
+add_bitset(regex_t* reg, BitSetRef bs)
+{
+  BBUF_ADD(reg, bs, SIZE_BITSET);
+  return 0;
+}
+
+static int
+add_opcode_option(regex_t* reg, int opcode, OnigOptionType option)
+{
+  int r;
+
+  r = add_opcode(reg, opcode);
+  if (r) return r;
+  r = add_option(reg, option);
+  return r;
+}
+
+static int compile_length_tree(Node* node, regex_t* reg);
+static int compile_tree(Node* node, regex_t* reg);
+
+
+#define IS_NEED_STR_LEN_OP_EXACT(op) \
+   ((op) == OP_EXACTN    || (op) == OP_EXACTMB2N ||\
+    (op) == OP_EXACTMB3N || (op) == OP_EXACTMBN  || (op) == OP_EXACTN_IC)
+
+static int
+select_str_opcode(int mb_len, OnigDistance byte_len, int ignore_case)
+{
+  int op;
+  OnigDistance str_len = (byte_len + mb_len - 1) / mb_len;
+
+  if (ignore_case) {
+    switch (str_len) {
+    case 1:  op = OP_EXACT1_IC; break;
+    default: op = OP_EXACTN_IC; break;
+    }
+  }
+  else {
+    switch (mb_len) {
+    case 1:
+      switch (str_len) {
+      case 1:  op = OP_EXACT1; break;
+      case 2:  op = OP_EXACT2; break;
+      case 3:  op = OP_EXACT3; break;
+      case 4:  op = OP_EXACT4; break;
+      case 5:  op = OP_EXACT5; break;
+      default: op = OP_EXACTN; break;
+      }
+      break;
+
+    case 2:
+      switch (str_len) {
+      case 1:  op = OP_EXACTMB2N1; break;
+      case 2:  op = OP_EXACTMB2N2; break;
+      case 3:  op = OP_EXACTMB2N3; break;
+      default: op = OP_EXACTMB2N;  break;
+      }
+      break;
+
+    case 3:
+      op = OP_EXACTMB3N;
+      break;
+
+    default:
+      op = OP_EXACTMBN;
+      break;
+    }
+  }
+  return op;
+}
+
+static int
+compile_tree_empty_check(Node* node, regex_t* reg, int empty_info)
+{
+  int r;
+  int saved_num_null_check = reg->num_null_check;
+
+  if (empty_info != 0) {
+    r = add_opcode(reg, OP_NULL_CHECK_START);
+    if (r) return r;
+    r = add_mem_num(reg, reg->num_null_check); /* NULL CHECK ID */
+    if (r) return r;
+    reg->num_null_check++;
+  }
+
+  r = compile_tree(node, reg);
+  if (r) return r;
+
+  if (empty_info != 0) {
+    if (empty_info == NQ_TARGET_IS_EMPTY)
+      r = add_opcode(reg, OP_NULL_CHECK_END);
+    else if (empty_info == NQ_TARGET_IS_EMPTY_MEM)
+      r = add_opcode(reg, OP_NULL_CHECK_END_MEMST);
+    else if (empty_info == NQ_TARGET_IS_EMPTY_REC)
+      r = add_opcode(reg, OP_NULL_CHECK_END_MEMST_PUSH);
+
+    if (r) return r;
+    r = add_mem_num(reg, saved_num_null_check); /* NULL CHECK ID */
+  }
+  return r;
+}
+
+#ifdef USE_SUBEXP_CALL
+static int
+compile_call(CallNode* node, regex_t* reg)
+{
+  int r;
+
+  r = add_opcode(reg, OP_CALL);
+  if (r) return r;
+  r = unset_addr_list_add(node->unset_addr_list, BBUF_GET_OFFSET_POS(reg),
+                          node->target);
+  if (r) return r;
+  r = add_abs_addr(reg, 0 /*dummy addr.*/);
+  return r;
+}
+#endif
+
+static int
+compile_tree_n_times(Node* node, int n, regex_t* reg)
+{
+  int i, r;
+
+  for (i = 0; i < n; i++) {
+    r = compile_tree(node, reg);
+    if (r) return r;
+  }
+  return 0;
+}
+
+static int
+add_compile_string_length(UChar* s ARG_UNUSED, int mb_len, OnigDistance byte_len,
+                          regex_t* reg ARG_UNUSED, int ignore_case)
+{
+  int len;
+  int op = select_str_opcode(mb_len, byte_len, ignore_case);
+
+  len = SIZE_OPCODE;
+
+  if (op == OP_EXACTMBN)  len += SIZE_LENGTH;
+  if (IS_NEED_STR_LEN_OP_EXACT(op))
+    len += SIZE_LENGTH;
+
+  len += (int )byte_len;
+  return len;
+}
+
+static int
+add_compile_string(UChar* s, int mb_len, OnigDistance byte_len,
+                   regex_t* reg, int ignore_case)
+{
+  int op = select_str_opcode(mb_len, byte_len, ignore_case);
+  add_opcode(reg, op);
+
+  if (op == OP_EXACTMBN)
+    add_length(reg, mb_len);
+
+  if (IS_NEED_STR_LEN_OP_EXACT(op)) {
+    if (op == OP_EXACTN_IC)
+      add_length(reg, byte_len);
+    else
+      add_length(reg, byte_len / mb_len);
+  }
+
+  add_bytes(reg, s, byte_len);
+  return 0;
+}
+
+
+static int
+compile_length_string_node(Node* node, regex_t* reg)
+{
+  int rlen, r, len, prev_len, blen, ambig;
+  OnigEncoding enc = reg->enc;
+  UChar *p, *prev;
+  StrNode* sn;
+
+  sn = NSTR(node);
+  if (sn->end <= sn->s)
+    return 0;
+
+  ambig = NSTRING_IS_AMBIG(node);
+
+  p = prev = sn->s;
+  prev_len = enclen(enc, p);
+  p += prev_len;
+  blen = prev_len;
+  rlen = 0;
+
+  for (; p < sn->end; ) {
+    len = enclen(enc, p);
+    if (len == prev_len || ambig) {
+      blen += len;
+    }
+    else {
+      r = add_compile_string_length(prev, prev_len, blen, reg, ambig);
+      rlen += r;
+      prev = p;
+      blen = len;
+      prev_len = len;
+    }
+    p += len;
+  }
+  r = add_compile_string_length(prev, prev_len, blen, reg, ambig);
+  rlen += r;
+  return rlen;
+}
+
+static int
+compile_length_string_raw_node(StrNode* sn, regex_t* reg)
+{
+  if (sn->end <= sn->s)
+    return 0;
+
+  return add_compile_string_length(sn->s, 1 /* sb */, sn->end - sn->s, reg, 0);
+}
+
+static int
+compile_string_node(Node* node, regex_t* reg)
+{
+  int r, len, prev_len, blen, ambig;
+  OnigEncoding enc = reg->enc;
+  UChar *p, *prev, *end;
+  StrNode* sn;
+
+  sn = NSTR(node);
+  if (sn->end <= sn->s)
+    return 0;
+
+  end = sn->end;
+  ambig = NSTRING_IS_AMBIG(node);
+
+  p = prev = sn->s;
+  prev_len = enclen(enc, p);
+  p += prev_len;
+  blen = prev_len;
+
+  for (; p < end; ) {
+    len = enclen(enc, p);
+    if (len == prev_len || ambig) {
+      blen += len;
+    }
+    else {
+      r = add_compile_string(prev, prev_len, blen, reg, ambig);
+      if (r) return r;
+
+      prev  = p;
+      blen  = len;
+      prev_len = len;
+    }
+
+    p += len;
+  }
+  return add_compile_string(prev, prev_len, blen, reg, ambig);
+}
+
+static int
+compile_string_raw_node(StrNode* sn, regex_t* reg)
+{
+  if (sn->end <= sn->s)
+    return 0;
+
+  return add_compile_string(sn->s, 1 /* sb */, sn->end - sn->s, reg, 0);
+}
+
+static int
+add_multi_byte_cclass(BBuf* mbuf, regex_t* reg)
+{
+#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
+  add_length(reg, mbuf->used);
+  return add_bytes(reg, mbuf->p, mbuf->used);
+#else
+  int r, pad_size;
+  UChar* p = BBUF_GET_ADD_ADDRESS(reg) + SIZE_LENGTH;
+
+  GET_ALIGNMENT_PAD_SIZE(p, pad_size);
+  add_length(reg, mbuf->used + (WORD_ALIGNMENT_SIZE - 1));
+  if (pad_size != 0) add_bytes(reg, PadBuf, pad_size);
+
+  r = add_bytes(reg, mbuf->p, mbuf->used);
+
+  /* padding for return value from compile_length_cclass_node() to be fix. */
+  pad_size = (WORD_ALIGNMENT_SIZE - 1) - pad_size;
+  if (pad_size != 0) add_bytes(reg, PadBuf, pad_size);
+  return r;
+#endif
+}
+
+static int
+compile_length_cclass_node(CClassNode* cc, regex_t* reg)
+{
+  int len;
+
+  if (IS_NCCLASS_SHARE(cc)) {
+    len = SIZE_OPCODE + SIZE_POINTER;
+    return len;
+  }
+
+  if (IS_NULL(cc->mbuf)) {
+    len = SIZE_OPCODE + SIZE_BITSET;
+  }
+  else {
+    if (ONIGENC_MBC_MINLEN(reg->enc) > 1 || bitset_is_empty(cc->bs)) {
+      len = SIZE_OPCODE;
+    }
+    else {
+      len = SIZE_OPCODE + SIZE_BITSET;
+    }
+#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
+    len += SIZE_LENGTH + cc->mbuf->used;
+#else
+    len += SIZE_LENGTH + cc->mbuf->used + (WORD_ALIGNMENT_SIZE - 1);
+#endif
+  }
+
+  return len;
+}
+
+static int
+compile_cclass_node(CClassNode* cc, regex_t* reg)
+{
+  int r;
+
+  if (IS_NCCLASS_SHARE(cc)) {
+    add_opcode(reg, OP_CCLASS_NODE);
+    r = add_pointer(reg, cc);
+    return r;
+  }
+
+  if (IS_NULL(cc->mbuf)) {
+    if (IS_NCCLASS_NOT(cc))
+      add_opcode(reg, OP_CCLASS_NOT);
+    else
+      add_opcode(reg, OP_CCLASS);
+
+    r = add_bitset(reg, cc->bs);
+  }
+  else {
+    if (ONIGENC_MBC_MINLEN(reg->enc) > 1 || bitset_is_empty(cc->bs)) {
+      if (IS_NCCLASS_NOT(cc))
+        add_opcode(reg, OP_CCLASS_MB_NOT);
+      else
+        add_opcode(reg, OP_CCLASS_MB);
+
+      r = add_multi_byte_cclass(cc->mbuf, reg);
+    }
+    else {
+      if (IS_NCCLASS_NOT(cc))
+        add_opcode(reg, OP_CCLASS_MIX_NOT);
+      else
+        add_opcode(reg, OP_CCLASS_MIX);
+
+      r = add_bitset(reg, cc->bs);
+      if (r) return r;
+      r = add_multi_byte_cclass(cc->mbuf, reg);
+    }
+  }
+
+  return r;
+}
+
+static int
+entry_repeat_range(regex_t* reg, int id, int lower, int upper)
+{
+#define REPEAT_RANGE_ALLOC  4
+
+  OnigRepeatRange* p;
+
+  if (reg->repeat_range_alloc == 0) {
+    p = (OnigRepeatRange* )xmalloc(sizeof(OnigRepeatRange) * REPEAT_RANGE_ALLOC);
+    CHECK_NULL_RETURN_MEMERR(p);
+    reg->repeat_range = p;
+    reg->repeat_range_alloc = REPEAT_RANGE_ALLOC;
+  }
+  else if (reg->repeat_range_alloc <= id) {
+    int n;
+    n = reg->repeat_range_alloc + REPEAT_RANGE_ALLOC;
+    p = (OnigRepeatRange* )xrealloc(reg->repeat_range,
+                                    sizeof(OnigRepeatRange) * n);
+    CHECK_NULL_RETURN_MEMERR(p);
+    reg->repeat_range = p;
+    reg->repeat_range_alloc = n;
+  }
+  else {
+    p = reg->repeat_range;
+  }
+
+  p[id].lower = lower;
+  p[id].upper = (IS_REPEAT_INFINITE(upper) ? 0x7fffffff : upper);
+  return 0;
+}
+
+static int
+compile_range_repeat_node(QtfrNode* qn, int target_len, int empty_info,
+                          regex_t* reg)
+{
+  int r;
+  int num_repeat = reg->num_repeat;
+
+  r = add_opcode(reg, qn->greedy ? OP_REPEAT : OP_REPEAT_NG);
+  if (r) return r;
+  r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */
+  reg->num_repeat++;
+  if (r) return r;
+  r = add_rel_addr(reg, target_len + SIZE_OP_REPEAT_INC);
+  if (r) return r;
+
+  r = entry_repeat_range(reg, num_repeat, qn->lower, qn->upper);
+  if (r) return r;
+
+  r = compile_tree_empty_check(qn->target, reg, empty_info);
+  if (r) return r;
+
+  if (
+#ifdef USE_SUBEXP_CALL
+      reg->num_call > 0 ||
+#endif
+      IS_QUANTIFIER_IN_REPEAT(qn)) {
+    r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC_SG : OP_REPEAT_INC_NG_SG);
+  }
+  else {
+    r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC : OP_REPEAT_INC_NG);
+  }
+  if (r) return r;
+  r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */
+  return r;
+}
+
+static int
+is_anychar_star_quantifier(QtfrNode* qn)
+{
+  if (qn->greedy && IS_REPEAT_INFINITE(qn->upper) &&
+      NTYPE(qn->target) == NT_CANY)
+    return 1;
+  else
+    return 0;
+}
+
+#define QUANTIFIER_EXPAND_LIMIT_SIZE   50
+#define CKN_ON   (ckn > 0)
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+
+static int
+compile_length_quantifier_node(QtfrNode* qn, regex_t* reg)
+{
+  int len, mod_tlen, cklen;
+  int ckn;
+  int infinite = IS_REPEAT_INFINITE(qn->upper);
+  int empty_info = qn->target_empty_info;
+  int tlen = compile_length_tree(qn->target, reg);
+
+  if (tlen < 0) return tlen;
+
+  ckn = ((reg->num_comb_exp_check > 0) ? qn->comb_exp_check_num : 0);
+
+  cklen = (CKN_ON ? SIZE_STATE_CHECK_NUM: 0);
+
+  /* anychar repeat */
+  if (NTYPE(qn->target) == NT_CANY) {
+    if (qn->greedy && infinite) {
+      if (IS_NOT_NULL(qn->next_head_exact) && !CKN_ON)
+        return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower + cklen;
+      else
+        return SIZE_OP_ANYCHAR_STAR + tlen * qn->lower + cklen;
+    }
+  }
+
+  if (empty_info != 0)
+    mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
+  else
+    mod_tlen = tlen;
+
+  if (infinite && qn->lower <= 1) {
+    if (qn->greedy) {
+      if (qn->lower == 1)
+	len = SIZE_OP_JUMP;
+      else
+	len = 0;
+
+      len += SIZE_OP_PUSH + cklen + mod_tlen + SIZE_OP_JUMP;
+    }
+    else {
+      if (qn->lower == 0)
+	len = SIZE_OP_JUMP;
+      else
+	len = 0;
+
+      len += mod_tlen + SIZE_OP_PUSH + cklen;
+    }
+  }
+  else if (qn->upper == 0) {
+    if (qn->is_refered != 0) /* /(?<n>..){0}/ */
+      len = SIZE_OP_JUMP + tlen;
+    else
+      len = 0;
+  }
+  else if (qn->upper == 1 && qn->greedy) {
+    if (qn->lower == 0) {
+      if (CKN_ON) {
+	len = SIZE_OP_STATE_CHECK_PUSH + tlen;
+      }
+      else {
+	len = SIZE_OP_PUSH + tlen;
+      }
+    }
+    else {
+      len = tlen;
+    }
+  }
+  else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
+    len = SIZE_OP_PUSH + cklen + SIZE_OP_JUMP + tlen;
+  }
+  else {
+    len = SIZE_OP_REPEAT_INC
+        + mod_tlen + SIZE_OPCODE + SIZE_RELADDR + SIZE_MEMNUM;
+    if (CKN_ON)
+      len += SIZE_OP_STATE_CHECK;
+  }
+
+  return len;
+}
+
+static int
+compile_quantifier_node(QtfrNode* qn, regex_t* reg)
+{
+  int r, mod_tlen;
+  int ckn;
+  int infinite = IS_REPEAT_INFINITE(qn->upper);
+  int empty_info = qn->target_empty_info;
+  int tlen = compile_length_tree(qn->target, reg);
+
+  if (tlen < 0) return tlen;
+
+  ckn = ((reg->num_comb_exp_check > 0) ? qn->comb_exp_check_num : 0);
+
+  if (is_anychar_star_quantifier(qn)) {
+    r = compile_tree_n_times(qn->target, qn->lower, reg);
+    if (r) return r;
+    if (IS_NOT_NULL(qn->next_head_exact) && !CKN_ON) {
+      if (IS_MULTILINE(reg->options))
+	r = add_opcode(reg, OP_ANYCHAR_ML_STAR_PEEK_NEXT);
+      else
+	r = add_opcode(reg, OP_ANYCHAR_STAR_PEEK_NEXT);
+      if (r) return r;
+      if (CKN_ON) {
+	r = add_state_check_num(reg, ckn);
+	if (r) return r;
+      }
+
+      return add_bytes(reg, NSTR(qn->next_head_exact)->s, 1);
+    }
+    else {
+      if (IS_MULTILINE(reg->options)) {
+	r = add_opcode(reg, (CKN_ON ?
+			       OP_STATE_CHECK_ANYCHAR_ML_STAR
+			     : OP_ANYCHAR_ML_STAR));
+      }
+      else {
+	r = add_opcode(reg, (CKN_ON ?
+			       OP_STATE_CHECK_ANYCHAR_STAR
+			     : OP_ANYCHAR_STAR));
+      }
+      if (r) return r;
+      if (CKN_ON)
+	r = add_state_check_num(reg, ckn);
+
+      return r;
+    }
+  }
+
+  if (empty_info != 0)
+    mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
+  else
+    mod_tlen = tlen;
+
+  if (infinite && qn->lower <= 1) {
+    if (qn->greedy) {
+      if (qn->lower == 1) {
+	r = add_opcode_rel_addr(reg, OP_JUMP,
+			(CKN_ON ? SIZE_OP_STATE_CHECK_PUSH : SIZE_OP_PUSH));
+	if (r) return r;
+      }
+
+      if (CKN_ON) {
+	r = add_opcode(reg, OP_STATE_CHECK_PUSH);
+	if (r) return r;
+	r = add_state_check_num(reg, ckn);
+	if (r) return r;
+	r = add_rel_addr(reg, mod_tlen + SIZE_OP_JUMP);
+      }
+      else {
+	r = add_opcode_rel_addr(reg, OP_PUSH, mod_tlen + SIZE_OP_JUMP);
+      }
+      if (r) return r;
+      r = compile_tree_empty_check(qn->target, reg, empty_info);
+      if (r) return r;
+      r = add_opcode_rel_addr(reg, OP_JUMP,
+	      -(mod_tlen + (int )SIZE_OP_JUMP
+		+ (int )(CKN_ON ? SIZE_OP_STATE_CHECK_PUSH : SIZE_OP_PUSH)));
+    }
+    else {
+      if (qn->lower == 0) {
+	r = add_opcode_rel_addr(reg, OP_JUMP, mod_tlen);
+	if (r) return r;
+      }
+      r = compile_tree_empty_check(qn->target, reg, empty_info);
+      if (r) return r;
+      if (CKN_ON) {
+	r = add_opcode(reg, OP_STATE_CHECK_PUSH_OR_JUMP);
+	if (r) return r;
+	r = add_state_check_num(reg, ckn);
+	if (r) return r;
+	r = add_rel_addr(reg,
+		 -(mod_tlen + (int )SIZE_OP_STATE_CHECK_PUSH_OR_JUMP));
+      }
+      else
+	r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH));
+    }
+  }
+  else if (qn->upper == 0) {
+    if (qn->is_refered != 0) { /* /(?<n>..){0}/ */
+      r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
+      if (r) return r;
+      r = compile_tree(qn->target, reg);
+    }
+    else
+      r = 0;
+  }
+  else if (qn->upper == 1 && qn->greedy) {
+    if (qn->lower == 0) {
+      if (CKN_ON) {
+	r = add_opcode(reg, OP_STATE_CHECK_PUSH);
+	if (r) return r;
+	r = add_state_check_num(reg, ckn);
+	if (r) return r;
+	r = add_rel_addr(reg, tlen);
+      }
+      else {
+	r = add_opcode_rel_addr(reg, OP_PUSH, tlen);
+      }
+      if (r) return r;
+    }
+
+    r = compile_tree(qn->target, reg);
+  }
+  else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
+    if (CKN_ON) {
+      r = add_opcode(reg, OP_STATE_CHECK_PUSH);
+      if (r) return r;
+      r = add_state_check_num(reg, ckn);
+      if (r) return r;
+      r = add_rel_addr(reg, SIZE_OP_JUMP);
+    }
+    else {
+      r = add_opcode_rel_addr(reg, OP_PUSH, SIZE_OP_JUMP);
+    }
+
+    if (r) return r;
+    r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
+    if (r) return r;
+    r = compile_tree(qn->target, reg);
+  }
+  else {
+    r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg);
+    if (CKN_ON) {
+      if (r) return r;
+      r = add_opcode(reg, OP_STATE_CHECK);
+      if (r) return r;
+      r = add_state_check_num(reg, ckn);
+    }
+  }
+  return r;
+}
+
+#else /* USE_COMBINATION_EXPLOSION_CHECK */
+
+static int
+compile_length_quantifier_node(QtfrNode* qn, regex_t* reg)
+{
+  int len, mod_tlen;
+  int infinite = IS_REPEAT_INFINITE(qn->upper);
+  int empty_info = qn->target_empty_info;
+  int tlen = compile_length_tree(qn->target, reg);
+
+  if (tlen < 0) return tlen;
+
+  /* anychar repeat */
+  if (NTYPE(qn->target) == NT_CANY) {
+    if (qn->greedy && infinite) {
+      if (IS_NOT_NULL(qn->next_head_exact))
+        return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower;
+      else
+        return SIZE_OP_ANYCHAR_STAR + tlen * qn->lower;
+    }
+  }
+
+  if (empty_info != 0)
+    mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
+  else
+    mod_tlen = tlen;
+
+  if (infinite &&
+      (qn->lower <= 1 || tlen * qn->lower <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
+    if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) {
+      len = SIZE_OP_JUMP;
+    }
+    else {
+      len = tlen * qn->lower;
+    }
+
+    if (qn->greedy) {
+      if (IS_NOT_NULL(qn->head_exact))
+	len += SIZE_OP_PUSH_OR_JUMP_EXACT1 + mod_tlen + SIZE_OP_JUMP;
+      else if (IS_NOT_NULL(qn->next_head_exact))
+	len += SIZE_OP_PUSH_IF_PEEK_NEXT + mod_tlen + SIZE_OP_JUMP;
+      else
+	len += SIZE_OP_PUSH + mod_tlen + SIZE_OP_JUMP;
+    }
+    else
+      len += SIZE_OP_JUMP + mod_tlen + SIZE_OP_PUSH;
+  }
+  else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */
+    len = SIZE_OP_JUMP + tlen;
+  }
+  else if (!infinite && qn->greedy &&
+           (qn->upper == 1 || (tlen + SIZE_OP_PUSH) * qn->upper
+                                      <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
+    len = tlen * qn->lower;
+    len += (SIZE_OP_PUSH + tlen) * (qn->upper - qn->lower);
+  }
+  else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
+    len = SIZE_OP_PUSH + SIZE_OP_JUMP + tlen;
+  }
+  else {
+    len = SIZE_OP_REPEAT_INC
+        + mod_tlen + SIZE_OPCODE + SIZE_RELADDR + SIZE_MEMNUM;
+  }
+
+  return len;
+}
+
+static int
+compile_quantifier_node(QtfrNode* qn, regex_t* reg)
+{
+  int i, r, mod_tlen;
+  int infinite = IS_REPEAT_INFINITE(qn->upper);
+  int empty_info = qn->target_empty_info;
+  int tlen = compile_length_tree(qn->target, reg);
+
+  if (tlen < 0) return tlen;
+
+  if (is_anychar_star_quantifier(qn)) {
+    r = compile_tree_n_times(qn->target, qn->lower, reg);
+    if (r) return r;
+    if (IS_NOT_NULL(qn->next_head_exact)) {
+      if (IS_MULTILINE(reg->options))
+	r = add_opcode(reg, OP_ANYCHAR_ML_STAR_PEEK_NEXT);
+      else
+	r = add_opcode(reg, OP_ANYCHAR_STAR_PEEK_NEXT);
+      if (r) return r;
+      return add_bytes(reg, NSTR(qn->next_head_exact)->s, 1);
+    }
+    else {
+      if (IS_MULTILINE(reg->options))
+	return add_opcode(reg, OP_ANYCHAR_ML_STAR);
+      else
+	return add_opcode(reg, OP_ANYCHAR_STAR);
+    }
+  }
+
+  if (empty_info != 0)
+    mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
+  else
+    mod_tlen = tlen;
+
+  if (infinite &&
+      (qn->lower <= 1 || tlen * qn->lower <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
+    if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) {
+      if (qn->greedy) {
+	if (IS_NOT_NULL(qn->head_exact))
+	  r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH_OR_JUMP_EXACT1);
+	else if (IS_NOT_NULL(qn->next_head_exact))
+	  r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH_IF_PEEK_NEXT);
+	else
+	  r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH);
+      }
+      else {
+	r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_JUMP);
+      }
+      if (r) return r;
+    }
+    else {
+      r = compile_tree_n_times(qn->target, qn->lower, reg);
+      if (r) return r;
+    }
+
+    if (qn->greedy) {
+      if (IS_NOT_NULL(qn->head_exact)) {
+	r = add_opcode_rel_addr(reg, OP_PUSH_OR_JUMP_EXACT1,
+			     mod_tlen + SIZE_OP_JUMP);
+	if (r) return r;
+	add_bytes(reg, NSTR(qn->head_exact)->s, 1);
+	r = compile_tree_empty_check(qn->target, reg, empty_info);
+	if (r) return r;
+	r = add_opcode_rel_addr(reg, OP_JUMP,
+	-(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH_OR_JUMP_EXACT1));
+      }
+      else if (IS_NOT_NULL(qn->next_head_exact)) {
+	r = add_opcode_rel_addr(reg, OP_PUSH_IF_PEEK_NEXT,
+				mod_tlen + SIZE_OP_JUMP);
+	if (r) return r;
+	add_bytes(reg, NSTR(qn->next_head_exact)->s, 1);
+	r = compile_tree_empty_check(qn->target, reg, empty_info);
+	if (r) return r;
+	r = add_opcode_rel_addr(reg, OP_JUMP,
+          -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH_IF_PEEK_NEXT));
+      }
+      else {
+	r = add_opcode_rel_addr(reg, OP_PUSH, mod_tlen + SIZE_OP_JUMP);
+	if (r) return r;
+	r = compile_tree_empty_check(qn->target, reg, empty_info);
+	if (r) return r;
+	r = add_opcode_rel_addr(reg, OP_JUMP,
+		     -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH));
+      }
+    }
+    else {
+      r = add_opcode_rel_addr(reg, OP_JUMP, mod_tlen);
+      if (r) return r;
+      r = compile_tree_empty_check(qn->target, reg, empty_info);
+      if (r) return r;
+      r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH));
+    }
+  }
+  else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */
+    r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
+    if (r) return r;
+    r = compile_tree(qn->target, reg);
+  }
+  else if (!infinite && qn->greedy &&
+           (qn->upper == 1 || (tlen + SIZE_OP_PUSH) * qn->upper
+                                  <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
+    int n = qn->upper - qn->lower;
+
+    r = compile_tree_n_times(qn->target, qn->lower, reg);
+    if (r) return r;
+
+    for (i = 0; i < n; i++) {
+      r = add_opcode_rel_addr(reg, OP_PUSH,
+			   (n - i) * tlen + (n - i - 1) * SIZE_OP_PUSH);
+      if (r) return r;
+      r = compile_tree(qn->target, reg);
+      if (r) return r;
+    }
+  }
+  else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
+    r = add_opcode_rel_addr(reg, OP_PUSH, SIZE_OP_JUMP);
+    if (r) return r;
+    r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
+    if (r) return r;
+    r = compile_tree(qn->target, reg);
+  }
+  else {
+    r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg);
+  }
+  return r;
+}
+#endif /* USE_COMBINATION_EXPLOSION_CHECK */
+
+static int
+compile_length_option_node(EncloseNode* node, regex_t* reg)
+{
+  int tlen;
+  OnigOptionType prev = reg->options;
+
+  reg->options = node->option;
+  tlen = compile_length_tree(node->target, reg);
+  reg->options = prev;
+
+  if (tlen < 0) return tlen;
+
+  if (IS_DYNAMIC_OPTION(prev ^ node->option)) {
+    return SIZE_OP_SET_OPTION_PUSH + SIZE_OP_SET_OPTION + SIZE_OP_FAIL
+           + tlen + SIZE_OP_SET_OPTION;
+  }
+  else
+    return tlen;
+}
+
+static int
+compile_option_node(EncloseNode* node, regex_t* reg)
+{
+  int r;
+  OnigOptionType prev = reg->options;
+
+  if (IS_DYNAMIC_OPTION(prev ^ node->option)) {
+    r = add_opcode_option(reg, OP_SET_OPTION_PUSH, node->option);
+    if (r) return r;
+    r = add_opcode_option(reg, OP_SET_OPTION, prev);
+    if (r) return r;
+    r = add_opcode(reg, OP_FAIL);
+    if (r) return r;
+  }
+
+  reg->options = node->option;
+  r = compile_tree(node->target, reg);
+  reg->options = prev;
+
+  if (IS_DYNAMIC_OPTION(prev ^ node->option)) {
+    if (r) return r;
+    r = add_opcode_option(reg, OP_SET_OPTION, prev);
+  }
+  return r;
+}
+
+static int
+compile_length_enclose_node(EncloseNode* node, regex_t* reg)
+{
+  int len;
+  int tlen;
+
+  if (node->type == ENCLOSE_OPTION)
+    return compile_length_option_node(node, reg);
+
+  if (node->target) {
+    tlen = compile_length_tree(node->target, reg);
+    if (tlen < 0) return tlen;
+  }
+  else
+    tlen = 0;
+
+  switch (node->type) {
+  case ENCLOSE_MEMORY:
+#ifdef USE_SUBEXP_CALL
+    if (IS_ENCLOSE_CALLED(node)) {
+      len = SIZE_OP_MEMORY_START_PUSH + tlen
+	  + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN;
+      if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
+	len += (IS_ENCLOSE_RECURSION(node)
+		? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH);
+      else
+	len += (IS_ENCLOSE_RECURSION(node)
+		? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END);
+    }
+    else
+#endif
+    {
+      if (BIT_STATUS_AT(reg->bt_mem_start, node->regnum))
+	len = SIZE_OP_MEMORY_START_PUSH;
+      else
+	len = SIZE_OP_MEMORY_START;
+
+      len += tlen + (BIT_STATUS_AT(reg->bt_mem_end, node->regnum)
+		     ? SIZE_OP_MEMORY_END_PUSH : SIZE_OP_MEMORY_END);
+    }
+    break;
+
+  case ENCLOSE_STOP_BACKTRACK:
+    if (IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(node)) {
+      QtfrNode* qn = NQTFR(node->target);
+      tlen = compile_length_tree(qn->target, reg);
+      if (tlen < 0) return tlen;
+
+      len = tlen * qn->lower
+	  + SIZE_OP_PUSH + tlen + SIZE_OP_POP + SIZE_OP_JUMP;
+    }
+    else {
+      len = SIZE_OP_PUSH_STOP_BT + tlen + SIZE_OP_POP_STOP_BT;
+    }
+    break;
+
+  case ENCLOSE_CONDITION:
+    len = SIZE_OP_CONDITION;
+    if (NTYPE(node->target) == NT_ALT) {
+      Node* x = node->target;
+
+      tlen = compile_length_tree(NCAR(x), reg); /* yes-node */
+      if (tlen < 0) return tlen;
+      len += tlen + SIZE_OP_JUMP;
+      if (NCDR(x) == NULL) return ONIGERR_PARSER_BUG;
+      x = NCDR(x);
+      tlen = compile_length_tree(NCAR(x), reg); /* no-node */
+      if (tlen < 0) return tlen;
+      len += tlen;
+      if (NCDR(x) != NULL) return ONIGERR_INVALID_CONDITION_PATTERN;
+    }
+    else {
+      return ONIGERR_PARSER_BUG;
+    }
+    break;
+
+  default:
+    return ONIGERR_TYPE_BUG;
+    break;
+  }
+
+  return len;
+}
+
+static int get_char_length_tree(Node* node, regex_t* reg, int* len);
+
+static int
+compile_enclose_node(EncloseNode* node, regex_t* reg)
+{
+  int r, len;
+
+  if (node->type == ENCLOSE_OPTION)
+    return compile_option_node(node, reg);
+
+  switch (node->type) {
+  case ENCLOSE_MEMORY:
+#ifdef USE_SUBEXP_CALL
+    if (IS_ENCLOSE_CALLED(node)) {
+      r = add_opcode(reg, OP_CALL);
+      if (r) return r;
+      node->call_addr = BBUF_GET_OFFSET_POS(reg) + SIZE_ABSADDR + SIZE_OP_JUMP;
+      node->state |= NST_ADDR_FIXED;
+      r = add_abs_addr(reg, (int )node->call_addr);
+      if (r) return r;
+      len = compile_length_tree(node->target, reg);
+      len += (SIZE_OP_MEMORY_START_PUSH + SIZE_OP_RETURN);
+      if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
+	len += (IS_ENCLOSE_RECURSION(node)
+		? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH);
+      else
+	len += (IS_ENCLOSE_RECURSION(node)
+		? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END);
+
+      r = add_opcode_rel_addr(reg, OP_JUMP, len);
+      if (r) return r;
+    }
+#endif
+    if (BIT_STATUS_AT(reg->bt_mem_start, node->regnum))
+      r = add_opcode(reg, OP_MEMORY_START_PUSH);
+    else
+      r = add_opcode(reg, OP_MEMORY_START);
+    if (r) return r;
+    r = add_mem_num(reg, node->regnum);
+    if (r) return r;
+    r = compile_tree(node->target, reg);
+    if (r) return r;
+#ifdef USE_SUBEXP_CALL
+    if (IS_ENCLOSE_CALLED(node)) {
+      if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
+	r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node)
+			     ? OP_MEMORY_END_PUSH_REC : OP_MEMORY_END_PUSH));
+      else
+	r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node)
+			     ? OP_MEMORY_END_REC : OP_MEMORY_END));
+
+      if (r) return r;
+      r = add_mem_num(reg, node->regnum);
+      if (r) return r;
+      r = add_opcode(reg, OP_RETURN);
+    }
+    else
+#endif
+    {
+      if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
+	r = add_opcode(reg, OP_MEMORY_END_PUSH);
+      else
+	r = add_opcode(reg, OP_MEMORY_END);
+      if (r) return r;
+      r = add_mem_num(reg, node->regnum);
+    }
+    break;
+
+  case ENCLOSE_STOP_BACKTRACK:
+    if (IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(node)) {
+      QtfrNode* qn = NQTFR(node->target);
+      r = compile_tree_n_times(qn->target, qn->lower, reg);
+      if (r) return r;
+
+      len = compile_length_tree(qn->target, reg);
+      if (len < 0) return len;
+
+      r = add_opcode_rel_addr(reg, OP_PUSH, len + SIZE_OP_POP + SIZE_OP_JUMP);
+      if (r) return r;
+      r = compile_tree(qn->target, reg);
+      if (r) return r;
+      r = add_opcode(reg, OP_POP);
+      if (r) return r;
+      r = add_opcode_rel_addr(reg, OP_JUMP,
+	 -((int )SIZE_OP_PUSH + len + (int )SIZE_OP_POP + (int )SIZE_OP_JUMP));
+    }
+    else {
+      r = add_opcode(reg, OP_PUSH_STOP_BT);
+      if (r) return r;
+      r = compile_tree(node->target, reg);
+      if (r) return r;
+      r = add_opcode(reg, OP_POP_STOP_BT);
+    }
+    break;
+
+  case ENCLOSE_CONDITION:
+    r = add_opcode(reg, OP_CONDITION);
+    if (r) return r;
+    r = add_mem_num(reg, node->regnum);
+    if (r) return r;
+
+    if (NTYPE(node->target) == NT_ALT) {
+      Node* x = node->target;
+      int len2;
+
+      len = compile_length_tree(NCAR(x), reg);  /* yes-node */
+      if (len < 0) return len;
+      if (NCDR(x) == NULL) return ONIGERR_PARSER_BUG;
+      x = NCDR(x);
+      len2 = compile_length_tree(NCAR(x), reg); /* no-node */
+      if (len2 < 0) return len2;
+      if (NCDR(x) != NULL) return ONIGERR_INVALID_CONDITION_PATTERN;
+
+      x = node->target;
+      r = add_rel_addr(reg, len + SIZE_OP_JUMP);
+      if (r) return r;
+      r = compile_tree(NCAR(x), reg);   /* yes-node */
+      if (r) return r;
+      r = add_opcode_rel_addr(reg, OP_JUMP, len2);
+      if (r) return r;
+      x = NCDR(x);
+      r = compile_tree(NCAR(x), reg);   /* no-node */
+    }
+    else {
+      return ONIGERR_PARSER_BUG;
+    }
+    break;
+
+  default:
+    return ONIGERR_TYPE_BUG;
+    break;
+  }
+
+  return r;
+}
+
+static int
+compile_length_anchor_node(AnchorNode* node, regex_t* reg)
+{
+  int len;
+  int tlen = 0;
+
+  if (node->target) {
+    tlen = compile_length_tree(node->target, reg);
+    if (tlen < 0) return tlen;
+  }
+
+  switch (node->type) {
+  case ANCHOR_PREC_READ:
+    len = SIZE_OP_PUSH_POS + tlen + SIZE_OP_POP_POS;
+    break;
+  case ANCHOR_PREC_READ_NOT:
+    len = SIZE_OP_PUSH_POS_NOT + tlen + SIZE_OP_FAIL_POS;
+    break;
+  case ANCHOR_LOOK_BEHIND:
+    len = SIZE_OP_LOOK_BEHIND + tlen;
+    break;
+  case ANCHOR_LOOK_BEHIND_NOT:
+    len = SIZE_OP_PUSH_LOOK_BEHIND_NOT + tlen + SIZE_OP_FAIL_LOOK_BEHIND_NOT;
+    break;
+
+  default:
+    len = SIZE_OPCODE;
+    break;
+  }
+
+  return len;
+}
+
+static int
+compile_anchor_node(AnchorNode* node, regex_t* reg)
+{
+  int r, len;
+
+  switch (node->type) {
+  case ANCHOR_BEGIN_BUF:      r = add_opcode(reg, OP_BEGIN_BUF);      break;
+  case ANCHOR_END_BUF:        r = add_opcode(reg, OP_END_BUF);        break;
+  case ANCHOR_BEGIN_LINE:     r = add_opcode(reg, OP_BEGIN_LINE);     break;
+  case ANCHOR_END_LINE:       r = add_opcode(reg, OP_END_LINE);       break;
+  case ANCHOR_SEMI_END_BUF:   r = add_opcode(reg, OP_SEMI_END_BUF);   break;
+  case ANCHOR_BEGIN_POSITION: r = add_opcode(reg, OP_BEGIN_POSITION); break;
+
+  /* used for implicit anchor optimization: /.*a/ ==> /(?:^|\G).*a/ */
+  case ANCHOR_ANYCHAR_STAR:   r = add_opcode(reg, OP_BEGIN_POS_OR_LINE); break;
+
+  case ANCHOR_WORD_BOUND:
+    if (node->ascii_range)    r = add_opcode(reg, OP_ASCII_WORD_BOUND);
+    else                      r = add_opcode(reg, OP_WORD_BOUND);
+    break;
+  case ANCHOR_NOT_WORD_BOUND:
+    if (node->ascii_range)    r = add_opcode(reg, OP_NOT_ASCII_WORD_BOUND);
+    else                      r = add_opcode(reg, OP_NOT_WORD_BOUND);
+    break;
+#ifdef USE_WORD_BEGIN_END
+  case ANCHOR_WORD_BEGIN:
+    if (node->ascii_range)    r = add_opcode(reg, OP_ASCII_WORD_BEGIN);
+    else                      r = add_opcode(reg, OP_WORD_BEGIN);
+    break;
+  case ANCHOR_WORD_END:
+    if (node->ascii_range)    r = add_opcode(reg, OP_ASCII_WORD_END);
+    else                      r = add_opcode(reg, OP_WORD_END);
+    break;
+#endif
+  case ANCHOR_KEEP:           r = add_opcode(reg, OP_KEEP);           break;
+
+  case ANCHOR_PREC_READ:
+    r = add_opcode(reg, OP_PUSH_POS);
+    if (r) return r;
+    r = compile_tree(node->target, reg);
+    if (r) return r;
+    r = add_opcode(reg, OP_POP_POS);
+    break;
+
+  case ANCHOR_PREC_READ_NOT:
+    len = compile_length_tree(node->target, reg);
+    if (len < 0) return len;
+    r = add_opcode_rel_addr(reg, OP_PUSH_POS_NOT, len + SIZE_OP_FAIL_POS);
+    if (r) return r;
+    r = compile_tree(node->target, reg);
+    if (r) return r;
+    r = add_opcode(reg, OP_FAIL_POS);
+    break;
+
+  case ANCHOR_LOOK_BEHIND:
+    {
+      int n;
+      r = add_opcode(reg, OP_LOOK_BEHIND);
+      if (r) return r;
+      if (node->char_len < 0) {
+	r = get_char_length_tree(node->target, reg, &n);
+	if (r) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
+      }
+      else
+	n = node->char_len;
+      r = add_length(reg, n);
+      if (r) return r;
+      r = compile_tree(node->target, reg);
+    }
+    break;
+
+  case ANCHOR_LOOK_BEHIND_NOT:
+    {
+      int n;
+      len = compile_length_tree(node->target, reg);
+      r = add_opcode_rel_addr(reg, OP_PUSH_LOOK_BEHIND_NOT,
+			   len + SIZE_OP_FAIL_LOOK_BEHIND_NOT);
+      if (r) return r;
+      if (node->char_len < 0) {
+	r = get_char_length_tree(node->target, reg, &n);
+	if (r) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
+      }
+      else
+	n = node->char_len;
+      r = add_length(reg, n);
+      if (r) return r;
+      r = compile_tree(node->target, reg);
+      if (r) return r;
+      r = add_opcode(reg, OP_FAIL_LOOK_BEHIND_NOT);
+    }
+    break;
+
+  default:
+    return ONIGERR_TYPE_BUG;
+    break;
+  }
+
+  return r;
+}
+
+static int
+compile_length_tree(Node* node, regex_t* reg)
+{
+  int len, type, r;
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+    len = 0;
+    do {
+      r = compile_length_tree(NCAR(node), reg);
+      if (r < 0) return r;
+      len += r;
+    } while (IS_NOT_NULL(node = NCDR(node)));
+    r = len;
+    break;
+
+  case NT_ALT:
+    {
+      int n = 0;
+      len = 0;
+      do {
+        r = compile_length_tree(NCAR(node), reg);
+        if (r < 0) return r;
+        len += r;
+        n++;
+      } while (IS_NOT_NULL(node = NCDR(node)));
+      r = len;
+      r += (SIZE_OP_PUSH + SIZE_OP_JUMP) * (n - 1);
+    }
+    break;
+
+  case NT_STR:
+    if (NSTRING_IS_RAW(node))
+      r = compile_length_string_raw_node(NSTR(node), reg);
+    else
+      r = compile_length_string_node(node, reg);
+    break;
+
+  case NT_CCLASS:
+    r = compile_length_cclass_node(NCCLASS(node), reg);
+    break;
+
+  case NT_CTYPE:
+  case NT_CANY:
+    r = SIZE_OPCODE;
+    break;
+
+  case NT_BREF:
+    {
+      BRefNode* br = NBREF(node);
+
+#ifdef USE_BACKREF_WITH_LEVEL
+      if (IS_BACKREF_NEST_LEVEL(br)) {
+        r = SIZE_OPCODE + SIZE_OPTION + SIZE_LENGTH +
+            SIZE_LENGTH + (SIZE_MEMNUM * br->back_num);
+      }
+      else
+#endif
+      if (br->back_num == 1) {
+	r = ((!IS_IGNORECASE(reg->options) && br->back_static[0] <= 2)
+	     ? SIZE_OPCODE : (SIZE_OPCODE + SIZE_MEMNUM));
+      }
+      else {
+	r = SIZE_OPCODE + SIZE_LENGTH + (SIZE_MEMNUM * br->back_num);
+      }
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    r = SIZE_OP_CALL;
+    break;
+#endif
+
+  case NT_QTFR:
+    r = compile_length_quantifier_node(NQTFR(node), reg);
+    break;
+
+  case NT_ENCLOSE:
+    r = compile_length_enclose_node(NENCLOSE(node), reg);
+    break;
+
+  case NT_ANCHOR:
+    r = compile_length_anchor_node(NANCHOR(node), reg);
+    break;
+
+  default:
+    return ONIGERR_TYPE_BUG;
+    break;
+  }
+
+  return r;
+}
+
+static int
+compile_tree(Node* node, regex_t* reg)
+{
+  int n, type, len, pos, r = 0;
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+    do {
+      r = compile_tree(NCAR(node), reg);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_ALT:
+    {
+      Node* x = node;
+      len = 0;
+      do {
+	len += compile_length_tree(NCAR(x), reg);
+	if (NCDR(x) != NULL) {
+	  len += SIZE_OP_PUSH + SIZE_OP_JUMP;
+	}
+      } while (IS_NOT_NULL(x = NCDR(x)));
+      pos = reg->used + len;  /* goal position */
+
+      do {
+	len = compile_length_tree(NCAR(node), reg);
+	if (IS_NOT_NULL(NCDR(node))) {
+	  r = add_opcode_rel_addr(reg, OP_PUSH, len + SIZE_OP_JUMP);
+	  if (r) break;
+	}
+	r = compile_tree(NCAR(node), reg);
+	if (r) break;
+	if (IS_NOT_NULL(NCDR(node))) {
+	  len = pos - (reg->used + SIZE_OP_JUMP);
+	  r = add_opcode_rel_addr(reg, OP_JUMP, len);
+	  if (r) break;
+	}
+      } while (IS_NOT_NULL(node = NCDR(node)));
+    }
+    break;
+
+  case NT_STR:
+    if (NSTRING_IS_RAW(node))
+      r = compile_string_raw_node(NSTR(node), reg);
+    else
+      r = compile_string_node(node, reg);
+    break;
+
+  case NT_CCLASS:
+    r = compile_cclass_node(NCCLASS(node), reg);
+    break;
+
+  case NT_CTYPE:
+    {
+      int op;
+
+      switch (NCTYPE(node)->ctype) {
+      case ONIGENC_CTYPE_WORD:
+	if (NCTYPE(node)->ascii_range != 0) {
+	  if (NCTYPE(node)->not != 0)  op = OP_NOT_ASCII_WORD;
+	  else                         op = OP_ASCII_WORD;
+	}
+	else {
+	  if (NCTYPE(node)->not != 0)  op = OP_NOT_WORD;
+	  else                         op = OP_WORD;
+	}
+	break;
+      default:
+	return ONIGERR_TYPE_BUG;
+	break;
+      }
+      r = add_opcode(reg, op);
+    }
+    break;
+
+  case NT_CANY:
+    if (IS_MULTILINE(reg->options))
+      r = add_opcode(reg, OP_ANYCHAR_ML);
+    else
+      r = add_opcode(reg, OP_ANYCHAR);
+    break;
+
+  case NT_BREF:
+    {
+      BRefNode* br = NBREF(node);
+
+#ifdef USE_BACKREF_WITH_LEVEL
+      if (IS_BACKREF_NEST_LEVEL(br)) {
+	r = add_opcode(reg, OP_BACKREF_WITH_LEVEL);
+	if (r) return r;
+	r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE));
+	if (r) return r;
+	r = add_length(reg, br->nest_level);
+	if (r) return r;
+
+	goto add_bacref_mems;
+      }
+      else
+#endif
+      if (br->back_num == 1) {
+	n = br->back_static[0];
+	if (IS_IGNORECASE(reg->options)) {
+	  r = add_opcode(reg, OP_BACKREFN_IC);
+	  if (r) return r;
+	  r = add_mem_num(reg, n);
+	}
+	else {
+	  switch (n) {
+	  case 1:  r = add_opcode(reg, OP_BACKREF1); break;
+	  case 2:  r = add_opcode(reg, OP_BACKREF2); break;
+	  default:
+	    r = add_opcode(reg, OP_BACKREFN);
+	    if (r) return r;
+	    r = add_mem_num(reg, n);
+	    break;
+	  }
+	}
+      }
+      else {
+	int i;
+	int* p;
+
+        if (IS_IGNORECASE(reg->options)) {
+          r = add_opcode(reg, OP_BACKREF_MULTI_IC);
+        }
+        else {
+          r = add_opcode(reg, OP_BACKREF_MULTI);
+        }
+	if (r) return r;
+
+#ifdef USE_BACKREF_WITH_LEVEL
+      add_bacref_mems:
+#endif
+	r = add_length(reg, br->back_num);
+	if (r) return r;
+	p = BACKREFS_P(br);
+	for (i = br->back_num - 1; i >= 0; i--) {
+	  r = add_mem_num(reg, p[i]);
+	  if (r) return r;
+	}
+      }
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    r = compile_call(NCALL(node), reg);
+    break;
+#endif
+
+  case NT_QTFR:
+    r = compile_quantifier_node(NQTFR(node), reg);
+    break;
+
+  case NT_ENCLOSE:
+    r = compile_enclose_node(NENCLOSE(node), reg);
+    break;
+
+  case NT_ANCHOR:
+    r = compile_anchor_node(NANCHOR(node), reg);
+    break;
+
+  default:
+#ifdef ONIG_DEBUG
+    fprintf(stderr, "compile_tree: undefined node type %d\n", NTYPE(node));
+#endif
+    break;
+  }
+
+  return r;
+}
+
+#ifdef USE_NAMED_GROUP
+
+static int
+noname_disable_map(Node** plink, GroupNumRemap* map, int* counter)
+{
+  int r = 0;
+  Node* node = *plink;
+
+  switch (NTYPE(node)) {
+  case NT_LIST:
+  case NT_ALT:
+    do {
+      r = noname_disable_map(&(NCAR(node)), map, counter);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_QTFR:
+    {
+      Node** ptarget = &(NQTFR(node)->target);
+      Node*  old = *ptarget;
+      r = noname_disable_map(ptarget, map, counter);
+      if (*ptarget != old && NTYPE(*ptarget) == NT_QTFR) {
+	onig_reduce_nested_quantifier(node, *ptarget);
+      }
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      if (en->type == ENCLOSE_MEMORY) {
+	if (IS_ENCLOSE_NAMED_GROUP(en)) {
+	  (*counter)++;
+	  map[en->regnum].new_val = *counter;
+	  en->regnum = *counter;
+	}
+	else if (en->regnum != 0) {
+	  *plink = en->target;
+	  en->target = NULL_NODE;
+	  onig_node_free(node);
+	  r = noname_disable_map(plink, map, counter);
+	  break;
+	}
+      }
+      r = noname_disable_map(&(en->target), map, counter);
+    }
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+      case ANCHOR_PREC_READ_NOT:
+      case ANCHOR_LOOK_BEHIND:
+      case ANCHOR_LOOK_BEHIND_NOT:
+	r = noname_disable_map(&(an->target), map, counter);
+	break;
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+static int
+renumber_node_backref(Node* node, GroupNumRemap* map)
+{
+  int i, pos, n, old_num;
+  int *backs;
+  BRefNode* bn = NBREF(node);
+
+  if (! IS_BACKREF_NAME_REF(bn))
+    return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
+
+  old_num = bn->back_num;
+  if (IS_NULL(bn->back_dynamic))
+    backs = bn->back_static;
+  else
+    backs = bn->back_dynamic;
+
+  for (i = 0, pos = 0; i < old_num; i++) {
+    n = map[backs[i]].new_val;
+    if (n > 0) {
+      backs[pos] = n;
+      pos++;
+    }
+  }
+
+  bn->back_num = pos;
+  return 0;
+}
+
+static int
+renumber_by_map(Node* node, GroupNumRemap* map)
+{
+  int r = 0;
+
+  switch (NTYPE(node)) {
+  case NT_LIST:
+  case NT_ALT:
+    do {
+      r = renumber_by_map(NCAR(node), map);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+  case NT_QTFR:
+    r = renumber_by_map(NQTFR(node)->target, map);
+    break;
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      if (en->type == ENCLOSE_CONDITION)
+        en->regnum = map[en->regnum].new_val;
+      r = renumber_by_map(en->target, map);
+    }
+    break;
+
+  case NT_BREF:
+    r = renumber_node_backref(node, map);
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+      case ANCHOR_PREC_READ_NOT:
+      case ANCHOR_LOOK_BEHIND:
+      case ANCHOR_LOOK_BEHIND_NOT:
+	r = renumber_by_map(an->target, map);
+	break;
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+static int
+numbered_ref_check(Node* node)
+{
+  int r = 0;
+
+  switch (NTYPE(node)) {
+  case NT_LIST:
+  case NT_ALT:
+    do {
+      r = numbered_ref_check(NCAR(node));
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+  case NT_QTFR:
+    r = numbered_ref_check(NQTFR(node)->target);
+    break;
+  case NT_ENCLOSE:
+    r = numbered_ref_check(NENCLOSE(node)->target);
+    break;
+
+  case NT_BREF:
+    if (! IS_BACKREF_NAME_REF(NBREF(node)))
+      return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+static int
+disable_noname_group_capture_(Node** root, regex_t* reg, ScanEnv* env, GroupNumRemap* map)
+{
+  int r, i, pos, counter;
+  BitStatusType loc;
+
+  CHECK_NULL_RETURN_MEMERR(map);
+  for (i = 1; i <= env->num_mem; i++) {
+    map[i].new_val = 0;
+  }
+  counter = 0;
+  r = noname_disable_map(root, map, &counter);
+  if (r != 0) return r;
+
+  r = renumber_by_map(*root, map);
+  if (r != 0) return r;
+
+  for (i = 1, pos = 1; i <= env->num_mem; i++) {
+    if (map[i].new_val > 0) {
+      SCANENV_MEM_NODES(env)[pos] = SCANENV_MEM_NODES(env)[i];
+      pos++;
+    }
+  }
+
+  loc = env->capture_history;
+  BIT_STATUS_CLEAR(env->capture_history);
+  for (i = 1; i <= ONIG_MAX_CAPTURE_HISTORY_GROUP; i++) {
+    if (BIT_STATUS_AT(loc, i)) {
+      BIT_STATUS_ON_AT_SIMPLE(env->capture_history, map[i].new_val);
+    }
+  }
+
+  env->num_mem = env->num_named;
+  reg->num_mem = env->num_named;
+
+  return onig_renumber_name_table(reg, map);
+}
+
+static int
+disable_noname_group_capture(Node** root, regex_t* reg, ScanEnv* env)
+{
+	GroupNumRemap* map = (GroupNumRemap*)xmalloc(sizeof(GroupNumRemap) * (env->num_mem + 1));
+	int ret = disable_noname_group_capture_(root, reg, env, map);
+	xfree(map);
+	return ret;
+}
+#endif /* USE_NAMED_GROUP */
+
+#ifdef USE_SUBEXP_CALL
+static int
+unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg)
+{
+  int i, offset;
+  EncloseNode* en;
+  AbsAddrType addr;
+
+  for (i = 0; i < uslist->num; i++) {
+    en = NENCLOSE(uslist->us[i].target);
+    if (! IS_ENCLOSE_ADDR_FIXED(en)) return ONIGERR_PARSER_BUG;
+    addr = en->call_addr;
+    offset = uslist->us[i].offset;
+
+    BBUF_WRITE(reg, offset, &addr, SIZE_ABSADDR);
+  }
+  return 0;
+}
+#endif
+
+#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
+static int
+quantifiers_memory_node_info(Node* node)
+{
+  int r = 0;
+
+  switch (NTYPE(node)) {
+  case NT_LIST:
+  case NT_ALT:
+    {
+      int v;
+      do {
+	v = quantifiers_memory_node_info(NCAR(node));
+	if (v > r) r = v;
+      } while (v >= 0 && IS_NOT_NULL(node = NCDR(node)));
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    if (IS_CALL_RECURSION(NCALL(node))) {
+      return NQ_TARGET_IS_EMPTY_REC; /* tiny version */
+    }
+    else
+      r = quantifiers_memory_node_info(NCALL(node)->target);
+    break;
+#endif
+
+  case NT_QTFR:
+    {
+      QtfrNode* qn = NQTFR(node);
+      if (qn->upper != 0) {
+	r = quantifiers_memory_node_info(qn->target);
+      }
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      switch (en->type) {
+      case ENCLOSE_MEMORY:
+	return NQ_TARGET_IS_EMPTY_MEM;
+	break;
+
+      case ENCLOSE_OPTION:
+      case ENCLOSE_STOP_BACKTRACK:
+      case ENCLOSE_CONDITION:
+	r = quantifiers_memory_node_info(en->target);
+	break;
+      default:
+	break;
+      }
+    }
+    break;
+
+  case NT_BREF:
+  case NT_STR:
+  case NT_CTYPE:
+  case NT_CCLASS:
+  case NT_CANY:
+  case NT_ANCHOR:
+  default:
+    break;
+  }
+
+  return r;
+}
+#endif /* USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT */
+
+static int
+get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env)
+{
+  OnigDistance tmin;
+  int r = 0;
+
+  *min = 0;
+  switch (NTYPE(node)) {
+  case NT_BREF:
+    {
+      int i;
+      int* backs;
+      Node** nodes = SCANENV_MEM_NODES(env);
+      BRefNode* br = NBREF(node);
+      if (br->state & NST_RECURSION) break;
+
+      backs = BACKREFS_P(br);
+      if (backs[0] > env->num_mem)  return ONIGERR_INVALID_BACKREF;
+      r = get_min_match_length(nodes[backs[0]], min, env);
+      if (r != 0) break;
+      for (i = 1; i < br->back_num; i++) {
+	if (backs[i] > env->num_mem)  return ONIGERR_INVALID_BACKREF;
+	r = get_min_match_length(nodes[backs[i]], &tmin, env);
+	if (r != 0) break;
+	if (*min > tmin) *min = tmin;
+      }
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    if (IS_CALL_RECURSION(NCALL(node))) {
+      EncloseNode* en = NENCLOSE(NCALL(node)->target);
+      if (IS_ENCLOSE_MIN_FIXED(en))
+	*min = en->min_len;
+    }
+    else
+      r = get_min_match_length(NCALL(node)->target, min, env);
+    break;
+#endif
+
+  case NT_LIST:
+    do {
+      r = get_min_match_length(NCAR(node), &tmin, env);
+      if (r == 0) *min += tmin;
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_ALT:
+    {
+      Node *x, *y;
+      y = node;
+      do {
+	x = NCAR(y);
+	r = get_min_match_length(x, &tmin, env);
+	if (r != 0) break;
+	if (y == node) *min = tmin;
+	else if (*min > tmin) *min = tmin;
+      } while (r == 0 && IS_NOT_NULL(y = NCDR(y)));
+    }
+    break;
+
+  case NT_STR:
+    {
+      StrNode* sn = NSTR(node);
+      *min = sn->end - sn->s;
+    }
+    break;
+
+  case NT_CTYPE:
+    *min = 1;
+    break;
+
+  case NT_CCLASS:
+  case NT_CANY:
+    *min = 1;
+    break;
+
+  case NT_QTFR:
+    {
+      QtfrNode* qn = NQTFR(node);
+
+      if (qn->lower > 0) {
+	r = get_min_match_length(qn->target, min, env);
+	if (r == 0)
+	  *min = distance_multiply(*min, qn->lower);
+      }
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      switch (en->type) {
+      case ENCLOSE_MEMORY:
+#ifdef USE_SUBEXP_CALL
+	if (IS_ENCLOSE_MIN_FIXED(en))
+	  *min = en->min_len;
+	else {
+	  r = get_min_match_length(en->target, min, env);
+	  if (r == 0) {
+	    en->min_len = *min;
+	    SET_ENCLOSE_STATUS(node, NST_MIN_FIXED);
+	  }
+	}
+	break;
+#endif
+      case ENCLOSE_OPTION:
+      case ENCLOSE_STOP_BACKTRACK:
+      case ENCLOSE_CONDITION:
+	r = get_min_match_length(en->target, min, env);
+	break;
+      }
+    }
+    break;
+
+  case NT_ANCHOR:
+  default:
+    break;
+  }
+
+  return r;
+}
+
+static int
+get_max_match_length(Node* node, OnigDistance *max, ScanEnv* env)
+{
+  OnigDistance tmax;
+  int r = 0;
+
+  *max = 0;
+  switch (NTYPE(node)) {
+  case NT_LIST:
+    do {
+      r = get_max_match_length(NCAR(node), &tmax, env);
+      if (r == 0)
+	*max = distance_add(*max, tmax);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_ALT:
+    do {
+      r = get_max_match_length(NCAR(node), &tmax, env);
+      if (r == 0 && *max < tmax) *max = tmax;
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_STR:
+    {
+      StrNode* sn = NSTR(node);
+      *max = sn->end - sn->s;
+    }
+    break;
+
+  case NT_CTYPE:
+    *max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
+    break;
+
+  case NT_CCLASS:
+  case NT_CANY:
+    *max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
+    break;
+
+  case NT_BREF:
+    {
+      int i;
+      int* backs;
+      Node** nodes = SCANENV_MEM_NODES(env);
+      BRefNode* br = NBREF(node);
+      if (br->state & NST_RECURSION) {
+	*max = ONIG_INFINITE_DISTANCE;
+	break;
+      }
+      backs = BACKREFS_P(br);
+      for (i = 0; i < br->back_num; i++) {
+	if (backs[i] > env->num_mem)  return ONIGERR_INVALID_BACKREF;
+	r = get_max_match_length(nodes[backs[i]], &tmax, env);
+	if (r != 0) break;
+	if (*max < tmax) *max = tmax;
+      }
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    if (! IS_CALL_RECURSION(NCALL(node)))
+      r = get_max_match_length(NCALL(node)->target, max, env);
+    else
+      *max = ONIG_INFINITE_DISTANCE;
+    break;
+#endif
+
+  case NT_QTFR:
+    {
+      QtfrNode* qn = NQTFR(node);
+
+      if (qn->upper != 0) {
+	r = get_max_match_length(qn->target, max, env);
+	if (r == 0 && *max != 0) {
+	  if (! IS_REPEAT_INFINITE(qn->upper))
+	    *max = distance_multiply(*max, qn->upper);
+	  else
+	    *max = ONIG_INFINITE_DISTANCE;
+	}
+      }
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      switch (en->type) {
+      case ENCLOSE_MEMORY:
+#ifdef USE_SUBEXP_CALL
+	if (IS_ENCLOSE_MAX_FIXED(en))
+	  *max = en->max_len;
+	else {
+	  r = get_max_match_length(en->target, max, env);
+	  if (r == 0) {
+	    en->max_len = *max;
+	    SET_ENCLOSE_STATUS(node, NST_MAX_FIXED);
+	  }
+	}
+	break;
+#endif
+      case ENCLOSE_OPTION:
+      case ENCLOSE_STOP_BACKTRACK:
+      case ENCLOSE_CONDITION:
+	r = get_max_match_length(en->target, max, env);
+	break;
+      }
+    }
+    break;
+
+  case NT_ANCHOR:
+  default:
+    break;
+  }
+
+  return r;
+}
+
+#define GET_CHAR_LEN_VARLEN           -1
+#define GET_CHAR_LEN_TOP_ALT_VARLEN   -2
+
+/* fixed size pattern node only */
+static int
+get_char_length_tree1(Node* node, regex_t* reg, int* len, int level)
+{
+  int tlen;
+  int r = 0;
+
+  level++;
+  *len = 0;
+  switch (NTYPE(node)) {
+  case NT_LIST:
+    do {
+      r = get_char_length_tree1(NCAR(node), reg, &tlen, level);
+      if (r == 0)
+	*len = (int )distance_add(*len, tlen);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_ALT:
+    {
+      int tlen2;
+      int varlen = 0;
+
+      r = get_char_length_tree1(NCAR(node), reg, &tlen, level);
+      while (r == 0 && IS_NOT_NULL(node = NCDR(node))) {
+	r = get_char_length_tree1(NCAR(node), reg, &tlen2, level);
+	if (r == 0) {
+	  if (tlen != tlen2)
+	    varlen = 1;
+	}
+      }
+      if (r == 0) {
+	if (varlen != 0) {
+	  if (level == 1)
+	    r = GET_CHAR_LEN_TOP_ALT_VARLEN;
+	  else
+	    r = GET_CHAR_LEN_VARLEN;
+	}
+	else
+	  *len = tlen;
+      }
+    }
+    break;
+
+  case NT_STR:
+    {
+      StrNode* sn = NSTR(node);
+      UChar *s = sn->s;
+      while (s < sn->end) {
+	s += enclen(reg->enc, s);
+	(*len)++;
+      }
+    }
+    break;
+
+  case NT_QTFR:
+    {
+      QtfrNode* qn = NQTFR(node);
+      if (qn->lower == qn->upper) {
+	r = get_char_length_tree1(qn->target, reg, &tlen, level);
+	if (r == 0)
+	  *len = (int )distance_multiply(tlen, qn->lower);
+      }
+      else
+	r = GET_CHAR_LEN_VARLEN;
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    if (! IS_CALL_RECURSION(NCALL(node)))
+      r = get_char_length_tree1(NCALL(node)->target, reg, len, level);
+    else
+      r = GET_CHAR_LEN_VARLEN;
+    break;
+#endif
+
+  case NT_CTYPE:
+    *len = 1;
+    break;
+
+  case NT_CCLASS:
+  case NT_CANY:
+    *len = 1;
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      switch (en->type) {
+      case ENCLOSE_MEMORY:
+#ifdef USE_SUBEXP_CALL
+	if (IS_ENCLOSE_CLEN_FIXED(en))
+	  *len = en->char_len;
+	else {
+	  r = get_char_length_tree1(en->target, reg, len, level);
+	  if (r == 0) {
+	    en->char_len = *len;
+	    SET_ENCLOSE_STATUS(node, NST_CLEN_FIXED);
+	  }
+	}
+	break;
+#endif
+      case ENCLOSE_OPTION:
+      case ENCLOSE_STOP_BACKTRACK:
+      case ENCLOSE_CONDITION:
+	r = get_char_length_tree1(en->target, reg, len, level);
+	break;
+      default:
+	break;
+      }
+    }
+    break;
+
+  case NT_ANCHOR:
+    break;
+
+  default:
+    r = GET_CHAR_LEN_VARLEN;
+    break;
+  }
+
+  return r;
+}
+
+static int
+get_char_length_tree(Node* node, regex_t* reg, int* len)
+{
+  return get_char_length_tree1(node, reg, len, 0);
+}
+
+/* x is not included y ==>  1 : 0 */
+static int
+is_not_included(Node* x, Node* y, regex_t* reg)
+{
+  int i;
+  OnigDistance len;
+  OnigCodePoint code;
+  UChar *p;
+  int ytype;
+
+ retry:
+  ytype = NTYPE(y);
+  switch (NTYPE(x)) {
+  case NT_CTYPE:
+    {
+      switch (ytype) {
+      case NT_CTYPE:
+	if (NCTYPE(y)->ctype == NCTYPE(x)->ctype &&
+	    NCTYPE(y)->not   != NCTYPE(x)->not &&
+	    NCTYPE(y)->ascii_range == NCTYPE(x)->ascii_range)
+	  return 1;
+	else
+	  return 0;
+	break;
+
+      case NT_CCLASS:
+      swap:
+	{
+	  Node* tmp;
+	  tmp = x; x = y; y = tmp;
+	  goto retry;
+	}
+	break;
+
+      case NT_STR:
+	goto swap;
+	break;
+
+      default:
+	break;
+      }
+    }
+    break;
+
+  case NT_CCLASS:
+    {
+      CClassNode* xc = NCCLASS(x);
+      switch (ytype) {
+      case NT_CTYPE:
+	switch (NCTYPE(y)->ctype) {
+	case ONIGENC_CTYPE_WORD:
+	  if (NCTYPE(y)->not == 0) {
+	    if (IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) {
+	      for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
+		if (BITSET_AT(xc->bs, i)) {
+		  if (NCTYPE(y)->ascii_range) {
+		    if (IS_CODE_SB_WORD(reg->enc, i)) return 0;
+		  }
+		  else {
+		    if (ONIGENC_IS_CODE_WORD(reg->enc, i)) return 0;
+		  }
+		}
+	      }
+	      return 1;
+	    }
+	    return 0;
+	  }
+	  else {
+	    if (IS_NOT_NULL(xc->mbuf)) return 0;
+	    for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
+	      int is_word;
+	      if (NCTYPE(y)->ascii_range)
+		is_word = IS_CODE_SB_WORD(reg->enc, i);
+	      else
+		is_word = ONIGENC_IS_CODE_WORD(reg->enc, i);
+	      if (! is_word) {
+		if (!IS_NCCLASS_NOT(xc)) {
+		  if (BITSET_AT(xc->bs, i))
+		    return 0;
+		}
+		else {
+		  if (! BITSET_AT(xc->bs, i))
+		    return 0;
+		}
+	      }
+	    }
+	    return 1;
+	  }
+	  break;
+
+	default:
+	  break;
+	}
+	break;
+
+      case NT_CCLASS:
+	{
+	  int v;
+	  CClassNode* yc = NCCLASS(y);
+
+	  for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
+	    v = BITSET_AT(xc->bs, i);
+	    if ((v != 0 && !IS_NCCLASS_NOT(xc)) ||
+                (v == 0 && IS_NCCLASS_NOT(xc))) {
+	      v = BITSET_AT(yc->bs, i);
+	      if ((v != 0 && !IS_NCCLASS_NOT(yc)) ||
+                  (v == 0 && IS_NCCLASS_NOT(yc)))
+		return 0;
+	    }
+	  }
+	  if ((IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) ||
+	      (IS_NULL(yc->mbuf) && !IS_NCCLASS_NOT(yc)))
+	    return 1;
+	  return 0;
+	}
+	break;
+
+      case NT_STR:
+	goto swap;
+	break;
+
+      default:
+	break;
+      }
+    }
+    break;
+
+  case NT_STR:
+    {
+      StrNode* xs = NSTR(x);
+      if (NSTRING_LEN(x) == 0)
+	break;
+
+      switch (ytype) {
+      case NT_CTYPE:
+	switch (NCTYPE(y)->ctype) {
+	case ONIGENC_CTYPE_WORD:
+	  if (NCTYPE(y)->ascii_range) {
+	    if (ONIGENC_IS_MBC_ASCII_WORD(reg->enc, xs->s, xs->end))
+	      return NCTYPE(y)->not;
+	    else
+	      return !(NCTYPE(y)->not);
+	  }
+	  else {
+	    if (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end))
+	      return NCTYPE(y)->not;
+	    else
+	      return !(NCTYPE(y)->not);
+	  }
+	  break;
+	default:
+	  break;
+	}
+	break;
+
+      case NT_CCLASS:
+        {
+          CClassNode* cc = NCCLASS(y);
+
+          code = ONIGENC_MBC_TO_CODE(reg->enc, xs->s,
+                                     xs->s + ONIGENC_MBC_MAXLEN(reg->enc));
+          return (onig_is_code_in_cc(reg->enc, code, cc) != 0 ? 0 : 1);
+        }
+        break;
+
+      case NT_STR:
+        {
+          UChar *q;
+          StrNode* ys = NSTR(y);
+          len = NSTRING_LEN(x);
+          if (len > NSTRING_LEN(y)) len = NSTRING_LEN(y);
+          if (NSTRING_IS_AMBIG(x) || NSTRING_IS_AMBIG(y)) {
+            /* tiny version */
+            return 0;
+	  }
+	  else {
+	    for (i = 0, p = ys->s, q = xs->s; (OnigDistance )i < len; i++, p++, q++) {
+	      if (*p != *q) return 1;
+	    }
+	  }
+	}
+	break;
+
+      default:
+        break;
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return 0;
+}
+
+static Node*
+get_head_value_node(Node* node, int exact, regex_t* reg)
+{
+  Node* n = NULL_NODE;
+
+  switch (NTYPE(node)) {
+  case NT_BREF:
+  case NT_ALT:
+  case NT_CANY:
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+#endif
+    break;
+
+  case NT_CTYPE:
+  case NT_CCLASS:
+    if (exact == 0) {
+      n = node;
+    }
+    break;
+
+  case NT_LIST:
+    n = get_head_value_node(NCAR(node), exact, reg);
+    break;
+
+  case NT_STR:
+    {
+      StrNode* sn = NSTR(node);
+
+      if (sn->end <= sn->s)
+	break;
+
+      if (exact != 0 &&
+	  !NSTRING_IS_RAW(node) && IS_IGNORECASE(reg->options)) {
+      }
+      else {
+	n = node;
+      }
+    }
+    break;
+
+  case NT_QTFR:
+    {
+      QtfrNode* qn = NQTFR(node);
+      if (qn->lower > 0) {
+	if (IS_NOT_NULL(qn->head_exact))
+	  n = qn->head_exact;
+	else
+	  n = get_head_value_node(qn->target, exact, reg);
+      }
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      switch (en->type) {
+      case ENCLOSE_OPTION:
+	{
+	  OnigOptionType options = reg->options;
+
+	  reg->options = NENCLOSE(node)->option;
+	  n = get_head_value_node(NENCLOSE(node)->target, exact, reg);
+	  reg->options = options;
+	}
+	break;
+
+      case ENCLOSE_MEMORY:
+      case ENCLOSE_STOP_BACKTRACK:
+      case ENCLOSE_CONDITION:
+	n = get_head_value_node(en->target, exact, reg);
+	break;
+      }
+    }
+    break;
+
+  case NT_ANCHOR:
+    if (NANCHOR(node)->type == ANCHOR_PREC_READ)
+      n = get_head_value_node(NANCHOR(node)->target, exact, reg);
+    break;
+
+  default:
+    break;
+  }
+
+  return n;
+}
+
+static int
+check_type_tree(Node* node, int type_mask, int enclose_mask, int anchor_mask)
+{
+  int type, r = 0;
+
+  type = NTYPE(node);
+  if ((NTYPE2BIT(type) & type_mask) == 0)
+    return 1;
+
+  switch (type) {
+  case NT_LIST:
+  case NT_ALT:
+    do {
+      r = check_type_tree(NCAR(node), type_mask, enclose_mask,
+			  anchor_mask);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_QTFR:
+    r = check_type_tree(NQTFR(node)->target, type_mask, enclose_mask,
+			anchor_mask);
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+      if ((en->type & enclose_mask) == 0)
+	return 1;
+
+      r = check_type_tree(en->target, type_mask, enclose_mask, anchor_mask);
+    }
+    break;
+
+  case NT_ANCHOR:
+    type = NANCHOR(node)->type;
+    if ((type & anchor_mask) == 0)
+      return 1;
+
+    if (NANCHOR(node)->target)
+      r = check_type_tree(NANCHOR(node)->target,
+			  type_mask, enclose_mask, anchor_mask);
+    break;
+
+  default:
+    break;
+  }
+  return r;
+}
+
+#ifdef USE_SUBEXP_CALL
+
+#define RECURSION_EXIST       1
+#define RECURSION_INFINITE    2
+
+static int
+subexp_inf_recursive_check(Node* node, ScanEnv* env, int head)
+{
+  int type;
+  int r = 0;
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+    {
+      Node *x;
+      OnigDistance min;
+      int ret;
+
+      x = node;
+      do {
+	ret = subexp_inf_recursive_check(NCAR(x), env, head);
+	if (ret < 0 || ret == RECURSION_INFINITE) return ret;
+	r |= ret;
+	if (head) {
+	  ret = get_min_match_length(NCAR(x), &min, env);
+	  if (ret != 0) return ret;
+	  if (min != 0) head = 0;
+	}
+      } while (IS_NOT_NULL(x = NCDR(x)));
+    }
+    break;
+
+  case NT_ALT:
+    {
+      int ret;
+      r = RECURSION_EXIST;
+      do {
+	ret = subexp_inf_recursive_check(NCAR(node), env, head);
+	if (ret < 0 || ret == RECURSION_INFINITE) return ret;
+	r &= ret;
+      } while (IS_NOT_NULL(node = NCDR(node)));
+    }
+    break;
+
+  case NT_QTFR:
+    r = subexp_inf_recursive_check(NQTFR(node)->target, env, head);
+    if (r == RECURSION_EXIST) {
+      if (NQTFR(node)->lower == 0) r = 0;
+    }
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+      case ANCHOR_PREC_READ_NOT:
+      case ANCHOR_LOOK_BEHIND:
+      case ANCHOR_LOOK_BEHIND_NOT:
+	r = subexp_inf_recursive_check(an->target, env, head);
+	break;
+      }
+    }
+    break;
+
+  case NT_CALL:
+    r = subexp_inf_recursive_check(NCALL(node)->target, env, head);
+    break;
+
+  case NT_ENCLOSE:
+    if (IS_ENCLOSE_MARK2(NENCLOSE(node)))
+      return 0;
+    else if (IS_ENCLOSE_MARK1(NENCLOSE(node)))
+      return (head == 0 ? RECURSION_EXIST : RECURSION_INFINITE);
+    else {
+      SET_ENCLOSE_STATUS(node, NST_MARK2);
+      r = subexp_inf_recursive_check(NENCLOSE(node)->target, env, head);
+      CLEAR_ENCLOSE_STATUS(node, NST_MARK2);
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+static int
+subexp_inf_recursive_check_trav(Node* node, ScanEnv* env)
+{
+  int type;
+  int r = 0;
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+  case NT_ALT:
+    do {
+      r = subexp_inf_recursive_check_trav(NCAR(node), env);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_QTFR:
+    r = subexp_inf_recursive_check_trav(NQTFR(node)->target, env);
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+      case ANCHOR_PREC_READ_NOT:
+      case ANCHOR_LOOK_BEHIND:
+      case ANCHOR_LOOK_BEHIND_NOT:
+	r = subexp_inf_recursive_check_trav(an->target, env);
+	break;
+      }
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+
+      if (IS_ENCLOSE_RECURSION(en)) {
+	SET_ENCLOSE_STATUS(node, NST_MARK1);
+	r = subexp_inf_recursive_check(en->target, env, 1);
+	if (r > 0) return ONIGERR_NEVER_ENDING_RECURSION;
+	CLEAR_ENCLOSE_STATUS(node, NST_MARK1);
+      }
+      r = subexp_inf_recursive_check_trav(en->target, env);
+    }
+
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+static int
+subexp_recursive_check(Node* node)
+{
+  int r = 0;
+
+  switch (NTYPE(node)) {
+  case NT_LIST:
+  case NT_ALT:
+    do {
+      r |= subexp_recursive_check(NCAR(node));
+    } while (IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_QTFR:
+    r = subexp_recursive_check(NQTFR(node)->target);
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+      case ANCHOR_PREC_READ_NOT:
+      case ANCHOR_LOOK_BEHIND:
+      case ANCHOR_LOOK_BEHIND_NOT:
+	r = subexp_recursive_check(an->target);
+	break;
+      }
+    }
+    break;
+
+  case NT_CALL:
+    r = subexp_recursive_check(NCALL(node)->target);
+    if (r != 0) SET_CALL_RECURSION(node);
+    break;
+
+  case NT_ENCLOSE:
+    if (IS_ENCLOSE_MARK2(NENCLOSE(node)))
+      return 0;
+    else if (IS_ENCLOSE_MARK1(NENCLOSE(node)))
+      return 1; /* recursion */
+    else {
+      SET_ENCLOSE_STATUS(node, NST_MARK2);
+      r = subexp_recursive_check(NENCLOSE(node)->target);
+      CLEAR_ENCLOSE_STATUS(node, NST_MARK2);
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+
+static int
+subexp_recursive_check_trav(Node* node, ScanEnv* env)
+{
+#define FOUND_CALLED_NODE    1
+
+  int type;
+  int r = 0;
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+  case NT_ALT:
+    {
+      int ret;
+      do {
+	ret = subexp_recursive_check_trav(NCAR(node), env);
+	if (ret == FOUND_CALLED_NODE) r = FOUND_CALLED_NODE;
+	else if (ret < 0) return ret;
+      } while (IS_NOT_NULL(node = NCDR(node)));
+    }
+    break;
+
+  case NT_QTFR:
+    r = subexp_recursive_check_trav(NQTFR(node)->target, env);
+    if (NQTFR(node)->upper == 0) {
+      if (r == FOUND_CALLED_NODE)
+	NQTFR(node)->is_refered = 1;
+    }
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+      case ANCHOR_PREC_READ_NOT:
+      case ANCHOR_LOOK_BEHIND:
+      case ANCHOR_LOOK_BEHIND_NOT:
+	r = subexp_recursive_check_trav(an->target, env);
+	break;
+      }
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+
+      if (! IS_ENCLOSE_RECURSION(en)) {
+	if (IS_ENCLOSE_CALLED(en)) {
+	  SET_ENCLOSE_STATUS(node, NST_MARK1);
+	  r = subexp_recursive_check(en->target);
+	  if (r != 0) SET_ENCLOSE_STATUS(node, NST_RECURSION);
+	  CLEAR_ENCLOSE_STATUS(node, NST_MARK1);
+	}
+      }
+      r = subexp_recursive_check_trav(en->target, env);
+      if (IS_ENCLOSE_CALLED(en))
+	r |= FOUND_CALLED_NODE;
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+static int
+setup_subexp_call(Node* node, ScanEnv* env)
+{
+  int type;
+  int r = 0;
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+    do {
+      r = setup_subexp_call(NCAR(node), env);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_ALT:
+    do {
+      r = setup_subexp_call(NCAR(node), env);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_QTFR:
+    r = setup_subexp_call(NQTFR(node)->target, env);
+    break;
+  case NT_ENCLOSE:
+    r = setup_subexp_call(NENCLOSE(node)->target, env);
+    break;
+
+  case NT_CALL:
+    {
+      CallNode* cn = NCALL(node);
+      Node** nodes = SCANENV_MEM_NODES(env);
+
+      if (cn->group_num != 0) {
+	int gnum = cn->group_num;
+
+#ifdef USE_NAMED_GROUP
+	if (env->num_named > 0 &&
+	    IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
+	    !ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_CAPTURE_GROUP)) {
+	  return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
+	}
+#endif
+	if (gnum > env->num_mem) {
+	  onig_scan_env_set_error_string(env,
+		 ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
+	  return ONIGERR_UNDEFINED_GROUP_REFERENCE;
+	}
+
+#ifdef USE_NAMED_GROUP
+      set_call_attr:
+#endif
+	cn->target = nodes[cn->group_num];
+	if (IS_NULL(cn->target)) {
+	  onig_scan_env_set_error_string(env,
+		 ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
+	  return ONIGERR_UNDEFINED_NAME_REFERENCE;
+	}
+	SET_ENCLOSE_STATUS(cn->target, NST_CALLED);
+	BIT_STATUS_ON_AT(env->bt_mem_start, cn->group_num);
+	cn->unset_addr_list = env->unset_addr_list;
+      }
+#ifdef USE_NAMED_GROUP
+#ifdef USE_PERL_SUBEXP_CALL
+      else if (cn->name == cn->name_end) {
+	goto set_call_attr;
+      }
+#endif
+      else {
+	int *refs;
+
+	int n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end,
+					   &refs);
+	if (n <= 0) {
+	  onig_scan_env_set_error_string(env,
+		 ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
+	  return ONIGERR_UNDEFINED_NAME_REFERENCE;
+	}
+	else if (n > 1 &&
+	    ! IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME_CALL)) {
+	  onig_scan_env_set_error_string(env,
+	    ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL, cn->name, cn->name_end);
+	  return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;
+	}
+	else {
+	  cn->group_num = refs[0];
+	  goto set_call_attr;
+	}
+      }
+#endif
+    }
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+      case ANCHOR_PREC_READ_NOT:
+      case ANCHOR_LOOK_BEHIND:
+      case ANCHOR_LOOK_BEHIND_NOT:
+	r = setup_subexp_call(an->target, env);
+	break;
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+#endif
+
+/* divide different length alternatives in look-behind.
+  (?<=A|B) ==> (?<=A)|(?<=B)
+  (?<!A|B) ==> (?<!A)(?<!B)
+*/
+static int
+divide_look_behind_alternatives(Node* node)
+{
+  Node *head, *np, *insert_node;
+  AnchorNode* an = NANCHOR(node);
+  int anc_type = an->type;
+
+  head = an->target;
+  np = NCAR(head);
+  swap_node(node, head);
+  NCAR(node) = head;
+  NANCHOR(head)->target = np;
+
+  np = node;
+  while ((np = NCDR(np)) != NULL_NODE) {
+    insert_node = onig_node_new_anchor(anc_type);
+    CHECK_NULL_RETURN_MEMERR(insert_node);
+    NANCHOR(insert_node)->target = NCAR(np);
+    NCAR(np) = insert_node;
+  }
+
+  if (anc_type == ANCHOR_LOOK_BEHIND_NOT) {
+    np = node;
+    do {
+      SET_NTYPE(np, NT_LIST);  /* alt -> list */
+    } while ((np = NCDR(np)) != NULL_NODE);
+  }
+  return 0;
+}
+
+static int
+setup_look_behind(Node* node, regex_t* reg, ScanEnv* env)
+{
+  int r, len;
+  AnchorNode* an = NANCHOR(node);
+
+  r = get_char_length_tree(an->target, reg, &len);
+  if (r == 0)
+    an->char_len = len;
+  else if (r == GET_CHAR_LEN_VARLEN)
+    r = ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
+  else if (r == GET_CHAR_LEN_TOP_ALT_VARLEN) {
+    if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND))
+      r = divide_look_behind_alternatives(node);
+    else
+      r = ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
+  }
+
+  return r;
+}
+
+static int
+next_setup(Node* node, Node* next_node, int in_root, regex_t* reg)
+{
+  int type;
+
+ retry:
+  type = NTYPE(node);
+  if (type == NT_QTFR) {
+    QtfrNode* qn = NQTFR(node);
+    if (qn->greedy && IS_REPEAT_INFINITE(qn->upper)) {
+#ifdef USE_QTFR_PEEK_NEXT
+      Node* n = get_head_value_node(next_node, 1, reg);
+      /* '\0': for UTF-16BE etc... */
+      if (IS_NOT_NULL(n) && NSTR(n)->s[0] != '\0') {
+	qn->next_head_exact = n;
+      }
+#endif
+      /* automatic possessification a*b ==> (?>a*)b */
+      if (qn->lower <= 1) {
+	int ttype = NTYPE(qn->target);
+	if (IS_NODE_TYPE_SIMPLE(ttype)) {
+	  Node *x, *y;
+	  x = get_head_value_node(qn->target, 0, reg);
+	  if (IS_NOT_NULL(x)) {
+	    y = get_head_value_node(next_node,  0, reg);
+	    if (IS_NOT_NULL(y) && is_not_included(x, y, reg)) {
+	      Node* en = onig_node_new_enclose(ENCLOSE_STOP_BACKTRACK);
+	      CHECK_NULL_RETURN_MEMERR(en);
+	      SET_ENCLOSE_STATUS(en, NST_STOP_BT_SIMPLE_REPEAT);
+	      swap_node(node, en);
+	      NENCLOSE(node)->target = en;
+	    }
+	  }
+	}
+      }
+
+#ifndef ONIG_DONT_OPTIMIZE
+      if (NTYPE(node) == NT_QTFR && /* the type may be changed by above block */
+	  in_root && /* qn->lower == 0 && */
+	  NTYPE(qn->target) == NT_CANY &&
+	  ! IS_MULTILINE(reg->options)) {
+	/* implicit anchor: /.*a/ ==> /(?:^|\G).*a/ */
+	Node *np;
+	np = onig_node_new_list(NULL_NODE, NULL_NODE);
+	CHECK_NULL_RETURN_MEMERR(np);
+	swap_node(node, np);
+	NCDR(node) = onig_node_new_list(np, NULL_NODE);
+	if (IS_NULL(NCDR(node))) {
+	  onig_node_free(np);
+	  return ONIGERR_MEMORY;
+	}
+	np = onig_node_new_anchor(ANCHOR_ANYCHAR_STAR);   /* (?:^|\G) */
+	CHECK_NULL_RETURN_MEMERR(np);
+	NCAR(node) = np;
+      }
+#endif
+    }
+  }
+  else if (type == NT_ENCLOSE) {
+    EncloseNode* en = NENCLOSE(node);
+    in_root = 0;
+    if (en->type == ENCLOSE_MEMORY) {
+      node = en->target;
+      goto retry;
+    }
+  }
+  return 0;
+}
+
+
+static int
+update_string_node_case_fold(regex_t* reg, Node *node)
+{
+  UChar *p, *end, buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
+  UChar *sbuf, *ebuf, *sp;
+  int r, i, len;
+  OnigDistance sbuf_size;
+  StrNode* sn = NSTR(node);
+
+  end = sn->end;
+  sbuf_size = (end - sn->s) * 2;
+  sbuf = (UChar* )xmalloc(sbuf_size);
+  CHECK_NULL_RETURN_MEMERR(sbuf);
+  ebuf = sbuf + sbuf_size;
+
+  sp = sbuf;
+  p = sn->s;
+  while (p < end) {
+    len = ONIGENC_MBC_CASE_FOLD(reg->enc, reg->case_fold_flag, &p, end, buf);
+    for (i = 0; i < len; i++) {
+      if (sp >= ebuf) {
+	UChar* p = (UChar* )xrealloc(sbuf, sbuf_size * 2);
+	if (IS_NULL(p)) {
+	  xfree(sbuf);
+	  return ONIGERR_MEMORY;
+	}
+	sbuf = p;
+	sp = sbuf + sbuf_size;
+	sbuf_size *= 2;
+	ebuf = sbuf + sbuf_size;
+      }
+
+      *sp++ = buf[i];
+    }
+  }
+
+  r = onig_node_str_set(node, sbuf, sp);
+
+  xfree(sbuf);
+  return r;
+}
+
+static int
+expand_case_fold_make_rem_string(Node** rnode, UChar *s, UChar *end,
+				 regex_t* reg)
+{
+  int r;
+  Node *node;
+
+  node = onig_node_new_str(s, end);
+  if (IS_NULL(node)) return ONIGERR_MEMORY;
+
+  r = update_string_node_case_fold(reg, node);
+  if (r != 0) {
+    onig_node_free(node);
+    return r;
+  }
+
+  NSTRING_SET_AMBIG(node);
+  NSTRING_SET_DONT_GET_OPT_INFO(node);
+  *rnode = node;
+  return 0;
+}
+
+static int
+is_case_fold_variable_len(int item_num, OnigCaseFoldCodeItem items[],
+			  int slen)
+{
+  int i;
+
+  for (i = 0; i < item_num; i++) {
+    if (items[i].byte_len != slen) {
+      return 1;
+    }
+    if (items[i].code_len != 1) {
+      return 1;
+    }
+  }
+  return 0;
+}
+
+static int
+expand_case_fold_string_alt(int item_num, OnigCaseFoldCodeItem items[],
+			    UChar *p, int slen, UChar *end,
+			    regex_t* reg, Node **rnode)
+{
+  int r, i, j, len, varlen;
+  Node *anode, *var_anode, *snode, *xnode, *an;
+  UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
+
+  *rnode = var_anode = NULL_NODE;
+
+  varlen = 0;
+  for (i = 0; i < item_num; i++) {
+    if (items[i].byte_len != slen) {
+      varlen = 1;
+      break;
+    }
+  }
+
+  if (varlen != 0) {
+    *rnode = var_anode = onig_node_new_alt(NULL_NODE, NULL_NODE);
+    if (IS_NULL(var_anode)) return ONIGERR_MEMORY;
+
+    xnode = onig_node_new_list(NULL, NULL);
+    if (IS_NULL(xnode)) goto mem_err;
+    NCAR(var_anode) = xnode;
+
+    anode = onig_node_new_alt(NULL_NODE, NULL_NODE);
+    if (IS_NULL(anode)) goto mem_err;
+    NCAR(xnode) = anode;
+  }
+  else {
+    *rnode = anode = onig_node_new_alt(NULL_NODE, NULL_NODE);
+    if (IS_NULL(anode)) return ONIGERR_MEMORY;
+  }
+
+  snode = onig_node_new_str(p, p + slen);
+  if (IS_NULL(snode)) goto mem_err;
+
+  NCAR(anode) = snode;
+
+  for (i = 0; i < item_num; i++) {
+    snode = onig_node_new_str(NULL, NULL);
+    if (IS_NULL(snode)) goto mem_err;
+
+    for (j = 0; j < items[i].code_len; j++) {
+      len = ONIGENC_CODE_TO_MBC(reg->enc, items[i].code[j], buf);
+      if (len < 0) {
+	r = len;
+	goto mem_err2;
+      }
+
+      r = onig_node_str_cat(snode, buf, buf + len);
+      if (r != 0) goto mem_err2;
+    }
+
+    an = onig_node_new_alt(NULL_NODE, NULL_NODE);
+    if (IS_NULL(an)) {
+      goto mem_err2;
+    }
+
+    if (items[i].byte_len != slen) {
+      Node *rem;
+      UChar *q = p + items[i].byte_len;
+
+      if (q < end) {
+        r = expand_case_fold_make_rem_string(&rem, q, end, reg);
+        if (r != 0) {
+          onig_node_free(an);
+          goto mem_err2;
+        }
+
+        xnode = onig_node_list_add(NULL_NODE, snode);
+        if (IS_NULL(xnode)) {
+          onig_node_free(an);
+          onig_node_free(rem);
+          goto mem_err2;
+        }
+        if (IS_NULL(onig_node_list_add(xnode, rem))) {
+          onig_node_free(an);
+          onig_node_free(xnode);
+          onig_node_free(rem);
+          goto mem_err;
+        }
+
+        NCAR(an) = xnode;
+      }
+      else {
+        NCAR(an) = snode;
+      }
+
+      NCDR(var_anode) = an;
+      var_anode = an;
+    }
+    else {
+      NCAR(an)     = snode;
+      NCDR(anode) = an;
+      anode = an;
+    }
+  }
+
+  return varlen;
+
+ mem_err2:
+  onig_node_free(snode);
+
+ mem_err:
+  onig_node_free(*rnode);
+
+  return ONIGERR_MEMORY;
+}
+
+static int
+expand_case_fold_string(Node* node, regex_t* reg)
+{
+#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION  8
+
+  int r, n, len, alt_num;
+  int varlen = 0;
+  UChar *start, *end, *p;
+  Node *top_root, *root, *snode, *prev_node;
+  OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
+  StrNode* sn = NSTR(node);
+
+  if (NSTRING_IS_AMBIG(node)) return 0;
+
+  start = sn->s;
+  end   = sn->end;
+  if (start >= end) return 0;
+
+  r = 0;
+  top_root = root = prev_node = snode = NULL_NODE;
+  alt_num = 1;
+  p = start;
+  while (p < end) {
+    n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(reg->enc, reg->case_fold_flag,
+					   p, end, items);
+    if (n < 0) {
+      r = n;
+      goto err;
+    }
+
+    len = enclen(reg->enc, p);
+
+    varlen = is_case_fold_variable_len(n, items, len);
+    if (n == 0 || varlen == 0) {
+      if (IS_NULL(snode)) {
+	if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
+	  top_root = root = onig_node_list_add(NULL_NODE, prev_node);
+	  if (IS_NULL(root)) {
+	    onig_node_free(prev_node);
+	    goto mem_err;
+	  }
+	}
+
+	prev_node = snode = onig_node_new_str(NULL, NULL);
+	if (IS_NULL(snode)) goto mem_err;
+	if (IS_NOT_NULL(root)) {
+	  if (IS_NULL(onig_node_list_add(root, snode))) {
+	    onig_node_free(snode);
+	    goto mem_err;
+	  }
+	}
+      }
+
+      r = onig_node_str_cat(snode, p, p + len);
+      if (r != 0) goto err;
+    }
+    else {
+      alt_num *= (n + 1);
+      if (alt_num > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break;
+
+      if (IS_NOT_NULL(snode)) {
+	r = update_string_node_case_fold(reg, snode);
+	if (r == 0) {
+	  NSTRING_SET_AMBIG(snode);
+	}
+      }
+      if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
+	top_root = root = onig_node_list_add(NULL_NODE, prev_node);
+	if (IS_NULL(root)) {
+	  onig_node_free(prev_node);
+	  goto mem_err;
+	}
+      }
+
+      r = expand_case_fold_string_alt(n, items, p, len, end, reg, &prev_node);
+      if (r < 0) goto mem_err;
+      if (r == 1) {
+	if (IS_NULL(root)) {
+	  top_root = prev_node;
+	}
+	else {
+	  if (IS_NULL(onig_node_list_add(root, prev_node))) {
+	    onig_node_free(prev_node);
+	    goto mem_err;
+	  }
+	}
+
+	root = NCAR(prev_node);
+      }
+      else { /* r == 0 */
+	if (IS_NOT_NULL(root)) {
+	  if (IS_NULL(onig_node_list_add(root, prev_node))) {
+	    onig_node_free(prev_node);
+	    goto mem_err;
+	  }
+	}
+      }
+
+      snode = NULL_NODE;
+    }
+
+    p += len;
+  }
+  if (IS_NOT_NULL(snode)) {
+    r = update_string_node_case_fold(reg, snode);
+    if (r == 0) {
+      NSTRING_SET_AMBIG(snode);
+    }
+  }
+
+  if (p < end) {
+    Node *srem;
+
+    r = expand_case_fold_make_rem_string(&srem, p, end, reg);
+    if (r != 0) goto mem_err;
+
+    if (IS_NOT_NULL(prev_node) && IS_NULL(root)) {
+      top_root = root = onig_node_list_add(NULL_NODE, prev_node);
+      if (IS_NULL(root)) {
+	onig_node_free(srem);
+	onig_node_free(prev_node);
+	goto mem_err;
+      }
+    }
+
+    if (IS_NULL(root)) {
+      prev_node = srem;
+    }
+    else {
+      if (IS_NULL(onig_node_list_add(root, srem))) {
+	onig_node_free(srem);
+	goto mem_err;
+      }
+    }
+  }
+
+  /* ending */
+  top_root = (IS_NOT_NULL(top_root) ? top_root : prev_node);
+  swap_node(node, top_root);
+  onig_node_free(top_root);
+  return 0;
+
+ mem_err:
+  r = ONIGERR_MEMORY;
+
+ err:
+  onig_node_free(top_root);
+  return r;
+}
+
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+
+#define CEC_THRES_NUM_BIG_REPEAT         512
+#define CEC_INFINITE_NUM          0x7fffffff
+
+#define CEC_IN_INFINITE_REPEAT    (1<<0)
+#define CEC_IN_FINITE_REPEAT      (1<<1)
+#define CEC_CONT_BIG_REPEAT       (1<<2)
+
+static int
+setup_comb_exp_check(Node* node, int state, ScanEnv* env)
+{
+  int type;
+  int r = state;
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+    {
+      Node* prev = NULL_NODE;
+      do {
+	r = setup_comb_exp_check(NCAR(node), r, env);
+	prev = NCAR(node);
+      } while (r >= 0 && IS_NOT_NULL(node = NCDR(node)));
+    }
+    break;
+
+  case NT_ALT:
+    {
+      int ret;
+      do {
+	ret = setup_comb_exp_check(NCAR(node), state, env);
+	r |= ret;
+      } while (ret >= 0 && IS_NOT_NULL(node = NCDR(node)));
+    }
+    break;
+
+  case NT_QTFR:
+    {
+      int child_state = state;
+      int add_state = 0;
+      QtfrNode* qn = NQTFR(node);
+      Node* target = qn->target;
+      int var_num;
+
+      if (! IS_REPEAT_INFINITE(qn->upper)) {
+	if (qn->upper > 1) {
+	  /* {0,1}, {1,1} are allowed */
+	  child_state |= CEC_IN_FINITE_REPEAT;
+
+	  /* check (a*){n,m}, (a+){n,m} => (a*){n,n}, (a+){n,n} */
+	  if (env->backrefed_mem == 0) {
+	    if (NTYPE(qn->target) == NT_ENCLOSE) {
+	      EncloseNode* en = NENCLOSE(qn->target);
+	      if (en->type == ENCLOSE_MEMORY) {
+		if (NTYPE(en->target) == NT_QTFR) {
+		  QtfrNode* q = NQTFR(en->target);
+		  if (IS_REPEAT_INFINITE(q->upper)
+		      && q->greedy == qn->greedy) {
+		    qn->upper = (qn->lower == 0 ? 1 : qn->lower);
+		    if (qn->upper == 1)
+		      child_state = state;
+		  }
+		}
+	      }
+	    }
+	  }
+	}
+      }
+
+      if (state & CEC_IN_FINITE_REPEAT) {
+	qn->comb_exp_check_num = -1;
+      }
+      else {
+	if (IS_REPEAT_INFINITE(qn->upper)) {
+	  var_num = CEC_INFINITE_NUM;
+	  child_state |= CEC_IN_INFINITE_REPEAT;
+	}
+	else {
+	  var_num = qn->upper - qn->lower;
+	}
+
+	if (var_num >= CEC_THRES_NUM_BIG_REPEAT)
+	  add_state |= CEC_CONT_BIG_REPEAT;
+
+	if (((state & CEC_IN_INFINITE_REPEAT) != 0 && var_num != 0) ||
+	    ((state & CEC_CONT_BIG_REPEAT) != 0 &&
+	     var_num >= CEC_THRES_NUM_BIG_REPEAT)) {
+	  if (qn->comb_exp_check_num == 0) {
+	    env->num_comb_exp_check++;
+	    qn->comb_exp_check_num = env->num_comb_exp_check;
+	    if (env->curr_max_regnum > env->comb_exp_max_regnum)
+	      env->comb_exp_max_regnum = env->curr_max_regnum;
+	  }
+	}
+      }
+
+      r = setup_comb_exp_check(target, child_state, env);
+      r |= add_state;
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+
+      switch (en->type) {
+      case ENCLOSE_MEMORY:
+	{
+	  if (env->curr_max_regnum < en->regnum)
+	    env->curr_max_regnum = en->regnum;
+
+	  r = setup_comb_exp_check(en->target, state, env);
+	}
+	break;
+
+      default:
+	r = setup_comb_exp_check(en->target, state, env);
+	break;
+      }
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    if (IS_CALL_RECURSION(NCALL(node)))
+      env->has_recursion = 1;
+    else
+      r = setup_comb_exp_check(NCALL(node)->target, state, env);
+    break;
+#endif
+
+  default:
+    break;
+  }
+
+  return r;
+}
+#endif
+
+#define IN_ALT        (1<<0)
+#define IN_NOT        (1<<1)
+#define IN_REPEAT     (1<<2)
+#define IN_VAR_REPEAT (1<<3)
+#define IN_ROOT       (1<<4)
+
+/* setup_tree does the following work.
+ 1. check empty loop. (set qn->target_empty_info)
+ 2. expand ignore-case in char class.
+ 3. set memory status bit flags. (reg->mem_stats)
+ 4. set qn->head_exact for [push, exact] -> [push_or_jump_exact1, exact].
+ 5. find invalid patterns in look-behind.
+ 6. expand repeated string.
+ */
+static int
+setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
+{
+  int type;
+  int r = 0;
+  int in_root = state & IN_ROOT;
+
+  state &= ~IN_ROOT;
+restart:
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+    {
+      Node* prev = NULL_NODE;
+      int prev_in_root = 0;
+      state |= in_root;
+      do {
+	r = setup_tree(NCAR(node), reg, state, env);
+	if (IS_NOT_NULL(prev) && r == 0) {
+	  r = next_setup(prev, NCAR(node), prev_in_root, reg);
+	}
+	prev = NCAR(node);
+	prev_in_root = state & IN_ROOT;
+	state &= ~IN_ROOT;
+      } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    }
+    break;
+
+  case NT_ALT:
+    do {
+      r = setup_tree(NCAR(node), reg, (state | IN_ALT), env);
+    } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  case NT_CCLASS:
+    break;
+
+  case NT_STR:
+    if (IS_IGNORECASE(reg->options) && !NSTRING_IS_RAW(node)) {
+      r = expand_case_fold_string(node, reg);
+    }
+    break;
+
+  case NT_CTYPE:
+  case NT_CANY:
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    break;
+#endif
+
+  case NT_BREF:
+    {
+      int i;
+      int* p;
+      Node** nodes = SCANENV_MEM_NODES(env);
+      BRefNode* br = NBREF(node);
+      p = BACKREFS_P(br);
+      for (i = 0; i < br->back_num; i++) {
+	if (p[i] > env->num_mem)  return ONIGERR_INVALID_BACKREF;
+	BIT_STATUS_ON_AT(env->backrefed_mem, p[i]);
+	BIT_STATUS_ON_AT(env->bt_mem_start, p[i]);
+#ifdef USE_BACKREF_WITH_LEVEL
+	if (IS_BACKREF_NEST_LEVEL(br)) {
+	  BIT_STATUS_ON_AT(env->bt_mem_end, p[i]);
+	}
+#endif
+	SET_ENCLOSE_STATUS(nodes[p[i]], NST_MEM_BACKREFED);
+      }
+    }
+    break;
+
+  case NT_QTFR:
+    {
+      OnigDistance d;
+      QtfrNode* qn = NQTFR(node);
+      Node* target = qn->target;
+
+      if ((state & IN_REPEAT) != 0) {
+        qn->state |= NST_IN_REPEAT;
+      }
+
+      if (IS_REPEAT_INFINITE(qn->upper) || qn->upper >= 1) {
+	r = get_min_match_length(target, &d, env);
+	if (r) break;
+	if (d == 0) {
+	  qn->target_empty_info = NQ_TARGET_IS_EMPTY;
+#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
+	  r = quantifiers_memory_node_info(target);
+	  if (r < 0) break;
+	  if (r > 0) {
+	    qn->target_empty_info = r;
+	  }
+#endif
+#if 0
+	  r = get_max_match_length(target, &d, env);
+	  if (r == 0 && d == 0) {
+	    /*  ()* ==> ()?, ()+ ==> ()  */
+	    qn->upper = 1;
+	    if (qn->lower > 1) qn->lower = 1;
+	    if (NTYPE(target) == NT_STR) {
+	      qn->upper = qn->lower = 0;  /* /(?:)+/ ==> // */
+	    }
+	  }
+#endif
+	}
+      }
+
+      state |= IN_REPEAT;
+      if (qn->lower != qn->upper)
+	state |= IN_VAR_REPEAT;
+      r = setup_tree(target, reg, state, env);
+      if (r) break;
+
+      /* expand string */
+#define EXPAND_STRING_MAX_LENGTH  100
+      if (NTYPE(target) == NT_STR) {
+	if (qn->lower > 1) {
+	  int i, n = qn->lower;
+	  OnigDistance len = NSTRING_LEN(target);
+	  StrNode* sn = NSTR(target);
+	  Node* np;
+
+	  np = onig_node_new_str(sn->s, sn->end);
+	  if (IS_NULL(np)) return ONIGERR_MEMORY;
+	  NSTR(np)->flag = sn->flag;
+
+	  for (i = 1; i < n && (i+1) * len <= EXPAND_STRING_MAX_LENGTH; i++) {
+	    r = onig_node_str_cat(np, sn->s, sn->end);
+	    if (r) {
+	      onig_node_free(np);
+	      return r;
+	    }
+	  }
+	  if (i < qn->upper || IS_REPEAT_INFINITE(qn->upper)) {
+	    Node *np1, *np2;
+
+	    qn->lower -= i;
+	    if (! IS_REPEAT_INFINITE(qn->upper))
+	      qn->upper -= i;
+
+	    np1 = onig_node_new_list(np, NULL);
+	    if (IS_NULL(np1)) {
+	      onig_node_free(np);
+	      return ONIGERR_MEMORY;
+	    }
+	    swap_node(np1, node);
+	    np2 = onig_node_list_add(node, np1);
+	    if (IS_NULL(np2)) {
+	      onig_node_free(np1);
+	      return ONIGERR_MEMORY;
+	    }
+	  }
+	  else {
+	    swap_node(np, node);
+	    onig_node_free(np);
+	  }
+	  break; /* break case NT_QTFR: */
+	}
+      }
+
+#ifdef USE_OP_PUSH_OR_JUMP_EXACT
+      if (qn->greedy && (qn->target_empty_info != 0)) {
+	if (NTYPE(target) == NT_QTFR) {
+	  QtfrNode* tqn = NQTFR(target);
+	  if (IS_NOT_NULL(tqn->head_exact)) {
+	    qn->head_exact  = tqn->head_exact;
+	    tqn->head_exact = NULL;
+	  }
+	}
+	else {
+	  qn->head_exact = get_head_value_node(qn->target, 1, reg);
+	}
+      }
+#endif
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+
+      switch (en->type) {
+      case ENCLOSE_OPTION:
+	{
+	  OnigOptionType options = reg->options;
+	  state |= in_root;
+	  reg->options = NENCLOSE(node)->option;
+	  r = setup_tree(NENCLOSE(node)->target, reg, state, env);
+	  reg->options = options;
+	}
+	break;
+
+      case ENCLOSE_MEMORY:
+	if ((state & (IN_ALT | IN_NOT | IN_VAR_REPEAT)) != 0) {
+	  BIT_STATUS_ON_AT(env->bt_mem_start, en->regnum);
+	  /* SET_ENCLOSE_STATUS(node, NST_MEM_IN_ALT_NOT); */
+	}
+        r = setup_tree(en->target, reg, state, env);
+        break;
+
+      case ENCLOSE_STOP_BACKTRACK:
+	{
+	  Node* target = en->target;
+	  r = setup_tree(target, reg, state, env);
+	  if (NTYPE(target) == NT_QTFR) {
+	    QtfrNode* tqn = NQTFR(target);
+	    if (IS_REPEAT_INFINITE(tqn->upper) && tqn->lower <= 1 &&
+		tqn->greedy != 0) {  /* (?>a*), a*+ etc... */
+	      int qtype = NTYPE(tqn->target);
+	      if (IS_NODE_TYPE_SIMPLE(qtype))
+		SET_ENCLOSE_STATUS(node, NST_STOP_BT_SIMPLE_REPEAT);
+	    }
+	  }
+	}
+	break;
+
+      case ENCLOSE_CONDITION:
+#ifdef USE_NAMED_GROUP
+	if (! IS_ENCLOSE_NAME_REF(NENCLOSE(node)) &&
+	    env->num_named > 0 &&
+	    IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
+	    !ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_CAPTURE_GROUP)) {
+	  return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
+	}
+#endif
+	r = setup_tree(NENCLOSE(node)->target, reg, state, env);
+	break;
+      }
+    }
+    break;
+
+  case NT_ANCHOR:
+    {
+      AnchorNode* an = NANCHOR(node);
+
+      switch (an->type) {
+      case ANCHOR_PREC_READ:
+	r = setup_tree(an->target, reg, state, env);
+	break;
+      case ANCHOR_PREC_READ_NOT:
+	r = setup_tree(an->target, reg, (state | IN_NOT), env);
+	break;
+
+/* allowed node types in look-behind */
+#define ALLOWED_TYPE_IN_LB  \
+  ( BIT_NT_LIST | BIT_NT_ALT | BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE | \
+    BIT_NT_CANY | BIT_NT_ANCHOR | BIT_NT_ENCLOSE | BIT_NT_QTFR | BIT_NT_CALL )
+
+#define ALLOWED_ENCLOSE_IN_LB       ( ENCLOSE_MEMORY | ENCLOSE_OPTION )
+#define ALLOWED_ENCLOSE_IN_LB_NOT   ENCLOSE_OPTION
+
+#define ALLOWED_ANCHOR_IN_LB \
+( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | \
+  ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION | ANCHOR_KEEP | \
+  ANCHOR_WORD_BOUND | ANCHOR_NOT_WORD_BOUND | \
+  ANCHOR_WORD_BEGIN | ANCHOR_WORD_END )
+#define ALLOWED_ANCHOR_IN_LB_NOT \
+( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | \
+  ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION | ANCHOR_KEEP | \
+  ANCHOR_WORD_BOUND | ANCHOR_NOT_WORD_BOUND | \
+  ANCHOR_WORD_BEGIN | ANCHOR_WORD_END )
+
+      case ANCHOR_LOOK_BEHIND:
+	{
+	  r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB,
+			      ALLOWED_ENCLOSE_IN_LB, ALLOWED_ANCHOR_IN_LB);
+	  if (r < 0) return r;
+	  if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
+	  r = setup_look_behind(node, reg, env);
+	  if (r != 0) return r;
+	  if (NTYPE(node) != NT_ANCHOR) goto restart;
+	  r = setup_tree(an->target, reg, state, env);
+	}
+	break;
+
+      case ANCHOR_LOOK_BEHIND_NOT:
+	{
+	  r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB,
+		      ALLOWED_ENCLOSE_IN_LB_NOT, ALLOWED_ANCHOR_IN_LB_NOT);
+	  if (r < 0) return r;
+	  if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
+	  r = setup_look_behind(node, reg, env);
+	  if (r != 0) return r;
+	  if (NTYPE(node) != NT_ANCHOR) goto restart;
+	  r = setup_tree(an->target, reg, (state | IN_NOT), env);
+	}
+	break;
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return r;
+}
+
+#ifndef USE_SUNDAY_QUICK_SEARCH
+/* set skip map for Boyer-Moore search */
+static int
+set_bm_skip(UChar* s, UChar* end, regex_t* reg,
+	    UChar skip[], int** int_skip, int ignore_case)
+{
+  OnigDistance i, len;
+  int clen, flen, n, j, k;
+  UChar *p, buf[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM][ONIGENC_MBC_CASE_FOLD_MAXLEN];
+  OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
+  OnigEncoding enc = reg->enc;
+
+  len = end - s;
+  if (len < ONIG_CHAR_TABLE_SIZE) {
+    for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )len;
+
+    n = 0;
+    for (i = 0; i < len - 1; i += clen) {
+      p = s + i;
+      if (ignore_case)
+	n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag,
+					       p, end, items);
+      clen = enclen(enc, p);
+
+      for (j = 0; j < n; j++) {
+	if ((items[j].code_len != 1) || (items[j].byte_len != clen))
+	  return 1;  /* different length isn't supported. */
+	flen = ONIGENC_CODE_TO_MBC(enc, items[j].code[0], buf[j]);
+	if (flen != clen)
+	  return 1;  /* different length isn't supported. */
+      }
+      for (j = 0; j < clen; j++) {
+	skip[s[i + j]] = (UChar )(len - 1 - i - j);
+	for (k = 0; k < n; k++) {
+	  skip[buf[k][j]] = (UChar )(len - 1 - i - j);
+	}
+      }
+    }
+  }
+  else {
+    if (IS_NULL(*int_skip)) {
+      *int_skip = (int* )xmalloc(sizeof(int) * ONIG_CHAR_TABLE_SIZE);
+      if (IS_NULL(*int_skip)) return ONIGERR_MEMORY;
+    }
+    for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) (*int_skip)[i] = (int )len;
+
+    n = 0;
+    for (i = 0; i < len - 1; i += clen) {
+      p = s + i;
+      if (ignore_case)
+	n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag,
+					       p, end, items);
+      clen = enclen(enc, p);
+
+      for (j = 0; j < n; j++) {
+	if ((items[j].code_len != 1) || (items[j].byte_len != clen))
+	  return 1;  /* different length isn't supported. */
+	flen = ONIGENC_CODE_TO_MBC(enc, items[j].code[0], buf[j]);
+	if (flen != clen)
+	  return 1;  /* different length isn't supported. */
+      }
+      for (j = 0; j < clen; j++) {
+	(*int_skip)[s[i + j]] = (int )(len - 1 - i - j);
+	for (k = 0; k < n; k++) {
+	  (*int_skip)[buf[k][j]] = (int )(len - 1 - i - j);
+	}
+      }
+    }
+  }
+  return 0;
+}
+
+#else /* USE_SUNDAY_QUICK_SEARCH */
+
+/* set skip map for Sunday's quick search */
+static int
+set_bm_skip(UChar* s, UChar* end, regex_t* reg,
+	    UChar skip[], int** int_skip, int ignore_case)
+{
+  OnigDistance i, len;
+  int clen, flen, n, j, k;
+  UChar *p, buf[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM][ONIGENC_MBC_CASE_FOLD_MAXLEN];
+  OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
+  OnigEncoding enc = reg->enc;
+
+  len = end - s;
+  if (len < ONIG_CHAR_TABLE_SIZE) {
+    for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )(len + 1);
+
+    n = 0;
+    for (i = 0; i < len; i += clen) {
+      p = s + i;
+      if (ignore_case)
+	n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag,
+					       p, end, items);
+      clen = enclen(enc, p);
+
+      for (j = 0; j < n; j++) {
+	if ((items[j].code_len != 1) || (items[j].byte_len != clen))
+	  return 1;  /* different length isn't supported. */
+	flen = ONIGENC_CODE_TO_MBC(enc, items[j].code[0], buf[j]);
+	if (flen != clen)
+	  return 1;  /* different length isn't supported. */
+      }
+      for (j = 0; j < clen; j++) {
+	skip[s[i + j]] = (UChar )(len - i - j);
+	for (k = 0; k < n; k++) {
+	  skip[buf[k][j]] = (UChar )(len - i - j);
+	}
+      }
+    }
+  }
+  else {
+    if (IS_NULL(*int_skip)) {
+      *int_skip = (int* )xmalloc(sizeof(int) * ONIG_CHAR_TABLE_SIZE);
+      if (IS_NULL(*int_skip)) return ONIGERR_MEMORY;
+    }
+    for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) (*int_skip)[i] = (int )(len + 1);
+
+    n = 0;
+    for (i = 0; i < len; i += clen) {
+      p = s + i;
+      if (ignore_case)
+	n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag,
+					       p, end, items);
+      clen = enclen(enc, p);
+
+      for (j = 0; j < n; j++) {
+	if ((items[j].code_len != 1) || (items[j].byte_len != clen))
+	  return 1;  /* different length isn't supported. */
+	flen = ONIGENC_CODE_TO_MBC(enc, items[j].code[0], buf[j]);
+	if (flen != clen)
+	  return 1;  /* different length isn't supported. */
+      }
+      for (j = 0; j < clen; j++) {
+	(*int_skip)[s[i + j]] = (int )(len - i - j);
+	for (k = 0; k < n; k++) {
+	  (*int_skip)[buf[k][j]] = (int )(len - i - j);
+	}
+      }
+    }
+  }
+  return 0;
+}
+#endif /* USE_SUNDAY_QUICK_SEARCH */
+
+#define OPT_EXACT_MAXLEN   24
+
+typedef struct {
+  OnigDistance min;  /* min byte length */
+  OnigDistance max;  /* max byte length */
+} MinMaxLen;
+
+typedef struct {
+  MinMaxLen        mmd;
+  OnigEncoding     enc;
+  OnigOptionType   options;
+  OnigCaseFoldType case_fold_flag;
+  ScanEnv*         scan_env;
+} OptEnv;
+
+typedef struct {
+  int left_anchor;
+  int right_anchor;
+} OptAncInfo;
+
+typedef struct {
+  MinMaxLen  mmd; /* info position */
+  OptAncInfo anc;
+
+  int   reach_end;
+  int   ignore_case;  /* -1: unset, 0: case sensitive, 1: ignore case */
+  int   len;
+  UChar s[OPT_EXACT_MAXLEN];
+} OptExactInfo;
+
+typedef struct {
+  MinMaxLen mmd; /* info position */
+  OptAncInfo anc;
+
+  int   value;      /* weighted value */
+  UChar map[ONIG_CHAR_TABLE_SIZE];
+} OptMapInfo;
+
+typedef struct {
+  MinMaxLen    len;
+
+  OptAncInfo   anc;
+  OptExactInfo exb;    /* boundary */
+  OptExactInfo exm;    /* middle */
+  OptExactInfo expr;   /* prec read (?=...) */
+
+  OptMapInfo   map;   /* boundary */
+} NodeOptInfo;
+
+
+static int
+map_position_value(OnigEncoding enc, int i)
+{
+  static const short int ByteValTable[] = {
+     5,  1,  1,  1,  1,  1,  1,  1,  1, 10, 10,  1,  1, 10,  1,  1,
+     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
+    12,  4,  7,  4,  4,  4,  4,  4,  4,  5,  5,  5,  5,  5,  5,  5,
+     6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  5,  5,  5,  5,  5,  5,
+     5,  6,  6,  6,  6,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+     6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  5,  6,  5,  5,  5,
+     5,  6,  6,  6,  6,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
+     6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  5,  5,  5,  5,  1
+  };
+
+  if (i < numberof(ByteValTable)) {
+    if (i == 0 && ONIGENC_MBC_MINLEN(enc) > 1)
+      return 20;
+    else
+      return (int )ByteValTable[i];
+  }
+  else
+    return 4;   /* Take it easy. */
+}
+
+static int
+distance_value(MinMaxLen* mm)
+{
+  /* 1000 / (min-max-dist + 1) */
+  static const short int dist_vals[] = {
+    1000,  500,  333,  250,  200,  167,  143,  125,  111,  100,
+      91,   83,   77,   71,   67,   63,   59,   56,   53,   50,
+      48,   45,   43,   42,   40,   38,   37,   36,   34,   33,
+      32,   31,   30,   29,   29,   28,   27,   26,   26,   25,
+      24,   24,   23,   23,   22,   22,   21,   21,   20,   20,
+      20,   19,   19,   19,   18,   18,   18,   17,   17,   17,
+      16,   16,   16,   16,   15,   15,   15,   15,   14,   14,
+      14,   14,   14,   14,   13,   13,   13,   13,   13,   13,
+      12,   12,   12,   12,   12,   12,   11,   11,   11,   11,
+      11,   11,   11,   11,   11,   10,   10,   10,   10,   10
+  };
+
+  OnigDistance d;
+
+  if (mm->max == ONIG_INFINITE_DISTANCE) return 0;
+
+  d = mm->max - mm->min;
+  if (d < numberof(dist_vals))
+    /* return dist_vals[d] * 16 / (mm->min + 12); */
+    return (int )dist_vals[d];
+  else
+    return 1;
+}
+
+static int
+comp_distance_value(MinMaxLen* d1, MinMaxLen* d2, int v1, int v2)
+{
+  if (v2 <= 0) return -1;
+  if (v1 <= 0) return  1;
+
+  v1 *= distance_value(d1);
+  v2 *= distance_value(d2);
+
+  if (v2 > v1) return  1;
+  if (v2 < v1) return -1;
+
+  if (d2->min < d1->min) return  1;
+  if (d2->min > d1->min) return -1;
+  return 0;
+}
+
+static int
+is_equal_mml(MinMaxLen* a, MinMaxLen* b)
+{
+  return (a->min == b->min && a->max == b->max) ? 1 : 0;
+}
+
+
+static void
+set_mml(MinMaxLen* mml, OnigDistance min, OnigDistance max)
+{
+  mml->min = min;
+  mml->max = max;
+}
+
+static void
+clear_mml(MinMaxLen* mml)
+{
+  mml->min = mml->max = 0;
+}
+
+static void
+copy_mml(MinMaxLen* to, MinMaxLen* from)
+{
+  to->min = from->min;
+  to->max = from->max;
+}
+
+static void
+add_mml(MinMaxLen* to, MinMaxLen* from)
+{
+  to->min = distance_add(to->min, from->min);
+  to->max = distance_add(to->max, from->max);
+}
+
+#if 0
+static void
+add_len_mml(MinMaxLen* to, OnigDistance len)
+{
+  to->min = distance_add(to->min, len);
+  to->max = distance_add(to->max, len);
+}
+#endif
+
+static void
+alt_merge_mml(MinMaxLen* to, MinMaxLen* from)
+{
+  if (to->min > from->min) to->min = from->min;
+  if (to->max < from->max) to->max = from->max;
+}
+
+static void
+copy_opt_env(OptEnv* to, OptEnv* from)
+{
+  *to = *from;
+}
+
+static void
+clear_opt_anc_info(OptAncInfo* anc)
+{
+  anc->left_anchor  = 0;
+  anc->right_anchor = 0;
+}
+
+static void
+copy_opt_anc_info(OptAncInfo* to, OptAncInfo* from)
+{
+  *to = *from;
+}
+
+static void
+concat_opt_anc_info(OptAncInfo* to, OptAncInfo* left, OptAncInfo* right,
+		    OnigDistance left_len, OnigDistance right_len)
+{
+  clear_opt_anc_info(to);
+
+  to->left_anchor = left->left_anchor;
+  if (left_len == 0) {
+    to->left_anchor |= right->left_anchor;
+  }
+
+  to->right_anchor = right->right_anchor;
+  if (right_len == 0) {
+    to->right_anchor |= left->right_anchor;
+  }
+  else {
+    to->right_anchor |= (left->right_anchor & ANCHOR_PREC_READ_NOT);
+  }
+}
+
+static int
+is_left_anchor(int anc)
+{
+  if (anc == ANCHOR_END_BUF || anc == ANCHOR_SEMI_END_BUF ||
+      anc == ANCHOR_END_LINE || anc == ANCHOR_PREC_READ ||
+      anc == ANCHOR_PREC_READ_NOT)
+    return 0;
+
+  return 1;
+}
+
+static int
+is_set_opt_anc_info(OptAncInfo* to, int anc)
+{
+  if ((to->left_anchor & anc) != 0) return 1;
+
+  return ((to->right_anchor & anc) != 0 ? 1 : 0);
+}
+
+static void
+add_opt_anc_info(OptAncInfo* to, int anc)
+{
+  if (is_left_anchor(anc))
+    to->left_anchor |= anc;
+  else
+    to->right_anchor |= anc;
+}
+
+static void
+remove_opt_anc_info(OptAncInfo* to, int anc)
+{
+  if (is_left_anchor(anc))
+    to->left_anchor &= ~anc;
+  else
+    to->right_anchor &= ~anc;
+}
+
+static void
+alt_merge_opt_anc_info(OptAncInfo* to, OptAncInfo* add)
+{
+  to->left_anchor  &= add->left_anchor;
+  to->right_anchor &= add->right_anchor;
+}
+
+static int
+is_full_opt_exact_info(OptExactInfo* ex)
+{
+  return (ex->len >= OPT_EXACT_MAXLEN ? 1 : 0);
+}
+
+static void
+clear_opt_exact_info(OptExactInfo* ex)
+{
+  clear_mml(&ex->mmd);
+  clear_opt_anc_info(&ex->anc);
+  ex->reach_end   = 0;
+  ex->ignore_case = -1;   /* unset */
+  ex->len         = 0;
+  ex->s[0]        = '\0';
+}
+
+static void
+copy_opt_exact_info(OptExactInfo* to, OptExactInfo* from)
+{
+  *to = *from;
+}
+
+static void
+concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc)
+{
+  int i, j, len;
+  UChar *p, *end;
+  OptAncInfo tanc;
+
+  if (to->ignore_case < 0)
+    to->ignore_case = add->ignore_case;
+  else if (to->ignore_case != add->ignore_case)
+    return ;  /* avoid */
+
+  p = add->s;
+  end = p + add->len;
+  for (i = to->len; p < end; ) {
+    len = enclen(enc, p);
+    if (i + len > OPT_EXACT_MAXLEN) break;
+    for (j = 0; j < len && p < end; j++)
+      to->s[i++] = *p++;
+  }
+
+  to->len = i;
+  to->reach_end = (p == end ? add->reach_end : 0);
+
+  concat_opt_anc_info(&tanc, &to->anc, &add->anc, 1, 1);
+  if (! to->reach_end) tanc.right_anchor = 0;
+  copy_opt_anc_info(&to->anc, &tanc);
+}
+
+static void
+concat_opt_exact_info_str(OptExactInfo* to, UChar* s, UChar* end,
+			  int raw ARG_UNUSED, OnigEncoding enc)
+{
+  int i, j, len;
+  UChar *p;
+
+  for (i = to->len, p = s; p < end && i < OPT_EXACT_MAXLEN; ) {
+    len = enclen(enc, p);
+    if (i + len > OPT_EXACT_MAXLEN) break;
+    for (j = 0; j < len && p < end; j++)
+      to->s[i++] = *p++;
+  }
+
+  to->len = i;
+}
+
+static void
+alt_merge_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OptEnv* env)
+{
+  int i, j, len;
+
+  if (add->len == 0 || to->len == 0) {
+    clear_opt_exact_info(to);
+    return ;
+  }
+
+  if (! is_equal_mml(&to->mmd, &add->mmd)) {
+    clear_opt_exact_info(to);
+    return ;
+  }
+
+  for (i = 0; i < to->len && i < add->len; ) {
+    if (to->s[i] != add->s[i]) break;
+    len = enclen(env->enc, to->s + i);
+
+    for (j = 1; j < len; j++) {
+      if (to->s[i+j] != add->s[i+j]) break;
+    }
+    if (j < len) break;
+    i += len;
+  }
+
+  if (! add->reach_end || i < add->len || i < to->len) {
+    to->reach_end = 0;
+  }
+  to->len = i;
+  if (to->ignore_case < 0)
+    to->ignore_case = add->ignore_case;
+  else if (add->ignore_case >= 0)
+    to->ignore_case |= add->ignore_case;
+
+  alt_merge_opt_anc_info(&to->anc, &add->anc);
+  if (! to->reach_end) to->anc.right_anchor = 0;
+}
+
+static void
+select_opt_exact_info(OnigEncoding enc, OptExactInfo* now, OptExactInfo* alt)
+{
+  int v1, v2;
+
+  v1 = now->len;
+  v2 = alt->len;
+
+  if (v2 == 0) {
+    return ;
+  }
+  else if (v1 == 0) {
+    copy_opt_exact_info(now, alt);
+    return ;
+  }
+  else if (v1 <= 2 && v2 <= 2) {
+    /* ByteValTable[x] is big value --> low price */
+    v2 = map_position_value(enc, now->s[0]);
+    v1 = map_position_value(enc, alt->s[0]);
+
+    if (now->len > 1) v1 += 5;
+    if (alt->len > 1) v2 += 5;
+  }
+
+  if (now->ignore_case <= 0) v1 *= 2;
+  if (alt->ignore_case <= 0) v2 *= 2;
+
+  if (comp_distance_value(&now->mmd, &alt->mmd, v1, v2) > 0)
+    copy_opt_exact_info(now, alt);
+}
+
+static void
+clear_opt_map_info(OptMapInfo* map)
+{
+  static const OptMapInfo clean_info = {
+    {0, 0}, {0, 0}, 0,
+    {
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+    }
+  };
+
+  xmemcpy(map, &clean_info, sizeof(OptMapInfo));
+}
+
+static void
+copy_opt_map_info(OptMapInfo* to, OptMapInfo* from)
+{
+  *to = *from;
+}
+
+static void
+add_char_opt_map_info(OptMapInfo* map, UChar c, OnigEncoding enc)
+{
+  if (map->map[c] == 0) {
+    map->map[c] = 1;
+    map->value += map_position_value(enc, c);
+  }
+}
+
+static int
+add_char_amb_opt_map_info(OptMapInfo* map, UChar* p, UChar* end,
+                          OnigEncoding enc, OnigCaseFoldType case_fold_flag)
+{
+  OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
+  UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
+  int i, n;
+
+  add_char_opt_map_info(map, p[0], enc);
+
+  case_fold_flag = DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag);
+  n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, case_fold_flag, p, end, items);
+  if (n < 0) return n;
+
+  for (i = 0; i < n; i++) {
+    ONIGENC_CODE_TO_MBC(enc, items[i].code[0], buf);
+    add_char_opt_map_info(map, buf[0], enc);
+  }
+
+  return 0;
+}
+
+static void
+select_opt_map_info(OptMapInfo* now, OptMapInfo* alt)
+{
+  const int z = 1<<15; /* 32768: something big value */
+
+  int v1, v2;
+
+  if (alt->value == 0) return ;
+  if (now->value == 0) {
+    copy_opt_map_info(now, alt);
+    return ;
+  }
+
+  v1 = z / now->value;
+  v2 = z / alt->value;
+  if (comp_distance_value(&now->mmd, &alt->mmd, v1, v2) > 0)
+    copy_opt_map_info(now, alt);
+}
+
+static int
+comp_opt_exact_or_map_info(OptExactInfo* e, OptMapInfo* m)
+{
+#define COMP_EM_BASE  20
+  int ve, vm;
+
+  if (m->value <= 0) return -1;
+
+  ve = COMP_EM_BASE * e->len * (e->ignore_case > 0 ? 1 : 2);
+  vm = COMP_EM_BASE * 5 * 2 / m->value;
+  return comp_distance_value(&e->mmd, &m->mmd, ve, vm);
+}
+
+static void
+alt_merge_opt_map_info(OnigEncoding enc, OptMapInfo* to, OptMapInfo* add)
+{
+  int i, val;
+
+  /* if (! is_equal_mml(&to->mmd, &add->mmd)) return ; */
+  if (to->value == 0) return ;
+  if (add->value == 0 || to->mmd.max < add->mmd.min) {
+    clear_opt_map_info(to);
+    return ;
+  }
+
+  alt_merge_mml(&to->mmd, &add->mmd);
+
+  val = 0;
+  for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) {
+    if (add->map[i])
+      to->map[i] = 1;
+
+    if (to->map[i])
+      val += map_position_value(enc, i);
+  }
+  to->value = val;
+
+  alt_merge_opt_anc_info(&to->anc, &add->anc);
+}
+
+static void
+set_bound_node_opt_info(NodeOptInfo* opt, MinMaxLen* mmd)
+{
+  copy_mml(&(opt->exb.mmd),  mmd);
+  copy_mml(&(opt->expr.mmd), mmd);
+  copy_mml(&(opt->map.mmd),  mmd);
+}
+
+static void
+clear_node_opt_info(NodeOptInfo* opt)
+{
+  clear_mml(&opt->len);
+  clear_opt_anc_info(&opt->anc);
+  clear_opt_exact_info(&opt->exb);
+  clear_opt_exact_info(&opt->exm);
+  clear_opt_exact_info(&opt->expr);
+  clear_opt_map_info(&opt->map);
+}
+
+static void
+copy_node_opt_info(NodeOptInfo* to, NodeOptInfo* from)
+{
+  *to = *from;
+}
+
+static void
+concat_left_node_opt_info(OnigEncoding enc, NodeOptInfo* to, NodeOptInfo* add)
+{
+  int exb_reach, exm_reach;
+  OptAncInfo tanc;
+
+  concat_opt_anc_info(&tanc, &to->anc, &add->anc, to->len.max, add->len.max);
+  copy_opt_anc_info(&to->anc, &tanc);
+
+  if (add->exb.len > 0 && to->len.max == 0) {
+    concat_opt_anc_info(&tanc, &to->anc, &add->exb.anc,
+			to->len.max, add->len.max);
+    copy_opt_anc_info(&add->exb.anc, &tanc);
+  }
+
+  if (add->map.value > 0 && to->len.max == 0) {
+    if (add->map.mmd.max == 0)
+      add->map.anc.left_anchor |= to->anc.left_anchor;
+  }
+
+  exb_reach = to->exb.reach_end;
+  exm_reach = to->exm.reach_end;
+
+  if (add->len.max != 0)
+    to->exb.reach_end = to->exm.reach_end = 0;
+
+  if (add->exb.len > 0) {
+    if (exb_reach) {
+      concat_opt_exact_info(&to->exb, &add->exb, enc);
+      clear_opt_exact_info(&add->exb);
+    }
+    else if (exm_reach) {
+      concat_opt_exact_info(&to->exm, &add->exb, enc);
+      clear_opt_exact_info(&add->exb);
+    }
+  }
+  select_opt_exact_info(enc, &to->exm, &add->exb);
+  select_opt_exact_info(enc, &to->exm, &add->exm);
+
+  if (to->expr.len > 0) {
+    if (add->len.max > 0) {
+      if (to->expr.len > (int )add->len.max)
+	to->expr.len = (int )add->len.max;
+
+      if (to->expr.mmd.max == 0)
+	select_opt_exact_info(enc, &to->exb, &to->expr);
+      else
+	select_opt_exact_info(enc, &to->exm, &to->expr);
+    }
+  }
+  else if (add->expr.len > 0) {
+    copy_opt_exact_info(&to->expr, &add->expr);
+  }
+
+  select_opt_map_info(&to->map, &add->map);
+
+  add_mml(&to->len, &add->len);
+}
+
+static void
+alt_merge_node_opt_info(NodeOptInfo* to, NodeOptInfo* add, OptEnv* env)
+{
+  alt_merge_opt_anc_info  (&to->anc,  &add->anc);
+  alt_merge_opt_exact_info(&to->exb,  &add->exb, env);
+  alt_merge_opt_exact_info(&to->exm,  &add->exm, env);
+  alt_merge_opt_exact_info(&to->expr, &add->expr, env);
+  alt_merge_opt_map_info(env->enc, &to->map,  &add->map);
+
+  alt_merge_mml(&to->len, &add->len);
+}
+
+
+#define MAX_NODE_OPT_INFO_REF_COUNT    5
+
+static int
+optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
+{
+  int type;
+  int r = 0;
+
+  clear_node_opt_info(opt);
+  set_bound_node_opt_info(opt, &env->mmd);
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+    {
+      OptEnv nenv;
+      NodeOptInfo nopt;
+      Node* nd = node;
+
+      copy_opt_env(&nenv, env);
+      do {
+	r = optimize_node_left(NCAR(nd), &nopt, &nenv);
+	if (r == 0) {
+	  add_mml(&nenv.mmd, &nopt.len);
+	  concat_left_node_opt_info(env->enc, opt, &nopt);
+	}
+      } while (r == 0 && IS_NOT_NULL(nd = NCDR(nd)));
+    }
+    break;
+
+  case NT_ALT:
+    {
+      NodeOptInfo nopt;
+      Node* nd = node;
+
+      do {
+	r = optimize_node_left(NCAR(nd), &nopt, env);
+	if (r == 0) {
+	  if (nd == node) copy_node_opt_info(opt, &nopt);
+	  else            alt_merge_node_opt_info(opt, &nopt, env);
+	}
+      } while ((r == 0) && IS_NOT_NULL(nd = NCDR(nd)));
+    }
+    break;
+
+  case NT_STR:
+    {
+      StrNode* sn = NSTR(node);
+      OnigDistance slen = sn->end - sn->s;
+      int is_raw = NSTRING_IS_RAW(node);
+
+      if (! NSTRING_IS_AMBIG(node)) {
+	concat_opt_exact_info_str(&opt->exb, sn->s, sn->end,
+				  is_raw, env->enc);
+	opt->exb.ignore_case = 0;
+	if (slen > 0) {
+	  add_char_opt_map_info(&opt->map, *(sn->s), env->enc);
+	}
+        set_mml(&opt->len, slen, slen);
+      }
+      else {
+        OnigDistance max;
+
+	if (NSTRING_IS_DONT_GET_OPT_INFO(node)) {
+          int n = onigenc_strlen(env->enc, sn->s, sn->end);
+          max = ONIGENC_MBC_MAXLEN_DIST(env->enc) * n;
+	}
+	else {
+	  concat_opt_exact_info_str(&opt->exb, sn->s, sn->end,
+				    is_raw, env->enc);
+	  opt->exb.ignore_case = 1;
+
+	  if (slen > 0) {
+	    r = add_char_amb_opt_map_info(&opt->map, sn->s, sn->end,
+					  env->enc, env->case_fold_flag);
+	    if (r != 0) break;
+	  }
+
+	  max = slen;
+	}
+
+        set_mml(&opt->len, slen, max);
+      }
+
+      if ((OnigDistance )opt->exb.len == slen)
+	opt->exb.reach_end = 1;
+    }
+    break;
+
+  case NT_CCLASS:
+    {
+      int i, z;
+      CClassNode* cc = NCCLASS(node);
+
+      /* no need to check ignore case. (set in setup_tree()) */
+
+      if (IS_NOT_NULL(cc->mbuf) || IS_NCCLASS_NOT(cc)) {
+        OnigDistance min = ONIGENC_MBC_MINLEN(env->enc);
+	OnigDistance max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
+
+	set_mml(&opt->len, min, max);
+      }
+      else {
+        for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
+          z = BITSET_AT(cc->bs, i);
+          if ((z && !IS_NCCLASS_NOT(cc)) || (!z && IS_NCCLASS_NOT(cc))) {
+            add_char_opt_map_info(&opt->map, (UChar )i, env->enc);
+          }
+        }
+	set_mml(&opt->len, 1, 1);
+      }
+    }
+    break;
+
+  case NT_CTYPE:
+    {
+      int i, min, max;
+      int maxcode;
+
+      max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
+
+      if (max == 1) {
+        min = 1;
+
+	maxcode = NCTYPE(node)->ascii_range ? 0x80 : SINGLE_BYTE_SIZE;
+	switch (NCTYPE(node)->ctype) {
+	case ONIGENC_CTYPE_WORD:
+	  if (NCTYPE(node)->not != 0) {
+	    for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
+	      if (! ONIGENC_IS_CODE_WORD(env->enc, i) || i >= maxcode) {
+		add_char_opt_map_info(&opt->map, (UChar )i, env->enc);
+	      }
+	    }
+	  }
+	  else {
+	    for (i = 0; i < maxcode; i++) {
+	      if (ONIGENC_IS_CODE_WORD(env->enc, i)) {
+		add_char_opt_map_info(&opt->map, (UChar )i, env->enc);
+	      }
+	    }
+	  }
+	  break;
+	}
+      }
+      else {
+        min = ONIGENC_MBC_MINLEN(env->enc);
+      }
+      set_mml(&opt->len, min, max);
+    }
+    break;
+
+  case NT_CANY:
+    {
+      OnigDistance min = ONIGENC_MBC_MINLEN(env->enc);
+      OnigDistance max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
+      set_mml(&opt->len, min, max);
+    }
+    break;
+
+  case NT_ANCHOR:
+    switch (NANCHOR(node)->type) {
+    case ANCHOR_BEGIN_BUF:
+    case ANCHOR_BEGIN_POSITION:
+    case ANCHOR_BEGIN_LINE:
+    case ANCHOR_END_BUF:
+    case ANCHOR_SEMI_END_BUF:
+    case ANCHOR_END_LINE:
+    case ANCHOR_LOOK_BEHIND:	/* just for (?<=x).* */
+    case ANCHOR_PREC_READ_NOT:	/* just for (?!x).* */
+      add_opt_anc_info(&opt->anc, NANCHOR(node)->type);
+      break;
+
+    case ANCHOR_PREC_READ:
+      {
+	NodeOptInfo nopt;
+
+	r = optimize_node_left(NANCHOR(node)->target, &nopt, env);
+	if (r == 0) {
+	  if (nopt.exb.len > 0)
+	    copy_opt_exact_info(&opt->expr, &nopt.exb);
+	  else if (nopt.exm.len > 0)
+	    copy_opt_exact_info(&opt->expr, &nopt.exm);
+
+	  opt->expr.reach_end = 0;
+
+	  if (nopt.map.value > 0)
+	    copy_opt_map_info(&opt->map, &nopt.map);
+	}
+      }
+      break;
+
+    case ANCHOR_LOOK_BEHIND_NOT:
+      break;
+    }
+    break;
+
+  case NT_BREF:
+    {
+      int i;
+      int* backs;
+      OnigDistance min, max, tmin, tmax;
+      Node** nodes = SCANENV_MEM_NODES(env->scan_env);
+      BRefNode* br = NBREF(node);
+
+      if (br->state & NST_RECURSION) {
+	set_mml(&opt->len, 0, ONIG_INFINITE_DISTANCE);
+	break;
+      }
+      backs = BACKREFS_P(br);
+      r = get_min_match_length(nodes[backs[0]], &min, env->scan_env);
+      if (r != 0) break;
+      r = get_max_match_length(nodes[backs[0]], &max, env->scan_env);
+      if (r != 0) break;
+      for (i = 1; i < br->back_num; i++) {
+	r = get_min_match_length(nodes[backs[i]], &tmin, env->scan_env);
+	if (r != 0) break;
+	r = get_max_match_length(nodes[backs[i]], &tmax, env->scan_env);
+	if (r != 0) break;
+	if (min > tmin) min = tmin;
+	if (max < tmax) max = tmax;
+      }
+      if (r == 0) set_mml(&opt->len, min, max);
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    if (IS_CALL_RECURSION(NCALL(node)))
+      set_mml(&opt->len, 0, ONIG_INFINITE_DISTANCE);
+    else {
+      OnigOptionType save = env->options;
+      env->options = NENCLOSE(NCALL(node)->target)->option;
+      r = optimize_node_left(NCALL(node)->target, opt, env);
+      env->options = save;
+    }
+    break;
+#endif
+
+  case NT_QTFR:
+    {
+      int i;
+      OnigDistance min, max;
+      NodeOptInfo nopt;
+      QtfrNode* qn = NQTFR(node);
+
+      r = optimize_node_left(qn->target, &nopt, env);
+      if (r) break;
+
+      if (/*qn->lower == 0 &&*/ IS_REPEAT_INFINITE(qn->upper)) {
+	if (env->mmd.max == 0 &&
+	    NTYPE(qn->target) == NT_CANY && qn->greedy) {
+	  if (IS_MULTILINE(env->options))
+	    /* implicit anchor: /.*a/ ==> /\A.*a/ */
+	    add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR_ML);
+	  else
+	    add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR);
+	}
+      }
+      else {
+	if (qn->lower > 0) {
+	  copy_node_opt_info(opt, &nopt);
+	  if (nopt.exb.len > 0) {
+	    if (nopt.exb.reach_end) {
+	      for (i = 2; i <= qn->lower &&
+		          ! is_full_opt_exact_info(&opt->exb); i++) {
+		concat_opt_exact_info(&opt->exb, &nopt.exb, env->enc);
+	      }
+	      if (i < qn->lower) {
+		opt->exb.reach_end = 0;
+	      }
+	    }
+	  }
+
+	  if (qn->lower != qn->upper) {
+	    opt->exb.reach_end = 0;
+	    opt->exm.reach_end = 0;
+	  }
+	  if (qn->lower > 1)
+	    opt->exm.reach_end = 0;
+	}
+      }
+
+      min = distance_multiply(nopt.len.min, qn->lower);
+      if (IS_REPEAT_INFINITE(qn->upper))
+	max = (nopt.len.max > 0 ? ONIG_INFINITE_DISTANCE : 0);
+      else
+	max = distance_multiply(nopt.len.max, qn->upper);
+
+      set_mml(&opt->len, min, max);
+    }
+    break;
+
+  case NT_ENCLOSE:
+    {
+      EncloseNode* en = NENCLOSE(node);
+
+      switch (en->type) {
+      case ENCLOSE_OPTION:
+	{
+	  OnigOptionType save = env->options;
+
+	  env->options = en->option;
+	  r = optimize_node_left(en->target, opt, env);
+	  env->options = save;
+	}
+	break;
+
+      case ENCLOSE_MEMORY:
+#ifdef USE_SUBEXP_CALL
+	en->opt_count++;
+	if (en->opt_count > MAX_NODE_OPT_INFO_REF_COUNT) {
+	  OnigDistance min, max;
+
+	  min = 0;
+	  max = ONIG_INFINITE_DISTANCE;
+	  if (IS_ENCLOSE_MIN_FIXED(en)) min = en->min_len;
+	  if (IS_ENCLOSE_MAX_FIXED(en)) max = en->max_len;
+	  set_mml(&opt->len, min, max);
+	}
+	else
+#endif
+	{
+	  r = optimize_node_left(en->target, opt, env);
+
+	  if (is_set_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR_MASK)) {
+	    if (BIT_STATUS_AT(env->scan_env->backrefed_mem, en->regnum))
+	      remove_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR_MASK);
+	  }
+	}
+	break;
+
+      case ENCLOSE_STOP_BACKTRACK:
+      case ENCLOSE_CONDITION:
+	r = optimize_node_left(en->target, opt, env);
+	break;
+      }
+    }
+    break;
+
+  default:
+#ifdef ONIG_DEBUG
+    fprintf(stderr, "optimize_node_left: undefined node type %d\n",
+	    NTYPE(node));
+#endif
+    r = ONIGERR_TYPE_BUG;
+    break;
+  }
+
+  return r;
+}
+
+static int
+set_optimize_exact_info(regex_t* reg, OptExactInfo* e)
+{
+  int r;
+  int allow_reverse;
+
+  if (e->len == 0) return 0;
+
+  reg->exact = (UChar* )xmalloc(e->len);
+  CHECK_NULL_RETURN_MEMERR(reg->exact);
+  xmemcpy(reg->exact, e->s, e->len);
+  reg->exact_end = reg->exact + e->len;
+
+  allow_reverse =
+	ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);
+
+  if (e->ignore_case > 0) {
+    if (e->len >= 3 || (e->len >= 2 && allow_reverse)) {
+      r = set_bm_skip(reg->exact, reg->exact_end, reg,
+		      reg->map, &(reg->int_map), 1);
+      if (r == 0) {
+	reg->optimize = (allow_reverse != 0
+			 ? ONIG_OPTIMIZE_EXACT_BM_IC : ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC);
+      }
+      else {
+	reg->optimize = ONIG_OPTIMIZE_EXACT_IC;
+      }
+    }
+    else {
+      reg->optimize = ONIG_OPTIMIZE_EXACT_IC;
+    }
+  }
+  else {
+    if (e->len >= 3 || (e->len >= 2 && allow_reverse)) {
+      r = set_bm_skip(reg->exact, reg->exact_end, reg,
+	              reg->map, &(reg->int_map), 0);
+      if (r) return r;
+
+      reg->optimize = (allow_reverse != 0
+		       ? ONIG_OPTIMIZE_EXACT_BM : ONIG_OPTIMIZE_EXACT_BM_NOT_REV);
+    }
+    else {
+      reg->optimize = ONIG_OPTIMIZE_EXACT;
+    }
+  }
+
+  reg->dmin = e->mmd.min;
+  reg->dmax = e->mmd.max;
+
+  if (reg->dmin != ONIG_INFINITE_DISTANCE) {
+    reg->threshold_len = (int )(reg->dmin + (reg->exact_end - reg->exact));
+  }
+
+  return 0;
+}
+
+static void
+set_optimize_map_info(regex_t* reg, OptMapInfo* m)
+{
+  int i;
+
+  for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
+    reg->map[i] = m->map[i];
+
+  reg->optimize   = ONIG_OPTIMIZE_MAP;
+  reg->dmin       = m->mmd.min;
+  reg->dmax       = m->mmd.max;
+
+  if (reg->dmin != ONIG_INFINITE_DISTANCE) {
+    reg->threshold_len = (int )(reg->dmin + 1);
+  }
+}
+
+static void
+set_sub_anchor(regex_t* reg, OptAncInfo* anc)
+{
+  reg->sub_anchor |= anc->left_anchor  & ANCHOR_BEGIN_LINE;
+  reg->sub_anchor |= anc->right_anchor & ANCHOR_END_LINE;
+}
+
+#if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH)
+static void print_optimize_info(FILE* f, regex_t* reg);
+#endif
+
+static int
+set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env)
+{
+
+  int r;
+  NodeOptInfo opt;
+  OptEnv env;
+
+  env.enc            = reg->enc;
+  env.options        = reg->options;
+  env.case_fold_flag = reg->case_fold_flag;
+  env.scan_env   = scan_env;
+  clear_mml(&env.mmd);
+
+  r = optimize_node_left(node, &opt, &env);
+  if (r) return r;
+
+  reg->anchor = opt.anc.left_anchor & (ANCHOR_BEGIN_BUF |
+        ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML |
+        ANCHOR_LOOK_BEHIND);
+
+  reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF |
+	ANCHOR_PREC_READ_NOT);
+
+  if (reg->anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)) {
+    reg->anchor_dmin = opt.len.min;
+    reg->anchor_dmax = opt.len.max;
+  }
+
+  if (opt.exb.len > 0 || opt.exm.len > 0) {
+    select_opt_exact_info(reg->enc, &opt.exb, &opt.exm);
+    if (opt.map.value > 0 &&
+	comp_opt_exact_or_map_info(&opt.exb, &opt.map) > 0) {
+      goto set_map;
+    }
+    else {
+      r = set_optimize_exact_info(reg, &opt.exb);
+      set_sub_anchor(reg, &opt.exb.anc);
+    }
+  }
+  else if (opt.map.value > 0) {
+  set_map:
+    set_optimize_map_info(reg, &opt.map);
+    set_sub_anchor(reg, &opt.map.anc);
+  }
+  else {
+    reg->sub_anchor |= opt.anc.left_anchor & ANCHOR_BEGIN_LINE;
+    if (opt.len.max == 0)
+      reg->sub_anchor |= opt.anc.right_anchor & ANCHOR_END_LINE;
+  }
+
+#if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH)
+  print_optimize_info(stderr, reg);
+#endif
+  return r;
+}
+
+static void
+clear_optimize_info(regex_t* reg)
+{
+  reg->optimize      = ONIG_OPTIMIZE_NONE;
+  reg->anchor        = 0;
+  reg->anchor_dmin   = 0;
+  reg->anchor_dmax   = 0;
+  reg->sub_anchor    = 0;
+  reg->exact_end     = (UChar* )NULL;
+  reg->threshold_len = 0;
+  if (IS_NOT_NULL(reg->exact)) {
+    xfree(reg->exact);
+    reg->exact = (UChar* )NULL;
+  }
+}
+
+#ifdef ONIG_DEBUG
+
+static void print_enc_string(FILE* fp, OnigEncoding enc,
+			     const UChar *s, const UChar *end)
+{
+  fprintf(fp, "\nPATTERN: /");
+
+  if (ONIGENC_MBC_MINLEN(enc) > 1) {
+    const UChar *p;
+    OnigCodePoint code;
+
+    p = s;
+    while (p < end) {
+      code = ONIGENC_MBC_TO_CODE(enc, p, end);
+      if (code >= 0x80) {
+	fprintf(fp, " 0x%04x ", (int )code);
+      }
+      else {
+	fputc((int )code, fp);
+      }
+
+      p += enclen(enc, p);
+    }
+  }
+  else {
+    while (s < end) {
+      fputc((int )*s, fp);
+      s++;
+    }
+  }
+
+  fprintf(fp, "/ (%s)\n", enc->name);
+}
+#endif	/* ONIG_DEBUG */
+
+#if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH)
+static void
+print_distance_range(FILE* f, OnigDistance a, OnigDistance b)
+{
+  if (a == ONIG_INFINITE_DISTANCE)
+    fputs("inf", f);
+  else
+    fprintf(f, "(%"PRIuPTR")", a);
+
+  fputs("-", f);
+
+  if (b == ONIG_INFINITE_DISTANCE)
+    fputs("inf", f);
+  else
+    fprintf(f, "(%"PRIuPTR")", b);
+}
+
+static void
+print_anchor(FILE* f, int anchor)
+{
+  int q = 0;
+
+  fprintf(f, "[");
+
+  if (anchor & ANCHOR_BEGIN_BUF) {
+    fprintf(f, "begin-buf");
+    q = 1;
+  }
+  if (anchor & ANCHOR_BEGIN_LINE) {
+    if (q) fprintf(f, ", ");
+    q = 1;
+    fprintf(f, "begin-line");
+  }
+  if (anchor & ANCHOR_BEGIN_POSITION) {
+    if (q) fprintf(f, ", ");
+    q = 1;
+    fprintf(f, "begin-pos");
+  }
+  if (anchor & ANCHOR_END_BUF) {
+    if (q) fprintf(f, ", ");
+    q = 1;
+    fprintf(f, "end-buf");
+  }
+  if (anchor & ANCHOR_SEMI_END_BUF) {
+    if (q) fprintf(f, ", ");
+    q = 1;
+    fprintf(f, "semi-end-buf");
+  }
+  if (anchor & ANCHOR_END_LINE) {
+    if (q) fprintf(f, ", ");
+    q = 1;
+    fprintf(f, "end-line");
+  }
+  if (anchor & ANCHOR_ANYCHAR_STAR) {
+    if (q) fprintf(f, ", ");
+    q = 1;
+    fprintf(f, "anychar-star");
+  }
+  if (anchor & ANCHOR_ANYCHAR_STAR_ML) {
+    if (q) fprintf(f, ", ");
+    fprintf(f, "anychar-star-ml");
+  }
+
+  fprintf(f, "]");
+}
+
+static void
+print_optimize_info(FILE* f, regex_t* reg)
+{
+  static const char* on[] = { "NONE", "EXACT", "EXACT_BM", "EXACT_BM_NOT_REV",
+                              "EXACT_IC", "MAP",
+                              "EXACT_BM_IC", "EXACT_BM_NOT_REV_IC" };
+
+  fprintf(f, "optimize: %s\n", on[reg->optimize]);
+  fprintf(f, "  anchor: "); print_anchor(f, reg->anchor);
+  if ((reg->anchor & ANCHOR_END_BUF_MASK) != 0)
+    print_distance_range(f, reg->anchor_dmin, reg->anchor_dmax);
+  fprintf(f, "\n");
+
+  if (reg->optimize) {
+    fprintf(f, "  sub anchor: "); print_anchor(f, reg->sub_anchor);
+    fprintf(f, "\n");
+  }
+  fprintf(f, "\n");
+
+  if (reg->exact) {
+    UChar *p;
+    fprintf(f, "exact: [");
+    for (p = reg->exact; p < reg->exact_end; p++) {
+      fputc(*p, f);
+    }
+    fprintf(f, "]: length: %"PRIdPTR"\n", (reg->exact_end - reg->exact));
+  }
+  else if (reg->optimize & ONIG_OPTIMIZE_MAP) {
+    int c, i, n = 0;
+
+    for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
+      if (reg->map[i]) n++;
+
+    fprintf(f, "map: n=%d\n", n);
+    if (n > 0) {
+      c = 0;
+      fputc('[', f);
+      for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) {
+	if (reg->map[i] != 0) {
+          if (c > 0)  fputs(", ", f);
+          c++;
+          if (ONIGENC_MBC_MAXLEN(reg->enc) == 1 &&
+              ONIGENC_IS_CODE_PRINT(reg->enc, (OnigCodePoint )i))
+            fputc(i, f);
+          else
+            fprintf(f, "%d", i);
+        }
+      }
+      fprintf(f, "]\n");
+    }
+  }
+}
+#endif /* ONIG_DEBUG_COMPILE || ONIG_DEBUG_MATCH */
+
+
+extern void
+onig_free_body(regex_t* reg)
+{
+  if (IS_NOT_NULL(reg)) {
+    if (IS_NOT_NULL(reg->p))                xfree(reg->p);
+    if (IS_NOT_NULL(reg->exact))            xfree(reg->exact);
+    if (IS_NOT_NULL(reg->int_map))          xfree(reg->int_map);
+    if (IS_NOT_NULL(reg->int_map_backward)) xfree(reg->int_map_backward);
+    if (IS_NOT_NULL(reg->repeat_range))     xfree(reg->repeat_range);
+    if (IS_NOT_NULL(reg->chain))            onig_free(reg->chain);
+
+#ifdef USE_NAMED_GROUP
+    onig_names_free(reg);
+#endif
+  }
+}
+
+extern void
+onig_free(regex_t* reg)
+{
+  if (IS_NOT_NULL(reg)) {
+    onig_free_body(reg);
+    xfree(reg);
+  }
+}
+
+size_t
+onig_memsize(const regex_t *reg)
+{
+    size_t size = sizeof(regex_t);
+    if (IS_NULL(reg)) return 0;
+    if (IS_NOT_NULL(reg->p))                size += reg->alloc;
+    if (IS_NOT_NULL(reg->exact))            size += reg->exact_end - reg->exact;
+    if (IS_NOT_NULL(reg->int_map))          size += sizeof(int) * ONIG_CHAR_TABLE_SIZE;
+    if (IS_NOT_NULL(reg->int_map_backward)) size += sizeof(int) * ONIG_CHAR_TABLE_SIZE;
+    if (IS_NOT_NULL(reg->repeat_range))     size += reg->repeat_range_alloc * sizeof(OnigRepeatRange);
+    if (IS_NOT_NULL(reg->chain))            size += onig_memsize(reg->chain);
+
+    return size;
+}
+
+size_t
+onig_region_memsize(const OnigRegion *regs)
+{
+    size_t size = sizeof(*regs);
+    if (IS_NULL(regs)) return 0;
+    size += regs->allocated * (sizeof(*regs->beg) + sizeof(*regs->end));
+    return size;
+}
+
+#define REGEX_TRANSFER(to,from) do {\
+  (to)->state = ONIG_STATE_MODIFY;\
+  onig_free_body(to);\
+  xmemcpy(to, from, sizeof(regex_t));\
+  xfree(from);\
+} while (0)
+
+extern void
+onig_transfer(regex_t* to, regex_t* from)
+{
+  THREAD_ATOMIC_START;
+  REGEX_TRANSFER(to, from);
+  THREAD_ATOMIC_END;
+}
+
+#define REGEX_CHAIN_HEAD(reg) do {\
+  while (IS_NOT_NULL((reg)->chain)) {\
+    (reg) = (reg)->chain;\
+  }\
+} while (0)
+
+extern void
+onig_chain_link_add(regex_t* to, regex_t* add)
+{
+  THREAD_ATOMIC_START;
+  REGEX_CHAIN_HEAD(to);
+  to->chain = add;
+  THREAD_ATOMIC_END;
+}
+
+extern void
+onig_chain_reduce(regex_t* reg)
+{
+  regex_t *head, *prev;
+
+  prev = reg;
+  head = prev->chain;
+  if (IS_NOT_NULL(head)) {
+    reg->state = ONIG_STATE_MODIFY;
+    while (IS_NOT_NULL(head->chain)) {
+      prev = head;
+      head = head->chain;
+    }
+    prev->chain = (regex_t* )NULL;
+    REGEX_TRANSFER(reg, head);
+  }
+}
+
+#ifdef ONIG_DEBUG_COMPILE
+static void print_compiled_byte_code_list P_((FILE* f, regex_t* reg));
+#endif
+#ifdef ONIG_DEBUG_PARSE_TREE
+static void print_tree P_((FILE* f, Node* node));
+#endif
+
+extern int
+onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
+	      OnigErrorInfo* einfo)
+{
+#define COMPILE_INIT_SIZE  20
+
+  int r;
+  OnigDistance init_size;
+  Node*  root;
+  ScanEnv  scan_env = {0};
+#ifdef USE_SUBEXP_CALL
+  UnsetAddrList  uslist;
+#endif
+
+  if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;
+
+  reg->state = ONIG_STATE_COMPILING;
+
+#ifdef ONIG_DEBUG
+  print_enc_string(stderr, reg->enc, pattern, pattern_end);
+#endif
+
+  if (reg->alloc == 0) {
+    init_size = (pattern_end - pattern) * 2;
+    if (init_size <= 0) init_size = COMPILE_INIT_SIZE;
+    r = BBUF_INIT(reg, init_size);
+    if (r != 0) goto end;
+  }
+  else
+    reg->used = 0;
+
+  reg->num_mem            = 0;
+  reg->num_repeat         = 0;
+  reg->num_null_check     = 0;
+  reg->repeat_range_alloc = 0;
+  reg->repeat_range       = (OnigRepeatRange* )NULL;
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  reg->num_comb_exp_check = 0;
+#endif
+
+  r = onig_parse_make_tree(&root, pattern, pattern_end, reg, &scan_env);
+  if (r != 0) goto err;
+
+#ifdef USE_NAMED_GROUP
+  /* mixed use named group and no-named group */
+  if (scan_env.num_named > 0 &&
+      IS_SYNTAX_BV(scan_env.syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
+      !ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_CAPTURE_GROUP)) {
+    if (scan_env.num_named != scan_env.num_mem)
+      r = disable_noname_group_capture(&root, reg, &scan_env);
+    else
+      r = numbered_ref_check(root);
+
+    if (r != 0) goto err;
+  }
+#endif
+
+#ifdef USE_SUBEXP_CALL
+  if (scan_env.num_call > 0) {
+    r = unset_addr_list_init(&uslist, scan_env.num_call);
+    if (r != 0) goto err;
+    scan_env.unset_addr_list = &uslist;
+    r = setup_subexp_call(root, &scan_env);
+    if (r != 0) goto err_unset;
+    r = subexp_recursive_check_trav(root, &scan_env);
+    if (r  < 0) goto err_unset;
+    r = subexp_inf_recursive_check_trav(root, &scan_env);
+    if (r != 0) goto err_unset;
+
+    reg->num_call = scan_env.num_call;
+  }
+  else
+    reg->num_call = 0;
+#endif
+
+  r = setup_tree(root, reg, IN_ROOT, &scan_env);
+  if (r != 0) goto err_unset;
+
+#ifdef ONIG_DEBUG_PARSE_TREE
+  print_tree(stderr, root);
+#endif
+
+  reg->capture_history  = scan_env.capture_history;
+  reg->bt_mem_start     = scan_env.bt_mem_start;
+  reg->bt_mem_start    |= reg->capture_history;
+  if (IS_FIND_CONDITION(reg->options))
+    BIT_STATUS_ON_ALL(reg->bt_mem_end);
+  else {
+    reg->bt_mem_end  = scan_env.bt_mem_end;
+    reg->bt_mem_end |= reg->capture_history;
+  }
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  if (scan_env.backrefed_mem == 0
+#ifdef USE_SUBEXP_CALL
+      || scan_env.num_call == 0
+#endif
+      ) {
+    setup_comb_exp_check(root, 0, &scan_env);
+#ifdef USE_SUBEXP_CALL
+    if (scan_env.has_recursion != 0) {
+      scan_env.num_comb_exp_check = 0;
+    }
+    else
+#endif
+    if (scan_env.comb_exp_max_regnum > 0) {
+      int i;
+      for (i = 1; i <= scan_env.comb_exp_max_regnum; i++) {
+	if (BIT_STATUS_AT(scan_env.backrefed_mem, i) != 0) {
+	  scan_env.num_comb_exp_check = 0;
+	  break;
+	}
+      }
+    }
+  }
+
+  reg->num_comb_exp_check = scan_env.num_comb_exp_check;
+#endif
+
+  clear_optimize_info(reg);
+#ifndef ONIG_DONT_OPTIMIZE
+  r = set_optimize_info_from_tree(root, reg, &scan_env);
+  if (r != 0) goto err_unset;
+#endif
+
+  if (IS_NOT_NULL(scan_env.mem_nodes_dynamic)) {
+    xfree(scan_env.mem_nodes_dynamic);
+    scan_env.mem_nodes_dynamic = (Node** )NULL;
+  }
+
+  r = compile_tree(root, reg);
+  if (r == 0) {
+    r = add_opcode(reg, OP_END);
+#ifdef USE_SUBEXP_CALL
+    if (scan_env.num_call > 0) {
+      r = unset_addr_list_fix(&uslist, reg);
+      unset_addr_list_end(&uslist);
+      if (r) goto err;
+    }
+#endif
+
+    if ((reg->num_repeat != 0) || (reg->bt_mem_end != 0))
+      reg->stack_pop_level = STACK_POP_LEVEL_ALL;
+    else {
+      if (reg->bt_mem_start != 0)
+	reg->stack_pop_level = STACK_POP_LEVEL_MEM_START;
+      else
+	reg->stack_pop_level = STACK_POP_LEVEL_FREE;
+    }
+  }
+#ifdef USE_SUBEXP_CALL
+  else if (scan_env.num_call > 0) {
+    unset_addr_list_end(&uslist);
+  }
+#endif
+  onig_node_free(root);
+
+#ifdef ONIG_DEBUG_COMPILE
+#ifdef USE_NAMED_GROUP
+  onig_print_names(stderr, reg);
+#endif
+  print_compiled_byte_code_list(stderr, reg);
+#endif
+
+ end:
+  reg->state = ONIG_STATE_NORMAL;
+  return r;
+
+ err_unset:
+#ifdef USE_SUBEXP_CALL
+  if (scan_env.num_call > 0) {
+    unset_addr_list_end(&uslist);
+  }
+#endif
+ err:
+  if (IS_NOT_NULL(scan_env.error)) {
+    if (IS_NOT_NULL(einfo)) {
+      einfo->enc     = scan_env.enc;
+      einfo->par     = scan_env.error;
+      einfo->par_end = scan_env.error_end;
+    }
+  }
+
+  onig_node_free(root);
+  if (IS_NOT_NULL(scan_env.mem_nodes_dynamic))
+      xfree(scan_env.mem_nodes_dynamic);
+  return r;
+}
+
+#ifdef USE_RECOMPILE_API
+extern int
+onig_recompile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
+	    OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
+	    OnigErrorInfo* einfo)
+{
+  int r;
+  regex_t *new_reg;
+
+  r = onig_new(&new_reg, pattern, pattern_end, option, enc, syntax, einfo);
+  if (r) return r;
+  if (ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
+    onig_transfer(reg, new_reg);
+  }
+  else {
+    onig_chain_link_add(reg, new_reg);
+  }
+  return 0;
+}
+#endif
+
+static int onig_inited = 0;
+
+extern int
+onig_reg_init(regex_t* reg, OnigOptionType option,
+	      OnigCaseFoldType case_fold_flag,
+	      OnigEncoding enc, OnigSyntaxType* syntax)
+{
+  if (! onig_inited)
+    onig_init();
+
+  if (IS_NULL(reg))
+    return ONIGERR_INVALID_ARGUMENT;
+
+  if (ONIGENC_IS_UNDEF(enc))
+    return ONIGERR_DEFAULT_ENCODING_IS_NOT_SET;
+
+  if ((option & (ONIG_OPTION_DONT_CAPTURE_GROUP|ONIG_OPTION_CAPTURE_GROUP))
+      == (ONIG_OPTION_DONT_CAPTURE_GROUP|ONIG_OPTION_CAPTURE_GROUP)) {
+    return ONIGERR_INVALID_COMBINATION_OF_OPTIONS;
+  }
+
+  (reg)->state = ONIG_STATE_MODIFY;
+
+  if ((option & ONIG_OPTION_NEGATE_SINGLELINE) != 0) {
+    option |= syntax->options;
+    option &= ~ONIG_OPTION_SINGLELINE;
+  }
+  else
+    option |= syntax->options;
+
+  (reg)->enc              = enc;
+  (reg)->options          = option;
+  (reg)->syntax           = syntax;
+  (reg)->optimize         = 0;
+  (reg)->exact            = (UChar* )NULL;
+  (reg)->int_map          = (int* )NULL;
+  (reg)->int_map_backward = (int* )NULL;
+  (reg)->chain            = (regex_t* )NULL;
+
+  (reg)->p                = (UChar* )NULL;
+  (reg)->alloc            = 0;
+  (reg)->used             = 0;
+  (reg)->name_table       = (void* )NULL;
+
+  (reg)->case_fold_flag   = case_fold_flag;
+  return 0;
+}
+
+extern int
+onig_new_without_alloc(regex_t* reg, const UChar* pattern,
+          const UChar* pattern_end, OnigOptionType option, OnigEncoding enc,
+          OnigSyntaxType* syntax, OnigErrorInfo* einfo)
+{
+  int r;
+
+  r = onig_reg_init(reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
+  if (r) return r;
+
+  r = onig_compile(reg, pattern, pattern_end, einfo);
+  return r;
+}
+
+extern int
+onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
+	  OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
+	  OnigErrorInfo* einfo)
+{
+  int r;
+
+  *reg = (regex_t* )xmalloc(sizeof(regex_t));
+  if (IS_NULL(*reg)) return ONIGERR_MEMORY;
+
+  r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
+  if (r) goto err;
+
+  r = onig_compile(*reg, pattern, pattern_end, einfo);
+  if (r) {
+  err:
+    onig_free(*reg);
+    *reg = NULL;
+  }
+  return r;
+}
+
+
+extern int
+onig_init(void)
+{
+  if (onig_inited != 0)
+    return 0;
+
+  THREAD_SYSTEM_INIT;
+  THREAD_ATOMIC_START;
+
+  onig_inited = 1;
+
+  onigenc_init();
+  /* onigenc_set_default_caseconv_table((UChar* )0); */
+
+#ifdef ONIG_DEBUG_STATISTICS
+  onig_statistics_init();
+#endif
+
+  THREAD_ATOMIC_END;
+  return 0;
+}
+
+
+static OnigEndCallListItemType* EndCallTop;
+
+extern void onig_add_end_call(void (*func)(void))
+{
+  OnigEndCallListItemType* item;
+
+  item = (OnigEndCallListItemType* )xmalloc(sizeof(*item));
+  if (item == 0) return ;
+
+  item->next = EndCallTop;
+  item->func = func;
+
+  EndCallTop = item;
+}
+
+static void
+exec_end_call_list(void)
+{
+  OnigEndCallListItemType* prev;
+  void (*func)(void);
+
+  while (EndCallTop != 0) {
+    func = EndCallTop->func;
+    (*func)();
+
+    prev = EndCallTop;
+    EndCallTop = EndCallTop->next;
+    xfree(prev);
+  }
+}
+
+extern int
+onig_end(void)
+{
+  THREAD_ATOMIC_START;
+
+  exec_end_call_list();
+
+#ifdef ONIG_DEBUG_STATISTICS
+  onig_print_statistics(stderr);
+#endif
+
+#ifdef USE_SHARED_CCLASS_TABLE
+  onig_free_shared_cclass_table();
+#endif
+
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+  onig_free_node_list();
+#endif
+
+  onig_inited = 0;
+
+  THREAD_ATOMIC_END;
+  THREAD_SYSTEM_END;
+  return 0;
+}
+
+extern int
+onig_is_in_code_range(const UChar* p, OnigCodePoint code)
+{
+  OnigCodePoint n, *data;
+  OnigCodePoint low, high, x;
+
+  GET_CODE_POINT(n, p);
+  data = (OnigCodePoint* )p;
+  data++;
+
+  for (low = 0, high = n; low < high; ) {
+    x = (low + high) >> 1;
+    if (code > data[x * 2 + 1])
+      low = x + 1;
+    else
+      high = x;
+  }
+
+  return ((low < n && code >= data[low * 2]) ? 1 : 0);
+}
+
+extern int
+onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode* cc)
+{
+  int found;
+
+  if (elen > 1 || (code >= SINGLE_BYTE_SIZE)) {
+    if (IS_NULL(cc->mbuf)) {
+      found = 0;
+    }
+    else {
+      found = (onig_is_in_code_range(cc->mbuf->p, code) != 0 ? 1 : 0);
+    }
+  }
+  else {
+    found = (BITSET_AT(cc->bs, code) == 0 ? 0 : 1);
+  }
+
+  if (IS_NCCLASS_NOT(cc))
+    return !found;
+  else
+    return found;
+}
+
+extern int
+onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode* cc)
+{
+  int len;
+
+  if (ONIGENC_MBC_MINLEN(enc) > 1) {
+    len = 2;
+  }
+  else {
+    len = ONIGENC_CODE_TO_MBCLEN(enc, code);
+  }
+  return onig_is_code_in_cc_len(len, code, cc);
+}
+
+
+#ifdef ONIG_DEBUG
+
+/* arguments type */
+#define ARG_SPECIAL     -1
+#define ARG_NON          0
+#define ARG_RELADDR      1
+#define ARG_ABSADDR      2
+#define ARG_LENGTH       3
+#define ARG_MEMNUM       4
+#define ARG_OPTION       5
+#define ARG_STATE_CHECK  6
+
+OnigOpInfoType OnigOpInfo[] = {
+  { OP_FINISH,            "finish",          ARG_NON },
+  { OP_END,               "end",             ARG_NON },
+  { OP_EXACT1,            "exact1",          ARG_SPECIAL },
+  { OP_EXACT2,            "exact2",          ARG_SPECIAL },
+  { OP_EXACT3,            "exact3",          ARG_SPECIAL },
+  { OP_EXACT4,            "exact4",          ARG_SPECIAL },
+  { OP_EXACT5,            "exact5",          ARG_SPECIAL },
+  { OP_EXACTN,            "exactn",          ARG_SPECIAL },
+  { OP_EXACTMB2N1,        "exactmb2-n1",     ARG_SPECIAL },
+  { OP_EXACTMB2N2,        "exactmb2-n2",     ARG_SPECIAL },
+  { OP_EXACTMB2N3,        "exactmb2-n3",     ARG_SPECIAL },
+  { OP_EXACTMB2N,         "exactmb2-n",      ARG_SPECIAL },
+  { OP_EXACTMB3N,         "exactmb3n"  ,     ARG_SPECIAL },
+  { OP_EXACTMBN,          "exactmbn",        ARG_SPECIAL },
+  { OP_EXACT1_IC,         "exact1-ic",       ARG_SPECIAL },
+  { OP_EXACTN_IC,         "exactn-ic",       ARG_SPECIAL },
+  { OP_CCLASS,            "cclass",          ARG_SPECIAL },
+  { OP_CCLASS_MB,         "cclass-mb",       ARG_SPECIAL },
+  { OP_CCLASS_MIX,        "cclass-mix",      ARG_SPECIAL },
+  { OP_CCLASS_NOT,        "cclass-not",      ARG_SPECIAL },
+  { OP_CCLASS_MB_NOT,     "cclass-mb-not",   ARG_SPECIAL },
+  { OP_CCLASS_MIX_NOT,    "cclass-mix-not",  ARG_SPECIAL },
+  { OP_CCLASS_NODE,       "cclass-node",     ARG_SPECIAL },
+  { OP_ANYCHAR,           "anychar",         ARG_NON },
+  { OP_ANYCHAR_ML,        "anychar-ml",      ARG_NON },
+  { OP_ANYCHAR_STAR,      "anychar*",        ARG_NON },
+  { OP_ANYCHAR_ML_STAR,   "anychar-ml*",     ARG_NON },
+  { OP_ANYCHAR_STAR_PEEK_NEXT, "anychar*-peek-next", ARG_SPECIAL },
+  { OP_ANYCHAR_ML_STAR_PEEK_NEXT, "anychar-ml*-peek-next", ARG_SPECIAL },
+  { OP_WORD,                "word",            ARG_NON },
+  { OP_NOT_WORD,            "not-word",        ARG_NON },
+  { OP_WORD_BOUND,          "word-bound",      ARG_NON },
+  { OP_NOT_WORD_BOUND,      "not-word-bound",  ARG_NON },
+  { OP_WORD_BEGIN,          "word-begin",      ARG_NON },
+  { OP_WORD_END,            "word-end",        ARG_NON },
+  { OP_ASCII_WORD,          "ascii-word",           ARG_NON },
+  { OP_NOT_ASCII_WORD,      "not-ascii-word",       ARG_NON },
+  { OP_ASCII_WORD_BOUND,    "ascii-word-bound",     ARG_NON },
+  { OP_NOT_ASCII_WORD_BOUND,"not-ascii-word-bound", ARG_NON },
+  { OP_ASCII_WORD_BEGIN,    "ascii-word-begin",     ARG_NON },
+  { OP_ASCII_WORD_END,      "ascii-word-end",       ARG_NON },
+  { OP_BEGIN_BUF,           "begin-buf",       ARG_NON },
+  { OP_END_BUF,             "end-buf",         ARG_NON },
+  { OP_BEGIN_LINE,          "begin-line",      ARG_NON },
+  { OP_END_LINE,            "end-line",        ARG_NON },
+  { OP_SEMI_END_BUF,        "semi-end-buf",    ARG_NON },
+  { OP_BEGIN_POSITION,      "begin-position",  ARG_NON },
+  { OP_BEGIN_POS_OR_LINE,   "begin-pos-or-line",    ARG_NON },
+  { OP_BACKREF1,            "backref1",             ARG_NON },
+  { OP_BACKREF2,            "backref2",             ARG_NON },
+  { OP_BACKREFN,            "backrefn",             ARG_MEMNUM  },
+  { OP_BACKREFN_IC,         "backrefn-ic",          ARG_SPECIAL },
+  { OP_BACKREF_MULTI,       "backref_multi",        ARG_SPECIAL },
+  { OP_BACKREF_MULTI_IC,    "backref_multi-ic",     ARG_SPECIAL },
+  { OP_BACKREF_WITH_LEVEL,  "backref_at_level",     ARG_SPECIAL },
+  { OP_MEMORY_START_PUSH,   "mem-start-push",       ARG_MEMNUM  },
+  { OP_MEMORY_START,        "mem-start",            ARG_MEMNUM  },
+  { OP_MEMORY_END_PUSH,     "mem-end-push",         ARG_MEMNUM  },
+  { OP_MEMORY_END_PUSH_REC, "mem-end-push-rec",     ARG_MEMNUM  },
+  { OP_MEMORY_END,          "mem-end",              ARG_MEMNUM  },
+  { OP_MEMORY_END_REC,      "mem-end-rec",          ARG_MEMNUM  },
+  { OP_SET_OPTION_PUSH,     "set-option-push",      ARG_OPTION  },
+  { OP_SET_OPTION,          "set-option",           ARG_OPTION  },
+  { OP_KEEP,                "keep",                 ARG_NON },
+  { OP_FAIL,                "fail",                 ARG_NON },
+  { OP_JUMP,                "jump",                 ARG_RELADDR },
+  { OP_PUSH,                "push",                 ARG_RELADDR },
+  { OP_POP,                 "pop",                  ARG_NON },
+  { OP_PUSH_OR_JUMP_EXACT1, "push-or-jump-e1",      ARG_SPECIAL },
+  { OP_PUSH_IF_PEEK_NEXT,   "push-if-peek-next",    ARG_SPECIAL },
+  { OP_REPEAT,              "repeat",               ARG_SPECIAL },
+  { OP_REPEAT_NG,           "repeat-ng",            ARG_SPECIAL },
+  { OP_REPEAT_INC,          "repeat-inc",           ARG_MEMNUM  },
+  { OP_REPEAT_INC_NG,       "repeat-inc-ng",        ARG_MEMNUM  },
+  { OP_REPEAT_INC_SG,       "repeat-inc-sg",        ARG_MEMNUM  },
+  { OP_REPEAT_INC_NG_SG,    "repeat-inc-ng-sg",     ARG_MEMNUM  },
+  { OP_NULL_CHECK_START,    "null-check-start",     ARG_MEMNUM  },
+  { OP_NULL_CHECK_END,      "null-check-end",       ARG_MEMNUM  },
+  { OP_NULL_CHECK_END_MEMST,"null-check-end-memst", ARG_MEMNUM  },
+  { OP_NULL_CHECK_END_MEMST_PUSH,"null-check-end-memst-push", ARG_MEMNUM  },
+  { OP_PUSH_POS,             "push-pos",             ARG_NON },
+  { OP_POP_POS,              "pop-pos",              ARG_NON },
+  { OP_PUSH_POS_NOT,         "push-pos-not",         ARG_RELADDR },
+  { OP_FAIL_POS,             "fail-pos",             ARG_NON },
+  { OP_PUSH_STOP_BT,         "push-stop-bt",         ARG_NON },
+  { OP_POP_STOP_BT,          "pop-stop-bt",          ARG_NON },
+  { OP_LOOK_BEHIND,          "look-behind",          ARG_SPECIAL },
+  { OP_PUSH_LOOK_BEHIND_NOT, "push-look-behind-not", ARG_SPECIAL },
+  { OP_FAIL_LOOK_BEHIND_NOT, "fail-look-behind-not", ARG_NON },
+  { OP_CALL,                 "call",                 ARG_ABSADDR },
+  { OP_RETURN,               "return",               ARG_NON },
+  { OP_CONDITION,            "condition",            ARG_SPECIAL },
+  { OP_STATE_CHECK_PUSH,         "state-check-push",         ARG_SPECIAL },
+  { OP_STATE_CHECK_PUSH_OR_JUMP, "state-check-push-or-jump", ARG_SPECIAL },
+  { OP_STATE_CHECK,              "state-check",              ARG_STATE_CHECK },
+  { OP_STATE_CHECK_ANYCHAR_STAR, "state-check-anychar*",     ARG_STATE_CHECK },
+  { OP_STATE_CHECK_ANYCHAR_ML_STAR,
+    "state-check-anychar-ml*", ARG_STATE_CHECK },
+  { -1, "", ARG_NON }
+};
+
+static const char*
+op2name(int opcode)
+{
+  int i;
+
+  for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
+    if (opcode == OnigOpInfo[i].opcode)
+      return OnigOpInfo[i].name;
+  }
+  return "";
+}
+
+static int
+op2arg_type(int opcode)
+{
+  int i;
+
+  for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
+    if (opcode == OnigOpInfo[i].opcode)
+      return OnigOpInfo[i].arg_type;
+  }
+  return ARG_SPECIAL;
+}
+
+#ifdef ONIG_DEBUG_PARSE_TREE
+static void
+Indent(FILE* f, int indent)
+{
+  int i;
+  for (i = 0; i < indent; i++) putc(' ', f);
+}
+#endif /* ONIG_DEBUG_PARSE_TREE */
+
+static void
+p_string(FILE* f, ptrdiff_t len, UChar* s)
+{
+  fputs(":", f);
+  while (len-- > 0) { fputc(*s++, f); }
+}
+
+static void
+p_len_string(FILE* f, LengthType len, int mb_len, UChar* s)
+{
+  int x = len * mb_len;
+
+  fprintf(f, ":%d:", len);
+  while (x-- > 0) { fputc(*s++, f); }
+}
+
+extern void
+onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
+                              OnigEncoding enc)
+{
+  int i, n, arg_type;
+  RelAddrType addr;
+  LengthType len;
+  MemNumType mem;
+  StateCheckNumType scn;
+  OnigCodePoint code;
+  UChar *q;
+
+  fprintf(f, "[%s", op2name(*bp));
+  arg_type = op2arg_type(*bp);
+  if (arg_type != ARG_SPECIAL) {
+    bp++;
+    switch (arg_type) {
+    case ARG_NON:
+      break;
+    case ARG_RELADDR:
+      GET_RELADDR_INC(addr, bp);
+      fprintf(f, ":(+%d)", addr);
+      break;
+    case ARG_ABSADDR:
+      GET_ABSADDR_INC(addr, bp);
+      fprintf(f, ":(%d)", addr);
+      break;
+    case ARG_LENGTH:
+      GET_LENGTH_INC(len, bp);
+      fprintf(f, ":%d", len);
+      break;
+    case ARG_MEMNUM:
+      mem = *((MemNumType* )bp);
+      bp += SIZE_MEMNUM;
+      fprintf(f, ":%d", mem);
+      break;
+    case ARG_OPTION:
+      {
+	OnigOptionType option = *((OnigOptionType* )bp);
+	bp += SIZE_OPTION;
+	fprintf(f, ":%d", option);
+      }
+      break;
+
+    case ARG_STATE_CHECK:
+      scn = *((StateCheckNumType* )bp);
+      bp += SIZE_STATE_CHECK_NUM;
+      fprintf(f, ":%d", scn);
+      break;
+    }
+  }
+  else {
+    switch (*bp++) {
+    case OP_EXACT1:
+    case OP_ANYCHAR_STAR_PEEK_NEXT:
+    case OP_ANYCHAR_ML_STAR_PEEK_NEXT:
+      p_string(f, 1, bp++); break;
+    case OP_EXACT2:
+      p_string(f, 2, bp); bp += 2; break;
+    case OP_EXACT3:
+      p_string(f, 3, bp); bp += 3; break;
+    case OP_EXACT4:
+      p_string(f, 4, bp); bp += 4; break;
+    case OP_EXACT5:
+      p_string(f, 5, bp); bp += 5; break;
+    case OP_EXACTN:
+      GET_LENGTH_INC(len, bp);
+      p_len_string(f, len, 1, bp);
+      bp += len;
+      break;
+
+    case OP_EXACTMB2N1:
+      p_string(f, 2, bp); bp += 2; break;
+    case OP_EXACTMB2N2:
+      p_string(f, 4, bp); bp += 4; break;
+    case OP_EXACTMB2N3:
+      p_string(f, 6, bp); bp += 6; break;
+    case OP_EXACTMB2N:
+      GET_LENGTH_INC(len, bp);
+      p_len_string(f, len, 2, bp);
+      bp += len * 2;
+      break;
+    case OP_EXACTMB3N:
+      GET_LENGTH_INC(len, bp);
+      p_len_string(f, len, 3, bp);
+      bp += len * 3;
+      break;
+    case OP_EXACTMBN:
+      {
+	int mb_len;
+
+	GET_LENGTH_INC(mb_len, bp);
+	GET_LENGTH_INC(len, bp);
+	fprintf(f, ":%d:%d:", mb_len, len);
+	n = len * mb_len;
+	while (n-- > 0) { fputc(*bp++, f); }
+      }
+      break;
+
+    case OP_EXACT1_IC:
+      len = enclen(enc, bp);
+      p_string(f, len, bp);
+      bp += len;
+      break;
+    case OP_EXACTN_IC:
+      GET_LENGTH_INC(len, bp);
+      p_len_string(f, len, 1, bp);
+      bp += len;
+      break;
+
+    case OP_CCLASS:
+      n = bitset_on_num((BitSetRef )bp);
+      bp += SIZE_BITSET;
+      fprintf(f, ":%d", n);
+      break;
+
+    case OP_CCLASS_NOT:
+      n = bitset_on_num((BitSetRef )bp);
+      bp += SIZE_BITSET;
+      fprintf(f, ":%d", n);
+      break;
+
+    case OP_CCLASS_MB:
+    case OP_CCLASS_MB_NOT:
+      GET_LENGTH_INC(len, bp);
+      q = bp;
+#ifndef PLATFORM_UNALIGNED_WORD_ACCESS
+      ALIGNMENT_RIGHT(q);
+#endif
+      GET_CODE_POINT(code, q);
+      bp += len;
+      fprintf(f, ":%d:%d", (int )code, len);
+      break;
+
+    case OP_CCLASS_MIX:
+    case OP_CCLASS_MIX_NOT:
+      n = bitset_on_num((BitSetRef )bp);
+      bp += SIZE_BITSET;
+      GET_LENGTH_INC(len, bp);
+      q = bp;
+#ifndef PLATFORM_UNALIGNED_WORD_ACCESS
+      ALIGNMENT_RIGHT(q);
+#endif
+      GET_CODE_POINT(code, q);
+      bp += len;
+      fprintf(f, ":%d:%d:%d", n, (int )code, len);
+      break;
+
+    case OP_CCLASS_NODE:
+      {
+        CClassNode *cc;
+
+        GET_POINTER_INC(cc, bp);
+        n = bitset_on_num(cc->bs);
+        fprintf(f, ":%"PRIuPTR":%d", (uintptr_t )cc, n);
+      }
+      break;
+
+    case OP_BACKREFN_IC:
+      mem = *((MemNumType* )bp);
+      bp += SIZE_MEMNUM;
+      fprintf(f, ":%d", mem);
+      break;
+
+    case OP_BACKREF_MULTI_IC:
+    case OP_BACKREF_MULTI:
+      fputs(" ", f);
+      GET_LENGTH_INC(len, bp);
+      for (i = 0; i < len; i++) {
+	GET_MEMNUM_INC(mem, bp);
+	if (i > 0) fputs(", ", f);
+	fprintf(f, "%d", mem);
+      }
+      break;
+
+    case OP_BACKREF_WITH_LEVEL:
+      {
+	OnigOptionType option;
+	LengthType level;
+
+	GET_OPTION_INC(option, bp);
+	fprintf(f, ":%d", option);
+	GET_LENGTH_INC(level, bp);
+	fprintf(f, ":%d", level);
+
+	fputs(" ", f);
+	GET_LENGTH_INC(len, bp);
+	for (i = 0; i < len; i++) {
+	  GET_MEMNUM_INC(mem, bp);
+	  if (i > 0) fputs(", ", f);
+	  fprintf(f, "%d", mem);
+	}
+      }
+      break;
+
+    case OP_REPEAT:
+    case OP_REPEAT_NG:
+      {
+	mem = *((MemNumType* )bp);
+	bp += SIZE_MEMNUM;
+	addr = *((RelAddrType* )bp);
+	bp += SIZE_RELADDR;
+	fprintf(f, ":%d:%d", mem, addr);
+      }
+      break;
+
+    case OP_PUSH_OR_JUMP_EXACT1:
+    case OP_PUSH_IF_PEEK_NEXT:
+      addr = *((RelAddrType* )bp);
+      bp += SIZE_RELADDR;
+      fprintf(f, ":(%d)", addr);
+      p_string(f, 1, bp);
+      bp += 1;
+      break;
+
+    case OP_LOOK_BEHIND:
+      GET_LENGTH_INC(len, bp);
+      fprintf(f, ":%d", len);
+      break;
+
+    case OP_PUSH_LOOK_BEHIND_NOT:
+      GET_RELADDR_INC(addr, bp);
+      GET_LENGTH_INC(len, bp);
+      fprintf(f, ":%d:(%d)", len, addr);
+      break;
+
+    case OP_STATE_CHECK_PUSH:
+    case OP_STATE_CHECK_PUSH_OR_JUMP:
+      scn = *((StateCheckNumType* )bp);
+      bp += SIZE_STATE_CHECK_NUM;
+      addr = *((RelAddrType* )bp);
+      bp += SIZE_RELADDR;
+      fprintf(f, ":%d:(%d)", scn, addr);
+      break;
+
+    case OP_CONDITION:
+      GET_MEMNUM_INC(mem, bp);
+      GET_RELADDR_INC(addr, bp);
+      fprintf(f, ":%d:(%d)", mem, addr);
+      break;
+
+    default:
+      fprintf(stderr, "onig_print_compiled_byte_code: undefined code %d\n",
+	      *--bp);
+    }
+  }
+  fputs("]", f);
+  if (nextp) *nextp = bp;
+}
+
+#ifdef ONIG_DEBUG_COMPILE
+static void
+print_compiled_byte_code_list(FILE* f, regex_t* reg)
+{
+  int ncode;
+  UChar* bp = reg->p;
+  UChar* end = reg->p + reg->used;
+
+  fprintf(f, "code length: %d", reg->used);
+
+  ncode = -1;
+  while (bp < end) {
+    ncode++;
+    if (ncode % 5 == 0)
+      fprintf(f, "\n%ld:", bp - reg->p);
+    else
+      fprintf(f, " %ld:", bp - reg->p);
+    onig_print_compiled_byte_code(f, bp, &bp, reg->enc);
+  }
+
+  fprintf(f, "\n");
+}
+#endif /* ONIG_DEBUG_COMPILE */
+
+#ifdef ONIG_DEBUG_PARSE_TREE
+static void
+print_indent_tree(FILE* f, Node* node, int indent)
+{
+  int i, type, container_p = 0;
+  int add = 3;
+  UChar* p;
+
+  Indent(f, indent);
+  if (IS_NULL(node)) {
+    fprintf(f, "ERROR: null node!!!\n");
+    exit (0);
+  }
+
+  type = NTYPE(node);
+  switch (type) {
+  case NT_LIST:
+  case NT_ALT:
+    if (NTYPE(node) == NT_LIST)
+      fprintf(f, "<list:%"PRIxPTR">\n", (intptr_t )node);
+    else
+      fprintf(f, "<alt:%"PRIxPTR">\n", (intptr_t )node);
+
+    print_indent_tree(f, NCAR(node), indent + add);
+    while (IS_NOT_NULL(node = NCDR(node))) {
+      if (NTYPE(node) != type) {
+	fprintf(f, "ERROR: list/alt right is not a cons. %d\n", NTYPE(node));
+	exit(0);
+      }
+      print_indent_tree(f, NCAR(node), indent + add);
+    }
+    break;
+
+  case NT_STR:
+    fprintf(f, "<string%s:%"PRIxPTR">",
+	    (NSTRING_IS_RAW(node) ? "-raw" : ""), (intptr_t )node);
+    for (p = NSTR(node)->s; p < NSTR(node)->end; p++) {
+      if (*p >= 0x20 && *p < 0x7f)
+	fputc(*p, f);
+      else {
+	fprintf(f, " 0x%02x", *p);
+      }
+    }
+    break;
+
+  case NT_CCLASS:
+    fprintf(f, "<cclass:%"PRIxPTR">", (intptr_t )node);
+    if (IS_NCCLASS_NOT(NCCLASS(node))) fputs(" not", f);
+    if (NCCLASS(node)->mbuf) {
+      BBuf* bbuf = NCCLASS(node)->mbuf;
+      for (i = 0; i < (int )bbuf->used; i++) {
+	if (i > 0) fprintf(f, ",");
+	fprintf(f, "%0x", bbuf->p[i]);
+      }
+    }
+    break;
+
+  case NT_CTYPE:
+    fprintf(f, "<ctype:%"PRIxPTR"> ", (intptr_t )node);
+    switch (NCTYPE(node)->ctype) {
+    case ONIGENC_CTYPE_WORD:
+      if (NCTYPE(node)->not != 0)
+	fputs("not word",       f);
+      else
+	fputs("word",           f);
+      break;
+
+    default:
+      fprintf(f, "ERROR: undefined ctype.\n");
+      exit(0);
+    }
+    break;
+
+  case NT_CANY:
+    fprintf(f, "<anychar:%"PRIxPTR">", (intptr_t )node);
+    break;
+
+  case NT_ANCHOR:
+    fprintf(f, "<anchor:%"PRIxPTR"> ", (intptr_t )node);
+    switch (NANCHOR(node)->type) {
+    case ANCHOR_BEGIN_BUF:      fputs("begin buf",      f); break;
+    case ANCHOR_END_BUF:        fputs("end buf",        f); break;
+    case ANCHOR_BEGIN_LINE:     fputs("begin line",     f); break;
+    case ANCHOR_END_LINE:       fputs("end line",       f); break;
+    case ANCHOR_SEMI_END_BUF:   fputs("semi end buf",   f); break;
+    case ANCHOR_BEGIN_POSITION: fputs("begin position", f); break;
+    case ANCHOR_ANYCHAR_STAR:   fputs("begin position/line", f); break;
+
+    case ANCHOR_WORD_BOUND:      fputs("word bound",     f); break;
+    case ANCHOR_NOT_WORD_BOUND:  fputs("not word bound", f); break;
+#ifdef USE_WORD_BEGIN_END
+    case ANCHOR_WORD_BEGIN:      fputs("word begin", f);     break;
+    case ANCHOR_WORD_END:        fputs("word end", f);       break;
+#endif
+    case ANCHOR_PREC_READ:       fputs("prec read",      f); container_p = TRUE; break;
+    case ANCHOR_PREC_READ_NOT:   fputs("prec read not",  f); container_p = TRUE; break;
+    case ANCHOR_LOOK_BEHIND:     fputs("look_behind",    f); container_p = TRUE; break;
+    case ANCHOR_LOOK_BEHIND_NOT: fputs("look_behind_not",f); container_p = TRUE; break;
+    case ANCHOR_KEEP:            fputs("keep",f);            break;
+
+    default:
+      fprintf(f, "ERROR: undefined anchor type.\n");
+      break;
+    }
+    break;
+
+  case NT_BREF:
+    {
+      int* p;
+      BRefNode* br = NBREF(node);
+      p = BACKREFS_P(br);
+      fprintf(f, "<backref:%"PRIxPTR">", (intptr_t )node);
+      for (i = 0; i < br->back_num; i++) {
+	if (i > 0) fputs(", ", f);
+	fprintf(f, "%d", p[i]);
+      }
+    }
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case NT_CALL:
+    {
+      CallNode* cn = NCALL(node);
+      fprintf(f, "<call:%"PRIxPTR">", (intptr_t )node);
+      p_string(f, cn->name_end - cn->name, cn->name);
+    }
+    break;
+#endif
+
+  case NT_QTFR:
+    fprintf(f, "<quantifier:%"PRIxPTR">{%d,%d}%s\n", (intptr_t )node,
+	    NQTFR(node)->lower, NQTFR(node)->upper,
+	    (NQTFR(node)->greedy ? "" : "?"));
+    print_indent_tree(f, NQTFR(node)->target, indent + add);
+    break;
+
+  case NT_ENCLOSE:
+    fprintf(f, "<enclose:%"PRIxPTR"> ", (intptr_t )node);
+    switch (NENCLOSE(node)->type) {
+    case ENCLOSE_OPTION:
+      fprintf(f, "option:%d", NENCLOSE(node)->option);
+      break;
+    case ENCLOSE_MEMORY:
+      fprintf(f, "memory:%d", NENCLOSE(node)->regnum);
+      break;
+    case ENCLOSE_STOP_BACKTRACK:
+      fprintf(f, "stop-bt");
+      break;
+    case ENCLOSE_CONDITION:
+      fprintf(f, "condition:%d", NENCLOSE(node)->regnum);
+      break;
+
+    default:
+      break;
+    }
+    fprintf(f, "\n");
+    print_indent_tree(f, NENCLOSE(node)->target, indent + add);
+    break;
+
+  default:
+    fprintf(f, "print_indent_tree: undefined node type %d\n", NTYPE(node));
+    break;
+  }
+
+  if (type != NT_LIST && type != NT_ALT && type != NT_QTFR &&
+      type != NT_ENCLOSE)
+    fprintf(f, "\n");
+
+  if (container_p) print_indent_tree(f, NANCHOR(node)->target, indent + add);
+
+  fflush(f);
+}
+
+static void
+print_tree(FILE* f, Node* node)
+{
+  print_indent_tree(f, node, 0);
+}
+#endif /* ONIG_DEBUG_PARSE_TREE */
+#endif /* ONIG_DEBUG */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regenc.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regenc.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regenc.c	(revision 279)
@@ -0,0 +1,932 @@
+/**********************************************************************
+  regenc.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+OnigEncoding OnigEncDefaultCharEncoding = ONIG_ENCODING_INIT_DEFAULT;
+
+extern int
+onigenc_init(void)
+{
+  return 0;
+}
+
+extern OnigEncoding
+onigenc_get_default_encoding(void)
+{
+  return OnigEncDefaultCharEncoding;
+}
+
+extern int
+onigenc_set_default_encoding(OnigEncoding enc)
+{
+  OnigEncDefaultCharEncoding = enc;
+  return 0;
+}
+
+extern UChar*
+onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
+{
+  UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
+  if (p < s) {
+    p += enclen(enc, p);
+  }
+  return p;
+}
+
+extern UChar*
+onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc,
+				   const UChar* start, const UChar* s, const UChar** prev)
+{
+  UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
+
+  if (p < s) {
+    if (prev) *prev = (const UChar* )p;
+    p += enclen(enc, p);
+  }
+  else {
+    if (prev) *prev = (const UChar* )NULL; /* Sorry */
+  }
+  return p;
+}
+
+extern UChar*
+onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
+{
+  if (s <= start)
+    return (UChar* )NULL;
+
+  return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
+}
+
+extern UChar*
+onigenc_step_back(OnigEncoding enc, const UChar* start, const UChar* s, int n)
+{
+  while (ONIG_IS_NOT_NULL(s) && n-- > 0) {
+    if (s <= start)
+      return (UChar* )NULL;
+
+    s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
+  }
+  return (UChar* )s;
+}
+
+extern UChar*
+onigenc_step(OnigEncoding enc, const UChar* p, const UChar* end, int n)
+{
+  UChar* q = (UChar* )p;
+  while (n-- > 0) {
+    q += ONIGENC_MBC_ENC_LEN(enc, q);
+  }
+  return (q <= end ? q : NULL);
+}
+
+extern int
+onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end)
+{
+  int n = 0;
+  UChar* q = (UChar* )p;
+
+  while (q < end) {
+    q += ONIGENC_MBC_ENC_LEN(enc, q);
+    n++;
+  }
+  return n;
+}
+
+extern int
+onigenc_strlen_null(OnigEncoding enc, const UChar* s)
+{
+  int n = 0;
+  UChar* p = (UChar* )s;
+
+  while (1) {
+    if (*p == '\0') {
+      UChar* q;
+      int len = ONIGENC_MBC_MINLEN(enc);
+
+      if (len == 1) return n;
+      q = p + 1;
+      while (len > 1) {
+        if (*q != '\0') break;
+        q++;
+        len--;
+      }
+      if (len == 1) return n;
+    }
+    p += ONIGENC_MBC_ENC_LEN(enc, p);
+    n++;
+  }
+}
+
+extern int
+onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
+{
+  UChar* start = (UChar* )s;
+  UChar* p = (UChar* )s;
+
+  while (1) {
+    if (*p == '\0') {
+      UChar* q;
+      int len = ONIGENC_MBC_MINLEN(enc);
+
+      if (len == 1) return (int )(p - start);
+      q = p + 1;
+      while (len > 1) {
+        if (*q != '\0') break;
+        q++;
+        len--;
+      }
+      if (len == 1) return (int )(p - start);
+    }
+    p += ONIGENC_MBC_ENC_LEN(enc, p);
+  }
+}
+
+const UChar OnigEncAsciiToLowerCaseTable[] = {
+  '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+  '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+  '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+  '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+  '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+  '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+  '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+  '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+  '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+  '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+  '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+  '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
+  '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+  '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+  '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+  '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
+  '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
+  '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
+  '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
+  '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
+  '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
+  '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
+  '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
+  '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+  '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
+  '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
+  '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
+  '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
+  '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+  '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+  '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
+  '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
+};
+
+#ifdef USE_UPPER_CASE_TABLE
+const UChar OnigEncAsciiToUpperCaseTable[256] = {
+  '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+  '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+  '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+  '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+  '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+  '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+  '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+  '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+  '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
+  '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
+  '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
+  '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
+  '\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
+  '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
+  '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
+  '\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
+  '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
+  '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
+  '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
+  '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
+  '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
+  '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
+  '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
+  '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+  '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
+  '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
+  '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
+  '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
+  '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+  '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+  '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
+  '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
+};
+#endif
+
+const unsigned short OnigEncAsciiCtypeTable[256] = {
+  0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
+  0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
+  0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
+  0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
+  0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
+  0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
+  0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
+  0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
+  0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
+  0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
+  0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
+  0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
+  0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
+  0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
+  0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
+  0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+  0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+const UChar OnigEncISO_8859_1_ToLowerCaseTable[256] = {
+  '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+  '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+  '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+  '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+  '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+  '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+  '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+  '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+  '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+  '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+  '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+  '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
+  '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+  '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+  '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+  '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
+  '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
+  '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
+  '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
+  '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
+  '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
+  '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
+  '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
+  '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+  '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+  '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+  '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
+  '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
+  '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+  '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+  '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
+  '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
+};
+
+#ifdef USE_UPPER_CASE_TABLE
+const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = {
+  '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+  '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+  '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+  '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+  '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+  '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+  '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+  '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+  '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
+  '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
+  '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
+  '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
+  '\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
+  '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
+  '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
+  '\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
+  '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
+  '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
+  '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
+  '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
+  '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
+  '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
+  '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
+  '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+  '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
+  '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
+  '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
+  '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
+  '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
+  '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
+  '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\367',
+  '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\377',
+};
+#endif
+
+extern void
+onigenc_set_default_caseconv_table(const UChar* table ARG_UNUSED)
+{
+  /* nothing */
+  /* obsoleted. */
+}
+
+extern UChar*
+onigenc_get_left_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
+{
+  return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
+}
+
+const OnigPairCaseFoldCodes OnigAsciiLowerMap[] = {
+  { 0x41, 0x61 },
+  { 0x42, 0x62 },
+  { 0x43, 0x63 },
+  { 0x44, 0x64 },
+  { 0x45, 0x65 },
+  { 0x46, 0x66 },
+  { 0x47, 0x67 },
+  { 0x48, 0x68 },
+  { 0x49, 0x69 },
+  { 0x4a, 0x6a },
+  { 0x4b, 0x6b },
+  { 0x4c, 0x6c },
+  { 0x4d, 0x6d },
+  { 0x4e, 0x6e },
+  { 0x4f, 0x6f },
+  { 0x50, 0x70 },
+  { 0x51, 0x71 },
+  { 0x52, 0x72 },
+  { 0x53, 0x73 },
+  { 0x54, 0x74 },
+  { 0x55, 0x75 },
+  { 0x56, 0x76 },
+  { 0x57, 0x77 },
+  { 0x58, 0x78 },
+  { 0x59, 0x79 },
+  { 0x5a, 0x7a }
+};
+
+extern int
+onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
+				  OnigApplyAllCaseFoldFunc f, void* arg)
+{
+  OnigCodePoint code;
+  int i, r;
+
+  for (i = 0; i < numberof(OnigAsciiLowerMap); i++) {
+    code = OnigAsciiLowerMap[i].to;
+    r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg);
+    if (r != 0) return r;
+
+    code = OnigAsciiLowerMap[i].from;
+    r = (*f)(OnigAsciiLowerMap[i].to, &code, 1, arg);
+    if (r != 0) return r;
+  }
+
+  return 0;
+}
+
+extern int
+onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag ARG_UNUSED,
+	 const OnigUChar* p, const OnigUChar* end ARG_UNUSED,
+	 OnigCaseFoldCodeItem items[])
+{
+  if (0x41 <= *p && *p <= 0x5a) {
+    items[0].byte_len = 1;
+    items[0].code_len = 1;
+    items[0].code[0] = (OnigCodePoint )(*p + 0x20);
+    return 1;
+  }
+  else if (0x61 <= *p && *p <= 0x7a) {
+    items[0].byte_len = 1;
+    items[0].code_len = 1;
+    items[0].code[0] = (OnigCodePoint )(*p - 0x20);
+    return 1;
+  }
+  else
+    return 0;
+}
+
+static int
+ss_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
+		       OnigApplyAllCaseFoldFunc f, void* arg)
+{
+  OnigCodePoint ss[] = { 0x73, 0x73 };
+
+  return (*f)((OnigCodePoint )0xdf, ss, 2, arg);
+}
+
+extern int
+onigenc_apply_all_case_fold_with_map(int map_size,
+    const OnigPairCaseFoldCodes map[],
+    int ess_tsett_flag, OnigCaseFoldType flag,
+    OnigApplyAllCaseFoldFunc f, void* arg)
+{
+  OnigCodePoint code;
+  int i, r;
+
+  r = onigenc_ascii_apply_all_case_fold(flag, f, arg);
+  if (r != 0) return r;
+
+  for (i = 0; i < map_size; i++) {
+    code = map[i].to;
+    r = (*f)(map[i].from, &code, 1, arg);
+    if (r != 0) return r;
+
+    code = map[i].from;
+    r = (*f)(map[i].to, &code, 1, arg);
+    if (r != 0) return r;
+  }
+
+  if (ess_tsett_flag != 0)
+    return ss_apply_all_case_fold(flag, f, arg);
+
+  return 0;
+}
+
+extern int
+onigenc_get_case_fold_codes_by_str_with_map(int map_size,
+    const OnigPairCaseFoldCodes map[],
+    int ess_tsett_flag, OnigCaseFoldType flag ARG_UNUSED,
+    const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
+{
+  if (0x41 <= *p && *p <= 0x5a) {
+    items[0].byte_len = 1;
+    items[0].code_len = 1;
+    items[0].code[0] = (OnigCodePoint )(*p + 0x20);
+    if (*p == 0x53 && ess_tsett_flag != 0 && end > p + 1
+	&& (*(p+1) == 0x53 || *(p+1) == 0x73)) {
+      /* SS */
+      items[1].byte_len = 2;
+      items[1].code_len = 1;
+      items[1].code[0] = (OnigCodePoint )0xdf;
+      return 2;
+    }
+    else
+      return 1;
+  }
+  else if (0x61 <= *p && *p <= 0x7a) {
+    items[0].byte_len = 1;
+    items[0].code_len = 1;
+    items[0].code[0] = (OnigCodePoint )(*p - 0x20);
+    if (*p == 0x73 && ess_tsett_flag != 0 && end > p + 1
+	&& (*(p+1) == 0x73 || *(p+1) == 0x53)) {
+      /* ss */
+      items[1].byte_len = 2;
+      items[1].code_len = 1;
+      items[1].code[0] = (OnigCodePoint )0xdf;
+      return 2;
+    }
+    else
+      return 1;
+  }
+  else if (*p == 0xdf && ess_tsett_flag != 0) {
+    items[0].byte_len = 1;
+    items[0].code_len = 2;
+    items[0].code[0] = (OnigCodePoint )'s';
+    items[0].code[1] = (OnigCodePoint )'s';
+
+    items[1].byte_len = 1;
+    items[1].code_len = 2;
+    items[1].code[0] = (OnigCodePoint )'S';
+    items[1].code[1] = (OnigCodePoint )'S';
+
+    items[2].byte_len = 1;
+    items[2].code_len = 2;
+    items[2].code[0] = (OnigCodePoint )'s';
+    items[2].code[1] = (OnigCodePoint )'S';
+
+    items[3].byte_len = 1;
+    items[3].code_len = 2;
+    items[3].code[0] = (OnigCodePoint )'S';
+    items[3].code[1] = (OnigCodePoint )'s';
+
+    return 4;
+  }
+  else {
+    int i;
+
+    for (i = 0; i < map_size; i++) {
+      if (*p == map[i].from) {
+	items[0].byte_len = 1;
+	items[0].code_len = 1;
+	items[0].code[0] = map[i].to;
+	return 1;
+      }
+      else if (*p == map[i].to) {
+	items[0].byte_len = 1;
+	items[0].code_len = 1;
+	items[0].code[0] = map[i].from;
+	return 1;
+      }
+    }
+  }
+
+  return 0;
+}
+
+
+extern int
+onigenc_not_support_get_ctype_code_range(OnigCtype ctype ARG_UNUSED,
+	 OnigCodePoint* sb_out ARG_UNUSED,
+	 const OnigCodePoint* ranges[] ARG_UNUSED)
+{
+  return ONIG_NO_SUPPORT_CONFIG;
+}
+
+extern int
+onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end)
+{
+  if (p < end) {
+    if (*p == 0x0a) return 1;
+  }
+  return 0;
+}
+
+/* for single byte encodings */
+extern int
+onigenc_ascii_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, const UChar** p,
+	    const UChar*end ARG_UNUSED, UChar* lower)
+{
+  *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p);
+
+  (*p)++;
+  return 1; /* return byte length of converted char to lower */
+}
+
+#if 0
+extern int
+onigenc_ascii_is_mbc_ambiguous(OnigCaseFoldType flag ARG_UNUSED,
+			       const UChar** pp, const UChar* end ARG_UNUSED)
+{
+  const UChar* p = *pp;
+
+  (*pp)++;
+  return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
+}
+#endif
+
+extern int
+onigenc_single_byte_mbc_enc_len(const UChar* p ARG_UNUSED)
+{
+  return 1;
+}
+
+extern OnigCodePoint
+onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
+{
+  return (OnigCodePoint )(*p);
+}
+
+extern int
+onigenc_single_byte_code_to_mbclen(OnigCodePoint code ARG_UNUSED)
+{
+  return (code < 0x100 ? 1 : ONIGERR_INVALID_CODE_POINT_VALUE);
+}
+
+extern int
+onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf)
+{
+  *buf = (UChar )(code & 0xff);
+  return 1;
+}
+
+extern UChar*
+onigenc_single_byte_left_adjust_char_head(const UChar* start ARG_UNUSED,
+					  const UChar* s)
+{
+  return (UChar* )s;
+}
+
+extern int
+onigenc_always_true_is_allowed_reverse_match(const UChar* s   ARG_UNUSED,
+					     const UChar* end ARG_UNUSED)
+{
+  return TRUE;
+}
+
+extern int
+onigenc_always_false_is_allowed_reverse_match(const UChar* s   ARG_UNUSED,
+					      const UChar* end ARG_UNUSED)
+{
+  return FALSE;
+}
+
+extern int
+onigenc_ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype)
+{
+  if (code < 128)
+    return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
+  else
+    return FALSE;
+}
+
+extern OnigCodePoint
+onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
+{
+  int c, i, len;
+  OnigCodePoint n;
+
+  len = enclen(enc, p);
+  n = (OnigCodePoint )(*p++);
+  if (len == 1) return n;
+
+  for (i = 1; i < len; i++) {
+    if (p >= end) break;
+    c = *p++;
+    n <<= 8;  n += c;
+  }
+  return n;
+}
+
+extern int
+onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag ARG_UNUSED,
+                          const UChar** pp, const UChar* end ARG_UNUSED,
+			  UChar* lower)
+{
+  int len;
+  const UChar *p = *pp;
+
+  if (ONIGENC_IS_MBC_ASCII(p)) {
+    *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
+    (*pp)++;
+    return 1;
+  }
+  else {
+    int i;
+
+    len = enclen(enc, p);
+    for (i = 0; i < len; i++) {
+      *lower++ = *p++;
+    }
+    (*pp) += len;
+    return len; /* return byte length of converted to lower char */
+  }
+}
+
+#if 0
+extern int
+onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag,
+                             const UChar** pp, const UChar* end ARG_UNUSED)
+{
+  const UChar* p = *pp;
+
+  if (ONIGENC_IS_MBC_ASCII(p)) {
+    (*pp)++;
+    return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
+  }
+
+  (*pp) += enclen(enc, p);
+  return FALSE;
+}
+#endif
+
+extern int
+onigenc_mb2_code_to_mbclen(OnigCodePoint code)
+{
+  if ((code & 0xff00) != 0) return 2;
+  else return 1;
+}
+
+extern int
+onigenc_mb4_code_to_mbclen(OnigCodePoint code)
+{
+       if ((code & 0xff000000) != 0) return 4;
+  else if ((code & 0xff0000) != 0) return 3;
+  else if ((code & 0xff00) != 0) return 2;
+  else return 1;
+}
+
+extern int
+onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
+{
+  UChar *p = buf;
+
+  if ((code & 0xff00) != 0) {
+    *p++ = (UChar )((code >>  8) & 0xff);
+  }
+  *p++ = (UChar )(code & 0xff);
+
+#if 1
+  if (enclen(enc, buf) != (p - buf))
+    return ONIGERR_INVALID_CODE_POINT_VALUE;
+#endif
+  return (int )(p - buf);
+}
+
+extern int
+onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
+{
+  UChar *p = buf;
+
+  if ((code & 0xff000000) != 0) {
+    *p++ = (UChar )((code >> 24) & 0xff);
+  }
+  if ((code & 0xff0000) != 0 || p != buf) {
+    *p++ = (UChar )((code >> 16) & 0xff);
+  }
+  if ((code & 0xff00) != 0 || p != buf) {
+    *p++ = (UChar )((code >> 8) & 0xff);
+  }
+  *p++ = (UChar )(code & 0xff);
+
+#if 1
+  if (enclen(enc, buf) != (p - buf))
+    return ONIGERR_INVALID_CODE_POINT_VALUE;
+#endif
+  return (int )(p - buf);
+}
+
+extern int
+onigenc_minimum_property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
+{
+  static const PosixBracketEntryType PBS[] = {
+    POSIX_BRACKET_ENTRY_INIT("Alnum",  ONIGENC_CTYPE_ALNUM),
+    POSIX_BRACKET_ENTRY_INIT("Alpha",  ONIGENC_CTYPE_ALPHA),
+    POSIX_BRACKET_ENTRY_INIT("Blank",  ONIGENC_CTYPE_BLANK),
+    POSIX_BRACKET_ENTRY_INIT("Cntrl",  ONIGENC_CTYPE_CNTRL),
+    POSIX_BRACKET_ENTRY_INIT("Digit",  ONIGENC_CTYPE_DIGIT),
+    POSIX_BRACKET_ENTRY_INIT("Graph",  ONIGENC_CTYPE_GRAPH),
+    POSIX_BRACKET_ENTRY_INIT("Lower",  ONIGENC_CTYPE_LOWER),
+    POSIX_BRACKET_ENTRY_INIT("Print",  ONIGENC_CTYPE_PRINT),
+    POSIX_BRACKET_ENTRY_INIT("Punct",  ONIGENC_CTYPE_PUNCT),
+    POSIX_BRACKET_ENTRY_INIT("Space",  ONIGENC_CTYPE_SPACE),
+    POSIX_BRACKET_ENTRY_INIT("Upper",  ONIGENC_CTYPE_UPPER),
+    POSIX_BRACKET_ENTRY_INIT("XDigit", ONIGENC_CTYPE_XDIGIT),
+    POSIX_BRACKET_ENTRY_INIT("ASCII",  ONIGENC_CTYPE_ASCII),
+    POSIX_BRACKET_ENTRY_INIT("Word",   ONIGENC_CTYPE_WORD),
+  };
+
+  const PosixBracketEntryType *pb;
+  int len;
+
+  len = onigenc_strlen(enc, p, end);
+  for (pb = PBS; pb < PBS + numberof(PBS); pb++) {
+    if (len == pb->len &&
+        onigenc_with_ascii_strnicmp(enc, p, end, pb->name, pb->len) == 0)
+      return pb->ctype;
+  }
+
+  return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
+}
+
+extern int
+onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
+			  unsigned int ctype)
+{
+  if (code < 128)
+    return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
+  else {
+    if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
+      return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
+    }
+  }
+
+  return FALSE;
+}
+
+extern int
+onigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
+			  unsigned int ctype)
+{
+  if (code < 128)
+    return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
+  else {
+    if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
+      return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
+    }
+  }
+
+  return FALSE;
+}
+
+extern int
+onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end,
+                           const UChar* sascii /* ascii */, int n)
+{
+  int x, c;
+
+  while (n-- > 0) {
+    if (p >= end) return (int )(*sascii);
+
+    c = (int )ONIGENC_MBC_TO_CODE(enc, p, end);
+    x = *sascii - c;
+    if (x) return x;
+
+    sascii++;
+    p += enclen(enc, p);
+  }
+  return 0;
+}
+
+extern int
+onigenc_with_ascii_strnicmp(OnigEncoding enc, const UChar* p, const UChar* end,
+                            const UChar* sascii /* ascii */, int n)
+{
+  int x, c;
+
+  while (n-- > 0) {
+    if (p >= end) return (int )(*sascii);
+
+    c = (int )ONIGENC_MBC_TO_CODE(enc, p, end);
+    if (ONIGENC_IS_ASCII_CODE(c))
+      c = ONIGENC_ASCII_CODE_TO_LOWER_CASE(c);
+    x = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*sascii) - c;
+    if (x) return x;
+
+    sascii++;
+    p += enclen(enc, p);
+  }
+  return 0;
+}
+
+/* Property management */
+static int
+resize_property_list(int new_size, const OnigCodePoint*** plist, int* psize)
+{
+  size_t size;
+  const OnigCodePoint **list = *plist;
+
+  size = sizeof(OnigCodePoint*) * new_size;
+  if (IS_NULL(list)) {
+    list = (const OnigCodePoint** )xmalloc(size);
+    if (IS_NULL(list)) return ONIGERR_MEMORY;
+  }
+  else {
+    const OnigCodePoint **tmp;
+    tmp = (const OnigCodePoint** )xrealloc((void* )list, size);
+    if (IS_NULL(tmp)) return ONIGERR_MEMORY;
+    list = tmp;
+  }
+
+  *plist = list;
+  *psize = new_size;
+
+  return 0;
+}
+
+extern int
+onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop,
+     hash_table_type **table, const OnigCodePoint*** plist, int *pnum,
+     int *psize)
+{
+#define PROP_INIT_SIZE     16
+
+  int r;
+
+  if (*psize <= *pnum) {
+    int new_size = (*psize == 0 ? PROP_INIT_SIZE : *psize * 2);
+    r = resize_property_list(new_size, plist, psize);
+    if (r != 0) return r;
+  }
+
+  (*plist)[*pnum] = prop;
+
+  if (ONIG_IS_NULL(*table)) {
+    *table = onig_st_init_strend_table_with_size(PROP_INIT_SIZE);
+    if (ONIG_IS_NULL(*table)) return ONIGERR_MEMORY;
+  }
+
+  *pnum = *pnum + 1;
+  onig_st_insert_strend(*table, name, name + strlen((char* )name),
+			(hash_data_type )(*pnum + ONIGENC_MAX_STD_CTYPE));
+  return 0;
+}
+
+extern int
+onigenc_property_list_init(int (*f)(void))
+{
+  int r;
+
+  THREAD_ATOMIC_START;
+
+  r = f();
+
+  THREAD_ATOMIC_END;
+  return r;
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regenc.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regenc.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regenc.h	(revision 279)
@@ -0,0 +1,205 @@
+#ifndef REGENC_H
+#define REGENC_H
+/**********************************************************************
+  regenc.h -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef PACKAGE
+/* PACKAGE is defined in config.h */
+#include "config.h"
+#endif
+
+#ifdef ONIG_ESCAPE_UCHAR_COLLISION
+#undef ONIG_ESCAPE_UCHAR_COLLISION
+#endif
+
+#include "oniguruma.h"
+
+typedef struct {
+  OnigCodePoint from;
+  OnigCodePoint to;
+} OnigPairCaseFoldCodes;
+
+
+#ifndef NULL
+#define NULL   ((void* )0)
+#endif
+
+#ifndef TRUE
+#define TRUE    1
+#endif
+
+#ifndef FALSE
+#define FALSE   0
+#endif
+
+#ifndef ARG_UNUSED
+#if defined(__GNUC__)
+#  define ARG_UNUSED  __attribute__ ((unused))
+#else
+#  define ARG_UNUSED
+#endif
+#endif
+
+#define ONIG_IS_NULL(p)                    (((void*)(p)) == (void*)0)
+#define ONIG_IS_NOT_NULL(p)                (((void*)(p)) != (void*)0)
+#define ONIG_CHECK_NULL_RETURN(p)          if (ONIG_IS_NULL(p)) return NULL
+#define ONIG_CHECK_NULL_RETURN_VAL(p,val)  if (ONIG_IS_NULL(p)) return (val)
+
+#define enclen(enc,p)      ONIGENC_MBC_ENC_LEN(enc,p)
+
+/* character types bit flag */
+#define BIT_CTYPE_NEWLINE  (1<< ONIGENC_CTYPE_NEWLINE)
+#define BIT_CTYPE_ALPHA    (1<< ONIGENC_CTYPE_ALPHA)
+#define BIT_CTYPE_BLANK    (1<< ONIGENC_CTYPE_BLANK)
+#define BIT_CTYPE_CNTRL    (1<< ONIGENC_CTYPE_CNTRL)
+#define BIT_CTYPE_DIGIT    (1<< ONIGENC_CTYPE_DIGIT)
+#define BIT_CTYPE_GRAPH    (1<< ONIGENC_CTYPE_GRAPH)
+#define BIT_CTYPE_LOWER    (1<< ONIGENC_CTYPE_LOWER)
+#define BIT_CTYPE_PRINT    (1<< ONIGENC_CTYPE_PRINT)
+#define BIT_CTYPE_PUNCT    (1<< ONIGENC_CTYPE_PUNCT)
+#define BIT_CTYPE_SPACE    (1<< ONIGENC_CTYPE_SPACE)
+#define BIT_CTYPE_UPPER    (1<< ONIGENC_CTYPE_UPPER)
+#define BIT_CTYPE_XDIGIT   (1<< ONIGENC_CTYPE_XDIGIT)
+#define BIT_CTYPE_WORD     (1<< ONIGENC_CTYPE_WORD)
+#define BIT_CTYPE_ALNUM    (1<< ONIGENC_CTYPE_ALNUM)
+#define BIT_CTYPE_ASCII    (1<< ONIGENC_CTYPE_ASCII)
+
+#define CTYPE_TO_BIT(ctype)  (1<<(ctype))
+#define CTYPE_IS_WORD_GRAPH_PRINT(ctype) \
+  ((ctype) == ONIGENC_CTYPE_WORD || (ctype) == ONIGENC_CTYPE_GRAPH ||\
+   (ctype) == ONIGENC_CTYPE_PRINT)
+
+
+typedef struct {
+  const UChar *name;
+  int       ctype;
+  short int len;
+} PosixBracketEntryType;
+
+#define POSIX_BRACKET_ENTRY_INIT(name, ctype) \
+  {(const UChar* )(name), (ctype), (short int )(sizeof(name) - 1)}
+
+#ifndef numberof
+#define numberof(array) (int )(sizeof(array) / sizeof((array)[0]))
+#endif
+
+
+#define USE_CRNL_AS_LINE_TERMINATOR
+#define USE_UNICODE_PROPERTIES
+#define USE_UNICODE_AGE_PROPERTIES
+/* #define USE_UNICODE_CASE_FOLD_TURKISH_AZERI */
+/* #define USE_UNICODE_ALL_LINE_TERMINATORS */  /* see Unicode.org UTS #18 */
+
+
+#define ONIG_ENCODING_INIT_DEFAULT           ONIG_ENCODING_UTF8
+
+/* for encoding system implementation (internal) */
+ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
+ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
+ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
+ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
+ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[]));
+ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end));
+
+
+/* methods for single byte encoding */
+ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));
+ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p));
+ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end));
+ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code));
+ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf));
+ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s));
+ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end));
+ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end));
+ONIG_EXTERN int onigenc_ascii_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));
+
+/* methods for multi byte encoding */
+ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));
+ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));
+ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code));
+ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
+ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
+ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
+ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
+ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code));
+ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
+ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
+
+
+/* in enc/unicode.c */
+ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));
+ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[]));
+ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));
+ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
+ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));
+ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
+
+
+#define UTF16_IS_SURROGATE_FIRST(c)    (((c) & 0xfc) == 0xd8)
+#define UTF16_IS_SURROGATE_SECOND(c)   (((c) & 0xfc) == 0xdc)
+
+#define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
+  OnigEncISO_8859_1_ToLowerCaseTable[c]
+#define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
+  OnigEncISO_8859_1_ToUpperCaseTable[c]
+
+ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];
+ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];
+
+ONIG_EXTERN int
+onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
+ONIG_EXTERN int
+onigenc_with_ascii_strnicmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
+ONIG_EXTERN UChar*
+onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));
+
+/* defined in regexec.c, but used in enc/xxx.c */
+extern int  onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));
+
+ONIG_EXTERN OnigEncoding  OnigEncDefaultCharEncoding;
+ONIG_EXTERN const UChar  OnigEncAsciiToLowerCaseTable[];
+ONIG_EXTERN const UChar  OnigEncAsciiToUpperCaseTable[];
+ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
+
+#define ONIGENC_IS_ASCII_CODE(code)  ((code) < 0x80)
+#define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]
+#define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]
+#define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \
+  ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
+#define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \
+ (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\
+  ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))
+
+/* Check if the code is in the range. (from <= code && code <= to) */
+#define ONIGENC_IS_IN_RANGE(code, from, to) \
+  ((OnigCodePoint )((code) - (from)) <= (OnigCodePoint )((to) - (from)))
+
+
+#endif /* REGENC_H */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regerror.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regerror.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regerror.c	(revision 279)
@@ -0,0 +1,400 @@
+/**********************************************************************
+  regerror.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+#include <stdio.h> /* for vsnprintf() */
+
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
+
+extern UChar*
+onig_error_code_to_format(OnigPosition code)
+{
+  const char *p;
+
+  if (code >= 0) return (UChar* )0;
+
+  switch (code) {
+  case ONIG_MISMATCH:
+    p = "mismatch"; break;
+  case ONIG_NO_SUPPORT_CONFIG:
+    p = "no support in this configuration"; break;
+  case ONIGERR_MEMORY:
+    p = "failed to allocate memory"; break;
+  case ONIGERR_TYPE_BUG:
+    p = "undefined type (bug)"; break;
+  case ONIGERR_PARSER_BUG:
+    p = "internal parser error (bug)"; break;
+  case ONIGERR_STACK_BUG:
+    p = "stack error (bug)"; break;
+  case ONIGERR_UNDEFINED_BYTECODE:
+    p = "undefined bytecode (bug)"; break;
+  case ONIGERR_UNEXPECTED_BYTECODE:
+    p = "unexpected bytecode (bug)"; break;
+  case ONIGERR_MATCH_STACK_LIMIT_OVER:
+    p = "match-stack limit over"; break;
+  case ONIGERR_DEFAULT_ENCODING_IS_NOT_SET:
+    p = "default multibyte-encoding is not set"; break;
+  case ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR:
+    p = "can't convert to wide-char on specified multibyte-encoding"; break;
+  case ONIGERR_INVALID_ARGUMENT:
+    p = "invalid argument"; break;
+  case ONIGERR_END_PATTERN_AT_LEFT_BRACE:
+    p = "end pattern at left brace"; break;
+  case ONIGERR_END_PATTERN_AT_LEFT_BRACKET:
+    p = "end pattern at left bracket"; break;
+  case ONIGERR_EMPTY_CHAR_CLASS:
+    p = "empty char-class"; break;
+  case ONIGERR_PREMATURE_END_OF_CHAR_CLASS:
+    p = "premature end of char-class"; break;
+  case ONIGERR_END_PATTERN_AT_ESCAPE:
+    p = "end pattern at escape"; break;
+  case ONIGERR_END_PATTERN_AT_META:
+    p = "end pattern at meta"; break;
+  case ONIGERR_END_PATTERN_AT_CONTROL:
+    p = "end pattern at control"; break;
+  case ONIGERR_META_CODE_SYNTAX:
+    p = "invalid meta-code syntax"; break;
+  case ONIGERR_CONTROL_CODE_SYNTAX:
+    p = "invalid control-code syntax"; break;
+  case ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE:
+    p = "char-class value at end of range"; break;
+  case ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE:
+    p = "char-class value at start of range"; break;
+  case ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS:
+    p = "unmatched range specifier in char-class"; break;
+  case ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED:
+    p = "target of repeat operator is not specified"; break;
+  case ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID:
+    p = "target of repeat operator is invalid"; break;
+  case ONIGERR_NESTED_REPEAT_OPERATOR:
+    p = "nested repeat operator"; break;
+  case ONIGERR_UNMATCHED_CLOSE_PARENTHESIS:
+    p = "unmatched close parenthesis"; break;
+  case ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS:
+    p = "end pattern with unmatched parenthesis"; break;
+  case ONIGERR_END_PATTERN_IN_GROUP:
+    p = "end pattern in group"; break;
+  case ONIGERR_UNDEFINED_GROUP_OPTION:
+    p = "undefined group option"; break;
+  case ONIGERR_INVALID_POSIX_BRACKET_TYPE:
+    p = "invalid POSIX bracket type"; break;
+  case ONIGERR_INVALID_LOOK_BEHIND_PATTERN:
+    p = "invalid pattern in look-behind"; break;
+  case ONIGERR_INVALID_REPEAT_RANGE_PATTERN:
+    p = "invalid repeat range {lower,upper}"; break;
+  case ONIGERR_INVALID_CONDITION_PATTERN:
+    p = "invalid conditional pattern"; break;
+  case ONIGERR_TOO_BIG_NUMBER:
+    p = "too big number"; break;
+  case ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE:
+    p = "too big number for repeat range"; break;
+  case ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE:
+    p = "upper is smaller than lower in repeat range"; break;
+  case ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS:
+    p = "empty range in char class"; break;
+  case ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE:
+    p = "mismatch multibyte code length in char-class range"; break;
+  case ONIGERR_TOO_MANY_MULTI_BYTE_RANGES:
+    p = "too many multibyte code ranges are specified"; break;
+  case ONIGERR_TOO_SHORT_MULTI_BYTE_STRING:
+    p = "too short multibyte code string"; break;
+  case ONIGERR_TOO_BIG_BACKREF_NUMBER:
+    p = "too big backref number"; break;
+  case ONIGERR_INVALID_BACKREF:
+#ifdef USE_NAMED_GROUP
+    p = "invalid backref number/name"; break;
+#else
+    p = "invalid backref number"; break;
+#endif
+  case ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED:
+    p = "numbered backref/call is not allowed. (use name)"; break;
+  case ONIGERR_TOO_SHORT_DIGITS:
+    p = "too short digits"; break;
+  case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE:
+    p = "too long wide-char value"; break;
+  case ONIGERR_EMPTY_GROUP_NAME:
+    p = "group name is empty"; break;
+  case ONIGERR_INVALID_GROUP_NAME:
+    p = "invalid group name <%n>"; break;
+  case ONIGERR_INVALID_CHAR_IN_GROUP_NAME:
+#ifdef USE_NAMED_GROUP
+    p = "invalid char in group name <%n>"; break;
+#else
+    p = "invalid char in group number <%n>"; break;
+#endif
+  case ONIGERR_UNDEFINED_NAME_REFERENCE:
+    p = "undefined name <%n> reference"; break;
+  case ONIGERR_UNDEFINED_GROUP_REFERENCE:
+    p = "undefined group <%n> reference"; break;
+  case ONIGERR_MULTIPLEX_DEFINED_NAME:
+    p = "multiplex defined name <%n>"; break;
+  case ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL:
+    p = "multiplex definition name <%n> call"; break;
+  case ONIGERR_NEVER_ENDING_RECURSION:
+    p = "never ending recursion"; break;
+  case ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY:
+    p = "group number is too big for capture history"; break;
+  case ONIGERR_INVALID_CHAR_PROPERTY_NAME:
+    p = "invalid character property name {%n}"; break;
+  case ONIGERR_TOO_MANY_CAPTURE_GROUPS:
+    p = "too many capture groups are specified"; break;
+  case ONIGERR_INVALID_CODE_POINT_VALUE:
+    p = "invalid code point value"; break;
+  case ONIGERR_TOO_BIG_WIDE_CHAR_VALUE:
+    p = "too big wide-char value"; break;
+  case ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION:
+    p = "not supported encoding combination"; break;
+  case ONIGERR_INVALID_COMBINATION_OF_OPTIONS:
+    p = "invalid combination of options"; break;
+  case ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT:
+    p = "over thread pass limit count"; break;
+
+  default:
+    p = "undefined error code"; break;
+  }
+
+  return (UChar* )p;
+}
+
+static void sprint_byte(char* s, unsigned int v)
+{
+  sprintf(s, "%02x", (v & 0377));
+}
+
+static void sprint_byte_with_x(char* s, unsigned int v)
+{
+  sprintf(s, "\\x%02x", (v & 0377));
+}
+
+static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
+		    UChar buf[], int buf_size, int *is_over)
+{
+  int len;
+  UChar *p;
+  OnigCodePoint code;
+
+  if (ONIGENC_MBC_MINLEN(enc) > 1) {
+    p = s;
+    len = 0;
+    while (p < end) {
+      code = ONIGENC_MBC_TO_CODE(enc, p, end);
+      if (code >= 0x80) {
+	if (code > 0xffff && len + 10 <= buf_size) {
+	  sprint_byte_with_x((char*)(&(buf[len])), (unsigned int)(code >> 24));
+	  sprint_byte((char*)(&(buf[len+4])),      (unsigned int)(code >> 16));
+	  sprint_byte((char*)(&(buf[len+6])),      (unsigned int)(code >>  8));
+	  sprint_byte((char*)(&(buf[len+8])),      (unsigned int)code);
+	  len += 10;
+	}
+	else if (len + 6 <= buf_size) {
+	  sprint_byte_with_x((char*)(&(buf[len])), (unsigned int)(code >> 8));
+	  sprint_byte((char*)(&(buf[len+4])),      (unsigned int)code);
+	  len += 6;
+	}
+	else {
+	  break;
+	}
+      }
+      else {
+	buf[len++] = (UChar )code;
+      }
+
+      p += enclen(enc, p);
+      if (len >= buf_size) break;
+    }
+
+    *is_over = ((p < end) ? 1 : 0);
+  }
+  else {
+    len = (int )MIN((end - s), buf_size);
+    xmemcpy(buf, s, (size_t )len);
+    *is_over = ((buf_size < (end - s)) ? 1 : 0);
+  }
+
+  return len;
+}
+
+
+/* for ONIG_MAX_ERROR_MESSAGE_LEN */
+#define MAX_ERROR_PAR_LEN   30
+
+extern int
+#ifdef HAVE_STDARG_PROTOTYPES
+onig_error_code_to_str(UChar* s, OnigPosition code, ...)
+#else
+onig_error_code_to_str(s, code, va_alist)
+  UChar* s;
+  OnigPosition code;
+  va_dcl
+#endif
+{
+  UChar *p, *q;
+  OnigErrorInfo* einfo;
+  size_t len;
+  int is_over;
+  UChar parbuf[MAX_ERROR_PAR_LEN];
+  va_list vargs;
+
+  va_init_list(vargs, code);
+
+  switch (code) {
+  case ONIGERR_UNDEFINED_NAME_REFERENCE:
+  case ONIGERR_UNDEFINED_GROUP_REFERENCE:
+  case ONIGERR_MULTIPLEX_DEFINED_NAME:
+  case ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL:
+  case ONIGERR_INVALID_GROUP_NAME:
+  case ONIGERR_INVALID_CHAR_IN_GROUP_NAME:
+  case ONIGERR_INVALID_CHAR_PROPERTY_NAME:
+    einfo = va_arg(vargs, OnigErrorInfo*);
+    len = to_ascii(einfo->enc, einfo->par, einfo->par_end,
+		   parbuf, MAX_ERROR_PAR_LEN - 3, &is_over);
+    q = onig_error_code_to_format(code);
+    p = s;
+    while (*q != '\0') {
+      if (*q == '%') {
+	q++;
+	if (*q == 'n') { /* '%n': name */
+	  xmemcpy(p, parbuf, len);
+	  p += len;
+	  if (is_over != 0) {
+	    xmemcpy(p, "...", 3);
+	    p += 3;
+	  }
+	  q++;
+	}
+	else
+	  goto normal_char;
+      }
+      else {
+      normal_char:
+	*p++ = *q++;
+      }
+    }
+    *p = '\0';
+    len = p - s;
+    break;
+
+  default:
+    q = onig_error_code_to_format(code);
+    if (q) {
+      len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, q);
+      xmemcpy(s, q, len);
+    } else {
+      len = 0;
+    }
+    s[len] = '\0';
+    break;
+  }
+
+  va_end(vargs);
+  return (int )len;
+}
+
+
+void
+#ifdef HAVE_STDARG_PROTOTYPES
+onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,
+                           UChar* pat, UChar* pat_end, const UChar *fmt, ...)
+#else
+onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
+    UChar buf[];
+    int bufsize;
+    OnigEncoding enc;
+    UChar* pat;
+    UChar* pat_end;
+    const UChar *fmt;
+    va_dcl
+#endif
+{
+  size_t need;
+  int n, len;
+  UChar *p, *s, *bp;
+  UChar bs[6];
+  va_list args;
+
+  va_init_list(args, fmt);
+  n = xvsnprintf((char* )buf, bufsize, (const char* )fmt, args);
+  va_end(args);
+
+  need = (pat_end - pat) * 4 + 4;
+
+  if (n + need < (size_t )bufsize) {
+    strcat((char* )buf, ": /");
+    s = buf + onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, buf);
+
+    p = pat;
+    while (p < pat_end) {
+      if (*p == '\\') {
+	*s++ = *p++;
+	len = enclen(enc, p);
+	while (len-- > 0) *s++ = *p++;
+      }
+      else if (*p == '/') {
+	*s++ = (unsigned char )'\\';
+	*s++ = *p++;
+      }
+      else if (ONIGENC_IS_MBC_HEAD(enc, p)) {
+        len = enclen(enc, p);
+        if (ONIGENC_MBC_MINLEN(enc) == 1) {
+          while (len-- > 0) *s++ = *p++;
+        }
+        else { /* for UTF16 */
+          int blen;
+
+          while (len-- > 0) {
+            sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
+            blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
+            bp = bs;
+            while (blen-- > 0) *s++ = *bp++;
+          }
+        }
+      }
+      else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
+	       !ONIGENC_IS_CODE_SPACE(enc, *p)) {
+	sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
+	len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
+        bp = bs;
+	while (len-- > 0) *s++ = *bp++;
+      }
+      else {
+	*s++ = *p++;
+      }
+    }
+
+    *s++ = '/';
+    *s   = '\0';
+  }
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regexec.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regexec.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regexec.c	(revision 279)
@@ -0,0 +1,4524 @@
+/**********************************************************************
+  regexec.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+#define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+
+#ifndef USE_DIRECT_THREADED_VM
+# ifdef __GNUC__
+#   define USE_DIRECT_THREADED_VM 1
+# else
+#   define USE_DIRECT_THREADED_VM 0
+# endif
+#endif
+
+#ifdef USE_CRNL_AS_LINE_TERMINATOR
+#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
+  (ONIGENC_MBC_TO_CODE(enc,p,end) == 13 && \
+   ONIGENC_MBC_TO_CODE(enc,(p+enclen(enc,p)),end) == 10)
+#define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \
+  is_mbc_newline_ex((enc),(p),(start),(end),(option),(check_prev))
+static int
+is_mbc_newline_ex(OnigEncoding enc, const UChar *p, const UChar *start,
+		  const UChar *end, OnigOptionType option, int check_prev)
+{
+  if (IS_NEWLINE_CRLF(option)) {
+    if (ONIGENC_MBC_TO_CODE(enc, p, end) == 0x0a) {
+      if (check_prev) {
+	const UChar *prev = onigenc_get_prev_char_head(enc, start, p);
+	if ((prev != NULL) && ONIGENC_MBC_TO_CODE(enc, prev, end) == 0x0d)
+	  return 0;
+	else
+	  return 1;
+      }
+      else
+	return 1;
+    }
+    else {
+      const UChar *pnext = p + enclen(enc, p);
+      if (pnext < end &&
+	  ONIGENC_MBC_TO_CODE(enc, p, end) == 0x0d &&
+	  ONIGENC_MBC_TO_CODE(enc, pnext, end) == 0x0a)
+	return 1;
+      if (ONIGENC_IS_MBC_NEWLINE(enc, p, end))
+	return 1;
+      return 0;
+    }
+  }
+  else {
+    return ONIGENC_IS_MBC_NEWLINE(enc, p, end);
+  }
+}
+#else /* USE_CRNL_AS_LINE_TERMINATOR */
+#define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \
+  ONIGENC_IS_MBC_NEWLINE((enc), (p), (end))
+#endif /* USE_CRNL_AS_LINE_TERMINATOR */
+
+#ifdef USE_CAPTURE_HISTORY
+static void history_tree_free(OnigCaptureTreeNode* node);
+
+static void
+history_tree_clear(OnigCaptureTreeNode* node)
+{
+  int i;
+
+  if (IS_NOT_NULL(node)) {
+    for (i = 0; i < node->num_childs; i++) {
+      if (IS_NOT_NULL(node->childs[i])) {
+        history_tree_free(node->childs[i]);
+      }
+    }
+    for (i = 0; i < node->allocated; i++) {
+      node->childs[i] = (OnigCaptureTreeNode* )0;
+    }
+    node->num_childs = 0;
+    node->beg = ONIG_REGION_NOTPOS;
+    node->end = ONIG_REGION_NOTPOS;
+    node->group = -1;
+    xfree(node->childs);
+    node->childs = (OnigCaptureTreeNode** )0;
+  }
+}
+
+static void
+history_tree_free(OnigCaptureTreeNode* node)
+{
+  history_tree_clear(node);
+  xfree(node);
+}
+
+static void
+history_root_free(OnigRegion* r)
+{
+  if (IS_NOT_NULL(r->history_root)) {
+    history_tree_free(r->history_root);
+    r->history_root = (OnigCaptureTreeNode* )0;
+  }
+}
+
+static OnigCaptureTreeNode*
+history_node_new(void)
+{
+  OnigCaptureTreeNode* node;
+
+  node = (OnigCaptureTreeNode* )xmalloc(sizeof(OnigCaptureTreeNode));
+  CHECK_NULL_RETURN(node);
+  node->childs     = (OnigCaptureTreeNode** )0;
+  node->allocated  = 0;
+  node->num_childs = 0;
+  node->group      = -1;
+  node->beg        = ONIG_REGION_NOTPOS;
+  node->end        = ONIG_REGION_NOTPOS;
+
+  return node;
+}
+
+static int
+history_tree_add_child(OnigCaptureTreeNode* parent, OnigCaptureTreeNode* child)
+{
+#define HISTORY_TREE_INIT_ALLOC_SIZE  8
+
+  if (parent->num_childs >= parent->allocated) {
+    int n, i;
+
+    if (IS_NULL(parent->childs)) {
+      n = HISTORY_TREE_INIT_ALLOC_SIZE;
+      parent->childs =
+        (OnigCaptureTreeNode** )xmalloc(sizeof(OnigCaptureTreeNode*) * n);
+      CHECK_NULL_RETURN_MEMERR(parent->childs);
+    }
+    else {
+      OnigCaptureTreeNode** tmp;
+      n = parent->allocated * 2;
+      tmp =
+        (OnigCaptureTreeNode** )xrealloc(parent->childs,
+                                         sizeof(OnigCaptureTreeNode*) * n);
+      if (tmp == 0) {
+	history_tree_clear(parent);
+	return ONIGERR_MEMORY;
+      }
+      parent->childs = tmp;
+    }
+    for (i = parent->allocated; i < n; i++) {
+      parent->childs[i] = (OnigCaptureTreeNode* )0;
+    }
+    parent->allocated = n;
+  }
+
+  parent->childs[parent->num_childs] = child;
+  parent->num_childs++;
+  return 0;
+}
+
+static OnigCaptureTreeNode*
+history_tree_clone(OnigCaptureTreeNode* node)
+{
+  int i, r;
+  OnigCaptureTreeNode *clone, *child;
+
+  clone = history_node_new();
+  CHECK_NULL_RETURN(clone);
+
+  clone->beg = node->beg;
+  clone->end = node->end;
+  for (i = 0; i < node->num_childs; i++) {
+    child = history_tree_clone(node->childs[i]);
+    if (IS_NULL(child)) {
+      history_tree_free(clone);
+      return (OnigCaptureTreeNode* )0;
+    }
+    r = history_tree_add_child(clone, child);
+    if (r != 0) {
+      history_tree_free(child);
+      history_tree_free(clone);
+      return (OnigCaptureTreeNode* )0;
+    }
+  }
+
+  return clone;
+}
+
+extern  OnigCaptureTreeNode*
+onig_get_capture_tree(OnigRegion* region)
+{
+  return region->history_root;
+}
+#endif /* USE_CAPTURE_HISTORY */
+
+extern void
+onig_region_clear(OnigRegion* region)
+{
+  int i;
+
+  for (i = 0; i < region->num_regs; i++) {
+    region->beg[i] = region->end[i] = ONIG_REGION_NOTPOS;
+  }
+#ifdef USE_CAPTURE_HISTORY
+  history_root_free(region);
+#endif
+}
+
+extern int
+onig_region_resize(OnigRegion* region, int n)
+{
+  region->num_regs = n;
+
+  if (n < ONIG_NREGION)
+    n = ONIG_NREGION;
+
+  if (region->allocated == 0) {
+    region->beg = (OnigPosition* )xmalloc(n * sizeof(OnigPosition));
+    if (region->beg == 0)
+      return ONIGERR_MEMORY;
+
+    region->end = (OnigPosition* )xmalloc(n * sizeof(OnigPosition));
+    if (region->end == 0) {
+      xfree(region->beg);
+      return ONIGERR_MEMORY;
+    }
+
+    region->allocated = n;
+  }
+  else if (region->allocated < n) {
+    OnigPosition *tmp;
+
+    region->allocated = 0;
+    tmp = (OnigPosition* )xrealloc(region->beg, n * sizeof(OnigPosition));
+    if (tmp == 0) {
+      xfree(region->beg);
+      xfree(region->end);
+      return ONIGERR_MEMORY;
+    }
+    region->beg = tmp;
+    tmp = (OnigPosition* )xrealloc(region->end, n * sizeof(OnigPosition));
+    if (tmp == 0) {
+      xfree(region->beg);
+      xfree(region->end);
+      return ONIGERR_MEMORY;
+    }
+    region->end = tmp;
+
+    region->allocated = n;
+  }
+
+  return 0;
+}
+
+static int
+onig_region_resize_clear(OnigRegion* region, int n)
+{
+  int r;
+
+  r = onig_region_resize(region, n);
+  if (r != 0) return r;
+  onig_region_clear(region);
+  return 0;
+}
+
+extern int
+onig_region_set(OnigRegion* region, int at, int beg, int end)
+{
+  if (at < 0) return ONIGERR_INVALID_ARGUMENT;
+
+  if (at >= region->allocated) {
+    int r = onig_region_resize(region, at + 1);
+    if (r < 0) return r;
+  }
+
+  region->beg[at] = beg;
+  region->end[at] = end;
+  return 0;
+}
+
+extern void
+onig_region_init(OnigRegion* region)
+{
+  region->num_regs     = 0;
+  region->allocated    = 0;
+  region->beg          = (OnigPosition* )0;
+  region->end          = (OnigPosition* )0;
+  region->history_root = (OnigCaptureTreeNode* )0;
+}
+
+extern OnigRegion*
+onig_region_new(void)
+{
+  OnigRegion* r;
+
+  r = (OnigRegion* )xmalloc(sizeof(OnigRegion));
+  if (r)
+    onig_region_init(r);
+  return r;
+}
+
+extern void
+onig_region_free(OnigRegion* r, int free_self)
+{
+  if (r) {
+    if (r->allocated > 0) {
+      if (r->beg) xfree(r->beg);
+      if (r->end) xfree(r->end);
+      r->allocated = 0;
+    }
+#ifdef USE_CAPTURE_HISTORY
+    history_root_free(r);
+#endif
+    if (free_self) xfree(r);
+  }
+}
+
+extern void
+onig_region_copy(OnigRegion* to, OnigRegion* from)
+{
+#define RREGC_SIZE   (sizeof(int) * from->num_regs)
+  int i, r;
+
+  if (to == from) return;
+
+  r = onig_region_resize(to, from->num_regs);
+  if (r) return;
+
+  for (i = 0; i < from->num_regs; i++) {
+    to->beg[i] = from->beg[i];
+    to->end[i] = from->end[i];
+  }
+  to->num_regs = from->num_regs;
+
+#ifdef USE_CAPTURE_HISTORY
+  history_root_free(to);
+
+  if (IS_NOT_NULL(from->history_root)) {
+    to->history_root = history_tree_clone(from->history_root);
+  }
+#endif
+}
+
+
+/** stack **/
+#define INVALID_STACK_INDEX   -1
+
+/* stack type */
+/* used by normal-POP */
+#define STK_ALT                    0x0001
+#define STK_LOOK_BEHIND_NOT        0x0002
+#define STK_POS_NOT                0x0003
+/* handled by normal-POP */
+#define STK_MEM_START              0x0100
+#define STK_MEM_END                0x8200
+#define STK_REPEAT_INC             0x0300
+#define STK_STATE_CHECK_MARK       0x1000
+/* avoided by normal-POP */
+#define STK_NULL_CHECK_START       0x3000
+#define STK_NULL_CHECK_END         0x5000  /* for recursive call */
+#define STK_MEM_END_MARK           0x8400
+#define STK_POS                    0x0500  /* used when POP-POS */
+#define STK_STOP_BT                0x0600  /* mark for "(?>...)" */
+#define STK_REPEAT                 0x0700
+#define STK_CALL_FRAME             0x0800
+#define STK_RETURN                 0x0900
+#define STK_VOID                   0x0a00  /* for fill a blank */
+
+/* stack type check mask */
+#define STK_MASK_POP_USED          0x00ff
+#define STK_MASK_TO_VOID_TARGET    0x10ff
+#define STK_MASK_MEM_END_OR_MARK   0x8000  /* MEM_END or MEM_END_MARK */
+
+#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+#define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
+  (msa).stack_p  = (void* )0;\
+  (msa).options  = (arg_option);\
+  (msa).region   = (arg_region);\
+  (msa).start    = (arg_start);\
+  (msa).gpos     = (arg_gpos);\
+  (msa).best_len = ONIG_MISMATCH;\
+} while(0)
+#else
+#define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
+  (msa).stack_p  = (void* )0;\
+  (msa).options  = (arg_option);\
+  (msa).region   = (arg_region);\
+  (msa).start    = (arg_start);\
+  (msa).gpos     = (arg_gpos);\
+} while(0)
+#endif
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+
+#define STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE  16
+
+#define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num) do {	\
+  if ((state_num) > 0 && str_len >= STATE_CHECK_STRING_THRESHOLD_LEN) {\
+    unsigned int size = (unsigned int )(((str_len) + 1) * (state_num) + 7) >> 3;\
+    offset = ((offset) * (state_num)) >> 3;\
+    if (size > 0 && offset < size && size < STATE_CHECK_BUFF_MAX_SIZE) {\
+      if (size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) {\
+        (msa).state_check_buff = (void* )xmalloc(size);\
+        CHECK_NULL_RETURN_MEMERR((msa).state_check_buff);\
+      }\
+      else \
+        (msa).state_check_buff = (void* )xalloca(size);\
+      xmemset(((char* )((msa).state_check_buff)+(offset)), 0, \
+              (size_t )(size - (offset))); \
+      (msa).state_check_buff_size = size;\
+    }\
+    else {\
+      (msa).state_check_buff = (void* )0;\
+      (msa).state_check_buff_size = 0;\
+    }\
+  }\
+  else {\
+    (msa).state_check_buff = (void* )0;\
+    (msa).state_check_buff_size = 0;\
+  }\
+  } while(0)
+
+#define MATCH_ARG_FREE(msa) do {\
+  if ((msa).stack_p) xfree((msa).stack_p);\
+  if ((msa).state_check_buff_size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { \
+    if ((msa).state_check_buff) xfree((msa).state_check_buff);\
+  }\
+} while(0)
+#else /* USE_COMBINATION_EXPLOSION_CHECK */
+#define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num)
+#define MATCH_ARG_FREE(msa)  if ((msa).stack_p) xfree((msa).stack_p)
+#endif /* USE_COMBINATION_EXPLOSION_CHECK */
+
+
+
+#define MAX_PTR_NUM 100
+
+#define STACK_INIT(alloc_addr, heap_addr, ptr_num, stack_num)  do {\
+  if (ptr_num > MAX_PTR_NUM) {\
+    alloc_addr = (char* )xmalloc(sizeof(OnigStackIndex) * (ptr_num));\
+    heap_addr  = alloc_addr;\
+    if (msa->stack_p) {\
+      stk_alloc = (OnigStackType* )(msa->stack_p);\
+      stk_base  = stk_alloc;\
+      stk       = stk_base;\
+      stk_end   = stk_base + msa->stack_n;\
+    } else {\
+      stk_alloc = (OnigStackType* )xmalloc(sizeof(OnigStackType) * (stack_num));\
+      stk_base  = stk_alloc;\
+      stk       = stk_base;\
+      stk_end   = stk_base + (stack_num);\
+    }\
+  } else if (msa->stack_p) {\
+    alloc_addr = (char* )xmalloc(sizeof(OnigStackIndex) * (ptr_num));\
+    heap_addr  = NULL;\
+    stk_alloc  = (OnigStackType* )(msa->stack_p);\
+    stk_base   = stk_alloc;\
+    stk        = stk_base;\
+    stk_end    = stk_base + msa->stack_n;\
+  }\
+  else {\
+    alloc_addr = (char* )xmalloc(sizeof(OnigStackIndex) * (ptr_num)\
+		       + sizeof(OnigStackType) * (stack_num));\
+    heap_addr  = NULL;\
+    stk_alloc  = (OnigStackType* )(alloc_addr + sizeof(OnigStackIndex) * (ptr_num));\
+    stk_base   = stk_alloc;\
+    stk        = stk_base;\
+    stk_end    = stk_base + (stack_num);\
+  }\
+} while(0)
+
+#define STACK_SAVE do{\
+  if (stk_base != stk_alloc) {\
+    msa->stack_p = stk_base;\
+    msa->stack_n = stk_end - stk_base; /* TODO: check overflow */\
+  };\
+} while(0)
+
+static unsigned int MatchStackLimitSize = DEFAULT_MATCH_STACK_LIMIT_SIZE;
+
+extern unsigned int
+onig_get_match_stack_limit_size(void)
+{
+  return MatchStackLimitSize;
+}
+
+extern int
+onig_set_match_stack_limit_size(unsigned int size)
+{
+  MatchStackLimitSize = size;
+  return 0;
+}
+
+static int
+stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end,
+	     OnigStackType** arg_stk, OnigStackType* stk_alloc, OnigMatchArg* msa)
+{
+  size_t n;
+  OnigStackType *x, *stk_base, *stk_end, *stk;
+
+  stk_base = *arg_stk_base;
+  stk_end  = *arg_stk_end;
+  stk      = *arg_stk;
+
+  n = stk_end - stk_base;
+  if (stk_base == stk_alloc && IS_NULL(msa->stack_p)) {
+    x = (OnigStackType* )xmalloc(sizeof(OnigStackType) * n * 2);
+    if (IS_NULL(x)) {
+      STACK_SAVE;
+      return ONIGERR_MEMORY;
+    }
+    xmemcpy(x, stk_base, n * sizeof(OnigStackType));
+    n *= 2;
+  }
+  else {
+    unsigned int limit_size = MatchStackLimitSize;
+    n *= 2;
+    if (limit_size != 0 && n > limit_size) {
+      if ((unsigned int )(stk_end - stk_base) == limit_size)
+        return ONIGERR_MATCH_STACK_LIMIT_OVER;
+      else
+        n = limit_size;
+    }
+    x = (OnigStackType* )xrealloc(stk_base, sizeof(OnigStackType) * n);
+    if (IS_NULL(x)) {
+      STACK_SAVE;
+      return ONIGERR_MEMORY;
+    }
+  }
+  *arg_stk      = x + (stk - stk_base);
+  *arg_stk_base = x;
+  *arg_stk_end  = x + n;
+  return 0;
+}
+
+#define STACK_ENSURE(n)	do {\
+  if (stk_end - stk < (n)) {\
+    int r = stack_double(&stk_base, &stk_end, &stk, stk_alloc, msa);\
+    if (r != 0) {\
+      STACK_SAVE;\
+      if (xmalloc_base) xfree(xmalloc_base);\
+      return r;\
+    }\
+  }\
+} while(0)
+
+#define STACK_AT(index)        (stk_base + (index))
+#define GET_STACK_INDEX(stk)   ((stk) - stk_base)
+
+#define STACK_PUSH_TYPE(stack_type) do {\
+  STACK_ENSURE(1);\
+  stk->type = (stack_type);\
+  STACK_INC;\
+} while(0)
+
+#define IS_TO_VOID_TARGET(stk) (((stk)->type & STK_MASK_TO_VOID_TARGET) != 0)
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+#define STATE_CHECK_POS(s,snum) \
+  (((s) - str) * num_comb_exp_check + ((snum) - 1))
+#define STATE_CHECK_VAL(v,snum) do {\
+  if (state_check_buff != NULL) {\
+    int x = STATE_CHECK_POS(s,snum);\
+    (v) = state_check_buff[x/8] & (1<<(x%8));\
+  }\
+  else (v) = 0;\
+} while(0)
+
+
+#define ELSE_IF_STATE_CHECK_MARK(stk) \
+  else if ((stk)->type == STK_STATE_CHECK_MARK) { \
+    int x = STATE_CHECK_POS(stk->u.state.pstr, stk->u.state.state_check);\
+    state_check_buff[x/8] |= (1<<(x%8));				\
+  }
+
+#define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\
+  STACK_ENSURE(1);\
+  stk->type = (stack_type);\
+  stk->u.state.pcode     = (pat);\
+  stk->u.state.pstr      = (s);\
+  stk->u.state.pstr_prev = (sprev);\
+  stk->u.state.state_check = 0;\
+  stk->u.state.pkeep     = (keep);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_ENSURED(stack_type,pat) do {\
+  stk->type = (stack_type);\
+  stk->u.state.pcode = (pat);\
+  stk->u.state.state_check = 0;\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_ALT_WITH_STATE_CHECK(pat,s,sprev,snum,keep) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_ALT;\
+  stk->u.state.pcode     = (pat);\
+  stk->u.state.pstr      = (s);\
+  stk->u.state.pstr_prev = (sprev);\
+  stk->u.state.state_check = ((state_check_buff != NULL) ? (snum) : 0);\
+  stk->u.state.pkeep     = (keep);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_STATE_CHECK(s,snum) do {\
+  if (state_check_buff != NULL) {\
+    STACK_ENSURE(1);\
+    stk->type = STK_STATE_CHECK_MARK;\
+    stk->u.state.pstr = (s);\
+    stk->u.state.state_check = (snum);\
+    STACK_INC;\
+  }\
+} while(0)
+
+#else /* USE_COMBINATION_EXPLOSION_CHECK */
+
+#define ELSE_IF_STATE_CHECK_MARK(stk)
+
+#define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\
+  STACK_ENSURE(1);\
+  stk->type = (stack_type);\
+  stk->u.state.pcode     = (pat);\
+  stk->u.state.pstr      = (s);\
+  stk->u.state.pstr_prev = (sprev);\
+  stk->u.state.pkeep     = (keep);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_ENSURED(stack_type,pat) do {\
+  stk->type = (stack_type);\
+  stk->u.state.pcode = (pat);\
+  STACK_INC;\
+} while(0)
+#endif /* USE_COMBINATION_EXPLOSION_CHECK */
+
+#define STACK_PUSH_ALT(pat,s,sprev,keep)     STACK_PUSH(STK_ALT,pat,s,sprev,keep)
+#define STACK_PUSH_POS(s,sprev,keep)         STACK_PUSH(STK_POS,NULL_UCHARP,s,sprev,keep)
+#define STACK_PUSH_POS_NOT(pat,s,sprev,keep) STACK_PUSH(STK_POS_NOT,pat,s,sprev,keep)
+#define STACK_PUSH_STOP_BT              STACK_PUSH_TYPE(STK_STOP_BT)
+#define STACK_PUSH_LOOK_BEHIND_NOT(pat,s,sprev,keep) \
+        STACK_PUSH(STK_LOOK_BEHIND_NOT,pat,s,sprev,keep)
+
+#define STACK_PUSH_REPEAT(id, pat) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_REPEAT;\
+  stk->u.repeat.num    = (id);\
+  stk->u.repeat.pcode  = (pat);\
+  stk->u.repeat.count  = 0;\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_REPEAT_INC(sindex) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_REPEAT_INC;\
+  stk->u.repeat_inc.si  = (sindex);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_MEM_START(mnum, s) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_MEM_START;\
+  stk->u.mem.num      = (mnum);\
+  stk->u.mem.pstr     = (s);\
+  stk->u.mem.start    = mem_start_stk[mnum];\
+  stk->u.mem.end      = mem_end_stk[mnum];\
+  mem_start_stk[mnum] = GET_STACK_INDEX(stk);\
+  mem_end_stk[mnum]   = INVALID_STACK_INDEX;\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_MEM_END(mnum, s) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_MEM_END;\
+  stk->u.mem.num    = (mnum);\
+  stk->u.mem.pstr   = (s);\
+  stk->u.mem.start  = mem_start_stk[mnum];\
+  stk->u.mem.end    = mem_end_stk[mnum];\
+  mem_end_stk[mnum] = GET_STACK_INDEX(stk);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_MEM_END_MARK(mnum) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_MEM_END_MARK;\
+  stk->u.mem.num = (mnum);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_GET_MEM_START(mnum, k) do {\
+  int level = 0;\
+  k = stk;\
+  while (k > stk_base) {\
+    k--;\
+    if ((k->type & STK_MASK_MEM_END_OR_MARK) != 0 \
+      && k->u.mem.num == (mnum)) {\
+      level++;\
+    }\
+    else if (k->type == STK_MEM_START && k->u.mem.num == (mnum)) {\
+      if (level == 0) break;\
+      level--;\
+    }\
+  }\
+} while(0)
+
+#define STACK_GET_MEM_RANGE(k, mnum, start, end) do {\
+  int level = 0;\
+  while (k < stk) {\
+    if (k->type == STK_MEM_START && k->u.mem.num == (mnum)) {\
+      if (level == 0) (start) = k->u.mem.pstr;\
+      level++;\
+    }\
+    else if (k->type == STK_MEM_END && k->u.mem.num == (mnum)) {\
+      level--;\
+      if (level == 0) {\
+        (end) = k->u.mem.pstr;\
+        break;\
+      }\
+    }\
+    k++;\
+  }\
+} while(0)
+
+#define STACK_PUSH_NULL_CHECK_START(cnum, s) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_NULL_CHECK_START;\
+  stk->u.null_check.num  = (cnum);\
+  stk->u.null_check.pstr = (s);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_NULL_CHECK_END(cnum) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_NULL_CHECK_END;\
+  stk->u.null_check.num  = (cnum);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_CALL_FRAME(pat) do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_CALL_FRAME;\
+  stk->u.call_frame.ret_addr = (pat);\
+  STACK_INC;\
+} while(0)
+
+#define STACK_PUSH_RETURN do {\
+  STACK_ENSURE(1);\
+  stk->type = STK_RETURN;\
+  STACK_INC;\
+} while(0)
+
+
+#ifdef ONIG_DEBUG
+#define STACK_BASE_CHECK(p, at) \
+  if ((p) < stk_base) {\
+    fprintf(stderr, "at %s\n", at);\
+    goto stack_error;\
+  }
+#else
+#define STACK_BASE_CHECK(p, at)
+#endif
+
+#define STACK_POP_ONE do {\
+  stk--;\
+  STACK_BASE_CHECK(stk, "STACK_POP_ONE"); \
+} while(0)
+
+#define STACK_POP  do {\
+  switch (pop_level) {\
+  case STACK_POP_LEVEL_FREE:\
+    while (1) {\
+      stk--;\
+      STACK_BASE_CHECK(stk, "STACK_POP"); \
+      if ((stk->type & STK_MASK_POP_USED) != 0)  break;\
+      ELSE_IF_STATE_CHECK_MARK(stk);\
+    }\
+    break;\
+  case STACK_POP_LEVEL_MEM_START:\
+    while (1) {\
+      stk--;\
+      STACK_BASE_CHECK(stk, "STACK_POP 2"); \
+      if ((stk->type & STK_MASK_POP_USED) != 0)  break;\
+      else if (stk->type == STK_MEM_START) {\
+        mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
+        mem_end_stk[stk->u.mem.num]   = stk->u.mem.end;\
+      }\
+      ELSE_IF_STATE_CHECK_MARK(stk);\
+    }\
+    break;\
+  default:\
+    while (1) {\
+      stk--;\
+      STACK_BASE_CHECK(stk, "STACK_POP 3"); \
+      if ((stk->type & STK_MASK_POP_USED) != 0)  break;\
+      else if (stk->type == STK_MEM_START) {\
+        mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
+        mem_end_stk[stk->u.mem.num]   = stk->u.mem.end;\
+      }\
+      else if (stk->type == STK_REPEAT_INC) {\
+        STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\
+      }\
+      else if (stk->type == STK_MEM_END) {\
+        mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
+        mem_end_stk[stk->u.mem.num]   = stk->u.mem.end;\
+      }\
+      ELSE_IF_STATE_CHECK_MARK(stk);\
+    }\
+    break;\
+  }\
+} while(0)
+
+#define STACK_POP_TIL_POS_NOT  do {\
+  while (1) {\
+    stk--;\
+    STACK_BASE_CHECK(stk, "STACK_POP_TIL_POS_NOT"); \
+    if (stk->type == STK_POS_NOT) break;\
+    else if (stk->type == STK_MEM_START) {\
+      mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
+      mem_end_stk[stk->u.mem.num]   = stk->u.mem.end;\
+    }\
+    else if (stk->type == STK_REPEAT_INC) {\
+      STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\
+    }\
+    else if (stk->type == STK_MEM_END) {\
+      mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
+      mem_end_stk[stk->u.mem.num]   = stk->u.mem.end;\
+    }\
+    ELSE_IF_STATE_CHECK_MARK(stk);\
+  }\
+} while(0)
+
+#define STACK_POP_TIL_LOOK_BEHIND_NOT  do {\
+  while (1) {\
+    stk--;\
+    STACK_BASE_CHECK(stk, "STACK_POP_TIL_LOOK_BEHIND_NOT"); \
+    if (stk->type == STK_LOOK_BEHIND_NOT) break;\
+    else if (stk->type == STK_MEM_START) {\
+      mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
+      mem_end_stk[stk->u.mem.num]   = stk->u.mem.end;\
+    }\
+    else if (stk->type == STK_REPEAT_INC) {\
+      STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\
+    }\
+    else if (stk->type == STK_MEM_END) {\
+      mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
+      mem_end_stk[stk->u.mem.num]   = stk->u.mem.end;\
+    }\
+    ELSE_IF_STATE_CHECK_MARK(stk);\
+  }\
+} while(0)
+
+#define STACK_POS_END(k) do {\
+  k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_POS_END"); \
+    if (IS_TO_VOID_TARGET(k)) {\
+      k->type = STK_VOID;\
+    }\
+    else if (k->type == STK_POS) {\
+      k->type = STK_VOID;\
+      break;\
+    }\
+  }\
+} while(0)
+
+#define STACK_STOP_BT_END do {\
+  OnigStackType *k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_STOP_BT_END"); \
+    if (IS_TO_VOID_TARGET(k)) {\
+      k->type = STK_VOID;\
+    }\
+    else if (k->type == STK_STOP_BT) {\
+      k->type = STK_VOID;\
+      break;\
+    }\
+  }\
+} while(0)
+
+#define STACK_NULL_CHECK(isnull,id,s) do {\
+  OnigStackType* k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_NULL_CHECK"); \
+    if (k->type == STK_NULL_CHECK_START) {\
+      if (k->u.null_check.num == (id)) {\
+        (isnull) = (k->u.null_check.pstr == (s));\
+        break;\
+      }\
+    }\
+  }\
+} while(0)
+
+#define STACK_NULL_CHECK_REC(isnull,id,s) do {\
+  int level = 0;\
+  OnigStackType* k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_NULL_CHECK_REC"); \
+    if (k->type == STK_NULL_CHECK_START) {\
+      if (k->u.null_check.num == (id)) {\
+        if (level == 0) {\
+          (isnull) = (k->u.null_check.pstr == (s));\
+          break;\
+        }\
+        else level--;\
+      }\
+    }\
+    else if (k->type == STK_NULL_CHECK_END) {\
+      level++;\
+    }\
+  }\
+} while(0)
+
+#define STACK_NULL_CHECK_MEMST(isnull,id,s,reg) do {\
+  OnigStackType* k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST"); \
+    if (k->type == STK_NULL_CHECK_START) {\
+      if (k->u.null_check.num == (id)) {\
+        if (k->u.null_check.pstr != (s)) {\
+          (isnull) = 0;\
+          break;\
+        }\
+        else {\
+          UChar* endp;\
+          (isnull) = 1;\
+          while (k < stk) {\
+            if (k->type == STK_MEM_START) {\
+              if (k->u.mem.end == INVALID_STACK_INDEX) {\
+                (isnull) = 0; break;\
+              }\
+              if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\
+                endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\
+              else\
+                endp = (UChar* )k->u.mem.end;\
+              if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\
+                (isnull) = 0; break;\
+              }\
+              else if (endp != s) {\
+                (isnull) = -1; /* empty, but position changed */ \
+              }\
+            }\
+            k++;\
+          }\
+          break;\
+        }\
+      }\
+    }\
+  }\
+} while(0)
+
+#define STACK_NULL_CHECK_MEMST_REC(isnull,id,s,reg) do {\
+  int level = 0;\
+  OnigStackType* k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST_REC"); \
+    if (k->type == STK_NULL_CHECK_START) {\
+      if (k->u.null_check.num == (id)) {\
+        if (level == 0) {\
+          if (k->u.null_check.pstr != (s)) {\
+            (isnull) = 0;\
+            break;\
+          }\
+          else {\
+            UChar* endp;\
+            (isnull) = 1;\
+            while (k < stk) {\
+              if (k->type == STK_MEM_START) {\
+                if (k->u.mem.end == INVALID_STACK_INDEX) {\
+                  (isnull) = 0; break;\
+                }\
+                if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\
+                  endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\
+                else\
+                  endp = (UChar* )k->u.mem.end;\
+                if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\
+                  (isnull) = 0; break;\
+                }\
+                else if (endp != s) {\
+                  (isnull) = -1; /* empty, but position changed */ \
+                }\
+              }\
+              k++;\
+            }\
+            break;\
+          }\
+        }\
+        else {\
+          level--;\
+        }\
+      }\
+    }\
+    else if (k->type == STK_NULL_CHECK_END) {\
+      if (k->u.null_check.num == (id)) level++;\
+    }\
+  }\
+} while(0)
+
+#define STACK_GET_REPEAT(id, k) do {\
+  int level = 0;\
+  k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_GET_REPEAT"); \
+    if (k->type == STK_REPEAT) {\
+      if (level == 0) {\
+        if (k->u.repeat.num == (id)) {\
+          break;\
+        }\
+      }\
+    }\
+    else if (k->type == STK_CALL_FRAME) level--;\
+    else if (k->type == STK_RETURN)     level++;\
+  }\
+} while(0)
+
+#define STACK_RETURN(addr)  do {\
+  int level = 0;\
+  OnigStackType* k = stk;\
+  while (1) {\
+    k--;\
+    STACK_BASE_CHECK(k, "STACK_RETURN"); \
+    if (k->type == STK_CALL_FRAME) {\
+      if (level == 0) {\
+        (addr) = k->u.call_frame.ret_addr;\
+        break;\
+      }\
+      else level--;\
+    }\
+    else if (k->type == STK_RETURN)\
+      level++;\
+  }\
+} while(0)
+
+
+#define STRING_CMP(s1,s2,len) do {\
+  while (len-- > 0) {\
+    if (*s1++ != *s2++) goto fail;\
+  }\
+} while(0)
+
+#define STRING_CMP_IC(case_fold_flag,s1,ps2,len) do {\
+  if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len) == 0) \
+    goto fail; \
+} while(0)
+
+static int string_cmp_ic(OnigEncoding enc, int case_fold_flag,
+			 UChar* s1, UChar** ps2, OnigDistance mblen)
+{
+  UChar buf1[ONIGENC_MBC_CASE_FOLD_MAXLEN];
+  UChar buf2[ONIGENC_MBC_CASE_FOLD_MAXLEN];
+  UChar *p1, *p2, *end1, *s2, *end2;
+  int len1, len2;
+
+  s2   = *ps2;
+  end1 = s1 + mblen;
+  end2 = s2 + mblen;
+  while (s1 < end1) {
+    len1 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s1, end1, buf1);
+    len2 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s2, end2, buf2);
+    if (len1 != len2) return 0;
+    p1 = buf1;
+    p2 = buf2;
+    while (len1-- > 0) {
+      if (*p1 != *p2) return 0;
+      p1++;
+      p2++;
+    }
+  }
+
+  *ps2 = s2;
+  return 1;
+}
+
+#define STRING_CMP_VALUE(s1,s2,len,is_fail) do {\
+  is_fail = 0;\
+  while (len-- > 0) {\
+    if (*s1++ != *s2++) {\
+      is_fail = 1; break;\
+    }\
+  }\
+} while(0)
+
+#define STRING_CMP_VALUE_IC(case_fold_flag,s1,ps2,len,is_fail) do {\
+  if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len) == 0) \
+    is_fail = 1; \
+  else \
+    is_fail = 0; \
+} while(0)
+
+
+#define IS_EMPTY_STR           (str == end)
+#define ON_STR_BEGIN(s)       ((s) == str)
+#define ON_STR_END(s)         ((s) == end)
+#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+#define DATA_ENSURE_CHECK1     (s < right_range)
+#define DATA_ENSURE_CHECK(n)   (s + (n) <= right_range)
+#define DATA_ENSURE(n)         if (s + (n) > right_range) goto fail
+#else
+#define DATA_ENSURE_CHECK1     (s < end)
+#define DATA_ENSURE_CHECK(n)   (s + (n) <= end)
+#define DATA_ENSURE(n)         if (s + (n) > end) goto fail
+#endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
+
+
+#ifdef USE_CAPTURE_HISTORY
+static int
+make_capture_history_tree(OnigCaptureTreeNode* node, OnigStackType** kp,
+                          OnigStackType* stk_top, UChar* str, regex_t* reg)
+{
+  int n, r;
+  OnigCaptureTreeNode* child;
+  OnigStackType* k = *kp;
+
+  while (k < stk_top) {
+    if (k->type == STK_MEM_START) {
+      n = k->u.mem.num;
+      if (n <= ONIG_MAX_CAPTURE_HISTORY_GROUP &&
+          BIT_STATUS_AT(reg->capture_history, n) != 0) {
+        child = history_node_new();
+        CHECK_NULL_RETURN_MEMERR(child);
+        child->group = n;
+        child->beg = k->u.mem.pstr - str;
+        r = history_tree_add_child(node, child);
+        if (r != 0) {
+          history_tree_free(child);
+          return r;
+        }
+        *kp = (k + 1);
+        r = make_capture_history_tree(child, kp, stk_top, str, reg);
+        if (r != 0) return r;
+
+        k = *kp;
+        child->end = k->u.mem.pstr - str;
+      }
+    }
+    else if (k->type == STK_MEM_END) {
+      if (k->u.mem.num == node->group) {
+        node->end = k->u.mem.pstr - str;
+        *kp = k;
+        return 0;
+      }
+    }
+    k++;
+  }
+
+  return 1; /* 1: root node ending. */
+}
+#endif /* USE_CAPTURE_HISTORY */
+
+#ifdef USE_BACKREF_WITH_LEVEL
+static int mem_is_in_memp(int mem, int num, UChar* memp)
+{
+  int i;
+  MemNumType m;
+
+  for (i = 0; i < num; i++) {
+    GET_MEMNUM_INC(m, memp);
+    if (mem == (int )m) return 1;
+  }
+  return 0;
+}
+
+static int backref_match_at_nested_level(regex_t* reg
+	 , OnigStackType* top, OnigStackType* stk_base
+	 , int ignore_case, int case_fold_flag
+	 , int nest, int mem_num, UChar* memp, UChar** s, const UChar* send)
+{
+  UChar *ss, *p, *pstart, *pend = NULL_UCHARP;
+  int level;
+  OnigStackType* k;
+
+  level = 0;
+  k = top;
+  k--;
+  while (k >= stk_base) {
+    if (k->type == STK_CALL_FRAME) {
+      level--;
+    }
+    else if (k->type == STK_RETURN) {
+      level++;
+    }
+    else if (level == nest) {
+      if (k->type == STK_MEM_START) {
+	if (mem_is_in_memp(k->u.mem.num, mem_num, memp)) {
+	  pstart = k->u.mem.pstr;
+	  if (pend != NULL_UCHARP) {
+	    if (pend - pstart > send - *s) return 0; /* or goto next_mem; */
+	    p  = pstart;
+	    ss = *s;
+
+	    if (ignore_case != 0) {
+	      if (string_cmp_ic(reg->enc, case_fold_flag,
+				pstart, &ss, pend - pstart) == 0)
+		return 0; /* or goto next_mem; */
+	    }
+	    else {
+	      while (p < pend) {
+		if (*p++ != *ss++) return 0; /* or goto next_mem; */
+	      }
+	    }
+
+	    *s = ss;
+	    return 1;
+	  }
+	}
+      }
+      else if (k->type == STK_MEM_END) {
+	if (mem_is_in_memp(k->u.mem.num, mem_num, memp)) {
+	  pend = k->u.mem.pstr;
+	}
+      }
+    }
+    k--;
+  }
+
+  return 0;
+}
+#endif /* USE_BACKREF_WITH_LEVEL */
+
+
+#ifdef ONIG_DEBUG_STATISTICS
+
+#define USE_TIMEOFDAY
+
+#ifdef USE_TIMEOFDAY
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+static struct timeval ts, te;
+#define GETTIME(t)        gettimeofday(&(t), (struct timezone* )0)
+#define TIMEDIFF(te,ts)   (((te).tv_usec - (ts).tv_usec) + \
+                           (((te).tv_sec - (ts).tv_sec)*1000000))
+#else /* USE_TIMEOFDAY */
+#ifdef HAVE_SYS_TIMES_H
+#include <sys/times.h>
+#endif
+static struct tms ts, te;
+#define GETTIME(t)         times(&(t))
+#define TIMEDIFF(te,ts)   ((te).tms_utime - (ts).tms_utime)
+#endif /* USE_TIMEOFDAY */
+
+static int OpCounter[256];
+static int OpPrevCounter[256];
+static unsigned long OpTime[256];
+static int OpCurr = OP_FINISH;
+static int OpPrevTarget = OP_FAIL;
+static int MaxStackDepth = 0;
+
+#define MOP_IN(opcode) do {\
+  if (opcode == OpPrevTarget) OpPrevCounter[OpCurr]++;\
+  OpCurr = opcode;\
+  OpCounter[opcode]++;\
+  GETTIME(ts);\
+} while(0)
+
+#define MOP_OUT do {\
+  GETTIME(te);\
+  OpTime[OpCurr] += TIMEDIFF(te, ts);\
+} while(0)
+
+extern void
+onig_statistics_init(void)
+{
+  int i;
+  for (i = 0; i < 256; i++) {
+    OpCounter[i] = OpPrevCounter[i] = 0; OpTime[i] = 0;
+  }
+  MaxStackDepth = 0;
+}
+
+extern void
+onig_print_statistics(FILE* f)
+{
+  int i;
+  fprintf(f, "   count      prev        time\n");
+  for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
+    fprintf(f, "%8d: %8d: %10lu: %s\n",
+	    OpCounter[i], OpPrevCounter[i], OpTime[i], OnigOpInfo[i].name);
+  }
+  fprintf(f, "\nmax stack depth: %d\n", MaxStackDepth);
+}
+
+#define STACK_INC do {\
+  stk++;\
+  if (stk - stk_base > MaxStackDepth) \
+    MaxStackDepth = stk - stk_base;\
+} while(0)
+
+#else /* ONIG_DEBUG_STATISTICS */
+#define STACK_INC     stk++
+
+#define MOP_IN(opcode)
+#define MOP_OUT
+#endif /* ONIG_DEBUG_STATISTICS */
+
+
+
+/* matching region of POSIX API */
+typedef int regoff_t;
+
+typedef struct {
+  regoff_t  rm_so;
+  regoff_t  rm_eo;
+} posix_regmatch_t;
+
+/* match data(str - end) from position (sstart). */
+/* if sstart == str then set sprev to NULL. */
+static OnigPosition
+match_at_(regex_t* reg, const UChar* str, const UChar* end,
+#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+	 const UChar* right_range,
+#endif
+	 const UChar* sstart, UChar* sprev, OnigMatchArg* msa, char **palloca_base)
+{
+  static const UChar FinishCode[] = { OP_FINISH };
+
+  int i, num_mem, pop_level;
+  ptrdiff_t n, best_len;
+  LengthType tlen, tlen2;
+  MemNumType mem;
+  RelAddrType addr;
+  OnigOptionType option = reg->options;
+  OnigEncoding encode = reg->enc;
+  OnigCaseFoldType case_fold_flag = reg->case_fold_flag;
+  UChar *s, *q, *sbegin;
+  UChar *p = reg->p;
+  UChar *pkeep;
+  char *xmalloc_base = NULL;
+  OnigStackType *stk_alloc, *stk_base, *stk, *stk_end;
+  OnigStackType *stkp; /* used as any purpose. */
+  OnigStackIndex si;
+  OnigStackIndex *repeat_stk;
+  OnigStackIndex *mem_start_stk, *mem_end_stk;
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  int scv;
+  unsigned char* state_check_buff = msa->state_check_buff;
+  int num_comb_exp_check = reg->num_comb_exp_check;
+#endif
+
+#if USE_DIRECT_THREADED_VM
+#define VM_LOOP JUMP;
+#define VM_LOOP_END
+#define CASE(x) L_##x: sbegin = s; OPCODE_EXEC_HOOK;
+#define DEFAULT L_DEFAULT:
+#define NEXT sprev = sbegin; JUMP
+#define JUMP goto *oplabels[*p++]
+
+  static const void *oplabels[] = {
+    &&L_OP_FINISH,               /* matching process terminator (no more alternative) */
+    &&L_OP_END,                  /* pattern code terminator (success end) */
+
+    &&L_OP_EXACT1,               /* single byte, N = 1 */
+    &&L_OP_EXACT2,               /* single byte, N = 2 */
+    &&L_OP_EXACT3,               /* single byte, N = 3 */
+    &&L_OP_EXACT4,               /* single byte, N = 4 */
+    &&L_OP_EXACT5,               /* single byte, N = 5 */
+    &&L_OP_EXACTN,               /* single byte */
+    &&L_OP_EXACTMB2N1,           /* mb-length = 2 N = 1 */
+    &&L_OP_EXACTMB2N2,           /* mb-length = 2 N = 2 */
+    &&L_OP_EXACTMB2N3,           /* mb-length = 2 N = 3 */
+    &&L_OP_EXACTMB2N,            /* mb-length = 2 */
+    &&L_OP_EXACTMB3N,            /* mb-length = 3 */
+    &&L_OP_EXACTMBN,             /* other length */
+
+    &&L_OP_EXACT1_IC,            /* single byte, N = 1, ignore case */
+    &&L_OP_EXACTN_IC,            /* single byte,        ignore case */
+
+    &&L_OP_CCLASS,
+    &&L_OP_CCLASS_MB,
+    &&L_OP_CCLASS_MIX,
+    &&L_OP_CCLASS_NOT,
+    &&L_OP_CCLASS_MB_NOT,
+    &&L_OP_CCLASS_MIX_NOT,
+    &&L_OP_CCLASS_NODE,          /* pointer to CClassNode node */
+
+    &&L_OP_ANYCHAR,                 /* "."  */
+    &&L_OP_ANYCHAR_ML,              /* "."  multi-line */
+    &&L_OP_ANYCHAR_STAR,            /* ".*" */
+    &&L_OP_ANYCHAR_ML_STAR,         /* ".*" multi-line */
+    &&L_OP_ANYCHAR_STAR_PEEK_NEXT,
+    &&L_OP_ANYCHAR_ML_STAR_PEEK_NEXT,
+
+    &&L_OP_WORD,
+    &&L_OP_NOT_WORD,
+    &&L_OP_WORD_BOUND,
+    &&L_OP_NOT_WORD_BOUND,
+#ifdef USE_WORD_BEGIN_END
+    &&L_OP_WORD_BEGIN,
+    &&L_OP_WORD_END,
+#else
+    &&L_DEFAULT,
+    &&L_DEFAULT,
+#endif
+    &&L_OP_ASCII_WORD,
+    &&L_OP_NOT_ASCII_WORD,
+    &&L_OP_ASCII_WORD_BOUND,
+    &&L_OP_NOT_ASCII_WORD_BOUND,
+#ifdef USE_WORD_BEGIN_END
+    &&L_OP_ASCII_WORD_BEGIN,
+    &&L_OP_ASCII_WORD_END,
+#else
+    &&L_DEFAULT,
+    &&L_DEFAULT,
+#endif
+
+    &&L_OP_BEGIN_BUF,
+    &&L_OP_END_BUF,
+    &&L_OP_BEGIN_LINE,
+    &&L_OP_END_LINE,
+    &&L_OP_SEMI_END_BUF,
+    &&L_OP_BEGIN_POSITION,
+    &&L_OP_BEGIN_POS_OR_LINE,    /* used for implicit anchor optimization */
+
+    &&L_OP_BACKREF1,
+    &&L_OP_BACKREF2,
+    &&L_OP_BACKREFN,
+    &&L_OP_BACKREFN_IC,
+    &&L_OP_BACKREF_MULTI,
+    &&L_OP_BACKREF_MULTI_IC,
+#ifdef USE_BACKREF_WITH_LEVEL
+    &&L_OP_BACKREF_WITH_LEVEL,   /* \k<xxx+n>, \k<xxx-n> */
+#else
+    &&L_DEFAULT,
+#endif
+    &&L_OP_MEMORY_START,
+    &&L_OP_MEMORY_START_PUSH,    /* push back-tracker to stack */
+    &&L_OP_MEMORY_END_PUSH,      /* push back-tracker to stack */
+#ifdef USE_SUBEXP_CALL
+    &&L_OP_MEMORY_END_PUSH_REC,  /* push back-tracker to stack */
+#else
+    &&L_DEFAULT,
+#endif
+    &&L_OP_MEMORY_END,
+#ifdef USE_SUBEXP_CALL
+    &&L_OP_MEMORY_END_REC,       /* push marker to stack */
+#else
+    &&L_DEFAULT,
+#endif
+
+    &&L_OP_KEEP,
+
+    &&L_OP_FAIL,                 /* pop stack and move */
+    &&L_OP_JUMP,
+    &&L_OP_PUSH,
+    &&L_OP_POP,
+    &&L_OP_PUSH_OR_JUMP_EXACT1,  /* if match exact then push, else jump. */
+    &&L_OP_PUSH_IF_PEEK_NEXT,    /* if match exact then push, else none. */
+    &&L_OP_REPEAT,               /* {n,m} */
+    &&L_OP_REPEAT_NG,            /* {n,m}? (non greedy) */
+    &&L_OP_REPEAT_INC,
+    &&L_OP_REPEAT_INC_NG,        /* non greedy */
+    &&L_OP_REPEAT_INC_SG,        /* search and get in stack */
+    &&L_OP_REPEAT_INC_NG_SG,     /* search and get in stack (non greedy) */
+    &&L_OP_NULL_CHECK_START,     /* null loop checker start */
+    &&L_OP_NULL_CHECK_END,       /* null loop checker end   */
+#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
+    &&L_OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
+#else
+    &&L_DEFAULT,
+#endif
+#ifdef USE_SUBEXP_CALL
+    &&L_OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
+#else
+    &&L_DEFAULT,
+#endif
+
+    &&L_OP_PUSH_POS,             /* (?=...)  start */
+    &&L_OP_POP_POS,              /* (?=...)  end   */
+    &&L_OP_PUSH_POS_NOT,         /* (?!...)  start */
+    &&L_OP_FAIL_POS,             /* (?!...)  end   */
+    &&L_OP_PUSH_STOP_BT,         /* (?>...)  start */
+    &&L_OP_POP_STOP_BT,          /* (?>...)  end   */
+    &&L_OP_LOOK_BEHIND,          /* (?<=...) start (no needs end opcode) */
+    &&L_OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
+    &&L_OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end   */
+
+#ifdef USE_SUBEXP_CALL
+    &&L_OP_CALL,                 /* \g<name> */
+    &&L_OP_RETURN,
+#else
+    &&L_DEFAULT,
+    &&L_DEFAULT,
+#endif
+    &&L_OP_CONDITION,
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+    &&L_OP_STATE_CHECK_PUSH,         /* combination explosion check and push */
+    &&L_OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump  */
+    &&L_OP_STATE_CHECK,              /* check only */
+#else
+    &&L_DEFAULT,
+    &&L_DEFAULT,
+    &&L_DEFAULT,
+#endif
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+    &&L_OP_STATE_CHECK_ANYCHAR_STAR,
+    &&L_OP_STATE_CHECK_ANYCHAR_ML_STAR,
+#else
+    &&L_DEFAULT,
+    &&L_DEFAULT,
+#endif
+    /* no need: IS_DYNAMIC_OPTION() == 0 */
+#if 0   /* no need: IS_DYNAMIC_OPTION() == 0 */
+    &&L_OP_SET_OPTION_PUSH,    /* set option and push recover option */
+    &&L_OP_SET_OPTION          /* set option */
+#else
+    &&L_DEFAULT,
+    &&L_DEFAULT
+#endif
+  };
+#else
+
+#define VM_LOOP                                 \
+  while (1) {                                   \
+  OPCODE_EXEC_HOOK;                             \
+  sbegin = s;                                   \
+  switch (*p++) {
+#define VM_LOOP_END } sprev = sbegin; }
+#define CASE(x) case x:
+#define DEFAULT default:
+#define NEXT break
+#define JUMP continue; break
+#endif
+
+
+#ifdef USE_SUBEXP_CALL
+  /* Stack #0 is used to store the pattern itself and used for (?R), \g<0>, etc. */
+  n = reg->num_repeat + (reg->num_mem + 1) * 2;
+
+  STACK_INIT(*palloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE);
+  pop_level = reg->stack_pop_level;
+  num_mem = reg->num_mem;
+  repeat_stk = (OnigStackIndex* )*palloca_base;
+
+  mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
+  mem_end_stk   = mem_start_stk + (num_mem + 1);
+#else /* USE_SUBEXP_CALL */
+  /* Stack #0 not is used. */
+  n = reg->num_repeat + reg->num_mem * 2;
+
+  STACK_INIT(*palloca_base, xmalloc_base, n, INIT_MATCH_STACK_SIZE);
+  pop_level = reg->stack_pop_level;
+  num_mem = reg->num_mem;
+  repeat_stk = (OnigStackIndex* )*palloca_base;
+
+  mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
+  mem_end_stk   = mem_start_stk + num_mem;
+  mem_start_stk--; /* for index start from 1,
+		      mem_start_stk[1]..mem_start_stk[num_mem] */
+  mem_end_stk--;   /* for index start from 1,
+		      mem_end_stk[1]..mem_end_stk[num_mem] */
+#endif /* USE_SUBEXP_CALL */
+  {
+      OnigStackIndex *pp = mem_start_stk;
+      for (; pp < (repeat_stk + n); pp+=2) {
+	  pp[0] = INVALID_STACK_INDEX;
+	  pp[1] = INVALID_STACK_INDEX;
+      }
+  }
+
+#ifdef ONIG_DEBUG_MATCH
+  fprintf(stderr, "match_at: str: %"PRIdPTR" (%p), end: %"PRIdPTR" (%p), start: %"PRIdPTR" (%p), sprev: %"PRIdPTR" (%p)\n",
+	  (intptr_t )str, str, (intptr_t )end, end, (intptr_t )sstart, sstart, (intptr_t )sprev, sprev);
+  fprintf(stderr, "size: %d, start offset: %d\n",
+	  (int )(end - str), (int )(sstart - str));
+#endif
+
+  STACK_PUSH_ENSURED(STK_ALT, (UChar* )FinishCode);  /* bottom stack */
+  best_len = ONIG_MISMATCH;
+  s = (UChar* )sstart;
+  pkeep = (UChar* )sstart;
+
+
+#ifdef ONIG_DEBUG_MATCH
+#define OPCODE_EXEC_HOOK                                                \
+    if (s) {                                                            \
+      UChar *op, *q, *bp, buf[50];                                      \
+      int len;                                                          \
+      op = p - 1;                                                       \
+      fprintf(stderr, "%4"PRIdPTR"> \"", (*op == OP_FINISH) ? (ptrdiff_t )-1 : s - str); \
+      bp = buf;                                                         \
+      q = s;                                                            \
+      if (*op != OP_FINISH) {    /* s may not be a valid pointer if OP_FINISH. */ \
+	for (i = 0; i < 7 && q < end; i++) {                            \
+	  len = enclen(encode, q);                                      \
+	  while (len-- > 0) *bp++ = *q++;                               \
+	}                                                               \
+      }                                                                 \
+      if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; }                \
+      else         { xmemcpy(bp, "\"",    1); bp += 1; }                \
+      *bp = 0;                                                          \
+      fputs((char* )buf, stderr);                                       \
+      for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr);         \
+      fprintf(stderr, "%4"PRIdPTR":", (op == FinishCode) ? (ptrdiff_t )-1 : op - reg->p); \
+      onig_print_compiled_byte_code(stderr, op, NULL, encode);           \
+      fprintf(stderr, "\n");                                            \
+    }
+#else
+#define OPCODE_EXEC_HOOK ((void) 0)
+#endif
+
+
+  VM_LOOP {
+    CASE(OP_END)  MOP_IN(OP_END);
+      n = s - sstart;
+      if (n > best_len) {
+	OnigRegion* region;
+#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+	if (IS_FIND_LONGEST(option)) {
+	  if (n > msa->best_len) {
+	    msa->best_len = n;
+	    msa->best_s   = (UChar* )sstart;
+	  }
+	  else
+	    goto end_best_len;
+        }
+#endif
+	best_len = n;
+	region = msa->region;
+	if (region) {
+#ifdef USE_POSIX_API_REGION_OPTION
+	  if (IS_POSIX_REGION(msa->options)) {
+	    posix_regmatch_t* rmt = (posix_regmatch_t* )region;
+
+	    rmt[0].rm_so = (regoff_t )(((pkeep > s) ? s : pkeep) - str);
+	    rmt[0].rm_eo = (regoff_t )(s - str);
+	    for (i = 1; i <= num_mem; i++) {
+	      if (mem_end_stk[i] != INVALID_STACK_INDEX) {
+		if (BIT_STATUS_AT(reg->bt_mem_start, i))
+		  rmt[i].rm_so = (regoff_t )(STACK_AT(mem_start_stk[i])->u.mem.pstr - str);
+		else
+		  rmt[i].rm_so = (regoff_t )((UChar* )((void* )(mem_start_stk[i])) - str);
+
+		rmt[i].rm_eo = (regoff_t )((BIT_STATUS_AT(reg->bt_mem_end, i)
+				? STACK_AT(mem_end_stk[i])->u.mem.pstr
+				: (UChar* )((void* )mem_end_stk[i])) - str);
+	      }
+	      else {
+		rmt[i].rm_so = rmt[i].rm_eo = ONIG_REGION_NOTPOS;
+	      }
+	    }
+	  }
+	  else {
+#endif /* USE_POSIX_API_REGION_OPTION */
+	    region->beg[0] = ((pkeep > s) ? s : pkeep) - str;
+	    region->end[0] = s - str;
+	    for (i = 1; i <= num_mem; i++) {
+	      if (mem_end_stk[i] != INVALID_STACK_INDEX) {
+		if (BIT_STATUS_AT(reg->bt_mem_start, i))
+		  region->beg[i] = STACK_AT(mem_start_stk[i])->u.mem.pstr - str;
+		else
+		  region->beg[i] = (UChar* )((void* )mem_start_stk[i]) - str;
+
+		region->end[i] = (BIT_STATUS_AT(reg->bt_mem_end, i)
+				  ? STACK_AT(mem_end_stk[i])->u.mem.pstr
+				  : (UChar* )((void* )mem_end_stk[i])) - str;
+	      }
+	      else {
+		region->beg[i] = region->end[i] = ONIG_REGION_NOTPOS;
+	      }
+	    }
+
+#ifdef USE_CAPTURE_HISTORY
+	    if (reg->capture_history != 0) {
+              int r;
+              OnigCaptureTreeNode* node;
+
+              if (IS_NULL(region->history_root)) {
+                region->history_root = node = history_node_new();
+                CHECK_NULL_RETURN_MEMERR(node);
+              }
+              else {
+                node = region->history_root;
+                history_tree_clear(node);
+              }
+
+              node->group = 0;
+              node->beg   = ((pkeep > s) ? s : pkeep) - str;
+              node->end   = s - str;
+
+              stkp = stk_base;
+              r = make_capture_history_tree(region->history_root, &stkp,
+                                            stk, (UChar* )str, reg);
+              if (r < 0) {
+                best_len = r; /* error code */
+                goto finish;
+              }
+	    }
+#endif /* USE_CAPTURE_HISTORY */
+#ifdef USE_POSIX_API_REGION_OPTION
+	  } /* else IS_POSIX_REGION() */
+#endif
+	} /* if (region) */
+      } /* n > best_len */
+
+#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+    end_best_len:
+#endif
+      MOP_OUT;
+
+      if (IS_FIND_CONDITION(option)) {
+	if (IS_FIND_NOT_EMPTY(option) && s == sstart) {
+	  best_len = ONIG_MISMATCH;
+	  goto fail; /* for retry */
+	}
+	if (IS_FIND_LONGEST(option) && DATA_ENSURE_CHECK1) {
+	  goto fail; /* for retry */
+	}
+      }
+
+      /* default behavior: return first-matching result. */
+      goto finish;
+      NEXT;
+
+    CASE(OP_EXACT1)  MOP_IN(OP_EXACT1);
+#if 0
+      DATA_ENSURE(1);
+      if (*p != *s) goto fail;
+      p++; s++;
+#endif
+      if (*p != *s++) goto fail;
+      DATA_ENSURE(0);
+      p++;
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_EXACT1_IC)  MOP_IN(OP_EXACT1_IC);
+      {
+	int len;
+	UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
+
+	DATA_ENSURE(1);
+	len = ONIGENC_MBC_CASE_FOLD(encode,
+		    /* DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag), */
+		    case_fold_flag,
+		    &s, end, lowbuf);
+	DATA_ENSURE(0);
+	q = lowbuf;
+	while (len-- > 0) {
+	  if (*p != *q) {
+            goto fail;
+          }
+	  p++; q++;
+	}
+      }
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_EXACT2)  MOP_IN(OP_EXACT2);
+      DATA_ENSURE(2);
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      sprev = s;
+      p++; s++;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACT3)  MOP_IN(OP_EXACT3);
+      DATA_ENSURE(3);
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      sprev = s;
+      p++; s++;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACT4)  MOP_IN(OP_EXACT4);
+      DATA_ENSURE(4);
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      sprev = s;
+      p++; s++;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACT5)  MOP_IN(OP_EXACT5);
+      DATA_ENSURE(5);
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      sprev = s;
+      p++; s++;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACTN)  MOP_IN(OP_EXACTN);
+      GET_LENGTH_INC(tlen, p);
+      DATA_ENSURE(tlen);
+      while (tlen-- > 0) {
+	if (*p++ != *s++) goto fail;
+      }
+      sprev = s - 1;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACTN_IC)  MOP_IN(OP_EXACTN_IC);
+      {
+	int len;
+	UChar *q, *endp, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
+
+	GET_LENGTH_INC(tlen, p);
+	endp = p + tlen;
+
+	while (p < endp) {
+	  sprev = s;
+	  DATA_ENSURE(1);
+	  len = ONIGENC_MBC_CASE_FOLD(encode,
+		      /* DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag), */
+		      case_fold_flag,
+		      &s, end, lowbuf);
+	  DATA_ENSURE(0);
+	  q = lowbuf;
+	  while (len-- > 0) {
+	    if (*p != *q) goto fail;
+	    p++; q++;
+	  }
+	}
+      }
+
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACTMB2N1)  MOP_IN(OP_EXACTMB2N1);
+      DATA_ENSURE(2);
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_EXACTMB2N2)  MOP_IN(OP_EXACTMB2N2);
+      DATA_ENSURE(4);
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      sprev = s;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACTMB2N3)  MOP_IN(OP_EXACTMB2N3);
+      DATA_ENSURE(6);
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      sprev = s;
+      if (*p != *s) goto fail;
+      p++; s++;
+      if (*p != *s) goto fail;
+      p++; s++;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACTMB2N)  MOP_IN(OP_EXACTMB2N);
+      GET_LENGTH_INC(tlen, p);
+      DATA_ENSURE(tlen * 2);
+      while (tlen-- > 0) {
+	if (*p != *s) goto fail;
+	p++; s++;
+	if (*p != *s) goto fail;
+	p++; s++;
+      }
+      sprev = s - 2;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACTMB3N)  MOP_IN(OP_EXACTMB3N);
+      GET_LENGTH_INC(tlen, p);
+      DATA_ENSURE(tlen * 3);
+      while (tlen-- > 0) {
+	if (*p != *s) goto fail;
+	p++; s++;
+	if (*p != *s) goto fail;
+	p++; s++;
+	if (*p != *s) goto fail;
+	p++; s++;
+      }
+      sprev = s - 3;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_EXACTMBN)  MOP_IN(OP_EXACTMBN);
+      GET_LENGTH_INC(tlen,  p);  /* mb-len */
+      GET_LENGTH_INC(tlen2, p);  /* string len */
+      tlen2 *= tlen;
+      DATA_ENSURE(tlen2);
+      while (tlen2-- > 0) {
+	if (*p != *s) goto fail;
+	p++; s++;
+      }
+      sprev = s - tlen;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_CCLASS)  MOP_IN(OP_CCLASS);
+      DATA_ENSURE(1);
+      if (BITSET_AT(((BitSetRef )p), *s) == 0) goto fail;
+      p += SIZE_BITSET;
+      s += enclen(encode, s);   /* OP_CCLASS can match mb-code. \D, \S */
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_CCLASS_MB)  MOP_IN(OP_CCLASS_MB);
+      if (! ONIGENC_IS_MBC_HEAD(encode, s)) goto fail;
+
+    cclass_mb:
+      GET_LENGTH_INC(tlen, p);
+      {
+	OnigCodePoint code;
+	UChar *ss;
+	int mb_len;
+
+	DATA_ENSURE(1);
+	mb_len = enclen(encode, s);
+	DATA_ENSURE(mb_len);
+	ss = s;
+	s += mb_len;
+	code = ONIGENC_MBC_TO_CODE(encode, ss, s);
+
+#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
+	if (! onig_is_in_code_range(p, code)) goto fail;
+#else
+	q = p;
+	ALIGNMENT_RIGHT(q);
+	if (! onig_is_in_code_range(q, code)) goto fail;
+#endif
+      }
+      p += tlen;
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_CCLASS_MIX)  MOP_IN(OP_CCLASS_MIX);
+      DATA_ENSURE(1);
+      if (ONIGENC_IS_MBC_HEAD(encode, s)) {
+	p += SIZE_BITSET;
+	goto cclass_mb;
+      }
+      else {
+	if (BITSET_AT(((BitSetRef )p), *s) == 0)
+	  goto fail;
+
+	p += SIZE_BITSET;
+	GET_LENGTH_INC(tlen, p);
+	p += tlen;
+	s++;
+      }
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_CCLASS_NOT)  MOP_IN(OP_CCLASS_NOT);
+      DATA_ENSURE(1);
+      if (BITSET_AT(((BitSetRef )p), *s) != 0) goto fail;
+      p += SIZE_BITSET;
+      s += enclen(encode, s);
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_CCLASS_MB_NOT)  MOP_IN(OP_CCLASS_MB_NOT);
+      DATA_ENSURE(1);
+      if (! ONIGENC_IS_MBC_HEAD(encode, s)) {
+	s++;
+	GET_LENGTH_INC(tlen, p);
+	p += tlen;
+	goto cc_mb_not_success;
+      }
+
+    cclass_mb_not:
+      GET_LENGTH_INC(tlen, p);
+      {
+	OnigCodePoint code;
+	UChar *ss;
+	int mb_len = enclen(encode, s);
+
+	if (! DATA_ENSURE_CHECK(mb_len)) {
+          DATA_ENSURE(1);
+	  s = (UChar* )end;
+	  p += tlen;
+	  goto cc_mb_not_success;
+	}
+
+	ss = s;
+	s += mb_len;
+	code = ONIGENC_MBC_TO_CODE(encode, ss, s);
+
+#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
+	if (onig_is_in_code_range(p, code)) goto fail;
+#else
+	q = p;
+	ALIGNMENT_RIGHT(q);
+	if (onig_is_in_code_range(q, code)) goto fail;
+#endif
+      }
+      p += tlen;
+
+    cc_mb_not_success:
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_CCLASS_MIX_NOT)  MOP_IN(OP_CCLASS_MIX_NOT);
+      DATA_ENSURE(1);
+      if (ONIGENC_IS_MBC_HEAD(encode, s)) {
+	p += SIZE_BITSET;
+	goto cclass_mb_not;
+      }
+      else {
+	if (BITSET_AT(((BitSetRef )p), *s) != 0)
+	  goto fail;
+
+	p += SIZE_BITSET;
+	GET_LENGTH_INC(tlen, p);
+	p += tlen;
+	s++;
+      }
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_CCLASS_NODE)  MOP_IN(OP_CCLASS_NODE);
+      {
+	OnigCodePoint code;
+        void *node;
+        int mb_len;
+        UChar *ss;
+
+        DATA_ENSURE(1);
+        GET_POINTER_INC(node, p);
+	mb_len = enclen(encode, s);
+	ss = s;
+	s += mb_len;
+	DATA_ENSURE(0);
+	code = ONIGENC_MBC_TO_CODE(encode, ss, s);
+	if (onig_is_code_in_cc_len(mb_len, code, node) == 0) goto fail;
+      }
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_ANYCHAR)  MOP_IN(OP_ANYCHAR);
+      DATA_ENSURE(1);
+      n = enclen(encode, s);
+      DATA_ENSURE(n);
+      if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 0)) goto fail;
+      s += n;
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_ANYCHAR_ML)  MOP_IN(OP_ANYCHAR_ML);
+      DATA_ENSURE(1);
+      n = enclen(encode, s);
+      DATA_ENSURE(n);
+      s += n;
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_ANYCHAR_STAR)  MOP_IN(OP_ANYCHAR_STAR);
+      while (DATA_ENSURE_CHECK1) {
+	STACK_PUSH_ALT(p, s, sprev, pkeep);
+	n = enclen(encode, s);
+        DATA_ENSURE(n);
+        if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 0))  goto fail;
+        sprev = s;
+        s += n;
+      }
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_ANYCHAR_ML_STAR)  MOP_IN(OP_ANYCHAR_ML_STAR);
+      while (DATA_ENSURE_CHECK1) {
+	STACK_PUSH_ALT(p, s, sprev, pkeep);
+	n = enclen(encode, s);
+	if (n > 1) {
+	  DATA_ENSURE(n);
+	  sprev = s;
+	  s += n;
+	}
+	else {
+	  sprev = s;
+	  s++;
+	}
+      }
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_ANYCHAR_STAR_PEEK_NEXT)  MOP_IN(OP_ANYCHAR_STAR_PEEK_NEXT);
+      while (DATA_ENSURE_CHECK1) {
+	if (*p == *s) {
+	  STACK_PUSH_ALT(p + 1, s, sprev, pkeep);
+	}
+	n = enclen(encode, s);
+        DATA_ENSURE(n);
+        if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 0))  goto fail;
+        sprev = s;
+        s += n;
+      }
+      p++;
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_ANYCHAR_ML_STAR_PEEK_NEXT)MOP_IN(OP_ANYCHAR_ML_STAR_PEEK_NEXT);
+      while (DATA_ENSURE_CHECK1) {
+	if (*p == *s) {
+	  STACK_PUSH_ALT(p + 1, s, sprev, pkeep);
+	}
+	n = enclen(encode, s);
+	if (n > 1) {
+	  DATA_ENSURE(n);
+	  sprev = s;
+	  s += n;
+	}
+	else {
+	  sprev = s;
+	  s++;
+	}
+      }
+      p++;
+      MOP_OUT;
+      NEXT;
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+    CASE(OP_STATE_CHECK_ANYCHAR_STAR)  MOP_IN(OP_STATE_CHECK_ANYCHAR_STAR);
+      GET_STATE_CHECK_NUM_INC(mem, p);
+      while (DATA_ENSURE_CHECK1) {
+	STATE_CHECK_VAL(scv, mem);
+	if (scv) goto fail;
+
+	STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem, pkeep);
+	n = enclen(encode, s);
+        DATA_ENSURE(n);
+        if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 0))  goto fail;
+        sprev = s;
+        s += n;
+      }
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_STATE_CHECK_ANYCHAR_ML_STAR)
+      MOP_IN(OP_STATE_CHECK_ANYCHAR_ML_STAR);
+
+      GET_STATE_CHECK_NUM_INC(mem, p);
+      while (DATA_ENSURE_CHECK1) {
+	STATE_CHECK_VAL(scv, mem);
+	if (scv) goto fail;
+
+	STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem, pkeep);
+	n = enclen(encode, s);
+	if (n > 1) {
+	  DATA_ENSURE(n);
+	  sprev = s;
+	  s += n;
+	}
+	else {
+	  sprev = s;
+	  s++;
+	}
+      }
+      MOP_OUT;
+      NEXT;
+#endif /* USE_COMBINATION_EXPLOSION_CHECK */
+
+    CASE(OP_WORD)  MOP_IN(OP_WORD);
+      DATA_ENSURE(1);
+      if (! ONIGENC_IS_MBC_WORD(encode, s, end))
+	goto fail;
+
+      s += enclen(encode, s);
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_ASCII_WORD)  MOP_IN(OP_ASCII_WORD);
+      DATA_ENSURE(1);
+      if (! ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
+	goto fail;
+
+      s += enclen(encode, s);
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_NOT_WORD)  MOP_IN(OP_NOT_WORD);
+      DATA_ENSURE(1);
+      if (ONIGENC_IS_MBC_WORD(encode, s, end))
+	goto fail;
+
+      s += enclen(encode, s);
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_NOT_ASCII_WORD)  MOP_IN(OP_NOT_ASCII_WORD);
+      DATA_ENSURE(1);
+      if (ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
+	goto fail;
+
+      s += enclen(encode, s);
+      MOP_OUT;
+      NEXT;
+
+    CASE(OP_WORD_BOUND)  MOP_IN(OP_WORD_BOUND);
+      if (ON_STR_BEGIN(s)) {
+	DATA_ENSURE(1);
+	if (! ONIGENC_IS_MBC_WORD(encode, s, end))
+	  goto fail;
+      }
+      else if (ON_STR_END(s)) {
+	if (! ONIGENC_IS_MBC_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      else {
+	if (ONIGENC_IS_MBC_WORD(encode, s, end)
+	    == ONIGENC_IS_MBC_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_ASCII_WORD_BOUND)  MOP_IN(OP_ASCII_WORD_BOUND);
+      if (ON_STR_BEGIN(s)) {
+	DATA_ENSURE(1);
+	if (! ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
+	  goto fail;
+      }
+      else if (ON_STR_END(s)) {
+	if (! ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      else {
+	if (ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)
+	    == ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_NOT_WORD_BOUND)  MOP_IN(OP_NOT_WORD_BOUND);
+      if (ON_STR_BEGIN(s)) {
+	if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end))
+	  goto fail;
+      }
+      else if (ON_STR_END(s)) {
+	if (ONIGENC_IS_MBC_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      else {
+	if (ONIGENC_IS_MBC_WORD(encode, s, end)
+	    != ONIGENC_IS_MBC_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_NOT_ASCII_WORD_BOUND)  MOP_IN(OP_NOT_ASCII_WORD_BOUND);
+      if (ON_STR_BEGIN(s)) {
+	if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
+	  goto fail;
+      }
+      else if (ON_STR_END(s)) {
+	if (ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      else {
+	if (ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)
+	    != ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end))
+	  goto fail;
+      }
+      MOP_OUT;
+      JUMP;
+
+#ifdef USE_WORD_BEGIN_END
+    CASE(OP_WORD_BEGIN)  MOP_IN(OP_WORD_BEGIN);
+      if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end)) {
+	if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
+	  MOP_OUT;
+	  JUMP;
+	}
+      }
+      goto fail;
+      NEXT;
+
+    CASE(OP_ASCII_WORD_BEGIN)  MOP_IN(OP_ASCII_WORD_BEGIN);
+      if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)) {
+	if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end)) {
+	  MOP_OUT;
+	  JUMP;
+	}
+      }
+      goto fail;
+      NEXT;
+
+    CASE(OP_WORD_END)  MOP_IN(OP_WORD_END);
+      if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
+	if (ON_STR_END(s) || !ONIGENC_IS_MBC_WORD(encode, s, end)) {
+	  MOP_OUT;
+	  JUMP;
+	}
+      }
+      goto fail;
+      NEXT;
+
+    CASE(OP_ASCII_WORD_END)  MOP_IN(OP_ASCII_WORD_END);
+      if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end)) {
+	if (ON_STR_END(s) || !ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)) {
+	  MOP_OUT;
+	  JUMP;
+	}
+      }
+      goto fail;
+      NEXT;
+#endif
+
+    CASE(OP_BEGIN_BUF)  MOP_IN(OP_BEGIN_BUF);
+      if (! ON_STR_BEGIN(s)) goto fail;
+      if (IS_NOTBOS(msa->options)) goto fail;
+
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_END_BUF)  MOP_IN(OP_END_BUF);
+      if (! ON_STR_END(s)) goto fail;
+      if (IS_NOTEOS(msa->options)) goto fail;
+
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_BEGIN_LINE)  MOP_IN(OP_BEGIN_LINE);
+    op_begin_line:
+      if (ON_STR_BEGIN(s)) {
+	if (IS_NOTBOL(msa->options)) goto fail;
+	MOP_OUT;
+	JUMP;
+      }
+      else if (ONIGENC_IS_MBC_NEWLINE(encode, sprev, end)
+#ifdef USE_CRNL_AS_LINE_TERMINATOR
+		&& !(IS_NEWLINE_CRLF(option)
+		     && ONIGENC_IS_MBC_CRNL(encode, sprev, end))
+#endif
+		&& !ON_STR_END(s)) {
+	MOP_OUT;
+	JUMP;
+      }
+      goto fail;
+      NEXT;
+
+    CASE(OP_END_LINE)  MOP_IN(OP_END_LINE);
+      if (ON_STR_END(s)) {
+#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
+	if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE_EX(encode, sprev, str, end, option, 1)) {
+#endif
+	  if (IS_NOTEOL(msa->options)) goto fail;
+	  MOP_OUT;
+	  JUMP;
+#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
+	}
+#endif
+      }
+      else if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 1)) {
+	MOP_OUT;
+	JUMP;
+      }
+      goto fail;
+      NEXT;
+
+    CASE(OP_SEMI_END_BUF)  MOP_IN(OP_SEMI_END_BUF);
+      if (ON_STR_END(s)) {
+#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
+	if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE_EX(encode, sprev, str, end, option, 1)) {
+#endif
+	  if (IS_NOTEOL(msa->options)) goto fail;
+	  MOP_OUT;
+	  JUMP;
+#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
+	}
+#endif
+      }
+      else if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 1)) {
+	UChar* ss = s + enclen(encode, s);
+	if (ON_STR_END(ss)) {
+	  MOP_OUT;
+	  JUMP;
+	}
+#ifdef USE_CRNL_AS_LINE_TERMINATOR
+	else if (IS_NEWLINE_CRLF(option)
+	    && ONIGENC_IS_MBC_CRNL(encode, s, end)) {
+	  ss += enclen(encode, ss);
+	  if (ON_STR_END(ss)) {
+	    MOP_OUT;
+	    JUMP;
+	  }
+	}
+#endif
+      }
+      goto fail;
+      NEXT;
+
+    CASE(OP_BEGIN_POSITION)  MOP_IN(OP_BEGIN_POSITION);
+      if (s != msa->gpos)
+	goto fail;
+
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_BEGIN_POS_OR_LINE)  MOP_IN(OP_BEGIN_POS_OR_LINE);
+      if (s != msa->gpos)
+	goto op_begin_line;
+
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_MEMORY_START_PUSH)  MOP_IN(OP_MEMORY_START_PUSH);
+      GET_MEMNUM_INC(mem, p);
+      STACK_PUSH_MEM_START(mem, s);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_MEMORY_START)  MOP_IN(OP_MEMORY_START);
+      GET_MEMNUM_INC(mem, p);
+      mem_start_stk[mem] = (OnigStackIndex )((void* )s);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_MEMORY_END_PUSH)  MOP_IN(OP_MEMORY_END_PUSH);
+      GET_MEMNUM_INC(mem, p);
+      STACK_PUSH_MEM_END(mem, s);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_MEMORY_END)  MOP_IN(OP_MEMORY_END);
+      GET_MEMNUM_INC(mem, p);
+      mem_end_stk[mem] = (OnigStackIndex )((void* )s);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_KEEP)  MOP_IN(OP_KEEP);
+      pkeep = s;
+      MOP_OUT;
+      JUMP;
+
+#ifdef USE_SUBEXP_CALL
+    CASE(OP_MEMORY_END_PUSH_REC)  MOP_IN(OP_MEMORY_END_PUSH_REC);
+      GET_MEMNUM_INC(mem, p);
+      STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
+      STACK_PUSH_MEM_END(mem, s);
+      mem_start_stk[mem] = GET_STACK_INDEX(stkp);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_MEMORY_END_REC)  MOP_IN(OP_MEMORY_END_REC);
+      GET_MEMNUM_INC(mem, p);
+      mem_end_stk[mem] = (OnigStackIndex )((void* )s);
+      STACK_GET_MEM_START(mem, stkp);
+
+      if (BIT_STATUS_AT(reg->bt_mem_start, mem))
+	mem_start_stk[mem] = GET_STACK_INDEX(stkp);
+      else
+	mem_start_stk[mem] = (OnigStackIndex )((void* )stkp->u.mem.pstr);
+
+      STACK_PUSH_MEM_END_MARK(mem);
+      MOP_OUT;
+      JUMP;
+#endif
+
+    CASE(OP_BACKREF1)  MOP_IN(OP_BACKREF1);
+      mem = 1;
+      goto backref;
+      NEXT;
+
+    CASE(OP_BACKREF2)  MOP_IN(OP_BACKREF2);
+      mem = 2;
+      goto backref;
+      NEXT;
+
+    CASE(OP_BACKREFN)  MOP_IN(OP_BACKREFN);
+      GET_MEMNUM_INC(mem, p);
+    backref:
+      {
+	int len;
+	UChar *pstart, *pend;
+
+	/* if you want to remove following line,
+	   you should check in parse and compile time. */
+	if (mem > num_mem) goto fail;
+	if (mem_end_stk[mem]   == INVALID_STACK_INDEX) goto fail;
+	if (mem_start_stk[mem] == INVALID_STACK_INDEX) goto fail;
+
+	if (BIT_STATUS_AT(reg->bt_mem_start, mem))
+	  pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
+	else
+	  pstart = (UChar* )((void* )mem_start_stk[mem]);
+
+	pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
+		? STACK_AT(mem_end_stk[mem])->u.mem.pstr
+		: (UChar* )((void* )mem_end_stk[mem]));
+	n = pend - pstart;
+	DATA_ENSURE(n);
+	sprev = s;
+	STRING_CMP(pstart, s, n);
+	while (sprev + (len = enclen(encode, sprev)) < s)
+	  sprev += len;
+
+	MOP_OUT;
+	JUMP;
+      }
+
+    CASE(OP_BACKREFN_IC)  MOP_IN(OP_BACKREFN_IC);
+      GET_MEMNUM_INC(mem, p);
+      {
+	int len;
+	UChar *pstart, *pend;
+
+	/* if you want to remove following line,
+	   you should check in parse and compile time. */
+	if (mem > num_mem) goto fail;
+	if (mem_end_stk[mem]   == INVALID_STACK_INDEX) goto fail;
+	if (mem_start_stk[mem] == INVALID_STACK_INDEX) goto fail;
+
+	if (BIT_STATUS_AT(reg->bt_mem_start, mem))
+	  pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
+	else
+	  pstart = (UChar* )((void* )mem_start_stk[mem]);
+
+	pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
+		? STACK_AT(mem_end_stk[mem])->u.mem.pstr
+		: (UChar* )((void* )mem_end_stk[mem]));
+	n = pend - pstart;
+	DATA_ENSURE(n);
+	sprev = s;
+	STRING_CMP_IC(case_fold_flag, pstart, &s, n);
+	while (sprev + (len = enclen(encode, sprev)) < s)
+	  sprev += len;
+
+	MOP_OUT;
+	JUMP;
+      }
+      NEXT;
+
+    CASE(OP_BACKREF_MULTI)  MOP_IN(OP_BACKREF_MULTI);
+      {
+	int len, is_fail;
+	UChar *pstart, *pend, *swork;
+
+	GET_LENGTH_INC(tlen, p);
+	for (i = 0; i < tlen; i++) {
+	  GET_MEMNUM_INC(mem, p);
+
+	  if (mem_end_stk[mem]   == INVALID_STACK_INDEX) continue;
+	  if (mem_start_stk[mem] == INVALID_STACK_INDEX) continue;
+
+	  if (BIT_STATUS_AT(reg->bt_mem_start, mem))
+	    pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
+	  else
+	    pstart = (UChar* )((void* )mem_start_stk[mem]);
+
+	  pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
+		  ? STACK_AT(mem_end_stk[mem])->u.mem.pstr
+		  : (UChar* )((void* )mem_end_stk[mem]));
+	  n = pend - pstart;
+	  DATA_ENSURE(n);
+	  sprev = s;
+	  swork = s;
+	  STRING_CMP_VALUE(pstart, swork, n, is_fail);
+	  if (is_fail) continue;
+	  s = swork;
+	  while (sprev + (len = enclen(encode, sprev)) < s)
+	    sprev += len;
+
+	  p += (SIZE_MEMNUM * (tlen - i - 1));
+	  break; /* success */
+	}
+	if (i == tlen) goto fail;
+	MOP_OUT;
+	JUMP;
+      }
+      NEXT;
+
+    CASE(OP_BACKREF_MULTI_IC)  MOP_IN(OP_BACKREF_MULTI_IC);
+      {
+	int len, is_fail;
+	UChar *pstart, *pend, *swork;
+
+	GET_LENGTH_INC(tlen, p);
+	for (i = 0; i < tlen; i++) {
+	  GET_MEMNUM_INC(mem, p);
+
+	  if (mem_end_stk[mem]   == INVALID_STACK_INDEX) continue;
+	  if (mem_start_stk[mem] == INVALID_STACK_INDEX) continue;
+
+	  if (BIT_STATUS_AT(reg->bt_mem_start, mem))
+	    pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
+	  else
+	    pstart = (UChar* )((void* )mem_start_stk[mem]);
+
+	  pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
+		  ? STACK_AT(mem_end_stk[mem])->u.mem.pstr
+		  : (UChar* )((void* )mem_end_stk[mem]));
+	  n = pend - pstart;
+	  DATA_ENSURE(n);
+	  sprev = s;
+	  swork = s;
+	  STRING_CMP_VALUE_IC(case_fold_flag, pstart, &swork, n, is_fail);
+	  if (is_fail) continue;
+	  s = swork;
+	  while (sprev + (len = enclen(encode, sprev)) < s)
+	    sprev += len;
+
+	  p += (SIZE_MEMNUM * (tlen - i - 1));
+	  break; /* success */
+	}
+	if (i == tlen) goto fail;
+	MOP_OUT;
+	JUMP;
+      }
+
+#ifdef USE_BACKREF_WITH_LEVEL
+    CASE(OP_BACKREF_WITH_LEVEL)
+      {
+	int len;
+	OnigOptionType ic;
+	LengthType level;
+
+	GET_OPTION_INC(ic,    p);
+	GET_LENGTH_INC(level, p);
+	GET_LENGTH_INC(tlen,  p);
+
+	sprev = s;
+	if (backref_match_at_nested_level(reg, stk, stk_base, ic
+		  , case_fold_flag, (int )level, (int )tlen, p, &s, end)) {
+	  while (sprev + (len = enclen(encode, sprev)) < s)
+	    sprev += len;
+
+	  p += (SIZE_MEMNUM * tlen);
+	}
+	else
+	  goto fail;
+
+	MOP_OUT;
+	JUMP;
+      }
+
+#endif
+
+#if 0   /* no need: IS_DYNAMIC_OPTION() == 0 */
+    CASE(OP_SET_OPTION_PUSH)  MOP_IN(OP_SET_OPTION_PUSH);
+      GET_OPTION_INC(option, p);
+      STACK_PUSH_ALT(p, s, sprev, pkeep);
+      p += SIZE_OP_SET_OPTION + SIZE_OP_FAIL;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_SET_OPTION)  MOP_IN(OP_SET_OPTION);
+      GET_OPTION_INC(option, p);
+      MOP_OUT;
+      JUMP;
+#endif
+
+    CASE(OP_NULL_CHECK_START)  MOP_IN(OP_NULL_CHECK_START);
+      GET_MEMNUM_INC(mem, p);    /* mem: null check id */
+      STACK_PUSH_NULL_CHECK_START(mem, s);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_NULL_CHECK_END)  MOP_IN(OP_NULL_CHECK_END);
+      {
+	int isnull;
+
+	GET_MEMNUM_INC(mem, p); /* mem: null check id */
+	STACK_NULL_CHECK(isnull, mem, s);
+	if (isnull) {
+#ifdef ONIG_DEBUG_MATCH
+	  fprintf(stderr, "NULL_CHECK_END: skip  id:%d, s:%"PRIdPTR" (%p)\n",
+		  (int )mem, (intptr_t )s, s);
+#endif
+	null_check_found:
+	  /* empty loop founded, skip next instruction */
+	  switch (*p++) {
+	  case OP_JUMP:
+	  case OP_PUSH:
+	    p += SIZE_RELADDR;
+	    break;
+	  case OP_REPEAT_INC:
+	  case OP_REPEAT_INC_NG:
+	  case OP_REPEAT_INC_SG:
+	  case OP_REPEAT_INC_NG_SG:
+	    p += SIZE_MEMNUM;
+	    break;
+	  default:
+	    goto unexpected_bytecode_error;
+	    break;
+	  }
+	}
+      }
+      MOP_OUT;
+      JUMP;
+
+#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
+    CASE(OP_NULL_CHECK_END_MEMST)  MOP_IN(OP_NULL_CHECK_END_MEMST);
+      {
+	int isnull;
+
+	GET_MEMNUM_INC(mem, p); /* mem: null check id */
+	STACK_NULL_CHECK_MEMST(isnull, mem, s, reg);
+	if (isnull) {
+#ifdef ONIG_DEBUG_MATCH
+	  fprintf(stderr, "NULL_CHECK_END_MEMST: skip  id:%d, s:%"PRIdPTR" (%p)\n",
+		  (int )mem, (intptr_t )s, s);
+#endif
+	  if (isnull == -1) goto fail;
+	  goto null_check_found;
+	}
+      }
+      MOP_OUT;
+      JUMP;
+#endif
+
+#ifdef USE_SUBEXP_CALL
+    CASE(OP_NULL_CHECK_END_MEMST_PUSH)
+      MOP_IN(OP_NULL_CHECK_END_MEMST_PUSH);
+      {
+	int isnull;
+
+	GET_MEMNUM_INC(mem, p); /* mem: null check id */
+#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
+	STACK_NULL_CHECK_MEMST_REC(isnull, mem, s, reg);
+#else
+	STACK_NULL_CHECK_REC(isnull, mem, s);
+#endif
+	if (isnull) {
+#ifdef ONIG_DEBUG_MATCH
+	  fprintf(stderr, "NULL_CHECK_END_MEMST_PUSH: skip  id:%d, s:%"PRIdPTR" (%p)\n",
+		  (int )mem, (intptr_t )s, s);
+#endif
+	  if (isnull == -1) goto fail;
+	  goto null_check_found;
+	}
+	else {
+	  STACK_PUSH_NULL_CHECK_END(mem);
+	}
+      }
+      MOP_OUT;
+      JUMP;
+#endif
+
+    CASE(OP_JUMP)  MOP_IN(OP_JUMP);
+      GET_RELADDR_INC(addr, p);
+      p += addr;
+      MOP_OUT;
+      CHECK_INTERRUPT_IN_MATCH_AT;
+      JUMP;
+
+    CASE(OP_PUSH)  MOP_IN(OP_PUSH);
+      GET_RELADDR_INC(addr, p);
+      STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
+      MOP_OUT;
+      JUMP;
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+    CASE(OP_STATE_CHECK_PUSH)  MOP_IN(OP_STATE_CHECK_PUSH);
+      GET_STATE_CHECK_NUM_INC(mem, p);
+      STATE_CHECK_VAL(scv, mem);
+      if (scv) goto fail;
+
+      GET_RELADDR_INC(addr, p);
+      STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem, pkeep);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_STATE_CHECK_PUSH_OR_JUMP)  MOP_IN(OP_STATE_CHECK_PUSH_OR_JUMP);
+      GET_STATE_CHECK_NUM_INC(mem, p);
+      GET_RELADDR_INC(addr, p);
+      STATE_CHECK_VAL(scv, mem);
+      if (scv) {
+	p += addr;
+      }
+      else {
+	STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem, pkeep);
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_STATE_CHECK)  MOP_IN(OP_STATE_CHECK);
+      GET_STATE_CHECK_NUM_INC(mem, p);
+      STATE_CHECK_VAL(scv, mem);
+      if (scv) goto fail;
+
+      STACK_PUSH_STATE_CHECK(s, mem);
+      MOP_OUT;
+      JUMP;
+#endif /* USE_COMBINATION_EXPLOSION_CHECK */
+
+    CASE(OP_POP)  MOP_IN(OP_POP);
+      STACK_POP_ONE;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_PUSH_OR_JUMP_EXACT1)  MOP_IN(OP_PUSH_OR_JUMP_EXACT1);
+      GET_RELADDR_INC(addr, p);
+      if (*p == *s && DATA_ENSURE_CHECK1) {
+	p++;
+	STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
+	MOP_OUT;
+	JUMP;
+      }
+      p += (addr + 1);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_PUSH_IF_PEEK_NEXT)  MOP_IN(OP_PUSH_IF_PEEK_NEXT);
+      GET_RELADDR_INC(addr, p);
+      if (*p == *s) {
+	p++;
+	STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
+	MOP_OUT;
+	JUMP;
+      }
+      p++;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_REPEAT)  MOP_IN(OP_REPEAT);
+      {
+	GET_MEMNUM_INC(mem, p);    /* mem: OP_REPEAT ID */
+	GET_RELADDR_INC(addr, p);
+
+	STACK_ENSURE(1);
+	repeat_stk[mem] = GET_STACK_INDEX(stk);
+	STACK_PUSH_REPEAT(mem, p);
+
+	if (reg->repeat_range[mem].lower == 0) {
+	  STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
+	}
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_REPEAT_NG)  MOP_IN(OP_REPEAT_NG);
+      {
+	GET_MEMNUM_INC(mem, p);    /* mem: OP_REPEAT ID */
+	GET_RELADDR_INC(addr, p);
+
+	STACK_ENSURE(1);
+	repeat_stk[mem] = GET_STACK_INDEX(stk);
+	STACK_PUSH_REPEAT(mem, p);
+
+	if (reg->repeat_range[mem].lower == 0) {
+	  STACK_PUSH_ALT(p, s, sprev, pkeep);
+	  p += addr;
+	}
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_REPEAT_INC)  MOP_IN(OP_REPEAT_INC);
+      GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
+      si = repeat_stk[mem];
+      stkp = STACK_AT(si);
+
+    repeat_inc:
+      stkp->u.repeat.count++;
+      if (stkp->u.repeat.count >= reg->repeat_range[mem].upper) {
+        /* end of repeat. Nothing to do. */
+      }
+      else if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) {
+        STACK_PUSH_ALT(p, s, sprev, pkeep);
+        p = STACK_AT(si)->u.repeat.pcode; /* Don't use stkp after PUSH. */
+      }
+      else {
+        p = stkp->u.repeat.pcode;
+      }
+      STACK_PUSH_REPEAT_INC(si);
+      MOP_OUT;
+      CHECK_INTERRUPT_IN_MATCH_AT;
+      JUMP;
+
+    CASE(OP_REPEAT_INC_SG)  MOP_IN(OP_REPEAT_INC_SG);
+      GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
+      STACK_GET_REPEAT(mem, stkp);
+      si = GET_STACK_INDEX(stkp);
+      goto repeat_inc;
+      NEXT;
+
+    CASE(OP_REPEAT_INC_NG)  MOP_IN(OP_REPEAT_INC_NG);
+      GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
+      si = repeat_stk[mem];
+      stkp = STACK_AT(si);
+
+    repeat_inc_ng:
+      stkp->u.repeat.count++;
+      if (stkp->u.repeat.count < reg->repeat_range[mem].upper) {
+        if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) {
+          UChar* pcode = stkp->u.repeat.pcode;
+
+          STACK_PUSH_REPEAT_INC(si);
+          STACK_PUSH_ALT(pcode, s, sprev, pkeep);
+        }
+        else {
+          p = stkp->u.repeat.pcode;
+          STACK_PUSH_REPEAT_INC(si);
+        }
+      }
+      else if (stkp->u.repeat.count == reg->repeat_range[mem].upper) {
+        STACK_PUSH_REPEAT_INC(si);
+      }
+      MOP_OUT;
+      CHECK_INTERRUPT_IN_MATCH_AT;
+      JUMP;
+
+    CASE(OP_REPEAT_INC_NG_SG)  MOP_IN(OP_REPEAT_INC_NG_SG);
+      GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
+      STACK_GET_REPEAT(mem, stkp);
+      si = GET_STACK_INDEX(stkp);
+      goto repeat_inc_ng;
+      NEXT;
+
+    CASE(OP_PUSH_POS)  MOP_IN(OP_PUSH_POS);
+      STACK_PUSH_POS(s, sprev, pkeep);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_POP_POS)  MOP_IN(OP_POP_POS);
+      {
+	STACK_POS_END(stkp);
+	s     = stkp->u.state.pstr;
+	sprev = stkp->u.state.pstr_prev;
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_PUSH_POS_NOT)  MOP_IN(OP_PUSH_POS_NOT);
+      GET_RELADDR_INC(addr, p);
+      STACK_PUSH_POS_NOT(p + addr, s, sprev, pkeep);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_FAIL_POS)  MOP_IN(OP_FAIL_POS);
+      STACK_POP_TIL_POS_NOT;
+      goto fail;
+      NEXT;
+
+    CASE(OP_PUSH_STOP_BT)  MOP_IN(OP_PUSH_STOP_BT);
+      STACK_PUSH_STOP_BT;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_POP_STOP_BT)  MOP_IN(OP_POP_STOP_BT);
+      STACK_STOP_BT_END;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_LOOK_BEHIND)  MOP_IN(OP_LOOK_BEHIND);
+      GET_LENGTH_INC(tlen, p);
+      s = (UChar* )ONIGENC_STEP_BACK(encode, str, s, (int )tlen);
+      if (IS_NULL(s)) goto fail;
+      sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s);
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_PUSH_LOOK_BEHIND_NOT)  MOP_IN(OP_PUSH_LOOK_BEHIND_NOT);
+      GET_RELADDR_INC(addr, p);
+      GET_LENGTH_INC(tlen, p);
+      q = (UChar* )ONIGENC_STEP_BACK(encode, str, s, (int )tlen);
+      if (IS_NULL(q)) {
+	/* too short case -> success. ex. /(?<!XXX)a/.match("a")
+	   If you want to change to fail, replace following line. */
+	p += addr;
+	/* goto fail; */
+      }
+      else {
+	STACK_PUSH_LOOK_BEHIND_NOT(p + addr, s, sprev, pkeep);
+	s = q;
+	sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s);
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_FAIL_LOOK_BEHIND_NOT)  MOP_IN(OP_FAIL_LOOK_BEHIND_NOT);
+      STACK_POP_TIL_LOOK_BEHIND_NOT;
+      goto fail;
+      NEXT;
+
+#ifdef USE_SUBEXP_CALL
+    CASE(OP_CALL)  MOP_IN(OP_CALL);
+      GET_ABSADDR_INC(addr, p);
+      STACK_PUSH_CALL_FRAME(p);
+      p = reg->p + addr;
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_RETURN)  MOP_IN(OP_RETURN);
+      STACK_RETURN(p);
+      STACK_PUSH_RETURN;
+      MOP_OUT;
+      JUMP;
+#endif
+
+    CASE(OP_CONDITION)  MOP_IN(OP_CONDITION);
+      GET_MEMNUM_INC(mem, p);
+      GET_RELADDR_INC(addr, p);
+      if ((mem > num_mem) ||
+	  (mem_end_stk[mem]   == INVALID_STACK_INDEX) ||
+	  (mem_start_stk[mem] == INVALID_STACK_INDEX)) {
+	p += addr;
+      }
+      MOP_OUT;
+      JUMP;
+
+    CASE(OP_FINISH)
+      goto finish;
+      NEXT;
+
+    CASE(OP_FAIL)
+      if (0) {
+        /* fall */
+      fail:
+        MOP_OUT;
+      }
+      MOP_IN(OP_FAIL);
+      STACK_POP;
+      p     = stk->u.state.pcode;
+      s     = stk->u.state.pstr;
+      sprev = stk->u.state.pstr_prev;
+      pkeep = stk->u.state.pkeep;
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+      if (stk->u.state.state_check != 0) {
+        stk->type = STK_STATE_CHECK_MARK;
+        stk++;
+      }
+#endif
+
+      MOP_OUT;
+      JUMP;
+
+    DEFAULT
+      goto bytecode_error;
+  } VM_LOOP_END
+
+ finish:
+  STACK_SAVE;
+  if (xmalloc_base) xfree(xmalloc_base);
+  return best_len;
+
+#ifdef ONIG_DEBUG
+ stack_error:
+  STACK_SAVE;
+  if (xmalloc_base) xfree(xmalloc_base);
+  return ONIGERR_STACK_BUG;
+#endif
+
+ bytecode_error:
+  STACK_SAVE;
+  if (xmalloc_base) xfree(xmalloc_base);
+  return ONIGERR_UNDEFINED_BYTECODE;
+
+ unexpected_bytecode_error:
+  STACK_SAVE;
+  if (xmalloc_base) xfree(xmalloc_base);
+  return ONIGERR_UNEXPECTED_BYTECODE;
+}
+
+static OnigPosition
+match_at(regex_t* reg, const UChar* str, const UChar* end,
+#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+	const UChar* right_range,
+#endif
+	const UChar* sstart, UChar* sprev, OnigMatchArg* msa)
+{
+	char *alloca_base = NULL;
+	OnigPosition ret = match_at_(reg, str, end,
+#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+		right_range,
+#endif
+		sstart, sprev, msa, &alloca_base);
+	if(alloca_base) xfree(alloca_base);
+	return ret;
+}
+
+static UChar*
+slow_search(OnigEncoding enc, UChar* target, UChar* target_end,
+	    const UChar* text, const UChar* text_end, UChar* text_range)
+{
+  UChar *t, *p, *s, *end;
+
+  end = (UChar* )text_end;
+  end -= target_end - target - 1;
+  if (end > text_range)
+    end = text_range;
+
+  s = (UChar* )text;
+
+  if (enc->max_enc_len == enc->min_enc_len) {
+    int n = enc->max_enc_len;
+
+    while (s < end) {
+      if (*s == *target) {
+	p = s + 1;
+	t = target + 1;
+	if (target_end == t || memcmp(t, p, target_end - t) == 0)
+	  return s;
+      }
+      s += n;
+    }
+    return (UChar* )NULL;
+  }
+  while (s < end) {
+    if (*s == *target) {
+      p = s + 1;
+      t = target + 1;
+      if (target_end == t || memcmp(t, p, target_end - t) == 0)
+	return s;
+    }
+    s += enclen(enc, s);
+  }
+
+  return (UChar* )NULL;
+}
+
+static int
+str_lower_case_match(OnigEncoding enc, int case_fold_flag,
+                     const UChar* t, const UChar* tend,
+		     const UChar* p, const UChar* end)
+{
+  int lowlen;
+  UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
+
+  while (t < tend) {
+    lowlen = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &p, end, lowbuf);
+    q = lowbuf;
+    while (lowlen > 0) {
+      if (*t++ != *q++)	return 0;
+      lowlen--;
+    }
+  }
+
+  return 1;
+}
+
+static UChar*
+slow_search_ic(OnigEncoding enc, int case_fold_flag,
+	       UChar* target, UChar* target_end,
+	       const UChar* text, const UChar* text_end, UChar* text_range)
+{
+  UChar *s, *end;
+
+  end = (UChar* )text_end;
+  end -= target_end - target - 1;
+  if (end > text_range)
+    end = text_range;
+
+  s = (UChar* )text;
+
+  while (s < end) {
+    if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			     s, text_end))
+      return s;
+
+    s += enclen(enc, s);
+  }
+
+  return (UChar* )NULL;
+}
+
+static UChar*
+slow_search_backward(OnigEncoding enc, UChar* target, UChar* target_end,
+		     const UChar* text, const UChar* adjust_text,
+		     const UChar* text_end, const UChar* text_start)
+{
+  UChar *t, *p, *s;
+
+  s = (UChar* )text_end;
+  s -= (target_end - target);
+  if (s > text_start)
+    s = (UChar* )text_start;
+  else
+    s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, adjust_text, s);
+
+  while (s >= text) {
+    if (*s == *target) {
+      p = s + 1;
+      t = target + 1;
+      while (t < target_end) {
+	if (*t != *p++)
+	  break;
+	t++;
+      }
+      if (t == target_end)
+	return s;
+    }
+    s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s);
+  }
+
+  return (UChar* )NULL;
+}
+
+static UChar*
+slow_search_backward_ic(OnigEncoding enc, int case_fold_flag,
+			UChar* target, UChar* target_end,
+			const UChar* text, const UChar* adjust_text,
+			const UChar* text_end, const UChar* text_start)
+{
+  UChar *s;
+
+  s = (UChar* )text_end;
+  s -= (target_end - target);
+  if (s > text_start)
+    s = (UChar* )text_start;
+  else
+    s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, adjust_text, s);
+
+  while (s >= text) {
+    if (str_lower_case_match(enc, case_fold_flag,
+                             target, target_end, s, text_end))
+      return s;
+
+    s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s);
+  }
+
+  return (UChar* )NULL;
+}
+
+#ifndef USE_SUNDAY_QUICK_SEARCH
+/* Boyer-Moore-Horspool search applied to a multibyte string */
+static UChar*
+bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
+		 const UChar* text, const UChar* text_end,
+		 const UChar* text_range)
+{
+  const UChar *s, *se, *t, *p, *end;
+  const UChar *tail;
+  ptrdiff_t skip, tlen1;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "bm_search_notrev: text: %"PRIuPTR" (%p), text_end: %"PRIuPTR" (%p), text_range: %"PRIuPTR" (%p)\n",
+	  text, text, text_end, text_end, text_range, text_range);
+#endif
+
+  tail = target_end - 1;
+  tlen1 = tail - target;
+  end = text_range;
+  if (end + tlen1 > text_end)
+    end = text_end - tlen1;
+
+  s = text;
+
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      p = se = s + tlen1;
+      t = tail;
+      while (*p == *t) {
+	if (t == target) return (UChar* )s;
+	p--; t--;
+      }
+      skip = reg->map[*se];
+      t = s;
+      do {
+        s += enclen(reg->enc, s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+  else {
+    while (s < end) {
+      p = se = s + tlen1;
+      t = tail;
+      while (*p == *t) {
+	if (t == target) return (UChar* )s;
+	p--; t--;
+      }
+      skip = reg->int_map[*se];
+      t = s;
+      do {
+        s += enclen(reg->enc, s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+
+  return (UChar* )NULL;
+}
+
+/* Boyer-Moore-Horspool search */
+static UChar*
+bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
+	  const UChar* text, const UChar* text_end, const UChar* text_range)
+{
+  const UChar *s, *t, *p, *end;
+  const UChar *tail;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "bm_search: text: %"PRIuPTR", text_end: %"PRIuPTR", text_range: %"PRIuPTR"\n",
+	  text, text_end, text_range);
+#endif
+
+  end = text_range + (target_end - target) - 1;
+  if (end > text_end)
+    end = text_end;
+
+  tail = target_end - 1;
+  s = text + (target_end - target) - 1;
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      p = s;
+      t = tail;
+#ifdef ONIG_DEBUG_SEARCH
+      fprintf(stderr, "bm_search_loop: pos: %"PRIdPTR" %s\n",
+	  (intptr_t )(s - text), s);
+#endif
+      while (*p == *t) {
+	if (t == target) return (UChar* )p;
+	p--; t--;
+      }
+      s += reg->map[*s];
+    }
+  }
+  else { /* see int_map[] */
+    while (s < end) {
+      p = s;
+      t = tail;
+      while (*p == *t) {
+	if (t == target) return (UChar* )p;
+	p--; t--;
+      }
+      s += reg->int_map[*s];
+    }
+  }
+  return (UChar* )NULL;
+}
+
+/* Boyer-Moore-Horspool search applied to a multibyte string (ignore case) */
+static UChar*
+bm_search_notrev_ic(regex_t* reg, const UChar* target, const UChar* target_end,
+		    const UChar* text, const UChar* text_end,
+		    const UChar* text_range)
+{
+  const UChar *s, *se, *t, *end;
+  const UChar *tail;
+  ptrdiff_t skip, tlen1;
+  OnigEncoding enc = reg->enc;
+  int case_fold_flag = reg->case_fold_flag;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "bm_search_notrev_ic: text: %d (%p), text_end: %d (%p), text_range: %d (%p)\n",
+	  (int )text, text, (int )text_end, text_end, (int )text_range, text_range);
+#endif
+
+  tail = target_end - 1;
+  tlen1 = tail - target;
+  end = text_range;
+  if (end + tlen1 > text_end)
+    end = text_end - tlen1;
+
+  s = text;
+
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      se = s + tlen1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       s, se + 1))
+	return (UChar* )s;
+      skip = reg->map[*se];
+      t = s;
+      do {
+        s += enclen(reg->enc, s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+  else {
+    while (s < end) {
+      se = s + tlen1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       s, se + 1))
+	return (UChar* )s;
+      skip = reg->int_map[*se];
+      t = s;
+      do {
+        s += enclen(reg->enc, s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+
+  return (UChar* )NULL;
+}
+
+/* Boyer-Moore-Horspool search (ignore case) */
+static UChar*
+bm_search_ic(regex_t* reg, const UChar* target, const UChar* target_end,
+	     const UChar* text, const UChar* text_end, const UChar* text_range)
+{
+  const UChar *s, *p, *end;
+  const UChar *tail;
+  OnigEncoding enc = reg->enc;
+  int case_fold_flag = reg->case_fold_flag;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "bm_search_ic: text: %d (%p), text_end: %d (%p), text_range: %d (%p)\n",
+	  (int )text, text, (int )text_end, text_end, (int )text_range, text_range);
+#endif
+
+  end = text_range + (target_end - target) - 1;
+  if (end > text_end)
+    end = text_end;
+
+  tail = target_end - 1;
+  s = text + (target_end - target) - 1;
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      p = s - (target_end - target) + 1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       p, s + 1))
+	return (UChar* )p;
+      s += reg->map[*s];
+    }
+  }
+  else { /* see int_map[] */
+    while (s < end) {
+      p = s - (target_end - target) + 1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       p, s + 1))
+	return (UChar* )p;
+      s += reg->int_map[*s];
+    }
+  }
+  return (UChar* )NULL;
+}
+
+#else /* USE_SUNDAY_QUICK_SEARCH */
+
+/* Sunday's quick search applied to a multibyte string */
+static UChar*
+bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
+		 const UChar* text, const UChar* text_end,
+		 const UChar* text_range)
+{
+  const UChar *s, *se, *t, *p, *end;
+  const UChar *tail;
+  ptrdiff_t skip, tlen1;
+  OnigEncoding enc = reg->enc;
+  int (*mbc_enc_len)(const OnigUChar* p) = enc->mbc_enc_len;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "bm_search_notrev: text: %"PRIdPTR" (%p), text_end: %"PRIdPTR" (%p), text_range: %"PRIdPTR" (%p)\n",
+	  (intptr_t )text, text, (intptr_t )text_end, text_end, (intptr_t )text_range, text_range);
+#endif
+
+  tail = target_end - 1;
+  tlen1 = tail - target;
+  end = text_range;
+  if (end + tlen1 > text_end)
+    end = text_end - tlen1;
+
+  s = text;
+
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      p = se = s + tlen1;
+      t = tail;
+      while (*p == *t) {
+	if (t == target) return (UChar* )s;
+	p--; t--;
+      }
+      if (s + 1 >= end) break;
+      skip = reg->map[se[1]];
+      t = s;
+      do {
+        s += mbc_enc_len(s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+  else {
+    while (s < end) {
+      p = se = s + tlen1;
+      t = tail;
+      while (*p == *t) {
+	if (t == target) return (UChar* )s;
+	p--; t--;
+      }
+      if (s + 1 >= end) break;
+      skip = reg->int_map[se[1]];
+      t = s;
+      do {
+        s += mbc_enc_len(s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+
+  return (UChar* )NULL;
+}
+
+/* Sunday's quick search */
+static UChar*
+bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
+	  const UChar* text, const UChar* text_end, const UChar* text_range)
+{
+  const UChar *s, *t, *p, *end;
+  const UChar *tail;
+  ptrdiff_t tlen1;
+
+  tail = target_end - 1;
+  tlen1 = tail - target;
+  end = text_range + tlen1;
+  if (end > text_end)
+    end = text_end;
+
+  s = text + tlen1;
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      p = s;
+      t = tail;
+      while (*p == *t) {
+	if (t == target) return (UChar* )p;
+	p--; t--;
+      }
+      if (s + 1 >= end) break;
+      s += reg->map[s[1]];
+    }
+  }
+  else { /* see int_map[] */
+    while (s < end) {
+      p = s;
+      t = tail;
+      while (*p == *t) {
+	if (t == target) return (UChar* )p;
+	p--; t--;
+      }
+      if (s + 1 >= end) break;
+      s += reg->int_map[s[1]];
+    }
+  }
+  return (UChar* )NULL;
+}
+
+/* Sunday's quick search applied to a multibyte string (ignore case) */
+static UChar*
+bm_search_notrev_ic(regex_t* reg, const UChar* target, const UChar* target_end,
+		    const UChar* text, const UChar* text_end,
+		    const UChar* text_range)
+{
+  const UChar *s, *se, *t, *end;
+  const UChar *tail;
+  ptrdiff_t skip, tlen1;
+  OnigEncoding enc = reg->enc;
+  int (*mbc_enc_len)(const OnigUChar* p) = enc->mbc_enc_len;
+  int case_fold_flag = reg->case_fold_flag;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "bm_search_notrev_ic: text: %"PRIdPTR" (%p), text_end: %"PRIdPTR" (%p), text_range: %"PRIdPTR" (%p)\n",
+	  (intptr_t )text, text, (intptr_t )text_end, text_end, (intptr_t )text_range, text_range);
+#endif
+
+  tail = target_end - 1;
+  tlen1 = tail - target;
+  end = text_range;
+  if (end + tlen1 > text_end)
+    end = text_end - tlen1;
+
+  s = text;
+
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      se = s + tlen1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       s, se + 1))
+	return (UChar* )s;
+      if (s + 1 >= end) break;
+      skip = reg->map[se[1]];
+      t = s;
+      do {
+        s += mbc_enc_len(s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+  else {
+    while (s < end) {
+      se = s + tlen1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       s, se + 1))
+	return (UChar* )s;
+      if (s + 1 >= end) break;
+      skip = reg->int_map[se[1]];
+      t = s;
+      do {
+        s += mbc_enc_len(s);
+      } while ((s - t) < skip && s < end);
+    }
+  }
+
+  return (UChar* )NULL;
+}
+
+/* Sunday's quick search (ignore case) */
+static UChar*
+bm_search_ic(regex_t* reg, const UChar* target, const UChar* target_end,
+	     const UChar* text, const UChar* text_end, const UChar* text_range)
+{
+  const UChar *s, *p, *end;
+  const UChar *tail;
+  ptrdiff_t tlen1;
+  OnigEncoding enc = reg->enc;
+  int case_fold_flag = reg->case_fold_flag;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "bm_search_ic: text: %"PRIdPTR" (%p), text_end: %"PRIdPTR" (%p), text_range: %"PRIdPTR" (%p)\n",
+	  (intptr_t )text, text, (intptr_t )text_end, text_end, (intptr_t )text_range, text_range);
+#endif
+
+  tail = target_end - 1;
+  tlen1 = tail - target;
+  end = text_range + tlen1;
+  if (end > text_end)
+    end = text_end;
+
+  s = text + tlen1;
+  if (IS_NULL(reg->int_map)) {
+    while (s < end) {
+      p = s - tlen1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       p, s + 1))
+	return (UChar* )p;
+      if (s + 1 >= end) break;
+      s += reg->map[s[1]];
+    }
+  }
+  else { /* see int_map[] */
+    while (s < end) {
+      p = s - tlen1;
+      if (str_lower_case_match(enc, case_fold_flag, target, target_end,
+			       p, s + 1))
+	return (UChar* )p;
+      if (s + 1 >= end) break;
+      s += reg->int_map[s[1]];
+    }
+  }
+  return (UChar* )NULL;
+}
+#endif /* USE_SUNDAY_QUICK_SEARCH */
+
+static int
+set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
+		     int** skip)
+{
+  int i, len;
+
+  if (IS_NULL(*skip)) {
+    *skip = (int* )xmalloc(sizeof(int) * ONIG_CHAR_TABLE_SIZE);
+    if (IS_NULL(*skip)) return ONIGERR_MEMORY;
+  }
+
+  len = (int )(end - s);
+  for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
+    (*skip)[i] = len;
+
+  for (i = len - 1; i > 0; i--)
+    (*skip)[s[i]] = i;
+
+  return 0;
+}
+
+static UChar*
+bm_search_backward(regex_t* reg, const UChar* target, const UChar* target_end,
+		   const UChar* text, const UChar* adjust_text,
+		   const UChar* text_end, const UChar* text_start)
+{
+  const UChar *s, *t, *p;
+
+  s = text_end - (target_end - target);
+  if (text_start < s)
+    s = text_start;
+  else
+    s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s);
+
+  while (s >= text) {
+    p = s;
+    t = target;
+    while (t < target_end && *p == *t) {
+      p++; t++;
+    }
+    if (t == target_end)
+      return (UChar* )s;
+
+    s -= reg->int_map_backward[*s];
+    s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s);
+  }
+
+  return (UChar* )NULL;
+}
+
+static UChar*
+map_search(OnigEncoding enc, UChar map[],
+	   const UChar* text, const UChar* text_range)
+{
+  const UChar *s = text;
+
+  while (s < text_range) {
+    if (map[*s]) return (UChar* )s;
+
+    s += enclen(enc, s);
+  }
+  return (UChar* )NULL;
+}
+
+static UChar*
+map_search_backward(OnigEncoding enc, UChar map[],
+		    const UChar* text, const UChar* adjust_text,
+		    const UChar* text_start)
+{
+  const UChar *s = text_start;
+
+  while (s >= text) {
+    if (map[*s]) return (UChar* )s;
+
+    s = onigenc_get_prev_char_head(enc, adjust_text, s);
+  }
+  return (UChar* )NULL;
+}
+
+extern OnigPosition
+onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, OnigRegion* region,
+	    OnigOptionType option)
+{
+  ptrdiff_t r;
+  UChar *prev;
+  OnigMatchArg msa;
+
+#if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
+ start:
+  THREAD_ATOMIC_START;
+  if (ONIG_STATE(reg) >= ONIG_STATE_NORMAL) {
+    ONIG_STATE_INC(reg);
+    if (IS_NOT_NULL(reg->chain) && ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
+      onig_chain_reduce(reg);
+      ONIG_STATE_INC(reg);
+    }
+  }
+  else {
+    int n;
+
+    THREAD_ATOMIC_END;
+    n = 0;
+    while (ONIG_STATE(reg) < ONIG_STATE_NORMAL) {
+      if (++n > THREAD_PASS_LIMIT_COUNT)
+	return ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT;
+      THREAD_PASS;
+    }
+    goto start;
+  }
+  THREAD_ATOMIC_END;
+#endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
+
+  MATCH_ARG_INIT(msa, option, region, at, at);
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  {
+    int offset = at - str;
+    STATE_CHECK_BUFF_INIT(msa, end - str, offset, reg->num_comb_exp_check);
+  }
+#endif
+
+  if (region
+#ifdef USE_POSIX_API_REGION_OPTION
+      && !IS_POSIX_REGION(option)
+#endif
+      ) {
+    r = onig_region_resize_clear(region, reg->num_mem + 1);
+  }
+  else
+    r = 0;
+
+  if (r == 0) {
+    prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at);
+    r = match_at(reg, str, end,
+#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+		 end,
+#endif
+		 at, prev, &msa);
+  }
+
+  MATCH_ARG_FREE(msa);
+  ONIG_STATE_DEC_THREAD(reg);
+  return r;
+}
+
+static int
+forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
+		     UChar* range, UChar** low, UChar** high, UChar** low_prev)
+{
+  UChar *p, *pprev = (UChar* )NULL;
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "forward_search_range: str: %"PRIuPTR" (%p), end: %"PRIuPTR" (%p), s: %"PRIuPTR" (%p), range: %"PRIuPTR" (%p)\n",
+	  (intptr_t )str, str, (intptr_t )end, end, (intptr_t )s, s, (intptr_t )range, range);
+#endif
+
+  p = s;
+  if (reg->dmin > 0) {
+    if (ONIGENC_IS_SINGLEBYTE(reg->enc)) {
+      p += reg->dmin;
+    }
+    else {
+      UChar *q = p + reg->dmin;
+      while (p < q) p += enclen(reg->enc, p);
+    }
+  }
+
+ retry:
+  switch (reg->optimize) {
+  case ONIG_OPTIMIZE_EXACT:
+    p = slow_search(reg->enc, reg->exact, reg->exact_end, p, end, range);
+    break;
+  case ONIG_OPTIMIZE_EXACT_IC:
+    p = slow_search_ic(reg->enc, reg->case_fold_flag,
+                       reg->exact, reg->exact_end, p, end, range);
+    break;
+
+  case ONIG_OPTIMIZE_EXACT_BM:
+    p = bm_search(reg, reg->exact, reg->exact_end, p, end, range);
+    break;
+
+  case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:
+    p = bm_search_notrev(reg, reg->exact, reg->exact_end, p, end, range);
+    break;
+
+  case ONIG_OPTIMIZE_EXACT_BM_IC:
+    p = bm_search_ic(reg, reg->exact, reg->exact_end, p, end, range);
+    break;
+
+  case ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC:
+    p = bm_search_notrev_ic(reg, reg->exact, reg->exact_end, p, end, range);
+    break;
+
+  case ONIG_OPTIMIZE_MAP:
+    p = map_search(reg->enc, reg->map, p, range);
+    break;
+  }
+
+  if (p && p < range) {
+    if (p - reg->dmin < s) {
+    retry_gate:
+      pprev = p;
+      p += enclen(reg->enc, p);
+      goto retry;
+    }
+
+    if (reg->sub_anchor) {
+      UChar* prev;
+
+      switch (reg->sub_anchor) {
+      case ANCHOR_BEGIN_LINE:
+	if (!ON_STR_BEGIN(p)) {
+	  prev = onigenc_get_prev_char_head(reg->enc,
+					    (pprev ? pprev : str), p);
+	  if (!ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, prev, str, end, reg->options, 0))
+	    goto retry_gate;
+	}
+	break;
+
+      case ANCHOR_END_LINE:
+	if (ON_STR_END(p)) {
+#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
+	  prev = (UChar* )onigenc_get_prev_char_head(reg->enc,
+					    (pprev ? pprev : str), p);
+	  if (prev && ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, prev, str, end, reg->options, 1))
+	    goto retry_gate;
+#endif
+	}
+	else if (! ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, p, str, end, reg->options, 1))
+	  goto retry_gate;
+	break;
+      }
+    }
+
+    if (reg->dmax == 0) {
+      *low = p;
+      if (low_prev) {
+	if (*low > s)
+	  *low_prev = onigenc_get_prev_char_head(reg->enc, s, p);
+	else
+	  *low_prev = onigenc_get_prev_char_head(reg->enc,
+						 (pprev ? pprev : str), p);
+      }
+    }
+    else {
+      if (reg->dmax != ONIG_INFINITE_DISTANCE) {
+	*low = p - reg->dmax;
+	if (*low > s) {
+	  *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s,
+							      *low, (const UChar** )low_prev);
+	  if (low_prev && IS_NULL(*low_prev))
+	    *low_prev = onigenc_get_prev_char_head(reg->enc,
+						   (pprev ? pprev : s), *low);
+	}
+	else {
+	  if (low_prev)
+	    *low_prev = onigenc_get_prev_char_head(reg->enc,
+					       (pprev ? pprev : str), *low);
+	}
+      }
+    }
+    /* no needs to adjust *high, *high is used as range check only */
+    *high = p - reg->dmin;
+
+#ifdef ONIG_DEBUG_SEARCH
+    fprintf(stderr,
+    "forward_search_range success: low: %"PRIdPTR", high: %"PRIdPTR", dmin: %"PRIdPTR", dmax: %"PRIdPTR"\n",
+	    *low - str, *high - str, reg->dmin, reg->dmax);
+#endif
+    return 1; /* success */
+  }
+
+  return 0; /* fail */
+}
+
+#define BM_BACKWARD_SEARCH_LENGTH_THRESHOLD   100
+
+static int
+backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
+		      UChar* s, const UChar* range, UChar* adjrange,
+		      UChar** low, UChar** high)
+{
+  int r;
+  UChar *p;
+
+  range += reg->dmin;
+  p = s;
+
+ retry:
+  switch (reg->optimize) {
+  case ONIG_OPTIMIZE_EXACT:
+  exact_method:
+    p = slow_search_backward(reg->enc, reg->exact, reg->exact_end,
+			     range, adjrange, end, p);
+    break;
+
+  case ONIG_OPTIMIZE_EXACT_IC:
+  case ONIG_OPTIMIZE_EXACT_BM_IC:
+  case ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC:
+    p = slow_search_backward_ic(reg->enc, reg->case_fold_flag,
+                                reg->exact, reg->exact_end,
+                                range, adjrange, end, p);
+    break;
+
+  case ONIG_OPTIMIZE_EXACT_BM:
+  case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:
+    if (IS_NULL(reg->int_map_backward)) {
+      if (s - range < BM_BACKWARD_SEARCH_LENGTH_THRESHOLD)
+	goto exact_method;
+
+      r = set_bm_backward_skip(reg->exact, reg->exact_end, reg->enc,
+			       &(reg->int_map_backward));
+      if (r) return r;
+    }
+    p = bm_search_backward(reg, reg->exact, reg->exact_end, range, adjrange,
+			   end, p);
+    break;
+
+  case ONIG_OPTIMIZE_MAP:
+    p = map_search_backward(reg->enc, reg->map, range, adjrange, p);
+    break;
+  }
+
+  if (p) {
+    if (reg->sub_anchor) {
+      UChar* prev;
+
+      switch (reg->sub_anchor) {
+      case ANCHOR_BEGIN_LINE:
+	if (!ON_STR_BEGIN(p)) {
+	  prev = onigenc_get_prev_char_head(reg->enc, str, p);
+	  if (!ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, prev, str, end, reg->options, 0)) {
+	    p = prev;
+	    goto retry;
+	  }
+	}
+	break;
+
+      case ANCHOR_END_LINE:
+	if (ON_STR_END(p)) {
+#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
+	  prev = onigenc_get_prev_char_head(reg->enc, adjrange, p);
+	  if (IS_NULL(prev)) goto fail;
+	  if (ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, prev, str, end, reg->options, 1)) {
+	    p = prev;
+	    goto retry;
+	  }
+#endif
+	}
+	else if (! ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, p, str, end, reg->options, 1)) {
+	  p = onigenc_get_prev_char_head(reg->enc, adjrange, p);
+	  if (IS_NULL(p)) goto fail;
+	  goto retry;
+	}
+	break;
+      }
+    }
+
+    /* no needs to adjust *high, *high is used as range check only */
+    if (reg->dmax != ONIG_INFINITE_DISTANCE) {
+      *low  = p - reg->dmax;
+      *high = p - reg->dmin;
+      *high = onigenc_get_right_adjust_char_head(reg->enc, adjrange, *high);
+    }
+
+#ifdef ONIG_DEBUG_SEARCH
+    fprintf(stderr, "backward_search_range: low: %d, high: %d\n",
+	    (int )(*low - str), (int )(*high - str));
+#endif
+    return 1; /* success */
+  }
+
+ fail:
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "backward_search_range: fail.\n");
+#endif
+  return 0; /* fail */
+}
+
+
+extern OnigPosition
+onig_search(regex_t* reg, const UChar* str, const UChar* end,
+	    const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option)
+{
+  return onig_search_gpos(reg, str, end, start, start, range, region, option);
+}
+
+extern OnigPosition
+onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end,
+	    const UChar* global_pos,
+	    const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option)
+{
+  ptrdiff_t r;
+  UChar *s, *prev;
+  OnigMatchArg msa;
+#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+  const UChar *orig_start = start;
+  const UChar *orig_range = range;
+#endif
+
+#if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
+ start:
+  THREAD_ATOMIC_START;
+  if (ONIG_STATE(reg) >= ONIG_STATE_NORMAL) {
+    ONIG_STATE_INC(reg);
+    if (IS_NOT_NULL(reg->chain) && ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
+      onig_chain_reduce(reg);
+      ONIG_STATE_INC(reg);
+    }
+  }
+  else {
+    int n;
+
+    THREAD_ATOMIC_END;
+    n = 0;
+    while (ONIG_STATE(reg) < ONIG_STATE_NORMAL) {
+      if (++n > THREAD_PASS_LIMIT_COUNT)
+	return ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT;
+      THREAD_PASS;
+    }
+    goto start;
+  }
+  THREAD_ATOMIC_END;
+#endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr,
+     "onig_search (entry point): str: %"PRIuPTR" (%p), end: %"PRIuPTR", start: %"PRIuPTR", range: %"PRIuPTR"\n",
+     (intptr_t )str, str, end - str, start - str, range - str);
+#endif
+
+  if (region
+#ifdef USE_POSIX_API_REGION_OPTION
+      && !IS_POSIX_REGION(option)
+#endif
+      ) {
+    r = onig_region_resize_clear(region, reg->num_mem + 1);
+    if (r) goto finish_no_msa;
+  }
+
+  if (start > end || start < str) goto mismatch_no_msa;
+
+
+#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+#define MATCH_AND_RETURN_CHECK(upper_range) \
+  r = match_at(reg, str, end, (upper_range), s, prev, &msa); \
+  if (r != ONIG_MISMATCH) {\
+    if (r >= 0) {\
+      if (! IS_FIND_LONGEST(reg->options)) {\
+        goto match;\
+      }\
+    }\
+    else goto finish; /* error */ \
+  }
+#else
+#define MATCH_AND_RETURN_CHECK(upper_range) \
+  r = match_at(reg, str, end, (upper_range), s, prev, &msa); \
+  if (r != ONIG_MISMATCH) {\
+    if (r >= 0) {\
+      goto match;\
+    }\
+    else goto finish; /* error */ \
+  }
+#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */
+#else
+#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+#define MATCH_AND_RETURN_CHECK(none) \
+  r = match_at(reg, str, end, s, prev, &msa);\
+  if (r != ONIG_MISMATCH) {\
+    if (r >= 0) {\
+      if (! IS_FIND_LONGEST(reg->options)) {\
+        goto match;\
+      }\
+    }\
+    else goto finish; /* error */ \
+  }
+#else
+#define MATCH_AND_RETURN_CHECK(none) \
+  r = match_at(reg, str, end, s, prev, &msa);\
+  if (r != ONIG_MISMATCH) {\
+    if (r >= 0) {\
+      goto match;\
+    }\
+    else goto finish; /* error */ \
+  }
+#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */
+#endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
+
+
+  /* anchor optimize: resume search range */
+  if (reg->anchor != 0 && str < end) {
+    UChar *min_semi_end, *max_semi_end;
+
+    if (reg->anchor & ANCHOR_BEGIN_POSITION) {
+      /* search start-position only */
+    begin_position:
+      if (range > start)
+	range = start + 1;
+      else
+	range = start;
+    }
+    else if (reg->anchor & ANCHOR_BEGIN_BUF) {
+      /* search str-position only */
+      if (range > start) {
+	if (start != str) goto mismatch_no_msa;
+	range = str + 1;
+      }
+      else {
+	if (range <= str) {
+	  start = str;
+	  range = str;
+	}
+	else
+	  goto mismatch_no_msa;
+      }
+    }
+    else if (reg->anchor & ANCHOR_END_BUF) {
+      min_semi_end = max_semi_end = (UChar* )end;
+
+    end_buf:
+      if ((OnigDistance )(max_semi_end - str) < reg->anchor_dmin)
+	goto mismatch_no_msa;
+
+      if (range > start) {
+	if ((OnigDistance )(min_semi_end - start) > reg->anchor_dmax) {
+	  start = min_semi_end - reg->anchor_dmax;
+	  if (start < end)
+	    start = onigenc_get_right_adjust_char_head(reg->enc, str, start);
+	}
+	if ((OnigDistance )(max_semi_end - (range - 1)) < reg->anchor_dmin) {
+	  range = max_semi_end - reg->anchor_dmin + 1;
+	}
+
+	if (start > range) goto mismatch_no_msa;
+	/* If start == range, match with empty at end.
+	   Backward search is used. */
+      }
+      else {
+	if ((OnigDistance )(min_semi_end - range) > reg->anchor_dmax) {
+	  range = min_semi_end - reg->anchor_dmax;
+	}
+	if ((OnigDistance )(max_semi_end - start) < reg->anchor_dmin) {
+	  start = max_semi_end - reg->anchor_dmin;
+	  start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, start);
+	}
+	if (range > start) goto mismatch_no_msa;
+      }
+    }
+    else if (reg->anchor & ANCHOR_SEMI_END_BUF) {
+      UChar* pre_end = ONIGENC_STEP_BACK(reg->enc, str, end, 1);
+
+      max_semi_end = (UChar* )end;
+      if (ONIGENC_IS_MBC_NEWLINE(reg->enc, pre_end, end)) {
+	min_semi_end = pre_end;
+
+#ifdef USE_CRNL_AS_LINE_TERMINATOR
+	pre_end = ONIGENC_STEP_BACK(reg->enc, str, pre_end, 1);
+	if (IS_NOT_NULL(pre_end) &&
+	    IS_NEWLINE_CRLF(reg->options) &&
+	    ONIGENC_IS_MBC_CRNL(reg->enc, pre_end, end)) {
+	  min_semi_end = pre_end;
+	}
+#endif
+	if (min_semi_end > str && start <= min_semi_end) {
+	  goto end_buf;
+	}
+      }
+      else {
+	min_semi_end = (UChar* )end;
+	goto end_buf;
+      }
+    }
+    else if ((reg->anchor & ANCHOR_ANYCHAR_STAR_ML)) {
+      if (! (reg->anchor & ANCHOR_LOOK_BEHIND)) {
+	goto begin_position;
+      }
+    }
+  }
+  else if (str == end) { /* empty string */
+    static const UChar address_for_empty_string[] = "";
+
+#ifdef ONIG_DEBUG_SEARCH
+    fprintf(stderr, "onig_search: empty string.\n");
+#endif
+
+    if (reg->threshold_len == 0) {
+      start = end = str = address_for_empty_string;
+      s = (UChar* )start;
+      prev = (UChar* )NULL;
+
+      MATCH_ARG_INIT(msa, option, region, start, start);
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+      msa.state_check_buff = (void* )0;
+      msa.state_check_buff_size = 0;   /* NO NEED, for valgrind */
+#endif
+      MATCH_AND_RETURN_CHECK(end);
+      goto mismatch;
+    }
+    goto mismatch_no_msa;
+  }
+
+#ifdef ONIG_DEBUG_SEARCH
+  fprintf(stderr, "onig_search(apply anchor): end: %d, start: %d, range: %d\n",
+	  (int )(end - str), (int )(start - str), (int )(range - str));
+#endif
+
+  MATCH_ARG_INIT(msa, option, region, start, global_pos);
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  {
+    int offset = (MIN(start, range) - str);
+    STATE_CHECK_BUFF_INIT(msa, end - str, offset, reg->num_comb_exp_check);
+  }
+#endif
+
+  s = (UChar* )start;
+  if (range > start) {   /* forward search */
+    if (s > str)
+      prev = onigenc_get_prev_char_head(reg->enc, str, s);
+    else
+      prev = (UChar* )NULL;
+
+    if (reg->optimize != ONIG_OPTIMIZE_NONE) {
+      UChar *sch_range, *low, *high, *low_prev;
+
+      sch_range = (UChar* )range;
+      if (reg->dmax != 0) {
+	if (reg->dmax == ONIG_INFINITE_DISTANCE)
+	  sch_range = (UChar* )end;
+	else {
+	  sch_range += reg->dmax;
+	  if (sch_range > end) sch_range = (UChar* )end;
+	}
+      }
+
+      if ((end - start) < reg->threshold_len)
+        goto mismatch;
+
+      if (reg->dmax != ONIG_INFINITE_DISTANCE) {
+	do {
+	  if (! forward_search_range(reg, str, end, s, sch_range,
+				     &low, &high, &low_prev)) goto mismatch;
+	  if (s < low) {
+	    s    = low;
+	    prev = low_prev;
+	  }
+	  while (s <= high) {
+	    MATCH_AND_RETURN_CHECK(orig_range);
+	    prev = s;
+	    s += enclen(reg->enc, s);
+	  }
+	} while (s < range);
+	goto mismatch;
+      }
+      else { /* check only. */
+	if (! forward_search_range(reg, str, end, s, sch_range,
+				   &low, &high, (UChar** )NULL)) goto mismatch;
+
+        if ((reg->anchor & ANCHOR_ANYCHAR_STAR) != 0) {
+          do {
+            if ((reg->anchor & ANCHOR_BEGIN_POSITION) == 0)
+              msa.gpos = s;     /* move \G position */
+            MATCH_AND_RETURN_CHECK(orig_range);
+            prev = s;
+            s += enclen(reg->enc, s);
+
+            if ((reg->anchor & (ANCHOR_LOOK_BEHIND | ANCHOR_PREC_READ_NOT)) == 0) {
+              while (!ONIGENC_IS_MBC_NEWLINE_EX(reg->enc, prev, str, end, reg->options, 0)
+                     && s < range) {
+                prev = s;
+                s += enclen(reg->enc, s);
+              }
+            }
+          } while (s < range);
+          goto mismatch;
+        }
+      }
+    }
+
+    do {
+      MATCH_AND_RETURN_CHECK(orig_range);
+      prev = s;
+      s += enclen(reg->enc, s);
+    } while (s < range);
+
+    if (s == range) { /* because empty match with /$/. */
+      MATCH_AND_RETURN_CHECK(orig_range);
+    }
+  }
+  else {  /* backward search */
+    if (reg->optimize != ONIG_OPTIMIZE_NONE) {
+      UChar *low, *high, *adjrange, *sch_start;
+
+      if (range < end)
+	adjrange = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, range);
+      else
+	adjrange = (UChar* )end;
+
+      if (reg->dmax != ONIG_INFINITE_DISTANCE &&
+	  (end - range) >= reg->threshold_len) {
+	do {
+	  sch_start = s + reg->dmax;
+	  if (sch_start > end) sch_start = (UChar* )end;
+	  if (backward_search_range(reg, str, end, sch_start, range, adjrange,
+				    &low, &high) <= 0)
+	    goto mismatch;
+
+	  if (s > high)
+	    s = high;
+
+	  while (s >= low) {
+	    prev = onigenc_get_prev_char_head(reg->enc, str, s);
+	    MATCH_AND_RETURN_CHECK(orig_start);
+	    s = prev;
+	  }
+	} while (s >= range);
+	goto mismatch;
+      }
+      else { /* check only. */
+	if ((end - range) < reg->threshold_len) goto mismatch;
+
+	sch_start = s;
+	if (reg->dmax != 0) {
+	  if (reg->dmax == ONIG_INFINITE_DISTANCE)
+	    sch_start = (UChar* )end;
+	  else {
+	    sch_start += reg->dmax;
+	    if (sch_start > end) sch_start = (UChar* )end;
+	    else
+	      sch_start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc,
+						    start, sch_start);
+	  }
+	}
+	if (backward_search_range(reg, str, end, sch_start, range, adjrange,
+				  &low, &high) <= 0) goto mismatch;
+      }
+    }
+
+    do {
+      prev = onigenc_get_prev_char_head(reg->enc, str, s);
+      MATCH_AND_RETURN_CHECK(orig_start);
+      s = prev;
+    } while (s >= range);
+  }
+
+ mismatch:
+#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+  if (IS_FIND_LONGEST(reg->options)) {
+    if (msa.best_len >= 0) {
+      s = msa.best_s;
+      goto match;
+    }
+  }
+#endif
+  r = ONIG_MISMATCH;
+
+ finish:
+  MATCH_ARG_FREE(msa);
+  ONIG_STATE_DEC_THREAD(reg);
+
+  /* If result is mismatch and no FIND_NOT_EMPTY option,
+     then the region is not set in match_at(). */
+  if (IS_FIND_NOT_EMPTY(reg->options) && region
+#ifdef USE_POSIX_API_REGION_OPTION
+      && !IS_POSIX_REGION(option)
+#endif
+      ) {
+    onig_region_clear(region);
+  }
+
+#ifdef ONIG_DEBUG
+  if (r != ONIG_MISMATCH)
+    fprintf(stderr, "onig_search: error %"PRIdPTR"\n", r);
+#endif
+  return r;
+
+ mismatch_no_msa:
+  r = ONIG_MISMATCH;
+ finish_no_msa:
+  ONIG_STATE_DEC_THREAD(reg);
+#ifdef ONIG_DEBUG
+  if (r != ONIG_MISMATCH)
+    fprintf(stderr, "onig_search: error %"PRIdPTR"\n", r);
+#endif
+  return r;
+
+ match:
+  ONIG_STATE_DEC_THREAD(reg);
+  MATCH_ARG_FREE(msa);
+  return s - str;
+}
+
+extern OnigEncoding
+onig_get_encoding(regex_t* reg)
+{
+  return reg->enc;
+}
+
+extern OnigOptionType
+onig_get_options(regex_t* reg)
+{
+  return reg->options;
+}
+
+extern  OnigCaseFoldType
+onig_get_case_fold_flag(regex_t* reg)
+{
+  return reg->case_fold_flag;
+}
+
+extern OnigSyntaxType*
+onig_get_syntax(regex_t* reg)
+{
+  return reg->syntax;
+}
+
+extern int
+onig_number_of_captures(regex_t* reg)
+{
+  return reg->num_mem;
+}
+
+extern int
+onig_number_of_capture_histories(regex_t* reg)
+{
+#ifdef USE_CAPTURE_HISTORY
+  int i, n;
+
+  n = 0;
+  for (i = 0; i <= ONIG_MAX_CAPTURE_HISTORY_GROUP; i++) {
+    if (BIT_STATUS_AT(reg->capture_history, i) != 0)
+      n++;
+  }
+  return n;
+#else
+  return 0;
+#endif
+}
+
+extern void
+onig_copy_encoding(OnigEncoding to, OnigEncoding from)
+{
+  *to = *from;
+}
+
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regext.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regext.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regext.c	(revision 279)
@@ -0,0 +1,223 @@
+/**********************************************************************
+  regext.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+static void
+conv_ext0be32(const UChar* s, const UChar* end, UChar* conv)
+{
+  while (s < end) {
+    *conv++ = '\0';
+    *conv++ = '\0';
+    *conv++ = '\0';
+    *conv++ = *s++;
+  }
+}
+
+static void
+conv_ext0le32(const UChar* s, const UChar* end, UChar* conv)
+{
+  while (s < end) {
+    *conv++ = *s++;
+    *conv++ = '\0';
+    *conv++ = '\0';
+    *conv++ = '\0';
+  }
+}
+
+static void
+conv_ext0be(const UChar* s, const UChar* end, UChar* conv)
+{
+  while (s < end) {
+    *conv++ = '\0';
+    *conv++ = *s++;
+  }
+}
+
+static void
+conv_ext0le(const UChar* s, const UChar* end, UChar* conv)
+{
+  while (s < end) {
+    *conv++ = *s++;
+    *conv++ = '\0';
+  }
+}
+
+static void
+conv_swap4bytes(const UChar* s, const UChar* end, UChar* conv)
+{
+  while (s < end) {
+    *conv++ = s[3];
+    *conv++ = s[2];
+    *conv++ = s[1];
+    *conv++ = s[0];
+    s += 4;
+  }
+}
+
+static void
+conv_swap2bytes(const UChar* s, const UChar* end, UChar* conv)
+{
+  while (s < end) {
+    *conv++ = s[1];
+    *conv++ = s[0];
+    s += 2;
+  }
+}
+
+static int
+conv_encoding(OnigEncoding from, OnigEncoding to, const UChar* s, const UChar* end,
+              UChar** conv, UChar** conv_end)
+{
+  ptrdiff_t len = end - s;
+
+  if (to == ONIG_ENCODING_UTF16_BE) {
+    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
+      *conv = (UChar* )xmalloc(len * 2);
+      CHECK_NULL_RETURN_MEMERR(*conv);
+      *conv_end = *conv + (len * 2);
+      conv_ext0be(s, end, *conv);
+      return 0;
+    }
+    else if (from == ONIG_ENCODING_UTF16_LE) {
+    swap16:
+      *conv = (UChar* )xmalloc(len);
+      CHECK_NULL_RETURN_MEMERR(*conv);
+      *conv_end = *conv + len;
+      conv_swap2bytes(s, end, *conv);
+      return 0;
+    }
+  }
+  else if (to == ONIG_ENCODING_UTF16_LE) {
+    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
+      *conv = (UChar* )xmalloc(len * 2);
+      CHECK_NULL_RETURN_MEMERR(*conv);
+      *conv_end = *conv + (len * 2);
+      conv_ext0le(s, end, *conv);
+      return 0;
+    }
+    else if (from == ONIG_ENCODING_UTF16_BE) {
+      goto swap16;
+    }
+  }
+  if (to == ONIG_ENCODING_UTF32_BE) {
+    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
+      *conv = (UChar* )xmalloc(len * 4);
+      CHECK_NULL_RETURN_MEMERR(*conv);
+      *conv_end = *conv + (len * 4);
+      conv_ext0be32(s, end, *conv);
+      return 0;
+    }
+    else if (from == ONIG_ENCODING_UTF32_LE) {
+    swap32:
+      *conv = (UChar* )xmalloc(len);
+      CHECK_NULL_RETURN_MEMERR(*conv);
+      *conv_end = *conv + len;
+      conv_swap4bytes(s, end, *conv);
+      return 0;
+    }
+  }
+  else if (to == ONIG_ENCODING_UTF32_LE) {
+    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
+      *conv = (UChar* )xmalloc(len * 4);
+      CHECK_NULL_RETURN_MEMERR(*conv);
+      *conv_end = *conv + (len * 4);
+      conv_ext0le32(s, end, *conv);
+      return 0;
+    }
+    else if (from == ONIG_ENCODING_UTF32_BE) {
+      goto swap32;
+    }
+  }
+
+  return ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION;
+}
+
+extern int
+onig_new_deluxe(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
+                OnigCompileInfo* ci, OnigErrorInfo* einfo)
+{
+  int r;
+  UChar *cpat, *cpat_end;
+
+  if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;
+
+  if (ci->pattern_enc != ci->target_enc) {
+    r = conv_encoding(ci->pattern_enc, ci->target_enc, pattern, pattern_end,
+                      &cpat, &cpat_end);
+    if (r) return r;
+  }
+  else {
+    cpat     = (UChar* )pattern;
+    cpat_end = (UChar* )pattern_end;
+  }
+
+  *reg = (regex_t* )xmalloc(sizeof(regex_t));
+  if (IS_NULL(*reg)) {
+    r = ONIGERR_MEMORY;
+    goto err2;
+  }
+
+  r = onig_reg_init(*reg, ci->option, ci->case_fold_flag, ci->target_enc,
+		    ci->syntax);
+  if (r) goto err;
+
+  r = onig_compile(*reg, cpat, cpat_end, einfo);
+  if (r) {
+  err:
+    onig_free(*reg);
+    *reg = NULL;
+  }
+
+ err2:
+  if (cpat != pattern) xfree(cpat);
+
+  return r;
+}
+
+#ifdef USE_RECOMPILE_API
+extern int
+onig_recompile_deluxe(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
+                      OnigCompileInfo* ci, OnigErrorInfo* einfo)
+{
+  int r;
+  regex_t *new_reg;
+
+  r = onig_new_deluxe(&new_reg, pattern, pattern_end, ci, einfo);
+  if (r) return r;
+  if (ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
+    onig_transfer(reg, new_reg);
+  }
+  else {
+    onig_chain_link_add(reg, new_reg);
+  }
+  return 0;
+}
+#endif
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/reggnu.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/reggnu.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/reggnu.c	(revision 279)
@@ -0,0 +1,170 @@
+/**********************************************************************
+  reggnu.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+#ifndef ONIGGNU_H
+#include "oniggnu.h"
+#endif
+
+extern void
+re_free_registers(OnigRegion* r)
+{
+  /* 0: don't free self */
+  onig_region_free(r, 0);
+}
+
+extern int
+re_adjust_startpos(regex_t* reg, const char* string, int size,
+		   int startpos, int range)
+{
+  if (startpos > 0 && ONIGENC_MBC_MAXLEN(reg->enc) != 1 && startpos < size) {
+    UChar *p;
+    UChar *s = (UChar* )string + startpos;
+
+    if (range > 0) {
+      p = onigenc_get_right_adjust_char_head(reg->enc, (UChar* )string, s);
+    }
+    else {
+      p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, (UChar* )string, s);
+    }
+    return (int )(p - (UChar* )string);
+  }
+
+  return startpos;
+}
+
+extern int
+re_match(regex_t* reg, const char* str, int size, int pos,
+	 struct re_registers* regs)
+{
+  return (int )onig_match(reg, (UChar* )str, (UChar* )(str + size),
+		    (UChar* )(str + pos), regs, ONIG_OPTION_NONE);
+}
+
+extern int
+re_search(regex_t* bufp, const char* string, int size, int startpos, int range,
+	  struct re_registers* regs)
+{
+  return (int )onig_search(bufp, (UChar* )string, (UChar* )(string + size),
+		     (UChar* )(string + startpos),
+		     (UChar* )(string + startpos + range),
+		     regs, ONIG_OPTION_NONE);
+}
+
+extern int
+re_compile_pattern(const char* pattern, int size, regex_t* reg, char* ebuf)
+{
+  int r;
+  OnigErrorInfo einfo;
+
+  r = onig_compile(reg, (UChar* )pattern, (UChar* )(pattern + size), &einfo);
+  if (r != ONIG_NORMAL) {
+    if (IS_NOT_NULL(ebuf))
+      (void )onig_error_code_to_str((UChar* )ebuf, r, &einfo);
+  }
+
+  return r;
+}
+
+#ifdef USE_RECOMPILE_API
+extern int
+re_recompile_pattern(const char* pattern, int size, regex_t* reg, char* ebuf)
+{
+  int r;
+  OnigErrorInfo einfo;
+  OnigEncoding enc;
+
+  /* I think encoding and options should be arguments of this function.
+     But this is adapted to present re.c. (2002/11/29)
+   */
+  enc = OnigEncDefaultCharEncoding;
+
+  r = onig_recompile(reg, (UChar* )pattern, (UChar* )(pattern + size),
+		     reg->options, enc, OnigDefaultSyntax, &einfo);
+  if (r != ONIG_NORMAL) {
+    if (IS_NOT_NULL(ebuf))
+      (void )onig_error_code_to_str((UChar* )ebuf, r, &einfo);
+  }
+  return r;
+}
+#endif
+
+extern void
+re_free_pattern(regex_t* reg)
+{
+  onig_free(reg);
+}
+
+extern int
+re_alloc_pattern(regex_t** reg)
+{
+  *reg = (regex_t* )xmalloc(sizeof(regex_t));
+  if (IS_NULL(*reg)) return ONIGERR_MEMORY;
+
+  return onig_reg_init(*reg, ONIG_OPTION_DEFAULT,
+		       ONIGENC_CASE_FOLD_DEFAULT,
+		       OnigEncDefaultCharEncoding,
+		       OnigDefaultSyntax);
+}
+
+extern void
+re_set_casetable(const char* table)
+{
+  onigenc_set_default_caseconv_table((UChar* )table);
+}
+
+extern void
+re_mbcinit(int mb_code)
+{
+  OnigEncoding enc;
+
+  switch (mb_code) {
+  case RE_MBCTYPE_ASCII:
+    enc = ONIG_ENCODING_ASCII;
+    break;
+#if 0
+  case RE_MBCTYPE_EUC:
+    enc = ONIG_ENCODING_EUC_JP;
+    break;
+  case RE_MBCTYPE_SJIS:
+    enc = ONIG_ENCODING_SJIS;
+    break;
+#endif
+  case RE_MBCTYPE_UTF8:
+    enc = ONIG_ENCODING_UTF8;
+    break;
+  default:
+    return ;
+    break;
+  }
+
+  onigenc_set_default_encoding(enc);
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regint.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regint.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regint.h	(revision 279)
@@ -0,0 +1,951 @@
+#ifndef REGINT_H
+#define REGINT_H
+/**********************************************************************
+  regint.h -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2013  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* for debug */
+/* #define ONIG_DEBUG_PARSE_TREE */
+/* #define ONIG_DEBUG_COMPILE */
+/* #define ONIG_DEBUG_SEARCH */
+/* #define ONIG_DEBUG_MATCH */
+/* #define ONIG_DONT_OPTIMIZE */
+
+/* for byte-code statistical data. */
+/* #define ONIG_DEBUG_STATISTICS */
+
+#if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
+    defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
+    defined(ONIG_DEBUG_STATISTICS)
+#ifndef ONIG_DEBUG
+#define ONIG_DEBUG
+#endif
+#endif
+
+#ifndef UNALIGNED_WORD_ACCESS
+#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
+    defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
+    defined(__powerpc64__) || \
+    defined(__mc68020__)
+#define UNALIGNED_WORD_ACCESS 1
+#else
+#define UNALIGNED_WORD_ACCESS 0
+#endif
+#endif
+
+#if UNALIGNED_WORD_ACCESS
+#define PLATFORM_UNALIGNED_WORD_ACCESS
+#endif
+
+/* config */
+/* spec. config */
+#define USE_NAMED_GROUP
+#define USE_SUBEXP_CALL
+#define USE_PERL_SUBEXP_CALL
+#define USE_CAPITAL_P_NAMED_GROUP
+#define USE_BACKREF_WITH_LEVEL        /* \k<name+n>, \k<name-n> */
+#define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT  /* /(?:()|())*\2/ */
+#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE     /* /\n$/ =~ "\n" */
+#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
+/* #define USE_RECOMPILE_API */
+/* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
+#define USE_NO_INVALID_QUANTIFIER
+
+/* internal config */
+#define USE_PARSE_TREE_NODE_RECYCLE
+#define USE_OP_PUSH_OR_JUMP_EXACT
+#define USE_QTFR_PEEK_NEXT
+#define USE_ST_LIBRARY
+#define USE_SHARED_CCLASS_TABLE
+#define USE_SUNDAY_QUICK_SEARCH
+
+#define INIT_MATCH_STACK_SIZE                     160
+#define DEFAULT_MATCH_STACK_LIMIT_SIZE              0 /* unlimited */
+
+/* check config */
+#if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
+#if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
+#error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
+#endif
+#endif
+
+#if defined(__GNUC__)
+#  define ARG_UNUSED  __attribute__ ((unused))
+#else
+#  define ARG_UNUSED
+#endif
+
+/* */
+/* escape other system UChar definition */
+#include "config.h"
+#ifdef ONIG_ESCAPE_UCHAR_COLLISION
+#undef ONIG_ESCAPE_UCHAR_COLLISION
+#endif
+
+#define USE_WORD_BEGIN_END          /* "\<": word-begin, "\>": word-end */
+#define USE_CAPTURE_HISTORY
+#define USE_VARIABLE_META_CHARS
+#define USE_POSIX_API_REGION_OPTION     /* needed for POSIX API support */
+#define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+/* #define USE_COMBINATION_EXPLOSION_CHECK */     /* (X*)* */
+
+/* multithread config */
+/* #define USE_MULTI_THREAD_SYSTEM */
+/* #define USE_DEFAULT_MULTI_THREAD_SYSTEM */
+
+#if defined(USE_MULTI_THREAD_SYSTEM) \
+  && defined(USE_DEFAULT_MULTI_THREAD_SYSTEM)
+
+#if defined(_WIN32) && !defined(MUSL_LIBC)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+extern CRITICAL_SECTION gOnigMutex;
+#define THREAD_SYSTEM_INIT      InitializeCriticalSection(&gOnigMutex)
+#define THREAD_SYSTEM_END       DeleteCriticalSection(&gOnigMutex)
+#define THREAD_ATOMIC_START     EnterCriticalSection(&gOnigMutex)
+#define THREAD_ATOMIC_END       LeaveCriticalSection(&gOnigMutex)
+#define THREAD_PASS             Sleep(0)
+#else /* _WIN32 */
+#include <pthread.h>
+#include <sched.h>
+extern pthread_mutex_t gOnigMutex;
+#define THREAD_SYSTEM_INIT      pthread_mutex_init(&gOnigMutex, NULL)
+#define THREAD_SYSTEM_END       pthread_mutex_destroy(&gOnigMutex)
+#define THREAD_ATOMIC_START     pthread_mutex_lock(&gOnigMutex)
+#define THREAD_ATOMIC_END       pthread_mutex_unlock(&gOnigMutex)
+#define THREAD_PASS             sched_yield()
+#endif /* _WIN32 */
+
+#else /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
+
+#ifndef THREAD_SYSTEM_INIT
+#define THREAD_SYSTEM_INIT      /* depend on thread system */
+#endif
+#ifndef THREAD_SYSTEM_END
+#define THREAD_SYSTEM_END       /* depend on thread system */
+#endif
+#ifndef THREAD_ATOMIC_START
+#define THREAD_ATOMIC_START     /* depend on thread system */
+#endif
+#ifndef THREAD_ATOMIC_END
+#define THREAD_ATOMIC_END       /* depend on thread system */
+#endif
+#ifndef THREAD_PASS
+#define THREAD_PASS             /* depend on thread system */
+#endif
+
+#endif /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
+
+#ifndef xmalloc
+#define xmalloc     malloc
+#define xrealloc    realloc
+#define xcalloc     calloc
+#define xfree       free
+#endif
+
+#define CHECK_INTERRUPT_IN_MATCH_AT
+
+#define st_init_table                  onig_st_init_table
+#define st_init_table_with_size        onig_st_init_table_with_size
+#define st_init_numtable               onig_st_init_numtable
+#define st_init_numtable_with_size     onig_st_init_numtable_with_size
+#define st_init_strtable               onig_st_init_strtable
+#define st_init_strtable_with_size     onig_st_init_strtable_with_size
+#define st_delete                      onig_st_delete
+#define st_delete_safe                 onig_st_delete_safe
+#define st_insert                      onig_st_insert
+#define st_lookup                      onig_st_lookup
+#define st_foreach                     onig_st_foreach
+#define st_add_direct                  onig_st_add_direct
+#define st_free_table                  onig_st_free_table
+#define st_cleanup_safe                onig_st_cleanup_safe
+#define st_copy                        onig_st_copy
+#define st_nothing_key_clone           onig_st_nothing_key_clone
+#define st_nothing_key_free            onig_st_nothing_key_free
+/* */
+#define onig_st_is_member              st_is_member
+
+#define STATE_CHECK_STRING_THRESHOLD_LEN             7
+#define STATE_CHECK_BUFF_MAX_SIZE               0x4000
+
+#define THREAD_PASS_LIMIT_COUNT     8
+#define xmemset     memset
+#define xmemcpy     memcpy
+#define xmemmove    memmove
+
+#if defined(_WIN32) && !defined(__GNUC__) && !defined(MUSL_LIBC)
+#define xalloca     _alloca
+#define xvsnprintf  _vsnprintf
+#else
+/*#define xalloca     alloca*/
+#define xvsnprintf  vsnprintf
+#endif
+
+
+#if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
+#define ONIG_STATE_INC(reg) (reg)->state++
+#define ONIG_STATE_DEC(reg) (reg)->state--
+
+#define ONIG_STATE_INC_THREAD(reg) do {\
+  THREAD_ATOMIC_START;\
+  (reg)->state++;\
+  THREAD_ATOMIC_END;\
+} while(0)
+#define ONIG_STATE_DEC_THREAD(reg) do {\
+  THREAD_ATOMIC_START;\
+  (reg)->state--;\
+  THREAD_ATOMIC_END;\
+} while(0)
+#else
+#define ONIG_STATE_INC(reg)         /* Nothing */
+#define ONIG_STATE_DEC(reg)         /* Nothing */
+#define ONIG_STATE_INC_THREAD(reg)  /* Nothing */
+#define ONIG_STATE_DEC_THREAD(reg)  /* Nothing */
+#endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
+#include <alloca.h>
+#endif
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+#include <ctype.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+
+#ifdef STDC_HEADERS
+# include <stddef.h>
+#endif
+
+#if defined(_WIN32) && !defined(MUSL_LIBC)
+#include <malloc.h>	/* for alloca() */
+#endif
+
+#ifdef ONIG_DEBUG
+# include <stdio.h>
+#endif
+
+#if defined(_WIN32) && !defined(MUSL_LIBC)
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+#ifndef _INTPTR_T_DEFINED
+#define _INTPTR_T_DEFINED
+typedef int intptr_t;
+#endif
+#ifndef _UINTPTR_T_DEFINED
+#define _UINTPTR_T_DEFINED
+typedef unsigned int uintptr_t;
+#endif
+#endif
+#endif /* _WIN32 */
+
+#ifndef PRIdPTR
+#ifdef _WIN64
+#define PRIdPTR	"I64d"
+#define PRIuPTR	"I64u"
+#define PRIxPTR	"I64x"
+#else
+#define PRIdPTR	"ld"
+#define PRIuPTR	"lu"
+#define PRIxPTR	"lx"
+#endif
+#endif
+
+#include "regenc.h"
+
+#ifdef MIN
+#undef MIN
+#endif
+#ifdef MAX
+#undef MAX
+#endif
+#define MIN(a,b) (((a)>(b))?(b):(a))
+#define MAX(a,b) (((a)<(b))?(b):(a))
+
+#define IS_NULL(p)                    (((void*)(p)) == (void*)0)
+#define IS_NOT_NULL(p)                (((void*)(p)) != (void*)0)
+#define CHECK_NULL_RETURN(p)          if (IS_NULL(p)) return NULL
+#define CHECK_NULL_RETURN_MEMERR(p)   if (IS_NULL(p)) return ONIGERR_MEMORY
+#define NULL_UCHARP                   ((UChar* )0)
+
+#define ONIG_LAST_CODE_POINT    (~((OnigCodePoint )0))
+
+#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
+
+#define PLATFORM_GET_INC(val,p,type) do{\
+  val  = *(type* )p;\
+  (p) += sizeof(type);\
+} while(0)
+
+#else
+
+#define PLATFORM_GET_INC(val,p,type) do{\
+  xmemcpy(&val, (p), sizeof(type));\
+  (p) += sizeof(type);\
+} while(0)
+
+/* sizeof(OnigCodePoint) */
+#define WORD_ALIGNMENT_SIZE     SIZEOF_LONG
+
+#define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
+  (pad_size) = WORD_ALIGNMENT_SIZE \
+               - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
+  if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
+} while (0)
+
+#define ALIGNMENT_RIGHT(addr) do {\
+  (addr) += (WORD_ALIGNMENT_SIZE - 1);\
+  (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
+} while (0)
+
+#endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
+
+/* stack pop level */
+#define STACK_POP_LEVEL_FREE        0
+#define STACK_POP_LEVEL_MEM_START   1
+#define STACK_POP_LEVEL_ALL         2
+
+/* optimize flags */
+#define ONIG_OPTIMIZE_NONE              0
+#define ONIG_OPTIMIZE_EXACT             1   /* Slow Search */
+#define ONIG_OPTIMIZE_EXACT_BM          2   /* Boyer Moore Search */
+#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV  3   /* BM (applied to a multibyte string) */
+#define ONIG_OPTIMIZE_EXACT_IC          4   /* Slow Search (ignore case) */
+#define ONIG_OPTIMIZE_MAP               5   /* char map */
+#define ONIG_OPTIMIZE_EXACT_BM_IC         6 /* BM (ignore case) */
+#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC 7 /* BM (applied to a multibyte string) (ignore case) */
+
+/* bit status */
+typedef unsigned int  BitStatusType;
+
+#define BIT_STATUS_BITS_NUM          (sizeof(BitStatusType) * 8)
+#define BIT_STATUS_CLEAR(stats)      (stats) = 0
+#define BIT_STATUS_ON_ALL(stats)     (stats) = ~((BitStatusType )0)
+#define BIT_STATUS_AT(stats,n) \
+  ((n) < (int )BIT_STATUS_BITS_NUM  ?  ((stats) & ((BitStatusType )1 << n)) : ((stats) & 1))
+
+#define BIT_STATUS_ON_AT(stats,n) do {\
+  if ((n) < (int )BIT_STATUS_BITS_NUM)\
+    (stats) |= (1 << (n));\
+  else\
+    (stats) |= 1;\
+} while (0)
+
+#define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
+  if ((n) < (int )BIT_STATUS_BITS_NUM)\
+    (stats) |= (1 << (n));\
+} while (0)
+
+
+#define INT_MAX_LIMIT           ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
+
+#define DIGITVAL(code)    ((code) - '0')
+#define ODIGITVAL(code)   DIGITVAL(code)
+#define XDIGITVAL(enc,code) \
+  (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
+   : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
+
+#define IS_SINGLELINE(option)     ((option) & ONIG_OPTION_SINGLELINE)
+#define IS_MULTILINE(option)      ((option) & ONIG_OPTION_MULTILINE)
+#define IS_IGNORECASE(option)     ((option) & ONIG_OPTION_IGNORECASE)
+#define IS_EXTEND(option)         ((option) & ONIG_OPTION_EXTEND)
+#define IS_FIND_LONGEST(option)   ((option) & ONIG_OPTION_FIND_LONGEST)
+#define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
+#define IS_FIND_CONDITION(option) ((option) & \
+          (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
+#define IS_NOTBOL(option)         ((option) & ONIG_OPTION_NOTBOL)
+#define IS_NOTEOL(option)         ((option) & ONIG_OPTION_NOTEOL)
+#define IS_NOTBOS(option)         ((option) & ONIG_OPTION_NOTBOS)
+#define IS_NOTEOS(option)         ((option) & ONIG_OPTION_NOTEOS)
+#define IS_POSIX_REGION(option)   ((option) & ONIG_OPTION_POSIX_REGION)
+#define IS_ASCII_RANGE(option)    ((option) & ONIG_OPTION_ASCII_RANGE)
+#define IS_POSIX_BRACKET_ALL_RANGE(option)  ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
+#define IS_WORD_BOUND_ALL_RANGE(option)     ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
+#define IS_NEWLINE_CRLF(option)   ((option) & ONIG_OPTION_NEWLINE_CRLF)
+
+/* OP_SET_OPTION is required for these options.
+#define IS_DYNAMIC_OPTION(option) \
+  (((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
+*/
+/* ignore-case and multibyte status are included in compiled code. */
+#define IS_DYNAMIC_OPTION(option)  0
+
+#define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
+  ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
+
+#define REPEAT_INFINITE         -1
+#define IS_REPEAT_INFINITE(n)   ((n) == REPEAT_INFINITE)
+
+/* bitset */
+#define BITS_PER_BYTE      8
+#define SINGLE_BYTE_SIZE   (1 << BITS_PER_BYTE)
+#define BITS_IN_ROOM       ((int )sizeof(Bits) * BITS_PER_BYTE)
+#define BITSET_SIZE        (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
+
+#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
+typedef unsigned int   Bits;
+#else
+typedef unsigned char  Bits;
+#endif
+typedef Bits           BitSet[BITSET_SIZE];
+typedef Bits*          BitSetRef;
+
+#define SIZE_BITSET        (int )sizeof(BitSet)
+
+#define BITSET_CLEAR(bs) do {\
+  int i;\
+  for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; }	\
+} while (0)
+
+#define BS_ROOM(bs,pos)            (bs)[(int )(pos) / BITS_IN_ROOM]
+#define BS_BIT(pos)                (1U << ((int )(pos) % BITS_IN_ROOM))
+
+#define BITSET_AT(bs, pos)         (BS_ROOM(bs,pos) & BS_BIT(pos))
+#define BITSET_SET_BIT(bs, pos)     BS_ROOM(bs,pos) |= BS_BIT(pos)
+#define BITSET_CLEAR_BIT(bs, pos)   BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
+#define BITSET_INVERT_BIT(bs, pos)  BS_ROOM(bs,pos) ^= BS_BIT(pos)
+
+/* bytes buffer */
+typedef struct _BBuf {
+  UChar* p;
+  unsigned int used;
+  unsigned int alloc;
+} BBuf;
+
+#define BBUF_INIT(buf,size)    onig_bbuf_init((BBuf* )(buf), (size))
+
+#define BBUF_SIZE_INC(buf,inc) do{\
+  UChar *tmp;\
+  (buf)->alloc += (inc);\
+  tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
+  if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
+  (buf)->p = tmp;\
+} while (0)
+
+#define BBUF_EXPAND(buf,low) do{\
+  UChar *tmp;\
+  do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
+  tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
+  if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
+  (buf)->p = tmp;\
+} while (0)
+
+#define BBUF_ENSURE_SIZE(buf,size) do{\
+  unsigned int new_alloc = (buf)->alloc;\
+  while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
+  if ((buf)->alloc != new_alloc) {\
+    UChar *tmp;\
+    tmp = (UChar* )xrealloc((buf)->p, new_alloc);\
+    if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
+    (buf)->p = tmp;\
+    (buf)->alloc = new_alloc;\
+  }\
+} while (0)
+
+#define BBUF_WRITE(buf,pos,bytes,n) do{\
+  int used = (pos) + (int )(n);\
+  if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
+  xmemcpy((buf)->p + (pos), (bytes), (n));\
+  if ((buf)->used < (unsigned int )used) (buf)->used = used;\
+} while (0)
+
+#define BBUF_WRITE1(buf,pos,byte) do{\
+  int used = (pos) + 1;\
+  if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
+  (buf)->p[(pos)] = (UChar )(byte);\
+  if ((buf)->used < (unsigned int )used) (buf)->used = used;\
+} while (0)
+
+#define BBUF_ADD(buf,bytes,n)       BBUF_WRITE((buf),(buf)->used,(bytes),(n))
+#define BBUF_ADD1(buf,byte)         BBUF_WRITE1((buf),(buf)->used,(byte))
+#define BBUF_GET_ADD_ADDRESS(buf)   ((buf)->p + (buf)->used)
+#define BBUF_GET_OFFSET_POS(buf)    ((buf)->used)
+
+/* from < to */
+#define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
+  if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
+  xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
+  if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
+} while (0)
+
+/* from > to */
+#define BBUF_MOVE_LEFT(buf,from,to,n) do {\
+  xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
+} while (0)
+
+/* from > to */
+#define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
+  xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
+  (buf)->used -= (from - to);\
+} while (0)
+
+#define BBUF_INSERT(buf,pos,bytes,n) do {\
+  if (pos >= (buf)->used) {\
+    BBUF_WRITE(buf,pos,bytes,n);\
+  }\
+  else {\
+    BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
+    xmemcpy((buf)->p + (pos), (bytes), (n));\
+  }\
+} while (0)
+
+#define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
+
+
+#define ANCHOR_BEGIN_BUF        (1<<0)
+#define ANCHOR_BEGIN_LINE       (1<<1)
+#define ANCHOR_BEGIN_POSITION   (1<<2)
+#define ANCHOR_END_BUF          (1<<3)
+#define ANCHOR_SEMI_END_BUF     (1<<4)
+#define ANCHOR_END_LINE         (1<<5)
+
+#define ANCHOR_WORD_BOUND       (1<<6)
+#define ANCHOR_NOT_WORD_BOUND   (1<<7)
+#define ANCHOR_WORD_BEGIN       (1<<8)
+#define ANCHOR_WORD_END         (1<<9)
+#define ANCHOR_PREC_READ        (1<<10)
+#define ANCHOR_PREC_READ_NOT    (1<<11)
+#define ANCHOR_LOOK_BEHIND      (1<<12)
+#define ANCHOR_LOOK_BEHIND_NOT  (1<<13)
+
+#define ANCHOR_ANYCHAR_STAR     (1<<14)   /* ".*" optimize info */
+#define ANCHOR_ANYCHAR_STAR_ML  (1<<15)   /* ".*" optimize info (multi-line) */
+
+#define ANCHOR_KEEP             (1<<16)
+
+/* operation code */
+enum OpCode {
+  OP_FINISH = 0,        /* matching process terminator (no more alternative) */
+  OP_END    = 1,        /* pattern code terminator (success end) */
+
+  OP_EXACT1 = 2,        /* single byte, N = 1 */
+  OP_EXACT2,            /* single byte, N = 2 */
+  OP_EXACT3,            /* single byte, N = 3 */
+  OP_EXACT4,            /* single byte, N = 4 */
+  OP_EXACT5,            /* single byte, N = 5 */
+  OP_EXACTN,            /* single byte */
+  OP_EXACTMB2N1,        /* mb-length = 2 N = 1 */
+  OP_EXACTMB2N2,        /* mb-length = 2 N = 2 */
+  OP_EXACTMB2N3,        /* mb-length = 2 N = 3 */
+  OP_EXACTMB2N,         /* mb-length = 2 */
+  OP_EXACTMB3N,         /* mb-length = 3 */
+  OP_EXACTMBN,          /* other length */
+
+  OP_EXACT1_IC,         /* single byte, N = 1, ignore case */
+  OP_EXACTN_IC,         /* single byte,        ignore case */
+
+  OP_CCLASS,
+  OP_CCLASS_MB,
+  OP_CCLASS_MIX,
+  OP_CCLASS_NOT,
+  OP_CCLASS_MB_NOT,
+  OP_CCLASS_MIX_NOT,
+  OP_CCLASS_NODE,       /* pointer to CClassNode node */
+
+  OP_ANYCHAR,                 /* "."  */
+  OP_ANYCHAR_ML,              /* "."  multi-line */
+  OP_ANYCHAR_STAR,            /* ".*" */
+  OP_ANYCHAR_ML_STAR,         /* ".*" multi-line */
+  OP_ANYCHAR_STAR_PEEK_NEXT,
+  OP_ANYCHAR_ML_STAR_PEEK_NEXT,
+
+  OP_WORD,
+  OP_NOT_WORD,
+  OP_WORD_BOUND,
+  OP_NOT_WORD_BOUND,
+  OP_WORD_BEGIN,
+  OP_WORD_END,
+
+  OP_ASCII_WORD,
+  OP_NOT_ASCII_WORD,
+  OP_ASCII_WORD_BOUND,
+  OP_NOT_ASCII_WORD_BOUND,
+  OP_ASCII_WORD_BEGIN,
+  OP_ASCII_WORD_END,
+
+  OP_BEGIN_BUF,
+  OP_END_BUF,
+  OP_BEGIN_LINE,
+  OP_END_LINE,
+  OP_SEMI_END_BUF,
+  OP_BEGIN_POSITION,
+  OP_BEGIN_POS_OR_LINE,   /* used for implicit anchor optimization */
+
+  OP_BACKREF1,
+  OP_BACKREF2,
+  OP_BACKREFN,
+  OP_BACKREFN_IC,
+  OP_BACKREF_MULTI,
+  OP_BACKREF_MULTI_IC,
+  OP_BACKREF_WITH_LEVEL,    /* \k<xxx+n>, \k<xxx-n> */
+
+  OP_MEMORY_START,
+  OP_MEMORY_START_PUSH,   /* push back-tracker to stack */
+  OP_MEMORY_END_PUSH,     /* push back-tracker to stack */
+  OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
+  OP_MEMORY_END,
+  OP_MEMORY_END_REC,      /* push marker to stack */
+
+  OP_KEEP,
+
+  OP_FAIL,               /* pop stack and move */
+  OP_JUMP,
+  OP_PUSH,
+  OP_POP,
+  OP_PUSH_OR_JUMP_EXACT1,  /* if match exact then push, else jump. */
+  OP_PUSH_IF_PEEK_NEXT,    /* if match exact then push, else none. */
+  OP_REPEAT,               /* {n,m} */
+  OP_REPEAT_NG,            /* {n,m}? (non greedy) */
+  OP_REPEAT_INC,
+  OP_REPEAT_INC_NG,        /* non greedy */
+  OP_REPEAT_INC_SG,        /* search and get in stack */
+  OP_REPEAT_INC_NG_SG,     /* search and get in stack (non greedy) */
+  OP_NULL_CHECK_START,     /* null loop checker start */
+  OP_NULL_CHECK_END,       /* null loop checker end   */
+  OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
+  OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
+
+  OP_PUSH_POS,             /* (?=...)  start */
+  OP_POP_POS,              /* (?=...)  end   */
+  OP_PUSH_POS_NOT,         /* (?!...)  start */
+  OP_FAIL_POS,             /* (?!...)  end   */
+  OP_PUSH_STOP_BT,         /* (?>...)  start */
+  OP_POP_STOP_BT,          /* (?>...)  end   */
+  OP_LOOK_BEHIND,          /* (?<=...) start (no needs end opcode) */
+  OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
+  OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end   */
+
+  OP_CALL,                 /* \g<name> */
+  OP_RETURN,
+
+  OP_CONDITION,
+
+  OP_STATE_CHECK_PUSH,         /* combination explosion check and push */
+  OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump  */
+  OP_STATE_CHECK,              /* check only */
+  OP_STATE_CHECK_ANYCHAR_STAR,
+  OP_STATE_CHECK_ANYCHAR_ML_STAR,
+
+  /* no need: IS_DYNAMIC_OPTION() == 0 */
+  OP_SET_OPTION_PUSH,    /* set option and push recover option */
+  OP_SET_OPTION          /* set option */
+};
+
+typedef int RelAddrType;
+typedef int AbsAddrType;
+typedef int LengthType;
+typedef int RepeatNumType;
+typedef short int MemNumType;
+typedef short int StateCheckNumType;
+typedef void* PointerType;
+
+#define SIZE_OPCODE           1
+#define SIZE_RELADDR          (int )sizeof(RelAddrType)
+#define SIZE_ABSADDR          (int )sizeof(AbsAddrType)
+#define SIZE_LENGTH           (int )sizeof(LengthType)
+#define SIZE_MEMNUM           (int )sizeof(MemNumType)
+#define SIZE_STATE_CHECK_NUM  (int )sizeof(StateCheckNumType)
+#define SIZE_REPEATNUM        (int )sizeof(RepeatNumType)
+#define SIZE_OPTION           (int )sizeof(OnigOptionType)
+#define SIZE_CODE_POINT       (int )sizeof(OnigCodePoint)
+#define SIZE_POINTER          (int )sizeof(PointerType)
+
+
+#define GET_RELADDR_INC(addr,p)    PLATFORM_GET_INC(addr,   p, RelAddrType)
+#define GET_ABSADDR_INC(addr,p)    PLATFORM_GET_INC(addr,   p, AbsAddrType)
+#define GET_LENGTH_INC(len,p)      PLATFORM_GET_INC(len,    p, LengthType)
+#define GET_MEMNUM_INC(num,p)      PLATFORM_GET_INC(num,    p, MemNumType)
+#define GET_REPEATNUM_INC(num,p)   PLATFORM_GET_INC(num,    p, RepeatNumType)
+#define GET_OPTION_INC(option,p)   PLATFORM_GET_INC(option, p, OnigOptionType)
+#define GET_POINTER_INC(ptr,p)     PLATFORM_GET_INC(ptr,    p, PointerType)
+#define GET_STATE_CHECK_NUM_INC(num,p)  PLATFORM_GET_INC(num, p, StateCheckNumType)
+
+/* code point's address must be aligned address. */
+#define GET_CODE_POINT(code,p)   code = *((OnigCodePoint* )(p))
+#define GET_BYTE_INC(byte,p) do{\
+  byte = *(p);\
+  (p)++;\
+} while(0)
+
+
+/* op-code + arg size */
+#define SIZE_OP_ANYCHAR_STAR            SIZE_OPCODE
+#define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
+#define SIZE_OP_JUMP                   (SIZE_OPCODE + SIZE_RELADDR)
+#define SIZE_OP_PUSH                   (SIZE_OPCODE + SIZE_RELADDR)
+#define SIZE_OP_POP                     SIZE_OPCODE
+#define SIZE_OP_PUSH_OR_JUMP_EXACT1    (SIZE_OPCODE + SIZE_RELADDR + 1)
+#define SIZE_OP_PUSH_IF_PEEK_NEXT      (SIZE_OPCODE + SIZE_RELADDR + 1)
+#define SIZE_OP_REPEAT_INC             (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_REPEAT_INC_NG          (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_PUSH_POS                SIZE_OPCODE
+#define SIZE_OP_PUSH_POS_NOT           (SIZE_OPCODE + SIZE_RELADDR)
+#define SIZE_OP_POP_POS                 SIZE_OPCODE
+#define SIZE_OP_FAIL_POS                SIZE_OPCODE
+#define SIZE_OP_SET_OPTION             (SIZE_OPCODE + SIZE_OPTION)
+#define SIZE_OP_SET_OPTION_PUSH        (SIZE_OPCODE + SIZE_OPTION)
+#define SIZE_OP_FAIL                    SIZE_OPCODE
+#define SIZE_OP_MEMORY_START           (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_MEMORY_START_PUSH      (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_MEMORY_END_PUSH        (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_MEMORY_END_PUSH_REC    (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_MEMORY_END             (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_MEMORY_END_REC         (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_PUSH_STOP_BT            SIZE_OPCODE
+#define SIZE_OP_POP_STOP_BT             SIZE_OPCODE
+#define SIZE_OP_NULL_CHECK_START       (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_NULL_CHECK_END         (SIZE_OPCODE + SIZE_MEMNUM)
+#define SIZE_OP_LOOK_BEHIND            (SIZE_OPCODE + SIZE_LENGTH)
+#define SIZE_OP_PUSH_LOOK_BEHIND_NOT   (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
+#define SIZE_OP_FAIL_LOOK_BEHIND_NOT    SIZE_OPCODE
+#define SIZE_OP_CALL                   (SIZE_OPCODE + SIZE_ABSADDR)
+#define SIZE_OP_RETURN                  SIZE_OPCODE
+#define SIZE_OP_CONDITION              (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+#define SIZE_OP_STATE_CHECK            (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
+#define SIZE_OP_STATE_CHECK_PUSH       (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
+#define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
+#define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
+#endif
+
+#define MC_ESC(syn)               (syn)->meta_char_table.esc
+#define MC_ANYCHAR(syn)           (syn)->meta_char_table.anychar
+#define MC_ANYTIME(syn)           (syn)->meta_char_table.anytime
+#define MC_ZERO_OR_ONE_TIME(syn)  (syn)->meta_char_table.zero_or_one_time
+#define MC_ONE_OR_MORE_TIME(syn)  (syn)->meta_char_table.one_or_more_time
+#define MC_ANYCHAR_ANYTIME(syn)   (syn)->meta_char_table.anychar_anytime
+
+#define IS_MC_ESC_CODE(code, syn) \
+  ((code) == MC_ESC(syn) && \
+   !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
+
+
+#define SYN_POSIX_COMMON_OP \
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
+   ONIG_SYN_OP_DECIMAL_BACKREF | \
+   ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
+   ONIG_SYN_OP_LINE_ANCHOR | \
+   ONIG_SYN_OP_ESC_CONTROL_CHARS )
+
+#define SYN_GNU_REGEX_OP \
+  ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
+    ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
+    ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
+    ONIG_SYN_OP_VBAR_ALT | \
+    ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
+    ONIG_SYN_OP_QMARK_ZERO_ONE | \
+    ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
+    ONIG_SYN_OP_ESC_W_WORD | \
+    ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
+    ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
+    ONIG_SYN_OP_LINE_ANCHOR )
+
+#define SYN_GNU_REGEX_BV \
+  ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
+    ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
+    ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
+
+
+#define NCCLASS_FLAGS(cc)           ((cc)->flags)
+#define NCCLASS_FLAG_SET(cc,flag)    (NCCLASS_FLAGS(cc) |= (flag))
+#define NCCLASS_FLAG_CLEAR(cc,flag)  (NCCLASS_FLAGS(cc) &= ~(flag))
+#define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
+
+/* cclass node */
+#define FLAG_NCCLASS_NOT           (1<<0)
+#define FLAG_NCCLASS_SHARE         (1<<1)
+
+#define NCCLASS_SET_NOT(nd)     NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
+#define NCCLASS_SET_SHARE(nd)   NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
+#define NCCLASS_CLEAR_NOT(nd)   NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
+#define IS_NCCLASS_NOT(nd)      IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
+#define IS_NCCLASS_SHARE(nd)    IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
+
+typedef struct {
+  int type;
+  /* struct _Node* next; */
+  /* unsigned int flags; */
+} NodeBase;
+
+typedef struct {
+  NodeBase base;
+  unsigned int flags;
+  BitSet bs;
+  BBuf*  mbuf;   /* multi-byte info or NULL */
+} CClassNode;
+
+typedef intptr_t OnigStackIndex;
+
+typedef struct _OnigStackType {
+  unsigned int type;
+  union {
+    struct {
+      UChar *pcode;      /* byte code position */
+      UChar *pstr;       /* string position */
+      UChar *pstr_prev;  /* previous char position of pstr */
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+      unsigned int state_check;
+#endif
+      UChar *pkeep;      /* keep pattern position */
+    } state;
+    struct {
+      int   count;       /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
+      UChar *pcode;      /* byte code position (head of repeated target) */
+      int   num;         /* repeat id */
+    } repeat;
+    struct {
+      OnigStackIndex si;     /* index of stack */
+    } repeat_inc;
+    struct {
+      int num;           /* memory num */
+      UChar *pstr;       /* start/end position */
+      /* Following information is set, if this stack type is MEM-START */
+      OnigStackIndex start;  /* prev. info (for backtrack  "(...)*" ) */
+      OnigStackIndex end;    /* prev. info (for backtrack  "(...)*" ) */
+    } mem;
+    struct {
+      int num;           /* null check id */
+      UChar *pstr;       /* start position */
+    } null_check;
+#ifdef USE_SUBEXP_CALL
+    struct {
+      UChar *ret_addr;   /* byte code position */
+      int    num;        /* null check id */
+      UChar *pstr;       /* string position */
+    } call_frame;
+#endif
+  } u;
+} OnigStackType;
+
+typedef struct {
+  void* stack_p;
+  size_t stack_n;
+  OnigOptionType options;
+  OnigRegion*    region;
+  const UChar* start;   /* search start position */
+  const UChar* gpos;    /* global position (for \G: BEGIN_POSITION) */
+#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
+  OnigPosition best_len;  /* for ONIG_OPTION_FIND_LONGEST */
+  UChar* best_s;
+#endif
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  void* state_check_buff;
+  int   state_check_buff_size;
+#endif
+} OnigMatchArg;
+
+
+#define IS_CODE_SB_WORD(enc,code) \
+  (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
+
+typedef struct OnigEndCallListItem {
+  struct OnigEndCallListItem* next;
+  void (*func)(void);
+} OnigEndCallListItemType;
+
+extern void onig_add_end_call(void (*func)(void));
+
+
+#ifdef ONIG_DEBUG
+
+typedef struct {
+  short int opcode;
+  const char* name;
+  short int arg_type;
+} OnigOpInfoType;
+
+extern OnigOpInfoType OnigOpInfo[];
+
+
+extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar** nextp, OnigEncoding enc));
+
+#ifdef ONIG_DEBUG_STATISTICS
+extern void onig_statistics_init P_((void));
+extern void onig_print_statistics P_((FILE* f));
+#endif
+#endif
+
+extern UChar* onig_error_code_to_format P_((OnigPosition code));
+extern void  onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
+extern int  onig_bbuf_init P_((BBuf* buf, OnigDistance size));
+extern int  onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo));
+extern void onig_chain_reduce P_((regex_t* reg));
+extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
+extern void onig_transfer P_((regex_t* to, regex_t* from));
+extern int  onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc));
+extern int  onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc));
+
+/* strend hash */
+typedef void hash_table_type;
+typedef uintptr_t hash_data_type;
+
+extern hash_table_type* onig_st_init_strend_table_with_size P_((int size));
+extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
+extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
+
+/* encoding property management */
+#define PROPERTY_LIST_ADD_PROP(Name, CR) \
+  r = onigenc_property_list_add_property((UChar* )Name, CR,\
+	      &PropertyNameTable, &PropertyList, &PropertyListNum,\
+	      &PropertyListSize);\
+  if (r != 0) goto end
+
+#define PROPERTY_LIST_INIT_CHECK \
+  if (PropertyInited == 0) {\
+    int r = onigenc_property_list_init(init_property_list);\
+    if (r != 0) return r;\
+  }
+
+extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
+
+typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
+
+extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE));
+
+extern size_t onig_memsize P_((const regex_t *reg));
+extern size_t onig_region_memsize P_((const struct re_registers *regs));
+
+#endif /* REGINT_H */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regparse.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regparse.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regparse.c	(revision 279)
@@ -0,0 +1,6427 @@
+/**********************************************************************
+  regparse.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regparse.h"
+#include "st.h"
+
+#define WARN_BUFSIZE    256
+
+#define CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS
+
+
+OnigSyntaxType OnigSyntaxRuby = {
+  (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
+     ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
+     ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
+     ONIG_SYN_OP_ESC_C_CONTROL )
+   & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
+  , ( ONIG_SYN_OP2_QMARK_GROUP_EFFECT |
+      ONIG_SYN_OP2_OPTION_RUBY |
+      ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP | ONIG_SYN_OP2_ESC_K_NAMED_BACKREF |
+      ONIG_SYN_OP2_ESC_G_SUBEXP_CALL |
+      ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY  |
+      ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
+      ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT |
+      ONIG_SYN_OP2_CCLASS_SET_OP | ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL |
+      ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META | ONIG_SYN_OP2_ESC_V_VTAB |
+      ONIG_SYN_OP2_ESC_H_XDIGIT |
+      ONIG_SYN_OP2_ESC_CAPITAL_X_EXTENDED_GRAPHEME_CLUSTER |
+      ONIG_SYN_OP2_QMARK_LPAREN_CONDITION |
+      ONIG_SYN_OP2_ESC_CAPITAL_R_LINEBREAK |
+      ONIG_SYN_OP2_ESC_CAPITAL_K_KEEP )
+  , ( SYN_GNU_REGEX_BV |
+      ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV |
+      ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND |
+      ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
+      ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME |
+      ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY |
+      ONIG_SYN_WARN_CC_OP_NOT_ESCAPED |
+      ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT )
+  , ( ONIG_OPTION_ASCII_RANGE | ONIG_OPTION_POSIX_BRACKET_ALL_RANGE |
+      ONIG_OPTION_WORD_BOUND_ALL_RANGE )
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType*  OnigDefaultSyntax = ONIG_SYNTAX_RUBY;
+
+extern void onig_null_warn(const char* s ARG_UNUSED) { }
+
+#ifdef DEFAULT_WARN_FUNCTION
+static OnigWarnFunc onig_warn = (OnigWarnFunc )DEFAULT_WARN_FUNCTION;
+#else
+static OnigWarnFunc onig_warn = onig_null_warn;
+#endif
+
+#ifdef DEFAULT_VERB_WARN_FUNCTION
+static OnigWarnFunc onig_verb_warn = (OnigWarnFunc )DEFAULT_VERB_WARN_FUNCTION;
+#else
+static OnigWarnFunc onig_verb_warn = onig_null_warn;
+#endif
+
+extern void onig_set_warn_func(OnigWarnFunc f)
+{
+  onig_warn = f;
+}
+
+extern void onig_set_verb_warn_func(OnigWarnFunc f)
+{
+  onig_verb_warn = f;
+}
+
+static void
+bbuf_free(BBuf* bbuf)
+{
+  if (IS_NOT_NULL(bbuf)) {
+    if (IS_NOT_NULL(bbuf->p)) xfree(bbuf->p);
+    xfree(bbuf);
+  }
+}
+
+static int
+bbuf_clone(BBuf** rto, BBuf* from)
+{
+  int r;
+  BBuf *to;
+
+  *rto = to = (BBuf* )xmalloc(sizeof(BBuf));
+  CHECK_NULL_RETURN_MEMERR(to);
+  r = BBUF_INIT(to, from->alloc);
+  if (r != 0) return r;
+  to->used = from->used;
+  xmemcpy(to->p, from->p, from->used);
+  return 0;
+}
+
+#define BACKREF_REL_TO_ABS(rel_no, env) \
+  ((env)->num_mem + 1 + (rel_no))
+
+#define ONOFF(v,f,negative)    (negative) ? ((v) &= ~(f)) : ((v) |= (f))
+
+#define MBCODE_START_POS(enc) \
+  (OnigCodePoint )(ONIGENC_MBC_MINLEN(enc) > 1 ? 0 : 0x80)
+
+#define SET_ALL_MULTI_BYTE_RANGE(enc, pbuf) \
+  add_code_range_to_buf(pbuf, MBCODE_START_POS(enc), ONIG_LAST_CODE_POINT)
+
+#define ADD_ALL_MULTI_BYTE_RANGE(enc, mbuf) do {\
+  if (! ONIGENC_IS_SINGLEBYTE(enc)) {\
+    r = SET_ALL_MULTI_BYTE_RANGE(enc, &(mbuf));\
+    if (r) return r;\
+  }\
+} while (0)
+
+
+#define BITSET_IS_EMPTY(bs,empty) do {\
+  int i;\
+  empty = 1;\
+  for (i = 0; i < BITSET_SIZE; i++) {\
+    if ((bs)[i] != 0) {\
+      empty = 0; break;\
+    }\
+  }\
+} while (0)
+
+static void
+bitset_set_range(BitSetRef bs, int from, int to)
+{
+  int i;
+  for (i = from; i <= to && i < SINGLE_BYTE_SIZE; i++) {
+    BITSET_SET_BIT(bs, i);
+  }
+}
+
+#if 0
+static void
+bitset_set_all(BitSetRef bs)
+{
+  int i;
+  for (i = 0; i < BITSET_SIZE; i++) { bs[i] = ~((Bits )0); }
+}
+#endif
+
+static void
+bitset_invert(BitSetRef bs)
+{
+  int i;
+  for (i = 0; i < BITSET_SIZE; i++) { bs[i] = ~(bs[i]); }
+}
+
+static void
+bitset_invert_to(BitSetRef from, BitSetRef to)
+{
+  int i;
+  for (i = 0; i < BITSET_SIZE; i++) { to[i] = ~(from[i]); }
+}
+
+static void
+bitset_and(BitSetRef dest, BitSetRef bs)
+{
+  int i;
+  for (i = 0; i < BITSET_SIZE; i++) { dest[i] &= bs[i]; }
+}
+
+static void
+bitset_or(BitSetRef dest, BitSetRef bs)
+{
+  int i;
+  for (i = 0; i < BITSET_SIZE; i++) { dest[i] |= bs[i]; }
+}
+
+static void
+bitset_copy(BitSetRef dest, BitSetRef bs)
+{
+  int i;
+  for (i = 0; i < BITSET_SIZE; i++) { dest[i] = bs[i]; }
+}
+
+extern int
+onig_strncmp(const UChar* s1, const UChar* s2, int n)
+{
+  int x;
+
+  while (n-- > 0) {
+    x = *s2++ - *s1++;
+    if (x) return x;
+  }
+  return 0;
+}
+
+extern void
+onig_strcpy(UChar* dest, const UChar* src, const UChar* end)
+{
+  ptrdiff_t len = end - src;
+  if (len > 0) {
+    xmemcpy(dest, src, len);
+    dest[len] = (UChar )0;
+  }
+}
+
+#ifdef USE_NAMED_GROUP
+static UChar*
+strdup_with_null(OnigEncoding enc, UChar* s, UChar* end)
+{
+  ptrdiff_t slen;
+  int term_len, i;
+  UChar *r;
+
+  slen = end - s;
+  term_len = ONIGENC_MBC_MINLEN(enc);
+
+  r = (UChar* )xmalloc(slen + term_len);
+  CHECK_NULL_RETURN(r);
+  xmemcpy(r, s, slen);
+
+  for (i = 0; i < term_len; i++)
+    r[slen + i] = (UChar )0;
+
+  return r;
+}
+#endif
+
+/* scan pattern methods */
+#define PEND_VALUE   0
+
+#ifdef __GNUC__
+/* get rid of Wunused-but-set-variable and Wuninitialized */
+#define PFETCH_READY  UChar* pfetch_prev = NULL; (void)pfetch_prev
+#else
+#define PFETCH_READY  UChar* pfetch_prev
+#endif
+#define PEND         (p < end ?  0 : 1)
+#define PUNFETCH     p = pfetch_prev
+#define PINC       do { \
+  pfetch_prev = p; \
+  p += ONIGENC_MBC_ENC_LEN(enc, p); \
+} while (0)
+#define PFETCH(c)  do { \
+  c = ONIGENC_MBC_TO_CODE(enc, p, end); \
+  pfetch_prev = p; \
+  p += ONIGENC_MBC_ENC_LEN(enc, p); \
+} while (0)
+
+#define PINC_S     do { \
+  p += ONIGENC_MBC_ENC_LEN(enc, p); \
+} while (0)
+#define PFETCH_S(c) do { \
+  c = ONIGENC_MBC_TO_CODE(enc, p, end); \
+  p += ONIGENC_MBC_ENC_LEN(enc, p); \
+} while (0)
+
+#define PPEEK        (p < end ? ONIGENC_MBC_TO_CODE(enc, p, end) : PEND_VALUE)
+#define PPEEK_IS(c)  (PPEEK == (OnigCodePoint )c)
+
+static UChar*
+strcat_capa(UChar* dest, UChar* dest_end, const UChar* src, const UChar* src_end,
+	      size_t capa)
+{
+  UChar* r;
+
+  if (dest)
+    r = (UChar* )xrealloc(dest, capa + 1);
+  else
+    r = (UChar* )xmalloc(capa + 1);
+
+  CHECK_NULL_RETURN(r);
+  onig_strcpy(r + (dest_end - dest), src, src_end);
+  return r;
+}
+
+/* dest on static area */
+static UChar*
+strcat_capa_from_static(UChar* dest, UChar* dest_end,
+			const UChar* src, const UChar* src_end, size_t capa)
+{
+  UChar* r;
+
+  r = (UChar* )xmalloc(capa + 1);
+  CHECK_NULL_RETURN(r);
+  onig_strcpy(r, dest, dest_end);
+  onig_strcpy(r + (dest_end - dest), src, src_end);
+  return r;
+}
+
+
+#ifdef USE_ST_LIBRARY
+
+typedef struct {
+  UChar* s;
+  UChar* end;
+} st_str_end_key;
+
+static int
+str_end_cmp(st_str_end_key* x, st_str_end_key* y)
+{
+  UChar *p, *q;
+  int c;
+
+  if ((x->end - x->s) != (y->end - y->s))
+    return 1;
+
+  p = x->s;
+  q = y->s;
+  while (p < x->end) {
+    c = (int )*p - (int )*q;
+    if (c != 0) return c;
+
+    p++; q++;
+  }
+
+  return 0;
+}
+
+static int
+str_end_hash(st_str_end_key* x)
+{
+  UChar *p;
+  int val = 0;
+
+  p = x->s;
+  while (p < x->end) {
+    val = val * 997 + (int )*p++;
+  }
+
+  return val + (val >> 5);
+}
+
+extern hash_table_type*
+onig_st_init_strend_table_with_size(int size)
+{
+  static struct st_hash_type hashType = {
+    str_end_cmp,
+    str_end_hash,
+  };
+
+  return (hash_table_type* )
+           onig_st_init_table_with_size(&hashType, size);
+}
+
+extern int
+onig_st_lookup_strend(hash_table_type* table, const UChar* str_key,
+		      const UChar* end_key, hash_data_type *value)
+{
+  st_str_end_key key;
+
+  key.s   = (UChar* )str_key;
+  key.end = (UChar* )end_key;
+
+  return onig_st_lookup(table, (st_data_t )(&key), value);
+}
+
+extern int
+onig_st_insert_strend(hash_table_type* table, const UChar* str_key,
+		      const UChar* end_key, hash_data_type value)
+{
+  st_str_end_key* key;
+  int result;
+
+  key = (st_str_end_key* )xmalloc(sizeof(st_str_end_key));
+  key->s   = (UChar* )str_key;
+  key->end = (UChar* )end_key;
+  result = onig_st_insert(table, (st_data_t )key, value);
+  if (result) {
+    xfree(key);
+  }
+  return result;
+}
+
+#endif /* USE_ST_LIBRARY */
+
+
+#ifdef USE_NAMED_GROUP
+
+#define INIT_NAME_BACKREFS_ALLOC_NUM   8
+
+typedef struct {
+  UChar* name;
+  size_t name_len;   /* byte length */
+  int    back_num;   /* number of backrefs */
+  int    back_alloc;
+  int    back_ref1;
+  int*   back_refs;
+} NameEntry;
+
+#ifdef USE_ST_LIBRARY
+
+typedef st_table  NameTable;
+typedef st_data_t HashDataType;   /* 1.6 st.h doesn't define st_data_t type */
+
+#ifdef ONIG_DEBUG
+static int
+i_print_name_entry(UChar* key, NameEntry* e, void* arg)
+{
+  int i;
+  FILE* fp = (FILE* )arg;
+
+  fprintf(fp, "%s: ", e->name);
+  if (e->back_num == 0)
+    fputs("-", fp);
+  else if (e->back_num == 1)
+    fprintf(fp, "%d", e->back_ref1);
+  else {
+    for (i = 0; i < e->back_num; i++) {
+      if (i > 0) fprintf(fp, ", ");
+      fprintf(fp, "%d", e->back_refs[i]);
+    }
+  }
+  fputs("\n", fp);
+  return ST_CONTINUE;
+}
+
+extern int
+onig_print_names(FILE* fp, regex_t* reg)
+{
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t)) {
+    fprintf(fp, "name table\n");
+    onig_st_foreach(t, i_print_name_entry, (HashDataType )fp);
+    fputs("\n", fp);
+  }
+  return 0;
+}
+#endif /* ONIG_DEBUG */
+
+static int
+i_free_name_entry(UChar* key, NameEntry* e, void* arg ARG_UNUSED)
+{
+  xfree(e->name);
+  if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs);
+  xfree(key);
+  xfree(e);
+  return ST_DELETE;
+}
+
+static int
+names_clear(regex_t* reg)
+{
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t)) {
+    onig_st_foreach(t, i_free_name_entry, 0);
+  }
+  return 0;
+}
+
+extern int
+onig_names_free(regex_t* reg)
+{
+  int r;
+  NameTable* t;
+
+  r = names_clear(reg);
+  if (r) return r;
+
+  t = (NameTable* )reg->name_table;
+  if (IS_NOT_NULL(t)) onig_st_free_table(t);
+  reg->name_table = (void* )NULL;
+  return 0;
+}
+
+static NameEntry*
+name_find(regex_t* reg, const UChar* name, const UChar* name_end)
+{
+  NameEntry* e;
+  NameTable* t = (NameTable* )reg->name_table;
+
+  e = (NameEntry* )NULL;
+  if (IS_NOT_NULL(t)) {
+    onig_st_lookup_strend(t, name, name_end, (HashDataType* )((void* )(&e)));
+  }
+  return e;
+}
+
+typedef struct {
+  int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*);
+  regex_t* reg;
+  void* arg;
+  int ret;
+  OnigEncoding enc;
+} INamesArg;
+
+static int
+i_names(UChar* key ARG_UNUSED, NameEntry* e, INamesArg* arg)
+{
+  int r = (*(arg->func))(e->name,
+                         e->name + e->name_len,
+                         e->back_num,
+			 (e->back_num > 1 ? e->back_refs : &(e->back_ref1)),
+			 arg->reg, arg->arg);
+  if (r != 0) {
+    arg->ret = r;
+    return ST_STOP;
+  }
+  return ST_CONTINUE;
+}
+
+extern int
+onig_foreach_name(regex_t* reg,
+  int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg)
+{
+  INamesArg narg;
+  NameTable* t = (NameTable* )reg->name_table;
+
+  narg.ret = 0;
+  if (IS_NOT_NULL(t)) {
+    narg.func = func;
+    narg.reg  = reg;
+    narg.arg  = arg;
+    narg.enc  = reg->enc; /* should be pattern encoding. */
+    onig_st_foreach(t, i_names, (HashDataType )&narg);
+  }
+  return narg.ret;
+}
+
+static int
+i_renumber_name(UChar* key ARG_UNUSED, NameEntry* e, GroupNumRemap* map)
+{
+  int i;
+
+  if (e->back_num > 1) {
+    for (i = 0; i < e->back_num; i++) {
+      e->back_refs[i] = map[e->back_refs[i]].new_val;
+    }
+  }
+  else if (e->back_num == 1) {
+    e->back_ref1 = map[e->back_ref1].new_val;
+  }
+
+  return ST_CONTINUE;
+}
+
+extern int
+onig_renumber_name_table(regex_t* reg, GroupNumRemap* map)
+{
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t)) {
+    onig_st_foreach(t, i_renumber_name, (HashDataType )map);
+  }
+  return 0;
+}
+
+
+extern int
+onig_number_of_names(regex_t* reg)
+{
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t))
+    return t->num_entries;
+  else
+    return 0;
+}
+
+#else  /* USE_ST_LIBRARY */
+
+#define INIT_NAMES_ALLOC_NUM    8
+
+typedef struct {
+  NameEntry* e;
+  int        num;
+  int        alloc;
+} NameTable;
+
+#ifdef ONIG_DEBUG
+extern int
+onig_print_names(FILE* fp, regex_t* reg)
+{
+  int i, j;
+  NameEntry* e;
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t) && t->num > 0) {
+    fprintf(fp, "name table\n");
+    for (i = 0; i < t->num; i++) {
+      e = &(t->e[i]);
+      fprintf(fp, "%s: ", e->name);
+      if (e->back_num == 0) {
+	fputs("-", fp);
+      }
+      else if (e->back_num == 1) {
+	fprintf(fp, "%d", e->back_ref1);
+      }
+      else {
+	for (j = 0; j < e->back_num; j++) {
+	  if (j > 0) fprintf(fp, ", ");
+	  fprintf(fp, "%d", e->back_refs[j]);
+	}
+      }
+      fputs("\n", fp);
+    }
+    fputs("\n", fp);
+  }
+  return 0;
+}
+#endif
+
+static int
+names_clear(regex_t* reg)
+{
+  int i;
+  NameEntry* e;
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t)) {
+    for (i = 0; i < t->num; i++) {
+      e = &(t->e[i]);
+      if (IS_NOT_NULL(e->name)) {
+	xfree(e->name);
+	e->name       = NULL;
+	e->name_len   = 0;
+	e->back_num   = 0;
+	e->back_alloc = 0;
+	if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs);
+	e->back_refs = (int* )NULL;
+      }
+    }
+    if (IS_NOT_NULL(t->e)) {
+      xfree(t->e);
+      t->e = NULL;
+    }
+    t->num = 0;
+  }
+  return 0;
+}
+
+extern int
+onig_names_free(regex_t* reg)
+{
+  int r;
+  NameTable* t;
+
+  r = names_clear(reg);
+  if (r) return r;
+
+  t = (NameTable* )reg->name_table;
+  if (IS_NOT_NULL(t)) xfree(t);
+  reg->name_table = NULL;
+  return 0;
+}
+
+static NameEntry*
+name_find(regex_t* reg, const UChar* name, const UChar* name_end)
+{
+  int i, len;
+  NameEntry* e;
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t)) {
+    len = name_end - name;
+    for (i = 0; i < t->num; i++) {
+      e = &(t->e[i]);
+      if (len == e->name_len && onig_strncmp(name, e->name, len) == 0)
+	return e;
+    }
+  }
+  return (NameEntry* )NULL;
+}
+
+extern int
+onig_foreach_name(regex_t* reg,
+  int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg)
+{
+  int i, r;
+  NameEntry* e;
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t)) {
+    for (i = 0; i < t->num; i++) {
+      e = &(t->e[i]);
+      r = (*func)(e->name, e->name + e->name_len, e->back_num,
+		  (e->back_num > 1 ? e->back_refs : &(e->back_ref1)),
+		  reg, arg);
+      if (r != 0) return r;
+    }
+  }
+  return 0;
+}
+
+extern int
+onig_number_of_names(regex_t* reg)
+{
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (IS_NOT_NULL(t))
+    return t->num;
+  else
+    return 0;
+}
+
+#endif /* else USE_ST_LIBRARY */
+
+static int
+name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env)
+{
+  int alloc;
+  NameEntry* e;
+  NameTable* t = (NameTable* )reg->name_table;
+
+  if (name_end - name <= 0)
+    return ONIGERR_EMPTY_GROUP_NAME;
+
+  e = name_find(reg, name, name_end);
+  if (IS_NULL(e)) {
+#ifdef USE_ST_LIBRARY
+    if (IS_NULL(t)) {
+      t = onig_st_init_strend_table_with_size(5);
+      reg->name_table = (void* )t;
+    }
+    e = (NameEntry* )xmalloc(sizeof(NameEntry));
+    CHECK_NULL_RETURN_MEMERR(e);
+
+    e->name = strdup_with_null(reg->enc, name, name_end);
+    if (IS_NULL(e->name)) {
+      xfree(e);
+      return ONIGERR_MEMORY;
+    }
+    onig_st_insert_strend(t, e->name, (e->name + (name_end - name)),
+                          (HashDataType )e);
+
+    e->name_len   = name_end - name;
+    e->back_num   = 0;
+    e->back_alloc = 0;
+    e->back_refs  = (int* )NULL;
+
+#else
+
+    if (IS_NULL(t)) {
+      alloc = INIT_NAMES_ALLOC_NUM;
+      t = (NameTable* )xmalloc(sizeof(NameTable));
+      CHECK_NULL_RETURN_MEMERR(t);
+      t->e     = NULL;
+      t->alloc = 0;
+      t->num   = 0;
+
+      t->e = (NameEntry* )xmalloc(sizeof(NameEntry) * alloc);
+      if (IS_NULL(t->e)) {
+	xfree(t);
+	return ONIGERR_MEMORY;
+      }
+      t->alloc = alloc;
+      reg->name_table = t;
+      goto clear;
+    }
+    else if (t->num == t->alloc) {
+      int i;
+      NameEntry* p;
+
+      alloc = t->alloc * 2;
+      p = (NameEntry* )xrealloc(t->e, sizeof(NameEntry) * alloc);
+      CHECK_NULL_RETURN_MEMERR(p);
+      t->e = p;
+      t->alloc = alloc;
+
+    clear:
+      for (i = t->num; i < t->alloc; i++) {
+	t->e[i].name       = NULL;
+	t->e[i].name_len   = 0;
+	t->e[i].back_num   = 0;
+	t->e[i].back_alloc = 0;
+	t->e[i].back_refs  = (int* )NULL;
+      }
+    }
+    e = &(t->e[t->num]);
+    t->num++;
+    e->name = strdup_with_null(reg->enc, name, name_end);
+    if (IS_NULL(e->name)) return ONIGERR_MEMORY;
+    e->name_len = name_end - name;
+#endif
+  }
+
+  if (e->back_num >= 1 &&
+      ! IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME)) {
+    onig_scan_env_set_error_string(env, ONIGERR_MULTIPLEX_DEFINED_NAME,
+				    name, name_end);
+    return ONIGERR_MULTIPLEX_DEFINED_NAME;
+  }
+
+  e->back_num++;
+  if (e->back_num == 1) {
+    e->back_ref1 = backref;
+  }
+  else {
+    if (e->back_num == 2) {
+      alloc = INIT_NAME_BACKREFS_ALLOC_NUM;
+      e->back_refs = (int* )xmalloc(sizeof(int) * alloc);
+      CHECK_NULL_RETURN_MEMERR(e->back_refs);
+      e->back_alloc = alloc;
+      e->back_refs[0] = e->back_ref1;
+      e->back_refs[1] = backref;
+    }
+    else {
+      if (e->back_num > e->back_alloc) {
+	int* p;
+	alloc = e->back_alloc * 2;
+	p = (int* )xrealloc(e->back_refs, sizeof(int) * alloc);
+	CHECK_NULL_RETURN_MEMERR(p);
+	e->back_refs = p;
+	e->back_alloc = alloc;
+      }
+      e->back_refs[e->back_num - 1] = backref;
+    }
+  }
+
+  return 0;
+}
+
+extern int
+onig_name_to_group_numbers(regex_t* reg, const UChar* name,
+			   const UChar* name_end, int** nums)
+{
+  NameEntry* e = name_find(reg, name, name_end);
+
+  if (IS_NULL(e)) return ONIGERR_UNDEFINED_NAME_REFERENCE;
+
+  switch (e->back_num) {
+  case 0:
+    *nums = 0;
+    break;
+  case 1:
+    *nums = &(e->back_ref1);
+    break;
+  default:
+    *nums = e->back_refs;
+    break;
+  }
+  return e->back_num;
+}
+
+extern int
+onig_name_to_backref_number(regex_t* reg, const UChar* name,
+			    const UChar* name_end, OnigRegion *region)
+{
+  int i, n, *nums;
+
+  n = onig_name_to_group_numbers(reg, name, name_end, &nums);
+  if (n < 0)
+    return n;
+  else if (n == 0)
+    return ONIGERR_PARSER_BUG;
+  else if (n == 1)
+    return nums[0];
+  else {
+    if (IS_NOT_NULL(region)) {
+      for (i = n - 1; i >= 0; i--) {
+	if (region->beg[nums[i]] != ONIG_REGION_NOTPOS)
+	  return nums[i];
+      }
+    }
+    return nums[n - 1];
+  }
+}
+
+#else /* USE_NAMED_GROUP */
+
+extern int
+onig_name_to_group_numbers(regex_t* reg, const UChar* name,
+			   const UChar* name_end, int** nums)
+{
+  return ONIG_NO_SUPPORT_CONFIG;
+}
+
+extern int
+onig_name_to_backref_number(regex_t* reg, const UChar* name,
+			    const UChar* name_end, OnigRegion* region)
+{
+  return ONIG_NO_SUPPORT_CONFIG;
+}
+
+extern int
+onig_foreach_name(regex_t* reg,
+  int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg)
+{
+  return ONIG_NO_SUPPORT_CONFIG;
+}
+
+extern int
+onig_number_of_names(regex_t* reg)
+{
+  return 0;
+}
+#endif /* else USE_NAMED_GROUP */
+
+extern int
+onig_noname_group_capture_is_active(regex_t* reg)
+{
+  if (ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_DONT_CAPTURE_GROUP))
+    return 0;
+
+#ifdef USE_NAMED_GROUP
+  if (onig_number_of_names(reg) > 0 &&
+      IS_SYNTAX_BV(reg->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
+      !ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_CAPTURE_GROUP)) {
+    return 0;
+  }
+#endif
+
+  return 1;
+}
+
+
+#define INIT_SCANENV_MEMNODES_ALLOC_SIZE   16
+
+static void
+scan_env_clear(ScanEnv* env)
+{
+  int i;
+
+  BIT_STATUS_CLEAR(env->capture_history);
+  BIT_STATUS_CLEAR(env->bt_mem_start);
+  BIT_STATUS_CLEAR(env->bt_mem_end);
+  BIT_STATUS_CLEAR(env->backrefed_mem);
+  env->error      = (UChar* )NULL;
+  env->error_end  = (UChar* )NULL;
+  env->num_call   = 0;
+  env->num_mem    = 0;
+#ifdef USE_NAMED_GROUP
+  env->num_named  = 0;
+#endif
+  env->mem_alloc         = 0;
+  env->mem_nodes_dynamic = (Node** )NULL;
+
+  for (i = 0; i < SCANENV_MEMNODES_SIZE; i++)
+    env->mem_nodes_static[i] = NULL_NODE;
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  env->num_comb_exp_check  = 0;
+  env->comb_exp_max_regnum = 0;
+  env->curr_max_regnum     = 0;
+  env->has_recursion       = 0;
+#endif
+}
+
+static int
+scan_env_add_mem_entry(ScanEnv* env)
+{
+  int i, need, alloc;
+  Node** p;
+
+  need = env->num_mem + 1;
+  if (need > ONIG_MAX_CAPTURE_GROUP_NUM)
+    return ONIGERR_TOO_MANY_CAPTURE_GROUPS;
+  if (need >= SCANENV_MEMNODES_SIZE) {
+    if (env->mem_alloc <= need) {
+      if (IS_NULL(env->mem_nodes_dynamic)) {
+	alloc = INIT_SCANENV_MEMNODES_ALLOC_SIZE;
+	p = (Node** )xmalloc(sizeof(Node*) * alloc);
+	xmemcpy(p, env->mem_nodes_static,
+		sizeof(Node*) * SCANENV_MEMNODES_SIZE);
+      }
+      else {
+	alloc = env->mem_alloc * 2;
+	p = (Node** )xrealloc(env->mem_nodes_dynamic, sizeof(Node*) * alloc);
+      }
+      CHECK_NULL_RETURN_MEMERR(p);
+
+      for (i = env->num_mem + 1; i < alloc; i++)
+	p[i] = NULL_NODE;
+
+      env->mem_nodes_dynamic = p;
+      env->mem_alloc = alloc;
+    }
+  }
+
+  env->num_mem++;
+  return env->num_mem;
+}
+
+static int
+scan_env_set_mem_node(ScanEnv* env, int num, Node* node)
+{
+  if (env->num_mem >= num)
+    SCANENV_MEM_NODES(env)[num] = node;
+  else
+    return ONIGERR_PARSER_BUG;
+  return 0;
+}
+
+
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+typedef struct _FreeNode {
+  struct _FreeNode* next;
+} FreeNode;
+
+static FreeNode* FreeNodeList = (FreeNode* )NULL;
+#endif
+
+extern void
+onig_node_free(Node* node)
+{
+ start:
+  if (IS_NULL(node)) return ;
+
+  switch (NTYPE(node)) {
+  case NT_STR:
+    if (NSTR(node)->capa != 0 &&
+	IS_NOT_NULL(NSTR(node)->s) && NSTR(node)->s != NSTR(node)->buf) {
+      xfree(NSTR(node)->s);
+    }
+    break;
+
+  case NT_LIST:
+  case NT_ALT:
+    onig_node_free(NCAR(node));
+    {
+      Node* next_node = NCDR(node);
+
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+      {
+	FreeNode* n = (FreeNode* )node;
+
+        THREAD_ATOMIC_START;
+	n->next = FreeNodeList;
+	FreeNodeList = n;
+        THREAD_ATOMIC_END;
+      }
+#else
+      xfree(node);
+#endif
+      node = next_node;
+      goto start;
+    }
+    break;
+
+  case NT_CCLASS:
+    {
+      CClassNode* cc = NCCLASS(node);
+
+      if (IS_NCCLASS_SHARE(cc)) return ;
+      if (cc->mbuf)
+        bbuf_free(cc->mbuf);
+    }
+    break;
+
+  case NT_QTFR:
+    if (NQTFR(node)->target)
+      onig_node_free(NQTFR(node)->target);
+    break;
+
+  case NT_ENCLOSE:
+    if (NENCLOSE(node)->target)
+      onig_node_free(NENCLOSE(node)->target);
+    break;
+
+  case NT_BREF:
+    if (IS_NOT_NULL(NBREF(node)->back_dynamic))
+      xfree(NBREF(node)->back_dynamic);
+    break;
+
+  case NT_ANCHOR:
+    if (NANCHOR(node)->target)
+      onig_node_free(NANCHOR(node)->target);
+    break;
+  }
+
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+  {
+    FreeNode* n = (FreeNode* )node;
+
+    THREAD_ATOMIC_START;
+    n->next = FreeNodeList;
+    FreeNodeList = n;
+    THREAD_ATOMIC_END;
+  }
+#else
+  xfree(node);
+#endif
+}
+
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+extern int
+onig_free_node_list(void)
+{
+  FreeNode* n;
+
+  /* THREAD_ATOMIC_START; */
+  while (IS_NOT_NULL(FreeNodeList)) {
+    n = FreeNodeList;
+    FreeNodeList = FreeNodeList->next;
+    xfree(n);
+  }
+  /* THREAD_ATOMIC_END; */
+  return 0;
+}
+#endif
+
+static Node*
+node_new(void)
+{
+  Node* node;
+
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+  THREAD_ATOMIC_START;
+  if (IS_NOT_NULL(FreeNodeList)) {
+    node = (Node* )FreeNodeList;
+    FreeNodeList = FreeNodeList->next;
+    THREAD_ATOMIC_END;
+    return node;
+  }
+  THREAD_ATOMIC_END;
+#endif
+
+  node = (Node* )xmalloc(sizeof(Node));
+  /* xmemset(node, 0, sizeof(Node)); */
+  return node;
+}
+
+#if defined(USE_MULTI_THREAD_SYSTEM) && \
+    defined(USE_SHARED_CCLASS_TABLE) && \
+    defined(USE_PARSE_TREE_NODE_RECYCLE)
+static Node*
+node_new_locked(void)
+{
+  Node* node;
+
+  if (IS_NOT_NULL(FreeNodeList)) {
+    node = (Node* )FreeNodeList;
+    FreeNodeList = FreeNodeList->next;
+    return node;
+  }
+
+  node = (Node* )xmalloc(sizeof(Node));
+  /* xmemset(node, 0, sizeof(Node)); */
+  return node;
+}
+#endif
+
+static void
+initialize_cclass(CClassNode* cc)
+{
+  BITSET_CLEAR(cc->bs);
+  /* cc->base.flags = 0; */
+  cc->flags = 0;
+  cc->mbuf  = NULL;
+}
+
+static Node*
+node_new_cclass(void)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_CCLASS);
+  initialize_cclass(NCCLASS(node));
+  return node;
+}
+
+#if defined(USE_MULTI_THREAD_SYSTEM) && \
+    defined(USE_SHARED_CCLASS_TABLE) && \
+    defined(USE_PARSE_TREE_NODE_RECYCLE)
+static Node*
+node_new_cclass_locked(void)
+{
+  Node* node = node_new_locked();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_CCLASS);
+  initialize_cclass(NCCLASS(node));
+  return node;
+}
+#else
+#define node_new_cclass_locked()  node_new_cclass()
+#endif
+
+#ifdef USE_SHARED_CCLASS_TABLE
+static Node*
+node_new_cclass_by_codepoint_range(int not, OnigCodePoint sb_out,
+				   const OnigCodePoint ranges[])
+{
+  int n, i;
+  CClassNode* cc;
+  OnigCodePoint j;
+
+  Node* node = node_new_cclass_locked();
+  CHECK_NULL_RETURN(node);
+
+  cc = NCCLASS(node);
+  if (not != 0) NCCLASS_SET_NOT(cc);
+
+  BITSET_CLEAR(cc->bs);
+  if (sb_out > 0 && IS_NOT_NULL(ranges)) {
+    n = ONIGENC_CODE_RANGE_NUM(ranges);
+    for (i = 0; i < n; i++) {
+      for (j  = ONIGENC_CODE_RANGE_FROM(ranges, i);
+           j <= (OnigCodePoint )ONIGENC_CODE_RANGE_TO(ranges, i); j++) {
+	if (j >= sb_out) goto sb_end;
+
+        BITSET_SET_BIT(cc->bs, j);
+      }
+    }
+  }
+
+ sb_end:
+  if (IS_NULL(ranges)) {
+  is_null:
+    cc->mbuf = NULL;
+  }
+  else {
+    BBuf* bbuf;
+
+    n = ONIGENC_CODE_RANGE_NUM(ranges);
+    if (n == 0) goto is_null;
+
+    bbuf = (BBuf* )xmalloc(sizeof(BBuf));
+    CHECK_NULL_RETURN(bbuf);
+    bbuf->alloc = n + 1;
+    bbuf->used  = n + 1;
+    bbuf->p     = (UChar* )((void* )ranges);
+
+    cc->mbuf = bbuf;
+  }
+
+  return node;
+}
+#endif /* USE_SHARED_CCLASS_TABLE */
+
+static Node*
+node_new_ctype(int type, int not, int ascii_range)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_CTYPE);
+  NCTYPE(node)->ctype = type;
+  NCTYPE(node)->not   = not;
+  NCTYPE(node)->ascii_range = ascii_range;
+  return node;
+}
+
+static Node*
+node_new_anychar(void)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_CANY);
+  return node;
+}
+
+static Node*
+node_new_list(Node* left, Node* right)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_LIST);
+  NCAR(node)  = left;
+  NCDR(node) = right;
+  return node;
+}
+
+extern Node*
+onig_node_new_list(Node* left, Node* right)
+{
+  return node_new_list(left, right);
+}
+
+extern Node*
+onig_node_list_add(Node* list, Node* x)
+{
+  Node *n;
+
+  n = onig_node_new_list(x, NULL);
+  if (IS_NULL(n)) return NULL_NODE;
+
+  if (IS_NOT_NULL(list)) {
+    while (IS_NOT_NULL(NCDR(list)))
+      list = NCDR(list);
+
+    NCDR(list) = n;
+  }
+
+  return n;
+}
+
+extern Node*
+onig_node_new_alt(Node* left, Node* right)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_ALT);
+  NCAR(node)  = left;
+  NCDR(node) = right;
+  return node;
+}
+
+extern Node*
+onig_node_new_anchor(int type)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_ANCHOR);
+  NANCHOR(node)->type     = type;
+  NANCHOR(node)->target   = NULL;
+  NANCHOR(node)->char_len = -1;
+  NANCHOR(node)->ascii_range = 0;
+  return node;
+}
+
+static Node*
+node_new_backref(int back_num, int* backrefs, int by_name,
+#ifdef USE_BACKREF_WITH_LEVEL
+		 int exist_level, int nest_level,
+#endif
+		 ScanEnv* env)
+{
+  int i;
+  Node* node = node_new();
+
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_BREF);
+  NBREF(node)->state    = 0;
+  NBREF(node)->back_num = back_num;
+  NBREF(node)->back_dynamic = (int* )NULL;
+  if (by_name != 0)
+    NBREF(node)->state |= NST_NAME_REF;
+
+#ifdef USE_BACKREF_WITH_LEVEL
+  if (exist_level != 0) {
+    NBREF(node)->state |= NST_NEST_LEVEL;
+    NBREF(node)->nest_level  = nest_level;
+  }
+#endif
+
+  for (i = 0; i < back_num; i++) {
+    if (backrefs[i] <= env->num_mem &&
+	IS_NULL(SCANENV_MEM_NODES(env)[backrefs[i]])) {
+      NBREF(node)->state |= NST_RECURSION;   /* /...(\1).../ */
+      break;
+    }
+  }
+
+  if (back_num <= NODE_BACKREFS_SIZE) {
+    for (i = 0; i < back_num; i++)
+      NBREF(node)->back_static[i] = backrefs[i];
+  }
+  else {
+    int* p = (int* )xmalloc(sizeof(int) * back_num);
+    if (IS_NULL(p)) {
+      onig_node_free(node);
+      return NULL;
+    }
+    NBREF(node)->back_dynamic = p;
+    for (i = 0; i < back_num; i++)
+      p[i] = backrefs[i];
+  }
+  return node;
+}
+
+#ifdef USE_SUBEXP_CALL
+static Node*
+node_new_call(UChar* name, UChar* name_end, int gnum)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_CALL);
+  NCALL(node)->state     = 0;
+  NCALL(node)->target    = NULL_NODE;
+  NCALL(node)->name      = name;
+  NCALL(node)->name_end  = name_end;
+  NCALL(node)->group_num = gnum;  /* call by number if gnum != 0 */
+  return node;
+}
+#endif
+
+static Node*
+node_new_quantifier(int lower, int upper, int by_number)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_QTFR);
+  NQTFR(node)->state  = 0;
+  NQTFR(node)->target = NULL;
+  NQTFR(node)->lower  = lower;
+  NQTFR(node)->upper  = upper;
+  NQTFR(node)->greedy = 1;
+  NQTFR(node)->target_empty_info = NQ_TARGET_ISNOT_EMPTY;
+  NQTFR(node)->head_exact        = NULL_NODE;
+  NQTFR(node)->next_head_exact   = NULL_NODE;
+  NQTFR(node)->is_refered        = 0;
+  if (by_number != 0)
+    NQTFR(node)->state |= NST_BY_NUMBER;
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  NQTFR(node)->comb_exp_check_num = 0;
+#endif
+
+  return node;
+}
+
+static Node*
+node_new_enclose(int type)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_ENCLOSE);
+  NENCLOSE(node)->type      = type;
+  NENCLOSE(node)->state     =  0;
+  NENCLOSE(node)->regnum    =  0;
+  NENCLOSE(node)->option    =  0;
+  NENCLOSE(node)->target    = NULL;
+  NENCLOSE(node)->call_addr = -1;
+  NENCLOSE(node)->opt_count =  0;
+  return node;
+}
+
+extern Node*
+onig_node_new_enclose(int type)
+{
+  return node_new_enclose(type);
+}
+
+static Node*
+node_new_enclose_memory(OnigOptionType option, int is_named)
+{
+  Node* node = node_new_enclose(ENCLOSE_MEMORY);
+  CHECK_NULL_RETURN(node);
+  if (is_named != 0)
+    SET_ENCLOSE_STATUS(node, NST_NAMED_GROUP);
+
+#ifdef USE_SUBEXP_CALL
+  NENCLOSE(node)->option = option;
+#endif
+  return node;
+}
+
+static Node*
+node_new_option(OnigOptionType option)
+{
+  Node* node = node_new_enclose(ENCLOSE_OPTION);
+  CHECK_NULL_RETURN(node);
+  NENCLOSE(node)->option = option;
+  return node;
+}
+
+extern int
+onig_node_str_cat(Node* node, const UChar* s, const UChar* end)
+{
+  ptrdiff_t addlen = end - s;
+
+  if (addlen > 0) {
+    ptrdiff_t len  = NSTR(node)->end - NSTR(node)->s;
+
+    if (NSTR(node)->capa > 0 || (len + addlen > NODE_STR_BUF_SIZE - 1)) {
+      UChar* p;
+      ptrdiff_t capa = len + addlen + NODE_STR_MARGIN;
+
+      if (capa <= NSTR(node)->capa) {
+	onig_strcpy(NSTR(node)->s + len, s, end);
+      }
+      else {
+	if (NSTR(node)->s == NSTR(node)->buf)
+	  p = strcat_capa_from_static(NSTR(node)->s, NSTR(node)->end,
+				      s, end, capa);
+	else
+	  p = strcat_capa(NSTR(node)->s, NSTR(node)->end, s, end, capa);
+
+	CHECK_NULL_RETURN_MEMERR(p);
+	NSTR(node)->s    = p;
+	NSTR(node)->capa = (int )capa;
+      }
+    }
+    else {
+      onig_strcpy(NSTR(node)->s + len, s, end);
+    }
+    NSTR(node)->end = NSTR(node)->s + len + addlen;
+  }
+
+  return 0;
+}
+
+extern int
+onig_node_str_set(Node* node, const UChar* s, const UChar* end)
+{
+  onig_node_str_clear(node);
+  return onig_node_str_cat(node, s, end);
+}
+
+static int
+node_str_cat_char(Node* node, UChar c)
+{
+  UChar s[1];
+
+  s[0] = c;
+  return onig_node_str_cat(node, s, s + 1);
+}
+
+static int
+node_str_cat_codepoint(Node* node, OnigEncoding enc, OnigCodePoint c)
+{
+  UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
+  int num = ONIGENC_CODE_TO_MBC(enc, c, buf);
+  if (num < 0) return num;
+  return onig_node_str_cat(node, buf, buf + num);
+}
+
+extern void
+onig_node_conv_to_str_node(Node* node, int flag)
+{
+  SET_NTYPE(node, NT_STR);
+  NSTR(node)->flag = flag;
+  NSTR(node)->capa = 0;
+  NSTR(node)->s    = NSTR(node)->buf;
+  NSTR(node)->end  = NSTR(node)->buf;
+}
+
+extern void
+onig_node_str_clear(Node* node)
+{
+  if (NSTR(node)->capa != 0 &&
+      IS_NOT_NULL(NSTR(node)->s) && NSTR(node)->s != NSTR(node)->buf) {
+    xfree(NSTR(node)->s);
+  }
+
+  NSTR(node)->capa = 0;
+  NSTR(node)->flag = 0;
+  NSTR(node)->s    = NSTR(node)->buf;
+  NSTR(node)->end  = NSTR(node)->buf;
+}
+
+static Node*
+node_new_str(const UChar* s, const UChar* end)
+{
+  Node* node = node_new();
+  CHECK_NULL_RETURN(node);
+
+  SET_NTYPE(node, NT_STR);
+  NSTR(node)->capa = 0;
+  NSTR(node)->flag = 0;
+  NSTR(node)->s    = NSTR(node)->buf;
+  NSTR(node)->end  = NSTR(node)->buf;
+  if (onig_node_str_cat(node, s, end)) {
+    onig_node_free(node);
+    return NULL;
+  }
+  return node;
+}
+
+extern Node*
+onig_node_new_str(const UChar* s, const UChar* end)
+{
+  return node_new_str(s, end);
+}
+
+static Node*
+node_new_str_raw(UChar* s, UChar* end)
+{
+  Node* node = node_new_str(s, end);
+  if (IS_NOT_NULL(node))
+    NSTRING_SET_RAW(node);
+  return node;
+}
+
+static Node*
+node_new_empty(void)
+{
+  return node_new_str(NULL, NULL);
+}
+
+static Node*
+node_new_str_raw_char(UChar c)
+{
+  UChar p[1];
+
+  p[0] = c;
+  return node_new_str_raw(p, p + 1);
+}
+
+static Node*
+str_node_split_last_char(StrNode* sn, OnigEncoding enc)
+{
+  const UChar *p;
+  Node* n = NULL_NODE;
+
+  if (sn->end > sn->s) {
+    p = onigenc_get_prev_char_head(enc, sn->s, sn->end);
+    if (p && p > sn->s) { /* can be split. */
+      n = node_new_str(p, sn->end);
+      if (IS_NOT_NULL(n) && (sn->flag & NSTR_RAW) != 0)
+	NSTRING_SET_RAW(n);
+      sn->end = (UChar* )p;
+    }
+  }
+  return n;
+}
+
+static int
+str_node_can_be_split(StrNode* sn, OnigEncoding enc)
+{
+  if (sn->end > sn->s) {
+    return ((enclen(enc, sn->s) < sn->end - sn->s)  ?  1 : 0);
+  }
+  return 0;
+}
+
+#ifdef USE_PAD_TO_SHORT_BYTE_CHAR
+static int
+node_str_head_pad(StrNode* sn, int num, UChar val)
+{
+  UChar buf[NODE_STR_BUF_SIZE];
+  int i, len;
+
+  len = sn->end - sn->s;
+  onig_strcpy(buf, sn->s, sn->end);
+  onig_strcpy(&(sn->s[num]), buf, buf + len);
+  sn->end += num;
+
+  for (i = 0; i < num; i++) {
+    sn->s[i] = val;
+  }
+}
+#endif
+
+extern int
+onig_scan_unsigned_number(UChar** src, const UChar* end, OnigEncoding enc)
+{
+  unsigned int num, val;
+  OnigCodePoint c;
+  UChar* p = *src;
+  PFETCH_READY;
+
+  num = 0;
+  while (!PEND) {
+    PFETCH(c);
+    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+      val = (unsigned int )DIGITVAL(c);
+      if ((INT_MAX_LIMIT - val) / 10UL < num)
+	return -1;  /* overflow */
+
+      num = num * 10 + val;
+    }
+    else {
+      PUNFETCH;
+      break;
+    }
+  }
+  *src = p;
+  return num;
+}
+
+static int
+scan_unsigned_hexadecimal_number(UChar** src, UChar* end, int minlen,
+				 int maxlen, OnigEncoding enc)
+{
+  OnigCodePoint c;
+  unsigned int num, val;
+  int restlen;
+  UChar* p = *src;
+  PFETCH_READY;
+
+  restlen = maxlen - minlen;
+  num = 0;
+  while (!PEND && maxlen-- != 0) {
+    PFETCH(c);
+    if (ONIGENC_IS_CODE_XDIGIT(enc, c)) {
+      val = (unsigned int )XDIGITVAL(enc,c);
+      if ((INT_MAX_LIMIT - val) / 16UL < num)
+	return -1;  /* overflow */
+
+      num = (num << 4) + XDIGITVAL(enc,c);
+    }
+    else {
+      PUNFETCH;
+      break;
+    }
+  }
+  if (maxlen > restlen)
+    return -2;  /* not enough digits */
+  *src = p;
+  return num;
+}
+
+static int
+scan_unsigned_octal_number(UChar** src, UChar* end, int maxlen,
+			   OnigEncoding enc)
+{
+  OnigCodePoint c;
+  unsigned int num, val;
+  UChar* p = *src;
+  PFETCH_READY;
+
+  num = 0;
+  while (!PEND && maxlen-- != 0) {
+    PFETCH(c);
+    if (ONIGENC_IS_CODE_DIGIT(enc, c) && c < '8') {
+      val = ODIGITVAL(c);
+      if ((INT_MAX_LIMIT - val) / 8UL < num)
+	return -1;  /* overflow */
+
+      num = (num << 3) + val;
+    }
+    else {
+      PUNFETCH;
+      break;
+    }
+  }
+  *src = p;
+  return num;
+}
+
+
+#define BBUF_WRITE_CODE_POINT(bbuf,pos,code) \
+    BBUF_WRITE(bbuf, pos, &(code), SIZE_CODE_POINT)
+
+/* data format:
+     [n][from-1][to-1][from-2][to-2] ... [from-n][to-n]
+     (all data size is OnigCodePoint)
+ */
+static int
+new_code_range(BBuf** pbuf)
+{
+#define INIT_MULTI_BYTE_RANGE_SIZE  (SIZE_CODE_POINT * 5)
+  int r;
+  OnigCodePoint n;
+  BBuf* bbuf;
+
+  bbuf = *pbuf = (BBuf* )xmalloc(sizeof(BBuf));
+  CHECK_NULL_RETURN_MEMERR(*pbuf);
+  r = BBUF_INIT(*pbuf, INIT_MULTI_BYTE_RANGE_SIZE);
+  if (r) return r;
+
+  n = 0;
+  BBUF_WRITE_CODE_POINT(bbuf, 0, n);
+  return 0;
+}
+
+static int
+add_code_range_to_buf(BBuf** pbuf, OnigCodePoint from, OnigCodePoint to)
+{
+  int r, inc_n, pos;
+  OnigCodePoint low, high, bound, x;
+  OnigCodePoint n, *data;
+  BBuf* bbuf;
+
+  if (from > to) {
+    n = from; from = to; to = n;
+  }
+
+  if (IS_NULL(*pbuf)) {
+    r = new_code_range(pbuf);
+    if (r) return r;
+    bbuf = *pbuf;
+    n = 0;
+  }
+  else {
+    bbuf = *pbuf;
+    GET_CODE_POINT(n, bbuf->p);
+  }
+  data = (OnigCodePoint* )(bbuf->p);
+  data++;
+
+  bound = (from == 0) ? 0 : n;
+  for (low = 0; low < bound; ) {
+    x = (low + bound) >> 1;
+    if (from - 1 > data[x*2 + 1])
+      low = x + 1;
+    else
+      bound = x;
+  }
+
+  high = (to == ONIG_LAST_CODE_POINT) ? n : low;
+  for (bound = n; high < bound; ) {
+    x = (high + bound) >> 1;
+    if (to + 1 >= data[x*2])
+      high = x + 1;
+    else
+      bound = x;
+  }
+
+  inc_n = low + 1 - high;
+  if (n + inc_n > ONIG_MAX_MULTI_BYTE_RANGES_NUM)
+    return ONIGERR_TOO_MANY_MULTI_BYTE_RANGES;
+
+  if (inc_n != 1) {
+    if (from > data[low*2])
+      from = data[low*2];
+    if (to < data[(high - 1)*2 + 1])
+      to = data[(high - 1)*2 + 1];
+  }
+
+  if (inc_n != 0) {
+    int from_pos = SIZE_CODE_POINT * (1 + high * 2);
+    int to_pos   = SIZE_CODE_POINT * (1 + (low + 1) * 2);
+
+    if (inc_n > 0) {
+      if (high < n) {
+	int size = (n - high) * 2 * SIZE_CODE_POINT;
+	BBUF_MOVE_RIGHT(bbuf, from_pos, to_pos, size);
+      }
+    }
+    else {
+      BBUF_MOVE_LEFT_REDUCE(bbuf, from_pos, to_pos);
+    }
+  }
+
+  pos = SIZE_CODE_POINT * (1 + low * 2);
+  BBUF_ENSURE_SIZE(bbuf, pos + SIZE_CODE_POINT * 2);
+  BBUF_WRITE_CODE_POINT(bbuf, pos, from);
+  BBUF_WRITE_CODE_POINT(bbuf, pos + SIZE_CODE_POINT, to);
+  n += inc_n;
+  BBUF_WRITE_CODE_POINT(bbuf, 0, n);
+
+  return 0;
+}
+
+static int
+add_code_range(BBuf** pbuf, ScanEnv* env, OnigCodePoint from, OnigCodePoint to)
+{
+  if (from > to) {
+    if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC))
+      return 0;
+    else
+      return ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS;
+  }
+
+  return add_code_range_to_buf(pbuf, from, to);
+}
+
+static int
+not_code_range_buf(OnigEncoding enc, BBuf* bbuf, BBuf** pbuf)
+{
+  int r, i, n;
+  OnigCodePoint pre, from, *data, to = 0;
+
+  *pbuf = (BBuf* )NULL;
+  if (IS_NULL(bbuf)) {
+  set_all:
+    return SET_ALL_MULTI_BYTE_RANGE(enc, pbuf);
+  }
+
+  data = (OnigCodePoint* )(bbuf->p);
+  GET_CODE_POINT(n, data);
+  data++;
+  if (n <= 0) goto set_all;
+
+  r = 0;
+  pre = MBCODE_START_POS(enc);
+  for (i = 0; i < n; i++) {
+    from = data[i*2];
+    to   = data[i*2+1];
+    if (pre <= from - 1) {
+      r = add_code_range_to_buf(pbuf, pre, from - 1);
+      if (r != 0) return r;
+    }
+    if (to == ONIG_LAST_CODE_POINT) break;
+    pre = to + 1;
+  }
+  if (to < ONIG_LAST_CODE_POINT) {
+    r = add_code_range_to_buf(pbuf, to + 1, ONIG_LAST_CODE_POINT);
+  }
+  return r;
+}
+
+#define SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2) do {\
+  BBuf *tbuf; \
+  int  tnot; \
+  tnot = not1;  not1  = not2;  not2  = tnot; \
+  tbuf = bbuf1; bbuf1 = bbuf2; bbuf2 = tbuf; \
+} while (0)
+
+static int
+or_code_range_buf(OnigEncoding enc, BBuf* bbuf1, int not1,
+                  BBuf* bbuf2, int not2, BBuf** pbuf)
+{
+  int r;
+  OnigCodePoint i, n1, *data1;
+  OnigCodePoint from, to;
+
+  *pbuf = (BBuf* )NULL;
+  if (IS_NULL(bbuf1) && IS_NULL(bbuf2)) {
+    if (not1 != 0 || not2 != 0)
+      return SET_ALL_MULTI_BYTE_RANGE(enc, pbuf);
+    return 0;
+  }
+
+  r = 0;
+  if (IS_NULL(bbuf2))
+    SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2);
+
+  if (IS_NULL(bbuf1)) {
+    if (not1 != 0) {
+      return SET_ALL_MULTI_BYTE_RANGE(enc, pbuf);
+    }
+    else {
+      if (not2 == 0) {
+	return bbuf_clone(pbuf, bbuf2);
+      }
+      else {
+	return not_code_range_buf(enc, bbuf2, pbuf);
+      }
+    }
+  }
+
+  if (not1 != 0)
+    SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2);
+
+  data1 = (OnigCodePoint* )(bbuf1->p);
+  GET_CODE_POINT(n1, data1);
+  data1++;
+
+  if (not2 == 0 && not1 == 0) { /* 1 OR 2 */
+    r = bbuf_clone(pbuf, bbuf2);
+  }
+  else if (not1 == 0) { /* 1 OR (not 2) */
+    r = not_code_range_buf(enc, bbuf2, pbuf);
+  }
+  if (r != 0) return r;
+
+  for (i = 0; i < n1; i++) {
+    from = data1[i*2];
+    to   = data1[i*2+1];
+    r = add_code_range_to_buf(pbuf, from, to);
+    if (r != 0) return r;
+  }
+  return 0;
+}
+
+static int
+and_code_range1(BBuf** pbuf, OnigCodePoint from1, OnigCodePoint to1,
+	        OnigCodePoint* data, int n)
+{
+  int i, r;
+  OnigCodePoint from2, to2;
+
+  for (i = 0; i < n; i++) {
+    from2 = data[i*2];
+    to2   = data[i*2+1];
+    if (from2 < from1) {
+      if (to2 < from1) continue;
+      else {
+	from1 = to2 + 1;
+      }
+    }
+    else if (from2 <= to1) {
+      if (to2 < to1) {
+	if (from1 <= from2 - 1) {
+	  r = add_code_range_to_buf(pbuf, from1, from2-1);
+	  if (r != 0) return r;
+	}
+	from1 = to2 + 1;
+      }
+      else {
+	to1 = from2 - 1;
+      }
+    }
+    else {
+      from1 = from2;
+    }
+    if (from1 > to1) break;
+  }
+  if (from1 <= to1) {
+    r = add_code_range_to_buf(pbuf, from1, to1);
+    if (r != 0) return r;
+  }
+  return 0;
+}
+
+static int
+and_code_range_buf(BBuf* bbuf1, int not1, BBuf* bbuf2, int not2, BBuf** pbuf)
+{
+  int r;
+  OnigCodePoint i, j, n1, n2, *data1, *data2;
+  OnigCodePoint from, to, from1, to1, from2, to2;
+
+  *pbuf = (BBuf* )NULL;
+  if (IS_NULL(bbuf1)) {
+    if (not1 != 0 && IS_NOT_NULL(bbuf2)) /* not1 != 0 -> not2 == 0 */
+      return bbuf_clone(pbuf, bbuf2);
+    return 0;
+  }
+  else if (IS_NULL(bbuf2)) {
+    if (not2 != 0)
+      return bbuf_clone(pbuf, bbuf1);
+    return 0;
+  }
+
+  if (not1 != 0)
+    SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2);
+
+  data1 = (OnigCodePoint* )(bbuf1->p);
+  data2 = (OnigCodePoint* )(bbuf2->p);
+  GET_CODE_POINT(n1, data1);
+  GET_CODE_POINT(n2, data2);
+  data1++;
+  data2++;
+
+  if (not2 == 0 && not1 == 0) { /* 1 AND 2 */
+    for (i = 0; i < n1; i++) {
+      from1 = data1[i*2];
+      to1   = data1[i*2+1];
+      for (j = 0; j < n2; j++) {
+	from2 = data2[j*2];
+	to2   = data2[j*2+1];
+	if (from2 > to1) break;
+	if (to2 < from1) continue;
+	from = MAX(from1, from2);
+	to   = MIN(to1, to2);
+	r = add_code_range_to_buf(pbuf, from, to);
+	if (r != 0) return r;
+      }
+    }
+  }
+  else if (not1 == 0) { /* 1 AND (not 2) */
+    for (i = 0; i < n1; i++) {
+      from1 = data1[i*2];
+      to1   = data1[i*2+1];
+      r = and_code_range1(pbuf, from1, to1, data2, n2);
+      if (r != 0) return r;
+    }
+  }
+
+  return 0;
+}
+
+static int
+and_cclass(CClassNode* dest, CClassNode* cc, OnigEncoding enc)
+{
+  int r, not1, not2;
+  BBuf *buf1, *buf2, *pbuf = 0;
+  BitSetRef bsr1, bsr2;
+  BitSet bs1, bs2;
+
+  not1 = IS_NCCLASS_NOT(dest);
+  bsr1 = dest->bs;
+  buf1 = dest->mbuf;
+  not2 = IS_NCCLASS_NOT(cc);
+  bsr2 = cc->bs;
+  buf2 = cc->mbuf;
+
+  if (not1 != 0) {
+    bitset_invert_to(bsr1, bs1);
+    bsr1 = bs1;
+  }
+  if (not2 != 0) {
+    bitset_invert_to(bsr2, bs2);
+    bsr2 = bs2;
+  }
+  bitset_and(bsr1, bsr2);
+  if (bsr1 != dest->bs) {
+    bitset_copy(dest->bs, bsr1);
+    bsr1 = dest->bs;
+  }
+  if (not1 != 0) {
+    bitset_invert(dest->bs);
+  }
+
+  if (! ONIGENC_IS_SINGLEBYTE(enc)) {
+    if (not1 != 0 && not2 != 0) {
+      r = or_code_range_buf(enc, buf1, 0, buf2, 0, &pbuf);
+    }
+    else {
+      r = and_code_range_buf(buf1, not1, buf2, not2, &pbuf);
+      if (r == 0 && not1 != 0) {
+	BBuf *tbuf = 0;
+	r = not_code_range_buf(enc, pbuf, &tbuf);
+	bbuf_free(pbuf);
+	pbuf = tbuf;
+      }
+    }
+    if (r != 0) {
+      bbuf_free(pbuf);
+      return r;
+    }
+
+    dest->mbuf = pbuf;
+    bbuf_free(buf1);
+    return r;
+  }
+  return 0;
+}
+
+static int
+or_cclass(CClassNode* dest, CClassNode* cc, OnigEncoding enc)
+{
+  int r, not1, not2;
+  BBuf *buf1, *buf2, *pbuf = 0;
+  BitSetRef bsr1, bsr2;
+  BitSet bs1, bs2;
+
+  not1 = IS_NCCLASS_NOT(dest);
+  bsr1 = dest->bs;
+  buf1 = dest->mbuf;
+  not2 = IS_NCCLASS_NOT(cc);
+  bsr2 = cc->bs;
+  buf2 = cc->mbuf;
+
+  if (not1 != 0) {
+    bitset_invert_to(bsr1, bs1);
+    bsr1 = bs1;
+  }
+  if (not2 != 0) {
+    bitset_invert_to(bsr2, bs2);
+    bsr2 = bs2;
+  }
+  bitset_or(bsr1, bsr2);
+  if (bsr1 != dest->bs) {
+    bitset_copy(dest->bs, bsr1);
+    bsr1 = dest->bs;
+  }
+  if (not1 != 0) {
+    bitset_invert(dest->bs);
+  }
+
+  if (! ONIGENC_IS_SINGLEBYTE(enc)) {
+    if (not1 != 0 && not2 != 0) {
+      r = and_code_range_buf(buf1, 0, buf2, 0, &pbuf);
+    }
+    else {
+      r = or_code_range_buf(enc, buf1, not1, buf2, not2, &pbuf);
+      if (r == 0 && not1 != 0) {
+	BBuf *tbuf = 0;
+	r = not_code_range_buf(enc, pbuf, &tbuf);
+	bbuf_free(pbuf);
+	pbuf = tbuf;
+      }
+    }
+    if (r != 0) {
+      bbuf_free(pbuf);
+      return r;
+    }
+
+    dest->mbuf = pbuf;
+    bbuf_free(buf1);
+    return r;
+  }
+  else
+    return 0;
+}
+
+static int
+conv_backslash_value(int c, ScanEnv* env)
+{
+  if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_CONTROL_CHARS)) {
+    switch (c) {
+    case 'n': return '\n';
+    case 't': return '\t';
+    case 'r': return '\r';
+    case 'f': return '\f';
+    case 'a': return '\007';
+    case 'b': return '\010';
+    case 'e': return '\033';
+    case 'v':
+      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_V_VTAB))
+	return '\v';
+      break;
+
+    default:
+      break;
+    }
+  }
+  return c;
+}
+
+#ifdef USE_NO_INVALID_QUANTIFIER
+#define is_invalid_quantifier_target(node) 0
+#else
+static int
+is_invalid_quantifier_target(Node* node)
+{
+  switch (NTYPE(node)) {
+  case NT_ANCHOR:
+    return 1;
+    break;
+
+  case NT_ENCLOSE:
+    /* allow enclosed elements */
+    /* return is_invalid_quantifier_target(NENCLOSE(node)->target); */
+    break;
+
+  case NT_LIST:
+    do {
+      if (! is_invalid_quantifier_target(NCAR(node))) return 0;
+    } while (IS_NOT_NULL(node = NCDR(node)));
+    return 0;
+    break;
+
+  case NT_ALT:
+    do {
+      if (is_invalid_quantifier_target(NCAR(node))) return 1;
+    } while (IS_NOT_NULL(node = NCDR(node)));
+    break;
+
+  default:
+    break;
+  }
+  return 0;
+}
+#endif
+
+/* ?:0, *:1, +:2, ??:3, *?:4, +?:5 */
+static int
+popular_quantifier_num(QtfrNode* q)
+{
+  if (q->greedy) {
+    if (q->lower == 0) {
+      if (q->upper == 1) return 0;
+      else if (IS_REPEAT_INFINITE(q->upper)) return 1;
+    }
+    else if (q->lower == 1) {
+      if (IS_REPEAT_INFINITE(q->upper)) return 2;
+    }
+  }
+  else {
+    if (q->lower == 0) {
+      if (q->upper == 1) return 3;
+      else if (IS_REPEAT_INFINITE(q->upper)) return 4;
+    }
+    else if (q->lower == 1) {
+      if (IS_REPEAT_INFINITE(q->upper)) return 5;
+    }
+  }
+  return -1;
+}
+
+
+enum ReduceType {
+  RQ_ASIS = 0, /* as is */
+  RQ_DEL  = 1, /* delete parent */
+  RQ_A,        /* to '*'    */
+  RQ_AQ,       /* to '*?'   */
+  RQ_QQ,       /* to '??'   */
+  RQ_P_QQ,     /* to '+)??' */
+  RQ_PQ_Q      /* to '+?)?' */
+};
+
+static enum ReduceType const ReduceTypeTable[6][6] = {
+  {RQ_DEL,  RQ_A,    RQ_A,   RQ_QQ,   RQ_AQ,   RQ_ASIS}, /* '?'  */
+  {RQ_DEL,  RQ_DEL,  RQ_DEL, RQ_P_QQ, RQ_P_QQ, RQ_DEL},  /* '*'  */
+  {RQ_A,    RQ_A,    RQ_DEL, RQ_ASIS, RQ_P_QQ, RQ_DEL},  /* '+'  */
+  {RQ_DEL,  RQ_AQ,   RQ_AQ,  RQ_DEL,  RQ_AQ,   RQ_AQ},   /* '??' */
+  {RQ_DEL,  RQ_DEL,  RQ_DEL, RQ_DEL,  RQ_DEL,  RQ_DEL},  /* '*?' */
+  {RQ_ASIS, RQ_PQ_Q, RQ_DEL, RQ_AQ,   RQ_AQ,   RQ_DEL}   /* '+?' */
+};
+
+extern void
+onig_reduce_nested_quantifier(Node* pnode, Node* cnode)
+{
+  int pnum, cnum;
+  QtfrNode *p, *c;
+
+  p = NQTFR(pnode);
+  c = NQTFR(cnode);
+  pnum = popular_quantifier_num(p);
+  cnum = popular_quantifier_num(c);
+  if (pnum < 0 || cnum < 0) return ;
+
+  switch (ReduceTypeTable[cnum][pnum]) {
+  case RQ_DEL:
+    *pnode = *cnode;
+    break;
+  case RQ_A:
+    p->target = c->target;
+    p->lower  = 0;  p->upper = REPEAT_INFINITE;  p->greedy = 1;
+    break;
+  case RQ_AQ:
+    p->target = c->target;
+    p->lower  = 0;  p->upper = REPEAT_INFINITE;  p->greedy = 0;
+    break;
+  case RQ_QQ:
+    p->target = c->target;
+    p->lower  = 0;  p->upper = 1;  p->greedy = 0;
+    break;
+  case RQ_P_QQ:
+    p->target = cnode;
+    p->lower  = 0;  p->upper = 1;  p->greedy = 0;
+    c->lower  = 1;  c->upper = REPEAT_INFINITE;  c->greedy = 1;
+    return ;
+    break;
+  case RQ_PQ_Q:
+    p->target = cnode;
+    p->lower  = 0;  p->upper = 1;  p->greedy = 1;
+    c->lower  = 1;  c->upper = REPEAT_INFINITE;  c->greedy = 0;
+    return ;
+    break;
+  case RQ_ASIS:
+    p->target = cnode;
+    return ;
+    break;
+  }
+
+  c->target = NULL_NODE;
+  onig_node_free(cnode);
+}
+
+
+enum TokenSyms {
+  TK_EOT      = 0,   /* end of token */
+  TK_RAW_BYTE = 1,
+  TK_CHAR,
+  TK_STRING,
+  TK_CODE_POINT,
+  TK_ANYCHAR,
+  TK_CHAR_TYPE,
+  TK_BACKREF,
+  TK_CALL,
+  TK_ANCHOR,
+  TK_OP_REPEAT,
+  TK_INTERVAL,
+  TK_ANYCHAR_ANYTIME,  /* SQL '%' == .* */
+  TK_ALT,
+  TK_SUBEXP_OPEN,
+  TK_SUBEXP_CLOSE,
+  TK_CC_OPEN,
+  TK_QUOTE_OPEN,
+  TK_CHAR_PROPERTY,    /* \p{...}, \P{...} */
+  TK_LINEBREAK,
+  TK_EXTENDED_GRAPHEME_CLUSTER,
+  TK_KEEP,
+  /* in cc */
+  TK_CC_CLOSE,
+  TK_CC_RANGE,
+  TK_POSIX_BRACKET_OPEN,
+  TK_CC_AND,             /* && */
+  TK_CC_CC_OPEN          /* [ */
+};
+
+typedef struct {
+  enum TokenSyms type;
+  int escaped;
+  int base;   /* is number: 8, 16 (used in [....]) */
+  UChar* backp;
+  union {
+    UChar* s;
+    int   c;
+    OnigCodePoint code;
+    struct {
+      int subtype;
+      int ascii_range;
+    } anchor;
+    struct {
+      int lower;
+      int upper;
+      int greedy;
+      int possessive;
+    } repeat;
+    struct {
+      int  num;
+      int  ref1;
+      int* refs;
+      int  by_name;
+#ifdef USE_BACKREF_WITH_LEVEL
+      int  exist_level;
+      int  level;   /* \k<name+n> */
+#endif
+    } backref;
+    struct {
+      UChar* name;
+      UChar* name_end;
+      int    gnum;
+      int    rel;
+    } call;
+    struct {
+      int ctype;
+      int not;
+    } prop;
+  } u;
+} OnigToken;
+
+
+static int
+fetch_range_quantifier(UChar** src, UChar* end, OnigToken* tok, ScanEnv* env)
+{
+  int low, up, syn_allow, non_low = 0;
+  int r = 0;
+  OnigCodePoint c;
+  OnigEncoding enc = env->enc;
+  UChar* p = *src;
+  PFETCH_READY;
+
+  syn_allow = IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_INVALID_INTERVAL);
+
+  if (PEND) {
+    if (syn_allow)
+      return 1;  /* "....{" : OK! */
+    else
+      return ONIGERR_END_PATTERN_AT_LEFT_BRACE;  /* "....{" syntax error */
+  }
+
+  if (! syn_allow) {
+    c = PPEEK;
+    if (c == ')' || c == '(' || c == '|') {
+      return ONIGERR_END_PATTERN_AT_LEFT_BRACE;
+    }
+  }
+
+  low = onig_scan_unsigned_number(&p, end, env->enc);
+  if (low < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
+  if (low > ONIG_MAX_REPEAT_NUM)
+    return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
+
+  if (p == *src) { /* can't read low */
+    if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV)) {
+      /* allow {,n} as {0,n} */
+      low = 0;
+      non_low = 1;
+    }
+    else
+      goto invalid;
+  }
+
+  if (PEND) goto invalid;
+  PFETCH(c);
+  if (c == ',') {
+    UChar* prev = p;
+    up = onig_scan_unsigned_number(&p, end, env->enc);
+    if (up < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
+    if (up > ONIG_MAX_REPEAT_NUM)
+      return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
+
+    if (p == prev) {
+      if (non_low != 0)
+	goto invalid;
+      up = REPEAT_INFINITE;  /* {n,} : {n,infinite} */
+    }
+  }
+  else {
+    if (non_low != 0)
+      goto invalid;
+
+    PUNFETCH;
+    up = low;  /* {n} : exact n times */
+    r = 2;     /* fixed */
+  }
+
+  if (PEND) goto invalid;
+  PFETCH(c);
+  if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_BRACE_INTERVAL)) {
+    if (c != MC_ESC(env->syntax)) goto invalid;
+    PFETCH(c);
+  }
+  if (c != '}') goto invalid;
+
+  if (!IS_REPEAT_INFINITE(up) && low > up) {
+    return ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE;
+  }
+
+  tok->type = TK_INTERVAL;
+  tok->u.repeat.lower = low;
+  tok->u.repeat.upper = up;
+  *src = p;
+  return r; /* 0: normal {n,m}, 2: fixed {n} */
+
+ invalid:
+  if (syn_allow)
+    return 1;  /* OK */
+  else
+    return ONIGERR_INVALID_REPEAT_RANGE_PATTERN;
+}
+
+/* \M-, \C-, \c, or \... */
+static int
+fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env)
+{
+  int v;
+  OnigCodePoint c;
+  OnigEncoding enc = env->enc;
+  UChar* p = *src;
+
+  if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;
+
+  PFETCH_S(c);
+  switch (c) {
+  case 'M':
+    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META)) {
+      if (PEND) return ONIGERR_END_PATTERN_AT_META;
+      PFETCH_S(c);
+      if (c != '-') return ONIGERR_META_CODE_SYNTAX;
+      if (PEND) return ONIGERR_END_PATTERN_AT_META;
+      PFETCH_S(c);
+      if (c == MC_ESC(env->syntax)) {
+        v = fetch_escaped_value(&p, end, env);
+        if (v < 0) return v;
+        c = (OnigCodePoint )v;
+      }
+      c = ((c & 0xff) | 0x80);
+    }
+    else
+      goto backslash;
+    break;
+
+  case 'C':
+    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL)) {
+      if (PEND) return ONIGERR_END_PATTERN_AT_CONTROL;
+      PFETCH_S(c);
+      if (c != '-') return ONIGERR_CONTROL_CODE_SYNTAX;
+      goto control;
+    }
+    else
+      goto backslash;
+
+  case 'c':
+    if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_C_CONTROL)) {
+    control:
+      if (PEND) return ONIGERR_END_PATTERN_AT_CONTROL;
+      PFETCH_S(c);
+      if (c == '?') {
+        c = 0177;
+      }
+      else {
+        if (c == MC_ESC(env->syntax)) {
+          v = fetch_escaped_value(&p, end, env);
+          if (v < 0) return v;
+          c = (OnigCodePoint )v;
+        }
+        c &= 0x9f;
+      }
+      break;
+    }
+    /* fall through */
+
+  default:
+    {
+    backslash:
+      c = conv_backslash_value(c, env);
+    }
+    break;
+  }
+
+  *src = p;
+  return c;
+}
+
+static int fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env);
+
+static OnigCodePoint
+get_name_end_code_point(OnigCodePoint start)
+{
+  switch (start) {
+  case '<':  return (OnigCodePoint )'>'; break;
+  case '\'': return (OnigCodePoint )'\''; break;
+  case '(':  return (OnigCodePoint )')'; break;
+  case '{':  return (OnigCodePoint )'}'; break;
+  default:
+    break;
+  }
+
+  return (OnigCodePoint )0;
+}
+
+#ifdef USE_NAMED_GROUP
+#ifdef USE_BACKREF_WITH_LEVEL
+/*
+   \k<name+n>, \k<name-n>
+   \k<num+n>,  \k<num-n>
+   \k<-num+n>, \k<-num-n>
+*/
+static int
+fetch_name_with_level(OnigCodePoint start_code, UChar** src, UChar* end,
+		      UChar** rname_end, ScanEnv* env,
+		      int* rback_num, int* rlevel)
+{
+  int r, sign, is_num, exist_level;
+  OnigCodePoint end_code;
+  OnigCodePoint c = 0;
+  OnigEncoding enc = env->enc;
+  UChar *name_end;
+  UChar *pnum_head;
+  UChar *p = *src;
+  PFETCH_READY;
+
+  *rback_num = 0;
+  is_num = exist_level = 0;
+  sign = 1;
+  pnum_head = *src;
+
+  end_code = get_name_end_code_point(start_code);
+
+  name_end = end;
+  r = 0;
+  if (PEND) {
+    return ONIGERR_EMPTY_GROUP_NAME;
+  }
+  else {
+    PFETCH(c);
+    if (c == end_code)
+      return ONIGERR_EMPTY_GROUP_NAME;
+
+    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+      is_num = 1;
+    }
+    else if (c == '-') {
+      is_num = 2;
+      sign = -1;
+      pnum_head = p;
+    }
+    else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
+      r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
+    }
+  }
+
+  while (!PEND) {
+    name_end = p;
+    PFETCH(c);
+    if (c == end_code || c == ')' || c == '+' || c == '-') {
+      if (is_num == 2) r = ONIGERR_INVALID_GROUP_NAME;
+      break;
+    }
+
+    if (is_num != 0) {
+      if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+        is_num = 1;
+      }
+      else {
+        r = ONIGERR_INVALID_GROUP_NAME;
+        is_num = 0;
+      }
+    }
+    else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
+      r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
+    }
+  }
+
+  if (r == 0 && c != end_code) {
+    if (c == '+' || c == '-') {
+      int level;
+      int flag = (c == '-' ? -1 : 1);
+
+      PFETCH(c);
+      if (! ONIGENC_IS_CODE_DIGIT(enc, c)) goto err;
+      PUNFETCH;
+      level = onig_scan_unsigned_number(&p, end, enc);
+      if (level < 0) return ONIGERR_TOO_BIG_NUMBER;
+      *rlevel = (level * flag);
+      exist_level = 1;
+
+      PFETCH(c);
+      if (c == end_code)
+	goto end;
+    }
+
+  err:
+    r = ONIGERR_INVALID_GROUP_NAME;
+    name_end = end;
+  }
+
+ end:
+  if (r == 0) {
+    if (is_num != 0) {
+      *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc);
+      if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER;
+      else if (*rback_num == 0) goto err;
+
+      *rback_num *= sign;
+    }
+
+    *rname_end = name_end;
+    *src = p;
+    return (exist_level ? 1 : 0);
+  }
+  else {
+    onig_scan_env_set_error_string(env, r, *src, name_end);
+    return r;
+  }
+}
+#endif /* USE_BACKREF_WITH_LEVEL */
+
+/*
+  ref: 0 -> define name    (don't allow number name)
+       1 -> reference name (allow number name)
+*/
+static int
+fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
+	   UChar** rname_end, ScanEnv* env, int* rback_num, int ref)
+{
+  int r, is_num, sign;
+  OnigCodePoint end_code;
+  OnigCodePoint c = 0;
+  OnigEncoding enc = env->enc;
+  UChar *name_end;
+  UChar *pnum_head;
+  UChar *p = *src;
+
+  *rback_num = 0;
+
+  end_code = get_name_end_code_point(start_code);
+
+  name_end = end;
+  pnum_head = *src;
+  r = 0;
+  is_num = 0;
+  sign = 1;
+  if (PEND) {
+    return ONIGERR_EMPTY_GROUP_NAME;
+  }
+  else {
+    PFETCH_S(c);
+    if (c == end_code)
+      return ONIGERR_EMPTY_GROUP_NAME;
+
+    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+      if (ref == 1)
+        is_num = 1;
+      else {
+        r = ONIGERR_INVALID_GROUP_NAME;
+        is_num = 0;
+      }
+    }
+    else if (c == '-') {
+      if (ref == 1) {
+        is_num = 2;
+        sign = -1;
+        pnum_head = p;
+      }
+      else {
+	r = ONIGERR_INVALID_GROUP_NAME;
+	is_num = 0;
+      }
+    }
+    else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
+      r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
+    }
+  }
+
+  if (r == 0) {
+    while (!PEND) {
+      name_end = p;
+      PFETCH_S(c);
+      if (c == end_code || c == ')') {
+	if (is_num == 2) r = ONIGERR_INVALID_GROUP_NAME;
+	break;
+      }
+
+      if (is_num != 0) {
+        if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+          is_num = 1;
+        }
+        else {
+          if (!ONIGENC_IS_CODE_WORD(enc, c))
+            r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
+          else
+            r = ONIGERR_INVALID_GROUP_NAME;
+          is_num = 0;
+        }
+      }
+      else {
+        if (!ONIGENC_IS_CODE_WORD(enc, c)) {
+          r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
+        }
+      }
+    }
+
+    if (c != end_code) {
+      r = ONIGERR_INVALID_GROUP_NAME;
+      name_end = end;
+    }
+
+    if (is_num != 0) {
+      *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc);
+      if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER;
+      else if (*rback_num == 0) {
+        r = ONIGERR_INVALID_GROUP_NAME;
+        goto err;
+      }
+
+      *rback_num *= sign;
+    }
+
+    *rname_end = name_end;
+    *src = p;
+    return 0;
+  }
+  else {
+    while (!PEND) {
+      name_end = p;
+      PFETCH_S(c);
+      if (c == end_code || c == ')')
+        break;
+    }
+    if (PEND)
+      name_end = end;
+
+  err:
+    onig_scan_env_set_error_string(env, r, *src, name_end);
+    return r;
+  }
+}
+#else
+static int
+fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
+	   UChar** rname_end, ScanEnv* env, int* rback_num, int ref)
+{
+  int r, is_num, sign;
+  OnigCodePoint end_code;
+  OnigCodePoint c = 0;
+  UChar *name_end;
+  OnigEncoding enc = env->enc;
+  UChar *pnum_head;
+  UChar *p = *src;
+  PFETCH_READY;
+
+  *rback_num = 0;
+
+  end_code = get_name_end_code_point(start_code);
+
+  *rname_end = name_end = end;
+  r = 0;
+  pnum_head = *src;
+  is_num = 0;
+  sign = 1;
+
+  if (PEND) {
+    return ONIGERR_EMPTY_GROUP_NAME;
+  }
+  else {
+    PFETCH(c);
+    if (c == end_code)
+      return ONIGERR_EMPTY_GROUP_NAME;
+
+    if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
+      is_num = 1;
+    }
+    else if (c == '-') {
+      is_num = 2;
+      sign = -1;
+      pnum_head = p;
+    }
+    else {
+      r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
+    }
+  }
+
+  while (!PEND) {
+    name_end = p;
+
+    PFETCH(c);
+    if (c == end_code || c == ')') break;
+    if (! ONIGENC_IS_CODE_DIGIT(enc, c))
+      r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
+  }
+  if (r == 0 && c != end_code) {
+    r = ONIGERR_INVALID_GROUP_NAME;
+    name_end = end;
+  }
+
+  if (r == 0) {
+    *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc);
+    if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER;
+    else if (*rback_num == 0) {
+      r = ONIGERR_INVALID_GROUP_NAME;
+      goto err;
+    }
+    *rback_num *= sign;
+
+    *rname_end = name_end;
+    *src = p;
+    return 0;
+  }
+  else {
+  err:
+    onig_scan_env_set_error_string(env, r, *src, name_end);
+    return r;
+  }
+}
+#endif /* USE_NAMED_GROUP */
+
+static void
+CC_ESC_WARN(ScanEnv* env, UChar *c)
+{
+  if (onig_warn == onig_null_warn) return ;
+
+  if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_CC_OP_NOT_ESCAPED) &&
+      IS_SYNTAX_BV(env->syntax, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC)) {
+    UChar buf[WARN_BUFSIZE];
+    onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
+		env->pattern, env->pattern_end,
+                (UChar* )"character class has '%s' without escape", c);
+    (*onig_warn)((char* )buf);
+  }
+}
+
+static void
+CLOSE_BRACKET_WITHOUT_ESC_WARN(ScanEnv* env, UChar* c)
+{
+  if (onig_warn == onig_null_warn) return ;
+
+  if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_CC_OP_NOT_ESCAPED)) {
+    UChar buf[WARN_BUFSIZE];
+    onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
+		env->pattern, env->pattern_end,
+		(UChar* )"regular expression has '%s' without escape", c);
+    (*onig_warn)((char* )buf);
+  }
+}
+
+static UChar*
+find_str_position(OnigCodePoint s[], int n, UChar* from, UChar* to,
+		  UChar **next, OnigEncoding enc)
+{
+  int i;
+  OnigCodePoint x;
+  UChar *q;
+  UChar *p = from;
+
+  while (p < to) {
+    x = ONIGENC_MBC_TO_CODE(enc, p, to);
+    q = p + enclen(enc, p);
+    if (x == s[0]) {
+      for (i = 1; i < n && q < to; i++) {
+	x = ONIGENC_MBC_TO_CODE(enc, q, to);
+	if (x != s[i]) break;
+	q += enclen(enc, q);
+      }
+      if (i >= n) {
+	if (IS_NOT_NULL(next))
+	  *next = q;
+	return p;
+      }
+    }
+    p = q;
+  }
+  return NULL_UCHARP;
+}
+
+static int
+str_exist_check_with_esc(OnigCodePoint s[], int n, UChar* from, UChar* to,
+		 OnigCodePoint bad, OnigEncoding enc, OnigSyntaxType* syn)
+{
+  int i, in_esc;
+  OnigCodePoint x;
+  UChar *q;
+  UChar *p = from;
+
+  in_esc = 0;
+  while (p < to) {
+    if (in_esc) {
+      in_esc = 0;
+      p += enclen(enc, p);
+    }
+    else {
+      x = ONIGENC_MBC_TO_CODE(enc, p, to);
+      q = p + enclen(enc, p);
+      if (x == s[0]) {
+	for (i = 1; i < n && q < to; i++) {
+	  x = ONIGENC_MBC_TO_CODE(enc, q, to);
+	  if (x != s[i]) break;
+	  q += enclen(enc, q);
+	}
+	if (i >= n) return 1;
+	p += enclen(enc, p);
+      }
+      else {
+	x = ONIGENC_MBC_TO_CODE(enc, p, to);
+	if (x == bad) return 0;
+	else if (x == MC_ESC(syn)) in_esc = 1;
+	p = q;
+      }
+    }
+  }
+  return 0;
+}
+
+static int
+fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
+{
+  int num;
+  OnigCodePoint c, c2;
+  OnigSyntaxType* syn = env->syntax;
+  OnigEncoding enc = env->enc;
+  UChar* prev;
+  UChar* p = *src;
+  PFETCH_READY;
+
+  if (PEND) {
+    tok->type = TK_EOT;
+    return tok->type;
+  }
+
+  PFETCH(c);
+  tok->type = TK_CHAR;
+  tok->base = 0;
+  tok->u.c  = c;
+  tok->escaped = 0;
+
+  if (c == ']') {
+    tok->type = TK_CC_CLOSE;
+  }
+  else if (c == '-') {
+    tok->type = TK_CC_RANGE;
+  }
+  else if (c == MC_ESC(syn)) {
+    if (! IS_SYNTAX_BV(syn, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC))
+      goto end;
+
+    if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;
+
+    PFETCH(c);
+    tok->escaped = 1;
+    tok->u.c = c;
+    switch (c) {
+    case 'w':
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
+      tok->u.prop.not   = 0;
+      break;
+    case 'W':
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
+      tok->u.prop.not   = 1;
+      break;
+    case 'd':
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
+      tok->u.prop.not   = 0;
+      break;
+    case 'D':
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
+      tok->u.prop.not   = 1;
+      break;
+    case 's':
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
+      tok->u.prop.not   = 0;
+      break;
+    case 'S':
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
+      tok->u.prop.not   = 1;
+      break;
+    case 'h':
+      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+      tok->u.prop.not   = 0;
+      break;
+    case 'H':
+      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+      tok->u.prop.not   = 1;
+      break;
+
+    case 'p':
+    case 'P':
+      c2 = PPEEK;
+      if (c2 == '{' &&
+	  IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {
+	PINC;
+	tok->type = TK_CHAR_PROPERTY;
+	tok->u.prop.not = (c == 'P' ? 1 : 0);
+
+	if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {
+	  PFETCH(c2);
+	  if (c2 == '^') {
+	    tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);
+	  }
+	  else
+	    PUNFETCH;
+	}
+      }
+      break;
+
+    case 'x':
+      if (PEND) break;
+
+      prev = p;
+      if (PPEEK_IS('{') && IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_BRACE_HEX8)) {
+	PINC;
+	num = scan_unsigned_hexadecimal_number(&p, end, 0, 8, enc);
+	if (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
+	if (!PEND) {
+          c2 = PPEEK;
+          if (ONIGENC_IS_CODE_XDIGIT(enc, c2))
+            return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;
+        }
+
+	if (p > prev + enclen(enc, prev) && !PEND && (PPEEK_IS('}'))) {
+	  PINC;
+	  tok->type   = TK_CODE_POINT;
+	  tok->base   = 16;
+	  tok->u.code = (OnigCodePoint )num;
+	}
+	else {
+	  /* can't read nothing or invalid format */
+	  p = prev;
+	}
+      }
+      else if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_HEX2)) {
+	num = scan_unsigned_hexadecimal_number(&p, end, 0, 2, enc);
+	if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
+	if (p == prev) {  /* can't read nothing. */
+	  num = 0; /* but, it's not error */
+	}
+	tok->type = TK_RAW_BYTE;
+	tok->base = 16;
+	tok->u.c  = num;
+      }
+      break;
+
+    case 'u':
+      if (PEND) break;
+
+      prev = p;
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_U_HEX4)) {
+	num = scan_unsigned_hexadecimal_number(&p, end, 4, 4, enc);
+	if (num < -1) return ONIGERR_TOO_SHORT_DIGITS;
+	else if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
+	if (p == prev) {  /* can't read nothing. */
+	  num = 0; /* but, it's not error */
+	}
+	tok->type   = TK_CODE_POINT;
+	tok->base   = 16;
+	tok->u.code = (OnigCodePoint )num;
+      }
+      break;
+
+    case '0':
+    case '1': case '2': case '3': case '4': case '5': case '6': case '7':
+      if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) {
+	PUNFETCH;
+	prev = p;
+	num = scan_unsigned_octal_number(&p, end, 3, enc);
+	if (num < 0 || 0xff < num) return ONIGERR_TOO_BIG_NUMBER;
+	if (p == prev) {  /* can't read nothing. */
+	  num = 0; /* but, it's not error */
+	}
+	tok->type = TK_RAW_BYTE;
+	tok->base = 8;
+	tok->u.c  = num;
+      }
+      break;
+
+    default:
+      PUNFETCH;
+      num = fetch_escaped_value(&p, end, env);
+      if (num < 0) return num;
+      if (tok->u.c != num) {
+	tok->u.code = (OnigCodePoint )num;
+	tok->type   = TK_CODE_POINT;
+      }
+      break;
+    }
+  }
+  else if (c == '[') {
+    if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_POSIX_BRACKET) && (PPEEK_IS(':'))) {
+      OnigCodePoint send[] = { (OnigCodePoint )':', (OnigCodePoint )']' };
+      tok->backp = p; /* point at '[' is read */
+      PINC;
+      if (str_exist_check_with_esc(send, 2, p, end,
+                                   (OnigCodePoint )']', enc, syn)) {
+	tok->type = TK_POSIX_BRACKET_OPEN;
+      }
+      else {
+	PUNFETCH;
+	goto cc_in_cc;
+      }
+    }
+    else {
+    cc_in_cc:
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP)) {
+	tok->type = TK_CC_CC_OPEN;
+      }
+      else {
+	CC_ESC_WARN(env, (UChar* )"[");
+      }
+    }
+  }
+  else if (c == '&') {
+    if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP) &&
+	!PEND && (PPEEK_IS('&'))) {
+      PINC;
+      tok->type = TK_CC_AND;
+    }
+  }
+
+ end:
+  *src = p;
+  return tok->type;
+}
+
+#ifdef USE_NAMED_GROUP
+static int
+fetch_named_backref_token(OnigCodePoint c, OnigToken* tok, UChar** src,
+			  UChar* end, ScanEnv* env)
+{
+  int r, num;
+  OnigSyntaxType* syn = env->syntax;
+  UChar* prev;
+  UChar* p = *src;
+  UChar* name_end;
+  int* backs;
+  int back_num;
+
+  prev = p;
+
+#ifdef USE_BACKREF_WITH_LEVEL
+  name_end = NULL_UCHARP; /* no need. escape gcc warning. */
+  r = fetch_name_with_level(c, &p, end, &name_end,
+			    env, &back_num, &tok->u.backref.level);
+  if (r == 1) tok->u.backref.exist_level = 1;
+  else        tok->u.backref.exist_level = 0;
+#else
+  r = fetch_name(&p, end, &name_end, env, &back_num, 1);
+#endif
+  if (r < 0) return r;
+
+  if (back_num != 0) {
+    if (back_num < 0) {
+      back_num = BACKREF_REL_TO_ABS(back_num, env);
+      if (back_num <= 0)
+	return ONIGERR_INVALID_BACKREF;
+    }
+
+    if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
+      if (back_num > env->num_mem ||
+	  IS_NULL(SCANENV_MEM_NODES(env)[back_num]))
+	return ONIGERR_INVALID_BACKREF;
+    }
+    tok->type = TK_BACKREF;
+    tok->u.backref.by_name = 0;
+    tok->u.backref.num  = 1;
+    tok->u.backref.ref1 = back_num;
+  }
+  else {
+    num = onig_name_to_group_numbers(env->reg, prev, name_end, &backs);
+    if (num <= 0) {
+      onig_scan_env_set_error_string(env,
+		     ONIGERR_UNDEFINED_NAME_REFERENCE, prev, name_end);
+      return ONIGERR_UNDEFINED_NAME_REFERENCE;
+    }
+    if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
+      int i;
+      for (i = 0; i < num; i++) {
+	if (backs[i] > env->num_mem ||
+	    IS_NULL(SCANENV_MEM_NODES(env)[backs[i]]))
+	  return ONIGERR_INVALID_BACKREF;
+      }
+    }
+
+    tok->type = TK_BACKREF;
+    tok->u.backref.by_name = 1;
+    if (num == 1) {
+      tok->u.backref.num  = 1;
+      tok->u.backref.ref1 = backs[0];
+    }
+    else {
+      tok->u.backref.num  = num;
+      tok->u.backref.refs = backs;
+    }
+  }
+  *src = p;
+  return 0;
+}
+#endif
+
+static int
+fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
+{
+  int r, num;
+  OnigCodePoint c;
+  OnigEncoding enc = env->enc;
+  OnigSyntaxType* syn = env->syntax;
+  UChar* prev;
+  UChar* p = *src;
+  PFETCH_READY;
+
+ start:
+  if (PEND) {
+    tok->type = TK_EOT;
+    return tok->type;
+  }
+
+  tok->type  = TK_STRING;
+  tok->base  = 0;
+  tok->backp = p;
+
+  PFETCH(c);
+  if (IS_MC_ESC_CODE(c, syn)) {
+    if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;
+
+    tok->backp = p;
+    PFETCH(c);
+
+    tok->u.c = c;
+    tok->escaped = 1;
+    switch (c) {
+    case '*':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF)) break;
+      tok->type = TK_OP_REPEAT;
+      tok->u.repeat.lower = 0;
+      tok->u.repeat.upper = REPEAT_INFINITE;
+      goto greedy_check;
+      break;
+
+    case '+':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_PLUS_ONE_INF)) break;
+      tok->type = TK_OP_REPEAT;
+      tok->u.repeat.lower = 1;
+      tok->u.repeat.upper = REPEAT_INFINITE;
+      goto greedy_check;
+      break;
+
+    case '?':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_QMARK_ZERO_ONE)) break;
+      tok->type = TK_OP_REPEAT;
+      tok->u.repeat.lower = 0;
+      tok->u.repeat.upper = 1;
+    greedy_check:
+      if (!PEND && PPEEK_IS('?') &&
+	  IS_SYNTAX_OP(syn, ONIG_SYN_OP_QMARK_NON_GREEDY)) {
+	PFETCH(c);
+	tok->u.repeat.greedy     = 0;
+	tok->u.repeat.possessive = 0;
+      }
+      else {
+      possessive_check:
+	if (!PEND && PPEEK_IS('+') &&
+	    ((IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT) &&
+	      tok->type != TK_INTERVAL)  ||
+	     (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL) &&
+	      tok->type == TK_INTERVAL))) {
+	  PFETCH(c);
+	  tok->u.repeat.greedy     = 1;
+	  tok->u.repeat.possessive = 1;
+	}
+	else {
+	  tok->u.repeat.greedy     = 1;
+	  tok->u.repeat.possessive = 0;
+	}
+      }
+      break;
+
+    case '{':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_BRACE_INTERVAL)) break;
+      r = fetch_range_quantifier(&p, end, tok, env);
+      if (r < 0) return r;  /* error */
+      if (r == 0) goto greedy_check;
+      else if (r == 2) { /* {n} */
+	if (IS_SYNTAX_BV(syn, ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY))
+	  goto possessive_check;
+
+	goto greedy_check;
+      }
+      /* r == 1 : normal char */
+      break;
+
+    case '|':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_VBAR_ALT)) break;
+      tok->type = TK_ALT;
+      break;
+
+    case '(':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LPAREN_SUBEXP)) break;
+      tok->type = TK_SUBEXP_OPEN;
+      break;
+
+    case ')':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LPAREN_SUBEXP)) break;
+      tok->type = TK_SUBEXP_CLOSE;
+      break;
+
+    case 'w':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
+      tok->u.prop.not   = 0;
+      break;
+
+    case 'W':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
+      tok->u.prop.not   = 1;
+      break;
+
+    case 'b':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_WORD_BOUND;
+      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option)
+		&& ! IS_WORD_BOUND_ALL_RANGE(env->option);
+      break;
+
+    case 'B':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_NOT_WORD_BOUND;
+      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option)
+		&& ! IS_WORD_BOUND_ALL_RANGE(env->option);
+      break;
+
+#ifdef USE_WORD_BEGIN_END
+    case '<':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_WORD_BEGIN;
+      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option);
+      break;
+
+    case '>':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_WORD_END;
+      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option);
+      break;
+#endif
+
+    case 's':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
+      tok->u.prop.not   = 0;
+      break;
+
+    case 'S':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
+      tok->u.prop.not   = 1;
+      break;
+
+    case 'd':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
+      tok->u.prop.not   = 0;
+      break;
+
+    case 'D':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
+      tok->u.prop.not   = 1;
+      break;
+
+    case 'h':
+      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+      tok->u.prop.not   = 0;
+      break;
+
+    case 'H':
+      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
+      tok->type = TK_CHAR_TYPE;
+      tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+      tok->u.prop.not   = 1;
+      break;
+
+    case 'A':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;
+    begin_buf:
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_BEGIN_BUF;
+      break;
+
+    case 'Z':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_SEMI_END_BUF;
+      break;
+
+    case 'z':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;
+    end_buf:
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_END_BUF;
+      break;
+
+    case 'G':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = ANCHOR_BEGIN_POSITION;
+      break;
+
+    case '`':
+      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR)) break;
+      goto begin_buf;
+      break;
+
+    case '\'':
+      if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR)) break;
+      goto end_buf;
+      break;
+
+    case 'x':
+      if (PEND) break;
+
+      prev = p;
+      if (PPEEK_IS('{') && IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_BRACE_HEX8)) {
+	PINC;
+	num = scan_unsigned_hexadecimal_number(&p, end, 0, 8, enc);
+	if (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
+	if (!PEND) {
+          if (ONIGENC_IS_CODE_XDIGIT(enc, PPEEK))
+            return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;
+        }
+
+	if ((p > prev + enclen(enc, prev)) && !PEND && PPEEK_IS('}')) {
+	  PINC;
+	  tok->type   = TK_CODE_POINT;
+	  tok->u.code = (OnigCodePoint )num;
+	}
+	else {
+	  /* can't read nothing or invalid format */
+	  p = prev;
+	}
+      }
+      else if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_HEX2)) {
+	num = scan_unsigned_hexadecimal_number(&p, end, 0, 2, enc);
+	if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
+	if (p == prev) {  /* can't read nothing. */
+	  num = 0; /* but, it's not error */
+	}
+	tok->type = TK_RAW_BYTE;
+	tok->base = 16;
+	tok->u.c  = num;
+      }
+      break;
+
+    case 'u':
+      if (PEND) break;
+
+      prev = p;
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_U_HEX4)) {
+	num = scan_unsigned_hexadecimal_number(&p, end, 4, 4, enc);
+	if (num < -1) return ONIGERR_TOO_SHORT_DIGITS;
+	else if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
+	if (p == prev) {  /* can't read nothing. */
+	  num = 0; /* but, it's not error */
+	}
+	tok->type   = TK_CODE_POINT;
+	tok->base   = 16;
+	tok->u.code = (OnigCodePoint )num;
+      }
+      break;
+
+    case '1': case '2': case '3': case '4':
+    case '5': case '6': case '7': case '8': case '9':
+      PUNFETCH;
+      prev = p;
+      num = onig_scan_unsigned_number(&p, end, enc);
+      if (num < 0 || num > ONIG_MAX_BACKREF_NUM) {
+        goto skip_backref;
+      }
+
+      if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_DECIMAL_BACKREF) &&
+	  (num <= env->num_mem || num <= 9)) { /* This spec. from GNU regex */
+	if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
+	  if (num > env->num_mem || IS_NULL(SCANENV_MEM_NODES(env)[num]))
+	    return ONIGERR_INVALID_BACKREF;
+	}
+
+	tok->type = TK_BACKREF;
+	tok->u.backref.num     = 1;
+	tok->u.backref.ref1    = num;
+	tok->u.backref.by_name = 0;
+#ifdef USE_BACKREF_WITH_LEVEL
+	tok->u.backref.exist_level = 0;
+#endif
+	break;
+      }
+
+    skip_backref:
+      if (c == '8' || c == '9') {
+	/* normal char */
+	p = prev; PINC;
+	break;
+      }
+
+      p = prev;
+      /* fall through */
+    case '0':
+      if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) {
+	prev = p;
+	num = scan_unsigned_octal_number(&p, end, (c == '0' ? 2:3), enc);
+	if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
+	if (p == prev) {  /* can't read nothing. */
+	  num = 0; /* but, it's not error */
+	}
+	tok->type = TK_RAW_BYTE;
+	tok->base = 8;
+	tok->u.c  = num;
+      }
+      else if (c != '0') {
+	PINC;
+      }
+      break;
+
+#ifdef USE_NAMED_GROUP
+    case 'k':
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_K_NAMED_BACKREF)) {
+	PFETCH(c);
+	if (c == '<' || c == '\'') {
+	  r = fetch_named_backref_token(c, tok, &p, end, env);
+	  if (r < 0) return r;
+	}
+	else
+	  PUNFETCH;
+      }
+      break;
+#endif
+
+#if defined(USE_SUBEXP_CALL) || defined(USE_NAMED_GROUP)
+    case 'g':
+#ifdef USE_NAMED_GROUP
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_G_BRACE_BACKREF)) {
+	PFETCH(c);
+	if (c == '{') {
+	  r = fetch_named_backref_token(c, tok, &p, end, env);
+	  if (r < 0) return r;
+	}
+	else
+	  PUNFETCH;
+      }
+#endif
+#ifdef USE_SUBEXP_CALL
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_G_SUBEXP_CALL)) {
+	PFETCH(c);
+	if (c == '<' || c == '\'') {
+	  int gnum = -1, rel = 0;
+	  UChar* name_end;
+	  OnigCodePoint cnext;
+
+	  cnext = PPEEK;
+	  if (cnext == '0') {
+	    PINC;
+	    if (PPEEK_IS(get_name_end_code_point(c))) {  /* \g<0>, \g'0' */
+	      PINC;
+	      name_end = p;
+	      gnum = 0;
+	    }
+	  }
+	  else if (cnext == '+') {
+	    PINC;
+	    rel = 1;
+	  }
+	  prev = p;
+	  if (gnum < 0) {
+	    r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &gnum, 1);
+	    if (r < 0) return r;
+	  }
+
+	  tok->type = TK_CALL;
+	  tok->u.call.name     = prev;
+	  tok->u.call.name_end = name_end;
+	  tok->u.call.gnum     = gnum;
+	  tok->u.call.rel      = rel;
+	}
+	else
+	  PUNFETCH;
+      }
+#endif
+      break;
+#endif
+
+    case 'Q':
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE)) {
+	tok->type = TK_QUOTE_OPEN;
+      }
+      break;
+
+    case 'p':
+    case 'P':
+      if (PPEEK_IS('{') &&
+	  IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {
+	PINC;
+	tok->type = TK_CHAR_PROPERTY;
+	tok->u.prop.not = (c == 'P' ? 1 : 0);
+
+	if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {
+	  PFETCH(c);
+	  if (c == '^') {
+	    tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);
+	  }
+	  else
+	    PUNFETCH;
+	}
+      }
+      break;
+
+    case 'R':
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_CAPITAL_R_LINEBREAK)) {
+	tok->type = TK_LINEBREAK;
+      }
+      break;
+
+    case 'X':
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_CAPITAL_X_EXTENDED_GRAPHEME_CLUSTER)) {
+	tok->type = TK_EXTENDED_GRAPHEME_CLUSTER;
+      }
+      break;
+
+    case 'K':
+      if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_CAPITAL_K_KEEP)) {
+	tok->type = TK_KEEP;
+      }
+      break;
+
+    default:
+      PUNFETCH;
+      num = fetch_escaped_value(&p, end, env);
+      if (num < 0) return num;
+      /* set_raw: */
+      if (tok->u.c != num) {
+	tok->type = TK_CODE_POINT;
+	tok->u.code = (OnigCodePoint )num;
+      }
+      else { /* string */
+	p = tok->backp + enclen(enc, tok->backp);
+      }
+      break;
+    }
+  }
+  else {
+    tok->u.c = c;
+    tok->escaped = 0;
+
+#ifdef USE_VARIABLE_META_CHARS
+    if ((c != ONIG_INEFFECTIVE_META_CHAR) &&
+	IS_SYNTAX_OP(syn, ONIG_SYN_OP_VARIABLE_META_CHARACTERS)) {
+      if (c == MC_ANYCHAR(syn))
+	goto any_char;
+      else if (c == MC_ANYTIME(syn))
+	goto anytime;
+      else if (c == MC_ZERO_OR_ONE_TIME(syn))
+	goto zero_or_one_time;
+      else if (c == MC_ONE_OR_MORE_TIME(syn))
+	goto one_or_more_time;
+      else if (c == MC_ANYCHAR_ANYTIME(syn)) {
+	tok->type = TK_ANYCHAR_ANYTIME;
+	goto out;
+      }
+    }
+#endif
+
+    switch (c) {
+    case '.':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_DOT_ANYCHAR)) break;
+#ifdef USE_VARIABLE_META_CHARS
+    any_char:
+#endif
+      tok->type = TK_ANYCHAR;
+      break;
+
+    case '*':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ASTERISK_ZERO_INF)) break;
+#ifdef USE_VARIABLE_META_CHARS
+    anytime:
+#endif
+      tok->type = TK_OP_REPEAT;
+      tok->u.repeat.lower = 0;
+      tok->u.repeat.upper = REPEAT_INFINITE;
+      goto greedy_check;
+      break;
+
+    case '+':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_PLUS_ONE_INF)) break;
+#ifdef USE_VARIABLE_META_CHARS
+    one_or_more_time:
+#endif
+      tok->type = TK_OP_REPEAT;
+      tok->u.repeat.lower = 1;
+      tok->u.repeat.upper = REPEAT_INFINITE;
+      goto greedy_check;
+      break;
+
+    case '?':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_QMARK_ZERO_ONE)) break;
+#ifdef USE_VARIABLE_META_CHARS
+    zero_or_one_time:
+#endif
+      tok->type = TK_OP_REPEAT;
+      tok->u.repeat.lower = 0;
+      tok->u.repeat.upper = 1;
+      goto greedy_check;
+      break;
+
+    case '{':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_BRACE_INTERVAL)) break;
+      r = fetch_range_quantifier(&p, end, tok, env);
+      if (r < 0) return r;  /* error */
+      if (r == 0) goto greedy_check;
+      else if (r == 2) { /* {n} */
+	if (IS_SYNTAX_BV(syn, ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY))
+	  goto possessive_check;
+
+	goto greedy_check;
+      }
+      /* r == 1 : normal char */
+      break;
+
+    case '|':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_VBAR_ALT)) break;
+      tok->type = TK_ALT;
+      break;
+
+    case '(':
+      if (PPEEK_IS('?') &&
+          IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_QMARK_GROUP_EFFECT)) {
+        PINC;
+        if (PPEEK_IS('#')) {
+          PFETCH(c);
+          while (1) {
+            if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
+            PFETCH(c);
+            if (c == MC_ESC(syn)) {
+              if (!PEND) PFETCH(c);
+            }
+            else {
+              if (c == ')') break;
+            }
+          }
+          goto start;
+        }
+#ifdef USE_PERL_SUBEXP_CALL
+	/* (?&name), (?n), (?R), (?0), (?+n), (?-n) */
+	c = PPEEK;
+	if ((c == '&' || c == 'R' || ONIGENC_IS_CODE_DIGIT(enc, c)) &&
+	    IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_SUBEXP_CALL)) {
+	  /* (?&name), (?n), (?R), (?0) */
+	  int gnum;
+	  UChar *name;
+	  UChar *name_end;
+
+	  if (c == 'R' || c == '0') {
+	    PINC;   /* skip 'R' / '0' */
+	    if (!PPEEK_IS(')')) return ONIGERR_INVALID_GROUP_NAME;
+	    PINC;   /* skip ')' */
+	    name_end = name = p;
+	    gnum = 0;
+	  }
+	  else {
+	    int numref = 1;
+	    if (c == '&') {     /* (?&name) */
+	      PINC;
+	      numref = 0;       /* don't allow number name */
+	    }
+	    name = p;
+	    r = fetch_name((OnigCodePoint )'(', &p, end, &name_end, env, &gnum, numref);
+	    if (r < 0) return r;
+	  }
+
+	  tok->type = TK_CALL;
+	  tok->u.call.name     = name;
+	  tok->u.call.name_end = name_end;
+	  tok->u.call.gnum     = gnum;
+	  tok->u.call.rel      = 0;
+	  break;
+	}
+	else if ((c == '-' || c == '+') &&
+	    IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_SUBEXP_CALL)) {
+	  /* (?+n), (?-n) */
+	  int gnum;
+	  UChar *name;
+	  UChar *name_end;
+	  OnigCodePoint cnext;
+	  PFETCH_READY;
+
+	  PINC;     /* skip '-' / '+' */
+	  cnext = PPEEK;
+	  if (ONIGENC_IS_CODE_DIGIT(enc, cnext)) {
+	    if (c == '-') PUNFETCH;
+	    name = p;
+	    r = fetch_name((OnigCodePoint )'(', &p, end, &name_end, env, &gnum, 1);
+	    if (r < 0) return r;
+
+	    tok->type = TK_CALL;
+	    tok->u.call.name     = name;
+	    tok->u.call.name_end = name_end;
+	    tok->u.call.gnum     = gnum;
+	    tok->u.call.rel      = 1;
+	    break;
+	  }
+	}
+#endif /* USE_PERL_SUBEXP_CALL */
+#ifdef USE_CAPITAL_P_NAMED_GROUP
+	if (PPEEK_IS('P') &&
+	    IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_CAPITAL_P_NAMED_GROUP)) {
+	  int gnum;
+	  UChar *name;
+	  UChar *name_end;
+	  PFETCH_READY;
+
+	  PINC;     /* skip 'P' */
+	  PFETCH(c);
+	  if (c == '=') {       /* (?P=name): backref */
+	    r = fetch_named_backref_token((OnigCodePoint )'(', tok, &p, end, env);
+	    if (r < 0) return r;
+	    break;
+	  }
+	  else if (c == '>') {  /* (?P>name): subexp call */
+	    name = p;
+	    r = fetch_name((OnigCodePoint )'(', &p, end, &name_end, env, &gnum, 0);
+	    if (r < 0) return r;
+
+	    tok->type = TK_CALL;
+	    tok->u.call.name     = name;
+	    tok->u.call.name_end = name_end;
+	    tok->u.call.gnum     = gnum;
+	    tok->u.call.rel      = 0;
+	    break;
+	  }
+	  PUNFETCH;
+	}
+#endif /* USE_CAPITAL_P_NAMED_GROUP */
+        PUNFETCH;
+      }
+
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LPAREN_SUBEXP)) break;
+      tok->type = TK_SUBEXP_OPEN;
+      break;
+
+    case ')':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LPAREN_SUBEXP)) break;
+      tok->type = TK_SUBEXP_CLOSE;
+      break;
+
+    case '^':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LINE_ANCHOR)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = (IS_SINGLELINE(env->option)
+			       ? ANCHOR_BEGIN_BUF : ANCHOR_BEGIN_LINE);
+      break;
+
+    case '$':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LINE_ANCHOR)) break;
+      tok->type = TK_ANCHOR;
+      tok->u.anchor.subtype = (IS_SINGLELINE(env->option)
+			       ? ANCHOR_SEMI_END_BUF : ANCHOR_END_LINE);
+      break;
+
+    case '[':
+      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_BRACKET_CC)) break;
+      tok->type = TK_CC_OPEN;
+      break;
+
+    case ']':
+      if (*src > env->pattern)   /* /].../ is allowed. */
+	CLOSE_BRACKET_WITHOUT_ESC_WARN(env, (UChar* )"]");
+      break;
+
+    case '#':
+      if (IS_EXTEND(env->option)) {
+	while (!PEND) {
+	  PFETCH(c);
+	  if (ONIGENC_IS_CODE_NEWLINE(enc, c))
+	    break;
+	}
+	goto start;
+	break;
+      }
+      break;
+
+    case ' ': case '\t': case '\n': case '\r': case '\f':
+      if (IS_EXTEND(env->option))
+	goto start;
+      break;
+
+    default:
+      /* string */
+      break;
+    }
+  }
+
+#ifdef USE_VARIABLE_META_CHARS
+ out:
+#endif
+  *src = p;
+  return tok->type;
+}
+
+static int
+add_ctype_to_cc_by_range(CClassNode* cc, int ctype ARG_UNUSED, int not,
+			 OnigEncoding enc ARG_UNUSED,
+                         OnigCodePoint sb_out, const OnigCodePoint mbr[])
+{
+  int i, r;
+  OnigCodePoint j;
+
+  int n = ONIGENC_CODE_RANGE_NUM(mbr);
+
+  if (not == 0) {
+    for (i = 0; i < n; i++) {
+      for (j  = ONIGENC_CODE_RANGE_FROM(mbr, i);
+           j <= ONIGENC_CODE_RANGE_TO(mbr, i); j++) {
+	if (j >= sb_out) {
+	  if (j > ONIGENC_CODE_RANGE_FROM(mbr, i)) {
+	    r = add_code_range_to_buf(&(cc->mbuf), j,
+				      ONIGENC_CODE_RANGE_TO(mbr, i));
+	    if (r != 0) return r;
+	    i++;
+	  }
+
+	  goto sb_end;
+	}
+        BITSET_SET_BIT(cc->bs, j);
+      }
+    }
+
+  sb_end:
+    for ( ; i < n; i++) {
+      r = add_code_range_to_buf(&(cc->mbuf),
+                                ONIGENC_CODE_RANGE_FROM(mbr, i),
+                                ONIGENC_CODE_RANGE_TO(mbr, i));
+      if (r != 0) return r;
+    }
+  }
+  else {
+    OnigCodePoint prev = 0;
+
+    for (i = 0; i < n; i++) {
+      for (j = prev;
+	   j < ONIGENC_CODE_RANGE_FROM(mbr, i); j++) {
+	if (j >= sb_out) {
+	  goto sb_end2;
+	}
+	BITSET_SET_BIT(cc->bs, j);
+      }
+      prev = ONIGENC_CODE_RANGE_TO(mbr, i) + 1;
+    }
+    for (j = prev; j < sb_out; j++) {
+      BITSET_SET_BIT(cc->bs, j);
+    }
+
+  sb_end2:
+    prev = sb_out;
+
+    for (i = 0; i < n; i++) {
+      if (prev < ONIGENC_CODE_RANGE_FROM(mbr, i)) {
+	r = add_code_range_to_buf(&(cc->mbuf), prev,
+                                  ONIGENC_CODE_RANGE_FROM(mbr, i) - 1);
+	if (r != 0) return r;
+      }
+      prev = ONIGENC_CODE_RANGE_TO(mbr, i) + 1;
+    }
+    if (prev < 0x7fffffff) {
+      r = add_code_range_to_buf(&(cc->mbuf), prev, 0x7fffffff);
+      if (r != 0) return r;
+    }
+  }
+
+  return 0;
+}
+
+static int
+add_ctype_to_cc(CClassNode* cc, int ctype, int not, int ascii_range, ScanEnv* env)
+{
+  int maxcode;
+  int c, r;
+  const OnigCodePoint *ranges;
+  OnigCodePoint sb_out;
+  OnigEncoding enc = env->enc;
+
+  r = ONIGENC_GET_CTYPE_CODE_RANGE(enc, ctype, &sb_out, &ranges);
+  if (r == 0) {
+    if (ascii_range) {
+      CClassNode ccwork;
+      initialize_cclass(&ccwork);
+      r = add_ctype_to_cc_by_range(&ccwork, ctype, not, env->enc, sb_out,
+				   ranges);
+      if (r == 0) {
+	if (not) {
+	  r = add_code_range_to_buf(&(ccwork.mbuf), 0x80, ONIG_LAST_CODE_POINT);
+	}
+	else {
+	  CClassNode ccascii;
+	  initialize_cclass(&ccascii);
+	  if (ONIGENC_MBC_MINLEN(env->enc) > 1) {
+	    add_code_range(&(ccascii.mbuf), env, 0x00, 0x7F);
+	  }
+	  else {
+	    bitset_set_range(ccascii.bs, 0x00, 0x7F);
+	  }
+	  r = and_cclass(&ccwork, &ccascii, enc);
+	  if (IS_NOT_NULL(ccascii.mbuf)) bbuf_free(ccascii.mbuf);
+	}
+	if (r == 0) {
+	  r = or_cclass(cc, &ccwork, enc);
+	}
+	if (IS_NOT_NULL(ccwork.mbuf)) bbuf_free(ccwork.mbuf);
+      }
+    }
+    else {
+      r = add_ctype_to_cc_by_range(cc, ctype, not, env->enc, sb_out, ranges);
+    }
+    return r;
+  }
+  else if (r != ONIG_NO_SUPPORT_CONFIG) {
+    return r;
+  }
+
+  maxcode = ascii_range ? 0x80 : SINGLE_BYTE_SIZE;
+  r = 0;
+  switch (ctype) {
+  case ONIGENC_CTYPE_ALPHA:
+  case ONIGENC_CTYPE_BLANK:
+  case ONIGENC_CTYPE_CNTRL:
+  case ONIGENC_CTYPE_DIGIT:
+  case ONIGENC_CTYPE_LOWER:
+  case ONIGENC_CTYPE_PUNCT:
+  case ONIGENC_CTYPE_SPACE:
+  case ONIGENC_CTYPE_UPPER:
+  case ONIGENC_CTYPE_XDIGIT:
+  case ONIGENC_CTYPE_ASCII:
+  case ONIGENC_CTYPE_ALNUM:
+    if (not != 0) {
+      for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
+	if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
+	  BITSET_SET_BIT(cc->bs, c);
+      }
+      ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
+    }
+    else {
+      for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
+	if (ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
+	  BITSET_SET_BIT(cc->bs, c);
+      }
+    }
+    break;
+
+  case ONIGENC_CTYPE_GRAPH:
+  case ONIGENC_CTYPE_PRINT:
+    if (not != 0) {
+      for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
+	if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype)
+	    || c >= maxcode)
+	  BITSET_SET_BIT(cc->bs, c);
+      }
+      if (ascii_range)
+        ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
+    }
+    else {
+      for (c = 0; c < maxcode; c++) {
+	if (ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
+	  BITSET_SET_BIT(cc->bs, c);
+      }
+      if (! ascii_range)
+        ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
+    }
+    break;
+
+  case ONIGENC_CTYPE_WORD:
+    if (not == 0) {
+      for (c = 0; c < maxcode; c++) {
+	if (ONIGENC_IS_CODE_WORD(enc, c)) BITSET_SET_BIT(cc->bs, c);
+      }
+      if (! ascii_range)
+        ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
+    }
+    else {
+      for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
+        if ((ONIGENC_CODE_TO_MBCLEN(enc, c) > 0) /* check invalid code point */
+	    && (! ONIGENC_IS_CODE_WORD(enc, c) || c >= maxcode))
+	  BITSET_SET_BIT(cc->bs, c);
+      }
+      if (ascii_range)
+        ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
+    }
+    break;
+
+  default:
+    return ONIGERR_PARSER_BUG;
+    break;
+  }
+
+  return r;
+}
+
+static int
+parse_posix_bracket(CClassNode* cc, CClassNode* asc_cc,
+		    UChar** src, UChar* end, ScanEnv* env)
+{
+#define POSIX_BRACKET_CHECK_LIMIT_LENGTH  20
+#define POSIX_BRACKET_NAME_MIN_LEN         4
+
+  static const PosixBracketEntryType PBS[] = {
+    POSIX_BRACKET_ENTRY_INIT("alnum",  ONIGENC_CTYPE_ALNUM),
+    POSIX_BRACKET_ENTRY_INIT("alpha",  ONIGENC_CTYPE_ALPHA),
+    POSIX_BRACKET_ENTRY_INIT("blank",  ONIGENC_CTYPE_BLANK),
+    POSIX_BRACKET_ENTRY_INIT("cntrl",  ONIGENC_CTYPE_CNTRL),
+    POSIX_BRACKET_ENTRY_INIT("digit",  ONIGENC_CTYPE_DIGIT),
+    POSIX_BRACKET_ENTRY_INIT("graph",  ONIGENC_CTYPE_GRAPH),
+    POSIX_BRACKET_ENTRY_INIT("lower",  ONIGENC_CTYPE_LOWER),
+    POSIX_BRACKET_ENTRY_INIT("print",  ONIGENC_CTYPE_PRINT),
+    POSIX_BRACKET_ENTRY_INIT("punct",  ONIGENC_CTYPE_PUNCT),
+    POSIX_BRACKET_ENTRY_INIT("space",  ONIGENC_CTYPE_SPACE),
+    POSIX_BRACKET_ENTRY_INIT("upper",  ONIGENC_CTYPE_UPPER),
+    POSIX_BRACKET_ENTRY_INIT("xdigit", ONIGENC_CTYPE_XDIGIT),
+    POSIX_BRACKET_ENTRY_INIT("ascii",  ONIGENC_CTYPE_ASCII),
+    POSIX_BRACKET_ENTRY_INIT("word",   ONIGENC_CTYPE_WORD),
+  };
+
+  const PosixBracketEntryType *pb;
+  int not, i, r;
+  int ascii_range;
+  OnigCodePoint c;
+  OnigEncoding enc = env->enc;
+  UChar *p = *src;
+
+  if (PPEEK_IS('^')) {
+    PINC_S;
+    not = 1;
+  }
+  else
+    not = 0;
+
+  if (onigenc_strlen(enc, p, end) < POSIX_BRACKET_NAME_MIN_LEN + 3)
+    goto not_posix_bracket;
+
+  ascii_range = IS_ASCII_RANGE(env->option) &&
+		  ! IS_POSIX_BRACKET_ALL_RANGE(env->option);
+  for (pb = PBS; pb < PBS + numberof(PBS); pb++) {
+    if (onigenc_with_ascii_strncmp(enc, p, end, pb->name, pb->len) == 0) {
+      p = (UChar* )onigenc_step(enc, p, end, pb->len);
+      if (onigenc_with_ascii_strncmp(enc, p, end, (UChar* )":]", 2) != 0)
+        return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
+
+      r = add_ctype_to_cc(cc, pb->ctype, not, ascii_range, env);
+      if (r != 0) return r;
+
+      if (IS_NOT_NULL(asc_cc)) {
+	if (pb->ctype != ONIGENC_CTYPE_WORD &&
+	    pb->ctype != ONIGENC_CTYPE_ASCII &&
+	    !ascii_range)
+	  r = add_ctype_to_cc(asc_cc, pb->ctype, not, ascii_range, env);
+	if (r != 0) return r;
+      }
+
+      PINC_S; PINC_S;
+      *src = p;
+      return 0;
+    }
+  }
+
+ not_posix_bracket:
+  c = 0;
+  i = 0;
+  while (!PEND && ((c = PPEEK) != ':') && c != ']') {
+    PINC_S;
+    if (++i > POSIX_BRACKET_CHECK_LIMIT_LENGTH) break;
+  }
+  if (c == ':' && ! PEND) {
+    PINC_S;
+    if (! PEND) {
+      PFETCH_S(c);
+      if (c == ']')
+        return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
+    }
+  }
+
+  return 1;  /* 1: is not POSIX bracket, but no error. */
+}
+
+static int
+fetch_char_property_to_ctype(UChar** src, UChar* end, ScanEnv* env)
+{
+  int r;
+  OnigCodePoint c;
+  OnigEncoding enc = env->enc;
+  UChar *prev, *start, *p = *src;
+
+  r = 0;
+  start = prev = p;
+
+  while (!PEND) {
+    prev = p;
+    PFETCH_S(c);
+    if (c == '}') {
+      r = ONIGENC_PROPERTY_NAME_TO_CTYPE(enc, start, prev);
+      if (r < 0) break;
+
+      *src = p;
+      return r;
+    }
+    else if (c == '(' || c == ')' || c == '{' || c == '|') {
+      r = ONIGERR_INVALID_CHAR_PROPERTY_NAME;
+      break;
+    }
+  }
+
+  onig_scan_env_set_error_string(env, r, *src, prev);
+  return r;
+}
+
+static int cclass_case_fold(Node** np, CClassNode* cc, CClassNode* asc_cc, ScanEnv* env);
+
+static int
+parse_char_property(Node** np, OnigToken* tok, UChar** src, UChar* end,
+		    ScanEnv* env)
+{
+  int r, ctype;
+  CClassNode* cc;
+
+  ctype = fetch_char_property_to_ctype(src, end, env);
+  if (ctype < 0) return ctype;
+
+  *np = node_new_cclass();
+  CHECK_NULL_RETURN_MEMERR(*np);
+  cc = NCCLASS(*np);
+  r = add_ctype_to_cc(cc, ctype, 0, 0, env);
+  if (r != 0) return r;
+  if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc);
+
+  if (IS_IGNORECASE(env->option)) {
+    if (ctype != ONIGENC_CTYPE_ASCII)
+      r = cclass_case_fold(np, cc, cc, env);
+  }
+  return r;
+}
+
+
+enum CCSTATE {
+  CCS_VALUE,
+  CCS_RANGE,
+  CCS_COMPLETE,
+  CCS_START
+};
+
+enum CCVALTYPE {
+  CCV_SB,
+  CCV_CODE_POINT,
+  CCV_CLASS
+};
+
+static int
+next_state_class(CClassNode* cc, CClassNode* asc_cc,
+	         OnigCodePoint* vs, enum CCVALTYPE* type,
+		 enum CCSTATE* state, ScanEnv* env)
+{
+  int r;
+
+  if (*state == CCS_RANGE)
+    return ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE;
+
+  if (*state == CCS_VALUE && *type != CCV_CLASS) {
+    if (*type == CCV_SB) {
+      BITSET_SET_BIT(cc->bs, (int )(*vs));
+      if (IS_NOT_NULL(asc_cc))
+	BITSET_SET_BIT(asc_cc->bs, (int )(*vs));
+    }
+    else if (*type == CCV_CODE_POINT) {
+      r = add_code_range(&(cc->mbuf), env, *vs, *vs);
+      if (r < 0) return r;
+      if (IS_NOT_NULL(asc_cc)) {
+	r = add_code_range(&(asc_cc->mbuf), env, *vs, *vs);
+	if (r < 0) return r;
+      }
+    }
+  }
+
+  *state = CCS_VALUE;
+  *type  = CCV_CLASS;
+  return 0;
+}
+
+static int
+next_state_val(CClassNode* cc, CClassNode* asc_cc,
+	       OnigCodePoint *vs, OnigCodePoint v,
+	       int* vs_israw, int v_israw,
+	       enum CCVALTYPE intype, enum CCVALTYPE* type,
+	       enum CCSTATE* state, ScanEnv* env)
+{
+  int r;
+
+  switch (*state) {
+  case CCS_VALUE:
+    if (*type == CCV_SB) {
+      BITSET_SET_BIT(cc->bs, (int )(*vs));
+      if (IS_NOT_NULL(asc_cc))
+	BITSET_SET_BIT(asc_cc->bs, (int )(*vs));
+    }
+    else if (*type == CCV_CODE_POINT) {
+      r = add_code_range(&(cc->mbuf), env, *vs, *vs);
+      if (r < 0) return r;
+      if (IS_NOT_NULL(asc_cc)) {
+	r = add_code_range(&(asc_cc->mbuf), env, *vs, *vs);
+	if (r < 0) return r;
+      }
+    }
+    break;
+
+  case CCS_RANGE:
+    if (intype == *type) {
+      if (intype == CCV_SB) {
+        if (*vs > 0xff || v > 0xff)
+          return ONIGERR_INVALID_CODE_POINT_VALUE;
+
+	if (*vs > v) {
+	  if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC))
+	    goto ccs_range_end;
+	  else
+	    return ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS;
+	}
+	bitset_set_range(cc->bs, (int )*vs, (int )v);
+	if (IS_NOT_NULL(asc_cc))
+	  bitset_set_range(asc_cc->bs, (int )*vs, (int )v);
+      }
+      else {
+	r = add_code_range(&(cc->mbuf), env, *vs, v);
+	if (r < 0) return r;
+	if (IS_NOT_NULL(asc_cc)) {
+	  r = add_code_range(&(asc_cc->mbuf), env, *vs, v);
+	  if (r < 0) return r;
+	}
+      }
+    }
+    else {
+#if 0
+      if (intype == CCV_CODE_POINT && *type == CCV_SB) {
+#endif
+	if (*vs > v) {
+	  if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC))
+	    goto ccs_range_end;
+	  else
+	    return ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS;
+	}
+	bitset_set_range(cc->bs, (int )*vs, (int )(v < 0xff ? v : 0xff));
+	r = add_code_range(&(cc->mbuf), env, (OnigCodePoint )*vs, v);
+	if (r < 0) return r;
+	if (IS_NOT_NULL(asc_cc)) {
+	  bitset_set_range(asc_cc->bs, (int )*vs, (int )(v < 0xff ? v : 0xff));
+	  r = add_code_range(&(asc_cc->mbuf), env, (OnigCodePoint )*vs, v);
+	  if (r < 0) return r;
+	}
+#if 0
+      }
+      else
+	return ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE;
+#endif
+    }
+  ccs_range_end:
+    *state = CCS_COMPLETE;
+    break;
+
+  case CCS_COMPLETE:
+  case CCS_START:
+    *state = CCS_VALUE;
+    break;
+
+  default:
+    break;
+  }
+
+  *vs_israw = v_israw;
+  *vs       = v;
+  *type     = intype;
+  return 0;
+}
+
+static int
+code_exist_check(OnigCodePoint c, UChar* from, UChar* end, int ignore_escaped,
+		 ScanEnv* env)
+{
+  int in_esc;
+  OnigCodePoint code;
+  OnigEncoding enc = env->enc;
+  UChar* p = from;
+
+  in_esc = 0;
+  while (! PEND) {
+    if (ignore_escaped && in_esc) {
+      in_esc = 0;
+    }
+    else {
+      PFETCH_S(code);
+      if (code == c) return 1;
+      if (code == MC_ESC(env->syntax)) in_esc = 1;
+    }
+  }
+  return 0;
+}
+
+static int
+parse_char_class(Node** np, Node** asc_np, OnigToken* tok, UChar** src, UChar* end,
+		 ScanEnv* env)
+{
+  int r, neg, len, fetched, and_start;
+  OnigCodePoint v, vs;
+  UChar *p;
+  Node* node;
+  Node* asc_node;
+  CClassNode *cc, *prev_cc;
+  CClassNode *asc_cc, *asc_prev_cc;
+  CClassNode work_cc, asc_work_cc;
+
+  enum CCSTATE state;
+  enum CCVALTYPE val_type, in_type;
+  int val_israw, in_israw;
+
+  prev_cc = asc_prev_cc = (CClassNode* )NULL;
+  *np = *asc_np = NULL_NODE;
+  r = fetch_token_in_cc(tok, src, end, env);
+  if (r == TK_CHAR && tok->u.c == '^' && tok->escaped == 0) {
+    neg = 1;
+    r = fetch_token_in_cc(tok, src, end, env);
+  }
+  else {
+    neg = 0;
+  }
+
+  if (r < 0) return r;
+  if (r == TK_CC_CLOSE) {
+    if (! code_exist_check((OnigCodePoint )']',
+                           *src, env->pattern_end, 1, env))
+      return ONIGERR_EMPTY_CHAR_CLASS;
+
+    CC_ESC_WARN(env, (UChar* )"]");
+    r = tok->type = TK_CHAR;  /* allow []...] */
+  }
+
+  *np = node = node_new_cclass();
+  CHECK_NULL_RETURN_MEMERR(node);
+  cc = NCCLASS(node);
+
+  if (IS_IGNORECASE(env->option)) {
+    *asc_np = asc_node = node_new_cclass();
+    CHECK_NULL_RETURN_MEMERR(asc_node);
+    asc_cc = NCCLASS(asc_node);
+  }
+  else {
+    asc_node = NULL_NODE;
+    asc_cc = NULL;
+  }
+
+  and_start = 0;
+  state = CCS_START;
+  p = *src;
+  while (r != TK_CC_CLOSE) {
+    fetched = 0;
+    switch (r) {
+    case TK_CHAR:
+      if ((tok->u.code >= SINGLE_BYTE_SIZE) ||
+	  (len = ONIGENC_CODE_TO_MBCLEN(env->enc, tok->u.c)) > 1) {
+	in_type = CCV_CODE_POINT;
+      }
+      else if (len < 0) {
+	r = len;
+	goto err;
+      }
+      else {
+      sb_char:
+	in_type = CCV_SB;
+      }
+      v = (OnigCodePoint )tok->u.c;
+      in_israw = 0;
+      goto val_entry2;
+      break;
+
+    case TK_RAW_BYTE:
+      /* tok->base != 0 : octal or hexadec. */
+      if (! ONIGENC_IS_SINGLEBYTE(env->enc) && tok->base != 0) {
+	UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
+	UChar* bufe = buf + ONIGENC_CODE_TO_MBC_MAXLEN;
+	UChar* psave = p;
+	int i, base = tok->base;
+
+	buf[0] = (UChar )tok->u.c;
+	for (i = 1; i < ONIGENC_MBC_MAXLEN(env->enc); i++) {
+	  r = fetch_token_in_cc(tok, &p, end, env);
+	  if (r < 0) goto err;
+	  if (r != TK_RAW_BYTE || tok->base != base) {
+	    fetched = 1;
+	    break;
+	  }
+	  buf[i] = (UChar )tok->u.c;
+	}
+
+	if (i < ONIGENC_MBC_MINLEN(env->enc)) {
+	  r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;
+	  goto err;
+	}
+
+	len = enclen(env->enc, buf);
+	if (i < len) {
+	  r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;
+	  goto err;
+	}
+	else if (i > len) { /* fetch back */
+	  p = psave;
+	  for (i = 1; i < len; i++) {
+	    r = fetch_token_in_cc(tok, &p, end, env);
+	  }
+	  fetched = 0;
+	}
+
+	if (i == 1) {
+	  v = (OnigCodePoint )buf[0];
+	  goto raw_single;
+	}
+	else {
+	  v = ONIGENC_MBC_TO_CODE(env->enc, buf, bufe);
+	  in_type = CCV_CODE_POINT;
+	}
+      }
+      else {
+	v = (OnigCodePoint )tok->u.c;
+      raw_single:
+	in_type = CCV_SB;
+      }
+      in_israw = 1;
+      goto val_entry2;
+      break;
+
+    case TK_CODE_POINT:
+      v = tok->u.code;
+      in_israw = 1;
+    val_entry:
+      len = ONIGENC_CODE_TO_MBCLEN(env->enc, v);
+      if (len < 0) {
+	r = len;
+	goto err;
+      }
+      in_type = (len == 1 ? CCV_SB : CCV_CODE_POINT);
+    val_entry2:
+      r = next_state_val(cc, asc_cc, &vs, v, &val_israw, in_israw, in_type, &val_type,
+			 &state, env);
+      if (r != 0) goto err;
+      break;
+
+    case TK_POSIX_BRACKET_OPEN:
+      r = parse_posix_bracket(cc, asc_cc, &p, end, env);
+      if (r < 0) goto err;
+      if (r == 1) {  /* is not POSIX bracket */
+	CC_ESC_WARN(env, (UChar* )"[");
+	p = tok->backp;
+	v = (OnigCodePoint )tok->u.c;
+	in_israw = 0;
+	goto val_entry;
+      }
+      goto next_class;
+      break;
+
+    case TK_CHAR_TYPE:
+      r = add_ctype_to_cc(cc, tok->u.prop.ctype, tok->u.prop.not,
+			  IS_ASCII_RANGE(env->option), env);
+      if (r != 0) return r;
+      if (IS_NOT_NULL(asc_cc)) {
+	if (tok->u.prop.ctype != ONIGENC_CTYPE_WORD)
+	  r = add_ctype_to_cc(asc_cc, tok->u.prop.ctype, tok->u.prop.not,
+			      IS_ASCII_RANGE(env->option), env);
+	if (r != 0) return r;
+      }
+
+    next_class:
+      r = next_state_class(cc, asc_cc, &vs, &val_type, &state, env);
+      if (r != 0) goto err;
+      break;
+
+    case TK_CHAR_PROPERTY:
+      {
+	int ctype;
+
+	ctype = fetch_char_property_to_ctype(&p, end, env);
+	if (ctype < 0) return ctype;
+	r = add_ctype_to_cc(cc, ctype, tok->u.prop.not, 0, env);
+	if (r != 0) return r;
+	if (IS_NOT_NULL(asc_cc)) {
+	  if (ctype != ONIGENC_CTYPE_ASCII)
+	    r = add_ctype_to_cc(asc_cc, ctype, tok->u.prop.not, 0, env);
+	  if (r != 0) return r;
+	}
+	goto next_class;
+      }
+      break;
+
+    case TK_CC_RANGE:
+      if (state == CCS_VALUE) {
+	r = fetch_token_in_cc(tok, &p, end, env);
+	if (r < 0) goto err;
+	fetched = 1;
+	if (r == TK_CC_CLOSE) { /* allow [x-] */
+	range_end_val:
+	  v = (OnigCodePoint )'-';
+	  in_israw = 0;
+	  goto val_entry;
+	}
+	else if (r == TK_CC_AND) {
+	  CC_ESC_WARN(env, (UChar* )"-");
+	  goto range_end_val;
+	}
+	state = CCS_RANGE;
+      }
+      else if (state == CCS_START) {
+	/* [-xa] is allowed */
+	v = (OnigCodePoint )tok->u.c;
+	in_israw = 0;
+
+	r = fetch_token_in_cc(tok, &p, end, env);
+	if (r < 0) goto err;
+	fetched = 1;
+	/* [--x] or [a&&-x] is warned. */
+	if (r == TK_CC_RANGE || and_start != 0)
+	  CC_ESC_WARN(env, (UChar* )"-");
+
+	goto val_entry;
+      }
+      else if (state == CCS_RANGE) {
+	CC_ESC_WARN(env, (UChar* )"-");
+	goto sb_char;  /* [!--x] is allowed */
+      }
+      else { /* CCS_COMPLETE */
+	r = fetch_token_in_cc(tok, &p, end, env);
+	if (r < 0) goto err;
+	fetched = 1;
+	if (r == TK_CC_CLOSE) goto range_end_val; /* allow [a-b-] */
+	else if (r == TK_CC_AND) {
+	  CC_ESC_WARN(env, (UChar* )"-");
+	  goto range_end_val;
+	}
+
+	if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) {
+	  CC_ESC_WARN(env, (UChar* )"-");
+	  goto range_end_val;   /* [0-9-a] is allowed as [0-9\-a] */
+	}
+	r = ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS;
+	goto err;
+      }
+      break;
+
+    case TK_CC_CC_OPEN: /* [ */
+      {
+	Node *anode, *aasc_node;
+	CClassNode* acc;
+
+	r = parse_char_class(&anode, &aasc_node, tok, &p, end, env);
+	if (r == 0) {
+	  acc = NCCLASS(anode);
+	  r = or_cclass(cc, acc, env->enc);
+	}
+	if (r == 0 && IS_NOT_NULL(aasc_node)) {
+	  acc = NCCLASS(aasc_node);
+	  r = or_cclass(asc_cc, acc, env->enc);
+	}
+	onig_node_free(anode);
+	onig_node_free(aasc_node);
+	if (r != 0) goto err;
+      }
+      break;
+
+    case TK_CC_AND: /* && */
+      {
+	if (state == CCS_VALUE) {
+	  r = next_state_val(cc, asc_cc, &vs, 0, &val_israw, 0, val_type,
+			     &val_type, &state, env);
+	  if (r != 0) goto err;
+	}
+	/* initialize local variables */
+	and_start = 1;
+	state = CCS_START;
+
+	if (IS_NOT_NULL(prev_cc)) {
+	  r = and_cclass(prev_cc, cc, env->enc);
+	  if (r != 0) goto err;
+	  bbuf_free(cc->mbuf);
+	  if (IS_NOT_NULL(asc_cc)) {
+	    r = and_cclass(asc_prev_cc, asc_cc, env->enc);
+	    if (r != 0) goto err;
+	    bbuf_free(asc_cc->mbuf);
+	  }
+	}
+	else {
+	  prev_cc = cc;
+	  cc = &work_cc;
+	  if (IS_NOT_NULL(asc_cc)) {
+	    asc_prev_cc = asc_cc;
+	    asc_cc = &asc_work_cc;
+	  }
+	}
+	initialize_cclass(cc);
+	if (IS_NOT_NULL(asc_cc))
+	  initialize_cclass(asc_cc);
+      }
+      break;
+
+    case TK_EOT:
+      r = ONIGERR_PREMATURE_END_OF_CHAR_CLASS;
+      goto err;
+      break;
+    default:
+      r = ONIGERR_PARSER_BUG;
+      goto err;
+      break;
+    }
+
+    if (fetched)
+      r = tok->type;
+    else {
+      r = fetch_token_in_cc(tok, &p, end, env);
+      if (r < 0) goto err;
+    }
+  }
+
+  if (state == CCS_VALUE) {
+    r = next_state_val(cc, asc_cc, &vs, 0, &val_israw, 0, val_type,
+		       &val_type, &state, env);
+    if (r != 0) goto err;
+  }
+
+  if (IS_NOT_NULL(prev_cc)) {
+    r = and_cclass(prev_cc, cc, env->enc);
+    if (r != 0) goto err;
+    bbuf_free(cc->mbuf);
+    cc = prev_cc;
+    if (IS_NOT_NULL(asc_cc)) {
+      r = and_cclass(asc_prev_cc, asc_cc, env->enc);
+      if (r != 0) goto err;
+      bbuf_free(asc_cc->mbuf);
+      asc_cc = asc_prev_cc;
+    }
+  }
+
+  if (neg != 0) {
+    NCCLASS_SET_NOT(cc);
+    if (IS_NOT_NULL(asc_cc))
+      NCCLASS_SET_NOT(asc_cc);
+  }
+  else {
+    NCCLASS_CLEAR_NOT(cc);
+    if (IS_NOT_NULL(asc_cc))
+      NCCLASS_CLEAR_NOT(asc_cc);
+  }
+  if (IS_NCCLASS_NOT(cc) &&
+      IS_SYNTAX_BV(env->syntax, ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC)) {
+    int is_empty;
+
+    is_empty = (IS_NULL(cc->mbuf) ? 1 : 0);
+    if (is_empty != 0)
+      BITSET_IS_EMPTY(cc->bs, is_empty);
+
+    if (is_empty == 0) {
+#define NEWLINE_CODE    0x0a
+
+      if (ONIGENC_IS_CODE_NEWLINE(env->enc, NEWLINE_CODE)) {
+        if (ONIGENC_CODE_TO_MBCLEN(env->enc, NEWLINE_CODE) == 1)
+          BITSET_SET_BIT(cc->bs, NEWLINE_CODE);
+        else {
+          r = add_code_range(&(cc->mbuf), env, NEWLINE_CODE, NEWLINE_CODE);
+          if (r < 0) goto err;
+        }
+      }
+    }
+  }
+  *src = p;
+  return 0;
+
+ err:
+  if (cc != NCCLASS(*np))
+    bbuf_free(cc->mbuf);
+  if (IS_NOT_NULL(asc_cc) && (asc_cc != NCCLASS(*asc_np)))
+    bbuf_free(asc_cc->mbuf);
+  return r;
+}
+
+static int parse_subexp(Node** top, OnigToken* tok, int term,
+			UChar** src, UChar* end, ScanEnv* env);
+
+static int
+parse_enclose(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
+	      ScanEnv* env)
+{
+  int r = 0, num;
+  Node *target, *work1 = NULL, *work2 = NULL;
+  OnigOptionType option;
+  OnigCodePoint c;
+  OnigEncoding enc = env->enc;
+
+#ifdef USE_NAMED_GROUP
+  int list_capture;
+#endif
+
+  UChar* p = *src;
+  PFETCH_READY;
+
+  *np = NULL;
+  if (PEND) return ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS;
+
+  option = env->option;
+  if (PPEEK_IS('?') &&
+      IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_GROUP_EFFECT)) {
+    PINC;
+    if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
+
+    PFETCH(c);
+    switch (c) {
+    case ':':   /* (?:...) grouping only */
+    group:
+      r = fetch_token(tok, &p, end, env);
+      if (r < 0) return r;
+      r = parse_subexp(np, tok, term, &p, end, env);
+      if (r < 0) return r;
+      *src = p;
+      return 1; /* group */
+      break;
+
+    case '=':
+      *np = onig_node_new_anchor(ANCHOR_PREC_READ);
+      break;
+    case '!':   /* preceding read */
+      *np = onig_node_new_anchor(ANCHOR_PREC_READ_NOT);
+      break;
+    case '>':   /* (?>...) stop backtrack */
+      *np = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
+      break;
+
+#ifdef USE_NAMED_GROUP
+    case '\'':
+      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
+	goto named_group1;
+      }
+      else
+	return ONIGERR_UNDEFINED_GROUP_OPTION;
+      break;
+
+#ifdef USE_CAPITAL_P_NAMED_GROUP
+    case 'P':   /* (?P<name>...) */
+      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_CAPITAL_P_NAMED_GROUP)) {
+	PFETCH(c);
+	if (c == '<') goto named_group1;
+      }
+      return ONIGERR_UNDEFINED_GROUP_OPTION;
+      break;
+#endif
+#endif
+
+    case '<':   /* look behind (?<=...), (?<!...) */
+      PFETCH(c);
+      if (c == '=')
+	*np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND);
+      else if (c == '!')
+	*np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND_NOT);
+#ifdef USE_NAMED_GROUP
+      else {    /* (?<name>...) */
+	if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
+	  UChar *name;
+	  UChar *name_end;
+
+	  PUNFETCH;
+	  c = '<';
+
+	named_group1:
+	  list_capture = 0;
+
+	named_group2:
+	  name = p;
+	  r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &num, 0);
+	  if (r < 0) return r;
+
+	  num = scan_env_add_mem_entry(env);
+	  if (num < 0) return num;
+	  if (list_capture != 0 && num >= (int )BIT_STATUS_BITS_NUM)
+	    return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;
+
+	  r = name_add(env->reg, name, name_end, num, env);
+	  if (r != 0) return r;
+	  *np = node_new_enclose_memory(env->option, 1);
+	  CHECK_NULL_RETURN_MEMERR(*np);
+	  NENCLOSE(*np)->regnum = num;
+	  if (list_capture != 0)
+	    BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);
+	  env->num_named++;
+	}
+	else {
+	  return ONIGERR_UNDEFINED_GROUP_OPTION;
+	}
+      }
+#else
+      else {
+	return ONIGERR_UNDEFINED_GROUP_OPTION;
+      }
+#endif
+      break;
+
+    case '@':
+      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY)) {
+#ifdef USE_NAMED_GROUP
+	if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
+	  PFETCH(c);
+	  if (c == '<' || c == '\'') {
+	    list_capture = 1;
+	    goto named_group2; /* (?@<name>...) */
+	  }
+	  PUNFETCH;
+	}
+#endif
+	*np = node_new_enclose_memory(env->option, 0);
+	CHECK_NULL_RETURN_MEMERR(*np);
+	num = scan_env_add_mem_entry(env);
+	if (num < 0) return num;
+	if (num >= (int )BIT_STATUS_BITS_NUM)
+	  return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;
+
+	NENCLOSE(*np)->regnum = num;
+	BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);
+      }
+      else {
+	return ONIGERR_UNDEFINED_GROUP_OPTION;
+      }
+      break;
+
+    case '(':   /* conditional expression: (?(cond)yes), (?(cond)yes|no) */
+      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LPAREN_CONDITION)) {
+	UChar *name = NULL;
+	UChar *name_end;
+	PFETCH(c);
+	if (ONIGENC_IS_CODE_DIGIT(enc, c)) {     /* (n) */
+	  PUNFETCH;
+	  r = fetch_name((OnigCodePoint )'(', &p, end, &name_end, env, &num, 1);
+	  if (r < 0) return r;
+#if 0
+	  /* Relative number is not currently supported. (same as Perl) */
+	  if (num < 0) {
+	    num = BACKREF_REL_TO_ABS(num, env);
+	    if (num <= 0)
+	      return ONIGERR_INVALID_BACKREF;
+	  }
+#endif
+	  if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_STRICT_CHECK_BACKREF)) {
+	    if (num > env->num_mem ||
+	        IS_NULL(SCANENV_MEM_NODES(env)[num]))
+	    return ONIGERR_INVALID_BACKREF;
+	  }
+	}
+#ifdef USE_NAMED_GROUP
+	else if (c == '<' || c == '\'') {    /* (<name>), ('name') */
+	  int nums;
+	  int *backs;
+
+	  name = p;
+	  r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &num, 0);
+	  if (r < 0) return r;
+	  PFETCH(c);
+	  if (c != ')') return ONIGERR_UNDEFINED_GROUP_OPTION;
+
+	  nums = onig_name_to_group_numbers(env->reg, name, name_end, &backs);
+	  if (nums <= 0) {
+	    onig_scan_env_set_error_string(env,
+		     ONIGERR_UNDEFINED_NAME_REFERENCE, name, name_end);
+	    return ONIGERR_UNDEFINED_NAME_REFERENCE;
+	  }
+	  if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_STRICT_CHECK_BACKREF)) {
+	    int i;
+	    for (i = 0; i < nums; i++) {
+	      if (backs[i] > env->num_mem ||
+		  IS_NULL(SCANENV_MEM_NODES(env)[backs[i]]))
+	      return ONIGERR_INVALID_BACKREF;
+	    }
+	  }
+	  num = backs[0];       /* XXX: use left most named group as Perl */
+	}
+#endif
+	else
+	  return ONIGERR_INVALID_CONDITION_PATTERN;
+	*np = node_new_enclose(ENCLOSE_CONDITION);
+	CHECK_NULL_RETURN_MEMERR(*np);
+	NENCLOSE(*np)->regnum = num;
+	if (IS_NOT_NULL(name)) NENCLOSE(*np)->state |= NST_NAME_REF;
+      }
+      else
+	return ONIGERR_UNDEFINED_GROUP_OPTION;
+      break;
+
+#if 0
+    case '|':   /* branch reset: (?|...) */
+      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_VBAR_BRANCH_RESET)) {
+	/* TODO */
+      }
+      else
+	return ONIGERR_UNDEFINED_GROUP_OPTION;
+      break;
+#endif
+
+    case '^':   /* loads default options */
+      if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {
+	/* d-imsx */
+	ONOFF(option, ONIG_OPTION_ASCII_RANGE, 1);
+	ONOFF(option, ONIG_OPTION_IGNORECASE, 1);
+	ONOFF(option, ONIG_OPTION_SINGLELINE, 0);
+	ONOFF(option, ONIG_OPTION_MULTILINE,  1);
+	ONOFF(option, ONIG_OPTION_EXTEND, 1);
+	PFETCH(c);
+      }
+#if 0
+      else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) {
+	/* d-imx */
+	ONOFF(option, ONIG_OPTION_ASCII_RANGE, 0);
+	ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 0);
+	ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 0);
+	ONOFF(option, ONIG_OPTION_IGNORECASE, 1);
+	ONOFF(option, ONIG_OPTION_MULTILINE,  1);
+	ONOFF(option, ONIG_OPTION_EXTEND, 1);
+	PFETCH(c);
+      }
+#endif
+      else {
+	return ONIGERR_UNDEFINED_GROUP_OPTION;
+      }
+      /* fall through */
+#ifdef USE_POSIXLINE_OPTION
+    case 'p':
+#endif
+    case '-': case 'i': case 'm': case 's': case 'x':
+    case 'a': case 'd': case 'l': case 'u':
+      {
+	int neg = 0;
+
+	while (1) {
+	  switch (c) {
+	  case ':':
+	  case ')':
+	  break;
+
+	  case '-':  neg = 1; break;
+	  case 'x':  ONOFF(option, ONIG_OPTION_EXTEND,     neg); break;
+	  case 'i':  ONOFF(option, ONIG_OPTION_IGNORECASE, neg); break;
+	  case 's':
+	    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {
+	      ONOFF(option, ONIG_OPTION_MULTILINE,  neg);
+	    }
+	    else
+	      return ONIGERR_UNDEFINED_GROUP_OPTION;
+	    break;
+
+	  case 'm':
+	    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {
+	      ONOFF(option, ONIG_OPTION_SINGLELINE, (neg == 0 ? 1 : 0));
+	    }
+	    else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) {
+	      ONOFF(option, ONIG_OPTION_MULTILINE,  neg);
+	    }
+	    else
+	      return ONIGERR_UNDEFINED_GROUP_OPTION;
+	    break;
+#ifdef USE_POSIXLINE_OPTION
+	  case 'p':
+	    ONOFF(option, ONIG_OPTION_MULTILINE|ONIG_OPTION_SINGLELINE, neg);
+	    break;
+#endif
+
+	  case 'a':     /* limits \d, \s, \w and POSIX brackets to ASCII range */
+	    if ((IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL) ||
+	         IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) &&
+	        (neg == 0)) {
+	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 0);
+	      ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 1);
+	      ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 1);
+	    }
+	    else
+	      return ONIGERR_UNDEFINED_GROUP_OPTION;
+	    break;
+
+	  case 'u':
+	    if ((IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL) ||
+	         IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) &&
+	        (neg == 0)) {
+	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 1);
+	      ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 1);
+	      ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 1);
+	    }
+	    else
+	      return ONIGERR_UNDEFINED_GROUP_OPTION;
+	    break;
+
+	  case 'd':
+	    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL) &&
+	        (neg == 0)) {
+	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 1);
+	    }
+	    else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY) &&
+	        (neg == 0)) {
+	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 0);
+	      ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 0);
+	      ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 0);
+	    }
+	    else
+	      return ONIGERR_UNDEFINED_GROUP_OPTION;
+	    break;
+
+	  case 'l':
+	    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL) && (neg == 0)) {
+	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 1);
+	    }
+	    else
+	      return ONIGERR_UNDEFINED_GROUP_OPTION;
+	    break;
+
+	  default:
+	    return ONIGERR_UNDEFINED_GROUP_OPTION;
+	  }
+
+	  if (c == ')') {
+	    *np = node_new_option(option);
+	    CHECK_NULL_RETURN_MEMERR(*np);
+	    *src = p;
+	    return 2; /* option only */
+	  }
+	  else if (c == ':') {
+	    OnigOptionType prev = env->option;
+
+	    env->option     = option;
+	    r = fetch_token(tok, &p, end, env);
+	    if (r < 0) return r;
+	    r = parse_subexp(&target, tok, term, &p, end, env);
+	    env->option = prev;
+	    if (r < 0) return r;
+	    *np = node_new_option(option);
+	    CHECK_NULL_RETURN_MEMERR(*np);
+	    NENCLOSE(*np)->target = target;
+	    *src = p;
+	    return 0;
+	  }
+
+	  if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
+	  PFETCH(c);
+	}
+      }
+      break;
+
+    default:
+      return ONIGERR_UNDEFINED_GROUP_OPTION;
+    }
+  }
+  else {
+    if (ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_DONT_CAPTURE_GROUP))
+      goto group;
+
+    *np = node_new_enclose_memory(env->option, 0);
+    CHECK_NULL_RETURN_MEMERR(*np);
+    num = scan_env_add_mem_entry(env);
+    if (num < 0) return num;
+    NENCLOSE(*np)->regnum = num;
+  }
+
+  CHECK_NULL_RETURN_MEMERR(*np);
+  r = fetch_token(tok, &p, end, env);
+  if (r < 0) return r;
+  r = parse_subexp(&target, tok, term, &p, end, env);
+  if (r < 0) {
+    onig_node_free(target);
+    return r;
+  }
+
+  if (NTYPE(*np) == NT_ANCHOR)
+    NANCHOR(*np)->target = target;
+  else {
+    NENCLOSE(*np)->target = target;
+    if (NENCLOSE(*np)->type == ENCLOSE_MEMORY) {
+      /* Don't move this to previous of parse_subexp() */
+      r = scan_env_set_mem_node(env, NENCLOSE(*np)->regnum, *np);
+      if (r != 0) return r;
+    }
+    else if (NENCLOSE(*np)->type == ENCLOSE_CONDITION) {
+      if (NTYPE(target) != NT_ALT) {
+	/* convert (?(cond)yes) to (?(cond)yes|empty) */
+	work1 = node_new_empty();
+	if (IS_NULL(work1)) goto err;
+	work2 = onig_node_new_alt(work1, NULL_NODE);
+	if (IS_NULL(work2)) goto err;
+	work1 = onig_node_new_alt(target, work2);
+	if (IS_NULL(work1)) goto err;
+	NENCLOSE(*np)->target = work1;
+      }
+    }
+  }
+
+  *src = p;
+  return 0;
+
+ err:
+  onig_node_free(work1);
+  onig_node_free(work2);
+  onig_node_free(*np);
+  *np = NULL;
+  return ONIGERR_MEMORY;
+}
+
+static const char* const PopularQStr[] = {
+  "?", "*", "+", "??", "*?", "+?"
+};
+
+static const char* const ReduceQStr[] = {
+  "", "", "*", "*?", "??", "+ and ??", "+? and ?"
+};
+
+static int
+set_quantifier(Node* qnode, Node* target, int group, ScanEnv* env)
+{
+  QtfrNode* qn;
+
+  qn = NQTFR(qnode);
+  if (qn->lower == 1 && qn->upper == 1) {
+    return 1;
+  }
+
+  switch (NTYPE(target)) {
+  case NT_STR:
+    if (! group) {
+      StrNode* sn = NSTR(target);
+      if (str_node_can_be_split(sn, env->enc)) {
+	Node* n = str_node_split_last_char(sn, env->enc);
+	if (IS_NOT_NULL(n)) {
+	  qn->target = n;
+	  return 2;
+	}
+      }
+    }
+    break;
+
+  case NT_QTFR:
+    { /* check redundant double repeat. */
+      /* verbose warn (?:.?)? etc... but not warn (.?)? etc... */
+      QtfrNode* qnt   = NQTFR(target);
+      int nestq_num   = popular_quantifier_num(qn);
+      int targetq_num = popular_quantifier_num(qnt);
+
+#ifdef USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
+      if (!IS_QUANTIFIER_BY_NUMBER(qn) && !IS_QUANTIFIER_BY_NUMBER(qnt) &&
+	  IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT)) {
+        UChar buf[WARN_BUFSIZE];
+
+        switch (ReduceTypeTable[targetq_num][nestq_num]) {
+        case RQ_ASIS:
+          break;
+
+        case RQ_DEL:
+          if (onig_verb_warn != onig_null_warn) {
+            onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
+                                 env->pattern, env->pattern_end,
+                                 (UChar* )"redundant nested repeat operator");
+            (*onig_verb_warn)((char* )buf);
+          }
+          goto warn_exit;
+          break;
+
+        default:
+          if (onig_verb_warn != onig_null_warn) {
+            onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
+                                       env->pattern, env->pattern_end,
+            (UChar* )"nested repeat operator %s and %s was replaced with '%s'",
+            PopularQStr[targetq_num], PopularQStr[nestq_num],
+            ReduceQStr[ReduceTypeTable[targetq_num][nestq_num]]);
+            (*onig_verb_warn)((char* )buf);
+          }
+          goto warn_exit;
+          break;
+        }
+      }
+
+    warn_exit:
+#endif
+      if (targetq_num >= 0) {
+	if (nestq_num >= 0) {
+	  onig_reduce_nested_quantifier(qnode, target);
+	  goto q_exit;
+	}
+	else if (targetq_num == 1 || targetq_num == 2) { /* * or + */
+	  /* (?:a*){n,m}, (?:a+){n,m} => (?:a*){n,n}, (?:a+){n,n} */
+	  if (! IS_REPEAT_INFINITE(qn->upper) && qn->upper > 1 && qn->greedy) {
+	    qn->upper = (qn->lower == 0 ? 1 : qn->lower);
+	  }
+	}
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  qn->target = target;
+ q_exit:
+  return 0;
+}
+
+
+#ifdef USE_SHARED_CCLASS_TABLE
+
+#define THRESHOLD_RANGE_NUM_FOR_SHARE_CCLASS     8
+
+/* for ctype node hash table */
+
+typedef struct {
+  OnigEncoding enc;
+  int not;
+  int type;
+} type_cclass_key;
+
+static int type_cclass_cmp(type_cclass_key* x, type_cclass_key* y)
+{
+  if (x->type != y->type) return 1;
+  if (x->enc  != y->enc)  return 1;
+  if (x->not  != y->not)  return 1;
+  return 0;
+}
+
+static int type_cclass_hash(type_cclass_key* key)
+{
+  int i, val;
+  UChar *p;
+
+  val = 0;
+
+  p = (UChar* )&(key->enc);
+  for (i = 0; i < (int )sizeof(key->enc); i++) {
+    val = val * 997 + (int )*p++;
+  }
+
+  p = (UChar* )(&key->type);
+  for (i = 0; i < (int )sizeof(key->type); i++) {
+    val = val * 997 + (int )*p++;
+  }
+
+  val += key->not;
+  return val + (val >> 5);
+}
+
+static struct st_hash_type type_type_cclass_hash = {
+    type_cclass_cmp,
+    type_cclass_hash,
+};
+
+static st_table* OnigTypeCClassTable;
+
+
+static int
+i_free_shared_class(type_cclass_key* key, Node* node, void* arg ARG_UNUSED)
+{
+  if (IS_NOT_NULL(node)) {
+    CClassNode* cc = NCCLASS(node);
+    if (IS_NOT_NULL(cc->mbuf)) xfree(cc->mbuf);
+    xfree(node);
+  }
+
+  if (IS_NOT_NULL(key)) xfree(key);
+  return ST_DELETE;
+}
+
+extern int
+onig_free_shared_cclass_table(void)
+{
+  /* THREAD_ATOMIC_START; */
+  if (IS_NOT_NULL(OnigTypeCClassTable)) {
+    onig_st_foreach(OnigTypeCClassTable, i_free_shared_class, 0);
+    onig_st_free_table(OnigTypeCClassTable);
+    OnigTypeCClassTable = NULL;
+  }
+  /* THREAD_ATOMIC_END; */
+
+  return 0;
+}
+
+#endif /* USE_SHARED_CCLASS_TABLE */
+
+
+#ifndef CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS
+static int
+clear_not_flag_cclass(CClassNode* cc, OnigEncoding enc)
+{
+  BBuf *tbuf;
+  int r;
+
+  if (IS_NCCLASS_NOT(cc)) {
+    bitset_invert(cc->bs);
+
+    if (! ONIGENC_IS_SINGLEBYTE(enc)) {
+      r = not_code_range_buf(enc, cc->mbuf, &tbuf);
+      if (r != 0) return r;
+
+      bbuf_free(cc->mbuf);
+      cc->mbuf = tbuf;
+    }
+
+    NCCLASS_CLEAR_NOT(cc);
+  }
+
+  return 0;
+}
+#endif /* CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS */
+
+typedef struct {
+  ScanEnv*    env;
+  CClassNode* cc;
+  CClassNode* asc_cc;
+  Node*       alt_root;
+  Node**      ptail;
+} IApplyCaseFoldArg;
+
+static int
+i_apply_case_fold(OnigCodePoint from, OnigCodePoint to[],
+		  int to_len, void* arg)
+{
+  IApplyCaseFoldArg* iarg;
+  ScanEnv* env;
+  CClassNode* cc;
+  CClassNode* asc_cc;
+  BitSetRef bs;
+  int add_flag;
+
+  iarg = (IApplyCaseFoldArg* )arg;
+  env = iarg->env;
+  cc  = iarg->cc;
+  asc_cc = iarg->asc_cc;
+  bs = cc->bs;
+
+  if (IS_NULL(asc_cc)) {
+    add_flag = 0;
+  }
+  else if (ONIGENC_IS_ASCII_CODE(from) == ONIGENC_IS_ASCII_CODE(*to)) {
+    add_flag = 1;
+  }
+  else {
+    add_flag = onig_is_code_in_cc(env->enc, from, asc_cc);
+    if (IS_NCCLASS_NOT(asc_cc))
+      add_flag = !add_flag;
+  }
+
+  if (to_len == 1) {
+    int is_in = onig_is_code_in_cc(env->enc, from, cc);
+#ifdef CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS
+    if ((is_in != 0 && !IS_NCCLASS_NOT(cc)) ||
+	(is_in == 0 &&  IS_NCCLASS_NOT(cc))) {
+      if (add_flag) {
+	if (ONIGENC_MBC_MINLEN(env->enc) > 1 || *to >= SINGLE_BYTE_SIZE) {
+	  add_code_range(&(cc->mbuf), env, *to, *to);
+	}
+	else {
+	  BITSET_SET_BIT(bs, *to);
+	}
+      }
+    }
+#else
+    if (is_in != 0) {
+      if (add_flag) {
+	if (ONIGENC_MBC_MINLEN(env->enc) > 1 || *to >= SINGLE_BYTE_SIZE) {
+	  if (IS_NCCLASS_NOT(cc)) clear_not_flag_cclass(cc, env->enc);
+	  add_code_range(&(cc->mbuf), env, *to, *to);
+	}
+	else {
+	  if (IS_NCCLASS_NOT(cc)) {
+	    BITSET_CLEAR_BIT(bs, *to);
+	  }
+	  else {
+	    BITSET_SET_BIT(bs, *to);
+	  }
+	}
+      }
+    }
+#endif /* CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS */
+  }
+  else {
+    int r, i, len;
+    UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
+    Node *snode = NULL_NODE;
+
+    if (onig_is_code_in_cc(env->enc, from, cc)
+#ifdef CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS
+	&& !IS_NCCLASS_NOT(cc)
+#endif
+	) {
+      for (i = 0; i < to_len; i++) {
+	len = ONIGENC_CODE_TO_MBC(env->enc, to[i], buf);
+	if (i == 0) {
+	  snode = onig_node_new_str(buf, buf + len);
+	  CHECK_NULL_RETURN_MEMERR(snode);
+
+	  /* char-class expanded multi-char only
+	     compare with string folded at match time. */
+	  NSTRING_SET_AMBIG(snode);
+	}
+	else {
+	  r = onig_node_str_cat(snode, buf, buf + len);
+	  if (r < 0) {
+	    onig_node_free(snode);
+	    return r;
+	  }
+	}
+      }
+
+      *(iarg->ptail) = onig_node_new_alt(snode, NULL_NODE);
+      CHECK_NULL_RETURN_MEMERR(*(iarg->ptail));
+      iarg->ptail = &(NCDR((*(iarg->ptail))));
+    }
+  }
+
+  return 0;
+}
+
+static int
+cclass_case_fold(Node** np, CClassNode* cc, CClassNode* asc_cc, ScanEnv* env)
+{
+  int r;
+  IApplyCaseFoldArg iarg;
+
+  iarg.env         = env;
+  iarg.cc          = cc;
+  iarg.asc_cc      = asc_cc;
+  iarg.alt_root    = NULL_NODE;
+  iarg.ptail       = &(iarg.alt_root);
+
+  r = ONIGENC_APPLY_ALL_CASE_FOLD(env->enc, env->case_fold_flag,
+				  i_apply_case_fold, &iarg);
+  if (r != 0) {
+    onig_node_free(iarg.alt_root);
+    return r;
+  }
+  if (IS_NOT_NULL(iarg.alt_root)) {
+    Node* work = onig_node_new_alt(*np, iarg.alt_root);
+    if (IS_NULL(work)) {
+      onig_node_free(iarg.alt_root);
+      return ONIGERR_MEMORY;
+    }
+    *np = work;
+  }
+  return r;
+}
+
+static int
+node_linebreak(Node** np, ScanEnv* env)
+{
+  /* same as (?>\x0D\x0A|[\x0A-\x0D\x{85}\x{2028}\x{2029}]) */
+  Node* left = NULL;
+  Node* right = NULL;
+  Node* target1 = NULL;
+  Node* target2 = NULL;
+  CClassNode* cc;
+  int num1, num2;
+  UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN * 2];
+
+  /* \x0D\x0A */
+  num1 = ONIGENC_CODE_TO_MBC(env->enc, 0x0D, buf);
+  if (num1 < 0) return num1;
+  num2 = ONIGENC_CODE_TO_MBC(env->enc, 0x0A, buf + num1);
+  if (num2 < 0) return num2;
+  left = node_new_str_raw(buf, buf + num1 + num2);
+  if (IS_NULL(left)) goto err;
+
+  /* [\x0A-\x0D] or [\x0A-\x0D\x{85}\x{2028}\x{2029}] */
+  right = node_new_cclass();
+  if (IS_NULL(right)) goto err;
+  cc = NCCLASS(right);
+  if (ONIGENC_MBC_MINLEN(env->enc) > 1) {
+    add_code_range(&(cc->mbuf), env, 0x0A, 0x0D);
+  }
+  else {
+    bitset_set_range(cc->bs, 0x0A, 0x0D);
+  }
+
+  /* TODO: move this block to enc/unicode.c */
+  if (ONIGENC_IS_UNICODE(env->enc)) {
+    /* UTF-8, UTF-16BE/LE, UTF-32BE/LE */
+    add_code_range(&(cc->mbuf), env, 0x85, 0x85);
+    add_code_range(&(cc->mbuf), env, 0x2028, 0x2029);
+  }
+
+  /* ...|... */
+  target1 = onig_node_new_alt(right, NULL_NODE);
+  if (IS_NULL(target1)) goto err;
+  right = NULL;
+  target2 = onig_node_new_alt(left, target1);
+  if (IS_NULL(target2)) goto err;
+  left = NULL;
+  target1 = NULL;
+
+  /* (?>...) */
+  *np = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
+  if (IS_NULL(*np)) goto err;
+  NENCLOSE(*np)->target = target2;
+  return ONIG_NORMAL;
+
+ err:
+  onig_node_free(left);
+  onig_node_free(right);
+  onig_node_free(target1);
+  onig_node_free(target2);
+  return ONIGERR_MEMORY;
+}
+
+static int
+node_extended_grapheme_cluster(Node** np, ScanEnv* env)
+{
+  /* same as (?>\P{M}\p{M}*) */
+  Node* np1 = NULL;
+  Node* np2 = NULL;
+  Node* qn = NULL;
+  Node* list1 = NULL;
+  Node* list2 = NULL;
+  int r = 0;
+
+#ifdef USE_UNICODE_PROPERTIES
+  if (ONIGENC_IS_UNICODE(env->enc)) {
+    /* UTF-8, UTF-16BE/LE, UTF-32BE/LE */
+    CClassNode* cc1;
+    CClassNode* cc2;
+    UChar* propname = (UChar* )"M";
+    int ctype = env->enc->property_name_to_ctype(ONIG_ENCODING_ASCII,
+	propname, propname + 1);
+    if (ctype >= 0) {
+      /* \P{M} */
+      np1 = node_new_cclass();
+      if (IS_NULL(np1)) goto err;
+      cc1 = NCCLASS(np1);
+      r = add_ctype_to_cc(cc1, ctype, 0, 0, env);
+      if (r != 0) goto err;
+      NCCLASS_SET_NOT(cc1);
+
+      /* \p{M}* */
+      np2 = node_new_cclass();
+      if (IS_NULL(np2)) goto err;
+      cc2 = NCCLASS(np2);
+      r = add_ctype_to_cc(cc2, ctype, 0, 0, env);
+      if (r != 0) goto err;
+
+      qn = node_new_quantifier(0, REPEAT_INFINITE, 0);
+      if (IS_NULL(qn)) goto err;
+      NQTFR(qn)->target = np2;
+      np2 = NULL;
+
+      /* \P{M}\p{M}* */
+      list2 = node_new_list(qn, NULL_NODE);
+      if (IS_NULL(list2)) goto err;
+      qn = NULL;
+      list1 = node_new_list(np1, list2);
+      if (IS_NULL(list1)) goto err;
+      np1 = NULL;
+      list2 = NULL;
+
+      /* (?>...) */
+      *np = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
+      if (IS_NULL(*np)) goto err;
+      NENCLOSE(*np)->target = list1;
+      return ONIG_NORMAL;
+    }
+  }
+#endif /* USE_UNICODE_PROPERTIES */
+  if (IS_NULL(*np)) {
+    /* PerlSyntax: (?s:.), RubySyntax: (?m:.) */
+    OnigOptionType option;
+    np1 = node_new_anychar();
+    if (IS_NULL(np1)) goto err;
+
+    option = env->option;
+    ONOFF(option, ONIG_OPTION_MULTILINE, 0);
+    *np = node_new_option(option);
+    if (IS_NULL(*np)) goto err;
+    NENCLOSE(*np)->target = np1;
+  }
+  return ONIG_NORMAL;
+
+ err:
+  onig_node_free(np1);
+  onig_node_free(np2);
+  onig_node_free(qn);
+  onig_node_free(list1);
+  onig_node_free(list2);
+  return (r == 0) ? ONIGERR_MEMORY : r;
+}
+
+static int
+countbits(unsigned int bits)
+{
+  bits = (bits & 0x55555555) + ((bits >> 1) & 0x55555555);
+  bits = (bits & 0x33333333) + ((bits >> 2) & 0x33333333);
+  bits = (bits & 0x0f0f0f0f) + ((bits >> 4) & 0x0f0f0f0f);
+  bits = (bits & 0x00ff00ff) + ((bits >> 8) & 0x00ff00ff);
+  return (bits & 0x0000ffff) + ((bits >>16) & 0x0000ffff);
+}
+
+static int
+is_onechar_cclass(CClassNode* cc, OnigCodePoint* code)
+{
+  const OnigCodePoint not_found = ONIG_LAST_CODE_POINT;
+  OnigCodePoint c = not_found;
+  int i;
+  BBuf *bbuf = cc->mbuf;
+
+  if (IS_NCCLASS_NOT(cc)) return 0;
+
+  /* check bbuf */
+  if (IS_NOT_NULL(bbuf)) {
+    OnigCodePoint n, *data;
+    GET_CODE_POINT(n, bbuf->p);
+    data = (OnigCodePoint* )(bbuf->p) + 1;
+    if ((n == 1) && (data[0] == data[1])) {
+      /* only one char found in the bbuf, save the code point. */
+      c = data[0];
+      if (((c < SINGLE_BYTE_SIZE) && BITSET_AT(cc->bs, c))) {
+        /* skip if c is included in the bitset */
+	c = not_found;
+      }
+    }
+    else {
+      return 0;  /* the bbuf contains multiple chars */
+    }
+  }
+
+  /* check bitset */
+  for (i = 0; i < BITSET_SIZE; i++) {
+    Bits b1 = cc->bs[i];
+    if (b1 != 0) {
+      if (((b1 & (b1 - 1)) == 0) && (c == not_found)) {
+        c = BITS_IN_ROOM * i + countbits(b1 - 1);
+      } else {
+        return 0;  /* the character class contains multiple chars */
+      }
+    }
+  }
+
+  if (c != not_found) {
+    *code = c;
+    return 1;
+  }
+
+  /* the character class contains no char. */
+  return 0;
+}
+
+
+static int
+parse_exp(Node** np, OnigToken* tok, int term,
+	  UChar** src, UChar* end, ScanEnv* env)
+{
+  int r, len, group = 0;
+  Node* qn;
+  Node** targetp;
+
+  *np = NULL;
+  if (tok->type == (enum TokenSyms )term)
+    goto end_of_token;
+
+  switch (tok->type) {
+  case TK_ALT:
+  case TK_EOT:
+  end_of_token:
+    *np = node_new_empty();
+    return tok->type;
+    break;
+
+  case TK_SUBEXP_OPEN:
+    r = parse_enclose(np, tok, TK_SUBEXP_CLOSE, src, end, env);
+    if (r < 0) return r;
+    if (r == 1) group = 1;
+    else if (r == 2) { /* option only */
+      Node* target;
+      OnigOptionType prev = env->option;
+
+      env->option = NENCLOSE(*np)->option;
+      r = fetch_token(tok, src, end, env);
+      if (r < 0) return r;
+      r = parse_subexp(&target, tok, term, src, end, env);
+      env->option = prev;
+      if (r < 0) {
+	onig_node_free(target);
+	return r;
+      }
+      NENCLOSE(*np)->target = target;
+      return tok->type;
+    }
+    break;
+
+  case TK_SUBEXP_CLOSE:
+    if (! IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP))
+      return ONIGERR_UNMATCHED_CLOSE_PARENTHESIS;
+
+    if (tok->escaped) goto tk_raw_byte;
+    else goto tk_byte;
+    break;
+
+  case TK_LINEBREAK:
+    r = node_linebreak(np, env);
+    if (r < 0) return r;
+    break;
+
+  case TK_EXTENDED_GRAPHEME_CLUSTER:
+    r = node_extended_grapheme_cluster(np, env);
+    if (r < 0) return r;
+    break;
+
+  case TK_KEEP:
+    *np = onig_node_new_anchor(ANCHOR_KEEP);
+    CHECK_NULL_RETURN_MEMERR(*np);
+    break;
+
+  case TK_STRING:
+  tk_byte:
+    {
+      *np = node_new_str(tok->backp, *src);
+      CHECK_NULL_RETURN_MEMERR(*np);
+
+    string_loop:
+      while (1) {
+	r = fetch_token(tok, src, end, env);
+	if (r < 0) return r;
+	if (r == TK_STRING) {
+	  r = onig_node_str_cat(*np, tok->backp, *src);
+	}
+#ifndef NUMBERED_CHAR_IS_NOT_CASE_AMBIG
+	else if (r == TK_CODE_POINT) {
+	  r = node_str_cat_codepoint(*np, env->enc, tok->u.code);
+	}
+#endif
+	else {
+	  break;
+	}
+	if (r < 0) return r;
+      }
+
+    string_end:
+      targetp = np;
+      goto repeat;
+    }
+    break;
+
+  case TK_RAW_BYTE:
+  tk_raw_byte:
+    {
+      *np = node_new_str_raw_char((UChar )tok->u.c);
+      CHECK_NULL_RETURN_MEMERR(*np);
+      len = 1;
+      while (1) {
+	if (len >= ONIGENC_MBC_MINLEN(env->enc)) {
+	  if (len == enclen(env->enc, NSTR(*np)->s)) {
+	    r = fetch_token(tok, src, end, env);
+	    NSTRING_CLEAR_RAW(*np);
+	    goto string_end;
+	  }
+	}
+
+	r = fetch_token(tok, src, end, env);
+	if (r < 0) return r;
+	if (r != TK_RAW_BYTE) {
+	  /* Don't use this, it is wrong for little endian encodings. */
+#ifdef USE_PAD_TO_SHORT_BYTE_CHAR
+	  int rem;
+	  if (len < ONIGENC_MBC_MINLEN(env->enc)) {
+	    rem = ONIGENC_MBC_MINLEN(env->enc) - len;
+	    (void )node_str_head_pad(NSTR(*np), rem, (UChar )0);
+	    if (len + rem == enclen(env->enc, NSTR(*np)->s)) {
+	      NSTRING_CLEAR_RAW(*np);
+	      goto string_end;
+	    }
+	  }
+#endif
+	  return ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;
+	}
+
+	r = node_str_cat_char(*np, (UChar )tok->u.c);
+	if (r < 0) return r;
+
+	len++;
+      }
+    }
+    break;
+
+  case TK_CODE_POINT:
+    {
+      *np = node_new_empty();
+      CHECK_NULL_RETURN_MEMERR(*np);
+      r = node_str_cat_codepoint(*np, env->enc, tok->u.code);
+      if (r != 0) return r;
+#ifdef NUMBERED_CHAR_IS_NOT_CASE_AMBIG
+      NSTRING_SET_RAW(*np);
+#else
+      goto string_loop;
+#endif
+    }
+    break;
+
+  case TK_QUOTE_OPEN:
+    {
+      OnigCodePoint end_op[2];
+      UChar *qstart, *qend, *nextp;
+
+      end_op[0] = (OnigCodePoint )MC_ESC(env->syntax);
+      end_op[1] = (OnigCodePoint )'E';
+      qstart = *src;
+      qend = find_str_position(end_op, 2, qstart, end, &nextp, env->enc);
+      if (IS_NULL(qend)) {
+	nextp = qend = end;
+      }
+      *np = node_new_str(qstart, qend);
+      CHECK_NULL_RETURN_MEMERR(*np);
+      *src = nextp;
+    }
+    break;
+
+  case TK_CHAR_TYPE:
+    {
+      switch (tok->u.prop.ctype) {
+      case ONIGENC_CTYPE_WORD:
+	*np = node_new_ctype(tok->u.prop.ctype, tok->u.prop.not,
+			     IS_ASCII_RANGE(env->option));
+	CHECK_NULL_RETURN_MEMERR(*np);
+	break;
+
+      case ONIGENC_CTYPE_SPACE:
+      case ONIGENC_CTYPE_DIGIT:
+      case ONIGENC_CTYPE_XDIGIT:
+	{
+	  CClassNode* cc;
+
+#ifdef USE_SHARED_CCLASS_TABLE
+          const OnigCodePoint *mbr;
+	  OnigCodePoint sb_out;
+
+          r = ONIGENC_GET_CTYPE_CODE_RANGE(env->enc, tok->u.prop.ctype,
+					   &sb_out, &mbr);
+          if (r == 0 &&
+              ! IS_ASCII_RANGE(env->option) &&
+              ONIGENC_CODE_RANGE_NUM(mbr)
+              >= THRESHOLD_RANGE_NUM_FOR_SHARE_CCLASS) {
+            type_cclass_key  key;
+            type_cclass_key* new_key;
+
+            key.enc  = env->enc;
+            key.not  = tok->u.prop.not;
+            key.type = tok->u.prop.ctype;
+
+            THREAD_ATOMIC_START;
+
+            if (IS_NULL(OnigTypeCClassTable)) {
+              OnigTypeCClassTable
+                = onig_st_init_table_with_size(&type_type_cclass_hash, 10);
+              if (IS_NULL(OnigTypeCClassTable)) {
+                THREAD_ATOMIC_END;
+                return ONIGERR_MEMORY;
+              }
+            }
+            else {
+              if (onig_st_lookup(OnigTypeCClassTable, (st_data_t )&key,
+                                 (st_data_t* )np)) {
+                THREAD_ATOMIC_END;
+                break;
+              }
+            }
+
+            *np = node_new_cclass_by_codepoint_range(tok->u.prop.not,
+						     sb_out, mbr);
+            if (IS_NULL(*np)) {
+              THREAD_ATOMIC_END;
+              return ONIGERR_MEMORY;
+            }
+
+            cc = NCCLASS(*np);
+            NCCLASS_SET_SHARE(cc);
+            new_key = (type_cclass_key* )xmalloc(sizeof(type_cclass_key));
+	    xmemcpy(new_key, &key, sizeof(type_cclass_key));
+            onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key,
+                               (st_data_t )*np);
+
+            THREAD_ATOMIC_END;
+          }
+          else {
+#endif
+            *np = node_new_cclass();
+            CHECK_NULL_RETURN_MEMERR(*np);
+            cc = NCCLASS(*np);
+            r = add_ctype_to_cc(cc, tok->u.prop.ctype, 0,
+			    IS_ASCII_RANGE(env->option), env);
+	    if (r != 0) return r;
+            if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc);
+#ifdef USE_SHARED_CCLASS_TABLE
+          }
+#endif
+	}
+	break;
+
+      default:
+	return ONIGERR_PARSER_BUG;
+	break;
+      }
+    }
+    break;
+
+  case TK_CHAR_PROPERTY:
+    r = parse_char_property(np, tok, src, end, env);
+    if (r != 0) return r;
+    break;
+
+  case TK_CC_OPEN:
+    {
+      Node *asc_node;
+      CClassNode* cc;
+      OnigCodePoint code;
+
+      r = parse_char_class(np, &asc_node, tok, src, end, env);
+      if (r != 0) {
+	onig_node_free(asc_node);
+	return r;
+      }
+
+      cc = NCCLASS(*np);
+      if (is_onechar_cclass(cc, &code)) {
+	onig_node_free(*np);
+	onig_node_free(asc_node);
+	*np = node_new_empty();
+	CHECK_NULL_RETURN_MEMERR(*np);
+	r = node_str_cat_codepoint(*np, env->enc, code);
+	if (r != 0) return r;
+	goto string_loop;
+      }
+      if (IS_IGNORECASE(env->option)) {
+	r = cclass_case_fold(np, cc, NCCLASS(asc_node), env);
+	if (r != 0) {
+	  onig_node_free(asc_node);
+	  return r;
+	}
+      }
+      onig_node_free(asc_node);
+    }
+    break;
+
+  case TK_ANYCHAR:
+    *np = node_new_anychar();
+    CHECK_NULL_RETURN_MEMERR(*np);
+    break;
+
+  case TK_ANYCHAR_ANYTIME:
+    *np = node_new_anychar();
+    CHECK_NULL_RETURN_MEMERR(*np);
+    qn = node_new_quantifier(0, REPEAT_INFINITE, 0);
+    CHECK_NULL_RETURN_MEMERR(qn);
+    NQTFR(qn)->target = *np;
+    *np = qn;
+    break;
+
+  case TK_BACKREF:
+    len = tok->u.backref.num;
+    *np = node_new_backref(len,
+		   (len > 1 ? tok->u.backref.refs : &(tok->u.backref.ref1)),
+			   tok->u.backref.by_name,
+#ifdef USE_BACKREF_WITH_LEVEL
+			   tok->u.backref.exist_level,
+			   tok->u.backref.level,
+#endif
+			   env);
+    CHECK_NULL_RETURN_MEMERR(*np);
+    break;
+
+#ifdef USE_SUBEXP_CALL
+  case TK_CALL:
+    {
+      int gnum = tok->u.call.gnum;
+
+      if (gnum < 0 || tok->u.call.rel != 0) {
+	if (gnum > 0) gnum--;
+	gnum = BACKREF_REL_TO_ABS(gnum, env);
+	if (gnum <= 0)
+	  return ONIGERR_INVALID_BACKREF;
+      }
+      *np = node_new_call(tok->u.call.name, tok->u.call.name_end, gnum);
+      CHECK_NULL_RETURN_MEMERR(*np);
+      env->num_call++;
+    }
+    break;
+#endif
+
+  case TK_ANCHOR:
+    *np = onig_node_new_anchor(tok->u.anchor.subtype);
+    CHECK_NULL_RETURN_MEMERR(*np);
+    NANCHOR(*np)->ascii_range = tok->u.anchor.ascii_range;
+    break;
+
+  case TK_OP_REPEAT:
+  case TK_INTERVAL:
+    if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS)) {
+      if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS))
+	return ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED;
+      else
+	*np = node_new_empty();
+    }
+    else {
+      goto tk_byte;
+    }
+    break;
+
+  default:
+    return ONIGERR_PARSER_BUG;
+    break;
+  }
+
+  {
+    targetp = np;
+
+  re_entry:
+    r = fetch_token(tok, src, end, env);
+    if (r < 0) return r;
+
+  repeat:
+    if (r == TK_OP_REPEAT || r == TK_INTERVAL) {
+      if (is_invalid_quantifier_target(*targetp))
+	return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID;
+
+      qn = node_new_quantifier(tok->u.repeat.lower, tok->u.repeat.upper,
+			       (r == TK_INTERVAL ? 1 : 0));
+      CHECK_NULL_RETURN_MEMERR(qn);
+      NQTFR(qn)->greedy = tok->u.repeat.greedy;
+      r = set_quantifier(qn, *targetp, group, env);
+      if (r < 0) {
+	onig_node_free(qn);
+	return r;
+      }
+
+      if (tok->u.repeat.possessive != 0) {
+	Node* en;
+	en = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
+	if (IS_NULL(en)) {
+	  onig_node_free(qn);
+	  return ONIGERR_MEMORY;
+	}
+	NENCLOSE(en)->target = qn;
+	qn = en;
+      }
+
+      if (r == 0) {
+	*targetp = qn;
+      }
+      else if (r == 1) {
+	onig_node_free(qn);
+      }
+      else if (r == 2) { /* split case: /abc+/ */
+	Node *tmp;
+
+	*targetp = node_new_list(*targetp, NULL);
+	if (IS_NULL(*targetp)) {
+	  onig_node_free(qn);
+	  return ONIGERR_MEMORY;
+	}
+	tmp = NCDR(*targetp) = node_new_list(qn, NULL);
+	if (IS_NULL(tmp)) {
+	  onig_node_free(qn);
+	  return ONIGERR_MEMORY;
+	}
+	targetp = &(NCAR(tmp));
+      }
+      goto re_entry;
+    }
+  }
+
+  return r;
+}
+
+static int
+parse_branch(Node** top, OnigToken* tok, int term,
+	     UChar** src, UChar* end, ScanEnv* env)
+{
+  int r;
+  Node *node, **headp;
+
+  *top = NULL;
+  r = parse_exp(&node, tok, term, src, end, env);
+  if (r < 0) {
+    onig_node_free(node);
+    return r;
+  }
+
+  if (r == TK_EOT || r == term || r == TK_ALT) {
+    *top = node;
+  }
+  else {
+    *top  = node_new_list(node, NULL);
+    headp = &(NCDR(*top));
+    while (r != TK_EOT && r != term && r != TK_ALT) {
+      r = parse_exp(&node, tok, term, src, end, env);
+      if (r < 0) {
+	onig_node_free(node);
+	return r;
+      }
+
+      if (NTYPE(node) == NT_LIST) {
+	*headp = node;
+	while (IS_NOT_NULL(NCDR(node))) node = NCDR(node);
+	headp = &(NCDR(node));
+      }
+      else {
+	*headp = node_new_list(node, NULL);
+	headp = &(NCDR(*headp));
+      }
+    }
+  }
+
+  return r;
+}
+
+/* term_tok: TK_EOT or TK_SUBEXP_CLOSE */
+static int
+parse_subexp(Node** top, OnigToken* tok, int term,
+	     UChar** src, UChar* end, ScanEnv* env)
+{
+  int r;
+  Node *node, **headp;
+
+  *top = NULL;
+  r = parse_branch(&node, tok, term, src, end, env);
+  if (r < 0) {
+    onig_node_free(node);
+    return r;
+  }
+
+  if (r == term) {
+    *top = node;
+  }
+  else if (r == TK_ALT) {
+    *top  = onig_node_new_alt(node, NULL);
+    headp = &(NCDR(*top));
+    while (r == TK_ALT) {
+      r = fetch_token(tok, src, end, env);
+      if (r < 0) return r;
+      r = parse_branch(&node, tok, term, src, end, env);
+      if (r < 0) {
+	onig_node_free(node);
+	return r;
+      }
+
+      *headp = onig_node_new_alt(node, NULL);
+      headp = &(NCDR(*headp));
+    }
+
+    if (tok->type != (enum TokenSyms )term)
+      goto err;
+  }
+  else {
+    onig_node_free(node);
+  err:
+    if (term == TK_SUBEXP_CLOSE)
+      return ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS;
+    else
+      return ONIGERR_PARSER_BUG;
+  }
+
+  return r;
+}
+
+static int
+parse_regexp(Node** top, UChar** src, UChar* end, ScanEnv* env)
+{
+  int r;
+  OnigToken tok;
+
+  r = fetch_token(&tok, src, end, env);
+  if (r < 0) return r;
+  r = parse_subexp(top, &tok, TK_EOT, src, end, env);
+  if (r < 0) return r;
+
+#ifdef USE_SUBEXP_CALL
+  if (env->num_call > 0) {
+    /* Capture the pattern itself. It is used for (?R), (?0) and \g<0>. */
+    const int num = 0;
+    Node* np;
+    np = node_new_enclose_memory(env->option, 0);
+    CHECK_NULL_RETURN_MEMERR(np);
+    NENCLOSE(np)->regnum = num;
+    NENCLOSE(np)->target = *top;
+    r = scan_env_set_mem_node(env, num, np);
+    if (r != 0) {
+	onig_node_free(np);
+	return r;
+    }
+    *top = np;
+  }
+#endif
+  return 0;
+}
+
+extern int
+onig_parse_make_tree(Node** root, const UChar* pattern, const UChar* end,
+		     regex_t* reg, ScanEnv* env)
+{
+  int r;
+  UChar* p;
+
+#ifdef USE_NAMED_GROUP
+  names_clear(reg);
+#endif
+
+  scan_env_clear(env);
+  env->option         = reg->options;
+  env->case_fold_flag = reg->case_fold_flag;
+  env->enc            = reg->enc;
+  env->syntax         = reg->syntax;
+  env->pattern        = (UChar* )pattern;
+  env->pattern_end    = (UChar* )end;
+  env->reg            = reg;
+
+  *root = NULL;
+  p = (UChar* )pattern;
+  r = parse_regexp(root, &p, (UChar* )end, env);
+  reg->num_mem = env->num_mem;
+  return r;
+}
+
+extern void
+onig_scan_env_set_error_string(ScanEnv* env, int ecode ARG_UNUSED,
+				UChar* arg, UChar* arg_end)
+{
+  env->error     = arg;
+  env->error_end = arg_end;
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regparse.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regparse.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regparse.h	(revision 279)
@@ -0,0 +1,360 @@
+#ifndef REGPARSE_H
+#define REGPARSE_H
+/**********************************************************************
+  regparse.h -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+/* node type */
+#define NT_STR         0
+#define NT_CCLASS      1
+#define NT_CTYPE       2
+#define NT_CANY        3
+#define NT_BREF        4
+#define NT_QTFR        5
+#define NT_ENCLOSE     6
+#define NT_ANCHOR      7
+#define NT_LIST        8
+#define NT_ALT         9
+#define NT_CALL       10
+
+/* node type bit */
+#define NTYPE2BIT(type)      (1<<(type))
+
+#define BIT_NT_STR        NTYPE2BIT(NT_STR)
+#define BIT_NT_CCLASS     NTYPE2BIT(NT_CCLASS)
+#define BIT_NT_CTYPE      NTYPE2BIT(NT_CTYPE)
+#define BIT_NT_CANY       NTYPE2BIT(NT_CANY)
+#define BIT_NT_BREF       NTYPE2BIT(NT_BREF)
+#define BIT_NT_QTFR       NTYPE2BIT(NT_QTFR)
+#define BIT_NT_ENCLOSE    NTYPE2BIT(NT_ENCLOSE)
+#define BIT_NT_ANCHOR     NTYPE2BIT(NT_ANCHOR)
+#define BIT_NT_LIST       NTYPE2BIT(NT_LIST)
+#define BIT_NT_ALT        NTYPE2BIT(NT_ALT)
+#define BIT_NT_CALL       NTYPE2BIT(NT_CALL)
+
+#define IS_NODE_TYPE_SIMPLE(type) \
+  ((NTYPE2BIT(type) & (BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE |\
+                       BIT_NT_CANY | BIT_NT_BREF)) != 0)
+
+#define NTYPE(node)             ((node)->u.base.type)
+#define SET_NTYPE(node, ntype) \
+    do { \
+	int value = ntype; \
+	memcpy(&((node)->u.base.type), &value, sizeof(int)); \
+    } while (0)
+
+#define NSTR(node)         (&((node)->u.str))
+#define NCCLASS(node)      (&((node)->u.cclass))
+#define NCTYPE(node)       (&((node)->u.ctype))
+#define NBREF(node)        (&((node)->u.bref))
+#define NQTFR(node)        (&((node)->u.qtfr))
+#define NENCLOSE(node)     (&((node)->u.enclose))
+#define NANCHOR(node)      (&((node)->u.anchor))
+#define NCONS(node)        (&((node)->u.cons))
+#define NCALL(node)        (&((node)->u.call))
+
+#define NCAR(node)         (NCONS(node)->car)
+#define NCDR(node)         (NCONS(node)->cdr)
+
+
+
+#define ANCHOR_ANYCHAR_STAR_MASK (ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML)
+#define ANCHOR_END_BUF_MASK      (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)
+
+#define ENCLOSE_MEMORY           (1<<0)
+#define ENCLOSE_OPTION           (1<<1)
+#define ENCLOSE_STOP_BACKTRACK   (1<<2)
+#define ENCLOSE_CONDITION        (1<<3)
+
+#define NODE_STR_MARGIN         16
+#define NODE_STR_BUF_SIZE       24  /* sizeof(CClassNode) - sizeof(int)*4 */
+#define NODE_BACKREFS_SIZE       6
+
+#define NSTR_RAW                (1<<0) /* by backslashed number */
+#define NSTR_AMBIG              (1<<1)
+#define NSTR_DONT_GET_OPT_INFO  (1<<2)
+
+#define NSTRING_LEN(node) (OnigDistance )((node)->u.str.end - (node)->u.str.s)
+#define NSTRING_SET_RAW(node)          (node)->u.str.flag |= NSTR_RAW
+#define NSTRING_CLEAR_RAW(node)        (node)->u.str.flag &= ~NSTR_RAW
+#define NSTRING_SET_AMBIG(node)        (node)->u.str.flag |= NSTR_AMBIG
+#define NSTRING_SET_DONT_GET_OPT_INFO(node) \
+  (node)->u.str.flag |= NSTR_DONT_GET_OPT_INFO
+#define NSTRING_IS_RAW(node)          (((node)->u.str.flag & NSTR_RAW)   != 0)
+#define NSTRING_IS_AMBIG(node)        (((node)->u.str.flag & NSTR_AMBIG) != 0)
+#define NSTRING_IS_DONT_GET_OPT_INFO(node) \
+  (((node)->u.str.flag & NSTR_DONT_GET_OPT_INFO) != 0)
+
+#define BACKREFS_P(br) \
+  (IS_NOT_NULL((br)->back_dynamic) ? (br)->back_dynamic : (br)->back_static);
+
+#define NQ_TARGET_ISNOT_EMPTY     0
+#define NQ_TARGET_IS_EMPTY        1
+#define NQ_TARGET_IS_EMPTY_MEM    2
+#define NQ_TARGET_IS_EMPTY_REC    3
+
+/* status bits */
+#define NST_MIN_FIXED             (1<<0)
+#define NST_MAX_FIXED             (1<<1)
+#define NST_CLEN_FIXED            (1<<2)
+#define NST_MARK1                 (1<<3)
+#define NST_MARK2                 (1<<4)
+#define NST_MEM_BACKREFED         (1<<5)
+#define NST_STOP_BT_SIMPLE_REPEAT (1<<6)
+#define NST_RECURSION             (1<<7)
+#define NST_CALLED                (1<<8)
+#define NST_ADDR_FIXED            (1<<9)
+#define NST_NAMED_GROUP           (1<<10)
+#define NST_NAME_REF              (1<<11)
+#define NST_IN_REPEAT             (1<<12) /* STK_REPEAT is nested in stack. */
+#define NST_NEST_LEVEL            (1<<13)
+#define NST_BY_NUMBER             (1<<14) /* {n,m} */
+
+#define SET_ENCLOSE_STATUS(node,f)      (node)->u.enclose.state |=  (f)
+#define CLEAR_ENCLOSE_STATUS(node,f)    (node)->u.enclose.state &= ~(f)
+
+#define IS_ENCLOSE_CALLED(en)          (((en)->state & NST_CALLED)        != 0)
+#define IS_ENCLOSE_ADDR_FIXED(en)      (((en)->state & NST_ADDR_FIXED)    != 0)
+#define IS_ENCLOSE_RECURSION(en)       (((en)->state & NST_RECURSION)     != 0)
+#define IS_ENCLOSE_MARK1(en)           (((en)->state & NST_MARK1)         != 0)
+#define IS_ENCLOSE_MARK2(en)           (((en)->state & NST_MARK2)         != 0)
+#define IS_ENCLOSE_MIN_FIXED(en)       (((en)->state & NST_MIN_FIXED)     != 0)
+#define IS_ENCLOSE_MAX_FIXED(en)       (((en)->state & NST_MAX_FIXED)     != 0)
+#define IS_ENCLOSE_CLEN_FIXED(en)      (((en)->state & NST_CLEN_FIXED)    != 0)
+#define IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(en) \
+    (((en)->state & NST_STOP_BT_SIMPLE_REPEAT) != 0)
+#define IS_ENCLOSE_NAMED_GROUP(en)     (((en)->state & NST_NAMED_GROUP)   != 0)
+#define IS_ENCLOSE_NAME_REF(en)        (((en)->state & NST_NAME_REF)      != 0)
+
+#define SET_CALL_RECURSION(node)       (node)->u.call.state |= NST_RECURSION
+#define IS_CALL_RECURSION(cn)          (((cn)->state & NST_RECURSION)  != 0)
+#define IS_CALL_NAME_REF(cn)           (((cn)->state & NST_NAME_REF)   != 0)
+#define IS_BACKREF_NAME_REF(bn)        (((bn)->state & NST_NAME_REF)   != 0)
+#define IS_BACKREF_NEST_LEVEL(bn)      (((bn)->state & NST_NEST_LEVEL) != 0)
+#define IS_QUANTIFIER_IN_REPEAT(qn)    (((qn)->state & NST_IN_REPEAT)  != 0)
+#define IS_QUANTIFIER_BY_NUMBER(qn)    (((qn)->state & NST_BY_NUMBER)  != 0)
+
+#define CALLNODE_REFNUM_UNDEF  -1
+
+typedef struct {
+  NodeBase base;
+  UChar* s;
+  UChar* end;
+  unsigned int flag;
+  int    capa;    /* (allocated size - 1) or 0: use buf[] */
+  UChar  buf[NODE_STR_BUF_SIZE];
+} StrNode;
+
+typedef struct {
+  NodeBase base;
+  int state;
+  struct _Node* target;
+  int lower;
+  int upper;
+  int greedy;
+  int target_empty_info;
+  struct _Node* head_exact;
+  struct _Node* next_head_exact;
+  int is_refered;     /* include called node. don't eliminate even if {0} */
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  int comb_exp_check_num;  /* 1,2,3...: check,  0: no check  */
+#endif
+} QtfrNode;
+
+typedef struct {
+  NodeBase base;
+  int state;
+  int type;
+  int regnum;
+  OnigOptionType option;
+  AbsAddrType    call_addr;
+  struct _Node*  target;
+  /* for multiple call reference */
+  OnigDistance min_len; /* min length (byte) */
+  OnigDistance max_len; /* max length (byte) */
+  int char_len;         /* character length  */
+  int opt_count;        /* referenced count in optimize_node_left() */
+} EncloseNode;
+
+#ifdef USE_SUBEXP_CALL
+
+typedef struct {
+  int           offset;
+  struct _Node* target;
+} UnsetAddr;
+
+typedef struct {
+  int        num;
+  int        alloc;
+  UnsetAddr* us;
+} UnsetAddrList;
+
+typedef struct {
+  NodeBase base;
+  int     state;
+  int     group_num;
+  UChar*  name;
+  UChar*  name_end;
+  struct _Node*  target;  /* EncloseNode : ENCLOSE_MEMORY */
+  UnsetAddrList* unset_addr_list;
+} CallNode;
+
+#endif
+
+typedef struct {
+  NodeBase base;
+  int  state;
+  int  back_num;
+  int  back_static[NODE_BACKREFS_SIZE];
+  int* back_dynamic;
+  int  nest_level;
+} BRefNode;
+
+typedef struct {
+  NodeBase base;
+  int type;
+  struct _Node* target;
+  int char_len;
+  int ascii_range;
+} AnchorNode;
+
+typedef struct {
+  NodeBase base;
+  struct _Node* car;
+  struct _Node* cdr;
+} ConsAltNode;
+
+typedef struct {
+  NodeBase base;
+  int ctype;
+  int not;
+  int ascii_range;
+} CtypeNode;
+
+typedef struct _Node {
+  union {
+    NodeBase     base;
+    StrNode      str;
+    CClassNode   cclass;
+    QtfrNode     qtfr;
+    EncloseNode  enclose;
+    BRefNode     bref;
+    AnchorNode   anchor;
+    ConsAltNode  cons;
+    CtypeNode    ctype;
+#ifdef USE_SUBEXP_CALL
+    CallNode     call;
+#endif
+  } u;
+} Node;
+
+
+#define NULL_NODE  ((Node* )0)
+
+#define SCANENV_MEMNODES_SIZE               8
+#define SCANENV_MEM_NODES(senv)   \
+ (IS_NOT_NULL((senv)->mem_nodes_dynamic) ? \
+    (senv)->mem_nodes_dynamic : (senv)->mem_nodes_static)
+
+typedef struct {
+  OnigOptionType   option;
+  OnigCaseFoldType case_fold_flag;
+  OnigEncoding     enc;
+  OnigSyntaxType*  syntax;
+  BitStatusType    capture_history;
+  BitStatusType    bt_mem_start;
+  BitStatusType    bt_mem_end;
+  BitStatusType    backrefed_mem;
+  UChar*           pattern;
+  UChar*           pattern_end;
+  UChar*           error;
+  UChar*           error_end;
+  regex_t*         reg;       /* for reg->names only */
+#ifdef USE_SUBEXP_CALL
+  UnsetAddrList*   unset_addr_list;
+#endif
+  int              num_call;
+  int              num_mem;
+#ifdef USE_NAMED_GROUP
+  int              num_named;
+#endif
+  int              mem_alloc;
+  Node*            mem_nodes_static[SCANENV_MEMNODES_SIZE];
+  Node**           mem_nodes_dynamic;
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+  int num_comb_exp_check;
+  int comb_exp_max_regnum;
+  int curr_max_regnum;
+  int has_recursion;
+#endif
+} ScanEnv;
+
+
+#define IS_SYNTAX_OP(syn, opm)    (((syn)->op  & (opm)) != 0)
+#define IS_SYNTAX_OP2(syn, opm)   (((syn)->op2 & (opm)) != 0)
+#define IS_SYNTAX_BV(syn, bvm)    (((syn)->behavior & (bvm)) != 0)
+
+#ifdef USE_NAMED_GROUP
+typedef struct {
+  int new_val;
+} GroupNumRemap;
+
+extern int    onig_renumber_name_table P_((regex_t* reg, GroupNumRemap* map));
+#endif
+
+extern int    onig_strncmp P_((const UChar* s1, const UChar* s2, int n));
+extern void   onig_strcpy P_((UChar* dest, const UChar* src, const UChar* end));
+extern void   onig_scan_env_set_error_string P_((ScanEnv* env, int ecode, UChar* arg, UChar* arg_end));
+extern int    onig_scan_unsigned_number P_((UChar** src, const UChar* end, OnigEncoding enc));
+extern void   onig_reduce_nested_quantifier P_((Node* pnode, Node* cnode));
+extern void   onig_node_conv_to_str_node P_((Node* node, int raw));
+extern int    onig_node_str_cat P_((Node* node, const UChar* s, const UChar* end));
+extern int    onig_node_str_set P_((Node* node, const UChar* s, const UChar* end));
+extern void   onig_node_free P_((Node* node));
+extern Node*  onig_node_new_enclose P_((int type));
+extern Node*  onig_node_new_anchor P_((int type));
+extern Node*  onig_node_new_str P_((const UChar* s, const UChar* end));
+extern Node*  onig_node_new_list P_((Node* left, Node* right));
+extern Node*  onig_node_list_add P_((Node* list, Node* x));
+extern Node*  onig_node_new_alt P_((Node* left, Node* right));
+extern void   onig_node_str_clear P_((Node* node));
+extern int    onig_free_node_list P_((void));
+extern int    onig_names_free P_((regex_t* reg));
+extern int    onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env));
+extern int    onig_free_shared_cclass_table P_((void));
+
+#ifdef ONIG_DEBUG
+#ifdef USE_NAMED_GROUP
+extern int onig_print_names(FILE*, regex_t*);
+#endif
+#endif
+
+#endif /* REGPARSE_H */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regposerr.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regposerr.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regposerr.c	(revision 279)
@@ -0,0 +1,100 @@
+/**********************************************************************
+  regposerr.c - Oniguruma (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "onigposix.h"
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+#if defined(__GNUC__)
+#  define ARG_UNUSED  __attribute__ ((unused))
+#else
+#  define ARG_UNUSED
+#endif
+
+#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
+
+static const char* ESTRING[] = {
+  NULL,
+  "failed to match",                         /* REG_NOMATCH    */
+  "Invalid regular expression",              /* REG_BADPAT     */
+  "invalid collating element referenced",    /* REG_ECOLLATE   */
+  "invalid character class type referenced", /* REG_ECTYPE     */
+  "bad backslash-escape sequence",           /* REG_EESCAPE    */
+  "invalid back reference number",           /* REG_ESUBREG    */
+  "imbalanced [ and ]",                      /* REG_EBRACK     */
+  "imbalanced ( and )",                      /* REG_EPAREN     */
+  "imbalanced { and }",                      /* REG_EBRACE     */
+  "invalid repeat range {n,m}",              /* REG_BADBR      */
+  "invalid range",                           /* REG_ERANGE     */
+  "Out of memory",                           /* REG_ESPACE     */
+  "? * + not preceded by valid regular expression", /* REG_BADRPT   */
+
+  /* Extended errors */
+  "internal error",                          /* REG_EONIG_INTERNAL */
+  "invalid wide char value",                 /* REG_EONIG_BADWC    */
+  "invalid argument",                        /* REG_EONIG_BADARG   */
+  "multi-thread error"                       /* REG_EONIG_THREAD   */
+};
+
+#include <stdio.h>
+
+
+extern size_t
+regerror(int posix_ecode, const regex_t* reg ARG_UNUSED, char* buf,
+	 size_t size)
+{
+  const char* s;
+  char tbuf[35];
+  size_t len;
+
+  if (posix_ecode > 0
+      && posix_ecode < numberof(ESTRING)) {
+    s = ESTRING[posix_ecode];
+  }
+  else if (posix_ecode == 0) {
+    s = "";
+  }
+  else {
+    sprintf(tbuf, "undefined error code (%d)", posix_ecode);
+    s = tbuf;
+  }
+
+  len = strlen(s) + 1; /* use strlen() because s is ascii encoding. */
+
+  if (buf != NULL && size > 0) {
+    strncpy(buf, s, size - 1);
+    buf[size - 1] = '\0';
+  }
+  return len;
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regposix.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regposix.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regposix.c	(revision 279)
@@ -0,0 +1,307 @@
+/**********************************************************************
+  regposix.c - Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define regex_t   onig_regex_t
+#include "regint.h"
+#undef regex_t
+#include "onigposix.h"
+
+#define ONIG_C(reg)    ((onig_regex_t* )((reg)->onig))
+#define PONIG_C(reg)   ((onig_regex_t** )(&(reg)->onig))
+
+/* #define ENC_STRING_LEN(enc,s,len)    len = strlen(s) */
+#define ENC_STRING_LEN(enc,s,len) do { \
+  if (ONIGENC_MBC_MINLEN(enc) == 1) { \
+    UChar* tmps = (UChar* )(s); \
+    while (*tmps != 0) tmps++; \
+    len = (int )(tmps - (UChar* )(s)); \
+  } \
+  else { \
+    len = onigenc_str_bytelen_null(enc, (UChar* )s); \
+  } \
+} while(0)
+
+typedef struct {
+  int onig_err;
+  int posix_err;
+} O2PERR;
+
+static int
+onig2posix_error_code(int code)
+{
+  static const O2PERR o2p[] = {
+    { ONIG_MISMATCH,                                      REG_NOMATCH },
+    { ONIG_NO_SUPPORT_CONFIG,                             REG_EONIG_INTERNAL },
+    { ONIGERR_MEMORY,                                     REG_ESPACE  },
+    { ONIGERR_MATCH_STACK_LIMIT_OVER,                     REG_EONIG_INTERNAL },
+    { ONIGERR_TYPE_BUG,                                   REG_EONIG_INTERNAL },
+    { ONIGERR_PARSER_BUG,                                 REG_EONIG_INTERNAL },
+    { ONIGERR_STACK_BUG,                                  REG_EONIG_INTERNAL },
+    { ONIGERR_UNDEFINED_BYTECODE,                         REG_EONIG_INTERNAL },
+    { ONIGERR_UNEXPECTED_BYTECODE,                        REG_EONIG_INTERNAL },
+    { ONIGERR_DEFAULT_ENCODING_IS_NOT_SET,                REG_EONIG_BADARG },
+    { ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR, REG_EONIG_BADARG },
+    { ONIGERR_INVALID_ARGUMENT,                           REG_EONIG_BADARG },
+    { ONIGERR_END_PATTERN_AT_LEFT_BRACE,                  REG_EBRACE  },
+    { ONIGERR_END_PATTERN_AT_LEFT_BRACKET,                REG_EBRACK  },
+    { ONIGERR_EMPTY_CHAR_CLASS,                           REG_ECTYPE  },
+    { ONIGERR_PREMATURE_END_OF_CHAR_CLASS,                REG_ECTYPE  },
+    { ONIGERR_END_PATTERN_AT_ESCAPE,                      REG_EESCAPE },
+    { ONIGERR_END_PATTERN_AT_META,                        REG_EESCAPE },
+    { ONIGERR_END_PATTERN_AT_CONTROL,                     REG_EESCAPE },
+    { ONIGERR_META_CODE_SYNTAX,                           REG_BADPAT  },
+    { ONIGERR_CONTROL_CODE_SYNTAX,                        REG_BADPAT  },
+    { ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE,           REG_ECTYPE  },
+    { ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE,         REG_ECTYPE  },
+    { ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS,    REG_ECTYPE  },
+    { ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED,    REG_BADRPT  },
+    { ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID,          REG_BADRPT  },
+    { ONIGERR_NESTED_REPEAT_OPERATOR,                     REG_BADRPT  },
+    { ONIGERR_UNMATCHED_CLOSE_PARENTHESIS,                REG_EPAREN  },
+    { ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS,     REG_EPAREN  },
+    { ONIGERR_END_PATTERN_IN_GROUP,                       REG_BADPAT  },
+    { ONIGERR_UNDEFINED_GROUP_OPTION,                     REG_BADPAT  },
+    { ONIGERR_INVALID_POSIX_BRACKET_TYPE,                 REG_BADPAT  },
+    { ONIGERR_INVALID_LOOK_BEHIND_PATTERN,                REG_BADPAT  },
+    { ONIGERR_INVALID_REPEAT_RANGE_PATTERN,               REG_BADPAT  },
+    { ONIGERR_TOO_BIG_NUMBER,                             REG_BADPAT  },
+    { ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE,            REG_BADBR   },
+    { ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE,   REG_BADBR   },
+    { ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS,                  REG_ECTYPE  },
+    { ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE,        REG_ECTYPE  },
+    { ONIGERR_TOO_MANY_MULTI_BYTE_RANGES,                 REG_ECTYPE  },
+    { ONIGERR_TOO_SHORT_MULTI_BYTE_STRING,                REG_BADPAT  },
+    { ONIGERR_TOO_BIG_BACKREF_NUMBER,                     REG_ESUBREG },
+    { ONIGERR_INVALID_BACKREF,                            REG_ESUBREG },
+    { ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED,       REG_BADPAT  },
+    { ONIGERR_TOO_BIG_WIDE_CHAR_VALUE,                    REG_EONIG_BADWC },
+    { ONIGERR_TOO_LONG_WIDE_CHAR_VALUE,                   REG_EONIG_BADWC },
+    { ONIGERR_INVALID_CODE_POINT_VALUE,                   REG_EONIG_BADWC },
+    { ONIGERR_EMPTY_GROUP_NAME,                           REG_BADPAT },
+    { ONIGERR_INVALID_GROUP_NAME,                         REG_BADPAT },
+    { ONIGERR_INVALID_CHAR_IN_GROUP_NAME,                 REG_BADPAT },
+    { ONIGERR_UNDEFINED_NAME_REFERENCE,                   REG_BADPAT },
+    { ONIGERR_UNDEFINED_GROUP_REFERENCE,                  REG_BADPAT },
+    { ONIGERR_MULTIPLEX_DEFINED_NAME,                     REG_BADPAT },
+    { ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL,             REG_BADPAT },
+    { ONIGERR_NEVER_ENDING_RECURSION,                     REG_BADPAT },
+    { ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY,      REG_BADPAT },
+    { ONIGERR_INVALID_CHAR_PROPERTY_NAME,                 REG_BADPAT },
+    { ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION,         REG_EONIG_BADARG },
+    { ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT,               REG_EONIG_THREAD }
+
+  };
+
+  int i;
+
+  if (code >= 0) return 0;
+
+  for (i = 0; i < numberof(o2p); i++) {
+    if (code == o2p[i].onig_err)
+      return o2p[i].posix_err;
+  }
+
+  return REG_EONIG_INTERNAL;  /* but, unknown error code */
+}
+
+extern int
+regcomp(regex_t* reg, const char* pattern, int posix_options)
+{
+  int r, len;
+  OnigSyntaxType* syntax = OnigDefaultSyntax;
+  OnigOptionType options;
+
+  if ((posix_options & REG_EXTENDED) == 0)
+    syntax = ONIG_SYNTAX_POSIX_BASIC;
+
+  options = syntax->options;
+  if ((posix_options & REG_ICASE)   != 0)
+    ONIG_OPTION_ON(options, ONIG_OPTION_IGNORECASE);
+  if ((posix_options & REG_NEWLINE) != 0) {
+    ONIG_OPTION_ON( options, ONIG_OPTION_NEGATE_SINGLELINE);
+    ONIG_OPTION_OFF(options, ONIG_OPTION_SINGLELINE);
+  }
+
+  reg->comp_options = posix_options;
+
+  ENC_STRING_LEN(OnigEncDefaultCharEncoding, pattern, len);
+  r = onig_new(PONIG_C(reg), (UChar* )pattern, (UChar* )(pattern + len),
+	       options, OnigEncDefaultCharEncoding, syntax,
+	       (OnigErrorInfo* )NULL);
+  if (r != ONIG_NORMAL) {
+    return onig2posix_error_code(r);
+  }
+
+  reg->re_nsub = ONIG_C(reg)->num_mem;
+  return 0;
+}
+
+extern int
+regexec(regex_t* reg, const char* str, size_t nmatch,
+	regmatch_t pmatch[], int posix_options)
+{
+  int r, i, len;
+  UChar* end;
+  regmatch_t* pm;
+  OnigOptionType options;
+
+  options = ONIG_OPTION_POSIX_REGION;
+  if ((posix_options & REG_NOTBOL) != 0) options |= ONIG_OPTION_NOTBOL;
+  if ((posix_options & REG_NOTEOL) != 0) options |= ONIG_OPTION_NOTEOL;
+
+  if (nmatch == 0 || (reg->comp_options & REG_NOSUB) != 0) {
+    pm = (regmatch_t* )NULL;
+    nmatch = 0;
+  }
+  else if ((int )nmatch < ONIG_C(reg)->num_mem + 1) {
+    pm = (regmatch_t* )xmalloc(sizeof(regmatch_t)
+                               * (ONIG_C(reg)->num_mem + 1));
+    if (pm == NULL)
+      return REG_ESPACE;
+  }
+  else {
+    pm = pmatch;
+  }
+
+  ENC_STRING_LEN(ONIG_C(reg)->enc, str, len);
+  end = (UChar* )(str + len);
+  r = (int )onig_search(ONIG_C(reg), (UChar* )str, end, (UChar* )str, end,
+		  (OnigRegion* )pm, options);
+
+  if (r >= 0) {
+    r = 0; /* Match */
+    if (pm != pmatch && pm != NULL) {
+      xmemcpy(pmatch, pm, sizeof(regmatch_t) * nmatch);
+    }
+  }
+  else if (r == ONIG_MISMATCH) {
+    r = REG_NOMATCH;
+    for (i = 0; i < (int )nmatch; i++)
+      pmatch[i].rm_so = pmatch[i].rm_eo = ONIG_REGION_NOTPOS;
+  }
+  else {
+    r = onig2posix_error_code(r);
+  }
+
+  if (pm != pmatch && pm != NULL)
+    xfree(pm);
+
+#if 0
+  if (reg->re_nsub > nmatch - 1)
+    reg->re_nsub = (nmatch <= 1 ? 0 : nmatch - 1);
+#endif
+
+  return r;
+}
+
+extern void
+regfree(regex_t* reg)
+{
+  onig_free(ONIG_C(reg));
+}
+
+
+extern void
+reg_set_encoding(int mb_code)
+{
+  OnigEncoding enc;
+
+  switch (mb_code) {
+  case REG_POSIX_ENCODING_ASCII:
+    enc = ONIG_ENCODING_ASCII;
+    break;
+#if 0
+  case REG_POSIX_ENCODING_EUC_JP:
+    enc = ONIG_ENCODING_EUC_JP;
+    break;
+  case REG_POSIX_ENCODING_SJIS:
+    enc = ONIG_ENCODING_SJIS;
+    break;
+#endif
+  case REG_POSIX_ENCODING_UTF8:
+    enc = ONIG_ENCODING_UTF8;
+    break;
+#if 0
+  case REG_POSIX_ENCODING_UTF16_BE:
+    enc = ONIG_ENCODING_UTF16_BE;
+    break;
+  case REG_POSIX_ENCODING_UTF16_LE:
+    enc = ONIG_ENCODING_UTF16_LE;
+    break;
+#endif
+  default:
+    return ;
+    break;
+  }
+
+  onigenc_set_default_encoding(enc);
+}
+
+extern int
+reg_name_to_group_numbers(regex_t* reg,
+  const unsigned char* name, const unsigned char* name_end, int** nums)
+{
+  return onig_name_to_group_numbers(ONIG_C(reg), name, name_end, nums);
+}
+
+typedef struct {
+  int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*);
+  regex_t* reg;
+  void* arg;
+} i_wrap;
+
+static int
+i_wrapper(const UChar* name, const UChar* name_end, int ng, int* gs,
+	  onig_regex_t* reg ARG_UNUSED, void* arg)
+{
+  i_wrap* warg = (i_wrap* )arg;
+
+  return (*warg->func)(name, name_end, ng, gs, warg->reg, warg->arg);
+}
+
+extern int
+reg_foreach_name(regex_t* reg,
+ int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*),
+ void* arg)
+{
+  i_wrap warg;
+
+  warg.func = func;
+  warg.reg  = reg;
+  warg.arg  = arg;
+
+  return onig_foreach_name(ONIG_C(reg), i_wrapper, &warg);
+}
+
+extern int
+reg_number_of_names(regex_t* reg)
+{
+  return onig_number_of_names(ONIG_C(reg));
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regsyntax.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regsyntax.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regsyntax.c	(revision 279)
@@ -0,0 +1,387 @@
+/**********************************************************************
+  regsyntax.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2006  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2012  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+OnigSyntaxType OnigSyntaxASIS = {
+    0
+  , ONIG_SYN_OP2_INEFFECTIVE_ESCAPE
+  , 0
+  , ONIG_OPTION_NONE
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType OnigSyntaxPosixBasic = {
+  ( SYN_POSIX_COMMON_OP | ONIG_SYN_OP_ESC_LPAREN_SUBEXP |
+    ONIG_SYN_OP_ESC_BRACE_INTERVAL )
+  , 0
+  , 0
+  , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType OnigSyntaxPosixExtended = {
+  ( SYN_POSIX_COMMON_OP | ONIG_SYN_OP_LPAREN_SUBEXP |
+    ONIG_SYN_OP_BRACE_INTERVAL |
+    ONIG_SYN_OP_PLUS_ONE_INF | ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_VBAR_ALT )
+  , 0
+  , ( ONIG_SYN_CONTEXT_INDEP_ANCHORS |
+      ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS |
+      ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP |
+      ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
+  , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType OnigSyntaxEmacs = {
+  ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC |
+    ONIG_SYN_OP_ESC_BRACE_INTERVAL |
+    ONIG_SYN_OP_ESC_LPAREN_SUBEXP | ONIG_SYN_OP_ESC_VBAR_ALT |
+    ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF |
+    ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_DECIMAL_BACKREF |
+    ONIG_SYN_OP_LINE_ANCHOR | ONIG_SYN_OP_ESC_CONTROL_CHARS )
+  , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR
+  , ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC
+  , ONIG_OPTION_NONE
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType OnigSyntaxGrep = {
+  ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_POSIX_BRACKET |
+    ONIG_SYN_OP_ESC_BRACE_INTERVAL | ONIG_SYN_OP_ESC_LPAREN_SUBEXP |
+    ONIG_SYN_OP_ESC_VBAR_ALT |
+    ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_ESC_PLUS_ONE_INF |
+    ONIG_SYN_OP_ESC_QMARK_ZERO_ONE | ONIG_SYN_OP_LINE_ANCHOR |
+    ONIG_SYN_OP_ESC_W_WORD | ONIG_SYN_OP_ESC_B_WORD_BOUND |
+    ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | ONIG_SYN_OP_DECIMAL_BACKREF )
+  , 0
+  , ( ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC | ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC )
+  , ONIG_OPTION_NONE
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType OnigSyntaxGnuRegex = {
+  SYN_GNU_REGEX_OP
+  , 0
+  , SYN_GNU_REGEX_BV
+  , ONIG_OPTION_NONE
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType OnigSyntaxJava = {
+  (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
+     ONIG_SYN_OP_ESC_CONTROL_CHARS | ONIG_SYN_OP_ESC_C_CONTROL |
+     ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 )
+   & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
+  , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE | ONIG_SYN_OP2_QMARK_GROUP_EFFECT |
+      ONIG_SYN_OP2_OPTION_PERL | ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT |
+      ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL | ONIG_SYN_OP2_CCLASS_SET_OP |
+      ONIG_SYN_OP2_ESC_V_VTAB | ONIG_SYN_OP2_ESC_U_HEX4 |
+      ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY )
+  , ( SYN_GNU_REGEX_BV | ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND )
+  , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_ASCII_RANGE |
+      ONIG_OPTION_WORD_BOUND_ALL_RANGE )
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+/* Perl 5.8 */
+OnigSyntaxType OnigSyntaxPerl58 = {
+  (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
+     ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
+     ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
+     ONIG_SYN_OP_ESC_C_CONTROL )
+   & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
+  , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE |
+      ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
+      ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
+      ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
+      ONIG_SYN_OP2_ESC_CAPITAL_X_EXTENDED_GRAPHEME_CLUSTER |
+      ONIG_SYN_OP2_QMARK_LPAREN_CONDITION)
+  , SYN_GNU_REGEX_BV
+  , ONIG_OPTION_SINGLELINE
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+/* Perl 5.8 + named group */
+OnigSyntaxType OnigSyntaxPerl58_NG = {
+  (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
+     ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
+     ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
+     ONIG_SYN_OP_ESC_C_CONTROL )
+   & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
+  , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE |
+      ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
+      ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY  |
+      ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
+      ONIG_SYN_OP2_ESC_CAPITAL_X_EXTENDED_GRAPHEME_CLUSTER |
+      ONIG_SYN_OP2_QMARK_LPAREN_CONDITION     |
+      ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP       |
+      ONIG_SYN_OP2_ESC_K_NAMED_BACKREF        |
+      ONIG_SYN_OP2_ESC_G_SUBEXP_CALL )
+  , ( SYN_GNU_REGEX_BV |
+      ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
+      ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME )
+  , ONIG_OPTION_SINGLELINE
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+/* Perl 5.10+ */
+OnigSyntaxType OnigSyntaxPerl = {
+  (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
+     ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
+     ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
+     ONIG_SYN_OP_ESC_C_CONTROL )
+   & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
+  , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE |
+      ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
+      ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY  |
+      ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
+      ONIG_SYN_OP2_ESC_CAPITAL_X_EXTENDED_GRAPHEME_CLUSTER |
+      ONIG_SYN_OP2_QMARK_LPAREN_CONDITION |
+      ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT |
+      ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL |
+      ONIG_SYN_OP2_ESC_CAPITAL_R_LINEBREAK |
+      ONIG_SYN_OP2_ESC_CAPITAL_K_KEEP |
+      ONIG_SYN_OP2_QMARK_SUBEXP_CALL |
+      ONIG_SYN_OP2_ESC_G_BRACE_BACKREF |
+      ONIG_SYN_OP2_QMARK_CAPITAL_P_NAMED_GROUP |
+      ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP |
+      ONIG_SYN_OP2_ESC_K_NAMED_BACKREF )
+  , ( SYN_GNU_REGEX_BV |
+      ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME |
+      ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME_CALL )
+  , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_CAPTURE_GROUP )
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+OnigSyntaxType OnigSyntaxPython = {
+  (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
+     ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
+     ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
+     ONIG_SYN_OP_ESC_C_CONTROL )
+   & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
+  , ( ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
+      ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY  |
+      ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
+      ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT |
+      ONIG_SYN_OP2_ESC_V_VTAB |
+      ONIG_SYN_OP2_ESC_U_HEX4 |
+      ONIG_SYN_OP2_QMARK_LPAREN_CONDITION |
+      ONIG_SYN_OP2_QMARK_CAPITAL_P_NAMED_GROUP )
+  , ( SYN_GNU_REGEX_BV |
+      ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV )
+  , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_ASCII_RANGE )
+  ,
+  {
+      (OnigCodePoint )'\\'                       /* esc */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
+    , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
+  }
+};
+
+
+
+extern int
+onig_set_default_syntax(OnigSyntaxType* syntax)
+{
+  if (IS_NULL(syntax))
+    syntax = ONIG_SYNTAX_RUBY;
+
+  OnigDefaultSyntax = syntax;
+  return 0;
+}
+
+extern void
+onig_copy_syntax(OnigSyntaxType* to, const OnigSyntaxType* from)
+{
+  *to = *from;
+}
+
+extern void
+onig_set_syntax_op(OnigSyntaxType* syntax, unsigned int op)
+{
+  syntax->op = op;
+}
+
+extern void
+onig_set_syntax_op2(OnigSyntaxType* syntax, unsigned int op2)
+{
+  syntax->op2 = op2;
+}
+
+extern void
+onig_set_syntax_behavior(OnigSyntaxType* syntax, unsigned int behavior)
+{
+  syntax->behavior = behavior;
+}
+
+extern void
+onig_set_syntax_options(OnigSyntaxType* syntax, OnigOptionType options)
+{
+  syntax->options = options;
+}
+
+extern unsigned int
+onig_get_syntax_op(OnigSyntaxType* syntax)
+{
+  return syntax->op;
+}
+
+extern unsigned int
+onig_get_syntax_op2(OnigSyntaxType* syntax)
+{
+  return syntax->op2;
+}
+
+extern unsigned int
+onig_get_syntax_behavior(OnigSyntaxType* syntax)
+{
+  return syntax->behavior;
+}
+
+extern OnigOptionType
+onig_get_syntax_options(OnigSyntaxType* syntax)
+{
+  return syntax->options;
+}
+
+#ifdef USE_VARIABLE_META_CHARS
+extern int onig_set_meta_char(OnigSyntaxType* enc,
+                              unsigned int what, OnigCodePoint code)
+{
+  switch (what) {
+  case ONIG_META_CHAR_ESCAPE:
+    enc->meta_char_table.esc = code;
+    break;
+  case ONIG_META_CHAR_ANYCHAR:
+    enc->meta_char_table.anychar = code;
+    break;
+  case ONIG_META_CHAR_ANYTIME:
+    enc->meta_char_table.anytime = code;
+    break;
+  case ONIG_META_CHAR_ZERO_OR_ONE_TIME:
+    enc->meta_char_table.zero_or_one_time = code;
+    break;
+  case ONIG_META_CHAR_ONE_OR_MORE_TIME:
+    enc->meta_char_table.one_or_more_time = code;
+    break;
+  case ONIG_META_CHAR_ANYCHAR_ANYTIME:
+    enc->meta_char_table.anychar_anytime = code;
+    break;
+  default:
+    return ONIGERR_INVALID_ARGUMENT;
+    break;
+  }
+  return 0;
+}
+#endif /* USE_VARIABLE_META_CHARS */
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regtrav.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regtrav.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regtrav.c	(revision 279)
@@ -0,0 +1,78 @@
+/**********************************************************************
+  regtrav.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2004  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011       K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "regint.h"
+
+#ifdef USE_CAPTURE_HISTORY
+
+static int
+capture_tree_traverse(OnigCaptureTreeNode* node, int at,
+              int(*callback_func)(int,OnigPosition,OnigPosition,int,int,void*),
+              int level, void* arg)
+{
+  int r, i;
+
+  if (node == (OnigCaptureTreeNode* )0)
+    return 0;
+
+  if ((at & ONIG_TRAVERSE_CALLBACK_AT_FIRST) != 0) {
+    r = (*callback_func)(node->group, node->beg, node->end,
+                         level, ONIG_TRAVERSE_CALLBACK_AT_FIRST, arg);
+    if (r != 0) return r;
+  }
+
+  for (i = 0; i < node->num_childs; i++) {
+    r = capture_tree_traverse(node->childs[i], at,
+                              callback_func, level + 1, arg);
+    if (r != 0) return r;
+  }
+
+  if ((at & ONIG_TRAVERSE_CALLBACK_AT_LAST) != 0) {
+    r = (*callback_func)(node->group, node->beg, node->end,
+                         level, ONIG_TRAVERSE_CALLBACK_AT_LAST, arg);
+    if (r != 0) return r;
+  }
+
+  return 0;
+}
+#endif /* USE_CAPTURE_HISTORY */
+
+extern int
+onig_capture_tree_traverse(OnigRegion* region, int at,
+              int(*callback_func)(int,OnigPosition,OnigPosition,int,int,void*),
+              void* arg)
+{
+#ifdef USE_CAPTURE_HISTORY
+  return capture_tree_traverse(region->history_root, at,
+                               callback_func, 0, arg);
+#else
+  return ONIG_NO_SUPPORT_CONFIG;
+#endif
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/regversion.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/regversion.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/regversion.c	(revision 279)
@@ -0,0 +1,58 @@
+/**********************************************************************
+  regversion.c -  Onigmo (Oniguruma-mod) (regular expression library)
+**********************************************************************/
+/*-
+ * Copyright (c) 2002-2009  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "oniguruma.h"
+#include <stdio.h>
+
+extern const char*
+onig_version(void)
+{
+  static char s[12];
+
+  sprintf(s, "%d.%d.%d",
+          ONIGURUMA_VERSION_MAJOR,
+          ONIGURUMA_VERSION_MINOR,
+          ONIGURUMA_VERSION_TEENY);
+  return s;
+}
+
+extern const char*
+onig_copyright(void)
+{
+  static char s[80];
+
+  sprintf(s, "Onigmo %d.%d.%d : Copyright (C) 2002-2009 K.Kosako, "
+	     "2011-2014 K.Takata",
+          ONIGURUMA_VERSION_MAJOR,
+          ONIGURUMA_VERSION_MINOR,
+          ONIGURUMA_VERSION_TEENY);
+  return s;
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/st.c
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/st.c	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/st.c	(revision 279)
@@ -0,0 +1,578 @@
+/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
+
+/* static	char	sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _WIN32
+#include <malloc.h>
+#endif
+
+#include "regint.h"
+#include "st.h"
+
+typedef struct st_table_entry st_table_entry;
+
+struct st_table_entry {
+    unsigned int hash;
+    st_data_t key;
+    st_data_t record;
+    st_table_entry *next;
+};
+
+#define ST_DEFAULT_MAX_DENSITY 5
+#define ST_DEFAULT_INIT_TABLE_SIZE 11
+
+    /*
+     * DEFAULT_MAX_DENSITY is the default for the largest we allow the
+     * average number of items per bin before increasing the number of
+     * bins
+     *
+     * DEFAULT_INIT_TABLE_SIZE is the default for the number of bins
+     * allocated initially
+     *
+     */
+
+static int numcmp(long, long);
+static int numhash(long);
+static struct st_hash_type type_numhash = {
+    numcmp,
+    numhash,
+};
+
+/* extern int strcmp(const char *, const char *); */
+static int strhash(const char *);
+static struct st_hash_type type_strhash = {
+    strcmp,
+    strhash,
+};
+
+static void rehash(st_table *);
+
+#define alloc(type) (type*)xmalloc((unsigned)sizeof(type))
+#define Calloc(n,s) (char*)xcalloc((n),(s))
+
+#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0)
+
+#define do_hash(key,table) (unsigned int)(*(table)->type->hash)((key))
+#define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins)
+
+/*
+ * MINSIZE is the minimum size of a dictionary.
+ */
+
+#define MINSIZE 8
+
+/*
+Table of prime numbers 2^n+a, 2<=n<=30.
+*/
+static const long primes[] = {
+	8 + 3,
+	16 + 3,
+	32 + 5,
+	64 + 3,
+	128 + 3,
+	256 + 27,
+	512 + 9,
+	1024 + 9,
+	2048 + 5,
+	4096 + 3,
+	8192 + 27,
+	16384 + 43,
+	32768 + 3,
+	65536 + 45,
+	131072 + 29,
+	262144 + 3,
+	524288 + 21,
+	1048576 + 7,
+	2097152 + 17,
+	4194304 + 15,
+	8388608 + 9,
+	16777216 + 43,
+	33554432 + 35,
+	67108864 + 15,
+	134217728 + 29,
+	268435456 + 3,
+	536870912 + 11,
+	1073741824 + 85,
+	0
+};
+
+static int
+new_size(size)
+    int size;
+{
+    int i;
+
+#if 0
+    for (i=3; i<31; i++) {
+	if ((1<<i) > size) return 1<<i;
+    }
+    return -1;
+#else
+    int newsize;
+
+    for (i = 0, newsize = MINSIZE;
+	 i < (int )(sizeof(primes)/sizeof(primes[0]));
+	 i++, newsize <<= 1)
+    {
+	if (newsize > size) return primes[i];
+    }
+    /* Ran out of polynomials */
+    return -1;			/* should raise exception */
+#endif
+}
+
+#ifdef HASH_LOG
+static int collision = 0;
+static int init_st = 0;
+
+static void
+stat_col()
+{
+    FILE *f = fopen("/tmp/col", "w");
+    fprintf(f, "collision: %d\n", collision);
+    fclose(f);
+}
+#endif
+
+st_table*
+st_init_table_with_size(type, size)
+    struct st_hash_type *type;
+    int size;
+{
+    st_table *tbl;
+
+#ifdef HASH_LOG
+    if (init_st == 0) {
+	init_st = 1;
+	atexit(stat_col);
+    }
+#endif
+
+    size = new_size(size);	/* round up to prime number */
+
+    tbl = alloc(st_table);
+    tbl->type = type;
+    tbl->num_entries = 0;
+    tbl->num_bins = size;
+    tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*));
+
+    return tbl;
+}
+
+st_table*
+st_init_table(type)
+    struct st_hash_type *type;
+{
+    return st_init_table_with_size(type, 0);
+}
+
+st_table*
+st_init_numtable(void)
+{
+    return st_init_table(&type_numhash);
+}
+
+st_table*
+st_init_numtable_with_size(size)
+    int size;
+{
+    return st_init_table_with_size(&type_numhash, size);
+}
+
+st_table*
+st_init_strtable(void)
+{
+    return st_init_table(&type_strhash);
+}
+
+st_table*
+st_init_strtable_with_size(size)
+    int size;
+{
+    return st_init_table_with_size(&type_strhash, size);
+}
+
+void
+st_free_table(table)
+    st_table *table;
+{
+    register st_table_entry *ptr, *next;
+    int i;
+
+    for(i = 0; i < table->num_bins; i++) {
+	ptr = table->bins[i];
+	while (ptr != 0) {
+	    next = ptr->next;
+	    free(ptr);
+	    ptr = next;
+	}
+    }
+    free(table->bins);
+    free(table);
+}
+
+#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
+((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
+
+#ifdef HASH_LOG
+#define COLLISION collision++
+#else
+#define COLLISION
+#endif
+
+#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
+    bin_pos = hash_val%(table)->num_bins;\
+    ptr = (table)->bins[bin_pos];\
+    if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
+	COLLISION;\
+	while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
+	    ptr = ptr->next;\
+	}\
+	ptr = ptr->next;\
+    }\
+} while (0)
+
+int
+st_lookup(table, key, value)
+    st_table *table;
+    register st_data_t key;
+    st_data_t *value;
+{
+    unsigned int hash_val, bin_pos;
+    register st_table_entry *ptr;
+
+    hash_val = do_hash(key, table);
+    FIND_ENTRY(table, ptr, hash_val, bin_pos);
+
+    if (ptr == 0) {
+	return 0;
+    }
+    else {
+	if (value != 0)  *value = ptr->record;
+	return 1;
+    }
+}
+
+#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
+do {\
+    st_table_entry *entry;\
+    if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
+	rehash(table);\
+        bin_pos = hash_val % table->num_bins;\
+    }\
+    \
+    entry = alloc(st_table_entry);\
+    \
+    entry->hash = hash_val;\
+    entry->key = key;\
+    entry->record = value;\
+    entry->next = table->bins[bin_pos];\
+    table->bins[bin_pos] = entry;\
+    table->num_entries++;\
+} while (0)
+
+int
+st_insert(table, key, value)
+    register st_table *table;
+    register st_data_t key;
+    st_data_t value;
+{
+    unsigned int hash_val, bin_pos;
+    register st_table_entry *ptr;
+
+    hash_val = do_hash(key, table);
+    FIND_ENTRY(table, ptr, hash_val, bin_pos);
+
+    if (ptr == 0) {
+	ADD_DIRECT(table, key, value, hash_val, bin_pos);
+	return 0;
+    }
+    else {
+	ptr->record = value;
+	return 1;
+    }
+}
+
+void
+st_add_direct(table, key, value)
+    st_table *table;
+    st_data_t key;
+    st_data_t value;
+{
+    unsigned int hash_val, bin_pos;
+
+    hash_val = do_hash(key, table);
+    bin_pos = hash_val % table->num_bins;
+    ADD_DIRECT(table, key, value, hash_val, bin_pos);
+}
+
+static void
+rehash(table)
+    register st_table *table;
+{
+    register st_table_entry *ptr, *next, **new_bins;
+    int i, old_num_bins = table->num_bins, new_num_bins;
+    unsigned int hash_val;
+
+    new_num_bins = new_size(old_num_bins+1);
+    new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*));
+
+    for(i = 0; i < old_num_bins; i++) {
+	ptr = table->bins[i];
+	while (ptr != 0) {
+	    next = ptr->next;
+	    hash_val = ptr->hash % new_num_bins;
+	    ptr->next = new_bins[hash_val];
+	    new_bins[hash_val] = ptr;
+	    ptr = next;
+	}
+    }
+    free(table->bins);
+    table->num_bins = new_num_bins;
+    table->bins = new_bins;
+}
+
+st_table*
+st_copy(old_table)
+    st_table *old_table;
+{
+    st_table *new_table;
+    st_table_entry *ptr, *entry;
+    int i, num_bins = old_table->num_bins;
+
+    new_table = alloc(st_table);
+    if (new_table == 0) {
+	return 0;
+    }
+
+    *new_table = *old_table;
+    new_table->bins = (st_table_entry**)
+	Calloc((unsigned)num_bins, sizeof(st_table_entry*));
+
+    if (new_table->bins == 0) {
+	free(new_table);
+	return 0;
+    }
+
+    for(i = 0; i < num_bins; i++) {
+	new_table->bins[i] = 0;
+	ptr = old_table->bins[i];
+	while (ptr != 0) {
+	    entry = alloc(st_table_entry);
+	    if (entry == 0) {
+		free(new_table->bins);
+		free(new_table);
+		return 0;
+	    }
+	    *entry = *ptr;
+	    entry->next = new_table->bins[i];
+	    new_table->bins[i] = entry;
+	    ptr = ptr->next;
+	}
+    }
+    return new_table;
+}
+
+int
+st_delete(table, key, value)
+    register st_table *table;
+    register st_data_t *key;
+    st_data_t *value;
+{
+    unsigned int hash_val;
+    st_table_entry *tmp;
+    register st_table_entry *ptr;
+
+    hash_val = do_hash_bin(*key, table);
+    ptr = table->bins[hash_val];
+
+    if (ptr == 0) {
+	if (value != 0) *value = 0;
+	return 0;
+    }
+
+    if (EQUAL(table, *key, ptr->key)) {
+	table->bins[hash_val] = ptr->next;
+	table->num_entries--;
+	if (value != 0) *value = ptr->record;
+	*key = ptr->key;
+	free(ptr);
+	return 1;
+    }
+
+    for(; ptr->next != 0; ptr = ptr->next) {
+	if (EQUAL(table, ptr->next->key, *key)) {
+	    tmp = ptr->next;
+	    ptr->next = ptr->next->next;
+	    table->num_entries--;
+	    if (value != 0) *value = tmp->record;
+	    *key = tmp->key;
+	    free(tmp);
+	    return 1;
+	}
+    }
+
+    return 0;
+}
+
+int
+st_delete_safe(table, key, value, never)
+    register st_table *table;
+    register st_data_t *key;
+    st_data_t *value;
+    st_data_t never;
+{
+    unsigned int hash_val;
+    register st_table_entry *ptr;
+
+    hash_val = do_hash_bin(*key, table);
+    ptr = table->bins[hash_val];
+
+    if (ptr == 0) {
+	if (value != 0) *value = 0;
+	return 0;
+    }
+
+    for(; ptr != 0; ptr = ptr->next) {
+	if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) {
+	    table->num_entries--;
+	    *key = ptr->key;
+	    if (value != 0) *value = ptr->record;
+	    ptr->key = ptr->record = never;
+	    return 1;
+	}
+    }
+
+    return 0;
+}
+
+static int
+#if defined(__GNUC__)
+delete_never(st_data_t key __attribute__ ((unused)), st_data_t value,
+	     st_data_t never)
+#else
+delete_never(key, value, never)
+    st_data_t key, value, never;
+#endif
+{
+    if (value == never) return ST_DELETE;
+    return ST_CONTINUE;
+}
+
+void
+st_cleanup_safe(table, never)
+    st_table *table;
+    st_data_t never;
+{
+    int num_entries = table->num_entries;
+
+    st_foreach(table, delete_never, never);
+    table->num_entries = num_entries;
+}
+
+int
+st_foreach(table, func, arg)
+    st_table *table;
+    int (*func)();
+    st_data_t arg;
+{
+    st_table_entry *ptr, *last, *tmp;
+    enum st_retval retval;
+    int i;
+
+    for(i = 0; i < table->num_bins; i++) {
+	last = 0;
+	for(ptr = table->bins[i]; ptr != 0;) {
+	    retval = (*func)(ptr->key, ptr->record, arg);
+	    switch (retval) {
+	    case ST_CHECK:	/* check if hash is modified during iteration */
+	        tmp = 0;
+		if (i < table->num_bins) {
+		    for (tmp = table->bins[i]; tmp; tmp=tmp->next) {
+			if (tmp == ptr) break;
+		    }
+		}
+		if (!tmp) {
+		    /* call func with error notice */
+		    return 1;
+		}
+		/* fall through */
+	    case ST_CONTINUE:
+		last = ptr;
+		ptr = ptr->next;
+		break;
+	    case ST_STOP:
+	        return 0;
+	    case ST_DELETE:
+		tmp = ptr;
+		if (last == 0) {
+		    table->bins[i] = ptr->next;
+		}
+		else {
+		    last->next = ptr->next;
+		}
+		ptr = ptr->next;
+		free(tmp);
+		table->num_entries--;
+	    }
+	}
+    }
+    return 0;
+}
+
+static int
+strhash(string)
+    register const char *string;
+{
+    register int c;
+
+#ifdef HASH_ELFHASH
+    register unsigned int h = 0, g;
+
+    while ((c = *string++) != '\0') {
+	h = ( h << 4 ) + c;
+	if ( g = h & 0xF0000000 )
+	    h ^= g >> 24;
+	h &= ~g;
+    }
+    return h;
+#elif HASH_PERL
+    register int val = 0;
+
+    while ((c = *string++) != '\0') {
+	val += c;
+	val += (val << 10);
+	val ^= (val >> 6);
+    }
+    val += (val << 3);
+    val ^= (val >> 11);
+
+    return val + (val << 15);
+#else
+    register int val = 0;
+
+    while ((c = *string++) != '\0') {
+	val = val*997 + c;
+    }
+
+    return val + (val>>5);
+#endif
+}
+
+static int
+numcmp(x, y)
+    long x, y;
+{
+    return x != y;
+}
+
+static int
+numhash(n)
+    long n;
+{
+    return n;
+}
Index: /EcnlProtoTool/trunk/onigmo-5.15.0/src/st.h
===================================================================
--- /EcnlProtoTool/trunk/onigmo-5.15.0/src/st.h	(revision 279)
+++ /EcnlProtoTool/trunk/onigmo-5.15.0/src/st.h	(revision 279)
@@ -0,0 +1,64 @@
+/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
+
+/* @(#) st.h 5.1 89/12/14 */
+
+#ifndef ST_INCLUDED
+
+#define ST_INCLUDED
+
+typedef uintptr_t st_data_t;
+#define ST_DATA_T_DEFINED
+
+typedef struct st_table st_table;
+typedef int st_index_t;
+
+struct st_hash_type {
+    int (*compare)();
+    int (*hash)();
+};
+
+struct st_table {
+    struct st_hash_type *type;
+    int num_bins;
+    int num_entries;
+    struct st_table_entry **bins;
+};
+
+#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
+
+enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
+
+#ifndef _
+# define _(args) args
+#endif
+#ifndef ANYARGS
+# ifdef __cplusplus
+#   define ANYARGS ...
+# else
+#   define ANYARGS
+# endif
+#endif
+
+st_table *st_init_table _((struct st_hash_type *));
+st_table *st_init_table_with_size _((struct st_hash_type *, int));
+st_table *st_init_numtable _((void));
+st_table *st_init_numtable_with_size _((int));
+st_table *st_init_strtable _((void));
+st_table *st_init_strtable_with_size _((int));
+int st_delete _((st_table *, st_data_t *, st_data_t *));
+int st_delete_safe _((st_table *, st_data_t *, st_data_t *, st_data_t));
+int st_insert _((st_table *, st_data_t, st_data_t));
+int st_lookup _((st_table *, st_data_t, st_data_t *));
+int st_foreach _((st_table *, int (*)(ANYARGS), st_data_t));
+void st_add_direct _((st_table *, st_data_t, st_data_t));
+void st_free_table _((st_table *));
+void st_cleanup_safe _((st_table *, st_data_t));
+st_table *st_copy _((st_table *));
+
+#define ST_NUMCMP	((int (*)()) 0)
+#define ST_NUMHASH	((int (*)()) -2)
+
+#define st_numcmp	ST_NUMCMP
+#define st_numhash	ST_NUMHASH
+
+#endif /* ST_INCLUDED */
Index: /EcnlProtoTool/trunk/prototool/.Debuglinker
===================================================================
--- /EcnlProtoTool/trunk/prototool/.Debuglinker	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/.Debuglinker	(revision 279)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="ASCII"?>
+<com.renesas.linkersection.model:SectionContainer xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:com.renesas.linkersection.model="http:///LinkerSection.ecore">
+  <sections name=".boot" isKeep="true">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="402653184"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".boot"/>
+  </sections>
+  <sections name=".fvectors" isKeep="true">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="404750336"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".fvectors"/>
+  </sections>
+  <sections name=".text">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="404750592"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".text"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".text.*"/>
+  </sections>
+  <sections name=".rvectors" isKeep="true">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.2"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_rvectors_start"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".rvectors"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_rvectors_end"/>
+  </sections>
+  <sections name=".init">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.3"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".init"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE_HIDDEN (__exidx_start = .)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE_HIDDEN (__exidx_end = .)"/>
+  </sections>
+  <sections name=".fini">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.4"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".fini"/>
+  </sections>
+  <sections name=".got">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.5"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".got"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".got.plt"/>
+  </sections>
+  <sections name=".rodata">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.6"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".rodata"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".rodata.*"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_erodata"/>
+  </sections>
+  <sections name=".eh_frame_hdr">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.7"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".eh_frame_hdr"/>
+  </sections>
+  <sections name=".eh_frame">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.8"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".eh_frame"/>
+  </sections>
+  <sections name=".jcr">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.9"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".jcr"/>
+  </sections>
+  <sections name=".tors">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.10"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__CTOR_LIST__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text=". = ALIGN(2)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__ctors"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".ctors"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__ctors_end"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__CTOR_END__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__DTOR_LIST__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="___dtors"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".dtors"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="___dtors_end"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="__DTOR_END__"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text=". = ALIGN(2)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_mdata"/>
+  </sections>
+  <sections name=".data">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="537919488"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_data"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".data"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".data.*"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_edata"/>
+    <reservedMemAddress xsi:type="com.renesas.linkersection.model:ReferencedLabelAddress" label="//@sections.11/@contents.12"/>
+  </sections>
+  <sections name=".bss">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:ReferencedSectionAddress" referencedSection="//@sections.12"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE(__bss_start__ = .)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_bss"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".bss"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name=".bss.**"/>
+    <contents xsi:type="com.renesas.linkersection.model:WildCardExpression" specificSection="true" name="COMMON"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE(__bss_end__ = .)"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_ebss"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_end"/>
+    <contents xsi:type="com.renesas.linkersection.model:Keyword" text="PROVIDE(end = .)"/>
+  </sections>
+  <sections name=".stack" isNoLoad="true" isKeep="true">
+    <sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="543162368"/>
+    <contents xsi:type="com.renesas.linkersection.model:Label" rhs="= .;" lhs="_stack"/>
+  </sections>
+</com.renesas.linkersection.model:SectionContainer>
Index: /EcnlProtoTool/trunk/prototool/.cproject
===================================================================
--- /EcnlProtoTool/trunk/prototool/.cproject	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/.cproject	(revision 279)
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="com.renesas.cdt.rz.debug.win32.configuration.Id.1066563720">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.renesas.cdt.rz.debug.win32.configuration.Id.1066563720" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactExtension="mot" artifactName="prototool" buildArtefactType="com.renesas.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=com.renesas.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf *.lst *.lis *.lpp *.map libgcc.a" description="" id="com.renesas.cdt.rz.debug.win32.configuration.Id.1066563720" name="Debug" parent="com.renesas.cdt.rz.debug.win32.configuration.Id" postbuildStep="arm-none-eabi-objcopy -O binary prototool.x prototool.bin" prebuildStep="make -f ../lib/makefile.mrbc">
+					<folderInfo id="com.renesas.cdt.rz.debug.win32.configuration.Id.1066563720." name="/" resourcePath="">
+						<toolChain id="com.renesas.cdt.rz.debug.win32.toolchain.Id.433570446" name="KPIT GNUARM-NONE-EABI Toolchain" superClass="com.renesas.cdt.rz.debug.win32.toolchain.Id">
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.PE" id="com.renesas.cdt.rz.debug.win32.targetplatform.Id.1186803334" name="Target Platform" osList="all" superClass="com.renesas.cdt.rz.debug.win32.targetplatform.Id"/>
+							<builder buildPath="${workspace_loc:/prototool}/Debug" id="com.renesas.cdt.rz.debug.win32.builder.Id.2050079037" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Builder" superClass="com.renesas.cdt.rz.debug.win32.builder.Id"/>
+							<tool command="" id="com.renesas.cdt.rz.debug.win32.tool.libgen.Id.151600472" name="Library Generator" superClass="com.renesas.cdt.rz.debug.win32.tool.libgen.Id">
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.enableAll.299749034" name="ãã¹ã¦ä½¿ç¨å¯è½" superClass="com.renesas.cdt.core.LibraryGenerator.option.enableAll" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary.1883050310" name="ã©ã¤ãã©ãªã¼ã®é¸æ" superClass="com.renesas.cdt.core.LibraryGenerator.option.selectLibrary" value="com.renesas.core.LibraryGenerator.option.selectLibrary.newLib" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.libraryType.1566674346" name="ã©ã¤ãã©ãªã¼å" superClass="com.renesas.cdt.core.LibraryGenerator.option.libraryType" value="com.renesas.cdt.core.LibraryGenerator.option.libraryType.preBuilt" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc9.224486490" name="åé¢æ°ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-ffunction-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc9" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc14.1868247370" name="é¢æ°ã®ã¢ãã¬ã¹ãã¬ã¸ã¹ã¿ã¼ã«ç½®ããªã (-fno-function-cse)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc14" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc36.2099974322" name="Parse the whole compilation unit before starting to produce code ( -funit-at-a-time)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc36" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc10.1568344694" name="åãã¼ã¿ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-fdata-sections)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc10" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.misc37.1158588751" name="Align branch targets to a power-of-two boundary (-falign-jumps)" superClass="com.renesas.cdt.core.LibraryGenerator.option.misc37" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.ctype.2058196033" name="ctype.h : æå­ãæ±ããã§ãã¯ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.ctype" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.math.108434046" name="math.h : ä¸è§é¢æ°ãªã©æ°å¤ã®è¨ç®ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.math" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdio.1528074812" name="stdio.h : å
+¥å/åºåãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdio" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.stdlib.1449174297" name="stdlib.h : æ ¼ç´é åã®ç®¡çãªã© C ãã­ã°ã©ã ã®æ¨æºå¦çãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.stdlib" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.LibraryGenerator.option.string.1770979533" name="string.h : æå­åã®æ¯è¼ã¨ã³ãã¼ãè¡ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.string" value="true" valueType="boolean"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.compiler.Id.1599684796" name="Compiler" superClass="com.renesas.cdt.rz.debug.win32.tool.compiler.Id">
+								<option defaultValue="true" id="com.renesas.cdt.core.Compiler.option.misc2.705849748" name="æ¨æºã·ã¹ãã ã»ãã£ã¬ã¯ããªã¼ã§ãããã¼ã»ãã¡ã¤ã«ãæ¤ç´¢ããªã (-nostdinc)" superClass="com.renesas.cdt.core.Compiler.option.misc2" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.architecture.1326747160" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Compiler.option.architecture" value="com.renesas.cdt.rz.Debug.Compiler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.1644847738" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.cpuType" value="com.renesas.cdt.rz.Debug.Compiler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.1505228670" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Compiler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.1581157059" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.instructionset" value="com.renesas.cdt.rz.Debug.Compiler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.interworking.239167748" name="ã¤ã³ã¿ã¼ã»ã¯ã¼ã­ã³ã° (-mthumb-interwork)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.interworking" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.1978978778" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu" value="com.renesas.cdt.rz.Debug.Compiler.option.targetfpu.vfpv3" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.1195890920" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Compiler.option.floatingpointabi.hard" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warnStackSize.861461599" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.core.Compiler.option.warnStackSize" value="100" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.CPUSeries.1432710063" name="CPU ã·ãªã¼ãº" superClass="com.renesas.cdt.core.Compiler.option.CPUSeries" value="RZ/A" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.device.443282008" name="Device" superClass="com.renesas.cdt.core.Compiler.option.device" value="R7S721001" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.deviceShortName.752035440" name="DeviceShortName" superClass="com.renesas.cdt.core.Compiler.option.deviceShortName" value="R7S721001" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.stackSizeInDecimal.1821950522" name="Decimal representation of '-Wsatck-usage'" superClass="com.renesas.cdt.core.Compiler.option.stackSizeInDecimal" value="256" valueType="string"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Compiler.option.includeFileDir.461834980" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Compiler.option.includeFileDir" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:}/musl-1.1.12/include&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:}/onigmo-5.15.0/src&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/hal}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/api}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc/iodefines}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mruby-1.2.0/include}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:}/ntshell/ntshell&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:}/ntshell/gr_peach&quot;"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines.133908648" name="ãã¯ã­å®ç¾©" superClass="com.renesas.cdt.rz.Debug.Compiler.option.macroDefines" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="MRB_GC_STRESS"/>
+									<listOptionValue builtIn="false" value="MRB_ENABLE_DEBUG_HOOK"/>
+									<listOptionValue builtIn="false" value="FD_SETSIZE=32"/>
+								</option>
+								<option id="com.renesas.cdt.core.Compiler.option.stdWarnings.1803476376" name="æ¨æºã®è­¦å" superClass="com.renesas.cdt.core.Compiler.option.stdWarnings" value="com.renesas.cdt.core.Compiler.option.stdWarnings.enableAll" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning1.1133058357" name="é
+åã®æ·»å­ã®åã char ã§ããå ´åã«è­¦åãã (-Wchar-subscripts)" superClass="com.renesas.cdt.core.Compiler.option.warning1" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning2.706412841" name="ã³ã¡ã³ãã®ä¸­ã«ã³ã¡ã³ããåºç¾ããå ´åã«è­¦åãã (-Wcomment)" superClass="com.renesas.cdt.core.Compiler.option.warning2" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning3.1969743283" name="æå­åã®é¢æ°ãã©ã¼ããããæ­£ãããªãå ´åã«è­¦åãã (-Wformat)" superClass="com.renesas.cdt.core.Compiler.option.warning3" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning4.1367213009" name="é¢æ°ãå¼æ°ãæç¤ºçã«å®£è¨ããã¦ããå ´åã«è­¦åãã (-Wimplicit)" superClass="com.renesas.cdt.core.Compiler.option.warning4" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning5.742877233" name="#import ã®ä½¿ç¨ã«å¯¾ããè­¦åãç¡å¹ã«ãã (-Wno-import)" superClass="com.renesas.cdt.core.Compiler.option.warning5" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning6.1136015423" name="ç¹å®ã®æèã§æ¬å¼§ãçç¥ããã¦ããå ´åã«è­¦åãã (-Wparentheses)" superClass="com.renesas.cdt.core.Compiler.option.warning6" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning7.1384330048" name="æ»ãå¤ã®åã«åé¡ãããå ´åã«è­¦åãã (-Wreturn-type)" superClass="com.renesas.cdt.core.Compiler.option.warning7" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning8.1703709673" name="switch æã«åé¡ãããå ´åã«è­¦åãã(-Wswitch)" superClass="com.renesas.cdt.core.Compiler.option.warning8" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning9.1004558301" name="ãã©ã¤ã°ã©ããåºç¾ããå ´åã«è­¦åãã (-Wtrigraphs)" superClass="com.renesas.cdt.core.Compiler.option.warning9" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning10.1831665847" name="å®£è¨ãããé¢æ°ãä½¿ç¨ããã¦ããªãå ´åã«è­¦åãã (-Wunused)" superClass="com.renesas.cdt.core.Compiler.option.warning10" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning11.953929254" name="åæåããã¦ããªãèªåå¤æ°ãä½¿ç¨ããã¦ããå ´åã«è­¦åãã (-Wuninitialized)" superClass="com.renesas.cdt.core.Compiler.option.warning11" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning12.1693791872" name="ã¡ã³ãã¼åæåã®ä¸ä¸è´ãè­¦åãã (-Wreorder)" superClass="com.renesas.cdt.core.Compiler.option.warning12" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning13.1142601544" name="èª¤ã£ãç¬¦å·æ¯è¼ãè­¦åãã (-Wsign-compare)" superClass="com.renesas.cdt.core.Compiler.option.warning13" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.advWarnings.1570239770" name="é«åº¦ãªè­¦å" superClass="com.renesas.cdt.core.Compiler.option.advWarnings" value="com.renesas.cdt.core.Compiler.option.advWarnings.selectOptions" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning14.321008174" name="è¿½å ã®è­¦åã¡ãã»ã¼ã¸ãè¡¨ç¤ºãã (-Wextra)" superClass="com.renesas.cdt.core.Compiler.option.warning14" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning15.1876124178" name="é¢æ°ãæ§é ä½ã¾ãã¯å
+±ç¨ä½ãè¿ãå ´åã«è­¦åãã (-Waggregate-return)" superClass="com.renesas.cdt.core.Compiler.option.warning15" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning16.273479800" name="é¢æ°ã®å¼ã³åºããä¸è´ããªãåã«ã­ã£ã¹ãããã¦ããå ´åã«è­¦åãã (-Wbad-function-cast)" superClass="com.renesas.cdt.core.Compiler.option.warning16" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning17.798012030" name="ãã¤ã³ã¿ã¼ã®ã­ã£ã¹ãã§ã¢ã©ã¤ã¡ã³ããèª¤ã£ã¦ããå ´åã«è­¦åãã (-Wcast-align)" superClass="com.renesas.cdt.core.Compiler.option.warning17" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning18.2088382859" name="ãã¤ã³ã¿ã¼ã®ã­ã£ã¹ãã§åä¿®é£¾å­ãèª¤ã£ã¦ããå ´åã«è­¦åãã (-Wcast-qual)" superClass="com.renesas.cdt.core.Compiler.option.warning18" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning19.619593184" name="ç¹å®ã®ãã­ãã¿ã¤ãå¤æã«å¯¾ãã¦è­¦åãã (-Wconversion)" superClass="com.renesas.cdt.core.Compiler.option.warning19" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning20.815721946" name="ãã¹ã¦ã®è­¦åãã¨ã©ã¼ã«å¤æãã (-Werror)    " superClass="com.renesas.cdt.core.Compiler.option.warning20" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning21.1126906290" name="é¢æ°ãã¤ã³ã©ã¤ã³å±éã§ããªãå ´åã«è­¦åãã (-Winline)" superClass="com.renesas.cdt.core.Compiler.option.warning21" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning22.308702192" name="ã°ã­ã¼ãã«é¢æ°ãå®£è¨ããã«å®ç¾©ããå ´åã«è­¦åãã (-Wmissing-declarations)" superClass="com.renesas.cdt.core.Compiler.option.warning22" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning23.861342358" name="ã°ã­ã¼ãã«é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ããªãå ´åã«è­¦åãã (-Wmissing-prototypes)" superClass="com.renesas.cdt.core.Compiler.option.warning23" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning24.1544315733" name="é¢æ°å
+ã« extern é¢æ°ãå­å¨ããå ´åã«è­¦åãã (-Wnested-externs)" superClass="com.renesas.cdt.core.Compiler.option.warning24" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning25.1309490501" name="é¢æ°ã®åã void ã«ä¾å­ããå ´åã«è­¦åãã (-Wpointer-arith)" superClass="com.renesas.cdt.core.Compiler.option.warning25" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning26.1312267048" name="è¤æ°ã®å®£è¨ãããå ´åã«è­¦åãã (-Wredundant-decls)" superClass="com.renesas.cdt.core.Compiler.option.warning26" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning27.1756685044" name="ã­ã¼ã«ã«å¤æ°ãä»ã®ã­ã¼ã«ã«å¤æ°ãé ãã¦ããå ´åã«è­¦åãã (-Wshadow)" superClass="com.renesas.cdt.core.Compiler.option.warning27" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning28.2066762597" name="é¢æ°ã«å¼æ°ã®åããªãå ´åã«è­¦åãã (-Wstrict-prototypes)" superClass="com.renesas.cdt.core.Compiler.option.warning28" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning29.614445109" name="g++ ã·ã³ã»ãµã¤ã¶ã¼ãèª¤ã£ã¦ããå ´åã«è­¦åãã (-Wsynth)" superClass="com.renesas.cdt.core.Compiler.option.warning29" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning30.876487416" name="C ã¨ ANSI C ã§æ§é ãç°ãªãå ´åã«è­¦åãã (-Wtraditional)" superClass="com.renesas.cdt.core.Compiler.option.warning30" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warning31.474472286" name="æå­å®æ°ã«å¯¾ããå 'const char[length]' ãä¸ãã (-Wwrite-strings)" superClass="com.renesas.cdt.core.Compiler.option.warning31" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.inhibitWarningMess.1548815167" name="ãã¹ã¦ã®è­¦åãç¦æ­¢ãã" superClass="com.renesas.cdt.core.Compiler.option.inhibitWarningMess" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.misc53.555407143" name="åãã¼ã¿é 
+ç®ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã(-fdata-sections)" superClass="com.renesas.cdt.core.Compiler.option.misc53" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.core.Compiler.option.misc19.234511440" name="åé¢æ°ããåºåãã¡ã¤ã«å
+ã®å¯¾å¿ããã»ã¯ã·ã§ã³ã«é
+ç½®ãã (-ffunction-sections)" superClass="com.renesas.cdt.core.Compiler.option.misc19" value="true" valueType="boolean"/>
+								<inputType id="%Base.Compiler.C.InputType.Id.347710053" name="C å
+¥å" superClass="%Base.Compiler.C.InputType.Id"/>
+								<inputType id="Base.Compiler.CPP.InputType.Id.1588040127" name="C++ å
+¥å" superClass="Base.Compiler.CPP.InputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.assembler.Id.1271918947" name="Assembler" superClass="com.renesas.cdt.rz.debug.win32.tool.assembler.Id">
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.architecture.468242299" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Assembler.option.architecture" value="com.renesas.cdt.rz.Debug.Assembler.option.architecture.armv7a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.1182870135" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.cpuType" value="com.renesas.cdt.rz.Debug.Assembler.option.cpuType.rza" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.1117426347" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian" value="com.renesas.cdt.rz.Debug.Assembler.option.dataEndian.little" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.684245946" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.instructionset" value="com.renesas.cdt.rz.Debug.Assembler.option.instructionset.arm" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu.550909895" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.targetfpu" value="vfpv3" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.361978812" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi" value="com.renesas.cdt.rz.Debug.Assembler.option.floatingpointabi.hard" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Assembler.option.includeFileDirectories.1556939281" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Assembler.option.includeFileDirectories" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/src&quot;"/>
+								</option>
+								<inputType id="%Base.Assembler.inputType.Id.422139258" name="ã¢ã»ã³ãã©ã¼å
+¥åã¿ã¤ã" superClass="%Base.Assembler.inputType.Id"/>
+							</tool>
+							<tool command="arm-none-eabi-gcc" id="com.renesas.cdt.rz.debug.win32.tool.linker.Id.68534288" name="Linker" superClass="com.renesas.cdt.rz.debug.win32.tool.linker.Id">
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories.1048191791" name="ã¢ã¼ã«ã¤ãæ¤ç´¢ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveSearchDirectories" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/tcc-0.9.26/Debug}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/onigmo-5.15.0/Debug}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mruby-1.2.0/build/arm-none-eabi/lib}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/lib/gcc/arm-none-eabi/${GCC_VERSION}/armv7-ar/thumb/fpu&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${TCINSTALL}/arm-none-eabi/lib/armv7-ar/thumb/fpu&quot;"/>
+								</option>
+								<option id="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.61169564" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Linker.option.dataEndian" value="com.renesas.cdt.rz.Debug.Linker.option.dataEndian.little" valueType="enumerated"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" command="-Wl," id="com.renesas.cdt.core.Linker.option.userDefinedOptions.1560126376" name="ã¦ã¼ã¶ã¼å®ç¾©ãªãã·ã§ã³" superClass="com.renesas.cdt.core.Linker.option.userDefinedOptions" valueType="stringList">
+									<listOptionValue builtIn="false" value="-e_PowerON_Reset"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.linkOrderList.926659105" name="" superClass="com.renesas.cdt.core.Linker.option.linkOrderList" valueType="stringList">
+									<listOptionValue builtIn="false" value="&quot;.\src\apibreak.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\apiprint.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\cmdbreak.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\cmdmisc.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\cmdprint.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\cmdrun.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\main.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\mirb.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\mrbc.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\mrdb.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\mruby.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\onitest.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\xprintf.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\arduino.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src\shellif.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ntshell/Debug/ntshell_bin.o}&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/musl\freeaddrinfo.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/musl\gai_strerror.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/musl\getaddrinfo.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/musl\inet_aton.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/musl\lookup_ipliteral.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/musl\lookup_name.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/musl\lookup_serv.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\bb_strtonum.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\bb_time.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\compare_string_array.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\copyfd.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\default_error_retval.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\full_write.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\last_char_is.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\libbb.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\messages.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\perror_msg.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\ptr_to_globals.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\read.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\read_key.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\safe_poll.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\safe_write.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\skip_whitespace.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\verror_msg.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\vi.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\xfunc_die.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\xfuncs.o&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;.\src/libbb\xfuncs_printf.o&quot;"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Linker.option.additionalInputFiles.1022783886" name="è¿½å å
+¥åãã¡ã¤ã«" superClass="com.renesas.cdt.core.Linker.option.additionalInputFiles" valueType="userObjs">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ntshell/Debug/ntshell_bin.o}&quot;"/>
+								</option>
+								<option id="com.renesas.cdt.core.Linker.option.linkOrderUsed.1088314581" name="ãªã³ã¯é ã®ã«ã¹ã¿ãã¤ãºä½¿ç¨" superClass="com.renesas.cdt.core.Linker.option.linkOrderUsed" value="false" valueType="boolean"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles.397699621" name="ã¢ã¼ã«ã¤ã ( ã©ã¤ãã©ãªã¼ ) ãã¡ã¤ã«" superClass="com.renesas.cdt.rz.Debug.Linker.option.archiveLibraryFiles" valueType="stringList">
+									<listOptionValue builtIn="false" value="out"/>
+									<listOptionValue builtIn="false" value="m"/>
+									<listOptionValue builtIn="false" value="gcc"/>
+									<listOptionValue builtIn="false" value="onigmo"/>
+									<listOptionValue builtIn="false" value="mruby"/>
+									<listOptionValue builtIn="false" value="mrbcode"/>
+									<listOptionValue builtIn="false" value="tcc"/>
+								</option>
+								<option command="-Wl,--gc-sections" id="com.renesas.cdt.core.Linker.option.misc19.807194175" name="æªä½¿ç¨ã®å
+¥åã»ã¯ã·ã§ã³ã®ã¬ãã¼ã¸ã»ã³ã¬ã¯ã·ã§ã³ãæå¹ã«ãã (-gc-sections)" superClass="com.renesas.cdt.core.Linker.option.misc19" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Linker.option.linkOptimizationflto.291470231" name="ãªã³ã¯ææé©åãæå¹ã«ãã (-flto)" superClass="com.renesas.cdt.rz.Debug.Linker.option.linkOptimizationflto" value="true" valueType="boolean"/>
+								<option command="-nostartfiles" id="com.renesas.cdt.rz.Debug.Linker.option.linkUsingGcc.1128476310" name="ãªã³ã¯æã« &quot;ld&quot; ã³ãã³ãã®ä»£ããã« &quot;gcc&quot; ã³ãã³ããä½¿ç¨ãã" superClass="com.renesas.cdt.rz.Debug.Linker.option.linkUsingGcc" value="true" valueType="boolean"/>
+							</tool>
+							<tool id="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id.344160852" name="Objcopy" superClass="com.renesas.cdt.rz.debug.win32.tool.objcopy.Id"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="prototool.com.renesas.cdt.rz.projectType.win32.Id.1677050452" name="Executable (Renesas)" projectType="com.renesas.cdt.rz.projectType.win32.Id"/>
+	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+	<storageModule moduleId="refreshScope" versionNumber="2">
+		<configuration configurationName="Debug">
+			<resource resourceType="PROJECT" workspacePath="/prototool"/>
+		</configuration>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+		<buildTargets>
+			<target name="makefile.mrbc" path="src" targetID="com.renesas.cdt.build.MakeTargetBuilder">
+				<buildCommand>make</buildCommand>
+				<buildArguments/>
+				<buildTarget>makefile.mrbc</buildTarget>
+				<stopOnError>false</stopOnError>
+				<useDefaultCommand>true</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+		</buildTargets>
+	</storageModule>
+</cproject>
Index: /EcnlProtoTool/trunk/prototool/.info
===================================================================
--- /EcnlProtoTool/trunk/prototool/.info	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/.info	(revision 279)
@@ -0,0 +1,7 @@
+TOOL_CHAIN=KPIT GNUARM-NONE-EABI Toolchain
+VERSION=v16.01
+TC_INSTALL=C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\
+GCC_STRING=5.2-GNUARM-NONE_v16.01
+VERSION_IDE=
+E2STUDIO_VERSION=5.3.1.002
+ACTIVE_CONFIGURATION=Debug
Index: /EcnlProtoTool/trunk/prototool/.project
===================================================================
--- /EcnlProtoTool/trunk/prototool/.project	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/.project	(revision 279)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>prototool</name>
+	<comment></comment>
+	<projects>
+		<project>mruby-1.2.0</project>
+		<project>ntshell</project>
+		<project>onigmo-5.15.0</project>
+		<project>tcc-0.9.26</project>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.renesas.cdt.core.genmakebuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>com.renesas.cdt.core.kpitcnature</nature>
+		<nature>com.renesas.cdt.core.kpitccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>
Index: /EcnlProtoTool/trunk/prototool/build_newlib.bat
===================================================================
--- /EcnlProtoTool/trunk/prototool/build_newlib.bat	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/build_newlib.bat	(revision 279)
@@ -0,0 +1,15 @@
+@ECHO OFF
+set PATH=%PATH%;C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\bin
+
+copy "C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\arm-none-eabi\lib\armv7-ar\thumb\fpu\libc.a" .\libout.a
+arm-none-eabi-ar d libout.a lib_a-abort.o lib_a-syscalls.o lib_a-localtime.o lib_a-svfprintf.o lib_a-vfprintf.o lib_a-svfiprintf.o lib_a-vfiprintf.o
+
+copy libout.a lib
+rem copy libout.a libopt.a 
+rem arm-none-eabi-ar x libopt.a lib_a-setjmp.o
+
+rem arm-none-eabi-libgen --select-lib=newlib --header-files=all --compiler-options=-mcpu=cortex-a9,-march=armv7-a,-mlittle-endian,-mthumb-interwork,-mfloat-abi=hard,-mfpu=vfp,-Os,-ffunction-sections,-fdata-sections,-fno-function-cse,-funit-at-a-time,-falign-jumps --assembler-options=-mcpu=cortex-a9,-march=armv7-a,-mlittle-endian,-mthumb-interwork,-mfloat-abi=hard,-mfpu=vfp --output=libopt.a
+rem arm-none-eabi-libgen --select-lib=optlib --header-files=all --compiler-options=-mcpu=cortex-a9,-march=armv7-a,-mlittle-endian,-mthumb-interwork,-mfloat-abi=hard,-mfpu=vfp,-Os,-ffunction-sections,-fdata-sections,-fno-function-cse,-funit-at-a-time,-falign-jumps --assembler-options=-mcpu=cortex-a9,-march=armv7-a,-mlittle-endian,-mthumb-interwork,-mfloat-abi=hard,-mfpu=vfp --output=libopt.a
+rem arm-none-eabi-ar r libopt.a lib_a-setjmp.o
+
+rem copy libopt.a lib
Index: /EcnlProtoTool/trunk/prototool/lib/makefile.mrbc
===================================================================
--- /EcnlProtoTool/trunk/prototool/lib/makefile.mrbc	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/lib/makefile.mrbc	(revision 279)
@@ -0,0 +1,26 @@
+
+CC=arm-none-eabi-gcc
+AR=arm-none-eabi-ar
+MRBC=../../mruby-1.2.0/bin/mrbc
+
+CFLAGS=-mcpu=cortex-a9 -march=armv7-a -mlittle-endian -marm -mthumb-interwork -mfloat-abi=hard -mfpu=vfpv3 -I../../mruby-1.2.0/include
+COBJS=echo_server.o echo_client.o
+CSRCS=$(foreach file,$(COBJS),$(file:.o=.c))
+
+vpath %.rb ../src
+
+all: libmrbcode.a
+
+libmrbcode.a: $(COBJS)
+	$(AR) -rcs ../lib/libmrbcode.a $(COBJS)
+
+$(CSRCS): %.c: %.rb
+	$(MRBC) -e -B$*_code -o $*.c $<
+
+$(COBJS): %.o: %.c
+	$(CC) -c $(CFLAGS) -o $@ $<
+
+clean:
+	rm -f $(CSRCS)
+	rm -f $(COBJS)
+
Index: /EcnlProtoTool/trunk/prototool/src/apibreak.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/apibreak.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/apibreak.c	(revision 279)
@@ -0,0 +1,524 @@
+/*
+** apibreak.c
+**
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "mruby.h"
+#include "mruby/irep.h"
+#include "mrdb.h"
+#include "mruby/debug.h"
+#include "mruby/opcode.h"
+#include "mruby/class.h"
+#include "mruby/proc.h"
+#include "mruby/variable.h"
+#include "mrdberror.h"
+#include "apibreak.h"
+
+#define MAX_BREAKPOINTNO (MAX_BREAKPOINT * 1024)
+#define MRB_DEBUG_BP_FILE_OK   (0x0001)
+#define MRB_DEBUG_BP_LINENO_OK (0x0002)
+
+static uint16_t
+check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
+{
+	uint32_t count = info_file->line_entry_count;
+	uint16_t l_idx;
+
+	if (info_file->line_type == mrb_debug_line_ary) {
+		for (l_idx = 0; l_idx < count; ++l_idx) {
+			if (lineno == info_file->lines.ary[l_idx]) {
+				return lineno;
+			}
+		}
+	}
+	else {
+		for (l_idx = 0; l_idx < count; ++l_idx) {
+			if (lineno == info_file->lines.flat_map[l_idx].line) {
+				return lineno;
+			}
+		}
+	}
+
+	return 0;
+}
+
+static int32_t
+get_break_index(mrb_debug_context *dbg, uint32_t bpno)
+{
+	uint32_t i;
+	int32_t index;
+	char hit = FALSE;
+
+	for (i = 0; i < dbg->bpnum; i++) {
+		if (dbg->bp[i].bpno == bpno) {
+			hit = TRUE;
+			index = i;
+			break;
+		}
+	}
+
+	if (hit == FALSE) {
+		return MRB_DEBUG_BREAK_INVALID_NO;
+	}
+
+	return index;
+}
+
+static void
+free_breakpoint(mrb_state *mrb, mrb_debug_breakpoint *bp)
+{
+	switch (bp->type) {
+	case MRB_DEBUG_BPTYPE_LINE:
+		mrb_free(mrb, (void*)bp->point.linepoint.file);
+		break;
+	case MRB_DEBUG_BPTYPE_METHOD:
+		mrb_free(mrb, (void*)bp->point.methodpoint.method_name);
+		if (bp->point.methodpoint.class_name != NULL) {
+			mrb_free(mrb, (void*)bp->point.methodpoint.class_name);
+		}
+		break;
+	default:
+		break;
+	}
+}
+
+static uint16_t
+check_file_lineno(struct mrb_irep *irep, const char *file, uint16_t lineno)
+{
+	mrb_irep_debug_info_file *info_file;
+	uint16_t result = 0;
+	uint16_t f_idx;
+	uint16_t fix_lineno;
+	uint16_t i;
+
+	for (f_idx = 0; f_idx < irep->debug_info->flen; ++f_idx) {
+		info_file = irep->debug_info->files[f_idx];
+		if (!strcmp(info_file->filename, file)) {
+			result = MRB_DEBUG_BP_FILE_OK;
+
+			fix_lineno = check_lineno(info_file, lineno);
+			if (fix_lineno != 0) {
+				return result | MRB_DEBUG_BP_LINENO_OK;
+			}
+		}
+		for (i = 0; i < irep->rlen; ++i) {
+			result |= check_file_lineno(irep->reps[i], file, lineno);
+			if (result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
+				return result;
+			}
+		}
+	}
+	return result;
+}
+
+static const char*
+get_class_name(mrb_state *mrb, struct RClass *class_obj)
+{
+	struct RClass *outer;
+	mrb_sym class_sym;
+
+	outer = mrb_class_outer_module(mrb, class_obj);
+	class_sym = mrb_class_sym(mrb, class_obj, outer);
+	return mrb_sym2name(mrb, class_sym);
+}
+
+static int32_t
+compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
+{
+	const char* class_name;
+	const char* method_name;
+	struct RProc* m;
+	struct RClass* sc;
+	const char* sn;
+	mrb_sym ssym;
+	mrb_debug_methodpoint *method_p;
+	mrb_bool is_defined;
+
+	method_name = mrb_sym2name(mrb, method_sym);
+
+	method_p = &bp->point.methodpoint;
+	if (strcmp(method_p->method_name, method_name) == 0) {
+		class_name = get_class_name(mrb, class_obj);
+		if (class_name == NULL) {
+			if (method_p->class_name == NULL) {
+				return bp->bpno;
+			}
+		}
+		else if (method_p->class_name != NULL) {
+			m = mrb_method_search_vm(mrb, &class_obj, method_sym);
+			if (m == NULL) {
+				return MRB_DEBUG_OK;
+			}
+			if (MRB_PROC_CFUNC_P(m)) {
+				*isCfunc = TRUE;
+			}
+
+			is_defined = mrb_class_defined(mrb, method_p->class_name);
+			if (is_defined == FALSE) {
+				return MRB_DEBUG_OK;
+			}
+
+			sc = mrb_class_get(mrb, method_p->class_name);
+			ssym = mrb_symbol(mrb_check_intern_cstr(mrb, method_p->method_name));
+			m = mrb_method_search_vm(mrb, &sc, ssym);
+			if (m == NULL) {
+				return MRB_DEBUG_OK;
+			}
+
+			class_name = get_class_name(mrb, class_obj);
+			sn = get_class_name(mrb, sc);
+			if (strcmp(sn, class_name) == 0) {
+				return bp->bpno;
+			}
+		}
+	}
+	return MRB_DEBUG_OK;
+}
+
+int32_t
+mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
+{
+	int32_t index;
+	char* set_file;
+	uint16_t result;
+
+	if ((mrb == NULL) || (dbg == NULL) || (file == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	if (dbg->bpnum >= MAX_BREAKPOINT) {
+		return MRB_DEBUG_BREAK_NUM_OVER;
+	}
+
+	if (dbg->next_bpno > MAX_BREAKPOINTNO) {
+		return MRB_DEBUG_BREAK_NO_OVER;
+	}
+
+	/* file and lineno check (line type mrb_debug_line_ary only.) */
+	result = check_file_lineno(dbg->root_irep, file, lineno);
+	if (result == 0) {
+		return MRB_DEBUG_BREAK_INVALID_FILE;
+	}
+	else if (result == MRB_DEBUG_BP_FILE_OK) {
+		return MRB_DEBUG_BREAK_INVALID_LINENO;
+	}
+
+	int len = strlen(file) + 1;
+	set_file = (char *)mrb_malloc(mrb, len);
+
+	index = dbg->bpnum;
+	dbg->bp[index].bpno = dbg->next_bpno;
+	dbg->next_bpno++;
+	dbg->bp[index].enable = TRUE;
+	dbg->bp[index].type = MRB_DEBUG_BPTYPE_LINE;
+	dbg->bp[index].point.linepoint.lineno = lineno;
+	dbg->bpnum++;
+
+	strlcpy(set_file, file, len);
+
+	dbg->bp[index].point.linepoint.file = set_file;
+
+	return dbg->bp[index].bpno;
+}
+
+int32_t
+mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name)
+{
+	int32_t index;
+	char* set_class;
+	char* set_method;
+	int len;
+
+	if ((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	if (dbg->bpnum >= MAX_BREAKPOINT) {
+		return MRB_DEBUG_BREAK_NUM_OVER;
+	}
+
+	if (dbg->next_bpno > MAX_BREAKPOINTNO) {
+		return MRB_DEBUG_BREAK_NO_OVER;
+	}
+
+	if (class_name != NULL) {
+		len = strlen(class_name) + 1;
+		set_class = (char *)mrb_malloc(mrb, len);
+		strlcpy(set_class, class_name, len);
+	}
+	else {
+		set_class = NULL;
+	}
+
+	len = strlen(method_name) + 1;
+	set_method = (char *)mrb_malloc(mrb, len);
+
+	strlcpy(set_method, method_name, len);
+
+	index = dbg->bpnum;
+	dbg->bp[index].bpno = dbg->next_bpno;
+	dbg->next_bpno++;
+	dbg->bp[index].enable = TRUE;
+	dbg->bp[index].type = MRB_DEBUG_BPTYPE_METHOD;
+	dbg->bp[index].point.methodpoint.method_name = set_method;
+	dbg->bp[index].point.methodpoint.class_name = set_class;
+	dbg->bpnum++;
+
+	return dbg->bp[index].bpno;
+}
+
+int32_t
+mrb_debug_get_breaknum(mrb_state *mrb, mrb_debug_context *dbg)
+{
+	if ((mrb == NULL) || (dbg == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	return dbg->bpnum;
+}
+
+int32_t
+mrb_debug_get_break_all(mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint bp[])
+{
+	uint32_t get_size = 0;
+
+	if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	if (dbg->bpnum >= size) {
+		get_size = size;
+	}
+	else {
+		get_size = dbg->bpnum;
+	}
+
+	memcpy(bp, dbg->bp, sizeof(mrb_debug_breakpoint) * get_size);
+
+	return get_size;
+}
+
+int32_t
+mrb_debug_get_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp)
+{
+  int32_t index;
+
+	if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	index = get_break_index(dbg, bpno);
+	if (index == MRB_DEBUG_BREAK_INVALID_NO) {
+		return MRB_DEBUG_BREAK_INVALID_NO;
+	}
+
+	bp->bpno = dbg->bp[index].bpno;
+	bp->enable = dbg->bp[index].enable;
+	bp->point = dbg->bp[index].point;
+	bp->type = dbg->bp[index].type;
+
+	return 0;
+}
+
+int32_t
+mrb_debug_delete_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
+{
+	uint32_t i;
+	int32_t index;
+
+	if ((mrb == NULL) || (dbg == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	index = get_break_index(dbg, bpno);
+	if (index == MRB_DEBUG_BREAK_INVALID_NO) {
+		return MRB_DEBUG_BREAK_INVALID_NO;
+	}
+
+	free_breakpoint(mrb, &dbg->bp[index]);
+
+	for (i = index; i < dbg->bpnum; i++) {
+		if ((i + 1) == dbg->bpnum) {
+			memset(&dbg->bp[i], 0, sizeof(mrb_debug_breakpoint));
+		}
+		else {
+			memcpy(&dbg->bp[i], &dbg->bp[i + 1], sizeof(mrb_debug_breakpoint));
+		}
+	}
+
+	dbg->bpnum--;
+
+	return MRB_DEBUG_OK;
+}
+
+int32_t
+mrb_debug_delete_break_all(mrb_state *mrb, mrb_debug_context *dbg)
+{
+	uint32_t i;
+
+	if ((mrb == NULL) || (dbg == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	for (i = 0; i < dbg->bpnum; i++) {
+		free_breakpoint(mrb, &dbg->bp[i]);
+	}
+
+	dbg->bpnum = 0;
+
+	return MRB_DEBUG_OK;
+}
+
+int32_t
+mrb_debug_enable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
+{
+	int32_t index = 0;
+
+	if ((mrb == NULL) || (dbg == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	index = get_break_index(dbg, bpno);
+	if (index == MRB_DEBUG_BREAK_INVALID_NO) {
+		return MRB_DEBUG_BREAK_INVALID_NO;
+	}
+
+	dbg->bp[index].enable = TRUE;
+
+	return MRB_DEBUG_OK;
+}
+
+int32_t
+mrb_debug_enable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
+{
+	uint32_t i;
+
+	if ((mrb == NULL) || (dbg == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	for (i = 0; i < dbg->bpnum; i++) {
+		dbg->bp[i].enable = TRUE;
+	}
+
+	return MRB_DEBUG_OK;
+}
+
+int32_t
+mrb_debug_disable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
+{
+	int32_t index = 0;
+
+	if ((mrb == NULL) || (dbg == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	index = get_break_index(dbg, bpno);
+	if (index == MRB_DEBUG_BREAK_INVALID_NO) {
+		return MRB_DEBUG_BREAK_INVALID_NO;
+	}
+
+	dbg->bp[index].enable = FALSE;
+
+	return MRB_DEBUG_OK;
+}
+
+int32_t
+mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
+{
+	uint32_t i;
+
+	if ((mrb == NULL) || (dbg == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	for (i = 0; i < dbg->bpnum; i++) {
+		dbg->bp[i].enable = FALSE;
+	}
+
+	return MRB_DEBUG_OK;
+}
+
+static mrb_bool
+check_start_pc_for_line(mrb_irep *irep, mrb_code *pc, uint16_t line)
+{
+	if (pc > irep->iseq) {
+		if (line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+int32_t
+mrb_debug_check_breakpoint_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line)
+{
+	mrb_debug_breakpoint *bp;
+	mrb_debug_linepoint *line_p;
+  uint32_t i;
+
+	if ((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	if (!check_start_pc_for_line(dbg->irep, dbg->pc, line)) {
+		return MRB_DEBUG_OK;
+	}
+
+	bp = dbg->bp;
+	for (i = 0; i < dbg->bpnum; i++) {
+		switch (bp->type) {
+		case MRB_DEBUG_BPTYPE_LINE:
+			if (bp->enable == TRUE) {
+				line_p = &bp->point.linepoint;
+				if ((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
+					return bp->bpno;
+				}
+			}
+			break;
+		case MRB_DEBUG_BPTYPE_METHOD:
+			break;
+		case MRB_DEBUG_BPTYPE_NONE:
+		default:
+			return MRB_DEBUG_OK;
+		}
+		bp++;
+	}
+	return MRB_DEBUG_OK;
+}
+
+
+int32_t
+mrb_debug_check_breakpoint_method(mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
+{
+	mrb_debug_breakpoint *bp;
+	int32_t bpno;
+  uint32_t i;
+
+	if ((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
+		return MRB_DEBUG_INVALID_ARGUMENT;
+	}
+
+	bp = dbg->bp;
+	for (i = 0; i < dbg->bpnum; i++) {
+		if (bp->type == MRB_DEBUG_BPTYPE_METHOD) {
+			if (bp->enable == TRUE) {
+				bpno = compare_break_method(mrb, bp, class_obj, method_sym, isCfunc);
+				if (bpno > 0) {
+					return bpno;
+				}
+			}
+		}
+		else if (bp->type == MRB_DEBUG_BPTYPE_NONE) {
+			break;
+		}
+		bp++;
+	}
+
+	return 0;
+}
+
+
Index: /EcnlProtoTool/trunk/prototool/src/apibreak.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/apibreak.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/apibreak.h	(revision 279)
@@ -0,0 +1,26 @@
+/*
+** apibreak.h
+**
+*/
+
+#ifndef APIBREAK_H_
+#define APIBREAK_H_
+
+#include "mruby.h"
+#include "mrdb.h"
+
+int32_t mrb_debug_set_break_line( mrb_state *, mrb_debug_context *, const char *, uint16_t );
+int32_t mrb_debug_set_break_method( mrb_state *, mrb_debug_context *, const char *, const char * );
+int32_t mrb_debug_get_breaknum( mrb_state *, mrb_debug_context * );
+int32_t mrb_debug_get_break_all( mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]);
+int32_t mrb_debug_get_break( mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint * );
+int32_t mrb_debug_delete_break( mrb_state *, mrb_debug_context *, uint32_t );
+int32_t mrb_debug_delete_break_all( mrb_state *, mrb_debug_context * );
+int32_t mrb_debug_enable_break( mrb_state *, mrb_debug_context *, uint32_t );
+int32_t mrb_debug_enable_break_all( mrb_state *, mrb_debug_context * );
+int32_t mrb_debug_disable_break( mrb_state *, mrb_debug_context *, uint32_t );
+int32_t mrb_debug_disable_break_all( mrb_state *, mrb_debug_context * );
+int32_t mrb_debug_check_breakpoint_line( mrb_state *, mrb_debug_context *, const char *, uint16_t );
+int32_t mrb_debug_check_breakpoint_method( mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool* );
+
+#endif /* APIBREAK_H_ */
Index: /EcnlProtoTool/trunk/prototool/src/apiprint.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/apiprint.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/apiprint.c	(revision 279)
@@ -0,0 +1,79 @@
+/*
+** apiprint.c
+**
+*/
+
+#include <stdlib.h>
+
+#include "mrdb.h"
+#include "mruby/value.h"
+#include "mruby/class.h"
+#include "mruby/compile.h"
+#include "mruby/error.h"
+#include "mruby/numeric.h"
+#include "mruby/string.h"
+#include "apiprint.h"
+
+static void
+mrdb_check_syntax(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t len)
+{
+	mrbc_context *c;
+
+	c = mrbc_context_new(mrb);
+	c->no_exec = TRUE;
+	c->capture_errors = TRUE;
+	c->filename = (char*)dbg->prvfile;
+	c->lineno = dbg->prvline;
+
+	/* Load program */
+	mrb_load_nstring_cxt(mrb, expr, len, c);
+
+	mrbc_context_free(mrb, c);
+}
+
+mrb_value
+mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t len, mrb_bool *exc)
+{
+	void(*tmp)(struct mrb_state *, struct mrb_irep *, mrb_code *, mrb_value *);
+	mrb_value ruby_code;
+	mrb_value s;
+	mrb_value v;
+	mrb_value recv;
+
+	/* disable code_fetch_hook */
+	tmp = mrb->code_fetch_hook;
+	mrb->code_fetch_hook = NULL;
+
+	mrdb_check_syntax(mrb, dbg, expr, len);
+	if (mrb->exc) {
+		v = mrb_obj_value(mrb->exc);
+		mrb->exc = 0;
+	}
+	else {
+		/*
+		 * begin
+		 *   expr
+		 * rescue => e
+		 *   e
+		 * end
+		 */
+		ruby_code = mrb_str_new_lit(mrb, "begin\n");
+		ruby_code = mrb_str_cat(mrb, ruby_code, expr, len);
+		ruby_code = mrb_str_cat_lit(mrb, ruby_code, "\nrescue => e\ne\nend");
+
+		recv = dbg->regs[0];
+
+		v = mrb_funcall(mrb, recv, "instance_eval", 1, ruby_code);
+	}
+
+	if (exc) {
+		*exc = mrb_obj_is_kind_of(mrb, v, mrb->eException_class);
+	}
+
+	s = mrb_funcall(mrb, v, "inspect", 0);
+
+	/* enable code_fetch_hook */
+	mrb->code_fetch_hook = tmp;
+
+	return s;
+}
Index: /EcnlProtoTool/trunk/prototool/src/apiprint.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/apiprint.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/apiprint.h	(revision 279)
@@ -0,0 +1,13 @@
+/*
+ * apiprint.h
+ */
+
+#ifndef APIPRINT_H_
+#define APIPRINT_H_
+
+#include "mruby.h"
+#include "mrdb.h"
+
+mrb_value mrb_debug_eval(mrb_state*, mrb_debug_context*, const char*, size_t, mrb_bool*);
+
+#endif /* APIPRINT_H_ */
Index: /EcnlProtoTool/trunk/prototool/src/arduino.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/arduino.c	(revision 278)
+++ /EcnlProtoTool/trunk/prototool/src/arduino.c	(revision 279)
@@ -1,4 +1,7 @@
 #include <arduino.h>
 #include <mruby.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
 #include "../llbruby.h"
 
@@ -16,7 +19,4 @@
 i2c_t Wire5;
 
-FATFS RomDisk;
-SD Sd;
-
 char ExeFilename[64];
 
@@ -27,9 +27,10 @@
 void randomSeed(long seed)
 {
+	srand(seed);
 }
 
 long arduino_random(long min, long max)
 {
-	return min;
+	return (long)(((double)rand() / (double)RAND_MAX) / ((double)max - (double)min)) + min;
 }
 
@@ -223,16 +224,16 @@
 int EEP_fopen(FILEEEP *fp, const char *str, char mode)
 {
-	FRESULT ret;
-	BYTE fm;
+	int ret;
+	int fm;
 
 	switch (mode){
 	case 0:
-		fm = FA_READ;
+		fm = O_RDONLY;
 		break;
 	case 1:
-		fm = FA_READ | FA_WRITE | FA_CREATE_NEW;
+		fm = O_RDWR | O_CREAT;
 		break;
 	case 2:
-		fm = FA_READ | FA_WRITE;
+		fm = O_RDWR;
 		break;
 	default:
@@ -240,26 +241,35 @@
 	}
 
-	ret = f_open(&fp->fp, str, fm);
-
-	return (ret == FR_OK) ? 0 : -1;
+	ret = open(str, fm);
+	if (ret < 0) {
+		fp->fd = 0;
+		return -1;
+	}
+	fp->fd = ret;
+
+	return 0;
 }
 
 int EEP_fwrite(FILEEEP *fp, byte *data, int *len)
 {
-	FRESULT ret;
-
-	ret = f_write(&fp->fp, data, (UINT)*len, (UINT *)len);
-
-	return (ret == FR_OK) ? 1 : -1;
+	int ret;
+
+	ret = write(fp->fd, data, *len);
+	if (ret < 0) {
+		*len = 0;
+		return -1;
+	}
+	*len = ret;
+
+	return 0;
 }
 
 int EEP_fread(FILEEEP *fp)
 {
-	FRESULT ret;
+	int ret;
 	char c;
-	UINT br;
-
-	ret = f_read(&fp->fp, &c, 1, &br);
-	if (ret != FR_OK)
+
+	ret = read(fp->fd, &c, 1);
+	if (ret < 0)
 		return -1;
 
@@ -269,252 +279,255 @@
 void EEP_fclose(FILEEEP *fp)
 {
-	f_close(&fp->fp);
+	close(fp->fd);
 }
 
 int EEP_fseek(FILEEEP *fp, int pos, int mode)
 {
-	FRESULT ret;
+	int ret;
 
 	switch (mode){
 	case EEP_SEEKTOP:
-		ret = f_lseek(&fp->fp, pos);
+		ret = lseek(fp->fd, pos, SEEK_SET);
 		break;
 	case EEP_SEEKCUR:
-		ret = f_lseek(&fp->fp, fp->fp.fptr + pos);
+		ret = lseek(fp->fd, pos, SEEK_CUR);
 		break;
 	case EEP_SEEKEND:
-		ret = f_lseek(&fp->fp, fp->fp.fsize - pos);
+		ret = lseek(fp->fd, pos, SEEK_END);
 		break;
 	default:
-		ret = FR_INVALID_PARAMETER;
-		break;
-	}
-
-	if (ret != FR_OK)
-		f_lseek(&fp->fp, 0);
-
-	return fp->fp.fptr;
+		return -1;
+		break;
+	}
+
+	if (ret < 0)
+		return false;
+
+	return true;
 }
 
 int EEP_ffilesize(const char *str)
 {
-	FRESULT ret;
-	FILINFO fno;
-
-	ret = f_stat(str, &fno);
-	if (ret != FR_OK)
+	int ret;
+	struct stat fno;
+
+	ret = stat(str, &fno);
+	if (ret < 0)
 		return 0;
 
-	return fno.fsize;
+	return fno.st_size;
 }
 
 bool EEP_fEof(FILEEEP *fp)
 {
-	return f_tell(&fp->fp) == f_size(&fp->fp);
+	int ret, pos;
+	struct stat fno;
+
+	ret = fstat(fp->fd, &fno);
+	if (ret < 0)
+		return false;
+
+	pos = lseek(fp->fd, 0, SEEK_CUR);
+
+	return pos == fno.st_size;
 }
 
 bool EEP_fexist(const char *path)
 {
-	FRESULT ret;
-	FILINFO fno;
-
-	ret = f_stat(path, &fno);
-
-	return (ret == FR_OK);
+	int ret;
+	struct stat fno;
+
+	ret = stat(path, &fno);
+
+	return (ret == 0);
 }
 
 bool EEP_fcopy(const char *src, const char *dst)
 {
-	FIL fsrc, fdst;
-	BYTE buffer[512];
-	FRESULT res;
-	UINT br, bw;
-
-	res = f_open(&fsrc, src, FA_OPEN_EXISTING | FA_READ);
-	if (res != FR_OK)
-		return false;
-
-	res = f_open(&fdst, dst, FA_CREATE_ALWAYS | FA_WRITE);
-	if (res != FR_OK){
-		f_close(&fsrc);
+	int fsrc, fdst;
+	unsigned char buffer[512];
+	int res = true;
+	int br, bw;
+
+	fsrc = open(src, O_RDONLY);
+	if (fsrc < 0)
+		return false;
+
+	fdst = open(dst, O_RDWR | O_CREAT);
+	if (fdst < 0){
+		close(fsrc);
 		return false;
 	}
 
 	for (;;) {
-		res = f_read(&fsrc, buffer, sizeof(buffer), &br);
-		if ((res != FR_OK) || br == 0)
+		br = read(fsrc, buffer, sizeof(buffer));
+		if (br < 0) {
+			res = false;
 			break;
-
-		res = f_write(&fdst, buffer, br, &bw);
-		if ((res != FR_OK) || bw < br)
+		}
+		if (br == 0)
 			break;
-	}
-
-	f_close(&fsrc);
-	f_close(&fdst);
-
-	return (res == FR_OK);
+
+		bw = write(fdst, buffer, br);
+		if ((bw < 0) || bw < br) {
+			res = false;
+			break;
+		}
+	}
+
+	close(fsrc);
+	close(fdst);
+
+	return res;
 }
 
 bool EEP_fdelete(const char *path)
 {
-	FRESULT res;
-
-	res = f_unlink(path);
-
-	return (res == FR_OK);
-}
-
-bool SD_begin()
-{
-	DSTATUS dst;
-	FRESULT res;
-	BYTE pdrv = 1, type;
-
-	if (Sd.FatFs.fs_type != 0)
-		return true;
-
-	if ((dst = disk_initialize(pdrv)) != RES_OK) {
-		return false;
-	}
-
-	if ((dst = disk_ioctl(pdrv, MMC_GET_TYPE, &type)) != RES_OK) {
-		Sd.dst = dst;
-		Sd.type = 0;
-	}
-	else {
-		Sd.dst = RES_OK;
-		Sd.type = type;
-	}
-
-	if ((res = f_mount(&Sd.FatFs, "1:", 1)) != FR_OK) {
-		return false;
-	}
-
+	int res;
+
+	res = unlink(path);
+
+	return (res == 0);
+}
+
+bool SD_open(File *file, const char *path, int mode)
+{
+	int ret;
+
+	if (!SD_begin())
+		return false;
+
+	ret = open(path, mode);
+	if (ret < 0) {
+		file->fd = 0;
+		return false;
+	}
+
+	file->fd = ret;
 	return true;
 }
 
-bool SD_open(File *file, const char *path, int mode)
-{
-	FRESULT ret;
+bool SD_rmdir(const char *path)
+{
+	int ret;
 
 	if (!SD_begin())
 		return false;
 
-	ret = f_open(&file->fp, path, mode);
-
-	return ret == FR_OK;
-}
-
-bool SD_rmdir(const char *path)
-{
-	FRESULT ret;
+	ret = rmdir(path);
+
+	return ret == 0;
+}
+
+bool SD_rename(const char *path1, const char *path2)
+{
+	int ret;
 
 	if (!SD_begin())
 		return false;
 
-	ret = f_unlink(path);
-
-	return ret == FR_OK;
-}
-
-bool SD_rename(const char *path1, const char *path2)
-{
-	FRESULT ret;
+	ret = rename(path1, path2);
+	
+	return ret == 0;
+}
+
+bool SD_remove(const char *path)
+{
+	int ret;
 
 	if (!SD_begin())
 		return false;
 
-	ret = f_rename(path1, path2);
-	
-	return ret == FR_OK;
-}
-
-bool SD_remove(const char *path)
-{
-	FRESULT ret;
+	ret = unlink(path);
+
+	return ret == 0;
+}
+
+bool SD_exists(const char *path)
+{
+	int ret;
+	struct stat fno;
 
 	if (!SD_begin())
 		return false;
 
-	ret = f_unlink(path);
-
-	return ret == FR_OK;
-}
-
-bool SD_exists(const char *path)
-{
-	FRESULT ret;
-	FILINFO fno;
+	ret = stat(path, &fno);
+
+	return ret == 0;
+}
+
+bool SD_mkdir(const char *path)
+{
+	int ret;
 
 	if (!SD_begin())
 		return false;
 
-	ret = f_stat(path, &fno);
-
-	return ret == FR_OK;
-}
-
-bool SD_mkdir(const char *path)
-{
-	FRESULT ret;
-
-	if (!SD_begin())
-		return false;
-
-	ret = f_mkdir(path);
-
-	return ret == FR_OK;
-}
-
-int file_write(File *fd, unsigned char *str, int len)
-{
-	FRESULT ret;
-	UINT bw;
-
-	ret = f_write(&fd->fp, str, len, &bw);
-	if (ret != FR_OK)
-		return -1;
-
-	return bw;
-}
-
-void file_close(File *fd)
-{
-	f_close(&fd->fp);
-}
-
-int file_size(File *fd)
-{
-	return f_size(&fd->fp);
-}
-
-int file_position(File *fd)
-{
-	return fd->fp.fptr;
-}
-
-void file_flush(File *fd)
-{
-	f_flush(&fd->fp);
-}
-
-bool file_seek(File *fd, int pos)
-{
-	FRESULT ret;
-
-	ret = f_lseek(&fd->fp, pos);
-
-	return ret != FR_OK;
-}
-
-int file_read(File *fd)
-{
-	FRESULT ret;
+	ret = mkdir(path, 0777);
+
+	return ret == 0;
+}
+
+int file_write(File *fp, unsigned char *str, int len)
+{
+	int ret;
+
+	ret = write(fp->fd, str, len);
+	if (ret < 0)
+		return -1;
+
+	return ret;
+}
+
+void file_close(File *fp)
+{
+	close(fp->fd);
+}
+
+int file_size(File *fp)
+{
+	int ret;
+	struct stat fno;
+
+	ret = fstat(fp->fd, &fno);
+	if (ret < 0)
+		return -1;
+
+	return fno.st_size;
+}
+
+int file_position(File *fp)
+{
+	int ret;
+	struct stat fno;
+
+	ret = lseek(fp->fd, 0, SEEK_CUR);
+	if (ret < 0)
+		return -1;
+
+	return ret;
+}
+
+void file_flush(File *fp)
+{
+	fsync(fp->fd);
+}
+
+bool file_seek(File *fp, int pos)
+{
+	int ret;
+
+	ret = lseek(fp->fd, pos, SEEK_SET);
+
+	return ret == 0;
+}
+
+int file_read(File *fp)
+{
+	int ret;
 	char c;
-	UINT br;
-
-	ret = f_read(&fd->fp, &c, 1, &br);
-	if (ret != FR_OK)
+
+	ret = read(fp->fd, &c, 1);
+	if (ret < 0)
 		return -1;
 
@@ -524,5 +537,5 @@
 void system_reboot(int mode)
 {
-
+	exit(mode);
 }
 
@@ -531,27 +544,2 @@
 	return 0;
 }
-
-DWORD get_fattime(void)
-{
-	time_t temp;
-	struct tm _tm;
-
-	time(&temp);
-	gmtime_r(&temp, &_tm);
-
-	return	  ((DWORD)(_tm.tm_year - 1980) << 25)
-		| ((DWORD)_tm.tm_mon << 21)
-		| ((DWORD)_tm.tm_mday << 16)
-		| ((DWORD)_tm.tm_hour << 11)
-		| ((DWORD)_tm.tm_min << 5)
-		| ((DWORD)_tm.tm_sec >> 1);
-}
-
-void mrb_gr_peach_gem_init(mrb_state *mrb)
-{
-}
-
-void mrb_gr_peach_gem_final(mrb_state *mrb)
-{
-
-}
Index: /EcnlProtoTool/trunk/prototool/src/arduino.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/arduino.h	(revision 278)
+++ /EcnlProtoTool/trunk/prototool/src/arduino.h	(revision 279)
@@ -30,6 +30,4 @@
 #include <us_ticker_api.h>
 #include <wait_api.h>
-#include "diskio.h"
-#include "ff.h"
 
 #ifndef bool
@@ -116,5 +114,5 @@
 
 typedef struct File {
-	FIL fp;
+	int  fd;
 } File;
 
@@ -130,12 +128,4 @@
 int file_read(File *fd);
 
-typedef struct SD {
-	DSTATUS dst;
-	BYTE type;
-	FATFS FatFs;
-} SD;
-
-extern SD Sd;
-
 bool SD_begin();
 bool SD_open(File *file, const char *path, int mode);
@@ -147,5 +137,5 @@
 
 typedef struct FILEEEP {
-	FIL fp;
+	int fd;
 } FILEEEP;
 
Index: /EcnlProtoTool/trunk/prototool/src/cmdbreak.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/cmdbreak.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/cmdbreak.c	(revision 279)
@@ -0,0 +1,437 @@
+/*
+** cmdbreak.c
+**
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "mruby.h"
+#include "mruby/dump.h"
+#include "mruby/debug.h"
+#include "mruby/string.h"
+#include "mrdb.h"
+#include "mrdberror.h"
+#include "apibreak.h"
+
+#define BREAK_SET_MSG_LINE                  "Breakpoint %d: file %s, line %d.\n"
+#define BREAK_SET_MSG_METHOD                "Breakpoint %d: method %s.\n"
+#define BREAK_SET_MSG_CLASS_METHOD          "Breakpoint %d: class %s, method %s.\n"
+#define BREAK_INFO_MSG_HEADER               "Num     Type           Enb What"
+#define BREAK_INFO_MSG_LINEBREAK            "%-8ubreakpoint     %s   at %s:%u\n"
+#define BREAK_INFO_MSG_METHODBREAK          "%-8ubreakpoint     %s   in %s:%s\n"
+#define BREAK_INFO_MSG_METHODBREAK_NOCLASS  "%-8ubreakpoint     %s   in %s\n"
+#define BREAK_INFO_MSG_ENABLE               "y"
+#define BREAK_INFO_MSG_DISABLE              "n"
+
+#define BREAK_ERR_MSG_INVALIDARG            "Internal error."
+#define BREAK_ERR_MSG_BLANK                 "Try \'help break\' for more information."
+#define BREAK_ERR_MSG_RANGEOVER             "The line number range is from 1 to 65535."
+#define BREAK_ERR_MSG_NUMOVER               "Exceeded the setable number of breakpoint."
+#define BREAK_ERR_MSG_NOOVER                "Breakno is over the available number.Please 'quit' and restart mrdb."
+#define BREAK_ERR_MSG_INVALIDSTR            "String \'%s\' is invalid.\n"
+#define BREAK_ERR_MSG_INVALIDLINENO         "Line %d in file \"%s\" is unavailable.\n"
+#define BREAK_ERR_MSG_INVALIDCLASS          "Class name \'%s\' is invalid.\n"
+#define BREAK_ERR_MSG_INVALIDMETHOD         "Method name \'%s\' is invalid.\n"
+#define BREAK_ERR_MSG_INVALIDFILE           "Source file named \"%s\" is unavailable.\n"
+#define BREAK_ERR_MSG_INVALIDBPNO           "warning: bad breakpoint number at or near '%s'\n"
+#define BREAK_ERR_MSG_INVALIDBPNO_INFO      "Args must be numbers variables."
+#define BREAK_ERR_MSG_NOBPNO                "No breakpoint number %d.\n"
+#define BREAK_ERR_MSG_NOBPNO_INFO           "No breakpoint matching '%d'\n"
+#define BREAK_ERR_MSG_NOBPNO_INFOALL        "No breakpoints."
+
+#define LINENO_MAX_DIGIT 6
+#define BPNO_LETTER_NUM 9
+
+typedef int32_t(*all_command_func)(mrb_state *, mrb_debug_context *);
+typedef int32_t(*select_command_func)(mrb_state *, mrb_debug_context *, uint32_t);
+
+static void
+print_api_common_error(int32_t error)
+{
+	switch (error) {
+	case MRB_DEBUG_INVALID_ARGUMENT:
+		puts(BREAK_ERR_MSG_INVALIDARG);
+		break;
+	default:
+		break;
+	}
+}
+
+#undef STRTOUL
+#define STRTOUL(ul,s) { \
+    int i; \
+    ul = 0; \
+    for(i=0; ISDIGIT(s[i]); i++) ul = 10*ul + (s[i] -'0'); \
+}
+
+static int32_t
+parse_breakpoint_no(char* args)
+{
+	char* ps = args;
+	uint32_t l;
+
+	if ((*ps == '0') || (strlen(ps) >= BPNO_LETTER_NUM)) {
+		return 0;
+	}
+
+	while (!(ISBLANK(*ps) || ISCNTRL(*ps))) {
+		if (!ISDIGIT(*ps)) {
+			return 0;
+		}
+		ps++;
+	}
+
+	STRTOUL(l, args);
+	return l;
+}
+
+static mrb_bool
+exe_set_command_all(mrb_state *mrb, mrdb_state *mrdb, all_command_func func)
+{
+	int32_t ret = MRB_DEBUG_OK;
+
+	if (mrdb->wcnt == 1) {
+		ret = func(mrb, mrdb->dbg);
+		print_api_common_error(ret);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static void
+exe_set_command_select(mrb_state *mrb, mrdb_state *mrdb, select_command_func func)
+{
+	char* ps;
+	int32_t ret = MRB_DEBUG_OK;
+	int32_t bpno = 0;
+	int32_t i;
+
+	for (i = 1; i < mrdb->wcnt; i++) {
+		ps = mrdb->words[i];
+		bpno = parse_breakpoint_no(ps);
+		if (bpno == 0) {
+			printf(BREAK_ERR_MSG_INVALIDBPNO, ps);
+			break;
+		}
+		ret = func(mrb, mrdb->dbg, (uint32_t)bpno);
+		if (ret == MRB_DEBUG_BREAK_INVALID_NO) {
+			printf(BREAK_ERR_MSG_NOBPNO, bpno);
+		}
+		else if (ret != MRB_DEBUG_OK) {
+			print_api_common_error(ret);
+		}
+	}
+}
+
+mrb_debug_bptype
+check_bptype(char* args)
+{
+	char* ps = args;
+
+	if (ISBLANK(*ps) || ISCNTRL(*ps)) {
+		puts(BREAK_ERR_MSG_BLANK);
+		return MRB_DEBUG_BPTYPE_NONE;
+	}
+
+	if (!ISDIGIT(*ps)) {
+		return MRB_DEBUG_BPTYPE_METHOD;
+	}
+
+	while (!(ISBLANK(*ps) || ISCNTRL(*ps))) {
+		if (!ISDIGIT(*ps)) {
+			printf(BREAK_ERR_MSG_INVALIDSTR, args);
+			return MRB_DEBUG_BPTYPE_NONE;
+		}
+		ps++;
+	}
+
+	if ((*args == '0') || (strlen(args) >= LINENO_MAX_DIGIT)) {
+		puts(BREAK_ERR_MSG_RANGEOVER);
+		return MRB_DEBUG_BPTYPE_NONE;
+	}
+
+	return MRB_DEBUG_BPTYPE_LINE;
+}
+
+static void
+print_breakpoint(mrb_debug_breakpoint *bp)
+{
+	const char* enable_letter[] = { BREAK_INFO_MSG_DISABLE, BREAK_INFO_MSG_ENABLE };
+
+	if (bp->type == MRB_DEBUG_BPTYPE_LINE) {
+		printf(BREAK_INFO_MSG_LINEBREAK,
+			bp->bpno, enable_letter[bp->enable], bp->point.linepoint.file, bp->point.linepoint.lineno);
+	}
+	else {
+		if (bp->point.methodpoint.class_name == NULL) {
+			printf(BREAK_INFO_MSG_METHODBREAK_NOCLASS,
+				bp->bpno, enable_letter[bp->enable], bp->point.methodpoint.method_name);
+		}
+		else {
+			printf(BREAK_INFO_MSG_METHODBREAK,
+				bp->bpno, enable_letter[bp->enable], bp->point.methodpoint.class_name, bp->point.methodpoint.method_name);
+		}
+	}
+}
+
+static void
+info_break_all(mrb_state *mrb, mrdb_state *mrdb)
+{
+	int32_t bpnum = 0;
+	int32_t i = 0;
+	int32_t ret = MRB_DEBUG_OK;
+	mrb_debug_breakpoint *bp_list;
+
+	bpnum = mrb_debug_get_breaknum(mrb, mrdb->dbg);
+	if (bpnum < 0) {
+		print_api_common_error(bpnum);
+		return;
+	}
+	else if (bpnum == 0) {
+		puts(BREAK_ERR_MSG_NOBPNO_INFOALL);
+		return;
+	}
+	bp_list = (mrb_debug_breakpoint*)mrb_malloc(mrb, bpnum * sizeof(mrb_debug_breakpoint));
+
+	ret = mrb_debug_get_break_all(mrb, mrdb->dbg, (uint32_t)bpnum, bp_list);
+	if (ret < 0) {
+		print_api_common_error(ret);
+		return;
+	}
+	puts(BREAK_INFO_MSG_HEADER);
+	for (i = 0; i < bpnum; i++) {
+		print_breakpoint(&bp_list[i]);
+	}
+
+	mrb_free(mrb, bp_list);
+}
+
+static void
+info_break_select(mrb_state *mrb, mrdb_state *mrdb)
+{
+	int32_t ret = MRB_DEBUG_OK;
+	int32_t bpno = 0;
+	char* ps = mrdb->command;
+	mrb_debug_breakpoint bp;
+	mrb_bool isFirst = TRUE;
+	int32_t i;
+
+	for (i = 2; i < mrdb->wcnt; i++) {
+		ps = mrdb->words[i];
+		bpno = parse_breakpoint_no(ps);
+		if (bpno == 0) {
+			puts(BREAK_ERR_MSG_INVALIDBPNO_INFO);
+			break;
+		}
+
+		ret = mrb_debug_get_break(mrb, mrdb->dbg, bpno, &bp);
+		if (ret == MRB_DEBUG_BREAK_INVALID_NO) {
+			printf(BREAK_ERR_MSG_NOBPNO_INFO, bpno);
+			break;
+		}
+		else if (ret != MRB_DEBUG_OK) {
+			print_api_common_error(ret);
+			break;
+		}
+		else if (isFirst == TRUE) {
+			isFirst = FALSE;
+			puts(BREAK_INFO_MSG_HEADER);
+		}
+		print_breakpoint(&bp);
+	}
+}
+
+mrb_debug_bptype
+parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **cname, char **method)
+{
+	mrb_debug_context *dbg = mrdb->dbg;
+	char *args;
+	char *body;
+	mrb_debug_bptype type;
+	uint32_t l;
+
+	if (mrdb->wcnt <= 1) {
+		puts(BREAK_ERR_MSG_BLANK);
+		return MRB_DEBUG_BPTYPE_NONE;
+	}
+
+	args = mrdb->words[1];
+	if ((body = strrchr(args, ':')) == NULL) {
+		body = args;
+		type = check_bptype(body);
+	}
+	else {
+		if (body == args) {
+			printf(BREAK_ERR_MSG_INVALIDSTR, args);
+			return MRB_DEBUG_BPTYPE_NONE;
+		}
+		*body = '\0';
+		type = check_bptype(++body);
+	}
+
+	switch (type) {
+	case MRB_DEBUG_BPTYPE_LINE:
+		STRTOUL(l, body);
+		if (l <= 65535) {
+			*line = l;
+			*file = (body == args) ? mrb_debug_get_filename(dbg->irep, (uint32_t)(dbg->pc - dbg->irep->iseq)) : args;
+		}
+		else {
+			puts(BREAK_ERR_MSG_RANGEOVER);
+			type = MRB_DEBUG_BPTYPE_NONE;
+		}
+		break;
+	case MRB_DEBUG_BPTYPE_METHOD:
+		if (body == args) {
+			/* method only */
+			if (ISUPPER(*body) || ISLOWER(*body) || (*body == '_')) {
+				*method = body;
+				*cname = NULL;
+			}
+			else {
+				printf(BREAK_ERR_MSG_INVALIDMETHOD, args);
+				type = MRB_DEBUG_BPTYPE_NONE;
+			}
+		}
+		else {
+			if (ISUPPER(*args)) {
+				switch (*body) {
+				case '@': case '$': case '?': case '.': case ',': case ':':
+				case ';': case '#': case '\\': case '\'': case '\"':
+					printf(BREAK_ERR_MSG_INVALIDMETHOD, body);
+					type = MRB_DEBUG_BPTYPE_NONE;
+					break;
+				default:
+					*method = body;
+					*cname = args;
+					break;
+				}
+			}
+			else {
+				printf(BREAK_ERR_MSG_INVALIDCLASS, args);
+				type = MRB_DEBUG_BPTYPE_NONE;
+			}
+		}
+		break;
+	case MRB_DEBUG_BPTYPE_NONE:
+	default:
+		break;
+	}
+
+	return type;
+}
+
+dbgcmd_state
+dbgcmd_break(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_debug_bptype type;
+	mrb_debug_context *dbg = mrdb->dbg;
+	const char *file = NULL;
+	uint32_t line = 0;
+	char *cname = NULL;
+	char *method = NULL;
+	int32_t ret;
+
+	type = parse_breakcommand(mrdb, &file, &line, &cname, &method);
+	switch (type) {
+	case MRB_DEBUG_BPTYPE_LINE:
+		ret = mrb_debug_set_break_line(mrb, dbg, file, line);
+		break;
+	case MRB_DEBUG_BPTYPE_METHOD:
+		ret = mrb_debug_set_break_method(mrb, dbg, cname, method);
+		break;
+	case MRB_DEBUG_BPTYPE_NONE:
+	default:
+		return DBGST_PROMPT;
+	}
+
+	if (ret >= 0) {
+		if (type == MRB_DEBUG_BPTYPE_LINE) {
+			printf(BREAK_SET_MSG_LINE, ret, file, line);
+		}
+		else if ((type == MRB_DEBUG_BPTYPE_METHOD) && (cname == NULL)) {
+			printf(BREAK_SET_MSG_METHOD, ret, method);
+		}
+		else {
+			printf(BREAK_SET_MSG_CLASS_METHOD, ret, cname, method);
+		}
+	}
+	else {
+		switch (ret) {
+		case MRB_DEBUG_BREAK_INVALID_LINENO:
+			printf(BREAK_ERR_MSG_INVALIDLINENO, line, file);
+			break;
+		case MRB_DEBUG_BREAK_INVALID_FILE:
+			printf(BREAK_ERR_MSG_INVALIDFILE, file);
+			break;
+		case MRB_DEBUG_BREAK_NUM_OVER:
+			puts(BREAK_ERR_MSG_NUMOVER);
+			break;
+		case MRB_DEBUG_BREAK_NO_OVER:
+			puts(BREAK_ERR_MSG_NOOVER);
+			break;
+		case MRB_DEBUG_INVALID_ARGUMENT:
+			puts(BREAK_ERR_MSG_INVALIDARG);
+			break;
+		case MRB_DEBUG_NOBUF:
+			puts("T.B.D.");
+			break;
+		default:
+			break;
+		}
+	}
+
+	return DBGST_PROMPT;
+}
+
+dbgcmd_state
+dbgcmd_info_break(mrb_state *mrb, mrdb_state *mrdb)
+{
+	if (mrdb->wcnt == 2) {
+		info_break_all(mrb, mrdb);
+	}
+	else {
+		info_break_select(mrb, mrdb);
+	}
+
+	return DBGST_PROMPT;
+}
+
+dbgcmd_state
+dbgcmd_delete(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_bool ret = FALSE;
+
+	ret = exe_set_command_all(mrb, mrdb, mrb_debug_delete_break_all);
+	if (ret != TRUE) {
+		exe_set_command_select(mrb, mrdb, mrb_debug_delete_break);
+	}
+
+	return DBGST_PROMPT;
+}
+
+dbgcmd_state
+dbgcmd_enable(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_bool ret = FALSE;
+
+	ret = exe_set_command_all(mrb, mrdb, mrb_debug_enable_break_all);
+	if (ret != TRUE) {
+		exe_set_command_select(mrb, mrdb, mrb_debug_enable_break);
+	}
+
+	return DBGST_PROMPT;
+}
+
+dbgcmd_state
+dbgcmd_disable(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_bool ret = FALSE;
+
+	ret = exe_set_command_all(mrb, mrdb, mrb_debug_disable_break_all);
+	if (ret != TRUE) {
+		exe_set_command_select(mrb, mrdb, mrb_debug_disable_break);
+	}
+	return DBGST_PROMPT;
+}
Index: /EcnlProtoTool/trunk/prototool/src/cmdmisc.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/cmdmisc.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/cmdmisc.c	(revision 279)
@@ -0,0 +1,483 @@
+/*
+** cmdmisc.c - mruby debugger miscellaneous command functions
+**
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "mruby/compile.h"
+#include "mrdb.h"
+
+typedef struct help_msg
+{
+	const char *cmd1;
+	const char *cmd2;
+	const char *short_msg;
+	const char *long_msg;
+} help_msg;
+
+static help_msg help_msg_list[] = {
+  {
+	"b[reak]", NULL, "Set breakpoint",
+	"Usage: break [file:]line\n"
+	"       break [class:]method\n"
+	"\n"
+	"Set breakpoint at specified line or method.\n"
+	"If \'[file:]line\' is specified, break at start of code for that line (in a file).\n"
+	"If \'[class:]method\' is specified, break at start of code for that method (of the class).\n"
+  },
+  {
+	"c[ontinue]", NULL, "Continue program being debugged",
+	"Usage: continue [N]\n"
+	"\n"
+	"Continue program stopped by a breakpoint.\n"
+	"If N, which is non negative value, is passed,\n"
+	"proceed program until the N-th breakpoint is coming.\n"
+	"If N is not passed, N is assumed 1.\n"
+  },
+  {
+	"d[elete]", NULL, "Delete some breakpoints",
+	"Usage: delete [bpno1 [bpno2 [... [bpnoN]]]]\n"
+	"\n"
+	"Delete some breakpoints.\n"
+	"Arguments are breakpoint numbers with spaces in between.\n"
+	"To delete all breakpoints, give no argument.\n"
+  },
+  {
+	"dis[able]", NULL, "Disable some breakpoints",
+	"Usage: disable [bpno1 [bpno2 [... [bpnoN]]]]\n"
+	"\n"
+	"Disable some breakpoints.\n"
+	"Arguments are breakpoint numbers with spaces in between.\n"
+	"To disable all breakpoints, give no argument.\n"
+  },
+  {
+	"en[able]", NULL, "Enable some breakpoints",
+	"Usage: enable [bpno1 [bpno2 [... [bpnoN]]]]\n"
+	"\n"
+	"Enable some breakpoints.\n"
+	"Arguments are breakpoint numbers with spaces in between.\n"
+	"To enable all breakpoints, give no argument.\n"
+  },
+  {
+	"ev[al]", NULL, "Evaluate expression",
+	"Usage: eval expr\n"
+	"\n"
+	"It evaluates and prints the value of the mruby expression.\n"
+	"This is equivalent to the \'print\' command.\n"
+  },
+  {
+	"h[elp]", NULL, "Print this help",
+	"Usage: help [command]\n"
+	"\n"
+	"With no arguments, help displays a short list of commands.\n"
+	"With a command name as help argument, help displays how to use that command.\n"
+  },
+  {
+	"i[nfo]", "b[reakpoints]", "Status of breakpoints",
+	"Usage: info breakpoints [bpno1 [bpno2 [... [bpnoN]]]]\n"
+	"\n"
+	"Status of specified breakpoints (all user-settable breakpoints if no argument).\n"
+	"Arguments are breakpoint numbers with spaces in between.\n"
+  },
+  {
+	"l[ist]", NULL, "List specified line",
+	"Usage: list\n"
+	"       list first[,last]\n"
+	"       list filename:first[,last]\n"
+	"\n"
+	"Print lines from a source file.\n"
+	"\n"
+	"With first and last, list prints lines from first to last.\n"
+	"When last is empty, it stands for ten lines away from first.\n"
+	"With filename, list prints lines in the specified source file.\n"
+  },
+  {
+	"p[rint]", NULL, "Print value of expression",
+	"Usage: print expr\n"
+	"\n"
+	"It evaluates and prints the value of the mruby expression.\n"
+	"This is equivalent to the \'eval\' command.\n"
+  },
+  {
+	"q[uit]", NULL, "Exit mrdb",
+	"Usage: quit\n"
+	"\n"
+	"Exit mrdb.\n"
+  },
+  {
+	"r[un]", NULL, "Start debugged program",
+	"Usage: run\n"
+	"\n"
+	"Start debugged program.\n"
+  },
+  {
+	"s[tep]", NULL, "Step program until it reaches a different source line",
+	"Usage: step\n"
+	"\n"
+	"Step program until it reaches a different source line.\n"
+  },
+  { NULL, NULL, NULL, NULL }
+};
+
+typedef struct listcmd_parser_state
+{
+	mrb_bool parse_error;
+	mrb_bool has_line_min;
+	mrb_bool has_line_max;
+	char *filename;
+	uint16_t line_min;
+	uint16_t line_max;
+} listcmd_parser_state;
+
+static listcmd_parser_state*
+listcmd_parser_state_new(mrb_state *mrb)
+{
+	listcmd_parser_state *st = (listcmd_parser_state *)mrb_malloc(mrb, sizeof(listcmd_parser_state));
+	memset(st, 0, sizeof(listcmd_parser_state));
+	return st;
+}
+
+static void
+listcmd_parser_state_free(mrb_state *mrb, listcmd_parser_state *st)
+{
+	if (st != NULL) {
+		if (st->filename != NULL) {
+			mrb_free(mrb, st->filename);
+		}
+		mrb_free(mrb, st);
+	}
+}
+
+static mrb_bool
+parse_uint(char **sp, uint16_t *n)
+{
+	char *p;
+	int i;
+
+	if (*sp == NULL || **sp == '\0') {
+		return FALSE;
+	}
+
+	for (p = *sp; *p != '\0' && ISDIGIT(*p); p++);
+
+	if (p != *sp && (i = atoi(*sp)) >= 0) {
+		*n = (uint16_t)i;
+		*sp = p;
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static mrb_bool
+skip_char(char **sp, char c)
+{
+	if (*sp != NULL && **sp == c) {
+		++*sp;
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static mrb_bool
+parse_lineno(mrb_state *mrb, char **sp, listcmd_parser_state *st)
+{
+	if (*sp == NULL || **sp == '\0') {
+		return FALSE;
+	}
+
+	st->has_line_min = FALSE;
+	st->has_line_max = FALSE;
+
+	if (parse_uint(sp, &st->line_min)) {
+		st->has_line_min = TRUE;
+	}
+	else {
+		return FALSE;
+	}
+
+	if (skip_char(sp, ',')) {
+		if (parse_uint(sp, &st->line_max)) {
+			st->has_line_max = TRUE;
+		}
+		else {
+			st->parse_error = TRUE;
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+static mrb_bool
+parse_filename(mrb_state *mrb, char **sp, listcmd_parser_state *st)
+{
+	char *p;
+	int len;
+
+	if (st->filename != NULL) {
+		mrb_free(mrb, st->filename);
+		st->filename = NULL;
+	}
+
+	if ((p = strchr(*sp, ':')) != NULL) {
+		len = p - *sp;
+	}
+	else {
+		len = strlen(*sp);
+	}
+
+	if (len > 0) {
+		st->filename = mrb_malloc(mrb, len + 1);
+		strlcpy(st->filename, *sp, len + 1);
+		st->filename[len] = '\0';
+		*sp += len;
+		return TRUE;
+	}
+	else {
+		return FALSE;
+	}
+}
+
+char*
+replace_ext(mrb_state *mrb, const char *filename, const char *ext)
+{
+	size_t len, len2;
+	const char *p;
+	char *s;
+
+	if (filename == NULL) {
+		return NULL;
+	}
+
+	if ((p = strrchr(filename, '.')) != NULL && strchr(p, '/') == NULL) {
+		len = p - filename;
+	}
+	else {
+		len = strlen(filename);
+	}
+
+	len2 = len + strlen(ext) + 1;
+	s = mrb_malloc(mrb, len2);
+	memset(s, '\0', len2);
+	strlcpy(s, filename, len);
+	strlcat(s, ext, len2);
+
+	return s;
+}
+
+static mrb_bool
+parse_listcmd_args(mrb_state *mrb, mrdb_state *mrdb, listcmd_parser_state *st)
+{
+	char *p;
+
+	switch (mrdb->wcnt) {
+	case 2:
+		p = mrdb->words[1];
+
+		/* mrdb->words[1] ::= <lineno> | <filename> ':' <lineno> | <filename> */
+		if (!parse_lineno(mrb, &p, st)) {
+			if (parse_filename(mrb, &p, st)) {
+				if (skip_char(&p, ':')) {
+					if (!parse_lineno(mrb, &p, st)) {
+						st->parse_error = TRUE;
+					}
+				}
+			}
+			else {
+				st->parse_error = TRUE;
+			}
+		}
+		if (*p != '\0') {
+			st->parse_error = TRUE;
+		}
+		break;
+	case 1:
+	case 0:
+		/* do nothing */
+		break;
+	default:
+		st->parse_error = TRUE;
+		printf("too many arguments\n");
+		break;
+	}
+
+	if (!st->parse_error) {
+		if (!st->has_line_min) {
+			st->line_min = (!st->filename && mrdb->dbg->prvline > 0) ? mrdb->dbg->prvline : 1;
+		}
+
+		if (!st->has_line_max) {
+			st->line_max = st->line_min + 9;
+		}
+
+		if (st->filename == NULL) {
+			if (mrdb->dbg->prvfile && strcmp(mrdb->dbg->prvfile, "-")) {
+				st->filename = replace_ext(mrb, mrdb->dbg->prvfile, ".rb");
+			}
+		}
+	}
+
+	if (st->parse_error || st->filename == NULL) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static mrb_bool
+check_cmd_pattern(const char *pattern, const char *cmd)
+{
+	const char *lbracket, *rbracket, *p, *q;
+
+	if (pattern == NULL && cmd == NULL) {
+		return TRUE;
+	}
+	if (pattern == NULL || cmd == NULL) {
+		return FALSE;
+	}
+	if ((lbracket = strchr(pattern, '[')) == NULL) {
+		return !strcmp(pattern, cmd);
+	}
+	if ((rbracket = strchr(pattern, ']')) == NULL) {
+		return FALSE;
+	}
+	if (strncmp(pattern, cmd, lbracket - pattern)) {
+		return FALSE;
+	}
+
+	p = lbracket + 1;
+	q = (char *)cmd + (lbracket - pattern);
+
+	for (; p < rbracket && *q != '\0'; p++, q++) {
+		if (*p != *q) {
+			break;
+		}
+	}
+	return *q == '\0';
+}
+
+static help_msg*
+get_help_msg(char *cmd1, char *cmd2)
+{
+	help_msg *p;
+
+	if (cmd1 == NULL) {
+		return NULL;
+	}
+	for (p = help_msg_list; p->cmd1 != NULL; p++) {
+		if (check_cmd_pattern(p->cmd1, cmd1) && check_cmd_pattern(p->cmd2, cmd2)) {
+			return p;
+		}
+	}
+	return NULL;
+}
+
+static mrb_bool
+show_short_help(void)
+{
+	help_msg *p;
+
+	printf("Commands\n");
+
+	for (p = help_msg_list; p->cmd1 != NULL; p++) {
+		if (p->cmd2 == NULL) {
+			printf("  %s -- %s\n", p->cmd1, p->short_msg);
+		}
+		else {
+			printf("  %s %s -- %s\n", p->cmd1, p->cmd2, p->short_msg);
+		}
+	}
+	return TRUE;
+}
+
+static mrb_bool
+show_long_help(char *cmd1, char *cmd2)
+{
+	help_msg *help;
+
+	if ((help = get_help_msg(cmd1, cmd2)) == NULL) {
+		return FALSE;
+	}
+	printf("%s", help->long_msg);
+	return TRUE;
+}
+
+dbgcmd_state
+dbgcmd_help(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_bool is_valid;
+	int i;
+
+	switch (mrdb->wcnt) {
+	case 0:
+	case 1:
+		is_valid = show_short_help();
+		break;
+	case 2:
+		is_valid = show_long_help(mrdb->words[1], NULL);
+		break;
+	case 3:
+		is_valid = show_long_help(mrdb->words[1], mrdb->words[2]);
+		break;
+	default:
+		is_valid = FALSE;
+		break;
+	}
+
+	if (!is_valid) {
+		printf("Invalid command \"");
+		for (i = 1; i < mrdb->wcnt; i++) {
+			printf("%s%s", i == 1 ? "" : " ", mrdb->words[i]);
+		}
+		printf("\". Try \"help\".\n");
+	}
+
+	return DBGST_PROMPT;
+}
+
+dbgcmd_state
+dbgcmd_quit(mrb_state *mrb, mrdb_state *mrdb)
+{
+	switch (mrdb->dbg->xm) {
+	case DBG_RUN:
+	case DBG_STEP:
+	case DBG_NEXT:
+		while (1) {
+			char c;
+			int buf;
+
+			printf("The program is running.  Exit anyway? (y or n) ");
+			fflush(stdout);
+
+			if ((buf = getchar()) == EOF) {
+				InterlockedExchange(&mrdb->dbg->xm, DBG_QUIT);
+				break;
+			}
+			c = buf;
+			while (buf != '\n' && (buf = getchar()) != EOF);
+
+			if (c == 'y' || c == 'Y') {
+				InterlockedExchange(&mrdb->dbg->xm, DBG_QUIT);
+				break;
+			}
+			else if (c == 'n' || c == 'N') {
+				break;
+			}
+			else {
+				printf("Please answer y or n.\n");
+			}
+		}
+		break;
+	default:
+		InterlockedExchange(&mrdb->dbg->xm, DBG_QUIT);
+		break;
+	}
+
+	if (mrdb->dbg->xm == DBG_QUIT) {
+		struct RClass *exc;
+		exc = mrb_define_class(mrb, "DebuggerExit", mrb_class_get(mrb, "Exception"));
+		mrb_raise(mrb, exc, "Exit mrdb.");
+	}
+	return DBGST_PROMPT;
+}
Index: /EcnlProtoTool/trunk/prototool/src/cmdprint.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/cmdprint.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/cmdprint.c	(revision 279)
@@ -0,0 +1,59 @@
+/*
+** cmdprint.c - mruby debugger print command functions
+**
+*/
+
+#include <stdlib.h>
+
+#include "mrdb.h"
+#include "mruby/value.h"
+#include "mruby/class.h"
+#include "mruby/compile.h"
+#include "mruby/error.h"
+#include "mruby/numeric.h"
+#include "mruby/string.h"
+#include "apiprint.h"
+
+dbgcmd_state
+dbgcmd_print(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_value expr;
+	mrb_value result;
+	mrb_value s;
+	uint8_t wcnt;
+	int ai;
+
+	if (mrdb->wcnt <= 1) {
+		puts("Parameter not specified.");
+		return DBGST_PROMPT;
+	}
+
+	ai = mrb_gc_arena_save(mrb);
+
+	/* eval expr */
+	expr = mrb_str_new_cstr(mrb, NULL);
+	for (wcnt = 1; wcnt < mrdb->wcnt; wcnt++) {
+		expr = mrb_str_cat_lit(mrb, expr, " ");
+		expr = mrb_str_cat_cstr(mrb, expr, mrdb->words[wcnt]);
+	}
+
+	result = mrb_debug_eval(mrb, mrdb->dbg, RSTRING_PTR(expr), RSTRING_LEN(expr), NULL);
+
+	/* $print_no = result */
+	s = mrb_str_cat_lit(mrb, result, "\0");
+	printf("$%lu = %s\n", (unsigned long)mrdb->print_no++, RSTRING_PTR(s));
+
+	if (mrdb->print_no == 0) {
+		mrdb->print_no = 1;
+	}
+
+	mrb_gc_arena_restore(mrb, ai);
+
+	return DBGST_PROMPT;
+}
+
+dbgcmd_state
+dbgcmd_eval(mrb_state *mrb, mrdb_state *mrdb)
+{
+	return dbgcmd_print(mrb, mrdb);
+}
Index: /EcnlProtoTool/trunk/prototool/src/cmdrun.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/cmdrun.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/cmdrun.c	(revision 279)
@@ -0,0 +1,66 @@
+/*
+** cmdrun.c - mruby debugger run command functions
+**
+*/
+
+#include <stdlib.h>
+
+#include "mruby/opcode.h"
+#include "mrdb.h"
+
+dbgcmd_state
+dbgcmd_run(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_debug_context *dbg = mrdb->dbg;
+
+	if (dbg->xm == DBG_INIT) {
+		InterlockedExchange(&dbg->xm, DBG_RUN);
+	}
+	else {
+		InterlockedExchange(&dbg->xm, DBG_QUIT);
+		if (dbg->xphase == DBG_PHASE_RUNNING) {
+			struct RClass *exc;
+			puts("Start it from the beginning.");
+			exc = mrb_define_class(mrb, "DebuggerRestart", mrb_class_get(mrb, "Exception"));
+			mrb_raise(mrb, exc, "Restart mrdb.");
+		}
+	}
+
+	return DBGST_RESTART;
+}
+
+dbgcmd_state
+dbgcmd_continue(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_debug_context *dbg = mrdb->dbg;
+	int ccnt = 1;
+
+	if (mrdb->wcnt > 1) {
+		sscanf(mrdb->words[1], "%d", &ccnt);
+	}
+	dbg->ccnt = (uint16_t)(ccnt > 0 ? ccnt : 1);  /* count of continue */
+
+	if (dbg->xphase == DBG_PHASE_AFTER_RUN) {
+		puts("The program is not running.");
+		InterlockedExchange(&dbg->xm, DBG_QUIT);
+	}
+	else {
+		InterlockedExchange(&dbg->xm, DBG_RUN);
+	}
+	return DBGST_CONTINUE;
+}
+
+dbgcmd_state
+dbgcmd_step(mrb_state *mrb, mrdb_state *mrdb)
+{
+	InterlockedExchange(&mrdb->dbg->xm, DBG_STEP);
+	return DBGST_CONTINUE;
+}
+
+dbgcmd_state
+dbgcmd_next(mrb_state *mrb, mrdb_state *mrdb)
+{
+	InterlockedExchange(&mrdb->dbg->xm, DBG_NEXT);
+	mrdb->dbg->prvci = mrb->c->ci;
+	return DBGST_CONTINUE;
+}
Index: /EcnlProtoTool/trunk/prototool/src/echo_client.rb
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/echo_client.rb	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/echo_client.rb	(revision 279)
@@ -0,0 +1,13 @@
+
+host = if ARGV[0] then ARGV[0] else 'localhost' end
+port = if ARGV[1] then ARGV[1] else 'echo' end
+sock = TCPSocket.open(host, port)
+
+while msg = STDIN.gets
+	print("you writed:", msg)
+	#socketã«æ¸ãè¾¼ã
+	sock.write(msg)
+	#ãµã¼ãããè¿ã£ã¦ããã¡ãã»ã¼ã¸ãè¡¨ç¤ºããã
+	print("return message:", sock.gets)
+end
+sock.close
Index: /EcnlProtoTool/trunk/prototool/src/echo_server.rb
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/echo_server.rb	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/echo_server.rb	(revision 279)
@@ -0,0 +1,12 @@
+
+port = if ARGV[0] then ARGV[0] else 'echo' end
+gate = TCPServer.open(port)
+
+sock = gate.accept
+gate.close
+
+while msg = sock.gets
+	sock.write(msg)
+	print("you get:", msg)
+end
+sock.close
Index: /EcnlProtoTool/trunk/prototool/src/libbb/autoconf.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/autoconf.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/autoconf.h	(revision 279)
@@ -0,0 +1,7098 @@
+/*
+ * Automatically generated C config: don't edit
+ * Busybox version: 1.26.2
+ */
+#define AUTOCONF_TIMESTAMP "2017-03-19 23:38:35 DST"
+
+#define CONFIG_HAVE_DOT_CONFIG 1
+#define ENABLE_HAVE_DOT_CONFIG 1
+#ifdef MAKE_SUID
+# define IF_HAVE_DOT_CONFIG(...) __VA_ARGS__ "CONFIG_HAVE_DOT_CONFIG"
+#else
+# define IF_HAVE_DOT_CONFIG(...) __VA_ARGS__
+#endif
+#define IF_NOT_HAVE_DOT_CONFIG(...)
+
+/*
+ * Busybox Settings
+ */
+#undef CONFIG_DESKTOP
+#define ENABLE_DESKTOP 0
+# define IF_DESKTOP(...)
+#define IF_NOT_DESKTOP(...) __VA_ARGS__
+#define CONFIG_EXTRA_COMPAT 1
+#define ENABLE_EXTRA_COMPAT 1
+#ifdef MAKE_SUID
+# define IF_EXTRA_COMPAT(...) __VA_ARGS__ "CONFIG_EXTRA_COMPAT"
+#else
+# define IF_EXTRA_COMPAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_EXTRA_COMPAT(...)
+#define CONFIG_INCLUDE_SUSv2 1
+#define ENABLE_INCLUDE_SUSv2 1
+#ifdef MAKE_SUID
+# define IF_INCLUDE_SUSv2(...) __VA_ARGS__ "CONFIG_INCLUDE_SUSv2"
+#else
+# define IF_INCLUDE_SUSv2(...) __VA_ARGS__
+#endif
+#define IF_NOT_INCLUDE_SUSv2(...)
+#undef CONFIG_USE_PORTABLE_CODE
+#define ENABLE_USE_PORTABLE_CODE 0
+#define IF_USE_PORTABLE_CODE(...)
+#define IF_NOT_USE_PORTABLE_CODE(...) __VA_ARGS__
+#define CONFIG_PLATFORM_LINUX 1
+#define ENABLE_PLATFORM_LINUX 1
+#ifdef MAKE_SUID
+# define IF_PLATFORM_LINUX(...) __VA_ARGS__ "CONFIG_PLATFORM_LINUX"
+#else
+# define IF_PLATFORM_LINUX(...) __VA_ARGS__
+#endif
+#define IF_NOT_PLATFORM_LINUX(...)
+#define CONFIG_SHOW_USAGE 1
+#define ENABLE_SHOW_USAGE 1
+#ifdef MAKE_SUID
+# define IF_SHOW_USAGE(...) __VA_ARGS__ "CONFIG_SHOW_USAGE"
+#else
+# define IF_SHOW_USAGE(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHOW_USAGE(...)
+#define CONFIG_FEATURE_VERBOSE_USAGE 1
+#define ENABLE_FEATURE_VERBOSE_USAGE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VERBOSE_USAGE(...) __VA_ARGS__ "CONFIG_FEATURE_VERBOSE_USAGE"
+#else
+# define IF_FEATURE_VERBOSE_USAGE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VERBOSE_USAGE(...)
+#define CONFIG_FEATURE_COMPRESS_USAGE 1
+#define ENABLE_FEATURE_COMPRESS_USAGE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_COMPRESS_USAGE(...) __VA_ARGS__ "CONFIG_FEATURE_COMPRESS_USAGE"
+#else
+# define IF_FEATURE_COMPRESS_USAGE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_COMPRESS_USAGE(...)
+#define CONFIG_BUSYBOX 1
+#define ENABLE_BUSYBOX 1
+#ifdef MAKE_SUID
+# define IF_BUSYBOX(...) __VA_ARGS__ "CONFIG_BUSYBOX"
+#else
+# define IF_BUSYBOX(...) __VA_ARGS__
+#endif
+#define IF_NOT_BUSYBOX(...)
+#define CONFIG_FEATURE_INSTALLER 1
+#define ENABLE_FEATURE_INSTALLER 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INSTALLER(...) __VA_ARGS__ "CONFIG_FEATURE_INSTALLER"
+#else
+# define IF_FEATURE_INSTALLER(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INSTALLER(...)
+#undef CONFIG_INSTALL_NO_USR
+#define ENABLE_INSTALL_NO_USR 0
+#define IF_INSTALL_NO_USR(...)
+#define IF_NOT_INSTALL_NO_USR(...) __VA_ARGS__
+#undef CONFIG_PAM
+#define ENABLE_PAM 0
+#define IF_PAM(...)
+#define IF_NOT_PAM(...) __VA_ARGS__
+#define CONFIG_LONG_OPTS 1
+#define ENABLE_LONG_OPTS 1
+#ifdef MAKE_SUID
+# define IF_LONG_OPTS(...) __VA_ARGS__ "CONFIG_LONG_OPTS"
+#else
+# define IF_LONG_OPTS(...) __VA_ARGS__
+#endif
+#define IF_NOT_LONG_OPTS(...)
+#define CONFIG_FEATURE_DEVPTS 1
+#define ENABLE_FEATURE_DEVPTS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DEVPTS(...) __VA_ARGS__ "CONFIG_FEATURE_DEVPTS"
+#else
+# define IF_FEATURE_DEVPTS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DEVPTS(...)
+#undef CONFIG_FEATURE_CLEAN_UP
+#define ENABLE_FEATURE_CLEAN_UP 0
+#define IF_FEATURE_CLEAN_UP(...)
+#define IF_NOT_FEATURE_CLEAN_UP(...) __VA_ARGS__
+#define CONFIG_FEATURE_UTMP 1
+#define ENABLE_FEATURE_UTMP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UTMP(...) __VA_ARGS__ "CONFIG_FEATURE_UTMP"
+#else
+# define IF_FEATURE_UTMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UTMP(...)
+#define CONFIG_FEATURE_WTMP 1
+#define ENABLE_FEATURE_WTMP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WTMP(...) __VA_ARGS__ "CONFIG_FEATURE_WTMP"
+#else
+# define IF_FEATURE_WTMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WTMP(...)
+#define CONFIG_FEATURE_PIDFILE 1
+#define ENABLE_FEATURE_PIDFILE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PIDFILE(...) __VA_ARGS__ "CONFIG_FEATURE_PIDFILE"
+#else
+# define IF_FEATURE_PIDFILE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PIDFILE(...)
+#define CONFIG_PID_FILE_PATH "/var/run"
+#define ENABLE_PID_FILE_PATH 1
+#ifdef MAKE_SUID
+# define IF_PID_FILE_PATH(...) __VA_ARGS__ "CONFIG_PID_FILE_PATH"
+#else
+# define IF_PID_FILE_PATH(...) __VA_ARGS__
+#endif
+#define IF_NOT_PID_FILE_PATH(...)
+#define CONFIG_FEATURE_SUID 1
+#define ENABLE_FEATURE_SUID 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SUID(...) __VA_ARGS__ "CONFIG_FEATURE_SUID"
+#else
+# define IF_FEATURE_SUID(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SUID(...)
+#define CONFIG_FEATURE_SUID_CONFIG 1
+#define ENABLE_FEATURE_SUID_CONFIG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SUID_CONFIG(...) __VA_ARGS__ "CONFIG_FEATURE_SUID_CONFIG"
+#else
+# define IF_FEATURE_SUID_CONFIG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SUID_CONFIG(...)
+#define CONFIG_FEATURE_SUID_CONFIG_QUIET 1
+#define ENABLE_FEATURE_SUID_CONFIG_QUIET 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SUID_CONFIG_QUIET(...) __VA_ARGS__ "CONFIG_FEATURE_SUID_CONFIG_QUIET"
+#else
+# define IF_FEATURE_SUID_CONFIG_QUIET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SUID_CONFIG_QUIET(...)
+#undef CONFIG_SELINUX
+#define ENABLE_SELINUX 0
+#define IF_SELINUX(...)
+#define IF_NOT_SELINUX(...) __VA_ARGS__
+#define CONFIG_FEATURE_PREFER_APPLETS 1
+#define ENABLE_FEATURE_PREFER_APPLETS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PREFER_APPLETS(...) __VA_ARGS__ "CONFIG_FEATURE_PREFER_APPLETS"
+#else
+# define IF_FEATURE_PREFER_APPLETS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PREFER_APPLETS(...)
+#define CONFIG_BUSYBOX_EXEC_PATH "/proc/self/exe"
+#define ENABLE_BUSYBOX_EXEC_PATH 1
+#ifdef MAKE_SUID
+# define IF_BUSYBOX_EXEC_PATH(...) __VA_ARGS__ "CONFIG_BUSYBOX_EXEC_PATH"
+#else
+# define IF_BUSYBOX_EXEC_PATH(...) __VA_ARGS__
+#endif
+#define IF_NOT_BUSYBOX_EXEC_PATH(...)
+#define CONFIG_FEATURE_SYSLOG 1
+#define ENABLE_FEATURE_SYSLOG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SYSLOG(...) __VA_ARGS__ "CONFIG_FEATURE_SYSLOG"
+#else
+# define IF_FEATURE_SYSLOG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SYSLOG(...)
+#define CONFIG_FEATURE_HAVE_RPC 1
+#define ENABLE_FEATURE_HAVE_RPC 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HAVE_RPC(...) __VA_ARGS__ "CONFIG_FEATURE_HAVE_RPC"
+#else
+# define IF_FEATURE_HAVE_RPC(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HAVE_RPC(...)
+
+/*
+ * Build Options
+ */
+#undef CONFIG_STATIC
+#define ENABLE_STATIC 0
+#define IF_STATIC(...)
+#define IF_NOT_STATIC(...) __VA_ARGS__
+#undef CONFIG_PIE
+#define ENABLE_PIE 0
+#define IF_PIE(...)
+#define IF_NOT_PIE(...) __VA_ARGS__
+#define CONFIG_NOMMU 1
+#define ENABLE_NOMMU 1
+#ifdef MAKE_SUID
+# define IF_NOMMU(...) __VA_ARGS__ "CONFIG_NOMMU"
+#else
+# define IF_NOMMU(...) __VA_ARGS__
+#endif
+#define IF_NOT_NOMMU(...)
+#undef CONFIG_BUILD_LIBBUSYBOX
+#define ENABLE_BUILD_LIBBUSYBOX 0
+#define IF_BUILD_LIBBUSYBOX(...)
+#define IF_NOT_BUILD_LIBBUSYBOX(...) __VA_ARGS__
+#undef CONFIG_FEATURE_INDIVIDUAL
+#define ENABLE_FEATURE_INDIVIDUAL 0
+#define IF_FEATURE_INDIVIDUAL(...)
+#define IF_NOT_FEATURE_INDIVIDUAL(...) __VA_ARGS__
+#undef CONFIG_FEATURE_SHARED_BUSYBOX
+#define ENABLE_FEATURE_SHARED_BUSYBOX 0
+#define IF_FEATURE_SHARED_BUSYBOX(...)
+#define IF_NOT_FEATURE_SHARED_BUSYBOX(...) __VA_ARGS__
+#define CONFIG_LFS 1
+#define ENABLE_LFS 1
+#ifdef MAKE_SUID
+# define IF_LFS(...) __VA_ARGS__ "CONFIG_LFS"
+#else
+# define IF_LFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_LFS(...)
+#define CONFIG_CROSS_COMPILER_PREFIX ""
+#define ENABLE_CROSS_COMPILER_PREFIX 1
+#ifdef MAKE_SUID
+# define IF_CROSS_COMPILER_PREFIX(...) __VA_ARGS__ "CONFIG_CROSS_COMPILER_PREFIX"
+#else
+# define IF_CROSS_COMPILER_PREFIX(...) __VA_ARGS__
+#endif
+#define IF_NOT_CROSS_COMPILER_PREFIX(...)
+#define CONFIG_SYSROOT ""
+#define ENABLE_SYSROOT 1
+#ifdef MAKE_SUID
+# define IF_SYSROOT(...) __VA_ARGS__ "CONFIG_SYSROOT"
+#else
+# define IF_SYSROOT(...) __VA_ARGS__
+#endif
+#define IF_NOT_SYSROOT(...)
+#define CONFIG_EXTRA_CFLAGS ""
+#define ENABLE_EXTRA_CFLAGS 1
+#ifdef MAKE_SUID
+# define IF_EXTRA_CFLAGS(...) __VA_ARGS__ "CONFIG_EXTRA_CFLAGS"
+#else
+# define IF_EXTRA_CFLAGS(...) __VA_ARGS__
+#endif
+#define IF_NOT_EXTRA_CFLAGS(...)
+#define CONFIG_EXTRA_LDFLAGS ""
+#define ENABLE_EXTRA_LDFLAGS 1
+#ifdef MAKE_SUID
+# define IF_EXTRA_LDFLAGS(...) __VA_ARGS__ "CONFIG_EXTRA_LDFLAGS"
+#else
+# define IF_EXTRA_LDFLAGS(...) __VA_ARGS__
+#endif
+#define IF_NOT_EXTRA_LDFLAGS(...)
+#define CONFIG_EXTRA_LDLIBS ""
+#define ENABLE_EXTRA_LDLIBS 1
+#ifdef MAKE_SUID
+# define IF_EXTRA_LDLIBS(...) __VA_ARGS__ "CONFIG_EXTRA_LDLIBS"
+#else
+# define IF_EXTRA_LDLIBS(...) __VA_ARGS__
+#endif
+#define IF_NOT_EXTRA_LDLIBS(...)
+
+/*
+ * Installation Options ("make install" behavior)
+ */
+#define CONFIG_INSTALL_APPLET_SYMLINKS 1
+#define ENABLE_INSTALL_APPLET_SYMLINKS 1
+#ifdef MAKE_SUID
+# define IF_INSTALL_APPLET_SYMLINKS(...) __VA_ARGS__ "CONFIG_INSTALL_APPLET_SYMLINKS"
+#else
+# define IF_INSTALL_APPLET_SYMLINKS(...) __VA_ARGS__
+#endif
+#define IF_NOT_INSTALL_APPLET_SYMLINKS(...)
+#undef CONFIG_INSTALL_APPLET_HARDLINKS
+#define ENABLE_INSTALL_APPLET_HARDLINKS 0
+#define IF_INSTALL_APPLET_HARDLINKS(...)
+#define IF_NOT_INSTALL_APPLET_HARDLINKS(...) __VA_ARGS__
+#undef CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS
+#define ENABLE_INSTALL_APPLET_SCRIPT_WRAPPERS 0
+#define IF_INSTALL_APPLET_SCRIPT_WRAPPERS(...)
+#define IF_NOT_INSTALL_APPLET_SCRIPT_WRAPPERS(...) __VA_ARGS__
+#undef CONFIG_INSTALL_APPLET_DONT
+#define ENABLE_INSTALL_APPLET_DONT 0
+#define IF_INSTALL_APPLET_DONT(...)
+#define IF_NOT_INSTALL_APPLET_DONT(...) __VA_ARGS__
+#undef CONFIG_INSTALL_SH_APPLET_SYMLINK
+#define ENABLE_INSTALL_SH_APPLET_SYMLINK 0
+#define IF_INSTALL_SH_APPLET_SYMLINK(...)
+#define IF_NOT_INSTALL_SH_APPLET_SYMLINK(...) __VA_ARGS__
+#undef CONFIG_INSTALL_SH_APPLET_HARDLINK
+#define ENABLE_INSTALL_SH_APPLET_HARDLINK 0
+#define IF_INSTALL_SH_APPLET_HARDLINK(...)
+#define IF_NOT_INSTALL_SH_APPLET_HARDLINK(...) __VA_ARGS__
+#undef CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER
+#define ENABLE_INSTALL_SH_APPLET_SCRIPT_WRAPPER 0
+#define IF_INSTALL_SH_APPLET_SCRIPT_WRAPPER(...)
+#define IF_NOT_INSTALL_SH_APPLET_SCRIPT_WRAPPER(...) __VA_ARGS__
+#define CONFIG_PREFIX "./_install"
+#define ENABLE_PREFIX 1
+#ifdef MAKE_SUID
+# define IF_PREFIX(...) __VA_ARGS__ "CONFIG_PREFIX"
+#else
+# define IF_PREFIX(...) __VA_ARGS__
+#endif
+#define IF_NOT_PREFIX(...)
+
+/*
+ * Debugging Options
+ */
+#undef CONFIG_DEBUG
+#define ENABLE_DEBUG 0
+#define IF_DEBUG(...)
+#define IF_NOT_DEBUG(...) __VA_ARGS__
+#undef CONFIG_DEBUG_PESSIMIZE
+#define ENABLE_DEBUG_PESSIMIZE 0
+#define IF_DEBUG_PESSIMIZE(...)
+#define IF_NOT_DEBUG_PESSIMIZE(...) __VA_ARGS__
+#undef CONFIG_DEBUG_SANITIZE
+#define ENABLE_DEBUG_SANITIZE 0
+#define IF_DEBUG_SANITIZE(...)
+#define IF_NOT_DEBUG_SANITIZE(...) __VA_ARGS__
+#undef CONFIG_UNIT_TEST
+#define ENABLE_UNIT_TEST 0
+#define IF_UNIT_TEST(...)
+#define IF_NOT_UNIT_TEST(...) __VA_ARGS__
+#undef CONFIG_WERROR
+#define ENABLE_WERROR 0
+#define IF_WERROR(...)
+#define IF_NOT_WERROR(...) __VA_ARGS__
+#define CONFIG_NO_DEBUG_LIB 1
+#define ENABLE_NO_DEBUG_LIB 1
+#ifdef MAKE_SUID
+# define IF_NO_DEBUG_LIB(...) __VA_ARGS__ "CONFIG_NO_DEBUG_LIB"
+#else
+# define IF_NO_DEBUG_LIB(...) __VA_ARGS__
+#endif
+#define IF_NOT_NO_DEBUG_LIB(...)
+#undef CONFIG_DMALLOC
+#define ENABLE_DMALLOC 0
+#define IF_DMALLOC(...)
+#define IF_NOT_DMALLOC(...) __VA_ARGS__
+#undef CONFIG_EFENCE
+#define ENABLE_EFENCE 0
+#define IF_EFENCE(...)
+#define IF_NOT_EFENCE(...) __VA_ARGS__
+
+/*
+ * Busybox Library Tuning
+ */
+#undef CONFIG_FEATURE_USE_BSS_TAIL
+#define ENABLE_FEATURE_USE_BSS_TAIL 0
+#define IF_FEATURE_USE_BSS_TAIL(...)
+#define IF_NOT_FEATURE_USE_BSS_TAIL(...) __VA_ARGS__
+#define CONFIG_FEATURE_RTMINMAX 1
+#define ENABLE_FEATURE_RTMINMAX 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_RTMINMAX(...) __VA_ARGS__ "CONFIG_FEATURE_RTMINMAX"
+#else
+# define IF_FEATURE_RTMINMAX(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_RTMINMAX(...)
+#define CONFIG_FEATURE_BUFFERS_USE_MALLOC 1
+#define ENABLE_FEATURE_BUFFERS_USE_MALLOC 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_BUFFERS_USE_MALLOC(...) __VA_ARGS__ "CONFIG_FEATURE_BUFFERS_USE_MALLOC"
+#else
+# define IF_FEATURE_BUFFERS_USE_MALLOC(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_BUFFERS_USE_MALLOC(...)
+#undef CONFIG_FEATURE_BUFFERS_GO_ON_STACK
+#define ENABLE_FEATURE_BUFFERS_GO_ON_STACK 0
+#define IF_FEATURE_BUFFERS_GO_ON_STACK(...)
+#define IF_NOT_FEATURE_BUFFERS_GO_ON_STACK(...) __VA_ARGS__
+#undef CONFIG_FEATURE_BUFFERS_GO_IN_BSS
+#define ENABLE_FEATURE_BUFFERS_GO_IN_BSS 0
+#define IF_FEATURE_BUFFERS_GO_IN_BSS(...)
+#define IF_NOT_FEATURE_BUFFERS_GO_IN_BSS(...) __VA_ARGS__
+#define CONFIG_PASSWORD_MINLEN 6
+#define ENABLE_PASSWORD_MINLEN 1
+#ifdef MAKE_SUID
+# define IF_PASSWORD_MINLEN(...) __VA_ARGS__ "CONFIG_PASSWORD_MINLEN"
+#else
+# define IF_PASSWORD_MINLEN(...) __VA_ARGS__
+#endif
+#define IF_NOT_PASSWORD_MINLEN(...)
+#define CONFIG_MD5_SMALL 1
+#define ENABLE_MD5_SMALL 1
+#ifdef MAKE_SUID
+# define IF_MD5_SMALL(...) __VA_ARGS__ "CONFIG_MD5_SMALL"
+#else
+# define IF_MD5_SMALL(...) __VA_ARGS__
+#endif
+#define IF_NOT_MD5_SMALL(...)
+#define CONFIG_SHA3_SMALL 1
+#define ENABLE_SHA3_SMALL 1
+#ifdef MAKE_SUID
+# define IF_SHA3_SMALL(...) __VA_ARGS__ "CONFIG_SHA3_SMALL"
+#else
+# define IF_SHA3_SMALL(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHA3_SMALL(...)
+#define CONFIG_FEATURE_FAST_TOP 1
+#define ENABLE_FEATURE_FAST_TOP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FAST_TOP(...) __VA_ARGS__ "CONFIG_FEATURE_FAST_TOP"
+#else
+# define IF_FEATURE_FAST_TOP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FAST_TOP(...)
+#define CONFIG_FEATURE_ETC_NETWORKS 1
+#define ENABLE_FEATURE_ETC_NETWORKS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_ETC_NETWORKS(...) __VA_ARGS__ "CONFIG_FEATURE_ETC_NETWORKS"
+#else
+# define IF_FEATURE_ETC_NETWORKS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_ETC_NETWORKS(...)
+#define CONFIG_FEATURE_USE_TERMIOS 1
+#define ENABLE_FEATURE_USE_TERMIOS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_USE_TERMIOS(...) __VA_ARGS__ "CONFIG_FEATURE_USE_TERMIOS"
+#else
+# define IF_FEATURE_USE_TERMIOS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_USE_TERMIOS(...)
+#define CONFIG_FEATURE_EDITING 1
+#define ENABLE_FEATURE_EDITING 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EDITING(...) __VA_ARGS__ "CONFIG_FEATURE_EDITING"
+#else
+# define IF_FEATURE_EDITING(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EDITING(...)
+#define CONFIG_FEATURE_EDITING_MAX_LEN 1024
+#define ENABLE_FEATURE_EDITING_MAX_LEN 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EDITING_MAX_LEN(...) __VA_ARGS__ "CONFIG_FEATURE_EDITING_MAX_LEN"
+#else
+# define IF_FEATURE_EDITING_MAX_LEN(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EDITING_MAX_LEN(...)
+#define CONFIG_FEATURE_EDITING_VI 1
+#define ENABLE_FEATURE_EDITING_VI 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EDITING_VI(...) __VA_ARGS__ "CONFIG_FEATURE_EDITING_VI"
+#else
+# define IF_FEATURE_EDITING_VI(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EDITING_VI(...)
+#define CONFIG_FEATURE_EDITING_HISTORY 15
+#define ENABLE_FEATURE_EDITING_HISTORY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EDITING_HISTORY(...) __VA_ARGS__ "CONFIG_FEATURE_EDITING_HISTORY"
+#else
+# define IF_FEATURE_EDITING_HISTORY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EDITING_HISTORY(...)
+#undef CONFIG_FEATURE_EDITING_SAVEHISTORY
+#define ENABLE_FEATURE_EDITING_SAVEHISTORY 0
+#define IF_FEATURE_EDITING_SAVEHISTORY(...)
+#define IF_NOT_FEATURE_EDITING_SAVEHISTORY(...) __VA_ARGS__
+#undef CONFIG_FEATURE_EDITING_SAVE_ON_EXIT
+#define ENABLE_FEATURE_EDITING_SAVE_ON_EXIT 0
+#define IF_FEATURE_EDITING_SAVE_ON_EXIT(...)
+#define IF_NOT_FEATURE_EDITING_SAVE_ON_EXIT(...) __VA_ARGS__
+#define CONFIG_FEATURE_REVERSE_SEARCH 1
+#define ENABLE_FEATURE_REVERSE_SEARCH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_REVERSE_SEARCH(...) __VA_ARGS__ "CONFIG_FEATURE_REVERSE_SEARCH"
+#else
+# define IF_FEATURE_REVERSE_SEARCH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_REVERSE_SEARCH(...)
+#define CONFIG_FEATURE_TAB_COMPLETION 1
+#define ENABLE_FEATURE_TAB_COMPLETION 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAB_COMPLETION(...) __VA_ARGS__ "CONFIG_FEATURE_TAB_COMPLETION"
+#else
+# define IF_FEATURE_TAB_COMPLETION(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAB_COMPLETION(...)
+#define CONFIG_FEATURE_USERNAME_COMPLETION 1
+#define ENABLE_FEATURE_USERNAME_COMPLETION 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_USERNAME_COMPLETION(...) __VA_ARGS__ "CONFIG_FEATURE_USERNAME_COMPLETION"
+#else
+# define IF_FEATURE_USERNAME_COMPLETION(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_USERNAME_COMPLETION(...)
+#define CONFIG_FEATURE_EDITING_FANCY_PROMPT 1
+#define ENABLE_FEATURE_EDITING_FANCY_PROMPT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EDITING_FANCY_PROMPT(...) __VA_ARGS__ "CONFIG_FEATURE_EDITING_FANCY_PROMPT"
+#else
+# define IF_FEATURE_EDITING_FANCY_PROMPT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EDITING_FANCY_PROMPT(...)
+#define CONFIG_FEATURE_EDITING_ASK_TERMINAL 1
+#define ENABLE_FEATURE_EDITING_ASK_TERMINAL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EDITING_ASK_TERMINAL(...) __VA_ARGS__ "CONFIG_FEATURE_EDITING_ASK_TERMINAL"
+#else
+# define IF_FEATURE_EDITING_ASK_TERMINAL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EDITING_ASK_TERMINAL(...)
+#undef CONFIG_LOCALE_SUPPORT
+#define ENABLE_LOCALE_SUPPORT 0
+#define IF_LOCALE_SUPPORT(...)
+#define IF_NOT_LOCALE_SUPPORT(...) __VA_ARGS__
+#undef CONFIG_UNICODE_SUPPORT
+#define ENABLE_UNICODE_SUPPORT 0
+#define IF_UNICODE_SUPPORT(...)
+#define IF_NOT_UNICODE_SUPPORT(...) __VA_ARGS__
+#undef CONFIG_UNICODE_USING_LOCALE
+#define ENABLE_UNICODE_USING_LOCALE 0
+#define IF_UNICODE_USING_LOCALE(...)
+#define IF_NOT_UNICODE_USING_LOCALE(...) __VA_ARGS__
+#undef CONFIG_FEATURE_CHECK_UNICODE_IN_ENV
+#define ENABLE_FEATURE_CHECK_UNICODE_IN_ENV 0
+#define IF_FEATURE_CHECK_UNICODE_IN_ENV(...)
+#define IF_NOT_FEATURE_CHECK_UNICODE_IN_ENV(...) __VA_ARGS__
+#define CONFIG_SUBST_WCHAR 0
+#define ENABLE_SUBST_WCHAR 1
+#ifdef MAKE_SUID
+# define IF_SUBST_WCHAR(...) __VA_ARGS__ "CONFIG_SUBST_WCHAR"
+#else
+# define IF_SUBST_WCHAR(...) __VA_ARGS__
+#endif
+#define IF_NOT_SUBST_WCHAR(...)
+#define CONFIG_LAST_SUPPORTED_WCHAR 0
+#define ENABLE_LAST_SUPPORTED_WCHAR 1
+#ifdef MAKE_SUID
+# define IF_LAST_SUPPORTED_WCHAR(...) __VA_ARGS__ "CONFIG_LAST_SUPPORTED_WCHAR"
+#else
+# define IF_LAST_SUPPORTED_WCHAR(...) __VA_ARGS__
+#endif
+#define IF_NOT_LAST_SUPPORTED_WCHAR(...)
+#undef CONFIG_UNICODE_COMBINING_WCHARS
+#define ENABLE_UNICODE_COMBINING_WCHARS 0
+#define IF_UNICODE_COMBINING_WCHARS(...)
+#define IF_NOT_UNICODE_COMBINING_WCHARS(...) __VA_ARGS__
+#undef CONFIG_UNICODE_WIDE_WCHARS
+#define ENABLE_UNICODE_WIDE_WCHARS 0
+#define IF_UNICODE_WIDE_WCHARS(...)
+#define IF_NOT_UNICODE_WIDE_WCHARS(...) __VA_ARGS__
+#undef CONFIG_UNICODE_BIDI_SUPPORT
+#define ENABLE_UNICODE_BIDI_SUPPORT 0
+#define IF_UNICODE_BIDI_SUPPORT(...)
+#define IF_NOT_UNICODE_BIDI_SUPPORT(...) __VA_ARGS__
+#undef CONFIG_UNICODE_NEUTRAL_TABLE
+#define ENABLE_UNICODE_NEUTRAL_TABLE 0
+#define IF_UNICODE_NEUTRAL_TABLE(...)
+#define IF_NOT_UNICODE_NEUTRAL_TABLE(...) __VA_ARGS__
+#undef CONFIG_UNICODE_PRESERVE_BROKEN
+#define ENABLE_UNICODE_PRESERVE_BROKEN 0
+#define IF_UNICODE_PRESERVE_BROKEN(...)
+#define IF_NOT_UNICODE_PRESERVE_BROKEN(...) __VA_ARGS__
+#define CONFIG_FEATURE_NON_POSIX_CP 1
+#define ENABLE_FEATURE_NON_POSIX_CP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_NON_POSIX_CP(...) __VA_ARGS__ "CONFIG_FEATURE_NON_POSIX_CP"
+#else
+# define IF_FEATURE_NON_POSIX_CP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_NON_POSIX_CP(...)
+#define CONFIG_FEATURE_VERBOSE_CP_MESSAGE 1
+#define ENABLE_FEATURE_VERBOSE_CP_MESSAGE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VERBOSE_CP_MESSAGE(...) __VA_ARGS__ "CONFIG_FEATURE_VERBOSE_CP_MESSAGE"
+#else
+# define IF_FEATURE_VERBOSE_CP_MESSAGE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VERBOSE_CP_MESSAGE(...)
+#undef CONFIG_FEATURE_USE_SENDFILE
+#define ENABLE_FEATURE_USE_SENDFILE 0
+#define IF_FEATURE_USE_SENDFILE(...)
+#define IF_NOT_FEATURE_USE_SENDFILE(...) __VA_ARGS__
+#define CONFIG_FEATURE_COPYBUF_KB 1
+#define ENABLE_FEATURE_COPYBUF_KB 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_COPYBUF_KB(...) __VA_ARGS__ "CONFIG_FEATURE_COPYBUF_KB"
+#else
+# define IF_FEATURE_COPYBUF_KB(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_COPYBUF_KB(...)
+#define CONFIG_FEATURE_SKIP_ROOTFS 1
+#define ENABLE_FEATURE_SKIP_ROOTFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SKIP_ROOTFS(...) __VA_ARGS__ "CONFIG_FEATURE_SKIP_ROOTFS"
+#else
+# define IF_FEATURE_SKIP_ROOTFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SKIP_ROOTFS(...)
+#undef CONFIG_MONOTONIC_SYSCALL
+#define ENABLE_MONOTONIC_SYSCALL 0
+#define IF_MONOTONIC_SYSCALL(...)
+#define IF_NOT_MONOTONIC_SYSCALL(...) __VA_ARGS__
+#define CONFIG_IOCTL_HEX2STR_ERROR 1
+#define ENABLE_IOCTL_HEX2STR_ERROR 1
+#ifdef MAKE_SUID
+# define IF_IOCTL_HEX2STR_ERROR(...) __VA_ARGS__ "CONFIG_IOCTL_HEX2STR_ERROR"
+#else
+# define IF_IOCTL_HEX2STR_ERROR(...) __VA_ARGS__
+#endif
+#define IF_NOT_IOCTL_HEX2STR_ERROR(...)
+#define CONFIG_FEATURE_HWIB 1
+#define ENABLE_FEATURE_HWIB 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HWIB(...) __VA_ARGS__ "CONFIG_FEATURE_HWIB"
+#else
+# define IF_FEATURE_HWIB(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HWIB(...)
+
+/*
+ * Applets
+ */
+
+/*
+ * Archival Utilities
+ */
+#define CONFIG_FEATURE_SEAMLESS_XZ 1
+#define ENABLE_FEATURE_SEAMLESS_XZ 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SEAMLESS_XZ(...) __VA_ARGS__ "CONFIG_FEATURE_SEAMLESS_XZ"
+#else
+# define IF_FEATURE_SEAMLESS_XZ(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SEAMLESS_XZ(...)
+#define CONFIG_FEATURE_SEAMLESS_LZMA 1
+#define ENABLE_FEATURE_SEAMLESS_LZMA 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SEAMLESS_LZMA(...) __VA_ARGS__ "CONFIG_FEATURE_SEAMLESS_LZMA"
+#else
+# define IF_FEATURE_SEAMLESS_LZMA(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SEAMLESS_LZMA(...)
+#define CONFIG_FEATURE_SEAMLESS_BZ2 1
+#define ENABLE_FEATURE_SEAMLESS_BZ2 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SEAMLESS_BZ2(...) __VA_ARGS__ "CONFIG_FEATURE_SEAMLESS_BZ2"
+#else
+# define IF_FEATURE_SEAMLESS_BZ2(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SEAMLESS_BZ2(...)
+#define CONFIG_FEATURE_SEAMLESS_GZ 1
+#define ENABLE_FEATURE_SEAMLESS_GZ 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SEAMLESS_GZ(...) __VA_ARGS__ "CONFIG_FEATURE_SEAMLESS_GZ"
+#else
+# define IF_FEATURE_SEAMLESS_GZ(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SEAMLESS_GZ(...)
+#define CONFIG_FEATURE_SEAMLESS_Z 1
+#define ENABLE_FEATURE_SEAMLESS_Z 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SEAMLESS_Z(...) __VA_ARGS__ "CONFIG_FEATURE_SEAMLESS_Z"
+#else
+# define IF_FEATURE_SEAMLESS_Z(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SEAMLESS_Z(...)
+#define CONFIG_AR 1
+#define ENABLE_AR 1
+#ifdef MAKE_SUID
+# define IF_AR(...) __VA_ARGS__ "CONFIG_AR"
+#else
+# define IF_AR(...) __VA_ARGS__
+#endif
+#define IF_NOT_AR(...)
+#define CONFIG_FEATURE_AR_LONG_FILENAMES 1
+#define ENABLE_FEATURE_AR_LONG_FILENAMES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_AR_LONG_FILENAMES(...) __VA_ARGS__ "CONFIG_FEATURE_AR_LONG_FILENAMES"
+#else
+# define IF_FEATURE_AR_LONG_FILENAMES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_AR_LONG_FILENAMES(...)
+#define CONFIG_FEATURE_AR_CREATE 1
+#define ENABLE_FEATURE_AR_CREATE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_AR_CREATE(...) __VA_ARGS__ "CONFIG_FEATURE_AR_CREATE"
+#else
+# define IF_FEATURE_AR_CREATE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_AR_CREATE(...)
+#define CONFIG_UNCOMPRESS 1
+#define ENABLE_UNCOMPRESS 1
+#ifdef MAKE_SUID
+# define IF_UNCOMPRESS(...) __VA_ARGS__ "CONFIG_UNCOMPRESS"
+#else
+# define IF_UNCOMPRESS(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNCOMPRESS(...)
+#define CONFIG_GUNZIP 1
+#define ENABLE_GUNZIP 1
+#ifdef MAKE_SUID
+# define IF_GUNZIP(...) __VA_ARGS__ "CONFIG_GUNZIP"
+#else
+# define IF_GUNZIP(...) __VA_ARGS__
+#endif
+#define IF_NOT_GUNZIP(...)
+#define CONFIG_ZCAT 1
+#define ENABLE_ZCAT 1
+#ifdef MAKE_SUID
+# define IF_ZCAT(...) __VA_ARGS__ "CONFIG_ZCAT"
+#else
+# define IF_ZCAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_ZCAT(...)
+#define CONFIG_FEATURE_GUNZIP_LONG_OPTIONS 1
+#define ENABLE_FEATURE_GUNZIP_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_GUNZIP_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_GUNZIP_LONG_OPTIONS"
+#else
+# define IF_FEATURE_GUNZIP_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_GUNZIP_LONG_OPTIONS(...)
+#define CONFIG_BUNZIP2 1
+#define ENABLE_BUNZIP2 1
+#ifdef MAKE_SUID
+# define IF_BUNZIP2(...) __VA_ARGS__ "CONFIG_BUNZIP2"
+#else
+# define IF_BUNZIP2(...) __VA_ARGS__
+#endif
+#define IF_NOT_BUNZIP2(...)
+#define CONFIG_BZCAT 1
+#define ENABLE_BZCAT 1
+#ifdef MAKE_SUID
+# define IF_BZCAT(...) __VA_ARGS__ "CONFIG_BZCAT"
+#else
+# define IF_BZCAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_BZCAT(...)
+#define CONFIG_UNLZMA 1
+#define ENABLE_UNLZMA 1
+#ifdef MAKE_SUID
+# define IF_UNLZMA(...) __VA_ARGS__ "CONFIG_UNLZMA"
+#else
+# define IF_UNLZMA(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNLZMA(...)
+#define CONFIG_LZCAT 1
+#define ENABLE_LZCAT 1
+#ifdef MAKE_SUID
+# define IF_LZCAT(...) __VA_ARGS__ "CONFIG_LZCAT"
+#else
+# define IF_LZCAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_LZCAT(...)
+#define CONFIG_LZMA 1
+#define ENABLE_LZMA 1
+#ifdef MAKE_SUID
+# define IF_LZMA(...) __VA_ARGS__ "CONFIG_LZMA"
+#else
+# define IF_LZMA(...) __VA_ARGS__
+#endif
+#define IF_NOT_LZMA(...)
+#define CONFIG_FEATURE_LZMA_FAST 1
+#define ENABLE_FEATURE_LZMA_FAST 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LZMA_FAST(...) __VA_ARGS__ "CONFIG_FEATURE_LZMA_FAST"
+#else
+# define IF_FEATURE_LZMA_FAST(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LZMA_FAST(...)
+#define CONFIG_UNXZ 1
+#define ENABLE_UNXZ 1
+#ifdef MAKE_SUID
+# define IF_UNXZ(...) __VA_ARGS__ "CONFIG_UNXZ"
+#else
+# define IF_UNXZ(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNXZ(...)
+#define CONFIG_XZCAT 1
+#define ENABLE_XZCAT 1
+#ifdef MAKE_SUID
+# define IF_XZCAT(...) __VA_ARGS__ "CONFIG_XZCAT"
+#else
+# define IF_XZCAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_XZCAT(...)
+#define CONFIG_XZ 1
+#define ENABLE_XZ 1
+#ifdef MAKE_SUID
+# define IF_XZ(...) __VA_ARGS__ "CONFIG_XZ"
+#else
+# define IF_XZ(...) __VA_ARGS__
+#endif
+#define IF_NOT_XZ(...)
+#define CONFIG_BZIP2 1
+#define ENABLE_BZIP2 1
+#ifdef MAKE_SUID
+# define IF_BZIP2(...) __VA_ARGS__ "CONFIG_BZIP2"
+#else
+# define IF_BZIP2(...) __VA_ARGS__
+#endif
+#define IF_NOT_BZIP2(...)
+#define CONFIG_CPIO 1
+#define ENABLE_CPIO 1
+#ifdef MAKE_SUID
+# define IF_CPIO(...) __VA_ARGS__ "CONFIG_CPIO"
+#else
+# define IF_CPIO(...) __VA_ARGS__
+#endif
+#define IF_NOT_CPIO(...)
+#define CONFIG_FEATURE_CPIO_O 1
+#define ENABLE_FEATURE_CPIO_O 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CPIO_O(...) __VA_ARGS__ "CONFIG_FEATURE_CPIO_O"
+#else
+# define IF_FEATURE_CPIO_O(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CPIO_O(...)
+#define CONFIG_FEATURE_CPIO_P 1
+#define ENABLE_FEATURE_CPIO_P 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CPIO_P(...) __VA_ARGS__ "CONFIG_FEATURE_CPIO_P"
+#else
+# define IF_FEATURE_CPIO_P(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CPIO_P(...)
+#define CONFIG_DPKG 1
+#define ENABLE_DPKG 1
+#ifdef MAKE_SUID
+# define IF_DPKG(...) __VA_ARGS__ "CONFIG_DPKG"
+#else
+# define IF_DPKG(...) __VA_ARGS__
+#endif
+#define IF_NOT_DPKG(...)
+#define CONFIG_DPKG_DEB 1
+#define ENABLE_DPKG_DEB 1
+#ifdef MAKE_SUID
+# define IF_DPKG_DEB(...) __VA_ARGS__ "CONFIG_DPKG_DEB"
+#else
+# define IF_DPKG_DEB(...) __VA_ARGS__
+#endif
+#define IF_NOT_DPKG_DEB(...)
+#define CONFIG_GZIP 1
+#define ENABLE_GZIP 1
+#ifdef MAKE_SUID
+# define IF_GZIP(...) __VA_ARGS__ "CONFIG_GZIP"
+#else
+# define IF_GZIP(...) __VA_ARGS__
+#endif
+#define IF_NOT_GZIP(...)
+#define CONFIG_FEATURE_GZIP_LONG_OPTIONS 1
+#define ENABLE_FEATURE_GZIP_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_GZIP_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_GZIP_LONG_OPTIONS"
+#else
+# define IF_FEATURE_GZIP_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_GZIP_LONG_OPTIONS(...)
+#define CONFIG_GZIP_FAST 0
+#define ENABLE_GZIP_FAST 1
+#ifdef MAKE_SUID
+# define IF_GZIP_FAST(...) __VA_ARGS__ "CONFIG_GZIP_FAST"
+#else
+# define IF_GZIP_FAST(...) __VA_ARGS__
+#endif
+#define IF_NOT_GZIP_FAST(...)
+#undef CONFIG_FEATURE_GZIP_LEVELS
+#define ENABLE_FEATURE_GZIP_LEVELS 0
+#define IF_FEATURE_GZIP_LEVELS(...)
+#define IF_NOT_FEATURE_GZIP_LEVELS(...) __VA_ARGS__
+#define CONFIG_LZOP 1
+#define ENABLE_LZOP 1
+#ifdef MAKE_SUID
+# define IF_LZOP(...) __VA_ARGS__ "CONFIG_LZOP"
+#else
+# define IF_LZOP(...) __VA_ARGS__
+#endif
+#define IF_NOT_LZOP(...)
+#define CONFIG_UNLZOP 1
+#define ENABLE_UNLZOP 1
+#ifdef MAKE_SUID
+# define IF_UNLZOP(...) __VA_ARGS__ "CONFIG_UNLZOP"
+#else
+# define IF_UNLZOP(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNLZOP(...)
+#define CONFIG_LZOPCAT 1
+#define ENABLE_LZOPCAT 1
+#ifdef MAKE_SUID
+# define IF_LZOPCAT(...) __VA_ARGS__ "CONFIG_LZOPCAT"
+#else
+# define IF_LZOPCAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_LZOPCAT(...)
+#define CONFIG_LZOP_COMPR_HIGH 1
+#define ENABLE_LZOP_COMPR_HIGH 1
+#ifdef MAKE_SUID
+# define IF_LZOP_COMPR_HIGH(...) __VA_ARGS__ "CONFIG_LZOP_COMPR_HIGH"
+#else
+# define IF_LZOP_COMPR_HIGH(...) __VA_ARGS__
+#endif
+#define IF_NOT_LZOP_COMPR_HIGH(...)
+#define CONFIG_RPM 1
+#define ENABLE_RPM 1
+#ifdef MAKE_SUID
+# define IF_RPM(...) __VA_ARGS__ "CONFIG_RPM"
+#else
+# define IF_RPM(...) __VA_ARGS__
+#endif
+#define IF_NOT_RPM(...)
+#define CONFIG_RPM2CPIO 1
+#define ENABLE_RPM2CPIO 1
+#ifdef MAKE_SUID
+# define IF_RPM2CPIO(...) __VA_ARGS__ "CONFIG_RPM2CPIO"
+#else
+# define IF_RPM2CPIO(...) __VA_ARGS__
+#endif
+#define IF_NOT_RPM2CPIO(...)
+#define CONFIG_TAR 1
+#define ENABLE_TAR 1
+#ifdef MAKE_SUID
+# define IF_TAR(...) __VA_ARGS__ "CONFIG_TAR"
+#else
+# define IF_TAR(...) __VA_ARGS__
+#endif
+#define IF_NOT_TAR(...)
+#define CONFIG_FEATURE_TAR_CREATE 1
+#define ENABLE_FEATURE_TAR_CREATE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_CREATE(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_CREATE"
+#else
+# define IF_FEATURE_TAR_CREATE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_CREATE(...)
+#define CONFIG_FEATURE_TAR_AUTODETECT 1
+#define ENABLE_FEATURE_TAR_AUTODETECT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_AUTODETECT(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_AUTODETECT"
+#else
+# define IF_FEATURE_TAR_AUTODETECT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_AUTODETECT(...)
+#define CONFIG_FEATURE_TAR_FROM 1
+#define ENABLE_FEATURE_TAR_FROM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_FROM(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_FROM"
+#else
+# define IF_FEATURE_TAR_FROM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_FROM(...)
+#define CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY 1
+#define ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_OLDGNU_COMPATIBILITY(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY"
+#else
+# define IF_FEATURE_TAR_OLDGNU_COMPATIBILITY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_OLDGNU_COMPATIBILITY(...)
+#define CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY 1
+#define ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY"
+#else
+# define IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_OLDSUN_COMPATIBILITY(...)
+#define CONFIG_FEATURE_TAR_GNU_EXTENSIONS 1
+#define ENABLE_FEATURE_TAR_GNU_EXTENSIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_GNU_EXTENSIONS(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_GNU_EXTENSIONS"
+#else
+# define IF_FEATURE_TAR_GNU_EXTENSIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_GNU_EXTENSIONS(...)
+#define CONFIG_FEATURE_TAR_LONG_OPTIONS 1
+#define ENABLE_FEATURE_TAR_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_LONG_OPTIONS"
+#else
+# define IF_FEATURE_TAR_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_LONG_OPTIONS(...)
+#define CONFIG_FEATURE_TAR_TO_COMMAND 1
+#define ENABLE_FEATURE_TAR_TO_COMMAND 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_TO_COMMAND(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_TO_COMMAND"
+#else
+# define IF_FEATURE_TAR_TO_COMMAND(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_TO_COMMAND(...)
+#define CONFIG_FEATURE_TAR_UNAME_GNAME 1
+#define ENABLE_FEATURE_TAR_UNAME_GNAME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_UNAME_GNAME(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_UNAME_GNAME"
+#else
+# define IF_FEATURE_TAR_UNAME_GNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_UNAME_GNAME(...)
+#define CONFIG_FEATURE_TAR_NOPRESERVE_TIME 1
+#define ENABLE_FEATURE_TAR_NOPRESERVE_TIME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TAR_NOPRESERVE_TIME(...) __VA_ARGS__ "CONFIG_FEATURE_TAR_NOPRESERVE_TIME"
+#else
+# define IF_FEATURE_TAR_NOPRESERVE_TIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TAR_NOPRESERVE_TIME(...)
+#undef CONFIG_FEATURE_TAR_SELINUX
+#define ENABLE_FEATURE_TAR_SELINUX 0
+#define IF_FEATURE_TAR_SELINUX(...)
+#define IF_NOT_FEATURE_TAR_SELINUX(...) __VA_ARGS__
+#define CONFIG_UNZIP 1
+#define ENABLE_UNZIP 1
+#ifdef MAKE_SUID
+# define IF_UNZIP(...) __VA_ARGS__ "CONFIG_UNZIP"
+#else
+# define IF_UNZIP(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNZIP(...)
+
+/*
+ * Coreutils
+ */
+#define CONFIG_BASENAME 1
+#define ENABLE_BASENAME 1
+#ifdef MAKE_SUID
+# define IF_BASENAME(...) __VA_ARGS__ "CONFIG_BASENAME"
+#else
+# define IF_BASENAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_BASENAME(...)
+#define CONFIG_CAL 1
+#define ENABLE_CAL 1
+#ifdef MAKE_SUID
+# define IF_CAL(...) __VA_ARGS__ "CONFIG_CAL"
+#else
+# define IF_CAL(...) __VA_ARGS__
+#endif
+#define IF_NOT_CAL(...)
+#define CONFIG_CAT 1
+#define ENABLE_CAT 1
+#ifdef MAKE_SUID
+# define IF_CAT(...) __VA_ARGS__ "CONFIG_CAT"
+#else
+# define IF_CAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_CAT(...)
+#define CONFIG_CATV 1
+#define ENABLE_CATV 1
+#ifdef MAKE_SUID
+# define IF_CATV(...) __VA_ARGS__ "CONFIG_CATV"
+#else
+# define IF_CATV(...) __VA_ARGS__
+#endif
+#define IF_NOT_CATV(...)
+#define CONFIG_CHGRP 1
+#define ENABLE_CHGRP 1
+#ifdef MAKE_SUID
+# define IF_CHGRP(...) __VA_ARGS__ "CONFIG_CHGRP"
+#else
+# define IF_CHGRP(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHGRP(...)
+#define CONFIG_CHMOD 1
+#define ENABLE_CHMOD 1
+#ifdef MAKE_SUID
+# define IF_CHMOD(...) __VA_ARGS__ "CONFIG_CHMOD"
+#else
+# define IF_CHMOD(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHMOD(...)
+#define CONFIG_CHOWN 1
+#define ENABLE_CHOWN 1
+#ifdef MAKE_SUID
+# define IF_CHOWN(...) __VA_ARGS__ "CONFIG_CHOWN"
+#else
+# define IF_CHOWN(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHOWN(...)
+#define CONFIG_FEATURE_CHOWN_LONG_OPTIONS 1
+#define ENABLE_FEATURE_CHOWN_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHOWN_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_CHOWN_LONG_OPTIONS"
+#else
+# define IF_FEATURE_CHOWN_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHOWN_LONG_OPTIONS(...)
+#define CONFIG_CHROOT 1
+#define ENABLE_CHROOT 1
+#ifdef MAKE_SUID
+# define IF_CHROOT(...) __VA_ARGS__ "CONFIG_CHROOT"
+#else
+# define IF_CHROOT(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHROOT(...)
+#define CONFIG_CKSUM 1
+#define ENABLE_CKSUM 1
+#ifdef MAKE_SUID
+# define IF_CKSUM(...) __VA_ARGS__ "CONFIG_CKSUM"
+#else
+# define IF_CKSUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_CKSUM(...)
+#define CONFIG_COMM 1
+#define ENABLE_COMM 1
+#ifdef MAKE_SUID
+# define IF_COMM(...) __VA_ARGS__ "CONFIG_COMM"
+#else
+# define IF_COMM(...) __VA_ARGS__
+#endif
+#define IF_NOT_COMM(...)
+#define CONFIG_CP 1
+#define ENABLE_CP 1
+#ifdef MAKE_SUID
+# define IF_CP(...) __VA_ARGS__ "CONFIG_CP"
+#else
+# define IF_CP(...) __VA_ARGS__
+#endif
+#define IF_NOT_CP(...)
+#define CONFIG_FEATURE_CP_LONG_OPTIONS 1
+#define ENABLE_FEATURE_CP_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CP_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_CP_LONG_OPTIONS"
+#else
+# define IF_FEATURE_CP_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CP_LONG_OPTIONS(...)
+#define CONFIG_CUT 1
+#define ENABLE_CUT 1
+#ifdef MAKE_SUID
+# define IF_CUT(...) __VA_ARGS__ "CONFIG_CUT"
+#else
+# define IF_CUT(...) __VA_ARGS__
+#endif
+#define IF_NOT_CUT(...)
+#define CONFIG_DATE 1
+#define ENABLE_DATE 1
+#ifdef MAKE_SUID
+# define IF_DATE(...) __VA_ARGS__ "CONFIG_DATE"
+#else
+# define IF_DATE(...) __VA_ARGS__
+#endif
+#define IF_NOT_DATE(...)
+#define CONFIG_FEATURE_DATE_ISOFMT 1
+#define ENABLE_FEATURE_DATE_ISOFMT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DATE_ISOFMT(...) __VA_ARGS__ "CONFIG_FEATURE_DATE_ISOFMT"
+#else
+# define IF_FEATURE_DATE_ISOFMT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DATE_ISOFMT(...)
+#undef CONFIG_FEATURE_DATE_NANO
+#define ENABLE_FEATURE_DATE_NANO 0
+#define IF_FEATURE_DATE_NANO(...)
+#define IF_NOT_FEATURE_DATE_NANO(...) __VA_ARGS__
+#define CONFIG_FEATURE_DATE_COMPAT 1
+#define ENABLE_FEATURE_DATE_COMPAT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DATE_COMPAT(...) __VA_ARGS__ "CONFIG_FEATURE_DATE_COMPAT"
+#else
+# define IF_FEATURE_DATE_COMPAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DATE_COMPAT(...)
+#define CONFIG_DD 1
+#define ENABLE_DD 1
+#ifdef MAKE_SUID
+# define IF_DD(...) __VA_ARGS__ "CONFIG_DD"
+#else
+# define IF_DD(...) __VA_ARGS__
+#endif
+#define IF_NOT_DD(...)
+#define CONFIG_FEATURE_DD_SIGNAL_HANDLING 1
+#define ENABLE_FEATURE_DD_SIGNAL_HANDLING 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DD_SIGNAL_HANDLING(...) __VA_ARGS__ "CONFIG_FEATURE_DD_SIGNAL_HANDLING"
+#else
+# define IF_FEATURE_DD_SIGNAL_HANDLING(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DD_SIGNAL_HANDLING(...)
+#define CONFIG_FEATURE_DD_THIRD_STATUS_LINE 1
+#define ENABLE_FEATURE_DD_THIRD_STATUS_LINE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DD_THIRD_STATUS_LINE(...) __VA_ARGS__ "CONFIG_FEATURE_DD_THIRD_STATUS_LINE"
+#else
+# define IF_FEATURE_DD_THIRD_STATUS_LINE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DD_THIRD_STATUS_LINE(...)
+#define CONFIG_FEATURE_DD_IBS_OBS 1
+#define ENABLE_FEATURE_DD_IBS_OBS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DD_IBS_OBS(...) __VA_ARGS__ "CONFIG_FEATURE_DD_IBS_OBS"
+#else
+# define IF_FEATURE_DD_IBS_OBS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DD_IBS_OBS(...)
+#define CONFIG_FEATURE_DD_STATUS 1
+#define ENABLE_FEATURE_DD_STATUS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DD_STATUS(...) __VA_ARGS__ "CONFIG_FEATURE_DD_STATUS"
+#else
+# define IF_FEATURE_DD_STATUS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DD_STATUS(...)
+#define CONFIG_DF 1
+#define ENABLE_DF 1
+#ifdef MAKE_SUID
+# define IF_DF(...) __VA_ARGS__ "CONFIG_DF"
+#else
+# define IF_DF(...) __VA_ARGS__
+#endif
+#define IF_NOT_DF(...)
+#define CONFIG_FEATURE_DF_FANCY 1
+#define ENABLE_FEATURE_DF_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DF_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_DF_FANCY"
+#else
+# define IF_FEATURE_DF_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DF_FANCY(...)
+#define CONFIG_DIRNAME 1
+#define ENABLE_DIRNAME 1
+#ifdef MAKE_SUID
+# define IF_DIRNAME(...) __VA_ARGS__ "CONFIG_DIRNAME"
+#else
+# define IF_DIRNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_DIRNAME(...)
+#define CONFIG_DOS2UNIX 1
+#define ENABLE_DOS2UNIX 1
+#ifdef MAKE_SUID
+# define IF_DOS2UNIX(...) __VA_ARGS__ "CONFIG_DOS2UNIX"
+#else
+# define IF_DOS2UNIX(...) __VA_ARGS__
+#endif
+#define IF_NOT_DOS2UNIX(...)
+#define CONFIG_UNIX2DOS 1
+#define ENABLE_UNIX2DOS 1
+#ifdef MAKE_SUID
+# define IF_UNIX2DOS(...) __VA_ARGS__ "CONFIG_UNIX2DOS"
+#else
+# define IF_UNIX2DOS(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNIX2DOS(...)
+#define CONFIG_DU 1
+#define ENABLE_DU 1
+#ifdef MAKE_SUID
+# define IF_DU(...) __VA_ARGS__ "CONFIG_DU"
+#else
+# define IF_DU(...) __VA_ARGS__
+#endif
+#define IF_NOT_DU(...)
+#define CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K 1
+#define ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(...) __VA_ARGS__ "CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K"
+#else
+# define IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(...)
+#define CONFIG_ECHO 1
+#define ENABLE_ECHO 1
+#ifdef MAKE_SUID
+# define IF_ECHO(...) __VA_ARGS__ "CONFIG_ECHO"
+#else
+# define IF_ECHO(...) __VA_ARGS__
+#endif
+#define IF_NOT_ECHO(...)
+#define CONFIG_FEATURE_FANCY_ECHO 1
+#define ENABLE_FEATURE_FANCY_ECHO 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FANCY_ECHO(...) __VA_ARGS__ "CONFIG_FEATURE_FANCY_ECHO"
+#else
+# define IF_FEATURE_FANCY_ECHO(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FANCY_ECHO(...)
+#define CONFIG_ENV 1
+#define ENABLE_ENV 1
+#ifdef MAKE_SUID
+# define IF_ENV(...) __VA_ARGS__ "CONFIG_ENV"
+#else
+# define IF_ENV(...) __VA_ARGS__
+#endif
+#define IF_NOT_ENV(...)
+#define CONFIG_FEATURE_ENV_LONG_OPTIONS 1
+#define ENABLE_FEATURE_ENV_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_ENV_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_ENV_LONG_OPTIONS"
+#else
+# define IF_FEATURE_ENV_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_ENV_LONG_OPTIONS(...)
+#define CONFIG_EXPAND 1
+#define ENABLE_EXPAND 1
+#ifdef MAKE_SUID
+# define IF_EXPAND(...) __VA_ARGS__ "CONFIG_EXPAND"
+#else
+# define IF_EXPAND(...) __VA_ARGS__
+#endif
+#define IF_NOT_EXPAND(...)
+#define CONFIG_FEATURE_EXPAND_LONG_OPTIONS 1
+#define ENABLE_FEATURE_EXPAND_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EXPAND_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_EXPAND_LONG_OPTIONS"
+#else
+# define IF_FEATURE_EXPAND_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EXPAND_LONG_OPTIONS(...)
+#define CONFIG_UNEXPAND 1
+#define ENABLE_UNEXPAND 1
+#ifdef MAKE_SUID
+# define IF_UNEXPAND(...) __VA_ARGS__ "CONFIG_UNEXPAND"
+#else
+# define IF_UNEXPAND(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNEXPAND(...)
+#define CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS 1
+#define ENABLE_FEATURE_UNEXPAND_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UNEXPAND_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS"
+#else
+# define IF_FEATURE_UNEXPAND_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UNEXPAND_LONG_OPTIONS(...)
+#define CONFIG_EXPR 1
+#define ENABLE_EXPR 1
+#ifdef MAKE_SUID
+# define IF_EXPR(...) __VA_ARGS__ "CONFIG_EXPR"
+#else
+# define IF_EXPR(...) __VA_ARGS__
+#endif
+#define IF_NOT_EXPR(...)
+#define CONFIG_EXPR_MATH_SUPPORT_64 1
+#define ENABLE_EXPR_MATH_SUPPORT_64 1
+#ifdef MAKE_SUID
+# define IF_EXPR_MATH_SUPPORT_64(...) __VA_ARGS__ "CONFIG_EXPR_MATH_SUPPORT_64"
+#else
+# define IF_EXPR_MATH_SUPPORT_64(...) __VA_ARGS__
+#endif
+#define IF_NOT_EXPR_MATH_SUPPORT_64(...)
+#define CONFIG_FALSE 1
+#define ENABLE_FALSE 1
+#ifdef MAKE_SUID
+# define IF_FALSE(...) __VA_ARGS__ "CONFIG_FALSE"
+#else
+# define IF_FALSE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FALSE(...)
+#define CONFIG_FOLD 1
+#define ENABLE_FOLD 1
+#ifdef MAKE_SUID
+# define IF_FOLD(...) __VA_ARGS__ "CONFIG_FOLD"
+#else
+# define IF_FOLD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FOLD(...)
+#define CONFIG_FSYNC 1
+#define ENABLE_FSYNC 1
+#ifdef MAKE_SUID
+# define IF_FSYNC(...) __VA_ARGS__ "CONFIG_FSYNC"
+#else
+# define IF_FSYNC(...) __VA_ARGS__
+#endif
+#define IF_NOT_FSYNC(...)
+#define CONFIG_HEAD 1
+#define ENABLE_HEAD 1
+#ifdef MAKE_SUID
+# define IF_HEAD(...) __VA_ARGS__ "CONFIG_HEAD"
+#else
+# define IF_HEAD(...) __VA_ARGS__
+#endif
+#define IF_NOT_HEAD(...)
+#define CONFIG_FEATURE_FANCY_HEAD 1
+#define ENABLE_FEATURE_FANCY_HEAD 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FANCY_HEAD(...) __VA_ARGS__ "CONFIG_FEATURE_FANCY_HEAD"
+#else
+# define IF_FEATURE_FANCY_HEAD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FANCY_HEAD(...)
+#define CONFIG_HOSTID 1
+#define ENABLE_HOSTID 1
+#ifdef MAKE_SUID
+# define IF_HOSTID(...) __VA_ARGS__ "CONFIG_HOSTID"
+#else
+# define IF_HOSTID(...) __VA_ARGS__
+#endif
+#define IF_NOT_HOSTID(...)
+#define CONFIG_ID 1
+#define ENABLE_ID 1
+#ifdef MAKE_SUID
+# define IF_ID(...) __VA_ARGS__ "CONFIG_ID"
+#else
+# define IF_ID(...) __VA_ARGS__
+#endif
+#define IF_NOT_ID(...)
+#define CONFIG_GROUPS 1
+#define ENABLE_GROUPS 1
+#ifdef MAKE_SUID
+# define IF_GROUPS(...) __VA_ARGS__ "CONFIG_GROUPS"
+#else
+# define IF_GROUPS(...) __VA_ARGS__
+#endif
+#define IF_NOT_GROUPS(...)
+#define CONFIG_INSTALL 1
+#define ENABLE_INSTALL 1
+#ifdef MAKE_SUID
+# define IF_INSTALL(...) __VA_ARGS__ "CONFIG_INSTALL"
+#else
+# define IF_INSTALL(...) __VA_ARGS__
+#endif
+#define IF_NOT_INSTALL(...)
+#define CONFIG_FEATURE_INSTALL_LONG_OPTIONS 1
+#define ENABLE_FEATURE_INSTALL_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INSTALL_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_INSTALL_LONG_OPTIONS"
+#else
+# define IF_FEATURE_INSTALL_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INSTALL_LONG_OPTIONS(...)
+#define CONFIG_LN 1
+#define ENABLE_LN 1
+#ifdef MAKE_SUID
+# define IF_LN(...) __VA_ARGS__ "CONFIG_LN"
+#else
+# define IF_LN(...) __VA_ARGS__
+#endif
+#define IF_NOT_LN(...)
+#define CONFIG_LOGNAME 1
+#define ENABLE_LOGNAME 1
+#ifdef MAKE_SUID
+# define IF_LOGNAME(...) __VA_ARGS__ "CONFIG_LOGNAME"
+#else
+# define IF_LOGNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_LOGNAME(...)
+#define CONFIG_LS 1
+#define ENABLE_LS 1
+#ifdef MAKE_SUID
+# define IF_LS(...) __VA_ARGS__ "CONFIG_LS"
+#else
+# define IF_LS(...) __VA_ARGS__
+#endif
+#define IF_NOT_LS(...)
+#define CONFIG_FEATURE_LS_FILETYPES 1
+#define ENABLE_FEATURE_LS_FILETYPES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_FILETYPES(...) __VA_ARGS__ "CONFIG_FEATURE_LS_FILETYPES"
+#else
+# define IF_FEATURE_LS_FILETYPES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_FILETYPES(...)
+#define CONFIG_FEATURE_LS_FOLLOWLINKS 1
+#define ENABLE_FEATURE_LS_FOLLOWLINKS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_FOLLOWLINKS(...) __VA_ARGS__ "CONFIG_FEATURE_LS_FOLLOWLINKS"
+#else
+# define IF_FEATURE_LS_FOLLOWLINKS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_FOLLOWLINKS(...)
+#define CONFIG_FEATURE_LS_RECURSIVE 1
+#define ENABLE_FEATURE_LS_RECURSIVE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_RECURSIVE(...) __VA_ARGS__ "CONFIG_FEATURE_LS_RECURSIVE"
+#else
+# define IF_FEATURE_LS_RECURSIVE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_RECURSIVE(...)
+#define CONFIG_FEATURE_LS_SORTFILES 1
+#define ENABLE_FEATURE_LS_SORTFILES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_SORTFILES(...) __VA_ARGS__ "CONFIG_FEATURE_LS_SORTFILES"
+#else
+# define IF_FEATURE_LS_SORTFILES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_SORTFILES(...)
+#define CONFIG_FEATURE_LS_TIMESTAMPS 1
+#define ENABLE_FEATURE_LS_TIMESTAMPS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_TIMESTAMPS(...) __VA_ARGS__ "CONFIG_FEATURE_LS_TIMESTAMPS"
+#else
+# define IF_FEATURE_LS_TIMESTAMPS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_TIMESTAMPS(...)
+#define CONFIG_FEATURE_LS_USERNAME 1
+#define ENABLE_FEATURE_LS_USERNAME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_USERNAME(...) __VA_ARGS__ "CONFIG_FEATURE_LS_USERNAME"
+#else
+# define IF_FEATURE_LS_USERNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_USERNAME(...)
+#define CONFIG_FEATURE_LS_COLOR 1
+#define ENABLE_FEATURE_LS_COLOR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_COLOR(...) __VA_ARGS__ "CONFIG_FEATURE_LS_COLOR"
+#else
+# define IF_FEATURE_LS_COLOR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_COLOR(...)
+#define CONFIG_FEATURE_LS_COLOR_IS_DEFAULT 1
+#define ENABLE_FEATURE_LS_COLOR_IS_DEFAULT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LS_COLOR_IS_DEFAULT(...) __VA_ARGS__ "CONFIG_FEATURE_LS_COLOR_IS_DEFAULT"
+#else
+# define IF_FEATURE_LS_COLOR_IS_DEFAULT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LS_COLOR_IS_DEFAULT(...)
+#define CONFIG_MD5SUM 1
+#define ENABLE_MD5SUM 1
+#ifdef MAKE_SUID
+# define IF_MD5SUM(...) __VA_ARGS__ "CONFIG_MD5SUM"
+#else
+# define IF_MD5SUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_MD5SUM(...)
+#define CONFIG_SHA1SUM 1
+#define ENABLE_SHA1SUM 1
+#ifdef MAKE_SUID
+# define IF_SHA1SUM(...) __VA_ARGS__ "CONFIG_SHA1SUM"
+#else
+# define IF_SHA1SUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHA1SUM(...)
+#define CONFIG_SHA256SUM 1
+#define ENABLE_SHA256SUM 1
+#ifdef MAKE_SUID
+# define IF_SHA256SUM(...) __VA_ARGS__ "CONFIG_SHA256SUM"
+#else
+# define IF_SHA256SUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHA256SUM(...)
+#define CONFIG_SHA512SUM 1
+#define ENABLE_SHA512SUM 1
+#ifdef MAKE_SUID
+# define IF_SHA512SUM(...) __VA_ARGS__ "CONFIG_SHA512SUM"
+#else
+# define IF_SHA512SUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHA512SUM(...)
+#define CONFIG_SHA3SUM 1
+#define ENABLE_SHA3SUM 1
+#ifdef MAKE_SUID
+# define IF_SHA3SUM(...) __VA_ARGS__ "CONFIG_SHA3SUM"
+#else
+# define IF_SHA3SUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHA3SUM(...)
+
+/*
+ * Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum
+ */
+#define CONFIG_FEATURE_MD5_SHA1_SUM_CHECK 1
+#define ENABLE_FEATURE_MD5_SHA1_SUM_CHECK 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MD5_SHA1_SUM_CHECK(...) __VA_ARGS__ "CONFIG_FEATURE_MD5_SHA1_SUM_CHECK"
+#else
+# define IF_FEATURE_MD5_SHA1_SUM_CHECK(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MD5_SHA1_SUM_CHECK(...)
+#define CONFIG_MKDIR 1
+#define ENABLE_MKDIR 1
+#ifdef MAKE_SUID
+# define IF_MKDIR(...) __VA_ARGS__ "CONFIG_MKDIR"
+#else
+# define IF_MKDIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKDIR(...)
+#define CONFIG_FEATURE_MKDIR_LONG_OPTIONS 1
+#define ENABLE_FEATURE_MKDIR_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MKDIR_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_MKDIR_LONG_OPTIONS"
+#else
+# define IF_FEATURE_MKDIR_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MKDIR_LONG_OPTIONS(...)
+#define CONFIG_MKFIFO 1
+#define ENABLE_MKFIFO 1
+#ifdef MAKE_SUID
+# define IF_MKFIFO(...) __VA_ARGS__ "CONFIG_MKFIFO"
+#else
+# define IF_MKFIFO(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKFIFO(...)
+#define CONFIG_MKNOD 1
+#define ENABLE_MKNOD 1
+#ifdef MAKE_SUID
+# define IF_MKNOD(...) __VA_ARGS__ "CONFIG_MKNOD"
+#else
+# define IF_MKNOD(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKNOD(...)
+#define CONFIG_MV 1
+#define ENABLE_MV 1
+#ifdef MAKE_SUID
+# define IF_MV(...) __VA_ARGS__ "CONFIG_MV"
+#else
+# define IF_MV(...) __VA_ARGS__
+#endif
+#define IF_NOT_MV(...)
+#define CONFIG_FEATURE_MV_LONG_OPTIONS 1
+#define ENABLE_FEATURE_MV_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MV_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_MV_LONG_OPTIONS"
+#else
+# define IF_FEATURE_MV_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MV_LONG_OPTIONS(...)
+#define CONFIG_NICE 1
+#define ENABLE_NICE 1
+#ifdef MAKE_SUID
+# define IF_NICE(...) __VA_ARGS__ "CONFIG_NICE"
+#else
+# define IF_NICE(...) __VA_ARGS__
+#endif
+#define IF_NOT_NICE(...)
+#define CONFIG_NOHUP 1
+#define ENABLE_NOHUP 1
+#ifdef MAKE_SUID
+# define IF_NOHUP(...) __VA_ARGS__ "CONFIG_NOHUP"
+#else
+# define IF_NOHUP(...) __VA_ARGS__
+#endif
+#define IF_NOT_NOHUP(...)
+#define CONFIG_OD 1
+#define ENABLE_OD 1
+#ifdef MAKE_SUID
+# define IF_OD(...) __VA_ARGS__ "CONFIG_OD"
+#else
+# define IF_OD(...) __VA_ARGS__
+#endif
+#define IF_NOT_OD(...)
+#define CONFIG_PRINTENV 1
+#define ENABLE_PRINTENV 1
+#ifdef MAKE_SUID
+# define IF_PRINTENV(...) __VA_ARGS__ "CONFIG_PRINTENV"
+#else
+# define IF_PRINTENV(...) __VA_ARGS__
+#endif
+#define IF_NOT_PRINTENV(...)
+#define CONFIG_PRINTF 1
+#define ENABLE_PRINTF 1
+#ifdef MAKE_SUID
+# define IF_PRINTF(...) __VA_ARGS__ "CONFIG_PRINTF"
+#else
+# define IF_PRINTF(...) __VA_ARGS__
+#endif
+#define IF_NOT_PRINTF(...)
+#define CONFIG_PWD 1
+#define ENABLE_PWD 1
+#ifdef MAKE_SUID
+# define IF_PWD(...) __VA_ARGS__ "CONFIG_PWD"
+#else
+# define IF_PWD(...) __VA_ARGS__
+#endif
+#define IF_NOT_PWD(...)
+#define CONFIG_READLINK 1
+#define ENABLE_READLINK 1
+#ifdef MAKE_SUID
+# define IF_READLINK(...) __VA_ARGS__ "CONFIG_READLINK"
+#else
+# define IF_READLINK(...) __VA_ARGS__
+#endif
+#define IF_NOT_READLINK(...)
+#define CONFIG_FEATURE_READLINK_FOLLOW 1
+#define ENABLE_FEATURE_READLINK_FOLLOW 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_READLINK_FOLLOW(...) __VA_ARGS__ "CONFIG_FEATURE_READLINK_FOLLOW"
+#else
+# define IF_FEATURE_READLINK_FOLLOW(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_READLINK_FOLLOW(...)
+#define CONFIG_REALPATH 1
+#define ENABLE_REALPATH 1
+#ifdef MAKE_SUID
+# define IF_REALPATH(...) __VA_ARGS__ "CONFIG_REALPATH"
+#else
+# define IF_REALPATH(...) __VA_ARGS__
+#endif
+#define IF_NOT_REALPATH(...)
+#define CONFIG_RM 1
+#define ENABLE_RM 1
+#ifdef MAKE_SUID
+# define IF_RM(...) __VA_ARGS__ "CONFIG_RM"
+#else
+# define IF_RM(...) __VA_ARGS__
+#endif
+#define IF_NOT_RM(...)
+#define CONFIG_RMDIR 1
+#define ENABLE_RMDIR 1
+#ifdef MAKE_SUID
+# define IF_RMDIR(...) __VA_ARGS__ "CONFIG_RMDIR"
+#else
+# define IF_RMDIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_RMDIR(...)
+#define CONFIG_FEATURE_RMDIR_LONG_OPTIONS 1
+#define ENABLE_FEATURE_RMDIR_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_RMDIR_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_RMDIR_LONG_OPTIONS"
+#else
+# define IF_FEATURE_RMDIR_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_RMDIR_LONG_OPTIONS(...)
+#define CONFIG_SEQ 1
+#define ENABLE_SEQ 1
+#ifdef MAKE_SUID
+# define IF_SEQ(...) __VA_ARGS__ "CONFIG_SEQ"
+#else
+# define IF_SEQ(...) __VA_ARGS__
+#endif
+#define IF_NOT_SEQ(...)
+#define CONFIG_SHUF 1
+#define ENABLE_SHUF 1
+#ifdef MAKE_SUID
+# define IF_SHUF(...) __VA_ARGS__ "CONFIG_SHUF"
+#else
+# define IF_SHUF(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHUF(...)
+#define CONFIG_SLEEP 1
+#define ENABLE_SLEEP 1
+#ifdef MAKE_SUID
+# define IF_SLEEP(...) __VA_ARGS__ "CONFIG_SLEEP"
+#else
+# define IF_SLEEP(...) __VA_ARGS__
+#endif
+#define IF_NOT_SLEEP(...)
+#define CONFIG_FEATURE_FANCY_SLEEP 1
+#define ENABLE_FEATURE_FANCY_SLEEP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FANCY_SLEEP(...) __VA_ARGS__ "CONFIG_FEATURE_FANCY_SLEEP"
+#else
+# define IF_FEATURE_FANCY_SLEEP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FANCY_SLEEP(...)
+#define CONFIG_FEATURE_FLOAT_SLEEP 1
+#define ENABLE_FEATURE_FLOAT_SLEEP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FLOAT_SLEEP(...) __VA_ARGS__ "CONFIG_FEATURE_FLOAT_SLEEP"
+#else
+# define IF_FEATURE_FLOAT_SLEEP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FLOAT_SLEEP(...)
+#define CONFIG_SORT 1
+#define ENABLE_SORT 1
+#ifdef MAKE_SUID
+# define IF_SORT(...) __VA_ARGS__ "CONFIG_SORT"
+#else
+# define IF_SORT(...) __VA_ARGS__
+#endif
+#define IF_NOT_SORT(...)
+#define CONFIG_FEATURE_SORT_BIG 1
+#define ENABLE_FEATURE_SORT_BIG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SORT_BIG(...) __VA_ARGS__ "CONFIG_FEATURE_SORT_BIG"
+#else
+# define IF_FEATURE_SORT_BIG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SORT_BIG(...)
+#define CONFIG_SPLIT 1
+#define ENABLE_SPLIT 1
+#ifdef MAKE_SUID
+# define IF_SPLIT(...) __VA_ARGS__ "CONFIG_SPLIT"
+#else
+# define IF_SPLIT(...) __VA_ARGS__
+#endif
+#define IF_NOT_SPLIT(...)
+#define CONFIG_FEATURE_SPLIT_FANCY 1
+#define ENABLE_FEATURE_SPLIT_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SPLIT_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_SPLIT_FANCY"
+#else
+# define IF_FEATURE_SPLIT_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SPLIT_FANCY(...)
+#define CONFIG_STAT 1
+#define ENABLE_STAT 1
+#ifdef MAKE_SUID
+# define IF_STAT(...) __VA_ARGS__ "CONFIG_STAT"
+#else
+# define IF_STAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_STAT(...)
+#define CONFIG_FEATURE_STAT_FORMAT 1
+#define ENABLE_FEATURE_STAT_FORMAT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_STAT_FORMAT(...) __VA_ARGS__ "CONFIG_FEATURE_STAT_FORMAT"
+#else
+# define IF_FEATURE_STAT_FORMAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_STAT_FORMAT(...)
+#define CONFIG_FEATURE_STAT_FILESYSTEM 1
+#define ENABLE_FEATURE_STAT_FILESYSTEM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_STAT_FILESYSTEM(...) __VA_ARGS__ "CONFIG_FEATURE_STAT_FILESYSTEM"
+#else
+# define IF_FEATURE_STAT_FILESYSTEM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_STAT_FILESYSTEM(...)
+#define CONFIG_STTY 1
+#define ENABLE_STTY 1
+#ifdef MAKE_SUID
+# define IF_STTY(...) __VA_ARGS__ "CONFIG_STTY"
+#else
+# define IF_STTY(...) __VA_ARGS__
+#endif
+#define IF_NOT_STTY(...)
+#define CONFIG_SUM 1
+#define ENABLE_SUM 1
+#ifdef MAKE_SUID
+# define IF_SUM(...) __VA_ARGS__ "CONFIG_SUM"
+#else
+# define IF_SUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_SUM(...)
+#define CONFIG_SYNC 1
+#define ENABLE_SYNC 1
+#ifdef MAKE_SUID
+# define IF_SYNC(...) __VA_ARGS__ "CONFIG_SYNC"
+#else
+# define IF_SYNC(...) __VA_ARGS__
+#endif
+#define IF_NOT_SYNC(...)
+#define CONFIG_FEATURE_SYNC_FANCY 1
+#define ENABLE_FEATURE_SYNC_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SYNC_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_SYNC_FANCY"
+#else
+# define IF_FEATURE_SYNC_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SYNC_FANCY(...)
+#define CONFIG_TAC 1
+#define ENABLE_TAC 1
+#ifdef MAKE_SUID
+# define IF_TAC(...) __VA_ARGS__ "CONFIG_TAC"
+#else
+# define IF_TAC(...) __VA_ARGS__
+#endif
+#define IF_NOT_TAC(...)
+#define CONFIG_TAIL 1
+#define ENABLE_TAIL 1
+#ifdef MAKE_SUID
+# define IF_TAIL(...) __VA_ARGS__ "CONFIG_TAIL"
+#else
+# define IF_TAIL(...) __VA_ARGS__
+#endif
+#define IF_NOT_TAIL(...)
+#define CONFIG_FEATURE_FANCY_TAIL 1
+#define ENABLE_FEATURE_FANCY_TAIL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FANCY_TAIL(...) __VA_ARGS__ "CONFIG_FEATURE_FANCY_TAIL"
+#else
+# define IF_FEATURE_FANCY_TAIL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FANCY_TAIL(...)
+#define CONFIG_TEE 1
+#define ENABLE_TEE 1
+#ifdef MAKE_SUID
+# define IF_TEE(...) __VA_ARGS__ "CONFIG_TEE"
+#else
+# define IF_TEE(...) __VA_ARGS__
+#endif
+#define IF_NOT_TEE(...)
+#define CONFIG_FEATURE_TEE_USE_BLOCK_IO 1
+#define ENABLE_FEATURE_TEE_USE_BLOCK_IO 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TEE_USE_BLOCK_IO(...) __VA_ARGS__ "CONFIG_FEATURE_TEE_USE_BLOCK_IO"
+#else
+# define IF_FEATURE_TEE_USE_BLOCK_IO(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TEE_USE_BLOCK_IO(...)
+#define CONFIG_TEST 1
+#define ENABLE_TEST 1
+#ifdef MAKE_SUID
+# define IF_TEST(...) __VA_ARGS__ "CONFIG_TEST"
+#else
+# define IF_TEST(...) __VA_ARGS__
+#endif
+#define IF_NOT_TEST(...)
+#define CONFIG_TEST1 1
+#define ENABLE_TEST1 1
+#ifdef MAKE_SUID
+# define IF_TEST1(...) __VA_ARGS__ "CONFIG_TEST1"
+#else
+# define IF_TEST1(...) __VA_ARGS__
+#endif
+#define IF_NOT_TEST1(...)
+#define CONFIG_TEST2 1
+#define ENABLE_TEST2 1
+#ifdef MAKE_SUID
+# define IF_TEST2(...) __VA_ARGS__ "CONFIG_TEST2"
+#else
+# define IF_TEST2(...) __VA_ARGS__
+#endif
+#define IF_NOT_TEST2(...)
+#define CONFIG_FEATURE_TEST_64 1
+#define ENABLE_FEATURE_TEST_64 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TEST_64(...) __VA_ARGS__ "CONFIG_FEATURE_TEST_64"
+#else
+# define IF_FEATURE_TEST_64(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TEST_64(...)
+#define CONFIG_TOUCH 1
+#define ENABLE_TOUCH 1
+#ifdef MAKE_SUID
+# define IF_TOUCH(...) __VA_ARGS__ "CONFIG_TOUCH"
+#else
+# define IF_TOUCH(...) __VA_ARGS__
+#endif
+#define IF_NOT_TOUCH(...)
+#define CONFIG_FEATURE_TOUCH_NODEREF 1
+#define ENABLE_FEATURE_TOUCH_NODEREF 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOUCH_NODEREF(...) __VA_ARGS__ "CONFIG_FEATURE_TOUCH_NODEREF"
+#else
+# define IF_FEATURE_TOUCH_NODEREF(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOUCH_NODEREF(...)
+#define CONFIG_FEATURE_TOUCH_SUSV3 1
+#define ENABLE_FEATURE_TOUCH_SUSV3 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOUCH_SUSV3(...) __VA_ARGS__ "CONFIG_FEATURE_TOUCH_SUSV3"
+#else
+# define IF_FEATURE_TOUCH_SUSV3(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOUCH_SUSV3(...)
+#define CONFIG_TR 1
+#define ENABLE_TR 1
+#ifdef MAKE_SUID
+# define IF_TR(...) __VA_ARGS__ "CONFIG_TR"
+#else
+# define IF_TR(...) __VA_ARGS__
+#endif
+#define IF_NOT_TR(...)
+#define CONFIG_FEATURE_TR_CLASSES 1
+#define ENABLE_FEATURE_TR_CLASSES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TR_CLASSES(...) __VA_ARGS__ "CONFIG_FEATURE_TR_CLASSES"
+#else
+# define IF_FEATURE_TR_CLASSES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TR_CLASSES(...)
+#define CONFIG_FEATURE_TR_EQUIV 1
+#define ENABLE_FEATURE_TR_EQUIV 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TR_EQUIV(...) __VA_ARGS__ "CONFIG_FEATURE_TR_EQUIV"
+#else
+# define IF_FEATURE_TR_EQUIV(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TR_EQUIV(...)
+#define CONFIG_TRUE 1
+#define ENABLE_TRUE 1
+#ifdef MAKE_SUID
+# define IF_TRUE(...) __VA_ARGS__ "CONFIG_TRUE"
+#else
+# define IF_TRUE(...) __VA_ARGS__
+#endif
+#define IF_NOT_TRUE(...)
+#define CONFIG_TRUNCATE 1
+#define ENABLE_TRUNCATE 1
+#ifdef MAKE_SUID
+# define IF_TRUNCATE(...) __VA_ARGS__ "CONFIG_TRUNCATE"
+#else
+# define IF_TRUNCATE(...) __VA_ARGS__
+#endif
+#define IF_NOT_TRUNCATE(...)
+#define CONFIG_TTY 1
+#define ENABLE_TTY 1
+#ifdef MAKE_SUID
+# define IF_TTY(...) __VA_ARGS__ "CONFIG_TTY"
+#else
+# define IF_TTY(...) __VA_ARGS__
+#endif
+#define IF_NOT_TTY(...)
+#define CONFIG_UNAME 1
+#define ENABLE_UNAME 1
+#ifdef MAKE_SUID
+# define IF_UNAME(...) __VA_ARGS__ "CONFIG_UNAME"
+#else
+# define IF_UNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNAME(...)
+#define CONFIG_UNAME_OSNAME "GNU/Linux"
+#define ENABLE_UNAME_OSNAME 1
+#ifdef MAKE_SUID
+# define IF_UNAME_OSNAME(...) __VA_ARGS__ "CONFIG_UNAME_OSNAME"
+#else
+# define IF_UNAME_OSNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNAME_OSNAME(...)
+#define CONFIG_UNIQ 1
+#define ENABLE_UNIQ 1
+#ifdef MAKE_SUID
+# define IF_UNIQ(...) __VA_ARGS__ "CONFIG_UNIQ"
+#else
+# define IF_UNIQ(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNIQ(...)
+#define CONFIG_UNLINK 1
+#define ENABLE_UNLINK 1
+#ifdef MAKE_SUID
+# define IF_UNLINK(...) __VA_ARGS__ "CONFIG_UNLINK"
+#else
+# define IF_UNLINK(...) __VA_ARGS__
+#endif
+#define IF_NOT_UNLINK(...)
+#define CONFIG_USLEEP 1
+#define ENABLE_USLEEP 1
+#ifdef MAKE_SUID
+# define IF_USLEEP(...) __VA_ARGS__ "CONFIG_USLEEP"
+#else
+# define IF_USLEEP(...) __VA_ARGS__
+#endif
+#define IF_NOT_USLEEP(...)
+#define CONFIG_UUDECODE 1
+#define ENABLE_UUDECODE 1
+#ifdef MAKE_SUID
+# define IF_UUDECODE(...) __VA_ARGS__ "CONFIG_UUDECODE"
+#else
+# define IF_UUDECODE(...) __VA_ARGS__
+#endif
+#define IF_NOT_UUDECODE(...)
+#define CONFIG_BASE64 1
+#define ENABLE_BASE64 1
+#ifdef MAKE_SUID
+# define IF_BASE64(...) __VA_ARGS__ "CONFIG_BASE64"
+#else
+# define IF_BASE64(...) __VA_ARGS__
+#endif
+#define IF_NOT_BASE64(...)
+#define CONFIG_UUENCODE 1
+#define ENABLE_UUENCODE 1
+#ifdef MAKE_SUID
+# define IF_UUENCODE(...) __VA_ARGS__ "CONFIG_UUENCODE"
+#else
+# define IF_UUENCODE(...) __VA_ARGS__
+#endif
+#define IF_NOT_UUENCODE(...)
+#define CONFIG_WC 1
+#define ENABLE_WC 1
+#ifdef MAKE_SUID
+# define IF_WC(...) __VA_ARGS__ "CONFIG_WC"
+#else
+# define IF_WC(...) __VA_ARGS__
+#endif
+#define IF_NOT_WC(...)
+#define CONFIG_FEATURE_WC_LARGE 1
+#define ENABLE_FEATURE_WC_LARGE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WC_LARGE(...) __VA_ARGS__ "CONFIG_FEATURE_WC_LARGE"
+#else
+# define IF_FEATURE_WC_LARGE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WC_LARGE(...)
+#define CONFIG_WHO 1
+#define ENABLE_WHO 1
+#ifdef MAKE_SUID
+# define IF_WHO(...) __VA_ARGS__ "CONFIG_WHO"
+#else
+# define IF_WHO(...) __VA_ARGS__
+#endif
+#define IF_NOT_WHO(...)
+#define CONFIG_USERS 1
+#define ENABLE_USERS 1
+#ifdef MAKE_SUID
+# define IF_USERS(...) __VA_ARGS__ "CONFIG_USERS"
+#else
+# define IF_USERS(...) __VA_ARGS__
+#endif
+#define IF_NOT_USERS(...)
+#define CONFIG_WHOAMI 1
+#define ENABLE_WHOAMI 1
+#ifdef MAKE_SUID
+# define IF_WHOAMI(...) __VA_ARGS__ "CONFIG_WHOAMI"
+#else
+# define IF_WHOAMI(...) __VA_ARGS__
+#endif
+#define IF_NOT_WHOAMI(...)
+#define CONFIG_YES 1
+#define ENABLE_YES 1
+#ifdef MAKE_SUID
+# define IF_YES(...) __VA_ARGS__ "CONFIG_YES"
+#else
+# define IF_YES(...) __VA_ARGS__
+#endif
+#define IF_NOT_YES(...)
+
+/*
+ * Common options
+ */
+#define CONFIG_FEATURE_VERBOSE 1
+#define ENABLE_FEATURE_VERBOSE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VERBOSE(...) __VA_ARGS__ "CONFIG_FEATURE_VERBOSE"
+#else
+# define IF_FEATURE_VERBOSE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VERBOSE(...)
+
+/*
+ * Common options for cp and mv
+ */
+#define CONFIG_FEATURE_PRESERVE_HARDLINKS 1
+#define ENABLE_FEATURE_PRESERVE_HARDLINKS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PRESERVE_HARDLINKS(...) __VA_ARGS__ "CONFIG_FEATURE_PRESERVE_HARDLINKS"
+#else
+# define IF_FEATURE_PRESERVE_HARDLINKS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PRESERVE_HARDLINKS(...)
+
+/*
+ * Common options for ls, more and telnet
+ */
+#define CONFIG_FEATURE_AUTOWIDTH 1
+#define ENABLE_FEATURE_AUTOWIDTH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_AUTOWIDTH(...) __VA_ARGS__ "CONFIG_FEATURE_AUTOWIDTH"
+#else
+# define IF_FEATURE_AUTOWIDTH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_AUTOWIDTH(...)
+
+/*
+ * Common options for df, du, ls
+ */
+#define CONFIG_FEATURE_HUMAN_READABLE 1
+#define ENABLE_FEATURE_HUMAN_READABLE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HUMAN_READABLE(...) __VA_ARGS__ "CONFIG_FEATURE_HUMAN_READABLE"
+#else
+# define IF_FEATURE_HUMAN_READABLE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HUMAN_READABLE(...)
+
+/*
+ * Console Utilities
+ */
+#define CONFIG_CHVT 1
+#define ENABLE_CHVT 1
+#ifdef MAKE_SUID
+# define IF_CHVT(...) __VA_ARGS__ "CONFIG_CHVT"
+#else
+# define IF_CHVT(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHVT(...)
+#define CONFIG_CLEAR 1
+#define ENABLE_CLEAR 1
+#ifdef MAKE_SUID
+# define IF_CLEAR(...) __VA_ARGS__ "CONFIG_CLEAR"
+#else
+# define IF_CLEAR(...) __VA_ARGS__
+#endif
+#define IF_NOT_CLEAR(...)
+#define CONFIG_DEALLOCVT 1
+#define ENABLE_DEALLOCVT 1
+#ifdef MAKE_SUID
+# define IF_DEALLOCVT(...) __VA_ARGS__ "CONFIG_DEALLOCVT"
+#else
+# define IF_DEALLOCVT(...) __VA_ARGS__
+#endif
+#define IF_NOT_DEALLOCVT(...)
+#define CONFIG_DUMPKMAP 1
+#define ENABLE_DUMPKMAP 1
+#ifdef MAKE_SUID
+# define IF_DUMPKMAP(...) __VA_ARGS__ "CONFIG_DUMPKMAP"
+#else
+# define IF_DUMPKMAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_DUMPKMAP(...)
+#define CONFIG_FGCONSOLE 1
+#define ENABLE_FGCONSOLE 1
+#ifdef MAKE_SUID
+# define IF_FGCONSOLE(...) __VA_ARGS__ "CONFIG_FGCONSOLE"
+#else
+# define IF_FGCONSOLE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FGCONSOLE(...)
+#define CONFIG_KBD_MODE 1
+#define ENABLE_KBD_MODE 1
+#ifdef MAKE_SUID
+# define IF_KBD_MODE(...) __VA_ARGS__ "CONFIG_KBD_MODE"
+#else
+# define IF_KBD_MODE(...) __VA_ARGS__
+#endif
+#define IF_NOT_KBD_MODE(...)
+#define CONFIG_LOADFONT 1
+#define ENABLE_LOADFONT 1
+#ifdef MAKE_SUID
+# define IF_LOADFONT(...) __VA_ARGS__ "CONFIG_LOADFONT"
+#else
+# define IF_LOADFONT(...) __VA_ARGS__
+#endif
+#define IF_NOT_LOADFONT(...)
+#define CONFIG_SETFONT 1
+#define ENABLE_SETFONT 1
+#ifdef MAKE_SUID
+# define IF_SETFONT(...) __VA_ARGS__ "CONFIG_SETFONT"
+#else
+# define IF_SETFONT(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETFONT(...)
+#define CONFIG_FEATURE_SETFONT_TEXTUAL_MAP 1
+#define ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SETFONT_TEXTUAL_MAP(...) __VA_ARGS__ "CONFIG_FEATURE_SETFONT_TEXTUAL_MAP"
+#else
+# define IF_FEATURE_SETFONT_TEXTUAL_MAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SETFONT_TEXTUAL_MAP(...)
+#define CONFIG_DEFAULT_SETFONT_DIR ""
+#define ENABLE_DEFAULT_SETFONT_DIR 1
+#ifdef MAKE_SUID
+# define IF_DEFAULT_SETFONT_DIR(...) __VA_ARGS__ "CONFIG_DEFAULT_SETFONT_DIR"
+#else
+# define IF_DEFAULT_SETFONT_DIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_DEFAULT_SETFONT_DIR(...)
+
+/*
+ * Common options for loadfont and setfont
+ */
+#define CONFIG_FEATURE_LOADFONT_PSF2 1
+#define ENABLE_FEATURE_LOADFONT_PSF2 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LOADFONT_PSF2(...) __VA_ARGS__ "CONFIG_FEATURE_LOADFONT_PSF2"
+#else
+# define IF_FEATURE_LOADFONT_PSF2(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LOADFONT_PSF2(...)
+#define CONFIG_FEATURE_LOADFONT_RAW 1
+#define ENABLE_FEATURE_LOADFONT_RAW 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LOADFONT_RAW(...) __VA_ARGS__ "CONFIG_FEATURE_LOADFONT_RAW"
+#else
+# define IF_FEATURE_LOADFONT_RAW(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LOADFONT_RAW(...)
+#define CONFIG_LOADKMAP 1
+#define ENABLE_LOADKMAP 1
+#ifdef MAKE_SUID
+# define IF_LOADKMAP(...) __VA_ARGS__ "CONFIG_LOADKMAP"
+#else
+# define IF_LOADKMAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_LOADKMAP(...)
+#define CONFIG_OPENVT 1
+#define ENABLE_OPENVT 1
+#ifdef MAKE_SUID
+# define IF_OPENVT(...) __VA_ARGS__ "CONFIG_OPENVT"
+#else
+# define IF_OPENVT(...) __VA_ARGS__
+#endif
+#define IF_NOT_OPENVT(...)
+#define CONFIG_RESET 1
+#define ENABLE_RESET 1
+#ifdef MAKE_SUID
+# define IF_RESET(...) __VA_ARGS__ "CONFIG_RESET"
+#else
+# define IF_RESET(...) __VA_ARGS__
+#endif
+#define IF_NOT_RESET(...)
+#define CONFIG_RESIZE 1
+#define ENABLE_RESIZE 1
+#ifdef MAKE_SUID
+# define IF_RESIZE(...) __VA_ARGS__ "CONFIG_RESIZE"
+#else
+# define IF_RESIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_RESIZE(...)
+#define CONFIG_FEATURE_RESIZE_PRINT 1
+#define ENABLE_FEATURE_RESIZE_PRINT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_RESIZE_PRINT(...) __VA_ARGS__ "CONFIG_FEATURE_RESIZE_PRINT"
+#else
+# define IF_FEATURE_RESIZE_PRINT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_RESIZE_PRINT(...)
+#define CONFIG_SETCONSOLE 1
+#define ENABLE_SETCONSOLE 1
+#ifdef MAKE_SUID
+# define IF_SETCONSOLE(...) __VA_ARGS__ "CONFIG_SETCONSOLE"
+#else
+# define IF_SETCONSOLE(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETCONSOLE(...)
+#define CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS 1
+#define ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SETCONSOLE_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS"
+#else
+# define IF_FEATURE_SETCONSOLE_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SETCONSOLE_LONG_OPTIONS(...)
+#define CONFIG_SETKEYCODES 1
+#define ENABLE_SETKEYCODES 1
+#ifdef MAKE_SUID
+# define IF_SETKEYCODES(...) __VA_ARGS__ "CONFIG_SETKEYCODES"
+#else
+# define IF_SETKEYCODES(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETKEYCODES(...)
+#define CONFIG_SETLOGCONS 1
+#define ENABLE_SETLOGCONS 1
+#ifdef MAKE_SUID
+# define IF_SETLOGCONS(...) __VA_ARGS__ "CONFIG_SETLOGCONS"
+#else
+# define IF_SETLOGCONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETLOGCONS(...)
+#define CONFIG_SHOWKEY 1
+#define ENABLE_SHOWKEY 1
+#ifdef MAKE_SUID
+# define IF_SHOWKEY(...) __VA_ARGS__ "CONFIG_SHOWKEY"
+#else
+# define IF_SHOWKEY(...) __VA_ARGS__
+#endif
+#define IF_NOT_SHOWKEY(...)
+
+/*
+ * Debian Utilities
+ */
+#define CONFIG_MKTEMP 1
+#define ENABLE_MKTEMP 1
+#ifdef MAKE_SUID
+# define IF_MKTEMP(...) __VA_ARGS__ "CONFIG_MKTEMP"
+#else
+# define IF_MKTEMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKTEMP(...)
+#define CONFIG_PIPE_PROGRESS 1
+#define ENABLE_PIPE_PROGRESS 1
+#ifdef MAKE_SUID
+# define IF_PIPE_PROGRESS(...) __VA_ARGS__ "CONFIG_PIPE_PROGRESS"
+#else
+# define IF_PIPE_PROGRESS(...) __VA_ARGS__
+#endif
+#define IF_NOT_PIPE_PROGRESS(...)
+#define CONFIG_RUN_PARTS 1
+#define ENABLE_RUN_PARTS 1
+#ifdef MAKE_SUID
+# define IF_RUN_PARTS(...) __VA_ARGS__ "CONFIG_RUN_PARTS"
+#else
+# define IF_RUN_PARTS(...) __VA_ARGS__
+#endif
+#define IF_NOT_RUN_PARTS(...)
+#define CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS 1
+#define ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_RUN_PARTS_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS"
+#else
+# define IF_FEATURE_RUN_PARTS_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_RUN_PARTS_LONG_OPTIONS(...)
+#define CONFIG_FEATURE_RUN_PARTS_FANCY 1
+#define ENABLE_FEATURE_RUN_PARTS_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_RUN_PARTS_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_RUN_PARTS_FANCY"
+#else
+# define IF_FEATURE_RUN_PARTS_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_RUN_PARTS_FANCY(...)
+#define CONFIG_START_STOP_DAEMON 1
+#define ENABLE_START_STOP_DAEMON 1
+#ifdef MAKE_SUID
+# define IF_START_STOP_DAEMON(...) __VA_ARGS__ "CONFIG_START_STOP_DAEMON"
+#else
+# define IF_START_STOP_DAEMON(...) __VA_ARGS__
+#endif
+#define IF_NOT_START_STOP_DAEMON(...)
+#define CONFIG_FEATURE_START_STOP_DAEMON_FANCY 1
+#define ENABLE_FEATURE_START_STOP_DAEMON_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_START_STOP_DAEMON_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_START_STOP_DAEMON_FANCY"
+#else
+# define IF_FEATURE_START_STOP_DAEMON_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_START_STOP_DAEMON_FANCY(...)
+#define CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS 1
+#define ENABLE_FEATURE_START_STOP_DAEMON_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_START_STOP_DAEMON_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS"
+#else
+# define IF_FEATURE_START_STOP_DAEMON_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_START_STOP_DAEMON_LONG_OPTIONS(...)
+#define CONFIG_WHICH 1
+#define ENABLE_WHICH 1
+#ifdef MAKE_SUID
+# define IF_WHICH(...) __VA_ARGS__ "CONFIG_WHICH"
+#else
+# define IF_WHICH(...) __VA_ARGS__
+#endif
+#define IF_NOT_WHICH(...)
+
+/*
+ * Editors
+ */
+#define CONFIG_AWK 1
+#define ENABLE_AWK 1
+#ifdef MAKE_SUID
+# define IF_AWK(...) __VA_ARGS__ "CONFIG_AWK"
+#else
+# define IF_AWK(...) __VA_ARGS__
+#endif
+#define IF_NOT_AWK(...)
+#define CONFIG_FEATURE_AWK_LIBM 1
+#define ENABLE_FEATURE_AWK_LIBM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_AWK_LIBM(...) __VA_ARGS__ "CONFIG_FEATURE_AWK_LIBM"
+#else
+# define IF_FEATURE_AWK_LIBM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_AWK_LIBM(...)
+#define CONFIG_FEATURE_AWK_GNU_EXTENSIONS 1
+#define ENABLE_FEATURE_AWK_GNU_EXTENSIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_AWK_GNU_EXTENSIONS(...) __VA_ARGS__ "CONFIG_FEATURE_AWK_GNU_EXTENSIONS"
+#else
+# define IF_FEATURE_AWK_GNU_EXTENSIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_AWK_GNU_EXTENSIONS(...)
+#define CONFIG_CMP 1
+#define ENABLE_CMP 1
+#ifdef MAKE_SUID
+# define IF_CMP(...) __VA_ARGS__ "CONFIG_CMP"
+#else
+# define IF_CMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_CMP(...)
+#define CONFIG_DIFF 1
+#define ENABLE_DIFF 1
+#ifdef MAKE_SUID
+# define IF_DIFF(...) __VA_ARGS__ "CONFIG_DIFF"
+#else
+# define IF_DIFF(...) __VA_ARGS__
+#endif
+#define IF_NOT_DIFF(...)
+#define CONFIG_FEATURE_DIFF_LONG_OPTIONS 1
+#define ENABLE_FEATURE_DIFF_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DIFF_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_DIFF_LONG_OPTIONS"
+#else
+# define IF_FEATURE_DIFF_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DIFF_LONG_OPTIONS(...)
+#define CONFIG_FEATURE_DIFF_DIR 1
+#define ENABLE_FEATURE_DIFF_DIR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DIFF_DIR(...) __VA_ARGS__ "CONFIG_FEATURE_DIFF_DIR"
+#else
+# define IF_FEATURE_DIFF_DIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DIFF_DIR(...)
+#define CONFIG_ED 1
+#define ENABLE_ED 1
+#ifdef MAKE_SUID
+# define IF_ED(...) __VA_ARGS__ "CONFIG_ED"
+#else
+# define IF_ED(...) __VA_ARGS__
+#endif
+#define IF_NOT_ED(...)
+#define CONFIG_PATCH 1
+#define ENABLE_PATCH 1
+#ifdef MAKE_SUID
+# define IF_PATCH(...) __VA_ARGS__ "CONFIG_PATCH"
+#else
+# define IF_PATCH(...) __VA_ARGS__
+#endif
+#define IF_NOT_PATCH(...)
+#define CONFIG_SED 1
+#define ENABLE_SED 1
+#ifdef MAKE_SUID
+# define IF_SED(...) __VA_ARGS__ "CONFIG_SED"
+#else
+# define IF_SED(...) __VA_ARGS__
+#endif
+#define IF_NOT_SED(...)
+#define CONFIG_VI 1
+#define ENABLE_VI 1
+#ifdef MAKE_SUID
+# define IF_VI(...) __VA_ARGS__ "CONFIG_VI"
+#else
+# define IF_VI(...) __VA_ARGS__
+#endif
+#define IF_NOT_VI(...)
+#define CONFIG_FEATURE_VI_MAX_LEN 4096
+#define ENABLE_FEATURE_VI_MAX_LEN 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_MAX_LEN(...) __VA_ARGS__ "CONFIG_FEATURE_VI_MAX_LEN"
+#else
+# define IF_FEATURE_VI_MAX_LEN(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_MAX_LEN(...)
+#define CONFIG_FEATURE_VI_8BIT 1
+#define ENABLE_FEATURE_VI_8BIT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_8BIT(...) __VA_ARGS__ "CONFIG_FEATURE_VI_8BIT"
+#else
+# define IF_FEATURE_VI_8BIT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_8BIT(...)
+#define CONFIG_FEATURE_VI_COLON 1
+#define ENABLE_FEATURE_VI_COLON 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_COLON(...) __VA_ARGS__ "CONFIG_FEATURE_VI_COLON"
+#else
+# define IF_FEATURE_VI_COLON(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_COLON(...)
+#define CONFIG_FEATURE_VI_YANKMARK 1
+#define ENABLE_FEATURE_VI_YANKMARK 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_YANKMARK(...) __VA_ARGS__ "CONFIG_FEATURE_VI_YANKMARK"
+#else
+# define IF_FEATURE_VI_YANKMARK(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_YANKMARK(...)
+#define CONFIG_FEATURE_VI_SEARCH 1
+#define ENABLE_FEATURE_VI_SEARCH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_SEARCH(...) __VA_ARGS__ "CONFIG_FEATURE_VI_SEARCH"
+#else
+# define IF_FEATURE_VI_SEARCH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_SEARCH(...)
+#undef CONFIG_FEATURE_VI_REGEX_SEARCH
+#define ENABLE_FEATURE_VI_REGEX_SEARCH 0
+#define IF_FEATURE_VI_REGEX_SEARCH(...)
+#define IF_NOT_FEATURE_VI_REGEX_SEARCH(...) __VA_ARGS__
+#undef CONFIG_FEATURE_VI_USE_SIGNALS
+#define ENABLE_FEATURE_VI_USE_SIGNALS 0
+#define IF_FEATURE_VI_USE_SIGNALS(...)
+#define IF_NOT_FEATURE_VI_USE_SIGNALS(...) __VA_ARGS__
+#define CONFIG_FEATURE_VI_DOT_CMD 1
+#define ENABLE_FEATURE_VI_DOT_CMD 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_DOT_CMD(...) __VA_ARGS__ "CONFIG_FEATURE_VI_DOT_CMD"
+#else
+# define IF_FEATURE_VI_DOT_CMD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_DOT_CMD(...)
+#define CONFIG_FEATURE_VI_READONLY 1
+#define ENABLE_FEATURE_VI_READONLY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_READONLY(...) __VA_ARGS__ "CONFIG_FEATURE_VI_READONLY"
+#else
+# define IF_FEATURE_VI_READONLY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_READONLY(...)
+#define CONFIG_FEATURE_VI_SETOPTS 1
+#define ENABLE_FEATURE_VI_SETOPTS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_SETOPTS(...) __VA_ARGS__ "CONFIG_FEATURE_VI_SETOPTS"
+#else
+# define IF_FEATURE_VI_SETOPTS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_SETOPTS(...)
+#define CONFIG_FEATURE_VI_SET 1
+#define ENABLE_FEATURE_VI_SET 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_SET(...) __VA_ARGS__ "CONFIG_FEATURE_VI_SET"
+#else
+# define IF_FEATURE_VI_SET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_SET(...)
+#define CONFIG_FEATURE_VI_WIN_RESIZE 1
+#define ENABLE_FEATURE_VI_WIN_RESIZE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_WIN_RESIZE(...) __VA_ARGS__ "CONFIG_FEATURE_VI_WIN_RESIZE"
+#else
+# define IF_FEATURE_VI_WIN_RESIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_WIN_RESIZE(...)
+#define CONFIG_FEATURE_VI_ASK_TERMINAL 1
+#define ENABLE_FEATURE_VI_ASK_TERMINAL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_ASK_TERMINAL(...) __VA_ARGS__ "CONFIG_FEATURE_VI_ASK_TERMINAL"
+#else
+# define IF_FEATURE_VI_ASK_TERMINAL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_ASK_TERMINAL(...)
+#define CONFIG_FEATURE_VI_UNDO 1
+#define ENABLE_FEATURE_VI_UNDO 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_UNDO(...) __VA_ARGS__ "CONFIG_FEATURE_VI_UNDO"
+#else
+# define IF_FEATURE_VI_UNDO(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_UNDO(...)
+#define CONFIG_FEATURE_VI_UNDO_QUEUE 1
+#define ENABLE_FEATURE_VI_UNDO_QUEUE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_UNDO_QUEUE(...) __VA_ARGS__ "CONFIG_FEATURE_VI_UNDO_QUEUE"
+#else
+# define IF_FEATURE_VI_UNDO_QUEUE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_UNDO_QUEUE(...)
+#define CONFIG_FEATURE_VI_UNDO_QUEUE_MAX 256
+#define ENABLE_FEATURE_VI_UNDO_QUEUE_MAX 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VI_UNDO_QUEUE_MAX(...) __VA_ARGS__ "CONFIG_FEATURE_VI_UNDO_QUEUE_MAX"
+#else
+# define IF_FEATURE_VI_UNDO_QUEUE_MAX(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VI_UNDO_QUEUE_MAX(...)
+#define CONFIG_FEATURE_ALLOW_EXEC 1
+#define ENABLE_FEATURE_ALLOW_EXEC 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_ALLOW_EXEC(...) __VA_ARGS__ "CONFIG_FEATURE_ALLOW_EXEC"
+#else
+# define IF_FEATURE_ALLOW_EXEC(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_ALLOW_EXEC(...)
+
+/*
+ * Finding Utilities
+ */
+#define CONFIG_FIND 1
+#define ENABLE_FIND 1
+#ifdef MAKE_SUID
+# define IF_FIND(...) __VA_ARGS__ "CONFIG_FIND"
+#else
+# define IF_FIND(...) __VA_ARGS__
+#endif
+#define IF_NOT_FIND(...)
+#define CONFIG_FEATURE_FIND_PRINT0 1
+#define ENABLE_FEATURE_FIND_PRINT0 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_PRINT0(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_PRINT0"
+#else
+# define IF_FEATURE_FIND_PRINT0(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_PRINT0(...)
+#define CONFIG_FEATURE_FIND_MTIME 1
+#define ENABLE_FEATURE_FIND_MTIME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_MTIME(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_MTIME"
+#else
+# define IF_FEATURE_FIND_MTIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_MTIME(...)
+#define CONFIG_FEATURE_FIND_MMIN 1
+#define ENABLE_FEATURE_FIND_MMIN 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_MMIN(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_MMIN"
+#else
+# define IF_FEATURE_FIND_MMIN(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_MMIN(...)
+#define CONFIG_FEATURE_FIND_PERM 1
+#define ENABLE_FEATURE_FIND_PERM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_PERM(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_PERM"
+#else
+# define IF_FEATURE_FIND_PERM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_PERM(...)
+#define CONFIG_FEATURE_FIND_TYPE 1
+#define ENABLE_FEATURE_FIND_TYPE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_TYPE(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_TYPE"
+#else
+# define IF_FEATURE_FIND_TYPE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_TYPE(...)
+#define CONFIG_FEATURE_FIND_XDEV 1
+#define ENABLE_FEATURE_FIND_XDEV 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_XDEV(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_XDEV"
+#else
+# define IF_FEATURE_FIND_XDEV(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_XDEV(...)
+#define CONFIG_FEATURE_FIND_MAXDEPTH 1
+#define ENABLE_FEATURE_FIND_MAXDEPTH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_MAXDEPTH(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_MAXDEPTH"
+#else
+# define IF_FEATURE_FIND_MAXDEPTH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_MAXDEPTH(...)
+#define CONFIG_FEATURE_FIND_NEWER 1
+#define ENABLE_FEATURE_FIND_NEWER 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_NEWER(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_NEWER"
+#else
+# define IF_FEATURE_FIND_NEWER(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_NEWER(...)
+#define CONFIG_FEATURE_FIND_INUM 1
+#define ENABLE_FEATURE_FIND_INUM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_INUM(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_INUM"
+#else
+# define IF_FEATURE_FIND_INUM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_INUM(...)
+#define CONFIG_FEATURE_FIND_EXEC 1
+#define ENABLE_FEATURE_FIND_EXEC 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_EXEC(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_EXEC"
+#else
+# define IF_FEATURE_FIND_EXEC(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_EXEC(...)
+#define CONFIG_FEATURE_FIND_EXEC_PLUS 1
+#define ENABLE_FEATURE_FIND_EXEC_PLUS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_EXEC_PLUS(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_EXEC_PLUS"
+#else
+# define IF_FEATURE_FIND_EXEC_PLUS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_EXEC_PLUS(...)
+#define CONFIG_FEATURE_FIND_USER 1
+#define ENABLE_FEATURE_FIND_USER 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_USER(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_USER"
+#else
+# define IF_FEATURE_FIND_USER(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_USER(...)
+#define CONFIG_FEATURE_FIND_GROUP 1
+#define ENABLE_FEATURE_FIND_GROUP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_GROUP(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_GROUP"
+#else
+# define IF_FEATURE_FIND_GROUP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_GROUP(...)
+#define CONFIG_FEATURE_FIND_NOT 1
+#define ENABLE_FEATURE_FIND_NOT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_NOT(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_NOT"
+#else
+# define IF_FEATURE_FIND_NOT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_NOT(...)
+#define CONFIG_FEATURE_FIND_DEPTH 1
+#define ENABLE_FEATURE_FIND_DEPTH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_DEPTH(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_DEPTH"
+#else
+# define IF_FEATURE_FIND_DEPTH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_DEPTH(...)
+#define CONFIG_FEATURE_FIND_PAREN 1
+#define ENABLE_FEATURE_FIND_PAREN 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_PAREN(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_PAREN"
+#else
+# define IF_FEATURE_FIND_PAREN(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_PAREN(...)
+#define CONFIG_FEATURE_FIND_SIZE 1
+#define ENABLE_FEATURE_FIND_SIZE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_SIZE(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_SIZE"
+#else
+# define IF_FEATURE_FIND_SIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_SIZE(...)
+#define CONFIG_FEATURE_FIND_PRUNE 1
+#define ENABLE_FEATURE_FIND_PRUNE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_PRUNE(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_PRUNE"
+#else
+# define IF_FEATURE_FIND_PRUNE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_PRUNE(...)
+#define CONFIG_FEATURE_FIND_DELETE 1
+#define ENABLE_FEATURE_FIND_DELETE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_DELETE(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_DELETE"
+#else
+# define IF_FEATURE_FIND_DELETE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_DELETE(...)
+#define CONFIG_FEATURE_FIND_PATH 1
+#define ENABLE_FEATURE_FIND_PATH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_PATH(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_PATH"
+#else
+# define IF_FEATURE_FIND_PATH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_PATH(...)
+#define CONFIG_FEATURE_FIND_REGEX 1
+#define ENABLE_FEATURE_FIND_REGEX 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_REGEX(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_REGEX"
+#else
+# define IF_FEATURE_FIND_REGEX(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_REGEX(...)
+#undef CONFIG_FEATURE_FIND_CONTEXT
+#define ENABLE_FEATURE_FIND_CONTEXT 0
+#define IF_FEATURE_FIND_CONTEXT(...)
+#define IF_NOT_FEATURE_FIND_CONTEXT(...) __VA_ARGS__
+#define CONFIG_FEATURE_FIND_LINKS 1
+#define ENABLE_FEATURE_FIND_LINKS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FIND_LINKS(...) __VA_ARGS__ "CONFIG_FEATURE_FIND_LINKS"
+#else
+# define IF_FEATURE_FIND_LINKS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FIND_LINKS(...)
+#define CONFIG_GREP 1
+#define ENABLE_GREP 1
+#ifdef MAKE_SUID
+# define IF_GREP(...) __VA_ARGS__ "CONFIG_GREP"
+#else
+# define IF_GREP(...) __VA_ARGS__
+#endif
+#define IF_NOT_GREP(...)
+#define CONFIG_EGREP 1
+#define ENABLE_EGREP 1
+#ifdef MAKE_SUID
+# define IF_EGREP(...) __VA_ARGS__ "CONFIG_EGREP"
+#else
+# define IF_EGREP(...) __VA_ARGS__
+#endif
+#define IF_NOT_EGREP(...)
+#define CONFIG_FGREP 1
+#define ENABLE_FGREP 1
+#ifdef MAKE_SUID
+# define IF_FGREP(...) __VA_ARGS__ "CONFIG_FGREP"
+#else
+# define IF_FGREP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FGREP(...)
+#define CONFIG_FEATURE_GREP_CONTEXT 1
+#define ENABLE_FEATURE_GREP_CONTEXT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_GREP_CONTEXT(...) __VA_ARGS__ "CONFIG_FEATURE_GREP_CONTEXT"
+#else
+# define IF_FEATURE_GREP_CONTEXT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_GREP_CONTEXT(...)
+#define CONFIG_XARGS 1
+#define ENABLE_XARGS 1
+#ifdef MAKE_SUID
+# define IF_XARGS(...) __VA_ARGS__ "CONFIG_XARGS"
+#else
+# define IF_XARGS(...) __VA_ARGS__
+#endif
+#define IF_NOT_XARGS(...)
+#define CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION 1
+#define ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_XARGS_SUPPORT_CONFIRMATION(...) __VA_ARGS__ "CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION"
+#else
+# define IF_FEATURE_XARGS_SUPPORT_CONFIRMATION(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_XARGS_SUPPORT_CONFIRMATION(...)
+#define CONFIG_FEATURE_XARGS_SUPPORT_QUOTES 1
+#define ENABLE_FEATURE_XARGS_SUPPORT_QUOTES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_XARGS_SUPPORT_QUOTES(...) __VA_ARGS__ "CONFIG_FEATURE_XARGS_SUPPORT_QUOTES"
+#else
+# define IF_FEATURE_XARGS_SUPPORT_QUOTES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_XARGS_SUPPORT_QUOTES(...)
+#define CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT 1
+#define ENABLE_FEATURE_XARGS_SUPPORT_TERMOPT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_XARGS_SUPPORT_TERMOPT(...) __VA_ARGS__ "CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT"
+#else
+# define IF_FEATURE_XARGS_SUPPORT_TERMOPT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_XARGS_SUPPORT_TERMOPT(...)
+#define CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM 1
+#define ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(...) __VA_ARGS__ "CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM"
+#else
+# define IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_XARGS_SUPPORT_ZERO_TERM(...)
+#define CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR 1
+#define ENABLE_FEATURE_XARGS_SUPPORT_REPL_STR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_XARGS_SUPPORT_REPL_STR(...) __VA_ARGS__ "CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR"
+#else
+# define IF_FEATURE_XARGS_SUPPORT_REPL_STR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_XARGS_SUPPORT_REPL_STR(...)
+
+/*
+ * Init Utilities
+ */
+#define CONFIG_BOOTCHARTD 1
+#define ENABLE_BOOTCHARTD 1
+#ifdef MAKE_SUID
+# define IF_BOOTCHARTD(...) __VA_ARGS__ "CONFIG_BOOTCHARTD"
+#else
+# define IF_BOOTCHARTD(...) __VA_ARGS__
+#endif
+#define IF_NOT_BOOTCHARTD(...)
+#define CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER 1
+#define ENABLE_FEATURE_BOOTCHARTD_BLOATED_HEADER 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_BOOTCHARTD_BLOATED_HEADER(...) __VA_ARGS__ "CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER"
+#else
+# define IF_FEATURE_BOOTCHARTD_BLOATED_HEADER(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_BOOTCHARTD_BLOATED_HEADER(...)
+#define CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE 1
+#define ENABLE_FEATURE_BOOTCHARTD_CONFIG_FILE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_BOOTCHARTD_CONFIG_FILE(...) __VA_ARGS__ "CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE"
+#else
+# define IF_FEATURE_BOOTCHARTD_CONFIG_FILE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_BOOTCHARTD_CONFIG_FILE(...)
+#define CONFIG_HALT 1
+#define ENABLE_HALT 1
+#ifdef MAKE_SUID
+# define IF_HALT(...) __VA_ARGS__ "CONFIG_HALT"
+#else
+# define IF_HALT(...) __VA_ARGS__
+#endif
+#define IF_NOT_HALT(...)
+#define CONFIG_POWEROFF 1
+#define ENABLE_POWEROFF 1
+#ifdef MAKE_SUID
+# define IF_POWEROFF(...) __VA_ARGS__ "CONFIG_POWEROFF"
+#else
+# define IF_POWEROFF(...) __VA_ARGS__
+#endif
+#define IF_NOT_POWEROFF(...)
+#define CONFIG_REBOOT 1
+#define ENABLE_REBOOT 1
+#ifdef MAKE_SUID
+# define IF_REBOOT(...) __VA_ARGS__ "CONFIG_REBOOT"
+#else
+# define IF_REBOOT(...) __VA_ARGS__
+#endif
+#define IF_NOT_REBOOT(...)
+#undef CONFIG_FEATURE_CALL_TELINIT
+#define ENABLE_FEATURE_CALL_TELINIT 0
+#define IF_FEATURE_CALL_TELINIT(...)
+#define IF_NOT_FEATURE_CALL_TELINIT(...) __VA_ARGS__
+#define CONFIG_TELINIT_PATH ""
+#define ENABLE_TELINIT_PATH 1
+#ifdef MAKE_SUID
+# define IF_TELINIT_PATH(...) __VA_ARGS__ "CONFIG_TELINIT_PATH"
+#else
+# define IF_TELINIT_PATH(...) __VA_ARGS__
+#endif
+#define IF_NOT_TELINIT_PATH(...)
+#define CONFIG_INIT 1
+#define ENABLE_INIT 1
+#ifdef MAKE_SUID
+# define IF_INIT(...) __VA_ARGS__ "CONFIG_INIT"
+#else
+# define IF_INIT(...) __VA_ARGS__
+#endif
+#define IF_NOT_INIT(...)
+#define CONFIG_LINUXRC 1
+#define ENABLE_LINUXRC 1
+#ifdef MAKE_SUID
+# define IF_LINUXRC(...) __VA_ARGS__ "CONFIG_LINUXRC"
+#else
+# define IF_LINUXRC(...) __VA_ARGS__
+#endif
+#define IF_NOT_LINUXRC(...)
+#define CONFIG_FEATURE_USE_INITTAB 1
+#define ENABLE_FEATURE_USE_INITTAB 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_USE_INITTAB(...) __VA_ARGS__ "CONFIG_FEATURE_USE_INITTAB"
+#else
+# define IF_FEATURE_USE_INITTAB(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_USE_INITTAB(...)
+#define CONFIG_FEATURE_KILL_REMOVED 1
+#define ENABLE_FEATURE_KILL_REMOVED 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_KILL_REMOVED(...) __VA_ARGS__ "CONFIG_FEATURE_KILL_REMOVED"
+#else
+# define IF_FEATURE_KILL_REMOVED(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_KILL_REMOVED(...)
+#define CONFIG_FEATURE_KILL_DELAY 1
+#define ENABLE_FEATURE_KILL_DELAY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_KILL_DELAY(...) __VA_ARGS__ "CONFIG_FEATURE_KILL_DELAY"
+#else
+# define IF_FEATURE_KILL_DELAY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_KILL_DELAY(...)
+#define CONFIG_FEATURE_INIT_SCTTY 1
+#define ENABLE_FEATURE_INIT_SCTTY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INIT_SCTTY(...) __VA_ARGS__ "CONFIG_FEATURE_INIT_SCTTY"
+#else
+# define IF_FEATURE_INIT_SCTTY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INIT_SCTTY(...)
+#define CONFIG_FEATURE_INIT_SYSLOG 1
+#define ENABLE_FEATURE_INIT_SYSLOG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INIT_SYSLOG(...) __VA_ARGS__ "CONFIG_FEATURE_INIT_SYSLOG"
+#else
+# define IF_FEATURE_INIT_SYSLOG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INIT_SYSLOG(...)
+#define CONFIG_FEATURE_EXTRA_QUIET 1
+#define ENABLE_FEATURE_EXTRA_QUIET 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EXTRA_QUIET(...) __VA_ARGS__ "CONFIG_FEATURE_EXTRA_QUIET"
+#else
+# define IF_FEATURE_EXTRA_QUIET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EXTRA_QUIET(...)
+#define CONFIG_FEATURE_INIT_COREDUMPS 1
+#define ENABLE_FEATURE_INIT_COREDUMPS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INIT_COREDUMPS(...) __VA_ARGS__ "CONFIG_FEATURE_INIT_COREDUMPS"
+#else
+# define IF_FEATURE_INIT_COREDUMPS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INIT_COREDUMPS(...)
+#define CONFIG_INIT_TERMINAL_TYPE "linux"
+#define ENABLE_INIT_TERMINAL_TYPE 1
+#ifdef MAKE_SUID
+# define IF_INIT_TERMINAL_TYPE(...) __VA_ARGS__ "CONFIG_INIT_TERMINAL_TYPE"
+#else
+# define IF_INIT_TERMINAL_TYPE(...) __VA_ARGS__
+#endif
+#define IF_NOT_INIT_TERMINAL_TYPE(...)
+#define CONFIG_FEATURE_INIT_MODIFY_CMDLINE 1
+#define ENABLE_FEATURE_INIT_MODIFY_CMDLINE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INIT_MODIFY_CMDLINE(...) __VA_ARGS__ "CONFIG_FEATURE_INIT_MODIFY_CMDLINE"
+#else
+# define IF_FEATURE_INIT_MODIFY_CMDLINE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INIT_MODIFY_CMDLINE(...)
+#define CONFIG_MESG 1
+#define ENABLE_MESG 1
+#ifdef MAKE_SUID
+# define IF_MESG(...) __VA_ARGS__ "CONFIG_MESG"
+#else
+# define IF_MESG(...) __VA_ARGS__
+#endif
+#define IF_NOT_MESG(...)
+#define CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP 1
+#define ENABLE_FEATURE_MESG_ENABLE_ONLY_GROUP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MESG_ENABLE_ONLY_GROUP(...) __VA_ARGS__ "CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP"
+#else
+# define IF_FEATURE_MESG_ENABLE_ONLY_GROUP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MESG_ENABLE_ONLY_GROUP(...)
+
+/*
+ * Login/Password Management Utilities
+ */
+#undef CONFIG_FEATURE_SHADOWPASSWDS
+#define ENABLE_FEATURE_SHADOWPASSWDS 0
+#define IF_FEATURE_SHADOWPASSWDS(...)
+#define IF_NOT_FEATURE_SHADOWPASSWDS(...) __VA_ARGS__
+#undef CONFIG_USE_BB_PWD_GRP
+#define ENABLE_USE_BB_PWD_GRP 0
+#define IF_USE_BB_PWD_GRP(...)
+#define IF_NOT_USE_BB_PWD_GRP(...) __VA_ARGS__
+#undef CONFIG_USE_BB_SHADOW
+#define ENABLE_USE_BB_SHADOW 0
+#define IF_USE_BB_SHADOW(...)
+#define IF_NOT_USE_BB_SHADOW(...) __VA_ARGS__
+#undef CONFIG_USE_BB_CRYPT
+#define ENABLE_USE_BB_CRYPT 0
+#define IF_USE_BB_CRYPT(...)
+#define IF_NOT_USE_BB_CRYPT(...) __VA_ARGS__
+#undef CONFIG_USE_BB_CRYPT_SHA
+#define ENABLE_USE_BB_CRYPT_SHA 0
+#define IF_USE_BB_CRYPT_SHA(...)
+#define IF_NOT_USE_BB_CRYPT_SHA(...) __VA_ARGS__
+#undef CONFIG_ADD_SHELL
+#define ENABLE_ADD_SHELL 0
+#define IF_ADD_SHELL(...)
+#define IF_NOT_ADD_SHELL(...) __VA_ARGS__
+#undef CONFIG_REMOVE_SHELL
+#define ENABLE_REMOVE_SHELL 0
+#define IF_REMOVE_SHELL(...)
+#define IF_NOT_REMOVE_SHELL(...) __VA_ARGS__
+#undef CONFIG_ADDGROUP
+#define ENABLE_ADDGROUP 0
+#define IF_ADDGROUP(...)
+#define IF_NOT_ADDGROUP(...) __VA_ARGS__
+#undef CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS
+#define ENABLE_FEATURE_ADDGROUP_LONG_OPTIONS 0
+#define IF_FEATURE_ADDGROUP_LONG_OPTIONS(...)
+#define IF_NOT_FEATURE_ADDGROUP_LONG_OPTIONS(...) __VA_ARGS__
+#undef CONFIG_FEATURE_ADDUSER_TO_GROUP
+#define ENABLE_FEATURE_ADDUSER_TO_GROUP 0
+#define IF_FEATURE_ADDUSER_TO_GROUP(...)
+#define IF_NOT_FEATURE_ADDUSER_TO_GROUP(...) __VA_ARGS__
+#undef CONFIG_ADDUSER
+#define ENABLE_ADDUSER 0
+#define IF_ADDUSER(...)
+#define IF_NOT_ADDUSER(...) __VA_ARGS__
+#undef CONFIG_FEATURE_ADDUSER_LONG_OPTIONS
+#define ENABLE_FEATURE_ADDUSER_LONG_OPTIONS 0
+#define IF_FEATURE_ADDUSER_LONG_OPTIONS(...)
+#define IF_NOT_FEATURE_ADDUSER_LONG_OPTIONS(...) __VA_ARGS__
+#undef CONFIG_FEATURE_CHECK_NAMES
+#define ENABLE_FEATURE_CHECK_NAMES 0
+#define IF_FEATURE_CHECK_NAMES(...)
+#define IF_NOT_FEATURE_CHECK_NAMES(...) __VA_ARGS__
+#define CONFIG_LAST_ID 0
+#define ENABLE_LAST_ID 1
+#ifdef MAKE_SUID
+# define IF_LAST_ID(...) __VA_ARGS__ "CONFIG_LAST_ID"
+#else
+# define IF_LAST_ID(...) __VA_ARGS__
+#endif
+#define IF_NOT_LAST_ID(...)
+#define CONFIG_FIRST_SYSTEM_ID 0
+#define ENABLE_FIRST_SYSTEM_ID 1
+#ifdef MAKE_SUID
+# define IF_FIRST_SYSTEM_ID(...) __VA_ARGS__ "CONFIG_FIRST_SYSTEM_ID"
+#else
+# define IF_FIRST_SYSTEM_ID(...) __VA_ARGS__
+#endif
+#define IF_NOT_FIRST_SYSTEM_ID(...)
+#define CONFIG_LAST_SYSTEM_ID 0
+#define ENABLE_LAST_SYSTEM_ID 1
+#ifdef MAKE_SUID
+# define IF_LAST_SYSTEM_ID(...) __VA_ARGS__ "CONFIG_LAST_SYSTEM_ID"
+#else
+# define IF_LAST_SYSTEM_ID(...) __VA_ARGS__
+#endif
+#define IF_NOT_LAST_SYSTEM_ID(...)
+#undef CONFIG_CHPASSWD
+#define ENABLE_CHPASSWD 0
+#define IF_CHPASSWD(...)
+#define IF_NOT_CHPASSWD(...) __VA_ARGS__
+#define CONFIG_FEATURE_DEFAULT_PASSWD_ALGO ""
+#define ENABLE_FEATURE_DEFAULT_PASSWD_ALGO 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DEFAULT_PASSWD_ALGO(...) __VA_ARGS__ "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO"
+#else
+# define IF_FEATURE_DEFAULT_PASSWD_ALGO(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DEFAULT_PASSWD_ALGO(...)
+#undef CONFIG_CRYPTPW
+#define ENABLE_CRYPTPW 0
+#define IF_CRYPTPW(...)
+#define IF_NOT_CRYPTPW(...) __VA_ARGS__
+#undef CONFIG_MKPASSWD
+#define ENABLE_MKPASSWD 0
+#define IF_MKPASSWD(...)
+#define IF_NOT_MKPASSWD(...) __VA_ARGS__
+#undef CONFIG_DELUSER
+#define ENABLE_DELUSER 0
+#define IF_DELUSER(...)
+#define IF_NOT_DELUSER(...) __VA_ARGS__
+#undef CONFIG_DELGROUP
+#define ENABLE_DELGROUP 0
+#define IF_DELGROUP(...)
+#define IF_NOT_DELGROUP(...) __VA_ARGS__
+#undef CONFIG_FEATURE_DEL_USER_FROM_GROUP
+#define ENABLE_FEATURE_DEL_USER_FROM_GROUP 0
+#define IF_FEATURE_DEL_USER_FROM_GROUP(...)
+#define IF_NOT_FEATURE_DEL_USER_FROM_GROUP(...) __VA_ARGS__
+#undef CONFIG_GETTY
+#define ENABLE_GETTY 0
+#define IF_GETTY(...)
+#define IF_NOT_GETTY(...) __VA_ARGS__
+#undef CONFIG_LOGIN
+#define ENABLE_LOGIN 0
+#define IF_LOGIN(...)
+#define IF_NOT_LOGIN(...) __VA_ARGS__
+#undef CONFIG_LOGIN_SESSION_AS_CHILD
+#define ENABLE_LOGIN_SESSION_AS_CHILD 0
+#define IF_LOGIN_SESSION_AS_CHILD(...)
+#define IF_NOT_LOGIN_SESSION_AS_CHILD(...) __VA_ARGS__
+#undef CONFIG_LOGIN_SCRIPTS
+#define ENABLE_LOGIN_SCRIPTS 0
+#define IF_LOGIN_SCRIPTS(...)
+#define IF_NOT_LOGIN_SCRIPTS(...) __VA_ARGS__
+#undef CONFIG_FEATURE_NOLOGIN
+#define ENABLE_FEATURE_NOLOGIN 0
+#define IF_FEATURE_NOLOGIN(...)
+#define IF_NOT_FEATURE_NOLOGIN(...) __VA_ARGS__
+#undef CONFIG_FEATURE_SECURETTY
+#define ENABLE_FEATURE_SECURETTY 0
+#define IF_FEATURE_SECURETTY(...)
+#define IF_NOT_FEATURE_SECURETTY(...) __VA_ARGS__
+#undef CONFIG_PASSWD
+#define ENABLE_PASSWD 0
+#define IF_PASSWD(...)
+#define IF_NOT_PASSWD(...) __VA_ARGS__
+#undef CONFIG_FEATURE_PASSWD_WEAK_CHECK
+#define ENABLE_FEATURE_PASSWD_WEAK_CHECK 0
+#define IF_FEATURE_PASSWD_WEAK_CHECK(...)
+#define IF_NOT_FEATURE_PASSWD_WEAK_CHECK(...) __VA_ARGS__
+#undef CONFIG_SU
+#define ENABLE_SU 0
+#define IF_SU(...)
+#define IF_NOT_SU(...) __VA_ARGS__
+#undef CONFIG_FEATURE_SU_SYSLOG
+#define ENABLE_FEATURE_SU_SYSLOG 0
+#define IF_FEATURE_SU_SYSLOG(...)
+#define IF_NOT_FEATURE_SU_SYSLOG(...) __VA_ARGS__
+#undef CONFIG_FEATURE_SU_CHECKS_SHELLS
+#define ENABLE_FEATURE_SU_CHECKS_SHELLS 0
+#define IF_FEATURE_SU_CHECKS_SHELLS(...)
+#define IF_NOT_FEATURE_SU_CHECKS_SHELLS(...) __VA_ARGS__
+#undef CONFIG_SULOGIN
+#define ENABLE_SULOGIN 0
+#define IF_SULOGIN(...)
+#define IF_NOT_SULOGIN(...) __VA_ARGS__
+#undef CONFIG_VLOCK
+#define ENABLE_VLOCK 0
+#define IF_VLOCK(...)
+#define IF_NOT_VLOCK(...) __VA_ARGS__
+
+/*
+ * Linux Ext2 FS Progs
+ */
+#undef CONFIG_CHATTR
+#define ENABLE_CHATTR 0
+#define IF_CHATTR(...)
+#define IF_NOT_CHATTR(...) __VA_ARGS__
+#undef CONFIG_FSCK
+#define ENABLE_FSCK 0
+#define IF_FSCK(...)
+#define IF_NOT_FSCK(...) __VA_ARGS__
+#undef CONFIG_LSATTR
+#define ENABLE_LSATTR 0
+#define IF_LSATTR(...)
+#define IF_NOT_LSATTR(...) __VA_ARGS__
+#undef CONFIG_TUNE2FS
+#define ENABLE_TUNE2FS 0
+#define IF_TUNE2FS(...)
+#define IF_NOT_TUNE2FS(...) __VA_ARGS__
+
+/*
+ * Linux Module Utilities
+ */
+#define CONFIG_MODPROBE_SMALL 1
+#define ENABLE_MODPROBE_SMALL 1
+#ifdef MAKE_SUID
+# define IF_MODPROBE_SMALL(...) __VA_ARGS__ "CONFIG_MODPROBE_SMALL"
+#else
+# define IF_MODPROBE_SMALL(...) __VA_ARGS__
+#endif
+#define IF_NOT_MODPROBE_SMALL(...)
+#undef CONFIG_DEPMOD
+#define ENABLE_DEPMOD 0
+#define IF_DEPMOD(...)
+#define IF_NOT_DEPMOD(...) __VA_ARGS__
+#undef CONFIG_INSMOD
+#define ENABLE_INSMOD 0
+#define IF_INSMOD(...)
+#define IF_NOT_INSMOD(...) __VA_ARGS__
+#undef CONFIG_LSMOD
+#define ENABLE_LSMOD 0
+#define IF_LSMOD(...)
+#define IF_NOT_LSMOD(...) __VA_ARGS__
+#undef CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT
+#define ENABLE_FEATURE_LSMOD_PRETTY_2_6_OUTPUT 0
+#define IF_FEATURE_LSMOD_PRETTY_2_6_OUTPUT(...)
+#define IF_NOT_FEATURE_LSMOD_PRETTY_2_6_OUTPUT(...) __VA_ARGS__
+#define CONFIG_MODINFO 1
+#define ENABLE_MODINFO 1
+#ifdef MAKE_SUID
+# define IF_MODINFO(...) __VA_ARGS__ "CONFIG_MODINFO"
+#else
+# define IF_MODINFO(...) __VA_ARGS__
+#endif
+#define IF_NOT_MODINFO(...)
+#define CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE 1
+#define ENABLE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(...) __VA_ARGS__ "CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE"
+#else
+# define IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(...)
+#define CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED 1
+#define ENABLE_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED(...) __VA_ARGS__ "CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED"
+#else
+# define IF_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED(...)
+#undef CONFIG_MODPROBE
+#define ENABLE_MODPROBE 0
+#define IF_MODPROBE(...)
+#define IF_NOT_MODPROBE(...) __VA_ARGS__
+#undef CONFIG_FEATURE_MODPROBE_BLACKLIST
+#define ENABLE_FEATURE_MODPROBE_BLACKLIST 0
+#define IF_FEATURE_MODPROBE_BLACKLIST(...)
+#define IF_NOT_FEATURE_MODPROBE_BLACKLIST(...) __VA_ARGS__
+#undef CONFIG_RMMOD
+#define ENABLE_RMMOD 0
+#define IF_RMMOD(...)
+#define IF_NOT_RMMOD(...) __VA_ARGS__
+
+/*
+ * Options common to multiple modutils
+ */
+#undef CONFIG_FEATURE_2_4_MODULES
+#define ENABLE_FEATURE_2_4_MODULES 0
+#define IF_FEATURE_2_4_MODULES(...)
+#define IF_NOT_FEATURE_2_4_MODULES(...) __VA_ARGS__
+#define CONFIG_FEATURE_INSMOD_TRY_MMAP 1
+#define ENABLE_FEATURE_INSMOD_TRY_MMAP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INSMOD_TRY_MMAP(...) __VA_ARGS__ "CONFIG_FEATURE_INSMOD_TRY_MMAP"
+#else
+# define IF_FEATURE_INSMOD_TRY_MMAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INSMOD_TRY_MMAP(...)
+#undef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
+#define ENABLE_FEATURE_INSMOD_VERSION_CHECKING 0
+#define IF_FEATURE_INSMOD_VERSION_CHECKING(...)
+#define IF_NOT_FEATURE_INSMOD_VERSION_CHECKING(...) __VA_ARGS__
+#undef CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
+#define ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS 0
+#define IF_FEATURE_INSMOD_KSYMOOPS_SYMBOLS(...)
+#define IF_NOT_FEATURE_INSMOD_KSYMOOPS_SYMBOLS(...) __VA_ARGS__
+#undef CONFIG_FEATURE_INSMOD_LOADINKMEM
+#define ENABLE_FEATURE_INSMOD_LOADINKMEM 0
+#define IF_FEATURE_INSMOD_LOADINKMEM(...)
+#define IF_NOT_FEATURE_INSMOD_LOADINKMEM(...) __VA_ARGS__
+#undef CONFIG_FEATURE_INSMOD_LOAD_MAP
+#define ENABLE_FEATURE_INSMOD_LOAD_MAP 0
+#define IF_FEATURE_INSMOD_LOAD_MAP(...)
+#define IF_NOT_FEATURE_INSMOD_LOAD_MAP(...) __VA_ARGS__
+#undef CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL
+#define ENABLE_FEATURE_INSMOD_LOAD_MAP_FULL 0
+#define IF_FEATURE_INSMOD_LOAD_MAP_FULL(...)
+#define IF_NOT_FEATURE_INSMOD_LOAD_MAP_FULL(...) __VA_ARGS__
+#undef CONFIG_FEATURE_CHECK_TAINTED_MODULE
+#define ENABLE_FEATURE_CHECK_TAINTED_MODULE 0
+#define IF_FEATURE_CHECK_TAINTED_MODULE(...)
+#define IF_NOT_FEATURE_CHECK_TAINTED_MODULE(...) __VA_ARGS__
+#undef CONFIG_FEATURE_MODUTILS_ALIAS
+#define ENABLE_FEATURE_MODUTILS_ALIAS 0
+#define IF_FEATURE_MODUTILS_ALIAS(...)
+#define IF_NOT_FEATURE_MODUTILS_ALIAS(...) __VA_ARGS__
+#undef CONFIG_FEATURE_MODUTILS_SYMBOLS
+#define ENABLE_FEATURE_MODUTILS_SYMBOLS 0
+#define IF_FEATURE_MODUTILS_SYMBOLS(...)
+#define IF_NOT_FEATURE_MODUTILS_SYMBOLS(...) __VA_ARGS__
+#define CONFIG_DEFAULT_MODULES_DIR "/lib/modules"
+#define ENABLE_DEFAULT_MODULES_DIR 1
+#ifdef MAKE_SUID
+# define IF_DEFAULT_MODULES_DIR(...) __VA_ARGS__ "CONFIG_DEFAULT_MODULES_DIR"
+#else
+# define IF_DEFAULT_MODULES_DIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_DEFAULT_MODULES_DIR(...)
+#define CONFIG_DEFAULT_DEPMOD_FILE "modules.dep"
+#define ENABLE_DEFAULT_DEPMOD_FILE 1
+#ifdef MAKE_SUID
+# define IF_DEFAULT_DEPMOD_FILE(...) __VA_ARGS__ "CONFIG_DEFAULT_DEPMOD_FILE"
+#else
+# define IF_DEFAULT_DEPMOD_FILE(...) __VA_ARGS__
+#endif
+#define IF_NOT_DEFAULT_DEPMOD_FILE(...)
+
+/*
+ * Linux System Utilities
+ */
+#undef CONFIG_ACPID
+#define ENABLE_ACPID 0
+#define IF_ACPID(...)
+#define IF_NOT_ACPID(...) __VA_ARGS__
+#undef CONFIG_FEATURE_ACPID_COMPAT
+#define ENABLE_FEATURE_ACPID_COMPAT 0
+#define IF_FEATURE_ACPID_COMPAT(...)
+#define IF_NOT_FEATURE_ACPID_COMPAT(...) __VA_ARGS__
+#define CONFIG_BLKDISCARD 1
+#define ENABLE_BLKDISCARD 1
+#ifdef MAKE_SUID
+# define IF_BLKDISCARD(...) __VA_ARGS__ "CONFIG_BLKDISCARD"
+#else
+# define IF_BLKDISCARD(...) __VA_ARGS__
+#endif
+#define IF_NOT_BLKDISCARD(...)
+#define CONFIG_BLKID 1
+#define ENABLE_BLKID 1
+#ifdef MAKE_SUID
+# define IF_BLKID(...) __VA_ARGS__ "CONFIG_BLKID"
+#else
+# define IF_BLKID(...) __VA_ARGS__
+#endif
+#define IF_NOT_BLKID(...)
+#undef CONFIG_FEATURE_BLKID_TYPE
+#define ENABLE_FEATURE_BLKID_TYPE 0
+#define IF_FEATURE_BLKID_TYPE(...)
+#define IF_NOT_FEATURE_BLKID_TYPE(...) __VA_ARGS__
+#define CONFIG_BLOCKDEV 1
+#define ENABLE_BLOCKDEV 1
+#ifdef MAKE_SUID
+# define IF_BLOCKDEV(...) __VA_ARGS__ "CONFIG_BLOCKDEV"
+#else
+# define IF_BLOCKDEV(...) __VA_ARGS__
+#endif
+#define IF_NOT_BLOCKDEV(...)
+#define CONFIG_DMESG 1
+#define ENABLE_DMESG 1
+#ifdef MAKE_SUID
+# define IF_DMESG(...) __VA_ARGS__ "CONFIG_DMESG"
+#else
+# define IF_DMESG(...) __VA_ARGS__
+#endif
+#define IF_NOT_DMESG(...)
+#define CONFIG_FEATURE_DMESG_PRETTY 1
+#define ENABLE_FEATURE_DMESG_PRETTY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DMESG_PRETTY(...) __VA_ARGS__ "CONFIG_FEATURE_DMESG_PRETTY"
+#else
+# define IF_FEATURE_DMESG_PRETTY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DMESG_PRETTY(...)
+#define CONFIG_FATATTR 1
+#define ENABLE_FATATTR 1
+#ifdef MAKE_SUID
+# define IF_FATATTR(...) __VA_ARGS__ "CONFIG_FATATTR"
+#else
+# define IF_FATATTR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FATATTR(...)
+#define CONFIG_FBSET 1
+#define ENABLE_FBSET 1
+#ifdef MAKE_SUID
+# define IF_FBSET(...) __VA_ARGS__ "CONFIG_FBSET"
+#else
+# define IF_FBSET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FBSET(...)
+#define CONFIG_FEATURE_FBSET_FANCY 1
+#define ENABLE_FEATURE_FBSET_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FBSET_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_FBSET_FANCY"
+#else
+# define IF_FEATURE_FBSET_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FBSET_FANCY(...)
+#define CONFIG_FEATURE_FBSET_READMODE 1
+#define ENABLE_FEATURE_FBSET_READMODE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FBSET_READMODE(...) __VA_ARGS__ "CONFIG_FEATURE_FBSET_READMODE"
+#else
+# define IF_FEATURE_FBSET_READMODE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FBSET_READMODE(...)
+#define CONFIG_FDFORMAT 1
+#define ENABLE_FDFORMAT 1
+#ifdef MAKE_SUID
+# define IF_FDFORMAT(...) __VA_ARGS__ "CONFIG_FDFORMAT"
+#else
+# define IF_FDFORMAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FDFORMAT(...)
+#define CONFIG_FDISK 1
+#define ENABLE_FDISK 1
+#ifdef MAKE_SUID
+# define IF_FDISK(...) __VA_ARGS__ "CONFIG_FDISK"
+#else
+# define IF_FDISK(...) __VA_ARGS__
+#endif
+#define IF_NOT_FDISK(...)
+#undef CONFIG_FDISK_SUPPORT_LARGE_DISKS
+#define ENABLE_FDISK_SUPPORT_LARGE_DISKS 0
+#define IF_FDISK_SUPPORT_LARGE_DISKS(...)
+#define IF_NOT_FDISK_SUPPORT_LARGE_DISKS(...) __VA_ARGS__
+#define CONFIG_FEATURE_FDISK_WRITABLE 1
+#define ENABLE_FEATURE_FDISK_WRITABLE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FDISK_WRITABLE(...) __VA_ARGS__ "CONFIG_FEATURE_FDISK_WRITABLE"
+#else
+# define IF_FEATURE_FDISK_WRITABLE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FDISK_WRITABLE(...)
+#define CONFIG_FEATURE_AIX_LABEL 1
+#define ENABLE_FEATURE_AIX_LABEL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_AIX_LABEL(...) __VA_ARGS__ "CONFIG_FEATURE_AIX_LABEL"
+#else
+# define IF_FEATURE_AIX_LABEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_AIX_LABEL(...)
+#define CONFIG_FEATURE_SGI_LABEL 1
+#define ENABLE_FEATURE_SGI_LABEL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SGI_LABEL(...) __VA_ARGS__ "CONFIG_FEATURE_SGI_LABEL"
+#else
+# define IF_FEATURE_SGI_LABEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SGI_LABEL(...)
+#define CONFIG_FEATURE_SUN_LABEL 1
+#define ENABLE_FEATURE_SUN_LABEL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SUN_LABEL(...) __VA_ARGS__ "CONFIG_FEATURE_SUN_LABEL"
+#else
+# define IF_FEATURE_SUN_LABEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SUN_LABEL(...)
+#define CONFIG_FEATURE_OSF_LABEL 1
+#define ENABLE_FEATURE_OSF_LABEL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_OSF_LABEL(...) __VA_ARGS__ "CONFIG_FEATURE_OSF_LABEL"
+#else
+# define IF_FEATURE_OSF_LABEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_OSF_LABEL(...)
+#undef CONFIG_FEATURE_GPT_LABEL
+#define ENABLE_FEATURE_GPT_LABEL 0
+#define IF_FEATURE_GPT_LABEL(...)
+#define IF_NOT_FEATURE_GPT_LABEL(...) __VA_ARGS__
+#define CONFIG_FEATURE_FDISK_ADVANCED 1
+#define ENABLE_FEATURE_FDISK_ADVANCED 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FDISK_ADVANCED(...) __VA_ARGS__ "CONFIG_FEATURE_FDISK_ADVANCED"
+#else
+# define IF_FEATURE_FDISK_ADVANCED(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FDISK_ADVANCED(...)
+#define CONFIG_FINDFS 1
+#define ENABLE_FINDFS 1
+#ifdef MAKE_SUID
+# define IF_FINDFS(...) __VA_ARGS__ "CONFIG_FINDFS"
+#else
+# define IF_FINDFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FINDFS(...)
+#define CONFIG_FLOCK 1
+#define ENABLE_FLOCK 1
+#ifdef MAKE_SUID
+# define IF_FLOCK(...) __VA_ARGS__ "CONFIG_FLOCK"
+#else
+# define IF_FLOCK(...) __VA_ARGS__
+#endif
+#define IF_NOT_FLOCK(...)
+#define CONFIG_FDFLUSH 1
+#define ENABLE_FDFLUSH 1
+#ifdef MAKE_SUID
+# define IF_FDFLUSH(...) __VA_ARGS__ "CONFIG_FDFLUSH"
+#else
+# define IF_FDFLUSH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FDFLUSH(...)
+#define CONFIG_FREERAMDISK 1
+#define ENABLE_FREERAMDISK 1
+#ifdef MAKE_SUID
+# define IF_FREERAMDISK(...) __VA_ARGS__ "CONFIG_FREERAMDISK"
+#else
+# define IF_FREERAMDISK(...) __VA_ARGS__
+#endif
+#define IF_NOT_FREERAMDISK(...)
+#define CONFIG_FSCK_MINIX 1
+#define ENABLE_FSCK_MINIX 1
+#ifdef MAKE_SUID
+# define IF_FSCK_MINIX(...) __VA_ARGS__ "CONFIG_FSCK_MINIX"
+#else
+# define IF_FSCK_MINIX(...) __VA_ARGS__
+#endif
+#define IF_NOT_FSCK_MINIX(...)
+#define CONFIG_FSTRIM 1
+#define ENABLE_FSTRIM 1
+#ifdef MAKE_SUID
+# define IF_FSTRIM(...) __VA_ARGS__ "CONFIG_FSTRIM"
+#else
+# define IF_FSTRIM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FSTRIM(...)
+#define CONFIG_GETOPT 1
+#define ENABLE_GETOPT 1
+#ifdef MAKE_SUID
+# define IF_GETOPT(...) __VA_ARGS__ "CONFIG_GETOPT"
+#else
+# define IF_GETOPT(...) __VA_ARGS__
+#endif
+#define IF_NOT_GETOPT(...)
+#define CONFIG_FEATURE_GETOPT_LONG 1
+#define ENABLE_FEATURE_GETOPT_LONG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_GETOPT_LONG(...) __VA_ARGS__ "CONFIG_FEATURE_GETOPT_LONG"
+#else
+# define IF_FEATURE_GETOPT_LONG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_GETOPT_LONG(...)
+#define CONFIG_HEXDUMP 1
+#define ENABLE_HEXDUMP 1
+#ifdef MAKE_SUID
+# define IF_HEXDUMP(...) __VA_ARGS__ "CONFIG_HEXDUMP"
+#else
+# define IF_HEXDUMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_HEXDUMP(...)
+#define CONFIG_FEATURE_HEXDUMP_REVERSE 1
+#define ENABLE_FEATURE_HEXDUMP_REVERSE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HEXDUMP_REVERSE(...) __VA_ARGS__ "CONFIG_FEATURE_HEXDUMP_REVERSE"
+#else
+# define IF_FEATURE_HEXDUMP_REVERSE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HEXDUMP_REVERSE(...)
+#define CONFIG_HD 1
+#define ENABLE_HD 1
+#ifdef MAKE_SUID
+# define IF_HD(...) __VA_ARGS__ "CONFIG_HD"
+#else
+# define IF_HD(...) __VA_ARGS__
+#endif
+#define IF_NOT_HD(...)
+#define CONFIG_HWCLOCK 1
+#define ENABLE_HWCLOCK 1
+#ifdef MAKE_SUID
+# define IF_HWCLOCK(...) __VA_ARGS__ "CONFIG_HWCLOCK"
+#else
+# define IF_HWCLOCK(...) __VA_ARGS__
+#endif
+#define IF_NOT_HWCLOCK(...)
+#define CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS 1
+#define ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HWCLOCK_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS"
+#else
+# define IF_FEATURE_HWCLOCK_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HWCLOCK_LONG_OPTIONS(...)
+#define CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS 1
+#define ENABLE_FEATURE_HWCLOCK_ADJTIME_FHS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HWCLOCK_ADJTIME_FHS(...) __VA_ARGS__ "CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS"
+#else
+# define IF_FEATURE_HWCLOCK_ADJTIME_FHS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HWCLOCK_ADJTIME_FHS(...)
+#define CONFIG_IPCRM 1
+#define ENABLE_IPCRM 1
+#ifdef MAKE_SUID
+# define IF_IPCRM(...) __VA_ARGS__ "CONFIG_IPCRM"
+#else
+# define IF_IPCRM(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPCRM(...)
+#define CONFIG_IPCS 1
+#define ENABLE_IPCS 1
+#ifdef MAKE_SUID
+# define IF_IPCS(...) __VA_ARGS__ "CONFIG_IPCS"
+#else
+# define IF_IPCS(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPCS(...)
+#define CONFIG_LOSETUP 1
+#define ENABLE_LOSETUP 1
+#ifdef MAKE_SUID
+# define IF_LOSETUP(...) __VA_ARGS__ "CONFIG_LOSETUP"
+#else
+# define IF_LOSETUP(...) __VA_ARGS__
+#endif
+#define IF_NOT_LOSETUP(...)
+#define CONFIG_LSPCI 1
+#define ENABLE_LSPCI 1
+#ifdef MAKE_SUID
+# define IF_LSPCI(...) __VA_ARGS__ "CONFIG_LSPCI"
+#else
+# define IF_LSPCI(...) __VA_ARGS__
+#endif
+#define IF_NOT_LSPCI(...)
+#define CONFIG_LSUSB 1
+#define ENABLE_LSUSB 1
+#ifdef MAKE_SUID
+# define IF_LSUSB(...) __VA_ARGS__ "CONFIG_LSUSB"
+#else
+# define IF_LSUSB(...) __VA_ARGS__
+#endif
+#define IF_NOT_LSUSB(...)
+#define CONFIG_MDEV 1
+#define ENABLE_MDEV 1
+#ifdef MAKE_SUID
+# define IF_MDEV(...) __VA_ARGS__ "CONFIG_MDEV"
+#else
+# define IF_MDEV(...) __VA_ARGS__
+#endif
+#define IF_NOT_MDEV(...)
+#define CONFIG_FEATURE_MDEV_CONF 1
+#define ENABLE_FEATURE_MDEV_CONF 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MDEV_CONF(...) __VA_ARGS__ "CONFIG_FEATURE_MDEV_CONF"
+#else
+# define IF_FEATURE_MDEV_CONF(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MDEV_CONF(...)
+#define CONFIG_FEATURE_MDEV_RENAME 1
+#define ENABLE_FEATURE_MDEV_RENAME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MDEV_RENAME(...) __VA_ARGS__ "CONFIG_FEATURE_MDEV_RENAME"
+#else
+# define IF_FEATURE_MDEV_RENAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MDEV_RENAME(...)
+#define CONFIG_FEATURE_MDEV_RENAME_REGEXP 1
+#define ENABLE_FEATURE_MDEV_RENAME_REGEXP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MDEV_RENAME_REGEXP(...) __VA_ARGS__ "CONFIG_FEATURE_MDEV_RENAME_REGEXP"
+#else
+# define IF_FEATURE_MDEV_RENAME_REGEXP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MDEV_RENAME_REGEXP(...)
+#define CONFIG_FEATURE_MDEV_EXEC 1
+#define ENABLE_FEATURE_MDEV_EXEC 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MDEV_EXEC(...) __VA_ARGS__ "CONFIG_FEATURE_MDEV_EXEC"
+#else
+# define IF_FEATURE_MDEV_EXEC(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MDEV_EXEC(...)
+#define CONFIG_FEATURE_MDEV_LOAD_FIRMWARE 1
+#define ENABLE_FEATURE_MDEV_LOAD_FIRMWARE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MDEV_LOAD_FIRMWARE(...) __VA_ARGS__ "CONFIG_FEATURE_MDEV_LOAD_FIRMWARE"
+#else
+# define IF_FEATURE_MDEV_LOAD_FIRMWARE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MDEV_LOAD_FIRMWARE(...)
+#define CONFIG_MKE2FS 1
+#define ENABLE_MKE2FS 1
+#ifdef MAKE_SUID
+# define IF_MKE2FS(...) __VA_ARGS__ "CONFIG_MKE2FS"
+#else
+# define IF_MKE2FS(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKE2FS(...)
+#define CONFIG_MKFS_EXT2 1
+#define ENABLE_MKFS_EXT2 1
+#ifdef MAKE_SUID
+# define IF_MKFS_EXT2(...) __VA_ARGS__ "CONFIG_MKFS_EXT2"
+#else
+# define IF_MKFS_EXT2(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKFS_EXT2(...)
+#define CONFIG_MKFS_MINIX 1
+#define ENABLE_MKFS_MINIX 1
+#ifdef MAKE_SUID
+# define IF_MKFS_MINIX(...) __VA_ARGS__ "CONFIG_MKFS_MINIX"
+#else
+# define IF_MKFS_MINIX(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKFS_MINIX(...)
+#define CONFIG_FEATURE_MINIX2 1
+#define ENABLE_FEATURE_MINIX2 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MINIX2(...) __VA_ARGS__ "CONFIG_FEATURE_MINIX2"
+#else
+# define IF_FEATURE_MINIX2(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MINIX2(...)
+#define CONFIG_MKFS_REISER 1
+#define ENABLE_MKFS_REISER 1
+#ifdef MAKE_SUID
+# define IF_MKFS_REISER(...) __VA_ARGS__ "CONFIG_MKFS_REISER"
+#else
+# define IF_MKFS_REISER(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKFS_REISER(...)
+#define CONFIG_MKDOSFS 1
+#define ENABLE_MKDOSFS 1
+#ifdef MAKE_SUID
+# define IF_MKDOSFS(...) __VA_ARGS__ "CONFIG_MKDOSFS"
+#else
+# define IF_MKDOSFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKDOSFS(...)
+#define CONFIG_MKFS_VFAT 1
+#define ENABLE_MKFS_VFAT 1
+#ifdef MAKE_SUID
+# define IF_MKFS_VFAT(...) __VA_ARGS__ "CONFIG_MKFS_VFAT"
+#else
+# define IF_MKFS_VFAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKFS_VFAT(...)
+#define CONFIG_MKSWAP 1
+#define ENABLE_MKSWAP 1
+#ifdef MAKE_SUID
+# define IF_MKSWAP(...) __VA_ARGS__ "CONFIG_MKSWAP"
+#else
+# define IF_MKSWAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_MKSWAP(...)
+#define CONFIG_FEATURE_MKSWAP_UUID 1
+#define ENABLE_FEATURE_MKSWAP_UUID 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MKSWAP_UUID(...) __VA_ARGS__ "CONFIG_FEATURE_MKSWAP_UUID"
+#else
+# define IF_FEATURE_MKSWAP_UUID(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MKSWAP_UUID(...)
+#define CONFIG_MORE 1
+#define ENABLE_MORE 1
+#ifdef MAKE_SUID
+# define IF_MORE(...) __VA_ARGS__ "CONFIG_MORE"
+#else
+# define IF_MORE(...) __VA_ARGS__
+#endif
+#define IF_NOT_MORE(...)
+#define CONFIG_MOUNT 1
+#define ENABLE_MOUNT 1
+#ifdef MAKE_SUID
+# define IF_MOUNT(...) __VA_ARGS__ "CONFIG_MOUNT"
+#else
+# define IF_MOUNT(...) __VA_ARGS__
+#endif
+#define IF_NOT_MOUNT(...)
+#define CONFIG_FEATURE_MOUNT_FAKE 1
+#define ENABLE_FEATURE_MOUNT_FAKE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_FAKE(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_FAKE"
+#else
+# define IF_FEATURE_MOUNT_FAKE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_FAKE(...)
+#define CONFIG_FEATURE_MOUNT_VERBOSE 1
+#define ENABLE_FEATURE_MOUNT_VERBOSE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_VERBOSE(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_VERBOSE"
+#else
+# define IF_FEATURE_MOUNT_VERBOSE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_VERBOSE(...)
+#define CONFIG_FEATURE_MOUNT_HELPERS 1
+#define ENABLE_FEATURE_MOUNT_HELPERS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_HELPERS(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_HELPERS"
+#else
+# define IF_FEATURE_MOUNT_HELPERS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_HELPERS(...)
+#define CONFIG_FEATURE_MOUNT_LABEL 1
+#define ENABLE_FEATURE_MOUNT_LABEL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_LABEL(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_LABEL"
+#else
+# define IF_FEATURE_MOUNT_LABEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_LABEL(...)
+#define CONFIG_FEATURE_MOUNT_NFS 1
+#define ENABLE_FEATURE_MOUNT_NFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_NFS(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_NFS"
+#else
+# define IF_FEATURE_MOUNT_NFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_NFS(...)
+#define CONFIG_FEATURE_MOUNT_CIFS 1
+#define ENABLE_FEATURE_MOUNT_CIFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_CIFS(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_CIFS"
+#else
+# define IF_FEATURE_MOUNT_CIFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_CIFS(...)
+#define CONFIG_FEATURE_MOUNT_FLAGS 1
+#define ENABLE_FEATURE_MOUNT_FLAGS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_FLAGS(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_FLAGS"
+#else
+# define IF_FEATURE_MOUNT_FLAGS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_FLAGS(...)
+#define CONFIG_FEATURE_MOUNT_FSTAB 1
+#define ENABLE_FEATURE_MOUNT_FSTAB 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_FSTAB(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_FSTAB"
+#else
+# define IF_FEATURE_MOUNT_FSTAB(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_FSTAB(...)
+#define CONFIG_FEATURE_MOUNT_OTHERTAB 1
+#define ENABLE_FEATURE_MOUNT_OTHERTAB 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_OTHERTAB(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_OTHERTAB"
+#else
+# define IF_FEATURE_MOUNT_OTHERTAB(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_OTHERTAB(...)
+#define CONFIG_NSENTER 1
+#define ENABLE_NSENTER 1
+#ifdef MAKE_SUID
+# define IF_NSENTER(...) __VA_ARGS__ "CONFIG_NSENTER"
+#else
+# define IF_NSENTER(...) __VA_ARGS__
+#endif
+#define IF_NOT_NSENTER(...)
+#define CONFIG_FEATURE_NSENTER_LONG_OPTS 1
+#define ENABLE_FEATURE_NSENTER_LONG_OPTS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_NSENTER_LONG_OPTS(...) __VA_ARGS__ "CONFIG_FEATURE_NSENTER_LONG_OPTS"
+#else
+# define IF_FEATURE_NSENTER_LONG_OPTS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_NSENTER_LONG_OPTS(...)
+#define CONFIG_PIVOT_ROOT 1
+#define ENABLE_PIVOT_ROOT 1
+#ifdef MAKE_SUID
+# define IF_PIVOT_ROOT(...) __VA_ARGS__ "CONFIG_PIVOT_ROOT"
+#else
+# define IF_PIVOT_ROOT(...) __VA_ARGS__
+#endif
+#define IF_NOT_PIVOT_ROOT(...)
+#define CONFIG_RDATE 1
+#define ENABLE_RDATE 1
+#ifdef MAKE_SUID
+# define IF_RDATE(...) __VA_ARGS__ "CONFIG_RDATE"
+#else
+# define IF_RDATE(...) __VA_ARGS__
+#endif
+#define IF_NOT_RDATE(...)
+#define CONFIG_RDEV 1
+#define ENABLE_RDEV 1
+#ifdef MAKE_SUID
+# define IF_RDEV(...) __VA_ARGS__ "CONFIG_RDEV"
+#else
+# define IF_RDEV(...) __VA_ARGS__
+#endif
+#define IF_NOT_RDEV(...)
+#define CONFIG_READPROFILE 1
+#define ENABLE_READPROFILE 1
+#ifdef MAKE_SUID
+# define IF_READPROFILE(...) __VA_ARGS__ "CONFIG_READPROFILE"
+#else
+# define IF_READPROFILE(...) __VA_ARGS__
+#endif
+#define IF_NOT_READPROFILE(...)
+#define CONFIG_REV 1
+#define ENABLE_REV 1
+#ifdef MAKE_SUID
+# define IF_REV(...) __VA_ARGS__ "CONFIG_REV"
+#else
+# define IF_REV(...) __VA_ARGS__
+#endif
+#define IF_NOT_REV(...)
+#define CONFIG_RTCWAKE 1
+#define ENABLE_RTCWAKE 1
+#ifdef MAKE_SUID
+# define IF_RTCWAKE(...) __VA_ARGS__ "CONFIG_RTCWAKE"
+#else
+# define IF_RTCWAKE(...) __VA_ARGS__
+#endif
+#define IF_NOT_RTCWAKE(...)
+#define CONFIG_SCRIPT 1
+#define ENABLE_SCRIPT 1
+#ifdef MAKE_SUID
+# define IF_SCRIPT(...) __VA_ARGS__ "CONFIG_SCRIPT"
+#else
+# define IF_SCRIPT(...) __VA_ARGS__
+#endif
+#define IF_NOT_SCRIPT(...)
+#define CONFIG_SCRIPTREPLAY 1
+#define ENABLE_SCRIPTREPLAY 1
+#ifdef MAKE_SUID
+# define IF_SCRIPTREPLAY(...) __VA_ARGS__ "CONFIG_SCRIPTREPLAY"
+#else
+# define IF_SCRIPTREPLAY(...) __VA_ARGS__
+#endif
+#define IF_NOT_SCRIPTREPLAY(...)
+#define CONFIG_SETARCH 1
+#define ENABLE_SETARCH 1
+#ifdef MAKE_SUID
+# define IF_SETARCH(...) __VA_ARGS__ "CONFIG_SETARCH"
+#else
+# define IF_SETARCH(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETARCH(...)
+#define CONFIG_LINUX32 1
+#define ENABLE_LINUX32 1
+#ifdef MAKE_SUID
+# define IF_LINUX32(...) __VA_ARGS__ "CONFIG_LINUX32"
+#else
+# define IF_LINUX32(...) __VA_ARGS__
+#endif
+#define IF_NOT_LINUX32(...)
+#define CONFIG_LINUX64 1
+#define ENABLE_LINUX64 1
+#ifdef MAKE_SUID
+# define IF_LINUX64(...) __VA_ARGS__ "CONFIG_LINUX64"
+#else
+# define IF_LINUX64(...) __VA_ARGS__
+#endif
+#define IF_NOT_LINUX64(...)
+#define CONFIG_SWAPON 1
+#define ENABLE_SWAPON 1
+#ifdef MAKE_SUID
+# define IF_SWAPON(...) __VA_ARGS__ "CONFIG_SWAPON"
+#else
+# define IF_SWAPON(...) __VA_ARGS__
+#endif
+#define IF_NOT_SWAPON(...)
+#define CONFIG_FEATURE_SWAPON_DISCARD 1
+#define ENABLE_FEATURE_SWAPON_DISCARD 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SWAPON_DISCARD(...) __VA_ARGS__ "CONFIG_FEATURE_SWAPON_DISCARD"
+#else
+# define IF_FEATURE_SWAPON_DISCARD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SWAPON_DISCARD(...)
+#define CONFIG_FEATURE_SWAPON_PRI 1
+#define ENABLE_FEATURE_SWAPON_PRI 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SWAPON_PRI(...) __VA_ARGS__ "CONFIG_FEATURE_SWAPON_PRI"
+#else
+# define IF_FEATURE_SWAPON_PRI(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SWAPON_PRI(...)
+#define CONFIG_SWAPOFF 1
+#define ENABLE_SWAPOFF 1
+#ifdef MAKE_SUID
+# define IF_SWAPOFF(...) __VA_ARGS__ "CONFIG_SWAPOFF"
+#else
+# define IF_SWAPOFF(...) __VA_ARGS__
+#endif
+#define IF_NOT_SWAPOFF(...)
+#define CONFIG_SWITCH_ROOT 1
+#define ENABLE_SWITCH_ROOT 1
+#ifdef MAKE_SUID
+# define IF_SWITCH_ROOT(...) __VA_ARGS__ "CONFIG_SWITCH_ROOT"
+#else
+# define IF_SWITCH_ROOT(...) __VA_ARGS__
+#endif
+#define IF_NOT_SWITCH_ROOT(...)
+#define CONFIG_UEVENT 1
+#define ENABLE_UEVENT 1
+#ifdef MAKE_SUID
+# define IF_UEVENT(...) __VA_ARGS__ "CONFIG_UEVENT"
+#else
+# define IF_UEVENT(...) __VA_ARGS__
+#endif
+#define IF_NOT_UEVENT(...)
+#define CONFIG_UMOUNT 1
+#define ENABLE_UMOUNT 1
+#ifdef MAKE_SUID
+# define IF_UMOUNT(...) __VA_ARGS__ "CONFIG_UMOUNT"
+#else
+# define IF_UMOUNT(...) __VA_ARGS__
+#endif
+#define IF_NOT_UMOUNT(...)
+#define CONFIG_FEATURE_UMOUNT_ALL 1
+#define ENABLE_FEATURE_UMOUNT_ALL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UMOUNT_ALL(...) __VA_ARGS__ "CONFIG_FEATURE_UMOUNT_ALL"
+#else
+# define IF_FEATURE_UMOUNT_ALL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UMOUNT_ALL(...)
+#undef CONFIG_UNSHARE
+#define ENABLE_UNSHARE 0
+#define IF_UNSHARE(...)
+#define IF_NOT_UNSHARE(...) __VA_ARGS__
+
+/*
+ * Common options for mount/umount
+ */
+#define CONFIG_FEATURE_MOUNT_LOOP 1
+#define ENABLE_FEATURE_MOUNT_LOOP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_LOOP(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_LOOP"
+#else
+# define IF_FEATURE_MOUNT_LOOP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_LOOP(...)
+#define CONFIG_FEATURE_MOUNT_LOOP_CREATE 1
+#define ENABLE_FEATURE_MOUNT_LOOP_CREATE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MOUNT_LOOP_CREATE(...) __VA_ARGS__ "CONFIG_FEATURE_MOUNT_LOOP_CREATE"
+#else
+# define IF_FEATURE_MOUNT_LOOP_CREATE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MOUNT_LOOP_CREATE(...)
+#undef CONFIG_FEATURE_MTAB_SUPPORT
+#define ENABLE_FEATURE_MTAB_SUPPORT 0
+#define IF_FEATURE_MTAB_SUPPORT(...)
+#define IF_NOT_FEATURE_MTAB_SUPPORT(...) __VA_ARGS__
+#define CONFIG_VOLUMEID 1
+#define ENABLE_VOLUMEID 1
+#ifdef MAKE_SUID
+# define IF_VOLUMEID(...) __VA_ARGS__ "CONFIG_VOLUMEID"
+#else
+# define IF_VOLUMEID(...) __VA_ARGS__
+#endif
+#define IF_NOT_VOLUMEID(...)
+
+/*
+ * Filesystem/Volume identification
+ */
+#define CONFIG_FEATURE_VOLUMEID_BCACHE 1
+#define ENABLE_FEATURE_VOLUMEID_BCACHE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_BCACHE(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_BCACHE"
+#else
+# define IF_FEATURE_VOLUMEID_BCACHE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_BCACHE(...)
+#define CONFIG_FEATURE_VOLUMEID_BTRFS 1
+#define ENABLE_FEATURE_VOLUMEID_BTRFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_BTRFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_BTRFS"
+#else
+# define IF_FEATURE_VOLUMEID_BTRFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_BTRFS(...)
+#define CONFIG_FEATURE_VOLUMEID_CRAMFS 1
+#define ENABLE_FEATURE_VOLUMEID_CRAMFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_CRAMFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_CRAMFS"
+#else
+# define IF_FEATURE_VOLUMEID_CRAMFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_CRAMFS(...)
+#define CONFIG_FEATURE_VOLUMEID_EXFAT 1
+#define ENABLE_FEATURE_VOLUMEID_EXFAT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_EXFAT(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_EXFAT"
+#else
+# define IF_FEATURE_VOLUMEID_EXFAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_EXFAT(...)
+#define CONFIG_FEATURE_VOLUMEID_EXT 1
+#define ENABLE_FEATURE_VOLUMEID_EXT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_EXT(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_EXT"
+#else
+# define IF_FEATURE_VOLUMEID_EXT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_EXT(...)
+#define CONFIG_FEATURE_VOLUMEID_F2FS 1
+#define ENABLE_FEATURE_VOLUMEID_F2FS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_F2FS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_F2FS"
+#else
+# define IF_FEATURE_VOLUMEID_F2FS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_F2FS(...)
+#define CONFIG_FEATURE_VOLUMEID_FAT 1
+#define ENABLE_FEATURE_VOLUMEID_FAT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_FAT(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_FAT"
+#else
+# define IF_FEATURE_VOLUMEID_FAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_FAT(...)
+#define CONFIG_FEATURE_VOLUMEID_HFS 1
+#define ENABLE_FEATURE_VOLUMEID_HFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_HFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_HFS"
+#else
+# define IF_FEATURE_VOLUMEID_HFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_HFS(...)
+#define CONFIG_FEATURE_VOLUMEID_ISO9660 1
+#define ENABLE_FEATURE_VOLUMEID_ISO9660 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_ISO9660(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_ISO9660"
+#else
+# define IF_FEATURE_VOLUMEID_ISO9660(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_ISO9660(...)
+#define CONFIG_FEATURE_VOLUMEID_JFS 1
+#define ENABLE_FEATURE_VOLUMEID_JFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_JFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_JFS"
+#else
+# define IF_FEATURE_VOLUMEID_JFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_JFS(...)
+#define CONFIG_FEATURE_VOLUMEID_LINUXRAID 1
+#define ENABLE_FEATURE_VOLUMEID_LINUXRAID 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_LINUXRAID(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_LINUXRAID"
+#else
+# define IF_FEATURE_VOLUMEID_LINUXRAID(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_LINUXRAID(...)
+#define CONFIG_FEATURE_VOLUMEID_LINUXSWAP 1
+#define ENABLE_FEATURE_VOLUMEID_LINUXSWAP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_LINUXSWAP(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_LINUXSWAP"
+#else
+# define IF_FEATURE_VOLUMEID_LINUXSWAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_LINUXSWAP(...)
+#define CONFIG_FEATURE_VOLUMEID_LUKS 1
+#define ENABLE_FEATURE_VOLUMEID_LUKS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_LUKS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_LUKS"
+#else
+# define IF_FEATURE_VOLUMEID_LUKS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_LUKS(...)
+#define CONFIG_FEATURE_VOLUMEID_NILFS 1
+#define ENABLE_FEATURE_VOLUMEID_NILFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_NILFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_NILFS"
+#else
+# define IF_FEATURE_VOLUMEID_NILFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_NILFS(...)
+#define CONFIG_FEATURE_VOLUMEID_NTFS 1
+#define ENABLE_FEATURE_VOLUMEID_NTFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_NTFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_NTFS"
+#else
+# define IF_FEATURE_VOLUMEID_NTFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_NTFS(...)
+#define CONFIG_FEATURE_VOLUMEID_OCFS2 1
+#define ENABLE_FEATURE_VOLUMEID_OCFS2 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_OCFS2(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_OCFS2"
+#else
+# define IF_FEATURE_VOLUMEID_OCFS2(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_OCFS2(...)
+#define CONFIG_FEATURE_VOLUMEID_REISERFS 1
+#define ENABLE_FEATURE_VOLUMEID_REISERFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_REISERFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_REISERFS"
+#else
+# define IF_FEATURE_VOLUMEID_REISERFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_REISERFS(...)
+#define CONFIG_FEATURE_VOLUMEID_ROMFS 1
+#define ENABLE_FEATURE_VOLUMEID_ROMFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_ROMFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_ROMFS"
+#else
+# define IF_FEATURE_VOLUMEID_ROMFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_ROMFS(...)
+#undef CONFIG_FEATURE_VOLUMEID_SQUASHFS
+#define ENABLE_FEATURE_VOLUMEID_SQUASHFS 0
+#define IF_FEATURE_VOLUMEID_SQUASHFS(...)
+#define IF_NOT_FEATURE_VOLUMEID_SQUASHFS(...) __VA_ARGS__
+#define CONFIG_FEATURE_VOLUMEID_SYSV 1
+#define ENABLE_FEATURE_VOLUMEID_SYSV 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_SYSV(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_SYSV"
+#else
+# define IF_FEATURE_VOLUMEID_SYSV(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_SYSV(...)
+#define CONFIG_FEATURE_VOLUMEID_UBIFS 1
+#define ENABLE_FEATURE_VOLUMEID_UBIFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_UBIFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_UBIFS"
+#else
+# define IF_FEATURE_VOLUMEID_UBIFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_UBIFS(...)
+#define CONFIG_FEATURE_VOLUMEID_UDF 1
+#define ENABLE_FEATURE_VOLUMEID_UDF 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_UDF(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_UDF"
+#else
+# define IF_FEATURE_VOLUMEID_UDF(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_UDF(...)
+#define CONFIG_FEATURE_VOLUMEID_XFS 1
+#define ENABLE_FEATURE_VOLUMEID_XFS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_VOLUMEID_XFS(...) __VA_ARGS__ "CONFIG_FEATURE_VOLUMEID_XFS"
+#else
+# define IF_FEATURE_VOLUMEID_XFS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_VOLUMEID_XFS(...)
+
+/*
+ * Miscellaneous Utilities
+ */
+#define CONFIG_ADJTIMEX 1
+#define ENABLE_ADJTIMEX 1
+#ifdef MAKE_SUID
+# define IF_ADJTIMEX(...) __VA_ARGS__ "CONFIG_ADJTIMEX"
+#else
+# define IF_ADJTIMEX(...) __VA_ARGS__
+#endif
+#define IF_NOT_ADJTIMEX(...)
+#define CONFIG_BBCONFIG 1
+#define ENABLE_BBCONFIG 1
+#ifdef MAKE_SUID
+# define IF_BBCONFIG(...) __VA_ARGS__ "CONFIG_BBCONFIG"
+#else
+# define IF_BBCONFIG(...) __VA_ARGS__
+#endif
+#define IF_NOT_BBCONFIG(...)
+#define CONFIG_FEATURE_COMPRESS_BBCONFIG 1
+#define ENABLE_FEATURE_COMPRESS_BBCONFIG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_COMPRESS_BBCONFIG(...) __VA_ARGS__ "CONFIG_FEATURE_COMPRESS_BBCONFIG"
+#else
+# define IF_FEATURE_COMPRESS_BBCONFIG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_COMPRESS_BBCONFIG(...)
+#define CONFIG_BEEP 1
+#define ENABLE_BEEP 1
+#ifdef MAKE_SUID
+# define IF_BEEP(...) __VA_ARGS__ "CONFIG_BEEP"
+#else
+# define IF_BEEP(...) __VA_ARGS__
+#endif
+#define IF_NOT_BEEP(...)
+#define CONFIG_FEATURE_BEEP_FREQ 4000
+#define ENABLE_FEATURE_BEEP_FREQ 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_BEEP_FREQ(...) __VA_ARGS__ "CONFIG_FEATURE_BEEP_FREQ"
+#else
+# define IF_FEATURE_BEEP_FREQ(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_BEEP_FREQ(...)
+#define CONFIG_FEATURE_BEEP_LENGTH_MS 30
+#define ENABLE_FEATURE_BEEP_LENGTH_MS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_BEEP_LENGTH_MS(...) __VA_ARGS__ "CONFIG_FEATURE_BEEP_LENGTH_MS"
+#else
+# define IF_FEATURE_BEEP_LENGTH_MS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_BEEP_LENGTH_MS(...)
+#define CONFIG_CHAT 1
+#define ENABLE_CHAT 1
+#ifdef MAKE_SUID
+# define IF_CHAT(...) __VA_ARGS__ "CONFIG_CHAT"
+#else
+# define IF_CHAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHAT(...)
+#define CONFIG_FEATURE_CHAT_NOFAIL 1
+#define ENABLE_FEATURE_CHAT_NOFAIL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHAT_NOFAIL(...) __VA_ARGS__ "CONFIG_FEATURE_CHAT_NOFAIL"
+#else
+# define IF_FEATURE_CHAT_NOFAIL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHAT_NOFAIL(...)
+#define CONFIG_FEATURE_CHAT_TTY_HIFI 1
+#define ENABLE_FEATURE_CHAT_TTY_HIFI 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHAT_TTY_HIFI(...) __VA_ARGS__ "CONFIG_FEATURE_CHAT_TTY_HIFI"
+#else
+# define IF_FEATURE_CHAT_TTY_HIFI(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHAT_TTY_HIFI(...)
+#define CONFIG_FEATURE_CHAT_IMPLICIT_CR 1
+#define ENABLE_FEATURE_CHAT_IMPLICIT_CR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHAT_IMPLICIT_CR(...) __VA_ARGS__ "CONFIG_FEATURE_CHAT_IMPLICIT_CR"
+#else
+# define IF_FEATURE_CHAT_IMPLICIT_CR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHAT_IMPLICIT_CR(...)
+#define CONFIG_FEATURE_CHAT_SWALLOW_OPTS 1
+#define ENABLE_FEATURE_CHAT_SWALLOW_OPTS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHAT_SWALLOW_OPTS(...) __VA_ARGS__ "CONFIG_FEATURE_CHAT_SWALLOW_OPTS"
+#else
+# define IF_FEATURE_CHAT_SWALLOW_OPTS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHAT_SWALLOW_OPTS(...)
+#define CONFIG_FEATURE_CHAT_SEND_ESCAPES 1
+#define ENABLE_FEATURE_CHAT_SEND_ESCAPES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHAT_SEND_ESCAPES(...) __VA_ARGS__ "CONFIG_FEATURE_CHAT_SEND_ESCAPES"
+#else
+# define IF_FEATURE_CHAT_SEND_ESCAPES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHAT_SEND_ESCAPES(...)
+#define CONFIG_FEATURE_CHAT_VAR_ABORT_LEN 1
+#define ENABLE_FEATURE_CHAT_VAR_ABORT_LEN 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHAT_VAR_ABORT_LEN(...) __VA_ARGS__ "CONFIG_FEATURE_CHAT_VAR_ABORT_LEN"
+#else
+# define IF_FEATURE_CHAT_VAR_ABORT_LEN(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHAT_VAR_ABORT_LEN(...)
+#define CONFIG_FEATURE_CHAT_CLR_ABORT 1
+#define ENABLE_FEATURE_CHAT_CLR_ABORT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CHAT_CLR_ABORT(...) __VA_ARGS__ "CONFIG_FEATURE_CHAT_CLR_ABORT"
+#else
+# define IF_FEATURE_CHAT_CLR_ABORT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CHAT_CLR_ABORT(...)
+#define CONFIG_CHRT 1
+#define ENABLE_CHRT 1
+#ifdef MAKE_SUID
+# define IF_CHRT(...) __VA_ARGS__ "CONFIG_CHRT"
+#else
+# define IF_CHRT(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHRT(...)
+#define CONFIG_CONSPY 1
+#define ENABLE_CONSPY 1
+#ifdef MAKE_SUID
+# define IF_CONSPY(...) __VA_ARGS__ "CONFIG_CONSPY"
+#else
+# define IF_CONSPY(...) __VA_ARGS__
+#endif
+#define IF_NOT_CONSPY(...)
+#define CONFIG_CROND 1
+#define ENABLE_CROND 1
+#ifdef MAKE_SUID
+# define IF_CROND(...) __VA_ARGS__ "CONFIG_CROND"
+#else
+# define IF_CROND(...) __VA_ARGS__
+#endif
+#define IF_NOT_CROND(...)
+#define CONFIG_FEATURE_CROND_D 1
+#define ENABLE_FEATURE_CROND_D 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CROND_D(...) __VA_ARGS__ "CONFIG_FEATURE_CROND_D"
+#else
+# define IF_FEATURE_CROND_D(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CROND_D(...)
+#define CONFIG_FEATURE_CROND_CALL_SENDMAIL 1
+#define ENABLE_FEATURE_CROND_CALL_SENDMAIL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CROND_CALL_SENDMAIL(...) __VA_ARGS__ "CONFIG_FEATURE_CROND_CALL_SENDMAIL"
+#else
+# define IF_FEATURE_CROND_CALL_SENDMAIL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CROND_CALL_SENDMAIL(...)
+#define CONFIG_FEATURE_CROND_DIR "/var/spool/cron"
+#define ENABLE_FEATURE_CROND_DIR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_CROND_DIR(...) __VA_ARGS__ "CONFIG_FEATURE_CROND_DIR"
+#else
+# define IF_FEATURE_CROND_DIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_CROND_DIR(...)
+#define CONFIG_CRONTAB 1
+#define ENABLE_CRONTAB 1
+#ifdef MAKE_SUID
+# define IF_CRONTAB(...) __VA_ARGS__ "CONFIG_CRONTAB"
+#else
+# define IF_CRONTAB(...) __VA_ARGS__
+#endif
+#define IF_NOT_CRONTAB(...)
+#define CONFIG_DC 1
+#define ENABLE_DC 1
+#ifdef MAKE_SUID
+# define IF_DC(...) __VA_ARGS__ "CONFIG_DC"
+#else
+# define IF_DC(...) __VA_ARGS__
+#endif
+#define IF_NOT_DC(...)
+#define CONFIG_FEATURE_DC_LIBM 1
+#define ENABLE_FEATURE_DC_LIBM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_DC_LIBM(...) __VA_ARGS__ "CONFIG_FEATURE_DC_LIBM"
+#else
+# define IF_FEATURE_DC_LIBM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_DC_LIBM(...)
+#undef CONFIG_DEVFSD
+#define ENABLE_DEVFSD 0
+#define IF_DEVFSD(...)
+#define IF_NOT_DEVFSD(...) __VA_ARGS__
+#undef CONFIG_DEVFSD_MODLOAD
+#define ENABLE_DEVFSD_MODLOAD 0
+#define IF_DEVFSD_MODLOAD(...)
+#define IF_NOT_DEVFSD_MODLOAD(...) __VA_ARGS__
+#undef CONFIG_DEVFSD_FG_NP
+#define ENABLE_DEVFSD_FG_NP 0
+#define IF_DEVFSD_FG_NP(...)
+#define IF_NOT_DEVFSD_FG_NP(...) __VA_ARGS__
+#undef CONFIG_DEVFSD_VERBOSE
+#define ENABLE_DEVFSD_VERBOSE 0
+#define IF_DEVFSD_VERBOSE(...)
+#define IF_NOT_DEVFSD_VERBOSE(...) __VA_ARGS__
+#undef CONFIG_FEATURE_DEVFS
+#define ENABLE_FEATURE_DEVFS 0
+#define IF_FEATURE_DEVFS(...)
+#define IF_NOT_FEATURE_DEVFS(...) __VA_ARGS__
+#define CONFIG_DEVMEM 1
+#define ENABLE_DEVMEM 1
+#ifdef MAKE_SUID
+# define IF_DEVMEM(...) __VA_ARGS__ "CONFIG_DEVMEM"
+#else
+# define IF_DEVMEM(...) __VA_ARGS__
+#endif
+#define IF_NOT_DEVMEM(...)
+#define CONFIG_EJECT 1
+#define ENABLE_EJECT 1
+#ifdef MAKE_SUID
+# define IF_EJECT(...) __VA_ARGS__ "CONFIG_EJECT"
+#else
+# define IF_EJECT(...) __VA_ARGS__
+#endif
+#define IF_NOT_EJECT(...)
+#define CONFIG_FEATURE_EJECT_SCSI 1
+#define ENABLE_FEATURE_EJECT_SCSI 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_EJECT_SCSI(...) __VA_ARGS__ "CONFIG_FEATURE_EJECT_SCSI"
+#else
+# define IF_FEATURE_EJECT_SCSI(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_EJECT_SCSI(...)
+#define CONFIG_FBSPLASH 1
+#define ENABLE_FBSPLASH 1
+#ifdef MAKE_SUID
+# define IF_FBSPLASH(...) __VA_ARGS__ "CONFIG_FBSPLASH"
+#else
+# define IF_FBSPLASH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FBSPLASH(...)
+#undef CONFIG_FLASH_ERASEALL
+#define ENABLE_FLASH_ERASEALL 0
+#define IF_FLASH_ERASEALL(...)
+#define IF_NOT_FLASH_ERASEALL(...) __VA_ARGS__
+#undef CONFIG_FLASH_LOCK
+#define ENABLE_FLASH_LOCK 0
+#define IF_FLASH_LOCK(...)
+#define IF_NOT_FLASH_LOCK(...) __VA_ARGS__
+#undef CONFIG_FLASH_UNLOCK
+#define ENABLE_FLASH_UNLOCK 0
+#define IF_FLASH_UNLOCK(...)
+#define IF_NOT_FLASH_UNLOCK(...) __VA_ARGS__
+#define CONFIG_FLASHCP 1
+#define ENABLE_FLASHCP 1
+#ifdef MAKE_SUID
+# define IF_FLASHCP(...) __VA_ARGS__ "CONFIG_FLASHCP"
+#else
+# define IF_FLASHCP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FLASHCP(...)
+#define CONFIG_HDPARM 1
+#define ENABLE_HDPARM 1
+#ifdef MAKE_SUID
+# define IF_HDPARM(...) __VA_ARGS__ "CONFIG_HDPARM"
+#else
+# define IF_HDPARM(...) __VA_ARGS__
+#endif
+#define IF_NOT_HDPARM(...)
+#define CONFIG_FEATURE_HDPARM_GET_IDENTITY 1
+#define ENABLE_FEATURE_HDPARM_GET_IDENTITY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HDPARM_GET_IDENTITY(...) __VA_ARGS__ "CONFIG_FEATURE_HDPARM_GET_IDENTITY"
+#else
+# define IF_FEATURE_HDPARM_GET_IDENTITY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HDPARM_GET_IDENTITY(...)
+#define CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF 1
+#define ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HDPARM_HDIO_SCAN_HWIF(...) __VA_ARGS__ "CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF"
+#else
+# define IF_FEATURE_HDPARM_HDIO_SCAN_HWIF(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HDPARM_HDIO_SCAN_HWIF(...)
+#define CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF 1
+#define ENABLE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(...) __VA_ARGS__ "CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF"
+#else
+# define IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(...)
+#define CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET 1
+#define ENABLE_FEATURE_HDPARM_HDIO_DRIVE_RESET 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HDPARM_HDIO_DRIVE_RESET(...) __VA_ARGS__ "CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET"
+#else
+# define IF_FEATURE_HDPARM_HDIO_DRIVE_RESET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HDPARM_HDIO_DRIVE_RESET(...)
+#define CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF 1
+#define ENABLE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(...) __VA_ARGS__ "CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF"
+#else
+# define IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(...)
+#define CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA 1
+#define ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HDPARM_HDIO_GETSET_DMA(...) __VA_ARGS__ "CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA"
+#else
+# define IF_FEATURE_HDPARM_HDIO_GETSET_DMA(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HDPARM_HDIO_GETSET_DMA(...)
+#define CONFIG_I2CGET 1
+#define ENABLE_I2CGET 1
+#ifdef MAKE_SUID
+# define IF_I2CGET(...) __VA_ARGS__ "CONFIG_I2CGET"
+#else
+# define IF_I2CGET(...) __VA_ARGS__
+#endif
+#define IF_NOT_I2CGET(...)
+#define CONFIG_I2CSET 1
+#define ENABLE_I2CSET 1
+#ifdef MAKE_SUID
+# define IF_I2CSET(...) __VA_ARGS__ "CONFIG_I2CSET"
+#else
+# define IF_I2CSET(...) __VA_ARGS__
+#endif
+#define IF_NOT_I2CSET(...)
+#define CONFIG_I2CDUMP 1
+#define ENABLE_I2CDUMP 1
+#ifdef MAKE_SUID
+# define IF_I2CDUMP(...) __VA_ARGS__ "CONFIG_I2CDUMP"
+#else
+# define IF_I2CDUMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_I2CDUMP(...)
+#define CONFIG_I2CDETECT 1
+#define ENABLE_I2CDETECT 1
+#ifdef MAKE_SUID
+# define IF_I2CDETECT(...) __VA_ARGS__ "CONFIG_I2CDETECT"
+#else
+# define IF_I2CDETECT(...) __VA_ARGS__
+#endif
+#define IF_NOT_I2CDETECT(...)
+#define CONFIG_INOTIFYD 1
+#define ENABLE_INOTIFYD 1
+#ifdef MAKE_SUID
+# define IF_INOTIFYD(...) __VA_ARGS__ "CONFIG_INOTIFYD"
+#else
+# define IF_INOTIFYD(...) __VA_ARGS__
+#endif
+#define IF_NOT_INOTIFYD(...)
+#define CONFIG_IONICE 1
+#define ENABLE_IONICE 1
+#ifdef MAKE_SUID
+# define IF_IONICE(...) __VA_ARGS__ "CONFIG_IONICE"
+#else
+# define IF_IONICE(...) __VA_ARGS__
+#endif
+#define IF_NOT_IONICE(...)
+#define CONFIG_LAST 1
+#define ENABLE_LAST 1
+#ifdef MAKE_SUID
+# define IF_LAST(...) __VA_ARGS__ "CONFIG_LAST"
+#else
+# define IF_LAST(...) __VA_ARGS__
+#endif
+#define IF_NOT_LAST(...)
+#undef CONFIG_FEATURE_LAST_FANCY
+#define ENABLE_FEATURE_LAST_FANCY 0
+#define IF_FEATURE_LAST_FANCY(...)
+#define IF_NOT_FEATURE_LAST_FANCY(...) __VA_ARGS__
+#define CONFIG_LESS 1
+#define ENABLE_LESS 1
+#ifdef MAKE_SUID
+# define IF_LESS(...) __VA_ARGS__ "CONFIG_LESS"
+#else
+# define IF_LESS(...) __VA_ARGS__
+#endif
+#define IF_NOT_LESS(...)
+#define CONFIG_FEATURE_LESS_MAXLINES 9999999
+#define ENABLE_FEATURE_LESS_MAXLINES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_MAXLINES(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_MAXLINES"
+#else
+# define IF_FEATURE_LESS_MAXLINES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_MAXLINES(...)
+#define CONFIG_FEATURE_LESS_BRACKETS 1
+#define ENABLE_FEATURE_LESS_BRACKETS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_BRACKETS(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_BRACKETS"
+#else
+# define IF_FEATURE_LESS_BRACKETS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_BRACKETS(...)
+#define CONFIG_FEATURE_LESS_FLAGS 1
+#define ENABLE_FEATURE_LESS_FLAGS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_FLAGS(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_FLAGS"
+#else
+# define IF_FEATURE_LESS_FLAGS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_FLAGS(...)
+#define CONFIG_FEATURE_LESS_TRUNCATE 1
+#define ENABLE_FEATURE_LESS_TRUNCATE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_TRUNCATE(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_TRUNCATE"
+#else
+# define IF_FEATURE_LESS_TRUNCATE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_TRUNCATE(...)
+#define CONFIG_FEATURE_LESS_MARKS 1
+#define ENABLE_FEATURE_LESS_MARKS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_MARKS(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_MARKS"
+#else
+# define IF_FEATURE_LESS_MARKS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_MARKS(...)
+#define CONFIG_FEATURE_LESS_REGEXP 1
+#define ENABLE_FEATURE_LESS_REGEXP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_REGEXP(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_REGEXP"
+#else
+# define IF_FEATURE_LESS_REGEXP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_REGEXP(...)
+#define CONFIG_FEATURE_LESS_WINCH 1
+#define ENABLE_FEATURE_LESS_WINCH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_WINCH(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_WINCH"
+#else
+# define IF_FEATURE_LESS_WINCH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_WINCH(...)
+#define CONFIG_FEATURE_LESS_ASK_TERMINAL 1
+#define ENABLE_FEATURE_LESS_ASK_TERMINAL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_ASK_TERMINAL(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_ASK_TERMINAL"
+#else
+# define IF_FEATURE_LESS_ASK_TERMINAL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_ASK_TERMINAL(...)
+#define CONFIG_FEATURE_LESS_DASHCMD 1
+#define ENABLE_FEATURE_LESS_DASHCMD 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_DASHCMD(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_DASHCMD"
+#else
+# define IF_FEATURE_LESS_DASHCMD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_DASHCMD(...)
+#define CONFIG_FEATURE_LESS_LINENUMS 1
+#define ENABLE_FEATURE_LESS_LINENUMS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LESS_LINENUMS(...) __VA_ARGS__ "CONFIG_FEATURE_LESS_LINENUMS"
+#else
+# define IF_FEATURE_LESS_LINENUMS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LESS_LINENUMS(...)
+#define CONFIG_MAKEDEVS 1
+#define ENABLE_MAKEDEVS 1
+#ifdef MAKE_SUID
+# define IF_MAKEDEVS(...) __VA_ARGS__ "CONFIG_MAKEDEVS"
+#else
+# define IF_MAKEDEVS(...) __VA_ARGS__
+#endif
+#define IF_NOT_MAKEDEVS(...)
+#undef CONFIG_FEATURE_MAKEDEVS_LEAF
+#define ENABLE_FEATURE_MAKEDEVS_LEAF 0
+#define IF_FEATURE_MAKEDEVS_LEAF(...)
+#define IF_NOT_FEATURE_MAKEDEVS_LEAF(...) __VA_ARGS__
+#define CONFIG_FEATURE_MAKEDEVS_TABLE 1
+#define ENABLE_FEATURE_MAKEDEVS_TABLE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MAKEDEVS_TABLE(...) __VA_ARGS__ "CONFIG_FEATURE_MAKEDEVS_TABLE"
+#else
+# define IF_FEATURE_MAKEDEVS_TABLE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MAKEDEVS_TABLE(...)
+#define CONFIG_MAN 1
+#define ENABLE_MAN 1
+#ifdef MAKE_SUID
+# define IF_MAN(...) __VA_ARGS__ "CONFIG_MAN"
+#else
+# define IF_MAN(...) __VA_ARGS__
+#endif
+#define IF_NOT_MAN(...)
+#define CONFIG_MICROCOM 1
+#define ENABLE_MICROCOM 1
+#ifdef MAKE_SUID
+# define IF_MICROCOM(...) __VA_ARGS__ "CONFIG_MICROCOM"
+#else
+# define IF_MICROCOM(...) __VA_ARGS__
+#endif
+#define IF_NOT_MICROCOM(...)
+#define CONFIG_MOUNTPOINT 1
+#define ENABLE_MOUNTPOINT 1
+#ifdef MAKE_SUID
+# define IF_MOUNTPOINT(...) __VA_ARGS__ "CONFIG_MOUNTPOINT"
+#else
+# define IF_MOUNTPOINT(...) __VA_ARGS__
+#endif
+#define IF_NOT_MOUNTPOINT(...)
+#define CONFIG_MT 1
+#define ENABLE_MT 1
+#ifdef MAKE_SUID
+# define IF_MT(...) __VA_ARGS__ "CONFIG_MT"
+#else
+# define IF_MT(...) __VA_ARGS__
+#endif
+#define IF_NOT_MT(...)
+#define CONFIG_NANDWRITE 1
+#define ENABLE_NANDWRITE 1
+#ifdef MAKE_SUID
+# define IF_NANDWRITE(...) __VA_ARGS__ "CONFIG_NANDWRITE"
+#else
+# define IF_NANDWRITE(...) __VA_ARGS__
+#endif
+#define IF_NOT_NANDWRITE(...)
+#define CONFIG_NANDDUMP 1
+#define ENABLE_NANDDUMP 1
+#ifdef MAKE_SUID
+# define IF_NANDDUMP(...) __VA_ARGS__ "CONFIG_NANDDUMP"
+#else
+# define IF_NANDDUMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_NANDDUMP(...)
+#define CONFIG_RAIDAUTORUN 1
+#define ENABLE_RAIDAUTORUN 1
+#ifdef MAKE_SUID
+# define IF_RAIDAUTORUN(...) __VA_ARGS__ "CONFIG_RAIDAUTORUN"
+#else
+# define IF_RAIDAUTORUN(...) __VA_ARGS__
+#endif
+#define IF_NOT_RAIDAUTORUN(...)
+#define CONFIG_READAHEAD 1
+#define ENABLE_READAHEAD 1
+#ifdef MAKE_SUID
+# define IF_READAHEAD(...) __VA_ARGS__ "CONFIG_READAHEAD"
+#else
+# define IF_READAHEAD(...) __VA_ARGS__
+#endif
+#define IF_NOT_READAHEAD(...)
+#undef CONFIG_RFKILL
+#define ENABLE_RFKILL 0
+#define IF_RFKILL(...)
+#define IF_NOT_RFKILL(...) __VA_ARGS__
+#define CONFIG_RUNLEVEL 1
+#define ENABLE_RUNLEVEL 1
+#ifdef MAKE_SUID
+# define IF_RUNLEVEL(...) __VA_ARGS__ "CONFIG_RUNLEVEL"
+#else
+# define IF_RUNLEVEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_RUNLEVEL(...)
+#define CONFIG_RX 1
+#define ENABLE_RX 1
+#ifdef MAKE_SUID
+# define IF_RX(...) __VA_ARGS__ "CONFIG_RX"
+#else
+# define IF_RX(...) __VA_ARGS__
+#endif
+#define IF_NOT_RX(...)
+#define CONFIG_SETSERIAL 1
+#define ENABLE_SETSERIAL 1
+#ifdef MAKE_SUID
+# define IF_SETSERIAL(...) __VA_ARGS__ "CONFIG_SETSERIAL"
+#else
+# define IF_SETSERIAL(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETSERIAL(...)
+#define CONFIG_SETSID 1
+#define ENABLE_SETSID 1
+#ifdef MAKE_SUID
+# define IF_SETSID(...) __VA_ARGS__ "CONFIG_SETSID"
+#else
+# define IF_SETSID(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETSID(...)
+#define CONFIG_STRINGS 1
+#define ENABLE_STRINGS 1
+#ifdef MAKE_SUID
+# define IF_STRINGS(...) __VA_ARGS__ "CONFIG_STRINGS"
+#else
+# define IF_STRINGS(...) __VA_ARGS__
+#endif
+#define IF_NOT_STRINGS(...)
+#define CONFIG_TASKSET 1
+#define ENABLE_TASKSET 1
+#ifdef MAKE_SUID
+# define IF_TASKSET(...) __VA_ARGS__ "CONFIG_TASKSET"
+#else
+# define IF_TASKSET(...) __VA_ARGS__
+#endif
+#define IF_NOT_TASKSET(...)
+#define CONFIG_FEATURE_TASKSET_FANCY 1
+#define ENABLE_FEATURE_TASKSET_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TASKSET_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_TASKSET_FANCY"
+#else
+# define IF_FEATURE_TASKSET_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TASKSET_FANCY(...)
+#define CONFIG_TIME 1
+#define ENABLE_TIME 1
+#ifdef MAKE_SUID
+# define IF_TIME(...) __VA_ARGS__ "CONFIG_TIME"
+#else
+# define IF_TIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_TIME(...)
+#define CONFIG_TIMEOUT 1
+#define ENABLE_TIMEOUT 1
+#ifdef MAKE_SUID
+# define IF_TIMEOUT(...) __VA_ARGS__ "CONFIG_TIMEOUT"
+#else
+# define IF_TIMEOUT(...) __VA_ARGS__
+#endif
+#define IF_NOT_TIMEOUT(...)
+#define CONFIG_TTYSIZE 1
+#define ENABLE_TTYSIZE 1
+#ifdef MAKE_SUID
+# define IF_TTYSIZE(...) __VA_ARGS__ "CONFIG_TTYSIZE"
+#else
+# define IF_TTYSIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_TTYSIZE(...)
+#define CONFIG_UBIATTACH 1
+#define ENABLE_UBIATTACH 1
+#ifdef MAKE_SUID
+# define IF_UBIATTACH(...) __VA_ARGS__ "CONFIG_UBIATTACH"
+#else
+# define IF_UBIATTACH(...) __VA_ARGS__
+#endif
+#define IF_NOT_UBIATTACH(...)
+#define CONFIG_UBIDETACH 1
+#define ENABLE_UBIDETACH 1
+#ifdef MAKE_SUID
+# define IF_UBIDETACH(...) __VA_ARGS__ "CONFIG_UBIDETACH"
+#else
+# define IF_UBIDETACH(...) __VA_ARGS__
+#endif
+#define IF_NOT_UBIDETACH(...)
+#define CONFIG_UBIMKVOL 1
+#define ENABLE_UBIMKVOL 1
+#ifdef MAKE_SUID
+# define IF_UBIMKVOL(...) __VA_ARGS__ "CONFIG_UBIMKVOL"
+#else
+# define IF_UBIMKVOL(...) __VA_ARGS__
+#endif
+#define IF_NOT_UBIMKVOL(...)
+#define CONFIG_UBIRMVOL 1
+#define ENABLE_UBIRMVOL 1
+#ifdef MAKE_SUID
+# define IF_UBIRMVOL(...) __VA_ARGS__ "CONFIG_UBIRMVOL"
+#else
+# define IF_UBIRMVOL(...) __VA_ARGS__
+#endif
+#define IF_NOT_UBIRMVOL(...)
+#define CONFIG_UBIRSVOL 1
+#define ENABLE_UBIRSVOL 1
+#ifdef MAKE_SUID
+# define IF_UBIRSVOL(...) __VA_ARGS__ "CONFIG_UBIRSVOL"
+#else
+# define IF_UBIRSVOL(...) __VA_ARGS__
+#endif
+#define IF_NOT_UBIRSVOL(...)
+#define CONFIG_UBIUPDATEVOL 1
+#define ENABLE_UBIUPDATEVOL 1
+#ifdef MAKE_SUID
+# define IF_UBIUPDATEVOL(...) __VA_ARGS__ "CONFIG_UBIUPDATEVOL"
+#else
+# define IF_UBIUPDATEVOL(...) __VA_ARGS__
+#endif
+#define IF_NOT_UBIUPDATEVOL(...)
+#define CONFIG_UBIRENAME 1
+#define ENABLE_UBIRENAME 1
+#ifdef MAKE_SUID
+# define IF_UBIRENAME(...) __VA_ARGS__ "CONFIG_UBIRENAME"
+#else
+# define IF_UBIRENAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_UBIRENAME(...)
+#define CONFIG_VOLNAME 1
+#define ENABLE_VOLNAME 1
+#ifdef MAKE_SUID
+# define IF_VOLNAME(...) __VA_ARGS__ "CONFIG_VOLNAME"
+#else
+# define IF_VOLNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_VOLNAME(...)
+#define CONFIG_WALL 1
+#define ENABLE_WALL 1
+#ifdef MAKE_SUID
+# define IF_WALL(...) __VA_ARGS__ "CONFIG_WALL"
+#else
+# define IF_WALL(...) __VA_ARGS__
+#endif
+#define IF_NOT_WALL(...)
+#define CONFIG_WATCHDOG 1
+#define ENABLE_WATCHDOG 1
+#ifdef MAKE_SUID
+# define IF_WATCHDOG(...) __VA_ARGS__ "CONFIG_WATCHDOG"
+#else
+# define IF_WATCHDOG(...) __VA_ARGS__
+#endif
+#define IF_NOT_WATCHDOG(...)
+
+/*
+ * Networking Utilities
+ */
+#define CONFIG_FEATURE_IPV6 1
+#define ENABLE_FEATURE_IPV6 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IPV6(...) __VA_ARGS__ "CONFIG_FEATURE_IPV6"
+#else
+# define IF_FEATURE_IPV6(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IPV6(...)
+#define CONFIG_FEATURE_UNIX_LOCAL 1
+#define ENABLE_FEATURE_UNIX_LOCAL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UNIX_LOCAL(...) __VA_ARGS__ "CONFIG_FEATURE_UNIX_LOCAL"
+#else
+# define IF_FEATURE_UNIX_LOCAL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UNIX_LOCAL(...)
+#define CONFIG_FEATURE_PREFER_IPV4_ADDRESS 1
+#define ENABLE_FEATURE_PREFER_IPV4_ADDRESS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PREFER_IPV4_ADDRESS(...) __VA_ARGS__ "CONFIG_FEATURE_PREFER_IPV4_ADDRESS"
+#else
+# define IF_FEATURE_PREFER_IPV4_ADDRESS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PREFER_IPV4_ADDRESS(...)
+#define CONFIG_VERBOSE_RESOLUTION_ERRORS 1
+#define ENABLE_VERBOSE_RESOLUTION_ERRORS 1
+#ifdef MAKE_SUID
+# define IF_VERBOSE_RESOLUTION_ERRORS(...) __VA_ARGS__ "CONFIG_VERBOSE_RESOLUTION_ERRORS"
+#else
+# define IF_VERBOSE_RESOLUTION_ERRORS(...) __VA_ARGS__
+#endif
+#define IF_NOT_VERBOSE_RESOLUTION_ERRORS(...)
+#define CONFIG_ARP 1
+#define ENABLE_ARP 1
+#ifdef MAKE_SUID
+# define IF_ARP(...) __VA_ARGS__ "CONFIG_ARP"
+#else
+# define IF_ARP(...) __VA_ARGS__
+#endif
+#define IF_NOT_ARP(...)
+#define CONFIG_ARPING 1
+#define ENABLE_ARPING 1
+#ifdef MAKE_SUID
+# define IF_ARPING(...) __VA_ARGS__ "CONFIG_ARPING"
+#else
+# define IF_ARPING(...) __VA_ARGS__
+#endif
+#define IF_NOT_ARPING(...)
+#define CONFIG_BRCTL 1
+#define ENABLE_BRCTL 1
+#ifdef MAKE_SUID
+# define IF_BRCTL(...) __VA_ARGS__ "CONFIG_BRCTL"
+#else
+# define IF_BRCTL(...) __VA_ARGS__
+#endif
+#define IF_NOT_BRCTL(...)
+#define CONFIG_FEATURE_BRCTL_FANCY 1
+#define ENABLE_FEATURE_BRCTL_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_BRCTL_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_BRCTL_FANCY"
+#else
+# define IF_FEATURE_BRCTL_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_BRCTL_FANCY(...)
+#define CONFIG_FEATURE_BRCTL_SHOW 1
+#define ENABLE_FEATURE_BRCTL_SHOW 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_BRCTL_SHOW(...) __VA_ARGS__ "CONFIG_FEATURE_BRCTL_SHOW"
+#else
+# define IF_FEATURE_BRCTL_SHOW(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_BRCTL_SHOW(...)
+#define CONFIG_DNSD 1
+#define ENABLE_DNSD 1
+#ifdef MAKE_SUID
+# define IF_DNSD(...) __VA_ARGS__ "CONFIG_DNSD"
+#else
+# define IF_DNSD(...) __VA_ARGS__
+#endif
+#define IF_NOT_DNSD(...)
+#define CONFIG_ETHER_WAKE 1
+#define ENABLE_ETHER_WAKE 1
+#ifdef MAKE_SUID
+# define IF_ETHER_WAKE(...) __VA_ARGS__ "CONFIG_ETHER_WAKE"
+#else
+# define IF_ETHER_WAKE(...) __VA_ARGS__
+#endif
+#define IF_NOT_ETHER_WAKE(...)
+#define CONFIG_FTPD 1
+#define ENABLE_FTPD 1
+#ifdef MAKE_SUID
+# define IF_FTPD(...) __VA_ARGS__ "CONFIG_FTPD"
+#else
+# define IF_FTPD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FTPD(...)
+#define CONFIG_FEATURE_FTPD_WRITE 1
+#define ENABLE_FEATURE_FTPD_WRITE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FTPD_WRITE(...) __VA_ARGS__ "CONFIG_FEATURE_FTPD_WRITE"
+#else
+# define IF_FEATURE_FTPD_WRITE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FTPD_WRITE(...)
+#define CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST 1
+#define ENABLE_FEATURE_FTPD_ACCEPT_BROKEN_LIST 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FTPD_ACCEPT_BROKEN_LIST(...) __VA_ARGS__ "CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST"
+#else
+# define IF_FEATURE_FTPD_ACCEPT_BROKEN_LIST(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FTPD_ACCEPT_BROKEN_LIST(...)
+#define CONFIG_FEATURE_FTPD_AUTHENTICATION 1
+#define ENABLE_FEATURE_FTPD_AUTHENTICATION 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FTPD_AUTHENTICATION(...) __VA_ARGS__ "CONFIG_FEATURE_FTPD_AUTHENTICATION"
+#else
+# define IF_FEATURE_FTPD_AUTHENTICATION(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FTPD_AUTHENTICATION(...)
+#define CONFIG_FTPGET 1
+#define ENABLE_FTPGET 1
+#ifdef MAKE_SUID
+# define IF_FTPGET(...) __VA_ARGS__ "CONFIG_FTPGET"
+#else
+# define IF_FTPGET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FTPGET(...)
+#define CONFIG_FTPPUT 1
+#define ENABLE_FTPPUT 1
+#ifdef MAKE_SUID
+# define IF_FTPPUT(...) __VA_ARGS__ "CONFIG_FTPPUT"
+#else
+# define IF_FTPPUT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FTPPUT(...)
+#define CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS 1
+#define ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FTPGETPUT_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS"
+#else
+# define IF_FEATURE_FTPGETPUT_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS(...)
+#define CONFIG_HOSTNAME 1
+#define ENABLE_HOSTNAME 1
+#ifdef MAKE_SUID
+# define IF_HOSTNAME(...) __VA_ARGS__ "CONFIG_HOSTNAME"
+#else
+# define IF_HOSTNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_HOSTNAME(...)
+#define CONFIG_DNSDOMAINNAME 1
+#define ENABLE_DNSDOMAINNAME 1
+#ifdef MAKE_SUID
+# define IF_DNSDOMAINNAME(...) __VA_ARGS__ "CONFIG_DNSDOMAINNAME"
+#else
+# define IF_DNSDOMAINNAME(...) __VA_ARGS__
+#endif
+#define IF_NOT_DNSDOMAINNAME(...)
+#define CONFIG_HTTPD 1
+#define ENABLE_HTTPD 1
+#ifdef MAKE_SUID
+# define IF_HTTPD(...) __VA_ARGS__ "CONFIG_HTTPD"
+#else
+# define IF_HTTPD(...) __VA_ARGS__
+#endif
+#define IF_NOT_HTTPD(...)
+#define CONFIG_FEATURE_HTTPD_RANGES 1
+#define ENABLE_FEATURE_HTTPD_RANGES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_RANGES(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_RANGES"
+#else
+# define IF_FEATURE_HTTPD_RANGES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_RANGES(...)
+#define CONFIG_FEATURE_HTTPD_SETUID 1
+#define ENABLE_FEATURE_HTTPD_SETUID 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_SETUID(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_SETUID"
+#else
+# define IF_FEATURE_HTTPD_SETUID(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_SETUID(...)
+#define CONFIG_FEATURE_HTTPD_BASIC_AUTH 1
+#define ENABLE_FEATURE_HTTPD_BASIC_AUTH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_BASIC_AUTH(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_BASIC_AUTH"
+#else
+# define IF_FEATURE_HTTPD_BASIC_AUTH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_BASIC_AUTH(...)
+#define CONFIG_FEATURE_HTTPD_AUTH_MD5 1
+#define ENABLE_FEATURE_HTTPD_AUTH_MD5 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_AUTH_MD5(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_AUTH_MD5"
+#else
+# define IF_FEATURE_HTTPD_AUTH_MD5(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_AUTH_MD5(...)
+#define CONFIG_FEATURE_HTTPD_CGI 1
+#define ENABLE_FEATURE_HTTPD_CGI 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_CGI(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_CGI"
+#else
+# define IF_FEATURE_HTTPD_CGI(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_CGI(...)
+#define CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 1
+#define ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR"
+#else
+# define IF_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR(...)
+#define CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 1
+#define ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV"
+#else
+# define IF_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV(...)
+#define CONFIG_FEATURE_HTTPD_ENCODE_URL_STR 1
+#define ENABLE_FEATURE_HTTPD_ENCODE_URL_STR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_ENCODE_URL_STR(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_ENCODE_URL_STR"
+#else
+# define IF_FEATURE_HTTPD_ENCODE_URL_STR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_ENCODE_URL_STR(...)
+#define CONFIG_FEATURE_HTTPD_ERROR_PAGES 1
+#define ENABLE_FEATURE_HTTPD_ERROR_PAGES 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_ERROR_PAGES(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_ERROR_PAGES"
+#else
+# define IF_FEATURE_HTTPD_ERROR_PAGES(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_ERROR_PAGES(...)
+#define CONFIG_FEATURE_HTTPD_PROXY 1
+#define ENABLE_FEATURE_HTTPD_PROXY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_PROXY(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_PROXY"
+#else
+# define IF_FEATURE_HTTPD_PROXY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_PROXY(...)
+#define CONFIG_FEATURE_HTTPD_GZIP 1
+#define ENABLE_FEATURE_HTTPD_GZIP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_HTTPD_GZIP(...) __VA_ARGS__ "CONFIG_FEATURE_HTTPD_GZIP"
+#else
+# define IF_FEATURE_HTTPD_GZIP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_HTTPD_GZIP(...)
+#define CONFIG_IFCONFIG 1
+#define ENABLE_IFCONFIG 1
+#ifdef MAKE_SUID
+# define IF_IFCONFIG(...) __VA_ARGS__ "CONFIG_IFCONFIG"
+#else
+# define IF_IFCONFIG(...) __VA_ARGS__
+#endif
+#define IF_NOT_IFCONFIG(...)
+#define CONFIG_FEATURE_IFCONFIG_STATUS 1
+#define ENABLE_FEATURE_IFCONFIG_STATUS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFCONFIG_STATUS(...) __VA_ARGS__ "CONFIG_FEATURE_IFCONFIG_STATUS"
+#else
+# define IF_FEATURE_IFCONFIG_STATUS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFCONFIG_STATUS(...)
+#define CONFIG_FEATURE_IFCONFIG_SLIP 1
+#define ENABLE_FEATURE_IFCONFIG_SLIP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFCONFIG_SLIP(...) __VA_ARGS__ "CONFIG_FEATURE_IFCONFIG_SLIP"
+#else
+# define IF_FEATURE_IFCONFIG_SLIP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFCONFIG_SLIP(...)
+#define CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ 1
+#define ENABLE_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ(...) __VA_ARGS__ "CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ"
+#else
+# define IF_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ(...)
+#define CONFIG_FEATURE_IFCONFIG_HW 1
+#define ENABLE_FEATURE_IFCONFIG_HW 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFCONFIG_HW(...) __VA_ARGS__ "CONFIG_FEATURE_IFCONFIG_HW"
+#else
+# define IF_FEATURE_IFCONFIG_HW(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFCONFIG_HW(...)
+#define CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS 1
+#define ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFCONFIG_BROADCAST_PLUS(...) __VA_ARGS__ "CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS"
+#else
+# define IF_FEATURE_IFCONFIG_BROADCAST_PLUS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFCONFIG_BROADCAST_PLUS(...)
+#define CONFIG_IFENSLAVE 1
+#define ENABLE_IFENSLAVE 1
+#ifdef MAKE_SUID
+# define IF_IFENSLAVE(...) __VA_ARGS__ "CONFIG_IFENSLAVE"
+#else
+# define IF_IFENSLAVE(...) __VA_ARGS__
+#endif
+#define IF_NOT_IFENSLAVE(...)
+#define CONFIG_IFPLUGD 1
+#define ENABLE_IFPLUGD 1
+#ifdef MAKE_SUID
+# define IF_IFPLUGD(...) __VA_ARGS__ "CONFIG_IFPLUGD"
+#else
+# define IF_IFPLUGD(...) __VA_ARGS__
+#endif
+#define IF_NOT_IFPLUGD(...)
+#define CONFIG_IFUP 1
+#define ENABLE_IFUP 1
+#ifdef MAKE_SUID
+# define IF_IFUP(...) __VA_ARGS__ "CONFIG_IFUP"
+#else
+# define IF_IFUP(...) __VA_ARGS__
+#endif
+#define IF_NOT_IFUP(...)
+#define CONFIG_IFDOWN 1
+#define ENABLE_IFDOWN 1
+#ifdef MAKE_SUID
+# define IF_IFDOWN(...) __VA_ARGS__ "CONFIG_IFDOWN"
+#else
+# define IF_IFDOWN(...) __VA_ARGS__
+#endif
+#define IF_NOT_IFDOWN(...)
+#define CONFIG_IFUPDOWN_IFSTATE_PATH "/var/run/ifstate"
+#define ENABLE_IFUPDOWN_IFSTATE_PATH 1
+#ifdef MAKE_SUID
+# define IF_IFUPDOWN_IFSTATE_PATH(...) __VA_ARGS__ "CONFIG_IFUPDOWN_IFSTATE_PATH"
+#else
+# define IF_IFUPDOWN_IFSTATE_PATH(...) __VA_ARGS__
+#endif
+#define IF_NOT_IFUPDOWN_IFSTATE_PATH(...)
+#define CONFIG_FEATURE_IFUPDOWN_IP 1
+#define ENABLE_FEATURE_IFUPDOWN_IP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFUPDOWN_IP(...) __VA_ARGS__ "CONFIG_FEATURE_IFUPDOWN_IP"
+#else
+# define IF_FEATURE_IFUPDOWN_IP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFUPDOWN_IP(...)
+#define CONFIG_FEATURE_IFUPDOWN_IPV4 1
+#define ENABLE_FEATURE_IFUPDOWN_IPV4 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFUPDOWN_IPV4(...) __VA_ARGS__ "CONFIG_FEATURE_IFUPDOWN_IPV4"
+#else
+# define IF_FEATURE_IFUPDOWN_IPV4(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFUPDOWN_IPV4(...)
+#define CONFIG_FEATURE_IFUPDOWN_IPV6 1
+#define ENABLE_FEATURE_IFUPDOWN_IPV6 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFUPDOWN_IPV6(...) __VA_ARGS__ "CONFIG_FEATURE_IFUPDOWN_IPV6"
+#else
+# define IF_FEATURE_IFUPDOWN_IPV6(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFUPDOWN_IPV6(...)
+#define CONFIG_FEATURE_IFUPDOWN_MAPPING 1
+#define ENABLE_FEATURE_IFUPDOWN_MAPPING 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFUPDOWN_MAPPING(...) __VA_ARGS__ "CONFIG_FEATURE_IFUPDOWN_MAPPING"
+#else
+# define IF_FEATURE_IFUPDOWN_MAPPING(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFUPDOWN_MAPPING(...)
+#define CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP 1
+#define ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IFUPDOWN_EXTERNAL_DHCP(...) __VA_ARGS__ "CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP"
+#else
+# define IF_FEATURE_IFUPDOWN_EXTERNAL_DHCP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IFUPDOWN_EXTERNAL_DHCP(...)
+#define CONFIG_INETD 1
+#define ENABLE_INETD 1
+#ifdef MAKE_SUID
+# define IF_INETD(...) __VA_ARGS__ "CONFIG_INETD"
+#else
+# define IF_INETD(...) __VA_ARGS__
+#endif
+#define IF_NOT_INETD(...)
+#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO 1
+#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_ECHO(...) __VA_ARGS__ "CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO"
+#else
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_ECHO(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INETD_SUPPORT_BUILTIN_ECHO(...)
+#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD 1
+#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD(...) __VA_ARGS__ "CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD"
+#else
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD(...)
+#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME 1
+#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_TIME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_TIME(...) __VA_ARGS__ "CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME"
+#else
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_TIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INETD_SUPPORT_BUILTIN_TIME(...)
+#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME 1
+#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME(...) __VA_ARGS__ "CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME"
+#else
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME(...)
+#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN 1
+#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN(...) __VA_ARGS__ "CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN"
+#else
+# define IF_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN(...)
+#define CONFIG_FEATURE_INETD_RPC 1
+#define ENABLE_FEATURE_INETD_RPC 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_INETD_RPC(...) __VA_ARGS__ "CONFIG_FEATURE_INETD_RPC"
+#else
+# define IF_FEATURE_INETD_RPC(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_INETD_RPC(...)
+#define CONFIG_IP 1
+#define ENABLE_IP 1
+#ifdef MAKE_SUID
+# define IF_IP(...) __VA_ARGS__ "CONFIG_IP"
+#else
+# define IF_IP(...) __VA_ARGS__
+#endif
+#define IF_NOT_IP(...)
+#define CONFIG_IPADDR 1
+#define ENABLE_IPADDR 1
+#ifdef MAKE_SUID
+# define IF_IPADDR(...) __VA_ARGS__ "CONFIG_IPADDR"
+#else
+# define IF_IPADDR(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPADDR(...)
+#define CONFIG_IPLINK 1
+#define ENABLE_IPLINK 1
+#ifdef MAKE_SUID
+# define IF_IPLINK(...) __VA_ARGS__ "CONFIG_IPLINK"
+#else
+# define IF_IPLINK(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPLINK(...)
+#define CONFIG_IPROUTE 1
+#define ENABLE_IPROUTE 1
+#ifdef MAKE_SUID
+# define IF_IPROUTE(...) __VA_ARGS__ "CONFIG_IPROUTE"
+#else
+# define IF_IPROUTE(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPROUTE(...)
+#define CONFIG_IPTUNNEL 1
+#define ENABLE_IPTUNNEL 1
+#ifdef MAKE_SUID
+# define IF_IPTUNNEL(...) __VA_ARGS__ "CONFIG_IPTUNNEL"
+#else
+# define IF_IPTUNNEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPTUNNEL(...)
+#define CONFIG_IPRULE 1
+#define ENABLE_IPRULE 1
+#ifdef MAKE_SUID
+# define IF_IPRULE(...) __VA_ARGS__ "CONFIG_IPRULE"
+#else
+# define IF_IPRULE(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPRULE(...)
+#define CONFIG_IPNEIGH 1
+#define ENABLE_IPNEIGH 1
+#ifdef MAKE_SUID
+# define IF_IPNEIGH(...) __VA_ARGS__ "CONFIG_IPNEIGH"
+#else
+# define IF_IPNEIGH(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPNEIGH(...)
+#define CONFIG_FEATURE_IP_ADDRESS 1
+#define ENABLE_FEATURE_IP_ADDRESS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_ADDRESS(...) __VA_ARGS__ "CONFIG_FEATURE_IP_ADDRESS"
+#else
+# define IF_FEATURE_IP_ADDRESS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_ADDRESS(...)
+#define CONFIG_FEATURE_IP_LINK 1
+#define ENABLE_FEATURE_IP_LINK 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_LINK(...) __VA_ARGS__ "CONFIG_FEATURE_IP_LINK"
+#else
+# define IF_FEATURE_IP_LINK(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_LINK(...)
+#define CONFIG_FEATURE_IP_ROUTE 1
+#define ENABLE_FEATURE_IP_ROUTE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_ROUTE(...) __VA_ARGS__ "CONFIG_FEATURE_IP_ROUTE"
+#else
+# define IF_FEATURE_IP_ROUTE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_ROUTE(...)
+#define CONFIG_FEATURE_IP_ROUTE_DIR "/etc/iproute2"
+#define ENABLE_FEATURE_IP_ROUTE_DIR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_ROUTE_DIR(...) __VA_ARGS__ "CONFIG_FEATURE_IP_ROUTE_DIR"
+#else
+# define IF_FEATURE_IP_ROUTE_DIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_ROUTE_DIR(...)
+#define CONFIG_FEATURE_IP_TUNNEL 1
+#define ENABLE_FEATURE_IP_TUNNEL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_TUNNEL(...) __VA_ARGS__ "CONFIG_FEATURE_IP_TUNNEL"
+#else
+# define IF_FEATURE_IP_TUNNEL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_TUNNEL(...)
+#define CONFIG_FEATURE_IP_RULE 1
+#define ENABLE_FEATURE_IP_RULE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_RULE(...) __VA_ARGS__ "CONFIG_FEATURE_IP_RULE"
+#else
+# define IF_FEATURE_IP_RULE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_RULE(...)
+#define CONFIG_FEATURE_IP_NEIGH 1
+#define ENABLE_FEATURE_IP_NEIGH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_NEIGH(...) __VA_ARGS__ "CONFIG_FEATURE_IP_NEIGH"
+#else
+# define IF_FEATURE_IP_NEIGH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_NEIGH(...)
+#define CONFIG_FEATURE_IP_RARE_PROTOCOLS 1
+#define ENABLE_FEATURE_IP_RARE_PROTOCOLS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IP_RARE_PROTOCOLS(...) __VA_ARGS__ "CONFIG_FEATURE_IP_RARE_PROTOCOLS"
+#else
+# define IF_FEATURE_IP_RARE_PROTOCOLS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IP_RARE_PROTOCOLS(...)
+#define CONFIG_IPCALC 1
+#define ENABLE_IPCALC 1
+#ifdef MAKE_SUID
+# define IF_IPCALC(...) __VA_ARGS__ "CONFIG_IPCALC"
+#else
+# define IF_IPCALC(...) __VA_ARGS__
+#endif
+#define IF_NOT_IPCALC(...)
+#define CONFIG_FEATURE_IPCALC_FANCY 1
+#define ENABLE_FEATURE_IPCALC_FANCY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IPCALC_FANCY(...) __VA_ARGS__ "CONFIG_FEATURE_IPCALC_FANCY"
+#else
+# define IF_FEATURE_IPCALC_FANCY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IPCALC_FANCY(...)
+#define CONFIG_FEATURE_IPCALC_LONG_OPTIONS 1
+#define ENABLE_FEATURE_IPCALC_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IPCALC_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_IPCALC_LONG_OPTIONS"
+#else
+# define IF_FEATURE_IPCALC_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IPCALC_LONG_OPTIONS(...)
+#define CONFIG_FAKEIDENTD 1
+#define ENABLE_FAKEIDENTD 1
+#ifdef MAKE_SUID
+# define IF_FAKEIDENTD(...) __VA_ARGS__ "CONFIG_FAKEIDENTD"
+#else
+# define IF_FAKEIDENTD(...) __VA_ARGS__
+#endif
+#define IF_NOT_FAKEIDENTD(...)
+#define CONFIG_NAMEIF 1
+#define ENABLE_NAMEIF 1
+#ifdef MAKE_SUID
+# define IF_NAMEIF(...) __VA_ARGS__ "CONFIG_NAMEIF"
+#else
+# define IF_NAMEIF(...) __VA_ARGS__
+#endif
+#define IF_NOT_NAMEIF(...)
+#define CONFIG_FEATURE_NAMEIF_EXTENDED 1
+#define ENABLE_FEATURE_NAMEIF_EXTENDED 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_NAMEIF_EXTENDED(...) __VA_ARGS__ "CONFIG_FEATURE_NAMEIF_EXTENDED"
+#else
+# define IF_FEATURE_NAMEIF_EXTENDED(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_NAMEIF_EXTENDED(...)
+#define CONFIG_NBDCLIENT 1
+#define ENABLE_NBDCLIENT 1
+#ifdef MAKE_SUID
+# define IF_NBDCLIENT(...) __VA_ARGS__ "CONFIG_NBDCLIENT"
+#else
+# define IF_NBDCLIENT(...) __VA_ARGS__
+#endif
+#define IF_NOT_NBDCLIENT(...)
+#define CONFIG_NC 1
+#define ENABLE_NC 1
+#ifdef MAKE_SUID
+# define IF_NC(...) __VA_ARGS__ "CONFIG_NC"
+#else
+# define IF_NC(...) __VA_ARGS__
+#endif
+#define IF_NOT_NC(...)
+#define CONFIG_NC_SERVER 1
+#define ENABLE_NC_SERVER 1
+#ifdef MAKE_SUID
+# define IF_NC_SERVER(...) __VA_ARGS__ "CONFIG_NC_SERVER"
+#else
+# define IF_NC_SERVER(...) __VA_ARGS__
+#endif
+#define IF_NOT_NC_SERVER(...)
+#define CONFIG_NC_EXTRA 1
+#define ENABLE_NC_EXTRA 1
+#ifdef MAKE_SUID
+# define IF_NC_EXTRA(...) __VA_ARGS__ "CONFIG_NC_EXTRA"
+#else
+# define IF_NC_EXTRA(...) __VA_ARGS__
+#endif
+#define IF_NOT_NC_EXTRA(...)
+#undef CONFIG_NC_110_COMPAT
+#define ENABLE_NC_110_COMPAT 0
+#define IF_NC_110_COMPAT(...)
+#define IF_NOT_NC_110_COMPAT(...) __VA_ARGS__
+#define CONFIG_NETSTAT 1
+#define ENABLE_NETSTAT 1
+#ifdef MAKE_SUID
+# define IF_NETSTAT(...) __VA_ARGS__ "CONFIG_NETSTAT"
+#else
+# define IF_NETSTAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_NETSTAT(...)
+#define CONFIG_FEATURE_NETSTAT_WIDE 1
+#define ENABLE_FEATURE_NETSTAT_WIDE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_NETSTAT_WIDE(...) __VA_ARGS__ "CONFIG_FEATURE_NETSTAT_WIDE"
+#else
+# define IF_FEATURE_NETSTAT_WIDE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_NETSTAT_WIDE(...)
+#define CONFIG_FEATURE_NETSTAT_PRG 1
+#define ENABLE_FEATURE_NETSTAT_PRG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_NETSTAT_PRG(...) __VA_ARGS__ "CONFIG_FEATURE_NETSTAT_PRG"
+#else
+# define IF_FEATURE_NETSTAT_PRG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_NETSTAT_PRG(...)
+#define CONFIG_NSLOOKUP 1
+#define ENABLE_NSLOOKUP 1
+#ifdef MAKE_SUID
+# define IF_NSLOOKUP(...) __VA_ARGS__ "CONFIG_NSLOOKUP"
+#else
+# define IF_NSLOOKUP(...) __VA_ARGS__
+#endif
+#define IF_NOT_NSLOOKUP(...)
+#define CONFIG_NTPD 1
+#define ENABLE_NTPD 1
+#ifdef MAKE_SUID
+# define IF_NTPD(...) __VA_ARGS__ "CONFIG_NTPD"
+#else
+# define IF_NTPD(...) __VA_ARGS__
+#endif
+#define IF_NOT_NTPD(...)
+#define CONFIG_FEATURE_NTPD_SERVER 1
+#define ENABLE_FEATURE_NTPD_SERVER 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_NTPD_SERVER(...) __VA_ARGS__ "CONFIG_FEATURE_NTPD_SERVER"
+#else
+# define IF_FEATURE_NTPD_SERVER(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_NTPD_SERVER(...)
+#define CONFIG_FEATURE_NTPD_CONF 1
+#define ENABLE_FEATURE_NTPD_CONF 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_NTPD_CONF(...) __VA_ARGS__ "CONFIG_FEATURE_NTPD_CONF"
+#else
+# define IF_FEATURE_NTPD_CONF(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_NTPD_CONF(...)
+#define CONFIG_PING 1
+#define ENABLE_PING 1
+#ifdef MAKE_SUID
+# define IF_PING(...) __VA_ARGS__ "CONFIG_PING"
+#else
+# define IF_PING(...) __VA_ARGS__
+#endif
+#define IF_NOT_PING(...)
+#define CONFIG_PING6 1
+#define ENABLE_PING6 1
+#ifdef MAKE_SUID
+# define IF_PING6(...) __VA_ARGS__ "CONFIG_PING6"
+#else
+# define IF_PING6(...) __VA_ARGS__
+#endif
+#define IF_NOT_PING6(...)
+#define CONFIG_FEATURE_FANCY_PING 1
+#define ENABLE_FEATURE_FANCY_PING 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_FANCY_PING(...) __VA_ARGS__ "CONFIG_FEATURE_FANCY_PING"
+#else
+# define IF_FEATURE_FANCY_PING(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_FANCY_PING(...)
+#define CONFIG_PSCAN 1
+#define ENABLE_PSCAN 1
+#ifdef MAKE_SUID
+# define IF_PSCAN(...) __VA_ARGS__ "CONFIG_PSCAN"
+#else
+# define IF_PSCAN(...) __VA_ARGS__
+#endif
+#define IF_NOT_PSCAN(...)
+#define CONFIG_ROUTE 1
+#define ENABLE_ROUTE 1
+#ifdef MAKE_SUID
+# define IF_ROUTE(...) __VA_ARGS__ "CONFIG_ROUTE"
+#else
+# define IF_ROUTE(...) __VA_ARGS__
+#endif
+#define IF_NOT_ROUTE(...)
+#define CONFIG_SLATTACH 1
+#define ENABLE_SLATTACH 1
+#ifdef MAKE_SUID
+# define IF_SLATTACH(...) __VA_ARGS__ "CONFIG_SLATTACH"
+#else
+# define IF_SLATTACH(...) __VA_ARGS__
+#endif
+#define IF_NOT_SLATTACH(...)
+#define CONFIG_TCPSVD 1
+#define ENABLE_TCPSVD 1
+#ifdef MAKE_SUID
+# define IF_TCPSVD(...) __VA_ARGS__ "CONFIG_TCPSVD"
+#else
+# define IF_TCPSVD(...) __VA_ARGS__
+#endif
+#define IF_NOT_TCPSVD(...)
+#define CONFIG_UDPSVD 1
+#define ENABLE_UDPSVD 1
+#ifdef MAKE_SUID
+# define IF_UDPSVD(...) __VA_ARGS__ "CONFIG_UDPSVD"
+#else
+# define IF_UDPSVD(...) __VA_ARGS__
+#endif
+#define IF_NOT_UDPSVD(...)
+#define CONFIG_TELNET 1
+#define ENABLE_TELNET 1
+#ifdef MAKE_SUID
+# define IF_TELNET(...) __VA_ARGS__ "CONFIG_TELNET"
+#else
+# define IF_TELNET(...) __VA_ARGS__
+#endif
+#define IF_NOT_TELNET(...)
+#define CONFIG_FEATURE_TELNET_TTYPE 1
+#define ENABLE_FEATURE_TELNET_TTYPE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TELNET_TTYPE(...) __VA_ARGS__ "CONFIG_FEATURE_TELNET_TTYPE"
+#else
+# define IF_FEATURE_TELNET_TTYPE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TELNET_TTYPE(...)
+#define CONFIG_FEATURE_TELNET_AUTOLOGIN 1
+#define ENABLE_FEATURE_TELNET_AUTOLOGIN 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TELNET_AUTOLOGIN(...) __VA_ARGS__ "CONFIG_FEATURE_TELNET_AUTOLOGIN"
+#else
+# define IF_FEATURE_TELNET_AUTOLOGIN(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TELNET_AUTOLOGIN(...)
+#define CONFIG_TELNETD 1
+#define ENABLE_TELNETD 1
+#ifdef MAKE_SUID
+# define IF_TELNETD(...) __VA_ARGS__ "CONFIG_TELNETD"
+#else
+# define IF_TELNETD(...) __VA_ARGS__
+#endif
+#define IF_NOT_TELNETD(...)
+#define CONFIG_FEATURE_TELNETD_STANDALONE 1
+#define ENABLE_FEATURE_TELNETD_STANDALONE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TELNETD_STANDALONE(...) __VA_ARGS__ "CONFIG_FEATURE_TELNETD_STANDALONE"
+#else
+# define IF_FEATURE_TELNETD_STANDALONE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TELNETD_STANDALONE(...)
+#define CONFIG_FEATURE_TELNETD_INETD_WAIT 1
+#define ENABLE_FEATURE_TELNETD_INETD_WAIT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TELNETD_INETD_WAIT(...) __VA_ARGS__ "CONFIG_FEATURE_TELNETD_INETD_WAIT"
+#else
+# define IF_FEATURE_TELNETD_INETD_WAIT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TELNETD_INETD_WAIT(...)
+#define CONFIG_TFTP 1
+#define ENABLE_TFTP 1
+#ifdef MAKE_SUID
+# define IF_TFTP(...) __VA_ARGS__ "CONFIG_TFTP"
+#else
+# define IF_TFTP(...) __VA_ARGS__
+#endif
+#define IF_NOT_TFTP(...)
+#define CONFIG_TFTPD 1
+#define ENABLE_TFTPD 1
+#ifdef MAKE_SUID
+# define IF_TFTPD(...) __VA_ARGS__ "CONFIG_TFTPD"
+#else
+# define IF_TFTPD(...) __VA_ARGS__
+#endif
+#define IF_NOT_TFTPD(...)
+
+/*
+ * Common options for tftp/tftpd
+ */
+#define CONFIG_FEATURE_TFTP_GET 1
+#define ENABLE_FEATURE_TFTP_GET 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TFTP_GET(...) __VA_ARGS__ "CONFIG_FEATURE_TFTP_GET"
+#else
+# define IF_FEATURE_TFTP_GET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TFTP_GET(...)
+#define CONFIG_FEATURE_TFTP_PUT 1
+#define ENABLE_FEATURE_TFTP_PUT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TFTP_PUT(...) __VA_ARGS__ "CONFIG_FEATURE_TFTP_PUT"
+#else
+# define IF_FEATURE_TFTP_PUT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TFTP_PUT(...)
+#define CONFIG_FEATURE_TFTP_BLOCKSIZE 1
+#define ENABLE_FEATURE_TFTP_BLOCKSIZE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TFTP_BLOCKSIZE(...) __VA_ARGS__ "CONFIG_FEATURE_TFTP_BLOCKSIZE"
+#else
+# define IF_FEATURE_TFTP_BLOCKSIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TFTP_BLOCKSIZE(...)
+#define CONFIG_FEATURE_TFTP_PROGRESS_BAR 1
+#define ENABLE_FEATURE_TFTP_PROGRESS_BAR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TFTP_PROGRESS_BAR(...) __VA_ARGS__ "CONFIG_FEATURE_TFTP_PROGRESS_BAR"
+#else
+# define IF_FEATURE_TFTP_PROGRESS_BAR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TFTP_PROGRESS_BAR(...)
+#define CONFIG_TFTP_DEBUG 1
+#define ENABLE_TFTP_DEBUG 1
+#ifdef MAKE_SUID
+# define IF_TFTP_DEBUG(...) __VA_ARGS__ "CONFIG_TFTP_DEBUG"
+#else
+# define IF_TFTP_DEBUG(...) __VA_ARGS__
+#endif
+#define IF_NOT_TFTP_DEBUG(...)
+#define CONFIG_TRACEROUTE 1
+#define ENABLE_TRACEROUTE 1
+#ifdef MAKE_SUID
+# define IF_TRACEROUTE(...) __VA_ARGS__ "CONFIG_TRACEROUTE"
+#else
+# define IF_TRACEROUTE(...) __VA_ARGS__
+#endif
+#define IF_NOT_TRACEROUTE(...)
+#define CONFIG_TRACEROUTE6 1
+#define ENABLE_TRACEROUTE6 1
+#ifdef MAKE_SUID
+# define IF_TRACEROUTE6(...) __VA_ARGS__ "CONFIG_TRACEROUTE6"
+#else
+# define IF_TRACEROUTE6(...) __VA_ARGS__
+#endif
+#define IF_NOT_TRACEROUTE6(...)
+#define CONFIG_FEATURE_TRACEROUTE_VERBOSE 1
+#define ENABLE_FEATURE_TRACEROUTE_VERBOSE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TRACEROUTE_VERBOSE(...) __VA_ARGS__ "CONFIG_FEATURE_TRACEROUTE_VERBOSE"
+#else
+# define IF_FEATURE_TRACEROUTE_VERBOSE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TRACEROUTE_VERBOSE(...)
+#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP 1
+#define ENABLE_FEATURE_TRACEROUTE_USE_ICMP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TRACEROUTE_USE_ICMP(...) __VA_ARGS__ "CONFIG_FEATURE_TRACEROUTE_USE_ICMP"
+#else
+# define IF_FEATURE_TRACEROUTE_USE_ICMP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TRACEROUTE_USE_ICMP(...)
+#define CONFIG_TUNCTL 1
+#define ENABLE_TUNCTL 1
+#ifdef MAKE_SUID
+# define IF_TUNCTL(...) __VA_ARGS__ "CONFIG_TUNCTL"
+#else
+# define IF_TUNCTL(...) __VA_ARGS__
+#endif
+#define IF_NOT_TUNCTL(...)
+#define CONFIG_FEATURE_TUNCTL_UG 1
+#define ENABLE_FEATURE_TUNCTL_UG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TUNCTL_UG(...) __VA_ARGS__ "CONFIG_FEATURE_TUNCTL_UG"
+#else
+# define IF_FEATURE_TUNCTL_UG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TUNCTL_UG(...)
+#define CONFIG_VCONFIG 1
+#define ENABLE_VCONFIG 1
+#ifdef MAKE_SUID
+# define IF_VCONFIG(...) __VA_ARGS__ "CONFIG_VCONFIG"
+#else
+# define IF_VCONFIG(...) __VA_ARGS__
+#endif
+#define IF_NOT_VCONFIG(...)
+#define CONFIG_WGET 1
+#define ENABLE_WGET 1
+#ifdef MAKE_SUID
+# define IF_WGET(...) __VA_ARGS__ "CONFIG_WGET"
+#else
+# define IF_WGET(...) __VA_ARGS__
+#endif
+#define IF_NOT_WGET(...)
+#define CONFIG_FEATURE_WGET_STATUSBAR 1
+#define ENABLE_FEATURE_WGET_STATUSBAR 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WGET_STATUSBAR(...) __VA_ARGS__ "CONFIG_FEATURE_WGET_STATUSBAR"
+#else
+# define IF_FEATURE_WGET_STATUSBAR(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WGET_STATUSBAR(...)
+#define CONFIG_FEATURE_WGET_AUTHENTICATION 1
+#define ENABLE_FEATURE_WGET_AUTHENTICATION 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WGET_AUTHENTICATION(...) __VA_ARGS__ "CONFIG_FEATURE_WGET_AUTHENTICATION"
+#else
+# define IF_FEATURE_WGET_AUTHENTICATION(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WGET_AUTHENTICATION(...)
+#define CONFIG_FEATURE_WGET_LONG_OPTIONS 1
+#define ENABLE_FEATURE_WGET_LONG_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WGET_LONG_OPTIONS(...) __VA_ARGS__ "CONFIG_FEATURE_WGET_LONG_OPTIONS"
+#else
+# define IF_FEATURE_WGET_LONG_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WGET_LONG_OPTIONS(...)
+#define CONFIG_FEATURE_WGET_TIMEOUT 1
+#define ENABLE_FEATURE_WGET_TIMEOUT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WGET_TIMEOUT(...) __VA_ARGS__ "CONFIG_FEATURE_WGET_TIMEOUT"
+#else
+# define IF_FEATURE_WGET_TIMEOUT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WGET_TIMEOUT(...)
+#define CONFIG_FEATURE_WGET_OPENSSL 1
+#define ENABLE_FEATURE_WGET_OPENSSL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WGET_OPENSSL(...) __VA_ARGS__ "CONFIG_FEATURE_WGET_OPENSSL"
+#else
+# define IF_FEATURE_WGET_OPENSSL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WGET_OPENSSL(...)
+#define CONFIG_FEATURE_WGET_SSL_HELPER 1
+#define ENABLE_FEATURE_WGET_SSL_HELPER 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_WGET_SSL_HELPER(...) __VA_ARGS__ "CONFIG_FEATURE_WGET_SSL_HELPER"
+#else
+# define IF_FEATURE_WGET_SSL_HELPER(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_WGET_SSL_HELPER(...)
+#define CONFIG_WHOIS 1
+#define ENABLE_WHOIS 1
+#ifdef MAKE_SUID
+# define IF_WHOIS(...) __VA_ARGS__ "CONFIG_WHOIS"
+#else
+# define IF_WHOIS(...) __VA_ARGS__
+#endif
+#define IF_NOT_WHOIS(...)
+#define CONFIG_ZCIP 1
+#define ENABLE_ZCIP 1
+#ifdef MAKE_SUID
+# define IF_ZCIP(...) __VA_ARGS__ "CONFIG_ZCIP"
+#else
+# define IF_ZCIP(...) __VA_ARGS__
+#endif
+#define IF_NOT_ZCIP(...)
+#undef CONFIG_UDHCPC6
+#define ENABLE_UDHCPC6 0
+#define IF_UDHCPC6(...)
+#define IF_NOT_UDHCPC6(...) __VA_ARGS__
+#define CONFIG_UDHCPD 1
+#define ENABLE_UDHCPD 1
+#ifdef MAKE_SUID
+# define IF_UDHCPD(...) __VA_ARGS__ "CONFIG_UDHCPD"
+#else
+# define IF_UDHCPD(...) __VA_ARGS__
+#endif
+#define IF_NOT_UDHCPD(...)
+#define CONFIG_DHCPRELAY 1
+#define ENABLE_DHCPRELAY 1
+#ifdef MAKE_SUID
+# define IF_DHCPRELAY(...) __VA_ARGS__ "CONFIG_DHCPRELAY"
+#else
+# define IF_DHCPRELAY(...) __VA_ARGS__
+#endif
+#define IF_NOT_DHCPRELAY(...)
+#define CONFIG_DUMPLEASES 1
+#define ENABLE_DUMPLEASES 1
+#ifdef MAKE_SUID
+# define IF_DUMPLEASES(...) __VA_ARGS__ "CONFIG_DUMPLEASES"
+#else
+# define IF_DUMPLEASES(...) __VA_ARGS__
+#endif
+#define IF_NOT_DUMPLEASES(...)
+#define CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY 1
+#define ENABLE_FEATURE_UDHCPD_WRITE_LEASES_EARLY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UDHCPD_WRITE_LEASES_EARLY(...) __VA_ARGS__ "CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY"
+#else
+# define IF_FEATURE_UDHCPD_WRITE_LEASES_EARLY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UDHCPD_WRITE_LEASES_EARLY(...)
+#undef CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC
+#define ENABLE_FEATURE_UDHCPD_BASE_IP_ON_MAC 0
+#define IF_FEATURE_UDHCPD_BASE_IP_ON_MAC(...)
+#define IF_NOT_FEATURE_UDHCPD_BASE_IP_ON_MAC(...) __VA_ARGS__
+#define CONFIG_DHCPD_LEASES_FILE "/var/lib/misc/udhcpd.leases"
+#define ENABLE_DHCPD_LEASES_FILE 1
+#ifdef MAKE_SUID
+# define IF_DHCPD_LEASES_FILE(...) __VA_ARGS__ "CONFIG_DHCPD_LEASES_FILE"
+#else
+# define IF_DHCPD_LEASES_FILE(...) __VA_ARGS__
+#endif
+#define IF_NOT_DHCPD_LEASES_FILE(...)
+#define CONFIG_UDHCPC 1
+#define ENABLE_UDHCPC 1
+#ifdef MAKE_SUID
+# define IF_UDHCPC(...) __VA_ARGS__ "CONFIG_UDHCPC"
+#else
+# define IF_UDHCPC(...) __VA_ARGS__
+#endif
+#define IF_NOT_UDHCPC(...)
+#define CONFIG_FEATURE_UDHCPC_ARPING 1
+#define ENABLE_FEATURE_UDHCPC_ARPING 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UDHCPC_ARPING(...) __VA_ARGS__ "CONFIG_FEATURE_UDHCPC_ARPING"
+#else
+# define IF_FEATURE_UDHCPC_ARPING(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UDHCPC_ARPING(...)
+#define CONFIG_FEATURE_UDHCPC_SANITIZEOPT 1
+#define ENABLE_FEATURE_UDHCPC_SANITIZEOPT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UDHCPC_SANITIZEOPT(...) __VA_ARGS__ "CONFIG_FEATURE_UDHCPC_SANITIZEOPT"
+#else
+# define IF_FEATURE_UDHCPC_SANITIZEOPT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UDHCPC_SANITIZEOPT(...)
+#define CONFIG_FEATURE_UDHCP_PORT 1
+#define ENABLE_FEATURE_UDHCP_PORT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UDHCP_PORT(...) __VA_ARGS__ "CONFIG_FEATURE_UDHCP_PORT"
+#else
+# define IF_FEATURE_UDHCP_PORT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UDHCP_PORT(...)
+#define CONFIG_UDHCP_DEBUG 9
+#define ENABLE_UDHCP_DEBUG 1
+#ifdef MAKE_SUID
+# define IF_UDHCP_DEBUG(...) __VA_ARGS__ "CONFIG_UDHCP_DEBUG"
+#else
+# define IF_UDHCP_DEBUG(...) __VA_ARGS__
+#endif
+#define IF_NOT_UDHCP_DEBUG(...)
+#define CONFIG_FEATURE_UDHCP_RFC3397 1
+#define ENABLE_FEATURE_UDHCP_RFC3397 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UDHCP_RFC3397(...) __VA_ARGS__ "CONFIG_FEATURE_UDHCP_RFC3397"
+#else
+# define IF_FEATURE_UDHCP_RFC3397(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UDHCP_RFC3397(...)
+#define CONFIG_FEATURE_UDHCP_8021Q 1
+#define ENABLE_FEATURE_UDHCP_8021Q 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UDHCP_8021Q(...) __VA_ARGS__ "CONFIG_FEATURE_UDHCP_8021Q"
+#else
+# define IF_FEATURE_UDHCP_8021Q(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UDHCP_8021Q(...)
+#define CONFIG_UDHCPC_DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
+#define ENABLE_UDHCPC_DEFAULT_SCRIPT 1
+#ifdef MAKE_SUID
+# define IF_UDHCPC_DEFAULT_SCRIPT(...) __VA_ARGS__ "CONFIG_UDHCPC_DEFAULT_SCRIPT"
+#else
+# define IF_UDHCPC_DEFAULT_SCRIPT(...) __VA_ARGS__
+#endif
+#define IF_NOT_UDHCPC_DEFAULT_SCRIPT(...)
+#define CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS 80
+#define ENABLE_UDHCPC_SLACK_FOR_BUGGY_SERVERS 1
+#ifdef MAKE_SUID
+# define IF_UDHCPC_SLACK_FOR_BUGGY_SERVERS(...) __VA_ARGS__ "CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS"
+#else
+# define IF_UDHCPC_SLACK_FOR_BUGGY_SERVERS(...) __VA_ARGS__
+#endif
+#define IF_NOT_UDHCPC_SLACK_FOR_BUGGY_SERVERS(...)
+#define CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS "-R -n"
+#define ENABLE_IFUPDOWN_UDHCPC_CMD_OPTIONS 1
+#ifdef MAKE_SUID
+# define IF_IFUPDOWN_UDHCPC_CMD_OPTIONS(...) __VA_ARGS__ "CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS"
+#else
+# define IF_IFUPDOWN_UDHCPC_CMD_OPTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_IFUPDOWN_UDHCPC_CMD_OPTIONS(...)
+
+/*
+ * Print Utilities
+ */
+#define CONFIG_LPD 1
+#define ENABLE_LPD 1
+#ifdef MAKE_SUID
+# define IF_LPD(...) __VA_ARGS__ "CONFIG_LPD"
+#else
+# define IF_LPD(...) __VA_ARGS__
+#endif
+#define IF_NOT_LPD(...)
+#define CONFIG_LPR 1
+#define ENABLE_LPR 1
+#ifdef MAKE_SUID
+# define IF_LPR(...) __VA_ARGS__ "CONFIG_LPR"
+#else
+# define IF_LPR(...) __VA_ARGS__
+#endif
+#define IF_NOT_LPR(...)
+#define CONFIG_LPQ 1
+#define ENABLE_LPQ 1
+#ifdef MAKE_SUID
+# define IF_LPQ(...) __VA_ARGS__ "CONFIG_LPQ"
+#else
+# define IF_LPQ(...) __VA_ARGS__
+#endif
+#define IF_NOT_LPQ(...)
+
+/*
+ * Mail Utilities
+ */
+#define CONFIG_MAKEMIME 1
+#define ENABLE_MAKEMIME 1
+#ifdef MAKE_SUID
+# define IF_MAKEMIME(...) __VA_ARGS__ "CONFIG_MAKEMIME"
+#else
+# define IF_MAKEMIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_MAKEMIME(...)
+#define CONFIG_POPMAILDIR 1
+#define ENABLE_POPMAILDIR 1
+#ifdef MAKE_SUID
+# define IF_POPMAILDIR(...) __VA_ARGS__ "CONFIG_POPMAILDIR"
+#else
+# define IF_POPMAILDIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_POPMAILDIR(...)
+#define CONFIG_FEATURE_POPMAILDIR_DELIVERY 1
+#define ENABLE_FEATURE_POPMAILDIR_DELIVERY 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_POPMAILDIR_DELIVERY(...) __VA_ARGS__ "CONFIG_FEATURE_POPMAILDIR_DELIVERY"
+#else
+# define IF_FEATURE_POPMAILDIR_DELIVERY(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_POPMAILDIR_DELIVERY(...)
+#define CONFIG_REFORMIME 1
+#define ENABLE_REFORMIME 1
+#ifdef MAKE_SUID
+# define IF_REFORMIME(...) __VA_ARGS__ "CONFIG_REFORMIME"
+#else
+# define IF_REFORMIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_REFORMIME(...)
+#define CONFIG_FEATURE_REFORMIME_COMPAT 1
+#define ENABLE_FEATURE_REFORMIME_COMPAT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_REFORMIME_COMPAT(...) __VA_ARGS__ "CONFIG_FEATURE_REFORMIME_COMPAT"
+#else
+# define IF_FEATURE_REFORMIME_COMPAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_REFORMIME_COMPAT(...)
+#define CONFIG_SENDMAIL 1
+#define ENABLE_SENDMAIL 1
+#ifdef MAKE_SUID
+# define IF_SENDMAIL(...) __VA_ARGS__ "CONFIG_SENDMAIL"
+#else
+# define IF_SENDMAIL(...) __VA_ARGS__
+#endif
+#define IF_NOT_SENDMAIL(...)
+#define CONFIG_FEATURE_MIME_CHARSET "us-ascii"
+#define ENABLE_FEATURE_MIME_CHARSET 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_MIME_CHARSET(...) __VA_ARGS__ "CONFIG_FEATURE_MIME_CHARSET"
+#else
+# define IF_FEATURE_MIME_CHARSET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_MIME_CHARSET(...)
+
+/*
+ * Process Utilities
+ */
+#define CONFIG_FREE 1
+#define ENABLE_FREE 1
+#ifdef MAKE_SUID
+# define IF_FREE(...) __VA_ARGS__ "CONFIG_FREE"
+#else
+# define IF_FREE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FREE(...)
+#define CONFIG_FUSER 1
+#define ENABLE_FUSER 1
+#ifdef MAKE_SUID
+# define IF_FUSER(...) __VA_ARGS__ "CONFIG_FUSER"
+#else
+# define IF_FUSER(...) __VA_ARGS__
+#endif
+#define IF_NOT_FUSER(...)
+#define CONFIG_IOSTAT 1
+#define ENABLE_IOSTAT 1
+#ifdef MAKE_SUID
+# define IF_IOSTAT(...) __VA_ARGS__ "CONFIG_IOSTAT"
+#else
+# define IF_IOSTAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_IOSTAT(...)
+#define CONFIG_KILL 1
+#define ENABLE_KILL 1
+#ifdef MAKE_SUID
+# define IF_KILL(...) __VA_ARGS__ "CONFIG_KILL"
+#else
+# define IF_KILL(...) __VA_ARGS__
+#endif
+#define IF_NOT_KILL(...)
+#define CONFIG_KILLALL 1
+#define ENABLE_KILLALL 1
+#ifdef MAKE_SUID
+# define IF_KILLALL(...) __VA_ARGS__ "CONFIG_KILLALL"
+#else
+# define IF_KILLALL(...) __VA_ARGS__
+#endif
+#define IF_NOT_KILLALL(...)
+#define CONFIG_KILLALL5 1
+#define ENABLE_KILLALL5 1
+#ifdef MAKE_SUID
+# define IF_KILLALL5(...) __VA_ARGS__ "CONFIG_KILLALL5"
+#else
+# define IF_KILLALL5(...) __VA_ARGS__
+#endif
+#define IF_NOT_KILLALL5(...)
+#define CONFIG_LSOF 1
+#define ENABLE_LSOF 1
+#ifdef MAKE_SUID
+# define IF_LSOF(...) __VA_ARGS__ "CONFIG_LSOF"
+#else
+# define IF_LSOF(...) __VA_ARGS__
+#endif
+#define IF_NOT_LSOF(...)
+#define CONFIG_MPSTAT 1
+#define ENABLE_MPSTAT 1
+#ifdef MAKE_SUID
+# define IF_MPSTAT(...) __VA_ARGS__ "CONFIG_MPSTAT"
+#else
+# define IF_MPSTAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_MPSTAT(...)
+#define CONFIG_NMETER 1
+#define ENABLE_NMETER 1
+#ifdef MAKE_SUID
+# define IF_NMETER(...) __VA_ARGS__ "CONFIG_NMETER"
+#else
+# define IF_NMETER(...) __VA_ARGS__
+#endif
+#define IF_NOT_NMETER(...)
+#define CONFIG_PGREP 1
+#define ENABLE_PGREP 1
+#ifdef MAKE_SUID
+# define IF_PGREP(...) __VA_ARGS__ "CONFIG_PGREP"
+#else
+# define IF_PGREP(...) __VA_ARGS__
+#endif
+#define IF_NOT_PGREP(...)
+#define CONFIG_PKILL 1
+#define ENABLE_PKILL 1
+#ifdef MAKE_SUID
+# define IF_PKILL(...) __VA_ARGS__ "CONFIG_PKILL"
+#else
+# define IF_PKILL(...) __VA_ARGS__
+#endif
+#define IF_NOT_PKILL(...)
+#define CONFIG_PIDOF 1
+#define ENABLE_PIDOF 1
+#ifdef MAKE_SUID
+# define IF_PIDOF(...) __VA_ARGS__ "CONFIG_PIDOF"
+#else
+# define IF_PIDOF(...) __VA_ARGS__
+#endif
+#define IF_NOT_PIDOF(...)
+#define CONFIG_FEATURE_PIDOF_SINGLE 1
+#define ENABLE_FEATURE_PIDOF_SINGLE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PIDOF_SINGLE(...) __VA_ARGS__ "CONFIG_FEATURE_PIDOF_SINGLE"
+#else
+# define IF_FEATURE_PIDOF_SINGLE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PIDOF_SINGLE(...)
+#define CONFIG_FEATURE_PIDOF_OMIT 1
+#define ENABLE_FEATURE_PIDOF_OMIT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PIDOF_OMIT(...) __VA_ARGS__ "CONFIG_FEATURE_PIDOF_OMIT"
+#else
+# define IF_FEATURE_PIDOF_OMIT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PIDOF_OMIT(...)
+#define CONFIG_PMAP 1
+#define ENABLE_PMAP 1
+#ifdef MAKE_SUID
+# define IF_PMAP(...) __VA_ARGS__ "CONFIG_PMAP"
+#else
+# define IF_PMAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_PMAP(...)
+#define CONFIG_POWERTOP 1
+#define ENABLE_POWERTOP 1
+#ifdef MAKE_SUID
+# define IF_POWERTOP(...) __VA_ARGS__ "CONFIG_POWERTOP"
+#else
+# define IF_POWERTOP(...) __VA_ARGS__
+#endif
+#define IF_NOT_POWERTOP(...)
+#define CONFIG_PS 1
+#define ENABLE_PS 1
+#ifdef MAKE_SUID
+# define IF_PS(...) __VA_ARGS__ "CONFIG_PS"
+#else
+# define IF_PS(...) __VA_ARGS__
+#endif
+#define IF_NOT_PS(...)
+#undef CONFIG_FEATURE_PS_WIDE
+#define ENABLE_FEATURE_PS_WIDE 0
+#define IF_FEATURE_PS_WIDE(...)
+#define IF_NOT_FEATURE_PS_WIDE(...) __VA_ARGS__
+#undef CONFIG_FEATURE_PS_LONG
+#define ENABLE_FEATURE_PS_LONG 0
+#define IF_FEATURE_PS_LONG(...)
+#define IF_NOT_FEATURE_PS_LONG(...) __VA_ARGS__
+#define CONFIG_FEATURE_PS_TIME 1
+#define ENABLE_FEATURE_PS_TIME 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PS_TIME(...) __VA_ARGS__ "CONFIG_FEATURE_PS_TIME"
+#else
+# define IF_FEATURE_PS_TIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PS_TIME(...)
+#define CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS 1
+#define ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PS_ADDITIONAL_COLUMNS(...) __VA_ARGS__ "CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS"
+#else
+# define IF_FEATURE_PS_ADDITIONAL_COLUMNS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PS_ADDITIONAL_COLUMNS(...)
+#define CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS 1
+#define ENABLE_FEATURE_PS_UNUSUAL_SYSTEMS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_PS_UNUSUAL_SYSTEMS(...) __VA_ARGS__ "CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS"
+#else
+# define IF_FEATURE_PS_UNUSUAL_SYSTEMS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_PS_UNUSUAL_SYSTEMS(...)
+#define CONFIG_PSTREE 1
+#define ENABLE_PSTREE 1
+#ifdef MAKE_SUID
+# define IF_PSTREE(...) __VA_ARGS__ "CONFIG_PSTREE"
+#else
+# define IF_PSTREE(...) __VA_ARGS__
+#endif
+#define IF_NOT_PSTREE(...)
+#define CONFIG_PWDX 1
+#define ENABLE_PWDX 1
+#ifdef MAKE_SUID
+# define IF_PWDX(...) __VA_ARGS__ "CONFIG_PWDX"
+#else
+# define IF_PWDX(...) __VA_ARGS__
+#endif
+#define IF_NOT_PWDX(...)
+#define CONFIG_RENICE 1
+#define ENABLE_RENICE 1
+#ifdef MAKE_SUID
+# define IF_RENICE(...) __VA_ARGS__ "CONFIG_RENICE"
+#else
+# define IF_RENICE(...) __VA_ARGS__
+#endif
+#define IF_NOT_RENICE(...)
+#define CONFIG_SMEMCAP 1
+#define ENABLE_SMEMCAP 1
+#ifdef MAKE_SUID
+# define IF_SMEMCAP(...) __VA_ARGS__ "CONFIG_SMEMCAP"
+#else
+# define IF_SMEMCAP(...) __VA_ARGS__
+#endif
+#define IF_NOT_SMEMCAP(...)
+#define CONFIG_BB_SYSCTL 1
+#define ENABLE_BB_SYSCTL 1
+#ifdef MAKE_SUID
+# define IF_BB_SYSCTL(...) __VA_ARGS__ "CONFIG_BB_SYSCTL"
+#else
+# define IF_BB_SYSCTL(...) __VA_ARGS__
+#endif
+#define IF_NOT_BB_SYSCTL(...)
+#define CONFIG_TOP 1
+#define ENABLE_TOP 1
+#ifdef MAKE_SUID
+# define IF_TOP(...) __VA_ARGS__ "CONFIG_TOP"
+#else
+# define IF_TOP(...) __VA_ARGS__
+#endif
+#define IF_NOT_TOP(...)
+#define CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE 1
+#define ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(...) __VA_ARGS__ "CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE"
+#else
+# define IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOP_CPU_USAGE_PERCENTAGE(...)
+#define CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS 1
+#define ENABLE_FEATURE_TOP_CPU_GLOBAL_PERCENTS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOP_CPU_GLOBAL_PERCENTS(...) __VA_ARGS__ "CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS"
+#else
+# define IF_FEATURE_TOP_CPU_GLOBAL_PERCENTS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOP_CPU_GLOBAL_PERCENTS(...)
+#define CONFIG_FEATURE_TOP_SMP_CPU 1
+#define ENABLE_FEATURE_TOP_SMP_CPU 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOP_SMP_CPU(...) __VA_ARGS__ "CONFIG_FEATURE_TOP_SMP_CPU"
+#else
+# define IF_FEATURE_TOP_SMP_CPU(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOP_SMP_CPU(...)
+#define CONFIG_FEATURE_TOP_DECIMALS 1
+#define ENABLE_FEATURE_TOP_DECIMALS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOP_DECIMALS(...) __VA_ARGS__ "CONFIG_FEATURE_TOP_DECIMALS"
+#else
+# define IF_FEATURE_TOP_DECIMALS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOP_DECIMALS(...)
+#define CONFIG_FEATURE_TOP_SMP_PROCESS 1
+#define ENABLE_FEATURE_TOP_SMP_PROCESS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOP_SMP_PROCESS(...) __VA_ARGS__ "CONFIG_FEATURE_TOP_SMP_PROCESS"
+#else
+# define IF_FEATURE_TOP_SMP_PROCESS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOP_SMP_PROCESS(...)
+#define CONFIG_FEATURE_TOPMEM 1
+#define ENABLE_FEATURE_TOPMEM 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_TOPMEM(...) __VA_ARGS__ "CONFIG_FEATURE_TOPMEM"
+#else
+# define IF_FEATURE_TOPMEM(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_TOPMEM(...)
+#define CONFIG_UPTIME 1
+#define ENABLE_UPTIME 1
+#ifdef MAKE_SUID
+# define IF_UPTIME(...) __VA_ARGS__ "CONFIG_UPTIME"
+#else
+# define IF_UPTIME(...) __VA_ARGS__
+#endif
+#define IF_NOT_UPTIME(...)
+#define CONFIG_FEATURE_UPTIME_UTMP_SUPPORT 1
+#define ENABLE_FEATURE_UPTIME_UTMP_SUPPORT 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_UPTIME_UTMP_SUPPORT(...) __VA_ARGS__ "CONFIG_FEATURE_UPTIME_UTMP_SUPPORT"
+#else
+# define IF_FEATURE_UPTIME_UTMP_SUPPORT(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_UPTIME_UTMP_SUPPORT(...)
+#define CONFIG_WATCH 1
+#define ENABLE_WATCH 1
+#ifdef MAKE_SUID
+# define IF_WATCH(...) __VA_ARGS__ "CONFIG_WATCH"
+#else
+# define IF_WATCH(...) __VA_ARGS__
+#endif
+#define IF_NOT_WATCH(...)
+#define CONFIG_FEATURE_SHOW_THREADS 1
+#define ENABLE_FEATURE_SHOW_THREADS 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SHOW_THREADS(...) __VA_ARGS__ "CONFIG_FEATURE_SHOW_THREADS"
+#else
+# define IF_FEATURE_SHOW_THREADS(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SHOW_THREADS(...)
+
+/*
+ * Runit Utilities
+ */
+#define CONFIG_CHPST 1
+#define ENABLE_CHPST 1
+#ifdef MAKE_SUID
+# define IF_CHPST(...) __VA_ARGS__ "CONFIG_CHPST"
+#else
+# define IF_CHPST(...) __VA_ARGS__
+#endif
+#define IF_NOT_CHPST(...)
+#define CONFIG_SETUIDGID 1
+#define ENABLE_SETUIDGID 1
+#ifdef MAKE_SUID
+# define IF_SETUIDGID(...) __VA_ARGS__ "CONFIG_SETUIDGID"
+#else
+# define IF_SETUIDGID(...) __VA_ARGS__
+#endif
+#define IF_NOT_SETUIDGID(...)
+#define CONFIG_ENVUIDGID 1
+#define ENABLE_ENVUIDGID 1
+#ifdef MAKE_SUID
+# define IF_ENVUIDGID(...) __VA_ARGS__ "CONFIG_ENVUIDGID"
+#else
+# define IF_ENVUIDGID(...) __VA_ARGS__
+#endif
+#define IF_NOT_ENVUIDGID(...)
+#define CONFIG_ENVDIR 1
+#define ENABLE_ENVDIR 1
+#ifdef MAKE_SUID
+# define IF_ENVDIR(...) __VA_ARGS__ "CONFIG_ENVDIR"
+#else
+# define IF_ENVDIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_ENVDIR(...)
+#define CONFIG_SOFTLIMIT 1
+#define ENABLE_SOFTLIMIT 1
+#ifdef MAKE_SUID
+# define IF_SOFTLIMIT(...) __VA_ARGS__ "CONFIG_SOFTLIMIT"
+#else
+# define IF_SOFTLIMIT(...) __VA_ARGS__
+#endif
+#define IF_NOT_SOFTLIMIT(...)
+#define CONFIG_RUNSV 1
+#define ENABLE_RUNSV 1
+#ifdef MAKE_SUID
+# define IF_RUNSV(...) __VA_ARGS__ "CONFIG_RUNSV"
+#else
+# define IF_RUNSV(...) __VA_ARGS__
+#endif
+#define IF_NOT_RUNSV(...)
+#define CONFIG_RUNSVDIR 1
+#define ENABLE_RUNSVDIR 1
+#ifdef MAKE_SUID
+# define IF_RUNSVDIR(...) __VA_ARGS__ "CONFIG_RUNSVDIR"
+#else
+# define IF_RUNSVDIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_RUNSVDIR(...)
+#define CONFIG_FEATURE_RUNSVDIR_LOG 1
+#define ENABLE_FEATURE_RUNSVDIR_LOG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_RUNSVDIR_LOG(...) __VA_ARGS__ "CONFIG_FEATURE_RUNSVDIR_LOG"
+#else
+# define IF_FEATURE_RUNSVDIR_LOG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_RUNSVDIR_LOG(...)
+#define CONFIG_SV 1
+#define ENABLE_SV 1
+#ifdef MAKE_SUID
+# define IF_SV(...) __VA_ARGS__ "CONFIG_SV"
+#else
+# define IF_SV(...) __VA_ARGS__
+#endif
+#define IF_NOT_SV(...)
+#define CONFIG_SV_DEFAULT_SERVICE_DIR "/var/service"
+#define ENABLE_SV_DEFAULT_SERVICE_DIR 1
+#ifdef MAKE_SUID
+# define IF_SV_DEFAULT_SERVICE_DIR(...) __VA_ARGS__ "CONFIG_SV_DEFAULT_SERVICE_DIR"
+#else
+# define IF_SV_DEFAULT_SERVICE_DIR(...) __VA_ARGS__
+#endif
+#define IF_NOT_SV_DEFAULT_SERVICE_DIR(...)
+#define CONFIG_SVC 1
+#define ENABLE_SVC 1
+#ifdef MAKE_SUID
+# define IF_SVC(...) __VA_ARGS__ "CONFIG_SVC"
+#else
+# define IF_SVC(...) __VA_ARGS__
+#endif
+#define IF_NOT_SVC(...)
+#define CONFIG_SVLOGD 1
+#define ENABLE_SVLOGD 1
+#ifdef MAKE_SUID
+# define IF_SVLOGD(...) __VA_ARGS__ "CONFIG_SVLOGD"
+#else
+# define IF_SVLOGD(...) __VA_ARGS__
+#endif
+#define IF_NOT_SVLOGD(...)
+#undef CONFIG_CHCON
+#define ENABLE_CHCON 0
+#define IF_CHCON(...)
+#define IF_NOT_CHCON(...) __VA_ARGS__
+#undef CONFIG_FEATURE_CHCON_LONG_OPTIONS
+#define ENABLE_FEATURE_CHCON_LONG_OPTIONS 0
+#define IF_FEATURE_CHCON_LONG_OPTIONS(...)
+#define IF_NOT_FEATURE_CHCON_LONG_OPTIONS(...) __VA_ARGS__
+#undef CONFIG_GETENFORCE
+#define ENABLE_GETENFORCE 0
+#define IF_GETENFORCE(...)
+#define IF_NOT_GETENFORCE(...) __VA_ARGS__
+#undef CONFIG_GETSEBOOL
+#define ENABLE_GETSEBOOL 0
+#define IF_GETSEBOOL(...)
+#define IF_NOT_GETSEBOOL(...) __VA_ARGS__
+#undef CONFIG_LOAD_POLICY
+#define ENABLE_LOAD_POLICY 0
+#define IF_LOAD_POLICY(...)
+#define IF_NOT_LOAD_POLICY(...) __VA_ARGS__
+#undef CONFIG_MATCHPATHCON
+#define ENABLE_MATCHPATHCON 0
+#define IF_MATCHPATHCON(...)
+#define IF_NOT_MATCHPATHCON(...) __VA_ARGS__
+#undef CONFIG_RUNCON
+#define ENABLE_RUNCON 0
+#define IF_RUNCON(...)
+#define IF_NOT_RUNCON(...) __VA_ARGS__
+#undef CONFIG_FEATURE_RUNCON_LONG_OPTIONS
+#define ENABLE_FEATURE_RUNCON_LONG_OPTIONS 0
+#define IF_FEATURE_RUNCON_LONG_OPTIONS(...)
+#define IF_NOT_FEATURE_RUNCON_LONG_OPTIONS(...) __VA_ARGS__
+#undef CONFIG_SELINUXENABLED
+#define ENABLE_SELINUXENABLED 0
+#define IF_SELINUXENABLED(...)
+#define IF_NOT_SELINUXENABLED(...) __VA_ARGS__
+#undef CONFIG_SESTATUS
+#define ENABLE_SESTATUS 0
+#define IF_SESTATUS(...)
+#define IF_NOT_SESTATUS(...) __VA_ARGS__
+#undef CONFIG_SETENFORCE
+#define ENABLE_SETENFORCE 0
+#define IF_SETENFORCE(...)
+#define IF_NOT_SETENFORCE(...) __VA_ARGS__
+#undef CONFIG_SETFILES
+#define ENABLE_SETFILES 0
+#define IF_SETFILES(...)
+#define IF_NOT_SETFILES(...) __VA_ARGS__
+#undef CONFIG_FEATURE_SETFILES_CHECK_OPTION
+#define ENABLE_FEATURE_SETFILES_CHECK_OPTION 0
+#define IF_FEATURE_SETFILES_CHECK_OPTION(...)
+#define IF_NOT_FEATURE_SETFILES_CHECK_OPTION(...) __VA_ARGS__
+#undef CONFIG_RESTORECON
+#define ENABLE_RESTORECON 0
+#define IF_RESTORECON(...)
+#define IF_NOT_RESTORECON(...) __VA_ARGS__
+#undef CONFIG_SETSEBOOL
+#define ENABLE_SETSEBOOL 0
+#define IF_SETSEBOOL(...)
+#define IF_NOT_SETSEBOOL(...) __VA_ARGS__
+
+/*
+ * Shells
+ */
+#undef CONFIG_SH_IS_ASH
+#define ENABLE_SH_IS_ASH 0
+#define IF_SH_IS_ASH(...)
+#define IF_NOT_SH_IS_ASH(...) __VA_ARGS__
+#define CONFIG_SH_IS_HUSH 1
+#define ENABLE_SH_IS_HUSH 1
+#ifdef MAKE_SUID
+# define IF_SH_IS_HUSH(...) __VA_ARGS__ "CONFIG_SH_IS_HUSH"
+#else
+# define IF_SH_IS_HUSH(...) __VA_ARGS__
+#endif
+#define IF_NOT_SH_IS_HUSH(...)
+#undef CONFIG_SH_IS_NONE
+#define ENABLE_SH_IS_NONE 0
+#define IF_SH_IS_NONE(...)
+#define IF_NOT_SH_IS_NONE(...) __VA_ARGS__
+#undef CONFIG_BASH_IS_ASH
+#define ENABLE_BASH_IS_ASH 0
+#define IF_BASH_IS_ASH(...)
+#define IF_NOT_BASH_IS_ASH(...) __VA_ARGS__
+#undef CONFIG_BASH_IS_HUSH
+#define ENABLE_BASH_IS_HUSH 0
+#define IF_BASH_IS_HUSH(...)
+#define IF_NOT_BASH_IS_HUSH(...) __VA_ARGS__
+#define CONFIG_BASH_IS_NONE 1
+#define ENABLE_BASH_IS_NONE 1
+#ifdef MAKE_SUID
+# define IF_BASH_IS_NONE(...) __VA_ARGS__ "CONFIG_BASH_IS_NONE"
+#else
+# define IF_BASH_IS_NONE(...) __VA_ARGS__
+#endif
+#define IF_NOT_BASH_IS_NONE(...)
+#undef CONFIG_ASH
+#define ENABLE_ASH 0
+#define IF_ASH(...)
+#define IF_NOT_ASH(...) __VA_ARGS__
+#undef CONFIG_ASH_OPTIMIZE_FOR_SIZE
+#define ENABLE_ASH_OPTIMIZE_FOR_SIZE 0
+#define IF_ASH_OPTIMIZE_FOR_SIZE(...)
+#define IF_NOT_ASH_OPTIMIZE_FOR_SIZE(...) __VA_ARGS__
+#undef CONFIG_ASH_INTERNAL_GLOB
+#define ENABLE_ASH_INTERNAL_GLOB 0
+#define IF_ASH_INTERNAL_GLOB(...)
+#define IF_NOT_ASH_INTERNAL_GLOB(...) __VA_ARGS__
+#undef CONFIG_ASH_RANDOM_SUPPORT
+#define ENABLE_ASH_RANDOM_SUPPORT 0
+#define IF_ASH_RANDOM_SUPPORT(...)
+#define IF_NOT_ASH_RANDOM_SUPPORT(...) __VA_ARGS__
+#undef CONFIG_ASH_EXPAND_PRMT
+#define ENABLE_ASH_EXPAND_PRMT 0
+#define IF_ASH_EXPAND_PRMT(...)
+#define IF_NOT_ASH_EXPAND_PRMT(...) __VA_ARGS__
+#undef CONFIG_ASH_BASH_COMPAT
+#define ENABLE_ASH_BASH_COMPAT 0
+#define IF_ASH_BASH_COMPAT(...)
+#define IF_NOT_ASH_BASH_COMPAT(...) __VA_ARGS__
+#undef CONFIG_ASH_IDLE_TIMEOUT
+#define ENABLE_ASH_IDLE_TIMEOUT 0
+#define IF_ASH_IDLE_TIMEOUT(...)
+#define IF_NOT_ASH_IDLE_TIMEOUT(...) __VA_ARGS__
+#undef CONFIG_ASH_JOB_CONTROL
+#define ENABLE_ASH_JOB_CONTROL 0
+#define IF_ASH_JOB_CONTROL(...)
+#define IF_NOT_ASH_JOB_CONTROL(...) __VA_ARGS__
+#undef CONFIG_ASH_ALIAS
+#define ENABLE_ASH_ALIAS 0
+#define IF_ASH_ALIAS(...)
+#define IF_NOT_ASH_ALIAS(...) __VA_ARGS__
+#undef CONFIG_ASH_GETOPTS
+#define ENABLE_ASH_GETOPTS 0
+#define IF_ASH_GETOPTS(...)
+#define IF_NOT_ASH_GETOPTS(...) __VA_ARGS__
+#undef CONFIG_ASH_BUILTIN_ECHO
+#define ENABLE_ASH_BUILTIN_ECHO 0
+#define IF_ASH_BUILTIN_ECHO(...)
+#define IF_NOT_ASH_BUILTIN_ECHO(...) __VA_ARGS__
+#undef CONFIG_ASH_BUILTIN_PRINTF
+#define ENABLE_ASH_BUILTIN_PRINTF 0
+#define IF_ASH_BUILTIN_PRINTF(...)
+#define IF_NOT_ASH_BUILTIN_PRINTF(...) __VA_ARGS__
+#undef CONFIG_ASH_BUILTIN_TEST
+#define ENABLE_ASH_BUILTIN_TEST 0
+#define IF_ASH_BUILTIN_TEST(...)
+#define IF_NOT_ASH_BUILTIN_TEST(...) __VA_ARGS__
+#undef CONFIG_ASH_HELP
+#define ENABLE_ASH_HELP 0
+#define IF_ASH_HELP(...)
+#define IF_NOT_ASH_HELP(...) __VA_ARGS__
+#undef CONFIG_ASH_CMDCMD
+#define ENABLE_ASH_CMDCMD 0
+#define IF_ASH_CMDCMD(...)
+#define IF_NOT_ASH_CMDCMD(...) __VA_ARGS__
+#undef CONFIG_ASH_MAIL
+#define ENABLE_ASH_MAIL 0
+#define IF_ASH_MAIL(...)
+#define IF_NOT_ASH_MAIL(...) __VA_ARGS__
+#define CONFIG_CTTYHACK 1
+#define ENABLE_CTTYHACK 1
+#ifdef MAKE_SUID
+# define IF_CTTYHACK(...) __VA_ARGS__ "CONFIG_CTTYHACK"
+#else
+# define IF_CTTYHACK(...) __VA_ARGS__
+#endif
+#define IF_NOT_CTTYHACK(...)
+#define CONFIG_HUSH 1
+#define ENABLE_HUSH 1
+#ifdef MAKE_SUID
+# define IF_HUSH(...) __VA_ARGS__ "CONFIG_HUSH"
+#else
+# define IF_HUSH(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH(...)
+#define CONFIG_HUSH_BASH_COMPAT 1
+#define ENABLE_HUSH_BASH_COMPAT 1
+#ifdef MAKE_SUID
+# define IF_HUSH_BASH_COMPAT(...) __VA_ARGS__ "CONFIG_HUSH_BASH_COMPAT"
+#else
+# define IF_HUSH_BASH_COMPAT(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_BASH_COMPAT(...)
+#define CONFIG_HUSH_BRACE_EXPANSION 1
+#define ENABLE_HUSH_BRACE_EXPANSION 1
+#ifdef MAKE_SUID
+# define IF_HUSH_BRACE_EXPANSION(...) __VA_ARGS__ "CONFIG_HUSH_BRACE_EXPANSION"
+#else
+# define IF_HUSH_BRACE_EXPANSION(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_BRACE_EXPANSION(...)
+#define CONFIG_HUSH_HELP 1
+#define ENABLE_HUSH_HELP 1
+#ifdef MAKE_SUID
+# define IF_HUSH_HELP(...) __VA_ARGS__ "CONFIG_HUSH_HELP"
+#else
+# define IF_HUSH_HELP(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_HELP(...)
+#define CONFIG_HUSH_INTERACTIVE 1
+#define ENABLE_HUSH_INTERACTIVE 1
+#ifdef MAKE_SUID
+# define IF_HUSH_INTERACTIVE(...) __VA_ARGS__ "CONFIG_HUSH_INTERACTIVE"
+#else
+# define IF_HUSH_INTERACTIVE(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_INTERACTIVE(...)
+#undef CONFIG_HUSH_SAVEHISTORY
+#define ENABLE_HUSH_SAVEHISTORY 0
+#define IF_HUSH_SAVEHISTORY(...)
+#define IF_NOT_HUSH_SAVEHISTORY(...) __VA_ARGS__
+#define CONFIG_HUSH_JOB 1
+#define ENABLE_HUSH_JOB 1
+#ifdef MAKE_SUID
+# define IF_HUSH_JOB(...) __VA_ARGS__ "CONFIG_HUSH_JOB"
+#else
+# define IF_HUSH_JOB(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_JOB(...)
+#define CONFIG_HUSH_TICK 1
+#define ENABLE_HUSH_TICK 1
+#ifdef MAKE_SUID
+# define IF_HUSH_TICK(...) __VA_ARGS__ "CONFIG_HUSH_TICK"
+#else
+# define IF_HUSH_TICK(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_TICK(...)
+#define CONFIG_HUSH_IF 1
+#define ENABLE_HUSH_IF 1
+#ifdef MAKE_SUID
+# define IF_HUSH_IF(...) __VA_ARGS__ "CONFIG_HUSH_IF"
+#else
+# define IF_HUSH_IF(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_IF(...)
+#define CONFIG_HUSH_LOOPS 1
+#define ENABLE_HUSH_LOOPS 1
+#ifdef MAKE_SUID
+# define IF_HUSH_LOOPS(...) __VA_ARGS__ "CONFIG_HUSH_LOOPS"
+#else
+# define IF_HUSH_LOOPS(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_LOOPS(...)
+#define CONFIG_HUSH_CASE 1
+#define ENABLE_HUSH_CASE 1
+#ifdef MAKE_SUID
+# define IF_HUSH_CASE(...) __VA_ARGS__ "CONFIG_HUSH_CASE"
+#else
+# define IF_HUSH_CASE(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_CASE(...)
+#define CONFIG_HUSH_FUNCTIONS 1
+#define ENABLE_HUSH_FUNCTIONS 1
+#ifdef MAKE_SUID
+# define IF_HUSH_FUNCTIONS(...) __VA_ARGS__ "CONFIG_HUSH_FUNCTIONS"
+#else
+# define IF_HUSH_FUNCTIONS(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_FUNCTIONS(...)
+#define CONFIG_HUSH_LOCAL 1
+#define ENABLE_HUSH_LOCAL 1
+#ifdef MAKE_SUID
+# define IF_HUSH_LOCAL(...) __VA_ARGS__ "CONFIG_HUSH_LOCAL"
+#else
+# define IF_HUSH_LOCAL(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_LOCAL(...)
+#define CONFIG_HUSH_RANDOM_SUPPORT 1
+#define ENABLE_HUSH_RANDOM_SUPPORT 1
+#ifdef MAKE_SUID
+# define IF_HUSH_RANDOM_SUPPORT(...) __VA_ARGS__ "CONFIG_HUSH_RANDOM_SUPPORT"
+#else
+# define IF_HUSH_RANDOM_SUPPORT(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_RANDOM_SUPPORT(...)
+#define CONFIG_HUSH_EXPORT_N 1
+#define ENABLE_HUSH_EXPORT_N 1
+#ifdef MAKE_SUID
+# define IF_HUSH_EXPORT_N(...) __VA_ARGS__ "CONFIG_HUSH_EXPORT_N"
+#else
+# define IF_HUSH_EXPORT_N(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_EXPORT_N(...)
+#define CONFIG_HUSH_MODE_X 1
+#define ENABLE_HUSH_MODE_X 1
+#ifdef MAKE_SUID
+# define IF_HUSH_MODE_X(...) __VA_ARGS__ "CONFIG_HUSH_MODE_X"
+#else
+# define IF_HUSH_MODE_X(...) __VA_ARGS__
+#endif
+#define IF_NOT_HUSH_MODE_X(...)
+#define CONFIG_MSH 1
+#define ENABLE_MSH 1
+#ifdef MAKE_SUID
+# define IF_MSH(...) __VA_ARGS__ "CONFIG_MSH"
+#else
+# define IF_MSH(...) __VA_ARGS__
+#endif
+#define IF_NOT_MSH(...)
+#define CONFIG_FEATURE_SH_MATH 1
+#define ENABLE_FEATURE_SH_MATH 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SH_MATH(...) __VA_ARGS__ "CONFIG_FEATURE_SH_MATH"
+#else
+# define IF_FEATURE_SH_MATH(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SH_MATH(...)
+#define CONFIG_FEATURE_SH_MATH_64 1
+#define ENABLE_FEATURE_SH_MATH_64 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SH_MATH_64(...) __VA_ARGS__ "CONFIG_FEATURE_SH_MATH_64"
+#else
+# define IF_FEATURE_SH_MATH_64(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SH_MATH_64(...)
+#define CONFIG_FEATURE_SH_EXTRA_QUIET 1
+#define ENABLE_FEATURE_SH_EXTRA_QUIET 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SH_EXTRA_QUIET(...) __VA_ARGS__ "CONFIG_FEATURE_SH_EXTRA_QUIET"
+#else
+# define IF_FEATURE_SH_EXTRA_QUIET(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SH_EXTRA_QUIET(...)
+#define CONFIG_FEATURE_SH_STANDALONE 1
+#define ENABLE_FEATURE_SH_STANDALONE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SH_STANDALONE(...) __VA_ARGS__ "CONFIG_FEATURE_SH_STANDALONE"
+#else
+# define IF_FEATURE_SH_STANDALONE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SH_STANDALONE(...)
+#define CONFIG_FEATURE_SH_NOFORK 1
+#define ENABLE_FEATURE_SH_NOFORK 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SH_NOFORK(...) __VA_ARGS__ "CONFIG_FEATURE_SH_NOFORK"
+#else
+# define IF_FEATURE_SH_NOFORK(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SH_NOFORK(...)
+#define CONFIG_FEATURE_SH_HISTFILESIZE 1
+#define ENABLE_FEATURE_SH_HISTFILESIZE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SH_HISTFILESIZE(...) __VA_ARGS__ "CONFIG_FEATURE_SH_HISTFILESIZE"
+#else
+# define IF_FEATURE_SH_HISTFILESIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SH_HISTFILESIZE(...)
+
+/*
+ * System Logging Utilities
+ */
+#define CONFIG_KLOGD 1
+#define ENABLE_KLOGD 1
+#ifdef MAKE_SUID
+# define IF_KLOGD(...) __VA_ARGS__ "CONFIG_KLOGD"
+#else
+# define IF_KLOGD(...) __VA_ARGS__
+#endif
+#define IF_NOT_KLOGD(...)
+
+/*
+ * klogd should not be used together with syslog to kernel printk buffer
+ */
+#define CONFIG_FEATURE_KLOGD_KLOGCTL 1
+#define ENABLE_FEATURE_KLOGD_KLOGCTL 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_KLOGD_KLOGCTL(...) __VA_ARGS__ "CONFIG_FEATURE_KLOGD_KLOGCTL"
+#else
+# define IF_FEATURE_KLOGD_KLOGCTL(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_KLOGD_KLOGCTL(...)
+#define CONFIG_LOGGER 1
+#define ENABLE_LOGGER 1
+#ifdef MAKE_SUID
+# define IF_LOGGER(...) __VA_ARGS__ "CONFIG_LOGGER"
+#else
+# define IF_LOGGER(...) __VA_ARGS__
+#endif
+#define IF_NOT_LOGGER(...)
+#define CONFIG_LOGREAD 1
+#define ENABLE_LOGREAD 1
+#ifdef MAKE_SUID
+# define IF_LOGREAD(...) __VA_ARGS__ "CONFIG_LOGREAD"
+#else
+# define IF_LOGREAD(...) __VA_ARGS__
+#endif
+#define IF_NOT_LOGREAD(...)
+#define CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING 1
+#define ENABLE_FEATURE_LOGREAD_REDUCED_LOCKING 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_LOGREAD_REDUCED_LOCKING(...) __VA_ARGS__ "CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING"
+#else
+# define IF_FEATURE_LOGREAD_REDUCED_LOCKING(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_LOGREAD_REDUCED_LOCKING(...)
+#define CONFIG_SYSLOGD 1
+#define ENABLE_SYSLOGD 1
+#ifdef MAKE_SUID
+# define IF_SYSLOGD(...) __VA_ARGS__ "CONFIG_SYSLOGD"
+#else
+# define IF_SYSLOGD(...) __VA_ARGS__
+#endif
+#define IF_NOT_SYSLOGD(...)
+#define CONFIG_FEATURE_ROTATE_LOGFILE 1
+#define ENABLE_FEATURE_ROTATE_LOGFILE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_ROTATE_LOGFILE(...) __VA_ARGS__ "CONFIG_FEATURE_ROTATE_LOGFILE"
+#else
+# define IF_FEATURE_ROTATE_LOGFILE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_ROTATE_LOGFILE(...)
+#define CONFIG_FEATURE_REMOTE_LOG 1
+#define ENABLE_FEATURE_REMOTE_LOG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_REMOTE_LOG(...) __VA_ARGS__ "CONFIG_FEATURE_REMOTE_LOG"
+#else
+# define IF_FEATURE_REMOTE_LOG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_REMOTE_LOG(...)
+#define CONFIG_FEATURE_SYSLOGD_DUP 1
+#define ENABLE_FEATURE_SYSLOGD_DUP 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SYSLOGD_DUP(...) __VA_ARGS__ "CONFIG_FEATURE_SYSLOGD_DUP"
+#else
+# define IF_FEATURE_SYSLOGD_DUP(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SYSLOGD_DUP(...)
+#define CONFIG_FEATURE_SYSLOGD_CFG 1
+#define ENABLE_FEATURE_SYSLOGD_CFG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SYSLOGD_CFG(...) __VA_ARGS__ "CONFIG_FEATURE_SYSLOGD_CFG"
+#else
+# define IF_FEATURE_SYSLOGD_CFG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SYSLOGD_CFG(...)
+#define CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE 256
+#define ENABLE_FEATURE_SYSLOGD_READ_BUFFER_SIZE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_SYSLOGD_READ_BUFFER_SIZE(...) __VA_ARGS__ "CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE"
+#else
+# define IF_FEATURE_SYSLOGD_READ_BUFFER_SIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_SYSLOGD_READ_BUFFER_SIZE(...)
+#define CONFIG_FEATURE_IPC_SYSLOG 1
+#define ENABLE_FEATURE_IPC_SYSLOG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IPC_SYSLOG(...) __VA_ARGS__ "CONFIG_FEATURE_IPC_SYSLOG"
+#else
+# define IF_FEATURE_IPC_SYSLOG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IPC_SYSLOG(...)
+#define CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE 16
+#define ENABLE_FEATURE_IPC_SYSLOG_BUFFER_SIZE 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_IPC_SYSLOG_BUFFER_SIZE(...) __VA_ARGS__ "CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE"
+#else
+# define IF_FEATURE_IPC_SYSLOG_BUFFER_SIZE(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_IPC_SYSLOG_BUFFER_SIZE(...)
+#define CONFIG_FEATURE_KMSG_SYSLOG 1
+#define ENABLE_FEATURE_KMSG_SYSLOG 1
+#ifdef MAKE_SUID
+# define IF_FEATURE_KMSG_SYSLOG(...) __VA_ARGS__ "CONFIG_FEATURE_KMSG_SYSLOG"
+#else
+# define IF_FEATURE_KMSG_SYSLOG(...) __VA_ARGS__
+#endif
+#define IF_NOT_FEATURE_KMSG_SYSLOG(...)
Index: /EcnlProtoTool/trunk/prototool/src/libbb/bb_strtonum.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/bb_strtonum.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/bb_strtonum.c	(revision 279)
@@ -0,0 +1,160 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+/* On exit: errno = 0 only if there was non-empty, '\0' terminated value
+ * errno = EINVAL if value was not '\0' terminated, but otherwise ok
+ *    Return value is still valid, caller should just check whether end[0]
+ *    is a valid terminating char for particular case. OTOH, if caller
+ *    requires '\0' terminated input, [s]he can just check errno == 0.
+ * errno = ERANGE if value had alphanumeric terminating char ("1234abcg").
+ * errno = ERANGE if value is out of range, missing, etc.
+ * errno = ERANGE if value had minus sign for strtouXX (even "-0" is not ok )
+ *    return value is all-ones in this case.
+ *
+ * Test code:
+ * char *endptr;
+ * const char *minus = "-";
+ * errno = 0;
+ * bb_strtoi(minus, &endptr, 0); // must set ERANGE
+ * printf("minus:%p endptr:%p errno:%d EINVAL:%d\n", minus, endptr, errno, EINVAL);
+ * errno = 0;
+ * bb_strtoi("-0-", &endptr, 0); // must set EINVAL and point to second '-'
+ * printf("endptr[0]:%c errno:%d EINVAL:%d\n", endptr[0], errno, EINVAL);
+ */
+
+static unsigned long long ret_ERANGE(void)
+{
+	errno = ERANGE; /* this ain't as small as it looks (on glibc) */
+	return ULLONG_MAX;
+}
+
+static unsigned long long handle_errors(unsigned long long v, char **endp)
+{
+	char next_ch = **endp;
+
+	/* errno is already set to ERANGE by strtoXXX if value overflowed */
+	if (next_ch) {
+		/* "1234abcg" or out-of-range? */
+		if (isalnum(next_ch) || errno)
+			return ret_ERANGE();
+		/* good number, just suspicious terminator */
+		errno = EINVAL;
+	}
+	return v;
+}
+
+
+unsigned long long FAST_FUNC bb_strtoull(const char *arg, char **endp, int base)
+{
+	unsigned long long v;
+	char *endptr;
+
+	if (!endp) endp = &endptr;
+	*endp = (char*) arg;
+
+	/* strtoul("  -4200000000") returns 94967296, errno 0 (!) */
+	/* I don't think that this is right. Preventing this... */
+	if (!isalnum(arg[0])) return ret_ERANGE();
+
+	/* not 100% correct for lib func, but convenient for the caller */
+	errno = 0;
+	v = strtoull(arg, endp, base);
+	return handle_errors(v, endp);
+}
+
+long long FAST_FUNC bb_strtoll(const char *arg, char **endp, int base)
+{
+	unsigned long long v;
+	char *endptr;
+	char first;
+
+	if (!endp) endp = &endptr;
+	*endp = (char*) arg;
+
+	/* Check for the weird "feature":
+	 * a "-" string is apparently a valid "number" for strto[u]l[l]!
+	 * It returns zero and errno is 0! :( */
+	first = (arg[0] != '-' ? arg[0] : arg[1]);
+	if (!isalnum(first)) return ret_ERANGE();
+
+	errno = 0;
+	v = strtoll(arg, endp, base);
+	return handle_errors(v, endp);
+}
+
+#if ULONG_MAX != ULLONG_MAX
+unsigned long FAST_FUNC bb_strtoul(const char *arg, char **endp, int base)
+{
+	unsigned long v;
+	char *endptr;
+
+	if (!endp) endp = &endptr;
+	*endp = (char*) arg;
+
+	if (!isalnum(arg[0])) return ret_ERANGE();
+	errno = 0;
+	v = strtoul(arg, endp, base);
+	return handle_errors(v, endp);
+}
+
+long FAST_FUNC bb_strtol(const char *arg, char **endp, int base)
+{
+	long v;
+	char *endptr;
+	char first;
+
+	if (!endp) endp = &endptr;
+	*endp = (char*) arg;
+
+	first = (arg[0] != '-' ? arg[0] : arg[1]);
+	if (!isalnum(first)) return ret_ERANGE();
+
+	errno = 0;
+	v = strtol(arg, endp, base);
+	return handle_errors(v, endp);
+}
+#endif
+
+#if UINT_MAX != ULONG_MAX
+unsigned FAST_FUNC bb_strtou(const char *arg, char **endp, int base)
+{
+	unsigned long v;
+	char *endptr;
+
+	if (!endp) endp = &endptr;
+	*endp = (char*) arg;
+
+	if (!isalnum(arg[0])) return ret_ERANGE();
+	errno = 0;
+	v = strtoul(arg, endp, base);
+	if (v > UINT_MAX) return ret_ERANGE();
+	return handle_errors(v, endp);
+}
+
+int FAST_FUNC bb_strtoi(const char *arg, char **endp, int base)
+{
+	long v;
+	char *endptr;
+	char first;
+
+	if (!endp) endp = &endptr;
+	*endp = (char*) arg;
+
+	first = (arg[0] != '-' ? arg[0] : arg[1]);
+	if (!isalnum(first)) return ret_ERANGE();
+
+	errno = 0;
+	v = strtol(arg, endp, base);
+	if (v > INT_MAX) return ret_ERANGE();
+	if (v < INT_MIN) return ret_ERANGE();
+	return handle_errors(v, endp);
+}
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/libbb/bb_time.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/bb_time.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/bb_time.c	(revision 279)
@@ -0,0 +1,299 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2007 Denys Vlasenko
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#include "libbb.h"
+
+void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
+{
+	char end = '\0';
+	const char *last_colon = strrchr(date_str, ':');
+
+	if (last_colon != NULL) {
+		/* Parse input and assign appropriately to ptm */
+#if ENABLE_DESKTOP
+		const char *endp;
+#endif
+
+		/* HH:MM */
+		if (sscanf(date_str, "%u:%u%c",
+					&ptm->tm_hour,
+					&ptm->tm_min,
+					&end) >= 2
+		) {
+			/* no adjustments needed */
+		} else
+		/* mm.dd-HH:MM */
+		if (sscanf(date_str, "%u.%u-%u:%u%c",
+					&ptm->tm_mon, &ptm->tm_mday,
+					&ptm->tm_hour, &ptm->tm_min,
+					&end) >= 4
+		) {
+			/* Adjust month from 1-12 to 0-11 */
+			ptm->tm_mon -= 1;
+		} else
+		/* yyyy.mm.dd-HH:MM */
+		if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &ptm->tm_year,
+					&ptm->tm_mon, &ptm->tm_mday,
+					&ptm->tm_hour, &ptm->tm_min,
+					&end) >= 5
+		/* yyyy-mm-dd HH:MM */
+		 || sscanf(date_str, "%u-%u-%u %u:%u%c", &ptm->tm_year,
+					&ptm->tm_mon, &ptm->tm_mday,
+					&ptm->tm_hour, &ptm->tm_min,
+					&end) >= 5
+		) {
+			ptm->tm_year -= 1900; /* Adjust years */
+			ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
+		} else
+#if ENABLE_DESKTOP  /* strptime is BIG: ~1k in uclibc, ~10k in glibc */
+		/* month_name d HH:MM:SS YYYY. Supported by GNU date */
+		if ((endp = strptime(date_str, "%b %d %T %Y", ptm)) != NULL
+		 && *endp == '\0'
+		) {
+			return; /* don't fall through to end == ":" check */
+		} else
+#endif
+		{
+			bb_error_msg_and_die(bb_msg_invalid_date, date_str);
+		}
+		if (end == ':') {
+			/* xxx:SS */
+			if (sscanf(last_colon + 1, "%u%c", &ptm->tm_sec, &end) == 1)
+				end = '\0';
+			/* else end != NUL and we error out */
+		}
+	} else
+	if (strchr(date_str, '-')
+	    /* Why strchr('-') check?
+	     * sscanf below will trash ptm->tm_year, this breaks
+	     * if parse_str is "10101010" (iow, "MMddhhmm" form)
+	     * because we destroy year. Do these sscanf
+	     * only if we saw a dash in parse_str.
+	     */
+		/* yyyy-mm-dd HH */
+	 && (sscanf(date_str, "%u-%u-%u %u%c", &ptm->tm_year,
+				&ptm->tm_mon, &ptm->tm_mday,
+				&ptm->tm_hour,
+				&end) >= 4
+		/* yyyy-mm-dd */
+	     || sscanf(date_str, "%u-%u-%u%c", &ptm->tm_year,
+				&ptm->tm_mon, &ptm->tm_mday,
+				&end) >= 3
+	    )
+	) {
+		ptm->tm_year -= 1900; /* Adjust years */
+		ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
+	} else
+	if (date_str[0] == '@') {
+		time_t t = bb_strtol(date_str + 1, NULL, 10);
+		if (!errno) {
+			struct tm *lt = localtime(&t);
+			if (lt) {
+				*ptm = *lt;
+				return;
+			}
+		}
+		end = '1';
+	} else {
+		/* Googled the following on an old date manpage:
+		 *
+		 * The canonical representation for setting the date/time is:
+		 * cc   Century (either 19 or 20)
+		 * yy   Year in abbreviated form (e.g. 89, 06)
+		 * mm   Numeric month, a number from 1 to 12
+		 * dd   Day, a number from 1 to 31
+		 * HH   Hour, a number from 0 to 23
+		 * MM   Minutes, a number from 0 to 59
+		 * .SS  Seconds, a number from 0 to 61 (with leap seconds)
+		 * Everything but the minutes is optional
+		 *
+		 * "touch -t DATETIME" format: [[[[[YY]YY]MM]DD]hh]mm[.ss]
+		 * Some, but not all, Unix "date DATETIME" commands
+		 * move [[YY]YY] past minutes mm field (!).
+		 * Coreutils date does it, and SUS mandates it.
+		 * (date -s DATETIME does not support this format. lovely!)
+		 * In bbox, this format is special-cased in date applet
+		 * (IOW: this function assumes "touch -t" format).
+		 */
+		unsigned cur_year = ptm->tm_year;
+		int len = strchrnul(date_str, '.') - date_str;
+
+		/* MM[.SS] */
+		if (len == 2 && sscanf(date_str, "%2u%2u%2u%2u""%2u%c" + 12,
+					&ptm->tm_min,
+					&end) >= 1) {
+		} else
+		/* HHMM[.SS] */
+		if (len == 4 && sscanf(date_str, "%2u%2u%2u""%2u%2u%c" + 9,
+					&ptm->tm_hour,
+					&ptm->tm_min,
+					&end) >= 2) {
+		} else
+		/* ddHHMM[.SS] */
+		if (len == 6 && sscanf(date_str, "%2u%2u""%2u%2u%2u%c" + 6,
+					&ptm->tm_mday,
+					&ptm->tm_hour,
+					&ptm->tm_min,
+					&end) >= 3) {
+		} else
+		/* mmddHHMM[.SS] */
+		if (len == 8 && sscanf(date_str, "%2u""%2u%2u%2u%2u%c" + 3,
+					&ptm->tm_mon,
+					&ptm->tm_mday,
+					&ptm->tm_hour,
+					&ptm->tm_min,
+					&end) >= 4) {
+			/* Adjust month from 1-12 to 0-11 */
+			ptm->tm_mon -= 1;
+		} else
+		/* yymmddHHMM[.SS] */
+		if (len == 10 && sscanf(date_str, "%2u%2u%2u%2u%2u%c",
+					&ptm->tm_year,
+					&ptm->tm_mon,
+					&ptm->tm_mday,
+					&ptm->tm_hour,
+					&ptm->tm_min,
+					&end) >= 5) {
+			/* Adjust month from 1-12 to 0-11 */
+			ptm->tm_mon -= 1;
+			if ((int)cur_year >= 50) { /* >= 1950 */
+				/* Adjust year: */
+				/* 1. Put it in the current century */
+				ptm->tm_year += (cur_year / 100) * 100;
+				/* 2. If too far in the past, +100 years */
+				if (ptm->tm_year < cur_year - 50)
+					ptm->tm_year += 100;
+				/* 3. If too far in the future, -100 years */
+				if (ptm->tm_year > cur_year + 50)
+					ptm->tm_year -= 100;
+			}
+		} else
+		/* ccyymmddHHMM[.SS] */
+		if (len == 12 && sscanf(date_str, "%4u%2u%2u%2u%2u%c",
+					&ptm->tm_year,
+					&ptm->tm_mon,
+					&ptm->tm_mday,
+					&ptm->tm_hour,
+					&ptm->tm_min,
+					&end) >= 5) {
+			ptm->tm_year -= 1900; /* Adjust years */
+			ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
+		} else {
+			bb_error_msg_and_die(bb_msg_invalid_date, date_str);
+		}
+		ptm->tm_sec = 0; /* assume zero if [.SS] is not given */
+		if (end == '.') {
+			/* xxx.SS */
+			if (sscanf(strchr(date_str, '.') + 1, "%u%c",
+					&ptm->tm_sec, &end) == 1)
+				end = '\0';
+			/* else end != NUL and we error out */
+		}
+	}
+	if (end != '\0') {
+		bb_error_msg_and_die(bb_msg_invalid_date, date_str);
+	}
+}
+
+time_t FAST_FUNC validate_tm_time(const char *date_str, struct tm *ptm)
+{
+	time_t t = mktime(ptm);
+	if (t == (time_t) -1L) {
+		bb_error_msg_and_die(bb_msg_invalid_date, date_str);
+	}
+	return t;
+}
+
+static char* strftime_fmt(char *buf, unsigned len, time_t *tp, const char *fmt)
+{
+	time_t t;
+	if (!tp) {
+		tp = &t;
+		time(tp);
+	}
+	/* Returns pointer to NUL */
+	return buf + strftime(buf, len, fmt, localtime(tp));
+}
+
+char* FAST_FUNC strftime_HHMMSS(char *buf, unsigned len, time_t *tp)
+{
+	return strftime_fmt(buf, len, tp, "%H:%M:%S");
+}
+
+char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp)
+{
+	return strftime_fmt(buf, len, tp, "%Y-%m-%d %H:%M:%S");
+}
+
+#if ENABLE_MONOTONIC_SYSCALL
+
+#include <sys/syscall.h>
+/* Old glibc (< 2.3.4) does not provide this constant. We use syscall
+ * directly so this definition is safe. */
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC 1
+#endif
+
+/* libc has incredibly messy way of doing this,
+ * typically requiring -lrt. We just skip all this mess */
+static void get_mono(struct timespec *ts)
+{
+	if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
+		bb_error_msg_and_die("clock_gettime(MONOTONIC) failed");
+}
+unsigned long long FAST_FUNC monotonic_ns(void)
+{
+	struct timespec ts;
+	get_mono(&ts);
+	return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
+}
+unsigned long long FAST_FUNC monotonic_us(void)
+{
+	struct timespec ts;
+	get_mono(&ts);
+	return ts.tv_sec * 1000000ULL + ts.tv_nsec/1000;
+}
+unsigned long long FAST_FUNC monotonic_ms(void)
+{
+	struct timespec ts;
+	get_mono(&ts);
+	return ts.tv_sec * 1000ULL + ts.tv_nsec/1000000;
+}
+unsigned FAST_FUNC monotonic_sec(void)
+{
+	struct timespec ts;
+	get_mono(&ts);
+	return ts.tv_sec;
+}
+
+#else
+
+unsigned long long FAST_FUNC monotonic_ns(void)
+{
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000;
+}
+unsigned long long FAST_FUNC monotonic_us(void)
+{
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return tv.tv_sec * 1000000ULL + tv.tv_usec;
+}
+unsigned long long FAST_FUNC monotonic_ms(void)
+{
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return tv.tv_sec * 1000ULL + tv.tv_usec / 1000;
+}
+unsigned FAST_FUNC monotonic_sec(void)
+{
+	return time(NULL);
+}
+
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/libbb/compare_string_array.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/compare_string_array.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/compare_string_array.c	(revision 279)
@@ -0,0 +1,171 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+/*
+ * Return NULL if string is not prefixed with key. Return pointer to the
+ * first character in string after the prefix key. If key is an empty string,
+ * return pointer to the beginning of string.
+ */
+char* FAST_FUNC is_prefixed_with(const char *string, const char *key)
+{
+#if 0	/* Two passes over key - probably slower */
+	int len = strlen(key);
+	if (strncmp(string, key, len) == 0)
+		return string + len;
+	return NULL;
+#else	/* Open-coded */
+	while (*key != '\0') {
+		if (*key != *string)
+			return NULL;
+		key++;
+		string++;
+	}
+	return (char*)string;
+#endif
+}
+
+/*
+ * Return NULL if string is not suffixed with key. Return pointer to the
+ * beginning of prefix key in string. If key is an empty string return pointer
+ * to the end of string.
+ */
+char* FAST_FUNC is_suffixed_with(const char *string, const char *key)
+{
+	size_t key_len = strlen(key);
+	ssize_t len_diff = strlen(string) - key_len;
+
+	if (len_diff >= 0) {
+		string += len_diff;
+		if (strcmp(string, key) == 0) {
+			return (char*)string;
+		}
+	}
+
+	return NULL;
+}
+
+/* returns the array index of the string */
+/* (index of first match is returned, or -1) */
+int FAST_FUNC index_in_str_array(const char *const string_array[], const char *key)
+{
+	int i;
+
+	for (i = 0; string_array[i] != 0; i++) {
+		if (strcmp(string_array[i], key) == 0) {
+			return i;
+		}
+	}
+	return -1;
+}
+
+int FAST_FUNC index_in_strings(const char *strings, const char *key)
+{
+	int idx = 0;
+
+	while (*strings) {
+		if (strcmp(strings, key) == 0) {
+			return idx;
+		}
+		strings += strlen(strings) + 1; /* skip NUL */
+		idx++;
+	}
+	return -1;
+}
+
+/* returns the array index of the string, even if it matches only a beginning */
+/* (index of first match is returned, or -1) */
+#ifdef UNUSED
+int FAST_FUNC index_in_substr_array(const char *const string_array[], const char *key)
+{
+	int i;
+	if (key[0]) {
+		for (i = 0; string_array[i] != 0; i++) {
+			if (is_prefixed_with(string_array[i], key)) {
+				return i;
+			}
+		}
+	}
+	return -1;
+}
+#endif
+
+int FAST_FUNC index_in_substrings(const char *strings, const char *key)
+{
+	int matched_idx = -1;
+	const int len = strlen(key);
+
+	if (len) {
+		int idx = 0;
+		while (*strings) {
+			if (strncmp(strings, key, len) == 0) {
+				if (strings[len] == '\0')
+					return idx; /* exact match */
+				if (matched_idx >= 0)
+					return -1; /* ambiguous match */
+				matched_idx = idx;
+			}
+			strings += strlen(strings) + 1; /* skip NUL */
+			idx++;
+		}
+	}
+	return matched_idx;
+}
+
+const char* FAST_FUNC nth_string(const char *strings, int n)
+{
+	while (n) {
+		n--;
+		strings += strlen(strings) + 1;
+	}
+	return strings;
+}
+
+#ifdef UNUSED_SO_FAR /* only brctl.c needs it yet */
+/* Returns 0 for no, 1 for yes or a negative value on error.  */
+smallint FAST_FUNC yesno(const char *str)
+{
+	static const char no_yes[] ALIGN1 =
+		"0\0" "off\0" "no\0"
+		"1\0" "on\0" "yes\0";
+	int ret = index_in_substrings(no_yes, str);
+	return ret / 3;
+}
+#endif
+
+#if ENABLE_UNIT_TEST
+
+BBUNIT_DEFINE_TEST(is_prefixed_with)
+{
+	BBUNIT_ASSERT_STREQ(" bar", is_prefixed_with("foo bar", "foo"));
+	BBUNIT_ASSERT_STREQ("bar", is_prefixed_with("foo bar", "foo "));
+	BBUNIT_ASSERT_STREQ("", is_prefixed_with("foo", "foo"));
+	BBUNIT_ASSERT_STREQ("foo", is_prefixed_with("foo", ""));
+	BBUNIT_ASSERT_STREQ("", is_prefixed_with("", ""));
+
+	BBUNIT_ASSERT_NULL(is_prefixed_with("foo", "bar foo"));
+	BBUNIT_ASSERT_NULL(is_prefixed_with("foo foo", "bar"));
+	BBUNIT_ASSERT_NULL(is_prefixed_with("", "foo"));
+
+	BBUNIT_ENDTEST;
+}
+
+BBUNIT_DEFINE_TEST(is_suffixed_with)
+{
+	BBUNIT_ASSERT_STREQ("bar", is_suffixed_with("foo bar", "bar"));
+	BBUNIT_ASSERT_STREQ("foo", is_suffixed_with("foo", "foo"));
+	BBUNIT_ASSERT_STREQ("", is_suffixed_with("foo", ""));
+	BBUNIT_ASSERT_STREQ("", is_suffixed_with("", ""));
+	BBUNIT_ASSERT_STREQ("foo", is_suffixed_with("barfoofoo", "foo"));
+
+	BBUNIT_ASSERT_NULL(is_suffixed_with("foo", "bar foo"));
+	BBUNIT_ASSERT_NULL(is_suffixed_with("foo foo", "bar"));
+	BBUNIT_ASSERT_NULL(is_suffixed_with("", "foo"));
+
+	BBUNIT_ENDTEST;
+}
+
+#endif /* ENABLE_UNIT_TEST */
Index: /EcnlProtoTool/trunk/prototool/src/libbb/copyfd.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/copyfd.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/copyfd.c	(revision 279)
@@ -0,0 +1,160 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+#if ENABLE_FEATURE_USE_SENDFILE
+# include <sys/sendfile.h>
+#else
+# define sendfile(a,b,c,d) (-1)
+#endif
+
+/*
+ * We were using 0x7fff0000 as sendfile chunk size, but it
+ * was seen to cause largish delays when user tries to ^C a file copy.
+ * Let's use a saner size.
+ * Note: needs to be >= max(CONFIG_FEATURE_COPYBUF_KB),
+ * or else "copy to eof" code will use neddlesly short reads.
+ */
+#define SENDFILE_BIGBUF (16*1024*1024)
+
+/* Used by NOFORK applets (e.g. cat) - must not use xmalloc.
+ * size < 0 means "ignore write errors", used by tar --to-command
+ * size = 0 means "copy till EOF"
+ */
+static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
+{
+	int status = -1;
+	off_t total = 0;
+	bool continue_on_write_error = 0;
+	ssize_t sendfile_sz;
+#if CONFIG_FEATURE_COPYBUF_KB > 4
+	char *buffer = buffer; /* for compiler */
+	int buffer_size = 0;
+#else
+	char buffer[CONFIG_FEATURE_COPYBUF_KB * 1024];
+	enum { buffer_size = sizeof(buffer) };
+#endif
+
+	if (size < 0) {
+		size = -size;
+		continue_on_write_error = 1;
+	}
+
+	if (src_fd < 0)
+		goto out;
+
+	sendfile_sz = !ENABLE_FEATURE_USE_SENDFILE
+		? 0
+		: SENDFILE_BIGBUF;
+	if (!size) {
+		size = SENDFILE_BIGBUF;
+		status = 1; /* copy until eof */
+	}
+
+	while (1) {
+		ssize_t rd;
+
+		if (sendfile_sz) {
+			rd = sendfile(dst_fd, src_fd, NULL,
+				size > sendfile_sz ? sendfile_sz : size);
+			if (rd >= 0)
+				goto read_ok;
+			sendfile_sz = 0; /* do not try sendfile anymore */
+		}
+#if CONFIG_FEATURE_COPYBUF_KB > 4
+		if (buffer_size == 0) {
+			if (size > 0 && size <= 4 * 1024)
+				goto use_small_buf;
+			/* We want page-aligned buffer, just in case kernel is clever
+			 * and can do page-aligned io more efficiently */
+			buffer = mmap(NULL, CONFIG_FEATURE_COPYBUF_KB * 1024,
+					PROT_READ | PROT_WRITE,
+					MAP_PRIVATE | MAP_ANON,
+					/* ignored: */ -1, 0);
+			buffer_size = CONFIG_FEATURE_COPYBUF_KB * 1024;
+			if (buffer == MAP_FAILED) {
+ use_small_buf:
+				buffer = alloca(4 * 1024);
+				buffer_size = 4 * 1024;
+			}
+		}
+#endif
+		rd = safe_read(src_fd, buffer,
+			size > buffer_size ? buffer_size : size);
+		if (rd < 0) {
+			bb_perror_msg(bb_msg_read_error);
+			break;
+		}
+ read_ok:
+		if (!rd) { /* eof - all done */
+			status = 0;
+			break;
+		}
+		/* dst_fd == -1 is a fake, else... */
+		if (dst_fd >= 0 && !sendfile_sz) {
+			ssize_t wr = full_write(dst_fd, buffer, rd);
+			if (wr < rd) {
+				if (!continue_on_write_error) {
+					bb_perror_msg(bb_msg_write_error);
+					break;
+				}
+				dst_fd = -1;
+			}
+		}
+		total += rd;
+		if (status < 0) { /* if we aren't copying till EOF... */
+			size -= rd;
+			if (!size) {
+				/* 'size' bytes copied - all done */
+				status = 0;
+				break;
+			}
+		}
+	}
+ out:
+
+	if (buffer_size > 4 * 1024)
+		munmap(buffer, buffer_size);
+	return status ? -1 : total;
+}
+
+
+#if 0
+void FAST_FUNC complain_copyfd_and_die(off_t sz)
+{
+	if (sz != -1)
+		bb_error_msg_and_die("short read");
+	/* if sz == -1, bb_copyfd_XX already complained */
+	xfunc_die();
+}
+#endif
+
+off_t FAST_FUNC bb_copyfd_size(int fd1, int fd2, off_t size)
+{
+	if (size) {
+		return bb_full_fd_action(fd1, fd2, size);
+	}
+	return 0;
+}
+
+void FAST_FUNC bb_copyfd_exact_size(int fd1, int fd2, off_t size)
+{
+	off_t sz = bb_copyfd_size(fd1, fd2, size);
+	if (sz == (size >= 0 ? size : -size))
+		return;
+	if (sz != -1)
+		bb_error_msg_and_die("short read");
+	/* if sz == -1, bb_copyfd_XX already complained */
+	xfunc_die();
+}
+
+off_t FAST_FUNC bb_copyfd_eof(int fd1, int fd2)
+{
+	return bb_full_fd_action(fd1, fd2, 0);
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/default_error_retval.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/default_error_retval.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/default_error_retval.c	(revision 279)
@@ -0,0 +1,18 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+/* Seems silly to copyright a global variable.  ;-)  Oh well.
+ *
+ * At least one applet (cmp) returns a value different from the typical
+ * EXIT_FAILURE values (1) when an error occurs.  So, make it configurable
+ * by the applet.  I suppose we could use a wrapper function to set it, but
+ * that too seems silly.
+ */
+
+#include "libbb.h"
+
+uint8_t xfunc_error_retval = EXIT_FAILURE;
Index: /EcnlProtoTool/trunk/prototool/src/libbb/full_write.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/full_write.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/full_write.c	(revision 279)
@@ -0,0 +1,42 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+/*
+ * Write all of the supplied buffer out to a file.
+ * This does multiple writes as necessary.
+ * Returns the amount written, or -1 on an error.
+ */
+ssize_t FAST_FUNC full_write(int fd, const void *buf, size_t len)
+{
+	ssize_t cc;
+	ssize_t total;
+
+	total = 0;
+
+	while (len) {
+		cc = safe_write(fd, buf, len);
+
+		if (cc < 0) {
+			if (total) {
+				/* we already wrote some! */
+				/* user can do another write to know the error code */
+				return total;
+			}
+			return cc;  /* write() returns -1 on failure. */
+		}
+
+		total += cc;
+		buf = ((const char *)buf) + cc;
+		len -= cc;
+	}
+
+	return total;
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/last_char_is.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/last_char_is.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/last_char_is.c	(revision 279)
@@ -0,0 +1,24 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * busybox library eXtended function
+ *
+ * Copyright (C) 2001 Larry Doolittle, <ldoolitt@recycle.lbl.gov>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+/* Find out if the last character of a string matches the one given.
+ * Don't underrun the buffer if the string length is 0.
+ */
+char* FAST_FUNC last_char_is(const char *s, int c)
+{
+	if (s && *s) {
+		size_t sz = strlen(s) - 1;
+		s += sz;
+		if ( (unsigned char)*s == c)
+			return (char*)s;
+	}
+	return NULL;
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/libbb.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/libbb.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/libbb.c	(revision 279)
@@ -0,0 +1,40 @@
+#include "libbb.h"
+
+const char *applet_name;
+
+void bb_show_usage(void) { xfunc_die(); }
+void FAST_FUNC kill_myself_with_sig(int sig){ abort(); }
+void BUG_sizeof(void) { abort(); }
+
+static unsigned long long ret_ERANGE(void)
+{
+	errno = ERANGE; /* this ain't as small as it looks (on glibc) */
+	return ULLONG_MAX;
+}
+
+static unsigned long long handle_errors(unsigned long long v, char **endp)
+{
+	char next_ch = **endp;
+
+	/* errno is already set to ERANGE by strtoXXX if value overflowed */
+	if (next_ch) {
+		/* "1234abcg" or out-of-range? */
+		if (isalnum(next_ch) || errno)
+			return ret_ERANGE();
+		/* good number, just suspicious terminator */
+		errno = EINVAL;
+	}
+	return v;
+}
+
+char* FAST_FUNC uid2uname_utoa(uid_t uid)
+{
+	errno = ENOSYS;
+	return NULL;
+}
+
+char* FAST_FUNC gid2group_utoa(gid_t gid)
+{
+	errno = ENOSYS;
+	return NULL;
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/libbb.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/libbb.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/libbb.h	(revision 279)
@@ -0,0 +1,2184 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Busybox main internal header file
+ *
+ * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
+ * Permission has been granted to redistribute this code under GPL.
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#ifndef LIBBB_H
+#define LIBBB_H 1
+
+#define BB_VER "1.26.2"
+#define BB_BT "2017/3/16 10:00:00"
+#include "autoconf.h"
+
+#define fgets_unlocked fgets
+#define getchar_unlocked getchar
+#define fputs_unlocked fputs
+#define putchar_unlocked putchar
+#define ferror_unlocked ferror
+#define fileno_unlocked fileno
+
+#include "platform.h"
+
+#include <ctype.h>
+#include "_dirent.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <netdb.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <paths.h>
+#if defined __UCLIBC__ /* TODO: and glibc? */
+/* use inlined versions of these: */
+# define sigfillset(s)    __sigfillset(s)
+# define sigemptyset(s)   __sigemptyset(s)
+# define sigisemptyset(s) __sigisemptyset(s)
+#endif
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+/* There are two incompatible basename's, let's not use them! */
+/* See the dirname/basename man page for details */
+#include <libgen.h> /* dirname,basename */
+#undef basename
+#define basename dont_use_basename
+#include <poll.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#if !defined(major) || defined(__GLIBC__)
+# include <sys/sysmacros.h>
+#endif
+#include <sys/wait.h>
+#include "_termios.h"
+#include <time.h>
+#include <sys/param.h>
+#include <pwd.h>
+#include <grp.h>
+#if ENABLE_FEATURE_SHADOWPASSWDS
+# if !ENABLE_USE_BB_SHADOW
+/* If using busybox's shadow implementation, do not include the shadow.h
+ * header as the toolchain may not provide it at all.
+ */
+#  include <shadow.h>
+# endif
+#endif
+#if defined(ANDROID) || defined(__ANDROID__)
+# define endpwent() ((void)0)
+# define endgrent() ((void)0)
+#endif
+#ifdef HAVE_MNTENT_H
+# include <mntent.h>
+#endif
+#ifdef HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+#endif
+
+extern char *strchrnul(const char *, int);
+extern void *memrchr(const void *s, int c, size_t n);
+
+/* Don't do this here:
+ * #include <sys/sysinfo.h>
+ * Some linux/ includes pull in conflicting definition
+ * of struct sysinfo (only in some toolchanins), which breaks build.
+ * Include sys/sysinfo.h only in those files which need it.
+ */
+#if ENABLE_SELINUX
+# include <selinux/selinux.h>
+# include <selinux/context.h>
+#endif
+#if ENABLE_FEATURE_UTMP
+# if defined __UCLIBC__ && ( \
+    (UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 32) \
+     && UCLIBC_VERSION < KERNEL_VERSION(0, 9, 34) \
+     && defined __UCLIBC_HAS_UTMPX__ \
+    ) || ( \
+	 UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 34) \
+	) \
+  )
+#  include <utmpx.h>
+# elif defined __UCLIBC__
+#  include <utmp.h>
+#  define utmpx utmp
+#  define setutxent setutent
+#  define endutxent endutent
+#  define getutxent getutent
+#  define getutxid getutid
+#  define getutxline getutline
+#  define pututxline pututline
+#  define utmpxname utmpname
+#  define updwtmpx updwtmp
+#  define _PATH_UTMPX _PATH_UTMP
+# else
+#  include <utmp.h>
+#  include <utmpx.h>
+#  if defined _PATH_UTMP && !defined _PATH_UTMPX
+#   define _PATH_UTMPX _PATH_UTMP
+#  endif
+# endif
+#endif
+#if ENABLE_LOCALE_SUPPORT
+# include <locale.h>
+#else
+# define setlocale(x,y) ((void)0)
+#endif
+#ifdef DMALLOC
+# include <dmalloc.h>
+#endif
+/* Just in case libc doesn't define some of these... */
+#ifndef _PATH_PASSWD
+#define _PATH_PASSWD  "/etc/passwd"
+#endif
+#ifndef _PATH_GROUP
+#define _PATH_GROUP   "/etc/group"
+#endif
+#ifndef _PATH_SHADOW
+#define _PATH_SHADOW  "/etc/shadow"
+#endif
+#ifndef _PATH_GSHADOW
+#define _PATH_GSHADOW "/etc/gshadow"
+#endif
+#if defined __FreeBSD__ || defined __OpenBSD__
+# include <netinet/in.h>
+# include <arpa/inet.h>
+#elif defined __APPLE__
+# include <netinet/in.h>
+#else
+# include <arpa/inet.h>
+//This breaks on bionic:
+//# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
+///* We #define socklen_t *after* includes, otherwise we get
+// * typedef redefinition errors from system headers
+// * (in case "is it defined already" detection above failed)
+// */
+//#  define socklen_t bb_socklen_t
+//   typedef unsigned socklen_t;
+//# endif
+//if this is still needed, add a fix along the lines of
+//  ifdef SPECIFIC_BROKEN_LIBC_CHECK / typedef socklen_t / endif
+//in platform.h instead!
+#endif
+#ifndef HAVE_CLEARENV
+# define clearenv() do { if (environ) environ[0] = NULL; } while (0)
+#endif
+#ifndef HAVE_FDATASYNC
+# define fdatasync fsync
+#endif
+#ifndef HAVE_XTABS
+# define XTABS TAB3
+#endif
+
+
+/* Some libc's forget to declare these, do it ourself */
+
+extern char **environ;
+#if defined(__GLIBC__) && __GLIBC__ < 2
+int vdprintf(int d, const char *format, va_list ap);
+#endif
+/* klogctl is in libc's klog.h, but we cheat and not #include that */
+int klogctl(int type, char *b, int len);
+#ifndef PATH_MAX
+# define PATH_MAX 256
+#endif
+#ifndef BUFSIZ
+# define BUFSIZ 4096
+#endif
+
+
+/* Busybox does not use threads, we can speed up stdio. */
+#ifdef HAVE_UNLOCKED_STDIO
+# undef  getc
+# define getc(stream)   getc_unlocked(stream)
+# undef  getchar
+# define getchar()      getchar_unlocked()
+# undef  putc
+# define putc(c,stream) putc_unlocked(c,stream)
+# undef  putchar
+# define putchar(c)     putchar_unlocked(c)
+# undef  fgetc
+# define fgetc(stream)  getc_unlocked(stream)
+# undef  fputc
+# define fputc(c,stream) putc_unlocked(c,stream)
+#endif
+/* Above functions are required by POSIX.1-2008, below ones are extensions */
+#ifdef HAVE_UNLOCKED_LINE_OPS
+# undef  fgets
+# define fgets(s,n,stream) fgets_unlocked(s,n,stream)
+# undef  fputs
+# define fputs(s,stream) fputs_unlocked(s,stream)
+/* musl <= 1.1.15 does not support fflush_unlocked(NULL) */
+//# undef  fflush
+//# define fflush(stream) fflush_unlocked(stream)
+# undef  feof
+# define feof(stream)   feof_unlocked(stream)
+# undef  ferror
+# define ferror(stream) ferror_unlocked(stream)
+# undef  fileno
+# define fileno(stream) fileno_unlocked(stream)
+#endif
+
+
+/* Make all declarations hidden (-fvisibility flag only affects definitions) */
+/* (don't include system headers after this until corresponding pop!) */
+PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
+
+
+#if ENABLE_USE_BB_PWD_GRP
+# include "pwd_.h"
+# include "grp_.h"
+#endif
+#if ENABLE_FEATURE_SHADOWPASSWDS
+# if ENABLE_USE_BB_SHADOW
+#  include "shadow_.h"
+# endif
+#endif
+
+/* Tested to work correctly with all int types (IIRC :]) */
+#define MAXINT(T) (T)( \
+	((T)-1) > 0 \
+	? (T)-1 \
+	: (T)~((T)1 << (sizeof(T)*8-1)) \
+	)
+
+#define MININT(T) (T)( \
+	((T)-1) > 0 \
+	? (T)0 \
+	: ((T)1 << (sizeof(T)*8-1)) \
+	)
+
+/* Large file support */
+/* Note that CONFIG_LFS=y forces bbox to be built with all common ops
+ * (stat, lseek etc) mapped to "largefile" variants by libc.
+ * Practically it means that open() automatically has O_LARGEFILE added
+ * and all filesize/file_offset parameters and struct members are "large"
+ * (in today's world - signed 64bit). For full support of large files,
+ * we need a few helper #defines (below) and careful use of off_t
+ * instead of int/ssize_t. No lseek64(), O_LARGEFILE etc necessary */
+#if ENABLE_LFS
+/* CONFIG_LFS is on */
+# if ULONG_MAX > 0xffffffff
+/* "long" is long enough on this system */
+typedef unsigned long uoff_t;
+#  define XATOOFF(a) xatoul_range((a), 0, LONG_MAX)
+/* usage: sz = BB_STRTOOFF(s, NULL, 10); if (errno || sz < 0) die(); */
+#  define BB_STRTOOFF bb_strtoul
+#  define STRTOOFF strtoul
+/* usage: printf("size: %"OFF_FMT"d (%"OFF_FMT"x)\n", sz, sz); */
+#  define OFF_FMT "l"
+# else
+/* "long" is too short, need "long long" */
+typedef unsigned long long uoff_t;
+#  define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX)
+long long FAST_FUNC bb_strtoll(const char *arg, char **endp, int base);
+unsigned long long FAST_FUNC bb_strtoull(const char *arg, char **endp, int base);
+#  define BB_STRTOOFF bb_strtoull
+#  define STRTOOFF strtoull
+#  define OFF_FMT "ll"
+# endif
+#else
+/* CONFIG_LFS is off */
+# if UINT_MAX == 0xffffffff
+/* While sizeof(off_t) == sizeof(int), off_t is typedef'ed to long anyway.
+ * gcc will throw warnings on printf("%d", off_t). Crap... */
+typedef unsigned long uoff_t;
+#  define XATOOFF(a) xatoi_positive(a)
+#  define BB_STRTOOFF bb_strtou
+#  define STRTOOFF strtol
+#  define OFF_FMT "l"
+# else
+typedef unsigned long uoff_t;
+#  define XATOOFF(a) xatoul_range((a), 0, LONG_MAX)
+#  define BB_STRTOOFF bb_strtoul
+#  define STRTOOFF strtol
+#  define OFF_FMT "l"
+# endif
+#endif
+/* scary. better ideas? (but do *test* them first!) */
+#define OFF_T_MAX  ((off_t)~((off_t)1 << (sizeof(off_t)*8-1)))
+/* Users report bionic to use 32-bit off_t even if LARGEFILE support is requested.
+ * We misdetected that. Don't let it build:
+ *
+struct BUG_off_t_size_is_misdetected {
+	char BUG_off_t_size_is_misdetected[sizeof(off_t) == sizeof(uoff_t) ? 1 : -1];
+};*/
+long FAST_FUNC bb_strtol(const char *arg, char **endp, int base);
+unsigned long FAST_FUNC bb_strtoul(const char *arg, char **endp, int base);
+#if UINT_MAX != ULONG_MAX
+int FAST_FUNC bb_strtoi(const char *arg, char **endp, int base);
+unsigned FAST_FUNC bb_strtou(const char *arg, char **endp, int base);
+#else
+#define bb_strtoi bb_strtol
+#define bb_strtou bb_strtoul
+#endif
+
+/* Some useful definitions */
+#undef FALSE
+#define FALSE   ((int) 0)
+#undef TRUE
+#define TRUE    ((int) 1)
+#undef SKIP
+#define SKIP	((int) 2)
+
+/* Macros for min/max.  */
+#ifndef MIN
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+/* buffer allocation schemes */
+#if ENABLE_FEATURE_BUFFERS_GO_ON_STACK
+#define RESERVE_CONFIG_BUFFER(buffer,len)  char buffer[len]
+#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len]
+#define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
+#else
+#if ENABLE_FEATURE_BUFFERS_GO_IN_BSS
+#define RESERVE_CONFIG_BUFFER(buffer,len)  static          char buffer[len]
+#define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len]
+#define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
+#else
+#define RESERVE_CONFIG_BUFFER(buffer,len)  char *buffer = xmalloc(len)
+#define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer = xmalloc(len)
+#define RELEASE_CONFIG_BUFFER(buffer)      free(buffer)
+#endif
+#endif
+
+#if defined(__GLIBC__)
+/* glibc uses __errno_location() to get a ptr to errno */
+/* We can just memorize it once - no multithreading in busybox :) */
+extern int *const bb_errno;
+#undef errno
+#define errno (*bb_errno)
+#endif
+
+#if !(ULONG_MAX > 0xffffffff)
+/* Only 32-bit CPUs need this, 64-bit ones use inlined version */
+uint64_t bb_bswap_64(uint64_t x) FAST_FUNC;
+#endif
+
+unsigned long long monotonic_ns(void) FAST_FUNC;
+unsigned long long monotonic_us(void) FAST_FUNC;
+unsigned long long monotonic_ms(void) FAST_FUNC;
+unsigned monotonic_sec(void) FAST_FUNC;
+
+extern void chomp(char *s) FAST_FUNC;
+extern void trim(char *s) FAST_FUNC;
+extern char *skip_whitespace(const char *) FAST_FUNC;
+extern char *skip_non_whitespace(const char *) FAST_FUNC;
+extern char *skip_dev_pfx(const char *tty_name) FAST_FUNC;
+
+extern char *strrstr(const char *haystack, const char *needle) FAST_FUNC;
+
+//TODO: supply a pointer to char[11] buffer (avoid statics)?
+extern const char *bb_mode_string(mode_t mode) FAST_FUNC;
+extern int is_directory(const char *name, int followLinks) FAST_FUNC;
+enum {	/* cp.c, mv.c, install.c depend on these values. CAREFUL when changing them! */
+	FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */
+	FILEUTILS_DEREFERENCE     = 1 << 1, /* !-d */
+	FILEUTILS_RECUR           = 1 << 2, /* -R */
+	FILEUTILS_FORCE           = 1 << 3, /* -f */
+	FILEUTILS_INTERACTIVE     = 1 << 4, /* -i */
+	FILEUTILS_MAKE_HARDLINK   = 1 << 5, /* -l */
+	FILEUTILS_MAKE_SOFTLINK   = 1 << 6, /* -s */
+	FILEUTILS_DEREF_SOFTLINK  = 1 << 7, /* -L */
+	FILEUTILS_DEREFERENCE_L0  = 1 << 8, /* -H */
+	/* -a = -pdR (mapped in cp.c) */
+	/* -r = -dR  (mapped in cp.c) */
+	/* -P = -d   (mapped in cp.c) */
+	FILEUTILS_VERBOSE         = (1 << 12) * ENABLE_FEATURE_VERBOSE,	/* -v */
+	FILEUTILS_UPDATE          = 1 << 13, /* -u */
+#if ENABLE_SELINUX
+	FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 14, /* -c */
+#endif
+	FILEUTILS_RMDEST          = 1 << (15 - !ENABLE_SELINUX), /* --remove-destination */
+	/*
+	 * Hole. cp may have some bits set here,
+	 * they should not affect remove_file()/copy_file()
+	 */
+#if ENABLE_SELINUX
+	FILEUTILS_SET_SECURITY_CONTEXT = 1 << 30,
+#endif
+	FILEUTILS_IGNORE_CHMOD_ERR = 1 << 31,
+};
+#define FILEUTILS_CP_OPTSTR "pdRfilsLHarPvu" IF_SELINUX("c")
+extern int remove_file(const char *path, int flags) FAST_FUNC;
+/* NB: without FILEUTILS_RECUR in flags, it will basically "cat"
+ * the source, not copy (unless "source" is a directory).
+ * This makes "cp /dev/null file" and "install /dev/null file" (!!!)
+ * work coreutils-compatibly. */
+extern int copy_file(const char *source, const char *dest, int flags) FAST_FUNC;
+
+enum {
+	ACTION_RECURSE        = (1 << 0),
+	ACTION_FOLLOWLINKS    = (1 << 1),
+	ACTION_FOLLOWLINKS_L0 = (1 << 2),
+	ACTION_DEPTHFIRST     = (1 << 3),
+	/*ACTION_REVERSE      = (1 << 4), - unused */
+	ACTION_QUIET          = (1 << 5),
+	ACTION_DANGLING_OK    = (1 << 6),
+};
+typedef uint8_t recurse_flags_t;
+extern int recursive_action(const char *fileName, unsigned flags,
+	int FAST_FUNC (*fileAction)(const char *fileName, struct stat* statbuf, void* userData, int depth),
+	int FAST_FUNC (*dirAction)(const char *fileName, struct stat* statbuf, void* userData, int depth),
+	void* userData, unsigned depth) FAST_FUNC;
+extern int device_open(const char *device, int mode) FAST_FUNC;
+enum { GETPTY_BUFSIZE = 16 }; /* more than enough for "/dev/ttyXXX" */
+extern int xgetpty(char *line) FAST_FUNC;
+extern int get_console_fd_or_die(void) FAST_FUNC;
+extern void console_make_active(int fd, const int vt_num) FAST_FUNC;
+extern char *find_block_device(const char *path) FAST_FUNC;
+/* bb_copyfd_XX print read/write errors and return -1 if they occur */
+extern off_t bb_copyfd_eof(int fd1, int fd2) FAST_FUNC;
+extern off_t bb_copyfd_size(int fd1, int fd2, off_t size) FAST_FUNC;
+extern void bb_copyfd_exact_size(int fd1, int fd2, off_t size) FAST_FUNC;
+/* "short" copy can be detected by return value < size */
+/* this helper yells "short read!" if param is not -1 */
+extern void complain_copyfd_and_die(off_t sz) NORETURN FAST_FUNC;
+
+extern char bb_process_escape_sequence(const char **ptr) FAST_FUNC;
+char* strcpy_and_process_escape_sequences(char *dst, const char *src) FAST_FUNC;
+/* xxxx_strip version can modify its parameter:
+ * "/"        -> "/"
+ * "abc"      -> "abc"
+ * "abc/def"  -> "def"
+ * "abc/def/" -> "def" !!
+ */
+char *bb_get_last_path_component_strip(char *path) FAST_FUNC;
+/* "abc/def/" -> "" and it never modifies 'path' */
+char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC;
+/* Simpler version: does not special case "/" string */
+const char *bb_basename(const char *name) FAST_FUNC;
+/* NB: can violate const-ness (similarly to strchr) */
+char *last_char_is(const char *s, int c) FAST_FUNC;
+const char* endofname(const char *name) FAST_FUNC;
+char *is_prefixed_with(const char *string, const char *key) FAST_FUNC;
+char *is_suffixed_with(const char *string, const char *key) FAST_FUNC;
+
+int ndelay_on(int fd) FAST_FUNC;
+int ndelay_off(int fd) FAST_FUNC;
+void close_on_exec_on(int fd) FAST_FUNC;
+void xdup2(int, int) FAST_FUNC;
+void xmove_fd(int, int) FAST_FUNC;
+
+
+DIR *xopendir(const char *path) FAST_FUNC;
+DIR *warn_opendir(const char *path) FAST_FUNC;
+
+char *xmalloc_realpath(const char *path) FAST_FUNC RETURNS_MALLOC;
+char *xmalloc_readlink(const char *path) FAST_FUNC RETURNS_MALLOC;
+char *xmalloc_readlink_or_warn(const char *path) FAST_FUNC RETURNS_MALLOC;
+/* !RETURNS_MALLOC: it's a realloc-like function */
+char *xrealloc_getcwd_or_warn(char *cwd) FAST_FUNC;
+
+char *xmalloc_follow_symlinks(const char *path) FAST_FUNC RETURNS_MALLOC;
+
+
+enum {
+	/* bb_signals(BB_FATAL_SIGS, handler) catches all signals which
+	 * otherwise would kill us, except for those resulting from bugs:
+	 * SIGSEGV, SIGILL, SIGFPE.
+	 * Other fatal signals not included (TODO?):
+	 * SIGBUS   Bus error (bad memory access)
+	 * SIGPOLL  Pollable event. Synonym of SIGIO
+	 * SIGPROF  Profiling timer expired
+	 * SIGSYS   Bad argument to routine
+	 * SIGTRAP  Trace/breakpoint trap
+	 *
+	 * The only known arch with some of these sigs not fitting
+	 * into 32 bits is parisc (SIGXCPU=33, SIGXFSZ=34, SIGSTKFLT=36).
+	 * Dance around with long long to guard against that...
+	 */
+	BB_FATAL_SIGS = (int)(0
+		+ (1LL << SIGHUP)
+		+ (1LL << SIGINT)
+		+ (1LL << SIGTERM)
+		+ (1LL << SIGPIPE)   // Write to pipe with no readers
+		+ (1LL << SIGQUIT)   // Quit from keyboard
+		+ (1LL << SIGABRT)   // Abort signal from abort(3)
+		+ (1LL << SIGALRM)   // Timer signal from alarm(2)
+		+ (1LL << SIGVTALRM) // Virtual alarm clock
+		+ (1LL << SIGXCPU)   // CPU time limit exceeded
+		+ (1LL << SIGXFSZ)   // File size limit exceeded
+		+ (1LL << SIGUSR1)   // Yes kids, these are also fatal!
+		+ (1LL << SIGUSR2)
+		+ 0),
+};
+void bb_signals(int sigs, void (*f)(int)) FAST_FUNC;
+/* Unlike signal() and bb_signals, sets handler with sigaction()
+ * and in a way that while signal handler is run, no other signals
+ * will be blocked; syscalls will not be restarted: */
+void bb_signals_recursive_norestart(int sigs, void (*f)(int)) FAST_FUNC;
+/* syscalls like read() will be interrupted with EINTR: */
+void signal_no_SA_RESTART_empty_mask(int sig, void (*handler)(int)) FAST_FUNC;
+/* syscalls like read() won't be interrupted (though select/poll will be): */
+void signal_SA_RESTART_empty_mask(int sig, void (*handler)(int)) FAST_FUNC;
+void wait_for_any_sig(void) FAST_FUNC;
+void kill_myself_with_sig(int sig) NORETURN FAST_FUNC;
+void sig_block(int sig) FAST_FUNC;
+void sig_unblock(int sig) FAST_FUNC;
+/* Will do sigaction(signum, act, NULL): */
+int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC;
+/* SIG_BLOCK/SIG_UNBLOCK all signals: */
+int sigprocmask_allsigs(int how) FAST_FUNC;
+/* Standard handler which just records signo */
+extern smallint bb_got_signal;
+void record_signo(int signo); /* not FAST_FUNC! */
+
+
+void xsetgid(gid_t gid) FAST_FUNC;
+void xsetuid(uid_t uid) FAST_FUNC;
+void xsetegid(gid_t egid) FAST_FUNC;
+void xseteuid(uid_t euid) FAST_FUNC;
+void xchdir(const char *path) FAST_FUNC;
+void xfchdir(int fd) FAST_FUNC;
+void xchroot(const char *path) FAST_FUNC;
+void xsetenv(const char *key, const char *value) FAST_FUNC;
+void bb_unsetenv(const char *key) FAST_FUNC;
+void bb_unsetenv_and_free(char *key) FAST_FUNC;
+void xunlink(const char *pathname) FAST_FUNC;
+void xstat(const char *pathname, struct stat *buf) FAST_FUNC;
+void xfstat(int fd, struct stat *buf, const char *errmsg) FAST_FUNC;
+int open3_or_warn(const char *pathname, int flags, int mode) FAST_FUNC;
+int open_or_warn(const char *pathname, int flags) FAST_FUNC;
+int xopen3(const char *pathname, int flags, int mode) FAST_FUNC;
+int xopen(const char *pathname, int flags) FAST_FUNC;
+int xopen_nonblocking(const char *pathname) FAST_FUNC;
+int xopen_as_uid_gid(const char *pathname, int flags, uid_t u, gid_t g) FAST_FUNC;
+int open_or_warn_stdin(const char *pathname) FAST_FUNC;
+int xopen_stdin(const char *pathname) FAST_FUNC;
+void xrename(const char *oldpath, const char *newpath) FAST_FUNC;
+int rename_or_warn(const char *oldpath, const char *newpath) FAST_FUNC;
+off_t xlseek(int fd, off_t offset, int whence) FAST_FUNC;
+int xmkstemp(char *template) FAST_FUNC;
+off_t fdlength(int fd) FAST_FUNC;
+
+uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
+		const char *override,
+		unsigned override_units,
+		int extend);
+
+void xpipe(int filedes[2]) FAST_FUNC;
+/* In this form code with pipes is much more readable */
+struct fd_pair { int rd; int wr; };
+#define piped_pair(pair)  pipe(&((pair).rd))
+#define xpiped_pair(pair) xpipe(&((pair).rd))
+
+/* Useful for having small structure members/global variables */
+typedef int8_t socktype_t;
+typedef int8_t family_t;
+struct BUG_too_small {
+	char BUG_socktype_t_too_small[(0
+			| SOCK_STREAM
+			| SOCK_DGRAM
+			| SOCK_RDM
+			| SOCK_SEQPACKET
+			| SOCK_RAW
+			) <= 127 ? 1 : -1];
+	char BUG_family_t_too_small[(0
+			| AF_UNSPEC
+			| AF_INET
+			| AF_INET6
+			| AF_UNIX
+#ifdef AF_PACKET
+			| AF_PACKET
+#endif
+#ifdef AF_NETLINK
+			| AF_NETLINK
+#endif
+			/* | AF_DECnet */
+			/* | AF_IPX */
+			) <= 127 ? 1 : -1];
+};
+
+
+void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC;
+time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC;
+char *strftime_HHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC;
+char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC;
+
+int xsocket(int domain, int type, int protocol) FAST_FUNC;
+void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC;
+void xlisten(int s, int backlog) FAST_FUNC;
+void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) FAST_FUNC;
+ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
+				socklen_t tolen) FAST_FUNC;
+
+int setsockopt_int(int fd, int level, int optname, int optval) FAST_FUNC;
+int setsockopt_1(int fd, int level, int optname) FAST_FUNC;
+int setsockopt_SOL_SOCKET_int(int fd, int optname, int optval) FAST_FUNC;
+int setsockopt_SOL_SOCKET_1(int fd, int optname) FAST_FUNC;
+/* SO_REUSEADDR allows a server to rebind to an address that is already
+ * "in use" by old connections to e.g. previous server instance which is
+ * killed or crashed. Without it bind will fail until all such connections
+ * time out. Linux does not allow multiple live binds on same ip:port
+ * regardless of SO_REUSEADDR (unlike some other flavors of Unix).
+ * Turn it on before you call bind(). */
+void setsockopt_reuseaddr(int fd) FAST_FUNC; /* On Linux this never fails. */
+int setsockopt_keepalive(int fd) FAST_FUNC;
+int setsockopt_broadcast(int fd) FAST_FUNC;
+int setsockopt_bindtodevice(int fd, const char *iface) FAST_FUNC;
+/* NB: returns port in host byte order */
+unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port) FAST_FUNC;
+typedef struct len_and_sockaddr {
+	socklen_t len;
+	union {
+		struct sockaddr sa;
+		struct sockaddr_in sin;
+#if ENABLE_FEATURE_IPV6
+		struct sockaddr_in6 sin6;
+#endif
+	} u;
+} len_and_sockaddr;
+enum {
+	LSA_LEN_SIZE = offsetof(len_and_sockaddr, u),
+	LSA_SIZEOF_SA = sizeof(
+		union {
+			struct sockaddr sa;
+			struct sockaddr_in sin;
+#if ENABLE_FEATURE_IPV6
+			struct sockaddr_in6 sin6;
+#endif
+		}
+	)
+};
+/* Create stream socket, and allocate suitable lsa.
+ * (lsa of correct size and lsa->sa.sa_family (AF_INET/AF_INET6))
+ * af == AF_UNSPEC will result in trying to create IPv6 socket,
+ * and if kernel doesn't support it, fall back to IPv4.
+ * This is useful if you plan to bind to resulting local lsa.
+ */
+int xsocket_type(len_and_sockaddr **lsap, int af, int sock_type) FAST_FUNC;
+int xsocket_stream(len_and_sockaddr **lsap) FAST_FUNC;
+/* Create server socket bound to bindaddr:port. bindaddr can be NULL,
+ * numeric IP ("N.N.N.N") or numeric IPv6 address,
+ * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT").
+ * Only if there is no suffix, port argument is used */
+/* NB: these set SO_REUSEADDR before bind */
+int create_and_bind_stream_or_die(const char *bindaddr, int port) FAST_FUNC;
+int create_and_bind_dgram_or_die(const char *bindaddr, int port) FAST_FUNC;
+/* Create client TCP socket connected to peer:port. Peer cannot be NULL.
+ * Peer can be numeric IP ("N.N.N.N"), numeric IPv6 address or hostname,
+ * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT").
+ * If there is no suffix, port argument is used */
+int create_and_connect_stream_or_die(const char *peer, int port) FAST_FUNC;
+/* Connect to peer identified by lsa */
+int xconnect_stream(const len_and_sockaddr *lsa) FAST_FUNC;
+/* Get local address of bound or accepted socket */
+len_and_sockaddr *get_sock_lsa(int fd) FAST_FUNC RETURNS_MALLOC;
+/* Get remote address of connected or accepted socket */
+len_and_sockaddr *get_peer_lsa(int fd) FAST_FUNC RETURNS_MALLOC;
+/* Return malloc'ed len_and_sockaddr with socket address of host:port
+ * Currently will return IPv4 or IPv6 sockaddrs only
+ * (depending on host), but in theory nothing prevents e.g.
+ * UNIX socket address being returned, IPX sockaddr etc...
+ * On error does bb_error_msg and returns NULL */
+len_and_sockaddr* host2sockaddr(const char *host, int port) FAST_FUNC RETURNS_MALLOC;
+/* Version which dies on error */
+len_and_sockaddr* xhost2sockaddr(const char *host, int port) FAST_FUNC RETURNS_MALLOC;
+len_and_sockaddr* xdotted2sockaddr(const char *host, int port) FAST_FUNC RETURNS_MALLOC;
+/* Same, useful if you want to force family (e.g. IPv6) */
+#if !ENABLE_FEATURE_IPV6
+#define host_and_af2sockaddr(host, port, af) host2sockaddr((host), (port))
+#define xhost_and_af2sockaddr(host, port, af) xhost2sockaddr((host), (port))
+#else
+len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af) FAST_FUNC RETURNS_MALLOC;
+len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af) FAST_FUNC RETURNS_MALLOC;
+#endif
+/* Assign sin[6]_port member if the socket is an AF_INET[6] one,
+ * otherwise no-op. Useful for ftp.
+ * NB: does NOT do htons() internally, just direct assignment. */
+void set_nport(struct sockaddr *sa, unsigned port) FAST_FUNC;
+/* Retrieve sin[6]_port or return -1 for non-INET[6] lsa's */
+int get_nport(const struct sockaddr *sa) FAST_FUNC;
+/* Reverse DNS. Returns NULL on failure. */
+char* xmalloc_sockaddr2host(const struct sockaddr *sa) FAST_FUNC RETURNS_MALLOC;
+/* This one doesn't append :PORTNUM */
+char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa) FAST_FUNC RETURNS_MALLOC;
+/* This one also doesn't fall back to dotted IP (returns NULL) */
+char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa) FAST_FUNC RETURNS_MALLOC;
+/* inet_[ap]ton on steroids */
+char* xmalloc_sockaddr2dotted(const struct sockaddr *sa) FAST_FUNC RETURNS_MALLOC;
+char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa) FAST_FUNC RETURNS_MALLOC;
+// "old" (ipv4 only) API
+// users: traceroute.c hostname.c - use _list_ of all IPs
+struct hostent *xgethostbyname(const char *name) FAST_FUNC;
+// Also mount.c and inetd.c are using gethostbyname(),
+// + inet_common.c has additional IPv4-only stuff
+
+
+void socket_want_pktinfo(int fd) FAST_FUNC;
+ssize_t send_to_from(int fd, void *buf, size_t len, int flags,
+		const struct sockaddr *to,
+		const struct sockaddr *from,
+		socklen_t tolen) FAST_FUNC;
+ssize_t recv_from_to(int fd, void *buf, size_t len, int flags,
+		struct sockaddr *from,
+		struct sockaddr *to,
+		socklen_t sa_size) FAST_FUNC;
+
+uint16_t inet_cksum(uint16_t *addr, int len) FAST_FUNC;
+
+char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC;
+char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC;
+void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC;
+void overlapping_strcpy(char *dst, const char *src) FAST_FUNC;
+char *safe_strncpy(char *dst, const char *src, size_t size) FAST_FUNC;
+char *strncpy_IFNAMSIZ(char *dst, const char *src) FAST_FUNC;
+unsigned count_strstr(const char *str, const char *sub) FAST_FUNC;
+char *xmalloc_substitute_string(const char *src, int count, const char *sub, const char *repl) FAST_FUNC;
+/* Guaranteed to NOT be a macro (smallest code). Saves nearly 2k on uclibc.
+ * But potentially slow, don't use in one-billion-times loops */
+int bb_putchar(int ch) FAST_FUNC;
+/* Note: does not use stdio, writes to fd 2 directly */
+int bb_putchar_stderr(char ch) FAST_FUNC;
+char *xasprintf(const char *format, ...) __attribute__ ((format(printf, 1, 2))) FAST_FUNC RETURNS_MALLOC;
+char *auto_string(char *str) FAST_FUNC;
+// gcc-4.1.1 still isn't good enough at optimizing it
+// (+200 bytes compared to macro)
+//static ALWAYS_INLINE
+//int LONE_DASH(const char *s) { return s[0] == '-' && !s[1]; }
+//static ALWAYS_INLINE
+//int NOT_LONE_DASH(const char *s) { return s[0] != '-' || s[1]; }
+#define LONE_DASH(s)     ((s)[0] == '-' && !(s)[1])
+#define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1])
+#define LONE_CHAR(s,c)     ((s)[0] == (c) && !(s)[1])
+#define NOT_LONE_CHAR(s,c) ((s)[0] != (c) || (s)[1])
+#define DOT_OR_DOTDOT(s) ((s)[0] == '.' && (!(s)[1] || ((s)[1] == '.' && !(s)[2])))
+
+typedef struct uni_stat_t {
+	unsigned byte_count;
+	unsigned unicode_count;
+	unsigned unicode_width;
+} uni_stat_t;
+/* Returns a string with unprintable chars replaced by '?' or
+ * SUBST_WCHAR. This function is unicode-aware. */
+const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str);
+/* Prints unprintable char ch as ^C or M-c to file
+ * (M-c is used only if ch is ORed with PRINTABLE_META),
+ * else it is printed as-is (except for ch = 0x9b) */
+enum { PRINTABLE_META = 0x100 };
+void fputc_printable(int ch, FILE *file) FAST_FUNC;
+/* Return a string that is the printable representation of character ch.
+ * Buffer must hold at least four characters. */
+enum {
+	VISIBLE_ENDLINE   = 1 << 0,
+	VISIBLE_SHOW_TABS = 1 << 1,
+};
+void visible(unsigned ch, char *buf, int flags) FAST_FUNC;
+
+/* dmalloc will redefine these to it's own implementation. It is safe
+ * to have the prototypes here unconditionally.  */
+void *malloc_or_warn(size_t size) FAST_FUNC RETURNS_MALLOC;
+void *xmalloc(size_t size) FAST_FUNC RETURNS_MALLOC;
+void *xzalloc(size_t size) FAST_FUNC RETURNS_MALLOC;
+void *xrealloc(void *old, size_t size) FAST_FUNC;
+/* After v = xrealloc_vector(v, SHIFT, idx) it's ok to use
+ * at least v[idx] and v[idx+1], for all idx values.
+ * SHIFT specifies how many new elements are added (1:2, 2:4, ..., 8:256...)
+ * when all elements are used up. New elements are zeroed out.
+ * xrealloc_vector(v, SHIFT, idx) *MUST* be called with consecutive IDXs -
+ * skipping an index is a bad bug - it may miss a realloc!
+ */
+#define xrealloc_vector(vector, shift, idx) \
+	xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx))
+void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC;
+
+
+extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC;
+extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count) FAST_FUNC;
+// NB: will return short read on error, not -1,
+// if some data was read before error occurred
+extern ssize_t full_read(int fd, void *buf, size_t count) FAST_FUNC;
+extern void xread(int fd, void *buf, size_t count) FAST_FUNC;
+extern unsigned char xread_char(int fd) FAST_FUNC;
+extern ssize_t read_close(int fd, void *buf, size_t maxsz) FAST_FUNC;
+extern ssize_t open_read_close(const char *filename, void *buf, size_t maxsz) FAST_FUNC;
+// Reads one line a-la fgets (but doesn't save terminating '\n').
+// Reads byte-by-byte. Useful when it is important to not read ahead.
+// Bytes are appended to pfx (which must be malloced, or NULL).
+extern char *xmalloc_reads(int fd, size_t *maxsz_p) FAST_FUNC;
+/* Reads block up to *maxsz_p (default: INT_MAX - 4095) */
+extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
+/* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */
+extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
+/* Never returns NULL */
+extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
+
+#if defined(ARG_MAX) && (ARG_MAX >= 60*1024 || !defined(_SC_ARG_MAX))
+/* Use _constant_ maximum if: defined && (big enough || no variable one exists) */
+# define bb_arg_max() ((unsigned)ARG_MAX)
+#elif defined(_SC_ARG_MAX)
+/* Else use variable one (a bit more expensive) */
+unsigned bb_arg_max(void) FAST_FUNC;
+#else
+/* If all else fails */
+# define bb_arg_max() ((unsigned)(32 * 1024))
+#endif
+unsigned bb_clk_tck(void) FAST_FUNC;
+
+#define SEAMLESS_COMPRESSION (0 \
+ || ENABLE_FEATURE_SEAMLESS_XZ \
+ || ENABLE_FEATURE_SEAMLESS_LZMA \
+ || ENABLE_FEATURE_SEAMLESS_BZ2 \
+ || ENABLE_FEATURE_SEAMLESS_GZ \
+ || ENABLE_FEATURE_SEAMLESS_Z)
+
+#if SEAMLESS_COMPRESSION
+/* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */
+extern int setup_unzip_on_fd(int fd, int fail_if_not_compressed) FAST_FUNC;
+/* Autodetects .gz etc */
+extern int open_zipped(const char *fname, int fail_if_not_compressed) FAST_FUNC;
+extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
+#else
+# define setup_unzip_on_fd(...) (0)
+# define open_zipped(fname, fail_if_not_compressed)  open((fname), O_RDONLY);
+# define xmalloc_open_zipped_read_close(fname, maxsz_p) xmalloc_open_read_close((fname), (maxsz_p))
+#endif
+
+extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC;
+// NB: will return short write on error, not -1,
+// if some data was written before error occurred
+extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC;
+extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC;
+extern void xwrite_str(int fd, const char *str) FAST_FUNC;
+extern ssize_t full_write1_str(const char *str) FAST_FUNC;
+extern ssize_t full_write2_str(const char *str) FAST_FUNC;
+extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC;
+
+/* Close fd, but check for failures (some types of write errors) */
+extern void xclose(int fd) FAST_FUNC;
+
+/* Reads and prints to stdout till eof, then closes FILE. Exits on error: */
+extern void xprint_and_close_file(FILE *file) FAST_FUNC;
+
+/* Reads a line from a text file, up to a newline or NUL byte, inclusive.
+ * Returns malloc'ed char*. If end is NULL '\n' isn't considered
+ * end of line. If end isn't NULL, length of the chunk is stored in it.
+ * Returns NULL if EOF/error.
+ */
+extern char *bb_get_chunk_from_file(FILE *file, int *end) FAST_FUNC;
+/* Reads up to (and including) TERMINATING_STRING: */
+extern char *xmalloc_fgets_str(FILE *file, const char *terminating_string) FAST_FUNC RETURNS_MALLOC;
+/* Same, with limited max size, and returns the length (excluding NUL): */
+extern char *xmalloc_fgets_str_len(FILE *file, const char *terminating_string, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
+/* Chops off TERMINATING_STRING from the end: */
+extern char *xmalloc_fgetline_str(FILE *file, const char *terminating_string) FAST_FUNC RETURNS_MALLOC;
+/* Reads up to (and including) "\n" or NUL byte: */
+extern char *xmalloc_fgets(FILE *file) FAST_FUNC RETURNS_MALLOC;
+/* Chops off '\n' from the end, unlike fgets: */
+extern char *xmalloc_fgetline(FILE *file) FAST_FUNC RETURNS_MALLOC;
+/* Same, but doesn't try to conserve space (may have some slack after the end) */
+/* extern char *xmalloc_fgetline_fast(FILE *file) FAST_FUNC RETURNS_MALLOC; */
+
+void die_if_ferror(FILE *file, const char *msg) FAST_FUNC;
+void die_if_ferror_stdout(void) FAST_FUNC;
+int fflush_all(void) FAST_FUNC;
+void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC;
+int fclose_if_not_stdin(FILE *file) FAST_FUNC;
+FILE* xfopen(const char *filename, const char *mode) FAST_FUNC;
+/* Prints warning to stderr and returns NULL on failure: */
+FILE* fopen_or_warn(const char *filename, const char *mode) FAST_FUNC;
+/* "Opens" stdin if filename is special, else just opens file: */
+FILE* xfopen_stdin(const char *filename) FAST_FUNC;
+FILE* fopen_or_warn_stdin(const char *filename) FAST_FUNC;
+FILE* fopen_for_read(const char *path) FAST_FUNC;
+FILE* xfopen_for_read(const char *path) FAST_FUNC;
+FILE* fopen_for_write(const char *path) FAST_FUNC;
+FILE* xfopen_for_write(const char *path) FAST_FUNC;
+FILE* xfdopen_for_read(int fd) FAST_FUNC;
+FILE* xfdopen_for_write(int fd) FAST_FUNC;
+
+int bb_pstrcmp(const void *a, const void *b) /* not FAST_FUNC! */;
+void qsort_string_vector(char **sv, unsigned count) FAST_FUNC;
+
+/* Wrapper which restarts poll on EINTR or ENOMEM.
+ * On other errors complains [perror("poll")] and returns.
+ * Warning! May take (much) longer than timeout_ms to return!
+ * If this is a problem, use bare poll and open-code EINTR/ENOMEM handling */
+int safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout_ms) FAST_FUNC;
+
+char *safe_gethostname(void) FAST_FUNC;
+
+/* Convert each alpha char in str to lower-case */
+char* str_tolower(char *str) FAST_FUNC;
+
+char *bb_utoa(unsigned n) FAST_FUNC;
+char *bb_itoa(int n) FAST_FUNC;
+/* Returns a pointer past the formatted number, does NOT null-terminate */
+char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC;
+char *itoa_to_buf(int n, char *buf, unsigned buflen) FAST_FUNC;
+/* Intelligent formatters of bignums */
+char *smart_ulltoa4(unsigned long long ul, char buf[4], const char *scale) FAST_FUNC;
+char *smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_FUNC;
+/* If block_size == 0, display size without fractional part,
+ * else display (size * block_size) with one decimal digit.
+ * If display_unit == 0, show value no bigger than 1024 with suffix (K,M,G...),
+ * else divide by display_unit and do not use suffix. */
+#define HUMAN_READABLE_MAX_WIDTH      7  /* "1024.0G" */
+#define HUMAN_READABLE_MAX_WIDTH_STR "7"
+//TODO: provide pointer to buf (avoid statics)?
+const char *make_human_readable_str(unsigned long long size,
+		unsigned long block_size, unsigned long display_unit) FAST_FUNC;
+/* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */
+char *bin2hex(char *dst, const char *src, int count) FAST_FUNC;
+/* Reverse */
+char* hex2bin(char *dst, const char *src, int count) FAST_FUNC;
+
+/* Generate a UUID */
+void generate_uuid(uint8_t *buf) FAST_FUNC;
+
+/* Last element is marked by mult == 0 */
+struct suffix_mult {
+	char suffix[4];
+	unsigned mult;
+};
+extern const struct suffix_mult bkm_suffixes[];
+#define km_suffixes (bkm_suffixes + 1)
+extern const struct suffix_mult cwbkMG_suffixes[];
+#define kMG_suffixes (cwbkMG_suffixes + 3)
+extern const struct suffix_mult kmg_i_suffixes[];
+
+/*#include "xatonum.h"*/
+long FAST_FUNC bb_strtol(const char *arg, char **endp, int base);
+/* Specialized: */
+
+/* Using xatoi() instead of naive atoi() is not always convenient -
+ * in many places people want *non-negative* values, but store them
+ * in signed int. Therefore we need this one:
+ * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc.
+ * It should really be named xatoi_nonnegative (since it allows 0),
+ * but that would be too long.
+ */
+int xatoi_positive(const char *numstr) FAST_FUNC;
+
+/* Useful for reading port numbers */
+uint16_t xatou16(const char *numstr) FAST_FUNC;
+
+
+/* These parse entries in /etc/passwd and /etc/group.  This is desirable
+ * for BusyBox since we want to avoid using the glibc NSS stuff, which
+ * increases target size and is often not needed on embedded systems.  */
+long xuname2uid(const char *name) FAST_FUNC;
+long xgroup2gid(const char *name) FAST_FUNC;
+/* wrapper: allows string to contain numeric uid or gid */
+unsigned long get_ug_id(const char *s, long FAST_FUNC (*xname2id)(const char *)) FAST_FUNC;
+struct bb_uidgid_t {
+	uid_t uid;
+	gid_t gid;
+};
+/* always sets uid and gid; returns 0 on failure */
+int get_uidgid(struct bb_uidgid_t*, const char*) FAST_FUNC;
+/* always sets uid and gid; exits on failure */
+void xget_uidgid(struct bb_uidgid_t*, const char*) FAST_FUNC;
+/* chown-like handling of "user[:[group]" */
+void parse_chown_usergroup_or_die(struct bb_uidgid_t *u, char *user_group) FAST_FUNC;
+struct passwd* xgetpwnam(const char *name) FAST_FUNC;
+struct group* xgetgrnam(const char *name) FAST_FUNC;
+struct passwd* xgetpwuid(uid_t uid) FAST_FUNC;
+struct group* xgetgrgid(gid_t gid) FAST_FUNC;
+char* xuid2uname(uid_t uid) FAST_FUNC;
+char* xgid2group(gid_t gid) FAST_FUNC;
+char* uid2uname(uid_t uid) FAST_FUNC;
+char* gid2group(gid_t gid) FAST_FUNC;
+char* uid2uname_utoa(uid_t uid) FAST_FUNC;
+char* gid2group_utoa(gid_t gid) FAST_FUNC;
+/* versions which cache results (useful for ps, ls etc) */
+const char* get_cached_username(uid_t uid) FAST_FUNC;
+const char* get_cached_groupname(gid_t gid) FAST_FUNC;
+void clear_username_cache(void) FAST_FUNC;
+/* internally usernames are saved in fixed-sized char[] buffers */
+enum { USERNAME_MAX_SIZE = 32 - sizeof(uid_t) };
+#if ENABLE_FEATURE_CHECK_NAMES
+void die_if_bad_username(const char* name) FAST_FUNC;
+#else
+#define die_if_bad_username(name) ((void)(name))
+#endif
+
+#if ENABLE_FEATURE_UTMP
+void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname);
+void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname);
+void FAST_FUNC update_utmp_DEAD_PROCESS(pid_t pid);
+#else
+# define write_new_utmp(pid, new_type, tty_name, username, hostname) ((void)0)
+# define update_utmp(pid, new_type, tty_name, username, hostname) ((void)0)
+# define update_utmp_DEAD_PROCESS(pid) ((void)0)
+#endif
+
+
+int file_is_executable(const char *name) FAST_FUNC;
+char *find_executable(const char *filename, char **PATHp) FAST_FUNC;
+int executable_exists(const char *filename) FAST_FUNC;
+
+/* BB_EXECxx always execs (it's not doing NOFORK/NOEXEC stuff),
+ * but it may exec busybox and call applet instead of searching PATH.
+ */
+#if ENABLE_FEATURE_PREFER_APPLETS
+int BB_EXECVP(const char *file, char *const argv[]) FAST_FUNC;
+#define BB_EXECLP(prog,cmd,...) \
+	do { \
+		if (find_applet_by_name(prog) >= 0) \
+			execlp(bb_busybox_exec_path, cmd, __VA_ARGS__); \
+		execlp(prog, cmd, __VA_ARGS__); \
+	} while (0)
+#else
+#define BB_EXECVP(prog,cmd)     execvp(prog,cmd)
+#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd,__VA_ARGS__)
+#endif
+void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
+void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
+
+/* xvfork() can't be a _function_, return after vfork in child mangles stack
+ * in the parent. It must be a macro. */
+#define xvfork() \
+({ \
+	pid_t bb__xvfork_pid = vfork(); \
+	if (bb__xvfork_pid < 0) \
+		bb_perror_msg_and_die("vfork"); \
+	bb__xvfork_pid; \
+})
+#if BB_MMU
+pid_t xfork(void) FAST_FUNC;
+#endif
+void xvfork_parent_waits_and_exits(void) FAST_FUNC;
+
+/* NOMMU friendy fork+exec: */
+pid_t spawn(char **argv) FAST_FUNC;
+pid_t xspawn(char **argv) FAST_FUNC;
+
+pid_t safe_waitpid(pid_t pid, int *wstat, int options) FAST_FUNC;
+pid_t wait_any_nohang(int *wstat) FAST_FUNC;
+/* wait4pid: unlike waitpid, waits ONLY for one process.
+ * Returns sig + 0x180 if child is killed by signal.
+ * It's safe to pass negative 'pids' from failed [v]fork -
+ * wait4pid will return -1 (and will not clobber [v]fork's errno).
+ * IOW: rc = wait4pid(spawn(argv));
+ *      if (rc < 0) bb_perror_msg("%s", argv[0]);
+ *      if (rc > 0) bb_error_msg("exit code: %d", rc & 0xff);
+ */
+int wait4pid(pid_t pid) FAST_FUNC;
+int wait_for_exitstatus(pid_t pid) FAST_FUNC;
+/* Same as wait4pid(spawn(argv)), but with NOFORK/NOEXEC if configured: */
+int spawn_and_wait(char **argv) FAST_FUNC;
+/* Does NOT check that applet is NOFORK, just blindly runs it */
+int run_nofork_applet(int applet_no, char **argv) FAST_FUNC;
+
+/* Helpers for daemonization.
+ *
+ * bb_daemonize(flags) = daemonize, does not compile on NOMMU
+ *
+ * bb_daemonize_or_rexec(flags, argv) = daemonizes on MMU (and ignores argv),
+ *      rexec's itself on NOMMU with argv passed as command line.
+ * Thus bb_daemonize_or_rexec may cause your <applet>_main() to be re-executed
+ * from the start. (It will detect it and not reexec again second time).
+ * You have to audit carefully that you don't do something twice as a result
+ * (opening files/sockets, parsing config files etc...)!
+ *
+ * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty
+ * (will do setsid()).
+ *
+ * fork_or_rexec(argv) = bare-bones fork on MMU,
+ *      "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid().
+ *      On MMU ignores argv.
+ *
+ * Helper for network daemons in foreground mode:
+ *
+ * bb_sanitize_stdio() = make sure that fd 0,1,2 are opened by opening them
+ * to /dev/null if they are not.
+ */
+enum {
+	DAEMON_CHDIR_ROOT = 1,
+	DAEMON_DEVNULL_STDIO = 2,
+	DAEMON_CLOSE_EXTRA_FDS = 4,
+	DAEMON_ONLY_SANITIZE = 8, /* internal use */
+	DAEMON_DOUBLE_FORK = 16, /* double fork to avoid controlling tty */
+};
+#if BB_MMU
+  enum { re_execed = 0 };
+# define fork_or_rexec(argv)                xfork()
+# define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags)
+# define bb_daemonize(flags)                bb_daemonize_or_rexec(flags, bogus)
+#else
+  extern bool re_execed;
+  /* Note: re_exec() and fork_or_rexec() do argv[0][0] |= 0x80 on NOMMU!
+   * _Parent_ needs to undo it if it doesn't want to have argv[0] mangled.
+   */
+  void re_exec(char **argv) NORETURN FAST_FUNC;
+  pid_t fork_or_rexec(char **argv) FAST_FUNC;
+  int  BUG_fork_is_unavailable_on_nommu(void) FAST_FUNC;
+  int  BUG_daemon_is_unavailable_on_nommu(void) FAST_FUNC;
+  void BUG_bb_daemonize_is_unavailable_on_nommu(void) FAST_FUNC;
+# define fork()          BUG_fork_is_unavailable_on_nommu()
+# define xfork()         BUG_fork_is_unavailable_on_nommu()
+# define daemon(a,b)     BUG_daemon_is_unavailable_on_nommu()
+# define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu()
+#endif
+void bb_daemonize_or_rexec(int flags, char **argv) FAST_FUNC;
+void bb_sanitize_stdio(void) FAST_FUNC;
+/* Clear dangerous stuff, set PATH. Return 1 if was run by different user. */
+int sanitize_env_if_suid(void) FAST_FUNC;
+
+
+char* single_argv(char **argv) FAST_FUNC;
+extern const char *const bb_argv_dash[]; /* "-", NULL */
+extern const char *opt_complementary;
+#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
+#define No_argument "\0"
+#define Required_argument "\001"
+#define Optional_argument "\002"
+extern const char *applet_long_options;
+#endif
+extern uint32_t option_mask32;
+extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC;
+
+
+/* Having next pointer as a first member allows easy creation
+ * of "llist-compatible" structs, and using llist_FOO functions
+ * on them.
+ */
+typedef struct llist_t {
+	struct llist_t *link;
+	char *data;
+} llist_t;
+void llist_add_to(llist_t **old_head, void *data) FAST_FUNC;
+void llist_add_to_end(llist_t **list_head, void *data) FAST_FUNC;
+void *llist_pop(llist_t **elm) FAST_FUNC;
+void llist_unlink(llist_t **head, llist_t *elm) FAST_FUNC;
+void llist_free(llist_t *elm, void (*freeit)(void *data)) FAST_FUNC;
+llist_t *llist_rev(llist_t *list) FAST_FUNC;
+llist_t *llist_find_str(llist_t *first, const char *str) FAST_FUNC;
+/* BTW, surprisingly, changing API to
+ *   llist_t *llist_add_to(llist_t *old_head, void *data)
+ * etc does not result in smaller code... */
+
+/* start_stop_daemon and udhcpc are special - they want
+ * to create pidfiles regardless of FEATURE_PIDFILE */
+#if ENABLE_FEATURE_PIDFILE || defined(WANT_PIDFILE)
+/* True only if we created pidfile which is *file*, not /dev/null etc */
+extern smallint wrote_pidfile;
+void write_pidfile(const char *path) FAST_FUNC;
+#define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
+#else
+enum { wrote_pidfile = 0 };
+#define write_pidfile(path)  ((void)0)
+#define remove_pidfile(path) ((void)0)
+#endif
+
+enum {
+	LOGMODE_NONE = 0,
+	LOGMODE_STDIO = (1 << 0),
+	LOGMODE_SYSLOG = (1 << 1) * ENABLE_FEATURE_SYSLOG,
+	LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
+};
+extern const char *msg_eol;
+extern smallint syslog_level;
+extern smallint logmode;
+extern uint8_t xfunc_error_retval;
+extern void (*die_func)(void);
+extern void xfunc_die(void) NORETURN FAST_FUNC;
+extern void bb_show_usage(void) NORETURN FAST_FUNC;
+extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
+extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
+extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
+extern void bb_simple_perror_msg(const char *s) FAST_FUNC;
+extern void bb_perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
+extern void bb_simple_perror_msg_and_die(const char *s) NORETURN FAST_FUNC;
+extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
+extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
+extern void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC;
+extern void bb_perror_nomsg(void) FAST_FUNC;
+extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
+extern void bb_logenv_override(void) FAST_FUNC;
+
+/* We need to export XXX_main from libbusybox
+ * only if we build "individual" binaries
+ */
+#if ENABLE_FEATURE_INDIVIDUAL
+#define MAIN_EXTERNALLY_VISIBLE EXTERNALLY_VISIBLE
+#else
+#define MAIN_EXTERNALLY_VISIBLE
+#endif
+
+
+/* Applets which are useful from another applets */
+int bb_cat(char** argv);
+/* If shell needs them, they exist even if not enabled as applets */
+int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
+int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
+int test_main(int argc, char **argv)
+#if ENABLE_TEST || ENABLE_TEST1 || ENABLE_TEST2
+		MAIN_EXTERNALLY_VISIBLE
+#endif
+;
+int kill_main(int argc, char **argv)
+#if ENABLE_KILL || ENABLE_KILLALL || ENABLE_KILLALL5
+		MAIN_EXTERNALLY_VISIBLE
+#endif
+;
+/* Similar, but used by chgrp, not shell */
+int chown_main(int argc, char **argv) IF_CHOWN(MAIN_EXTERNALLY_VISIBLE);
+/* Used by ftpd */
+int ls_main(int argc, char **argv) IF_LS(MAIN_EXTERNALLY_VISIBLE);
+/* Don't need IF_xxx() guard for these */
+int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+
+#if ENABLE_ROUTE
+void bb_displayroutes(int noresolve, int netstatfmt) FAST_FUNC;
+#endif
+
+
+/* Networking */
+/* This structure defines protocol families and their handlers. */
+struct aftype {
+	const char *name;
+	const char *title;
+	int af;
+	int alen;
+	char*       FAST_FUNC (*print)(unsigned char *);
+	const char* FAST_FUNC (*sprint)(struct sockaddr *, int numeric);
+	int         FAST_FUNC (*input)(/*int type,*/ const char *bufp, struct sockaddr *);
+	void        FAST_FUNC (*herror)(char *text);
+	int         FAST_FUNC (*rprint)(int options);
+	int         FAST_FUNC (*rinput)(int typ, int ext, char **argv);
+	/* may modify src */
+	int         FAST_FUNC (*getmask)(char *src, struct sockaddr *mask, char *name);
+};
+/* This structure defines hardware protocols and their handlers. */
+struct hwtype {
+	const char *name;
+	const char *title;
+	int type;
+	int alen;
+	char* FAST_FUNC (*print)(unsigned char *);
+	int   FAST_FUNC (*input)(const char *, struct sockaddr *);
+	int   FAST_FUNC (*activate)(int fd);
+	int suppress_null_addr;
+};
+extern smallint interface_opt_a;
+int display_interfaces(char *ifname) FAST_FUNC;
+int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC;
+#if ENABLE_FEATURE_HWIB
+int in_ib(const char *bufp, struct sockaddr *sap) FAST_FUNC;
+#else
+#define in_ib(a, b) 1 /* fail */
+#endif
+const struct aftype *get_aftype(const char *name) FAST_FUNC;
+const struct hwtype *get_hwtype(const char *name) FAST_FUNC;
+const struct hwtype *get_hwntype(int type) FAST_FUNC;
+
+
+#ifndef BUILD_INDIVIDUAL
+extern int find_applet_by_name(const char *name) FAST_FUNC;
+extern void run_applet_no_and_exit(int a, char **argv) NORETURN FAST_FUNC;
+#endif
+
+#ifdef HAVE_MNTENT_H
+extern int match_fstype(const struct mntent *mt, const char *fstypes) FAST_FUNC;
+extern struct mntent *find_mount_point(const char *name, int subdir_too) FAST_FUNC;
+#endif
+extern void erase_mtab(const char * name) FAST_FUNC;
+extern unsigned int tty_baud_to_value(speed_t speed) FAST_FUNC;
+extern speed_t tty_value_to_baud(unsigned int value) FAST_FUNC;
+#if ENABLE_DESKTOP
+extern void bb_warn_ignoring_args(char *arg) FAST_FUNC;
+#else
+# define bb_warn_ignoring_args(arg) ((void)0)
+#endif
+
+extern int get_linux_version_code(void) FAST_FUNC;
+
+extern char *query_loop(const char *device) FAST_FUNC;
+extern int del_loop(const char *device) FAST_FUNC;
+/* If *devname is not NULL, use that name, otherwise try to find free one,
+ * malloc and return it in *devname.
+ * return value: 1: read-only loopdev was setup, 0: rw, < 0: error */
+extern int set_loop(char **devname, const char *file, unsigned long long offset, int ro) FAST_FUNC;
+
+/* Like bb_ask below, but asks on stdin with no timeout.  */
+char *bb_ask_stdin(const char * prompt) FAST_FUNC;
+//TODO: pass buf pointer or return allocated buf (avoid statics)?
+char *bb_ask(const int fd, int timeout, const char * prompt) FAST_FUNC;
+int bb_ask_confirmation(void) FAST_FUNC;
+
+/* Returns -1 if input is invalid. current_mode is a base for e.g. "u+rw" */
+int bb_parse_mode(const char* s, unsigned cur_mode) FAST_FUNC;
+
+/*
+ * Config file parser
+ */
+enum {
+	PARSE_COLLAPSE  = 0x00010000, // treat consecutive delimiters as one
+	PARSE_TRIM      = 0x00020000, // trim leading and trailing delimiters
+// TODO: COLLAPSE and TRIM seem to always go in pair
+	PARSE_GREEDY    = 0x00040000, // last token takes entire remainder of the line
+	PARSE_MIN_DIE   = 0x00100000, // die if < min tokens found
+	// keep a copy of current line
+	PARSE_KEEP_COPY = 0x00200000 * ENABLE_FEATURE_CROND_D,
+	PARSE_EOL_COMMENTS = 0x00400000, // comments are recognized even if they aren't the first char
+	// NORMAL is:
+	// * remove leading and trailing delimiters and collapse
+	//   multiple delimiters into one
+	// * warn and continue if less than mintokens delimiters found
+	// * grab everything into last token
+	// * comments are recognized even if they aren't the first char
+	PARSE_NORMAL    = PARSE_COLLAPSE | PARSE_TRIM | PARSE_GREEDY | PARSE_EOL_COMMENTS,
+};
+typedef struct parser_t {
+	FILE *fp;
+	char *data;
+	char *line, *nline;
+	size_t line_alloc, nline_alloc;
+	int lineno;
+} parser_t;
+parser_t* config_open(const char *filename) FAST_FUNC;
+parser_t* config_open2(const char *filename, FILE* FAST_FUNC (*fopen_func)(const char *path)) FAST_FUNC;
+/* delims[0] is a comment char (use '\0' to disable), the rest are token delimiters */
+int config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims) FAST_FUNC;
+#define config_read(parser, tokens, max, min, str, flags) \
+	config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str)
+void config_close(parser_t *parser) FAST_FUNC;
+
+/* Concatenate path and filename to new allocated buffer.
+ * Add "/" only as needed (no duplicate "//" are produced).
+ * If path is NULL, it is assumed to be "/".
+ * filename should not be NULL. */
+char *concat_path_file(const char *path, const char *filename) FAST_FUNC;
+/* Returns NULL on . and .. */
+char *concat_subpath_file(const char *path, const char *filename) FAST_FUNC;
+
+
+int bb_make_directory(char *path, long mode, int flags) FAST_FUNC;
+
+int get_signum(const char *name) FAST_FUNC;
+const char *get_signame(int number) FAST_FUNC;
+void print_signames(void) FAST_FUNC;
+
+char *bb_simplify_path(const char *path) FAST_FUNC;
+/* Returns ptr to NUL */
+char *bb_simplify_abs_path_inplace(char *path) FAST_FUNC;
+
+#ifndef LOGIN_FAIL_DELAY
+#define LOGIN_FAIL_DELAY 3
+#endif
+extern void bb_do_delay(int seconds) FAST_FUNC;
+extern void change_identity(const struct passwd *pw) FAST_FUNC;
+extern void run_shell(const char *shell, int loginshell, const char **args) NORETURN FAST_FUNC;
+
+/* Returns $SHELL, getpwuid(getuid())->pw_shell, or DEFAULT_SHELL.
+ * Note that getpwuid result might need xstrdup'ing
+ * if there is a possibility of intervening getpwxxx() calls.
+ */
+const char *get_shell_name(void) FAST_FUNC;
+
+#if ENABLE_SELINUX
+extern void renew_current_security_context(void) FAST_FUNC;
+extern void set_current_security_context(security_context_t sid) FAST_FUNC;
+extern context_t set_security_context_component(security_context_t cur_context,
+						char *user, char *role, char *type, char *range) FAST_FUNC;
+extern void setfscreatecon_or_die(security_context_t scontext) FAST_FUNC;
+extern void selinux_preserve_fcontext(int fdesc) FAST_FUNC;
+#else
+#define selinux_preserve_fcontext(fdesc) ((void)0)
+#endif
+extern void selinux_or_die(void) FAST_FUNC;
+
+
+/* setup_environment:
+ * if chdir pw->pw_dir: ok: else if to_tmp == 1: goto /tmp else: goto / or die
+ * if clear_env = 1: cd(pw->pw_dir), clear environment, then set
+ *   TERM=(old value)
+ *   USER=pw->pw_name, LOGNAME=pw->pw_name
+ *   PATH=bb_default_[root_]path
+ *   HOME=pw->pw_dir
+ *   SHELL=shell
+ * else if change_env = 1:
+ *   if not root (if pw->pw_uid != 0):
+ *     USER=pw->pw_name, LOGNAME=pw->pw_name
+ *   HOME=pw->pw_dir
+ *   SHELL=shell
+ * else does nothing
+ */
+#define SETUP_ENV_CHANGEENV (1 << 0)
+#define SETUP_ENV_CLEARENV  (1 << 1)
+#define SETUP_ENV_TO_TMP    (1 << 2)
+#define SETUP_ENV_NO_CHDIR  (1 << 4)
+void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
+void nuke_str(char *str) FAST_FUNC;
+int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC;
+int ask_and_check_password_extended(const struct passwd *pw, int timeout, const char *prompt) FAST_FUNC;
+int ask_and_check_password(const struct passwd *pw) FAST_FUNC;
+/* Returns a malloced string */
+#if !ENABLE_USE_BB_CRYPT
+#define pw_encrypt(clear, salt, cleanup) pw_encrypt(clear, salt)
+#endif
+extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_FUNC;
+extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC;
+/*
+ * rnd is additional random input. New one is returned.
+ * Useful if you call crypt_make_salt many times in a row:
+ * rnd = crypt_make_salt(buf1, 4, 0);
+ * rnd = crypt_make_salt(buf2, 4, rnd);
+ * rnd = crypt_make_salt(buf3, 4, rnd);
+ * (otherwise we risk having same salt generated)
+ */
+extern int crypt_make_salt(char *p, int cnt /*, int rnd*/) FAST_FUNC;
+/* "$N$" + sha_salt_16_bytes + NUL */
+#define MAX_PW_SALT_LEN (3 + 16 + 1)
+extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC;
+
+
+/* Returns number of lines changed, or -1 on error */
+#if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP)
+#define update_passwd(filename, username, data, member) \
+	update_passwd(filename, username, data)
+#endif
+extern int update_passwd(const char *filename,
+		const char *username,
+		const char *data,
+		const char *member) FAST_FUNC;
+
+int index_in_str_array(const char *const string_array[], const char *key) FAST_FUNC;
+int index_in_strings(const char *strings, const char *key) FAST_FUNC;
+int index_in_substr_array(const char *const string_array[], const char *key) FAST_FUNC;
+int index_in_substrings(const char *strings, const char *key) FAST_FUNC;
+const char *nth_string(const char *strings, int n) FAST_FUNC;
+
+extern void print_login_issue(const char *issue_file, const char *tty) FAST_FUNC;
+extern void print_login_prompt(void) FAST_FUNC;
+
+char *xmalloc_ttyname(int fd) FAST_FUNC RETURNS_MALLOC;
+/* NB: typically you want to pass fd 0, not 1. Think 'applet | grep something' */
+int get_terminal_width_height(int fd, unsigned *width, unsigned *height) FAST_FUNC;
+int get_terminal_width(int fd) FAST_FUNC;
+
+int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC;
+
+/* NB: "unsigned request" is crucial! "int request" will break some arches! */
+int ioctl_or_perror(int fd, unsigned request, void *argp, const char *fmt,...) __attribute__ ((format (printf, 4, 5))) FAST_FUNC;
+int ioctl_or_perror_and_die(int fd, unsigned request, void *argp, const char *fmt,...) __attribute__ ((format (printf, 4, 5))) FAST_FUNC;
+#if ENABLE_IOCTL_HEX2STR_ERROR
+int bb_ioctl_or_warn(int fd, unsigned request, void *argp, const char *ioctl_name) FAST_FUNC;
+int bb_xioctl(int fd, unsigned request, void *argp, const char *ioctl_name) FAST_FUNC;
+#define ioctl_or_warn(fd,request,argp) bb_ioctl_or_warn(fd,request,argp,#request)
+#define xioctl(fd,request,argp)        bb_xioctl(fd,request,argp,#request)
+#else
+int bb_ioctl_or_warn(int fd, unsigned request, void *argp) FAST_FUNC;
+int bb_xioctl(int fd, unsigned request, void *argp) FAST_FUNC;
+#define ioctl_or_warn(fd,request,argp) bb_ioctl_or_warn(fd,request,argp)
+#define xioctl(fd,request,argp)        bb_xioctl(fd,request,argp)
+#endif
+
+char *is_in_ino_dev_hashtable(const struct stat *statbuf) FAST_FUNC;
+void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name) FAST_FUNC;
+void reset_ino_dev_hashtable(void) FAST_FUNC;
+#ifdef __GLIBC__
+/* At least glibc has horrendously large inline for this, so wrap it */
+unsigned long long bb_makedev(unsigned major, unsigned minor) FAST_FUNC;
+#undef makedev
+#define makedev(a,b) bb_makedev(a,b)
+#endif
+
+
+/* "Keycodes" that report an escape sequence.
+ * We use something which fits into signed char,
+ * yet doesn't represent any valid Unicode character.
+ * Also, -1 is reserved for error indication and we don't use it. */
+enum {
+	KEYCODE_UP        =  -2,
+	KEYCODE_DOWN      =  -3,
+	KEYCODE_RIGHT     =  -4,
+	KEYCODE_LEFT      =  -5,
+	KEYCODE_HOME      =  -6,
+	KEYCODE_END       =  -7,
+	KEYCODE_INSERT    =  -8,
+	KEYCODE_DELETE    =  -9,
+	KEYCODE_PAGEUP    = -10,
+	KEYCODE_PAGEDOWN  = -11,
+	KEYCODE_BACKSPACE = -12, /* Used only if Alt/Ctrl/Shifted */
+	KEYCODE_D         = -13, /* Used only if Alted */
+#if 0
+	KEYCODE_FUN1      = ,
+	KEYCODE_FUN2      = ,
+	KEYCODE_FUN3      = ,
+	KEYCODE_FUN4      = ,
+	KEYCODE_FUN5      = ,
+	KEYCODE_FUN6      = ,
+	KEYCODE_FUN7      = ,
+	KEYCODE_FUN8      = ,
+	KEYCODE_FUN9      = ,
+	KEYCODE_FUN10     = ,
+	KEYCODE_FUN11     = ,
+	KEYCODE_FUN12     = ,
+#endif
+	/* ^^^^^ Be sure that last defined value is small enough.
+	 * Current read_key() code allows going up to -32 (0xfff..fffe0).
+	 * This gives three upper bits in LSB to play with:
+	 * KEYCODE_foo values are 0xfff..fffXX, lowest XX bits are: scavvvvv,
+	 * s=0 if SHIFT, c=0 if CTRL, a=0 if ALT,
+	 * vvvvv bits are the same for same key regardless of "shift bits".
+	 */
+	//KEYCODE_SHIFT_...   = KEYCODE_...   & ~0x80,
+	KEYCODE_CTRL_RIGHT    = KEYCODE_RIGHT & ~0x40,
+	KEYCODE_CTRL_LEFT     = KEYCODE_LEFT  & ~0x40,
+	KEYCODE_ALT_RIGHT     = KEYCODE_RIGHT & ~0x20,
+	KEYCODE_ALT_LEFT      = KEYCODE_LEFT  & ~0x20,
+	KEYCODE_ALT_BACKSPACE = KEYCODE_BACKSPACE & ~0x20,
+	KEYCODE_ALT_D         = KEYCODE_D     & ~0x20,
+
+	KEYCODE_CURSOR_POS = -0x100, /* 0xfff..fff00 */
+	/* How long is the longest ESC sequence we know?
+	 * We want it big enough to be able to contain
+	 * cursor position sequence "ESC [ 9999 ; 9999 R"
+	 */
+	KEYCODE_BUFFER_SIZE = 16
+};
+/* Note: fd may be in blocking or non-blocking mode, both make sense.
+ * For one, less uses non-blocking mode.
+ * Only the first read syscall inside read_key may block indefinitely
+ * (unless fd is in non-blocking mode),
+ * subsequent reads will time out after a few milliseconds.
+ * Return of -1 means EOF or error (errno == 0 on EOF).
+ * buffer[0] is used as a counter of buffered chars and must be 0
+ * on first call.
+ * timeout:
+ * -2: do not poll for input;
+ * -1: poll(-1) (i.e. block);
+ * >=0: poll for TIMEOUT milliseconds, return -1/EAGAIN on timeout
+ */
+int64_t read_key(int fd, char *buffer, int timeout) FAST_FUNC;
+void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC;
+
+
+#if ENABLE_FEATURE_EDITING
+/* It's NOT just ENABLEd or disabled. It's a number: */
+# if defined CONFIG_FEATURE_EDITING_HISTORY && CONFIG_FEATURE_EDITING_HISTORY > 0
+#  define MAX_HISTORY (CONFIG_FEATURE_EDITING_HISTORY + 0)
+unsigned size_from_HISTFILESIZE(const char *hp) FAST_FUNC;
+# else
+#  define MAX_HISTORY 0
+# endif
+typedef struct line_input_t {
+	int flags;
+	const char *path_lookup;
+# if MAX_HISTORY
+	int cnt_history;
+	int cur_history;
+	int max_history; /* must never be <= 0 */
+#  if ENABLE_FEATURE_EDITING_SAVEHISTORY
+	/* meaning of this field depends on FEATURE_EDITING_SAVE_ON_EXIT:
+	 * if !FEATURE_EDITING_SAVE_ON_EXIT: "how many lines are
+	 * in on-disk history"
+	 * if FEATURE_EDITING_SAVE_ON_EXIT: "how many in-memory lines are
+	 * also in on-disk history (and thus need to be skipped on save)"
+	 */
+	unsigned cnt_history_in_file;
+	const char *hist_file;
+#  endif
+	char *history[MAX_HISTORY + 1];
+# endif
+} line_input_t;
+enum {
+	DO_HISTORY       = 1 * (MAX_HISTORY > 0),
+	TAB_COMPLETION   = 2 * ENABLE_FEATURE_TAB_COMPLETION,
+	USERNAME_COMPLETION = 4 * ENABLE_FEATURE_USERNAME_COMPLETION,
+	VI_MODE          = 8 * ENABLE_FEATURE_EDITING_VI,
+	WITH_PATH_LOOKUP = 0x10,
+	FOR_SHELL        = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
+};
+line_input_t *new_line_input_t(int flags) FAST_FUNC;
+/* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */
+/*
+ * maxsize must be >= 2.
+ * Returns:
+ * -1 on read errors or EOF, or on bare Ctrl-D,
+ * 0  on ctrl-C (the line entered is still returned in 'command'),
+ * >0 length of input string, including terminating '\n'
+ */
+int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) FAST_FUNC;
+void show_history(const line_input_t *st) FAST_FUNC;
+# if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
+void save_history(line_input_t *st);
+# endif
+#else
+#define MAX_HISTORY 0
+int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC;
+#define read_line_input(state, prompt, command, maxsize, timeout) \
+	read_line_input(prompt, command, maxsize)
+#endif
+
+
+#ifndef COMM_LEN
+# ifdef TASK_COMM_LEN
+enum { COMM_LEN = TASK_COMM_LEN };
+# else
+/* synchronize with sizeof(task_struct.comm) in /usr/include/linux/sched.h */
+enum { COMM_LEN = 16 };
+# endif
+#endif
+
+struct smaprec {
+	unsigned long mapped_rw;
+	unsigned long mapped_ro;
+	unsigned long shared_clean;
+	unsigned long shared_dirty;
+	unsigned long private_clean;
+	unsigned long private_dirty;
+	unsigned long stack;
+	unsigned long smap_pss, smap_swap;
+	unsigned long smap_size;
+	unsigned long smap_start;
+	char smap_mode[5];
+	char *smap_name;
+};
+
+#if !ENABLE_PMAP
+#define procps_read_smaps(pid, total, cb, data) \
+	procps_read_smaps(pid, total)
+#endif
+int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
+		void (*cb)(struct smaprec *, void *), void *data);
+
+typedef struct procps_status_t {
+	DIR *dir;
+	IF_FEATURE_SHOW_THREADS(DIR *task_dir;)
+	uint8_t shift_pages_to_bytes;
+	uint8_t shift_pages_to_kb;
+/* Fields are set to 0/NULL if failed to determine (or not requested) */
+	uint16_t argv_len;
+	char *argv0;
+	char *exe;
+	IF_SELINUX(char *context;)
+	IF_FEATURE_SHOW_THREADS(unsigned main_thread_pid;)
+	/* Everything below must contain no ptrs to malloc'ed data:
+	 * it is memset(0) for each process in procps_scan() */
+	unsigned long vsz, rss; /* we round it to kbytes */
+	unsigned long stime, utime;
+	unsigned long start_time;
+	unsigned pid;
+	unsigned ppid;
+	unsigned pgid;
+	unsigned sid;
+	unsigned uid;
+	unsigned gid;
+#if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
+	unsigned ruid;
+	unsigned rgid;
+	int niceness;
+#endif
+	unsigned tty_major,tty_minor;
+#if ENABLE_FEATURE_TOPMEM
+	struct smaprec smaps;
+#endif
+	char state[4];
+	/* basename of executable in exec(2), read from /proc/N/stat
+	 * (if executable is symlink or script, it is NOT replaced
+	 * by link target or interpreter name) */
+	char comm[COMM_LEN];
+	/* user/group? - use passwd/group parsing functions */
+#if ENABLE_FEATURE_TOP_SMP_PROCESS
+	int last_seen_on_cpu;
+#endif
+} procps_status_t;
+/* flag bits for procps_scan(xx, flags) calls */
+enum {
+	PSSCAN_PID      = 1 << 0,
+	PSSCAN_PPID     = 1 << 1,
+	PSSCAN_PGID     = 1 << 2,
+	PSSCAN_SID      = 1 << 3,
+	PSSCAN_UIDGID   = 1 << 4,
+	PSSCAN_COMM     = 1 << 5,
+	/* PSSCAN_CMD      = 1 << 6, - use read_cmdline instead */
+	PSSCAN_ARGV0    = 1 << 7,
+	PSSCAN_EXE      = 1 << 8,
+	PSSCAN_STATE    = 1 << 9,
+	PSSCAN_VSZ      = 1 << 10,
+	PSSCAN_RSS      = 1 << 11,
+	PSSCAN_STIME    = 1 << 12,
+	PSSCAN_UTIME    = 1 << 13,
+	PSSCAN_TTY      = 1 << 14,
+	PSSCAN_SMAPS	= (1 << 15) * ENABLE_FEATURE_TOPMEM,
+	/* NB: used by find_pid_by_name(). Any applet using it
+	 * needs to be mentioned here. */
+	PSSCAN_ARGVN    = (1 << 16) * (ENABLE_KILLALL
+				|| ENABLE_PGREP || ENABLE_PKILL
+				|| ENABLE_PIDOF
+				|| ENABLE_SESTATUS
+				),
+	PSSCAN_CONTEXT  = (1 << 17) * ENABLE_SELINUX,
+	PSSCAN_START_TIME = 1 << 18,
+	PSSCAN_CPU      = (1 << 19) * ENABLE_FEATURE_TOP_SMP_PROCESS,
+	PSSCAN_NICE     = (1 << 20) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS,
+	PSSCAN_RUIDGID  = (1 << 21) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS,
+	PSSCAN_TASKS	= (1 << 22) * ENABLE_FEATURE_SHOW_THREADS,
+};
+//procps_status_t* alloc_procps_scan(void) FAST_FUNC;
+void free_procps_scan(procps_status_t* sp) FAST_FUNC;
+procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC;
+/* Format cmdline (up to col chars) into char buf[size] */
+/* Puts [comm] if cmdline is empty (-> process is a kernel thread) */
+void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC;
+pid_t *find_pid_by_name(const char* procName) FAST_FUNC;
+pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC;
+int starts_with_cpu(const char *str) FAST_FUNC;
+unsigned get_cpu_count(void) FAST_FUNC;
+
+
+/* Use strict=1 if you process input from untrusted source:
+ * it will return NULL on invalid %xx (bad hex chars)
+ * and str + 1 if decoded char is / or NUL.
+ * In non-strict mode, it always succeeds (returns str),
+ * and also it additionally decoded '+' to space.
+ */
+char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
+
+
+extern const char bb_uuenc_tbl_base64[] ALIGN1;
+extern const char bb_uuenc_tbl_std[] ALIGN1;
+void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC;
+enum {
+	BASE64_FLAG_UU_STOP = 0x100,
+	/* Sign-extends to a value which never matches fgetc result: */
+	BASE64_FLAG_NO_STOP_CHAR = 0x80,
+};
+const char *decode_base64(char **pp_dst, const char *src) FAST_FUNC;
+void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC;
+
+typedef struct md5_ctx_t {
+	uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */
+	void (*process_block)(struct md5_ctx_t*) FAST_FUNC;
+	uint64_t total64;    /* must be directly before hash[] */
+	uint32_t hash[8];    /* 4 elements for md5, 5 for sha1, 8 for sha256 */
+} md5_ctx_t;
+typedef struct md5_ctx_t sha1_ctx_t;
+typedef struct md5_ctx_t sha256_ctx_t;
+typedef struct sha512_ctx_t {
+	uint64_t total64[2];  /* must be directly before hash[] */
+	uint64_t hash[8];
+	uint8_t wbuffer[128]; /* always correctly aligned for uint64_t */
+} sha512_ctx_t;
+typedef struct sha3_ctx_t {
+	uint64_t state[25];
+	unsigned bytes_queued;
+	unsigned input_block_bytes;
+} sha3_ctx_t;
+void md5_begin(md5_ctx_t *ctx) FAST_FUNC;
+void md5_hash(md5_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
+void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC;
+void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC;
+#define sha1_hash md5_hash
+void sha1_end(sha1_ctx_t *ctx, void *resbuf) FAST_FUNC;
+void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC;
+#define sha256_hash md5_hash
+#define sha256_end  sha1_end
+void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;
+void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
+void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC;
+void sha3_begin(sha3_ctx_t *ctx) FAST_FUNC;
+void sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
+void sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC;
+
+extern uint32_t *global_crc32_table;
+uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC;
+uint32_t crc32_block_endian1(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) FAST_FUNC;
+uint32_t crc32_block_endian0(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) FAST_FUNC;
+
+typedef struct masks_labels_t {
+	const char *labels;
+	const int masks[];
+} masks_labels_t;
+int print_flags_separated(const int *masks, const char *labels,
+		int flags, const char *separator) FAST_FUNC;
+int print_flags(const masks_labels_t *ml, int flags) FAST_FUNC;
+
+typedef struct bb_progress_t {
+	unsigned last_size;
+	unsigned last_update_sec;
+	unsigned last_change_sec;
+	unsigned start_sec;
+	const char *curfile;
+} bb_progress_t;
+
+#define is_bb_progress_inited(p) ((p)->curfile != NULL)
+#define bb_progress_free(p) do { \
+	if (ENABLE_UNICODE_SUPPORT) free((char*)((p)->curfile)); \
+	(p)->curfile = NULL; \
+} while (0)
+void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC;
+void bb_progress_update(bb_progress_t *p,
+			uoff_t beg_range,
+			uoff_t transferred,
+			uoff_t totalsize) FAST_FUNC;
+
+unsigned ubi_devnum_from_devname(const char *str) FAST_FUNC;
+int ubi_get_volid_by_name(unsigned ubi_devnum, const char *vol_name) FAST_FUNC;
+
+
+extern const char *applet_name;
+
+/* Some older linkers don't perform string merging, we used to have common strings
+ * as global arrays to do it by hand. But:
+ * (1) newer linkers do it themselves,
+ * (2) however, they DONT merge string constants with global arrays,
+ * even if the value is the same (!). Thus global arrays actually
+ * increased size a bit: for example, "/etc/passwd" string from libc
+ * wasn't merged with bb_path_passwd_file[] array!
+ * Therefore now we use #defines.
+ */
+/* "BusyBox vN.N.N (timestamp or extra_version)" */
+extern const char bb_banner[] ALIGN1;
+extern const char bb_msg_memory_exhausted[] ALIGN1;
+extern const char bb_msg_invalid_date[] ALIGN1;
+#define bb_msg_read_error "read error"
+#define bb_msg_write_error "write error"
+extern const char bb_msg_unknown[] ALIGN1;
+extern const char bb_msg_can_not_create_raw_socket[] ALIGN1;
+extern const char bb_msg_perm_denied_are_you_root[] ALIGN1;
+extern const char bb_msg_you_must_be_root[] ALIGN1;
+extern const char bb_msg_requires_arg[] ALIGN1;
+extern const char bb_msg_invalid_arg_to[] ALIGN1;
+extern const char bb_msg_standard_input[] ALIGN1;
+extern const char bb_msg_standard_output[] ALIGN1;
+
+/* NB: (bb_hexdigits_upcase[i] | 0x20) -> lowercase hex digit */
+extern const char bb_hexdigits_upcase[] ALIGN1;
+
+extern const char bb_path_wtmp_file[] ALIGN1;
+
+/* Busybox mount uses either /proc/mounts or /etc/mtab to
+ * get the list of currently mounted filesystems */
+#define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts")
+
+#define bb_path_passwd_file  _PATH_PASSWD
+#define bb_path_group_file   _PATH_GROUP
+#define bb_path_shadow_file  _PATH_SHADOW
+#define bb_path_gshadow_file _PATH_GSHADOW
+
+#define bb_path_motd_file "/etc/motd"
+
+#define bb_dev_null "/dev/null"
+extern const char bb_busybox_exec_path[] ALIGN1;
+/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
+ * but I want to save a few bytes here */
+extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */
+#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH"))
+#define bb_default_path      (bb_PATH_root_path + sizeof("PATH=/sbin:/usr/sbin"))
+
+extern const int const_int_0;
+//extern const int const_int_1;
+
+/* This struct is deliberately not defined. */
+/* See docs/keep_data_small.txt */
+struct globals;
+/* '*const' ptr makes gcc optimize code much better.
+ * Magic prevents ptr_to_globals from going into rodata.
+ * If you want to assign a value, use SET_PTR_TO_GLOBALS(x) */
+extern struct globals *const ptr_to_globals;
+/* At least gcc 3.4.6 on mipsel system needs optimization barrier */
+#define barrier() __asm__ __volatile__("":::"memory")
+#define SET_PTR_TO_GLOBALS(x) do { \
+	(*(struct globals**)&ptr_to_globals) = (void*)(x); \
+	barrier(); \
+} while (0)
+#define FREE_PTR_TO_GLOBALS() do { \
+	if (ENABLE_FEATURE_CLEAN_UP) { \
+		free(ptr_to_globals); \
+	} \
+} while (0)
+
+/* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it,
+ * use bb_default_login_shell and following defines.
+ * If you change LIBBB_DEFAULT_LOGIN_SHELL,
+ * don't forget to change increment constant. */
+#define LIBBB_DEFAULT_LOGIN_SHELL  "-/bin/sh"
+extern const char bb_default_login_shell[] ALIGN1;
+/* "/bin/sh" */
+#define DEFAULT_SHELL              (bb_default_login_shell+1)
+/* "sh" */
+#define DEFAULT_SHELL_SHORT_NAME   (bb_default_login_shell+6)
+
+/* The following devices are the same on all systems.  */
+#define CURRENT_TTY "/dev/tty"
+#define DEV_CONSOLE "/dev/console"
+
+#if defined(__FreeBSD_kernel__)
+# define CURRENT_VC CURRENT_TTY
+# define VC_1 "/dev/ttyv0"
+# define VC_2 "/dev/ttyv1"
+# define VC_3 "/dev/ttyv2"
+# define VC_4 "/dev/ttyv3"
+# define VC_5 "/dev/ttyv4"
+# define VC_FORMAT "/dev/ttyv%d"
+#elif defined(__GNU__)
+# define CURRENT_VC CURRENT_TTY
+# define VC_1 "/dev/tty1"
+# define VC_2 "/dev/tty2"
+# define VC_3 "/dev/tty3"
+# define VC_4 "/dev/tty4"
+# define VC_5 "/dev/tty5"
+# define VC_FORMAT "/dev/tty%d"
+#elif ENABLE_FEATURE_DEVFS
+/*Linux, obsolete devfs names */
+# define CURRENT_VC "/dev/vc/0"
+# define VC_1 "/dev/vc/1"
+# define VC_2 "/dev/vc/2"
+# define VC_3 "/dev/vc/3"
+# define VC_4 "/dev/vc/4"
+# define VC_5 "/dev/vc/5"
+# define VC_FORMAT "/dev/vc/%d"
+# define LOOP_FORMAT "/dev/loop/%u"
+# define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1)
+# define LOOP_NAME "/dev/loop/"
+# define FB_0 "/dev/fb/0"
+#else
+/*Linux, normal names */
+# define CURRENT_VC "/dev/tty0"
+# define VC_1 "/dev/tty1"
+# define VC_2 "/dev/tty2"
+# define VC_3 "/dev/tty3"
+# define VC_4 "/dev/tty4"
+# define VC_5 "/dev/tty5"
+# define VC_FORMAT "/dev/tty%d"
+# define LOOP_FORMAT "/dev/loop%u"
+# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)
+# define LOOP_NAME "/dev/loop"
+# define FB_0 "/dev/fb0"
+#endif
+
+
+#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
+
+/* We redefine ctype macros. Unicode-correct handling of char types
+ * can't be done with such byte-oriented operations anyway,
+ * we don't lose anything.
+ */
+#undef isalnum
+#undef isalpha
+#undef isascii
+#undef isblank
+#undef iscntrl
+#undef isdigit
+#undef isgraph
+#undef islower
+#undef isprint
+#undef ispunct
+#undef isspace
+#undef isupper
+#undef isxdigit
+#undef toupper
+#undef tolower
+
+/* We save ~500 bytes on isdigit alone.
+ * BTW, x86 likes (unsigned char) cast more than (unsigned). */
+
+/* These work the same for ASCII and Unicode,
+ * assuming no one asks "is this a *Unicode* letter?" using isalpha(letter) */
+#define isascii(a) ((unsigned char)(a) <= 0x7f)
+#define isdigit(a) ((unsigned char)((a) - '0') <= 9)
+#define isupper(a) ((unsigned char)((a) - 'A') <= ('Z' - 'A'))
+#define islower(a) ((unsigned char)((a) - 'a') <= ('z' - 'a'))
+#define isalpha(a) ((unsigned char)(((a)|0x20) - 'a') <= ('z' - 'a'))
+#define isblank(a) ({ unsigned char bb__isblank = (a); bb__isblank == ' ' || bb__isblank == '\t'; })
+#define iscntrl(a) ({ unsigned char bb__iscntrl = (a); bb__iscntrl < ' ' || bb__iscntrl == 0x7f; })
+/* In POSIX/C locale isspace is only these chars: "\t\n\v\f\r" and space.
+ * "\t\n\v\f\r" happen to have ASCII codes 9,10,11,12,13.
+ */
+#define isspace(a) ({ unsigned char bb__isspace = (a) - 9; bb__isspace == (' ' - 9) || bb__isspace <= (13 - 9); })
+// Unsafe wrt NUL: #define ispunct(a) (strchr("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", (a)) != NULL)
+#define ispunct(a) (strchrnul("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", (a))[0])
+// Bigger code: #define isalnum(a) ({ unsigned char bb__isalnum = (a) - '0'; bb__isalnum <= 9 || ((bb__isalnum - ('A' - '0')) & 0xdf) <= 25; })
+#define isalnum(a) bb_ascii_isalnum(a)
+static ALWAYS_INLINE int bb_ascii_isalnum(unsigned char a)
+{
+	unsigned char b = a - '0';
+	if (b <= 9)
+		return (b <= 9);
+	b = (a|0x20) - 'a';
+	return b <= 'z' - 'a';
+}
+#define isxdigit(a) bb_ascii_isxdigit(a)
+static ALWAYS_INLINE int bb_ascii_isxdigit(unsigned char a)
+{
+	unsigned char b = a - '0';
+	if (b <= 9)
+		return (b <= 9);
+	b = (a|0x20) - 'a';
+	return b <= 'f' - 'a';
+}
+#define toupper(a) bb_ascii_toupper(a)
+static ALWAYS_INLINE unsigned char bb_ascii_toupper(unsigned char a)
+{
+	unsigned char b = a - 'a';
+	if (b <= ('z' - 'a'))
+		a -= 'a' - 'A';
+	return a;
+}
+#define tolower(a) bb_ascii_tolower(a)
+static ALWAYS_INLINE unsigned char bb_ascii_tolower(unsigned char a)
+{
+	unsigned char b = a - 'A';
+	if (b <= ('Z' - 'A'))
+		a += 'a' - 'A';
+	return a;
+}
+
+/* In ASCII and Unicode, these are likely to be very different.
+ * Let's prevent ambiguous usage from the start */
+#define isgraph(a) isgraph_is_ambiguous_dont_use(a)
+#define isprint(a) isprint_is_ambiguous_dont_use(a)
+/* NB: must not treat EOF as isgraph or isprint */
+#define isgraph_asciionly(a) ((unsigned)((a) - 0x21) <= 0x7e - 0x21)
+#define isprint_asciionly(a) ((unsigned)((a) - 0x20) <= 0x7e - 0x20)
+
+
+/* Simple unit-testing framework */
+
+typedef void (*bbunit_testfunc)(void);
+
+struct bbunit_listelem {
+	const char* name;
+	bbunit_testfunc testfunc;
+};
+
+void bbunit_registertest(struct bbunit_listelem* test);
+void bbunit_settestfailed(void);
+
+#define BBUNIT_DEFINE_TEST(NAME) \
+	static void bbunit_##NAME##_test(void); \
+	static struct bbunit_listelem bbunit_##NAME##_elem = { \
+		.name = #NAME, \
+		.testfunc = bbunit_##NAME##_test, \
+	}; \
+	static void INIT_FUNC bbunit_##NAME##_register(void) \
+	{ \
+		bbunit_registertest(&bbunit_##NAME##_elem); \
+	} \
+	static void bbunit_##NAME##_test(void)
+
+/*
+ * Both 'goto bbunit_end' and 'break' are here only to get rid
+ * of compiler warnings.
+ */
+#define BBUNIT_ENDTEST \
+	do { \
+		goto bbunit_end; \
+	bbunit_end: \
+		break; \
+	} while (0)
+
+#define BBUNIT_PRINTASSERTFAIL \
+	do { \
+		bb_error_msg( \
+			"[ERROR] Assertion failed in file %s, line %d", \
+			__FILE__, __LINE__); \
+	} while (0)
+
+#define BBUNIT_ASSERTION_FAILED \
+	do { \
+		bbunit_settestfailed(); \
+		goto bbunit_end; \
+	} while (0)
+
+/*
+ * Assertions.
+ * For now we only offer assertions which cause tests to fail
+ * immediately. In the future 'expects' might be added too -
+ * similar to those offered by the gtest framework.
+ */
+#define BBUNIT_ASSERT_EQ(EXPECTED, ACTUAL) \
+	do { \
+		if ((EXPECTED) != (ACTUAL)) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] '%s' isn't equal to '%s'", \
+						#EXPECTED, #ACTUAL); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+#define BBUNIT_ASSERT_NOTEQ(EXPECTED, ACTUAL) \
+	do { \
+		if ((EXPECTED) == (ACTUAL)) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] '%s' is equal to '%s'", \
+						#EXPECTED, #ACTUAL); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+#define BBUNIT_ASSERT_NOTNULL(PTR) \
+	do { \
+		if ((PTR) == NULL) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] '%s' is NULL!", #PTR); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+#define BBUNIT_ASSERT_NULL(PTR) \
+	do { \
+		if ((PTR) != NULL) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] '%s' is not NULL!", #PTR); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+#define BBUNIT_ASSERT_FALSE(STATEMENT) \
+	do { \
+		if ((STATEMENT)) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] Statement '%s' evaluated to true!", \
+								#STATEMENT); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+#define BBUNIT_ASSERT_TRUE(STATEMENT) \
+	do { \
+		if (!(STATEMENT)) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] Statement '%s' evaluated to false!", \
+					#STATEMENT); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+#define BBUNIT_ASSERT_STREQ(STR1, STR2) \
+	do { \
+		if (strcmp(STR1, STR2) != 0) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] Strings '%s' and '%s' " \
+					"are not the same", STR1, STR2); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+#define BBUNIT_ASSERT_STRNOTEQ(STR1, STR2) \
+	do { \
+		if (strcmp(STR1, STR2) == 0) { \
+			BBUNIT_PRINTASSERTFAIL; \
+			bb_error_msg("[ERROR] Strings '%s' and '%s' " \
+					"are the same, but were " \
+					"expected to differ", STR1, STR2); \
+			BBUNIT_ASSERTION_FAILED; \
+		} \
+	} while (0)
+
+
+POP_SAVED_FUNCTION_VISIBILITY
+
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/libbb/messages.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/messages.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/messages.c	(revision 279)
@@ -0,0 +1,61 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+/* allow default system PATH to be extended via CFLAGS */
+#ifndef BB_ADDITIONAL_PATH
+#define BB_ADDITIONAL_PATH ""
+#endif
+
+/* allow version to be extended, via CFLAGS */
+#ifndef BB_EXTRA_VERSION
+#define BB_EXTRA_VERSION BB_BT
+#endif
+
+#define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
+
+const char bb_banner[] ALIGN1 = BANNER;
+
+
+const char bb_msg_memory_exhausted[] ALIGN1 = "out of memory";
+const char bb_msg_invalid_date[] ALIGN1 = "invalid date '%s'";
+const char bb_msg_unknown[] ALIGN1 = "(unknown)";
+const char bb_msg_can_not_create_raw_socket[] ALIGN1 = "can't create raw socket";
+const char bb_msg_perm_denied_are_you_root[] ALIGN1 = "permission denied (are you root?)";
+const char bb_msg_you_must_be_root[] ALIGN1 = "you must be root";
+const char bb_msg_requires_arg[] ALIGN1 = "%s requires an argument";
+const char bb_msg_invalid_arg_to[] ALIGN1 = "invalid argument '%s' to '%s'";
+const char bb_msg_standard_input[] ALIGN1 = "standard input";
+const char bb_msg_standard_output[] ALIGN1 = "standard output";
+
+const char bb_hexdigits_upcase[] ALIGN1 = "0123456789ABCDEF";
+
+const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH;
+const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL;
+/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
+ * but I want to save a few bytes here. Check libbb.h before changing! */
+const char bb_PATH_root_path[] ALIGN1 =
+	"PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH;
+
+
+//const int const_int_1 = 1;
+/* explicitly = 0, otherwise gcc may make it a common variable
+ * and it will end up in bss */
+const int const_int_0 = 0;
+
+#if ENABLE_FEATURE_WTMP
+/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */
+const char bb_path_wtmp_file[] ALIGN1 =
+# if defined _PATH_WTMP
+	_PATH_WTMP;
+# elif defined WTMP_FILE
+	WTMP_FILE;
+# else
+#  error unknown path to wtmp file
+# endif
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/libbb/perror_msg.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/perror_msg.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/perror_msg.c	(revision 279)
@@ -0,0 +1,40 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+#include "libbb.h"
+
+void FAST_FUNC bb_perror_msg(const char *s, ...)
+{
+	va_list p;
+
+	va_start(p, s);
+	/* Guard against "<error message>: Success" */
+	bb_verror_msg(s, p, errno ? strerror(errno) : NULL);
+	va_end(p);
+}
+
+void FAST_FUNC bb_perror_msg_and_die(const char *s, ...)
+{
+	va_list p;
+
+	va_start(p, s);
+	/* Guard against "<error message>: Success" */
+	bb_verror_msg(s, p, errno ? strerror(errno) : NULL);
+	va_end(p);
+	xfunc_die();
+}
+
+void FAST_FUNC bb_simple_perror_msg(const char *s)
+{
+	bb_perror_msg("%s", s);
+}
+
+void FAST_FUNC bb_simple_perror_msg_and_die(const char *s)
+{
+	bb_perror_msg_and_die("%s", s);
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/platform.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/platform.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/platform.h	(revision 279)
@@ -0,0 +1,582 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright 2006, Bernhard Reutner-Fischer
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+#ifndef BB_PLATFORM_H
+#define BB_PLATFORM_H 1
+
+
+/* Convenience macros to test the version of gcc. */
+#undef __GNUC_PREREQ
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+		((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define __GNUC_PREREQ(maj, min) 0
+#endif
+
+/* __restrict is known in EGCS 1.2 and above. */
+#if !__GNUC_PREREQ(2,92)
+# ifndef __restrict
+#  define __restrict
+# endif
+#endif
+
+#if !__GNUC_PREREQ(2,7)
+# ifndef __attribute__
+#  define __attribute__(x)
+# endif
+#endif
+
+#undef inline
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
+/* it's a keyword */
+#elif __GNUC_PREREQ(2,7)
+# define inline __inline__
+#else
+# define inline
+#endif
+
+#ifndef __const
+# define __const const
+#endif
+
+#define UNUSED_PARAM __attribute__ ((__unused__))
+#define NORETURN __attribute__ ((__noreturn__))
+/* "The malloc attribute is used to tell the compiler that a function
+ * may be treated as if any non-NULL pointer it returns cannot alias
+ * any other pointer valid when the function returns. This will often
+ * improve optimization. Standard functions with this property include
+ * malloc and calloc. realloc-like functions have this property as long
+ * as the old pointer is never referred to (including comparing it
+ * to the new pointer) after the function returns a non-NULL value."
+ */
+#define RETURNS_MALLOC __attribute__ ((malloc))
+#define PACKED __attribute__ ((__packed__))
+#define ALIGNED(m) __attribute__ ((__aligned__(m)))
+
+/* __NO_INLINE__: some gcc's do not honor inlining! :( */
+#if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__)
+# define ALWAYS_INLINE __attribute__ ((always_inline)) inline
+/* I've seen a toolchain where I needed __noinline__ instead of noinline */
+# define NOINLINE      __attribute__((__noinline__))
+# if !ENABLE_WERROR
+#  define DEPRECATED __attribute__ ((__deprecated__))
+#  define UNUSED_PARAM_RESULT __attribute__ ((warn_unused_result))
+# else
+#  define DEPRECATED
+#  define UNUSED_PARAM_RESULT
+# endif
+#else
+# define ALWAYS_INLINE inline
+# define NOINLINE
+# define DEPRECATED
+# define UNUSED_PARAM_RESULT
+#endif
+
+/* used by unit test machinery to run registration functions before calling main() */
+#define INIT_FUNC __attribute__ ((constructor))
+
+/* -fwhole-program makes all symbols local. The attribute externally_visible
+ * forces a symbol global.  */
+#if __GNUC_PREREQ(4,1)
+# define EXTERNALLY_VISIBLE __attribute__(( visibility("default") ))
+//__attribute__ ((__externally_visible__))
+#else
+# define EXTERNALLY_VISIBLE
+#endif
+
+/* At 4.4 gcc become much more anal about this, need to use "aliased" types */
+#if __GNUC_PREREQ(4,4)
+# define FIX_ALIASING __attribute__((__may_alias__))
+#else
+# define FIX_ALIASING
+#endif
+
+/* We use __extension__ in some places to suppress -pedantic warnings
+ * about GCC extensions.  This feature didn't work properly before
+ * gcc 2.8.  */
+#if !__GNUC_PREREQ(2,8)
+# ifndef __extension__
+#  define __extension__
+# endif
+#endif
+
+/* FAST_FUNC is a qualifier which (possibly) makes function call faster
+ * and/or smaller by using modified ABI. It is usually only needed
+ * on non-static, busybox internal functions. Recent versions of gcc
+ * optimize statics automatically. FAST_FUNC on static is required
+ * only if you need to match a function pointer's type */
+#if __GNUC_PREREQ(3,0) && defined(i386) /* || defined(__x86_64__)? */
+/* stdcall makes callee to pop arguments from stack, not caller */
+# define FAST_FUNC __attribute__((regparm(3),stdcall))
+/* #elif ... - add your favorite arch today! */
+#else
+# define FAST_FUNC
+#endif
+
+/* Make all declarations hidden (-fvisibility flag only affects definitions) */
+/* (don't include system headers after this until corresponding pop!) */
+#if __GNUC_PREREQ(4,1) && !defined(__CYGWIN__)
+# define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN _Pragma("GCC visibility push(hidden)")
+# define POP_SAVED_FUNCTION_VISIBILITY              _Pragma("GCC visibility pop")
+#else
+# define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
+# define POP_SAVED_FUNCTION_VISIBILITY
+#endif
+
+/* gcc-2.95 had no va_copy but only __va_copy. */
+#if !__GNUC_PREREQ(3,0)
+# include <stdarg.h>
+# if !defined va_copy && defined __va_copy
+#  define va_copy(d,s) __va_copy((d),(s))
+# endif
+#endif
+
+
+/* ---- Endian Detection ------------------------------------ */
+
+#include <limits.h>
+#if defined(__digital__) && defined(__unix__)
+# include <sex.h>
+#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
+   || defined(__APPLE__)
+# include <sys/resource.h>  /* rlimit */
+# include <machine/endian.h>
+# define bswap_64 __bswap64
+# define bswap_32 __bswap32
+# define bswap_16 __bswap16
+#else
+# include <byteswap.h>
+# include <endian.h>
+#endif
+
+#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
+# define BB_BIG_ENDIAN 1
+# define BB_LITTLE_ENDIAN 0
+#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
+# define BB_BIG_ENDIAN 0
+# define BB_LITTLE_ENDIAN 1
+#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN
+# define BB_BIG_ENDIAN 1
+# define BB_LITTLE_ENDIAN 0
+#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN
+# define BB_BIG_ENDIAN 0
+# define BB_LITTLE_ENDIAN 1
+#elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
+# define BB_BIG_ENDIAN 1
+# define BB_LITTLE_ENDIAN 0
+#elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
+# define BB_BIG_ENDIAN 0
+# define BB_LITTLE_ENDIAN 1
+#elif defined(__386__)
+# define BB_BIG_ENDIAN 0
+# define BB_LITTLE_ENDIAN 1
+#else
+# error "Can't determine endianness"
+#endif
+
+#if ULONG_MAX > 0xffffffff
+# define bb_bswap_64(x) bswap_64(x)
+#endif
+
+/* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */
+#if BB_BIG_ENDIAN
+# define SWAP_BE16(x) (x)
+# define SWAP_BE32(x) (x)
+# define SWAP_BE64(x) (x)
+# define SWAP_LE16(x) bswap_16(x)
+# define SWAP_LE32(x) bswap_32(x)
+# define SWAP_LE64(x) bb_bswap_64(x)
+# define IF_BIG_ENDIAN(...) __VA_ARGS__
+# define IF_LITTLE_ENDIAN(...)
+#else
+# define SWAP_BE16(x) bswap_16(x)
+# define SWAP_BE32(x) bswap_32(x)
+# define SWAP_BE64(x) bb_bswap_64(x)
+# define SWAP_LE16(x) (x)
+# define SWAP_LE32(x) (x)
+# define SWAP_LE64(x) (x)
+# define IF_BIG_ENDIAN(...)
+# define IF_LITTLE_ENDIAN(...) __VA_ARGS__
+#endif
+
+
+/* ---- Unaligned access ------------------------------------ */
+
+#include <stdint.h>
+typedef int      bb__aliased_int      FIX_ALIASING;
+typedef long     bb__aliased_long     FIX_ALIASING;
+typedef uint16_t bb__aliased_uint16_t FIX_ALIASING;
+typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
+typedef uint64_t bb__aliased_uint64_t FIX_ALIASING;
+
+/* NB: unaligned parameter should be a pointer, aligned one -
+ * a lvalue. This makes it more likely to not swap them by mistake
+ */
+#if defined(i386) || defined(__x86_64__) || defined(__powerpc__)
+# define BB_UNALIGNED_MEMACCESS_OK 1
+# define move_from_unaligned_int(v, intp)  ((v) = *(bb__aliased_int*)(intp))
+# define move_from_unaligned_long(v, longp) ((v) = *(bb__aliased_long*)(longp))
+# define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p))
+# define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p))
+# define move_to_unaligned16(u16p, v)   (*(bb__aliased_uint16_t*)(u16p) = (v))
+# define move_to_unaligned32(u32p, v)   (*(bb__aliased_uint32_t*)(u32p) = (v))
+/* #elif ... - add your favorite arch today! */
+#else
+# define BB_UNALIGNED_MEMACCESS_OK 0
+/* performs reasonably well (gcc usually inlines memcpy here) */
+# define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int)))
+# define move_from_unaligned_long(v, longp) (memcpy(&(v), (longp), sizeof(long)))
+# define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2))
+# define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4))
+# define move_to_unaligned16(u16p, v) do { \
+	uint16_t __t = (v); \
+	memcpy((u16p), &__t, 2); \
+} while (0)
+# define move_to_unaligned32(u32p, v) do { \
+	uint32_t __t = (v); \
+	memcpy((u32p), &__t, 4); \
+} while (0)
+#endif
+
+
+/* ---- Size-saving "small" ints (arch-dependent) ----------- */
+
+#if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__)
+/* add other arches which benefit from this... */
+typedef signed char smallint;
+typedef unsigned char smalluint;
+#else
+/* for arches where byte accesses generate larger code: */
+typedef int smallint;
+typedef unsigned smalluint;
+#endif
+
+/* ISO C Standard:  7.16  Boolean type and values  <stdbool.h> */
+#if (defined __digital__ && defined __unix__)
+/* old system without (proper) C99 support */
+# define bool smalluint
+#else
+/* modern system, so use it */
+# include <stdbool.h>
+#endif
+
+
+/*----- Kernel versioning ------------------------------------*/
+
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+
+#ifdef __UCLIBC__
+# define UCLIBC_VERSION KERNEL_VERSION(__UCLIBC_MAJOR__, __UCLIBC_MINOR__, __UCLIBC_SUBLEVEL__)
+#else
+# define UCLIBC_VERSION 0
+#endif
+
+
+/* ---- Miscellaneous --------------------------------------- */
+
+#if defined __GLIBC__ \
+ || defined __UCLIBC__ \
+ || defined __dietlibc__ \
+ || defined __BIONIC__ \
+ || defined _NEWLIB_VERSION
+# include <features.h>
+#endif
+
+/* Define bb_setpgrp */
+#if defined(__digital__) && defined(__unix__)
+/* use legacy setpgrp(pid_t, pid_t) for now.  move to platform.c */
+# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0)
+#else
+# define bb_setpgrp() setpgrp()
+#endif
+
+/* fdprintf is more readable, we used it before dprintf was standardized */
+#include <unistd.h>
+#define fdprintf dprintf
+
+/* Useful for defeating gcc's alignment of "char message[]"-like data */
+#if !defined(__s390__)
+    /* on s390[x], non-word-aligned data accesses require larger code */
+# define ALIGN1 __attribute__((aligned(1)))
+# define ALIGN2 __attribute__((aligned(2)))
+# define ALIGN4 __attribute__((aligned(4)))
+#else
+/* Arches which MUST have 2 or 4 byte alignment for everything are here */
+# define ALIGN1
+# define ALIGN2
+# define ALIGN4
+#endif
+
+/*
+ * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably.
+ * For earlier versions there is no reliable way to check if we are building
+ * for a mmu-less system.
+ */
+#if ENABLE_NOMMU || \
+    (defined __UCLIBC__ && \
+     UCLIBC_VERSION > KERNEL_VERSION(0, 9, 28) && \
+     !defined __ARCH_USE_MMU__)
+# define BB_MMU 0
+# define USE_FOR_NOMMU(...) __VA_ARGS__
+# define USE_FOR_MMU(...)
+#else
+# define BB_MMU 1
+# define USE_FOR_NOMMU(...)
+# define USE_FOR_MMU(...) __VA_ARGS__
+#endif
+
+#if defined(__digital__) && defined(__unix__)
+# include <standards.h>
+# include <inttypes.h>
+# define PRIu32 "u"
+# if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET
+#  define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET)
+# endif
+# if !defined ADJ_FREQUENCY && defined MOD_FREQUENCY
+#  define ADJ_FREQUENCY MOD_FREQUENCY
+# endif
+# if !defined ADJ_TIMECONST && defined MOD_TIMECONST
+#  define ADJ_TIMECONST MOD_TIMECONST
+# endif
+# if !defined ADJ_TICK && defined MOD_CLKB
+#  define ADJ_TICK MOD_CLKB
+# endif
+#endif
+
+#if defined(__CYGWIN__)
+# define MAXSYMLINKS SYMLOOP_MAX
+#endif
+
+#if defined(ANDROID) || defined(__ANDROID__)
+# define BB_ADDITIONAL_PATH ":/system/sbin:/system/bin:/system/xbin"
+# define SYS_ioprio_set __NR_ioprio_set
+# define SYS_ioprio_get __NR_ioprio_get
+#endif
+
+
+/* ---- Who misses what? ------------------------------------ */
+
+/* Assume all these functions and header files exist by default.
+ * Platforms where it is not true will #undef them below.
+ */
+#define HAVE_CLEARENV 1
+#define HAVE_FDATASYNC 1
+#define HAVE_DPRINTF 1
+#define HAVE_MEMRCHR 1
+#define HAVE_MKDTEMP 1
+#define HAVE_TTYNAME_R 1
+#define HAVE_PTSNAME_R 1
+#define HAVE_SETBIT 1
+#define HAVE_SIGHANDLER_T 1
+#define HAVE_STPCPY 1
+#define HAVE_MEMPCPY 1
+#define HAVE_STRCASESTR 1
+#define HAVE_STRCHRNUL 1
+#define HAVE_STRSEP 1
+#define HAVE_STRSIGNAL 1
+#define HAVE_STRVERSCMP 0
+#define HAVE_VASPRINTF 1
+#define HAVE_USLEEP 1
+#define HAVE_UNLOCKED_STDIO 1
+#define HAVE_UNLOCKED_LINE_OPS 1
+#define HAVE_GETLINE 1
+#define HAVE_XTABS 1
+#define HAVE_MNTENT_H 1
+#define HAVE_NET_ETHERNET_H 1
+#define HAVE_SYS_STATFS_H 1
+
+#if defined(__UCLIBC__)
+# if UCLIBC_VERSION < KERNEL_VERSION(0, 9, 32)
+#  undef HAVE_STRVERSCMP
+# endif
+# if UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30)
+#  ifndef __UCLIBC_SUSV3_LEGACY__
+#   undef HAVE_USLEEP
+#  endif
+# endif
+#endif
+
+#if defined(__WATCOMC__)
+# undef HAVE_DPRINTF
+# undef HAVE_GETLINE
+# undef HAVE_MEMRCHR
+# undef HAVE_MKDTEMP
+# undef HAVE_SETBIT
+# undef HAVE_STPCPY
+# undef HAVE_STRCASESTR
+# undef HAVE_STRCHRNUL
+# undef HAVE_STRSEP
+# undef HAVE_STRSIGNAL
+# undef HAVE_STRVERSCMP
+# undef HAVE_VASPRINTF
+# undef HAVE_UNLOCKED_STDIO
+# undef HAVE_UNLOCKED_LINE_OPS
+# undef HAVE_NET_ETHERNET_H
+#endif
+
+#if defined(__CYGWIN__)
+# undef HAVE_CLEARENV
+# undef HAVE_FDPRINTF
+# undef HAVE_MEMRCHR
+# undef HAVE_PTSNAME_R
+# undef HAVE_STRVERSCMP
+# undef HAVE_UNLOCKED_LINE_OPS
+#endif
+
+/* These BSD-derived OSes share many similarities */
+#if (defined __digital__ && defined __unix__) \
+ || defined __APPLE__ \
+ || defined __OpenBSD__ || defined __NetBSD__
+# undef HAVE_CLEARENV
+# undef HAVE_FDATASYNC
+# undef HAVE_GETLINE
+# undef HAVE_MNTENT_H
+# undef HAVE_PTSNAME_R
+# undef HAVE_SYS_STATFS_H
+# undef HAVE_SIGHANDLER_T
+# undef HAVE_STRVERSCMP
+# undef HAVE_XTABS
+# undef HAVE_DPRINTF
+# undef HAVE_UNLOCKED_STDIO
+# undef HAVE_UNLOCKED_LINE_OPS
+#endif
+
+#if defined(__dietlibc__)
+# undef HAVE_STRCHRNUL
+#endif
+
+#if defined(__APPLE__)
+# undef HAVE_STRCHRNUL
+#endif
+
+#if defined(__FreeBSD__)
+/* users say mempcpy is not present in FreeBSD 9.x */
+# undef HAVE_MEMPCPY
+# undef HAVE_CLEARENV
+# undef HAVE_FDATASYNC
+# undef HAVE_MNTENT_H
+# undef HAVE_PTSNAME_R
+# undef HAVE_SYS_STATFS_H
+# undef HAVE_SIGHANDLER_T
+# undef HAVE_STRVERSCMP
+# undef HAVE_XTABS
+# undef HAVE_UNLOCKED_LINE_OPS
+# include <osreldate.h>
+# if __FreeBSD_version < 1000029
+#  undef HAVE_STRCHRNUL /* FreeBSD added strchrnul() between 1000028 and 1000029 */
+# endif
+#endif
+
+#if defined(__NetBSD__)
+# define HAVE_GETLINE 1  /* Recent NetBSD versions have getline() */
+#endif
+
+#if defined(__digital__) && defined(__unix__)
+# undef HAVE_STPCPY
+#endif
+
+#if defined(ANDROID) || defined(__ANDROID__)
+# if __ANDROID_API__ < 8
+   /* ANDROID < 8 has no [f]dprintf at all */
+#  undef HAVE_DPRINTF
+# elif __ANDROID_API__ < 21
+   /* ANDROID < 21 has fdprintf */
+#  define dprintf fdprintf
+# else
+   /* ANDROID >= 21 has standard dprintf */
+# endif
+# if __ANDROID_API__ < 21
+#  undef HAVE_TTYNAME_R
+#  undef HAVE_GETLINE
+#  undef HAVE_STPCPY
+# endif
+# undef HAVE_MEMPCPY
+# undef HAVE_STRCHRNUL
+# undef HAVE_STRVERSCMP
+# undef HAVE_UNLOCKED_LINE_OPS
+# undef HAVE_NET_ETHERNET_H
+#endif
+
+/*
+ * Now, define prototypes for all the functions defined in platform.c
+ * These must come after all the HAVE_* macros are defined (or not)
+ */
+
+#ifndef HAVE_DPRINTF
+extern int dprintf(int fd, const char *format, ...);
+#endif
+
+#ifndef HAVE_MEMRCHR
+extern void *memrchr(const void *s, int c, size_t n) FAST_FUNC;
+#endif
+
+#ifndef HAVE_MKDTEMP
+extern char *mkdtemp(char *template) FAST_FUNC;
+#endif
+
+#ifndef HAVE_TTYNAME_R
+#define ttyname_r bb_ttyname_r
+extern int ttyname_r(int fd, char *buf, size_t buflen);
+#endif
+
+#ifndef HAVE_SETBIT
+# define setbit(a, b)  ((a)[(b) >> 3] |= 1 << ((b) & 7))
+# define clrbit(a, b)  ((a)[(b) >> 3] &= ~(1 << ((b) & 7)))
+#endif
+
+#ifndef HAVE_SIGHANDLER_T
+typedef void (*sighandler_t)(int);
+#endif
+
+#ifndef HAVE_STPCPY
+extern char *stpcpy(char *p, const char *to_add) FAST_FUNC;
+#endif
+
+#ifndef HAVE_MEMPCPY
+#include <string.h>
+/* In case we are wrong about !HAVE_MEMPCPY, and toolchain _does_ have
+ * mempcpy(), avoid colliding with it:
+ */
+#define mempcpy bb__mempcpy
+static ALWAYS_INLINE void *mempcpy(void *dest, const void *src, size_t len)
+{
+	return memcpy(dest, src, len) + len;
+}
+#endif
+
+#ifndef HAVE_STRCASESTR
+extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC;
+#endif
+
+#ifndef HAVE_STRCHRNUL
+extern char *strchrnul(const char *s, int c) FAST_FUNC;
+#endif
+
+#ifndef HAVE_STRSEP
+extern char *strsep(char **stringp, const char *delim) FAST_FUNC;
+#endif
+
+#ifndef HAVE_STRSIGNAL
+/* Not exactly the same: instead of "Stopped" it shows "STOP" etc */
+# define strsignal(sig) get_signame(sig)
+#endif
+
+#ifndef HAVE_USLEEP
+extern int usleep(unsigned) FAST_FUNC;
+#endif
+
+#ifndef HAVE_VASPRINTF
+extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC;
+#endif
+
+#ifndef HAVE_GETLINE
+# include <stdio.h> /* for FILE */
+# include <sys/types.h> /* size_t */
+extern ssize_t getline(char **lineptr, size_t *n, FILE *stream) FAST_FUNC;
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/libbb/ptr_to_globals.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/ptr_to_globals.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/ptr_to_globals.c	(revision 279)
@@ -0,0 +1,35 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+#include <errno.h>
+
+struct globals;
+
+#ifndef GCC_COMBINE
+
+/* We cheat here. It is declared as const ptr in libbb.h,
+ * but here we make it live in R/W memory */
+struct globals *ptr_to_globals;
+
+#ifdef __GLIBC__
+int *bb_errno;
+#endif
+
+
+#else
+
+
+/* gcc -combine will see through and complain */
+/* Using alternative method which is more likely to break
+ * on weird architectures, compilers, linkers and so on */
+struct globals *const ptr_to_globals __attribute__ ((section (".data")));
+
+#ifdef __GLIBC__
+int *const bb_errno __attribute__ ((section (".data")));
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/libbb/read.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/read.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/read.c	(revision 279)
@@ -0,0 +1,72 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+#include "libbb.h"
+
+ssize_t FAST_FUNC safe_read(int fd, void *buf, size_t count)
+{
+	ssize_t n;
+
+	do {
+		n = read(fd, buf, count);
+	} while (n < 0 && errno == EINTR);
+
+	return n;
+}
+
+/*
+ * Read all of the supplied buffer from a file.
+ * This does multiple reads as necessary.
+ * Returns the amount read, or -1 on an error.
+ * A short read is returned on an end of file.
+ */
+ssize_t FAST_FUNC full_read(int fd, void *buf, size_t len)
+{
+	ssize_t cc;
+	ssize_t total;
+
+	total = 0;
+
+	while (len) {
+		cc = safe_read(fd, buf, len);
+
+		if (cc < 0) {
+			if (total) {
+				/* we already have some! */
+				/* user can do another read to know the error code */
+				return total;
+			}
+			return cc; /* read() returns -1 on failure. */
+		}
+		if (cc == 0)
+			break;
+		buf = ((char *)buf) + cc;
+		total += cc;
+		len -= cc;
+	}
+
+	return total;
+}
+
+ssize_t FAST_FUNC read_close(int fd, void *buf, size_t size)
+{
+	/*int e;*/
+	size = full_read(fd, buf, size);
+	/*e = errno;*/
+	close(fd);
+	/*errno = e;*/
+	return size;
+}
+
+ssize_t FAST_FUNC open_read_close(const char *filename, void *buf, size_t size)
+{
+	int fd = open(filename, O_RDONLY);
+	if (fd < 0)
+		return fd;
+	return read_close(fd, buf, size);
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/read_key.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/read_key.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/read_key.c	(revision 279)
@@ -0,0 +1,293 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2008 Rob Landley <rob@landley.net>
+ * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+#include "libbb.h"
+
+int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
+{
+	struct pollfd pfd;
+	const char *seq;
+	int n;
+
+	/* Known escape sequences for cursor and function keys.
+	 * See "Xterm Control Sequences"
+	 * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+	 * Array should be sorted from shortest to longest.
+	 */
+	static const char esccmds[] ALIGN1 = {
+		'\x7f'         |0x80,KEYCODE_ALT_BACKSPACE,
+		'\b'           |0x80,KEYCODE_ALT_BACKSPACE,
+		'd'            |0x80,KEYCODE_ALT_D   ,
+	/* lineedit mimics bash: Alt-f and Alt-b are forward/backward
+	 * word jumps. We cheat here and make them return ALT_LEFT/RIGHT
+	 * keycodes. This way, lineedit need no special code to handle them.
+	 * If we'll need to distinguish them, introduce new ALT_F/B keycodes,
+	 * and update lineedit to react to them.
+	 */
+		'f'            |0x80,KEYCODE_ALT_RIGHT,
+		'b'            |0x80,KEYCODE_ALT_LEFT,
+		'O','A'        |0x80,KEYCODE_UP      ,
+		'O','B'        |0x80,KEYCODE_DOWN    ,
+		'O','C'        |0x80,KEYCODE_RIGHT   ,
+		'O','D'        |0x80,KEYCODE_LEFT    ,
+		'O','H'        |0x80,KEYCODE_HOME    ,
+		'O','F'        |0x80,KEYCODE_END     ,
+#if 0
+		'O','P'        |0x80,KEYCODE_FUN1    ,
+		/* [ESC] ESC O [2] P - [Alt-][Shift-]F1 */
+		/* ESC [ O 1 ; 2 P - Shift-F1 */
+		/* ESC [ O 1 ; 3 P - Alt-F1 */
+		/* ESC [ O 1 ; 4 P - Alt-Shift-F1 */
+		/* ESC [ O 1 ; 5 P - Ctrl-F1 */
+		/* ESC [ O 1 ; 6 P - Ctrl-Shift-F1 */
+		'O','Q'        |0x80,KEYCODE_FUN2    ,
+		'O','R'        |0x80,KEYCODE_FUN3    ,
+		'O','S'        |0x80,KEYCODE_FUN4    ,
+#endif
+		'[','A'        |0x80,KEYCODE_UP      ,
+		'[','B'        |0x80,KEYCODE_DOWN    ,
+		'[','C'        |0x80,KEYCODE_RIGHT   ,
+		'[','D'        |0x80,KEYCODE_LEFT    ,
+		/* ESC [ 1 ; 2 x, where x = A/B/C/D: Shift-<arrow> */
+		/* ESC [ 1 ; 3 x, where x = A/B/C/D: Alt-<arrow> - implemented below */
+		/* ESC [ 1 ; 4 x, where x = A/B/C/D: Alt-Shift-<arrow> */
+		/* ESC [ 1 ; 5 x, where x = A/B/C/D: Ctrl-<arrow> - implemented below */
+		/* ESC [ 1 ; 6 x, where x = A/B/C/D: Ctrl-Shift-<arrow> */
+		/* ESC [ 1 ; 7 x, where x = A/B/C/D: Ctrl-Alt-<arrow> */
+		/* ESC [ 1 ; 8 x, where x = A/B/C/D: Ctrl-Alt-Shift-<arrow> */
+		'[','H'        |0x80,KEYCODE_HOME    , /* xterm */
+		'[','F'        |0x80,KEYCODE_END     , /* xterm */
+		/* [ESC] ESC [ [2] H - [Alt-][Shift-]Home (End similarly?) */
+		/* '[','Z'        |0x80,KEYCODE_SHIFT_TAB, */
+		'[','1','~'    |0x80,KEYCODE_HOME    , /* vt100? linux vt? or what? */
+		'[','2','~'    |0x80,KEYCODE_INSERT  ,
+		/* ESC [ 2 ; 3 ~ - Alt-Insert */
+		'[','3','~'    |0x80,KEYCODE_DELETE  ,
+		/* [ESC] ESC [ 3 [;2] ~ - [Alt-][Shift-]Delete */
+		/* ESC [ 3 ; 3 ~ - Alt-Delete */
+		/* ESC [ 3 ; 5 ~ - Ctrl-Delete */
+		'[','4','~'    |0x80,KEYCODE_END     , /* vt100? linux vt? or what? */
+		'[','5','~'    |0x80,KEYCODE_PAGEUP  ,
+		/* ESC [ 5 ; 3 ~ - Alt-PgUp */
+		/* ESC [ 5 ; 5 ~ - Ctrl-PgUp */
+		/* ESC [ 5 ; 7 ~ - Ctrl-Alt-PgUp */
+		'[','6','~'    |0x80,KEYCODE_PAGEDOWN,
+		'[','7','~'    |0x80,KEYCODE_HOME    , /* vt100? linux vt? or what? */
+		'[','8','~'    |0x80,KEYCODE_END     , /* vt100? linux vt? or what? */
+#if 0
+		'[','1','1','~'|0x80,KEYCODE_FUN1    , /* old xterm, deprecated by ESC O P */
+		'[','1','2','~'|0x80,KEYCODE_FUN2    , /* old xterm... */
+		'[','1','3','~'|0x80,KEYCODE_FUN3    , /* old xterm... */
+		'[','1','4','~'|0x80,KEYCODE_FUN4    , /* old xterm... */
+		'[','1','5','~'|0x80,KEYCODE_FUN5    ,
+		/* [ESC] ESC [ 1 5 [;2] ~ - [Alt-][Shift-]F5 */
+		'[','1','7','~'|0x80,KEYCODE_FUN6    ,
+		'[','1','8','~'|0x80,KEYCODE_FUN7    ,
+		'[','1','9','~'|0x80,KEYCODE_FUN8    ,
+		'[','2','0','~'|0x80,KEYCODE_FUN9    ,
+		'[','2','1','~'|0x80,KEYCODE_FUN10   ,
+		'[','2','3','~'|0x80,KEYCODE_FUN11   ,
+		'[','2','4','~'|0x80,KEYCODE_FUN12   ,
+		/* ESC [ 2 4 ; 2 ~ - Shift-F12 */
+		/* ESC [ 2 4 ; 3 ~ - Alt-F12 */
+		/* ESC [ 2 4 ; 4 ~ - Alt-Shift-F12 */
+		/* ESC [ 2 4 ; 5 ~ - Ctrl-F12 */
+		/* ESC [ 2 4 ; 6 ~ - Ctrl-Shift-F12 */
+#endif
+		/* '[','1',';','5','A' |0x80,KEYCODE_CTRL_UP   , - unused */
+		/* '[','1',';','5','B' |0x80,KEYCODE_CTRL_DOWN , - unused */
+		'[','1',';','5','C' |0x80,KEYCODE_CTRL_RIGHT,
+		'[','1',';','5','D' |0x80,KEYCODE_CTRL_LEFT ,
+		/* '[','1',';','3','A' |0x80,KEYCODE_ALT_UP    , - unused */
+		/* '[','1',';','3','B' |0x80,KEYCODE_ALT_DOWN  , - unused */
+		'[','1',';','3','C' |0x80,KEYCODE_ALT_RIGHT,
+		'[','1',';','3','D' |0x80,KEYCODE_ALT_LEFT ,
+		/* '[','3',';','3','~' |0x80,KEYCODE_ALT_DELETE, - unused */
+		0
+	};
+
+	pfd.fd = fd;
+	pfd.events = POLLIN;
+
+	buffer++; /* saved chars counter is in buffer[-1] now */
+
+ start_over:
+	errno = 0;
+	n = (unsigned char)buffer[-1];
+	if (n == 0) {
+		/* If no data, wait for input.
+		 * If requested, wait TIMEOUT ms. TIMEOUT = -1 is useful
+		 * if fd can be in non-blocking mode.
+		 */
+		if (timeout >= -1) {
+			if (safe_poll(&pfd, 1, timeout) == 0) {
+				/* Timed out */
+				errno = EAGAIN;
+				return -1;
+			}
+		}
+		/* It is tempting to read more than one byte here,
+		 * but it breaks pasting. Example: at shell prompt,
+		 * user presses "c","a","t" and then pastes "\nline\n".
+		 * When we were reading 3 bytes here, we were eating
+		 * "li" too, and cat was getting wrong input.
+		 */
+		n = safe_read(fd, buffer, 1);
+		if (n <= 0)
+			return -1;
+	}
+
+	{
+		unsigned char c = buffer[0];
+		n--;
+		if (n)
+			memmove(buffer, buffer + 1, n);
+		/* Only ESC starts ESC sequences */
+		if (c != 27) {
+			buffer[-1] = n;
+			return c;
+		}
+	}
+
+	/* Loop through known ESC sequences */
+	seq = esccmds;
+	while (*seq != '\0') {
+		/* n - position in sequence we did not read yet */
+		int i = 0; /* position in sequence to compare */
+
+		/* Loop through chars in this sequence */
+		while (1) {
+			/* So far escape sequence matched up to [i-1] */
+			if (n <= i) {
+				/* Need more chars, read another one if it wouldn't block.
+				 * Note that escape sequences come in as a unit,
+				 * so if we block for long it's not really an escape sequence.
+				 * Timeout is needed to reconnect escape sequences
+				 * split up by transmission over a serial console. */
+				if (safe_poll(&pfd, 1, 50) == 0) {
+					/* No more data!
+					 * Array is sorted from shortest to longest,
+					 * we can't match anything later in array -
+					 * anything later is longer than this seq.
+					 * Break out of both loops. */
+					goto got_all;
+				}
+				errno = 0;
+				if (safe_read(fd, buffer + n, 1) <= 0) {
+					/* If EAGAIN, then fd is O_NONBLOCK and poll lied:
+					 * in fact, there is no data. */
+					if (errno != EAGAIN) {
+						/* otherwise: it's EOF/error */
+						buffer[-1] = 0;
+						return -1;
+					}
+					goto got_all;
+				}
+				n++;
+			}
+			if (buffer[i] != (seq[i] & 0x7f)) {
+				/* This seq doesn't match, go to next */
+				seq += i;
+				/* Forward to last char */
+				while (!(*seq & 0x80))
+					seq++;
+				/* Skip it and the keycode which follows */
+				seq += 2;
+				break;
+			}
+			if (seq[i] & 0x80) {
+				/* Entire seq matched */
+				n = 0;
+				/* n -= i; memmove(...);
+				 * would be more correct,
+				 * but we never read ahead that much,
+				 * and n == i here. */
+				buffer[-1] = 0;
+				return (signed char)seq[i+1];
+			}
+			i++;
+		}
+	}
+	/* We did not find matching sequence.
+	 * We possibly read and stored more input in buffer[] by now.
+	 * n = bytes read. Try to read more until we time out.
+	 */
+	while (n < KEYCODE_BUFFER_SIZE-1) { /* 1 for count byte at buffer[-1] */
+		if (safe_poll(&pfd, 1, 50) == 0) {
+			/* No more data! */
+			break;
+		}
+		errno = 0;
+		if (safe_read(fd, buffer + n, 1) <= 0) {
+			/* If EAGAIN, then fd is O_NONBLOCK and poll lied:
+			 * in fact, there is no data. */
+			if (errno != EAGAIN) {
+				/* otherwise: it's EOF/error */
+				buffer[-1] = 0;
+				return -1;
+			}
+			break;
+		}
+		n++;
+		/* Try to decipher "ESC [ NNN ; NNN R" sequence */
+		if ((ENABLE_FEATURE_EDITING_ASK_TERMINAL
+		    || ENABLE_FEATURE_VI_ASK_TERMINAL
+		    || ENABLE_FEATURE_LESS_ASK_TERMINAL
+		    )
+		 && n >= 5
+		 && buffer[0] == '['
+		 && buffer[n-1] == 'R'
+		 && isdigit(buffer[1])
+		) {
+			char *end;
+			unsigned long row, col;
+
+			row = strtoul(buffer + 1, &end, 10);
+			if (*end != ';' || !isdigit(end[1]))
+				continue;
+			col = strtoul(end + 1, &end, 10);
+			if (*end != 'R')
+				continue;
+			if (row < 1 || col < 1 || (row | col) > 0x7fff)
+				continue;
+
+			buffer[-1] = 0;
+			/* Pack into "1 <row15bits> <col16bits>" 32-bit sequence */
+			col |= (((-1 << 15) | row) << 16);
+			/* Return it in high-order word */
+			return ((int64_t) col << 32) | (uint32_t)KEYCODE_CURSOR_POS;
+		}
+	}
+ got_all:
+
+	if (n <= 1) {
+		/* Alt-x is usually returned as ESC x.
+		 * Report ESC, x is remembered for the next call.
+		 */
+		buffer[-1] = n;
+		return 27;
+	}
+
+	/* We were doing "buffer[-1] = n; return c;" here, but this results
+	 * in unknown key sequences being interpreted as ESC + garbage.
+	 * This was not useful. Pretend there was no key pressed,
+	 * go and wait for a new keypress:
+	 */
+	buffer[-1] = 0;
+	goto start_over;
+}
+
+void FAST_FUNC read_key_ungets(char *buffer, const char *str, unsigned len)
+{
+	unsigned cur_len = (unsigned char)buffer[0];
+	if (len > KEYCODE_BUFFER_SIZE-1 - cur_len)
+		len = KEYCODE_BUFFER_SIZE-1 - cur_len;
+	memcpy(buffer + 1 + cur_len, str, len);
+	buffer[0] += len;
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/safe_poll.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/safe_poll.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/safe_poll.c	(revision 279)
@@ -0,0 +1,34 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2007 by Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+/* Wrapper which restarts poll on EINTR or ENOMEM.
+ * On other errors does perror("poll") and returns.
+ * Warning! May take longer than timeout_ms to return! */
+int FAST_FUNC safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout)
+{
+	while (1) {
+		int n = poll(ufds, nfds, timeout);
+		if (n >= 0)
+			return n;
+		/* Make sure we inch towards completion */
+		if (timeout > 0)
+			timeout--;
+		/* E.g. strace causes poll to return this */
+		if (errno == EINTR)
+			continue;
+		/* Kernel is very low on memory. Retry. */
+		/* I doubt many callers would handle this correctly! */
+		if (errno == ENOMEM)
+			continue;
+		bb_perror_msg("poll");
+		return n;
+	}
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/safe_write.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/safe_write.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/safe_write.c	(revision 279)
@@ -0,0 +1,21 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+ssize_t FAST_FUNC safe_write(int fd, const void *buf, size_t count)
+{
+	ssize_t n;
+
+	do {
+		n = write(fd, buf, count);
+	} while (n < 0 && errno == EINTR);
+
+	return n;
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/skip_whitespace.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/skip_whitespace.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/skip_whitespace.c	(revision 279)
@@ -0,0 +1,39 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * skip_whitespace implementation for busybox
+ *
+ * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+#include "libbb.h"
+
+char* FAST_FUNC skip_whitespace(const char *s)
+{
+	/* In POSIX/C locale (the only locale we care about: do we REALLY want
+	 * to allow Unicode whitespace in, say, .conf files? nuts!)
+	 * isspace is only these chars: "\t\n\v\f\r" and space.
+	 * "\t\n\v\f\r" happen to have ASCII codes 9,10,11,12,13.
+	 * Use that.
+	 */
+	while (*s == ' ' || (unsigned char)(*s - 9) <= (13 - 9))
+		s++;
+
+	return (char *) s;
+}
+
+char* FAST_FUNC skip_non_whitespace(const char *s)
+{
+	while (*s != '\0' && *s != ' ' && (unsigned char)(*s - 9) > (13 - 9))
+		s++;
+
+	return (char *) s;
+}
+
+char* FAST_FUNC skip_dev_pfx(const char *tty_name)
+{
+	if (is_prefixed_with(tty_name, "/dev/"))
+		tty_name += 5;
+	return (char*)tty_name;
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/verror_msg.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/verror_msg.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/verror_msg.c	(revision 279)
@@ -0,0 +1,182 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+#include "libbb.h"
+#if ENABLE_FEATURE_SYSLOG
+# include <syslog.h>
+#endif
+
+#if ENABLE_FEATURE_SYSLOG
+smallint syslog_level = LOG_ERR;
+#endif
+smallint logmode = LOGMODE_STDIO;
+const char *msg_eol = "\n";
+
+void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr)
+{
+	char *msg, *msg1;
+	char stack_msg[80];
+	int applet_len, strerr_len, msgeol_len, used;
+
+	if (!logmode)
+		return;
+
+	if (!s) /* nomsg[_and_die] uses NULL fmt */
+		s = ""; /* some libc don't like printf(NULL) */
+
+	applet_len = strlen(applet_name) + 2; /* "applet: " */
+	strerr_len = strerr ? strlen(strerr) : 0;
+	msgeol_len = strlen(msg_eol);
+
+	/* This costs ~90 bytes of code, but avoids costly
+	 * malloc()[in vasprintf]+realloc()+memmove()+free() in 99% of cases.
+	 * ~40% speedup.
+	 */
+	if ((int)sizeof(stack_msg) - applet_len > 0) {
+		va_list p2;
+
+		/* It is not portable to use va_list twice, need to va_copy it */
+		va_copy(p2, p);
+		used = vsnprintf(stack_msg + applet_len, (int)sizeof(stack_msg) - applet_len, s, p2);
+		va_end(p2);
+		msg = stack_msg;
+		used += applet_len;
+		if (used < (int)sizeof(stack_msg) - 3 - msgeol_len - strerr_len)
+			goto add_pfx_and_sfx;
+	}
+
+	used = vasprintf(&msg, s, p);
+	if (used < 0)
+		return;
+
+	/* This is ugly and costs +60 bytes compared to multiple
+	 * fprintf's, but is guaranteed to do a single write.
+	 * This is needed for e.g. httpd logging, when multiple
+	 * children can produce log messages simultaneously. */
+
+	/* can't use xrealloc: it calls error_msg on failure,
+	 * that may result in a recursion */
+	/* +3 is for ": " before strerr and for terminating NUL */
+	msg1 = realloc(msg, applet_len + used + strerr_len + msgeol_len + 3);
+	if (!msg1) {
+		msg[used++] = '\n'; /* overwrites NUL */
+		applet_len = 0;
+	} else {
+		msg = msg1;
+		/* TODO: maybe use writev instead of memmoving? Need full_writev? */
+		memmove(msg + applet_len, msg, used);
+		used += applet_len;
+ add_pfx_and_sfx:
+		strcpy(msg, applet_name);
+		msg[applet_len - 2] = ':';
+		msg[applet_len - 1] = ' ';
+		if (strerr) {
+			if (s[0]) { /* not perror_nomsg? */
+				msg[used++] = ':';
+				msg[used++] = ' ';
+			}
+			strcpy(&msg[used], strerr);
+			used += strerr_len;
+		}
+		strcpy(&msg[used], msg_eol);
+		used += msgeol_len;
+	}
+
+	if (logmode & LOGMODE_STDIO) {
+		fflush_all();
+		full_write(STDERR_FILENO, msg, used);
+	}
+#if ENABLE_FEATURE_SYSLOG
+	if (logmode & LOGMODE_SYSLOG) {
+		syslog(syslog_level, "%s", msg + applet_len);
+	}
+#endif
+	if (msg != stack_msg)
+		free(msg);
+}
+
+#ifdef VERSION_WITH_WRITEV
+/* Code size is approximately the same, but currently it's the only user
+ * of writev in entire bbox. __libc_writev in uclibc is ~50 bytes. */
+void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr)
+{
+	int strerr_len, msgeol_len;
+	struct iovec iov[3];
+
+#define used   (iov[2].iov_len)
+#define msgv   (iov[2].iov_base)
+#define msgc   ((char*)(iov[2].iov_base))
+#define msgptr (&(iov[2].iov_base))
+
+	if (!logmode)
+		return;
+
+	if (!s) /* nomsg[_and_die] uses NULL fmt */
+		s = ""; /* some libc don't like printf(NULL) */
+
+	/* Prevent "derefing type-punned ptr will break aliasing rules" */
+	used = vasprintf((char**)(void*)msgptr, s, p);
+	if (used < 0)
+		return;
+
+	/* This is ugly and costs +60 bytes compared to multiple
+	 * fprintf's, but is guaranteed to do a single write.
+	 * This is needed for e.g. httpd logging, when multiple
+	 * children can produce log messages simultaneously. */
+
+	strerr_len = strerr ? strlen(strerr) : 0;
+	msgeol_len = strlen(msg_eol);
+	/* +3 is for ": " before strerr and for terminating NUL */
+	msgv = xrealloc(msgv, used + strerr_len + msgeol_len + 3);
+	if (strerr) {
+		msgc[used++] = ':';
+		msgc[used++] = ' ';
+		strcpy(msgc + used, strerr);
+		used += strerr_len;
+	}
+	strcpy(msgc + used, msg_eol);
+	used += msgeol_len;
+
+	if (logmode & LOGMODE_STDIO) {
+		iov[0].iov_base = (char*)applet_name;
+		iov[0].iov_len = strlen(applet_name);
+		iov[1].iov_base = (char*)": ";
+		iov[1].iov_len = 2;
+		/*iov[2].iov_base = msgc;*/
+		/*iov[2].iov_len = used;*/
+		fflush_all();
+		writev(STDERR_FILENO, iov, 3);
+	}
+# if ENABLE_FEATURE_SYSLOG
+	if (logmode & LOGMODE_SYSLOG) {
+		syslog(LOG_ERR, "%s", msgc);
+	}
+# endif
+	free(msgc);
+}
+#endif
+
+
+void FAST_FUNC bb_error_msg_and_die(const char *s, ...)
+{
+	va_list p;
+
+	va_start(p, s);
+	bb_verror_msg(s, p, NULL);
+	va_end(p);
+	xfunc_die();
+}
+
+void FAST_FUNC bb_error_msg(const char *s, ...)
+{
+	va_list p;
+
+	va_start(p, s);
+	bb_verror_msg(s, p, NULL);
+	va_end(p);
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/vi.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/vi.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/vi.c	(revision 279)
@@ -0,0 +1,4642 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * tiny vi.c: A small 'vi' clone
+ * Copyright (C) 2000, 2001 Sterling Huxley <sterling@europa.com>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+/*
+ * Things To Do:
+ *	EXINIT
+ *	$HOME/.exrc  and  ./.exrc
+ *	add magic to search	/foo.*bar
+ *	add :help command
+ *	:map macros
+ *	if mark[] values were line numbers rather than pointers
+ *      it would be easier to change the mark when add/delete lines
+ *	More intelligence in refresh()
+ *	":r !cmd"  and  "!cmd"  to filter text through an external command
+ *	An "ex" line oriented mode- maybe using "cmdedit"
+ */
+
+//config:config VI
+//config:	bool "vi"
+//config:	default y
+//config:	help
+//config:	  'vi' is a text editor. More specifically, it is the One True
+//config:	  text editor <grin>. It does, however, have a rather steep
+//config:	  learning curve. If you are not already comfortable with 'vi'
+//config:	  you may wish to use something else.
+//config:
+//config:config FEATURE_VI_MAX_LEN
+//config:	int "Maximum screen width in vi"
+//config:	range 256 16384
+//config:	default 4096
+//config:	depends on VI
+//config:	help
+//config:	  Contrary to what you may think, this is not eating much.
+//config:	  Make it smaller than 4k only if you are very limited on memory.
+//config:
+//config:config FEATURE_VI_8BIT
+//config:	bool "Allow vi to display 8-bit chars (otherwise shows dots)"
+//config:	default n
+//config:	depends on VI
+//config:	help
+//config:	  If your terminal can display characters with high bit set,
+//config:	  you may want to enable this. Note: vi is not Unicode-capable.
+//config:	  If your terminal combines several 8-bit bytes into one character
+//config:	  (as in Unicode mode), this will not work properly.
+//config:
+//config:config FEATURE_VI_COLON
+//config:	bool "Enable \":\" colon commands (no \"ex\" mode)"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Enable a limited set of colon commands for vi. This does not
+//config:	  provide an "ex" mode.
+//config:
+//config:config FEATURE_VI_YANKMARK
+//config:	bool "Enable yank/put commands and mark cmds"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  This will enable you to use yank and put, as well as mark in
+//config:	  busybox vi.
+//config:
+//config:config FEATURE_VI_SEARCH
+//config:	bool "Enable search and replace cmds"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Select this if you wish to be able to do search and replace in
+//config:	  busybox vi.
+//config:
+//config:config FEATURE_VI_REGEX_SEARCH
+//config:	bool "Enable regex in search and replace"
+//config:	default n   # Uses GNU regex, which may be unavailable. FIXME
+//config:	depends on FEATURE_VI_SEARCH
+//config:	help
+//config:	  Use extended regex search.
+//config:
+//config:config FEATURE_VI_USE_SIGNALS
+//config:	bool "Catch signals"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Selecting this option will make busybox vi signal aware. This will
+//config:	  make busybox vi support SIGWINCH to deal with Window Changes, catch
+//config:	  Ctrl-Z and Ctrl-C and alarms.
+//config:
+//config:config FEATURE_VI_DOT_CMD
+//config:	bool "Remember previous cmd and \".\" cmd"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Make busybox vi remember the last command and be able to repeat it.
+//config:
+//config:config FEATURE_VI_READONLY
+//config:	bool "Enable -R option and \"view\" mode"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Enable the read-only command line option, which allows the user to
+//config:	  open a file in read-only mode.
+//config:
+//config:config FEATURE_VI_SETOPTS
+//config:	bool "Enable set-able options, ai ic showmatch"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Enable the editor to set some (ai, ic, showmatch) options.
+//config:
+//config:config FEATURE_VI_SET
+//config:	bool "Support for :set"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Support for ":set".
+//config:
+//config:config FEATURE_VI_WIN_RESIZE
+//config:	bool "Handle window resize"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Make busybox vi behave nicely with terminals that get resized.
+//config:
+//config:config FEATURE_VI_ASK_TERMINAL
+//config:	bool "Use 'tell me cursor position' ESC sequence to measure window"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  If terminal size can't be retrieved and $LINES/$COLUMNS are not set,
+//config:	  this option makes vi perform a last-ditch effort to find it:
+//config:	  position cursor to 999,999 and ask terminal to report real
+//config:	  cursor position using "ESC [ 6 n" escape sequence, then read stdin.
+//config:
+//config:	  This is not clean but helps a lot on serial lines and such.
+//config:config FEATURE_VI_UNDO
+//config:	bool "Support undo command 'u'"
+//config:	default y
+//config:	depends on VI
+//config:	help
+//config:	  Support the 'u' command to undo insertion, deletion, and replacement
+//config:	  of text.
+//config:config FEATURE_VI_UNDO_QUEUE
+//config:	bool "Enable undo operation queuing"
+//config:	default y
+//config:	depends on FEATURE_VI_UNDO
+//config:	help
+//config:	  The vi undo functions can use an intermediate queue to greatly lower
+//config:	  malloc() calls and overhead. When the maximum size of this queue is
+//config:	  reached, the contents of the queue are committed to the undo stack.
+//config:	  This increases the size of the undo code and allows some undo
+//config:	  operations (especially un-typing/backspacing) to be far more useful.
+//config:config FEATURE_VI_UNDO_QUEUE_MAX
+//config:	int "Maximum undo character queue size"
+//config:	default 256
+//config:	range 32 65536
+//config:	depends on FEATURE_VI_UNDO_QUEUE
+//config:	help
+//config:	  This option sets the number of bytes used at runtime for the queue.
+//config:	  Smaller values will create more undo objects and reduce the amount
+//config:	  of typed or backspaced characters that are grouped into one undo
+//config:	  operation; larger values increase the potential size of each undo
+//config:	  and will generally malloc() larger objects and less frequently.
+//config:	  Unless you want more (or less) frequent "undo points" while typing,
+//config:	  you should probably leave this unchanged.
+
+//applet:IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_VI) += vi.o
+
+//usage:#define vi_trivial_usage
+//usage:       "[OPTIONS] [FILE]..."
+//usage:#define vi_full_usage "\n\n"
+//usage:       "Edit FILE\n"
+//usage:	IF_FEATURE_VI_COLON(
+//usage:     "\n	-c CMD	Initial command to run ($EXINIT also available)"
+//usage:	)
+//usage:	IF_FEATURE_VI_READONLY(
+//usage:     "\n	-R	Read-only"
+//usage:	)
+//usage:     "\n	-H	List available features"
+
+#include "libbb.h"
+/* Should be after libbb.h: on some systems regex.h needs sys/types.h: */
+#if ENABLE_FEATURE_VI_REGEX_SEARCH
+# include <regex.h>
+#endif
+
+/* the CRASHME code is unmaintained, and doesn't currently build */
+#define ENABLE_FEATURE_VI_CRASHME 0
+
+#define ENABLE_BASIC_MULTI_CHAR_CODE
+
+#if ENABLE_LOCALE_SUPPORT
+
+#if ENABLE_FEATURE_VI_8BIT
+//FIXME: this does not work properly for Unicode anyway
+# define Isprint(c) (isprint)(c)
+#else
+# define Isprint(c) isprint_asciionly(c)
+#endif
+
+#else
+
+/* 0x9b is Meta-ESC */
+#if ENABLE_FEATURE_VI_8BIT
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+# define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b)
+#else
+bool Isprint(unsigned char c)
+{
+	static int mbc_st = 0;
+
+	if (mbc_st == 0) {
+		if ((c & 0xE0) == 0xC0) { mbc_st = 2; }
+		else if ((c & 0xF0) == 0xE0) { mbc_st = 3; }
+		else if ((c & 0xF8) == 0xF0) { mbc_st = 4; }
+		else if ((c & 0xFC) == 0xF8) { mbc_st = 5; }
+		else if ((c & 0xFE) == 0xFC) { mbc_st = 6; }
+	}
+
+	if (mbc_st == 0) {
+		return ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b);
+	}
+
+	mbc_st--;
+	return true;
+}
+#endif
+#else
+# define Isprint(c) ((unsigned char)(c) >= ' ' && (unsigned char)(c) < 0x7f)
+#endif
+
+#endif
+
+
+enum {
+	MAX_TABSTOP = 32, // sanity limit
+	// User input len. Need not be extra big.
+	// Lines in file being edited *can* be bigger than this.
+	MAX_INPUT_LEN = 128,
+	// Sanity limits. We have only one buffer of this size.
+	MAX_SCR_COLS = CONFIG_FEATURE_VI_MAX_LEN,
+	MAX_SCR_ROWS = CONFIG_FEATURE_VI_MAX_LEN,
+};
+
+/* VT102 ESC sequences.
+ * See "Xterm Control Sequences"
+ * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+ */
+/* Inverse/Normal text */
+#define ESC_BOLD_TEXT "\033[7m"
+#define ESC_NORM_TEXT "\033[0m"
+/* Bell */
+#define ESC_BELL "\007"
+/* Clear-to-end-of-line */
+#define ESC_CLEAR2EOL "\033[K"
+/* Clear-to-end-of-screen.
+ * (We use default param here.
+ * Full sequence is "ESC [ <num> J",
+ * <num> is 0/1/2 = "erase below/above/all".)
+ */
+#define ESC_CLEAR2EOS "\033[J"
+/* Cursor to given coordinate (1,1: top left) */
+#define ESC_SET_CURSOR_POS "\033[%u;%uH"
+//UNUSED
+///* Cursor up and down */
+//#define ESC_CURSOR_UP "\033[A"
+//#define ESC_CURSOR_DOWN "\n"
+
+#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
+// cmds modifying text[]
+// vda: removed "aAiIs" as they switch us into insert mode
+// and remembering input for replay after them makes no sense
+static const char modifying_cmds[] ALIGN1 = "cCdDJoOpPrRxX<>~";
+#endif
+
+enum {
+	YANKONLY = FALSE,
+	YANKDEL = TRUE,
+	FORWARD = 1,	// code depends on "1"  for array index
+	BACK = -1,	// code depends on "-1" for array index
+	LIMITED = 0,	// how much of text[] in char_search
+	FULL = 1,	// how much of text[] in char_search
+
+	S_BEFORE_WS = 1,	// used in skip_thing() for moving "dot"
+	S_TO_WS = 2,		// used in skip_thing() for moving "dot"
+	S_OVER_WS = 3,		// used in skip_thing() for moving "dot"
+	S_END_PUNCT = 4,	// used in skip_thing() for moving "dot"
+	S_END_ALNUM = 5,	// used in skip_thing() for moving "dot"
+};
+
+
+/* vi.c expects chars to be unsigned. */
+/* busybox build system provides that, but it's better */
+/* to audit and fix the source */
+
+struct globals {
+	/* many references - keep near the top of globals */
+	char *text, *end;       // pointers to the user data in memory
+	char *dot;              // where all the action takes place
+	int text_size;		// size of the allocated buffer
+
+	/* the rest */
+	smallint vi_setops;
+#define VI_AUTOINDENT 1
+#define VI_SHOWMATCH  2
+#define VI_IGNORECASE 4
+#define VI_ERR_METHOD 8
+#define autoindent (vi_setops & VI_AUTOINDENT)
+#define showmatch  (vi_setops & VI_SHOWMATCH )
+#define ignorecase (vi_setops & VI_IGNORECASE)
+/* indicate error with beep or flash */
+#define err_method (vi_setops & VI_ERR_METHOD)
+
+#if ENABLE_FEATURE_VI_READONLY
+	smallint readonly_mode;
+#define SET_READONLY_FILE(flags)        ((flags) |= 0x01)
+#define SET_READONLY_MODE(flags)        ((flags) |= 0x02)
+#define UNSET_READONLY_FILE(flags)      ((flags) &= 0xfe)
+#else
+#define SET_READONLY_FILE(flags)        ((void)0)
+#define SET_READONLY_MODE(flags)        ((void)0)
+#define UNSET_READONLY_FILE(flags)      ((void)0)
+#endif
+
+	smallint editing;        // >0 while we are editing a file
+	                         // [code audit says "can be 0, 1 or 2 only"]
+	smallint cmd_mode;       // 0=command  1=insert 2=replace
+	int modified_count;      // buffer contents changed if !0
+	int last_modified_count; // = -1;
+	int save_argc;           // how many file names on cmd line
+	int cmdcnt;              // repetition count
+	unsigned rows, columns;	 // the terminal screen is this size
+#if ENABLE_FEATURE_VI_ASK_TERMINAL
+	int get_rowcol_error;
+#endif
+	int crow, ccol;          // cursor is on Crow x Ccol
+	int offset;              // chars scrolled off the screen to the left
+	int have_status_msg;     // is default edit status needed?
+	                         // [don't make smallint!]
+	int last_status_cksum;   // hash of current status line
+	char *current_filename;
+	char *screenbegin;       // index into text[], of top line on the screen
+	char *screen;            // pointer to the virtual screen buffer
+	int screensize;          //            and its size
+	int tabstop;
+	int last_forward_char;   // last char searched for with 'f' (int because of Unicode)
+	char erase_char;         // the users erase character
+	char last_input_char;    // last char read from user
+
+#if ENABLE_FEATURE_VI_DOT_CMD
+	smallint adding2q;	 // are we currently adding user input to q
+	int lmc_len;             // length of last_modifying_cmd
+	char *ioq, *ioq_start;   // pointer to string for get_one_char to "read"
+#endif
+#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
+	int my_pid;
+#endif
+#if ENABLE_FEATURE_VI_SEARCH
+	char *last_search_pattern; // last pattern from a '/' or '?' search
+#endif
+
+	/* former statics */
+#if ENABLE_FEATURE_VI_YANKMARK
+	char *edit_file__cur_line;
+#endif
+	int refresh__old_offset;
+	int format_edit_status__tot;
+
+	/* a few references only */
+#if ENABLE_FEATURE_VI_YANKMARK
+	int YDreg, Ureg;        // default delete register and orig line for "U"
+	char *reg[28];          // named register a-z, "D", and "U" 0-25,26,27
+	char *mark[28];         // user marks points somewhere in text[]-  a-z and previous context ''
+	char *context_start, *context_end;
+#endif
+#if ENABLE_FEATURE_VI_USE_SIGNALS
+	sigjmp_buf restart;     // catch_sig()
+#endif
+	struct termios term_orig, term_vi; // remember what the cooked mode was
+#if ENABLE_FEATURE_VI_COLON
+	char *initial_cmds[3];  // currently 2 entries, NULL terminated
+#endif
+	// Should be just enough to hold a key sequence,
+	// but CRASHME mode uses it as generated command buffer too
+#if ENABLE_FEATURE_VI_CRASHME
+	char readbuffer[128];
+#else
+	char readbuffer[KEYCODE_BUFFER_SIZE];
+#endif
+#define STATUS_BUFFER_LEN  200
+	char status_buffer[STATUS_BUFFER_LEN]; // messages to the user
+#if ENABLE_FEATURE_VI_DOT_CMD
+	char last_modifying_cmd[MAX_INPUT_LEN];	// last modifying cmd for "."
+#endif
+	char get_input_line__buf[MAX_INPUT_LEN]; /* former static */
+
+	char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2];
+#if ENABLE_FEATURE_VI_UNDO
+// undo_push() operations
+#define UNDO_INS         0
+#define UNDO_DEL         1
+#define UNDO_INS_CHAIN   2
+#define UNDO_DEL_CHAIN   3
+// UNDO_*_QUEUED must be equal to UNDO_xxx ORed with UNDO_QUEUED_FLAG
+#define UNDO_QUEUED_FLAG 4
+#define UNDO_INS_QUEUED  4
+#define UNDO_DEL_QUEUED  5
+#define UNDO_USE_SPOS   32
+#define UNDO_EMPTY      64
+// Pass-through flags for functions that can be undone
+#define NO_UNDO          0
+#define ALLOW_UNDO       1
+#define ALLOW_UNDO_CHAIN 2
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+#define ALLOW_UNDO_QUEUED 3
+	char undo_queue_state;
+	int undo_q;
+	char *undo_queue_spos;	// Start position of queued operation
+	char undo_queue[CONFIG_FEATURE_VI_UNDO_QUEUE_MAX];
+# else
+// If undo queuing disabled, don't invoke the missing queue logic
+#define ALLOW_UNDO_QUEUED 1
+# endif
+
+	struct undo_object {
+		struct undo_object *prev;	// Linking back avoids list traversal (LIFO)
+		int start;		// Offset where the data should be restored/deleted
+		int length;		// total data size
+		uint8_t u_type;		// 0=deleted, 1=inserted, 2=swapped
+		char undo_text[1];	// text that was deleted (if deletion)
+	} *undo_stack_tail;
+#endif /* ENABLE_FEATURE_VI_UNDO */
+};
+#define G (*ptr_to_globals)
+#define text           (G.text          )
+#define text_size      (G.text_size     )
+#define end            (G.end           )
+#define dot            (G.dot           )
+#define reg            (G.reg           )
+
+#define vi_setops               (G.vi_setops          )
+#define editing                 (G.editing            )
+#define cmd_mode                (G.cmd_mode           )
+#define modified_count          (G.modified_count     )
+#define last_modified_count     (G.last_modified_count)
+#define save_argc               (G.save_argc          )
+#define cmdcnt                  (G.cmdcnt             )
+#define rows                    (G.rows               )
+#define columns                 (G.columns            )
+#define crow                    (G.crow               )
+#define ccol                    (G.ccol               )
+#define offset                  (G.offset             )
+#define status_buffer           (G.status_buffer      )
+#define have_status_msg         (G.have_status_msg    )
+#define last_status_cksum       (G.last_status_cksum  )
+#define current_filename        (G.current_filename   )
+#define screen                  (G.screen             )
+#define screensize              (G.screensize         )
+#define screenbegin             (G.screenbegin        )
+#define tabstop                 (G.tabstop            )
+#define last_forward_char       (G.last_forward_char  )
+#define erase_char              (G.erase_char         )
+#define last_input_char         (G.last_input_char    )
+#if ENABLE_FEATURE_VI_READONLY
+#define readonly_mode           (G.readonly_mode      )
+#else
+#define readonly_mode           0
+#endif
+#define adding2q                (G.adding2q           )
+#define lmc_len                 (G.lmc_len            )
+#define ioq                     (G.ioq                )
+#define ioq_start               (G.ioq_start          )
+#define my_pid                  (G.my_pid             )
+#define last_search_pattern     (G.last_search_pattern)
+
+#define edit_file__cur_line     (G.edit_file__cur_line)
+#define refresh__old_offset     (G.refresh__old_offset)
+#define format_edit_status__tot (G.format_edit_status__tot)
+
+#define YDreg          (G.YDreg         )
+#define Ureg           (G.Ureg          )
+#define mark           (G.mark          )
+#define context_start  (G.context_start )
+#define context_end    (G.context_end   )
+#define restart        (G.restart       )
+#define term_orig      (G.term_orig     )
+#define term_vi        (G.term_vi       )
+#define initial_cmds   (G.initial_cmds  )
+#define readbuffer     (G.readbuffer    )
+#define scr_out_buf    (G.scr_out_buf   )
+#define last_modifying_cmd  (G.last_modifying_cmd )
+#define get_input_line__buf (G.get_input_line__buf)
+
+#if ENABLE_FEATURE_VI_UNDO
+#define undo_stack_tail  (G.undo_stack_tail )
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+#define undo_queue_state (G.undo_queue_state)
+#define undo_q           (G.undo_q          )
+#define undo_queue       (G.undo_queue      )
+#define undo_queue_spos  (G.undo_queue_spos )
+# endif
+#endif
+
+#define INIT_G() do { \
+	SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+	last_modified_count = -1; \
+	/* "" but has space for 2 chars: */ \
+	IF_FEATURE_VI_SEARCH(last_search_pattern = xzalloc(2);) \
+} while (0)
+
+
+static void edit_file(char *);	// edit one file
+static void do_cmd(int);	// execute a command
+static int next_tabstop(int);
+static void sync_cursor(char *, int *, int *);	// synchronize the screen cursor to dot
+static char *begin_line(char *);	// return pointer to cur line B-o-l
+static char *end_line(char *);	// return pointer to cur line E-o-l
+static char *prev_line(char *);	// return pointer to prev line B-o-l
+static char *next_line(char *);	// return pointer to next line B-o-l
+static char *end_screen(void);	// get pointer to last char on screen
+static int count_lines(char *, char *);	// count line from start to stop
+static char *find_line(int);	// find beginning of line #li
+static char *move_to_col(char *, int);	// move "p" to column l
+static void dot_left(void);	// move dot left- dont leave line
+static void dot_right(void);	// move dot right- dont leave line
+static void dot_begin(void);	// move dot to B-o-l
+static void dot_end(void);	// move dot to E-o-l
+static void dot_next(void);	// move dot to next line B-o-l
+static void dot_prev(void);	// move dot to prev line B-o-l
+static void dot_scroll(int, int);	// move the screen up or down
+static void dot_skip_over_ws(void);	// move dot pat WS
+static char *bound_dot(char *);	// make sure  text[0] <= P < "end"
+static char *new_screen(int, int);	// malloc virtual screen memory
+#if !ENABLE_FEATURE_VI_UNDO
+#define char_insert(a,b,c) char_insert(a,b)
+#endif
+static char *char_insert(char *, char, int);	// insert the char c at 'p'
+// might reallocate text[]! use p += stupid_insert(p, ...),
+// and be careful to not use pointers into potentially freed text[]!
+static uintptr_t stupid_insert(char *, char);	// stupidly insert the char c at 'p'
+static int find_range(char **, char **, char);	// return pointers for an object
+static int st_test(char *, int, int, char *);	// helper for skip_thing()
+static char *skip_thing(char *, int, int, int);	// skip some object
+static char *find_pair(char *, const char);	// find matching pair ()  []  {}
+#if !ENABLE_FEATURE_VI_UNDO
+#define text_hole_delete(a,b,c) text_hole_delete(a,b)
+#endif
+static char *text_hole_delete(char *, char *, int);	// at "p", delete a 'size' byte hole
+// might reallocate text[]! use p += text_hole_make(p, ...),
+// and be careful to not use pointers into potentially freed text[]!
+static uintptr_t text_hole_make(char *, int);	// at "p", make a 'size' byte hole
+#if !ENABLE_FEATURE_VI_UNDO
+#define yank_delete(a,b,c,d,e) yank_delete(a,b,c,d)
+#endif
+static char *yank_delete(char *, char *, int, int, int);	// yank text[] into register then delete
+static void show_help(void);	// display some help info
+static void rawmode(void);	// set "raw" mode on tty
+static void cookmode(void);	// return to "cooked" mode on tty
+// sleep for 'h' 1/100 seconds, return 1/0 if stdin is (ready for read)/(not ready)
+static int mysleep(int);
+static int readit(void);	// read (maybe cursor) key from stdin
+static int get_one_char(void);	// read 1 char from stdin
+// file_insert might reallocate text[]!
+static int file_insert(const char *, char *, int);
+static int file_write(char *, char *, char *);
+static void place_cursor(int, int);
+static void screen_erase(void);
+static void clear_to_eol(void);
+static void clear_to_eos(void);
+static void go_bottom_and_clear_to_eol(void);
+static void standout_start(void);	// send "start reverse video" sequence
+static void standout_end(void);	// send "end reverse video" sequence
+static void flash(int);		// flash the terminal screen
+static void show_status_line(void);	// put a message on the bottom line
+static void status_line(const char *, ...);     // print to status buf
+static void status_line_bold(const char *, ...);
+static void status_line_bold_errno(const char *fn);
+static void not_implemented(const char *); // display "Not implemented" message
+static int format_edit_status(void);	// format file status on status line
+static void redraw(int);	// force a full screen refresh
+static char* format_line(char* /*, int*/);
+static void refresh(int);	// update the terminal from screen[]
+
+static void indicate_error(void);       // use flash or beep to indicate error
+static void Hit_Return(void);
+
+#if ENABLE_FEATURE_VI_SEARCH
+static char *char_search(char *, const char *, int, int);	// search for pattern starting at p
+#endif
+#if ENABLE_FEATURE_VI_COLON
+static char *get_one_address(char *, int *);	// get colon addr, if present
+static char *get_address(char *, int *, int *);	// get two colon addrs, if present
+#endif
+static void colon(char *);	// execute the "colon" mode cmds
+#if ENABLE_FEATURE_VI_USE_SIGNALS
+static void winch_sig(int);	// catch window size changes
+static void suspend_sig(int);	// catch ctrl-Z
+static void catch_sig(int);     // catch ctrl-C and alarm time-outs
+#endif
+#if ENABLE_FEATURE_VI_DOT_CMD
+static void start_new_cmd_q(char);	// new queue for command
+static void end_cmd_q(void);	// stop saving input chars
+#else
+#define end_cmd_q() ((void)0)
+#endif
+#if ENABLE_FEATURE_VI_SETOPTS
+static void showmatching(char *);	// show the matching pair ()  []  {}
+#endif
+#if ENABLE_FEATURE_VI_YANKMARK || (ENABLE_FEATURE_VI_COLON && ENABLE_FEATURE_VI_SEARCH) || ENABLE_FEATURE_VI_CRASHME
+// might reallocate text[]! use p += string_insert(p, ...),
+// and be careful to not use pointers into potentially freed text[]!
+# if !ENABLE_FEATURE_VI_UNDO
+#define string_insert(a,b,c) string_insert(a,b)
+# endif
+static uintptr_t string_insert(char *, const char *, int);	// insert the string at 'p'
+#endif
+#if ENABLE_FEATURE_VI_YANKMARK
+static char *text_yank(char *, char *, int);	// save copy of "p" into a register
+static char what_reg(void);		// what is letter of current YDreg
+static void check_context(char);	// remember context for '' command
+#endif
+#if ENABLE_FEATURE_VI_UNDO
+static void flush_undo_data(void);
+static void undo_push(char *, unsigned int, unsigned char);	// Push an operation on the undo stack
+static void undo_pop(void);	// Undo the last operation
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+static void undo_queue_commit(void);	// Flush any queued objects to the undo stack
+# else
+# define undo_queue_commit() ((void)0)
+# endif
+#else
+#define flush_undo_data()   ((void)0)
+#define undo_queue_commit() ((void)0)
+#endif
+
+#if ENABLE_FEATURE_VI_CRASHME
+static void crash_dummy();
+static void crash_test();
+static int crashme = 0;
+#endif
+
+#ifdef ENABLE_BASIC_MULTI_CHAR_CODE
+extern unsigned int Utf8_to_Utf16(const char *src, int *code_size);
+extern int bs_char_count(char *str, int pos);
+#endif
+
+static void write1(const char *out)
+{
+	fputs(out, stdout);
+}
+
+int vi_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int vi_main(int argc, char **argv)
+{
+	int c;
+
+	INIT_G();
+
+#if ENABLE_FEATURE_VI_UNDO
+	/* undo_stack_tail = NULL; - already is */
+#if ENABLE_FEATURE_VI_UNDO_QUEUE
+	undo_queue_state = UNDO_EMPTY;
+	/* undo_q = 0; - already is  */
+#endif
+#endif
+
+#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
+	my_pid = getpid();
+#endif
+#if ENABLE_FEATURE_VI_CRASHME
+	srand((long) my_pid);
+#endif
+#ifdef NO_SUCH_APPLET_YET
+	/* If we aren't "vi", we are "view" */
+	if (ENABLE_FEATURE_VI_READONLY && applet_name[2]) {
+		SET_READONLY_MODE(readonly_mode);
+	}
+#endif
+
+	// autoindent is not default in vim 7.3
+	vi_setops = /*VI_AUTOINDENT |*/ VI_SHOWMATCH | VI_IGNORECASE;
+	//  1-  process $HOME/.exrc file (not inplemented yet)
+	//  2-  process EXINIT variable from environment
+	//  3-  process command line args
+#if ENABLE_FEATURE_VI_COLON
+	{
+		char *p = getenv("EXINIT");
+		if (p && *p)
+			initial_cmds[0] = xstrndup(p, MAX_INPUT_LEN);
+	}
+#endif
+	while ((c = getopt(argc, argv, "hCRH" IF_FEATURE_VI_COLON("c:"))) != -1) {
+		switch (c) {
+#if ENABLE_FEATURE_VI_CRASHME
+		case 'C':
+			crashme = 1;
+			break;
+#endif
+#if ENABLE_FEATURE_VI_READONLY
+		case 'R':		// Read-only flag
+			SET_READONLY_MODE(readonly_mode);
+			break;
+#endif
+#if ENABLE_FEATURE_VI_COLON
+		case 'c':		// cmd line vi command
+			if (*optarg)
+				initial_cmds[initial_cmds[0] != NULL] = xstrndup(optarg, MAX_INPUT_LEN);
+			break;
+#endif
+		case 'H':
+			show_help();
+			/* fall through */
+		default:
+			bb_show_usage();
+			return 1;
+		}
+	}
+
+	// The argv array can be used by the ":next"  and ":rewind" commands
+	argv += optind;
+	argc -= optind;
+
+	//----- This is the main file handling loop --------------
+	save_argc = argc;
+	optind = 0;
+	// "Save cursor, use alternate screen buffer, clear screen"
+	write1("\033[?1049h");
+	while (1) {
+		edit_file(argv[optind]); /* param might be NULL */
+		if (++optind >= argc)
+			break;
+	}
+	// "Use normal screen buffer, restore cursor"
+	write1("\033[?1049l");
+	//-----------------------------------------------------------
+
+	return 0;
+}
+
+/* read text from file or create an empty buf */
+/* will also update current_filename */
+static int init_text_buffer(char *fn)
+{
+	int rc;
+
+	flush_undo_data();
+	modified_count = 0;
+	last_modified_count = -1;
+#if ENABLE_FEATURE_VI_YANKMARK
+	/* init the marks */
+	memset(mark, 0, sizeof(mark));
+#endif
+
+	/* allocate/reallocate text buffer */
+	free(text);
+	text_size = 10240;
+	screenbegin = dot = end = text = xzalloc(text_size);
+
+	if (fn != current_filename) {
+		free(current_filename);
+		current_filename = xstrdup(fn);
+	}
+	rc = file_insert(fn, text, 1);
+	if (rc < 0) {
+		// file doesnt exist. Start empty buf with dummy line
+		char_insert(text, '\n', NO_UNDO);
+	}
+	return rc;
+}
+
+#if ENABLE_FEATURE_VI_WIN_RESIZE
+static int query_screen_dimensions(void)
+{
+	int err = get_terminal_width_height(STDIN_FILENO, &columns, &rows);
+	if (rows > MAX_SCR_ROWS)
+		rows = MAX_SCR_ROWS;
+	if (columns > MAX_SCR_COLS)
+		columns = MAX_SCR_COLS;
+	return err;
+}
+#else
+# define query_screen_dimensions() (0)
+#endif
+
+static void edit_file(char *fn)
+{
+#if ENABLE_FEATURE_VI_YANKMARK
+#define cur_line edit_file__cur_line
+#endif
+	int c;
+#if ENABLE_FEATURE_VI_USE_SIGNALS
+	int sig;
+#endif
+
+	editing = 1;	// 0 = exit, 1 = one file, 2 = multiple files
+	rawmode();
+	rows = 24;
+	columns = 80;
+	IF_FEATURE_VI_ASK_TERMINAL(G.get_rowcol_error =) query_screen_dimensions();
+#if ENABLE_FEATURE_VI_ASK_TERMINAL
+	if (G.get_rowcol_error /* TODO? && no input on stdin */) {
+		uint64_t k;
+		write1("\033[999;999H" "\033[6n");
+		fflush_all();
+		k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100);
+		if ((int32_t)k == KEYCODE_CURSOR_POS) {
+			uint32_t rc = (k >> 32);
+			columns = (rc & 0x7fff);
+			if (columns > MAX_SCR_COLS)
+				columns = MAX_SCR_COLS;
+			rows = ((rc >> 16) & 0x7fff);
+			if (rows > MAX_SCR_ROWS)
+				rows = MAX_SCR_ROWS;
+		}
+	}
+#endif
+	new_screen(rows, columns);	// get memory for virtual screen
+	init_text_buffer(fn);
+
+#if ENABLE_FEATURE_VI_YANKMARK
+	YDreg = 26;			// default Yank/Delete reg
+	Ureg = 27;			// hold orig line for "U" cmd
+	mark[26] = mark[27] = text;	// init "previous context"
+#endif
+
+	last_forward_char = last_input_char = '\0';
+	crow = 0;
+	ccol = 0;
+
+#if ENABLE_FEATURE_VI_USE_SIGNALS
+	signal(SIGINT, catch_sig);
+	signal(SIGWINCH, winch_sig);
+	signal(SIGTSTP, suspend_sig);
+	sig = sigsetjmp(restart, 1);
+	if (sig != 0) {
+		screenbegin = dot = text;
+	}
+#endif
+
+	cmd_mode = 0;		// 0=command  1=insert  2='R'eplace
+	cmdcnt = 0;
+	tabstop = 8;
+	offset = 0;			// no horizontal offset
+	c = '\0';
+#if ENABLE_FEATURE_VI_DOT_CMD
+	free(ioq_start);
+	ioq = ioq_start = NULL;
+	lmc_len = 0;
+	adding2q = 0;
+#endif
+
+#if ENABLE_FEATURE_VI_COLON
+	{
+		char *p, *q;
+		int n = 0;
+
+		while ((p = initial_cmds[n]) != NULL) {
+			do {
+				q = p;
+				p = strchr(q, '\n');
+				if (p)
+					while (*p == '\n')
+						*p++ = '\0';
+				if (*q)
+					colon(q);
+			} while (p);
+			free(initial_cmds[n]);
+			initial_cmds[n] = NULL;
+			n++;
+		}
+	}
+#endif
+	redraw(FALSE);			// dont force every col re-draw
+	//------This is the main Vi cmd handling loop -----------------------
+	while (editing > 0) {
+#if ENABLE_FEATURE_VI_CRASHME
+		if (crashme > 0) {
+			if ((end - text) > 1) {
+				crash_dummy();	// generate a random command
+			} else {
+				crashme = 0;
+				string_insert(text, "\n\n#####  Ran out of text to work on.  #####\n\n", NO_UNDO); // insert the string
+				dot = text;
+				refresh(FALSE);
+			}
+		}
+#endif
+		last_input_char = c = get_one_char();	// get a cmd from user
+#if ENABLE_FEATURE_VI_YANKMARK
+		// save a copy of the current line- for the 'U" command
+		if (begin_line(dot) != cur_line) {
+			cur_line = begin_line(dot);
+			text_yank(begin_line(dot), end_line(dot), Ureg);
+		}
+#endif
+#if ENABLE_FEATURE_VI_DOT_CMD
+		// These are commands that change text[].
+		// Remember the input for the "." command
+		if (!adding2q && ioq_start == NULL
+		 && cmd_mode == 0 // command mode
+		 && c > '\0' // exclude NUL and non-ASCII chars
+		 && c < 0x7f // (Unicode and such)
+		 && strchr(modifying_cmds, c)
+		) {
+			start_new_cmd_q(c);
+		}
+#endif
+		do_cmd(c);		// execute the user command
+
+		// poll to see if there is input already waiting. if we are
+		// not able to display output fast enough to keep up, skip
+		// the display update until we catch up with input.
+		if (!readbuffer[0] && mysleep(0) == 0) {
+			// no input pending - so update output
+			refresh(FALSE);
+			show_status_line();
+		}
+#if ENABLE_FEATURE_VI_CRASHME
+		if (crashme > 0)
+			crash_test();	// test editor variables
+#endif
+	}
+	//-------------------------------------------------------------------
+
+	go_bottom_and_clear_to_eol();
+	cookmode();
+#undef cur_line
+}
+
+//----- The Colon commands -------------------------------------
+#if ENABLE_FEATURE_VI_COLON
+static char *get_one_address(char *p, int *addr)	// get colon addr, if present
+{
+	int st;
+	char *q;
+	IF_FEATURE_VI_YANKMARK(char c;)
+	IF_FEATURE_VI_SEARCH(char *pat;)
+
+	*addr = -1;			// assume no addr
+	if (*p == '.') {	// the current line
+		p++;
+		q = begin_line(dot);
+		*addr = count_lines(text, q);
+	}
+#if ENABLE_FEATURE_VI_YANKMARK
+	else if (*p == '\'') {	// is this a mark addr
+		p++;
+		c = tolower(*p);
+		p++;
+		if (c >= 'a' && c <= 'z') {
+			// we have a mark
+			c = c - 'a';
+			q = mark[(unsigned char) c];
+			if (q != NULL) {	// is mark valid
+				*addr = count_lines(text, q);
+			}
+		}
+	}
+#endif
+#if ENABLE_FEATURE_VI_SEARCH
+	else if (*p == '/') {	// a search pattern
+		q = strchrnul(++p, '/');
+		pat = xstrndup(p, q - p); // save copy of pattern
+		p = q;
+		if (*p == '/')
+			p++;
+		q = char_search(dot, pat, FORWARD, FULL);
+		if (q != NULL) {
+			*addr = count_lines(text, q);
+		}
+		free(pat);
+	}
+#endif
+	else if (*p == '$') {	// the last line in file
+		p++;
+		q = begin_line(end - 1);
+		*addr = count_lines(text, q);
+	} else if (isdigit(*p)) {	// specific line number
+		sscanf(p, "%d%n", addr, &st);
+		p += st;
+	} else {
+		// unrecognized address - assume -1
+		*addr = -1;
+	}
+	return p;
+}
+
+static char *get_address(char *p, int *b, int *e)	// get two colon addrs, if present
+{
+	//----- get the address' i.e., 1,3   'a,'b  -----
+	// get FIRST addr, if present
+	while (isblank(*p))
+		p++;				// skip over leading spaces
+	if (*p == '%') {			// alias for 1,$
+		p++;
+		*b = 1;
+		*e = count_lines(text, end-1);
+		goto ga0;
+	}
+	p = get_one_address(p, b);
+	while (isblank(*p))
+		p++;
+	if (*p == ',') {			// is there a address separator
+		p++;
+		while (isblank(*p))
+			p++;
+		// get SECOND addr, if present
+		p = get_one_address(p, e);
+	}
+ ga0:
+	while (isblank(*p))
+		p++;				// skip over trailing spaces
+	return p;
+}
+
+#if ENABLE_FEATURE_VI_SET && ENABLE_FEATURE_VI_SETOPTS
+static void setops(const char *args, const char *opname, int flg_no,
+			const char *short_opname, int opt)
+{
+	const char *a = args + flg_no;
+	int l = strlen(opname) - 1; /* opname have + ' ' */
+
+	// maybe strncmp? we had tons of erroneous strncasecmp's...
+	if (strncasecmp(a, opname, l) == 0
+	 || strncasecmp(a, short_opname, 2) == 0
+	) {
+		if (flg_no)
+			vi_setops &= ~opt;
+		else
+			vi_setops |= opt;
+	}
+}
+#endif
+
+#endif /* FEATURE_VI_COLON */
+
+// buf must be no longer than MAX_INPUT_LEN!
+static void colon(char *buf)
+{
+#if !ENABLE_FEATURE_VI_COLON
+	/* Simple ":cmd" handler with minimal set of commands */
+	char *p = buf;
+	int cnt;
+
+	if (*p == ':')
+		p++;
+	cnt = strlen(p);
+	if (cnt == 0)
+		return;
+	if (strncmp(p, "quit", cnt) == 0
+	 || strncmp(p, "q!", cnt) == 0
+	) {
+		if (modified_count && p[1] != '!') {
+			status_line_bold("No write since last change (:%s! overrides)", p);
+		} else {
+			editing = 0;
+		}
+		return;
+	}
+	if (strncmp(p, "write", cnt) == 0
+	 || strncmp(p, "wq", cnt) == 0
+	 || strncmp(p, "wn", cnt) == 0
+	 || (p[0] == 'x' && !p[1])
+	) {
+		cnt = file_write(current_filename, text, end - 1);
+		if (cnt < 0) {
+			if (cnt == -1)
+				status_line_bold("Write error: %s", strerror(errno));
+		} else {
+			modified_count = 0;
+			last_modified_count = -1;
+			status_line("'%s' %dL, %dC",
+				current_filename,
+				count_lines(text, end - 1), cnt
+			);
+			if (p[0] == 'x' || p[1] == 'q' || p[1] == 'n'
+			 || p[0] == 'X' || p[1] == 'Q' || p[1] == 'N'
+			) {
+				editing = 0;
+			}
+		}
+		return;
+	}
+	if (strncmp(p, "file", cnt) == 0) {
+		last_status_cksum = 0;	// force status update
+		return;
+	}
+	if (sscanf(p, "%d", &cnt) > 0) {
+		dot = find_line(cnt);
+		dot_skip_over_ws();
+		return;
+	}
+	not_implemented(p);
+#else
+
+	char c, *orig_buf, *buf1, *q, *r;
+	char *fn, cmd[MAX_INPUT_LEN], args[MAX_INPUT_LEN];
+	int i, l, li, b, e;
+	int useforce;
+
+	// :3154	// if (-e line 3154) goto it  else stay put
+	// :4,33w! foo	// write a portion of buffer to file "foo"
+	// :w		// write all of buffer to current file
+	// :q		// quit
+	// :q!		// quit- dont care about modified file
+	// :'a,'z!sort -u   // filter block through sort
+	// :'f		// goto mark "f"
+	// :'fl		// list literal the mark "f" line
+	// :.r bar	// read file "bar" into buffer before dot
+	// :/123/,/abc/d    // delete lines from "123" line to "abc" line
+	// :/xyz/	// goto the "xyz" line
+	// :s/find/replace/ // substitute pattern "find" with "replace"
+	// :!<cmd>	// run <cmd> then return
+	//
+
+	if (!buf[0])
+		goto ret;
+	if (*buf == ':')
+		buf++;			// move past the ':'
+
+	li = i = 0;
+	b = e = -1;
+	q = text;			// assume 1,$ for the range
+	r = end - 1;
+	li = count_lines(text, end - 1);
+	fn = current_filename;
+
+	// look for optional address(es)  :.  :1  :1,9   :'q,'a   :%
+	buf = get_address(buf, &b, &e);
+
+	// remember orig command line
+	orig_buf = buf;
+
+	// get the COMMAND into cmd[]
+	buf1 = cmd;
+	while (*buf != '\0') {
+		if (isspace(*buf))
+			break;
+		*buf1++ = *buf++;
+	}
+	*buf1 = '\0';
+	// get any ARGuments
+	while (isblank(*buf))
+		buf++;
+	strcpy(args, buf);
+	useforce = FALSE;
+	buf1 = last_char_is(cmd, '!');
+	if (buf1) {
+		useforce = TRUE;
+		*buf1 = '\0';   // get rid of !
+	}
+	if (b >= 0) {
+		// if there is only one addr, then the addr
+		// is the line number of the single line the
+		// user wants. So, reset the end
+		// pointer to point at end of the "b" line
+		q = find_line(b);	// what line is #b
+		r = end_line(q);
+		li = 1;
+	}
+	if (e >= 0) {
+		// we were given two addrs.  change the
+		// end pointer to the addr given by user.
+		r = find_line(e);	// what line is #e
+		r = end_line(r);
+		li = e - b + 1;
+	}
+	// ------------ now look for the command ------------
+	i = strlen(cmd);
+	if (i == 0) {		// :123CR goto line #123
+		if (b >= 0) {
+			dot = find_line(b);	// what line is #b
+			dot_skip_over_ws();
+		}
+	}
+#if ENABLE_FEATURE_ALLOW_EXEC
+	else if (cmd[0] == '!') {	// run a cmd
+		int retcode;
+		// :!ls   run the <cmd>
+		go_bottom_and_clear_to_eol();
+		cookmode();
+		retcode = system(orig_buf + 1);	// run the cmd
+		if (retcode)
+			printf("\nshell returned %i\n\n", retcode);
+		rawmode();
+		Hit_Return();			// let user see results
+	}
+#endif
+	else if (cmd[0] == '=' && !cmd[1]) {	// where is the address
+		if (b < 0) {	// no addr given- use defaults
+			b = e = count_lines(text, dot);
+		}
+		status_line("%d", b);
+	} else if (strncmp(cmd, "delete", i) == 0) {	// delete lines
+		if (b < 0) {	// no addr given- use defaults
+			q = begin_line(dot);	// assume .,. for the range
+			r = end_line(dot);
+		}
+		dot = yank_delete(q, r, 1, YANKDEL, ALLOW_UNDO);	// save, then delete lines
+		dot_skip_over_ws();
+	} else if (strncmp(cmd, "edit", i) == 0) {	// Edit a file
+		int size;
+
+		// don't edit, if the current file has been modified
+		if (modified_count && !useforce) {
+			status_line_bold("No write since last change (:%s! overrides)", cmd);
+			goto ret;
+		}
+		if (args[0]) {
+			// the user supplied a file name
+			fn = args;
+		} else if (current_filename && current_filename[0]) {
+			// no user supplied name- use the current filename
+			// fn = current_filename;  was set by default
+		} else {
+			// no user file name, no current name- punt
+			status_line_bold("No current filename");
+			goto ret;
+		}
+
+		size = init_text_buffer(fn);
+
+#if ENABLE_FEATURE_VI_YANKMARK
+		if (Ureg >= 0 && Ureg < 28) {
+			free(reg[Ureg]);	//   free orig line reg- for 'U'
+			reg[Ureg] = NULL;
+		}
+		if (YDreg >= 0 && YDreg < 28) {
+			free(reg[YDreg]);	//   free default yank/delete register
+			reg[YDreg] = NULL;
+		}
+#endif
+		// how many lines in text[]?
+		li = count_lines(text, end - 1);
+		status_line("'%s'%s"
+			IF_FEATURE_VI_READONLY("%s")
+			" %dL, %dC",
+			current_filename,
+			(size < 0 ? " [New file]" : ""),
+			IF_FEATURE_VI_READONLY(
+				((readonly_mode) ? " [Readonly]" : ""),
+			)
+			li, (int)(end - text)
+		);
+	} else if (strncmp(cmd, "file", i) == 0) {	// what File is this
+		if (b != -1 || e != -1) {
+			status_line_bold("No address allowed on this command");
+			goto ret;
+		}
+		if (args[0]) {
+			// user wants a new filename
+			free(current_filename);
+			current_filename = xstrdup(args);
+		} else {
+			// user wants file status info
+			last_status_cksum = 0;	// force status update
+		}
+	} else if (strncmp(cmd, "features", i) == 0) {	// what features are available
+		// print out values of all features
+		go_bottom_and_clear_to_eol();
+		cookmode();
+		show_help();
+		rawmode();
+		Hit_Return();
+	} else if (strncmp(cmd, "list", i) == 0) {	// literal print line
+		if (b < 0) {	// no addr given- use defaults
+			q = begin_line(dot);	// assume .,. for the range
+			r = end_line(dot);
+		}
+		go_bottom_and_clear_to_eol();
+		puts("\r");
+		for (; q <= r; q++) {
+			int c_is_no_print;
+
+			c = *q;
+			c_is_no_print = (c & 0x80) && !Isprint(c);
+			if (c_is_no_print) {
+				c = '.';
+				standout_start();
+			}
+			if (c == '\n') {
+				write1("$\r");
+			} else if (c < ' ' || c == 127) {
+				bb_putchar('^');
+				if (c == 127)
+					c = '?';
+				else
+					c += '@';
+			}
+			bb_putchar(c);
+			if (c_is_no_print)
+				standout_end();
+		}
+		Hit_Return();
+	} else if (strncmp(cmd, "quit", i) == 0 // quit
+	        || strncmp(cmd, "next", i) == 0 // edit next file
+	        || strncmp(cmd, "prev", i) == 0 // edit previous file
+	) {
+		int n;
+		if (useforce) {
+			if (*cmd == 'q') {
+				// force end of argv list
+				optind = save_argc;
+			}
+			editing = 0;
+			goto ret;
+		}
+		// don't exit if the file been modified
+		if (modified_count) {
+			status_line_bold("No write since last change (:%s! overrides)", cmd);
+			goto ret;
+		}
+		// are there other file to edit
+		n = save_argc - optind - 1;
+		if (*cmd == 'q' && n > 0) {
+			status_line_bold("%d more file(s) to edit", n);
+			goto ret;
+		}
+		if (*cmd == 'n' && n <= 0) {
+			status_line_bold("No more files to edit");
+			goto ret;
+		}
+		if (*cmd == 'p') {
+			// are there previous files to edit
+			if (optind < 1) {
+				status_line_bold("No previous files to edit");
+				goto ret;
+			}
+			optind -= 2;
+		}
+		editing = 0;
+	} else if (strncmp(cmd, "read", i) == 0) {	// read file into text[]
+		int size;
+
+		fn = args;
+		if (!fn[0]) {
+			status_line_bold("No filename given");
+			goto ret;
+		}
+		if (b < 0) {	// no addr given- use defaults
+			q = begin_line(dot);	// assume "dot"
+		}
+		// read after current line- unless user said ":0r foo"
+		if (b != 0) {
+			q = next_line(q);
+			// read after last line
+			if (q == end-1)
+				++q;
+		}
+		{ // dance around potentially-reallocated text[]
+			uintptr_t ofs = q - text;
+			size = file_insert(fn, q, 0);
+			q = text + ofs;
+		}
+		if (size < 0)
+			goto ret;	// nothing was inserted
+		// how many lines in text[]?
+		li = count_lines(q, q + size - 1);
+		status_line("'%s'"
+			IF_FEATURE_VI_READONLY("%s")
+			" %dL, %dC",
+			fn,
+			IF_FEATURE_VI_READONLY((readonly_mode ? " [Readonly]" : ""),)
+			li, size
+		);
+		if (size > 0) {
+			// if the insert is before "dot" then we need to update
+			if (q <= dot)
+				dot += size;
+		}
+	} else if (strncmp(cmd, "rewind", i) == 0) {	// rewind cmd line args
+		if (modified_count && !useforce) {
+			status_line_bold("No write since last change (:%s! overrides)", cmd);
+		} else {
+			// reset the filenames to edit
+			optind = -1; /* start from 0th file */
+			editing = 0;
+		}
+#if ENABLE_FEATURE_VI_SET
+	} else if (strncmp(cmd, "set", i) == 0) {	// set or clear features
+#if ENABLE_FEATURE_VI_SETOPTS
+		char *argp;
+#endif
+		i = 0;			// offset into args
+		// only blank is regarded as args delimiter. What about tab '\t'?
+		if (!args[0] || strcasecmp(args, "all") == 0) {
+			// print out values of all options
+#if ENABLE_FEATURE_VI_SETOPTS
+			status_line_bold(
+				"%sautoindent "
+				"%sflash "
+				"%signorecase "
+				"%sshowmatch "
+				"tabstop=%u",
+				autoindent ? "" : "no",
+				err_method ? "" : "no",
+				ignorecase ? "" : "no",
+				showmatch ? "" : "no",
+				tabstop
+			);
+#endif
+			goto ret;
+		}
+#if ENABLE_FEATURE_VI_SETOPTS
+		argp = args;
+		while (*argp) {
+			if (strncmp(argp, "no", 2) == 0)
+				i = 2;		// ":set noautoindent"
+			setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
+			setops(argp, "flash "     , i, "fl", VI_ERR_METHOD);
+			setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE);
+			setops(argp, "showmatch " , i, "sm", VI_SHOWMATCH );
+			if (strncmp(argp + i, "tabstop=", 8) == 0) {
+				int t = 0;
+				sscanf(argp + i+8, "%u", &t);
+				if (t > 0 && t <= MAX_TABSTOP)
+					tabstop = t;
+			}
+			argp = skip_non_whitespace(argp);
+			argp = skip_whitespace(argp);
+		}
+#endif /* FEATURE_VI_SETOPTS */
+#endif /* FEATURE_VI_SET */
+#if ENABLE_FEATURE_VI_SEARCH
+	} else if (cmd[0] == 's') {	// substitute a pattern with a replacement pattern
+		char *F, *R, *flags;
+		size_t len_F, len_R;
+		int gflag;		// global replace flag
+#if ENABLE_FEATURE_VI_UNDO
+		int dont_chain_first_item = ALLOW_UNDO;
+#endif
+
+		// F points to the "find" pattern
+		// R points to the "replace" pattern
+		// replace the cmd line delimiters "/" with NULs
+		c = orig_buf[1];	// what is the delimiter
+		F = orig_buf + 2;	// start of "find"
+		R = strchr(F, c);	// middle delimiter
+		if (!R)
+			goto colon_s_fail;
+		len_F = R - F;
+		*R++ = '\0';	// terminate "find"
+		flags = strchr(R, c);
+		if (!flags)
+			goto colon_s_fail;
+		len_R = flags - R;
+		*flags++ = '\0';	// terminate "replace"
+		gflag = *flags;
+
+		q = begin_line(q);
+		if (b < 0) {	// maybe :s/foo/bar/
+			q = begin_line(dot);      // start with cur line
+			b = count_lines(text, q); // cur line number
+		}
+		if (e < 0)
+			e = b;		// maybe :.s/foo/bar/
+
+		for (i = b; i <= e; i++) {	// so, :20,23 s \0 find \0 replace \0
+			char *ls = q;		// orig line start
+			char *found;
+ vc4:
+			found = char_search(q, F, FORWARD, LIMITED);	// search cur line only for "find"
+			if (found) {
+				uintptr_t bias;
+				// we found the "find" pattern - delete it
+				// For undo support, the first item should not be chained
+				text_hole_delete(found, found + len_F - 1, dont_chain_first_item);
+#if ENABLE_FEATURE_VI_UNDO
+				dont_chain_first_item = ALLOW_UNDO_CHAIN;
+#endif
+				// insert the "replace" patern
+				bias = string_insert(found, R, ALLOW_UNDO_CHAIN);
+				found += bias;
+				ls += bias;
+				/*q += bias; - recalculated anyway */
+				// check for "global"  :s/foo/bar/g
+				if (gflag == 'g') {
+					if ((found + len_R) < end_line(ls)) {
+						q = found + len_R;
+						goto vc4;	// don't let q move past cur line
+					}
+				}
+			}
+			q = next_line(ls);
+		}
+#endif /* FEATURE_VI_SEARCH */
+	} else if (strncmp(cmd, "version", i) == 0) {  // show software version
+		status_line(BB_VER " " BB_BT);
+	} else if (strncmp(cmd, "write", i) == 0  // write text to file
+	        || strncmp(cmd, "wq", i) == 0
+	        || strncmp(cmd, "wn", i) == 0
+	        || (cmd[0] == 'x' && !cmd[1])
+	) {
+		int size;
+		//int forced = FALSE;
+
+		// is there a file name to write to?
+		if (args[0]) {
+			fn = args;
+		}
+#if ENABLE_FEATURE_VI_READONLY
+		if (readonly_mode && !useforce) {
+			status_line_bold("'%s' is read only", fn);
+			goto ret;
+		}
+#endif
+		// how many lines in text[]?
+		li = count_lines(q, r);
+		size = r - q + 1;
+		//if (useforce) {
+			// if "fn" is not write-able, chmod u+w
+			// sprintf(syscmd, "chmod u+w %s", fn);
+			// system(syscmd);
+			// forced = TRUE;
+		//}
+		l = file_write(fn, q, r);
+		//if (useforce && forced) {
+			// chmod u-w
+			// sprintf(syscmd, "chmod u-w %s", fn);
+			// system(syscmd);
+			// forced = FALSE;
+		//}
+		if (l < 0) {
+			if (l == -1)
+				status_line_bold_errno(fn);
+		} else {
+			status_line("'%s' %dL, %dC", fn, li, l);
+			if (q == text && r == end - 1 && l == size) {
+				modified_count = 0;
+				last_modified_count = -1;
+			}
+			if ((cmd[0] == 'x' || cmd[1] == 'q' || cmd[1] == 'n'
+			    || cmd[0] == 'X' || cmd[1] == 'Q' || cmd[1] == 'N'
+			    )
+			 && l == size
+			) {
+				editing = 0;
+			}
+		}
+#if ENABLE_FEATURE_VI_YANKMARK
+	} else if (strncmp(cmd, "yank", i) == 0) {	// yank lines
+		if (b < 0) {	// no addr given- use defaults
+			q = begin_line(dot);	// assume .,. for the range
+			r = end_line(dot);
+		}
+		text_yank(q, r, YDreg);
+		li = count_lines(q, r);
+		status_line("Yank %d lines (%d chars) into [%c]",
+				li, strlen(reg[YDreg]), what_reg());
+#endif
+	} else {
+		// cmd unknown
+		not_implemented(cmd);
+	}
+ ret:
+	dot = bound_dot(dot);	// make sure "dot" is valid
+	return;
+#if ENABLE_FEATURE_VI_SEARCH
+ colon_s_fail:
+	status_line(":s expression missing delimiters");
+#endif
+#endif /* FEATURE_VI_COLON */
+}
+
+static void Hit_Return(void)
+{
+	int c;
+
+	standout_start();
+	write1("[Hit return to continue]");
+	standout_end();
+	while ((c = get_one_char()) != '\n' && c != '\r')
+		continue;
+	redraw(TRUE);		// force redraw all
+}
+
+static int next_tabstop(int col)
+{
+	return col + ((tabstop - 1) - (col % tabstop));
+}
+
+//----- Synchronize the cursor to Dot --------------------------
+static NOINLINE void sync_cursor(char *d, int *row, int *col)
+{
+	char *beg_cur;	// begin and end of "d" line
+	char *tp;
+	int cnt, ro, co;
+
+	beg_cur = begin_line(d);	// first char of cur line
+
+	if (beg_cur < screenbegin) {
+		// "d" is before top line on screen
+		// how many lines do we have to move
+		cnt = count_lines(beg_cur, screenbegin);
+ sc1:
+		screenbegin = beg_cur;
+		if (cnt > (rows - 1) / 2) {
+			// we moved too many lines. put "dot" in middle of screen
+			for (cnt = 0; cnt < (rows - 1) / 2; cnt++) {
+				screenbegin = prev_line(screenbegin);
+			}
+		}
+	} else {
+		char *end_scr;	// begin and end of screen
+		end_scr = end_screen();	// last char of screen
+		if (beg_cur > end_scr) {
+			// "d" is after bottom line on screen
+			// how many lines do we have to move
+			cnt = count_lines(end_scr, beg_cur);
+			if (cnt > (rows - 1) / 2)
+				goto sc1;	// too many lines
+			for (ro = 0; ro < cnt - 1; ro++) {
+				// move screen begin the same amount
+				screenbegin = next_line(screenbegin);
+				// now, move the end of screen
+				end_scr = next_line(end_scr);
+				end_scr = end_line(end_scr);
+			}
+		}
+	}
+	// "d" is on screen- find out which row
+	tp = screenbegin;
+	for (ro = 0; ro < rows - 1; ro++) {	// drive "ro" to correct row
+		if (tp == beg_cur)
+			break;
+		tp = next_line(tp);
+	}
+
+	// find out what col "d" is on
+	co = 0;
+	while (tp < d) { // drive "co" to correct column
+		if (*tp == '\n') //vda || *tp == '\0')
+			break;
+		if (*tp == '\t') {
+			// handle tabs like real vi
+			if (d == tp && cmd_mode) {
+				break;
+			}
+			co = next_tabstop(co);
+		} else if ((unsigned char)*tp < ' ' || *tp == 0x7f) {
+			co++; // display as ^X, use 2 columns
+		}
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+		co++;
+		tp++;
+#else
+		unsigned short tmp_code;
+		int code_size;
+		tmp_code = Utf8_to_Utf16(tp, &code_size);
+		co += (code_size > 1 ? 2 : code_size);
+		tp += code_size;
+#endif
+	}
+
+	// "co" is the column where "dot" is.
+	// The screen has "columns" columns.
+	// The currently displayed columns are  0+offset -- columns+ofset
+	// |-------------------------------------------------------------|
+	//               ^ ^                                ^
+	//        offset | |------- columns ----------------|
+	//
+	// If "co" is already in this range then we do not have to adjust offset
+	//      but, we do have to subtract the "offset" bias from "co".
+	// If "co" is outside this range then we have to change "offset".
+	// If the first char of a line is a tab the cursor will try to stay
+	//  in column 7, but we have to set offset to 0.
+
+	if (co < 0 + offset) {
+		offset = co;
+	}
+	if (co >= columns + offset) {
+		offset = co - columns + 1;
+	}
+	// if the first char of the line is a tab, and "dot" is sitting on it
+	//  force offset to 0.
+	if (d == beg_cur && *d == '\t') {
+		offset = 0;
+	}
+	co -= offset;
+
+	*row = ro;
+	*col = co;
+}
+
+//----- Text Movement Routines ---------------------------------
+static char *begin_line(char *p) // return pointer to first char cur line
+{
+	if (p > text) {
+		p = memrchr(text, '\n', p - text);
+		if (!p)
+			return text;
+		return p + 1;
+	}
+	return p;
+}
+
+static char *end_line(char *p) // return pointer to NL of cur line
+{
+	if (p < end - 1) {
+		p = memchr(p, '\n', end - p - 1);
+		if (!p)
+			return end - 1;
+	}
+	return p;
+}
+
+static char *dollar_line(char *p) // return pointer to just before NL line
+{
+	p = end_line(p);
+	// Try to stay off of the Newline
+	if (*p == '\n' && (p - begin_line(p)) > 0)
+		p--;
+	return p;
+}
+
+static char *prev_line(char *p) // return pointer first char prev line
+{
+	p = begin_line(p);	// goto beginning of cur line
+	if (p > text && p[-1] == '\n')
+		p--;			// step to prev line
+	p = begin_line(p);	// goto beginning of prev line
+	return p;
+}
+
+static char *next_line(char *p) // return pointer first char next line
+{
+	p = end_line(p);
+	if (p < end - 1 && *p == '\n')
+		p++;			// step to next line
+	return p;
+}
+
+//----- Text Information Routines ------------------------------
+static char *end_screen(void)
+{
+	char *q;
+	int cnt;
+
+	// find new bottom line
+	q = screenbegin;
+	for (cnt = 0; cnt < rows - 2; cnt++)
+		q = next_line(q);
+	q = end_line(q);
+	return q;
+}
+
+// count line from start to stop
+static int count_lines(char *start, char *stop)
+{
+	char *q;
+	int cnt;
+
+	if (stop < start) { // start and stop are backwards- reverse them
+		q = start;
+		start = stop;
+		stop = q;
+	}
+	cnt = 0;
+	stop = end_line(stop);
+	while (start <= stop && start <= end - 1) {
+		start = end_line(start);
+		if (*start == '\n')
+			cnt++;
+		start++;
+	}
+	return cnt;
+}
+
+static char *find_line(int li)	// find beginning of line #li
+{
+	char *q;
+
+	for (q = text; li > 1; li--) {
+		q = next_line(q);
+	}
+	return q;
+}
+
+//----- Dot Movement Routines ----------------------------------
+static void dot_left(void)
+{
+	undo_queue_commit();
+	if (dot > text && dot[-1] != '\n')
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+		dot--;
+#else
+		dot -= bs_char_count(text, dot - text - 1);
+#endif
+}
+
+static void dot_right(void)
+{
+	undo_queue_commit();
+	if (dot < end - 1 && *dot != '\n')
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+		dot++;
+#else
+	{
+		int code_size;
+		unsigned short tmp_code = Utf8_to_Utf16(dot, &code_size);
+		if (dot[code_size - 1] != '\n')
+			dot += code_size;
+	}
+#endif
+}
+
+static void dot_begin(void)
+{
+	undo_queue_commit();
+	dot = begin_line(dot);	// return pointer to first char cur line
+}
+
+static void dot_end(void)
+{
+	undo_queue_commit();
+	dot = end_line(dot);	// return pointer to last char cur line
+}
+
+static char *move_to_col(char *p, int l)
+{
+	int co;
+
+	p = begin_line(p);
+	co = 0;
+	while (co < l && p < end) {
+		if (*p == '\n') //vda || *p == '\0')
+			break;
+		if (*p == '\t') {
+			co = next_tabstop(co);
+		}
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+		else if (*p < ' ' || *p == 127) {
+			co++; // display as ^X, use 2 columns
+		}
+		co++;
+		p++;
+#else
+		else {
+			int code_size, tmp_co;
+			char *tmp_p;
+			unsigned short tmp_code = Utf8_to_Utf16(p, &code_size);
+			tmp_co = co + (code_size > 1 ? 2 : 1);
+			if (tmp_co > l)
+				break;
+			else
+				co = tmp_co;
+			tmp_p = p + code_size;
+			if (tmp_p > end)
+				break;
+			else
+				p = tmp_p;
+		}
+#endif
+	}
+	return p;
+}
+
+static void dot_next(void)
+{
+	undo_queue_commit();
+	dot = next_line(dot);
+}
+
+static void dot_prev(void)
+{
+	undo_queue_commit();
+	dot = prev_line(dot);
+}
+
+static void dot_scroll(int cnt, int dir)
+{
+	char *q;
+
+	undo_queue_commit();
+	for (; cnt > 0; cnt--) {
+		if (dir < 0) {
+			// scroll Backwards
+			// ctrl-Y scroll up one line
+			screenbegin = prev_line(screenbegin);
+		} else {
+			// scroll Forwards
+			// ctrl-E scroll down one line
+			screenbegin = next_line(screenbegin);
+		}
+	}
+	// make sure "dot" stays on the screen so we dont scroll off
+	if (dot < screenbegin)
+		dot = screenbegin;
+	q = end_screen();	// find new bottom line
+	if (dot > q)
+		dot = begin_line(q);	// is dot is below bottom line?
+	dot_skip_over_ws();
+}
+
+static void dot_skip_over_ws(void)
+{
+	// skip WS
+	while (isspace(*dot) && *dot != '\n' && dot < end - 1)
+		dot++;
+}
+
+static char *bound_dot(char *p) // make sure  text[0] <= P < "end"
+{
+	if (p >= end && end > text) {
+		p = end - 1;
+		indicate_error();
+	}
+	if (p < text) {
+		p = text;
+		indicate_error();
+	}
+	return p;
+}
+
+//----- Helper Utility Routines --------------------------------
+
+//----------------------------------------------------------------
+//----- Char Routines --------------------------------------------
+/* Chars that are part of a word-
+ *    0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+ * Chars that are Not part of a word (stoppers)
+ *    !"#$%&'()*+,-./:;<=>?@[\]^`{|}~
+ * Chars that are WhiteSpace
+ *    TAB NEWLINE VT FF RETURN SPACE
+ * DO NOT COUNT NEWLINE AS WHITESPACE
+ */
+
+static char *new_screen(int ro, int co)
+{
+	int li;
+
+	free(screen);
+	screensize = ro * co + 8;
+	screen = xmalloc(screensize);
+	// initialize the new screen. assume this will be a empty file.
+	screen_erase();
+	//   non-existent text[] lines start with a tilde (~).
+	for (li = 1; li < ro - 1; li++) {
+		screen[(li * co) + 0] = '~';
+	}
+	return screen;
+}
+
+#if ENABLE_FEATURE_VI_SEARCH
+
+# if ENABLE_FEATURE_VI_REGEX_SEARCH
+
+// search for pattern starting at p
+static char *char_search(char *p, const char *pat, int dir, int range)
+{
+	struct re_pattern_buffer preg;
+	const char *err;
+	char *q;
+	int i;
+	int size;
+
+	re_syntax_options = RE_SYNTAX_POSIX_EXTENDED;
+	if (ignorecase)
+		re_syntax_options = RE_SYNTAX_POSIX_EXTENDED | RE_ICASE;
+
+	memset(&preg, 0, sizeof(preg));
+	err = re_compile_pattern(pat, strlen(pat), &preg);
+	if (err != NULL) {
+		status_line_bold("bad search pattern '%s': %s", pat, err);
+		return p;
+	}
+
+	// assume a LIMITED forward search
+	q = end - 1;
+	if (dir == BACK)
+		q = text;
+	// RANGE could be negative if we are searching backwards
+	range = q - p;
+	q = p;
+	size = range;
+	if (range < 0) {
+		size = -size;
+		q = p - size;
+		if (q < text)
+			q = text;
+	}
+	// search for the compiled pattern, preg, in p[]
+	// range < 0: search backward
+	// range > 0: search forward
+	// 0 < start < size
+	// re_search() < 0: not found or error
+	// re_search() >= 0: index of found pattern
+	//           struct pattern   char     int   int    int    struct reg
+	// re_search(*pattern_buffer, *string, size, start, range, *regs)
+	i = re_search(&preg, q, size, /*start:*/ 0, range, /*struct re_registers*:*/ NULL);
+	regfree(&preg);
+	if (i < 0)
+		return NULL;
+	if (dir == FORWARD)
+		p = p + i;
+	else
+		p = p - i;
+	return p;
+}
+
+# else
+
+#  if ENABLE_FEATURE_VI_SETOPTS
+static int mycmp(const char *s1, const char *s2, int len)
+{
+	if (ignorecase) {
+		return strncasecmp(s1, s2, len);
+	}
+	return strncmp(s1, s2, len);
+}
+#  else
+#   define mycmp strncmp
+#  endif
+
+static char *char_search(char *p, const char *pat, int dir, int range)
+{
+	char *start, *stop;
+	int len;
+
+	len = strlen(pat);
+	if (dir == FORWARD) {
+		stop = end - 1;	// assume range is p..end-1
+		if (range == LIMITED)
+			stop = next_line(p);	// range is to next line
+		for (start = p; start < stop; start++) {
+			if (mycmp(start, pat, len) == 0) {
+				return start;
+			}
+		}
+	} else if (dir == BACK) {
+		stop = text;	// assume range is text..p
+		if (range == LIMITED)
+			stop = prev_line(p);	// range is to prev line
+		for (start = p - len; start >= stop; start--) {
+			if (mycmp(start, pat, len) == 0) {
+				return start;
+			}
+		}
+	}
+	// pattern not found
+	return NULL;
+}
+
+# endif
+
+#endif /* FEATURE_VI_SEARCH */
+
+static char *char_insert(char *p, char c, int undo) // insert the char c at 'p'
+{
+	if (c == 22) {		// Is this an ctrl-V?
+		p += stupid_insert(p, '^');	// use ^ to indicate literal next
+		refresh(FALSE);	// show the ^
+		c = get_one_char();
+		*p = c;
+#if ENABLE_FEATURE_VI_UNDO
+		switch (undo) {
+			case ALLOW_UNDO:
+				undo_push(p, 1, UNDO_INS);
+				break;
+			case ALLOW_UNDO_CHAIN:
+				undo_push(p, 1, UNDO_INS_CHAIN);
+				break;
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+			case ALLOW_UNDO_QUEUED:
+				undo_push(p, 1, UNDO_INS_QUEUED);
+				break;
+# endif
+		}
+#else
+		modified_count++;
+#endif /* ENABLE_FEATURE_VI_UNDO */
+		p++;
+	} else if (c == 27) {	// Is this an ESC?
+		cmd_mode = 0;
+		undo_queue_commit();
+		cmdcnt = 0;
+		end_cmd_q();	// stop adding to q
+		last_status_cksum = 0;	// force status update
+		if ((p[-1] != '\n') && (dot > text)) {
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+			p--;
+#else
+			p -= bs_char_count(text, (p - text - 1));
+#endif
+		}
+	} else if (c == erase_char || c == 8 || c == 127) { // Is this a BS
+		if (p > text) {
+			p--;
+			p = text_hole_delete(p, p, ALLOW_UNDO_QUEUED);	// shrink buffer 1 char
+		}
+	} else {
+		// insert a char into text[]
+		if (c == 13)
+			c = '\n';	// translate \r to \n
+#if ENABLE_FEATURE_VI_UNDO
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+		if (c == '\n')
+			undo_queue_commit();
+# endif
+		switch (undo) {
+			case ALLOW_UNDO:
+				undo_push(p, 1, UNDO_INS);
+				break;
+			case ALLOW_UNDO_CHAIN:
+				undo_push(p, 1, UNDO_INS_CHAIN);
+				break;
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+			case ALLOW_UNDO_QUEUED:
+				undo_push(p, 1, UNDO_INS_QUEUED);
+				break;
+# endif
+		}
+#else
+		modified_count++;
+#endif /* ENABLE_FEATURE_VI_UNDO */
+		p += 1 + stupid_insert(p, c);	// insert the char
+#if ENABLE_FEATURE_VI_SETOPTS
+		if (showmatch && strchr(")]}", c) != NULL) {
+			showmatching(p - 1);
+		}
+		if (autoindent && c == '\n') {	// auto indent the new line
+			char *q;
+			size_t len;
+			q = prev_line(p);	// use prev line as template
+			len = strspn(q, " \t"); // space or tab
+			if (len) {
+				uintptr_t bias;
+				bias = text_hole_make(p, len);
+				p += bias;
+				q += bias;
+#if ENABLE_FEATURE_VI_UNDO
+				undo_push(p, len, UNDO_INS);
+#endif
+				memcpy(p, q, len);
+				p += len;
+			}
+		}
+#endif
+	}
+	return p;
+}
+
+// might reallocate text[]! use p += stupid_insert(p, ...),
+// and be careful to not use pointers into potentially freed text[]!
+static uintptr_t stupid_insert(char *p, char c) // stupidly insert the char c at 'p'
+{
+	uintptr_t bias;
+	bias = text_hole_make(p, 1);
+	p += bias;
+	*p = c;
+	return bias;
+}
+
+static int find_range(char **start, char **stop, char c)
+{
+	char *save_dot, *p, *q, *t;
+	int cnt, multiline = 0;
+
+	save_dot = dot;
+	p = q = dot;
+
+	if (strchr("cdy><", c)) {
+		// these cmds operate on whole lines
+		p = q = begin_line(p);
+		for (cnt = 1; cnt < cmdcnt; cnt++) {
+			q = next_line(q);
+		}
+		q = end_line(q);
+	} else if (strchr("^%$0bBeEfth\b\177", c)) {
+		// These cmds operate on char positions
+		do_cmd(c);		// execute movement cmd
+		q = dot;
+	} else if (strchr("wW", c)) {
+		do_cmd(c);		// execute movement cmd
+		// if we are at the next word's first char
+		// step back one char
+		// but check the possibilities when it is true
+		if (dot > text && ((isspace(dot[-1]) && !isspace(dot[0]))
+				|| (ispunct(dot[-1]) && !ispunct(dot[0]))
+				|| (isalnum(dot[-1]) && !isalnum(dot[0]))))
+			dot--;		// move back off of next word
+		if (dot > text && *dot == '\n')
+			dot--;		// stay off NL
+		q = dot;
+	} else if (strchr("H-k{", c)) {
+		// these operate on multi-lines backwards
+		q = end_line(dot);	// find NL
+		do_cmd(c);		// execute movement cmd
+		dot_begin();
+		p = dot;
+	} else if (strchr("L+j}\r\n", c)) {
+		// these operate on multi-lines forwards
+		p = begin_line(dot);
+		do_cmd(c);		// execute movement cmd
+		dot_end();		// find NL
+		q = dot;
+	} else {
+		// nothing -- this causes any other values of c to
+		// represent the one-character range under the
+		// cursor.  this is correct for ' ' and 'l', but
+		// perhaps no others.
+		//
+	}
+	if (q < p) {
+		t = q;
+		q = p;
+		p = t;
+	}
+
+	// backward char movements don't include start position
+	if (q > p && strchr("^0bBh\b\177", c)) q--;
+
+	multiline = 0;
+	for (t = p; t <= q; t++) {
+		if (*t == '\n') {
+			multiline = 1;
+			break;
+		}
+	}
+
+	*start = p;
+	*stop = q;
+	dot = save_dot;
+	return multiline;
+}
+
+static int st_test(char *p, int type, int dir, char *tested)
+{
+	char c, c0, ci;
+	int test, inc;
+
+	inc = dir;
+	c = c0 = p[0];
+	ci = p[inc];
+	test = 0;
+
+	if (type == S_BEFORE_WS) {
+		c = ci;
+		test = (!isspace(c) || c == '\n');
+	}
+	if (type == S_TO_WS) {
+		c = c0;
+		test = (!isspace(c) || c == '\n');
+	}
+	if (type == S_OVER_WS) {
+		c = c0;
+		test = isspace(c);
+	}
+	if (type == S_END_PUNCT) {
+		c = ci;
+		test = ispunct(c);
+	}
+	if (type == S_END_ALNUM) {
+		c = ci;
+		test = (isalnum(c) || c == '_');
+	}
+	*tested = c;
+	return test;
+}
+
+static char *skip_thing(char *p, int linecnt, int dir, int type)
+{
+	char c;
+
+	while (st_test(p, type, dir, &c)) {
+		// make sure we limit search to correct number of lines
+		if (c == '\n' && --linecnt < 1)
+			break;
+		if (dir >= 0 && p >= end - 1)
+			break;
+		if (dir < 0 && p <= text)
+			break;
+		p += dir;		// move to next char
+	}
+	return p;
+}
+
+// find matching char of pair  ()  []  {}
+// will crash if c is not one of these
+static char *find_pair(char *p, const char c)
+{
+	const char *braces = "()[]{}";
+	char match;
+	int dir, level;
+
+	dir = strchr(braces, c) - braces;
+	dir ^= 1;
+	match = braces[dir];
+	dir = ((dir & 1) << 1) - 1; /* 1 for ([{, -1 for )\} */
+
+	// look for match, count levels of pairs  (( ))
+	level = 1;
+	for (;;) {
+		p += dir;
+		if (p < text || p >= end)
+			return NULL;
+		if (*p == c)
+			level++;	// increase pair levels
+		if (*p == match) {
+			level--;	// reduce pair level
+			if (level == 0)
+				return p; // found matching pair
+		}
+	}
+}
+
+#if ENABLE_FEATURE_VI_SETOPTS
+// show the matching char of a pair,  ()  []  {}
+static void showmatching(char *p)
+{
+	char *q, *save_dot;
+
+	// we found half of a pair
+	q = find_pair(p, *p);	// get loc of matching char
+	if (q == NULL) {
+		indicate_error();	// no matching char
+	} else {
+		// "q" now points to matching pair
+		save_dot = dot;	// remember where we are
+		dot = q;		// go to new loc
+		refresh(FALSE);	// let the user see it
+		mysleep(40);	// give user some time
+		dot = save_dot;	// go back to old loc
+		refresh(FALSE);
+	}
+}
+#endif /* FEATURE_VI_SETOPTS */
+
+#if ENABLE_FEATURE_VI_UNDO
+static void flush_undo_data(void)
+{
+	struct undo_object *undo_entry;
+
+	while (undo_stack_tail) {
+		undo_entry = undo_stack_tail;
+		undo_stack_tail = undo_entry->prev;
+		free(undo_entry);
+	}
+}
+
+// Undo functions and hooks added by Jody Bruchon (jody@jodybruchon.com)
+static void undo_push(char *src, unsigned int length, uint8_t u_type)	// Add to the undo stack
+{
+	struct undo_object *undo_entry;
+
+	// "u_type" values
+	// UNDO_INS: insertion, undo will remove from buffer
+	// UNDO_DEL: deleted text, undo will restore to buffer
+	// UNDO_{INS,DEL}_CHAIN: Same as above but also calls undo_pop() when complete
+	// The CHAIN operations are for handling multiple operations that the user
+	// performs with a single action, i.e. REPLACE mode or find-and-replace commands
+	// UNDO_{INS,DEL}_QUEUED: If queuing feature is enabled, allow use of the queue
+	// for the INS/DEL operation. The raw values should be equal to the values of
+	// UNDO_{INS,DEL} ORed with UNDO_QUEUED_FLAG
+
+#if ENABLE_FEATURE_VI_UNDO_QUEUE
+	// This undo queuing functionality groups multiple character typing or backspaces
+	// into a single large undo object. This greatly reduces calls to malloc() for
+	// single-character operations while typing and has the side benefit of letting
+	// an undo operation remove chunks of text rather than a single character.
+	switch (u_type) {
+	case UNDO_EMPTY:	// Just in case this ever happens...
+		return;
+	case UNDO_DEL_QUEUED:
+		if (length != 1)
+			return;	// Only queue single characters
+		switch (undo_queue_state) {
+		case UNDO_EMPTY:
+			undo_queue_state = UNDO_DEL;
+		case UNDO_DEL:
+			undo_queue_spos = src;
+			undo_q++;
+			undo_queue[CONFIG_FEATURE_VI_UNDO_QUEUE_MAX - undo_q] = *src;
+			// If queue is full, dump it into an object
+			if (undo_q == CONFIG_FEATURE_VI_UNDO_QUEUE_MAX)
+				undo_queue_commit();
+			return;
+		case UNDO_INS:
+			// Switch from storing inserted text to deleted text
+			undo_queue_commit();
+			undo_push(src, length, UNDO_DEL_QUEUED);
+			return;
+		}
+		break;
+	case UNDO_INS_QUEUED:
+		if (length != 1)
+			return;
+		switch (undo_queue_state) {
+		case UNDO_EMPTY:
+			undo_queue_state = UNDO_INS;
+			undo_queue_spos = src;
+		case UNDO_INS:
+			undo_q++;	// Don't need to save any data for insertions
+			if (undo_q == CONFIG_FEATURE_VI_UNDO_QUEUE_MAX)
+				undo_queue_commit();
+			return;
+		case UNDO_DEL:
+			// Switch from storing deleted text to inserted text
+			undo_queue_commit();
+			undo_push(src, length, UNDO_INS_QUEUED);
+			return;
+		}
+		break;
+	}
+#else
+	// If undo queuing is disabled, ignore the queuing flag entirely
+	u_type = u_type & ~UNDO_QUEUED_FLAG;
+#endif
+
+	// Allocate a new undo object
+	if (u_type == UNDO_DEL || u_type == UNDO_DEL_CHAIN) {
+		// For UNDO_DEL objects, save deleted text
+		if ((src + length) == end)
+			length--;
+		// If this deletion empties text[], strip the newline. When the buffer becomes
+		// zero-length, a newline is added back, which requires this to compensate.
+		undo_entry = xzalloc(offsetof(struct undo_object, undo_text) + length);
+		memcpy(undo_entry->undo_text, src, length);
+	} else {
+		undo_entry = xzalloc(sizeof(*undo_entry));
+	}
+	undo_entry->length = length;
+#if ENABLE_FEATURE_VI_UNDO_QUEUE
+	if ((u_type & UNDO_USE_SPOS) != 0) {
+		undo_entry->start = undo_queue_spos - text;	// use start position from queue
+	} else {
+		undo_entry->start = src - text;	// use offset from start of text buffer
+	}
+	u_type = (u_type & ~UNDO_USE_SPOS);
+#else
+	undo_entry->start = src - text;
+#endif
+	undo_entry->u_type = u_type;
+
+	// Push it on undo stack
+	undo_entry->prev = undo_stack_tail;
+	undo_stack_tail = undo_entry;
+	modified_count++;
+}
+
+static void undo_pop(void)	// Undo the last operation
+{
+	int repeat;
+	char *u_start, *u_end;
+	struct undo_object *undo_entry;
+
+	// Commit pending undo queue before popping (should be unnecessary)
+	undo_queue_commit();
+
+	undo_entry = undo_stack_tail;
+	// Check for an empty undo stack
+	if (!undo_entry) {
+		status_line("Already at oldest change");
+		return;
+	}
+
+	switch (undo_entry->u_type) {
+	case UNDO_DEL:
+	case UNDO_DEL_CHAIN:
+		// make hole and put in text that was deleted; deallocate text
+		u_start = text + undo_entry->start;
+		text_hole_make(u_start, undo_entry->length);
+		memcpy(u_start, undo_entry->undo_text, undo_entry->length);
+		status_line("Undo [%d] %s %d chars at position %d",
+			modified_count, "restored",
+			undo_entry->length, undo_entry->start
+		);
+		break;
+	case UNDO_INS:
+	case UNDO_INS_CHAIN:
+		// delete what was inserted
+		u_start = undo_entry->start + text;
+		u_end = u_start - 1 + undo_entry->length;
+		text_hole_delete(u_start, u_end, NO_UNDO);
+		status_line("Undo [%d] %s %d chars at position %d",
+			modified_count, "deleted",
+			undo_entry->length, undo_entry->start
+		);
+		break;
+	}
+	repeat = 0;
+	switch (undo_entry->u_type) {
+	// If this is the end of a chain, lower modification count and refresh display
+	case UNDO_DEL:
+	case UNDO_INS:
+		dot = (text + undo_entry->start);
+		refresh(FALSE);
+		break;
+	case UNDO_DEL_CHAIN:
+	case UNDO_INS_CHAIN:
+		repeat = 1;
+		break;
+	}
+	// Deallocate the undo object we just processed
+	undo_stack_tail = undo_entry->prev;
+	free(undo_entry);
+	modified_count--;
+	// For chained operations, continue popping all the way down the chain.
+	if (repeat) {
+		undo_pop();	// Follow the undo chain if one exists
+	}
+}
+
+#if ENABLE_FEATURE_VI_UNDO_QUEUE
+static void undo_queue_commit(void)	// Flush any queued objects to the undo stack
+{
+	// Pushes the queue object onto the undo stack
+	if (undo_q > 0) {
+		// Deleted character undo events grow from the end
+		undo_push(undo_queue + CONFIG_FEATURE_VI_UNDO_QUEUE_MAX - undo_q,
+			undo_q,
+			(undo_queue_state | UNDO_USE_SPOS)
+		);
+		undo_queue_state = UNDO_EMPTY;
+		undo_q = 0;
+	}
+}
+#endif
+
+#endif /* ENABLE_FEATURE_VI_UNDO */
+
+// open a hole in text[]
+// might reallocate text[]! use p += text_hole_make(p, ...),
+// and be careful to not use pointers into potentially freed text[]!
+static uintptr_t text_hole_make(char *p, int size)	// at "p", make a 'size' byte hole
+{
+	uintptr_t bias = 0;
+
+	if (size <= 0)
+		return bias;
+	end += size;		// adjust the new END
+	if (end >= (text + text_size)) {
+		char *new_text;
+		text_size += end - (text + text_size) + 10240;
+		new_text = xrealloc(text, text_size);
+		bias = (new_text - text);
+		screenbegin += bias;
+		dot         += bias;
+		end         += bias;
+		p           += bias;
+#if ENABLE_FEATURE_VI_YANKMARK
+		{
+			int i;
+			for (i = 0; i < ARRAY_SIZE(mark); i++)
+				if (mark[i])
+					mark[i] += bias;
+		}
+#endif
+		text = new_text;
+	}
+	memmove(p + size, p, end - size - p);
+	memset(p, ' ', size);	// clear new hole
+	return bias;
+}
+
+//  close a hole in text[]
+//  "undo" value indicates if this operation should be undo-able
+static char *text_hole_delete(char *p, char *q, int undo) // delete "p" through "q", inclusive
+{
+	char *src, *dest;
+	int cnt, hole_size;
+
+	// move forwards, from beginning
+	// assume p <= q
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+	src = q + 1;
+	dest = p;
+	if (q < p) {		// they are backward- swap them
+		src = p + 1;
+		dest = q;
+	}
+	hole_size = q - p + 1;
+#else
+	int code_size;
+	unsigned short tmp_code;
+	if (q < p) {	// they are backward- swap them
+		tmp_code = Utf8_to_Utf16(p, &code_size);
+		src = p + code_size;
+		dest = q;
+		hole_size = p - q + code_size;
+	}
+	else {
+		if (q == (dot - 1)) {	// BS
+			code_size = bs_char_count(text, (dot - text - 1));
+			src = q + 1;
+			dest = p - (code_size - 1);
+		}
+		else {	// DEL
+			tmp_code = Utf8_to_Utf16(q, &code_size);
+			src = q + code_size;
+			dest = p;
+		}
+		hole_size = q - p + code_size;
+	}
+#endif
+	cnt = end - src;
+#if ENABLE_FEATURE_VI_UNDO
+	switch (undo) {
+		case NO_UNDO:
+			break;
+		case ALLOW_UNDO:
+			undo_push(p, hole_size, UNDO_DEL);
+			break;
+		case ALLOW_UNDO_CHAIN:
+			undo_push(p, hole_size, UNDO_DEL_CHAIN);
+			break;
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+		case ALLOW_UNDO_QUEUED:
+			undo_push(p, hole_size, UNDO_DEL_QUEUED);
+			break;
+# endif
+	}
+	modified_count--;
+#endif
+	if (src < text || src > end)
+		goto thd0;
+	if (dest < text || dest >= end)
+		goto thd0;
+	modified_count++;
+	if (src >= end)
+		goto thd_atend;	// just delete the end of the buffer
+	memmove(dest, src, cnt);
+ thd_atend:
+	end = end - hole_size;	// adjust the new END
+	if (dest >= end)
+		dest = end - 1;	// make sure dest in below end-1
+	if (end <= text)
+		dest = end = text;	// keep pointers valid
+ thd0:
+	return dest;
+}
+
+// copy text into register, then delete text.
+// if dist <= 0, do not include, or go past, a NewLine
+//
+static char *yank_delete(char *start, char *stop, int dist, int yf, int undo)
+{
+	char *p;
+
+	// make sure start <= stop
+	if (start > stop) {
+		// they are backwards, reverse them
+		p = start;
+		start = stop;
+		stop = p;
+	}
+	if (dist <= 0) {
+		// we cannot cross NL boundaries
+		p = start;
+		if (*p == '\n')
+			return p;
+		// dont go past a NewLine
+		for (; p + 1 <= stop; p++) {
+			if (p[1] == '\n') {
+				stop = p;	// "stop" just before NewLine
+				break;
+			}
+		}
+	}
+	p = start;
+#if ENABLE_FEATURE_VI_YANKMARK
+	text_yank(start, stop, YDreg);
+#endif
+	if (yf == YANKDEL) {
+		p = text_hole_delete(start, stop, undo);
+	}					// delete lines
+	return p;
+}
+
+static void show_help(void)
+{
+	puts("These features are available:"
+#if ENABLE_FEATURE_VI_SEARCH
+	"\n\tPattern searches with / and ?"
+#endif
+#if ENABLE_FEATURE_VI_DOT_CMD
+	"\n\tLast command repeat with ."
+#endif
+#if ENABLE_FEATURE_VI_YANKMARK
+	"\n\tLine marking with 'x"
+	"\n\tNamed buffers with \"x"
+#endif
+#if ENABLE_FEATURE_VI_READONLY
+	//not implemented: "\n\tReadonly if vi is called as \"view\""
+	//redundant: usage text says this too: "\n\tReadonly with -R command line arg"
+#endif
+#if ENABLE_FEATURE_VI_SET
+	"\n\tSome colon mode commands with :"
+#endif
+#if ENABLE_FEATURE_VI_SETOPTS
+	"\n\tSettable options with \":set\""
+#endif
+#if ENABLE_FEATURE_VI_USE_SIGNALS
+	"\n\tSignal catching- ^C"
+	"\n\tJob suspend and resume with ^Z"
+#endif
+#if ENABLE_FEATURE_VI_WIN_RESIZE
+	"\n\tAdapt to window re-sizes"
+#endif
+	);
+}
+
+#if ENABLE_FEATURE_VI_DOT_CMD
+static void start_new_cmd_q(char c)
+{
+	// get buffer for new cmd
+	// if there is a current cmd count put it in the buffer first
+	if (cmdcnt > 0) {
+		lmc_len = sprintf(last_modifying_cmd, "%d%c", cmdcnt, c);
+	} else { // just save char c onto queue
+		last_modifying_cmd[0] = c;
+		lmc_len = 1;
+	}
+	adding2q = 1;
+}
+
+static void end_cmd_q(void)
+{
+#if ENABLE_FEATURE_VI_YANKMARK
+	YDreg = 26;			// go back to default Yank/Delete reg
+#endif
+	adding2q = 0;
+}
+#endif /* FEATURE_VI_DOT_CMD */
+
+#if ENABLE_FEATURE_VI_YANKMARK \
+ || (ENABLE_FEATURE_VI_COLON && ENABLE_FEATURE_VI_SEARCH) \
+ || ENABLE_FEATURE_VI_CRASHME
+// might reallocate text[]! use p += string_insert(p, ...),
+// and be careful to not use pointers into potentially freed text[]!
+static uintptr_t string_insert(char *p, const char *s, int undo) // insert the string at 'p'
+{
+	uintptr_t bias;
+	int i;
+
+	i = strlen(s);
+#if ENABLE_FEATURE_VI_UNDO
+	switch (undo) {
+		case ALLOW_UNDO:
+			undo_push(p, i, UNDO_INS);
+			break;
+		case ALLOW_UNDO_CHAIN:
+			undo_push(p, i, UNDO_INS_CHAIN);
+			break;
+	}
+#endif
+	bias = text_hole_make(p, i);
+	p += bias;
+	memcpy(p, s, i);
+#if ENABLE_FEATURE_VI_YANKMARK
+	{
+		int cnt;
+		for (cnt = 0; *s != '\0'; s++) {
+			if (*s == '\n')
+				cnt++;
+		}
+		status_line("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
+	}
+#endif
+	return bias;
+}
+#endif
+
+#if ENABLE_FEATURE_VI_YANKMARK
+static char *text_yank(char *p, char *q, int dest)	// copy text into a register
+{
+	int cnt = q - p;
+	if (cnt < 0) {		// they are backwards- reverse them
+		p = q;
+		cnt = -cnt;
+	}
+	free(reg[dest]);	//  if already a yank register, free it
+	reg[dest] = xstrndup(p, cnt + 1);
+	return p;
+}
+
+static char what_reg(void)
+{
+	char c;
+
+	c = 'D';			// default to D-reg
+	if (0 <= YDreg && YDreg <= 25)
+		c = 'a' + (char) YDreg;
+	if (YDreg == 26)
+		c = 'D';
+	if (YDreg == 27)
+		c = 'U';
+	return c;
+}
+
+static void check_context(char cmd)
+{
+	// A context is defined to be "modifying text"
+	// Any modifying command establishes a new context.
+
+	if (dot < context_start || dot > context_end) {
+		if (strchr(modifying_cmds, cmd) != NULL) {
+			// we are trying to modify text[]- make this the current context
+			mark[27] = mark[26];	// move cur to prev
+			mark[26] = dot;	// move local to cur
+			context_start = prev_line(prev_line(dot));
+			context_end = next_line(next_line(dot));
+			//loiter= start_loiter= now;
+		}
+	}
+}
+
+static char *swap_context(char *p) // goto new context for '' command make this the current context
+{
+	char *tmp;
+
+	// the current context is in mark[26]
+	// the previous context is in mark[27]
+	// only swap context if other context is valid
+	if (text <= mark[27] && mark[27] <= end - 1) {
+		tmp = mark[27];
+		mark[27] = p;
+		mark[26] = p = tmp;
+		context_start = prev_line(prev_line(prev_line(p)));
+		context_end = next_line(next_line(next_line(p)));
+	}
+	return p;
+}
+#endif /* FEATURE_VI_YANKMARK */
+
+//----- Set terminal attributes --------------------------------
+static void rawmode(void)
+{
+	tcgetattr(0, &term_orig);
+	term_vi = term_orig;
+	term_vi.c_lflag &= (~ICANON & ~ECHO);	// leave ISIG on - allow intr's
+	term_vi.c_iflag &= (~IXON & ~ICRNL);
+	term_vi.c_oflag &= (~ONLCR);
+	term_vi.c_cc[VMIN] = 1;
+	term_vi.c_cc[VTIME] = 0;
+	erase_char = term_vi.c_cc[VERASE];
+	tcsetattr_stdin_TCSANOW(&term_vi);
+}
+
+static void cookmode(void)
+{
+	fflush_all();
+	tcsetattr_stdin_TCSANOW(&term_orig);
+}
+
+#if ENABLE_FEATURE_VI_USE_SIGNALS
+//----- Come here when we get a window resize signal ---------
+static void winch_sig(int sig UNUSED_PARAM)
+{
+	int save_errno = errno;
+	// FIXME: do it in main loop!!!
+	signal(SIGWINCH, winch_sig);
+	query_screen_dimensions();
+	new_screen(rows, columns);	// get memory for virtual screen
+	redraw(TRUE);		// re-draw the screen
+	errno = save_errno;
+}
+
+//----- Come here when we get a continue signal -------------------
+static void cont_sig(int sig UNUSED_PARAM)
+{
+	int save_errno = errno;
+	rawmode(); // terminal to "raw"
+	last_status_cksum = 0; // force status update
+	redraw(TRUE); // re-draw the screen
+
+	signal(SIGTSTP, suspend_sig);
+	signal(SIGCONT, SIG_DFL);
+	//kill(my_pid, SIGCONT); // huh? why? we are already "continued"...
+	errno = save_errno;
+}
+
+//----- Come here when we get a Suspend signal -------------------
+static void suspend_sig(int sig UNUSED_PARAM)
+{
+	int save_errno = errno;
+	go_bottom_and_clear_to_eol();
+	cookmode(); // terminal to "cooked"
+
+	signal(SIGCONT, cont_sig);
+	signal(SIGTSTP, SIG_DFL);
+	kill(my_pid, SIGTSTP);
+	errno = save_errno;
+}
+
+//----- Come here when we get a signal ---------------------------
+static void catch_sig(int sig)
+{
+	signal(SIGINT, catch_sig);
+	siglongjmp(restart, sig);
+}
+#endif /* FEATURE_VI_USE_SIGNALS */
+
+static int mysleep(int hund)	// sleep for 'hund' 1/100 seconds or stdin ready
+{
+	struct pollfd pfd[1];
+
+	if (hund != 0)
+		fflush_all();
+
+	pfd[0].fd = STDIN_FILENO;
+	pfd[0].events = POLLIN;
+	return safe_poll(pfd, 1, hund*10) > 0;
+}
+
+//----- IO Routines --------------------------------------------
+static int readit(void) // read (maybe cursor) key from stdin
+{
+	int c;
+
+	fflush_all();
+	c = read_key(STDIN_FILENO, readbuffer, /*timeout off:*/ -2);
+	if (c == -1) { // EOF/error
+		go_bottom_and_clear_to_eol();
+		cookmode(); // terminal to "cooked"
+		bb_error_msg_and_die("can't read user input");
+	}
+	return c;
+}
+
+//----- IO Routines --------------------------------------------
+static int get_one_char(void)
+{
+	int c;
+
+#if ENABLE_FEATURE_VI_DOT_CMD
+	if (!adding2q) {
+		// we are not adding to the q.
+		// but, we may be reading from a q
+		if (ioq == 0) {
+			// there is no current q, read from STDIN
+			c = readit();	// get the users input
+		} else {
+			// there is a queue to get chars from first
+			// careful with correct sign expansion!
+			c = (unsigned char)*ioq++;
+			if (c == '\0') {
+				// the end of the q, read from STDIN
+				free(ioq_start);
+				ioq_start = ioq = 0;
+				c = readit();	// get the users input
+			}
+		}
+	} else {
+		// adding STDIN chars to q
+		c = readit();	// get the users input
+		if (lmc_len >= MAX_INPUT_LEN - 1) {
+			status_line_bold("last_modifying_cmd overrun");
+		} else {
+			// add new char to q
+			last_modifying_cmd[lmc_len++] = c;
+		}
+	}
+#else
+	c = readit();		// get the users input
+#endif /* FEATURE_VI_DOT_CMD */
+	return c;
+}
+
+// Get input line (uses "status line" area)
+static char *get_input_line(const char *prompt)
+{
+	// char [MAX_INPUT_LEN]
+#define buf get_input_line__buf
+
+	int c;
+	int i;
+
+	strcpy(buf, prompt);
+	last_status_cksum = 0;	// force status update
+	go_bottom_and_clear_to_eol();
+	write1(prompt);      // write out the :, /, or ? prompt
+
+	i = strlen(buf);
+	while (i < MAX_INPUT_LEN) {
+		c = get_one_char();
+		if (c == '\n' || c == '\r' || c == 27)
+			break;		// this is end of input
+		if (c == erase_char || c == 8 || c == 127) {
+			// user wants to erase prev char
+			buf[--i] = '\0';
+			write1("\b \b"); // erase char on screen
+			if (i <= 0) // user backs up before b-o-l, exit
+				break;
+		} else if (c > 0 && c < 256) { // exclude Unicode
+			// (TODO: need to handle Unicode)
+			buf[i] = c;
+			buf[++i] = '\0';
+			bb_putchar(c);
+		}
+	}
+	refresh(FALSE);
+	return buf;
+#undef buf
+}
+
+// might reallocate text[]!
+static int file_insert(const char *fn, char *p, int initial)
+{
+	int cnt = -1;
+	int fd, size;
+	struct stat statbuf;
+
+	if (p < text)
+		p = text;
+	if (p > end)
+		p = end;
+
+	fd = open(fn, O_RDONLY);
+	if (fd < 0) {
+		if (!initial)
+			status_line_bold_errno(fn);
+		return cnt;
+	}
+
+	/* Validate file */
+//	if (fstat(fd, &statbuf) < 0) {
+	if (stat(fn, &statbuf) < 0) {
+		status_line_bold_errno(fn);
+		goto fi;
+	}
+	if (!S_ISREG(statbuf.st_mode)) {
+		status_line_bold("'%s' is not a regular file", fn);
+		goto fi;
+	}
+	size = (statbuf.st_size < INT_MAX ? (int)statbuf.st_size : INT_MAX);
+	p += text_hole_make(p, size);
+	cnt = full_read(fd, p, size);
+	if (cnt < 0) {
+		status_line_bold_errno(fn);
+		p = text_hole_delete(p, p + size - 1, NO_UNDO);	// un-do buffer insert
+	} else if (cnt < size) {
+		// There was a partial read, shrink unused space
+		p = text_hole_delete(p + cnt, p + size - 1, NO_UNDO);
+		status_line_bold("can't read '%s'", fn);
+	}
+ fi:
+	close(fd);
+
+#if ENABLE_FEATURE_VI_READONLY
+	if (initial
+	 && ((access(fn, W_OK) < 0) ||
+		/* root will always have access()
+		 * so we check fileperms too */
+		!(statbuf.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH))
+	    )
+	) {
+		SET_READONLY_FILE(readonly_mode);
+	}
+#endif
+	return cnt;
+}
+
+static int file_write(char *fn, char *first, char *last)
+{
+	int fd, cnt, charcnt;
+
+	if (fn == 0) {
+		status_line_bold("No current filename");
+		return -2;
+	}
+	/* By popular request we do not open file with O_TRUNC,
+	 * but instead ftruncate() it _after_ successful write.
+	 * Might reduce amount of data lost on power fail etc.
+	 */
+	fd = open(fn, (O_WRONLY | O_CREAT), 0666);
+	if (fd < 0)
+		return -1;
+	cnt = last - first + 1;
+	charcnt = full_write(fd, first, cnt);
+	ftruncate(fd, charcnt);
+	if (charcnt == cnt) {
+		// good write
+		//modified_count = FALSE;
+	} else {
+		charcnt = 0;
+	}
+	close(fd);
+	return charcnt;
+}
+
+//----- Terminal Drawing ---------------------------------------
+// The terminal is made up of 'rows' line of 'columns' columns.
+// classically this would be 24 x 80.
+//  screen coordinates
+//  0,0     ...     0,79
+//  1,0     ...     1,79
+//  .       ...     .
+//  .       ...     .
+//  22,0    ...     22,79
+//  23,0    ...     23,79   <- status line
+
+//----- Move the cursor to row x col (count from 0, not 1) -------
+static void place_cursor(int row, int col)
+{
+	char cm1[sizeof(ESC_SET_CURSOR_POS) + sizeof(int)*3 * 2];
+
+	if (row < 0) row = 0;
+	if (row >= rows) row = rows - 1;
+	if (col < 0) col = 0;
+	if (col >= columns) col = columns - 1;
+
+	sprintf(cm1, ESC_SET_CURSOR_POS, row + 1, col + 1);
+	write1(cm1);
+}
+
+//----- Erase from cursor to end of line -----------------------
+static void clear_to_eol(void)
+{
+	write1(ESC_CLEAR2EOL);
+}
+
+static void go_bottom_and_clear_to_eol(void)
+{
+	place_cursor(rows - 1, 0);
+	clear_to_eol();
+}
+
+//----- Erase from cursor to end of screen -----------------------
+static void clear_to_eos(void)
+{
+	write1(ESC_CLEAR2EOS);
+}
+
+//----- Start standout mode ------------------------------------
+static void standout_start(void)
+{
+	write1(ESC_BOLD_TEXT);
+}
+
+//----- End standout mode --------------------------------------
+static void standout_end(void)
+{
+	write1(ESC_NORM_TEXT);
+}
+
+//----- Flash the screen  --------------------------------------
+static void flash(int h)
+{
+	standout_start();
+	redraw(TRUE);
+	mysleep(h);
+	standout_end();
+	redraw(TRUE);
+}
+
+static void indicate_error(void)
+{
+#if ENABLE_FEATURE_VI_CRASHME
+	if (crashme > 0)
+		return;			// generate a random command
+#endif
+	if (!err_method) {
+		write1(ESC_BELL);
+	} else {
+		flash(10);
+	}
+}
+
+//----- Screen[] Routines --------------------------------------
+//----- Erase the Screen[] memory ------------------------------
+static void screen_erase(void)
+{
+	memset(screen, ' ', screensize);	// clear new screen
+}
+
+static int bufsum(char *buf, int count)
+{
+	int sum = 0;
+	char *e = buf + count;
+
+	while (buf < e)
+		sum += (unsigned char) *buf++;
+	return sum;
+}
+
+//----- Draw the status line at bottom of the screen -------------
+static void show_status_line(void)
+{
+	int cnt = 0, cksum = 0;
+
+	// either we already have an error or status message, or we
+	// create one.
+	if (!have_status_msg) {
+		cnt = format_edit_status();
+		cksum = bufsum(status_buffer, cnt);
+	}
+	if (have_status_msg || ((cnt > 0 && last_status_cksum != cksum))) {
+		last_status_cksum = cksum;		// remember if we have seen this line
+		go_bottom_and_clear_to_eol();
+		write1(status_buffer);
+		if (have_status_msg) {
+			if (((int)strlen(status_buffer) - (have_status_msg - 1)) >
+					(columns - 1) ) {
+				have_status_msg = 0;
+				Hit_Return();
+			}
+			have_status_msg = 0;
+		}
+		place_cursor(crow, ccol);  // put cursor back in correct place
+	}
+	fflush_all();
+}
+
+//----- format the status buffer, the bottom line of screen ------
+// format status buffer, with STANDOUT mode
+static void status_line_bold(const char *format, ...)
+{
+	va_list args;
+
+	va_start(args, format);
+	strcpy(status_buffer, ESC_BOLD_TEXT);
+	vsprintf(status_buffer + sizeof(ESC_BOLD_TEXT)-1, format, args);
+	strcat(status_buffer, ESC_NORM_TEXT);
+	va_end(args);
+
+	have_status_msg = 1 + sizeof(ESC_BOLD_TEXT) + sizeof(ESC_NORM_TEXT) - 2;
+}
+
+static void status_line_bold_errno(const char *fn)
+{
+	status_line_bold("'%s' %s", fn, strerror(errno));
+}
+
+// format status buffer
+static void status_line(const char *format, ...)
+{
+	va_list args;
+
+	va_start(args, format);
+	vsprintf(status_buffer, format, args);
+	va_end(args);
+
+	have_status_msg = 1;
+}
+
+// copy s to buf, convert unprintable
+static void print_literal(char *buf, const char *s)
+{
+	char *d;
+	unsigned char c;
+
+	buf[0] = '\0';
+	if (!s[0])
+		s = "(NULL)";
+
+	d = buf;
+	for (; *s; s++) {
+		int c_is_no_print;
+
+		c = *s;
+		c_is_no_print = (c & 0x80) && !Isprint(c);
+		if (c_is_no_print) {
+			strcpy(d, ESC_NORM_TEXT);
+			d += sizeof(ESC_NORM_TEXT)-1;
+			c = '.';
+		}
+		if (c < ' ' || c == 0x7f) {
+			*d++ = '^';
+			c |= '@'; /* 0x40 */
+			if (c == 0x7f)
+				c = '?';
+		}
+		*d++ = c;
+		*d = '\0';
+		if (c_is_no_print) {
+			strcpy(d, ESC_BOLD_TEXT);
+			d += sizeof(ESC_BOLD_TEXT)-1;
+		}
+		if (*s == '\n') {
+			*d++ = '$';
+			*d = '\0';
+		}
+		if (d - buf > MAX_INPUT_LEN - 10) // paranoia
+			break;
+	}
+}
+
+static void not_implemented(const char *s)
+{
+	char buf[MAX_INPUT_LEN];
+
+	print_literal(buf, s);
+	status_line_bold("\'%s\' is not implemented", buf);
+}
+
+// show file status on status line
+static int format_edit_status(void)
+{
+	static const char cmd_mode_indicator[] ALIGN1 = "-IR-";
+
+#define tot format_edit_status__tot
+
+	int cur, percent, ret, trunc_at;
+
+	// modified_count is now a counter rather than a flag.  this
+	// helps reduce the amount of line counting we need to do.
+	// (this will cause a mis-reporting of modified status
+	// once every MAXINT editing operations.)
+
+	// it would be nice to do a similar optimization here -- if
+	// we haven't done a motion that could have changed which line
+	// we're on, then we shouldn't have to do this count_lines()
+	cur = count_lines(text, dot);
+
+	// count_lines() is expensive.
+	// Call it only if something was changed since last time
+	// we were here:
+	if (modified_count != last_modified_count) {
+		tot = cur + count_lines(dot, end - 1) - 1;
+		last_modified_count = modified_count;
+	}
+
+	//    current line         percent
+	//   -------------    ~~ ----------
+	//    total lines            100
+	if (tot > 0) {
+		percent = (100 * cur) / tot;
+	} else {
+		cur = tot = 0;
+		percent = 100;
+	}
+
+	trunc_at = columns < STATUS_BUFFER_LEN-1 ?
+		columns : STATUS_BUFFER_LEN-1;
+
+	ret = snprintf(status_buffer, trunc_at+1,
+#if ENABLE_FEATURE_VI_READONLY
+		"%c %s%s%s %d/%d %d%%",
+#else
+		"%c %s%s %d/%d %d%%",
+#endif
+		cmd_mode_indicator[cmd_mode & 3],
+		(current_filename != NULL ? current_filename : "No file"),
+#if ENABLE_FEATURE_VI_READONLY
+		(readonly_mode ? " [Readonly]" : ""),
+#endif
+		(modified_count ? " [Modified]" : ""),
+		cur, tot, percent);
+
+	if (ret >= 0 && ret < trunc_at)
+		return ret;  /* it all fit */
+
+	return trunc_at;  /* had to truncate */
+#undef tot
+}
+
+//----- Force refresh of all Lines -----------------------------
+static void redraw(int full_screen)
+{
+	place_cursor(0, 0);
+	clear_to_eos();
+	screen_erase();		// erase the internal screen buffer
+	last_status_cksum = 0;	// force status update
+	refresh(full_screen);	// this will redraw the entire display
+	show_status_line();
+}
+
+//----- Format a text[] line into a buffer ---------------------
+static char* format_line(char *src /*, int li*/)
+{
+	unsigned char c;
+	int co;
+	int ofs = offset;
+	char *dest = scr_out_buf; // [MAX_SCR_COLS + MAX_TABSTOP * 2]
+
+	c = '~'; // char in col 0 in non-existent lines is '~'
+	co = 0;
+	while (co < columns + tabstop) {
+		// have we gone past the end?
+		if (src < end) {
+			c = *src++;
+			if (c == '\n')
+				break;
+			if ((c & 0x80) && !Isprint(c)) {
+				c = '.';
+			}
+			if (c < ' ' || c == 0x7f) {
+				if (c == '\t') {
+					c = ' ';
+					//      co %    8     !=     7
+					while ((co % tabstop) != (tabstop - 1)) {
+						dest[co++] = c;
+					}
+				} else {
+					dest[co++] = '^';
+					if (c == 0x7f)
+						c = '?';
+					else
+						c += '@'; // Ctrl-X -> 'X'
+				}
+			}
+		}
+		dest[co++] = c;
+		// discard scrolled-off-to-the-left portion,
+		// in tabstop-sized pieces
+		if (ofs >= tabstop && co >= tabstop) {
+			memmove(dest, dest + tabstop, co);
+			co -= tabstop;
+			ofs -= tabstop;
+		}
+		if (src >= end)
+			break;
+	}
+	// check "short line, gigantic offset" case
+	if (co < ofs)
+		ofs = co;
+	// discard last scrolled off part
+	co -= ofs;
+	dest += ofs;
+	// fill the rest with spaces
+	if (co < columns)
+		memset(&dest[co], ' ', columns - co);
+	return dest;
+}
+
+//----- Refresh the changed screen lines -----------------------
+// Copy the source line from text[] into the buffer and note
+// if the current screenline is different from the new buffer.
+// If they differ then that line needs redrawing on the terminal.
+//
+static void refresh(int full_screen)
+{
+#define old_offset refresh__old_offset
+
+	int li, changed;
+	char *tp, *sp;		// pointer into text[] and screen[]
+
+	if (ENABLE_FEATURE_VI_WIN_RESIZE IF_FEATURE_VI_ASK_TERMINAL(&& !G.get_rowcol_error) ) {
+		unsigned c = columns, r = rows;
+		query_screen_dimensions();
+		full_screen |= (c - columns) | (r - rows);
+	}
+	sync_cursor(dot, &crow, &ccol);	// where cursor will be (on "dot")
+	tp = screenbegin;	// index into text[] of top line
+
+	// compare text[] to screen[] and mark screen[] lines that need updating
+	for (li = 0; li < rows - 1; li++) {
+		int cs, ce;				// column start & end
+		char *out_buf;
+		// format current text line
+		out_buf = format_line(tp /*, li*/);
+
+		// skip to the end of the current text[] line
+		if (tp < end) {
+			char *t = memchr(tp, '\n', end - tp);
+			if (!t) t = end - 1;
+			tp = t + 1;
+		}
+
+		// see if there are any changes between virtual screen and out_buf
+		changed = FALSE;	// assume no change
+		cs = 0;
+		ce = columns - 1;
+		int cursor_column = 0;
+		sp = &screen[li * columns];	// start of screen line
+		if (full_screen) {
+			// force re-draw of every single column from 0 - columns-1
+			goto re0;
+		}
+		// compare newly formatted buffer with virtual screen
+		// look forward for first difference between buf and screen
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+		for (; cs <= ce; cs++) {
+			if (out_buf[cs] != sp[cs]) {
+				changed = TRUE;	// mark for redraw
+				break;
+			}
+		}
+#else
+		while (cs <= ce) {
+			int code_size;
+			unsigned short tmp_code = Utf8_to_Utf16(&sp[cs], &code_size);
+			if (memcmp(&out_buf[cs], &sp[cs], code_size)) {
+				changed = TRUE;	// mark for redraw
+				break;
+			}
+			cs += code_size;
+			cursor_column += (code_size > 1 ? 2 : 1);
+		}
+#endif
+		// look backward for last difference between out_buf and screen
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+		for (; ce >= cs; ce--) {
+			if (out_buf[ce] != sp[ce]) {
+				changed = TRUE;	// mark for redraw
+				break;
+			}
+		}
+#else
+		while (ce >= cs) {
+			int code_size = bs_char_count(sp, ce);
+			if (memcmp(&out_buf[ce], &sp[ce], code_size)) {
+				changed = TRUE;	// mark for redraw
+				break;
+			}
+			ce -= code_size;
+		}
+#endif
+		// now, cs is index of first diff, and ce is index of last diff
+
+		// if horz offset has changed, force a redraw
+		if (offset != old_offset) {
+ re0:
+			changed = TRUE;
+		}
+
+		// make a sanity check of columns indexes
+		if (cs < 0) { cs = 0; cursor_column = 0; }
+		if (ce > columns - 1) ce = columns - 1;
+		if (cs > ce) { cs = 0; ce = columns - 1; cursor_column = 0; }
+		// is there a change between virtual screen and out_buf
+		if (changed) {
+			// copy changed part of buffer to virtual screen
+			memcpy(sp+cs, out_buf+cs, ce-cs+1);
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+			place_cursor(li, cs);
+#else
+			place_cursor(li, cursor_column);
+#endif
+			// write line out to terminal
+			fwrite(&sp[cs], ce - cs + 1, 1, stdout);
+		}
+	}
+
+	place_cursor(crow, ccol);
+
+	old_offset = offset;
+#undef old_offset
+}
+
+//---------------------------------------------------------------------
+//----- the Ascii Chart -----------------------------------------------
+//
+//  00 nul   01 soh   02 stx   03 etx   04 eot   05 enq   06 ack   07 bel
+//  08 bs    09 ht    0a nl    0b vt    0c np    0d cr    0e so    0f si
+//  10 dle   11 dc1   12 dc2   13 dc3   14 dc4   15 nak   16 syn   17 etb
+//  18 can   19 em    1a sub   1b esc   1c fs    1d gs    1e rs    1f us
+//  20 sp    21 !     22 "     23 #     24 $     25 %     26 &     27 '
+//  28 (     29 )     2a *     2b +     2c ,     2d -     2e .     2f /
+//  30 0     31 1     32 2     33 3     34 4     35 5     36 6     37 7
+//  38 8     39 9     3a :     3b ;     3c <     3d =     3e >     3f ?
+//  40 @     41 A     42 B     43 C     44 D     45 E     46 F     47 G
+//  48 H     49 I     4a J     4b K     4c L     4d M     4e N     4f O
+//  50 P     51 Q     52 R     53 S     54 T     55 U     56 V     57 W
+//  58 X     59 Y     5a Z     5b [     5c \     5d ]     5e ^     5f _
+//  60 `     61 a     62 b     63 c     64 d     65 e     66 f     67 g
+//  68 h     69 i     6a j     6b k     6c l     6d m     6e n     6f o
+//  70 p     71 q     72 r     73 s     74 t     75 u     76 v     77 w
+//  78 x     79 y     7a z     7b {     7c |     7d }     7e ~     7f del
+//---------------------------------------------------------------------
+
+//----- Execute a Vi Command -----------------------------------
+static void do_cmd(int c)
+{
+	char *p, *q, *save_dot;
+	char buf[12];
+	int dir;
+	int cnt, i, j;
+	int c1;
+
+//	c1 = c; // quiet the compiler
+//	cnt = yf = 0; // quiet the compiler
+//	p = q = save_dot = buf; // quiet the compiler
+	memset(buf, '\0', sizeof(buf));
+
+	show_status_line();
+
+	/* if this is a cursor key, skip these checks */
+	switch (c) {
+		case KEYCODE_UP:
+		case KEYCODE_DOWN:
+		case KEYCODE_LEFT:
+		case KEYCODE_RIGHT:
+		case KEYCODE_HOME:
+		case KEYCODE_END:
+		case KEYCODE_PAGEUP:
+		case KEYCODE_PAGEDOWN:
+		case KEYCODE_DELETE:
+			goto key_cmd_mode;
+	}
+
+	if (cmd_mode == 2) {
+		//  flip-flop Insert/Replace mode
+		if (c == KEYCODE_INSERT)
+			goto dc_i;
+		// we are 'R'eplacing the current *dot with new char
+		if (*dot == '\n') {
+			// don't Replace past E-o-l
+			cmd_mode = 1;	// convert to insert
+			undo_queue_commit();
+		} else {
+			if (1 <= c || Isprint(c)) {
+				if (c != 27)
+					dot = yank_delete(dot, dot, 0, YANKDEL, ALLOW_UNDO);	// delete char
+				dot = char_insert(dot, c, ALLOW_UNDO_CHAIN);	// insert new char
+			}
+			goto dc1;
+		}
+	}
+	if (cmd_mode == 1) {
+		//  hitting "Insert" twice means "R" replace mode
+		if (c == KEYCODE_INSERT) goto dc5;
+		// insert the char c at "dot"
+		if (1 <= c || Isprint(c)) {
+			dot = char_insert(dot, c, ALLOW_UNDO_QUEUED);
+		}
+		goto dc1;
+	}
+
+ key_cmd_mode:
+	switch (c) {
+		//case 0x01:	// soh
+		//case 0x09:	// ht
+		//case 0x0b:	// vt
+		//case 0x0e:	// so
+		//case 0x0f:	// si
+		//case 0x10:	// dle
+		//case 0x11:	// dc1
+		//case 0x13:	// dc3
+#if ENABLE_FEATURE_VI_CRASHME
+	case 0x14:			// dc4  ctrl-T
+		crashme = (crashme == 0) ? 1 : 0;
+		break;
+#endif
+		//case 0x16:	// syn
+		//case 0x17:	// etb
+		//case 0x18:	// can
+		//case 0x1c:	// fs
+		//case 0x1d:	// gs
+		//case 0x1e:	// rs
+		//case 0x1f:	// us
+		//case '!':	// !-
+		//case '#':	// #-
+		//case '&':	// &-
+		//case '(':	// (-
+		//case ')':	// )-
+		//case '*':	// *-
+		//case '=':	// =-
+		//case '@':	// @-
+		//case 'F':	// F-
+		//case 'K':	// K-
+		//case 'Q':	// Q-
+		//case 'S':	// S-
+		//case 'T':	// T-
+		//case 'V':	// V-
+		//case '[':	// [-
+		//case '\\':	// \-
+		//case ']':	// ]-
+		//case '_':	// _-
+		//case '`':	// `-
+		//case 'v':	// v-
+	default:			// unrecognized command
+		buf[0] = c;
+		buf[1] = '\0';
+		not_implemented(buf);
+		end_cmd_q();	// stop adding to q
+	case 0x00:			// nul- ignore
+		break;
+	case 2:			// ctrl-B  scroll up   full screen
+	case KEYCODE_PAGEUP:	// Cursor Key Page Up
+		dot_scroll(rows - 2, -1);
+		break;
+	case 4:			// ctrl-D  scroll down half screen
+		dot_scroll((rows - 2) / 2, 1);
+		break;
+	case 5:			// ctrl-E  scroll down one line
+		dot_scroll(1, 1);
+		break;
+	case 6:			// ctrl-F  scroll down full screen
+	case KEYCODE_PAGEDOWN:	// Cursor Key Page Down
+		dot_scroll(rows - 2, 1);
+		break;
+	case 7:			// ctrl-G  show current status
+		last_status_cksum = 0;	// force status update
+		break;
+	case 'h':			// h- move left
+	case KEYCODE_LEFT:	// cursor key Left
+	case 8:		// ctrl-H- move left    (This may be ERASE char)
+	case 0x7f:	// DEL- move left   (This may be ERASE char)
+		do {
+			dot_left();
+		} while (--cmdcnt > 0);
+		break;
+	case 10:			// Newline ^J
+	case 'j':			// j- goto next line, same col
+	case KEYCODE_DOWN:	// cursor key Down
+		do {
+			dot_next();		// go to next B-o-l
+			// try stay in same col
+			dot = move_to_col(dot, ccol + offset);
+		} while (--cmdcnt > 0);
+		break;
+	case 12:			// ctrl-L  force redraw whole screen
+	case 18:			// ctrl-R  force redraw
+		place_cursor(0, 0);
+		clear_to_eos();
+		//mysleep(10); // why???
+		screen_erase();	// erase the internal screen buffer
+		last_status_cksum = 0;	// force status update
+		refresh(TRUE);	// this will redraw the entire display
+		break;
+	case 13:			// Carriage Return ^M
+	case '+':			// +- goto next line
+		do {
+			dot_next();
+			dot_skip_over_ws();
+		} while (--cmdcnt > 0);
+		break;
+	case 21:			// ctrl-U  scroll up   half screen
+		dot_scroll((rows - 2) / 2, -1);
+		break;
+	case 25:			// ctrl-Y  scroll up one line
+		dot_scroll(1, -1);
+		break;
+	case 27:			// esc
+		if (cmd_mode == 0)
+			indicate_error();
+		cmd_mode = 0;	// stop insrting
+		undo_queue_commit();
+		end_cmd_q();
+		last_status_cksum = 0;	// force status update
+		break;
+	case ' ':			// move right
+	case 'l':			// move right
+	case KEYCODE_RIGHT:	// Cursor Key Right
+		do {
+			dot_right();
+		} while (--cmdcnt > 0);
+		break;
+#if ENABLE_FEATURE_VI_YANKMARK
+	case '"':			// "- name a register to use for Delete/Yank
+		c1 = (get_one_char() | 0x20) - 'a'; // | 0x20 is tolower()
+		if ((unsigned)c1 <= 25) { // a-z?
+			YDreg = c1;
+		} else {
+			indicate_error();
+		}
+		break;
+	case '\'':			// '- goto a specific mark
+		c1 = (get_one_char() | 0x20);
+		if ((unsigned)(c1 - 'a') <= 25) { // a-z?
+			c1 = (c1 - 'a');
+			// get the b-o-l
+			q = mark[c1];
+			if (text <= q && q < end) {
+				dot = q;
+				dot_begin();	// go to B-o-l
+				dot_skip_over_ws();
+			}
+		} else if (c1 == '\'') {	// goto previous context
+			dot = swap_context(dot);	// swap current and previous context
+			dot_begin();	// go to B-o-l
+			dot_skip_over_ws();
+		} else {
+			indicate_error();
+		}
+		break;
+	case 'm':			// m- Mark a line
+		// this is really stupid.  If there are any inserts or deletes
+		// between text[0] and dot then this mark will not point to the
+		// correct location! It could be off by many lines!
+		// Well..., at least its quick and dirty.
+		c1 = (get_one_char() | 0x20) - 'a';
+		if ((unsigned)c1 <= 25) { // a-z?
+			// remember the line
+			mark[c1] = dot;
+		} else {
+			indicate_error();
+		}
+		break;
+	case 'P':			// P- Put register before
+	case 'p':			// p- put register after
+		p = reg[YDreg];
+		if (p == NULL) {
+			status_line_bold("Nothing in register %c", what_reg());
+			break;
+		}
+		// are we putting whole lines or strings
+		if (strchr(p, '\n') != NULL) {
+			if (c == 'P') {
+				dot_begin();	// putting lines- Put above
+			}
+			if (c == 'p') {
+				// are we putting after very last line?
+				if (end_line(dot) == (end - 1)) {
+					dot = end;	// force dot to end of text[]
+				} else {
+					dot_next();	// next line, then put before
+				}
+			}
+		} else {
+			if (c == 'p')
+				dot_right();	// move to right, can move to NL
+		}
+		string_insert(dot, p, ALLOW_UNDO);	// insert the string
+		end_cmd_q();	// stop adding to q
+		break;
+	case 'U':			// U- Undo; replace current line with original version
+		if (reg[Ureg] != NULL) {
+			p = begin_line(dot);
+			q = end_line(dot);
+			p = text_hole_delete(p, q, ALLOW_UNDO);	// delete cur line
+			p += string_insert(p, reg[Ureg], ALLOW_UNDO_CHAIN);	// insert orig line
+			dot = p;
+			dot_skip_over_ws();
+		}
+		break;
+#endif /* FEATURE_VI_YANKMARK */
+#if ENABLE_FEATURE_VI_UNDO
+	case 'u':	// u- undo last operation
+		undo_pop();
+		break;
+#endif
+	case '$':			// $- goto end of line
+	case KEYCODE_END:		// Cursor Key End
+		for (;;) {
+			dot = end_line(dot);
+			if (--cmdcnt <= 0)
+				break;
+			dot_next();
+		}
+		break;
+	case '%':			// %- find matching char of pair () [] {}
+		for (q = dot; q < end && *q != '\n'; q++) {
+			if (strchr("()[]{}", *q) != NULL) {
+				// we found half of a pair
+				p = find_pair(q, *q);
+				if (p == NULL) {
+					indicate_error();
+				} else {
+					dot = p;
+				}
+				break;
+			}
+		}
+		if (*q == '\n')
+			indicate_error();
+		break;
+	case 'f':			// f- forward to a user specified char
+		last_forward_char = get_one_char();	// get the search char
+		//
+		// dont separate these two commands. 'f' depends on ';'
+		//
+		//**** fall through to ... ';'
+	case ';':			// ;- look at rest of line for last forward char
+		do {
+			if (last_forward_char == 0)
+				break;
+			q = dot + 1;
+			while (q < end - 1 && *q != '\n' && *q != last_forward_char) {
+				q++;
+			}
+			if (*q == last_forward_char)
+				dot = q;
+		} while (--cmdcnt > 0);
+		break;
+	case ',':           // repeat latest 'f' in opposite direction
+		if (last_forward_char == 0)
+			break;
+		do {
+			q = dot - 1;
+			while (q >= text && *q != '\n' && *q != last_forward_char) {
+				q--;
+			}
+			if (q >= text && *q == last_forward_char)
+				dot = q;
+		} while (--cmdcnt > 0);
+		break;
+
+	case '-':			// -- goto prev line
+		do {
+			dot_prev();
+			dot_skip_over_ws();
+		} while (--cmdcnt > 0);
+		break;
+#if ENABLE_FEATURE_VI_DOT_CMD
+	case '.':			// .- repeat the last modifying command
+		// Stuff the last_modifying_cmd back into stdin
+		// and let it be re-executed.
+		if (lmc_len > 0) {
+			last_modifying_cmd[lmc_len] = 0;
+			ioq = ioq_start = xstrdup(last_modifying_cmd);
+		}
+		break;
+#endif
+#if ENABLE_FEATURE_VI_SEARCH
+	case '?':			// /- search for a pattern
+	case '/':			// /- search for a pattern
+		buf[0] = c;
+		buf[1] = '\0';
+		q = get_input_line(buf);	// get input line- use "status line"
+		if (q[0] && !q[1]) {
+			if (last_search_pattern[0])
+				last_search_pattern[0] = c;
+			goto dc3; // if no pat re-use old pat
+		}
+		if (q[0]) {       // strlen(q) > 1: new pat- save it and find
+			// there is a new pat
+			free(last_search_pattern);
+			last_search_pattern = xstrdup(q);
+			goto dc3;	// now find the pattern
+		}
+		// user changed mind and erased the "/"-  do nothing
+		break;
+	case 'N':			// N- backward search for last pattern
+		dir = BACK;		// assume BACKWARD search
+		p = dot - 1;
+		if (last_search_pattern[0] == '?') {
+			dir = FORWARD;
+			p = dot + 1;
+		}
+		goto dc4;		// now search for pattern
+		break;
+	case 'n':			// n- repeat search for last pattern
+		// search rest of text[] starting at next char
+		// if search fails return orignal "p" not the "p+1" address
+		do {
+			const char *msg;
+ dc3:
+			dir = FORWARD;	// assume FORWARD search
+			p = dot + 1;
+			if (last_search_pattern[0] == '?') {
+				dir = BACK;
+				p = dot - 1;
+			}
+ dc4:
+			q = char_search(p, last_search_pattern + 1, dir, FULL);
+			if (q != NULL) {
+				dot = q;	// good search, update "dot"
+				msg = NULL;
+				goto dc2;
+			}
+			// no pattern found between "dot" and "end"- continue at top
+			p = text;
+			if (dir == BACK) {
+				p = end - 1;
+			}
+			q = char_search(p, last_search_pattern + 1, dir, FULL);
+			if (q != NULL) {	// found something
+				dot = q;	// found new pattern- goto it
+				msg = "search hit BOTTOM, continuing at TOP";
+				if (dir == BACK) {
+					msg = "search hit TOP, continuing at BOTTOM";
+				}
+			} else {
+				msg = "Pattern not found";
+			}
+ dc2:
+			if (msg)
+				status_line_bold("%s", msg);
+		} while (--cmdcnt > 0);
+		break;
+	case '{':			// {- move backward paragraph
+		q = char_search(dot, "\n\n", BACK, FULL);
+		if (q != NULL) {	// found blank line
+			dot = next_line(q);	// move to next blank line
+		}
+		break;
+	case '}':			// }- move forward paragraph
+		q = char_search(dot, "\n\n", FORWARD, FULL);
+		if (q != NULL) {	// found blank line
+			dot = next_line(q);	// move to next blank line
+		}
+		break;
+#endif /* FEATURE_VI_SEARCH */
+	case '0':			// 0- goto beginning of line
+	case '1':			// 1-
+	case '2':			// 2-
+	case '3':			// 3-
+	case '4':			// 4-
+	case '5':			// 5-
+	case '6':			// 6-
+	case '7':			// 7-
+	case '8':			// 8-
+	case '9':			// 9-
+		if (c == '0' && cmdcnt < 1) {
+			dot_begin();	// this was a standalone zero
+		} else {
+			cmdcnt = cmdcnt * 10 + (c - '0');	// this 0 is part of a number
+		}
+		break;
+	case ':':			// :- the colon mode commands
+		p = get_input_line(":");	// get input line- use "status line"
+		colon(p);		// execute the command
+		break;
+	case '<':			// <- Left  shift something
+	case '>':			// >- Right shift something
+		cnt = count_lines(text, dot);	// remember what line we are on
+		c1 = get_one_char();	// get the type of thing to delete
+		find_range(&p, &q, c1);
+		yank_delete(p, q, 1, YANKONLY, NO_UNDO);	// save copy before change
+		p = begin_line(p);
+		q = end_line(q);
+		i = count_lines(p, q);	// # of lines we are shifting
+		for ( ; i > 0; i--, p = next_line(p)) {
+			if (c == '<') {
+				// shift left- remove tab or 8 spaces
+				if (*p == '\t') {
+					// shrink buffer 1 char
+					text_hole_delete(p, p, NO_UNDO);
+				} else if (*p == ' ') {
+					// we should be calculating columns, not just SPACE
+					for (j = 0; *p == ' ' && j < tabstop; j++) {
+						text_hole_delete(p, p, NO_UNDO);
+					}
+				}
+			} else if (c == '>') {
+				// shift right -- add tab or 8 spaces
+				char_insert(p, '\t', ALLOW_UNDO);
+			}
+		}
+		dot = find_line(cnt);	// what line were we on
+		dot_skip_over_ws();
+		end_cmd_q();	// stop adding to q
+		break;
+	case 'A':			// A- append at e-o-l
+		dot_end();		// go to e-o-l
+		//**** fall through to ... 'a'
+	case 'a':			// a- append after current char
+		if (*dot != '\n')
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+			dot++;
+#else
+		{
+			int code_size;
+			unsigned short tmp_code = Utf8_to_Utf16(dot, &code_size);
+			dot += code_size;
+		}
+#endif
+		goto dc_i;
+		break;
+	case 'B':			// B- back a blank-delimited Word
+	case 'E':			// E- end of a blank-delimited word
+	case 'W':			// W- forward a blank-delimited word
+		dir = FORWARD;
+		if (c == 'B')
+			dir = BACK;
+		do {
+			if (c == 'W' || isspace(dot[dir])) {
+				dot = skip_thing(dot, 1, dir, S_TO_WS);
+				dot = skip_thing(dot, 2, dir, S_OVER_WS);
+			}
+			if (c != 'W')
+				dot = skip_thing(dot, 1, dir, S_BEFORE_WS);
+		} while (--cmdcnt > 0);
+		break;
+	case 'C':			// C- Change to e-o-l
+	case 'D':			// D- delete to e-o-l
+		save_dot = dot;
+		dot = dollar_line(dot);	// move to before NL
+		// copy text into a register and delete
+		dot = yank_delete(save_dot, dot, 0, YANKDEL, ALLOW_UNDO);	// delete to e-o-l
+		if (c == 'C')
+			goto dc_i;	// start inserting
+#if ENABLE_FEATURE_VI_DOT_CMD
+		if (c == 'D')
+			end_cmd_q();	// stop adding to q
+#endif
+		break;
+	case 'g': // 'gg' goto a line number (vim) (default: very first line)
+		c1 = get_one_char();
+		if (c1 != 'g') {
+			buf[0] = 'g';
+			// c1 < 0 if the key was special. Try "g<up-arrow>"
+			// TODO: if Unicode?
+			buf[1] = (c1 >= 0 ? c1 : '*');
+			buf[2] = '\0';
+			not_implemented(buf);
+			break;
+		}
+		if (cmdcnt == 0)
+			cmdcnt = 1;
+		/* fall through */
+	case 'G':		// G- goto to a line number (default= E-O-F)
+		dot = end - 1;				// assume E-O-F
+		if (cmdcnt > 0) {
+			dot = find_line(cmdcnt);	// what line is #cmdcnt
+		}
+		dot_skip_over_ws();
+		break;
+	case 'H':			// H- goto top line on screen
+		dot = screenbegin;
+		if (cmdcnt > (rows - 1)) {
+			cmdcnt = (rows - 1);
+		}
+		if (--cmdcnt > 0) {
+			do_cmd('+');
+		}
+		dot_skip_over_ws();
+		break;
+	case 'I':			// I- insert before first non-blank
+		dot_begin();	// 0
+		dot_skip_over_ws();
+		//**** fall through to ... 'i'
+	case 'i':			// i- insert before current char
+	case KEYCODE_INSERT:	// Cursor Key Insert
+ dc_i:
+		cmd_mode = 1;	// start inserting
+		undo_queue_commit();	// commit queue when cmd_mode changes
+		break;
+	case 'J':			// J- join current and next lines together
+		do {
+			dot_end();		// move to NL
+			if (dot < end - 1) {	// make sure not last char in text[]
+#if ENABLE_FEATURE_VI_UNDO
+				undo_push(dot, 1, UNDO_DEL);
+				*dot++ = ' ';	// replace NL with space
+				undo_push((dot - 1), 1, UNDO_INS_CHAIN);
+#else
+				*dot++ = ' ';
+				modified_count++;
+#endif
+				while (isblank(*dot)) {	// delete leading WS
+					text_hole_delete(dot, dot, ALLOW_UNDO_CHAIN);
+				}
+			}
+		} while (--cmdcnt > 0);
+		end_cmd_q();	// stop adding to q
+		break;
+	case 'L':			// L- goto bottom line on screen
+		dot = end_screen();
+		if (cmdcnt > (rows - 1)) {
+			cmdcnt = (rows - 1);
+		}
+		if (--cmdcnt > 0) {
+			do_cmd('-');
+		}
+		dot_begin();
+		dot_skip_over_ws();
+		break;
+	case 'M':			// M- goto middle line on screen
+		dot = screenbegin;
+		for (cnt = 0; cnt < (rows-1) / 2; cnt++)
+			dot = next_line(dot);
+		break;
+	case 'O':			// O- open a empty line above
+		//    0i\n ESC -i
+		p = begin_line(dot);
+		if (p[-1] == '\n') {
+			dot_prev();
+	case 'o':			// o- open a empty line below; Yes, I know it is in the middle of the "if (..."
+			dot_end();
+			dot = char_insert(dot, '\n', ALLOW_UNDO);
+		} else {
+			dot_begin();	// 0
+			dot = char_insert(dot, '\n', ALLOW_UNDO);	// i\n ESC
+			dot_prev();	// -
+		}
+		goto dc_i;
+		break;
+	case 'R':			// R- continuous Replace char
+ dc5:
+		cmd_mode = 2;
+		undo_queue_commit();
+		break;
+	case KEYCODE_DELETE:
+		if (dot < end - 1)
+			dot = yank_delete(dot, dot, 1, YANKDEL, ALLOW_UNDO);
+		break;
+	case 'X':			// X- delete char before dot
+	case 'x':			// x- delete the current char
+	case 's':			// s- substitute the current char
+		dir = 0;
+		if (c == 'X')
+			dir = -1;
+		do {
+			if (dot[dir] != '\n') {
+				if (c == 'X')
+					dot--;	// delete prev char
+				dot = yank_delete(dot, dot, 0, YANKDEL, ALLOW_UNDO);	// delete char
+			}
+		} while (--cmdcnt > 0);
+		end_cmd_q();	// stop adding to q
+		if (c == 's')
+			goto dc_i;	// start inserting
+		break;
+	case 'Z':			// Z- if modified, {write}; exit
+		// ZZ means to save file (if necessary), then exit
+		c1 = get_one_char();
+		if (c1 != 'Z') {
+			indicate_error();
+			break;
+		}
+		if (modified_count) {
+			if (ENABLE_FEATURE_VI_READONLY && readonly_mode) {
+				status_line_bold("'%s' is read only", current_filename);
+				break;
+			}
+			cnt = file_write(current_filename, text, end - 1);
+			if (cnt < 0) {
+				if (cnt == -1)
+					status_line_bold("Write error: %s", strerror(errno));
+			} else if (cnt == (end - 1 - text + 1)) {
+				editing = 0;
+			}
+		} else {
+			editing = 0;
+		}
+		break;
+	case '^':			// ^- move to first non-blank on line
+		dot_begin();
+		dot_skip_over_ws();
+		break;
+	case 'b':			// b- back a word
+	case 'e':			// e- end of word
+		dir = FORWARD;
+		if (c == 'b')
+			dir = BACK;
+		do {
+			if ((dot + dir) < text || (dot + dir) > end - 1)
+				break;
+			dot += dir;
+			if (isspace(*dot)) {
+				dot = skip_thing(dot, (c == 'e') ? 2 : 1, dir, S_OVER_WS);
+			}
+			if (isalnum(*dot) || *dot == '_') {
+				dot = skip_thing(dot, 1, dir, S_END_ALNUM);
+			} else if (ispunct(*dot)) {
+				dot = skip_thing(dot, 1, dir, S_END_PUNCT);
+			}
+		} while (--cmdcnt > 0);
+		break;
+	case 'c':			// c- change something
+	case 'd':			// d- delete something
+#if ENABLE_FEATURE_VI_YANKMARK
+	case 'y':			// y- yank   something
+	case 'Y':			// Y- Yank a line
+#endif
+	{
+		int yf, ml, whole = 0;
+		yf = YANKDEL;	// assume either "c" or "d"
+#if ENABLE_FEATURE_VI_YANKMARK
+		if (c == 'y' || c == 'Y')
+			yf = YANKONLY;
+#endif
+		c1 = 'y';
+		if (c != 'Y')
+			c1 = get_one_char();	// get the type of thing to delete
+		// determine range, and whether it spans lines
+		ml = find_range(&p, &q, c1);
+		place_cursor(0, 0);
+		if (c1 == 27) {	// ESC- user changed mind and wants out
+			c = c1 = 27;	// Escape- do nothing
+		} else if (strchr("wW", c1)) {
+			if (c == 'c') {
+				// don't include trailing WS as part of word
+				while (isblank(*q)) {
+					if (q <= text || q[-1] == '\n')
+						break;
+					q--;
+				}
+			}
+			dot = yank_delete(p, q, ml, yf, ALLOW_UNDO);	// delete word
+		} else if (strchr("^0bBeEft%$ lh\b\177", c1)) {
+			// partial line copy text into a register and delete
+			dot = yank_delete(p, q, ml, yf, ALLOW_UNDO);	// delete word
+		} else if (strchr("cdykjHL+-{}\r\n", c1)) {
+			// whole line copy text into a register and delete
+			dot = yank_delete(p, q, ml, yf, ALLOW_UNDO);	// delete lines
+			whole = 1;
+		} else {
+			// could not recognize object
+			c = c1 = 27;	// error-
+			ml = 0;
+			indicate_error();
+		}
+		if (ml && whole) {
+			if (c == 'c') {
+				dot = char_insert(dot, '\n', ALLOW_UNDO_CHAIN);
+				// on the last line of file don't move to prev line
+				if (whole && dot != (end-1)) {
+					dot_prev();
+				}
+			} else if (c == 'd') {
+				dot_begin();
+				dot_skip_over_ws();
+			}
+		}
+		if (c1 != 27) {
+			// if CHANGING, not deleting, start inserting after the delete
+			if (c == 'c') {
+				strcpy(buf, "Change");
+				goto dc_i;	// start inserting
+			}
+			if (c == 'd') {
+				strcpy(buf, "Delete");
+			}
+#if ENABLE_FEATURE_VI_YANKMARK
+			if (c == 'y' || c == 'Y') {
+				strcpy(buf, "Yank");
+			}
+			p = reg[YDreg];
+			q = p + strlen(p);
+			for (cnt = 0; p <= q; p++) {
+				if (*p == '\n')
+					cnt++;
+			}
+			status_line("%s %d lines (%d chars) using [%c]",
+				buf, cnt, strlen(reg[YDreg]), what_reg());
+#endif
+			end_cmd_q();	// stop adding to q
+		}
+		break;
+	}
+	case 'k':			// k- goto prev line, same col
+	case KEYCODE_UP:		// cursor key Up
+		do {
+			dot_prev();
+			dot = move_to_col(dot, ccol + offset);	// try stay in same col
+		} while (--cmdcnt > 0);
+		break;
+	case 'r':			// r- replace the current char with user input
+		c1 = get_one_char();	// get the replacement char
+		if (*dot != '\n') {
+#if ENABLE_FEATURE_VI_UNDO
+			undo_push(dot, 1, UNDO_DEL);
+			*dot = c1;
+			undo_push(dot, 1, UNDO_INS_CHAIN);
+#else
+			*dot = c1;
+			modified_count++;
+#endif
+		}
+		end_cmd_q();	// stop adding to q
+		break;
+	case 't':			// t- move to char prior to next x
+		last_forward_char = get_one_char();
+		do_cmd(';');
+		if (*dot == last_forward_char)
+			dot_left();
+		last_forward_char = 0;
+		break;
+	case 'w':			// w- forward a word
+		do {
+			if (isalnum(*dot) || *dot == '_') {	// we are on ALNUM
+				dot = skip_thing(dot, 1, FORWARD, S_END_ALNUM);
+			} else if (ispunct(*dot)) {	// we are on PUNCT
+				dot = skip_thing(dot, 1, FORWARD, S_END_PUNCT);
+			}
+			if (dot < end - 1)
+				dot++;		// move over word
+			if (isspace(*dot)) {
+				dot = skip_thing(dot, 2, FORWARD, S_OVER_WS);
+			}
+		} while (--cmdcnt > 0);
+		break;
+	case 'z':			// z-
+		c1 = get_one_char();	// get the replacement char
+		cnt = 0;
+		if (c1 == '.')
+			cnt = (rows - 2) / 2;	// put dot at center
+		if (c1 == '-')
+			cnt = rows - 2;	// put dot at bottom
+		screenbegin = begin_line(dot);	// start dot at top
+		dot_scroll(cnt, -1);
+		break;
+	case '|':			// |- move to column "cmdcnt"
+		dot = move_to_col(dot, cmdcnt - 1);	// try to move to column
+		break;
+	case '~':			// ~- flip the case of letters   a-z -> A-Z
+		do {
+#if ENABLE_FEATURE_VI_UNDO
+			if (islower(*dot)) {
+				undo_push(dot, 1, UNDO_DEL);
+				*dot = toupper(*dot);
+				undo_push(dot, 1, UNDO_INS_CHAIN);
+			} else if (isupper(*dot)) {
+				undo_push(dot, 1, UNDO_DEL);
+				*dot = tolower(*dot);
+				undo_push(dot, 1, UNDO_INS_CHAIN);
+			}
+#else
+			if (islower(*dot)) {
+				*dot = toupper(*dot);
+				modified_count++;
+			} else if (isupper(*dot)) {
+				*dot = tolower(*dot);
+				modified_count++;
+			}
+#endif
+			dot_right();
+		} while (--cmdcnt > 0);
+		end_cmd_q();	// stop adding to q
+		break;
+		//----- The Cursor and Function Keys -----------------------------
+	case KEYCODE_HOME:	// Cursor Key Home
+		dot_begin();
+		break;
+		// The Fn keys could point to do_macro which could translate them
+#if 0
+	case KEYCODE_FUN1:	// Function Key F1
+	case KEYCODE_FUN2:	// Function Key F2
+	case KEYCODE_FUN3:	// Function Key F3
+	case KEYCODE_FUN4:	// Function Key F4
+	case KEYCODE_FUN5:	// Function Key F5
+	case KEYCODE_FUN6:	// Function Key F6
+	case KEYCODE_FUN7:	// Function Key F7
+	case KEYCODE_FUN8:	// Function Key F8
+	case KEYCODE_FUN9:	// Function Key F9
+	case KEYCODE_FUN10:	// Function Key F10
+	case KEYCODE_FUN11:	// Function Key F11
+	case KEYCODE_FUN12:	// Function Key F12
+		break;
+#endif
+	}
+
+ dc1:
+	// if text[] just became empty, add back an empty line
+	if (end == text) {
+		char_insert(text, '\n', NO_UNDO);	// start empty buf with dummy line
+		dot = text;
+	}
+	// it is OK for dot to exactly equal to end, otherwise check dot validity
+	if (dot != end) {
+		dot = bound_dot(dot);	// make sure "dot" is valid
+	}
+#if ENABLE_FEATURE_VI_YANKMARK
+	check_context(c);	// update the current context
+#endif
+
+	if (!isdigit(c))
+		cmdcnt = 0;		// cmd was not a number, reset cmdcnt
+	cnt = dot - begin_line(dot);
+	// Try to stay off of the Newline
+	if (*dot == '\n' && cnt > 0 && cmd_mode == 0)
+#ifndef ENABLE_BASIC_MULTI_CHAR_CODE
+		dot--;
+#else
+		dot -= bs_char_count(text, dot - text - 1);
+#endif
+}
+
+/* NB!  the CRASHME code is unmaintained, and doesn't currently build */
+#if ENABLE_FEATURE_VI_CRASHME
+static int totalcmds = 0;
+static int Mp = 85;             // Movement command Probability
+static int Np = 90;             // Non-movement command Probability
+static int Dp = 96;             // Delete command Probability
+static int Ip = 97;             // Insert command Probability
+static int Yp = 98;             // Yank command Probability
+static int Pp = 99;             // Put command Probability
+static int M = 0, N = 0, I = 0, D = 0, Y = 0, P = 0, U = 0;
+static const char chars[20] = "\t012345 abcdABCD-=.$";
+static const char *const words[20] = {
+	"this", "is", "a", "test",
+	"broadcast", "the", "emergency", "of",
+	"system", "quick", "brown", "fox",
+	"jumped", "over", "lazy", "dogs",
+	"back", "January", "Febuary", "March"
+};
+static const char *const lines[20] = {
+	"You should have received a copy of the GNU General Public License\n",
+	"char c, cm, *cmd, *cmd1;\n",
+	"generate a command by percentages\n",
+	"Numbers may be typed as a prefix to some commands.\n",
+	"Quit, discarding changes!\n",
+	"Forced write, if permission originally not valid.\n",
+	"In general, any ex or ed command (such as substitute or delete).\n",
+	"I have tickets available for the Blazers vs LA Clippers for Monday, Janurary 1 at 1:00pm.\n",
+	"Please get w/ me and I will go over it with you.\n",
+	"The following is a list of scheduled, committed changes.\n",
+	"1.   Launch Norton Antivirus (Start, Programs, Norton Antivirus)\n",
+	"Reminder....Town Meeting in Central Perk cafe today at 3:00pm.\n",
+	"Any question about transactions please contact Sterling Huxley.\n",
+	"I will try to get back to you by Friday, December 31.\n",
+	"This Change will be implemented on Friday.\n",
+	"Let me know if you have problems accessing this;\n",
+	"Sterling Huxley recently added you to the access list.\n",
+	"Would you like to go to lunch?\n",
+	"The last command will be automatically run.\n",
+	"This is too much english for a computer geek.\n",
+};
+static char *multilines[20] = {
+	"You should have received a copy of the GNU General Public License\n",
+	"char c, cm, *cmd, *cmd1;\n",
+	"generate a command by percentages\n",
+	"Numbers may be typed as a prefix to some commands.\n",
+	"Quit, discarding changes!\n",
+	"Forced write, if permission originally not valid.\n",
+	"In general, any ex or ed command (such as substitute or delete).\n",
+	"I have tickets available for the Blazers vs LA Clippers for Monday, Janurary 1 at 1:00pm.\n",
+	"Please get w/ me and I will go over it with you.\n",
+	"The following is a list of scheduled, committed changes.\n",
+	"1.   Launch Norton Antivirus (Start, Programs, Norton Antivirus)\n",
+	"Reminder....Town Meeting in Central Perk cafe today at 3:00pm.\n",
+	"Any question about transactions please contact Sterling Huxley.\n",
+	"I will try to get back to you by Friday, December 31.\n",
+	"This Change will be implemented on Friday.\n",
+	"Let me know if you have problems accessing this;\n",
+	"Sterling Huxley recently added you to the access list.\n",
+	"Would you like to go to lunch?\n",
+	"The last command will be automatically run.\n",
+	"This is too much english for a computer geek.\n",
+};
+
+// create a random command to execute
+static void crash_dummy()
+{
+	static int sleeptime;   // how long to pause between commands
+	char c, cm, *cmd, *cmd1;
+	int i, cnt, thing, rbi, startrbi, percent;
+
+	// "dot" movement commands
+	cmd1 = " \n\r\002\004\005\006\025\0310^$-+wWeEbBhjklHL";
+
+	// is there already a command running?
+	if (readbuffer[0] > 0)
+		goto cd1;
+ cd0:
+	readbuffer[0] = 'X';
+	startrbi = rbi = 1;
+	sleeptime = 0;          // how long to pause between commands
+	memset(readbuffer, '\0', sizeof(readbuffer));
+	// generate a command by percentages
+	percent = (int) lrand48() % 100;        // get a number from 0-99
+	if (percent < Mp) {     //  Movement commands
+		// available commands
+		cmd = cmd1;
+		M++;
+	} else if (percent < Np) {      //  non-movement commands
+		cmd = "mz<>\'\"";       // available commands
+		N++;
+	} else if (percent < Dp) {      //  Delete commands
+		cmd = "dx";             // available commands
+		D++;
+	} else if (percent < Ip) {      //  Inset commands
+		cmd = "iIaAsrJ";        // available commands
+		I++;
+	} else if (percent < Yp) {      //  Yank commands
+		cmd = "yY";             // available commands
+		Y++;
+	} else if (percent < Pp) {      //  Put commands
+		cmd = "pP";             // available commands
+		P++;
+	} else {
+		// We do not know how to handle this command, try again
+		U++;
+		goto cd0;
+	}
+	// randomly pick one of the available cmds from "cmd[]"
+	i = (int) lrand48() % strlen(cmd);
+	cm = cmd[i];
+	if (strchr(":\024", cm))
+		goto cd0;               // dont allow colon or ctrl-T commands
+	readbuffer[rbi++] = cm; // put cmd into input buffer
+
+	// now we have the command-
+	// there are 1, 2, and multi char commands
+	// find out which and generate the rest of command as necessary
+	if (strchr("dmryz<>\'\"", cm)) {        // 2-char commands
+		cmd1 = " \n\r0$^-+wWeEbBhjklHL";
+		if (cm == 'm' || cm == '\'' || cm == '\"') {    // pick a reg[]
+			cmd1 = "abcdefghijklmnopqrstuvwxyz";
+		}
+		thing = (int) lrand48() % strlen(cmd1); // pick a movement command
+		c = cmd1[thing];
+		readbuffer[rbi++] = c;  // add movement to input buffer
+	}
+	if (strchr("iIaAsc", cm)) {     // multi-char commands
+		if (cm == 'c') {
+			// change some thing
+			thing = (int) lrand48() % strlen(cmd1); // pick a movement command
+			c = cmd1[thing];
+			readbuffer[rbi++] = c;  // add movement to input buffer
+		}
+		thing = (int) lrand48() % 4;    // what thing to insert
+		cnt = (int) lrand48() % 10;     // how many to insert
+		for (i = 0; i < cnt; i++) {
+			if (thing == 0) {       // insert chars
+				readbuffer[rbi++] = chars[((int) lrand48() % strlen(chars))];
+			} else if (thing == 1) {        // insert words
+				strcat(readbuffer, words[(int) lrand48() % 20]);
+				strcat(readbuffer, " ");
+				sleeptime = 0;  // how fast to type
+			} else if (thing == 2) {        // insert lines
+				strcat(readbuffer, lines[(int) lrand48() % 20]);
+				sleeptime = 0;  // how fast to type
+			} else {        // insert multi-lines
+				strcat(readbuffer, multilines[(int) lrand48() % 20]);
+				sleeptime = 0;  // how fast to type
+			}
+		}
+		strcat(readbuffer, "\033");
+	}
+	readbuffer[0] = strlen(readbuffer + 1);
+ cd1:
+	totalcmds++;
+	if (sleeptime > 0)
+		mysleep(sleeptime);      // sleep 1/100 sec
+}
+
+// test to see if there are any errors
+static void crash_test()
+{
+	static time_t oldtim;
+
+	time_t tim;
+	char d[2], msg[80];
+
+	msg[0] = '\0';
+	if (end < text) {
+		strcat(msg, "end<text ");
+	}
+	if (end > textend) {
+		strcat(msg, "end>textend ");
+	}
+	if (dot < text) {
+		strcat(msg, "dot<text ");
+	}
+	if (dot > end) {
+		strcat(msg, "dot>end ");
+	}
+	if (screenbegin < text) {
+		strcat(msg, "screenbegin<text ");
+	}
+	if (screenbegin > end - 1) {
+		strcat(msg, "screenbegin>end-1 ");
+	}
+
+	if (msg[0]) {
+		printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
+			totalcmds, last_input_char, msg, ESC_BOLD_TEXT, ESC_NORM_TEXT);
+		fflush_all();
+		while (safe_read(STDIN_FILENO, d, 1) > 0) {
+			if (d[0] == '\n' || d[0] == '\r')
+				break;
+		}
+	}
+	tim = time(NULL);
+	if (tim >= (oldtim + 3)) {
+		sprintf(status_buffer,
+				"Tot=%d: M=%d N=%d I=%d D=%d Y=%d P=%d U=%d size=%d",
+				totalcmds, M, N, I, D, Y, P, U, end - text + 1);
+		oldtim = tim;
+	}
+}
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/libbb/xfunc_die.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/xfunc_die.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/xfunc_die.c	(revision 279)
@@ -0,0 +1,22 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+/* Keeping it separate allows to NOT pull in stdio for VERY small applets.
+ * Try building busybox with only "true" enabled... */
+
+#include "libbb.h"
+
+void (*die_func)(void);
+
+void FAST_FUNC xfunc_die(void)
+{
+	if (die_func)
+		die_func();
+	exit(xfunc_error_retval);
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/xfuncs.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/xfuncs.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/xfuncs.c	(revision 279)
@@ -0,0 +1,358 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2006 Rob Landley
+ * Copyright (C) 2006 Denys Vlasenko
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+/* We need to have separate xfuncs.c and xfuncs_printf.c because
+ * with current linkers, even with section garbage collection,
+ * if *.o module references any of XXXprintf functions, you pull in
+ * entire printf machinery. Even if you do not use the function
+ * which uses XXXprintf.
+ *
+ * xfuncs.c contains functions (not necessarily xfuncs)
+ * which do not pull in printf, directly or indirectly.
+ * xfunc_printf.c contains those which do.
+ *
+ * TODO: move xmalloc() and xatonum() here.
+ */
+
+#include "libbb.h"
+
+/* Turn on nonblocking I/O on a fd */
+int FAST_FUNC ndelay_on(int fd)
+{
+	int flags = fcntl(fd, F_GETFL);
+	if (flags & O_NONBLOCK)
+		return flags;
+	fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+	return flags;
+}
+
+int FAST_FUNC ndelay_off(int fd)
+{
+	int flags = fcntl(fd, F_GETFL);
+	if (!(flags & O_NONBLOCK))
+		return flags;
+	fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
+	return flags;
+}
+
+void FAST_FUNC close_on_exec_on(int fd)
+{
+	fcntl(fd, F_SETFD, FD_CLOEXEC);
+}
+
+char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src)
+{
+#ifndef IFNAMSIZ
+	enum { IFNAMSIZ = 16 };
+#endif
+	return strncpy(dst, src, IFNAMSIZ);
+}
+
+
+/* Convert unsigned integer to ascii, writing into supplied buffer.
+ * A truncated result contains the first few digits of the result ala strncpy.
+ * Returns a pointer past last generated digit, does _not_ store NUL.
+ */
+void BUG_sizeof(void);
+char* FAST_FUNC utoa_to_buf(unsigned n, char *buf, unsigned buflen)
+{
+	unsigned i, out, res;
+
+	if (buflen) {
+		out = 0;
+		if (sizeof(n) == 4)
+		// 2^32-1 = 4294967295
+			i = 1000000000;
+#if UINT_MAX > 4294967295 /* prevents warning about "const too large" */
+		else
+		if (sizeof(n) == 8)
+		// 2^64-1 = 18446744073709551615
+			i = 10000000000000000000;
+#endif
+		else
+			BUG_sizeof();
+		for (; i; i /= 10) {
+			res = n / i;
+			n = n % i;
+			if (res || out || i == 1) {
+				if (--buflen == 0)
+					break;
+				out++;
+				*buf++ = '0' + res;
+			}
+		}
+	}
+	return buf;
+}
+
+/* Convert signed integer to ascii, like utoa_to_buf() */
+char* FAST_FUNC itoa_to_buf(int n, char *buf, unsigned buflen)
+{
+	if (!buflen)
+		return buf;
+	if (n < 0) {
+		n = -n;
+		*buf++ = '-';
+		buflen--;
+	}
+	return utoa_to_buf((unsigned)n, buf, buflen);
+}
+
+// The following two functions use a static buffer, so calling either one a
+// second time will overwrite previous results.
+//
+// The largest 32 bit integer is -2 billion plus NUL, or 1+10+1=12 bytes.
+// It so happens that sizeof(int) * 3 is enough for 32+ bit ints.
+// (sizeof(int) * 3 + 2 is correct for any width, even 8-bit)
+
+static char local_buf[sizeof(int) * 3];
+
+/* Convert unsigned integer to ascii using a static buffer (returned). */
+char* FAST_FUNC bb_utoa(unsigned n)
+{
+	*(utoa_to_buf(n, local_buf, sizeof(local_buf) - 1)) = '\0';
+
+	return local_buf;
+}
+
+/* Convert signed integer to ascii using a static buffer (returned). */
+char* FAST_FUNC bb_itoa(int n)
+{
+	*(itoa_to_buf(n, local_buf, sizeof(local_buf) - 1)) = '\0';
+
+	return local_buf;
+}
+
+/* Emit a string of hex representation of bytes */
+char* FAST_FUNC bin2hex(char *p, const char *cp, int count)
+{
+	while (count) {
+		unsigned char c = *cp++;
+		/* put lowercase hex digits */
+		*p++ = 0x20 | bb_hexdigits_upcase[c >> 4];
+		*p++ = 0x20 | bb_hexdigits_upcase[c & 0xf];
+		count--;
+	}
+	return p;
+}
+
+/* Convert "[x]x[:][x]x[:][x]x[:][x]x" hex string to binary, no more than COUNT bytes */
+char* FAST_FUNC hex2bin(char *dst, const char *str, int count)
+{
+	errno = EINVAL;
+	while (*str && count) {
+		uint8_t val;
+		uint8_t c = *str++;
+		if (isdigit(c))
+			val = c - '0';
+		else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
+			val = (c|0x20) - ('a' - 10);
+		else
+			return NULL;
+		val <<= 4;
+		c = *str;
+		if (isdigit(c))
+			val |= c - '0';
+		else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
+			val |= (c|0x20) - ('a' - 10);
+		else if (c == ':' || c == '\0')
+			val >>= 4;
+		else
+			return NULL;
+
+		*dst++ = val;
+		if (c != '\0')
+			str++;
+		if (*str == ':')
+			str++;
+		count--;
+	}
+	errno = (*str ? ERANGE : 0);
+	return dst;
+}
+
+/* Return how long the file at fd is, if there's any way to determine it. */
+#ifdef UNUSED
+off_t FAST_FUNC fdlength(int fd)
+{
+	off_t bottom = 0, top = 0, pos;
+	long size;
+
+	// If the ioctl works for this, return it.
+
+	if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512;
+
+	// FIXME: explain why lseek(SEEK_END) is not used here!
+
+	// If not, do a binary search for the last location we can read.  (Some
+	// block devices don't do BLKGETSIZE right.)
+
+	do {
+		char temp;
+
+		pos = bottom + (top - bottom) / 2;
+
+		// If we can read from the current location, it's bigger.
+
+		if (lseek(fd, pos, SEEK_SET)>=0 && safe_read(fd, &temp, 1)==1) {
+			if (bottom == top) bottom = top = (top+1) * 2;
+			else bottom = pos;
+
+		// If we can't, it's smaller.
+		} else {
+			if (bottom == top) {
+				if (!top) return 0;
+				bottom = top/2;
+			}
+			else top = pos;
+		}
+	} while (bottom + 1 != top);
+
+	return pos + 1;
+}
+#endif
+
+int FAST_FUNC bb_putchar_stderr(char ch)
+{
+	return write(STDERR_FILENO, &ch, 1);
+}
+
+ssize_t FAST_FUNC full_write1_str(const char *str)
+{
+	return full_write(STDOUT_FILENO, str, strlen(str));
+}
+
+ssize_t FAST_FUNC full_write2_str(const char *str)
+{
+	return full_write(STDERR_FILENO, str, strlen(str));
+}
+
+static int wh_helper(int value, int def_val, const char *env_name, int *err)
+{
+	/* Envvars override even if "value" from ioctl is valid (>0).
+	 * Rationale: it's impossible to guess what user wants.
+	 * For example: "man CMD | ...": should "man" format output
+	 * to stdout's width? stdin's width? /dev/tty's width? 80 chars?
+	 * We _cant_ know it. If "..." saves text for e.g. email,
+	 * then it's probably 80 chars.
+	 * If "..." is, say, "grep -v DISCARD | $PAGER", then user
+	 * would prefer his tty's width to be used!
+	 *
+	 * Since we don't know, at least allow user to do this:
+	 * "COLUMNS=80 man CMD | ..."
+	 */
+	char *s = getenv(env_name);
+	if (s) {
+		value = atoi(s);
+		/* If LINES/COLUMNS are set, pretend that there is
+		 * no error getting w/h, this prevents some ugly
+		 * cursor tricks by our callers */
+		*err = 0;
+	}
+
+	if (value <= 1 || value >= 30000)
+		value = def_val;
+	return value;
+}
+
+/* It is perfectly ok to pass in a NULL for either width or for
+ * height, in which case that value will not be set.  */
+int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned *height)
+{
+	struct winsize win;
+	int err;
+	int close_me = -1;
+
+	if (fd == -1) {
+		if (isatty(STDOUT_FILENO))
+			fd = STDOUT_FILENO;
+		else
+		if (isatty(STDERR_FILENO))
+			fd = STDERR_FILENO;
+		else
+		if (isatty(STDIN_FILENO))
+			fd = STDIN_FILENO;
+		else
+			close_me = fd = open("/dev/tty", O_RDONLY);
+	}
+
+	win.ws_row = 0;
+	win.ws_col = 0;
+	/* I've seen ioctl returning 0, but row/col is (still?) 0.
+	 * We treat that as an error too.  */
+	err = ioctl(fd, TIOCGWINSZ, &win) != 0 || win.ws_row == 0;
+	if (height)
+		*height = wh_helper(win.ws_row, 24, "LINES", &err);
+	if (width)
+		*width = wh_helper(win.ws_col, 80, "COLUMNS", &err);
+
+	if (close_me >= 0)
+		close(close_me);
+
+	return err;
+}
+int FAST_FUNC get_terminal_width(int fd)
+{
+	unsigned width;
+	get_terminal_width_height(fd, &width, NULL);
+	return width;
+}
+
+int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp)
+{
+	return tcsetattr(STDIN_FILENO, TCSANOW, tp);
+}
+
+pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options)
+{
+	pid_t r;
+
+	do
+		r = waitpid(pid, wstat, options);
+	while ((r == -1) && (errno == EINTR));
+	return r;
+}
+
+pid_t FAST_FUNC wait_any_nohang(int *wstat)
+{
+	return safe_waitpid(-1, wstat, WNOHANG);
+}
+
+// Wait for the specified child PID to exit, returning child's error return.
+int FAST_FUNC wait4pid(pid_t pid)
+{
+	int status;
+
+	if (pid <= 0) {
+		/*errno = ECHILD; -- wrong. */
+		/* we expect errno to be already set from failed [v]fork/exec */
+		return -1;
+	}
+	if (safe_waitpid(pid, &status, 0) == -1)
+		return -1;
+	if (WIFEXITED(status))
+		return WEXITSTATUS(status);
+	if (WIFSIGNALED(status))
+		return WTERMSIG(status) + 0x180;
+	return 0;
+}
+
+// Useful when we do know that pid is valid, and we just want to wait
+// for it to exit. Not existing pid is fatal. waitpid() status is not returned.
+int FAST_FUNC wait_for_exitstatus(pid_t pid)
+{
+	int exit_status, n;
+
+	n = safe_waitpid(pid, &exit_status, 0);
+	if (n < 0)
+		bb_perror_msg_and_die("waitpid");
+	return exit_status;
+}
Index: /EcnlProtoTool/trunk/prototool/src/libbb/xfuncs_printf.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/libbb/xfuncs_printf.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/libbb/xfuncs_printf.c	(revision 279)
@@ -0,0 +1,685 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2006 Rob Landley
+ * Copyright (C) 2006 Denys Vlasenko
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
+
+/* We need to have separate xfuncs.c and xfuncs_printf.c because
+ * with current linkers, even with section garbage collection,
+ * if *.o module references any of XXXprintf functions, you pull in
+ * entire printf machinery. Even if you do not use the function
+ * which uses XXXprintf.
+ *
+ * xfuncs.c contains functions (not necessarily xfuncs)
+ * which do not pull in printf, directly or indirectly.
+ * xfunc_printf.c contains those which do.
+ */
+
+#include "libbb.h"
+
+
+/* All the functions starting with "x" call bb_error_msg_and_die() if they
+ * fail, so callers never need to check for errors.  If it returned, it
+ * succeeded. */
+
+#ifndef DMALLOC
+/* dmalloc provides variants of these that do abort() on failure.
+ * Since dmalloc's prototypes overwrite the impls here as they are
+ * included after these prototypes in libbb.h, all is well.
+ */
+// Warn if we can't allocate size bytes of memory.
+void* FAST_FUNC malloc_or_warn(size_t size)
+{
+	void *ptr = malloc(size);
+	if (ptr == NULL && size != 0)
+		bb_error_msg(bb_msg_memory_exhausted);
+	return ptr;
+}
+
+// Die if we can't allocate size bytes of memory.
+void* FAST_FUNC xmalloc(size_t size)
+{
+	void *ptr = malloc(size);
+	if (ptr == NULL && size != 0)
+		bb_error_msg_and_die(bb_msg_memory_exhausted);
+	return ptr;
+}
+
+// Die if we can't resize previously allocated memory.  (This returns a pointer
+// to the new memory, which may or may not be the same as the old memory.
+// It'll copy the contents to a new chunk and free the old one if necessary.)
+void* FAST_FUNC xrealloc(void *ptr, size_t size)
+{
+	ptr = realloc(ptr, size);
+	if (ptr == NULL && size != 0)
+		bb_error_msg_and_die(bb_msg_memory_exhausted);
+	return ptr;
+}
+#endif /* DMALLOC */
+
+// Die if we can't allocate and zero size bytes of memory.
+void* FAST_FUNC xzalloc(size_t size)
+{
+	void *ptr = xmalloc(size);
+	memset(ptr, 0, size);
+	return ptr;
+}
+
+// Die if we can't copy a string to freshly allocated memory.
+char* FAST_FUNC xstrdup(const char *s)
+{
+	char *t;
+
+	if (s == NULL)
+		return NULL;
+
+	t = strdup(s);
+
+	if (t == NULL)
+		bb_error_msg_and_die(bb_msg_memory_exhausted);
+
+	return t;
+}
+
+// Die if we can't allocate n+1 bytes (space for the null terminator) and copy
+// the (possibly truncated to length n) string into it.
+char* FAST_FUNC xstrndup(const char *s, int n)
+{
+	int m;
+	char *t;
+
+	if (ENABLE_DEBUG && s == NULL)
+		bb_error_msg_and_die("xstrndup bug");
+
+	/* We can just xmalloc(n+1) and strncpy into it, */
+	/* but think about xstrndup("abc", 10000) wastage! */
+	m = n;
+	t = (char*) s;
+	while (m) {
+		if (!*t) break;
+		m--;
+		t++;
+	}
+	n -= m;
+	t = xmalloc(n + 1);
+	t[n] = '\0';
+
+	return memcpy(t, s, n);
+}
+
+void* FAST_FUNC xmemdup(const void *s, int n)
+{
+	return memcpy(xmalloc(n), s, n);
+}
+
+// Die if we can't open a file and return a FILE* to it.
+// Notice we haven't got xfread(), This is for use with fscanf() and friends.
+FILE* FAST_FUNC xfopen(const char *path, const char *mode)
+{
+	FILE *fp = fopen(path, mode);
+	if (fp == NULL)
+		bb_perror_msg_and_die("can't open '%s'", path);
+	return fp;
+}
+
+// Die if we can't open a file and return a fd.
+int FAST_FUNC xopen3(const char *pathname, int flags, int mode)
+{
+	int ret;
+
+	ret = open(pathname, flags, mode);
+	if (ret < 0) {
+		bb_perror_msg_and_die("can't open '%s'", pathname);
+	}
+	return ret;
+}
+
+// Die if we can't open a file and return a fd.
+int FAST_FUNC xopen(const char *pathname, int flags)
+{
+	return xopen3(pathname, flags, 0666);
+}
+
+// Warn if we can't open a file and return a fd.
+int FAST_FUNC open3_or_warn(const char *pathname, int flags, int mode)
+{
+	int ret;
+
+	ret = open(pathname, flags, mode);
+	if (ret < 0) {
+		bb_perror_msg("can't open '%s'", pathname);
+	}
+	return ret;
+}
+
+// Warn if we can't open a file and return a fd.
+int FAST_FUNC open_or_warn(const char *pathname, int flags)
+{
+	return open3_or_warn(pathname, flags, 0666);
+}
+
+/* Die if we can't open an existing file readonly with O_NONBLOCK
+ * and return the fd.
+ * Note that for ioctl O_RDONLY is sufficient.
+ */
+int FAST_FUNC xopen_nonblocking(const char *pathname)
+{
+	return xopen(pathname, O_RDONLY | O_NONBLOCK);
+}
+
+int FAST_FUNC xopen_as_uid_gid(const char *pathname, int flags, uid_t u, gid_t g)
+{
+	int fd;
+	uid_t old_euid = geteuid();
+	gid_t old_egid = getegid();
+
+	xsetegid(g);
+	xseteuid(u);
+
+	fd = xopen(pathname, flags);
+
+	xseteuid(old_euid);
+	xsetegid(old_egid);
+
+	return fd;
+}
+
+void FAST_FUNC xunlink(const char *pathname)
+{
+	if (unlink(pathname))
+		bb_perror_msg_and_die("can't remove file '%s'", pathname);
+}
+
+void FAST_FUNC xrename(const char *oldpath, const char *newpath)
+{
+	if (rename(oldpath, newpath))
+		bb_perror_msg_and_die("can't move '%s' to '%s'", oldpath, newpath);
+}
+
+int FAST_FUNC rename_or_warn(const char *oldpath, const char *newpath)
+{
+	int n = rename(oldpath, newpath);
+	if (n)
+		bb_perror_msg("can't move '%s' to '%s'", oldpath, newpath);
+	return n;
+}
+
+void FAST_FUNC xpipe(int filedes[2])
+{
+	if (pipe(filedes))
+		bb_perror_msg_and_die("can't create pipe");
+}
+
+void FAST_FUNC xdup2(int from, int to)
+{
+	if (dup2(from, to) != to)
+		bb_perror_msg_and_die("can't duplicate file descriptor");
+}
+
+// "Renumber" opened fd
+void FAST_FUNC xmove_fd(int from, int to)
+{
+	if (from == to)
+		return;
+	xdup2(from, to);
+	close(from);
+}
+
+// Die with an error message if we can't write the entire buffer.
+void FAST_FUNC xwrite(int fd, const void *buf, size_t count)
+{
+	if (count) {
+		ssize_t size = full_write(fd, buf, count);
+		if ((size_t)size != count) {
+			/*
+			 * Two cases: write error immediately;
+			 * or some writes succeeded, then we hit an error.
+			 * In either case, errno is set.
+			 */
+			bb_perror_msg_and_die(
+				size >= 0 ? "short write" : "write error"
+			);
+		}
+	}
+}
+void FAST_FUNC xwrite_str(int fd, const char *str)
+{
+	xwrite(fd, str, strlen(str));
+}
+
+void FAST_FUNC xclose(int fd)
+{
+	if (close(fd))
+		bb_perror_msg_and_die("close failed");
+}
+
+// Die with an error message if we can't lseek to the right spot.
+off_t FAST_FUNC xlseek(int fd, off_t offset, int whence)
+{
+	off_t off = lseek(fd, offset, whence);
+	if (off == (off_t)-1) {
+		if (whence == SEEK_SET)
+			bb_perror_msg_and_die("lseek(%"OFF_FMT"u)", offset);
+		bb_perror_msg_and_die("lseek");
+	}
+	return off;
+}
+
+int FAST_FUNC xmkstemp(char *template)
+{
+	int fd = mkstemp(template);
+	if (fd < 0)
+		bb_perror_msg_and_die("can't create temp file '%s'", template);
+	return fd;
+}
+
+// Die with supplied filename if this FILE* has ferror set.
+void FAST_FUNC die_if_ferror(FILE *fp, const char *fn)
+{
+	if (ferror(fp)) {
+		/* ferror doesn't set useful errno */
+		bb_error_msg_and_die("%s: I/O error", fn);
+	}
+}
+
+// Die with an error message if stdout has ferror set.
+void FAST_FUNC die_if_ferror_stdout(void)
+{
+	die_if_ferror(stdout, bb_msg_standard_output);
+}
+
+int FAST_FUNC fflush_all(void)
+{
+	return fflush(NULL);
+}
+
+
+int FAST_FUNC bb_putchar(int ch)
+{
+	return putchar(ch);
+}
+
+/* Die with an error message if we can't copy an entire FILE* to stdout,
+ * then close that file. */
+void FAST_FUNC xprint_and_close_file(FILE *file)
+{
+	fflush_all();
+	// copyfd outputs error messages for us.
+	if (bb_copyfd_eof(fileno(file), STDOUT_FILENO) == -1)
+		xfunc_die();
+
+	fclose(file);
+}
+
+// Die with an error message if we can't malloc() enough space and do an
+// sprintf() into that space.
+char* FAST_FUNC xasprintf(const char *format, ...)
+{
+	va_list p;
+	int r;
+	char *string_ptr;
+
+	va_start(p, format);
+	r = vasprintf(&string_ptr, format, p);
+	va_end(p);
+
+	if (r < 0)
+		bb_error_msg_and_die(bb_msg_memory_exhausted);
+	return string_ptr;
+}
+
+void FAST_FUNC xsetenv(const char *key, const char *value)
+{
+	if (setenv(key, value, 1))
+		bb_error_msg_and_die(bb_msg_memory_exhausted);
+}
+
+/* Handles "VAR=VAL" strings, even those which are part of environ
+ * _right now_
+ */
+void FAST_FUNC bb_unsetenv(const char *var)
+{
+	char *tp = strchr(var, '=');
+
+	if (!tp) {
+		unsetenv(var);
+		return;
+	}
+
+	/* In case var was putenv'ed, we can't replace '='
+	 * with NUL and unsetenv(var) - it won't work,
+	 * env is modified by the replacement, unsetenv
+	 * sees "VAR" instead of "VAR=VAL" and does not remove it!
+	 * horror :( */
+	tp = xstrndup(var, tp - var);
+	unsetenv(tp);
+	free(tp);
+}
+
+void FAST_FUNC bb_unsetenv_and_free(char *var)
+{
+	bb_unsetenv(var);
+	free(var);
+}
+
+// Die with an error message if we can't set gid.  (Because resource limits may
+// limit this user to a given number of processes, and if that fills up the
+// setgid() will fail and we'll _still_be_root_, which is bad.)
+void FAST_FUNC xsetgid(gid_t gid)
+{
+	if (setgid(gid)) bb_perror_msg_and_die("setgid");
+}
+
+// Die with an error message if we can't set uid.  (See xsetgid() for why.)
+void FAST_FUNC xsetuid(uid_t uid)
+{
+	if (setuid(uid)) bb_perror_msg_and_die("setuid");
+}
+
+void FAST_FUNC xsetegid(gid_t egid)
+{
+	if (setegid(egid)) bb_perror_msg_and_die("setegid");
+}
+
+void FAST_FUNC xseteuid(uid_t euid)
+{
+	if (seteuid(euid)) bb_perror_msg_and_die("seteuid");
+}
+
+// Die if we can't chdir to a new path.
+void FAST_FUNC xchdir(const char *path)
+{
+	if (chdir(path))
+		bb_perror_msg_and_die("can't change directory to '%s'", path);
+}
+
+void FAST_FUNC xfchdir(int fd)
+{
+	if (fchdir(fd))
+		bb_perror_msg_and_die("fchdir");
+}
+
+void FAST_FUNC xchroot(const char *path)
+{
+	if (chroot(path))
+		bb_perror_msg_and_die("can't change root directory to '%s'", path);
+	xchdir("/");
+}
+
+// Print a warning message if opendir() fails, but don't die.
+DIR* FAST_FUNC warn_opendir(const char *path)
+{
+	DIR *dp;
+
+	dp = opendir(path);
+	if (!dp)
+		bb_perror_msg("can't open '%s'", path);
+	return dp;
+}
+
+// Die with an error message if opendir() fails.
+DIR* FAST_FUNC xopendir(const char *path)
+{
+	DIR *dp;
+
+	dp = opendir(path);
+	if (!dp)
+		bb_perror_msg_and_die("can't open '%s'", path);
+	return dp;
+}
+
+// Die with an error message if we can't open a new socket.
+int FAST_FUNC xsocket(int domain, int type, int protocol)
+{
+	int r = socket(domain, type, protocol);
+
+	if (r < 0) {
+		/* Hijack vaguely related config option */
+#if ENABLE_VERBOSE_RESOLUTION_ERRORS
+		const char *s = "INET";
+# ifdef AF_PACKET
+		if (domain == AF_PACKET) s = "PACKET";
+# endif
+# ifdef AF_NETLINK
+		if (domain == AF_NETLINK) s = "NETLINK";
+# endif
+IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";)
+		bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol);
+#else
+		bb_perror_msg_and_die("socket");
+#endif
+	}
+
+	return r;
+}
+
+// Die with an error message if we can't bind a socket to an address.
+void FAST_FUNC xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
+{
+	if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind");
+}
+
+// Die with an error message if we can't listen for connections on a socket.
+void FAST_FUNC xlisten(int s, int backlog)
+{
+	if (listen(s, backlog)) bb_perror_msg_and_die("listen");
+}
+
+/* Die with an error message if sendto failed.
+ * Return bytes sent otherwise  */
+ssize_t FAST_FUNC xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
+				socklen_t tolen)
+{
+	ssize_t ret = sendto(s, buf, len, 0, to, tolen);
+	if (ret < 0) {
+		if (ENABLE_FEATURE_CLEAN_UP)
+			close(s);
+		bb_perror_msg_and_die("sendto");
+	}
+	return ret;
+}
+
+// xstat() - a stat() which dies on failure with meaningful error message
+void FAST_FUNC xstat(const char *name, struct stat *stat_buf)
+{
+	if (stat(name, stat_buf))
+		bb_perror_msg_and_die("can't stat '%s'", name);
+}
+
+void FAST_FUNC xfstat(int fd, struct stat *stat_buf, const char *errmsg)
+{
+	/* errmsg is usually a file name, but not always:
+	 * xfstat may be called in a spot where file name is no longer
+	 * available, and caller may give e.g. "can't stat input file" string.
+	 */
+	if (fstat(fd, stat_buf))
+		bb_simple_perror_msg_and_die(errmsg);
+}
+
+// selinux_or_die() - die if SELinux is disabled.
+void FAST_FUNC selinux_or_die(void)
+{
+#if ENABLE_SELINUX
+	int rc = is_selinux_enabled();
+	if (rc == 0) {
+		bb_error_msg_and_die("SELinux is disabled");
+	} else if (rc < 0) {
+		bb_error_msg_and_die("is_selinux_enabled() failed");
+	}
+#else
+	bb_error_msg_and_die("SELinux support is disabled");
+#endif
+}
+
+int FAST_FUNC ioctl_or_perror_and_die(int fd, unsigned request, void *argp, const char *fmt,...)
+{
+	int ret;
+	va_list p;
+
+	ret = ioctl(fd, request, argp);
+	if (ret < 0) {
+		va_start(p, fmt);
+		bb_verror_msg(fmt, p, strerror(errno));
+		/* xfunc_die can actually longjmp, so be nice */
+		va_end(p);
+		xfunc_die();
+	}
+	return ret;
+}
+
+int FAST_FUNC ioctl_or_perror(int fd, unsigned request, void *argp, const char *fmt,...)
+{
+	va_list p;
+	int ret = ioctl(fd, request, argp);
+
+	if (ret < 0) {
+		va_start(p, fmt);
+		bb_verror_msg(fmt, p, strerror(errno));
+		va_end(p);
+	}
+	return ret;
+}
+
+#if ENABLE_IOCTL_HEX2STR_ERROR
+int FAST_FUNC bb_ioctl_or_warn(int fd, unsigned request, void *argp, const char *ioctl_name)
+{
+	int ret;
+
+	ret = ioctl(fd, request, argp);
+	if (ret < 0)
+		bb_simple_perror_msg(ioctl_name);
+	return ret;
+}
+int FAST_FUNC bb_xioctl(int fd, unsigned request, void *argp, const char *ioctl_name)
+{
+	int ret;
+
+	ret = ioctl(fd, request, argp);
+	if (ret < 0)
+		bb_simple_perror_msg_and_die(ioctl_name);
+	return ret;
+}
+#else
+int FAST_FUNC bb_ioctl_or_warn(int fd, unsigned request, void *argp)
+{
+	int ret;
+
+	ret = ioctl(fd, request, argp);
+	if (ret < 0)
+		bb_perror_msg("ioctl %#x failed", request);
+	return ret;
+}
+int FAST_FUNC bb_xioctl(int fd, unsigned request, void *argp)
+{
+	int ret;
+
+	ret = ioctl(fd, request, argp);
+	if (ret < 0)
+		bb_perror_msg_and_die("ioctl %#x failed", request);
+	return ret;
+}
+#endif
+
+char* FAST_FUNC xmalloc_ttyname(int fd)
+{
+	char buf[128];
+	int r = ttyname_r(fd, buf, sizeof(buf) - 1);
+	if (r)
+		return NULL;
+	return xstrdup(buf);
+}
+
+void FAST_FUNC generate_uuid(uint8_t *buf)
+{
+	/* http://www.ietf.org/rfc/rfc4122.txt
+	 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * |                          time_low                             |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * |       time_mid                |         time_hi_and_version   |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * |clk_seq_and_variant            |         node (0-1)            |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * |                         node (2-5)                            |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * IOW, uuid has this layout:
+	 * uint32_t time_low (big endian)
+	 * uint16_t time_mid (big endian)
+	 * uint16_t time_hi_and_version (big endian)
+	 *  version is a 4-bit field:
+	 *   1 Time-based
+	 *   2 DCE Security, with embedded POSIX UIDs
+	 *   3 Name-based (MD5)
+	 *   4 Randomly generated
+	 *   5 Name-based (SHA-1)
+	 * uint16_t clk_seq_and_variant (big endian)
+	 *  variant is a 3-bit field:
+	 *   0xx Reserved, NCS backward compatibility
+	 *   10x The variant specified in rfc4122
+	 *   110 Reserved, Microsoft backward compatibility
+	 *   111 Reserved for future definition
+	 * uint8_t node[6]
+	 *
+	 * For version 4, these bits are set/cleared:
+	 * time_hi_and_version & 0x0fff | 0x4000
+	 * clk_seq_and_variant & 0x3fff | 0x8000
+	 */
+	pid_t pid;
+	int i;
+
+	i = open("/dev/urandom", O_RDONLY);
+	if (i >= 0) {
+		read(i, buf, 16);
+		close(i);
+	}
+	/* Paranoia. /dev/urandom may be missing.
+	 * rand() is guaranteed to generate at least [0, 2^15) range,
+	 * but lowest bits in some libc are not so "random".  */
+	srand(monotonic_us()); /* pulls in printf */
+	pid = getpid();
+	while (1) {
+		for (i = 0; i < 16; i++)
+			buf[i] ^= rand() >> 5;
+		if (pid == 0)
+			break;
+		srand(pid);
+		pid = 0;
+	}
+
+	/* version = 4 */
+	buf[4 + 2    ] = (buf[4 + 2    ] & 0x0f) | 0x40;
+	/* variant = 10x */
+	buf[4 + 2 + 2] = (buf[4 + 2 + 2] & 0x3f) | 0x80;
+}
+
+#if BB_MMU
+pid_t FAST_FUNC xfork(void)
+{
+	pid_t pid;
+	pid = fork();
+	if (pid < 0) /* wtf? */
+		bb_perror_msg_and_die("vfork"+1);
+	return pid;
+}
+#endif
+
+void FAST_FUNC xvfork_parent_waits_and_exits(void)
+{
+	pid_t pid;
+
+	fflush_all();
+	pid = xvfork();
+	if (pid > 0) {
+		/* Parent */
+		int exit_status = wait_for_exitstatus(pid);
+		if (WIFSIGNALED(exit_status))
+			kill_myself_with_sig(WTERMSIG(exit_status));
+		_exit(WEXITSTATUS(exit_status));
+	}
+	/* Child continues */
+}
Index: /EcnlProtoTool/trunk/prototool/src/main.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/main.c	(revision 278)
+++ /EcnlProtoTool/trunk/prototool/src/main.c	(revision 279)
@@ -1,7 +1,7 @@
 /*
  *  TOPPERS ECHONET Lite Communication Middleware
- * 
- *  Copyright (C) 2014-2017 Cores Co., Ltd. Japan
- * 
+ *
+ *  Copyright (C) 2014-2016 Cores Co., Ltd. Japan
+ *
  *  ä¸è¨èä½æ¨©è
 ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
@@ -40,5 +40,5 @@
  *      å
 è²¬ãããã¨ï¼
- * 
+ *
  *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
 ã
@@ -47,23 +47,29 @@
  *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
  *  ã®è²¬ä»»ãè² ããªãï¼
- * 
+ *
  *  @(#) $Id$
  */
 
-/* 
- *  ãµã³ãã«ãã­ã°ã©ã (1)ã®æ¬ä½
- */
-
-#include <kernel.h>
-#include <t_syslog.h>
-#include <t_stdlib.h>
-#include <sil.h>
-#include <stdlib.h>
+ /*
+  *  ãµã³ãã«ãã­ã°ã©ã (1)ã®æ¬ä½
+  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/unistd.h>
+#include <errno.h>
+
 #include <string.h>
-#include "syssvc/serial.h"
-#include "syssvc/syslog.h"
-#include "kernel_cfg.h"
-#include "main.h"
-#include "rza1.h"
 #include <mruby.h>
 #include <mruby/compile.h>
@@ -74,806 +80,211 @@
 #include <mruby/dump.h>
 #include <mruby/string.h>
-#include <tinet_config.h>
-#include <netinet/in.h>
-#include <netinet/in_itron.h>
-#include <tinet_nic_defs.h>
-#include <tinet_cfg.h>
-#include <netinet/in_var.h>
-#include <net/ethernet.h>
-#include <net/if6_var.h>
-#include <net/net.h>
-#include <net/if_var.h>
-#include <netinet/udp_var.h>
-#include <ethernet_api.h>
-#include "../webserver/httpd.h"
-#include "../webserver/httpd-fs.h"
-#include "../webserver/http-strings.h"
-#include "../webserver/base64.h"
-#include "../webserver/sha1.h"
-#include "mruby_arduino.h"
-#include "gpio_api.h"
-#include "arduino.h"
-#include "ff.h"
-
-#ifndef _MSC_VER
-void strcpy_s(char *dst, int size, const char *src);
-void strcat_s(char *dst, int size, const char *src);
-#endif
-
-uint8_t mac_addr[6] = {0x00, 0x30, 0x13, 0x06, 0x62, 0xC0};
-
-SYSTIM main_time;
-struct httpd_state *uploding;
-
-static void netif_link_callback(T_IFNET *ether);
-static void execute_ruby();
-
-/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
-uint8_t tcp_swbuf1[TCP_SWBUF_SIZE];
-uint8_t tcp_rwbuf1[TCP_RWBUF_SIZE];
-uint8_t tcp_swbuf2[TCP_SWBUF_SIZE];
-uint8_t tcp_rwbuf2[TCP_RWBUF_SIZE];
-
-#define ISO_nl      0x0a
-#define ISO_space   0x20
-#define ISO_bang    0x21
-#define ISO_percent 0x25
-#define ISO_period  0x2e
-#define ISO_slash   0x2f
-#define ISO_colon   0x3a
-
-ID ecn_api_mailboxid;
-ID WEBSOCKET_MBXID;
-
-struct httpd_state httpd_state[2] = {
-	{MAIN1_TASK, TCP_CEPID1},
-	{MAIN2_TASK, TCP_CEPID2},
-};
-
-/*
-*  ãããã¯ã¼ã¯å±¤ã®é¸æ
-*/
-
-#ifdef SUPPORT_INET6
-
-#define TCP_ACP_CEP(c,r,d,t)	tcp6_acp_cep(c,r,d,t)
-#define IP2STR(s,a)		ipv62str(s,a)
-
-#else	/* of #ifdef SUPPORT_INET6 */
-
-#ifdef SUPPORT_INET4
-
-#define TCP_ACP_CEP(c,r,d,t)	tcp_acp_cep(c,r,d,t)
-#define IP2STR(s,a)		ip2str(s,a)
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-struct httpd_state *get_httpd(ID cepid)
-{
-	for (int i = 0; i < 2; i++) {
-		if (httpd_state[i].cepid != cepid)
-			continue;
-
-		return &httpd_state[i];
-	}
-	return NULL;
-}
-
-struct websocket *websocket_getws(ID wbsid)
-{
-	for (int i = 0; i < 2; i++) {
-		if (httpd_state[i].websocket.wbsid != wbsid)
-			continue;
-
-		return &httpd_state[i].websocket;
-	}
-	return NULL;
-}
-
-void send_file(struct httpd_state *s)
-{
-	char *buf;
-	int len, slen;
-
-	while (s->file.len > 0) {
-		slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
-		if (slen < 0) {
-			syslog(LOG_ERROR, "send_file#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
-			s->state = STATE_CLOSING;
-			break;
-		}
-		if (slen == 0)
-			return;
-
-		len = s->file.len;
-		if (len > slen)
-			len = slen;
-
-		len = httpd_fs_read(&s->file, buf, len);
-		if (len <= 0) {
-			syslog(LOG_ERROR, "send_file#httpd_fs_read(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
-			break;
-		}
-
-		s->file.len -= len;
-		s->file.pos += len;
-
-		if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
-			syslog(LOG_ERROR, "send_file#tcp_snd_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
-			s->state = STATE_CLOSING;
-			break;
-		}
-	}
-
-	syslog(LOG_NOTICE, "close:     %s.%d %s", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
-	httpd_fs_close(&s->file);
-	s->file.len = 0;
-	s->file.pos = 0;
-
-	s->out.state = OUT_STATE_SEND_END;
-}
-
-void send_data(struct httpd_state *s)
-{
-	char *buf;
-	int len, slen;
-
-	while (s->response_len > 0) {
-		slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
-		if (slen < 0) {
-			syslog(LOG_ERROR, "send_data#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
-			s->state = STATE_CLOSING;
-			break;
-		}
-		if (slen == 0)
-			return;
-
-		len = s->response_len;
-		if (len > slen)
-			len = slen;
-
-		memcpy(buf, &s->response_body[s->response_pos], len);
-
-		s->response_len -= len;
-		s->response_pos += len;
-
-		if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
-			syslog(LOG_ERROR, "send_data#tcp_snd_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
-			s->state = STATE_CLOSING;
-			break;
-		}
-	}
-
-	s->response_body = NULL;
-	s->response_len = 0;
-	s->response_pos = 0;
-
-	s->out.state = OUT_STATE_SEND_END;
-}
-
-void send_headers(struct httpd_state *s, const char *statushdr)
-{
-	int len;
-	char *ptr;
-
-	len = strlen(statushdr);
-	tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
-
-	if ((s->filename[0] == '0') && (s->file.len > 0)) {
-		len = sizeof(http_content_encoding_gzip) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_encoding_gzip, len, TMO_FEVR);
-	}
-
-	if (s->file.redirect) {
-		len = sizeof(http_location) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_location, len, TMO_FEVR);
-		if (s->filename[0] == '1') {
-			len = 2;
-			tcp_snd_dat(s->cepid, "/~", len, TMO_FEVR);
-		}
-		len = strlen(s->filename);
-		tcp_snd_dat(s->cepid, s->filename, len, TMO_FEVR);
-		if (s->query != NULL) {
-			tcp_snd_dat(s->cepid, "?", 1, TMO_FEVR);
-			len = strlen(s->query);
-			tcp_snd_dat(s->cepid, s->query, len, TMO_FEVR);
-		}
-		len = 2;
-		tcp_snd_dat(s->cepid, "\r", len, TMO_FEVR);
-	}
-
-	ptr = strrchr(s->filename, ISO_period);
-	if (ptr == NULL) {
-		len = sizeof(http_content_type_binary) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_binary, len, TMO_FEVR);
-	}
-	else if (strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 ||
-		strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) {
-		len = sizeof(http_content_type_html) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_html, len, TMO_FEVR);
-	}
-	else if (strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) {
-		len = sizeof(http_content_type_css) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_css, len, TMO_FEVR);
-	}
-	else if (strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) {
-		len = sizeof(http_content_type_js) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_js, len, TMO_FEVR);
-	}
-	else if (strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) {
-		len = sizeof(http_content_type_json) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_json, len, TMO_FEVR);
-	}
-	else if (strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) {
-		len = sizeof(http_content_type_png) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_png, len, TMO_FEVR);
-	}
-	else if (strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) {
-		len = sizeof(http_content_type_gif) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_gif, len, TMO_FEVR);
-	}
-	else if (strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) {
-		len = sizeof(http_content_type_jpg) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_jpg, len, TMO_FEVR);
-	}
-	else if (strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) {
-		len = sizeof(http_content_type_svg) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_svg, len, TMO_FEVR);
-	}
-	else if (strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) {
-		len = sizeof(http_content_type_text) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_text, len, TMO_FEVR);
-	}
-	else if (strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) {
-		len = sizeof(http_content_type_eot) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_eot, len, TMO_FEVR);
-	}
-	else if (strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) {
-		len = sizeof(http_content_type_ttf) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_ttf, len, TMO_FEVR);
-	}
-	else if (strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) {
-		len = sizeof(http_content_type_woff) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_woff, len, TMO_FEVR);
-	}
-	else if (strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) {
-		len = sizeof(http_content_type_woff2) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_woff2, len, TMO_FEVR);
-	}
-	else if (strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) {
-		len = sizeof(http_content_type_ico) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_ico, len, TMO_FEVR);
-	}
-	else {
-		len = sizeof(http_content_type_plain) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_type_plain, len, TMO_FEVR);
-	}
-
-	if (s->file.len > 0) {
-		len = sizeof(http_content_length) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_content_length, len, TMO_FEVR);
-		sprintf(s->temp, "%d\r\n", s->file.len);
-		tcp_snd_dat(s->cepid, (void *)s->temp, strlen(s->temp), TMO_FEVR);
-	}
-
-	if (s->message.should_keep_alive && s->reset == 0) {
-		len = sizeof(http_connection_keep_alive) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_connection_keep_alive, len, TMO_FEVR);
-	}
-	else {
-		len = sizeof(http_connection_close) - 1;
-		tcp_snd_dat(s->cepid, (void *)http_connection_close, len, TMO_FEVR);
-	}
-
-	tcp_snd_dat(s->cepid, (void *)http_crnl, 2, TMO_FEVR);
-
-	if (s->filename != NULL) {
-		s->out.state = OUT_STATE_SEND_FILE;
-	}
-	else {
-		s->out.state = OUT_STATE_SEND_DATA;
-	}
-}
-
-void handle_output(struct httpd_state *s)
-{
-	s->out.wait = false;
-
-	switch (s->out.state) {
-	case OUT_STATE_WAIT_REQUEST:
-		s->out.wait = true;
-		break;
-	case OUT_STATE_OPEN_GET_FILE:
-		syslog(LOG_NOTICE, "open:      %s.%d %s", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
-		if (!httpd_fs_open(s->filename, sizeof(s->message.request_url), &s->file)) {
-			s->filename = NULL;
-			s->response_body = http_content_404;
-			s->response_pos = 0;
-			s->response_len = sizeof(http_content_403) - 1;
-			s->out.statushdr = http_header_404;
-		}
-		else {
-			s->out.statushdr = s->file.redirect ? http_header_301 : http_header_200;
-		}
-		s->out.state = OUT_STATE_SEND_HEADER;
-		break;
-	case OUT_STATE_WAIT_POST_BODY:
-		s->out.wait = true;
-		break;
-	case OUT_STATE_BODY_RECEIVED:
-		s->out.statushdr = http_header_200;
-		s->out.state = OUT_STATE_SEND_HEADER;
-		break;
-	case OUT_STATE_SEND_HEADER:
-		send_headers(s, s->out.statushdr);
-		break;
-	case OUT_STATE_SEND_FILE:
-		send_file(s);
-		break;
-	case OUT_STATE_SEND_DATA:
-		send_data(s);
-		break;
-	case OUT_STATE_SEND_END:
-		s->out.wait = true;
-		if (s->message.should_keep_alive && s->reset == 0) {
-			s->out.state = OUT_STATE_WAIT_REQUEST;
-		}
-		else {
-			s->state = STATE_CLOSING;
-		}
-		break;
-	}
-}
-
-void send_ws_headers(struct httpd_state *s, const char *statushdr)
-{
-	int len;
-
-	len = strlen(statushdr);
-	tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
-
-	len = sizeof(http_upgrade) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_upgrade, len, TMO_FEVR);
-	len = strlen(s->message.upgrade);
-	tcp_snd_dat(s->cepid, s->message.upgrade, len, TMO_FEVR);
-	len = sizeof(http_crnl) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
-
-	len = sizeof(http_connection) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_connection, len, TMO_FEVR);
-	len = strlen(s->message.connection);
-	tcp_snd_dat(s->cepid, s->message.connection, len, TMO_FEVR);
-	len = sizeof(http_crnl) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
-
-	len = sizeof(http_sec_websocket_accept) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_sec_websocket_accept, len, TMO_FEVR);
-	len = strlen(s->message.response_key);
-	tcp_snd_dat(s->cepid, s->message.response_key, len, TMO_FEVR);
-	len = sizeof(http_crnl) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
-
-	len = sizeof(http_sec_websocket_protocol) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_sec_websocket_protocol, len, TMO_FEVR);
-	len = strlen(s->message.sec_websocket_protocol);
-	tcp_snd_dat(s->cepid, s->message.sec_websocket_protocol, len, TMO_FEVR);
-	len = sizeof(http_crnl) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
-
-	len = sizeof(http_crnl) - 1;
-	tcp_snd_dat(s->cepid, (void *)http_crnl, len, TMO_FEVR);
-}
-
-void send_ws_data(struct httpd_state *s)
-{
-	char *buf;
-	int slen;
-
-	slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
-	if (slen < 0) {
-		syslog(LOG_ERROR, "send_ws_data#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
-		return;
-	}
-
-	websocket_output(&s->websocket, buf, slen);
-}
-
-void handle_ws_output(struct httpd_state *s)
-{
-	char shaHash[20];
-	SHA_CTX sha1;
-	int len;
-
-	strlncat(s->message.response_key, sizeof(s->message.response_key),
-		s->message.sec_websocket_key, sizeof(s->message.sec_websocket_key));
-	len = strlncat(s->message.response_key, sizeof(s->message.response_key),
-		http_websocket_guid, sizeof(http_websocket_guid));
-	memset(shaHash, 0, sizeof(shaHash));
-	SHA1_Init(&sha1);
-	SHA1_Update(&sha1, (sha1_byte *)s->message.response_key, len);
-	SHA1_Final((sha1_byte *)shaHash, &sha1);
-	base64_encode((unsigned char *)s->message.response_key,
-		sizeof(s->message.response_key), (unsigned char *)shaHash, sizeof(shaHash));
-
-	send_ws_headers(s, http_header_101);
-
-	s->message.response_key[0] = '\0';
-
-	do {
-		while (!websocket_newdata(&s->websocket))
-			slp_tsk();
-
-		send_ws_data(s);
-	} while ((s->state == STATE_CONNECTED) && (!s->close_req));
-	s->state = STATE_DISCONNECTED;
-	websocket_destroy(&s->websocket);
-	s->close_req = 0;
-
-	s->state = STATE_CLOSING;
-}
-
-void handle_input(struct httpd_state *s)
-{
-	size_t done;
-	int len;
-
-	s->in.wait = false;
-
-	switch (s->in.state) {
-	case IN_STATE_START:
-		http_parser_init(&s->parser, HTTP_REQUEST);
-		s->in.state = IN_STATE_REQUEST;
-		break;
-	case IN_STATE_REQUEST:
-	case IN_STATE_RESPONSE:
-	case IN_STATE_UPLOAD:
-		if ((len = tcp_rcv_buf(s->cepid, (void **)&s->in.data, TMO_POL)) <= 0) {
-			if ((len == E_TMOUT) || (len == 0)) {
-				// 3ç§ã¯å¾
-ã¤
-				if (main_time - s->in.timer < 30000000) {
-					s->in.wait = true;
-					break;
-				}
-			}
-			syslog(LOG_ERROR, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
-			uploding = NULL;
-			s->state = STATE_CLOSING;
-			return;
-		}
-		done = http_parser_execute(&s->parser, &websvr_settings, s->in.data, len);
-		tcp_rel_buf(s->cepid, done);
-		if (s->parser.http_errno != HPE_OK) {
-			syslog(LOG_ERROR, "http_parser error %s.%d => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
-			uploding = NULL;
-			s->state = STATE_CLOSING;
-			return;
-		}
-
-		s->parse_pos = done;
-		s->parse_len = len - done;
-		break;
-	case IN_STATE_UPLOAD_WAIT:
-		if (uploding != NULL) {
-			s->in.wait = true;
-		}
-		else {
-			uploding = s;
-			s->in.state = IN_STATE_UPLOAD;
-		}
-		break;
-	case IN_STATE_WEBSOCKET:
-		if (s->parse_len <= 0) {
-			if ((len = tcp_rcv_buf(s->cepid, (void **)&s->in.data, TMO_POL)) <= 0) {
-				if ((len == E_TMOUT) || (len == 0)) {
-					s->in.wait = true;
-					break;
-				}
-				syslog(LOG_ERROR, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
-				s->state = STATE_CLOSING;
-				break;
-			}
-
-			s->parse_pos = 0;
-			s->parse_len = len;
-		}
-		else
-			len = s->parse_len;
-		done = websocket_input(&s->websocket, (void *)s->in.data, s->parse_len);
-		tcp_rel_buf(s->cepid, done);
-		if ((done != 0) || (s->websocket.rstate.opecode == connection_close)) {
-			s->close_req = 1;
-			s->state = STATE_CLOSING;
-			break;
-		}
-		s->parse_pos = done;
-		s->parse_len -= done;
-		break;
-	case IN_STATE_END:
-		s->in.wait = true;
-		break;
-	default:
-		s->state = STATE_CLOSING;
-		break;
-	}
-}
-
-/*
- *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
- */
-ER
-callback_nblk_tcp(ID cepid, FN fncd, void *p_parblk)
-{
-	struct httpd_state *s = get_httpd(cepid);
-
-	if (s == NULL)
-		syslog(LOG_NOTICE, "callback_nblk_tcp(%d, %d)", fncd, cepid);
-	else
-		syslog(LOG_NOTICE, "callback_nblk_tcp(%d, %s.%d)", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
-
-	return E_PAR;
-}
-
-/*
- * ã¡ã¤ã³ã¿ã¹ã¯
- */
-void main_task(intptr_t exinf)
-{
-	ER ret, ret2;
-	struct httpd_state *s = &httpd_state[exinf];
-
-	if (exinf == 0) {
-		gpio_t led_blue, led_green, led_red, sw;
-		gpio_init_out(&led_blue, LED_BLUE);
-		gpio_init_out(&led_green, LED_GREEN);
-		gpio_init_out(&led_red, LED_RED);
-		gpio_init_in(&sw, USER_BUTTON0);
-
-		bool_t exec = gpio_read(&sw) == 1;
-
-		gpio_write(&led_blue, 1);
-		gpio_write(&led_green, exec ? 1 : 0);
-		gpio_write(&led_red, 0);
-
-		/* åæå */
-		if (mruby_arduino_init() == 0) {
-			gpio_write(&led_blue, 0);
-		}
-		else {
-			gpio_write(&led_blue, 0);
-			gpio_write(&led_red, 1);
-		}
-
-		gpio_write(&led_green, 0);
-
-		/* TINETãèµ·åããã¾ã§å¾
-ã¤ */
-		ether_set_link_callback(netif_link_callback);
-
-		act_tsk(MAIN2_TASK);
-
-		if (exec) {
-			strcpy_s(RubyFilename, sizeof(RubyFilename), "1:/upload/main.mrb");
-
-			execute_ruby();
-		}
-	}
-
-	for (;;) {
-		ret2 = get_tim(&main_time);
-		if (ret2 != E_OK) {
-			syslog(LOG_ERROR, "get_tim");
-			return;
-		}
-
-		switch (s->state) {
-		case STATE_DISCONNECTED:
-			memset(&s->dst, 0, sizeof(s->dst));
-			if ((ret = TCP_ACP_CEP(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) {
-				syslog(LOG_ERROR, "tcp_acp_cep(%d) => %d", s->cepid, ret);
-				tslp_tsk(100000);	// TODO
-				s->state = STATE_CLOSING;
-				break;
-			}
-			IP2STR(s->addr, &((T_IPV4EP *)s->dst)->ipaddr);
-			syslog(LOG_NOTICE, "connected: %s.%d", s->addr, ((T_IPV4EP *)s->dst)->portno);
-			memset(&s->in, 0, sizeof(s->in));
-			memset(&s->out, 0, sizeof(s->out));
-			s->in.timer = main_time;
-			s->state = STATE_CONNECTED;
-			break;
-		case STATE_CONNECTED:
-			handle_input(s);
-			handle_output(s);
-			break;
-		case STATE_WEBSOCKET:
-			handle_input(s);
-			handle_ws_output(s);
-			break;
-		case STATE_CLOSING:
-			syslog(LOG_NOTICE, "close:     %s.%d", s->addr, ((T_IPV4EP *)s->dst)->portno);
-			tcp_sht_cep(s->cepid);
-			tcp_cls_cep(s->cepid, TMO_FEVR);
-
-			if (s->reset) {
-				s->reset = 0;
-				s->state = STATE_RESET;
-			}
-			else{
-				s->state = STATE_DISCONNECTED;
-			}
-			break;
-		case STATE_RESET:
-			execute_ruby();
-			s->state = STATE_DISCONNECTED;
-			break;
-		}
-
-		if (s->in.wait && s->out.wait) {
-			tslp_tsk(100000);
-		}
-	}
-}
-
-struct udp_msg {
-	T_IPV4EP dst;
+#include <usrcmd.h>
+
+#define ETHER_MAX_LEN 1518
+#define IF_FLAG_UP		1
+#define IF_FLAG_LINK_UP	2
+#define MAKE_IPV4_ADDR(a,b,c,d)		htonl(((uint32_t)(a)<<24)|((uint32_t)(b)<<16)|((uint32_t)(c)<<8)|(d))
+
+struct udp_msg
+{
+	struct sockaddr_in dst;
 	int len;
 	uint8_t buffer[ETHER_MAX_LEN];
 };
 
-SYSTIM mruby_time;
+typedef struct
+{
+	cmd_table_t *table;
+	cmd_table_t *count;
+} cmd_table_info_t;
+
+extern int mrbc_main(int argc, char **argv);
+extern int mrdb_main(int argc, char **argv);
+extern int mruby_main(int argc, char **argv);
+extern int mirb_main(int argc, char **argv);
+extern int tcc_main(int argc, char **argv);
+extern int vi_main(int argc, char **argv);
+extern int onitest_main(int argc, char **argv);
+extern int tcp_echo_main(int argc, char **argv);
+extern int echo_client_main(int argc, char **argv);
+extern int mrdb_break(void);
+
+static const cmd_table_t cmdlist[] = {
+	{"mrbc", "mruby compiler executable", mrbc_main},
+	{"mrdb","mruby debugger command", mrdb_main},
+	{"mruby","mruby command", mruby_main},
+	{"mirb", "Embeddable Interactive Ruby Shell", mirb_main},
+	{"tcc", "Tiny C compiler", tcc_main},
+	{"vi", "Text editor", vi_main},
+	{"cd", "change directory", usrcmd_cd },
+	{"ls", "list files", usrcmd_ls },
+	{"cp", "copy file", usrcmd_cp },
+	{"rm", "remove file", usrcmd_rm },
+	{"mv", "move file", usrcmd_mv },
+	{"mkdir", "Make directory", usrcmd_mkdir},
+	{"hexdump", "Hex dump", usrcmd_hexdump},
+	{"onitest", "Onigumo Test", onitest_main},
+	{"tcp_echo", "TCP echo server/client", tcp_echo_main},
+	{"help", "This is a description text string for help command.", usrcmd_help},
+	{"info", "This is a description text string for info command.", usrcmd_info},
+	{"exit", "Exit Natural Tyny Shell", usrcmd_exit},
+};
+cmd_table_info_t cmd_table_info = { &cmdlist, sizeof(cmdlist) / sizeof(cmdlist[0]) };
+
+int echonet = 1;
+struct timeval main_time;
 struct RClass *_module_target_board;
-
-extern const uint8_t main_rb_code[];
-uint8_t RubyCode[16 * 1024];
-
-/* MACã¢ãã¬ã¹ã®è¨­å®æã«å¼ã°ãã */
-void mbed_mac_address(char *mac)
-{
-	memcpy(mac, mac_addr, 6);
-}
-
-/*
- *  mrubyå®è¡ã¿ã¹ã¯
- */
-void mruby_task(intptr_t exinf)
-{
-	ER ret;
+int sock;
+
+int main(int argc, char **argv)
+{
+	if (argc == 0) {
+		return 0;
+	}
+	const cmd_table_t *p = cmd_table_info.table;
+	for (int i = 0; i < cmd_table_info.count; i++) {
+		if (strcmp((const char *)argv[0], p->cmd) == 0) {
+			return p->func(argc, argv);
+		}
+		p++;
+	}
+	printf("Unknown command found.\n");
+	return 0;
+}
+
+int run_mruby_code(int argc, char **argv, const uint8_t *code, const char *cmdline)
+{
+	mrb_state *mrb;
 	struct RProc* n;
 	struct mrb_irep *irep;
-	mrb_state *mrb;
-
-	syslog(LOG_NOTICE, "mruby_task");
+	mrb_value ARGV;
+	mrbc_context *c;
+	mrb_value v;
+	mrb_sym zero_sym;
+
+	echonet = 0;
 
 	/* mrubyã®åæå */
 	mrb = mrb_open();
 	if (mrb == NULL)
-		abort();
-
-	ret = get_tim(&mruby_time);
-	if (ret != E_OK) {
-		syslog(LOG_ERROR, "get_tim => %d", ret);
-		return;
-	}
-
-	irep = mrb_read_irep(mrb, RubyCode);
+		return -1;
+
+	int ai = mrb_gc_arena_save(mrb);
+	ARGV = mrb_ary_new_capa(mrb, argc);
+	for (int i = 0; i < argc; i++) {
+		mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, argv[i]));
+	}
+	mrb_define_global_const(mrb, "ARGV", ARGV);
+
+	c = mrbc_context_new(mrb);
+	c->dump_result = TRUE;
+
+	/* Set $0 */
+	zero_sym = mrb_intern_lit(mrb, "$0");
+	mrbc_filename(mrb, c, cmdline);
+	mrb_gv_set(mrb, zero_sym, mrb_str_new_cstr(mrb, cmdline));
+
+	irep = mrb_read_irep(mrb, code);
 	n = mrb_proc_new(mrb, irep);
 	mrb_run(mrb, n, mrb_nil_value());
 
+	mrb_gc_arena_restore(mrb, ai);
+	mrbc_context_free(mrb, c);
+	if (mrb->exc) {
+		if (!mrb_undef_p(v)) {
+			mrb_print_error(mrb);
+		}
+		n = -1;
+	}
+
 	mrb_close(mrb);
-}
-
-static void execute_ruby()
-{
-	FIL fd;
-	FRESULT res;
-	ER ret;
-
-	syslog(LOG_NOTICE, "execute_ruby");
-
-	ret = ter_tsk(MRUBY_TASK);
-	if ((ret != E_OK) && (ret != E_OBJ)) {
-		syslog(LOG_ERROR, "ter_tsk => %d", ret);
-	}
-
-	tslp_tsk(100000);
-
-	reset_heap();
-
-	strcpy_s(ExeFilename, sizeof(ExeFilename), RubyFilename);
-	RubyFilename[0] = '\0';
-	ExeFilename[sizeof(ExeFilename) - 1] = '\0';
-
-	if (ExeFilename[0] == '\0') {
+	return 0;
+}
+
+int tcp_echo_main(int argc, char **argv)
+{
+	extern const uint8_t echo_server_code[];
+	extern const uint8_t echo_client_code[];
+
+	if (argc >= 2) {
+		if (strcmp(argv[1], "-s") == 0) {
+			return run_mruby_code(argc - 2, &argv[2], echo_server_code, "echo_server");
+		}
+		else if (strcmp(argv[1], "-c") == 0) {
+			return run_mruby_code(argc - 2, &argv[2], echo_client_code, "echo_client");
+		}
+	}
+
+	printf("tcp_echo -s port\n");
+	printf("tcp_echo -c ipaddr port\n");
+
+	return 0;
+}
+
+int usrcmd_help(int argc, char **argv)
+{
+	const cmd_table_t *p = cmd_table_info.table;
+	for (int i = 0; i < cmd_table_info.count; i++) {
+		printf(p->cmd);
+		printf("\t:");
+		printf(p->desc);
+		printf("\n");
+		p++;
+	}
+	return 0;
+}
+
+void sigusr1_handler(int sig)
+{
+	printf("signal called\n");
+}
+
+void mrb_target_board_init()
+{
+	int ret;
+	struct sockaddr_in ep;
+	struct ip_mreq mreq;
+
+	signal(SIGUSR1, sigusr1_handler);
+
+	sock = socket(AF_INET, SOCK_DGRAM, 0);
+
+	memset(&ep, 0, sizeof(ep));
+	ep.sin_family = AF_INET;
+	ep.sin_port = htons(3610);
+	ep.sin_addr.s_addr = INADDR_ANY;
+	//ep.sin_addr.s_addr = MAKE_IPV4_ADDR(192,168,137,200);
+
+	ret = bind(sock, &ep, sizeof(ep));
+	if (ret != 0) {
+		printf("bind %d", ret);
 		return;
 	}
 
-	syslog(LOG_NOTICE, "%s", ExeFilename);
-
-	wai_sem(SEM_FILESYSTEM);
-
-	if ((res = f_open(&fd, ExeFilename, FA_OPEN_EXISTING | FA_READ)) == FR_OK) {
-		if (fd.fsize < sizeof(RubyCode)) {
-			int len = fd.fsize;
-			for (int pos = 0; pos < fd.fsize; pos += len) {
-				if (len > 1024)
-					len = 1024;
-
-				UINT rlen;
-				if ((res = f_read(&fd, &RubyCode[pos], len, &rlen)) != FR_OK)
-					break;
-
-				// ä»ã«ä½¿ãäººã®ããã«è§£æ¾
-				sig_sem(SEM_FILESYSTEM);
-				wai_sem(SEM_FILESYSTEM);
-			}
-		}
-		f_close(&fd);
-	}
-
-	sig_sem(SEM_FILESYSTEM);
-
-	if (res == FR_OK) {
-		ret = act_tsk(MRUBY_TASK);
-		if (ret != E_OK) {
-			syslog(LOG_ERROR, "act_tsk => %d", ret);
-		}
-	}
-}
-
-ER callback_nblk_udp(ID cepid, FN fncd, void *p_parblk)
-{
-	static struct udp_msg msg_inst[2];
-	static int msg_no = 0;
-	struct udp_msg *msg = &msg_inst[msg_no];
-	ER	error = E_OK;
-
-	switch (fncd) {
-	case TFN_UDP_CRE_CEP:
-	case TFN_UDP_RCV_DAT:
-		/* ECN_CAP_PUT("[UDP ECHO SRV] callback_nblk_udp() recv: %u", *(int *)p_parblk); */
-		memset(msg, 0, sizeof(struct udp_msg));
-		if ((msg->len = udp_rcv_dat(cepid, &msg->dst, msg->buffer, sizeof(msg->buffer), 0)) < 0) {
-			syslog(LOG_WARNING, "[UDP ECHO SRV] recv, error: %s", itron_strerror(msg->len));
-			return msg->len;
-		}
-		msg_no = (msg_no + 1) % 2;
-		return snd_dtq(MRUBY_DATAQUEUE, (intptr_t)msg);
-
-	case TFN_UDP_SND_DAT:
-		break;
-	default:
-		syslog(LOG_WARNING, "[UDP ECHO SRV] fncd:0x%04X(%s)", -fncd,
-			(fncd == TFN_UDP_CRE_CEP ? "TFN_UDP_CRE_CEP" :
-			(fncd == TFN_UDP_RCV_DAT ? "TFN_UDP_RCV_DAT" :
-				(fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef"))));
-
-		error = E_PAR;
-		break;
-	}
-	return error;
-}
-
-static void netif_link_callback(T_IFNET *ether)
-{
-	static struct udp_msg msg_inst[2];
-	static int msg_no = 0;
-	struct udp_msg *msg = &msg_inst[msg_no];
-	T_RTSK rtsk;
-	ER ret;
-
-	ret = ref_tsk(MRUBY_TASK, &rtsk);
-	if ((ret != E_OK) || (rtsk.tskstat == TTS_DMT))
+	mreq.imr_interface.s_addr = INADDR_ANY;
+	mreq.imr_multiaddr.s_addr = MAKE_IPV4_ADDR(224, 0, 23, 0);
+
+	ret = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq));
+	if (ret != 0) {
+		printf("setsockopt %d", ret);
 		return;
-
-	memset(msg, 0, sizeof(struct udp_msg));
-
-	msg->len = 1;
-	msg->buffer[0] = ether->flags;
-
-	msg_no = (msg_no + 1) % 2;
-	snd_dtq(MRUBY_DATAQUEUE, (intptr_t)msg);
+	}
+
+	ret = gettimeofday(&main_time, NULL);
+	if (ret != 0) {
+		printf("gettimeofday");
+		return;
+	}
+}
+
+void mrb_target_board_final()
+{
+	close(sock);
+}
+
+void mrb_target_board_break()
+{
+	raise(SIGUSR1);
 }
 
@@ -883,39 +294,57 @@
 static mrb_value mrb_target_board_wait_msg(mrb_state *mrb, mrb_value self)
 {
-	TMO timer;
-	SYSTIM now;
-	ER ret, ret2;
-	struct udp_msg *msg;
+	int tmr;
+	struct timeval timer, *ptimer;
+	struct timeval now, elps;
+	int ret, ret2;
+	struct udp_msg _msg;
+	struct udp_msg *msg = &_msg;
 	mrb_value arv[3];
-	static int first = 1;
-
-	mrb_get_args(mrb, "i", &timer);
-	if (timer != TMO_FEVR)
-		timer *= 1000;
-
-	if (first) {
-		first = 0;
-		syslog(LOG_NOTICE, "wait_msg");
-	}
+	fd_set readfds, writefds, errorfds;
+
+	mrb_get_args(mrb, "i", &tmr);
+
+	if (tmr < 0)
+		ptimer = NULL;
+	else {
+		timer.tv_sec = tmr / 1000;
+		timer.tv_usec = (tmr % 1000) * 1000;
+		ptimer = &timer;
+	}
+
+	FD_ZERO(&readfds);
+	FD_ZERO(&writefds);
+	FD_ZERO(&errorfds);
+	FD_SET(sock, &readfds);
+	FD_SET(sock, &writefds);
+	FD_SET(sock, &errorfds);
 
 	/* ã¡ãã»ã¼ã¸å¾
 ã¡ */
-	ret = trcv_dtq(MRUBY_DATAQUEUE, (intptr_t *)&msg, timer);
-	if ((ret != E_OK) && (ret != E_TMOUT)) {
-		syslog(LOG_ERROR, "trcv_dtq => %d", ret);
+	memset(msg, 0, sizeof(*msg));
+	ret = select(sock + 1, &readfds, &writefds, &errorfds, ptimer);
+	if (ret < 0)
+		mrb_raise(mrb, E_RUNTIME_ERROR, "socket select error");
+	if (FD_ISSET(sock, &readfds)) {
+		int fromlen = sizeof(msg->dst);
+		msg->len = recvfrom(sock, msg->buffer, sizeof(msg->buffer), 0, &msg->dst, &fromlen);
+		if (msg->len < 0) {
+			printf("recvfrom %d", msg->len);
+			return mrb_nil_value();
+		}
+	}
+
+	ret2 = gettimeofday(&now, NULL);
+	if (ret2 != 0) {
+		printf("gettimeofday");
 		return mrb_nil_value();
 	}
 
-	ret2 = get_tim(&now);
-	if (ret2 != E_OK) {
-		syslog(LOG_ERROR, "get_tim => %d", ret);
-		return mrb_nil_value();
-	}
-
-	arv[0] = mrb_fixnum_value((now - mruby_time) / 1000);
-	mruby_time = now;
+	timersub(&now, &main_time, &elps);
+	arv[0] = mrb_fixnum_value(elps.tv_sec);
+	main_time = now;
 
 	/* ã¿ã¤ã ã¢ã¦ãã®å ´å */
-	if (ret == E_TMOUT) {
+	if (ret == 0) {
 		return mrb_ary_new_from_values(mrb, 1, arv);
 	}
@@ -923,5 +352,5 @@
 	/* å
 é¨ã¤ãã³ãã®å ´å */
-	if (msg->dst.ipaddr == 0) {
+	if (msg->dst.sin_addr.s_addr == 0) {
 		/* Ethernet Link up */
 		if (msg->buffer[0] & IF_FLAG_LINK_UP) {
@@ -931,7 +360,4 @@
 		else if (msg->buffer[0] & IF_FLAG_UP) {
 			arv[1] = mrb_fixnum_value(2);
-		}
-		else {
-			arv[1] = mrb_fixnum_value(0);
 		}
 
@@ -967,19 +393,19 @@
 	mrb_value rep;
 	mrb_value rdat;
-	T_IPV4EP *ep;
-	ER_UINT ret;
+	struct sockaddr_in *ep;
+	int ret;
 
 	mrb_get_args(mrb, "SS", &rep, &rdat);
 
-	if (RSTRING_LEN(rep) != sizeof(T_IPV4EP)) {
+	if (RSTRING_LEN(rep) != sizeof(struct sockaddr_in)) {
 		mrb_raise(mrb, E_RUNTIME_ERROR, "snd_msg");
 		return mrb_nil_value();
 	}
 
-	ep = (T_IPV4EP *)RSTRING_PTR(rep);
-
-	ret = udp_snd_dat(MRUBY_ECNL_UDP_CEPID, ep, RSTRING_PTR(rdat), RSTRING_LEN(rdat), TMO_FEVR);
+	ep = (struct sockaddr_in *)RSTRING_PTR(rep);
+
+	ret = sendto(sock, RSTRING_PTR(rdat), RSTRING_LEN(rdat), 0, (struct sockaddr *)ep, sizeof(*ep));
 	if (ret < 0) {
-		mrb_raise(mrb, E_RUNTIME_ERROR, "snd_msg");
+		mrb_raise(mrb, E_RUNTIME_ERROR, "sendto");
 		return mrb_nil_value();
 	}
@@ -994,16 +420,16 @@
 {
 	mrb_value rep;
-	T_IPV4EP *ep;
+	struct sockaddr_in *ep;
 
 	mrb_get_args(mrb, "S", &rep);
 
-	if (RSTRING_LEN(rep) < sizeof(T_IPV4EP)) {
+	if (RSTRING_LEN(rep) < sizeof(struct sockaddr_in)) {
 		mrb_raise(mrb, E_RUNTIME_ERROR, "is_local_addr");
 		return mrb_nil_value();
 	}
 
-	ep = (T_IPV4EP *)RSTRING_PTR(rep);
-
-	return (ep->ipaddr == MAKE_IPV4_ADDR(127, 0, 0, 1)) ? mrb_true_value() : mrb_false_value();
+	ep = (struct sockaddr_in *)RSTRING_PTR(rep);
+
+	return (ep->sin_addr.s_addr == MAKE_IPV4_ADDR(127, 0, 0, 1)) ? mrb_true_value() : mrb_false_value();
 }
 
@@ -1014,16 +440,16 @@
 {
 	mrb_value rep;
-	T_IPV4EP *ep;
+	struct sockaddr_in *ep;
 
 	mrb_get_args(mrb, "S", &rep);
 
-	if (RSTRING_LEN(rep) < sizeof(T_IPV4EP)) {
+	if (RSTRING_LEN(rep) < sizeof(struct sockaddr_in)) {
 		mrb_raise(mrb, E_RUNTIME_ERROR, "is_multicast_addr");
 		return mrb_nil_value();
 	}
 
-	ep = (T_IPV4EP *)RSTRING_PTR(rep);
-
-	return (ep->ipaddr == MAKE_IPV4_ADDR(224, 0, 23, 0)) ? mrb_true_value() : mrb_false_value();
+	ep = (struct sockaddr_in *)RSTRING_PTR(rep);
+
+	return (ep->sin_addr.s_addr == MAKE_IPV4_ADDR(224, 0, 23, 0)) ? mrb_true_value() : mrb_false_value();
 }
 
@@ -1034,17 +460,17 @@
 {
 	mrb_value rep1, rep2;
-	T_IPV4EP *ep1, *ep2;
+	struct sockaddr_in *ep1, *ep2;
 
 	mrb_get_args(mrb, "SS", &rep1, &rep2);
 
-	if ((RSTRING_LEN(rep1) != sizeof(T_IPV4EP)) || (RSTRING_LEN(rep2) != sizeof(T_IPV4EP))) {
+	if ((RSTRING_LEN(rep1) != sizeof(struct sockaddr_in)) || (RSTRING_LEN(rep2) != sizeof(struct sockaddr_in))) {
 		mrb_raise(mrb, E_RUNTIME_ERROR, "equals_addr");
 		return mrb_nil_value();
 	}
 
-	ep1 = (T_IPV4EP *)RSTRING_PTR(rep1);
-	ep2 = (T_IPV4EP *)RSTRING_PTR(rep2);
-
-	return (ep1->ipaddr == ep2->ipaddr) ? mrb_true_value() : mrb_false_value();
+	ep1 = (struct sockaddr_in *)RSTRING_PTR(rep1);
+	ep2 = (struct sockaddr_in *)RSTRING_PTR(rep2);
+
+	return (ep1->sin_addr.s_addr == ep2->sin_addr.s_addr) ? mrb_true_value() : mrb_false_value();
 }
 
@@ -1054,9 +480,11 @@
 static mrb_value mrb_target_board_get_local_addr(mrb_state *mrb, mrb_value self)
 {
-	T_IPV4EP ep;
+	struct sockaddr_in ep;
 	mrb_value rep;
 
-	ep.ipaddr = MAKE_IPV4_ADDR(127, 0, 0, 1);
-	ep.portno = 3610;
+	memset(&ep, 0, sizeof(ep));
+	ep.sin_family = AF_INET;
+	ep.sin_addr.s_addr = MAKE_IPV4_ADDR(127, 0, 0, 1);
+	ep.sin_port = htons(3610);
 
 	rep = mrb_str_new(mrb, (char *)&ep, sizeof(ep));
@@ -1070,9 +498,11 @@
 static mrb_value mrb_target_board_get_multicast_addr(mrb_state *mrb, mrb_value self)
 {
-	T_IPV4EP ep;
+	struct sockaddr_in ep;
 	mrb_value rep;
 
-	ep.ipaddr = MAKE_IPV4_ADDR(224, 0, 23, 0);
-	ep.portno = 3610;
+	memset(&ep, 0, sizeof(ep));
+	ep.sin_family = AF_INET;
+	ep.sin_addr.s_addr = MAKE_IPV4_ADDR(224, 0, 23, 0);
+	ep.sin_port = htons(3610);
 
 	rep = mrb_str_new(mrb, (char *)&ep, sizeof(ep));
@@ -1083,52 +513,8 @@
 void mrb_mruby_others_gem_init(mrb_state* mrb)
 {
+	if (!echonet)
+		return;
+
 	_module_target_board = mrb_define_module(mrb, "TargetBoard");
-
-	// mbed Pin Names
-	mrb_define_const(mrb, _module_target_board, "LED1", mrb_fixnum_value(LED1));
-	mrb_define_const(mrb, _module_target_board, "LED2", mrb_fixnum_value(LED2));
-	mrb_define_const(mrb, _module_target_board, "LED3", mrb_fixnum_value(LED3));
-	mrb_define_const(mrb, _module_target_board, "LED4", mrb_fixnum_value(LED4));
-
-	mrb_define_const(mrb, _module_target_board, "LED_RED", mrb_fixnum_value(LED_RED));
-	mrb_define_const(mrb, _module_target_board, "LED_GREEN", mrb_fixnum_value(LED_GREEN));
-	mrb_define_const(mrb, _module_target_board, "LED_BLUE", mrb_fixnum_value(LED_BLUE));
-	mrb_define_const(mrb, _module_target_board, "LED_USER", mrb_fixnum_value(LED_USER));
-
-	mrb_define_const(mrb, _module_target_board, "USBTX", mrb_fixnum_value(USBTX));
-	mrb_define_const(mrb, _module_target_board, "USBRX", mrb_fixnum_value(USBRX));
-
-	// Arduiono Pin Names
-	mrb_define_const(mrb, _module_target_board, "D0", mrb_fixnum_value(D0));
-	mrb_define_const(mrb, _module_target_board, "D1", mrb_fixnum_value(D1));
-	mrb_define_const(mrb, _module_target_board, "D2", mrb_fixnum_value(D2));
-	mrb_define_const(mrb, _module_target_board, "D3", mrb_fixnum_value(D3));
-	mrb_define_const(mrb, _module_target_board, "D4", mrb_fixnum_value(D4));
-	mrb_define_const(mrb, _module_target_board, "D5", mrb_fixnum_value(D5));
-	mrb_define_const(mrb, _module_target_board, "D6", mrb_fixnum_value(D6));
-	mrb_define_const(mrb, _module_target_board, "D7", mrb_fixnum_value(D7));
-	mrb_define_const(mrb, _module_target_board, "D8", mrb_fixnum_value(D8));
-	mrb_define_const(mrb, _module_target_board, "D9", mrb_fixnum_value(D9));
-	mrb_define_const(mrb, _module_target_board, "D10", mrb_fixnum_value(D10));
-	mrb_define_const(mrb, _module_target_board, "D11", mrb_fixnum_value(D11));
-	mrb_define_const(mrb, _module_target_board, "D12", mrb_fixnum_value(D12));
-	mrb_define_const(mrb, _module_target_board, "D13", mrb_fixnum_value(D13));
-	mrb_define_const(mrb, _module_target_board, "D14", mrb_fixnum_value(D14));
-	mrb_define_const(mrb, _module_target_board, "D15", mrb_fixnum_value(D15));
-
-	mrb_define_const(mrb, _module_target_board, "A0", mrb_fixnum_value(A0));
-	mrb_define_const(mrb, _module_target_board, "A1", mrb_fixnum_value(A1));
-	mrb_define_const(mrb, _module_target_board, "A2", mrb_fixnum_value(A2));
-	mrb_define_const(mrb, _module_target_board, "A3", mrb_fixnum_value(A3));
-	mrb_define_const(mrb, _module_target_board, "A4", mrb_fixnum_value(A4));
-	mrb_define_const(mrb, _module_target_board, "A5", mrb_fixnum_value(A5));
-
-	mrb_define_const(mrb, _module_target_board, "I2C_SCL", mrb_fixnum_value(I2C_SCL));
-	mrb_define_const(mrb, _module_target_board, "I2C_SDA", mrb_fixnum_value(I2C_SDA));
-
-	mrb_define_const(mrb, _module_target_board, "USER_BUTTON0", mrb_fixnum_value(USER_BUTTON0));
-
-	// Not connected
-	mrb_define_const(mrb, _module_target_board, "NC", mrb_fixnum_value(NC));
 
 	mrb_define_class_method(mrb, _module_target_board, "wait_msg", mrb_target_board_wait_msg, MRB_ARGS_REQ(1));
@@ -1140,7 +526,62 @@
 	mrb_define_class_method(mrb, _module_target_board, "get_local_addr", mrb_target_board_get_local_addr, MRB_ARGS_NONE());
 	mrb_define_class_method(mrb, _module_target_board, "get_multicast_addr", mrb_target_board_get_multicast_addr, MRB_ARGS_NONE());
+
+	mrb_target_board_init();
 }
 
 void mrb_mruby_others_gem_final(mrb_state* mrb)
 {
-}
+	if (!echonet)
+		return;
+
+	mrb_target_board_final();
+}
+
+// Provide implementation of _sbrk (low-level dynamic memory allocation
+// routine) for GCC_ARM which compares new heap pointer with MSP instead of
+// SP.  This make it compatible with RTX RTOS thread stacks.
+
+// Linker defined symbol used by _sbrk to indicate where heap should start.
+int _end;
+uint32_t  _stack;
+
+// Turn off the errno macro and use actual global variable instead.
+#undef errno
+int errno;
+
+static unsigned char* heap = (unsigned char*)&_end;
+
+// Dynamic memory allocation related syscall.
+caddr_t _sbrk(int incr) {
+	unsigned char*        prev_heap = heap;
+	unsigned char*        new_heap = heap + incr;
+
+	if (new_heap >= (unsigned char*)&_stack) {     /* _stack is end of heap section */
+		errno = ENOMEM;
+		return (caddr_t)-1;
+	}
+
+	heap = new_heap;
+	return (caddr_t) prev_heap;
+}
+
+char *optarg;
+int _data, _mdata, _edata;
+int _bss, _ebss;
+
+int _PowerON_Reset(int argc, char **argv)
+{
+	memcpy(&_data, &_mdata, (size_t)&_edata - (size_t)&_data);
+	memset(&_bss, 0, (size_t)&_ebss - (size_t)&_bss);
+
+	optarg = *argv;
+	return main(argc, argv);
+}
+
+#define FVECT_SECT          __attribute__ ((section (".fvectors")))
+const void *HardwareVectors[] FVECT_SECT = {
+	_PowerON_Reset,
+	mrdb_break,
+};
+
+char stack_space[0x100000] __attribute__ ((section (".stack")));
Index: nlProtoTool/trunk/prototool/src/main.cdl
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/main.cdl	(revision 278)
+++ 	(revision )
@@ -1,125 +1,0 @@
-/*
- *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
- *
- *  $Id$
- */
-/*
- *  ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å®ç¾©
- */
-import(<kernel.cdl>);
-
-/*
- *  ã¿ã¼ã²ããéä¾å­ã®ã»ã«ã¿ã¤ãã®å®ç¾©
- */
-import("syssvc/tSerialPort.cdl");
-import("syssvc/tSerialAdapter.cdl");
-import("syssvc/tSysLog.cdl");
-import("syssvc/tSysLogAdapter.cdl");
-import("syssvc/tLogTask.cdl");
-import("syssvc/tBanner.cdl");
-
-/*
- *  ã¿ã¼ã²ããä¾å­é¨ã®åãè¾¼ã¿
- */
-import("target.cdl");
-
-/*
- *  ãã»ã«ã®çµä¸ãè¨è¿°ãã¨ã¯ï¼"cell"ã§å§ã¾ãè¡ããï¼ããã«å¯¾å¿ãã"};"
- *  ã®è¡ã¾ã§ã®ãã¨ãè¨ãï¼
- */
-
-/*
- *  ã·ã¹ãã ã­ã°æ©è½ã®çµä¸ãè¨è¿°
- *
- *  ã·ã¹ãã ã­ã°æ©è½ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãï¼ã³
- *  ã³ãã¤ã«ãªãã·ã§ã³ã«-DTOPPERS_OMIT_SYSLOGãè¿½å ããã°ããï¼ãã ãï¼
- *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ã¹ãã ã­ã°æ©è½ãä½¿ç¨ããããï¼ãããå¤ããã¨
- *  ãå¿
-è¦ã§ããï¼ã¾ãï¼ã·ã¹ãã ã­ã°æ©è½ã®ã¢ããã¿ãå¤ããªããã°ãªããª
- *  ãï¼tecsgenãè­¦åã¡ãã»ã¼ã¸ãåºããï¼ç¡è¦ãã¦ããï¼
- */
-cell tSysLog SysLog {
-	logBufferSize = 32;					/* ã­ã°ãããã¡ã®ãµã¤ãº */
-	initLogMask = C_EXP("LOG_UPTO(LOG_NOTICE)");
-										/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
-	initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)");
-									   	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
-	/* ä½ã¬ãã«åºåã¨ã®çµå */
-	cPutLog = PutLogTarget.ePutLog;
-};
-
-/*
- *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ã¹ãã ã­ã°æ©è½
- *  ãå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
- *
- *  ã·ã¹ãã ã­ã°æ©è½ã®ãµã¼ãã¹ã³ã¼ã«ï¼syslogé¢æ°ã¨syslog_0é¢æ°ï½syslog_5
- *  é¢æ°ä»¥å¤ã®ãã®ï¼ã«ãCè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºããª
- *  ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ããã°ããï¼
- */
-cell tSysLogAdapter SysLogAdapter {
-	cSysLog = SysLog.eSysLog;
-};
-
-/*
- *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®çµä¸ãè¨è¿°
- *
- *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ããå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨
- *  è¿°ãåé¤ããã°ããï¼ãã ãï¼ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼
- *  ã¹ãã©ã¤ããä½¿ç¨ããããï¼ãããå¤ããã¨ãå¿
-è¦ã§ããï¼ã¾ãï¼ã·ãªã¢
- *  ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¢ããã¿ãå¤ããªããã°ãªããªãï¼
- */
-cell tSerialPort SerialPort1 {
-	receiveBufferSize = 256;			/* åä¿¡ãããã¡ã®ãµã¤ãº */
-	sendBufferSize    = 256;			/* éä¿¡ãããã¡ã®ãµã¤ãº */
-
-	/* ã¿ã¼ã²ããä¾å­é¨ã¨ã®çµå */
-	cSIOPort = SIOPortTarget1.eSIOPort;
-	eiSIOCBR <= SIOPortTarget1.ciSIOCBR;	/* ã³ã¼ã«ããã¯ */
-};
-
-/*
- *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ãªã¢ã«ã¤ã³ã¿
- *  ãã§ã¼ã¹ãã©ã¤ããå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
- *
- *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ãµã¼ãã¹ã³ã¼ã«ãCè¨èªã§è¨è¿°ãããã¢
- *  ããªã±ã¼ã·ã§ã³ããå¼ã³åºããªãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãå
- *  é¤ããã°ããï¼
- */
-cell tSerialAdapter SerialAdapter {
-	cSerialPort[0] = SerialPort1.eSerialPort;
-};
-
-/*
- *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®çµä¸ãè¨è¿°
- *
- *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãã
- *  ã°ããï¼
- */
-cell tLogTask LogTask {
-	priority  = 3;					/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®åªå
-åº¦ */
-	stackSize = LogTaskStackSize;	/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
-
-	/* ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨ã®çµå */
-	cSerialPort        = SerialPort1.eSerialPort;
-	cnSerialPortManage = SerialPort1.enSerialPortManage;
-
-	/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®çµå */
-	cSysLog = SysLog.eSysLog;
-
-	/* ä½ã¬ãã«åºåã¨ã®çµå */
-	cPutLog = PutLogTarget.ePutLog;
-};
-
-/*
- *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåã®çµä¸ãè¨è¿°
- *
- *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸ã®åºåãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°
- *  ãåé¤ããã°ããï¼
- */
-cell tBanner Banner {
-	/* å±æ§ã®è¨­å® */
-	targetName      = BannerTargetName;
-	copyrightNotice = BannerCopyrightNotice;
-};
Index: nlProtoTool/trunk/prototool/src/main.cfg
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/main.cfg	(revision 278)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- *  TOPPERS ECHONET Lite Communication Middleware
- * 
- *  Copyright (C) 2014-2016 Cores Co., Ltd. Japan
- * 
- *  ä¸è¨èä½æ¨©è
-ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
- *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
- *  å¤ã»åé
-å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
- *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
- *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
- *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
- *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
- *      è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
- *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããªãå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
- *      ã¨ï¼
- *    (a) åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
- *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *    (b) åé
-å¸ã®å½¢æ
-ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
- *        å ±åãããã¨ï¼
- *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
- *      å®³ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ããå
-è²¬ãããã¨ï¼
- *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
- *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ãã
- *      å
-è²¬ãããã¨ï¼
- * 
- *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
-ã
- *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
- *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
- *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
- *  ã®è²¬ä»»ãè² ããªãï¼
- * 
- *  @(#) $Id$
- */
-
-/*
- *  ãµã³ãã«ãã­ã°ã©ã (1)ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
- */
-#include "main.h"
-#include <tinet_config.h>
-#include <netinet/in.h>
-#include <netinet/in_itron.h>
-#include <tinet_nic_defs.h>
-#include <netinet/in_var.h>
-#include <net/ethernet.h>
-#include <net/if6_var.h>
-
-INCLUDE("tecsgen.cfg");
-INCLUDE("tinet/tinet_asp.cfg");
-INCLUDE("tinet_main.cfg");
-/*#include "netapp/dhcp4_cli.h"*/
-/*INCLUDE("netapp/dhcp4_cli_asp.cfg");*/
-INCLUDE("mruby_arduino.cfg");
-
-CRE_TSK(MAIN1_TASK, { TA_ACT, 0, main_task, MAIN_PRIORITY, MAIN_STACK_SIZE, NULL });
-CRE_TSK(MAIN2_TASK, { TA_NULL, 1, main_task, MAIN_PRIORITY, MAIN_STACK_SIZE, NULL });
-CRE_SEM(SEM_FILESYSTEM, { TA_TPRI, 1, 1 });
-
-CRE_TSK(MRUBY_TASK, { TA_NULL, 0, mruby_task, MRUBY_PRIORITY, MRUBY_STACK_SIZE, NULL });
-CRE_DTQ(MRUBY_DATAQUEUE, { TA_TFIFO, 1, NULL });
Index: nlProtoTool/trunk/prototool/src/main.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/main.h	(revision 278)
+++ 	(revision )
@@ -1,109 +1,0 @@
-/*
- *  TOPPERS ECHONET Lite Communication Middleware
- * 
- *  Copyright (C) 2014-2017 Cores Co., Ltd. Japan
- * 
- *  ä¸è¨èä½æ¨©è
-ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
- *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
- *  å¤ã»åé
-å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
- *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
- *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
- *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
- *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
- *      è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
- *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããªãå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
- *      ã¨ï¼
- *    (a) åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
- *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *    (b) åé
-å¸ã®å½¢æ
-ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
- *        å ±åãããã¨ï¼
- *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
- *      å®³ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ããå
-è²¬ãããã¨ï¼
- *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
- *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ãã
- *      å
-è²¬ãããã¨ï¼
- * 
- *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
-ã
- *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
- *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
- *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
- *  ã®è²¬ä»»ãè² ããªãï¼
- * 
- *  @(#) $Id$
- */
-
-#ifndef _MAIN_H_
-#define _MAIN_H_
-
-/*
- *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ããããã¡ã¤ã«
- */
-
-/*
- *  ã¿ã¼ã²ããä¾å­ã®å®ç¾©
- */
-#include <kernel.h>
-
-/*
- *  åã¿ã¹ã¯ã®åªå
-åº¦ã®å®ç¾©
- */
-
-#define MAIN_PRIORITY	5		/* ã¡ã¤ã³ã¿ã¹ã¯ã®åªå
-åº¦ */
-#define MRUBY_PRIORITY	4		/* mrubyå®è¡ã¿ã¹ã¯ã®åªå
-åº¦ */
-
-#define MAIN_STACK_SIZE		1024	/* ã¡ã¤ã³ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®ãµã¤ãº */
-#define MRUBY_STACK_SIZE	16384	/* mrubyå®è¡ã®ã¹ã¿ãã¯é åã®ãµã¤ãº */
-
- /*  TCP éåä¿¡ã¦ã£ã³ããããã¡ãµã¤ãº  */
-
-#define TCP_SWBUF_SIZE	1024
-#define TCP_RWBUF_SIZE	1024
-
-/*
- *  é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨
- */
-#ifndef TOPPERS_MACRO_ONLY
-
- /*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
-
-extern uint8_t tcp_swbuf1[];
-extern uint8_t tcp_rwbuf1[];
-extern uint8_t tcp_swbuf2[];
-extern uint8_t tcp_rwbuf2[];
-
-/* ã¡ã¤ã³ã¿ã¹ã¯ */
-extern void main_task(intptr_t exinf);
-
-/* mrubyå®è¡ã¿ã¹ã¯ */
-extern void mruby_task(intptr_t exinf);
-
-/* 
- * ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
- */
-extern ER callback_nblk_udp(ID cepid, FN fncd, void *p_parblk);
-extern ER callback_nblk_tcp(ID cepid, FN fncd, void *p_parblk);
-
-#endif /* TOPPERS_MACRO_ONLY */
-
-#endif	/* of #ifndef _MAIN_H_ */
Index: nlProtoTool/trunk/prototool/src/main.rb
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/main.rb	(revision 278)
+++ 	(revision )
@@ -1,418 +1,0 @@
-# TOPPERSãã­ã¸ã§ã¯ã
-$MAKER_CODE = "\x00\x00\xB3"
-
-# ãã¼ããã­ãã¡ã¤ã«ãªãã¸ã§ã¯ã
-class LocalNode < ECNL::ENode
-	def initialize(eojx3)
-		# åä½ç¶æ
-
-		@operation_status = "\x30"
-		# ï¼¶ï½
-ï½ï½ï½ï½ï½æ
-å ±
-		@version_information = "\x01\x0A\x01\x00"
-		# è­å¥çªå·
-		@identification_number = 
-			# ä¸ä½éä¿¡å±¤IDãã£ã¼ã«ã
-			"\xFE" +
-			# ã¡ã¼ã«ã¼ã³ã¼ã
-			$MAKER_CODE +
-			# ã¦ãã¼ã¯IDé¨(ã¡ã¼ã«ã¼ç¬èª)
-			"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-		# ç°å¸¸å
-å®¹
-		@fault_content = "\x00\x00"
-		# ã¡ã¼ã«ã¼ã³ã¼ã
-		@manufacturer_code = $MAKER_CODE
-
-		# ã¤ã³ã¹ã¿ã³ã¹æ°
-		@inst_count = "\x00\x00\x01"
-		# ã¯ã©ã¹æ°
-		@class_count = "\x00\x02"
-		# ã¤ã³ã¹ã¿ã³ã¹ãªã¹ã
-		@inst_list = "\x01\x05\xff\x01"
-		# ã¯ã©ã¹ãªã¹ã
-		@class_list = "\x01\x05\xff"
-		# ã¢ãã¦ã³ã¹ãã­ããã£ããã
-		@anno_prpmap = "\x01\xd5"
-		# SETãã­ããã£ããã
-		@set_prpmap = "\x01\x80"
-		# GETãã­ããã£ããã
-		@get_prpmap = "\x0c\x80\x82\x83\x89\x8a\x9d\x9e\x9f\xd3\xd4\xd6\xd7"
-		# ãã­ããã£å®ç¾©
-		eprpinib_table = [
-			ECNL::EProperty.new(0x80, (ECNL::EPC_RULE_SET | ECNL::EPC_RULE_GET), @operation_status.length, :@operation_status, :onoff_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x82, (ECNL::EPC_RULE_GET), @version_information.length, :@version_information, :data_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x83, (ECNL::EPC_RULE_GET), @identification_number.length, :@identification_number, :data_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x89, (ECNL::EPC_RULE_GET), @fault_content.length, :fault_content, :@node_profile_object_fault_content_set, :data_prop_get),
-			ECNL::EProperty.new(0x8A, (ECNL::EPC_RULE_GET), @manufacturer_code.length, :@manufacturer_code, :data_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x9D, (ECNL::EPC_RULE_GET), @anno_prpmap.length, :@anno_prpmap, nil, :data_prop_get),
-			ECNL::EProperty.new(0x9E, (ECNL::EPC_RULE_GET), @set_prpmap.length, :@set_prpmap, nil, :data_prop_get),
-			ECNL::EProperty.new(0x9F, (ECNL::EPC_RULE_GET), @get_prpmap.length, :@get_prpmap, nil, :data_prop_get),
-			ECNL::EProperty.new(0xD3, (ECNL::EPC_RULE_GET), @inst_count.length, :@inst_count, nil, :data_prop_get),
-			ECNL::EProperty.new(0xD4, (ECNL::EPC_RULE_GET), @class_count.length, :@class_count, nil, :data_prop_get),
-			ECNL::EProperty.new(0xD5, (ECNL::EPC_RULE_ANNO), @inst_list.length, :@inst_list, nil, :data_prop_get),
-			ECNL::EProperty.new(0xD6, (ECNL::EPC_RULE_GET), @inst_list.length, :@inst_list, nil, :data_prop_get),
-			ECNL::EProperty.new(0xD7, (ECNL::EPC_RULE_GET), @class_list.length, :@class_list, nil, :data_prop_get)
-		]
-
-		super(eojx3, eprpinib_table)
-	end
-
-	# ç°å¸¸å
-å®¹è¨­å®é¢æ°
-	def node_profile_object_fault_content_set(prop, src)
-		# ãµã¤ãºã2ä»¥å¤ã¯åãä»ããªã
-		if (src.bytesize != 2) then
-			return 0
-		end
-
-		if (prop.anno) then
-			prop.set_anno(prop.exinf != src)
-		end
-
-		val = src.getbyte(0) << 8 | src.getbyte(1)
-
-		if ((val >= 0x0) && (val <= 0x3ec)) then
-			prop.set_exinf(val)
-			# TODO: ãã®ã®å ´åã®å¦ç
-		# ä¸è¨ä»¥å¤ã¯åãä»ããªã
-		else
-			return 0
-		end
-
-		return 2
-	end
-
-	# åä½ç¶æ
-ON/OFFè¨­å®é¢æ°ï¼0x30, 0x31ã®ã¿åãä»ãï¼
-	def onoff_prop_set(prop, src)
-		return 0
-	end
-end
-
-# ã³ã³ãã­ã¼ã©ã¼ã¯ã©ã¹
-class Controller < ECNL::EObject
-	def initialize(eojx3, enod)
-		# åä½ç¶æ
-
-		@operation_status = "\x30"
-		# è¨­ç½®å ´æ
-		@installation_location = "\x01\x0A\x01\x00"
-		# è¦æ ¼ï¼¶ï½
-ï½ï½ï½ï½ï½æ
-å ±
-		@standard_version_information = "\x00\x00C\x00"
-		# ç°å¸¸çºçç¶æ
-
-		@fault_status = "\x41"
-		# ã¡ã¼ã«ã¼ã³ã¼ã
-		@manufacturer_code = $MAKER_CODE
-
-		# ã¢ãã¦ã³ã¹ãã­ããã£ããã
-		@anno_prpmap = "\x03\x80\x81\x88"
-		# SETãã­ããã£ããã
-		@set_prpmap = "\x04\x80\x81\x97\x98"
-		# GETãã­ããã£ããã
-		@get_prpmap = "\x0a\x80\x81\x82\x88\x8a\x97\x98\x9d\x9e\x9f"
-		# ãã­ããã£å®ç¾©
-		eprpinib_table = [
-			ECNL::EProperty.new(0x80, (ECNL::EPC_RULE_SET | ECNL::EPC_RULE_GET | ECNL::EPC_ANNOUNCE), @operation_status.length, :@operation_status, :onoff_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x81, (ECNL::EPC_RULE_SET | ECNL::EPC_RULE_GET | ECNL::EPC_ANNOUNCE), @installation_location.length, :@installation_location, :data_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x82, (ECNL::EPC_RULE_GET), @standard_version_information.length, :@standard_version_information, :data_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x88, (ECNL::EPC_RULE_GET | ECNL::EPC_ANNOUNCE), @fault_status.length, :@fault_status, :alarm_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x8A, (ECNL::EPC_RULE_GET), @manufacturer_code.length, :@manufacturer_code, :data_prop_set, :data_prop_get),
-			ECNL::EProperty.new(0x97, (ECNL::EPC_RULE_SET | ECNL::EPC_RULE_GET), (2), nil, :time_prop_set, :time_prop_get),
-			ECNL::EProperty.new(0x98, (ECNL::EPC_RULE_SET | ECNL::EPC_RULE_GET), (4), nil, :date_prop_set, :date_prop_get),
-			ECNL::EProperty.new(0x9D, (ECNL::EPC_RULE_GET), @anno_prpmap.length, :@anno_prpmap, nil, :data_prop_get),
-			ECNL::EProperty.new(0x9E, (ECNL::EPC_RULE_GET), @set_prpmap.length, :@set_prpmap, nil, :data_prop_get),
-			ECNL::EProperty.new(0x9F, (ECNL::EPC_RULE_GET), @get_prpmap.length, :@get_prpmap, nil, :data_prop_get)
-		]
-
-		super(0x05, 0xFF, eojx3, enod, eprpinib_table)
-	end
-
-	# åä½ç¶æ
-ON/OFFè¨­å®é¢æ°ï¼0x30, 0x31ã®ã¿åãä»ãï¼
-	def onoff_prop_set(prop, src)
-		# ãµã¤ãºãï¼ä»¥å¤ã¯åãä»ããªã
-		if (src.bytesize != 1) then
-			return 0
-		end
-
-		if (prop.anno) then
-			prop.set_anno(prop.exinf != src)
-		end
-
-		case (src.getbyte(0))
-		# ONã®å ´å
-		when 0x30 then
-			prop.set_exinf(src)
-			# LEDã®"."ãON
-			digitalWrite(1, 1)
-		# OFFã®å ´å
-		when 0x31 then
-			prop.set_exinf(src)
-			# LEDã®"."ãOFF
-			digitalWrite(1, 0)
-		# 0x30ã0x31ä»¥å¤ã¯åãä»ããªã
-		else
-			return 0
-		end
-
-		return 1
-	end
-
-	# ç°å¸¸çºçç¶æ
-è¨­å®é¢æ°ï¼0x41, 0x42ã®ã¿åãä»ãï¼
-	def alarm_prop_set(prop, src)
-		# ãµã¤ãºãï¼ä»¥å¤ã¯åãä»ããªã
-		if (src.bytesize != 1) then
-			return 0
-		end
-
-		if (prop.anno) then
-			prop.set_anno(prop.exinf != src)
-		end
-
-		case (src.getbyte(0))
-		# ç°å¸¸çºçãã/ãªãã®å ´å
-		when 0x41,0x42 then
-			prop.set_exinf(src)
-		# 0x41ã0x42ä»¥å¤ã¯åãä»ããªã
-		else
-			return 0
-		end
-
-		return 1
-	end
-
-	# ç¾å¨å¹´ææ¥åå¾é¢æ°
-	def date_prop_get(prop, size)
-		# ãµã¤ãºãï¼ä»¥å¤ã¯åãä»ããªã
-		if (size != 4) then
-			return 0
-		end
-
-		time = Rtc.getTime
-
-		return ((time[0] & 0xFF00) >> 8).chr + (time[0] & 0xFF).chr + time[1].chr + time[2].chr
-	end
-
-	# ç¾å¨å¹´ææ¥è¨­å®é¢æ°
-	def date_prop_set(prop, src)
-		# ãµã¤ãºãï¼ä»¥å¤ã¯åãä»ããªã
-		if (src.bytesize != 4) then
-			return 0
-		end
-
-		time = Rtc.getTime
-		time[0] = (src.getbyte(0) << 8) | src.getbyte(1)
-		time[1] = src.getbyte(2)
-		time[2] = src.getbyte(3)
-		Rtc.setTime time[0], time[1], time[2], time[3], time[4], time[5]
-
-		return 4
-	end
-
-	# ç¾å¨æå»åå¾é¢æ°
-	def time_prop_get(prop, size)
-		# ãµã¤ãºãï¼ä»¥å¤ã¯åãä»ããªã
-		if (size != 2) then
-			return 0
-		end
-
-		time = Rtc.getTime
-
-		return time[3].chr + time[4].chr
-	end
-
-	# ç¾å¨æå»è¨­å®é¢æ°
-	def time_prop_set(prop, src)
-		# ãµã¤ãºãï¼ä»¥å¤ã¯åãä»ããªã
-		if (src.bytesize != 2) then
-			return 0
-		end
-
-		time = Rtc.getTime
-		time[3] = src.getbyte(0)
-		time[4] = src.getbyte(1)
-		Rtc.setTime time[0], time[1], time[2], time[3], time[4], time[5]
-
-		return 2
-	end
-end
-
-class EcnlTask < ECNL::SvcTask
-	def initialize()
-		@profile = LocalNode.new(0x01)
-		@devices = [ Controller.new(0x01, @profile) ]
-		@enodadrb_table = []
-
-		super()
-
-		# LEDãOFF
-		pinMode(TargetBoard::LED_USER, 1)
-		digitalWrite(TargetBoard::LED_USER, 0)
-		digitalWrite(TargetBoard::LED_BLUE, 0)
-
-		set_timer(1000)
-	end
-
-	def recv_esv(esv)
-		if (esv.esv != ECNL::ESV_GET_RES) && (esv.esv != ECNL::ESV_GET_SNA) then
-			return
-		end
-
-		itr = esv.itr_ini()
-		itr.itr_nxt()
-		until itr.is_eof do
-			if itr.epc == 0xD6 then
-				# LEDãON
-				digitalWrite(TargetBoard::LED_USER, 1)
-			end
-			itr.itr_nxt()
-		end
-	end
-
-	def break_wait(data)
-	end
-
-	def timeout()
-		esv = esv_get(nil, 0xD6)
-		snd_esv(esv)
-
-		set_timer(10000)
-	end
-
-	def snd_msg(ep, data)
-		# éä¿¡ã¬ã¤ã¤ã¼ã¸éä¿¡
-		TargetBoard::snd_msg(ep, data)
-	end
-
-	def is_local_addr(ep)
-		TargetBoard::is_local_addr(ep)
-	end
-
-	def is_multicast_addr(ep)
-		TargetBoard::is_multicast_addr(ep)
-	end
-
-	def is_valid_addrid(id)
-		(id >= 0) && ((id - ECNL::ENOD_REMOTE_ID) < @enodadrb_table.length)
-	end
-
-	def get_local_addr()
-		TargetBoard::get_local_addr()
-	end
-
-	def get_multicast_addr()
-		TargetBoard::get_multicast_addr()
-	end
-
-	def get_remote_addr(id)
-		index = id - ECNL::ENOD_REMOTE_ID
-		if (index < 0) || (index >= @enodadrb_table.length)
-			nil
-		else
-			@enodadrb_table[index]
-		end
-	end
-
-	# éä¿¡ã¬ã¤ã¤ã¼ã¢ãã¬ã¹ã®åããã®ãæ¤ç´¢
-	def get_remote_id(ep)
-		id = ECNL::ENOD_REMOTE_ID - 1
-		for ea in @enodadrb_table do
-			id += 1
-			if !ea then
-				next
-			end
-			if !TargetBoard::equals_addr(ea, ep) then
-				next
-			end
-
-			return id
-		end
-
-		return ECNL::ENOD_NOT_MATCH_ID
-	end
-
-	# å¯¾å¿ãããªã¢ã¼ããã¼ããæ¤ç´¢
-	def set_remote_addr(edata, ep)
-		id = ECNL::ENOD_REMOTE_ID - 1
-		for ea in @enodadrb_table do
-			id += 1
-			if !ea then
-				next
-			end
-			if !is_match(svc, edata, ep) then
-				next
-			end
-
-			# å¯¾å¿ãããªã¢ã¼ããã¼ããããã°éä¿¡ã¬ã¤ã¤ã¼ã¢ãã¬ã¹ãè¨­å®
-			@enodadrb_table[id - ECNL::ENOD_REMOTE_ID] = ep
-
-			return id
-		end
-
-		return ECNL::ENOD_NOT_MATCH_ID
-	end
-
-	# ç©ºãé åãæ¢ãã¦èªåç»é²
-	def add_remote_addr(edata, ep)
-		id = ECNL::ENOD_REMOTE_ID - 1
-		for ea in @enodadrb_table do
-			id += 1
-			if ea then
-				next
-			end
-
-			@enodadrb_table[id - ECNL::ENOD_REMOTE_ID] = ep
-
-			return id
-		end
-
-		if @enodadrb_table.length >= 100 then
-			return ECNL::ENOD_NOT_MATCH_ID
-		end
-
-		id = @enodadrb_table.length;
-		@enodadrb_table[id] = ep
-
-		return id + ECNL::ENOD_REMOTE_ID
-	end
-end
-
-ctrl = EcnlTask.new()
-
-# ã¡ã¤ã³ã«ã¼ã
-while (true) do
-	# ã¡ãã»ã¼ã¸å¾
-ã¡
-	ret = TargetBoard::wait_msg(ctrl.timer)
-	if !ret then
-		break;
-	end
-
-	# çµéæéã®è¨ç®
-	ctrl.progress ret[0]
-
-	# æ»ãå¤ãï¼ã¤ãªã
-	if ret.length == 2 then
-		# å
-é¨ã¤ãã³ã
-		case (ret[1])
-		when 1 then
-			TargetBoard::restart
-		when 2 then
-			ctrl.ntf_inl
-		end
-	# æ»ãå¤ãï¼ã¤ãªã
-	elsif ret.length == 3 then
-		# éä¿¡ã¬ã¤ã¤ã¼ããã®ã¡ãã»ã¼ã¸ï¼éä¿¡ç«¯ç¹ã¨é»æï¼
-		ctrl.recv_msg(ret[1], ret[2])
-	end
-
-	# ã¿ã¤ã ã¢ã¦ãã®å¦çãããã°è¡ã
-	ctrl.call_timeout
-end
Index: /EcnlProtoTool/trunk/prototool/src/mirb.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/mirb.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/mirb.c	(revision 279)
@@ -0,0 +1,493 @@
+/*
+** mirb - Embeddable Interactive Ruby Shell
+**
+** This program takes code from the user in
+** an interactive way and executes it
+** immediately. It's a REPL...
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef ENABLE_READLINE
+#include <readline/readline.h>
+#include <readline/history.h>
+#define MIRB_ADD_HISTORY(line) add_history(line)
+#define MIRB_READLINE(ch) readline(ch)
+#define MIRB_WRITE_HISTORY(path) write_history(path)
+#define MIRB_READ_HISTORY(path) read_history(path)
+#define MIRB_USING_HISTORY() using_history()
+#elif defined(ENABLE_LINENOISE)
+#define ENABLE_READLINE
+#include <linenoise.h>
+#define MIRB_ADD_HISTORY(line) linenoiseHistoryAdd(line)
+#define MIRB_READLINE(ch) linenoise(ch)
+#define MIRB_WRITE_HISTORY(path) linenoiseHistorySave(path)
+#define MIRB_READ_HISTORY(path) linenoiseHistoryLoad(history_path)
+#define MIRB_USING_HISTORY()
+#endif
+
+#include "mruby.h"
+#include "mruby/array.h"
+#include "mruby/proc.h"
+#include "mruby/compile.h"
+#include "mruby/string.h"
+
+#ifdef ENABLE_READLINE
+
+static const char history_file_name[] = ".mirb_history";
+
+static char *
+get_history_path(mrb_state *mrb)
+{
+	char *path = NULL;
+	const char *home = getenv("HOME");
+
+#ifdef _WIN32
+	if (home != NULL) {
+		home = getenv("USERPROFILE");
+	}
+#endif
+
+	if (home != NULL) {
+		int len = snprintf(NULL, 0, "%s/%s", home, history_file_name);
+		if (len >= 0) {
+			size_t size = len + 1;
+			path = (char *)mrb_malloc_simple(mrb, size);
+			if (path != NULL) {
+				int n = snprintf(path, size, "%s/%s", home, history_file_name);
+				if (n != len) {
+					mrb_free(mrb, path);
+					path = NULL;
+				}
+			}
+		}
+	}
+
+	return path;
+}
+
+#endif
+
+static void
+p(mrb_state *mrb, mrb_value obj, int prompt)
+{
+	mrb_value val;
+
+	val = mrb_funcall(mrb, obj, "inspect", 0);
+	if (prompt) {
+		if (!mrb->exc) {
+			fputs(" => ", stdout);
+		}
+		else {
+			val = mrb_funcall(mrb, mrb_obj_value(mrb->exc), "inspect", 0);
+		}
+	}
+	if (!mrb_string_p(val)) {
+		val = mrb_obj_as_string(mrb, obj);
+	}
+	fwrite(RSTRING_PTR(val), RSTRING_LEN(val), 1, stdout);
+	putc('\n', stdout);
+}
+
+/* Guess if the user might want to enter more
+ * or if he wants an evaluation of his code now */
+static mrb_bool
+is_code_block_open(struct mrb_parser_state *parser)
+{
+	mrb_bool code_block_open = FALSE;
+
+	/* check for heredoc */
+	if (parser->parsing_heredoc != NULL) return TRUE;
+	if (parser->heredoc_end_now) {
+		parser->heredoc_end_now = FALSE;
+		return FALSE;
+	}
+
+	/* check for unterminated string */
+	if (parser->lex_strterm) return TRUE;
+
+	/* check if parser error are available */
+	if (0 < parser->nerr) {
+		const char unexpected_end[] = "syntax error, unexpected $end";
+		const char *message = parser->error_buffer[0].message;
+
+		/* a parser error occur, we have to check if */
+		/* we need to read one more line or if there is */
+		/* a different issue which we have to show to */
+		/* the user */
+
+		if (strncmp(message, unexpected_end, sizeof(unexpected_end) - 1) == 0) {
+			code_block_open = TRUE;
+		}
+		else if (strcmp(message, "syntax error, unexpected keyword_end") == 0) {
+			code_block_open = FALSE;
+		}
+		else if (strcmp(message, "syntax error, unexpected tREGEXP_BEG") == 0) {
+			code_block_open = FALSE;
+		}
+		return code_block_open;
+	}
+
+	switch (parser->lstate) {
+
+	/* all states which need more code */
+
+	case EXPR_BEG:
+	  /* beginning of a statement, */
+	  /* that means previous line ended */
+		code_block_open = FALSE;
+		break;
+	case EXPR_DOT:
+	  /* a message dot was the last token, */
+	  /* there has to come more */
+		code_block_open = TRUE;
+		break;
+	case EXPR_CLASS:
+	  /* a class keyword is not enough! */
+	  /* we need also a name of the class */
+		code_block_open = TRUE;
+		break;
+	case EXPR_FNAME:
+	  /* a method name is necessary */
+		code_block_open = TRUE;
+		break;
+	case EXPR_VALUE:
+	  /* if, elsif, etc. without condition */
+		code_block_open = TRUE;
+		break;
+
+	  /* now all the states which are closed */
+
+	case EXPR_ARG:
+	  /* an argument is the last token */
+		code_block_open = FALSE;
+		break;
+
+	  /* all states which are unsure */
+
+	case EXPR_CMDARG:
+		break;
+	case EXPR_END:
+	  /* an expression was ended */
+		break;
+	case EXPR_ENDARG:
+	  /* closing parenthese */
+		break;
+	case EXPR_ENDFN:
+	  /* definition end */
+		break;
+	case EXPR_MID:
+	  /* jump keyword like break, return, ... */
+		break;
+	case EXPR_MAX_STATE:
+	  /* don't know what to do with this token */
+		break;
+	default:
+	  /* this state is unexpected! */
+		break;
+	}
+
+	return code_block_open;
+}
+
+struct _args {
+	mrb_bool verbose : 1;
+	int argc;
+	char** argv;
+};
+
+static void
+usage(const char *name)
+{
+	static const char *const usage_msg[] = {
+		"switches:",
+		"-v           print version number, then run in verbose mode",
+		"--verbose    run in verbose mode",
+		"--version    print the version",
+		"--copyright  print the copyright",
+		NULL
+	};
+	const char *const *p = usage_msg;
+
+	printf("Usage: %s [switches]\n", name);
+	while (*p)
+		printf("  %s\n", *p++);
+}
+
+static int
+parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
+{
+	static const struct _args args_zero = {0};
+
+	*args = args_zero;
+
+	for (argc--, argv++; argc > 0; argc--, argv++) {
+		char *item;
+		if (argv[0][0] != '-') break;
+
+		item = argv[0] + 1;
+		switch (*item++) {
+		case 'v':
+			if (!args->verbose) mrb_show_version(mrb);
+			args->verbose = TRUE;
+			break;
+		case '-':
+			if (strcmp((*argv) + 2, "version") == 0) {
+				mrb_show_version(mrb);
+				exit(EXIT_SUCCESS);
+			}
+			else if (strcmp((*argv) + 2, "verbose") == 0) {
+				args->verbose = TRUE;
+				break;
+			}
+			else if (strcmp((*argv) + 2, "copyright") == 0) {
+				mrb_show_copyright(mrb);
+				exit(EXIT_SUCCESS);
+			}
+		default:
+			return EXIT_FAILURE;
+		}
+	}
+	return EXIT_SUCCESS;
+}
+
+static void
+cleanup(mrb_state *mrb, struct _args *args)
+{
+	mrb_close(mrb);
+}
+
+/* Print a short remark for the user */
+static void
+print_hint(void)
+{
+	printf("mirb - Embeddable Interactive Ruby Shell\n\n");
+}
+
+#ifndef ENABLE_READLINE
+/* Print the command line prompt of the REPL */
+static void
+print_cmdline(int code_block_open)
+{
+	if (code_block_open) {
+		printf("* ");
+	}
+	else {
+		printf("> ");
+	}
+	fflush(stdout);
+}
+#endif
+
+void mrb_codedump_all(mrb_state*, struct RProc*);
+
+static int
+check_keyword(const char *buf, const char *word)
+{
+	const char *p = buf;
+	size_t len = strlen(word);
+
+	/* skip preceding spaces */
+	while (*p && isspace((unsigned char)*p)) {
+		p++;
+	}
+	/* check keyword */
+	if (strncmp(p, word, len) != 0) {
+		return 0;
+	}
+	p += len;
+	/* skip trailing spaces */
+	while (*p) {
+		if (!isspace((unsigned char)*p)) return 0;
+		p++;
+	}
+	return 1;
+}
+
+int
+mirb_main(int argc, char **argv)
+{
+	char ruby_code[1024] = {0};
+	char last_code_line[1024] = {0};
+#ifndef ENABLE_READLINE
+	int last_char;
+	int char_index;
+#else
+	char *history_path;
+#endif
+	mrbc_context *cxt;
+	struct mrb_parser_state *parser;
+	mrb_state *mrb;
+	mrb_value result;
+	struct _args args;
+	int n;
+	mrb_bool code_block_open = FALSE;
+	int ai;
+	unsigned int stack_keep = 0;
+
+	/* new interpreter instance */
+	mrb = mrb_open();
+	if (mrb == NULL) {
+		fputs("Invalid mrb interpreter, exiting mirb\n", stderr);
+		return EXIT_FAILURE;
+	}
+	mrb_define_global_const(mrb, "ARGV", mrb_ary_new_capa(mrb, 0));
+
+	n = parse_args(mrb, argc, argv, &args);
+	if (n == EXIT_FAILURE) {
+		cleanup(mrb, &args);
+		usage(argv[0]);
+		return n;
+	}
+
+#ifdef ENABLE_READLINE
+	history_path = get_history_path(mrb);
+	if (history_path == NULL) {
+		fputs("failed to get history path\n", stderr);
+		mrb_close(mrb);
+		return EXIT_FAILURE;
+	}
+
+	MIRB_USING_HISTORY();
+	MIRB_READ_HISTORY(history_path);
+#endif
+
+	print_hint();
+
+	cxt = mrbc_context_new(mrb);
+	cxt->capture_errors = TRUE;
+	cxt->lineno = 1;
+	mrbc_filename(mrb, cxt, "(mirb)");
+	if (args.verbose) cxt->dump_result = TRUE;
+
+	ai = mrb_gc_arena_save(mrb);
+
+	while (TRUE) {
+		char *utf8;
+
+#ifndef ENABLE_READLINE
+		print_cmdline(code_block_open);
+
+		char_index = 0;
+		while ((last_char = getchar()) != '\n') {
+			if (last_char == EOF) break;
+			if (char_index > sizeof(last_code_line) - 2) {
+				fputs("input string too long\n", stderr);
+				continue;
+			}
+			last_code_line[char_index++] = last_char;
+		}
+		if (last_char == EOF) {
+			fputs("\n", stdout);
+			break;
+		}
+
+		last_code_line[char_index++] = '\n';
+		last_code_line[char_index] = '\0';
+#else
+		char* line = MIRB_READLINE(code_block_open ? "* " : "> ");
+		if (line == NULL) {
+			printf("\n");
+			break;
+		}
+		if (strlen(line) > sizeof(last_code_line) - 2) {
+			fputs("input string too long\n", stderr);
+			continue;
+		}
+		strlcpy(last_code_line, line, sizeof(last_code_line));
+		strlcat(last_code_line, "\n", sizeof(last_code_line));
+		MIRB_ADD_HISTORY(line);
+		free(line);
+#endif
+
+		if (code_block_open) {
+			if (strlen(ruby_code) + strlen(last_code_line) > sizeof(ruby_code) - 1) {
+				fputs("concatenated input string too long\n", stderr);
+				continue;
+			}
+			strlcat(ruby_code, last_code_line, sizeof(ruby_code));
+		}
+		else {
+			if (check_keyword(last_code_line, "quit") || check_keyword(last_code_line, "exit")) {
+				break;
+			}
+			strlcpy(ruby_code, last_code_line, sizeof(ruby_code));
+		}
+
+		utf8 = mrb_utf8_from_locale(ruby_code, -1);
+		if (!utf8) abort();
+
+		/* parse code */
+		parser = mrb_parser_new(mrb);
+		if (parser == NULL) {
+			fputs("create parser state error\n", stderr);
+			break;
+		}
+		parser->s = utf8;
+		parser->send = utf8 + strlen(utf8);
+		parser->lineno = cxt->lineno;
+		mrb_parser_parse(parser, cxt);
+		code_block_open = is_code_block_open(parser);
+		mrb_utf8_free(utf8);
+
+		if (code_block_open) {
+		  /* no evaluation of code */
+		}
+		else {
+			if (0 < parser->nerr) {
+			  /* syntax error */
+				printf("line %d: %s\n", parser->error_buffer[0].lineno, parser->error_buffer[0].message);
+			}
+			else {
+			  /* generate bytecode */
+				struct RProc *proc = mrb_generate_code(mrb, parser);
+				if (proc == NULL) {
+					fputs("codegen error\n", stderr);
+					mrb_parser_free(parser);
+					break;
+				}
+
+				if (args.verbose) {
+					mrb_codedump_all(mrb, proc);
+				}
+				/* pass a proc for evaulation */
+				/* evaluate the bytecode */
+				result = mrb_context_run(mrb,
+					proc,
+					mrb_top_self(mrb),
+					stack_keep);
+				stack_keep = proc->body.irep->nlocals;
+				/* did an exception occur? */
+				if (mrb->exc) {
+					p(mrb, mrb_obj_value(mrb->exc), 0);
+					mrb->exc = 0;
+				}
+				else {
+				  /* no */
+					if (!mrb_respond_to(mrb, result, mrb_intern_lit(mrb, "inspect"))) {
+						result = mrb_any_to_s(mrb, result);
+					}
+					p(mrb, result, 1);
+				}
+			}
+			ruby_code[0] = '\0';
+			last_code_line[0] = '\0';
+			mrb_gc_arena_restore(mrb, ai);
+		}
+		mrb_parser_free(parser);
+		cxt->lineno++;
+	}
+
+#ifdef ENABLE_READLINE
+	MIRB_WRITE_HISTORY(history_path);
+	mrb_free(mrb, history_path);
+#endif
+
+	mrbc_context_free(mrb, cxt);
+	mrb_close(mrb);
+
+	return 0;
+}
Index: /EcnlProtoTool/trunk/prototool/src/mrbc.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/mrbc.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/mrbc.c	(revision 279)
@@ -0,0 +1,318 @@
+#include <stdlib.h>
+
+#include "mruby.h"
+#include "mruby/compile.h"
+#include "mruby/dump.h"
+#include "mruby/proc.h"
+
+#define RITEBIN_EXT ".mrb"
+#define C_EXT       ".c"
+
+struct mrbc_args
+{
+	int argc;
+	char **argv;
+	int idx;
+	const char *prog;
+	const char *outfile;
+	const char *initname;
+	mrb_bool check_syntax : 1;
+	mrb_bool verbose : 1;
+	unsigned int flags : 4;
+};
+
+static void
+usage(const char *name)
+{
+	static const char *const usage_msg[] = {
+		"switches:",
+		"-c           check syntax only",
+		"-o<outfile>  place the output into <outfile>",
+		"-v           print version number, then turn on verbose mode",
+		"-g           produce debugging information",
+		"-B<symbol>   binary <symbol> output in C language format",
+		"-e           generate little endian iseq data",
+		"-E           generate big endian iseq data",
+		"--verbose    run at verbose mode",
+		"--version    print the version",
+		"--copyright  print the copyright",
+		NULL
+	};
+	const char *const *p = usage_msg;
+
+	printf("Usage: %s [switches] programfile\n", name);
+	while (*p)
+		printf("  %s\n", *p++);
+}
+
+static char *
+get_outfilename(mrb_state *mrb, char *infile, const char *ext)
+{
+	size_t infilelen;
+	size_t extlen;
+	char *outfile;
+	char *p;
+
+	infilelen = strlen(infile);
+	extlen = strlen(ext);
+	outfile = (char*)mrb_malloc(mrb, infilelen + extlen + 1);
+	memcpy(outfile, infile, infilelen + 1);
+	if (*ext) {
+		if ((p = strrchr(outfile, '.')) == NULL)
+			p = outfile + infilelen;
+		memcpy(p, ext, extlen + 1);
+	}
+
+	return outfile;
+}
+
+static int
+parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args)
+{
+	static const struct mrbc_args args_zero = { 0 };
+	int i;
+
+	*args = args_zero;
+	args->argc = argc;
+	args->argv = argv;
+	args->prog = argv[0];
+
+	for (i = 1; i < argc; i++) {
+		if (argv[i][0] == '-') {
+			switch ((argv[i])[1]) {
+			case 'o':
+				if (args->outfile) {
+					fprintf(stderr, "%s: an output file is already specified. (%s)\n",
+						args->prog, args->outfile);
+					return -1;
+				}
+				if (argv[i][2] == '\0' && argv[i + 1]) {
+					i++;
+					args->outfile = get_outfilename(mrb, argv[i], "");
+				}
+				else {
+					args->outfile = get_outfilename(mrb, argv[i] + 2, "");
+				}
+				break;
+			case 'B':
+				if (argv[i][2] == '\0' && argv[i + 1]) {
+					i++;
+					args->initname = argv[i];
+				}
+				else {
+					args->initname = argv[i] + 2;
+				}
+				if (*args->initname == '\0') {
+					fprintf(stderr, "%s: function name is not specified.\n", args->prog);
+					return -1;
+				}
+				break;
+			case 'c':
+				args->check_syntax = TRUE;
+				break;
+			case 'v':
+				if (!args->verbose) mrb_show_version(mrb);
+				args->verbose = TRUE;
+				break;
+			case 'g':
+				args->flags |= DUMP_DEBUG_INFO;
+				break;
+			case 'E':
+				args->flags = DUMP_ENDIAN_BIG | (args->flags & ~DUMP_ENDIAN_MASK);
+				break;
+			case 'e':
+				args->flags = DUMP_ENDIAN_LIL | (args->flags & ~DUMP_ENDIAN_MASK);
+				break;
+			case 'h':
+				return -1;
+			case '-':
+				if (argv[i][1] == '\n') {
+					return i;
+				}
+				if (strcmp(argv[i] + 2, "version") == 0) {
+					mrb_show_version(mrb);
+					exit(EXIT_SUCCESS);
+				}
+				else if (strcmp(argv[i] + 2, "verbose") == 0) {
+					args->verbose = TRUE;
+					break;
+				}
+				else if (strcmp(argv[i] + 2, "copyright") == 0) {
+					mrb_show_copyright(mrb);
+					exit(EXIT_SUCCESS);
+				}
+				return -1;
+			default:
+				return i;
+			}
+		}
+		else {
+			break;
+		}
+	}
+	if (args->verbose && args->initname && (args->flags & DUMP_ENDIAN_MASK) == 0) {
+		fprintf(stderr, "%s: generating %s endian C file. specify -e/-E for cross compiling.\n",
+			args->prog, bigendian_p() ? "big" : "little");
+	}
+	return i;
+}
+
+static void
+cleanup(mrb_state *mrb, struct mrbc_args *args)
+{
+	mrb_free(mrb, (void*)args->outfile);
+	mrb_close(mrb);
+}
+
+static int
+partial_hook(struct mrb_parser_state *p)
+{
+	mrbc_context *c = p->cxt;
+	struct mrbc_args *args = (struct mrbc_args *)c->partial_data;
+	const char *fn;
+
+	if (p->f) fclose(p->f);
+	if (args->idx >= args->argc) {
+		p->f = NULL;
+		return -1;
+	}
+	fn = args->argv[args->idx++];
+	p->f = fopen(fn, "r");
+	if (p->f == NULL) {
+		fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, fn);
+		return -1;
+	}
+	mrb_parser_set_filename(p, fn);
+	return 0;
+}
+
+static mrb_value
+load_file(mrb_state *mrb, struct mrbc_args *args)
+{
+	mrbc_context *c;
+	mrb_value result;
+	char *input = args->argv[args->idx];
+	FILE *infile;
+	mrb_bool need_close = FALSE;
+
+	c = mrbc_context_new(mrb);
+	if (args->verbose)
+		c->dump_result = TRUE;
+	c->no_exec = TRUE;
+	if (input[0] == '-' && input[1] == '\0') {
+		infile = stdin;
+	}
+	else {
+		need_close = TRUE;
+		if ((infile = fopen(input, "r")) == NULL) {
+			fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, input);
+			return mrb_nil_value();
+		}
+	}
+	mrbc_filename(mrb, c, input);
+	args->idx++;
+	if (args->idx < args->argc) {
+		need_close = FALSE;
+		mrbc_partial_hook(mrb, c, partial_hook, (void*)args);
+	}
+
+	result = mrb_load_file_cxt(mrb, infile, c);
+	if (need_close) fclose(infile);
+	mrbc_context_free(mrb, c);
+	if (mrb_undef_p(result)) {
+		return mrb_nil_value();
+	}
+	return result;
+}
+
+static int
+dump_file(mrb_state *mrb, FILE *wfp, const char *outfile, struct RProc *proc, struct mrbc_args *args)
+{
+	int n = MRB_DUMP_OK;
+	mrb_irep *irep = proc->body.irep;
+
+	if (args->initname) {
+		n = mrb_dump_irep_cfunc(mrb, irep, args->flags, wfp, args->initname);
+		if (n == MRB_DUMP_INVALID_ARGUMENT) {
+			fprintf(stderr, "%s: invalid C language symbol name\n", args->initname);
+		}
+	}
+	else {
+		n = mrb_dump_irep_binary(mrb, irep, args->flags, wfp);
+	}
+	if (n != MRB_DUMP_OK) {
+		fprintf(stderr, "%s: error in mrb dump (%s) %d\n", args->prog, outfile, n);
+	}
+	return n;
+}
+
+int
+mrbc_main(int argc, char **argv)
+{
+	mrb_state *mrb = mrb_open_allocf(mrb_default_allocf, NULL, TRUE);
+	int n, result;
+	struct mrbc_args args;
+	FILE *wfp;
+	mrb_value load;
+
+	if (mrb == NULL) {
+		fputs("Invalid mrb_state, exiting mrbc\n", stderr);
+		return EXIT_FAILURE;
+	}
+
+	n = parse_args(mrb, argc, argv, &args);
+	if (n < 0) {
+		cleanup(mrb, &args);
+		usage(argv[0]);
+		return EXIT_FAILURE;
+	}
+	if (n == argc) {
+		fprintf(stderr, "%s: no program file given\n", args.prog);
+		return EXIT_FAILURE;
+	}
+	if (args.outfile == NULL && !args.check_syntax) {
+		if (n + 1 == argc) {
+			args.outfile = get_outfilename(mrb, argv[n], args.initname ? C_EXT : RITEBIN_EXT);
+		}
+		else {
+			fprintf(stderr, "%s: output file should be specified to compile multiple files\n", args.prog);
+			return EXIT_FAILURE;
+		}
+	}
+
+	args.idx = n;
+	load = load_file(mrb, &args);
+	if (mrb_nil_p(load)) {
+		cleanup(mrb, &args);
+		return EXIT_FAILURE;
+	}
+	if (args.check_syntax) {
+		printf("%s:%s:Syntax OK\n", args.prog, argv[n]);
+	}
+
+	if (args.check_syntax) {
+		cleanup(mrb, &args);
+		return EXIT_SUCCESS;
+	}
+
+	if (args.outfile) {
+		if (strcmp("-", args.outfile) == 0) {
+			wfp = stdout;
+		}
+		else if ((wfp = fopen(args.outfile, "wb")) == NULL) {
+			fprintf(stderr, "%s: cannot open output file:(%s)\n", args.prog, args.outfile);
+			return EXIT_FAILURE;
+		}
+	}
+	else {
+		fprintf(stderr, "Output file is required\n");
+		return EXIT_FAILURE;
+	}
+	result = dump_file(mrb, wfp, args.outfile, mrb_proc_ptr(load), &args);
+	fclose(wfp);
+	cleanup(mrb, &args);
+	if (result != MRB_DUMP_OK) {
+		return EXIT_FAILURE;
+	}
+	return EXIT_SUCCESS;
+}
Index: /EcnlProtoTool/trunk/prototool/src/mrdb.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/mrdb.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/mrdb.c	(revision 279)
@@ -0,0 +1,753 @@
+/*
+** mrdb.c - mruby debugger
+**
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "mruby.h"
+#include "mruby/dump.h"
+#include "mruby/debug.h"
+#include "mruby/class.h"
+#include "mruby/opcode.h"
+#include "mruby/variable.h"
+
+#include "mrdb.h"
+#include "apibreak.h"
+
+void mrdb_state_free(mrb_state *);
+
+static mrb_debug_context *_debug_context = NULL;
+static mrdb_state *_mrdb_state = NULL;
+
+struct _args
+{
+	FILE *rfp;
+	char* fname;
+	char* srcpath;
+	int argc;
+	char** argv;
+	mrb_bool mrbfile : 1;
+};
+
+typedef struct debug_command
+{
+	const char *cmd1;
+	const char *cmd2;
+	uint8_t len1;
+	uint8_t len2;
+	uint8_t div;
+	debug_command_id id;
+	debug_command_func func;
+} debug_command;
+
+static const debug_command debug_command_list[] = {
+  {"break",     NULL,           1, 0, 0, DBGCMD_BREAK,          dbgcmd_break},           /* b[reak] */
+  {"continue",  NULL,           1, 0, 0, DBGCMD_CONTINUE,       dbgcmd_continue},        /* c[ontinue] */
+  {"delete",    NULL,           1, 0, 1, DBGCMD_DELETE,         dbgcmd_delete},          /* d[elete] */
+  {"disable",   NULL,           3, 0, 1, DBGCMD_DISABLE,        dbgcmd_disable},         /* dis[able] */
+  {"enable",    NULL,           2, 0, 1, DBGCMD_ENABLE,         dbgcmd_enable},          /* en[able] */
+  {"eval",      NULL,           2, 0, 0, DBGCMD_EVAL,           dbgcmd_eval},            /* ev[al] */
+  {"help",      NULL,           1, 0, 1, DBGCMD_HELP,           dbgcmd_help},            /* h[elp] */
+  {"info",      "breakpoints",  1, 1, 1, DBGCMD_INFO_BREAK,     dbgcmd_info_break},      /* i[nfo] b[reakpoints] */
+  {"print",     NULL,           1, 0, 0, DBGCMD_PRINT,          dbgcmd_print},           /* p[rint] */
+  {"quit",      NULL,           1, 0, 0, DBGCMD_QUIT,           dbgcmd_quit},            /* q[uit] */
+  {"run",       NULL,           1, 0, 0, DBGCMD_RUN,            dbgcmd_run},             /* r[un] */
+  {"step",      NULL,           1, 0, 1, DBGCMD_STEP,           dbgcmd_step},            /* s[tep] */
+  {"next",      NULL,           1, 0, 1, DBGCMD_NEXT,           dbgcmd_next},            /* n[ext] */
+  {NULL}
+};
+
+
+static void
+usage(const char *name)
+{
+	static const char *const usage_msg[] = {
+		"switches:",
+		"-b           load and execute RiteBinary (mrb) file",
+		"-d           specify source directory",
+		"--version    print the version",
+		"--copyright  print the copyright",
+		NULL
+	};
+	const char *const *p = usage_msg;
+
+	printf("Usage: %s [switches] programfile\n", name);
+	while (*p) {
+		printf("  %s\n", *p++);
+	}
+}
+
+static int
+parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
+{
+	char **origargv = argv;
+	static const struct _args args_zero = { 0 };
+
+	*args = args_zero;
+
+	for (argc--, argv++; argc > 0; argc--, argv++) {
+		char *item;
+		if (argv[0][0] != '-') break;
+
+		item = argv[0] + 1;
+		switch (*item++) {
+		case 'b':
+			args->mrbfile = TRUE;
+			break;
+		case 'd':
+			if (item[0]) {
+				goto append_srcpath;
+			}
+			else if (argc > 1) {
+				argc--; argv++;
+				item = argv[0];
+			append_srcpath:
+				if (!args->srcpath) {
+					size_t buflen;
+					char *buf;
+
+					buflen = strlen(item) + 1;
+					buf = (char *)mrb_malloc(mrb, buflen);
+					memcpy(buf, item, buflen);
+					args->srcpath = buf;
+				}
+				else {
+					size_t srcpathlen;
+					size_t itemlen;
+
+					srcpathlen = strlen(args->srcpath);
+					itemlen = strlen(item);
+					args->srcpath =
+						(char *)mrb_realloc(mrb, args->srcpath, srcpathlen + itemlen + 2);
+					args->srcpath[srcpathlen] = '\n';
+					memcpy(args->srcpath + srcpathlen + 1, item, itemlen + 1);
+				}
+			}
+			else {
+				printf("%s: No path specified for -d\n", *origargv);
+				return EXIT_SUCCESS;
+			}
+			break;
+		case '-':
+			if (strcmp((*argv) + 2, "version") == 0) {
+				mrb_show_version(mrb);
+				exit(EXIT_SUCCESS);
+			}
+			else if (strcmp((*argv) + 2, "copyright") == 0) {
+				mrb_show_copyright(mrb);
+				exit(EXIT_SUCCESS);
+			}
+		default:
+			return EXIT_FAILURE;
+		}
+	}
+
+	if (args->rfp == NULL) {
+		if (*argv == NULL) {
+			printf("%s: Program file not specified.\n", *origargv);
+			return EXIT_FAILURE;
+		}
+		else {
+			args->rfp = fopen(argv[0], args->mrbfile ? "rb" : "r");
+			if (args->rfp == NULL) {
+				printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
+				return EXIT_FAILURE;
+			}
+			args->fname = argv[0];
+			argc--; argv++;
+		}
+	}
+	args->argv = (char **)mrb_realloc(mrb, args->argv, sizeof(char*) * (argc + 1));
+	memcpy(args->argv, argv, (argc + 1) * sizeof(char*));
+	args->argc = argc;
+
+	return EXIT_SUCCESS;
+}
+
+static void
+cleanup(mrb_state *mrb, struct _args *args)
+{
+	if (args->rfp)
+		fclose(args->rfp);
+	if (args->srcpath)
+		mrb_free(mrb, args->srcpath);
+	if (args->argv)
+		mrb_free(mrb, args->argv);
+	mrdb_state_free(mrb);
+	mrb_close(mrb);
+}
+
+static mrb_debug_context*
+mrb_debug_context_new(mrb_state *mrb)
+{
+	mrb_debug_context *dbg = (mrb_debug_context *)mrb_malloc(mrb, sizeof(mrb_debug_context));
+
+	memset(dbg, 0, sizeof(mrb_debug_context));
+
+	InterlockedExchange(&dbg->xm, DBG_INIT);
+	dbg->xphase = DBG_PHASE_BEFORE_RUN;
+	dbg->next_bpno = 1;
+
+	return dbg;
+}
+
+mrb_debug_context*
+mrb_debug_context_get(mrb_state *mrb)
+{
+	if (!_debug_context) {
+		_debug_context = mrb_debug_context_new(mrb);
+	}
+	return _debug_context;
+}
+
+void
+mrb_debug_context_set(mrb_debug_context *dbg)
+{
+	_debug_context = dbg;
+}
+
+void
+mrb_debug_context_free(mrb_state *mrb)
+{
+	if (_debug_context) {
+		mrb_debug_delete_break_all(mrb, _debug_context);
+		mrb_free(mrb, _debug_context);
+		_debug_context = NULL;
+	}
+}
+
+static mrdb_state*
+mrdb_state_new(mrb_state *mrb)
+{
+	mrdb_state *mrdb = (mrdb_state *)mrb_malloc(mrb, sizeof(mrdb_state));
+
+	memset(mrdb, 0, sizeof(mrdb_state));
+
+	mrdb->dbg = mrb_debug_context_get(mrb);
+	mrdb->command = (char *)mrb_malloc(mrb, MAX_COMMAND_LINE + 1);
+	mrdb->print_no = 1;
+
+	return mrdb;
+}
+
+mrdb_state*
+mrdb_state_get(mrb_state *mrb)
+{
+	if (!_mrdb_state) {
+		_mrdb_state = mrdb_state_new(mrb);
+	}
+	return _mrdb_state;
+}
+
+void
+mrdb_state_set(mrdb_state *mrdb)
+{
+	_mrdb_state = mrdb;
+}
+
+void
+mrdb_state_free(mrb_state *mrb)
+{
+	mrb_debug_context_free(mrb);
+	if (_mrdb_state) {
+		mrb_free(mrb, _mrdb_state->command);
+		mrb_free(mrb, _mrdb_state);
+		_mrdb_state = NULL;
+	}
+}
+
+static char*
+get_command(mrb_state *mrb, mrdb_state *mrdb)
+{
+	int i;
+	int c;
+
+	for (i = 0; i < MAX_COMMAND_LINE; i++) {
+		if ((c = getchar()) == EOF || c == '\n') break;
+		mrdb->command[i] = c;
+	}
+
+	if (i == 0 && feof(stdin)) {
+		clearerr(stdin);
+		strlcpy(mrdb->command, "quit", MAX_COMMAND_LINE + 1);
+		i += sizeof("quit") - 1;
+	}
+
+	if (i == MAX_COMMAND_LINE) {
+		for (; (c = getchar()) != EOF && c != '\n'; i++);
+	}
+
+	if (i > MAX_COMMAND_LINE) {
+		printf("command line too long.\n");
+		i = 0; /* discard command data */
+	}
+	mrdb->command[i] = '\0';
+
+	return mrdb->command;
+}
+
+static char*
+pick_out_word(mrb_state *mrb, char **pp)
+{
+	char *ps;
+
+	for (ps = *pp; ISBLANK(*ps); ps++);
+	if (*ps == '\0') {
+		return NULL;
+	}
+
+	if (*ps == '\"' || *ps == '\'') {
+		*pp = strchr(ps + 1, *ps);
+		if (*pp) (*pp)++;
+	}
+	else {
+		*pp = strpbrk(ps, " \t");
+	}
+
+	if (!*pp) {
+		*pp = ps + strlen(ps);
+	}
+
+	if (**pp != '\0') {
+		**pp = '\0';
+		(*pp)++;
+	}
+
+	return ps;
+}
+
+static debug_command*
+parse_command(mrb_state *mrb, mrdb_state *mrdb, char *buf)
+{
+	debug_command *cmd = NULL;
+	char *p = buf;
+	size_t wlen;
+
+	/* get word #1 */
+	mrdb->words[0] = pick_out_word(mrb, &p);
+	if (!mrdb->words[0]) {
+		return NULL;
+	}
+	mrdb->wcnt = 1;
+	/* set remain parameter */
+	for (; *p && ISBLANK(*p); p++);
+	if (*p) {
+		mrdb->words[mrdb->wcnt++] = p;
+	}
+
+	/* check word #1 */
+	for (cmd = (debug_command*)debug_command_list; cmd->cmd1; cmd++) {
+		wlen = strlen(mrdb->words[0]);
+		if (wlen >= cmd->len1 &&
+			strncmp(mrdb->words[0], cmd->cmd1, wlen) == 0) {
+			break;
+		}
+	}
+
+	if (cmd->cmd2) {
+		if (mrdb->wcnt > 1) {
+			/* get word #2 */
+			mrdb->words[1] = pick_out_word(mrb, &p);
+			if (mrdb->words[1]) {
+				/* update remain parameter */
+				for (; *p && ISBLANK(*p); p++);
+				if (*p) {
+					mrdb->words[mrdb->wcnt++] = p;
+				}
+			}
+		}
+
+		/* check word #1,#2 */
+		for (; cmd->cmd1; cmd++) {
+			wlen = strlen(mrdb->words[0]);
+			if (wlen < cmd->len1 ||
+				strncmp(mrdb->words[0], cmd->cmd1, wlen)) {
+				continue;
+			}
+
+			if (!cmd->cmd2) break;          /* word #1 only */
+
+			if (mrdb->wcnt == 1) continue;  /* word #2 not specified */
+
+			wlen = strlen(mrdb->words[1]);
+			if (wlen >= cmd->len2 &&
+				strncmp(mrdb->words[1], cmd->cmd2, wlen) == 0) {
+				break;  /* word #1 and #2 */
+			}
+		}
+	}
+
+	/* divide remain parameters */
+	if (cmd->cmd1 && cmd->div) {
+		p = mrdb->words[--mrdb->wcnt];
+		for (; mrdb->wcnt < MAX_COMMAND_WORD; mrdb->wcnt++) {
+			mrdb->words[mrdb->wcnt] = pick_out_word(mrb, &p);
+			if (!mrdb->words[mrdb->wcnt]) {
+				break;
+			}
+		}
+	}
+
+	return cmd->cmd1 ? cmd : NULL;
+}
+
+static void
+print_info_stopped_break(mrb_state *mrb, mrdb_state *mrdb)
+{
+	mrb_debug_breakpoint bp;
+	int32_t ret;
+	uint16_t lineno;
+	const char *file;
+	const char *method_name;
+	const char *class_name;
+
+	ret = mrb_debug_get_break(mrb, mrdb->dbg, mrdb->dbg->stopped_bpno, &bp);
+	if (ret == 0) {
+		switch (bp.type) {
+		case MRB_DEBUG_BPTYPE_LINE:
+			file = bp.point.linepoint.file;
+			lineno = bp.point.linepoint.lineno;
+			printf("Breakpoint %d, at %s:%d\n", bp.bpno, file, lineno);
+			break;
+		case MRB_DEBUG_BPTYPE_METHOD:
+			method_name = bp.point.methodpoint.method_name;
+			class_name = bp.point.methodpoint.class_name;
+			if (class_name == NULL) {
+				printf("Breakpoint %d, %s\n", bp.bpno, method_name);
+			}
+			else {
+				printf("Breakpoint %d, %s:%s\n", bp.bpno, class_name, method_name);
+			}
+			if (mrdb->dbg->isCfunc) {
+				printf("Stopped before calling the C function.\n");
+			}
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+static void
+print_info_stopped_step_next(mrb_state *mrb, mrdb_state *mrdb)
+{
+	const char* file = mrdb->dbg->prvfile;
+	uint16_t lineno = mrdb->dbg->prvline;
+	printf("%s:%d\n", file, lineno);
+}
+
+static void
+print_info_stopped(mrb_state *mrb, mrdb_state *mrdb)
+{
+	switch (mrdb->dbg->bm) {
+	case BRK_BREAK:
+		print_info_stopped_break(mrb, mrdb);
+		break;
+	case BRK_STEP:
+	case BRK_NEXT:
+		print_info_stopped_step_next(mrb, mrdb);
+		break;
+	default:
+		break;
+	}
+}
+
+static debug_command*
+get_and_parse_command(mrb_state *mrb, mrdb_state *mrdb)
+{
+	debug_command *cmd = NULL;
+	char *p;
+	int i;
+
+	while (!cmd) {
+		for (p = NULL; !p || *p == '\0'; ) {
+			printf("(%s:%d) ", mrdb->dbg->prvfile, mrdb->dbg->prvline);
+			fflush(stdout);
+			p = get_command(mrb, mrdb);
+		}
+
+		cmd = parse_command(mrb, mrdb, p);
+#ifdef _DBG_MRDB_PARSER_
+		for (i = 0; i < mrdb->wcnt; i++) {
+			printf("%d: %s\n", i, mrdb->words[i]);
+		}
+#endif
+		if (!cmd) {
+			printf("invalid command (");
+			for (i = 0; i < mrdb->wcnt; i++) {
+				if (i > 0) {
+					printf(" ");
+				}
+				printf("%s", mrdb->words[i]);
+			}
+			puts(")");
+		}
+	}
+	return cmd;
+}
+
+static int32_t
+check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *regs)
+{
+	struct RClass* c = NULL;
+	mrb_sym sym;
+	int32_t bpno;
+	mrb_bool isCfunc;
+
+	mrb_debug_context *dbg = mrb_debug_context_get(mrb);
+
+	isCfunc = FALSE;
+	bpno = dbg->method_bpno;
+	dbg->method_bpno = 0;
+
+	switch (GET_OPCODE(*pc)) {
+	case OP_SEND:
+	case OP_SENDB:
+		c = mrb_class(mrb, regs[GETARG_A(*pc)]);
+		sym = irep->syms[GETARG_B(*pc)];
+		break;
+	case OP_SUPER:
+		c = mrb->c->ci->target_class->super;
+		sym = mrb->c->ci->mid;
+		break;
+	default:
+		sym = 0;
+		break;
+	}
+	if (sym != 0) {
+		dbg->method_bpno = mrb_debug_check_breakpoint_method(mrb, dbg, c, sym, &isCfunc);
+		if (isCfunc) {
+			bpno = dbg->method_bpno;
+			dbg->method_bpno = 0;
+		}
+	}
+	dbg->isCfunc = isCfunc;
+	return bpno;
+}
+
+static void
+mrb_code_fetch_hook(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *regs)
+{
+	const char *file;
+	int32_t line;
+	int32_t bpno;
+
+	mrb_debug_context *dbg = mrb_debug_context_get(mrb);
+
+	mrb_assert(dbg);
+
+	dbg->irep = irep;
+	dbg->pc = pc;
+	dbg->regs = regs;
+
+	if (dbg->xphase == DBG_PHASE_RESTART) {
+		dbg->root_irep = irep;
+		dbg->prvfile = NULL;
+		dbg->prvline = 0;
+		dbg->prvci = NULL;
+		InterlockedExchange(&dbg->xm, DBG_RUN);
+		dbg->xphase = DBG_PHASE_RUNNING;
+	}
+
+	file = mrb_debug_get_filename(irep, (uint32_t)(pc - irep->iseq));
+	line = mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq));
+
+	switch (dbg->xm) {
+	case DBG_STEP:
+		if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
+			return;
+		}
+		dbg->method_bpno = 0;
+		dbg->bm = BRK_STEP;
+		break;
+
+	case DBG_NEXT:
+		if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
+			return;
+		}
+		if ((intptr_t)(dbg->prvci) < (intptr_t)(mrb->c->ci)) {
+			return;
+		}
+		dbg->prvci = NULL;
+		dbg->method_bpno = 0;
+		dbg->bm = BRK_NEXT;
+		break;
+
+	case DBG_RUN:
+		bpno = check_method_breakpoint(mrb, irep, pc, regs);
+		if (bpno > 0) {
+			dbg->stopped_bpno = bpno;
+			dbg->bm = BRK_BREAK;
+			break;
+		}
+		if (dbg->prvfile != file || dbg->prvline != line) {
+			bpno = mrb_debug_check_breakpoint_line(mrb, dbg, file, line);
+			if (bpno > 0) {
+				dbg->stopped_bpno = bpno;
+				dbg->bm = BRK_BREAK;
+				break;
+			}
+		}
+		dbg->prvfile = file;
+		dbg->prvline = line;
+		return;
+	case DBG_INIT:
+		dbg->root_irep = irep;
+		dbg->bm = BRK_INIT;
+		if (!file || line < 0) {
+			puts("Cannot get debugging information.");
+		}
+		break;
+
+	default:
+		return;
+	}
+
+	dbg->prvfile = file;
+	dbg->prvline = line;
+
+	if (dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {
+		return;
+	}
+	dbg->break_hook(mrb, dbg);
+
+	dbg->xphase = DBG_PHASE_RUNNING;
+}
+
+static mrdb_exemode
+mrb_debug_break_hook(mrb_state *mrb, mrb_debug_context *dbg)
+{
+	debug_command *cmd;
+	dbgcmd_state st = DBGST_CONTINUE;
+	mrdb_state *mrdb = mrdb_state_get(mrb);
+
+	print_info_stopped(mrb, mrdb);
+
+	while (1) {
+		cmd = get_and_parse_command(mrb, mrdb);
+		mrb_assert(cmd);
+
+		st = cmd->func(mrb, mrdb);
+
+		if ((st == DBGST_CONTINUE) || (st == DBGST_RESTART)) break;
+	}
+	return dbg->xm;
+}
+
+int
+mrdb_break(void)
+{
+	mrdb_state *mrdb = _mrdb_state;
+	if (mrdb == NULL)
+		return 0;
+	return InterlockedCompareExchange(&mrdb->dbg->xm, DBG_STEP, DBG_RUN) == DBG_RUN;
+}
+
+int
+mrdb_main(int argc, char **argv)
+{
+	mrb_state *mrb = mrb_open();
+	int n = -1;
+	struct _args args;
+	mrb_value v;
+	mrdb_state *mrdb;
+	mrdb_state *mrdb_backup;
+	mrb_debug_context* dbg_backup;
+	debug_command *cmd;
+
+l_restart:
+
+	if (mrb == NULL) {
+		fputs("Invalid mrb_state, exiting mruby\n", stderr);
+		return EXIT_FAILURE;
+	}
+
+	/* parse command parameters */
+	n = parse_args(mrb, argc, argv, &args);
+	if (n == EXIT_FAILURE || args.rfp == NULL) {
+		cleanup(mrb, &args);
+		usage(argv[0]);
+		return n;
+	}
+
+	/* initialize debugger information */
+	mrdb = mrdb_state_get(mrb);
+	mrb_assert(mrdb && mrdb->dbg);
+	mrdb->srcpath = args.srcpath;
+
+	if (mrdb->dbg->xm == DBG_QUIT) {
+		mrdb->dbg->xphase = DBG_PHASE_RESTART;
+	}
+	else {
+		mrdb->dbg->xphase = DBG_PHASE_BEFORE_RUN;
+	}
+	InterlockedExchange(&mrdb->dbg->xm, DBG_INIT);
+	mrdb->dbg->ccnt = 1;
+
+	/* setup hook functions */
+	mrb->code_fetch_hook = mrb_code_fetch_hook;
+	mrdb->dbg->break_hook = mrb_debug_break_hook;
+
+	if (args.mrbfile) { /* .mrb */
+		v = mrb_load_irep_file(mrb, args.rfp);
+	}
+	else {              /* .rb */
+		mrbc_context *cc = mrbc_context_new(mrb);
+		mrbc_filename(mrb, cc, args.fname);
+		v = mrb_load_file_cxt(mrb, args.rfp, cc);
+		mrbc_context_free(mrb, cc);
+	}
+	if (mrdb->dbg->xm == DBG_QUIT && !mrb_undef_p(v) && mrb->exc) {
+		const char *classname = mrb_obj_classname(mrb, mrb_obj_value(mrb->exc));
+		if (!strcmp(classname, "DebuggerExit")) {
+			cleanup(mrb, &args);
+			return 0;
+		}
+		if (!strcmp(classname, "DebuggerRestart")) {
+			mrdb_backup = mrdb_state_get(mrb);
+			dbg_backup = mrb_debug_context_get(mrb);
+
+			mrdb_state_set(NULL);
+			mrb_debug_context_set(NULL);
+
+			cleanup(mrb, &args);
+			mrb = mrb_open();
+
+			mrdb_state_set(mrdb_backup);
+			mrb_debug_context_set(dbg_backup);
+
+			goto l_restart;
+		}
+	}
+	puts("mruby application exited.");
+	mrdb->dbg->xphase = DBG_PHASE_AFTER_RUN;
+	if (!mrb_undef_p(v)) {
+		if (mrb->exc) {
+			mrb_print_error(mrb);
+		}
+		else {
+			printf(" => ");
+			mrb_p(mrb, v);
+		}
+	}
+
+	mrdb->dbg->prvfile = "-";
+	mrdb->dbg->prvline = 0;
+
+	while (1) {
+		cmd = get_and_parse_command(mrb, mrdb);
+		mrb_assert(cmd);
+
+		if (cmd->id == DBGCMD_QUIT) {
+			break;
+		}
+
+		if (cmd->func(mrb, mrdb) == DBGST_RESTART) goto l_restart;
+	}
+
+	cleanup(mrb, &args);
+
+	return 0;
+}
Index: /EcnlProtoTool/trunk/prototool/src/mrdb.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/mrdb.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/mrdb.h	(revision 279)
@@ -0,0 +1,173 @@
+/*
+** mrdb.h - mruby debugger
+**
+*/
+
+#ifndef MRDB_H
+#define MRDB_H
+
+#include "mruby.h"
+
+#include "mrdbconf.h"
+
+#define MAX_COMMAND_WORD (16)
+
+typedef enum debug_command_id {
+  DBGCMD_RUN,
+  DBGCMD_CONTINUE,
+  DBGCMD_NEXT,
+  DBGCMD_STEP,
+  DBGCMD_BREAK,
+  DBGCMD_INFO_BREAK,
+  DBGCMD_WATCH,
+  DBGCMD_INFO_WATCH,
+  DBGCMD_ENABLE,
+  DBGCMD_DISABLE,
+  DBGCMD_DELETE,
+  DBGCMD_PRINT,
+  DBGCMD_DISPLAY,
+  DBGCMD_INFO_DISPLAY,
+  DBGCMD_DELETE_DISPLAY,
+  DBGCMD_EVAL,
+  DBGCMD_BACKTRACE,
+  DBGCMD_LIST,
+  DBGCMD_HELP,
+  DBGCMD_QUIT,
+  DBGCMD_UNKNOWN
+} debug_command_id;
+
+typedef enum dbgcmd_state {
+  DBGST_CONTINUE,
+  DBGST_PROMPT,
+  DBGST_COMMAND_ERROR,
+  DBGST_MAX,
+  DBGST_RESTART
+} dbgcmd_state;
+
+typedef enum mrdb_exemode {
+  DBG_INIT,
+  DBG_RUN,
+  DBG_STEP,
+  DBG_NEXT,
+  DBG_QUIT,
+} mrdb_exemode;
+
+#ifdef _MSC_VER
+# define __func__ __FUNCTION__
+extern long __stdcall InterlockedExchange(long *dst, long src);
+extern long __stdcall InterlockedCompareExchange(long *dst, long src, long cmp);
+#else
+#define InterlockedExchange(dst, src) do { *(dst) = src; } while(0)
+__inline__ static enum mrdb_exemode InterlockedCompareExchange(enum mrdb_exemode *dst, enum mrdb_exemode src, enum mrdb_exemode cmp) { long prev = *(dst); if (*(dst) == cmp) *(dst) = src; return prev; }
+#endif
+
+typedef enum mrdb_exephase {
+  DBG_PHASE_BEFORE_RUN,
+  DBG_PHASE_RUNNING,
+  DBG_PHASE_AFTER_RUN,
+  DBG_PHASE_RESTART,
+} mrdb_exephase;
+
+typedef enum mrdb_brkmode {
+  BRK_INIT,
+  BRK_BREAK,
+  BRK_STEP,
+  BRK_NEXT,
+  BRK_QUIT,
+} mrdb_brkmode;
+
+typedef enum {
+  MRB_DEBUG_BPTYPE_NONE,
+  MRB_DEBUG_BPTYPE_LINE,
+  MRB_DEBUG_BPTYPE_METHOD,
+} mrb_debug_bptype;
+
+struct mrb_irep;
+struct mrbc_context;
+struct mrb_debug_context;
+
+typedef struct mrb_debug_linepoint {
+  const char *file;
+  uint16_t lineno;
+} mrb_debug_linepoint;
+
+typedef struct mrb_debug_methodpoint {
+  const char *class_name;
+  const char *method_name;
+} mrb_debug_methodpoint;
+
+typedef struct mrb_debug_breakpoint {
+  uint32_t bpno;
+  uint8_t enable;
+  mrb_debug_bptype type;
+  union point {
+    mrb_debug_linepoint linepoint;
+    mrb_debug_methodpoint methodpoint;
+  } point;
+} mrb_debug_breakpoint;
+
+typedef struct mrb_debug_context {
+  struct mrb_irep *root_irep;
+  struct mrb_irep *irep;
+  mrb_code *pc;
+  mrb_value *regs;
+
+  const char *prvfile;
+  int32_t prvline;
+  mrb_callinfo *prvci;
+
+#ifdef _MSC_VER
+  long xm;
+#else
+  mrdb_exemode xm;
+#endif
+  mrdb_exephase xphase;
+  mrdb_brkmode bm;
+  int16_t bmi;
+
+  uint16_t ccnt;
+  uint16_t scnt;
+
+  mrb_debug_breakpoint bp[MAX_BREAKPOINT];
+  uint32_t bpnum;
+  int32_t next_bpno;
+  int32_t method_bpno;
+  int32_t stopped_bpno;
+  mrb_bool isCfunc;
+
+  mrdb_exemode (*break_hook)(mrb_state *mrb, struct mrb_debug_context *dbg);
+
+} mrb_debug_context;
+
+typedef struct mrdb_state {
+  char *command;
+  uint8_t wcnt;
+  uint8_t pi;
+  char *words[MAX_COMMAND_WORD];
+  const char *srcpath;
+  uint32_t print_no;
+
+  mrb_debug_context *dbg;
+} mrdb_state;
+
+typedef dbgcmd_state (*debug_command_func)(mrb_state*, mrdb_state*);
+
+/* cmdrun.c */
+dbgcmd_state dbgcmd_run(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_continue(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_step(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_next(mrb_state*, mrdb_state*);
+/* cmdbreak.c */
+dbgcmd_state dbgcmd_break(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_info_break(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_delete(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_enable(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_disable(mrb_state*, mrdb_state*);
+/* cmdprint.c */
+dbgcmd_state dbgcmd_print(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_eval(mrb_state*, mrdb_state*);
+/* cmdmisc.c */
+dbgcmd_state dbgcmd_help(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_quit(mrb_state*, mrdb_state*);
+
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/mrdbconf.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/mrdbconf.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/mrdbconf.h	(revision 279)
@@ -0,0 +1,16 @@
+/*
+** mrdbconf.h - mruby debugger configuration
+**
+*/
+
+#ifndef MRDBCONF_H
+#define MRDBCONF_H
+
+/* configuration options: */
+/* maximum size for command buffer */
+#define MAX_COMMAND_LINE 1024
+
+/* maximum number of setable breakpoint */
+#define MAX_BREAKPOINT 5
+
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/mrdberror.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/mrdberror.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/mrdberror.h	(revision 279)
@@ -0,0 +1,20 @@
+/*
+** mrdberror.h - mruby debugger error code
+**
+*/
+
+#ifndef MRDBERROR_H
+#define MRDBERROR_H
+
+#define MRB_DEBUG_OK                   (0)
+#define MRB_DEBUG_NOBUF                (-1)
+#define MRB_DEBUG_INVALID_ARGUMENT     (-2)
+
+#define MRB_DEBUG_BREAK_INVALID_LINENO (-11)
+#define MRB_DEBUG_BREAK_INVALID_FILE   (-12)
+#define MRB_DEBUG_BREAK_INVALID_NO     (-13)
+#define MRB_DEBUG_BREAK_NUM_OVER       (-14)
+#define MRB_DEBUG_BREAK_NO_OVER        (-15)
+
+#endif
+
Index: /EcnlProtoTool/trunk/prototool/src/mruby.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/mruby.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/mruby.c	(revision 279)
@@ -0,0 +1,245 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "mruby.h"
+#include "mruby/array.h"
+#include "mruby/compile.h"
+#include "mruby/dump.h"
+#include "mruby/variable.h"
+
+#ifdef MRB_DISABLE_STDIO
+static void
+p(mrb_state *mrb, mrb_value obj)
+{
+	mrb_value val = mrb_inspect(mrb, obj);
+
+	fwrite(RSTRING_PTR(val), RSTRING_LEN(val), 1, stdout);
+	putc('\n', stdout);
+}
+#else
+#define p(mrb,obj) mrb_p(mrb,obj)
+#endif
+
+struct _args
+{
+	FILE *rfp;
+	char* cmdline;
+	mrb_bool fname : 1;
+	mrb_bool mrbfile : 1;
+	mrb_bool check_syntax : 1;
+	mrb_bool verbose : 1;
+	int argc;
+	char** argv;
+};
+
+static void
+usage(const char *name)
+{
+	static const char *const usage_msg[] = {
+		"switches:",
+		"-b           load and execute RiteBinary (mrb) file",
+		"-c           check syntax only",
+		"-e 'command' one line of script",
+		"-v           print version number, then run in verbose mode",
+		"--verbose    run in verbose mode",
+		"--version    print the version",
+		"--copyright  print the copyright",
+		NULL
+	};
+	const char *const *p = usage_msg;
+
+	printf("Usage: %s [switches] programfile\n", name);
+	while (*p)
+		printf("  %s\n", *p++);
+}
+
+static int
+parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
+{
+	char **origargv = argv;
+	static const struct _args args_zero = { 0 };
+
+	*args = args_zero;
+
+	for (argc--, argv++; argc > 0; argc--, argv++) {
+		char *item;
+		if (argv[0][0] != '-') break;
+
+		if (strlen(*argv) <= 1) {
+			argc--; argv++;
+			args->rfp = stdin;
+			break;
+		}
+
+		item = argv[0] + 1;
+		switch (*item++) {
+		case 'b':
+			args->mrbfile = TRUE;
+			break;
+		case 'c':
+			args->check_syntax = TRUE;
+			break;
+		case 'e':
+			if (item[0]) {
+				goto append_cmdline;
+			}
+			else if (argc > 1) {
+				argc--; argv++;
+				item = argv[0];
+			append_cmdline:
+				if (!args->cmdline) {
+					size_t buflen;
+					char *buf;
+
+					buflen = strlen(item) + 1;
+					buf = (char *)mrb_malloc(mrb, buflen);
+					memcpy(buf, item, buflen);
+					args->cmdline = buf;
+				}
+				else {
+					size_t cmdlinelen;
+					size_t itemlen;
+
+					cmdlinelen = strlen(args->cmdline);
+					itemlen = strlen(item);
+					args->cmdline =
+						(char *)mrb_realloc(mrb, args->cmdline, cmdlinelen + itemlen + 2);
+					args->cmdline[cmdlinelen] = '\n';
+					memcpy(args->cmdline + cmdlinelen + 1, item, itemlen + 1);
+				}
+			}
+			else {
+				printf("%s: No code specified for -e\n", *origargv);
+				return EXIT_SUCCESS;
+			}
+			break;
+		case 'v':
+			if (!args->verbose) mrb_show_version(mrb);
+			args->verbose = TRUE;
+			break;
+		case '-':
+			if (strcmp((*argv) + 2, "version") == 0) {
+				mrb_show_version(mrb);
+				exit(EXIT_SUCCESS);
+			}
+			else if (strcmp((*argv) + 2, "verbose") == 0) {
+				args->verbose = TRUE;
+				break;
+			}
+			else if (strcmp((*argv) + 2, "copyright") == 0) {
+				mrb_show_copyright(mrb);
+				exit(EXIT_SUCCESS);
+			}
+		default:
+			return EXIT_FAILURE;
+		}
+	}
+
+	if (args->rfp == NULL && args->cmdline == NULL) {
+		if (*argv == NULL) args->rfp = stdin;
+		else {
+			args->rfp = fopen(argv[0], args->mrbfile ? "rb" : "r");
+			if (args->rfp == NULL) {
+				printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
+				return EXIT_FAILURE;
+			}
+			args->fname = TRUE;
+			args->cmdline = argv[0];
+			argc--; argv++;
+		}
+	}
+	args->argv = (char **)mrb_realloc(mrb, args->argv, sizeof(char*) * (argc + 1));
+	memcpy(args->argv, argv, (argc + 1) * sizeof(char*));
+	args->argc = argc;
+
+	return EXIT_SUCCESS;
+}
+
+static void
+cleanup(mrb_state *mrb, struct _args *args)
+{
+	if (args->rfp && args->rfp != stdin)
+		fclose(args->rfp);
+	if (!args->fname)
+		mrb_free(mrb, args->cmdline);
+	mrb_free(mrb, args->argv);
+	mrb_close(mrb);
+}
+
+int
+mruby_main(int argc, char **argv)
+{
+	mrb_state *mrb = mrb_open();
+	int n = -1;
+	int i;
+	struct _args args;
+	mrb_value ARGV;
+	mrbc_context *c;
+	mrb_value v;
+	mrb_sym zero_sym;
+
+	if (mrb == NULL) {
+		fputs("Invalid mrb_state, exiting mruby\n", stderr);
+		return EXIT_FAILURE;
+	}
+
+	n = parse_args(mrb, argc, argv, &args);
+	if (n == EXIT_FAILURE || (args.cmdline == NULL && args.rfp == NULL)) {
+		cleanup(mrb, &args);
+		usage(argv[0]);
+		return n;
+	}
+	else {
+		int ai = mrb_gc_arena_save(mrb);
+		ARGV = mrb_ary_new_capa(mrb, args.argc);
+		for (i = 0; i < args.argc; i++) {
+			mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, args.argv[i]));
+		}
+		mrb_define_global_const(mrb, "ARGV", ARGV);
+
+		c = mrbc_context_new(mrb);
+		if (args.verbose)
+			c->dump_result = TRUE;
+		if (args.check_syntax)
+			c->no_exec = TRUE;
+
+		/* Set $0 */
+		zero_sym = mrb_intern_lit(mrb, "$0");
+		if (args.rfp) {
+			const char *cmdline;
+			cmdline = args.cmdline ? args.cmdline : "-";
+			mrbc_filename(mrb, c, cmdline);
+			mrb_gv_set(mrb, zero_sym, mrb_str_new_cstr(mrb, cmdline));
+		}
+		else {
+			mrbc_filename(mrb, c, "-e");
+			mrb_gv_set(mrb, zero_sym, mrb_str_new_lit(mrb, "-e"));
+		}
+
+		/* Load program */
+		if (args.mrbfile) {
+			v = mrb_load_irep_file_cxt(mrb, args.rfp, c);
+		}
+		else if (args.rfp) {
+			v = mrb_load_file_cxt(mrb, args.rfp, c);
+		}
+		else {
+			v = mrb_load_string_cxt(mrb, args.cmdline, c);
+		}
+
+		mrb_gc_arena_restore(mrb, ai);
+		mrbc_context_free(mrb, c);
+		if (mrb->exc) {
+			if (!mrb_undef_p(v)) {
+				mrb_print_error(mrb);
+			}
+			n = -1;
+		}
+		else if (args.check_syntax) {
+			printf("Syntax OK\n");
+		}
+	}
+	cleanup(mrb, &args);
+
+	return n == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
Index: /EcnlProtoTool/trunk/prototool/src/musl/freeaddrinfo.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/freeaddrinfo.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/freeaddrinfo.c	(revision 279)
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+#include <netdb.h>
+
+void freeaddrinfo(struct addrinfo *p)
+{
+	free(p);
+}
Index: /EcnlProtoTool/trunk/prototool/src/musl/gai_strerror.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/gai_strerror.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/gai_strerror.c	(revision 279)
@@ -0,0 +1,25 @@
+#include <netdb.h>
+//#include "locale_impl.h"
+
+static const char msgs[] =
+	"Invalid flags\0"
+	"Name does not resolve\0"
+	"Try again\0"
+	"Non-recoverable error\0"
+	"Unknown error\0"
+	"Unrecognized address family or invalid length\0"
+	"Unrecognized socket type\0"
+	"Unrecognized service\0"
+	"Unknown error\0"
+	"Out of memory\0"
+	"System error\0"
+	"Overflow\0"
+	"\0Unknown error";
+
+const char *gai_strerror(int ecode)
+{
+	const char *s;
+	for (s=msgs, ecode++; ecode && *s; ecode++, s++) for (; *s; s++);
+	if (!*s) s++;
+	return s;//LCTRANS_CUR(s);
+}
Index: /EcnlProtoTool/trunk/prototool/src/musl/getaddrinfo.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/getaddrinfo.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/getaddrinfo.c	(revision 279)
@@ -0,0 +1,92 @@
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include "lookup.h"
+
+int getaddrinfo(const char *restrict host, const char *restrict serv, const struct addrinfo *restrict hint, struct addrinfo **restrict res)
+{
+	struct service ports[MAXSERVS];
+	struct address addrs[MAXADDRS];
+	char canon[256], *outcanon;
+	int nservs, naddrs, nais, canon_len, i, j, k;
+	int family = AF_UNSPEC, flags = 0, proto = 0, socktype = 0;
+	struct aibuf {
+		struct addrinfo ai;
+		union sa {
+			struct sockaddr_in sin;
+			struct sockaddr_in6 sin6;
+		} sa;
+	} *out;
+
+	if (!host && !serv) return EAI_NONAME;
+
+	if (hint) {
+		family = hint->ai_family;
+		flags = hint->ai_flags;
+		proto = hint->ai_protocol;
+		socktype = hint->ai_socktype;
+
+		const int mask = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST |
+			AI_V4MAPPED | AI_ALL | AI_ADDRCONFIG | AI_NUMERICSERV;
+		if ((flags & mask) != flags)
+			return EAI_BADFLAGS;
+
+		switch (family) {
+		case AF_INET:
+		case AF_INET6:
+		case AF_UNSPEC:
+			break;
+		default:
+			return EAI_FAMILY;
+		}
+	}
+
+	nservs = __lookup_serv(ports, serv, proto, socktype, flags);
+	if (nservs < 0) return nservs;
+
+	naddrs = __lookup_name(addrs, canon, host, family, flags);
+	if (naddrs < 0) return naddrs;
+
+	nais = nservs * naddrs;
+	canon_len = strlen(canon);
+	out = calloc(1, nais * sizeof(*out) + canon_len + 1);
+	if (!out) return EAI_MEMORY;
+
+	if (canon_len) {
+		outcanon = (void *)&out[nais];
+		memcpy(outcanon, canon, canon_len+1);
+	} else {
+		outcanon = 0;
+	}
+
+	for (k=i=0; i<naddrs; i++) for (j=0; j<nservs; j++, k++) {
+		out[k].ai = (struct addrinfo){
+			.ai_family = addrs[i].family,
+			.ai_socktype = ports[j].socktype,
+			.ai_protocol = ports[j].proto,
+			.ai_addrlen = addrs[i].family == AF_INET
+				? sizeof(struct sockaddr_in)
+				: sizeof(struct sockaddr_in6),
+			.ai_addr = (void *)&out[k].sa,
+			.ai_canonname = outcanon,
+			.ai_next = &out[k+1].ai };
+		switch (addrs[i].family) {
+		case AF_INET:
+			out[k].sa.sin.sin_family = AF_INET;
+			out[k].sa.sin.sin_port = htons(ports[j].port);
+			memcpy(&out[k].sa.sin.sin_addr, &addrs[i].addr, 4);
+			break;
+		case AF_INET6:
+			out[k].sa.sin6.sin6_family = AF_INET6;
+			out[k].sa.sin6.sin6_port = htons(ports[j].port);
+			out[k].sa.sin6.sin6_scope_id = addrs[i].scopeid;
+			memcpy(&out[k].sa.sin6.sin6_addr, &addrs[i].addr, 16);
+			break;			
+		}
+	}
+	out[nais-1].ai.ai_next = 0;
+	*res = &out->ai;
+	return 0;
+}
Index: /EcnlProtoTool/trunk/prototool/src/musl/inet_aton.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/inet_aton.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/inet_aton.c	(revision 279)
@@ -0,0 +1,41 @@
+#include <ctype.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+//#include "libc.h"
+
+int __inet_aton(const char *s0, struct in_addr *dest)
+{
+	const char *s = s0;
+	unsigned char *d = (void *)dest;
+	unsigned long a[4] = { 0 };
+	char *z;
+	int i;
+
+	for (i=0; i<4; i++) {
+		a[i] = strtoul(s, &z, 0);
+		if (z==s || (*z && *z != '.') || !isdigit(*s))
+			return 0;
+		if (!*z) break;
+		s=z+1;
+	}
+	if (i==4) return 0;
+	switch (i) {
+	case 0:
+		a[1] = a[0] & 0xffffff;
+		a[0] >>= 24;
+	case 1:
+		a[2] = a[1] & 0xffff;
+		a[1] >>= 16;
+	case 2:
+		a[3] = a[2] & 0xff;
+		a[2] >>= 8;
+	}
+	for (i=0; i<4; i++) {
+		if (a[i] > 255) return 0;
+		d[i] = a[i];
+	}
+	return 1;
+}
+
+//weak_alias(__inet_aton, inet_aton);
Index: /EcnlProtoTool/trunk/prototool/src/musl/lookup.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/lookup.h	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/lookup.h	(revision 279)
@@ -0,0 +1,39 @@
+#ifndef LOOKUP_H
+#define LOOKUP_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+struct address {
+	int family;
+	unsigned scopeid;
+	uint8_t addr[16];
+	int sortkey;
+};
+
+struct service {
+	uint16_t port;
+	unsigned char proto, socktype;
+};
+
+#define MAXNS 3
+
+struct resolvconf {
+	struct address ns[MAXNS];
+	unsigned nns, attempts, ndots;
+	unsigned timeout;
+};
+
+/* The limit of 48 results is a non-sharp bound on the number of addresses
+ * that can fit in one 512-byte DNS packet full of v4 results and a second
+ * packet full of v6 results. Due to headers, the actual limit is lower. */
+#define MAXADDRS 48
+#define MAXSERVS 2
+
+int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags);
+int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags);
+int __lookup_ipliteral(struct address buf[static 1], const char *name, int family);
+
+int __get_resolv_conf(struct resolvconf *, char *, size_t);
+
+#endif
Index: /EcnlProtoTool/trunk/prototool/src/musl/lookup_ipliteral.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/lookup_ipliteral.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/lookup_ipliteral.c	(revision 279)
@@ -0,0 +1,57 @@
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include "lookup.h"
+
+int __inet_aton(const char *, struct in_addr *);
+
+int __lookup_ipliteral(struct address buf[static 1], const char *name, int family)
+{
+	struct in_addr a4;
+	struct in6_addr a6;
+	if (__inet_aton(name, &a4) > 0) {
+		if (family == AF_INET6) /* wrong family */
+			return EAI_NONAME;
+		memcpy(&buf[0].addr, &a4, sizeof a4);
+		buf[0].family = AF_INET;
+		buf[0].scopeid = 0;
+		return 1;
+	}
+
+	char tmp[64];
+	char *p = strchr(name, '%'), *z;
+	unsigned long long scopeid = 0;
+	if (p && p-name < 64) {
+		memcpy(tmp, name, p-name);
+		tmp[p-name] = 0;
+		name = tmp;
+	}
+
+	if (inet_pton(AF_INET6, name, &a6) <= 0)
+		return 0;
+	if (family == AF_INET) /* wrong family */
+		return EAI_NONAME;
+
+	memcpy(&buf[0].addr, &a6, sizeof a6);
+	buf[0].family = AF_INET6;
+	if (p) {
+		if (isdigit(*++p)) scopeid = strtoull(p, &z, 10);
+		else z = p-1;
+		if (*z) {
+			if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
+			    !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
+				return EAI_NONAME;
+			scopeid = if_nametoindex(p);
+			if (!scopeid) return EAI_NONAME;
+		}
+		if (scopeid > UINT_MAX) return EAI_NONAME;
+	}
+	buf[0].scopeid = scopeid;
+	return 1;
+}
Index: /EcnlProtoTool/trunk/prototool/src/musl/lookup_name.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/lookup_name.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/lookup_name.c	(revision 279)
@@ -0,0 +1,399 @@
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <errno.h>
+#include "lookup.h"
+#include <stdio.h>
+//#include "stdio_impl.h"
+//#include "syscall.h"
+
+static int is_valid_hostname(const char *host)
+{
+	const unsigned char *s;
+	if (strnlen(host, 255)-1 >= 254 || mbstowcs(0, host, 0) == -1) return 0;
+	for (s=(void *)host; *s>=0x80 || *s=='.' || *s=='-' || isalnum(*s); s++);
+	return !*s;
+}
+
+static int name_from_null(struct address buf[static 2], const char *name, int family, int flags)
+{
+	int cnt = 0;
+	if (name) return 0;
+	if (flags & AI_PASSIVE) {
+		if (family != AF_INET6)
+			buf[cnt++] = (struct address){ .family = AF_INET };
+		/*if (family != AF_INET)
+			buf[cnt++] = (struct address){ .family = AF_INET6 };*/
+	} else {
+		if (family != AF_INET6)
+			buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
+		/*if (family != AF_INET)
+			buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };*/
+	}
+	return cnt;
+}
+
+static int name_from_numeric(struct address buf[static 1], const char *name, int family)
+{
+	return __lookup_ipliteral(buf, name, family);
+}
+
+static int name_from_hosts(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
+{
+	char line[512];
+	size_t l = strlen(name);
+	int cnt = 0, badfam = 0;
+	unsigned char _buf[1032];
+	FILE *f = fopen("/etc/hosts", "r");
+	if (!f) switch (errno) {
+	case ENOENT:
+	case ENOTDIR:
+	case EACCES:
+		return 0;
+	default:
+		return EAI_SYSTEM;
+	}
+	while (fgets(line, sizeof line, f) && cnt < MAXADDRS) {
+		char *p, *z;
+
+		if ((p=strchr(line, '#'))) *p++='\n', *p=0;
+		for(p=line+1; (p=strstr(p, name)) &&
+			(!isspace(p[-1]) || !isspace(p[l])); p++);
+		if (!p) continue;
+
+		/* Isolate IP address to parse */
+		for (p=line; *p && !isspace(*p); p++);
+		*p++ = 0;
+		switch (name_from_numeric(buf+cnt, line, family)) {
+		case 1:
+			cnt++;
+			break;
+		case 0:
+			continue;
+		default:
+			badfam = EAI_NONAME;
+			continue;
+		}
+
+		/* Extract first name as canonical name */
+		for (; *p && isspace(*p); p++);
+		for (z=p; *z && !isspace(*z); z++);
+		*z = 0;
+		if (is_valid_hostname(p)) memcpy(canon, p, z-p+1);
+	}
+	fclose(f);
+	return cnt ? cnt : badfam;
+}
+#if 0
+struct dpc_ctx {
+	struct address *addrs;
+	char *canon;
+	int cnt;
+};
+
+int __dns_parse(const unsigned char *, int, int (*)(void *, int, const void *, int, const void *), void *);
+int __dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
+int __res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
+int __res_msend_rc(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int, const struct resolvconf *);
+
+#define RR_A 1
+#define RR_CNAME 5
+#define RR_AAAA 28
+
+static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet)
+{
+	char tmp[256];
+	struct dpc_ctx *ctx = c;
+	switch (rr) {
+	case RR_A:
+		if (len != 4) return -1;
+		ctx->addrs[ctx->cnt].family = AF_INET;
+		ctx->addrs[ctx->cnt].scopeid = 0;
+		memcpy(ctx->addrs[ctx->cnt++].addr, data, 4);
+		break;
+	case RR_AAAA:
+		if (len != 16) return -1;
+		ctx->addrs[ctx->cnt].family = AF_INET6;
+		ctx->addrs[ctx->cnt].scopeid = 0;
+		memcpy(ctx->addrs[ctx->cnt++].addr, data, 16);
+		break;
+	case RR_CNAME:
+		if (__dn_expand(packet, (const unsigned char *)packet + 512,
+		    data, tmp, sizeof tmp) > 0 && is_valid_hostname(tmp))
+			strcpy(ctx->canon, tmp);
+		break;
+	}
+	return 0;
+}
+
+static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, const struct resolvconf *conf)
+{
+	unsigned char qbuf[2][280], abuf[2][512];
+	const unsigned char *qp[2] = { qbuf[0], qbuf[1] };
+	unsigned char *ap[2] = { abuf[0], abuf[1] };
+	int qlens[2], alens[2];
+	int i, nq = 0;
+	struct dpc_ctx ctx = { .addrs = buf, .canon = canon };
+	static const struct { int af; int rr; } afrr[2] = {
+		{ .af = AF_INET6, .rr = RR_A },
+		{ .af = AF_INET, .rr = RR_AAAA },
+	};
+
+	for (i=0; i<2; i++) {
+		if (family != afrr[i].af) {
+			qlens[nq] = __res_mkquery(0, name, 1, afrr[i].rr,
+				0, 0, 0, qbuf[nq], sizeof *qbuf);
+			if (qlens[nq] == -1)
+				return EAI_NONAME;
+			nq++;
+		}
+	}
+
+	if (__res_msend_rc(nq, qp, qlens, ap, alens, sizeof *abuf, conf) < 0)
+		return EAI_SYSTEM;
+
+	for (i=0; i<nq; i++)
+		__dns_parse(abuf[i], alens[i], dns_parse_callback, &ctx);
+
+	if (ctx.cnt) return ctx.cnt;
+	if (alens[0] < 4 || (abuf[0][3] & 15) == 2) return EAI_AGAIN;
+	if ((abuf[0][3] & 15) == 0) return EAI_NONAME;
+	if ((abuf[0][3] & 15) == 3) return 0;
+	return EAI_FAIL;
+}
+
+static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
+{
+	char search[256];
+	struct resolvconf conf;
+	size_t l, dots;
+	char *p, *z;
+
+	if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1;
+
+	/* Count dots, suppress search when >=ndots or name ends in
+	 * a dot, which is an explicit request for global scope. */
+	for (dots=l=0; name[l]; l++) if (name[l]=='.') dots++;
+	if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
+
+	/* This can never happen; the caller already checked length. */
+	if (l >= 256) return EAI_NONAME;
+
+	/* Name with search domain appended is setup in canon[]. This both
+	 * provides the desired default canonical name (if the requested
+	 * name is not a CNAME record) and serves as a buffer for passing
+	 * the full requested name to name_from_dns. */
+	memcpy(canon, name, l);
+	canon[l] = '.';
+
+	for (p=search; *p; p=z) {
+		for (; isspace(*p); p++);
+		for (z=p; *z && !isspace(*z); z++);
+		if (z==p) break;
+		if (z-p < 256 - l - 1) {
+			memcpy(canon+l+1, p, z-p);
+			canon[z-p+1+l] = 0;
+			int cnt = name_from_dns(buf, canon, canon, family, &conf);
+			if (cnt) return cnt;
+		}
+	}
+
+	canon[l] = 0;
+	return name_from_dns(buf, canon, name, family, &conf);
+}
+#endif
+static const struct policy {
+	unsigned char addr[16];
+	unsigned char len, mask;
+	unsigned char prec, label;
+} defpolicy[] = {
+	{ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 15, 0xff, 50, 0 },
+	{ "\0\0\0\0\0\0\0\0\0\0\xff\xff", 11, 0xff, 35, 4 },
+	{ "\x20\2", 1, 0xff, 30, 2 },
+	{ "\x20\1", 3, 0xff, 5, 5 },
+	{ "\xfc", 0, 0xfe, 3, 13 },
+#if 0
+	/* These are deprecated and/or returned to the address
+	 * pool, so despite the RFC, treating them as special
+	 * is probably wrong. */
+	{ "", 11, 0xff, 1, 3 },
+	{ "\xfe\xc0", 1, 0xc0, 1, 11 },
+	{ "\x3f\xfe", 1, 0xff, 1, 12 },
+#endif
+	/* Last rule must match all addresses to stop loop. */
+	{ "", 0, 0, 40, 1 },
+};
+
+static const struct policy *policyof(const struct in6_addr *a)
+{
+	int i;
+	for (i=0; ; i++) {
+		if (memcmp(a->s6_addr, defpolicy[i].addr, defpolicy[i].len))
+			continue;
+		if ((a->s6_addr[defpolicy[i].len] & defpolicy[i].mask)
+		    != defpolicy[i].addr[defpolicy[i].len])
+			continue;
+		return defpolicy+i;
+	}
+}
+
+static int labelof(const struct in6_addr *a)
+{
+	return policyof(a)->label;
+}
+
+static int scopeof(const struct in6_addr *a)
+{
+	if (IN6_IS_ADDR_MULTICAST(a)) return a->s6_addr[1] & 15;
+	if (IN6_IS_ADDR_LINKLOCAL(a)) return 2;
+	if (IN6_IS_ADDR_LOOPBACK(a)) return 2;
+	if (IN6_IS_ADDR_SITELOCAL(a)) return 5;
+	return 14;
+}
+
+static int prefixmatch(const struct in6_addr *s, const struct in6_addr *d)
+{
+	/* FIXME: The common prefix length should be limited to no greater
+	 * than the nominal length of the prefix portion of the source
+	 * address. However the definition of the source prefix length is
+	 * not clear and thus this limiting is not yet implemented. */
+	unsigned i;
+	for (i=0; i<128 && !((s->s6_addr[i/8]^d->s6_addr[i/8])&(128>>(i%8))); i++);
+	return i;
+}
+
+#define DAS_USABLE              0x40000000
+#define DAS_MATCHINGSCOPE       0x20000000
+#define DAS_MATCHINGLABEL       0x10000000
+#define DAS_PREC_SHIFT          20
+#define DAS_SCOPE_SHIFT         16
+#define DAS_PREFIX_SHIFT        8
+#define DAS_ORDER_SHIFT         0
+
+static int addrcmp(const void *_a, const void *_b)
+{
+	const struct address *a = _a, *b = _b;
+	return b->sortkey - a->sortkey;
+}
+
+int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags)
+{
+	int cnt = 0, i, j;
+
+	*canon = 0;
+	if (name) {
+		/* reject empty name and check len so it fits into temp bufs */
+		size_t l = strnlen(name, 255);
+		if (l-1 >= 254)
+			return EAI_NONAME;
+		memcpy(canon, name, l+1);
+	}
+
+	/* Procedurally, a request for v6 addresses with the v4-mapped
+	 * flag set is like a request for unspecified family, followed
+	 * by filtering of the results. */
+	if (flags & AI_V4MAPPED) {
+		if (family == AF_INET6) family = AF_UNSPEC;
+		else flags -= AI_V4MAPPED;
+	}
+
+	/* Try each backend until there's at least one result. */
+	cnt = name_from_null(buf, name, family, flags);
+	if (!cnt) cnt = name_from_numeric(buf, name, family);
+	if (!cnt && !(flags & AI_NUMERICHOST)) {
+		cnt = name_from_hosts(buf, canon, name, family);
+		//if (!cnt) cnt = name_from_dns_search(buf, canon, name, family);
+	}
+	if (cnt<=0) return cnt ? cnt : EAI_NONAME;
+
+	/* Filter/transform results for v4-mapped lookup, if requested. */
+	if (flags & AI_V4MAPPED) {
+		if (!(flags & AI_ALL)) {
+			/* If any v6 results exist, remove v4 results. */
+			for (i=0; i<cnt && buf[i].family != AF_INET6; i++);
+			if (i<cnt) {
+				for (j=0; i<cnt; i++) {
+					if (buf[i].family == AF_INET6)
+						buf[j++] = buf[i];
+				}
+				cnt = i = j;
+			}
+		}
+		/* Translate any remaining v4 results to v6 */
+		for (i=0; i<cnt; i++) {
+			if (buf[i].family != AF_INET) continue;
+			memcpy(buf[i].addr+12, buf[i].addr, 4);
+			memcpy(buf[i].addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
+			buf[i].family = AF_INET6;
+		}
+	}
+
+	/* No further processing is needed if there are fewer than 2
+	 * results or if there are only IPv4 results. */
+	if (cnt<2 || family==AF_INET) return cnt;
+	for (i=0; buf[i].family == AF_INET; i++)
+		if (i==cnt) return cnt;
+
+	//int cs;
+	//pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+
+	/* The following implements a subset of RFC 3484/6724 destination
+	 * address selection by generating a single 31-bit sort key for
+	 * each address. Rules 3, 4, and 7 are omitted for having
+	 * excessive runtime and code size cost and dubious benefit.
+	 * So far the label/precedence table cannot be customized. */
+	for (i=0; i<cnt; i++) {
+		int key = 0;
+		struct sockaddr_in6 sa, da = {
+			.sin6_family = AF_INET6,
+			.sin6_scope_id = buf[i].scopeid,
+			.sin6_port = 65535
+		};
+		if (buf[i].family == AF_INET6) {
+			memcpy(da.sin6_addr.s6_addr, buf[i].addr, 16);
+		} else {
+			memcpy(da.sin6_addr.s6_addr,
+				"\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
+			memcpy(da.sin6_addr.s6_addr+12, buf[i].addr, 4);
+		}
+		const struct policy *dpolicy = policyof(&da.sin6_addr);
+		int dscope = scopeof(&da.sin6_addr);
+		int dlabel = dpolicy->label;
+		int dprec = dpolicy->prec;
+		int prefixlen = 0;
+		int fd = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
+		if (fd >= 0) {
+			if (!connect(fd, (void *)&da, sizeof da)) {
+				key |= DAS_USABLE;
+				if (!getsockname(fd, (void *)&sa,
+				    &(socklen_t){sizeof sa})) {
+					if (dscope == scopeof(&sa.sin6_addr))
+						key |= DAS_MATCHINGSCOPE;
+					if (dlabel == labelof(&sa.sin6_addr))
+						key |= DAS_MATCHINGLABEL;
+					prefixlen = prefixmatch(&sa.sin6_addr,
+						&da.sin6_addr);
+				}
+			}
+			close(fd);
+		}
+		key |= dprec << DAS_PREC_SHIFT;
+		key |= (15-dscope) << DAS_SCOPE_SHIFT;
+		key |= prefixlen << DAS_PREFIX_SHIFT;
+		key |= (MAXADDRS-i) << DAS_ORDER_SHIFT;
+		buf[i].sortkey = key;
+	}
+	qsort(buf, cnt, sizeof *buf, addrcmp);
+
+	//pthread_setcancelstate(cs, 0);
+
+	return cnt;
+}
Index: /EcnlProtoTool/trunk/prototool/src/musl/lookup_serv.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/musl/lookup_serv.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/musl/lookup_serv.c	(revision 279)
@@ -0,0 +1,114 @@
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "lookup.h"
+#include <stdio.h>
+//#include "stdio_impl.h"
+
+int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags)
+{
+	char line[128];
+	int cnt = 0;
+	char *p, *z = "";
+	unsigned long port = 0;
+
+	switch (socktype) {
+	case SOCK_STREAM:
+		switch (proto) {
+		case 0:
+			proto = IPPROTO_TCP;
+		case IPPROTO_TCP:
+			break;
+		default:
+			return EAI_SERVICE;
+		}
+		break;
+	case SOCK_DGRAM:
+		switch (proto) {
+		case 0:
+			proto = IPPROTO_UDP;
+		case IPPROTO_UDP:
+			break;
+		default:
+			return EAI_SERVICE;
+		}
+	case 0:
+		break;
+	default:
+		if (name) return EAI_SERVICE;
+		buf[0].port = 0;
+		buf[0].proto = proto;
+		buf[0].socktype = socktype;
+		return 1;
+	}
+
+	if (name) {
+		if (!*name) return EAI_SERVICE;
+		port = strtoul(name, &z, 10);
+	}
+	if (!*z) {
+		if (port > 65535) return EAI_SERVICE;
+		if (proto != IPPROTO_UDP) {
+			buf[cnt].port = port;
+			buf[cnt].socktype = SOCK_STREAM;
+			buf[cnt++].proto = IPPROTO_TCP;
+		}
+		if (proto != IPPROTO_TCP) {
+			buf[cnt].port = port;
+			buf[cnt].socktype = SOCK_DGRAM;
+			buf[cnt++].proto = IPPROTO_UDP;
+		}
+		return cnt;
+	}
+
+	if (flags & AI_NUMERICSERV) return EAI_SERVICE;
+
+	size_t l = strlen(name);
+
+	unsigned char _buf[1032];
+	FILE *f = fopen("/etc/services", "r");
+	if (!f) switch (errno) {
+	case ENOENT:
+	case ENOTDIR:
+	case EACCES:
+		return EAI_SERVICE;
+	default:
+		return EAI_SYSTEM;
+	}
+
+	while (fgets(line, sizeof line, f) && cnt < MAXSERVS) {
+		if ((p=strchr(line, '#'))) *p++='\n', *p=0;
+
+		/* Find service name */
+		for(p=line; (p=strstr(p, name)); p++) {
+			if (p>line && !isspace(p[-1])) continue;
+			if (p[l] && !isspace(p[l])) continue;
+			break;
+		}
+		if (!p) continue;
+
+		/* Skip past canonical name at beginning of line */
+		for (p=line; *p && !isspace(*p); p++);
+
+		port = strtoul(p, &z, 10);
+		if (port > 65535 || z==p) continue;
+		if (!strncmp(z, "/udp", 4)) {
+			if (proto == IPPROTO_TCP) continue;
+			buf[cnt].port = port;
+			buf[cnt].socktype = SOCK_DGRAM;
+			buf[cnt++].proto = IPPROTO_UDP;
+		}
+		if (!strncmp(z, "/tcp", 4)) {
+			if (proto == IPPROTO_UDP) continue;
+			buf[cnt].port = port;
+			buf[cnt].socktype = SOCK_STREAM;
+			buf[cnt++].proto = IPPROTO_TCP;
+		}
+	}
+	fclose(f);
+	return cnt > 0 ? cnt : EAI_SERVICE;
+}
Index: /EcnlProtoTool/trunk/prototool/src/onitest.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/onitest.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/onitest.c	(revision 279)
@@ -0,0 +1,868 @@
+/*
+ * This program was generated by testconv.rb.
+ */
+#include "config.h"
+#ifdef ONIG_ESCAPE_UCHAR_COLLISION
+#undef ONIG_ESCAPE_UCHAR_COLLISION
+#endif
+#include <stdio.h>
+
+#ifdef POSIX_TEST
+#include "onigposix.h"
+#else
+#include "oniguruma.h"
+#endif
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+#include <stdlib.h>
+#include <wchar.h>
+
+#define SLEN(s)  strlen(s)
+
+static int nsucc = 0;
+static int nfail = 0;
+static int nerror = 0;
+
+static FILE* err_file;
+
+#ifndef POSIX_TEST
+static OnigRegion* region;
+#endif
+
+static void xx(const char* pattern, const char* str, int from, int to, int mem, int not)
+{
+	int r;
+
+#ifdef POSIX_TEST
+	regex_t reg;
+	char buf[200];
+	regmatch_t pmatch[25];
+
+	r = regcomp(&reg, pattern, REG_EXTENDED | REG_NEWLINE);
+	if (r) {
+		regerror(r, &reg, buf, sizeof(buf));
+		fprintf(err_file, "ERROR: %s\n", buf);
+		nerror++;
+		return;
+	}
+
+	r = regexec(&reg, str, reg.re_nsub + 1, pmatch, 0);
+	if (r != 0 && r != REG_NOMATCH) {
+		regerror(r, &reg, buf, sizeof(buf));
+		fprintf(err_file, "ERROR: %s\n", buf);
+		nerror++;
+		return;
+	}
+
+	if (r == REG_NOMATCH) {
+		if (not) {
+			fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str);
+			nsucc++;
+		}
+		else {
+			fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str);
+			nfail++;
+		}
+	}
+	else {
+		if (not) {
+			fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str);
+			nfail++;
+		}
+		else {
+			if (pmatch[mem].rm_so == from && pmatch[mem].rm_eo == to) {
+				fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str);
+				nsucc++;
+			}
+			else {
+				fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str,
+					from, to, pmatch[mem].rm_so, pmatch[mem].rm_eo);
+				nfail++;
+			}
+		}
+	}
+	regfree(&reg);
+
+#else
+	regex_t* reg;
+	OnigErrorInfo einfo;
+	OnigSyntaxType syn = *ONIG_SYNTAX_DEFAULT;
+
+	/* ONIG_OPTION_OFF(syn.options, ONIG_OPTION_ASCII_RANGE); */
+
+	r = onig_new(&reg, (const char*)pattern, (const char*)(pattern + SLEN(pattern)),
+		ONIG_OPTION_DEFAULT, ONIG_ENCODING_UTF8, &syn, &einfo);
+	if (r) {
+		char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+		onig_error_code_to_str((const char*)s, r, &einfo);
+		fprintf(err_file, "ERROR: %s\n", s);
+		nerror++;
+		return;
+	}
+
+	r = onig_search(reg, (const char*)str, (const char*)(str + SLEN(str)),
+		(const char*)str, (const char*)(str + SLEN(str)),
+		region, ONIG_OPTION_NONE);
+	if (r < ONIG_MISMATCH) {
+		char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+		onig_error_code_to_str((const char*)s, r);
+		fprintf(err_file, "ERROR: %s\n", s);
+		nerror++;
+		return;
+	}
+
+	if (r == ONIG_MISMATCH) {
+		if (not) {
+			fprintf(stdout, "OK(N): /%s/ '%s'\n", pattern, str);
+			nsucc++;
+		}
+		else {
+			fprintf(stdout, "FAIL: /%s/ '%s'\n", pattern, str);
+			nfail++;
+		}
+	}
+	else {
+		if (not) {
+			fprintf(stdout, "FAIL(N): /%s/ '%s'\n", pattern, str);
+			nfail++;
+		}
+		else {
+			if (region->beg[mem] == from && region->end[mem] == to) {
+				fprintf(stdout, "OK: /%s/ '%s'\n", pattern, str);
+				nsucc++;
+			}
+			else {
+				fprintf(stdout, "FAIL: /%s/ '%s' %d-%d : %d-%d\n", pattern, str,
+					from, to, region->beg[mem], region->end[mem]);
+				nfail++;
+			}
+		}
+	}
+	onig_free(reg);
+#endif
+}
+
+static void x2(const char* pattern, const char* str, int from, int to)
+{
+	xx(pattern, str, from, to, 0, 0);
+}
+
+static void x3(const char* pattern, const char* str, int from, int to, int mem)
+{
+	xx(pattern, str, from, to, mem, 0);
+}
+
+static void n(const char* pattern, const char* str)
+{
+	xx(pattern, str, 0, 0, 0, 1);
+}
+
+extern int onitest_main(int argc, char* argv[])
+{
+	err_file = stdout;
+
+#ifdef POSIX_TEST
+	reg_set_encoding(REG_POSIX_ENCODING_UTF8);
+#else
+	region = onig_region_new();
+#endif
+
+	x2("", "", 0, 0);
+	x2("^", "", 0, 0);
+	x2("$", "", 0, 0);
+	x2("\\G", "", 0, 0);
+	x2("\\A", "", 0, 0);
+	x2("\\Z", "", 0, 0);
+	x2("\\z", "", 0, 0);
+	x2("^$", "", 0, 0);
+	x2("\\ca", "\001", 0, 1);
+	x2("\\C-b", "\002", 0, 1);
+	x2("\\c\\\\", "\034", 0, 1);
+	x2("q[\\c\\\\]", "q\034", 0, 2);
+	x2("", "a", 0, 0);
+	x2("a", "a", 0, 1);
+	x2("\\x61", "a", 0, 1);
+	x2("aa", "aa", 0, 2);
+	x2("aaa", "aaa", 0, 3);
+	x2("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, 35);
+	x2("ab", "ab", 0, 2);
+	x2("b", "ab", 1, 2);
+	x2("bc", "abc", 1, 3);
+	x2("(?i:#RET#)", "#INS##RET#", 5, 10);
+	x2("\\17", "\017", 0, 1);
+	x2("\\x1f", "\x1f", 0, 1);
+	x2("a(?#....\\\\JJJJ)b", "ab", 0, 2);
+	x2("(?x)  G (o O(?-x)oO) g ", "GoOoOgLe", 0, 7);
+	x2(".", "a", 0, 1);
+	n(".", "");
+	x2("..", "ab", 0, 2);
+	x2("\\w", "e", 0, 1);
+	n("\\W", "e");
+	x2("\\s", " ", 0, 1);
+	x2("\\S", "b", 0, 1);
+	x2("\\d", "4", 0, 1);
+	n("\\D", "4");
+	x2("\\b", "z ", 0, 0);
+	x2("\\b", " z", 1, 1);
+	x2("\\B", "zz ", 1, 1);
+	x2("\\B", "z ", 2, 2);
+	x2("\\B", " z", 0, 0);
+	x2("[ab]", "b", 0, 1);
+	n("[ab]", "c");
+	x2("[a-z]", "t", 0, 1);
+	n("[^a]", "a");
+	x2("[^a]", "\n", 0, 1);
+	x2("[]]", "]", 0, 1);
+	n("[^]]", "]");
+	x2("[\\^]+", "0^^1", 1, 3);
+	x2("[b-]", "b", 0, 1);
+	x2("[b-]", "-", 0, 1);
+	x2("[\\w]", "z", 0, 1);
+	n("[\\w]", " ");
+	x2("[\\W]", "b$", 1, 2);
+	x2("[\\d]", "5", 0, 1);
+	n("[\\d]", "e");
+	x2("[\\D]", "t", 0, 1);
+	n("[\\D]", "3");
+	x2("[\\s]", " ", 0, 1);
+	n("[\\s]", "a");
+	x2("[\\S]", "b", 0, 1);
+	n("[\\S]", " ");
+	x2("[\\w\\d]", "2", 0, 1);
+	n("[\\w\\d]", " ");
+	x2("[[:upper:]]", "B", 0, 1);
+	x2("[*[:xdigit:]+]", "+", 0, 1);
+	x2("[*[:xdigit:]+]", "GHIKK-9+*", 6, 7);
+	x2("[*[:xdigit:]+]", "-@^+", 3, 4);
+	n("[[:upper]]", "A");
+	x2("[[:upper]]", ":", 0, 1);
+	x2("[\\044-\\047]", "\046", 0, 1);
+	x2("[\\x5a-\\x5c]", "\x5b", 0, 1);
+	x2("[\\x6A-\\x6D]", "\x6c", 0, 1);
+	n("[\\x6A-\\x6D]", "\x6E");
+	n("^[0-9A-F]+ 0+ UNDEF ", "75F 00000000 SECT14A notype ()    External    | _rb_apply");
+	x2("[\\[]", "[", 0, 1);
+	x2("[\\]]", "]", 0, 1);
+	x2("[&]", "&", 0, 1);
+	x2("[[ab]]", "b", 0, 1);
+	x2("[[ab]c]", "c", 0, 1);
+	n("[[^a]]", "a");
+	n("[^[a]]", "a");
+	x2("[[ab]&&bc]", "b", 0, 1);
+	n("[[ab]&&bc]", "a");
+	n("[[ab]&&bc]", "c");
+	x2("[a-z&&b-y&&c-x]", "w", 0, 1);
+	n("[^a-z&&b-y&&c-x]", "w");
+	x2("[[^a&&a]&&a-z]", "b", 0, 1);
+	n("[[^a&&a]&&a-z]", "a");
+	x2("[[^a-z&&bcdef]&&[^c-g]]", "h", 0, 1);
+	n("[[^a-z&&bcdef]&&[^c-g]]", "c");
+	x2("[^[^abc]&&[^cde]]", "c", 0, 1);
+	x2("[^[^abc]&&[^cde]]", "e", 0, 1);
+	n("[^[^abc]&&[^cde]]", "f");
+	x2("[a-&&-a]", "-", 0, 1);
+	n("[a\\-&&\\-a]", "&");
+	n("\\wabc", " abc");
+	x2("a\\Wbc", "a bc", 0, 4);
+	x2("a.b.c", "aabbc", 0, 5);
+	x2(".\\wb\\W..c", "abb bcc", 0, 7);
+	x2("\\s\\wzzz", " zzzz", 0, 5);
+	x2("aa.b", "aabb", 0, 4);
+	n(".a", "ab");
+	x2(".a", "aa", 0, 2);
+	x2("^a", "a", 0, 1);
+	x2("^a$", "a", 0, 1);
+	x2("^\\w$", "a", 0, 1);
+	n("^\\w$", " ");
+	x2("^\\wab$", "zab", 0, 3);
+	x2("^\\wabcdef$", "zabcdef", 0, 7);
+	x2("^\\w...def$", "zabcdef", 0, 7);
+	x2("\\w\\w\\s\\Waaa\\d", "aa  aaa4", 0, 8);
+	x2("\\A\\Z", "", 0, 0);
+	x2("\\Axyz", "xyz", 0, 3);
+	x2("xyz\\Z", "xyz", 0, 3);
+	x2("xyz\\z", "xyz", 0, 3);
+	x2("a\\Z", "a", 0, 1);
+	x2("\\Gaz", "az", 0, 2);
+	n("\\Gz", "bza");
+	n("az\\G", "az");
+	n("az\\A", "az");
+	n("a\\Az", "az");
+	x2("\\^\\$", "^$", 0, 2);
+	x2("^x?y", "xy", 0, 2);
+	x2("^(x?y)", "xy", 0, 2);
+	x2("\\w", "_", 0, 1);
+	n("\\W", "_");
+	x2("(?=z)z", "z", 0, 1);
+	n("(?=z).", "a");
+	x2("(?!z)a", "a", 0, 1);
+	n("(?!z)a", "z");
+	x2("(?i:a)", "a", 0, 1);
+	x2("(?i:a)", "A", 0, 1);
+	x2("(?i:A)", "a", 0, 1);
+	n("(?i:A)", "b");
+	x2("(?i:[A-Z])", "a", 0, 1);
+	x2("(?i:[f-m])", "H", 0, 1);
+	x2("(?i:[f-m])", "h", 0, 1);
+	n("(?i:[f-m])", "e");
+	x2("(?i:[A-c])", "D", 0, 1);
+	n("(?i:[^a-z])", "A");
+	n("(?i:[^a-z])", "a");
+	x2("(?i:[!-k])", "Z", 0, 1);
+	x2("(?i:[!-k])", "7", 0, 1);
+	x2("(?i:[T-}])", "b", 0, 1);
+	x2("(?i:[T-}])", "{", 0, 1);
+	x2("(?i:\\?a)", "?A", 0, 2);
+	x2("(?i:\\*A)", "*a", 0, 2);
+	n(".", "\n");
+	x2("(?m:.)", "\n", 0, 1);
+	x2("(?m:a.)", "a\n", 0, 2);
+	x2("(?m:.b)", "a\nb", 1, 3);
+	x2(".*abc", "dddabdd\nddabc", 8, 13);
+	x2("(?m:.*abc)", "dddabddabc", 0, 10);
+	n("(?i)(?-i)a", "A");
+	n("(?i)(?-i:a)", "A");
+	x2("a?", "", 0, 0);
+	x2("a?", "b", 0, 0);
+	x2("a?", "a", 0, 1);
+	x2("a*", "", 0, 0);
+	x2("a*", "a", 0, 1);
+	x2("a*", "aaa", 0, 3);
+	x2("a*", "baaaa", 0, 0);
+	n("a+", "");
+	x2("a+", "a", 0, 1);
+	x2("a+", "aaaa", 0, 4);
+	x2("a+", "aabbb", 0, 2);
+	x2("a+", "baaaa", 1, 5);
+	x2(".?", "", 0, 0);
+	x2(".?", "f", 0, 1);
+	x2(".?", "\n", 0, 0);
+	x2(".*", "", 0, 0);
+	x2(".*", "abcde", 0, 5);
+	x2(".+", "z", 0, 1);
+	x2(".+", "zdswer\n", 0, 6);
+	x2("(.*)a\\1f", "babfbac", 0, 4);
+	x2("(.*)a\\1f", "bacbabf", 3, 7);
+	x2("((.*)a\\2f)", "bacbabf", 3, 7);
+	x2("(.*)a\\1f", "baczzzzzz\nbazz\nzzzzbabf", 19, 23);
+	x2("a|b", "a", 0, 1);
+	x2("a|b", "b", 0, 1);
+	x2("|a", "a", 0, 0);
+	x2("(|a)", "a", 0, 0);
+	x2("ab|bc", "ab", 0, 2);
+	x2("ab|bc", "bc", 0, 2);
+	x2("z(?:ab|bc)", "zbc", 0, 3);
+	x2("a(?:ab|bc)c", "aabc", 0, 4);
+	x2("ab|(?:ac|az)", "az", 0, 2);
+	x2("a|b|c", "dc", 1, 2);
+	x2("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "pqr", 0, 2);
+	n("a|b|cd|efg|h|ijk|lmn|o|pq|rstuvwx|yz", "mn");
+	x2("a|^z", "ba", 1, 2);
+	x2("a|^z", "za", 0, 1);
+	x2("a|\\Gz", "bza", 2, 3);
+	x2("a|\\Gz", "za", 0, 1);
+	x2("a|\\Az", "bza", 2, 3);
+	x2("a|\\Az", "za", 0, 1);
+	x2("a|b\\Z", "ba", 1, 2);
+	x2("a|b\\Z", "b", 0, 1);
+	x2("a|b\\z", "ba", 1, 2);
+	x2("a|b\\z", "b", 0, 1);
+	x2("\\w|\\s", " ", 0, 1);
+	n("\\w|\\w", " ");
+	x2("\\w|%", "%", 0, 1);
+	x2("\\w|[&$]", "&", 0, 1);
+	x2("[b-d]|[^e-z]", "a", 0, 1);
+	x2("(?:a|[c-f])|bz", "dz", 0, 1);
+	x2("(?:a|[c-f])|bz", "bz", 0, 2);
+	x2("abc|(?=zz)..f", "zzf", 0, 3);
+	x2("abc|(?!zz)..f", "abf", 0, 3);
+	x2("(?=za)..a|(?=zz)..a", "zza", 0, 3);
+	n("(?>a|abd)c", "abdc");
+	x2("(?>abd|a)c", "abdc", 0, 4);
+	x2("a?|b", "a", 0, 1);
+	x2("a?|b", "b", 0, 0);
+	x2("a?|b", "", 0, 0);
+	x2("a*|b", "aa", 0, 2);
+	x2("a*|b*", "ba", 0, 0);
+	x2("a*|b*", "ab", 0, 1);
+	x2("a+|b*", "", 0, 0);
+	x2("a+|b*", "bbb", 0, 3);
+	x2("a+|b*", "abbb", 0, 1);
+	n("a+|b+", "");
+	x2("(a|b)?", "b", 0, 1);
+	x2("(a|b)*", "ba", 0, 2);
+	x2("(a|b)+", "bab", 0, 3);
+	x2("(ab|ca)+", "caabbc", 0, 4);
+	x2("(ab|ca)+", "aabca", 1, 5);
+	x2("(ab|ca)+", "abzca", 0, 2);
+	x2("(a|bab)+", "ababa", 0, 5);
+	x2("(a|bab)+", "ba", 1, 2);
+	x2("(a|bab)+", "baaaba", 1, 4);
+	x2("(?:a|b)(?:a|b)", "ab", 0, 2);
+	x2("(?:a*|b*)(?:a*|b*)", "aaabbb", 0, 3);
+	x2("(?:a*|b*)(?:a+|b+)", "aaabbb", 0, 6);
+	x2("(?:a+|b+){2}", "aaabbb", 0, 6);
+	x2("h{0,}", "hhhh", 0, 4);
+	x2("(?:a+|b+){1,2}", "aaabbb", 0, 6);
+	n("ax{2}*a", "0axxxa1");
+	n("a.{0,2}a", "0aXXXa0");
+	n("a.{0,2}?a", "0aXXXa0");
+	n("a.{0,2}?a", "0aXXXXa0");
+	x2("^a{2,}?a$", "aaa", 0, 3);
+	x2("^[a-z]{2,}?$", "aaa", 0, 3);
+	x2("(?:a+|\\Ab*)cc", "cc", 0, 2);
+	n("(?:a+|\\Ab*)cc", "abcc");
+	x2("(?:^a+|b+)*c", "aabbbabc", 6, 8);
+	x2("(?:^a+|b+)*c", "aabbbbc", 0, 7);
+	x2("a|(?i)c", "C", 0, 1);
+	x2("(?i)c|a", "C", 0, 1);
+	x2("(?i)c|a", "A", 0, 1);
+	x2("(?i:c)|a", "C", 0, 1);
+	n("(?i:c)|a", "A");
+	x2("[abc]?", "abc", 0, 1);
+	x2("[abc]*", "abc", 0, 3);
+	x2("[^abc]*", "abc", 0, 0);
+	n("[^abc]+", "abc");
+	x2("a?\?", "aaa", 0, 0);
+	x2("ba?\?b", "bab", 0, 3);
+	x2("a*?", "aaa", 0, 0);
+	x2("ba*?", "baa", 0, 1);
+	x2("ba*?b", "baab", 0, 4);
+	x2("a+?", "aaa", 0, 1);
+	x2("ba+?", "baa", 0, 2);
+	x2("ba+?b", "baab", 0, 4);
+	x2("(?:a?)?\?", "a", 0, 0);
+	x2("(?:a?\?)?", "a", 0, 0);
+	x2("(?:a?)+?", "aaa", 0, 1);
+	x2("(?:a+)?\?", "aaa", 0, 0);
+	x2("(?:a+)?\?b", "aaab", 0, 4);
+	x2("(?:ab)?{2}", "", 0, 0);
+	x2("(?:ab)?{2}", "ababa", 0, 4);
+	x2("(?:ab)*{0}", "ababa", 0, 0);
+	x2("(?:ab){3,}", "abababab", 0, 8);
+	n("(?:ab){3,}", "abab");
+	x2("(?:ab){2,4}", "ababab", 0, 6);
+	x2("(?:ab){2,4}", "ababababab", 0, 8);
+	x2("(?:ab){2,4}?", "ababababab", 0, 4);
+	x2("(?:ab){,}", "ab{,}", 0, 5);
+	x2("(?:abc)+?{2}", "abcabcabc", 0, 6);
+	x2("(?:X*)(?i:xa)", "XXXa", 0, 4);
+	x2("(d+)([^abc]z)", "dddz", 0, 4);
+	x2("([^abc]*)([^abc]z)", "dddz", 0, 4);
+	x2("(\\w+)(\\wz)", "dddz", 0, 4);
+	x3("(a)", "a", 0, 1, 1);
+	x3("(ab)", "ab", 0, 2, 1);
+	x2("((ab))", "ab", 0, 2);
+	x3("((ab))", "ab", 0, 2, 1);
+	x3("((ab))", "ab", 0, 2, 2);
+	x3("((((((((((((((((((((ab))))))))))))))))))))", "ab", 0, 2, 20);
+	x3("(ab)(cd)", "abcd", 0, 2, 1);
+	x3("(ab)(cd)", "abcd", 2, 4, 2);
+	x3("()(a)bc(def)ghijk", "abcdefghijk", 3, 6, 3);
+	x3("(()(a)bc(def)ghijk)", "abcdefghijk", 3, 6, 4);
+	x2("(^a)", "a", 0, 1);
+	x3("(a)|(a)", "ba", 1, 2, 1);
+	x3("(^a)|(a)", "ba", 1, 2, 2);
+	x3("(a?)", "aaa", 0, 1, 1);
+	x3("(a*)", "aaa", 0, 3, 1);
+	x3("(a*)", "", 0, 0, 1);
+	x3("(a+)", "aaaaaaa", 0, 7, 1);
+	x3("(a+|b*)", "bbbaa", 0, 3, 1);
+	x3("(a+|b?)", "bbbaa", 0, 1, 1);
+	x3("(abc)?", "abc", 0, 3, 1);
+	x3("(abc)*", "abc", 0, 3, 1);
+	x3("(abc)+", "abc", 0, 3, 1);
+	x3("(xyz|abc)+", "abc", 0, 3, 1);
+	x3("([xyz][abc]|abc)+", "abc", 0, 3, 1);
+	x3("((?i:abc))", "AbC", 0, 3, 1);
+	x2("(abc)(?i:\\1)", "abcABC", 0, 6);
+	x3("((?m:a.c))", "a\nc", 0, 3, 1);
+	x3("((?=az)a)", "azb", 0, 1, 1);
+	x3("abc|(.abd)", "zabd", 0, 4, 1);
+	x2("(?:abc)|(ABC)", "abc", 0, 3);
+	x3("(?i:(abc))|(zzz)", "ABC", 0, 3, 1);
+	x3("a*(.)", "aaaaz", 4, 5, 1);
+	x3("a*?(.)", "aaaaz", 0, 1, 1);
+	x3("a*?(c)", "aaaac", 4, 5, 1);
+	x3("[bcd]a*(.)", "caaaaz", 5, 6, 1);
+	x3("(\\Abb)cc", "bbcc", 0, 2, 1);
+	n("(\\Abb)cc", "zbbcc");
+	x3("(^bb)cc", "bbcc", 0, 2, 1);
+	n("(^bb)cc", "zbbcc");
+	x3("cc(bb$)", "ccbb", 2, 4, 1);
+	n("cc(bb$)", "ccbbb");
+	n("(\\1)", "");
+	n("\\1(a)", "aa");
+	n("(a(b)\\1)\\2+", "ababb");
+	n("(?:(?:\\1|z)(a))+$", "zaa");
+	x2("(?:(?:\\1|z)(a))+$", "zaaa", 0, 4);
+	x2("(a)(?=\\1)", "aa", 0, 1);
+	n("(a)$|\\1", "az");
+	x2("(a)\\1", "aa", 0, 2);
+	n("(a)\\1", "ab");
+	x2("(a?)\\1", "aa", 0, 2);
+	x2("(a?\?)\\1", "aa", 0, 0);
+	x2("(a*)\\1", "aaaaa", 0, 4);
+	x3("(a*)\\1", "aaaaa", 0, 2, 1);
+	x2("a(b*)\\1", "abbbb", 0, 5);
+	x2("a(b*)\\1", "ab", 0, 1);
+	x2("(a*)(b*)\\1\\2", "aaabbaaabb", 0, 10);
+	x2("(a*)(b*)\\2", "aaabbbb", 0, 7);
+	x2("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 8);
+	x3("(((((((a*)b))))))c\\7", "aaabcaaa", 0, 3, 7);
+	x2("(a)(b)(c)\\2\\1\\3", "abcbac", 0, 6);
+	x2("([a-d])\\1", "cc", 0, 2);
+	x2("(\\w\\d\\s)\\1", "f5 f5 ", 0, 6);
+	n("(\\w\\d\\s)\\1", "f5 f5");
+	x2("(who|[a-c]{3})\\1", "whowho", 0, 6);
+	x2("...(who|[a-c]{3})\\1", "abcwhowho", 0, 9);
+	x2("(who|[a-c]{3})\\1", "cbccbc", 0, 6);
+	x2("(^a)\\1", "aa", 0, 2);
+	n("(^a)\\1", "baa");
+	n("(a$)\\1", "aa");
+	n("(ab\\Z)\\1", "ab");
+	x2("(a*\\Z)\\1", "a", 1, 1);
+	x2(".(a*\\Z)\\1", "ba", 1, 2);
+	x3("(.(abc)\\2)", "zabcabc", 0, 7, 1);
+	x3("(.(..\\d.)\\2)", "z12341234", 0, 9, 1);
+	x2("((?i:az))\\1", "AzAz", 0, 4);
+	n("((?i:az))\\1", "Azaz");
+	x2("(?<=a)b", "ab", 1, 2);
+	n("(?<=a)b", "bb");
+	x2("(?<=a|b)b", "bb", 1, 2);
+	x2("(?<=a|bc)b", "bcb", 2, 3);
+	x2("(?<=a|bc)b", "ab", 1, 2);
+	x2("(?<=a|bc||defghij|klmnopq|r)z", "rz", 1, 2);
+	x2("(a)\\g<1>", "aa", 0, 2);
+	x2("(?<!a)b", "cb", 1, 2);
+	n("(?<!a)b", "ab");
+	x2("(?<!a|bc)b", "bbb", 0, 1);
+	n("(?<!a|bc)z", "bcz");
+	x2("(?<name1>a)", "a", 0, 1);
+	x2("(?<name_2>ab)\\g<name_2>", "abab", 0, 4);
+	x2("(?<name_3>.zv.)\\k<name_3>", "azvbazvb", 0, 8);
+	x2("(?<=\\g<ab>)|-\\zEND (?<ab>XyZ)", "XyZ", 3, 3);
+	x2("(?<n>|a\\g<n>)+", "", 0, 0);
+	x2("(?<n>|\\(\\g<n>\\))+$", "()(())", 0, 6);
+	x3("\\g<n>(?<n>.){0}", "X", 0, 1, 1);
+	x2("\\g<n>(abc|df(?<n>.YZ){2,8}){0}", "XYZ", 0, 3);
+	x2("\\A(?<n>(a\\g<n>)|)\\z", "aaaa", 0, 4);
+	x2("(?<n>|\\g<m>\\g<n>)\\z|\\zEND (?<m>a|(b)\\g<m>)", "bbbbabba", 0, 8);
+	x2("(?<name1240>\\w+\\sx)a+\\k<name1240>", "  fg xaaaaaaaafg x", 2, 18);
+	x3("(z)()()(?<_9>a)\\g<_9>", "zaa", 2, 3, 1);
+	x2("(.)(((?<_>a)))\\k<_>", "zaa", 0, 3);
+	x2("((?<name1>\\d)|(?<name2>\\w))(\\k<name1>|\\k<name2>)", "ff", 0, 2);
+	x2("(?:(?<x>)|(?<x>efg))\\k<x>", "", 0, 0);
+	x2("(?:(?<x>abc)|(?<x>efg))\\k<x>", "abcefgefg", 3, 9);
+	n("(?:(?<x>abc)|(?<x>efg))\\k<x>", "abcefg");
+	x2("(?:(?<n1>.)|(?<n1>..)|(?<n1>...)|(?<n1>....)|(?<n1>.....)|(?<n1>......)|(?<n1>.......)|(?<n1>........)|(?<n1>.........)|(?<n1>..........)|(?<n1>...........)|(?<n1>............)|(?<n1>.............)|(?<n1>..............))\\k<n1>$", "a-pyumpyum", 2, 10);
+	x3("(?:(?<n1>.)|(?<n1>..)|(?<n1>...)|(?<n1>....)|(?<n1>.....)|(?<n1>......)|(?<n1>.......)|(?<n1>........)|(?<n1>.........)|(?<n1>..........)|(?<n1>...........)|(?<n1>............)|(?<n1>.............)|(?<n1>..............))\\k<n1>$", "xxxxabcdefghijklmnabcdefghijklmn", 4, 18, 14);
+	x3("(?<name1>)(?<name2>)(?<name3>)(?<name4>)(?<name5>)(?<name6>)(?<name7>)(?<name8>)(?<name9>)(?<name10>)(?<name11>)(?<name12>)(?<name13>)(?<name14>)(?<name15>)(?<name16>aaa)(?<name17>)$", "aaa", 0, 3, 16);
+	x2("(?<foo>a|\\(\\g<foo>\\))", "a", 0, 1);
+	x2("(?<foo>a|\\(\\g<foo>\\))", "((((((a))))))", 0, 13);
+	x3("(?<foo>a|\\(\\g<foo>\\))", "((((((((a))))))))", 0, 17, 1);
+	x2("\\g<bar>|\\zEND(?<bar>.*abc$)", "abcxxxabc", 0, 9);
+	x2("\\g<1>|\\zEND(.a.)", "bac", 0, 3);
+	x3("\\g<_A>\\g<_A>|\\zEND(.a.)(?<_A>.b.)", "xbxyby", 3, 6, 1);
+	x2("\\A(?:\\g<pon>|\\g<pan>|\\zEND  (?<pan>a|c\\g<pon>c)(?<pon>b|d\\g<pan>d))$", "cdcbcdc", 0, 7);
+	x2("\\A(?<n>|a\\g<m>)\\z|\\zEND (?<m>\\g<n>)", "aaaa", 0, 4);
+	x2("(?<n>(a|b\\g<n>c){3,5})", "baaaaca", 1, 5);
+	x2("(?<n>(a|b\\g<n>c){3,5})", "baaaacaaaaa", 0, 10);
+	x2("(?<pare>\\(([^\\(\\)]++|\\g<pare>)*+\\))", "((a))", 0, 5);
+	x2("()*\\1", "", 0, 0);
+	x2("(?:()|())*\\1\\2", "", 0, 0);
+	x3("(?:\\1a|())*", "a", 0, 0, 1);
+	x2("x((.)*)*x", "0x1x2x3", 1, 6);
+	x2("x((.)*)*x(?i:\\1)\\Z", "0x1x2x1X2", 1, 9);
+	x2("(?:()|()|()|()|()|())*\\2\\5", "", 0, 0);
+	x2("(?:()|()|()|(x)|()|())*\\2b\\5", "b", 0, 1);
+	x2("\217\372\000\000", "\217\372\000\000", 0, 3);
+	x2("", "ã", 0, 0);
+	x2("ã", "ã", 0, 3);
+	n("ã", "ã");
+	x2("ãã", "ãã", 0, 6);
+	x2("ããã", "ããã", 0, 9);
+	x2("ããããããããããããããããããããããããããããããããããã", "ããããããããããããããããããããããããããããããããããã", 0, 105);
+	x2("ã", "ãã", 3, 6);
+	x2("ãã", "ããã", 3, 9);
+	x2("e\207\000\000", "e\207\000\000", 0, 3);
+	x2(".", "ã", 0, 3);
+	x2("..", "ãã", 0, 6);
+	x2("(?u)\\w", "ã", 0, 3);
+	n("(?u)\\W", "ã");
+	x2("(?u)[\\W]", "ã$", 3, 4);
+	x2("\\S", "ã", 0, 3);
+	x2("\\S", "æ¼¢", 0, 3);
+	x2("\\b", "æ° ", 0, 0);
+	x2("\\b", " ã»", 1, 1);
+	x2("\\B", "ãã ", 3, 3);
+	x2("\\B", "ã ", 4, 4);
+	x2("\\B", " ã", 0, 0);
+	x2("[ãã¡]", "ã¡", 0, 3);
+	n("[ãªã«]", "ã¬");
+	x2("[ã-ã]", "ã", 0, 3);
+	n("[^ã]", "ã");
+	x2("(?u)[\\w]", "ã­", 0, 3);
+	n("[\\d]", "ãµ");
+	x2("[\\D]", "ã¯", 0, 3);
+	n("[\\s]", "ã");
+	x2("[\\S]", "ã¸", 0, 3);
+	x2("(?u)[\\w\\d]", "ã", 0, 3);
+	x2("(?u)[\\w\\d]", "   ã", 3, 6);
+	n("(?u)\\wé¬¼è»", " é¬¼è»");
+	x2("(?u)é¬¼\\Wè»", "é¬¼ è»", 0, 7);
+	x2("ã.ã.ã", "ããããã", 0, 15);
+	x2("(?u).\\wã\\W..ã", "ããã ããã", 0, 19);
+	x2("(?u)\\s\\wããã", " ãããã", 0, 13);
+	x2("ãã.ã", "ãããã", 0, 12);
+	n(".ã", "ãã");
+	x2(".ã", "ãã", 0, 6);
+	x2("^ã", "ã", 0, 3);
+	x2("^ã$", "ã", 0, 3);
+	x2("(?u)^\\w$", "ã«", 0, 3);
+	x2("(?u)^\\wããããã$", "zããããã", 0, 16);
+	x2("(?u)^\\w...ããã$", "zãããããã", 0, 19);
+	x2("(?u)\\w\\w\\s\\Wããã\\d", "aã  ããã4", 0, 16);
+	x2("\\Aãã¡ã¤", "ãã¡ã¤", 0, 9);
+	x2("ããã\\Z", "ããã", 0, 9);
+	x2("ããã\\z", "ããã", 0, 9);
+	x2("ããã\\Z", "ããã\n", 0, 9);
+	x2("\\Gã½ã´", "ã½ã´", 0, 6);
+	n("\\Gã", "ããã");
+	n("ã¨ã¦\\G", "ã¨ã¦");
+	n("ã¾ã¿\\A", "ã¾ã¿");
+	n("ã¾\\Aã¿", "ã¾ã¿");
+	x2("(?=ã)ã", "ã", 0, 3);
+	n("(?=ã).", "ã");
+	x2("(?!ã)ã", "ã", 0, 3);
+	n("(?!ã¨)ã", "ã¨");
+	x2("(?i:ã)", "ã", 0, 3);
+	x2("(?i:ã¶ã¹)", "ã¶ã¹", 0, 6);
+	n("(?i:ã)", "ã");
+	x2("(?m:ã.)", "ã\n", 0, 4);
+	x2("(?m:.ã)", "ã¾\nã", 3, 7);
+	x2("ã?", "", 0, 0);
+	x2("å¤?", "å", 0, 0);
+	x2("å¤?", "å¤", 0, 3);
+	x2("é*", "", 0, 0);
+	x2("é*", "é", 0, 3);
+	x2("å­*", "å­å­å­", 0, 9);
+	x2("é¦¬*", "é¹¿é¦¬é¦¬é¦¬é¦¬", 0, 0);
+	n("å±±+", "");
+	x2("æ²³+", "æ²³", 0, 3);
+	x2("æ+", "ææææ", 0, 12);
+	x2("ã+", "ããããã", 0, 6);
+	x2("ã+", "ããããã", 3, 15);
+	x2(".?", "ã", 0, 3);
+	x2(".*", "ã±ã´ã·ãº", 0, 12);
+	x2(".+", "ã", 0, 3);
+	x2(".+", "ãããã\n", 0, 12);
+	x2("ã|ã", "ã", 0, 3);
+	x2("ã|ã", "ã", 0, 3);
+	x2("ãã|ãã", "ãã", 0, 6);
+	x2("ãã|ãã", "ãã", 0, 6);
+	x2("ã(?:ãã|ãã)", "ããã", 0, 9);
+	x2("ã(?:ãã|ãã)ã", "ãããã", 0, 12);
+	x2("ãã|(?:ãã|ãã)", "ãã", 0, 6);
+	x2("ã|ã|ã", "ãã", 3, 6);
+	x2("ã|ã|ãã|ããã|ã|ããã|ããã|ã|ãã¡|ã¤ã¦ã¨ãªã«|ã¬ã­", "ããã", 0, 9);
+	n("ã|ã|ãã|ããã|ã|ããã|ããã|ã|ãã¡|ã¤ã¦ã¨ãªã«|ã¬ã­", "ãã");
+	x2("ã|^ã", "ã¶ã", 3, 6);
+	x2("ã|^ã", "ãã", 0, 3);
+	x2("é¬¼|\\Gè»", "ãè»é¬¼", 6, 9);
+	x2("é¬¼|\\Gè»", "è»é¬¼", 0, 3);
+	x2("é¬¼|\\Aè»", "bè»é¬¼", 4, 7);
+	x2("é¬¼|\\Aè»", "è»", 0, 3);
+	x2("é¬¼|è»\\Z", "è»é¬¼", 3, 6);
+	x2("é¬¼|è»\\Z", "è»", 0, 3);
+	x2("é¬¼|è»\\Z", "è»\n", 0, 3);
+	x2("é¬¼|è»\\z", "è»é¬¼", 3, 6);
+	x2("é¬¼|è»\\z", "è»", 0, 3);
+	x2("(?u)\\w|\\s", "ã", 0, 3);
+	x2("(?u)\\w|%", "%ã", 0, 1);
+	x2("(?u)\\w|[&$]", "ã&", 0, 3);
+	x2("[ã-ã]", "ã", 0, 3);
+	x2("[ã-ã]|[^ã-ã]", "ã", 0, 3);
+	x2("[ã-ã]|[^ã-ã]", "ã", 0, 3);
+	x2("[^ã]", "\n", 0, 1);
+	x2("(?:ã|[ã-ã])|ãã", "ãã", 0, 3);
+	x2("(?:ã|[ã-ã])|ãã", "ãã", 0, 6);
+	x2("ããã|(?=ãã)..ã»", "ããã»", 0, 9);
+	x2("ããã|(?!ãã)..ã»", "ããã»", 0, 9);
+	x2("(?=ãã)..ã|(?=ãã)..ã", "ããã", 0, 9);
+	x2("(?<=ã|ãã)ã", "ããã", 6, 9);
+	n("(?>ã|ããã)ã", "ãããã");
+	x2("(?>ããã|ã)ã", "ãããã", 0, 12);
+	x2("ã?|ã", "ã", 0, 3);
+	x2("ã?|ã", "ã", 0, 0);
+	x2("ã?|ã", "", 0, 0);
+	x2("ã*|ã", "ãã", 0, 6);
+	x2("ã*|ã*", "ãã", 0, 0);
+	x2("ã*|ã*", "ãã", 0, 3);
+	x2("[aã]*|ã*", "aãããã", 0, 4);
+	x2("ã+|ã*", "", 0, 0);
+	x2("ã+|ã*", "ããã", 0, 9);
+	x2("ã+|ã*", "ãããã", 0, 3);
+	x2("ã+|ã*", "aãããã", 0, 0);
+	n("ã+|ã+", "");
+	x2("(ã|ã)?", "ã", 0, 3);
+	x2("(ã|ã)*", "ãã", 0, 6);
+	x2("(ã|ã)+", "ããã", 0, 9);
+	x2("(ãã|ãã)+", "ãããããã", 0, 12);
+	x2("(ãã|ãã)+", "ãããããã", 6, 18);
+	x2("(ãã|ãã)+", "ããããã", 3, 15);
+	x2("(ãã|ãã)+", "ããããã", 0, 6);
+	x2("(ãã|ãã)+", "$$zzzzããããã", 6, 12);
+	x2("(ã|ããã)+", "ããããã", 0, 15);
+	x2("(ã|ããã)+", "ãã", 3, 6);
+	x2("(ã|ããã)+", "ãããããã", 3, 12);
+	x2("(?:ã|ã)(?:ã|ã)", "ãã", 0, 6);
+	x2("(?:ã*|ã*)(?:ã*|ã*)", "ãããããã", 0, 9);
+	x2("(?:ã*|ã*)(?:ã+|ã+)", "ãããããã", 0, 18);
+	x2("(?:ã+|ã+){2}", "ãããããã", 0, 18);
+	x2("(?:ã+|ã+){1,2}", "ãããããã", 0, 18);
+	x2("(?:ã+|\\Aã*)ãã", "ãã", 0, 6);
+	n("(?:ã+|\\Aã*)ãã", "ãããã");
+	x2("(?:^ã+|ã+)*ã", "ãããããããã", 18, 24);
+	x2("(?:^ã+|ã+)*ã", "ããããããã", 0, 21);
+	x2("ã{0,}", "ãããã", 0, 12);
+	x2("ã|(?i)c", "C", 0, 1);
+	x2("(?i)c|ã", "C", 0, 1);
+	x2("(?i:ã)|a", "a", 0, 1);
+	n("(?i:ã)|a", "A");
+	x2("[ããã]?", "ããã", 0, 3);
+	x2("[ããã]*", "ããã", 0, 9);
+	x2("[^ããã]*", "ããã", 0, 0);
+	n("[^ããã]+", "ããã");
+	x2("ã?\?", "ããã", 0, 0);
+	x2("ãã?\?ã", "ããã", 0, 9);
+	x2("ã*?", "ããã", 0, 0);
+	x2("ãã*?", "ããã", 0, 3);
+	x2("ãã*?ã", "ãããã", 0, 12);
+	x2("ã+?", "ããã", 0, 3);
+	x2("ãã+?", "ããã", 0, 6);
+	x2("ãã+?ã", "ãããã", 0, 12);
+	x2("(?:å¤©?)?\?", "å¤©", 0, 0);
+	x2("(?:å¤©?\?)?", "å¤©", 0, 0);
+	x2("(?:å¤¢?)+?", "å¤¢å¤¢å¤¢", 0, 3);
+	x2("(?:é¢¨+)?\?", "é¢¨é¢¨é¢¨", 0, 0);
+	x2("(?:éª+)?\?é", "éªéªéªé", 0, 12);
+	x2("(?:ãã)?{2}", "", 0, 0);
+	x2("(?:é¬¼è»)?{2}", "é¬¼è»é¬¼è»é¬¼", 0, 12);
+	x2("(?:é¬¼è»)*{0}", "é¬¼è»é¬¼è»é¬¼", 0, 0);
+	x2("(?:é¬¼è»){3,}", "é¬¼è»é¬¼è»é¬¼è»é¬¼è»", 0, 24);
+	n("(?:é¬¼è»){3,}", "é¬¼è»é¬¼è»");
+	x2("(?:é¬¼è»){2,4}", "é¬¼è»é¬¼è»é¬¼è»", 0, 18);
+	x2("(?:é¬¼è»){2,4}", "é¬¼è»é¬¼è»é¬¼è»é¬¼è»é¬¼è»", 0, 24);
+	x2("(?:é¬¼è»){2,4}?", "é¬¼è»é¬¼è»é¬¼è»é¬¼è»é¬¼è»", 0, 12);
+	x2("(?:é¬¼è»){,}", "é¬¼è»{,}", 0, 9);
+	x2("(?:ããã)+?{2}", "ããããããããã", 0, 18);
+	x3("(ç«)", "ç«", 0, 3, 1);
+	x3("(ç«æ°´)", "ç«æ°´", 0, 6, 1);
+	x2("((æé))", "æé", 0, 6);
+	x3("((é¢¨æ°´))", "é¢¨æ°´", 0, 6, 1);
+	x3("((æ¨æ¥))", "æ¨æ¥", 0, 6, 2);
+	x3("((((((((((((((((((((éå­))))))))))))))))))))", "éå­", 0, 6, 20);
+	x3("(ãã)(ãã)", "ãããã", 0, 6, 1);
+	x3("(ãã)(ãã)", "ãããã", 6, 12, 2);
+	x3("()(ã)ãã(ããã)ãããã", "ãããããããããã", 9, 18, 3);
+	x3("(()(ã)ãã(ããã)ãããã)", "ãããããããããã", 9, 18, 4);
+	x3(".*(ãã©)ã³ã»ã(ã³()ã·ã¥ã¿)ã¤ã³", "ãã©ã³ã»ãã³ã·ã¥ã¿ã¤ã³", 15, 27, 2);
+	x2("(^ã)", "ã", 0, 3);
+	x3("(ã)|(ã)", "ãã", 3, 6, 1);
+	x3("(^ã)|(ã)", "ãã", 3, 6, 2);
+	x3("(ã?)", "ããã", 0, 3, 1);
+	x3("(ã¾*)", "ã¾ã¾ã¾", 0, 9, 1);
+	x3("(ã¨*)", "", 0, 0, 1);
+	x3("(ã+)", "ããããããã", 0, 21, 1);
+	x3("(ãµ+|ã¸*)", "ãµãµãµã¸ã¸", 0, 9, 1);
+	x3("(ã+|ã?)", "ããããã", 0, 3, 1);
+	x3("(ããã)?", "ããã", 0, 9, 1);
+	x3("(ããã)*", "ããã", 0, 9, 1);
+	x3("(ããã)+", "ããã", 0, 9, 1);
+	x3("(ããã|ããã)+", "ããã", 0, 9, 1);
+	x3("([ãªã«ã¬][ããã]|ããã)+", "ããã", 0, 9, 1);
+	x3("((?i:ããã))", "ããã", 0, 9, 1);
+	x3("((?m:ã.ã))", "ã\nã", 0, 7, 1);
+	x3("((?=ãã)ã)", "ããã", 0, 3, 1);
+	x3("ããã|(.ããã)", "ãããã", 0, 12, 1);
+	x3("ã*(.)", "ããããã", 12, 15, 1);
+	x3("ã*?(.)", "ããããã", 0, 3, 1);
+	x3("ã*?(ã)", "ããããã", 12, 15, 1);
+	x3("[ããã]ã*(.)", "ãããããã", 15, 18, 1);
+	x3("(\\Aãã)ãã", "ãããã", 0, 6, 1);
+	n("(\\Aãã)ãã", "ããããã");
+	x3("(^ãã)ãã", "ãããã", 0, 6, 1);
+	n("(^ãã)ãã", "ããããã");
+	x3("ãã(ãã$)", "ãããã", 6, 12, 1);
+	n("ãã(ãã$)", "ããããã");
+	x2("(ç¡)\\1", "ç¡ç¡", 0, 6);
+	n("(ç¡)\\1", "ç¡æ­¦");
+	x2("(ç©º?)\\1", "ç©ºç©º", 0, 6);
+	x2("(ç©º?\?)\\1", "ç©ºç©º", 0, 0);
+	x2("(ç©º*)\\1", "ç©ºç©ºç©ºç©ºç©º", 0, 12);
+	x3("(ç©º*)\\1", "ç©ºç©ºç©ºç©ºç©º", 0, 6, 1);
+	x2("ã(ã*)\\1", "ããããã", 0, 15);
+	x2("ã(ã*)\\1", "ãã", 0, 3);
+	x2("(ã*)(ã*)\\1\\2", "ãããããããããã", 0, 30);
+	x2("(ã*)(ã*)\\2", "ããããããã", 0, 21);
+	x3("(ã*)(ã*)\\2", "ããããããã", 9, 15, 2);
+	x2("(((((((ã½*)ãº))))))ã´\\7", "ã½ã½ã½ãºã´ã½ã½ã½", 0, 24);
+	x3("(((((((ã½*)ãº))))))ã´\\7", "ã½ã½ã½ãºã´ã½ã½ã½", 0, 9, 7);
+	x2("(ã¯)(ã²)(ãµ)\\2\\1\\3", "ã¯ã²ãµã²ã¯ãµ", 0, 18);
+	x2("([ã-ã])\\1", "ãã", 0, 6);
+	x2("(?u)(\\w\\d\\s)\\1", "ã5 ã5 ", 0, 10);
+	n("(?u)(\\w\\d\\s)\\1", "ã5 ã5");
+	x2("(èª°ï¼|[ã-ã]{3})\\1", "èª°ï¼èª°ï¼", 0, 12);
+	x2("...(èª°ï¼|[ã-ã]{3})\\1", "ãaãèª°ï¼èª°ï¼", 0, 19);
+	x2("(èª°ï¼|[ã-ã]{3})\\1", "ãããããã", 0, 18);
+	x2("(^ã)\\1", "ãã", 0, 6);
+	n("(^ã)\\1", "ããã");
+	n("(ã$)\\1", "ãã");
+	n("(ãã\\Z)\\1", "ãã");
+	x2("(ã*\\Z)\\1", "ã", 3, 3);
+	x2(".(ã*\\Z)\\1", "ãã", 3, 6);
+	x3("(.(ããã)\\2)", "zãããããã", 0, 19, 1);
+	x3("(.(..\\d.)\\2)", "ã12341234", 0, 11, 1);
+	x2("((?i:ãvã))\\1", "ãvããvã", 0, 14);
+	x2("(?<æã>å¤|\\(\\g<æã>\\))", "((((((å¤))))))", 0, 15);
+	x2("\\A(?:\\g<é¿_1>|\\g<äº_2>|\\zçµäº  (?<é¿_1>è¦³|èª\\g<äº_2>èª)(?<äº_2>å¨|è©è©\\g<é¿_1>è©è©))$", "è©è©èªè©è©èªå¨èªè©è©èªè©è©", 0, 39);
+	x2("[[ã²ãµ]]", "ãµ", 0, 3);
+	x2("[[ããã]ã]", "ã", 0, 3);
+	n("[[^ã]]", "ã");
+	n("[^[ã]]", "ã");
+	x2("[^[^ã]]", "ã", 0, 3);
+	x2("[[ããã]&&ãã]", "ã", 0, 3);
+	n("[[ããã]&&ãã]", "ã");
+	n("[[ããã]&&ãã]", "ã");
+	x2("[ã-ã&&ã-ã&&ã-ã]", "ã", 0, 3);
+	n("[^ã-ã&&ã-ã&&ã-ã]", "ã");
+	x2("[[^ã&&ã]&&ã-ã]", "ã", 0, 3);
+	n("[[^ã&&ã]&&ã-ã]", "ã");
+	x2("[[^ã-ã&&ãããã]&&[^ã-ã]]", "ã", 0, 3);
+	n("[[^ã-ã&&ãããã]&&[^ã-ã]]", "ã");
+	x2("[^[^ããã]&&[^ããã]]", "ã", 0, 3);
+	x2("[^[^ããã]&&[^ããã]]", "ã", 0, 3);
+	n("[^[^ããã]&&[^ããã]]", "ã");
+	x2("[ã-&&-ã]", "-", 0, 1);
+	x2("[^[^a-zããã]&&[^bcdefgããã]q-w]", "ã", 0, 3);
+	x2("[^[^a-zããã]&&[^bcdefgããã]g-w]", "f", 0, 1);
+	x2("[^[^a-zããã]&&[^bcdefgããã]g-w]", "g", 0, 1);
+	n("[^[^a-zããã]&&[^bcdefgããã]g-w]", "2");
+	x2("a<b>ãã¼ã¸ã§ã³ã®ãã¦ã³ã­ã¼ã<\\/b>", "a<b>ãã¼ã¸ã§ã³ã®ãã¦ã³ã­ã¼ã</b>", 0, 44);
+	x2(".<b>ãã¼ã¸ã§ã³ã®ãã¦ã³ã­ã¼ã<\\/b>", "a<b>ãã¼ã¸ã§ã³ã®ãã¦ã³ã­ã¼ã</b>", 0, 44);
+	fprintf(stdout,
+		"\nRESULT   SUCC: %d,  FAIL: %d,  ERROR: %d      (by Onigmo %s)\n",
+		nsucc, nfail, nerror, onig_version());
+
+#ifndef POSIX_TEST
+	onig_region_free(region, 1);
+	onig_end();
+#endif
+
+	return ((nfail == 0 && nerror == 0) ? 0 : -1);
+}
Index: nlProtoTool/trunk/prototool/src/route_cfg.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/route_cfg.c	(revision 278)
+++ 	(revision )
@@ -1,113 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  ä¸è¨èä½æ¨©è
-ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
- *  ã«ãã£ã¦å
-¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
- *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
- *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
-å¸ï¼ä»¥ä¸ï¼
- *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
- *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
- *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
- *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
- *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
- *      è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
- *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããªãå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
- *    (a) åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
- *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
- *      å®³ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ããå
-è²¬ãããã¨ï¼
- *
- *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
-ã
- *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
- *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
- *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
- * 
- *  @(#) $Id$
- */
-
-/* 
- *  ã«ã¼ãã£ã³ã°è¡¨
- */
-
-#include <kernel.h>
-
-#include <tinet_defs.h>
-#include <tinet_config.h>
-
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-
-/* IPv4 ã«é¢ããå®ç¾© */
-
-#ifdef SUPPORT_INET4
-
-#ifdef SUPPORT_LOOP
-
-T_IN4_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = {
-	{ 0, 0, 0 },
-	};
-
-#endif	/* of #ifdef SUPPORT_LOOP */
-
-#ifdef SUPPORT_PPP
-
-T_IN4_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = {
-	{ 0, 0, 0 },
-	};
-
-#endif	/* of #ifdef SUPPORT_PPP */
-
-#ifdef SUPPORT_ETHER
-
-T_IN4_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = {
-
-	/* ç°ãªã LANãdefault gateway ã«ããéæ¥é
-é	*/
-	{ 0,			0,			IPV4_ADDR_DEFAULT_GW	},
-
-	/* åä¸ LAN å
-ãç´æ¥é
-é				*/
-	{ IPV4_ADDR_LOCAL &
-	  IPV4_ADDR_LOCAL_MASK,	IPV4_ADDR_LOCAL_MASK,	0			},
-
-	/* åä¸ LAN å
-ã¸ã®ãã­ã¼ãã­ã£ã¹ããç´æ¥é
-é	*/
-	{ 0xffffffff,		0xffffffff,		0			},
-
-	};
-
-#endif	/* of #ifdef SUPPORT_ETHER */
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-/* IPv6 ã«é¢ããå®ç¾© */
-
-#ifdef SUPPORT_INET6
-
-#if NUM_ROUTE_ENTRY > 0
-
-T_IN6_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = { };
-
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
-
-#endif	/* of #ifdef SUPPORT_INET6 */
Index: /EcnlProtoTool/trunk/prototool/src/shellif.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/shellif.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/shellif.c	(revision 279)
@@ -0,0 +1,708 @@
+#include <setjmp.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/select.h>
+#include <poll.h>
+#include <stdarg.h>
+#include "shellif.h"
+#include "analogin_api.h"
+#include "gpio_api.h"
+#include "i2c_api.h"
+#include "pwmout_api.h"
+#include "rtc_api.h"
+#include "serial_api.h"
+#include "us_ticker_api.h"
+#include "wait_api.h"
+#include "arduino.h"
+#include "usrcmd.h"
+#include <sys/mman.h>
+#include <signal.h>
+
+typedef struct __dirstream DIR;
+
+typedef void (*analogin_init_t)(analogin_t *obj, PinName pin);
+typedef uint16_t (*analogin_read_u16_t)(analogin_t *obj);
+typedef void (*gpio_init_t)(gpio_t *obj, PinName pin);
+typedef void (*gpio_dir_t)(gpio_t *obj, PinDirection direction);
+typedef int (*i2c_start_t)(i2c_t *obj);
+typedef int (*i2c_stop_t)(i2c_t *obj);
+typedef void (*i2c_init_t)(i2c_t *obj, PinName sda, PinName scl);
+typedef int (*i2c_read_t)(i2c_t *obj, int address, char *data, int length, int stop);
+typedef int (*i2c_write_t)(i2c_t *obj, int address, const char *data, int length, int stop);
+typedef int (*i2c_byte_read_t)(i2c_t *obj, int last);
+typedef int (*i2c_byte_write_t)(i2c_t *obj, int data);
+typedef void (*pwmout_free_t)(pwmout_t* obj);
+typedef void (*pwmout_init_t)(pwmout_t* obj, PinName pin);
+typedef void (*pwmout_pulsewidth_us_t)(pwmout_t* obj, int us);
+typedef void (*rtc_init_t)(void);
+typedef void (*rtc_free_t)(void);
+typedef int (*rtc_isenabled_t)(void);
+typedef time_t (*rtc_read_t)(void);
+typedef void (*rtc_write_t)(time_t t);
+typedef void (*serial_baud_t)(serial_t *obj, int baudrate);
+typedef void (*serial_init_t)(serial_t *obj, PinName tx, PinName rx);
+typedef int (*serial_readable_t)(serial_t *obj);
+typedef int (*serial_getc_t)(serial_t *obj);
+typedef void (*serial_putc_t)(serial_t *obj, int c);
+typedef uint32_t (*us_ticker_read_t)(void);
+typedef void (*wait_ms_t)(int ms);
+typedef bool (*SD_begin_t)();
+typedef int (*usrcmd_cd_t)(int argc, char **argv);
+typedef int (*usrcmd_ls_t)(int argc, char **argv);
+typedef int (*usrcmd_cp_t)(int argc, char **argv);
+typedef int (*usrcmd_rm_t)(int argc, char **argv);
+typedef int (*usrcmd_mv_t)(int argc, char **argv);
+typedef int (*usrcmd_mkdir_t)(int argc, char **argv);
+typedef int (*usrcmd_hexdump_t)(int argc, char **argv);
+typedef int (*usrcmd_info_t)(int argc, char **argv);
+typedef int (*usrcmd_exit_t)(int argc, char **argv);
+typedef void(*shell_abort_t)();
+typedef void(*shell_exit_t)(int exitcd);
+typedef int (*shell_kill_t)(int pid, int sig);
+typedef int (*shell_gettimeofday_t)(struct timeval * tp, void * tzvp);
+typedef void (*vsyslog_t)(int priority, const char *format, va_list ap);
+typedef int (*shell_open_t)(const char * path, int flags);
+typedef int (*shell_close_t)(int fd);
+typedef int (*shell_read_t)(int fd, char *data, int len);
+typedef int (*shell_write_t)(int fd, char *data, int len);
+typedef int (*shell_lseek_t)(int fd, int ptr, int dir);
+typedef int (*shell_fstat_t)(int fd, struct stat * st);
+typedef int (*shell_stat_t)(const char *fname, struct stat *st);
+typedef int (*shell_link_t)(void);
+typedef int (*shell_unlink_t)(const char *path);
+typedef int (*shell_isatty_t)(int fd);
+typedef int (*fsync_t)(int fd);
+typedef int (*ftruncate_t)(int fd, off_t length);
+typedef int (*ioctl_t)(int fd, int request, va_list ap);
+typedef int (*tcgetattr_t)(int fd, struct termios *termios_p);
+typedef int (*tcsetattr_t)(int fd, int optional_actions, const struct termios *termios_p);
+typedef int (*shell_rename_t)(const char *oldpath, const char *newpath);
+typedef int (*rmdir_t)(const char *path);
+typedef int (*mkdir_t)(const char *path, mode_t mode);
+typedef int (*chmod_t)(const char *path, mode_t mode);
+typedef char *(*getcwd_t)(char *buf, size_t size);
+typedef int (*chdir_t)(const char *path);
+typedef int (*chroot_t)(const char *path);
+typedef int (*closedir_t)(DIR *dir);
+typedef DIR *(*opendir_t)(const char *path);
+typedef struct dirent *(*readdir_t)(DIR *dir);
+typedef void (*rewinddir_t)(DIR *dir);
+typedef void (*seekdir_t)(DIR *dir, long pos);
+typedef long (*telldir_t)(DIR *dir);
+typedef int (*shell_getpid_t)();
+typedef int (*socket_t)(int family, int type, int protocol);
+typedef int (*bind_t)(int fd, const struct sockaddr *addr, socklen_t len);
+typedef int (*listen_t)(int fd, int backlog);
+typedef int (*connect_t)(int fd, const struct sockaddr *addr, socklen_t len);
+typedef int (*accept_t)(int fd, struct sockaddr *addr, socklen_t *len);
+typedef ssize_t (*send_t)(int fd, const void *buf, size_t len, int flags);
+typedef ssize_t (*sendto_t)(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen);
+typedef ssize_t (*recv_t)(int fd, void *buf, size_t len, int flags);
+typedef ssize_t (*recvfrom_t)(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen);
+typedef int (*shutdown_t)(int fd, int how);
+typedef int (*getsockopt_t)(int fd, int level, int optname, void *optval, socklen_t *optlen);
+typedef int (*setsockopt_t)(int fd, int level, int optname, const void *optval, socklen_t optlen);
+typedef int (*select_t)(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
+typedef int (*poll_t)(struct pollfd *fds, nfds_t nfds, int timeout);
+typedef int (*gethostname_t)(char *name, size_t len);
+typedef int (*getnameinfo_t)(const struct sockaddr *sa, socklen_t sl, char *node, socklen_t nodelen, char *serv, socklen_t servlen, int flags);
+typedef int (*getpeername_t)(int fd, struct sockaddr *addr, socklen_t *len);
+typedef int (*getsockname_t)(int fd, struct sockaddr *addr, socklen_t *len);
+typedef int (*socketpair_t)(int family, int type, int protocol, int fd[2]);
+
+void analogin_init(analogin_t *obj, PinName pin)
+{
+	__imp_analogin_init(obj, pin);
+}
+
+uint16_t analogin_read_u16(analogin_t *obj)
+{
+	return __imp_analogin_read_u16(obj);
+}
+
+void gpio_init(gpio_t *obj, PinName pin)
+{
+	__imp_gpio_init(obj, pin);
+}
+
+void gpio_dir(gpio_t *obj, PinDirection direction)
+{
+	__imp_gpio_dir(obj, direction);
+}
+
+int i2c_start(i2c_t *obj)
+{
+	return __imp_i2c_start(obj);
+}
+
+int i2c_stop(i2c_t *obj)
+{
+	return __imp_i2c_stop(obj);
+}
+
+void i2c_init(i2c_t *obj, PinName sda, PinName scl)
+{
+	__imp_i2c_init(obj, sda, scl);
+}
+
+int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
+{
+	return __imp_i2c_read(obj, address, data, length, stop);
+}
+
+int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
+{
+	return __imp_i2c_write(obj, address, data, length, stop);
+}
+
+int i2c_byte_read(i2c_t *obj, int last)
+{
+	return __imp_i2c_byte_read(obj, last);
+}
+
+int i2c_byte_write(i2c_t *obj, int data)
+{
+	return __imp_i2c_byte_write(obj, data);
+}
+
+void pwmout_free(pwmout_t* obj)
+{
+	__imp_pwmout_free(obj);
+}
+
+void pwmout_init(pwmout_t* obj, PinName pin)
+{
+	__imp_pwmout_init(obj, pin);
+}
+
+void pwmout_pulsewidth_us(pwmout_t* obj, int us)
+{
+	__imp_pwmout_pulsewidth_us(obj, us);
+}
+
+void rtc_init(void)
+{
+	__imp_rtc_init();
+}
+
+void rtc_free(void)
+{
+	__imp_rtc_free();
+}
+
+int rtc_isenabled(void)
+{
+	return __imp_rtc_isenabled();
+}
+
+time_t rtc_read(void)
+{
+	return __imp_rtc_read();
+}
+
+void rtc_write(time_t t)
+{
+	__imp_rtc_write(t);
+}
+
+void serial_baud(serial_t *obj, int baudrate)
+{
+	__imp_serial_baud(obj, baudrate);
+}
+
+void serial_init(serial_t *obj, PinName tx, PinName rx)
+{
+	__imp_serial_init(obj, tx, rx);
+}
+
+int serial_readable(serial_t *obj)
+{
+	return __imp_serial_readable(obj);
+}
+
+int serial_getc(serial_t *obj)
+{
+	return __imp_serial_getc(obj);
+}
+
+void serial_putc(serial_t *obj, int c)
+{
+	__imp_serial_putc(obj, c);
+}
+
+uint32_t us_ticker_read(void)
+{
+	return __imp_us_ticker_read();
+}
+
+void wait_ms(int ms)
+{
+	__imp_wait_ms(ms);
+}
+
+bool SD_begin()
+{
+	return __imp_SD_begin();
+}
+
+int usrcmd_cd(int argc, char **argv)
+{
+	return __imp_usrcmd_cd(argc, argv);
+}
+
+int usrcmd_ls(int argc, char **argv)
+{
+	return __imp_usrcmd_ls(argc, argv);
+}
+
+int usrcmd_cp(int argc, char **argv)
+{
+	return __imp_usrcmd_cp(argc, argv);
+}
+
+int usrcmd_rm(int argc, char **argv)
+{
+	return __imp_usrcmd_rm(argc, argv);
+}
+
+int usrcmd_mv(int argc, char **argv)
+{
+	return __imp_usrcmd_mv(argc, argv);
+}
+
+int usrcmd_mkdir(int argc, char **argv)
+{
+	return __imp_usrcmd_mkdir(argc, argv);
+}
+
+int usrcmd_hexdump(int argc, char **argv)
+{
+	return __imp_usrcmd_hexdump(argc, argv);
+}
+
+int usrcmd_info(int argc, char **argv)
+{
+	return __imp_usrcmd_info(argc, argv);
+}
+
+int usrcmd_exit(int argc, char **argv)
+{
+	return __imp_usrcmd_exit(argc, argv);
+}
+
+void abort()
+{
+	__imp_shell_abort();
+}
+
+void _exit(int exitcd)
+{
+	__imp_shell_exit(exitcd);
+}
+
+int _kill(int pid, int sig)
+{
+	return __imp_shell_kill(pid, sig);
+}
+
+int _gettimeofday(struct timeval * tp, void * tzvp)
+{
+	return __imp_shell_gettimeofday(tp, tzvp);
+}
+
+void vsyslog(int priority, const char *format, va_list ap)
+{
+	__imp_vsyslog(priority, format, ap);
+}
+
+void syslog(int priority, const char *format, ...)
+{
+	va_list ap;
+	va_start(ap, format);
+	vsyslog(priority, format, ap);
+	va_end(ap);
+}
+
+int _open(const char * path, int flags)
+{
+	return __imp_shell_open(path, flags);
+}
+
+int _close(int fd)
+{
+	return __imp_shell_close(fd);
+}
+
+int _read(int fd, char *data, int len)
+{
+	return __imp_shell_read(fd, data, len);
+}
+
+int _write(int fd, char *data, int len)
+{
+	return __imp_shell_write(fd, data, len);
+}
+
+int _lseek(int fd, int ptr, int dir)
+{
+	return __imp_shell_lseek(fd, ptr, dir);
+}
+
+int _fstat(int fd, struct stat * st)
+{
+	return __imp_shell_fstat(fd, st);
+}
+
+int _stat(const char *fname, struct stat *st)
+{
+	return __imp_shell_stat(fname, st);
+}
+
+int _link(void)
+{
+	return __imp_shell_link();
+}
+
+int _unlink(const char *path)
+{
+	return __imp_shell_unlink(path);
+}
+
+int _isatty(int fd)
+{
+	return __imp_shell_isatty(fd);
+}
+
+int fsync(int fd)
+{
+	return __imp_fsync(fd);
+}
+
+int ftruncate(int fd, off_t length)
+{
+	return __imp_ftruncate(fd, length);
+}
+
+int ioctl(int fd, int request, ...)
+{
+	int result;
+	va_list ap;
+	va_start(ap, request);
+	result = __imp_ioctl(fd, request, ap);
+	va_end(ap);
+	return result;
+}
+
+int tcgetattr(int fd, struct termios *termios_p)
+{
+	return __imp_tcgetattr(fd, termios_p);
+}
+
+int tcsetattr(int fd, int optional_actions, const struct termios *termios_p)
+{
+	return __imp_tcsetattr(fd, optional_actions, termios_p);
+}
+
+int _rename(const char *oldpath, const char *newpath)
+{
+	return __imp_shell_rename(oldpath, newpath);
+}
+
+int rmdir(const char *path)
+{
+	return __imp_rmdir(path);
+}
+
+int mkdir(const char *path, mode_t mode)
+{
+	return __imp_mkdir(path, mode);
+}
+
+int chmod(const char *path, mode_t mode)
+{
+	return __imp_chmod(path, mode);
+}
+
+char *getcwd(char *buf, size_t size)
+{
+	return __imp_getcwd(buf, size);
+}
+
+int chdir(const char *path)
+{
+	return __imp_chdir(path);
+}
+
+int chroot(const char *path)
+{
+	return __imp_chroot(path);
+}
+
+int closedir(DIR *dir)
+{
+	return __imp_closedir(dir);
+}
+
+DIR *opendir(const char *path)
+{
+	return __imp_opendir(path);
+}
+
+struct dirent *readdir(DIR *dir)
+{
+	return __imp_readdir(dir);
+}
+
+void rewinddir(DIR *dir)
+{
+	__imp_rewinddir(dir);
+}
+
+void seekdir(DIR *dir, long pos)
+{
+	__imp_seekdir(dir, pos);
+}
+
+long telldir(DIR *dir)
+{
+	return __imp_telldir(dir);
+}
+
+int _getpid()
+{
+	return __imp_shell_getpid();
+}
+
+int socket(int family, int type, int protocol)
+{
+	return __imp_socket(family, type, protocol);
+}
+
+int bind(int fd, const struct sockaddr *addr, socklen_t len)
+{
+	return __imp_bind(fd, addr, len);
+}
+
+int listen(int fd, int backlog)
+{
+	return __imp_listen(fd, backlog);
+}
+
+int connect(int fd, const struct sockaddr *addr, socklen_t len)
+{
+	return __imp_connect(fd, addr, len);
+}
+
+int accept(int fd, struct sockaddr *addr, socklen_t *len)
+{
+	return __imp_accept(fd, addr, len);
+}
+
+ssize_t send(int fd, const void *buf, size_t len, int flags)
+{
+	return __imp_send(fd, buf, len, flags);
+}
+
+ssize_t sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
+{
+	return __imp_sendto(fd, buf, len, flags, addr, alen);
+}
+
+ssize_t recv(int fd, void *buf, size_t len, int flags)
+{
+	return __imp_recv(fd, buf, len, flags);
+}
+
+ssize_t recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen)
+{
+	return __imp_recvfrom(fd, buf, len, flags, addr, alen);
+}
+
+int shutdown(int fd, int how)
+{
+	return __imp_shutdown(fd, how);
+}
+
+int getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen)
+{
+	return __imp_getsockopt(fd, level, optname, optval, optlen);
+}
+
+int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
+{
+	return __imp_setsockopt(fd, level, optname, optval, optlen);
+}
+
+int select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+{
+	return __imp_select(n, rfds, wfds, efds, tv);
+}
+
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+	return __imp_poll(fds, nfds, timeout);
+}
+
+unsigned if_nametoindex(const char *name)
+{
+	return 1;
+}
+
+int gethostname(char *name, size_t len)
+{
+	return __imp_gethostname(name, len);
+}
+
+int getnameinfo(const struct sockaddr *sa, socklen_t sl,
+	char *node, socklen_t nodelen,
+	char *serv, socklen_t servlen,
+	int flags)
+{
+	return __imp_getnameinfo(sa, sl, node, nodelen, serv, servlen, flags);
+}
+
+int getpeername(int fd, struct sockaddr *addr, socklen_t *len)
+{
+	return __imp_getpeername(fd, addr, len);
+}
+
+int getsockname(int fd, struct sockaddr *addr, socklen_t *len)
+{
+	return __imp_getsockname(fd, addr, len);
+}
+
+int socketpair(int family, int type, int protocol, int fd[2])
+{
+	return __imp_socketpair(family, type, protocol, fd);
+}
+
+char *basename(char *s)
+{
+	size_t i, j;
+	if (!s || !*s) return ".";
+	i = strlen(s) - 1;
+	for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
+	for (; i&&s[i] == '/'; i--) s[i] = 0;
+	for (; i&&s[i - 1] != '/'; i--);
+	return s + i;
+}
+
+char *dirname(char *_s)
+{
+	char *s = _s;
+	size_t i, j;
+	if (!s || !*s) return ".";
+	i = strlen(s) - 1;
+	for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
+	for (; s[i] == '/'; i--) if (!i) return (s == _s) ? "/" : _s;
+	for (; s[i] != '/'; i--) if (!i) return (s == _s) ? "." : _s;
+	for (; s[i] == '/'; i--) if (!i) if (s == _s) return "/"; else break;
+	s[i + 1] = 0;
+	return _s;
+}
+
+char *realpath(const char *filename, char *resolved)
+{
+	char *path = getcwd(resolved, 256);
+
+	if (path != NULL)
+		strcat(path, filename);
+
+	return path;
+}
+
+uint32_t htonl(uint32_t n)
+{
+	return (n >> 24) | ((n >> 8) & 0xFF00) | ((n << 8) & 0xFF0000) | (n << 24);
+}
+
+uint32_t ntohl(uint32_t n)
+{
+	return (n >> 24) | ((n >> 8) & 0xFF00) | ((n << 8) & 0xFF0000) | (n << 24);
+}
+
+uint16_t htons(uint16_t n)
+{
+	return ((n >> 8) & 0xFF) | ((n << 8) & 0xFF00);
+}
+
+uint16_t ntohs(uint16_t n)
+{
+	return ((n >> 8) & 0xFF) | ((n << 8) & 0xFF00);
+}
+
+int mprotect(void *addr, size_t len, int prot)
+{
+	return 0;
+}
+
+int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
+{
+	return 0;
+}
+
+unsigned int Utf8_to_Utf16(const char *src, int *code_size)
+{
+	int i;
+	unsigned int uc = 0;
+	unsigned char len = 0;
+
+	len = 0;
+	if ((src[0] & 0x80) == 0) { uc = src[0] & 0x7F; len = 0; }
+	else if ((src[0] & 0xE0) == 0xC0) { uc = src[0] & 0x1F; len = 1; }
+	else if ((src[0] & 0xF0) == 0xE0) { uc = src[0] & 0x0F; len = 2; }
+	else if ((src[0] & 0xF8) == 0xF0) { uc = src[0] & 0x07; len = 3; }
+	else if ((src[0] & 0xFC) == 0xF8) { uc = src[0] & 0x03; len = 4; }
+	else if ((src[0] & 0xFE) == 0xFC) { uc = src[0] & 0x01; len = 5; }
+
+	i = 1;
+	while ((i <= len) && ((src[i] & 0xC0) == 0x80)) {
+		uc = (uc << 6) | (src[i] & 0x3F);
+		i++;
+	}
+
+	//Áï¶Ýè
+	*code_size = i;
+
+	//»óA2oCgÀè
+	return uc;
+}
+
+int bs_char_count(char *str, int pos)
+{
+	int num = 1, local_pos = pos;
+	char *c;
+
+	while (1) {
+		c = str + local_pos;
+
+		if ((*c & 0x80) != 0x80)
+			return num;
+
+		if (((*c & 0xE0) == 0xC0) && (num == 2)) {
+			return num;
+		}
+		else if (((*c & 0xF0) == 0xE0) && (num == 3)) {
+			return num;
+		}
+		else if (((*c & 0xF8) == 0xF0) && (num == 4)) {
+			return num;
+		}
+		else if (((*c & 0xFC) == 0xF8) && (num == 5)) {
+			return num;
+		}
+		else if (((*c & 0xFE) == 0xFC) && (num == 6)) {
+			return num;
+		}
+		else {
+			if (local_pos > 0) {
+				local_pos--;
+				num++;
+			}
+			else
+				return 0;
+		}
+	}
+
+	return 0;
+}
Index: nlProtoTool/trunk/prototool/src/tinet_app_config.h
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/tinet_app_config.h	(revision 278)
+++ 	(revision )
@@ -1,681 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  ä¸è¨èä½æ¨©è
-ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
- *  ã«ãã£ã¦å
-¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
- *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
- *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
-å¸ï¼ä»¥ä¸ï¼
- *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
- *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
- *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
- *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
- *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
- *      è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
- *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããªãå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
- *    (a) åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
- *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
- *      å®³ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ããå
-è²¬ãããã¨ï¼
- *
- *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
-ã
- *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
- *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
- *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
- * 
- *  @(#) $Id$
- */
-
-#ifndef _TINET_APP_CONFIG_H_
-#define _TINET_APP_CONFIG_H_
-
-/*
- *  ã¤ã³ã¿ã¼ããããã­ãã³ã«ãã¡ããªã¼ã®ãµãã¼ã
- *
- *    Makefile ã§æå®ãã¦ãè¯ã
- */
-
-/*#define SUPPORT_INET4		TCP/IP,IPv4		*/
-/*#define SUPPORT_INET6		TCP/IP,IPv6		*/
-/*#define SUPPORT_TCP		TCP			*/
-/*#define SUPPORT_UDP		UDP			*/
-
-/*ãã¼ã¿ãªã³ã¯å±¤ã®ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ãé¸æãã	*/
-/*ããããä¸ã¤ã ãé¸æã§ããã				*/
-
-/*#define SUPPORT_PPP		PointtoPointProtocol	*/
-/*#define SUPPORT_LOOP		LocalLoopBack		*/
-/*#define SUPPORT_ETHER		Ethernet		*/
-
-/*#define SUPPORT_MIB		MIB(SNMP)		*/
-
-/*
- *  TCP/IP ã«é¢ããå®ç¾©
- */
-
-/* TCP ã«é¢ããå®ç¾© */
-
-/*
- *  TCPã®è½åãªã¼ãã³ã®ã¿ãµãã¼ããããã¨ãæå®ããã
- */
-
-#ifdef UNDEF_TCP_CFG_PASSIVE_OPEN
-#undef TCP_CFG_PASSIVE_OPEN
-#endif
-
-/*
- *  TCP éä¿¡ç«¯ç¹ã®éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
- *    æ³¨æ: Makefile ã§æå®ãã¦ããã
- */
-/*#define TCP_CFG_RWBUF_CSAVE_ONLY*/
-			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
-/*#define TCP_CFG_RWBUF_CSAVE*/
-			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
-/*#define TCP_CFG_SWBUF_CSAVE_ONLY*/
-			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
-/*#define TCP_CFG_SWBUF_CSAVE*/
-			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
-
-/*
- *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã
- *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æå¤§ã¨ã³ããªæ°ã
- *  ãã ããæ­£å¸¸ã«åä¿¡ããã»ã°ã¡ã³ããç ´æ£ãããããåéåæ°ãå¢å ããã
- *  ã¾ããæå®ããªãã¨å¶éããªãã
- */
-/*#define TCP_CFG_RWBUF_CSAVE_MAX_QUEUES	2*/
-
-/*
- *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã§ã
- *  éä¿¡ã¦ã£ã³ããããã¡ã«ä½¿ç¨ãããããã¯ã¼ã¯ãããã¡ã®ãµã¤ãºã
- */
-#define USE_TCP_MSS_SEG
-
-#ifdef USE_TCP_MSS_SEG
-
-#ifdef SUPPORT_INET4
-#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IP4_MSS)		/* æå¤§ãµã¤ãº */
-#endif
-
-#ifdef SUPPORT_INET6
-#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IPV6_MMTU)	/* æå¤§ãµã¤ãº */
-#endif
-
-#else	/* of #ifdef USE_TCP_MSS_SEG */
-
-#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	IF_PDU_SIZE			/* æå¤§ãµã¤ãº */
-
-#endif	/* of #ifdef USE_TCP_MSS_SEG */
-
-#define TCP_CFG_SWBUF_CSAVE_MIN_SIZE	0				/* æå°ãµã¤ãº */
-
-/*
- *  TCP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
- */
-
-#ifdef UNDEF_TCP_CFG_NON_BLOCKING
-#undef TCP_CFG_NON_BLOCKING
-#endif
-
-/*
- *  MAX_TCP_SND_SEG: éä¿¡ã»ã°ã¡ã³ããµã¤ãºã®æå¤§å¤
- *
- *    ç¸æãã MSS ãªãã·ã§ã³ã§ã»ã°ã¡ã³ããµã¤ãºãæå®ããã¦ãã
- *    ãã®å¤ã§ãã»ã°ã¡ã³ããµã¤ãºãå¶éã§ããã
- */
-
-#ifdef USE_TCP_MSS_SEG
-
-#ifdef MAX_TCP_SND_SEG
-#undef MAX_TCP_SND_SEG
-#endif
-
-#ifdef SUPPORT_INET4
-#define MAX_TCP_SND_SEG			TCP_MSS
-#endif
-
-#ifdef SUPPORT_INET6
-#define MAX_TCP_SND_SEG			TCP6_MSS
-#endif
-
-#endif	/* of #ifdef USE_TCP_MSS_SEG */
-
-/*
- *  DEF_TCP_RCV_SEG: åä¿¡ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤
- */
-
-#ifdef USE_TCP_MSS_SEG
-
-#ifdef DEF_TCP_RCV_SEG
-#undef DEF_TCP_RCV_SEG
-#endif
-
-#ifdef SUPPORT_INET4
-#define DEF_TCP_RCV_SEG			TCP_MSS
-#endif
-
-#ifdef SUPPORT_INET6
-#define DEF_TCP_RCV_SEG			TCP6_MSS
-#endif
-
-#endif	/* of #ifdef USE_TCP_MSS_SEG */
-
-/*
- *  ã¿ã¹ã¯ããã® Time Wait ç¶æ
-ã® TCP éä¿¡ç«¯ç¹åé¢æ©è½
- *
- *  Time Wait ç¶æ
-ã® TCP éä¿¡ç«¯ç¹ã®ã¨ã³ããªæ°ãæå®ããã
- *  æå®ããªããã0 ãæå®ããã¨ã
- *  ã¿ã¹ã¯ãã Time Wait ç¶æ
-ã® TCP éä¿¡ç«¯ç¹ãåé¢ããæ©è½ã¯çµè¾¼ã¾ãªãã
- */
-#if !defined(SUPPORT_TCP)
-#define NUM_TCP_TW_CEP_ENTRY		0
-#elif defined(USE_TCP_MSS_SEG)
-#define NUM_TCP_TW_CEP_ENTRY		3
-#else
-#define NUM_TCP_TW_CEP_ENTRY		6
-#endif
-
-/*
- *  TCP ãããã®ãã¬ã¼ã¹åºåæ©è½
- */
-//#define TCP_CFG_TRACE
-
-/*
- *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã® IPv4 ã¢ãã¬ã¹
- *  IPV4_ADDRANY ãæå®ããã¨ãå
-¨ã¦ã®ãã¹ããå¯¾è±¡ã¨ããã
- */
-#define TCP_CFG_TRACE_IPV4_RADDR	IPV4_ADDRANY
-
-/*
- *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã®ãã¼ãçªå·
- *  TCP_PORTANY ãæå®ããã¨ãå
-¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
- */
-#define TCP_CFG_TRACE_RPORTNO		TCP_PORTANY
-//#define TCP_CFG_TRACE_RPORTNO		UINT_C(7)
-
-/*
- *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ã­ã¼ã«ã«ãã¹ãã®ãã¼ãçªå·
- *  TCP_PORTANY ãæå®ããã¨ãå
-¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
- */
-#define TCP_CFG_TRACE_LPORTNO		TCP_PORTANY
-//#define TCP_CFG_TRACE_LPORTNO		UINT_C(7)
-
-/*
- *  ITRON TCP/IP APIãTCP ã®æ¡å¼µæ©è½
- */
-//#define TCP_CFG_EXTENTIONS
-
-/*
- *  TCP_CFG_URG_OFFSET: ç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®ãªãã»ãã
- *
- *    -1: BSD ã®å®è£
-ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®æ¬¡ã®ãã¤ããå·®ãã
- *     0: RFC1122 ã®è¦å®ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ããå·®ãã
- */
-
-//#define TCP_CFG_URG_OFFSET	-1
-//#define TCP_CFG_URG_OFFSET	0
-
-/* UDP ã«é¢ããå®ç¾© */
-
-/*
- *  UDP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
- */
-
-#ifdef UNDEF_UDP_CFG_NON_BLOCKING
-#undef UDP_CFG_NON_BLOCKING
-#endif
-
-/*
- *  ITRON TCP/IP APIãUDP ã®æ¡å¼µæ©è½
- */
-//#define UDP_CFG_EXTENTIONS
-
-/* IPv4 ã«é¢ããå®ç¾© */
-
-#ifdef SUPPORT_INET4
-
-#ifdef SUPPORT_PPP
-
-#if 1
-#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(192,168,1,21)
-#else
-#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
-#endif
-
-#if 1
-#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(192,168,1,31)
-#else
-#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
-#endif
-
-#define NUM_STATIC_ROUTE_ENTRY		1
-#define NUM_REDIRECT_ROUTE_ENTRY	0
-
-#endif	/* of #ifdef SUPPORT_PPP */
-
-#ifdef SUPPORT_ETHER
-
-#ifdef DHCP_CFG
-
-#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)
-#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(0,0,0,0)
-#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(0,0,0,0)
-
-#else	/* of #ifdef DHCP_CFG */
-
-#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(192,168,137,110)
-#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(255,255,255,0)
-#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(192,168,137,1)
-
-#endif	/* of #ifdef DHCP_CFG */
-
-#define NUM_STATIC_ROUTE_ENTRY		3
-#define NUM_REDIRECT_ROUTE_ENTRY	1
-
-#endif	/* of #ifdef SUPPORT_ETHER */
-
-#ifdef SUPPORT_LOOP
-
-#define NUM_STATIC_ROUTE_ENTRY		1
-#define NUM_REDIRECT_ROUTE_ENTRY	0
-
-#endif	/* of #ifdef SUPPORT_LOOP */
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-/* IPv6 ã«é¢ããå®ç¾© */
-
-#ifdef SUPPORT_INET6
-
-#ifdef SUPPORT_PPP
-
-#define NUM_STATIC_ROUTE_ENTRY		0
-#define NUM_REDIRECT_ROUTE_ENTRY	0
-
-#endif	/* of #ifdef SUPPORT_PPP */
-
-#ifdef SUPPORT_LOOP
-
-#define NUM_STATIC_ROUTE_ENTRY		0
-#define NUM_REDIRECT_ROUTE_ENTRY	0
-
-#endif	/* of #ifdef SUPPORT_LOOP */
-
-#ifdef SUPPORT_ETHER
-
-#define NUM_STATIC_ROUTE_ENTRY		0
-#define NUM_REDIRECT_ROUTE_ENTRY	1
-
-#endif	/* of #ifdef SUPPORT_ETHER */
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-/*
- *  ãã¼ã¿ãªã³ã¯å±¤ (ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹) ã«é¢ããå®ç¾©
- */
-
-/*
- *  ã¤ã¼ãµãããã«é¢ããå®ç¾©
- */
-
-/*
- *  PPP ã«é¢ããå®ç¾©
- */
-
-#define HDLC_PORTID			1	/* HDLC(PPP)ã«ç¨ããã·ãªã¢ã«ãã¼ãçªå·	*/
-
-/*#define PPP_IDLE_TIMEOUT		(180*NET_TIMER_HZ)*/
-					/* åæ­ã¾ã§ã®ã¢ã¤ãã«æéã		*/
-					/* åæ­ããªãå ´åã¯ã³ã¡ã³ãã¢ã¦ãããã	*/
-
-/*#define PPP_CFG_MODEM			 ã¢ãã æ¥ç¶ã®å ´åã¯ã³ã¡ã³ããå¤ãã	*/
-
-#define MODEM_CFG_INIT			"ATE1&D0&S0\\V0\\Q1S0=1"
-					/* ã¢ãã åæåæå­å			*/
-					/* NTT DoComo ã¢ãã¤ã«ã¢ããã¿ 96F ç¨	*/
-					/*   E1: ã¨ã³ã¼ããã¯ãã			*/
-					/*  &D0: ERä¿¡å·ç¡è¦			*/
-					/*  &S0: DRä¿¡å·å¸¸æ ON			*/
-					/*  \V0: ãªã¶ã«ãã³ã¼ã TYPE 1		*/
-					/*  \Q1: XON/XOFF ãã­ã¼å¶å¾¡		*/
-					/* S0=1: èªåçä¿¡ãªã³ã°åæ° = 1 å	*/
-
-#define MODEM_CFG_PHONE_NUMBER		"090-xxxx-9242"
-
-					/* èªæ§ææ
-å ±ã®è¦å®å¤			*/
-#define DEF_LCP_LOCAL_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
-					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
-
-					/* ç¸æã«è¨±ãæ§ææ
-å ±ã®è¦å®å¤		*/
-#define DEF_LCP_REMOTE_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
-					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
-
-/*
- *  èªè¨¼ã«é¢ããå®ç¾©
- */
-
-#define AUTH_CFG_CLIENT		   	/* èªè¨¼ã¯ã©ã¤ã¢ã³ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã	*/
-#define AUTH_CFG_SERVER			/* èªè¨¼ãµã¼ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã		*/
-
-#define AUTH_LOCAL_USER			"h8"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å	*/
-#define AUTH_LOCAL_PASSWD		"3048f"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã	*/
-#define AUTH_REMOTE_USER		"pen3"		/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å		*/
-#define AUTH_REMOTE_PASSWD		"600MHz"	/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã		*/
-
-/*
- *  ARP ã«é¢ããå®ç¾©
- */
-
-/*#define ARP_CFG_CALLBACK_DUPLICATED*/	/* IP ã¢ãã¬ã¹éè¤æ¤åºã³ã¼ã«ããã¯é¢æ°ã	*/
-					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã		*/
-
-/*
- *  ICMPv4/v6 ã«é¢ããå®ç¾©
- */
-
-#ifdef USE_PING
-
-#define ICMP_CFG_CALLBACK_ECHO_REPLY	/* ICMP ECHO å¿ç­ãåä¿¡ããã¨ãå¼åºãã³ã¼ã«ããã¯é¢æ°ã	*/
-					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã			*/
-
-#endif	/* of #ifdef USE_PING */
-
-/*
- *  ãããã¯ã¼ã¯ãããã¡ã«é¢ããå®ç¾©
- */
-
-#ifdef SUPPORT_ETHER
-
-/*
- *  ã¤ã¼ãµãããã®å ´åã®ãããã¯ã¼ã¯ãããã¡æ°ã®å²ãå½ã¦
- */
-
-/*
- *  64 ãªã¯ããã
- *
- *    IPv4 ã§ã®ã¿å²ãå½ã¦ãã
- *
- *    IPv6 ã§ã¯ãTCP å¶å¾¡ã»ã°ã¡ã³ãï¼CSEGãSDU ãªãï¼ãµã¤ãºã®
- *    ãããã¯ã¼ã¯ãããã¡ï¼IF + IPv6 + TCP = 74ï¼ä»¥ä¸ã®
- *    ãããã¯ã¼ã¯ãããã¡ã¯ä¸è¦ã§ããã
- */
-
-#ifdef NUM_MPF_NET_BUF_64
-#undef NUM_MPF_NET_BUF_64
-#endif
-
-#ifdef SUPPORT_INET4
-#define NUM_MPF_NET_BUF_64		4
-#else
-#define NUM_MPF_NET_BUF_64		0
-#endif
-
-/*
- *  CSEGï¼IF + IP + TCPï¼
- *
- *    IPv6 ã§ã®ã¿å²ãå½ã¦ãã
- *
- *    RX62N Ethernet Controler ã®ãã£ãã¤ã¹ãã©ã¤ãï¼if_rx62nï¼ã®æä½å²å½ã¦é·ã¯ã
- *    ã¤ã¼ãµããããã¬ã¼ã ã®æç­é·ã§ãã 60ï¼CRC ã® 4 ãªã¯ããããé¤ãã
- *    æ´ã«ã¢ã©ã¤ã³ãã¦ 62ï¼ãªã¯ãããã§ããã
- *    å¾ã£ã¦ãIPv4 ã§ã¯ãCSEG ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
- *   ï¼IF + IPv4 + TCP = 54ï¼ã¯ä¸è¦ã§ããã
- */
-
-#ifdef NUM_MPF_NET_BUF_CSEG
-#undef NUM_MPF_NET_BUF_CSEG
-#endif
-
-#ifdef SUPPORT_INET6
-#define NUM_MPF_NET_BUF_CSEG		4
-#else
-#define NUM_MPF_NET_BUF_CSEG		0
-#endif
-
-/*
- *  128 ãªã¯ããã
- *
- *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
- *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
- *    128 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
- */
-
-#ifdef NUM_MPF_NET_BUF_128
-#undef NUM_MPF_NET_BUF_128
-#endif
-
-#if defined(USE_TCP_MSS_SEG)
-#define NUM_MPF_NET_BUF_128		0
-#else
-#define NUM_MPF_NET_BUF_128		2
-#endif
-
-/*
- *  256 ãªã¯ããã
- *
- *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
- *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
- *    256 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
- */
-
-#ifdef NUM_MPF_NET_BUF_256
-#undef NUM_MPF_NET_BUF_256
-#endif
-
-#if defined(USE_TCP_MSS_SEG)
-#define NUM_MPF_NET_BUF_256		0
-#else
-#define NUM_MPF_NET_BUF_256		2
-#endif
-
-/*
- *  512 ãªã¯ããã	
- *
- *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
- *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
- *    512 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
- */
-
-#ifdef NUM_MPF_NET_BUF_512
-#undef NUM_MPF_NET_BUF_512
-#endif
-
-#if defined(USE_TCP_MSS_SEG)
-#define NUM_MPF_NET_BUF_512		0
-#else
-#define NUM_MPF_NET_BUF_512		2
-#endif
-
-/*
- *  TCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼
- *
- *   ã»IPv4 ã§ã®ã¿å²ãå½ã¦ãã
- *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
- *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
- */
-
-#ifdef NUM_MPF_NET_BUF_IP_MSS
-#undef NUM_MPF_NET_BUF_IP_MSS
-#endif
-
-#if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG)
-
-#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
-     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
-#define NUM_MPF_NET_BUF_IP_MSS		6
-#else
-#define NUM_MPF_NET_BUF_IP_MSS		4	/* IF + 576 ãªã¯ããã	*/
-#endif
-
-#else	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
-
-#define NUM_MPF_NET_BUF_IP_MSS		0	/* IF + 576 ãªã¯ããã	*/
-
-#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
-
-/*
- *  1024 ãªã¯ããã	
- *
- *    TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
- *    1024 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
- */
-
-#ifdef NUM_MPF_NET_BUF_1024
-#undef NUM_MPF_NET_BUF_1024
-#endif
-
-#if defined(USE_TCP_MSS_SEG)
-#define NUM_MPF_NET_BUF_1024		0	/* 1024 ãªã¯ããã	*/
-#else
-#define NUM_MPF_NET_BUF_1024		2	/* 1024 ãªã¯ããã	*/
-#endif
-
-/*
- *  TCP MSSï¼IPV6 MMTUãIF + 1280 ãªã¯ãããï¼
- *
- *   ã»IPv6 ã§ã®ã¿å²ãå½ã¦ãã
- *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
- *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
- */
-
-#ifdef NUM_MPF_NET_BUF_IPV6_MMTU
-#undef NUM_MPF_NET_BUF_IPV6_MMTU
-#endif
-
-#if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU))
-
-#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
-     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
-#define NUM_MPF_NET_BUF_IPV6_MMTU	6	/* IF + 1280	*/
-#else
-#define NUM_MPF_NET_BUF_IPV6_MMTU	4	/* IF + 1280	*/
-#endif
-
-#else	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
-
-#define NUM_MPF_NET_BUF_IPV6_MMTU	0	/* IF + 1280	*/
-
-#endif	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
-
-/*
- *  IF æå¤§ PDU ãµã¤ãº
- *
- *   ã»TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
- *     IF æå¤§ PDU ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
- *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
- *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
- */
-
-#ifdef NUM_MPF_NET_BUF_IF_PDU
-#undef NUM_MPF_NET_BUF_IF_PDU
-#endif
-
-#ifdef USE_TCP_MSS_SEG
-
-#define NUM_MPF_NET_BUF_IF_PDU		0
-
-#else	/* of #ifdef USE_TCP_MSS_SEG */
-
-#if (defined(TCP_CFG_RWBUF_CSAVE) || defined(TCP_CFG_SWBUF_CSAVE)) && defined(USE_COPYSAVE_API)
-#define NUM_MPF_NET_BUF_IF_PDU		12
-#else
-#define NUM_MPF_NET_BUF_IF_PDU		10
-#endif
-
-#endif	/* of #ifdef USE_TCP_MSS_SEG */
-
-/*
- *  65536 ãªã¯ããã
- *
- *  ã»NET_BUF_CFG_LONG_LEN ãå®ç¾©ããã¨ãã®ã¿å²ãå½ã¦ãã
- */
-
-#ifdef NET_BUF_CFG_LONG_LEN
-
-/* IPv6 ç¨ */
-
-#ifdef NUM_MPF_NET_BUF6_65536
-#undef NUM_MPF_NET_BUF6_65536
-#endif
-
-#if defined(USE_TCP_MSS_SEG)
-#define NUM_MPF_NET_BUF6_65536	0
-#else
-#define NUM_MPF_NET_BUF6_65536	4
-#endif
-
-#else	/* of ifdef NET_BUF_CFG_LONG_LEN */
-
-#define NUM_MPF_NET_BUF6_65536	0
-
-#endif	/* of ifdef NET_BUF_CFG_LONG_LEN */
-
-#endif	/* of #ifdef SUPPORT_ETHER */
-
-/*
- *  DNS ãµã¼ãã«é¢ããå®ç¾©
- */
-
-/* DNS ãµã¼ãã® IP ã¢ãã¬ã¹ */
-
-#if !defined(DHCP6_CLI_CFG)
-
-#define IPV6_ADDR_DNS_INIT	\
-	{{{ UINT_C(0xfd), UINT_C(0x90), UINT_C(0xcc), UINT_C(0xe5), \
-	    UINT_C(0x25), UINT_C(0xf6), UINT_C(0xff), UINT_C(0x81), \
-	    UINT_C(0x02), UINT_C(0xa0), UINT_C(0x24), UINT_C(0xff), \
-	    UINT_C(0xfe), UINT_C(0x56), UINT_C(0xc5), UINT_C(0xd6) }}}
-
-#endif	/* of #if !defined(DHCP6_CLI_CFG) */
-
-#if !defined(DHCP4_CLI_CFG)
-#define IPV4_ADDR_DNS		MAKE_IPV4_ADDR(192,168,2,1)
-#endif
-
-/* DOMAIN å */
-
-#if !(defined(DHCP4_CLI_CFG) || defined(DHCP6_CLI_CFG))
-#define RSLV_CFG_DNS_DOMAIN_NAME_STR	"jo.tomakomai-ct.ac.jp"
-#endif
-
-/*
- *  DHCP ã¯ã©ã¤ã¢ã³ãã«é¢ããå®ç¾©
- */
-
-/* DHCPv6 ã®åä½ã¢ã¼ãã®è¨­å® */
-
-#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATELESS
-//#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATEFULL
-
-#define ETHER_OUTPUT_PRIORITY	7	/* Ethernet åºåã¿ã¹ã¯ã®åªå
-åº¦		*/
-#define TCP_OUT_TASK_PRIORITY	6	/* TCP åºåã¿ã¹ã¯ã®åªå
-åº¦			*/
-#define NUM_DTQ_ETHER_OUTPUT	16	/* Ethernet åºåãã¼ã¿ã­ã¥ã¼ãµã¤ãº	*/
-
-#endif /* _TINET_APP_CONFIG_H_ */
Index: nlProtoTool/trunk/prototool/src/tinet_main.cfg
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/tinet_main.cfg	(revision 278)
+++ 	(revision )
@@ -1,135 +1,0 @@
-/*
- *  TOPPERS ECHONET Lite Communication Middleware
- * 
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
- * 
- *  ä¸è¨èä½æ¨©è
-ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
- *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
- *  å¤ã»åé
-å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
- *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
- *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
- *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
- *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
- *      è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
- *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
- *      ç¨ã§ããªãå½¢ã§åé
-å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
- *      ã¨ï¼
- *    (a) åé
-å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
-ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
- *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
- *    (b) åé
-å¸ã®å½¢æ
-ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
- *        å ±åãããã¨ï¼
- *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
- *      å®³ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ããå
-è²¬ãããã¨ï¼
- *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
- *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
-ããã³TOPPERSãã­ã¸ã§ã¯ãã
- *      å
-è²¬ãããã¨ï¼
- * 
- *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
-ã
- *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
- *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
- *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
- *  ã®è²¬ä»»ãè² ããªãï¼
- * 
- *  @(#) $Id$
- */
-
-/*
- *  ãããã¯ã¼ã¯å¯¾å¿ main.c ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
- */
-
-/*#include "netapp/dhcp4_cli.h"*/
-#include "main.h"
-
-/* DHCP ã¯ã©ã¤ã¢ã³ã */
-/*INCLUDE("netapp/tinet_dhcp4_cli.cfg");*/
-
-/* ECHONET Lite UDP éä¿¡ç«¯ç¹ */
-
-#ifdef SUPPORT_INET4
-
-UDP_CRE_CEP (MRUBY_ECNL_UDP_CEPID,	 { TA_ACT, { IPV4_ADDRANY, 3610 }, (FP)callback_nblk_udp } );
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-UDP6_CRE_CEP (MRUBY_ECNL_UDP_CEPID, { TA_NULL, { IPV6_ADDRANY, 3610 }, (FP)callback_nblk_udp } );
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-/* TCP åä»å£ */
-
-#ifdef SUPPORT_INET6
-
-TCP6_CRE_REP (TCP_REPID, { 0, { IPV6_ADDRANY, 80 } } );
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-#ifdef SUPPORT_INET4
-
-TCP_CRE_REP (TCP_REPID,	 { 0, { IPV4_ADDRANY, 80 } } );
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-/* TCP éä¿¡ç«¯ç¹ */
-
-#ifdef SUPPORT_INET6
-
-TCP6_CRE_CEP (TCP_CEPID1, {
-	0,
-	tcp_swbuf1,
-	TCP_SWBUF_SIZE,
-	tcp_rwbuf1,
-	TCP_RWBUF_SIZE,
-	(FP)callback_nblk_tcp
-	} );
-
-TCP6_CRE_CEP (TCP_CEPID2, {
-	0,
-	tcp_swbuf2,
-	TCP_SWBUF_SIZE,
-	tcp_rwbuf2,
-	TCP_RWBUF_SIZE,
-	(FP)callback_nblk_tcp
-	} );
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-#ifdef SUPPORT_INET4
-
-TCP_CRE_CEP (TCP_CEPID1, {
-	0,
-	tcp_swbuf1,
-	TCP_SWBUF_SIZE,
-	tcp_rwbuf1,
-	TCP_RWBUF_SIZE,
-	(FP)callback_nblk_tcp
-	} );
-
-TCP_CRE_CEP (TCP_CEPID2, {
-	0,
-	tcp_swbuf2,
-	TCP_SWBUF_SIZE,
-	tcp_rwbuf2,
-	TCP_RWBUF_SIZE,
-	(FP)callback_nblk_tcp
-	} );
-
-#endif	/* of #ifdef SUPPORT_INET4 */
Index: /EcnlProtoTool/trunk/prototool/src/xprintf.c
===================================================================
--- /EcnlProtoTool/trunk/prototool/src/xprintf.c	(revision 279)
+++ /EcnlProtoTool/trunk/prototool/src/xprintf.c	(revision 279)
@@ -0,0 +1,385 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1999 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ *
+ * Purpose:
+ *  A merge of Bjorn Reese's format() function and Daniel's dsprintf()
+ *  1.0. A full blooded printf() clone with full support for <num>$
+ *  everywhere (parameters, widths and precisions) including variabled
+ *  sized parameters (like doubles, long longs, long doubles and even
+ *  void * in 64-bit architectures).
+ *
+ * Current restrictions:
+ * - Max 128 parameters
+ * - No 'long double' support.
+ *
+ * If you ever want truly portable and good *printf() clones, the project that
+ * took on from here is named 'Trio' and you find more details on the trio web
+ * page at https://daniel.haxx.se/trio/
+ */
+
+/*------------------------------------------------------------------------/
+/  Universal string handler for user console interface
+/-------------------------------------------------------------------------/
+/
+/  Copyright (C) 2011, ChaN, all right reserved.
+/
+/ * This software is a free software and there is NO WARRANTY.
+/ * No restriction on use. You can use, modify and redistribute it for
+/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+/ * Redistributions of source code must retain the above copyright notice.
+/
+/-------------------------------------------------------------------------*/
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+struct nsprintf {
+  char *buffer;
+  size_t length;
+  size_t max;
+};
+
+struct asprintf {
+  char *buffer; /* allocated buffer */
+  size_t len;   /* length of string */
+  size_t alloc; /* length of alloc */
+  int fail;     /* (!= 0) if an alloc has failed and thus
+                   the output is not the complete data */
+};
+
+#define OUTCHAR(x) \
+  do{ \
+    if(stream((unsigned char)(x), (FILE *)data) != -1) \
+      done++; \
+    else \
+     return done; /* return immediately on failure */ \
+  } while(0)
+
+
+static int dprintf_formatf(
+	void *data,
+	int(*stream)(int, FILE *),
+	const char *fmt,
+	va_list arp)
+{
+	unsigned int r, i, j, w, f;
+	unsigned long v;
+	char s[16], c, d, *p;
+
+	/* Number of characters written.  */
+	int done = 0;
+
+	for (;;) {
+		c = *fmt++;					/* Get a char */
+		if (!c) break;				/* End of format? */
+		if (c != '%') {				/* Pass through it if not a % sequense */
+			OUTCHAR(c); continue;
+		}
+		f = 0;
+		c = *fmt++;					/* Get first char of the sequense */
+		if (c == '0') {				/* Flag: '0' padded */
+			f = 1; c = *fmt++;
+		}
+		else {
+			if (c == '-') {			/* Flag: left justified */
+				f = 2; c = *fmt++;
+			}
+		}
+		for (w = 0; c >= '0' && c <= '9'; c = *fmt++)	/* Minimum width */
+			w = w * 10 + c - '0';
+		if (c == 'l' || c == 'L') {	/* Prefix: Size is long int */
+			f |= 4; c = *fmt++;
+		}
+		else if (c == 'h') {	/* Prefix: Size is short int */
+			f |= 16; c = *fmt++;
+		}
+		if (!c) break;				/* End of format? */
+		d = c;
+		if (d >= 'a') d -= 0x20;
+		switch (d) {				/* Type is... */
+		case 'S':					/* String */
+			p = va_arg(arp, char*);
+			for (j = 0; p[j]; j++);
+			while (!(f & 2) && j++ < w) OUTCHAR(' ');
+			for (; *p; p++)
+				OUTCHAR(*p);
+			while (j++ < w) OUTCHAR(' ');
+			continue;
+		case 'C':					/* Character */
+			OUTCHAR((char)va_arg(arp, int)); continue;
+		case 'B':					/* Binary */
+			r = 2; break;
+		case 'O':					/* Octal */
+			r = 8; break;
+		case 'D':					/* Signed decimal */
+		case 'U':					/* Unsigned decimal */
+			r = 10; break;
+		case 'X':					/* Hexdecimal */
+			r = 16; break;
+		default:					/* Unknown type (passthrough) */
+			OUTCHAR(c); continue;
+		}
+
+		/* Get an argument and put it in numeral */
+		v = (f & 4) ? va_arg(arp, long)
+			: ((f & 16) ? ((d == 'D') ? (long)va_arg(arp, short) : (long)va_arg(arp, unsigned short))
+				: ((d == 'D') ? (long)va_arg(arp, int) : (long)va_arg(arp, unsigned int)));
+		if (d == 'D' && (v & 0x80000000)) {
+			v = 0 - v;
+			f |= 8;
+		}
+		i = 0;
+		do {
+			d = (char)(v % r); v /= r;
+			if (d > 9) d += (c == 'x') ? 0x27 : 0x07;
+			s[i++] = d + '0';
+		} while (v && i < sizeof(s));
+		if (f & 8) s[i++] = '-';
+		j = i; d = (f & 1) ? '0' : ' ';
+		while (!(f & 2) && j++ < w) OUTCHAR(d);
+		do OUTCHAR(s[--i]); while (i);
+		while (j++ < w) OUTCHAR(' ');
+	}
+	return done;
+}
+/* fputc() look-alike */
+static int addbyter(int output, FILE *data)
+{
+  struct nsprintf *infop=(struct nsprintf *)data;
+  unsigned char outc = (unsigned char)output;
+
+  if(infop->length < infop->max) {
+    /* only do this if we haven't reached max length yet */
+    infop->buffer[0] = outc; /* store */
+    infop->buffer++; /* increase pointer */
+    infop->length++; /* we are now one byte larger */
+    return outc;     /* fputc() returns like this on success */
+  }
+  return -1;
+}
+
+int vsnprintf(char *buffer, size_t maxlength, const char *format,
+                    va_list ap_save)
+{
+  int retcode;
+  struct nsprintf info;
+
+  info.buffer = buffer;
+  info.length = 0;
+  info.max = maxlength;
+
+  retcode = dprintf_formatf(&info, addbyter, format, ap_save);
+  if(info.max) {
+    /* we terminate this with a zero byte */
+    if(info.max == info.length)
+      /* we're at maximum, scrap the last letter */
+      info.buffer[-1] = 0;
+    else
+      info.buffer[0] = 0;
+  }
+  return retcode;
+}
+
+int snprintf(char *buffer, size_t maxlength, const char *format, ...)
+{
+  int retcode;
+  va_list ap_save; /* argument pointer */
+  va_start(ap_save, format);
+  retcode = vsnprintf(buffer, maxlength, format, ap_save);
+  va_end(ap_save);
+  return retcode;
+}
+
+/* fputc() look-alike */
+static int alloc_addbyter(int output, FILE *data)
+{
+  struct asprintf *infop=(struct asprintf *)data;
+  unsigned char outc = (unsigned char)output;
+
+  if(!infop->buffer) {
+    infop->buffer = malloc(32);
+    if(!infop->buffer) {
+      infop->fail = 1;
+      return -1; /* fail */
+    }
+    infop->alloc = 32;
+    infop->len =0;
+  }
+  else if(infop->len+1 >= infop->alloc) {
+    char *newptr;
+
+    newptr = realloc(infop->buffer, infop->alloc*2);
+
+    if(!newptr) {
+      infop->fail = 1;
+      return -1; /* fail */
+    }
+    infop->buffer = newptr;
+    infop->alloc *= 2;
+  }
+
+  infop->buffer[ infop->len ] = outc;
+
+  infop->len++;
+
+  return outc; /* fputc() returns like this on success */
+}
+
+char *aprintf(const char *format, ...)
+{
+  va_list ap_save; /* argument pointer */
+  int retcode;
+  struct asprintf info;
+
+  info.buffer = NULL;
+  info.len = 0;
+  info.alloc = 0;
+  info.fail = 0;
+
+  va_start(ap_save, format);
+  retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
+  va_end(ap_save);
+  if((-1 == retcode) || info.fail) {
+    if(info.alloc)
+      free(info.buffer);
+    return NULL;
+  }
+  if(info.alloc) {
+    info.buffer[info.len] = 0; /* we terminate this with a zero byte */
+    return info.buffer;
+  }
+  else
+    return strdup("");
+}
+
+char *vaprintf(const char *format, va_list ap_save)
+{
+  int retcode;
+  struct asprintf info;
+
+  info.buffer = NULL;
+  info.len = 0;
+  info.alloc = 0;
+  info.fail = 0;
+
+  retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
+  if((-1 == retcode) || info.fail) {
+    if(info.alloc)
+      free(info.buffer);
+    return NULL;
+  }
+
+  if(info.alloc) {
+    info.buffer[info.len] = 0; /* we terminate this with a zero byte */
+    return info.buffer;
+  }
+  else
+    return strdup("");
+}
+
+int vasprintf(char **dst, const char *format, va_list ap_save)
+{
+	int retcode;
+	struct asprintf info;
+
+	info.buffer = NULL;
+	info.len = 0;
+	info.alloc = 0;
+	info.fail = 0;
+
+	retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
+	if ((-1 == retcode) || info.fail) {
+		if (info.alloc)
+			free(info.buffer);
+		return -1;
+	}
+
+	if (info.alloc) {
+		info.buffer[info.len] = 0; /* we terminate this with a zero byte */
+		*dst = info.buffer;
+		return info.len;
+	}
+	else {
+		*dst = strdup("");
+		return 0;
+	}
+}
+
+static int storebuffer(int output, FILE *data)
+{
+  char **buffer = (char **)data;
+  unsigned char outc = (unsigned char)output;
+  **buffer = outc;
+  (*buffer)++;
+  return outc; /* act like fputc() ! */
+}
+
+int sprintf(char *buffer, const char *format, ...)
+{
+  va_list ap_save; /* argument pointer */
+  int retcode;
+  va_start(ap_save, format);
+  retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
+  va_end(ap_save);
+  *buffer=0; /* we terminate this with a zero byte */
+  return retcode;
+}
+
+int printf(const char *format, ...)
+{
+  int retcode;
+  va_list ap_save; /* argument pointer */
+  va_start(ap_save, format);
+
+  retcode = dprintf_formatf(stdout, fputc, format, ap_save);
+  va_end(ap_save);
+  return retcode;
+}
+
+int fprintf(FILE *whereto, const char *format, ...)
+{
+  int retcode;
+  va_list ap_save; /* argument pointer */
+  va_start(ap_save, format);
+  retcode = dprintf_formatf(whereto, fputc, format, ap_save);
+  va_end(ap_save);
+  return retcode;
+}
+
+int vsprintf(char *buffer, const char *format, va_list ap_save)
+{
+  int retcode;
+  retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
+  *buffer=0; /* we terminate this with a zero byte */
+  return retcode;
+}
+
+int vprintf(const char *format, va_list ap_save)
+{
+  return dprintf_formatf(stdout, fputc, format, ap_save);
+}
+
+int vfprintf(FILE *whereto, const char *format, va_list ap_save)
+{
+  return dprintf_formatf(whereto, fputc, format, ap_save);
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/.cproject
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/.cproject	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/.cproject	(revision 279)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
+		<cconfiguration id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.1798168813">
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.1798168813" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+				<externalSettings/>
+				<extensions>
+					<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+				</extensions>
+			</storageModule>
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+				<configuration artifactExtension="a" artifactName="tcc" buildArtefactType="com.renesas.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=com.renesas.cdt.build.core.buildArtefactType.staticLib,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf *.lst *.lis *.lpp *.map" description="" id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.1798168813" name="Debug" parent="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id">
+					<folderInfo id="com.renesas.cdt.rz.libraryProject.base.debug.configuration.Id.1798168813." name="/" resourcePath="">
+						<toolChain id="com.renesas.cdt.library.rz.debug.win32.toolchain.Id.513805226" name="KPIT GNUARM-NONE-EABI Toolchain" superClass="com.renesas.cdt.library.rz.debug.win32.toolchain.Id">
+							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.PE" id="com.renesas.cdt.rz.libraryProject.debug.win32.targetplatform.Id.1603870523" name="Target Platform" osList="win32,linux" superClass="com.renesas.cdt.rz.libraryProject.debug.win32.targetplatform.Id"/>
+							<builder buildPath="${workspace_loc:/tcc}/Debug" id="com.renesas.cdt.rz.library.project.debug.win32.builder.Id.1947549202" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.rz.library.project.debug.win32.builder.Id"/>
+							<tool id="com.renesas.cdt.rz.libraryProject.debug.win32.tool.compiler.Id.1351770923" name="Compiler" superClass="com.renesas.cdt.rz.libraryProject.debug.win32.tool.compiler.Id">
+								<option defaultValue="true" id="com.renesas.cdt.core.Compiler.option.misc2.373654238" name="æ¨æºã·ã¹ãã ã»ãã£ã¬ã¯ããªã¼ã§ãããã¼ã»ãã¡ã¤ã«ãæ¤ç´¢ããªã (-nostdinc)" superClass="com.renesas.cdt.core.Compiler.option.misc2" value="false" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.dataEndian.1091726519" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.dataEndian" value="Little-endian" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.instructionset.1331241682" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.instructionset" value="ARM" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.interworking.404979942" name="ã¤ã³ã¿ã¼ã»ã¯ã¼ã­ã³ã°" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.interworking" value="true" valueType="boolean"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.targetfpu.1883231980" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.targetfpu" value="vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.floatingpointabi.1001946086" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.floatingpointabi" value="Hard" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.warnStackSize.1222102532" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.core.Compiler.option.warnStackSize" value="100" valueType="string"/>
+								<option id="com.renesas.cdt.core.Compiler.option.CPUSeries.657838384" name="CPU ã·ãªã¼ãº" superClass="com.renesas.cdt.core.Compiler.option.CPUSeries" value="RZ/A" valueType="string"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.architecture.401098680" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.architecture" value="armv7-a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Compiler.option.library.cpuType.1123397289" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.cpuType" value="cortex-a9" valueType="enumerated"/>
+								<option id="com.renesas.cdt.core.Compiler.option.stackSizeInDecimal.1138208172" name="Decimal representation of '-Wsatck-usage'" superClass="com.renesas.cdt.core.Compiler.option.stackSizeInDecimal" value="256" valueType="string"/>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.core.Compiler.option.includeFileDir.276254572" name="ã¤ã³ã¯ã«ã¼ãã»ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¼" superClass="com.renesas.cdt.core.Compiler.option.includeFileDir" valueType="includePath">
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
+								</option>
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.rz.Debug.Compiler.option.library.macroDefines.1180675084" name="ãã¯ã­å®ç¾©" superClass="com.renesas.cdt.rz.Debug.Compiler.option.library.macroDefines" valueType="definedSymbols">
+									<listOptionValue builtIn="false" value="TCC_TARGET_ARM"/>
+									<listOptionValue builtIn="false" value="WITHOUT_LIBTCC"/>
+								</option>
+								<inputType id="%Base.Compiler.C.InputType.Id.1716911779" name="C å
+¥å" superClass="%Base.Compiler.C.InputType.Id"/>
+								<inputType id="Base.Compiler.CPP.InputType.Id.626465714" name="C++ å
+¥å" superClass="Base.Compiler.CPP.InputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.library.rz.Debug.win32.tool.assembler.Id.1658961068" name="Assembler" superClass="com.renesas.cdt.library.rz.Debug.win32.tool.assembler.Id">
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.dataEndian.992648775" name="ã¨ã³ãã£ã¢ã³" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.dataEndian" value="Little-endian" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.instructionset.1760881271" name="å½ä»¤ã»ãã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.instructionset" value="ARM" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.targetfpu.1986508057" name="ã¿ã¼ã²ãã FPU (-mfpu)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.targetfpu" value="vfp" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.floatingpointabi.659487149" name="æµ®åå°æ°ç¹ ABI (-mfloat-abi=name)" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.floatingpointabi" value="Hard" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.architecture.1028163560" name="ã¢ã¼ã­ãã¯ãã£ã¼" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.architecture" value="armv7-a" valueType="enumerated"/>
+								<option id="com.renesas.cdt.rz.Debug.Assembler.option.library.cpuType.1481182175" name="CPU ã¿ã¤ã" superClass="com.renesas.cdt.rz.Debug.Assembler.option.library.cpuType" value="cortex-a9" valueType="enumerated"/>
+								<inputType id="%Base.Assembler.inputType.Id.199268857" name="ã¢ã»ã³ãã©ã¼å
+¥åã¿ã¤ã" superClass="%Base.Assembler.inputType.Id"/>
+							</tool>
+							<tool id="com.renesas.cdt.library.rz.debug.win32.tool.archive.Id.340844013" name="Archive Generator" superClass="com.renesas.cdt.library.rz.debug.win32.tool.archive.Id"/>
+						</toolChain>
+					</folderInfo>
+					<sourceEntries>
+						<entry excluding="tests|lib|examples|tccpe.c|tcccoff.c|x86_64-gen.c|x86_64-asm.h|il-opcodes.h|il-gen.c|i386-tok.h|i386-gen.c|i386-asm.h|i386-asm.c|c67-gen.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
+					</sourceEntries>
+				</configuration>
+			</storageModule>
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+		</cconfiguration>
+	</storageModule>
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+		<project id="tcc.com.renesas.cdt.rz.library.projectType.Id.95769190" name="Static Library (Renesas)" projectType="com.renesas.cdt.rz.library.projectType.Id"/>
+	</storageModule>
+	<storageModule moduleId="scannerConfiguration">
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+</cproject>
Index: /EcnlProtoTool/trunk/tcc-0.9.26/.gitignore
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/.gitignore	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/.gitignore	(revision 279)
@@ -0,0 +1,58 @@
+*.o
+*.a
+tcc_g
+tcc
+/*-tcc
+tc2.c
+doc
+tc3s.c
+p3.c
+tc1.c
+error.c
+i386-gen1.c
+test.out1
+test.out1b
+test.out2
+test.out2b
+test.out3
+test.out3b
+web.sh
+memdebug.c
+bench
+Makefile.uClibc
+boundtest
+prog.ref
+test.ref
+test.out
+tcc-doc.html
+ideas
+tcctest.ref
+linux.tcc
+ldtest
+libtcc_test
+instr.S
+p.c
+p2.c
+tcctest[1234]
+test[1234].out
+tests/tcclib.h
+tests/tcctest.gcc
+tests/weaktest.*.o.txt
+tests2/fred.txt
+.gdb_history
+tcc.1
+tcc.pod
+config.h
+config.mak
+config.texi
+tags
+.DS_Store
+*.swp
+lib/x86_64
+lib/i386
+lib/x86_64-win32
+lib/i386-win32
+tcc-doc.info
+conftest*
+tiny_libmaker
+*.dSYM
Index: /EcnlProtoTool/trunk/tcc-0.9.26/.info
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/.info	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/.info	(revision 279)
@@ -0,0 +1,7 @@
+TOOL_CHAIN=KPIT GNUARM-NONE-EABI Toolchain
+VERSION=v16.01
+TC_INSTALL=C:\Program Files (x86)\KPIT\GNUARM-NONEv16.01-EABI\arm-none-eabi\arm-none-eabi\
+GCC_STRING=5.2-GNUARM-NONE_v16.01
+VERSION_IDE=
+E2STUDIO_VERSION=5.3.1.002
+ACTIVE_CONFIGURATION=Debug
Index: /EcnlProtoTool/trunk/tcc-0.9.26/.project
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/.project	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/.project	(revision 279)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>tcc-0.9.26</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.renesas.cdt.core.genmakebuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>com.renesas.cdt.core.kpitcnature</nature>
+		<nature>com.renesas.cdt.core.kpitccnature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+	</natures>
+</projectDescription>
Index: /EcnlProtoTool/trunk/tcc-0.9.26/COPYING
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/COPYING	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/COPYING	(revision 279)
@@ -0,0 +1,513 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
Index: /EcnlProtoTool/trunk/tcc-0.9.26/Changelog
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/Changelog	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/Changelog	(revision 279)
@@ -0,0 +1,396 @@
+version 0.9.26:
+
+User interface:
+- -MD/-MF (automatically generate dependencies for make)
+- -pthread option (same as -D_REENTRANT -lpthread) (Henry Kroll III)
+- -m32/-m64 to re-exec cross compiler (Henry Kroll III)
+- -Wl, Mimic all GNU -option forms supported by ld (Kirill Smelkov)
+- new LIBTCCAPI tcc_set_options() (grischka)
+
+Platforms:
+- Many improvements for x86-64 target (Shinichiro Hamaji, Michael Matz, grischka)
+- x86-64 assembler (Frederic Feret)
+- Many improvements for ARM target (Daniel Glöckner, Thomas Preud'homme)
+- Support WinCE PE ARM (Timo VJ Lahde)
+- Support ARM hardfloat calling convention (Thomas Preud'homme)
+- Support SELinux (Security-Enhanced Linux) (Henry Kroll III)
+- Support Debian GNU/kFreeBSD kernels (Pierre Chifflier)
+- Support GNU/Hurd kernels (Thomas Preud'homme)
+- Support OSX (tcc -run only) (Milutin Jovanovic)
+- Support multiarch configuration (Thomas Preud'homme)
+- Support out-of-tree build (Akim Demaille)
+
+Features:
+- C99 variable length arrays (Thomas Preud'homme & Joe Soroka)
+- Asm labels for variables and functions (Thomas Preud'homme)
+- STT_GNU_IFUNC (Indirect functions as externals) (Thomas Preud'homme)
+- More tests (tests2) (Milutin Jovanovic)
+
+version 0.9.25:
+
+- first support for x86-64 target (Shinichiro Hamaji)
+- support µClibc
+- split tcc.c into tcc.h libtcc.c tccpp.c tccgen.c tcc.c
+- improved preprocess output with linenumbers and spaces preserved
+- tcc_relocate now copies code into user buffer
+- fix bitfields with non-int types and in unions
+- improve ARM cross-compiling (Daniel GlÃ¶ckner)
+- link stabstr sections from multiple objects
+- better (still limited) support for multiple TCCStates
+
+version 0.9.24:
+
+- added verbosity levels -v, -vv, -vvv
+- Accept standard input as an inputstream (Hanzac Chen)
+- Support c89 compilers other than gcc (Hanzac Chen)
+- -soname linker option (Marc Andre Tanner)
+- Just warn about unknown directives, ignore quotes in #error/#warning
+- Define __STDC_VERSION__=199901L (477)
+- Switch to newer tccpe.c (includes support for resources)
+- Handle backslashes within #include/#error/#warning
+- Import changesets (part 4) 428,457,460,467: defines for openbsd etc.
+- Use _WIN32 for a windows hosted tcc and define it for the PE target,
+  otherwise define __unix / __linux (Detlef Riekenberg)
+- Import changesets (part 3) 409,410: ARM EABI by Daniel GlÃ¶ckner
+- Some in-between fixes:
+  TCC -E no longer hangs with macro calls involving newlines.
+  (next_nomacro1 now advances the read-pointer with TOK_LINEFEED)
+  Global cast (int g_i = 1LL;) no longer crashes tcc.
+  (nocode_wanted is initially 1, and only 0 for gen_function)
+  On win32 now tcc.exe finds 'include' & 'lib' even if itself is in 'bin'.
+  (new function w32_tcc_lib_path removes 'bin' if detected)
+  Added quick build batch file for mingw (win32/build-tcc.bat)
+  Last added case label optimization (455) produced wrong code. Reverted.
+
+- Import more changesets from Rob Landley's fork (part 2):
+  487: Handle long long constants in gen_opic() (Rob Landley)
+  484: Handle parentheses within __attribute__((...)) (Rob Landley)
+  480: Remove a goto in decl_initializer_alloc (Rob Landley)
+  475: Fix dereferences in inline assembly output (Joshua Phillips)
+  474: Cast ptrs to ints of different sizes correctly (Joshua Phillips)
+  473: Fix size of structs with empty array member (Joshua Phillips)
+  470: No warning for && and || with mixed pointers/integers (Rob Landley)
+  469: Fix symbol visibility problems in the linker (Vincent Pit)
+  468: Allow && and || involving pointer arguments (Rob Landley)
+  455: Optimize case labels with no code in between (Zdenek Pavlas)
+  450: Implement alloca for x86 (grischka)
+  415: Parse unicode escape sequences (Axel Liljencrantz)
+  407: Add a simple va_copy() in stdarg.h (Hasso Tepper)
+  400: Allow typedef names as symbols (Dave Dodge)
+
+- Import some changesets from Rob Landley's fork (part 1):
+  462: Use LGPL with bcheck.c and il-gen.c
+  458: Fix global compound literals (in unary: case '&':) (Andrew Johnson)
+  456: Use return code from tcc_output_file in main() (Michael Somos)
+  442: Fix indirections with function pointers (***fn)() (grischka)
+  441: Fix LL left shift in libtcc1.c:__shldi3 (grischka)
+  440: Pass structures and function ptrs through ?: (grischka)
+  439: Keep rvalue in bit assignment (bit2 = bit1 = x) (grischka)
+  438: Degrade nonportable pointer assignment to warning (grischka)
+  437: Call 'saveregs()' before jumping with logical and/or/not (grischka)
+  435: Put local static variables into global memory (grischka)
+  432/434: Cast double and ptr to bool (grischka)
+  420: Zero pad x87 tenbyte long doubles (Felix Nawothnig)
+  417: Make 'sizeof' unsigned (Rob Landley)
+  397: Fix save_reg for longlongs (Daniel GlÃ¶ckner)
+  396: Fix "invalid relocation entry" problem on ubuntu - (Bernhard Fischer)
+
+- ignore AS_NEEDED ld command
+- mark executable sections as executable when running in memory
+- added support for win32 wchar_t (Filip Navara)
+- segment override prefix support (Filip Navara)
+- normalized slashes in paths (Filip Navara)
+- windows style fastcall (Filip Navara)
+- support for empty input register section in asm (Filip Navara)
+- anonymous union/struct support (Filip Navara)
+- fixed parsing of function parameters
+- workaround for function pointers in conditional expressions (Dave Dodge)
+- initial '-E' option support to use the C preprocessor alone
+- discard type qualifiers when comparing function parameters (Dave Dodge)
+- Bug fix: A long long value used as a test expression ignores the
+  upper 32 bits at runtime (Dave Dodge)
+- fixed multiple concatenation of PPNUM tokens (initial patch by Dave Dodge)
+- fixed multiple typedef specifiers handling
+- fixed sign extension in some type conversions (Dave Dodge)
+
+version 0.9.23:
+
+- initial PE executable format for windows version (grischka)
+- '#pragma pack' support (grischka)
+- '#include_next' support (Bernhard Fischer)
+- ignore '-pipe' option
+- added -f[no-]leading-underscore
+- preprocessor function macro parsing fix (grischka)
+
+version 0.9.22:
+
+- simple memory optimisations: kernel compilation is 30% faster
+- linker symbol definitions fixes
+- gcc 3.4 fixes
+- fixed value stack full error
+- 'packed' attribute support for variables and structure fields
+- ignore 'const' and 'volatile' in function prototypes
+- allow '_Bool' in bit fields
+
+version 0.9.21:
+
+- ARM target support (Daniel GlÃ¶ckner)
+- added '-funsigned-char, '-fsigned-char' and
+  '-Wimplicit-function-declaration'
+- fixed assignment of const struct in struct
+- line comment fix (reported by Bertram Felgenhauer)
+- initial TMS320C67xx target support (TK)
+- win32 configure
+- regparm() attribute
+- many built-in assembler fixes
+- added '.org', '.fill' and '.previous' assembler directives
+- '-fno-common' option
+- '-Ttext' linker option
+- section alignment fixes
+- bit fields fixes
+- do not generate code for unused inline functions
+- '-oformat' linker option. 
+- added 'binary' output format.
+
+version 0.9.20:
+
+- added '-w' option
+- added '.gnu.linkonce' ELF sections support
+- fixed libc linking when running in memory (avoid 'stat' function
+  errors).
+- extended '-run' option to be able to give several arguments to a C
+  script.
+
+version 0.9.19:
+
+- "alacarte" linking (Dave Long)
+- simpler function call
+- more strict type checks
+- added 'const' and 'volatile' support and associated warnings
+- added -Werror, -Wunsupported, -Wwrite-strings, -Wall.
+- added __builtin_types_compatible_p() and __builtin_constant_p()
+- chars support in assembler (Dave Long)
+- .string, .globl, .section, .text, .data and .bss asm directive
+  support (Dave Long)
+- man page generated from tcc-doc.texi
+- fixed macro argument substitution
+- fixed zero argument macro parsing
+- changed license to LGPL
+- added -rdynamic option support
+
+version 0.9.18:
+
+- header fix (time.h)
+- fixed inline asm without operand case
+- fixed 'default:' or 'case x:' with '}' after (incorrect C construct accepted
+  by gcc)
+- added 'A' inline asm constraint.
+
+version 0.9.17:
+
+- PLT generation fix
+- tcc doc fixes (Peter Lund)
+- struct parse fix (signaled by Pedro A. Aranda Gutierrez)
+- better _Bool lvalue support (signaled by Alex Measday)
+- function parameters must be converted to pointers (signaled by Neil Brown)
+- sanitized string and character constant parsing
+- fixed comment parse (signaled by Damian M Gryski)
+- fixed macro function bug (signaled by Philippe Ribet)
+- added configure (initial patch by Mitchell N Charity)
+- added '-run' and '-v' options (initial patch by vlindos)
+- added real date report in __DATE__ and __TIME__ macros
+
+version 0.9.16:
+
+- added assembler language support
+- added GCC inline asm() support
+- fixed multiple variable definitions : uninitialized variables are
+  created as COMMON symbols.
+- optimized macro processing
+- added GCC statement expressions support
+- added GCC local labels support
+- fixed array declaration in old style function parameters
+- support casts in static structure initializations
+- added various __xxx[__] keywords for GCC compatibility
+- ignore __extension__ GCC in an expression or in a type (still not perfect)
+- added '? :' GCC extension support
+
+version 0.9.15:
+
+- compilation fixes for glibc 2.2, gcc 2.95.3 and gcc 3.2.
+- FreeBSD compile fixes. Makefile patches still missing (Carl Drougge).
+- fixed file type guessing if '.' is in the path.
+- fixed tcc_compile_string()
+- add a dummy page in ELF files to fix RX/RW accesses (pageexec at
+  freemail dot hu).
+
+version 0.9.14:
+
+- added #warning. error message if invalid preprocessing directive.
+- added CType structure to ease typing (faster parse).
+- suppressed secondary hash tables (faster parse).
+- rewrote parser by optimizing common cases (faster parse).
+- fixed signed long long comparisons.
+- fixed 'int a(), b();' declaration case.
+- fixed structure init without '{}'.
+- correct alignment support in structures.
+- empty structures support.
+- gcc testsuite now supported.
+- output only warning if implicit integer/pointer conversions.
+- added static bitfield init.
+
+version 0.9.13:
+
+- correct preprocessing token pasting (## operator) in all cases (added
+  preprocessing number token).
+- fixed long long register spill.
+- fixed signed long long '>>'.
+- removed memory leaks.
+- better error handling : processing can continue on link errors. A
+  custom callback can be added to display error messages. Most
+  errors do not call exit() now.
+- ignore -O, -W, -m and -f options
+- added old style function declarations
+- added GCC __alignof__ support.
+- added GCC typeof support.
+- added GCC computed gotos support.
+- added stack backtrace in runtime error message. Improved runtime
+  error position display.
+
+version 0.9.12:
+
+- more fixes for || and && handling.
+- improved '? :' type handling.
+- fixed bound checking generation with structures
+- force '#endif' to be in same file as matching '#if'
+- #include file optimization with '#ifndef #endif' construct detection
+- macro handling optimization
+- added tcc_relocate() and tcc_get_symbol() in libtcc.
+
+version 0.9.11:
+
+- stdarg.h fix for double type (thanks to Philippe Ribet).
+- correct white space characters and added MSDOS newline support.
+- fixed invalid implicit function call type declaration.
+- special macros such as __LINE__ are defined if tested with defined().
+- fixed '!' operator with relocated address.
+- added symbol + offset relocation (fixes some static variable initializers)
+- '-l' option can be specified anywhere. '-c' option yields default
+  output name. added '-r' option for relocatable output.
+- fixed '\nnn' octal parsing.
+- fixed local extern variables declarations.
+
+version 0.9.10:
+
+- fixed lvalue type when saved in local stack.
+- fixed '#include' syntax when using macros.
+- fixed '#line' bug.
+- removed size limit on strings. Unified string constants handling
+  with variable declarations.
+- added correct support for '\xX' in wchar_t strings.
+- added support for bound checking in generated executables
+- fixed -I include order.
+- fixed incorrect function displayed in runtime error.
+
+version 0.9.9:
+
+- fixed preprocessor expression parsing for #if/#elif.
+- relocated debug info (.stab section).
+- relocated bounds info (.bounds section).
+- fixed cast to char of char constants ('\377' is -1 instead of 255)
+- fixed implicit cast for unary plus.
+- strings and '__func__' have now 'char[]' type instead of 'char *'
+  (fixes sizeof() return value).
+- added __start_xxx and __stop_xxx symbols in linker.
+- better DLL creation support (option -shared begins to work).
+- ELF sections and hash tables are resized dynamically.
+- executables and DLLs are stripped by default.
+
+version 0.9.8:
+
+- First version of full ELF linking support (generate objects, static
+  executable, dynamic executable, dynamic libraries). Dynamic library
+  support is not finished (need PIC support in compiler and some
+  patches in symbol exporting).
+- First version of ELF loader for object (.o) and archive (.a) files.
+- Support of simple GNU ld scripts (GROUP and FILE commands)
+- Separated runtime library and bound check code from TCC (smaller
+  compiler core).
+- fixed register reload in float compare.
+- fixed implicit char/short to int casting.
+- allow array type for address of ('&') operator.
+- fixed unused || or && result.
+- added GCC style variadic macro support.
+- optimized bound checking code for array access.
+- tcc includes are now in $(prefix)/lib/tcc/include.
+- more command line options - more consistent handling of multiple
+  input files.
+- added tcc man page (thanks to Cyril Bouthors).
+- uClibc Makefile update
+- converted documentation to texinfo format.
+- added developper's guide in documentation.
+
+version 0.9.7:
+
+- added library API for easy dynamic compilation (see libtcc.h - first
+  draft).
+- fixed long long register spill bug.
+- fixed '? :' register spill bug.
+
+version 0.9.6:
+
+- added floating point constant propagation (fixes negative floating
+  point constants bug).
+
+version 0.9.5:
+
+ - uClibc patches (submitted by Alfonso Martone).
+ - error reporting fix
+ - added CONFIG_TCC_BCHECK to get smaller code if needed.
+
+version 0.9.4:
+
+ - windows port (currently cannot use -g, -b and dll functions).
+ - faster and simpler I/O handling.
+ - '-D' option works in all cases.
+ - preprocessor fixes (#elif and empty macro args)
+ - floating point fixes
+ - first code for CIL generation (does not work yet)
+
+version 0.9.3:
+
+ - better and smaller code generator.
+ - full ISOC99 64 bit 'long long' support.
+ - full 32 bit 'float', 64 bit 'double' and 96 bit 'long double' support.
+ - added '-U' option.
+ - added assembly sections support. 
+ - even faster startup time by mmaping sections instead of mallocing them.
+ - added GNUC __attribute__ keyword support (currently supports
+    'section' and 'aligned' attributes).
+ - added ELF file output (only usable for debugging now)
+ - added debug symbol generation (STAB format).
+ - added integrated runtime error analysis ('-g' option: print clear
+   run time error messages instead of "Segmentation fault").
+ - added first version of tiny memory and bound checker ('-b' option).
+
+version 0.9.2:
+
+ - even faster parsing.
+ - various syntax parsing fixes.
+ - fixed external relocation handling for variables or functions pointers.
+ - better function pointers type handling.
+ - can compile multiple files (-i option).
+ - ANSI C bit fields are supported.
+ - beginning of float/double/long double support.
+ - beginning of long long support.
+
+version 0.9.1:
+
+ - full ISOC99 initializers handling.
+ - compound literals.
+ - structures handle in assignments and as function param or return value.
+ - wide chars and strings.
+ - macro bug fix
+
+version 0.9:
+ - initial version.
Index: /EcnlProtoTool/trunk/tcc-0.9.26/Makefile
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/Makefile	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/Makefile	(revision 279)
@@ -0,0 +1,350 @@
+#
+# Tiny C Compiler Makefile
+#
+
+TOP ?= .
+include $(TOP)/config.mak
+VPATH = $(top_srcdir)
+
+CPPFLAGS = -I$(TOP) # for config.h
+
+ifeq (-$(findstring gcc,$(CC))-,-gcc-)
+ifeq (-$(findstring $(GCC_MAJOR),01)-,--)
+CFLAGS+=-fno-strict-aliasing
+ifeq (-$(findstring $(GCC_MAJOR),23)-,--)
+CFLAGS+=-Wno-pointer-sign -Wno-sign-compare
+ifeq (-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-4--)
+CFLAGS+=-D_FORTIFY_SOURCE=0
+else
+CFLAGS+=-Wno-unused-result
+endif
+endif
+endif
+else # not GCC
+ifeq (-$(findstring clang,$(CC))-,-clang-)
+# make clang accept gnuisms in libtcc1.c
+CFLAGS+=-fheinous-gnu-extensions
+endif
+endif
+
+CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC
+CFLAGS_P=$(CFLAGS) -pg -static
+LIBS_P=
+LDFLAGS_P=$(LDFLAGS)
+
+ifdef CONFIG_WIN64
+CONFIG_WIN32=yes
+endif
+
+ifndef CONFIG_WIN32
+LIBS=-lm
+ifndef CONFIG_NOLDL
+LIBS+=-ldl
+endif
+endif
+
+# make libtcc as static or dynamic library?
+ifdef DISABLE_STATIC
+LIBTCC=libtcc.so.1.0
+LINK_LIBTCC=-Wl,-rpath,"$(libdir)"
+ifdef DISABLE_RPATH
+LINK_LIBTCC=
+endif
+else
+LIBTCC=libtcc.a
+LINK_LIBTCC=
+endif
+
+CONFIG_$(ARCH) = yes
+NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
+NATIVE_DEFINES_$(CONFIG_x86-64) += -DTCC_TARGET_X86_64
+NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
+NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
+NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM -DWITHOUT_LIBTCC
+NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
+NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
+NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
+NATIVE_DEFINES += $(NATIVE_DEFINES_yes)
+
+ifeq ($(TOP),.)
+
+PROGS=tcc$(EXESUF)
+I386_CROSS = i386-tcc$(EXESUF)
+WIN32_CROSS = i386-win32-tcc$(EXESUF)
+WIN64_CROSS = x86_64-win32-tcc$(EXESUF)
+WINCE_CROSS = arm-win32-tcc$(EXESUF)
+X64_CROSS = x86_64-tcc$(EXESUF)
+ARM_FPA_CROSS = arm-fpa-tcc$(EXESUF)
+ARM_FPA_LD_CROSS = arm-fpa-ld-tcc$(EXESUF)
+ARM_VFP_CROSS = arm-vfp-tcc$(EXESUF)
+ARM_EABI_CROSS = arm-eabi-tcc$(EXESUF)
+ARM_CROSS = $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS)
+C67_CROSS = c67-tcc$(EXESUF)
+
+CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
+CORE_FILES += tcc.h config.h libtcc.h tcctok.h
+CORE_FILES += dummy.c
+I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
+WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
+WIN64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h tccpe.c
+WINCE_FILES = $(CORE_FILES) arm-gen.c tccpe.c
+X86_64_FILES = $(CORE_FILES) x86_64-gen.c i386-asm.c x86_64-asm.h
+ARM_FILES = $(CORE_FILES) arm-gen.c
+C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
+
+ifdef CONFIG_WIN64
+PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
+NATIVE_FILES=$(WIN64_FILES)
+PROGS_CROSS=$(WIN32_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(C67_CROSS)
+LIBTCC1_CROSS=lib/i386-win32/libtcc1.a
+LIBTCC1=libtcc1.a
+else ifdef CONFIG_WIN32
+PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
+NATIVE_FILES=$(WIN32_FILES)
+PROGS_CROSS=$(WIN64_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(C67_CROSS)
+LIBTCC1_CROSS=lib/x86_64-win32/libtcc1.a
+LIBTCC1=libtcc1.a
+else ifeq ($(ARCH),i386)
+NATIVE_FILES=$(I386_FILES)
+PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(C67_CROSS)
+LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a
+LIBTCC1=libtcc1.a
+else ifeq ($(ARCH),x86-64)
+NATIVE_FILES=$(X86_64_FILES)
+PROGS_CROSS=$(I386_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(C67_CROSS)
+LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a lib/i386/libtcc1.a
+LIBTCC1=libtcc1.a
+else ifeq ($(ARCH),arm)
+NATIVE_FILES=$(ARM_FILES)
+PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(C67_CROSS)
+endif
+
+ifeq ($(TARGETOS),Darwin)
+PROGS+=tiny_libmaker$(EXESUF)
+endif
+
+ifdef CONFIG_USE_LIBGCC
+LIBTCC1=
+endif
+
+TCCLIBS = $(LIBTCC1) $(LIBTCC)
+TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info
+
+ifdef CONFIG_CROSS
+PROGS+=$(PROGS_CROSS)
+TCCLIBS+=$(LIBTCC1_CROSS)
+endif
+
+all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
+
+# Host Tiny C Compiler
+tcc$(EXESUF): tcc.o $(LIBTCC)
+	$(CC) -o $@ $^ $(LIBS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LINK_LIBTCC)
+
+# Cross Tiny C Compilers
+%-tcc$(EXESUF): tcc.c
+	$(CC) -o $@ $< -DONE_SOURCE $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LIBS) $(LDFLAGS)
+
+# profiling version
+tcc_p$(EXESUF): $(NATIVE_FILES)
+	$(CC) -o $@ $< -DONE_SOURCE $(NATIVE_DEFINES) $(CPPFLAGS_P) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
+
+$(I386_CROSS): DEFINES = -DTCC_TARGET_I386 \
+    -DCONFIG_TCCDIR="\"$(tccdir)/i386\""
+$(X64_CROSS): DEFINES = -DTCC_TARGET_X86_64
+$(WIN32_CROSS): DEFINES = -DTCC_TARGET_I386 -DTCC_TARGET_PE \
+    -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
+    -DCONFIG_TCC_LIBPATHS="\"{B}/lib/32;{B}/lib\""
+$(WIN64_CROSS): DEFINES = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE \
+    -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
+    -DCONFIG_TCC_LIBPATHS="\"{B}/lib/64;{B}/lib\""
+$(WINCE_CROSS): DEFINES = -DTCC_TARGET_PE
+$(C67_CROSS): DEFINES = -DTCC_TARGET_C67
+$(ARM_FPA_CROSS): DEFINES = -DTCC_TARGET_ARM
+$(ARM_FPA_LD_CROSS)$(EXESUF): DEFINES = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12
+$(ARM_VFP_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_VFP
+$(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI
+
+$(I386_CROSS): $(I386_FILES)
+$(X64_CROSS): $(X86_64_FILES)
+$(WIN32_CROSS): $(WIN32_FILES)
+$(WIN64_CROSS): $(WIN64_FILES)
+$(WINCE_CROSS): $(WINCE_FILES)
+$(C67_CROSS): $(C67_FILES)
+$(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES)
+
+# libtcc generation and test
+ifndef ONE_SOURCE
+LIBTCC_OBJ = $(filter-out tcc.o,$(patsubst %.c,%.o,$(filter %.c,$(NATIVE_FILES))))
+LIBTCC_INC = $(filter %.h,$(CORE_FILES)) $(filter-out $(CORE_FILES),$(NATIVE_FILES))
+else
+LIBTCC_OBJ = libtcc.o
+LIBTCC_INC = $(NATIVE_FILES)
+libtcc.o : NATIVE_DEFINES += -DONE_SOURCE
+endif
+
+$(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC)
+	$(CC) -o $@ -c $< $(NATIVE_DEFINES) $(CPPFLAGS) $(CFLAGS)
+
+libtcc.a: $(LIBTCC_OBJ)
+	$(AR) rcs $@ $^
+
+libtcc.so.1.0: $(LIBTCC_OBJ)
+	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
+
+libtcc.so.1.0: CFLAGS+=-fPIC
+
+# windows utilities
+tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c
+	$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
+tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
+	$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
+
+# TinyCC runtime libraries
+libtcc1.a : FORCE
+	$(MAKE) -C lib native
+lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
+	$(MAKE) -C lib cross TARGET=$*
+
+FORCE:
+
+# install
+TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
+INSTALL=install
+ifdef STRIP_BINARIES
+INSTALLBIN=$(INSTALL) -s
+else
+INSTALLBIN=$(INSTALL)
+endif
+
+ifndef CONFIG_WIN32
+install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
+	mkdir -p "$(bindir)"
+ifeq ($(CC),tcc)
+	$(INSTALL) -m755 $(PROGS) "$(bindir)"
+else
+	$(INSTALLBIN) -m755 $(PROGS) "$(bindir)"
+endif
+	mkdir -p "$(mandir)/man1"
+	-$(INSTALL) tcc.1 "$(mandir)/man1"
+	mkdir -p "$(infodir)"
+	-$(INSTALL) tcc-doc.info "$(infodir)"
+	mkdir -p "$(tccdir)"
+	mkdir -p "$(tccdir)/include"
+ifneq ($(LIBTCC1),)
+	$(INSTALL) -m644 $(LIBTCC1) "$(tccdir)"
+endif
+	$(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) "$(tccdir)/include"
+	mkdir -p "$(libdir)"
+	$(INSTALL) -m755 $(LIBTCC) "$(libdir)"
+ifdef DISABLE_STATIC
+	ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1"
+	ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so"
+endif
+	mkdir -p "$(includedir)"
+	$(INSTALL) -m644 $(top_srcdir)/libtcc.h "$(includedir)"
+	mkdir -p "$(docdir)"
+	-$(INSTALL) -m644 tcc-doc.html "$(docdir)"
+ifdef CONFIG_CROSS
+	mkdir -p "$(tccdir)/win32/lib/32"
+	mkdir -p "$(tccdir)/win32/lib/64"
+ifeq ($(ARCH),x86-64)
+	mkdir -p "$(tccdir)/i386"
+	$(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386"
+	cp -r "$(tccdir)/include" "$(tccdir)/i386"
+endif
+	$(INSTALL) -m644 win32/lib/*.def "$(tccdir)/win32/lib"
+	$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/win32/lib/32"
+	$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/win32/lib/64"
+	cp -r win32/include/. "$(tccdir)/win32/include"
+	cp -r include/. "$(tccdir)/win32/include"
+endif
+
+uninstall:
+	rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
+	rm -fv $(foreach P,$(LIBTCC1),"$(tccdir)/$P")
+	rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
+	rm -fv "$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
+	rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
+	rm -fv "$(libdir)/libtcc.so*"
+	rm -rf "$(tccdir)/win32"
+	-rmdir $(tccdir)/include
+ifeq ($(ARCH),x86-64)
+	rm -rf "$(tccdir)/i386"
+endif
+else
+# on windows
+install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
+	mkdir -p "$(tccdir)"
+	mkdir -p "$(tccdir)/lib"
+	mkdir -p "$(tccdir)/include"
+	mkdir -p "$(tccdir)/examples"
+	mkdir -p "$(tccdir)/doc"
+	mkdir -p "$(tccdir)/libtcc"
+	$(INSTALLBIN) -m755 $(PROGS) "$(tccdir)"
+	$(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(tccdir)/lib"
+	cp -r win32/include/. "$(tccdir)/include"
+	cp -r win32/examples/. "$(tccdir)/examples"
+	$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
+	$(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc"
+	$(INSTALL) -m644 $(LIBTCC) libtcc.h "$(tccdir)/libtcc"
+ifdef CONFIG_CROSS
+	mkdir -p "$(tccdir)/lib/32"
+	mkdir -p "$(tccdir)/lib/64"
+	-$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/lib/32"
+	-$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/lib/64"
+endif
+
+uninstall:
+	rm -rfv "$(tccdir)/*"
+endif
+
+# documentation and man page
+tcc-doc.html: tcc-doc.texi
+	-texi2html -monolithic -number $<
+
+tcc.1: tcc-doc.texi
+	-$(top_srcdir)/texi2pod.pl $< tcc.pod
+	-pod2man --section=1 --center=" " --release=" " tcc.pod > $@
+
+tcc-doc.info: tcc-doc.texi
+	-makeinfo $<
+
+# in tests subdir
+export LIBTCC1
+
+%est:
+	$(MAKE) -C tests $@
+
+clean:
+	rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.exe libtcc_test$(EXESUF)
+	$(MAKE) -C tests $@
+ifneq ($(LIBTCC1),)
+	$(MAKE) -C lib $@
+endif
+
+distclean: clean
+	rm -vf config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
+
+config.mak:
+	@echo "Please run ./configure."
+	@exit 1
+
+# create release tarball from *current* git branch (including tcc-doc.html
+# and converting two files to CRLF)
+TCC-VERSION := tcc-$(shell cat $(top_srcdir)/VERSION)
+tar:    tcc-doc.html
+	mkdir $(TCC-VERSION)
+	( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
+	cp tcc-doc.html $(TCC-VERSION)
+	for f in tcc-win32.txt build-tcc.bat ; do \
+	    cat win32/$$f | sed 's,\(.*\),\1\r,g' > $(TCC-VERSION)/win32/$$f ; \
+	done
+	tar cjf $(TCC-VERSION).tar.bz2 $(TCC-VERSION)
+	rm -rf $(TCC-VERSION)
+	git reset
+
+
+.PHONY: all clean tar distclean install uninstall FORCE
+
+endif # ifeq ($(TOP),.)
Index: /EcnlProtoTool/trunk/tcc-0.9.26/README
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/README	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/README	(revision 279)
@@ -0,0 +1,101 @@
+Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler
+-----------------------------------------------------------------------
+
+Features:
+--------
+
+- SMALL! You can compile and execute C code everywhere, for example on
+  rescue disks.
+
+- FAST! tcc generates optimized x86 code. No byte code
+  overhead. Compile, assemble and link about 7 times faster than 'gcc
+  -O0'.
+
+- UNLIMITED! Any C dynamic library can be used directly. TCC is
+  heading torward full ISOC99 compliance. TCC can of course compile
+  itself.
+
+- SAFE! tcc includes an optional memory and bound checker. Bound
+  checked code can be mixed freely with standard code.
+
+- Compile and execute C source directly. No linking or assembly
+  necessary. Full C preprocessor included. 
+
+- C script supported : just add '#!/usr/local/bin/tcc -run' at the first
+  line of your C source, and execute it directly from the command
+  line.
+
+Documentation:
+-------------
+
+1) Installation on a i386 Linux host (for Windows read tcc-win32.txt)
+
+   ./configure
+   make
+   make test
+   make install
+
+Alternatively, out-of-tree builds are supported: you may use different
+directories to hold build objects, kept separate from your source tree:
+
+   mkdir _build
+   cd _build
+   ../configure
+   make
+   make test
+   make install
+
+By default, tcc is installed in /usr/local/bin.
+./configure --help  shows configuration options.
+
+
+2) Introduction
+
+We assume here that you know ANSI C. Look at the example ex1.c to know
+what the programs look like.
+
+The include file <tcclib.h> can be used if you want a small basic libc
+include support (especially useful for floppy disks). Of course, you
+can also use standard headers, although they are slower to compile.
+
+You can begin your C script with '#!/usr/local/bin/tcc -run' on the first
+line and set its execute bits (chmod a+x your_script). Then, you can
+launch the C code as a shell or perl script :-) The command line
+arguments are put in 'argc' and 'argv' of the main functions, as in
+ANSI C.
+
+3) Examples
+
+ex1.c: simplest example (hello world). Can also be launched directly
+as a script: './ex1.c'.
+
+ex2.c: more complicated example: find a number with the four
+operations given a list of numbers (benchmark).
+
+ex3.c: compute fibonacci numbers (benchmark).
+
+ex4.c: more complicated: X11 program. Very complicated test in fact
+because standard headers are being used ! As for ex1.c, can also be launched
+directly as a script: './ex4.c'.
+
+ex5.c: 'hello world' with standard glibc headers.
+
+tcc.c: TCC can of course compile itself. Used to check the code
+generator.
+
+tcctest.c: auto test for TCC which tests many subtle possible bugs. Used
+when doing 'make test'.
+
+4) Full Documentation
+
+Please read tcc-doc.html to have all the features of TCC.
+
+Additional information is available for the Windows port in tcc-win32.txt.
+
+License:
+-------
+
+TCC is distributed under the GNU Lesser General Public License (see
+COPYING file).
+
+Fabrice Bellard.
Index: /EcnlProtoTool/trunk/tcc-0.9.26/TODO
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/TODO	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/TODO	(revision 279)
@@ -0,0 +1,93 @@
+TODO list:
+
+Bugs:
+
+- fix macro substitution with nested definitions (ShangHongzhang)
+- FPU st(0) is left unclean (kwisatz haderach). Incompatible with
+  optimized gcc/msc code
+
+- constructors
+- cast bug (Peter Wang)
+- define incomplete type if defined several times (Peter Wang).
+- configure --cc=tcc (still one bug in libtcc1.c)
+- test binutils/gcc compile
+- tci patch + argument.
+- see -lxxx bug (Michael Charity).
+- see transparent union pb in /urs/include/sys/socket.h
+- precise behaviour of typeof with arrays ? (__put_user macro)
+  but should suffice for most cases)
+- handle '? x, y : z' in unsized variable initialization (',' is
+  considered incorrectly as separator in preparser)
+- transform functions to function pointers in function parameters
+  (net/ipv4/ip_output.c)
+- fix function pointer type display
+- check lcc test suite -> fix bitfield binary operations
+- check section alignment in C
+- fix invalid cast in comparison 'if (v == (int8_t)v)'
+- finish varargs.h support (gcc 3.2 testsuite issue)
+- fix static functions declared inside block
+- fix multiple unions init
+- sizeof, alignof, typeof can still generate code in some cases.
+- Fix the remaining libtcc memory leaks.
+- make libtcc fully reentrant (except for the compilation stage itself).
+
+Bound checking:
+
+- '-b' bug.
+- fix bound exit on RedHat 7.3
+- setjmp is not supported properly in bound checking.
+- fix bound check code with '&' on local variables (currently done
+  only for local arrays).
+- bound checking and float/long long/struct copy code. bound
+  checking and symbol + offset optimization
+
+Missing features:
+
+- disable-asm and disable-bcheck options
+- __builtin_expect()
+- improve '-E' option.
+- atexit (Nigel Horne)
+- packed attribute
+- C99: add complex types (gcc 3.2 testsuite issue)
+- postfix compound literals (see 20010124-1.c)
+
+Optimizations:
+
+- suppress specific anonymous symbol handling
+- more parse optimizations (=even faster compilation)
+- memory alloc optimizations (=even faster compilation)
+- optimize VT_LOCAL + const
+- better local variables handling (needed for other targets)
+
+Not critical:
+
+- C99: fix multiple compound literals inits in blocks (ISOC99
+  normative example - only relevant when using gotos! -> must add
+  boolean variable to tell if compound literal was already
+  initialized).
+- add PowerPC or ARM code generator and improve codegen for RISC (need
+  to suppress VT_LOCAL and use a base register instead).
+- interactive mode / integrated debugger
+- fix preprocessor symbol redefinition
+- better constant opt (&&, ||, ?:)
+- add portable byte code generator and interpreter for other
+  unsupported architectures.
+- C++: variable declaration in for, minimal 'class' support.
+- win32: __intxx. use resolve for bchecked malloc et al.
+  check exception code (exception filter func).
+- handle void (__attribute__() *ptr)()
+
+Fixed (probably):
+
+- bug with defines:
+    #define spin_lock(lock) do { } while (0)
+    #define wq_spin_lock spin_lock
+    #define TEST() wq_spin_lock(a)
+- typedefs can be structure fields
+- see bugfixes.diff + improvement.diff from Daniel Glockner
+- long long constant evaluation
+- add alloca()
+- gcc '-E' option.
+- #include_next support for /usr/include/limits ?
+- function pointers/lvalues in ? : (linux kernel net/core/dev.c)
+- win32: add __stdcall, check GetModuleHandle for dlls.
Index: /EcnlProtoTool/trunk/tcc-0.9.26/VERSION
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/VERSION	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/VERSION	(revision 279)
@@ -0,0 +1,1 @@
+0.9.26
Index: /EcnlProtoTool/trunk/tcc-0.9.26/arm-gen.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/arm-gen.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/arm-gen.c	(revision 279)
@@ -0,0 +1,2005 @@
+/*
+ *  ARMv4 code generator for TCC
+ * 
+ *  Copyright (c) 2003 Daniel Glöckner
+ *  Copyright (c) 2012 Thomas Preud'homme
+ *
+ *  Based on i386-gen.c by Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef TARGET_DEFS_ONLY
+
+#ifdef TCC_ARM_EABI
+#ifndef TCC_ARM_VFP // Avoid useless warning
+#define TCC_ARM_VFP
+#endif
+#endif
+
+/* number of available registers */
+#ifdef TCC_ARM_VFP
+#define NB_REGS            13
+#else
+#define NB_REGS             9
+#endif
+
+#ifndef TCC_ARM_VERSION
+# define TCC_ARM_VERSION 5
+#endif
+
+/* a register can belong to several classes. The classes must be
+   sorted from more general to more precise (see gv2() code which does
+   assumptions on it). */
+#define RC_INT     0x0001 /* generic integer register */
+#define RC_FLOAT   0x0002 /* generic float register */
+#define RC_R0      0x0004
+#define RC_R1      0x0008 
+#define RC_R2      0x0010
+#define RC_R3      0x0020
+#define RC_R12     0x0040
+#define RC_F0      0x0080
+#define RC_F1      0x0100
+#define RC_F2      0x0200
+#define RC_F3      0x0400
+#ifdef TCC_ARM_VFP
+#define RC_F4      0x0800
+#define RC_F5      0x1000
+#define RC_F6      0x2000
+#define RC_F7      0x4000
+#endif
+#define RC_IRET    RC_R0  /* function return: integer register */
+#define RC_LRET    RC_R1  /* function return: second integer register */
+#define RC_FRET    RC_F0  /* function return: float register */
+
+/* pretty names for the registers */
+enum {
+    TREG_R0 = 0,
+    TREG_R1,
+    TREG_R2,
+    TREG_R3,
+    TREG_R12,
+    TREG_F0,
+    TREG_F1,
+    TREG_F2,
+    TREG_F3,
+#ifdef TCC_ARM_VFP
+    TREG_F4,
+    TREG_F5,
+    TREG_F6,
+    TREG_F7,
+#endif
+};
+
+#ifdef TCC_ARM_VFP
+#define T2CPR(t) (((t) & VT_BTYPE) != VT_FLOAT ? 0x100 : 0)
+#endif
+
+/* return registers for function */
+#define REG_IRET TREG_R0 /* single word int return register */
+#define REG_LRET TREG_R1 /* second word return register (for long long) */
+#define REG_FRET TREG_F0 /* float return register */
+
+#ifdef TCC_ARM_EABI
+#define TOK___divdi3 TOK___aeabi_ldivmod
+#define TOK___moddi3 TOK___aeabi_ldivmod
+#define TOK___udivdi3 TOK___aeabi_uldivmod
+#define TOK___umoddi3 TOK___aeabi_uldivmod
+#endif
+
+/* defined if function parameters must be evaluated in reverse order */
+#define INVERT_FUNC_PARAMS
+
+/* defined if structures are passed as pointers. Otherwise structures
+   are directly pushed on stack. */
+//#define FUNC_STRUCT_PARAM_AS_PTR
+
+/* pointer size, in bytes */
+#define PTR_SIZE 4
+
+/* long double size and alignment, in bytes */
+#ifdef TCC_ARM_VFP
+#define LDOUBLE_SIZE  8
+#endif
+
+#ifndef LDOUBLE_SIZE
+#define LDOUBLE_SIZE  8
+#endif
+
+#ifdef TCC_ARM_EABI
+#define LDOUBLE_ALIGN 8
+#else
+#define LDOUBLE_ALIGN 4
+#endif
+
+/* maximum alignment (for aligned attribute support) */
+#define MAX_ALIGN     8
+
+#define CHAR_IS_UNSIGNED
+
+/******************************************************/
+/* ELF defines */
+
+#define EM_TCC_TARGET EM_ARM
+
+/* relocation type for 32 bit data relocation */
+#define R_DATA_32   R_ARM_ABS32
+#define R_DATA_PTR  R_ARM_ABS32
+#define R_JMP_SLOT  R_ARM_JUMP_SLOT
+#define R_COPY      R_ARM_COPY
+
+#define ELF_START_ADDR 0x00008000
+#define ELF_PAGE_SIZE  0x1000
+
+/******************************************************/
+#else /* ! TARGET_DEFS_ONLY */
+/******************************************************/
+#include "tcc.h"
+
+ST_DATA const int reg_classes[NB_REGS] = {
+    /* r0 */ RC_INT | RC_R0,
+    /* r1 */ RC_INT | RC_R1,
+    /* r2 */ RC_INT | RC_R2,
+    /* r3 */ RC_INT | RC_R3,
+    /* r12 */ RC_INT | RC_R12,
+    /* f0 */ RC_FLOAT | RC_F0,
+    /* f1 */ RC_FLOAT | RC_F1,
+    /* f2 */ RC_FLOAT | RC_F2,
+    /* f3 */ RC_FLOAT | RC_F3,
+#ifdef TCC_ARM_VFP
+ /* d4/s8 */ RC_FLOAT | RC_F4,
+/* d5/s10 */ RC_FLOAT | RC_F5,
+/* d6/s12 */ RC_FLOAT | RC_F6,
+/* d7/s14 */ RC_FLOAT | RC_F7,
+#endif
+};
+
+static int func_sub_sp_offset, last_itod_magic;
+static int leaffunc;
+
+#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
+static CType float_type, double_type, func_float_type, func_double_type;
+ST_FUNC void arm_init_types(void)
+{
+    float_type.t = VT_FLOAT;
+    double_type.t = VT_DOUBLE;
+    func_float_type.t = VT_FUNC;
+    func_float_type.ref = sym_push(SYM_FIELD, &float_type, FUNC_CDECL, FUNC_OLD);
+    func_double_type.t = VT_FUNC;
+    func_double_type.ref = sym_push(SYM_FIELD, &double_type, FUNC_CDECL, FUNC_OLD);
+}
+#else
+#define func_float_type func_old_type
+#define func_double_type func_old_type
+#define func_ldouble_type func_old_type
+ST_FUNC void arm_init_types(void) {}
+#endif
+
+static int two2mask(int a,int b) {
+  return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT);
+}
+
+static int regmask(int r) {
+  return reg_classes[r]&~(RC_INT|RC_FLOAT);
+}
+
+/******************************************************/
+
+void o(unsigned int i)
+{
+  /* this is a good place to start adding big-endian support*/
+  int ind1;
+
+  ind1 = ind + 4;
+  if (!cur_text_section)
+    tcc_error("compiler error! This happens f.ex. if the compiler\n"
+         "can't evaluate constant expressions outside of a function.");
+  if (ind1 > cur_text_section->data_allocated)
+    section_realloc(cur_text_section, ind1);
+  cur_text_section->data[ind++] = i&255;
+  i>>=8;
+  cur_text_section->data[ind++] = i&255;
+  i>>=8; 
+  cur_text_section->data[ind++] = i&255;
+  i>>=8;
+  cur_text_section->data[ind++] = i;
+}
+
+static uint32_t stuff_const(uint32_t op, uint32_t c)
+{
+  int try_neg=0;
+  uint32_t nc = 0, negop = 0;
+
+  switch(op&0x1F00000)
+  {
+    case 0x800000: //add
+    case 0x400000: //sub
+      try_neg=1;
+      negop=op^0xC00000;
+      nc=-c;
+      break;
+    case 0x1A00000: //mov
+    case 0x1E00000: //mvn
+      try_neg=1;
+      negop=op^0x400000;
+      nc=~c;
+      break;
+    case 0x200000: //xor
+      if(c==~0)
+	return (op&0xF010F000)|((op>>16)&0xF)|0x1E00000;
+      break;
+    case 0x0: //and
+      if(c==~0)
+	return (op&0xF010F000)|((op>>16)&0xF)|0x1A00000;
+    case 0x1C00000: //bic
+      try_neg=1;
+      negop=op^0x1C00000;
+      nc=~c;
+      break;
+    case 0x1800000: //orr
+      if(c==~0)
+	return (op&0xFFF0FFFF)|0x1E00000;
+      break;
+  }
+  do {
+    uint32_t m;
+    int i;
+    if(c<256) /* catch undefined <<32 */
+      return op|c;
+    for(i=2;i<32;i+=2) {
+      m=(0xff>>i)|(0xff<<(32-i));
+      if(!(c&~m))
+	return op|(i<<7)|(c<<i)|(c>>(32-i));
+    }
+    op=negop;
+    c=nc;
+  } while(try_neg--);
+  return 0;
+}
+
+
+//only add,sub
+void stuff_const_harder(uint32_t op, uint32_t v) {
+  uint32_t x;
+  x=stuff_const(op,v);
+  if(x)
+    o(x);
+  else {
+    uint32_t a[16], nv, no, o2, n2;
+    int i,j,k;
+    a[0]=0xff;
+    o2=(op&0xfff0ffff)|((op&0xf000)<<4);;
+    for(i=1;i<16;i++)
+      a[i]=(a[i-1]>>2)|(a[i-1]<<30);
+    for(i=0;i<12;i++)
+      for(j=i<4?i+12:15;j>=i+4;j--)
+	if((v&(a[i]|a[j]))==v) {
+	  o(stuff_const(op,v&a[i]));
+	  o(stuff_const(o2,v&a[j]));
+	  return;
+	}
+    no=op^0xC00000;
+    n2=o2^0xC00000;
+    nv=-v;
+    for(i=0;i<12;i++)
+      for(j=i<4?i+12:15;j>=i+4;j--)
+	if((nv&(a[i]|a[j]))==nv) {
+	  o(stuff_const(no,nv&a[i]));
+	  o(stuff_const(n2,nv&a[j]));
+	  return;
+	}
+    for(i=0;i<8;i++)
+      for(j=i+4;j<12;j++)
+	for(k=i<4?i+12:15;k>=j+4;k--)
+	  if((v&(a[i]|a[j]|a[k]))==v) {
+	    o(stuff_const(op,v&a[i]));
+	    o(stuff_const(o2,v&a[j]));
+	    o(stuff_const(o2,v&a[k]));
+	    return;
+	  }
+    no=op^0xC00000;
+    nv=-v;
+    for(i=0;i<8;i++)
+      for(j=i+4;j<12;j++)
+	for(k=i<4?i+12:15;k>=j+4;k--)
+	  if((nv&(a[i]|a[j]|a[k]))==nv) {
+	    o(stuff_const(no,nv&a[i]));
+	    o(stuff_const(n2,nv&a[j]));
+	    o(stuff_const(n2,nv&a[k]));
+	    return;
+	  }
+    o(stuff_const(op,v&a[0]));
+    o(stuff_const(o2,v&a[4]));
+    o(stuff_const(o2,v&a[8]));
+    o(stuff_const(o2,v&a[12]));
+  }
+}
+
+ST_FUNC uint32_t encbranch(int pos, int addr, int fail)
+{
+  addr-=pos+8;
+  addr/=4;
+  if(addr>=0x1000000 || addr<-0x1000000) {
+    if(fail)
+      tcc_error("FIXME: function bigger than 32MB");
+    return 0;
+  }
+  return 0x0A000000|(addr&0xffffff);
+}
+
+int decbranch(int pos)
+{
+  int x;
+  x=*(uint32_t *)(cur_text_section->data + pos);
+  x&=0x00ffffff;
+  if(x&0x800000)
+    x-=0x1000000;
+  return x*4+pos+8;
+}
+
+/* output a symbol and patch all calls to it */
+void gsym_addr(int t, int a)
+{
+  uint32_t *x;
+  int lt;
+  while(t) {
+    x=(uint32_t *)(cur_text_section->data + t);
+    t=decbranch(lt=t);
+    if(a==lt+4)
+      *x=0xE1A00000; // nop
+    else {
+      *x &= 0xff000000;
+      *x |= encbranch(lt,a,1);
+    }
+  }
+}
+
+void gsym(int t)
+{
+  gsym_addr(t, ind);
+}
+
+#ifdef TCC_ARM_VFP
+static uint32_t vfpr(int r)
+{
+  if(r<TREG_F0 || r>TREG_F7)
+    tcc_error("compiler error! register %i is no vfp register",r);
+  return r-5;
+}
+#else
+static uint32_t fpr(int r)
+{
+  if(r<TREG_F0 || r>TREG_F3)
+    tcc_error("compiler error! register %i is no fpa register",r);
+  return r-5;
+}
+#endif
+
+static uint32_t intr(int r)
+{
+  if(r==4)
+    return 12;
+  if((r<0 || r>4) && r!=14)
+    tcc_error("compiler error! register %i is no int register",r);
+  return r;
+}
+
+static void calcaddr(uint32_t *base, int *off, int *sgn, int maxoff, unsigned shift)
+{
+  if(*off>maxoff || *off&((1<<shift)-1)) {
+    uint32_t x, y;
+    x=0xE280E000;
+    if(*sgn)
+      x=0xE240E000;
+    x|=(*base)<<16;
+    *base=14; // lr
+    y=stuff_const(x,*off&~maxoff);
+    if(y) {
+      o(y);
+      *off&=maxoff;
+      return;
+    }
+    y=stuff_const(x,(*off+maxoff)&~maxoff);
+    if(y) {
+      o(y);
+      *sgn=!*sgn;
+      *off=((*off+maxoff)&~maxoff)-*off;
+      return;
+    }
+    stuff_const_harder(x,*off&~maxoff);
+    *off&=maxoff;
+  }
+}
+
+static uint32_t mapcc(int cc)
+{
+  switch(cc)
+  {
+    case TOK_ULT:
+      return 0x30000000; /* CC/LO */
+    case TOK_UGE:
+      return 0x20000000; /* CS/HS */
+    case TOK_EQ:
+      return 0x00000000; /* EQ */
+    case TOK_NE:
+      return 0x10000000; /* NE */
+    case TOK_ULE:
+      return 0x90000000; /* LS */
+    case TOK_UGT:
+      return 0x80000000; /* HI */
+    case TOK_Nset:
+      return 0x40000000; /* MI */
+    case TOK_Nclear:
+      return 0x50000000; /* PL */
+    case TOK_LT:
+      return 0xB0000000; /* LT */
+    case TOK_GE:
+      return 0xA0000000; /* GE */
+    case TOK_LE:
+      return 0xD0000000; /* LE */
+    case TOK_GT:
+      return 0xC0000000; /* GT */
+  }
+  tcc_error("unexpected condition code");
+  return 0xE0000000; /* AL */
+}
+
+static int negcc(int cc)
+{
+  switch(cc)
+  {
+    case TOK_ULT:
+      return TOK_UGE;
+    case TOK_UGE:
+      return TOK_ULT;
+    case TOK_EQ:
+      return TOK_NE;
+    case TOK_NE:
+      return TOK_EQ;
+    case TOK_ULE:
+      return TOK_UGT;
+    case TOK_UGT:
+      return TOK_ULE;
+    case TOK_Nset:
+      return TOK_Nclear;
+    case TOK_Nclear:
+      return TOK_Nset;
+    case TOK_LT:
+      return TOK_GE;
+    case TOK_GE:
+      return TOK_LT;
+    case TOK_LE:
+      return TOK_GT;
+    case TOK_GT:
+      return TOK_LE;
+  }
+  tcc_error("unexpected condition code");
+  return TOK_NE;
+}
+
+/* load 'r' from value 'sv' */
+void load(int r, SValue *sv)
+{
+  int v, ft, fc, fr, sign;
+  uint32_t op;
+  SValue v1;
+
+  fr = sv->r;
+  ft = sv->type.t;
+  fc = sv->c.ul;
+
+  if(fc>=0)
+    sign=0;
+  else {
+    sign=1;
+    fc=-fc;
+  }
+  
+  v = fr & VT_VALMASK;
+  if (fr & VT_LVAL) {
+    uint32_t base = 0xB; // fp
+    if(v == VT_LLOCAL) {
+      v1.type.t = VT_PTR;
+      v1.r = VT_LOCAL | VT_LVAL;
+      v1.c.ul = sv->c.ul;
+      load(base=14 /* lr */, &v1);
+      fc=sign=0;
+      v=VT_LOCAL;
+    } else if(v == VT_CONST) {
+      v1.type.t = VT_PTR;
+      v1.r = fr&~VT_LVAL;
+      v1.c.ul = sv->c.ul;
+      v1.sym=sv->sym;
+      load(base=14, &v1);
+      fc=sign=0;
+      v=VT_LOCAL;
+    } else if(v < VT_CONST) {
+      base=intr(v);
+      fc=sign=0;
+      v=VT_LOCAL;
+    }
+    if(v == VT_LOCAL) {
+      if(is_float(ft)) {
+	calcaddr(&base,&fc,&sign,1020,2);
+#ifdef TCC_ARM_VFP
+        op=0xED100A00; /* flds */
+        if(!sign)
+          op|=0x800000;
+        if ((ft & VT_BTYPE) != VT_FLOAT)
+          op|=0x100;   /* flds -> fldd */
+        o(op|(vfpr(r)<<12)|(fc>>2)|(base<<16));
+#else
+	op=0xED100100;
+	if(!sign)
+	  op|=0x800000;
+#if LDOUBLE_SIZE == 8
+	if ((ft & VT_BTYPE) != VT_FLOAT)
+	  op|=0x8000;
+#else
+	if ((ft & VT_BTYPE) == VT_DOUBLE)
+	  op|=0x8000;
+	else if ((ft & VT_BTYPE) == VT_LDOUBLE)
+	  op|=0x400000;
+#endif
+	o(op|(fpr(r)<<12)|(fc>>2)|(base<<16));
+#endif
+      } else if((ft & (VT_BTYPE|VT_UNSIGNED)) == VT_BYTE
+                || (ft & VT_BTYPE) == VT_SHORT) {
+	calcaddr(&base,&fc,&sign,255,0);
+	op=0xE1500090;
+	if ((ft & VT_BTYPE) == VT_SHORT)
+	  op|=0x20;
+	if ((ft & VT_UNSIGNED) == 0)
+	  op|=0x40;
+	if(!sign)
+	  op|=0x800000;
+	o(op|(intr(r)<<12)|(base<<16)|((fc&0xf0)<<4)|(fc&0xf));
+      } else {
+	calcaddr(&base,&fc,&sign,4095,0);
+	op=0xE5100000;
+	if(!sign)
+	  op|=0x800000;
+        if ((ft & VT_BTYPE) == VT_BYTE)
+          op|=0x400000;
+        o(op|(intr(r)<<12)|fc|(base<<16));
+      }
+      return;
+    }
+  } else {
+    if (v == VT_CONST) {
+      op=stuff_const(0xE3A00000|(intr(r)<<12),sv->c.ul);
+      if (fr & VT_SYM || !op) {
+        o(0xE59F0000|(intr(r)<<12));
+        o(0xEA000000);
+        if(fr & VT_SYM)
+	  greloc(cur_text_section, sv->sym, ind, R_ARM_ABS32);
+        o(sv->c.ul);
+      } else
+        o(op);
+      return;
+    } else if (v == VT_LOCAL) {
+      op=stuff_const(0xE28B0000|(intr(r)<<12),sv->c.ul);
+      if (fr & VT_SYM || !op) {
+	o(0xE59F0000|(intr(r)<<12));
+	o(0xEA000000);
+	if(fr & VT_SYM) // needed ?
+	  greloc(cur_text_section, sv->sym, ind, R_ARM_ABS32);
+	o(sv->c.ul);
+	o(0xE08B0000|(intr(r)<<12)|intr(r));
+      } else
+	o(op);
+      return;
+    } else if(v == VT_CMP) {
+      o(mapcc(sv->c.ul)|0x3A00001|(intr(r)<<12));
+      o(mapcc(negcc(sv->c.ul))|0x3A00000|(intr(r)<<12));
+      return;
+    } else if (v == VT_JMP || v == VT_JMPI) {
+      int t;
+      t = v & 1;
+      o(0xE3A00000|(intr(r)<<12)|t);
+      o(0xEA000000);
+      gsym(sv->c.ul);
+      o(0xE3A00000|(intr(r)<<12)|(t^1));
+      return;
+    } else if (v < VT_CONST) {
+      if(is_float(ft))
+#ifdef TCC_ARM_VFP
+        o(0xEEB00A40|(vfpr(r)<<12)|vfpr(v)|T2CPR(ft)); /* fcpyX */
+#else
+	o(0xEE008180|(fpr(r)<<12)|fpr(v));
+#endif
+      else
+	o(0xE1A00000|(intr(r)<<12)|intr(v));
+      return;
+    }
+  }
+  tcc_error("load unimplemented!");
+}
+
+/* store register 'r' in lvalue 'v' */
+void store(int r, SValue *sv)
+{
+  SValue v1;
+  int v, ft, fc, fr, sign;
+  uint32_t op;
+
+  fr = sv->r;
+  ft = sv->type.t;
+  fc = sv->c.ul;
+
+  if(fc>=0)
+    sign=0;
+  else {
+    sign=1;
+    fc=-fc;
+  }
+  
+  v = fr & VT_VALMASK; 
+  if (fr & VT_LVAL || fr == VT_LOCAL) {
+    uint32_t base = 0xb;
+    if(v < VT_CONST) {
+      base=intr(v);
+      v=VT_LOCAL;
+      fc=sign=0;
+    } else if(v == VT_CONST) {
+      v1.type.t = ft;
+      v1.r = fr&~VT_LVAL;
+      v1.c.ul = sv->c.ul;
+      v1.sym=sv->sym;
+      load(base=14, &v1);
+      fc=sign=0;
+      v=VT_LOCAL;   
+    }
+    if(v == VT_LOCAL) {
+       if(is_float(ft)) {
+	calcaddr(&base,&fc,&sign,1020,2);
+#ifdef TCC_ARM_VFP
+        op=0xED000A00; /* fsts */
+        if(!sign) 
+          op|=0x800000; 
+        if ((ft & VT_BTYPE) != VT_FLOAT) 
+          op|=0x100;   /* fsts -> fstd */
+        o(op|(vfpr(r)<<12)|(fc>>2)|(base<<16));
+#else
+	op=0xED000100;
+	if(!sign)
+	  op|=0x800000;
+#if LDOUBLE_SIZE == 8
+	if ((ft & VT_BTYPE) != VT_FLOAT)
+	  op|=0x8000;
+#else
+	if ((ft & VT_BTYPE) == VT_DOUBLE)
+	  op|=0x8000;
+	if ((ft & VT_BTYPE) == VT_LDOUBLE)
+	  op|=0x400000;
+#endif
+	o(op|(fpr(r)<<12)|(fc>>2)|(base<<16));
+#endif
+	return;
+      } else if((ft & VT_BTYPE) == VT_SHORT) {
+	calcaddr(&base,&fc,&sign,255,0);
+	op=0xE14000B0;
+	if(!sign)
+	  op|=0x800000;
+	o(op|(intr(r)<<12)|(base<<16)|((fc&0xf0)<<4)|(fc&0xf));
+      } else {
+	calcaddr(&base,&fc,&sign,4095,0);
+	op=0xE5000000;
+	if(!sign)
+	  op|=0x800000;
+        if ((ft & VT_BTYPE) == VT_BYTE)
+          op|=0x400000;
+        o(op|(intr(r)<<12)|fc|(base<<16));
+      }
+      return;
+    }
+  }
+  tcc_error("store unimplemented");
+}
+
+static void gadd_sp(int val)
+{
+  stuff_const_harder(0xE28DD000,val);
+}
+
+/* 'is_jmp' is '1' if it is a jump */
+static void gcall_or_jmp(int is_jmp)
+{
+  int r;
+  if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+    uint32_t x;
+    /* constant case */
+    x=encbranch(ind,ind+vtop->c.ul,0);
+    if(x) {
+      if (vtop->r & VT_SYM) {
+	/* relocation case */
+	greloc(cur_text_section, vtop->sym, ind, R_ARM_PC24);
+      } else
+	put_elf_reloc(symtab_section, cur_text_section, ind, R_ARM_PC24, 0);
+      o(x|(is_jmp?0xE0000000:0xE1000000));
+    } else {
+      if(!is_jmp)
+	o(0xE28FE004); // add lr,pc,#4
+      o(0xE51FF004);   // ldr pc,[pc,#-4]
+      if (vtop->r & VT_SYM)
+	greloc(cur_text_section, vtop->sym, ind, R_ARM_ABS32);
+      o(vtop->c.ul);
+    }
+  } else {
+    /* otherwise, indirect call */
+    r = gv(RC_INT);
+    if(!is_jmp)
+      o(0xE1A0E00F);       // mov lr,pc
+    o(0xE1A0F000|intr(r)); // mov pc,r
+  }
+}
+
+#ifdef TCC_ARM_HARDFLOAT
+static int is_float_hgen_aggr(CType *type)
+{
+  if ((type->t & VT_BTYPE) == VT_STRUCT) {
+    struct Sym *ref;
+    int btype, nb_fields = 0;
+
+    ref = type->ref;
+    btype = ref->type.t & VT_BTYPE;
+    if (btype == VT_FLOAT || btype == VT_DOUBLE) {
+      for(; ref && btype == (ref->type.t & VT_BTYPE); ref = ref->next, nb_fields++);
+      return !ref && nb_fields <= 4;
+    }
+  }
+  return 0;
+}
+
+struct avail_regs {
+  /* worst case: f(float, double, 3 float struct, double, 3 float struct, double) */
+  signed char avail[3];
+  int first_hole;
+  int last_hole;
+  int first_free_reg;
+};
+
+#define AVAIL_REGS_INITIALIZER (struct avail_regs) { { 0, 0, 0}, 0, 0, 0 }
+
+/* Assign a register for a CPRC param with correct size and alignment
+ * size and align are in bytes, as returned by type_size */
+int assign_fpreg(struct avail_regs *avregs, int align, int size)
+{
+  int first_reg = 0;
+
+  if (avregs->first_free_reg == -1)
+    return -1;
+  if (align >> 3) { // alignment needed (base type: double)
+    first_reg = avregs->first_free_reg;
+    if (first_reg & 1)
+      avregs->avail[avregs->last_hole++] = first_reg++;
+  } else {
+    if (size == 4 && avregs->first_hole != avregs->last_hole)
+      return avregs->avail[avregs->first_hole++];
+    else
+      first_reg = avregs->first_free_reg;
+  }
+  if (first_reg + size / 4 <= 16) {
+    avregs->first_free_reg = first_reg + size / 4;
+    return first_reg;
+  }
+  avregs->first_free_reg = -1;
+  return -1;
+}
+#endif
+
+/* Generate function call. The function address is pushed first, then
+   all the parameters in call order. This functions pops all the
+   parameters and the function address. */
+void gfunc_call(int nb_args)
+{
+  int size, align, r, args_size, i, ncrn, ncprn, argno, vfp_argno;
+  signed char plan[4][2]={{-1,-1},{-1,-1},{-1,-1},{-1,-1}};
+  SValue *before_stack = NULL; /* SValue before first on stack argument */
+  SValue *before_vfpreg_hfa = NULL; /* SValue before first in VFP reg hfa argument */
+#ifdef TCC_ARM_HARDFLOAT
+  struct avail_regs avregs = AVAIL_REGS_INITIALIZER;
+  signed char vfp_plan[16];
+  int plan2[4+16];
+  int variadic;
+#else
+  int plan2[4]={0,0,0,0};
+#endif
+  int vfp_todo=0;
+  int todo=0, keep;
+
+#ifdef TCC_ARM_HARDFLOAT
+  memset(vfp_plan, -1, sizeof(vfp_plan));
+  memset(plan2, 0, sizeof(plan2));
+  variadic = (vtop[-nb_args].type.ref->c == FUNC_ELLIPSIS);
+#endif
+  r = vtop->r & VT_VALMASK;
+  if (r == VT_CMP || (r & ~1) == VT_JMP)
+    gv(RC_INT);
+#ifdef TCC_ARM_EABI
+  if((vtop[-nb_args].type.ref->type.t & VT_BTYPE) == VT_STRUCT
+     && type_size(&vtop[-nb_args].type.ref->type, &align) <= 4) {
+    SValue tmp;
+    tmp=vtop[-nb_args];
+    vtop[-nb_args]=vtop[-nb_args+1];
+    vtop[-nb_args+1]=tmp;
+    --nb_args;
+  }
+  
+  vpushi(0), nb_args++;
+  vtop->type.t = VT_LLONG;
+#endif
+  ncrn = ncprn = argno = vfp_argno = args_size = 0;
+  /* Assign argument to registers and stack with alignment.
+     If, considering alignment constraints, enough registers of the correct type
+     (core or VFP) are free for the current argument, assign them to it, else
+     allocate on stack with correct alignment. Whenever a structure is allocated
+     in registers or on stack, it is always put on the stack at this stage. The
+     stack is divided in 3 zones. The zone are, from low addresses to high
+     addresses: structures to be loaded in core registers, structures to be
+     loaded in VFP registers, argument allocated to stack. SValue's representing
+     structures in the first zone are moved just after the SValue pointed by
+     before_vfpreg_hfa. SValue's representing structures in the second zone are
+     moved just after the SValue pointer by before_stack. */
+  for(i = nb_args; i-- ;) {
+    int j, assigned_vfpreg = 0;
+    size = type_size(&vtop[-i].type, &align);
+    switch(vtop[-i].type.t & VT_BTYPE) {
+      case VT_STRUCT:
+      case VT_FLOAT:
+      case VT_DOUBLE:
+      case VT_LDOUBLE:
+#ifdef TCC_ARM_HARDFLOAT
+      if (!variadic) {
+        int hfa = 0; /* Homogeneous float aggregate */
+
+        if (is_float(vtop[-i].type.t)
+            || (hfa = is_float_hgen_aggr(&vtop[-i].type))) {
+          int end_reg;
+
+          assigned_vfpreg = assign_fpreg(&avregs, align, size);
+          end_reg = assigned_vfpreg + (size - 1) / 4;
+          if (assigned_vfpreg >= 0) {
+            vfp_plan[vfp_argno++]=TREG_F0 + assigned_vfpreg/2;
+            if (hfa) {
+              /* before_stack can only have been set because all core registers
+                 are assigned, so no need to care about before_vfpreg_hfa if
+                 before_stack is set */
+              if (before_stack) {
+	        vrote(&vtop[-i], &vtop[-i] - before_stack);
+                before_stack++;
+              } else if (!before_vfpreg_hfa)
+                before_vfpreg_hfa = &vtop[-i-1];
+              for (j = assigned_vfpreg; j <= end_reg; j++)
+                vfp_todo|=(1<<j);
+            }
+            continue;
+          } else {
+            if (!hfa)
+              vfp_argno++;
+            /* No need to update before_stack as no more hfa can be allocated in
+               VFP regs */
+            if (!before_vfpreg_hfa)
+              before_vfpreg_hfa = &vtop[-i-1];
+            break;
+          }
+        }
+      }
+#endif
+      ncrn = (ncrn + (align-1)/4) & -(align/4);
+      size = (size + 3) & -4;
+      if (ncrn + size/4 <= 4 || (ncrn < 4 && assigned_vfpreg != -1)) {
+        /* Either there is HFA in VFP registers, or there is arguments on stack,
+           it cannot be both. Hence either before_stack already points after
+           the slot where the vtop[-i] SValue is moved, or before_stack will not
+           be used */
+        if (before_vfpreg_hfa) {
+	  vrote(&vtop[-i], &vtop[-i] - before_vfpreg_hfa);
+          before_vfpreg_hfa++;
+        }
+        for (j = ncrn; j < 4 && j < ncrn + size / 4; j++)
+          todo|=(1<<j);
+        ncrn+=size/4;
+        if (ncrn > 4) {
+          args_size = (ncrn - 4) * 4;
+          if (!before_stack)
+            before_stack = &vtop[-i-1];
+        }
+      }
+      else {
+        ncrn = 4;
+        /* No need to set before_vfpreg_hfa if not set since there will no
+           longer be any structure assigned to core registers */
+        if (!before_stack)
+          before_stack = &vtop[-i-1];
+        break;
+      }
+      continue;
+      default:
+#ifdef TCC_ARM_EABI
+      if (!i) {
+        break;
+      }
+#endif
+      if (ncrn < 4) {
+        int is_long = (vtop[-i].type.t & VT_BTYPE) == VT_LLONG;
+
+        if (is_long) {
+          ncrn = (ncrn + 1) & -2;
+          if (ncrn == 4) {
+            argno++;
+            break;
+          }
+        }
+        plan[argno++][0]=ncrn++;
+        if (is_long) {
+          plan[argno-1][1]=ncrn++;
+        }
+        continue;
+      }
+      argno++;
+    }
+#ifdef TCC_ARM_EABI
+    if(args_size & (align-1)) {
+      vpushi(0);
+      vtop->type.t = VT_VOID; /* padding */
+      vrott(i+2);
+      args_size += 4;
+      nb_args++;
+      argno++;
+    }
+#endif
+    args_size += (size + 3) & -4;
+  }
+#ifdef TCC_ARM_EABI
+  vtop--, nb_args--;
+#endif
+  args_size = keep = 0;
+  for(i = 0;i < nb_args; i++) {
+    vrotb(keep+1);
+    if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+      size = type_size(&vtop->type, &align);
+      /* align to stack align size */
+      size = (size + 3) & -4;
+      /* allocate the necessary size on stack */
+      gadd_sp(-size);
+      /* generate structure store */
+      r = get_reg(RC_INT);
+      o(0xE1A0000D|(intr(r)<<12));
+      vset(&vtop->type, r | VT_LVAL, 0);
+      vswap();
+      vstore();
+      vtop--;
+      args_size += size;
+    } else if (is_float(vtop->type.t)) {
+#ifdef TCC_ARM_HARDFLOAT
+      if (!variadic && --vfp_argno<16 && vfp_plan[vfp_argno]!=-1) {
+        plan2[keep++]=vfp_plan[vfp_argno];
+        continue;
+      }
+#endif
+#ifdef TCC_ARM_VFP
+      r=vfpr(gv(RC_FLOAT))<<12;
+      size=4;
+      if ((vtop->type.t & VT_BTYPE) != VT_FLOAT)
+      {
+        size=8;
+        r|=0x101; /* fstms -> fstmd */
+      }
+      o(0xED2D0A01+r);
+#else
+      r=fpr(gv(RC_FLOAT))<<12;
+      if ((vtop->type.t & VT_BTYPE) == VT_FLOAT)
+        size = 4;
+      else if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
+        size = 8;
+      else
+        size = LDOUBLE_SIZE;
+      
+      if (size == 12)
+	r|=0x400000;
+      else if(size == 8)
+	r|=0x8000;
+
+      o(0xED2D0100|r|(size>>2));
+#endif
+      vtop--;
+      args_size += size;
+    } else {
+      int s;
+      /* simple type (currently always same size) */
+      /* XXX: implicit cast ? */
+      size=4;
+      if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
+	lexpand_nr();
+	s=-1;
+	if(--argno<4 && plan[argno][1]!=-1)
+	  s=plan[argno][1];
+	argno++;
+	size = 8;
+	if(s==-1) {
+	  r = gv(RC_INT);
+	  o(0xE52D0004|(intr(r)<<12)); /* str r,[sp,#-4]! */
+	  vtop--;
+	} else {
+	  size=0;
+	  plan2[keep]=s;
+	  keep++;
+          vswap();
+	}
+      }
+      s=-1;
+      if(--argno<4 && plan[argno][0]!=-1)
+        s=plan[argno][0];
+#ifdef TCC_ARM_EABI
+      if(vtop->type.t == VT_VOID) {
+        if(s == -1)
+          o(0xE24DD004); /* sub sp,sp,#4 */
+        vtop--;
+      } else
+#endif
+      if(s == -1) {
+	r = gv(RC_INT);
+	o(0xE52D0004|(intr(r)<<12)); /* str r,[sp,#-4]! */
+	vtop--;
+      } else {
+        size=0;
+	plan2[keep]=s;
+	keep++;
+      }
+      args_size += size;
+    }
+  }
+  for(i = 0; i < keep; i++) {
+    vrotb(keep);
+    gv(regmask(plan2[i]));
+#ifdef TCC_ARM_HARDFLOAT
+    /* arg is in s(2d+1): plan2[i]<plan2[i+1] => alignment occured (ex f,d,f) */
+    if (i < keep - 1 && is_float(vtop->type.t) && (plan2[i] <= plan2[i + 1])) {
+      o(0xEEF00A40|(vfpr(plan2[i])<<12)|vfpr(plan2[i]));
+    }
+#endif
+  }
+save_regs(keep); /* save used temporary registers */
+  keep++;
+  if(ncrn) {
+    int nb_regs=0;
+    if (ncrn>4)
+      ncrn=4;
+    todo&=((1<<ncrn)-1);
+    if(todo) {
+      int i;
+      o(0xE8BD0000|todo);
+      for(i=0;i<4;i++)
+	if(todo&(1<<i)) {
+	  vpushi(0);
+	  vtop->r=i;
+	  keep++;
+	  nb_regs++;
+	}
+    }
+    args_size-=nb_regs*4;
+  }
+  if(vfp_todo) {
+    int nb_fregs=0;
+
+    for(i=0;i<16;i++)
+      if(vfp_todo&(1<<i)) {
+        o(0xED9D0A00|(i&1)<<22|(i>>1)<<12|nb_fregs);
+        vpushi(0);
+        /* There might be 2 floats in a double VFP reg but that doesn't seem
+           to matter */
+        if (!(i%2))
+          vtop->r=TREG_F0+i/2;
+        keep++;
+        nb_fregs++;
+      }
+    if (nb_fregs) {
+      gadd_sp(nb_fregs*4);
+      args_size-=nb_fregs*4;
+    }
+  }
+  vrotb(keep);
+  gcall_or_jmp(0);
+  if (args_size)
+      gadd_sp(args_size);
+#ifdef TCC_ARM_EABI
+  if((vtop->type.ref->type.t & VT_BTYPE) == VT_STRUCT
+     && type_size(&vtop->type.ref->type, &align) <= 4)
+  {
+    store(REG_IRET,vtop-keep);
+    ++keep;
+  }
+#ifdef TCC_ARM_VFP
+#ifdef TCC_ARM_HARDFLOAT
+  else if(variadic && is_float(vtop->type.ref->type.t)) {
+#else
+  else if(is_float(vtop->type.ref->type.t)) {
+#endif
+    if((vtop->type.ref->type.t & VT_BTYPE) == VT_FLOAT) {
+      o(0xEE000A10); /* fmsr s0,r0 */
+    } else {
+      o(0xEE000B10); /* fmdlr d0,r0 */
+      o(0xEE201B10); /* fmdhr d0,r1 */
+    }
+  }
+#endif
+#endif
+  vtop-=keep;
+  leaffunc = 0;
+}
+
+/* generate function prolog of type 't' */
+void gfunc_prolog(CType *func_type)
+{
+  Sym *sym,*sym2;
+  int n,nf,size,align, variadic, struct_ret = 0;
+#ifdef TCC_ARM_HARDFLOAT
+  struct avail_regs avregs = AVAIL_REGS_INITIALIZER;
+#endif
+
+  sym = func_type->ref;
+  func_vt = sym->type;
+
+  n = nf = 0;
+  variadic = (func_type->ref->c == FUNC_ELLIPSIS);
+  if((func_vt.t & VT_BTYPE) == VT_STRUCT
+     && type_size(&func_vt,&align) > 4)
+  {
+    n++;
+    struct_ret = 1;
+    func_vc = 12; /* Offset from fp of the place to store the result */
+  }
+  for(sym2=sym->next;sym2 && (n<4 || nf<16);sym2=sym2->next) {
+    size = type_size(&sym2->type, &align);
+#ifdef TCC_ARM_HARDFLOAT
+    if (!variadic && (is_float(sym2->type.t)
+        || is_float_hgen_aggr(&sym2->type))) {
+      int tmpnf = assign_fpreg(&avregs, align, size) + 1;
+      nf = (tmpnf > nf) ? tmpnf : nf;
+    } else
+#endif
+    if (n < 4)
+      n += (size + 3) / 4;
+  }
+  o(0xE1A0C00D); /* mov ip,sp */
+  if(variadic)
+    n=4;
+  if(n) {
+    if(n>4)
+      n=4;
+#ifdef TCC_ARM_EABI
+    n=(n+1)&-2;
+#endif
+    o(0xE92D0000|((1<<n)-1)); /* save r0-r4 on stack if needed */
+  }
+  if (nf) {
+    if (nf>16)
+      nf=16;
+    nf=(nf+1)&-2; /* nf => HARDFLOAT => EABI */
+    o(0xED2D0A00|nf); /* save s0-s15 on stack if needed */
+  }
+  o(0xE92D5800); /* save fp, ip, lr */
+  o(0xE1A0B00D); /* mov fp, sp */
+  func_sub_sp_offset = ind;
+  o(0xE1A00000); /* nop, leave space for stack adjustment in epilogue */
+  {
+    int addr, pn = struct_ret, sn = 0; /* pn=core, sn=stack */
+
+#ifdef TCC_ARM_HARDFLOAT
+    avregs = AVAIL_REGS_INITIALIZER;
+#endif
+    while ((sym = sym->next)) {
+      CType *type;
+      type = &sym->type;
+      size = type_size(type, &align);
+      size = (size + 3) >> 2;
+      align = (align + 3) & ~3;
+#ifdef TCC_ARM_HARDFLOAT
+      if (!variadic && (is_float(sym->type.t)
+          || is_float_hgen_aggr(&sym->type))) {
+        int fpn = assign_fpreg(&avregs, align, size << 2);
+        if (fpn >= 0) {
+          addr = fpn * 4;
+        } else
+          goto from_stack;
+      } else
+#endif
+      if (pn < 4) {
+#ifdef TCC_ARM_EABI
+        pn = (pn + (align-1)/4) & -(align/4);
+#endif
+        addr = (nf + pn) * 4;
+        pn += size;
+        if (!sn && pn > 4)
+          sn = (pn - 4);
+      } else {
+#ifdef TCC_ARM_HARDFLOAT
+from_stack:
+#endif
+#ifdef TCC_ARM_EABI
+        sn = (sn + (align-1)/4) & -(align/4);
+#endif
+        addr = (n + nf + sn) * 4;
+        sn += size;
+      }
+      sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), addr+12);
+    }
+  }
+  last_itod_magic=0;
+  leaffunc = 1;
+  loc = 0;
+}
+
+/* generate function epilog */
+void gfunc_epilog(void)
+{
+  uint32_t x;
+  int diff;
+#ifdef TCC_ARM_EABI
+  /* Useless but harmless copy of the float result into main register(s) in case
+     of variadic function in the hardfloat variant */
+  if(is_float(func_vt.t)) {
+    if((func_vt.t & VT_BTYPE) == VT_FLOAT)
+      o(0xEE100A10); /* fmrs r0, s0 */
+    else {
+      o(0xEE100B10); /* fmrdl r0, d0 */
+      o(0xEE301B10); /* fmrdh r1, d0 */
+    }
+  }
+#endif
+  o(0xE89BA800); /* restore fp, sp, pc */
+  diff = (-loc + 3) & -4;
+#ifdef TCC_ARM_EABI
+  if(!leaffunc)
+    diff = ((diff + 11) & -8) - 4;
+#endif
+  if(diff > 0) {
+    x=stuff_const(0xE24BD000, diff); /* sub sp,fp,# */
+    if(x)
+      *(uint32_t *)(cur_text_section->data + func_sub_sp_offset) = x;
+    else {
+      int addr;
+      addr=ind;
+      o(0xE59FC004); /* ldr ip,[pc+4] */
+      o(0xE04BD00C); /* sub sp,fp,ip  */
+      o(0xE1A0F00E); /* mov pc,lr */
+      o(diff);
+      *(uint32_t *)(cur_text_section->data + func_sub_sp_offset) = 0xE1000000|encbranch(func_sub_sp_offset,addr,1);
+    }
+  }
+}
+
+/* generate a jump to a label */
+int gjmp(int t)
+{
+  int r;
+  r=ind;
+  o(0xE0000000|encbranch(r,t,1));
+  return r;
+}
+
+/* generate a jump to a fixed address */
+void gjmp_addr(int a)
+{
+  gjmp(a);
+}
+
+/* generate a test. set 'inv' to invert test. Stack entry is popped */
+int gtst(int inv, int t)
+{
+  int v, r;
+  uint32_t op;
+  v = vtop->r & VT_VALMASK;
+  r=ind;
+  if (v == VT_CMP) {
+    op=mapcc(inv?negcc(vtop->c.i):vtop->c.i);
+    op|=encbranch(r,t,1);
+    o(op);
+    t=r;
+  } else if (v == VT_JMP || v == VT_JMPI) {
+    if ((v & 1) == inv) {
+      if(!vtop->c.i)
+	vtop->c.i=t;
+      else {
+	uint32_t *x;
+	int p,lp;
+	if(t) {
+          p = vtop->c.i;
+          do {
+	    p = decbranch(lp=p);
+          } while(p);
+	  x = (uint32_t *)(cur_text_section->data + lp);
+	  *x &= 0xff000000;
+	  *x |= encbranch(lp,t,1);
+	}
+	t = vtop->c.i;
+      }
+    } else {
+      t = gjmp(t);
+      gsym(vtop->c.i);
+    }
+  } else {
+    if (is_float(vtop->type.t)) {
+      r=gv(RC_FLOAT);
+#ifdef TCC_ARM_VFP
+      o(0xEEB50A40|(vfpr(r)<<12)|T2CPR(vtop->type.t)); /* fcmpzX */
+      o(0xEEF1FA10); /* fmstat */
+#else
+      o(0xEE90F118|(fpr(r)<<16));
+#endif
+      vtop->r = VT_CMP;
+      vtop->c.i = TOK_NE;
+      return gtst(inv, t);
+    } else if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+      /* constant jmp optimization */
+      if ((vtop->c.i != 0) != inv) 
+	t = gjmp(t);
+    } else {
+      v = gv(RC_INT);
+      o(0xE3300000|(intr(v)<<16));
+      vtop->r = VT_CMP;
+      vtop->c.i = TOK_NE;
+      return gtst(inv, t);
+    }   
+  }
+  vtop--;
+  return t;
+}
+
+/* generate an integer binary operation */
+void gen_opi(int op)
+{
+  int c, func = 0;
+  uint32_t opc = 0, r, fr;
+  unsigned short retreg = REG_IRET;
+
+  c=0;
+  switch(op) {
+    case '+':
+      opc = 0x8;
+      c=1;
+      break;
+    case TOK_ADDC1: /* add with carry generation */
+      opc = 0x9;
+      c=1;
+      break;
+    case '-':
+      opc = 0x4;
+      c=1;
+      break;
+    case TOK_SUBC1: /* sub with carry generation */
+      opc = 0x5;
+      c=1;
+      break;
+    case TOK_ADDC2: /* add with carry use */
+      opc = 0xA;
+      c=1;
+      break;
+    case TOK_SUBC2: /* sub with carry use */
+      opc = 0xC;
+      c=1;
+      break;
+    case '&':
+      opc = 0x0;
+      c=1;
+      break;
+    case '^':
+      opc = 0x2;
+      c=1;
+      break;
+    case '|':
+      opc = 0x18;
+      c=1;
+      break;
+    case '*':
+      gv2(RC_INT, RC_INT);
+      r = vtop[-1].r;
+      fr = vtop[0].r;
+      vtop--;
+      o(0xE0000090|(intr(r)<<16)|(intr(r)<<8)|intr(fr));
+      return;
+    case TOK_SHL:
+      opc = 0;
+      c=2;
+      break;
+    case TOK_SHR:
+      opc = 1;
+      c=2;
+      break;
+    case TOK_SAR:
+      opc = 2;
+      c=2;
+      break;
+    case '/':
+    case TOK_PDIV:
+      func=TOK___divsi3;
+      c=3;
+      break;
+    case TOK_UDIV:
+      func=TOK___udivsi3;
+      c=3;
+      break;
+    case '%':
+#ifdef TCC_ARM_EABI
+      func=TOK___aeabi_idivmod;
+      retreg=REG_LRET;
+#else
+      func=TOK___modsi3;
+#endif
+      c=3;
+      break;
+    case TOK_UMOD:
+#ifdef TCC_ARM_EABI
+      func=TOK___aeabi_uidivmod;
+      retreg=REG_LRET;
+#else
+      func=TOK___umodsi3;
+#endif
+      c=3;
+      break;
+    case TOK_UMULL:
+      gv2(RC_INT, RC_INT);
+      r=intr(vtop[-1].r2=get_reg(RC_INT));
+      c=vtop[-1].r;
+      vtop[-1].r=get_reg_ex(RC_INT,regmask(c));
+      vtop--;
+      o(0xE0800090|(r<<16)|(intr(vtop->r)<<12)|(intr(c)<<8)|intr(vtop[1].r));
+      return;
+    default:
+      opc = 0x15;
+      c=1;
+      break;
+  }
+  switch(c) {
+    case 1:
+      if((vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+	if(opc == 4 || opc == 5 || opc == 0xc) {
+	  vswap();
+	  opc|=2; // sub -> rsb
+	}
+      }
+      if ((vtop->r & VT_VALMASK) == VT_CMP ||
+          (vtop->r & (VT_VALMASK & ~1)) == VT_JMP)
+        gv(RC_INT);
+      vswap();
+      c=intr(gv(RC_INT));
+      vswap();
+      opc=0xE0000000|(opc<<20)|(c<<16);
+      if((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+	uint32_t x;
+	x=stuff_const(opc|0x2000000,vtop->c.i);
+	if(x) {
+	  r=intr(vtop[-1].r=get_reg_ex(RC_INT,regmask(vtop[-1].r)));
+	  o(x|(r<<12));
+	  goto done;
+	}
+      }
+      fr=intr(gv(RC_INT));
+      r=intr(vtop[-1].r=get_reg_ex(RC_INT,two2mask(vtop->r,vtop[-1].r)));
+      o(opc|(r<<12)|fr);
+done:
+      vtop--;
+      if (op >= TOK_ULT && op <= TOK_GT) {
+        vtop->r = VT_CMP;
+        vtop->c.i = op;
+      }
+      break;
+    case 2:
+      opc=0xE1A00000|(opc<<5);
+      if ((vtop->r & VT_VALMASK) == VT_CMP ||
+          (vtop->r & (VT_VALMASK & ~1)) == VT_JMP)
+        gv(RC_INT);
+      vswap();
+      r=intr(gv(RC_INT));
+      vswap();
+      opc|=r;
+      if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+	fr=intr(vtop[-1].r=get_reg_ex(RC_INT,regmask(vtop[-1].r)));
+	c = vtop->c.i & 0x1f;
+	o(opc|(c<<7)|(fr<<12));
+      } else {
+        fr=intr(gv(RC_INT));
+	c=intr(vtop[-1].r=get_reg_ex(RC_INT,two2mask(vtop->r,vtop[-1].r)));
+	o(opc|(c<<12)|(fr<<8)|0x10);
+      }
+      vtop--;
+      break;
+    case 3:
+      vpush_global_sym(&func_old_type, func);
+      vrott(3);
+      gfunc_call(2);
+      vpushi(0);
+      vtop->r = retreg;
+      break;
+    default:
+      tcc_error("gen_opi %i unimplemented!",op);
+  }
+}
+
+#ifdef TCC_ARM_VFP
+static int is_zero(int i)
+{
+  if((vtop[i].r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
+    return 0;
+  if (vtop[i].type.t == VT_FLOAT)
+    return (vtop[i].c.f == 0.f);
+  else if (vtop[i].type.t == VT_DOUBLE)
+    return (vtop[i].c.d == 0.0);
+  return (vtop[i].c.ld == 0.l);
+}
+
+/* generate a floating point operation 'v = t1 op t2' instruction. The
+ *    two operands are guaranted to have the same floating point type */
+void gen_opf(int op)
+{
+  uint32_t x;
+  int fneg=0,r;
+  x=0xEE000A00|T2CPR(vtop->type.t);
+  switch(op) {
+    case '+':
+      if(is_zero(-1))
+        vswap();
+      if(is_zero(0)) {
+        vtop--;
+        return;
+      }
+      x|=0x300000;
+      break;
+    case '-':
+      x|=0x300040;
+      if(is_zero(0)) {
+        vtop--;
+        return;
+      }
+      if(is_zero(-1)) {
+        x|=0x810000; /* fsubX -> fnegX */
+        vswap();
+        vtop--;
+        fneg=1;
+      }
+      break;
+    case '*':
+      x|=0x200000;
+      break;
+    case '/':
+      x|=0x800000;
+      break;
+    default:
+      if(op < TOK_ULT || op > TOK_GT) {
+        tcc_error("unknown fp op %x!",op);
+        return;
+      }
+      if(is_zero(-1)) {
+        vswap();
+        switch(op) {
+          case TOK_LT: op=TOK_GT; break;
+          case TOK_GE: op=TOK_ULE; break;
+          case TOK_LE: op=TOK_GE; break;
+          case TOK_GT: op=TOK_ULT; break;
+        }
+      }
+      x|=0xB40040; /* fcmpX */
+      if(op!=TOK_EQ && op!=TOK_NE)
+        x|=0x80; /* fcmpX -> fcmpeX */
+      if(is_zero(0)) {
+        vtop--;
+        o(x|0x10000|(vfpr(gv(RC_FLOAT))<<12)); /* fcmp(e)X -> fcmp(e)zX */
+      } else {
+        x|=vfpr(gv(RC_FLOAT));
+        vswap();
+        o(x|(vfpr(gv(RC_FLOAT))<<12));
+        vtop--;
+      }
+      o(0xEEF1FA10); /* fmstat */
+
+      switch(op) {
+        case TOK_LE: op=TOK_ULE; break;
+        case TOK_LT: op=TOK_ULT; break;
+        case TOK_UGE: op=TOK_GE; break;
+        case TOK_UGT: op=TOK_GT; break;
+      }
+      
+      vtop->r = VT_CMP;
+      vtop->c.i = op;
+      return;
+  }
+  r=gv(RC_FLOAT);
+  x|=vfpr(r);
+  r=regmask(r);
+  if(!fneg) {
+    int r2;
+    vswap();
+    r2=gv(RC_FLOAT);
+    x|=vfpr(r2)<<16;
+    r|=regmask(r2);
+  }
+  vtop->r=get_reg_ex(RC_FLOAT,r);
+  if(!fneg)
+    vtop--;
+  o(x|(vfpr(vtop->r)<<12));
+}
+
+#else
+static uint32_t is_fconst()
+{
+  long double f;
+  uint32_t r;
+  if((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
+    return 0;
+  if (vtop->type.t == VT_FLOAT)
+    f = vtop->c.f;
+  else if (vtop->type.t == VT_DOUBLE)
+    f = vtop->c.d;
+  else
+    f = vtop->c.ld;
+  if(!ieee_finite(f))
+    return 0;
+  r=0x8;
+  if(f<0.0) {
+    r=0x18;
+    f=-f;
+  }
+  if(f==0.0)
+    return r;
+  if(f==1.0)
+    return r|1;
+  if(f==2.0)
+    return r|2;
+  if(f==3.0)
+    return r|3;
+  if(f==4.0)
+    return r|4;
+  if(f==5.0)
+    return r|5;
+  if(f==0.5)
+    return r|6;
+  if(f==10.0)
+    return r|7;
+  return 0;
+}
+
+/* generate a floating point operation 'v = t1 op t2' instruction. The
+   two operands are guaranted to have the same floating point type */
+void gen_opf(int op)
+{
+  uint32_t x, r, r2, c1, c2;
+  //fputs("gen_opf\n",stderr);
+  vswap();
+  c1 = is_fconst();
+  vswap();
+  c2 = is_fconst();
+  x=0xEE000100;
+#if LDOUBLE_SIZE == 8
+  if ((vtop->type.t & VT_BTYPE) != VT_FLOAT)
+    x|=0x80;
+#else
+  if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
+    x|=0x80;
+  else if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE)
+    x|=0x80000;
+#endif
+  switch(op)
+  {
+    case '+':
+      if(!c2) {
+	vswap();
+	c2=c1;
+      }
+      vswap();
+      r=fpr(gv(RC_FLOAT));
+      vswap();
+      if(c2) {
+	if(c2>0xf)
+	  x|=0x200000; // suf
+	r2=c2&0xf;
+      } else {
+	r2=fpr(gv(RC_FLOAT));
+      }
+      break;
+    case '-':
+      if(c2) {
+	if(c2<=0xf)
+	  x|=0x200000; // suf
+	r2=c2&0xf;
+	vswap();
+	r=fpr(gv(RC_FLOAT));
+	vswap();
+      } else if(c1 && c1<=0xf) {
+	x|=0x300000; // rsf
+	r2=c1;
+	r=fpr(gv(RC_FLOAT));
+	vswap();
+      } else {
+	x|=0x200000; // suf
+	vswap();
+	r=fpr(gv(RC_FLOAT));
+	vswap();
+	r2=fpr(gv(RC_FLOAT));
+      }
+      break;
+    case '*':
+      if(!c2 || c2>0xf) {
+	vswap();
+	c2=c1;
+      }
+      vswap();
+      r=fpr(gv(RC_FLOAT));
+      vswap();
+      if(c2 && c2<=0xf)
+	r2=c2;
+      else
+	r2=fpr(gv(RC_FLOAT));
+      x|=0x100000; // muf
+      break;
+    case '/':
+      if(c2 && c2<=0xf) {
+	x|=0x400000; // dvf
+	r2=c2;
+	vswap();
+	r=fpr(gv(RC_FLOAT));
+	vswap();
+      } else if(c1 && c1<=0xf) {
+	x|=0x500000; // rdf
+	r2=c1;
+	r=fpr(gv(RC_FLOAT));
+	vswap();
+      } else {
+	x|=0x400000; // dvf
+	vswap();
+	r=fpr(gv(RC_FLOAT));
+	vswap();
+	r2=fpr(gv(RC_FLOAT));
+      }     
+      break;
+    default:
+      if(op >= TOK_ULT && op <= TOK_GT) {
+	x|=0xd0f110; // cmfe
+/* bug (intention?) in Linux FPU emulator
+   doesn't set carry if equal */
+	switch(op) {
+	  case TOK_ULT:
+	  case TOK_UGE:
+	  case TOK_ULE:
+	  case TOK_UGT:
+            tcc_error("unsigned comparision on floats?");
+	    break;
+	  case TOK_LT:
+            op=TOK_Nset;
+	    break;
+	  case TOK_LE:
+            op=TOK_ULE; /* correct in unordered case only if AC bit in FPSR set */
+	    break;
+	  case TOK_EQ:
+	  case TOK_NE:
+	    x&=~0x400000; // cmfe -> cmf
+	    break;
+	}
+	if(c1 && !c2) {
+	  c2=c1;
+	  vswap();
+	  switch(op) {
+            case TOK_Nset:
+              op=TOK_GT;
+	      break;
+            case TOK_GE:
+	      op=TOK_ULE;
+	      break;
+	    case TOK_ULE:
+              op=TOK_GE;
+	      break;
+            case TOK_GT:
+              op=TOK_Nset;
+	      break;
+	  }
+	}
+	vswap();
+	r=fpr(gv(RC_FLOAT));
+	vswap();
+	if(c2) {
+	  if(c2>0xf)
+	    x|=0x200000;
+	  r2=c2&0xf;
+	} else {
+	  r2=fpr(gv(RC_FLOAT));
+	}
+	vtop[-1].r = VT_CMP;
+	vtop[-1].c.i = op;
+      } else {
+        tcc_error("unknown fp op %x!",op);
+	return;
+      }
+  }
+  if(vtop[-1].r == VT_CMP)
+    c1=15;
+  else {
+    c1=vtop->r;
+    if(r2&0x8)
+      c1=vtop[-1].r;
+    vtop[-1].r=get_reg_ex(RC_FLOAT,two2mask(vtop[-1].r,c1));
+    c1=fpr(vtop[-1].r);
+  }
+  vtop--;
+  o(x|(r<<16)|(c1<<12)|r2);
+}
+#endif
+
+/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
+   and 'long long' cases. */
+ST_FUNC void gen_cvt_itof1(int t)
+{
+  uint32_t r, r2;
+  int bt;
+  bt=vtop->type.t & VT_BTYPE;
+  if(bt == VT_INT || bt == VT_SHORT || bt == VT_BYTE) {
+#ifndef TCC_ARM_VFP
+    uint32_t dsize = 0;
+#endif
+    r=intr(gv(RC_INT));
+#ifdef TCC_ARM_VFP
+    r2=vfpr(vtop->r=get_reg(RC_FLOAT));
+    o(0xEE000A10|(r<<12)|(r2<<16)); /* fmsr */
+    r2|=r2<<12;
+    if(!(vtop->type.t & VT_UNSIGNED))
+      r2|=0x80;                /* fuitoX -> fsituX */
+    o(0xEEB80A40|r2|T2CPR(t)); /* fYitoX*/
+#else
+    r2=fpr(vtop->r=get_reg(RC_FLOAT));
+    if((t & VT_BTYPE) != VT_FLOAT)
+      dsize=0x80;    /* flts -> fltd */
+    o(0xEE000110|dsize|(r2<<16)|(r<<12)); /* flts */
+    if((vtop->type.t & (VT_UNSIGNED|VT_BTYPE)) == (VT_UNSIGNED|VT_INT)) {
+      uint32_t off = 0;
+      o(0xE3500000|(r<<12));        /* cmp */
+      r=fpr(get_reg(RC_FLOAT));
+      if(last_itod_magic) {
+	off=ind+8-last_itod_magic;
+	off/=4;
+	if(off>255)
+	  off=0;
+      }
+      o(0xBD1F0100|(r<<12)|off);    /* ldflts */
+      if(!off) {
+        o(0xEA000000);              /* b */
+        last_itod_magic=ind;
+        o(0x4F800000);              /* 4294967296.0f */
+      }
+      o(0xBE000100|dsize|(r2<<16)|(r2<<12)|r); /* adflt */
+    }
+#endif
+    return;
+  } else if(bt == VT_LLONG) {
+    int func;
+    CType *func_type = 0;
+    if((t & VT_BTYPE) == VT_FLOAT) {
+      func_type = &func_float_type;
+      if(vtop->type.t & VT_UNSIGNED)
+        func=TOK___floatundisf;
+      else
+        func=TOK___floatdisf;
+#if LDOUBLE_SIZE != 8
+    } else if((t & VT_BTYPE) == VT_LDOUBLE) {
+      func_type = &func_ldouble_type;
+      if(vtop->type.t & VT_UNSIGNED)
+        func=TOK___floatundixf;
+      else
+        func=TOK___floatdixf;
+    } else if((t & VT_BTYPE) == VT_DOUBLE) {
+#else
+    } else if((t & VT_BTYPE) == VT_DOUBLE || (t & VT_BTYPE) == VT_LDOUBLE) {
+#endif
+      func_type = &func_double_type;
+      if(vtop->type.t & VT_UNSIGNED)
+        func=TOK___floatundidf;
+      else
+        func=TOK___floatdidf;
+    }
+    if(func_type) {
+      vpush_global_sym(func_type, func);
+      vswap();
+      gfunc_call(1);
+      vpushi(0);
+      vtop->r=TREG_F0;
+      return;
+    }
+  }
+  tcc_error("unimplemented gen_cvt_itof %x!",vtop->type.t);
+}
+
+/* convert fp to int 't' type */
+void gen_cvt_ftoi(int t)
+{
+  uint32_t r, r2;
+  int u, func = 0;
+  u=t&VT_UNSIGNED;
+  t&=VT_BTYPE;
+  r2=vtop->type.t & VT_BTYPE;
+  if(t==VT_INT) {
+#ifdef TCC_ARM_VFP
+    r=vfpr(gv(RC_FLOAT));
+    u=u?0:0x10000;
+    o(0xEEBC0AC0|(r<<12)|r|T2CPR(r2)|u); /* ftoXizY */
+    r2=intr(vtop->r=get_reg(RC_INT));
+    o(0xEE100A10|(r<<16)|(r2<<12));
+    return;
+#else
+    if(u) {
+      if(r2 == VT_FLOAT)
+        func=TOK___fixunssfsi;
+#if LDOUBLE_SIZE != 8
+      else if(r2 == VT_LDOUBLE)
+	func=TOK___fixunsxfsi;
+      else if(r2 == VT_DOUBLE)
+#else
+      else if(r2 == VT_LDOUBLE || r2 == VT_DOUBLE)
+#endif
+	func=TOK___fixunsdfsi;
+    } else {
+      r=fpr(gv(RC_FLOAT));
+      r2=intr(vtop->r=get_reg(RC_INT));
+      o(0xEE100170|(r2<<12)|r);
+      return;
+    }
+#endif
+  } else if(t == VT_LLONG) { // unsigned handled in gen_cvt_ftoi1
+    if(r2 == VT_FLOAT)
+      func=TOK___fixsfdi;
+#if LDOUBLE_SIZE != 8
+    else if(r2 == VT_LDOUBLE)
+      func=TOK___fixxfdi;
+    else if(r2 == VT_DOUBLE)
+#else
+    else if(r2 == VT_LDOUBLE || r2 == VT_DOUBLE)
+#endif
+      func=TOK___fixdfdi;
+  }
+  if(func) {
+    vpush_global_sym(&func_old_type, func);
+    vswap();
+    gfunc_call(1);
+    vpushi(0);
+    if(t == VT_LLONG)
+      vtop->r2 = REG_LRET;
+    vtop->r = REG_IRET;
+    return;
+  }
+  tcc_error("unimplemented gen_cvt_ftoi!");
+}
+
+/* convert from one floating point type to another */
+void gen_cvt_ftof(int t)
+{
+#ifdef TCC_ARM_VFP
+  if(((vtop->type.t & VT_BTYPE) == VT_FLOAT) != ((t & VT_BTYPE) == VT_FLOAT)) {
+    uint32_t r = vfpr(gv(RC_FLOAT));
+    o(0xEEB70AC0|(r<<12)|r|T2CPR(vtop->type.t));
+  }
+#else
+  /* all we have to do on i386 and FPA ARM is to put the float in a register */
+  gv(RC_FLOAT);
+#endif
+}
+
+/* computed goto support */
+void ggoto(void)
+{
+  gcall_or_jmp(1);
+  vtop--;
+}
+
+/* end of ARM code generator */
+/*************************************************************/
+#endif
+/*************************************************************/
Index: /EcnlProtoTool/trunk/tcc-0.9.26/c67-gen.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/c67-gen.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/c67-gen.c	(revision 279)
@@ -0,0 +1,2560 @@
+/*
+ *  TMS320C67xx code generator for TCC
+ * 
+ *  Copyright (c) 2001, 2002 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef TARGET_DEFS_ONLY
+
+//#define ASSEMBLY_LISTING_C67
+
+/* number of available registers */
+#define NB_REGS            24
+
+/* a register can belong to several classes. The classes must be
+   sorted from more general to more precise (see gv2() code which does
+   assumptions on it). */
+#define RC_INT     0x0001	/* generic integer register */
+#define RC_FLOAT   0x0002	/* generic float register */
+#define RC_EAX     0x0004
+#define RC_ST0     0x0008
+#define RC_ECX     0x0010
+#define RC_EDX     0x0020
+#define RC_INT_BSIDE  0x00000040	/* generic integer register  on b side */
+#define RC_C67_A4     0x00000100
+#define RC_C67_A5     0x00000200
+#define RC_C67_B4     0x00000400
+#define RC_C67_B5     0x00000800
+#define RC_C67_A6     0x00001000
+#define RC_C67_A7     0x00002000
+#define RC_C67_B6     0x00004000
+#define RC_C67_B7     0x00008000
+#define RC_C67_A8     0x00010000
+#define RC_C67_A9     0x00020000
+#define RC_C67_B8     0x00040000
+#define RC_C67_B9     0x00080000
+#define RC_C67_A10    0x00100000
+#define RC_C67_A11    0x00200000
+#define RC_C67_B10    0x00400000
+#define RC_C67_B11    0x00800000
+#define RC_C67_A12    0x01000000
+#define RC_C67_A13    0x02000000
+#define RC_C67_B12    0x04000000
+#define RC_C67_B13    0x08000000
+#define RC_IRET    RC_C67_A4	/* function return: integer register */
+#define RC_LRET    RC_C67_A5	/* function return: second integer register */
+#define RC_FRET    RC_C67_A4	/* function return: float register */
+
+/* pretty names for the registers */
+enum {
+    TREG_EAX = 0,		// really A2
+    TREG_ECX,			// really A3
+    TREG_EDX,			// really B0
+    TREG_ST0,			// really B1
+    TREG_C67_A4,
+    TREG_C67_A5,
+    TREG_C67_B4,
+    TREG_C67_B5,
+    TREG_C67_A6,
+    TREG_C67_A7,
+    TREG_C67_B6,
+    TREG_C67_B7,
+    TREG_C67_A8,
+    TREG_C67_A9,
+    TREG_C67_B8,
+    TREG_C67_B9,
+    TREG_C67_A10,
+    TREG_C67_A11,
+    TREG_C67_B10,
+    TREG_C67_B11,
+    TREG_C67_A12,
+    TREG_C67_A13,
+    TREG_C67_B12,
+    TREG_C67_B13,
+};
+
+/* return registers for function */
+#define REG_IRET TREG_C67_A4	/* single word int return register */
+#define REG_LRET TREG_C67_A5	/* second word return register (for long long) */
+#define REG_FRET TREG_C67_A4	/* float return register */
+
+/* defined if function parameters must be evaluated in reverse order */
+//#define INVERT_FUNC_PARAMS
+
+/* defined if structures are passed as pointers. Otherwise structures
+   are directly pushed on stack. */
+//#define FUNC_STRUCT_PARAM_AS_PTR
+
+/* pointer size, in bytes */
+#define PTR_SIZE 4
+
+/* long double size and alignment, in bytes */
+#define LDOUBLE_SIZE  12
+#define LDOUBLE_ALIGN 4
+/* maximum alignment (for aligned attribute support) */
+#define MAX_ALIGN     8
+
+/******************************************************/
+/* ELF defines */
+
+#define EM_TCC_TARGET EM_C60
+
+/* relocation type for 32 bit data relocation */
+#define R_DATA_32   R_C60_32
+#define R_DATA_PTR  R_C60_32
+#define R_JMP_SLOT  R_C60_JMP_SLOT
+#define R_COPY      R_C60_COPY
+
+#define ELF_START_ADDR 0x00000400
+#define ELF_PAGE_SIZE  0x1000
+
+/******************************************************/
+#else /* ! TARGET_DEFS_ONLY */
+/******************************************************/
+#include "tcc.h"
+
+ST_DATA const int reg_classes[NB_REGS] = {
+    /* eax */ RC_INT | RC_FLOAT | RC_EAX, 
+    // only allow even regs for floats (allow for doubles)
+    /* ecx */ RC_INT | RC_ECX,
+    /* edx */ RC_INT | RC_INT_BSIDE | RC_FLOAT | RC_EDX,
+    // only allow even regs for floats (allow for doubles)
+    /* st0 */ RC_INT | RC_INT_BSIDE | RC_ST0,
+    /* A4  */ RC_C67_A4,
+    /* A5  */ RC_C67_A5,
+    /* B4  */ RC_C67_B4,
+    /* B5  */ RC_C67_B5,
+    /* A6  */ RC_C67_A6,
+    /* A7  */ RC_C67_A7,
+    /* B6  */ RC_C67_B6,
+    /* B7  */ RC_C67_B7,
+    /* A8  */ RC_C67_A8,
+    /* A9  */ RC_C67_A9,
+    /* B8  */ RC_C67_B8,
+    /* B9  */ RC_C67_B9,
+    /* A10  */ RC_C67_A10,
+    /* A11  */ RC_C67_A11,
+    /* B10  */ RC_C67_B10,
+    /* B11  */ RC_C67_B11,
+    /* A12  */ RC_C67_A10,
+    /* A13  */ RC_C67_A11,
+    /* B12  */ RC_C67_B10,
+    /* B13  */ RC_C67_B11
+};
+
+// although tcc thinks it is passing parameters on the stack,
+// the C67 really passes up to the first 10 params in special
+// regs or regs pairs (for 64 bit params).  So keep track of
+// the stack offsets so we can translate to the appropriate 
+// reg (pair)
+
+#define NoCallArgsPassedOnStack 10
+int NoOfCurFuncArgs;
+int TranslateStackToReg[NoCallArgsPassedOnStack];
+int ParamLocOnStack[NoCallArgsPassedOnStack];
+int TotalBytesPushedOnStack;
+
+#ifndef FALSE
+# define FALSE 0
+# define TRUE 1
+#endif
+
+#undef BOOL
+#define BOOL int
+
+#define ALWAYS_ASSERT(x) \
+do {\
+   if (!(x))\
+       tcc_error("internal compiler error file at %s:%d", __FILE__, __LINE__);\
+} while (0)
+
+/******************************************************/
+static unsigned long func_sub_sp_offset;
+static int func_ret_sub;
+
+static BOOL C67_invert_test;
+static int C67_compare_reg;
+
+#ifdef ASSEMBLY_LISTING_C67
+FILE *f = NULL;
+#endif
+
+void C67_g(int c)
+{
+    int ind1;
+
+#ifdef ASSEMBLY_LISTING_C67
+    fprintf(f, " %08X", c);
+#endif
+    ind1 = ind + 4;
+    if (ind1 > (int) cur_text_section->data_allocated)
+	section_realloc(cur_text_section, ind1);
+    cur_text_section->data[ind] = c & 0xff;
+    cur_text_section->data[ind + 1] = (c >> 8) & 0xff;
+    cur_text_section->data[ind + 2] = (c >> 16) & 0xff;
+    cur_text_section->data[ind + 3] = (c >> 24) & 0xff;
+    ind = ind1;
+}
+
+
+/* output a symbol and patch all calls to it */
+void gsym_addr(int t, int a)
+{
+    int n, *ptr;
+    while (t) {
+	ptr = (int *) (cur_text_section->data + t);
+	{
+	    Sym *sym;
+
+	    // extract 32 bit address from MVKH/MVKL
+	    n = ((*ptr >> 7) & 0xffff);
+	    n |= ((*(ptr + 1) >> 7) & 0xffff) << 16;
+
+	    // define a label that will be relocated
+
+	    sym = get_sym_ref(&char_pointer_type, cur_text_section, a, 0);
+	    greloc(cur_text_section, sym, t, R_C60LO16);
+	    greloc(cur_text_section, sym, t + 4, R_C60HI16);
+
+	    // clear out where the pointer was
+
+	    *ptr &= ~(0xffff << 7);
+	    *(ptr + 1) &= ~(0xffff << 7);
+	}
+	t = n;
+    }
+}
+
+void gsym(int t)
+{
+    gsym_addr(t, ind);
+}
+
+// these are regs that tcc doesn't really know about, 
+// but asign them unique values so the mapping routines
+// can distinquish them
+
+#define C67_A0 105
+#define C67_SP 106
+#define C67_B3 107
+#define C67_FP 108
+#define C67_B2 109
+#define C67_CREG_ZERO -1	// Special code for no condition reg test
+
+
+int ConvertRegToRegClass(int r)
+{
+    // only works for A4-B13
+
+    return RC_C67_A4 << (r - TREG_C67_A4);
+}
+
+
+// map TCC reg to C67 reg number
+
+int C67_map_regn(int r)
+{
+    if (r == 0)			// normal tcc regs
+	return 0x2;		// A2
+    else if (r == 1)		// normal tcc regs
+	return 3;		// A3
+    else if (r == 2)		// normal tcc regs
+	return 0;		// B0
+    else if (r == 3)		// normal tcc regs
+	return 1;		// B1
+    else if (r >= TREG_C67_A4 && r <= TREG_C67_B13)	// these form a pattern of alt pairs
+	return (((r & 0xfffffffc) >> 1) | (r & 1)) + 2;
+    else if (r == C67_A0)
+	return 0;		// set to A0 (offset reg)
+    else if (r == C67_B2)
+	return 2;		// set to B2 (offset reg)
+    else if (r == C67_B3)
+	return 3;		// set to B3 (return address reg)
+    else if (r == C67_SP)
+	return 15;		// set to SP (B15) (offset reg)
+    else if (r == C67_FP)
+	return 15;		// set to FP (A15) (offset reg)
+    else if (r == C67_CREG_ZERO)
+	return 0;		// Special code for no condition reg test
+    else
+	ALWAYS_ASSERT(FALSE);
+
+    return 0;
+}
+
+// mapping from tcc reg number to 
+// C67 register to condition code field
+//
+// valid condition code regs are:
+//
+// tcc reg 2 ->B0 -> 1
+// tcc reg 3 ->B1 -> 2
+// tcc reg 0 -> A2 -> 5
+// tcc reg 1 -> A3 -> X
+// tcc reg      B2 -> 3
+
+int C67_map_regc(int r)
+{
+    if (r == 0)			// normal tcc regs
+	return 0x5;
+    else if (r == 2)		// normal tcc regs
+	return 0x1;
+    else if (r == 3)		// normal tcc regs
+	return 0x2;
+    else if (r == C67_B2)	// normal tcc regs
+	return 0x3;
+    else if (r == C67_CREG_ZERO)
+	return 0;		// Special code for no condition reg test
+    else
+	ALWAYS_ASSERT(FALSE);
+
+    return 0;
+}
+
+
+// map TCC reg to C67 reg side A or B
+
+int C67_map_regs(int r)
+{
+    if (r == 0)			// normal tcc regs
+	return 0x0;
+    else if (r == 1)		// normal tcc regs
+	return 0x0;
+    else if (r == 2)		// normal tcc regs
+	return 0x1;
+    else if (r == 3)		// normal tcc regs
+	return 0x1;
+    else if (r >= TREG_C67_A4 && r <= TREG_C67_B13)	// these form a pattern of alt pairs
+	return (r & 2) >> 1;
+    else if (r == C67_A0)
+	return 0;		// set to A side 
+    else if (r == C67_B2)
+	return 1;		// set to B side 
+    else if (r == C67_B3)
+	return 1;		// set to B side
+    else if (r == C67_SP)
+	return 0x1;		// set to SP (B15) B side 
+    else if (r == C67_FP)
+	return 0x0;		// set to FP (A15) A side 
+    else
+	ALWAYS_ASSERT(FALSE);
+
+    return 0;
+}
+
+int C67_map_S12(char *s)
+{
+    if (strstr(s, ".S1") != NULL)
+	return 0;
+    else if (strcmp(s, ".S2"))
+	return 1;
+    else
+	ALWAYS_ASSERT(FALSE);
+
+    return 0;
+}
+
+int C67_map_D12(char *s)
+{
+    if (strstr(s, ".D1") != NULL)
+	return 0;
+    else if (strcmp(s, ".D2"))
+	return 1;
+    else
+	ALWAYS_ASSERT(FALSE);
+
+    return 0;
+}
+
+
+
+void C67_asm(char *s, int a, int b, int c)
+{
+    BOOL xpath;
+
+#ifdef ASSEMBLY_LISTING_C67
+    if (!f) {
+	f = fopen("TCC67_out.txt", "wt");
+    }
+    fprintf(f, "%04X ", ind);
+#endif
+
+    if (strstr(s, "MVKL") == s) {
+	C67_g((C67_map_regn(b) << 23) |
+	      ((a & 0xffff) << 7) | (0x0a << 2) | (C67_map_regs(b) << 1));
+    } else if (strstr(s, "MVKH") == s) {
+	C67_g((C67_map_regn(b) << 23) |
+	      (((a >> 16) & 0xffff) << 7) |
+	      (0x1a << 2) | (C67_map_regs(b) << 1));
+    } else if (strstr(s, "STW.D SP POST DEC") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (15 << 18) |	//SP B15
+	      (2 << 13) |	//ucst5 (must keep 8 byte boundary !!)
+	      (0xa << 9) |	//mode a = post dec ucst
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (1 << 7) |	//y D1/D2 use B side
+	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STB.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2 A side
+	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STH.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2 A side
+	      (5 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STB.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2 A side
+	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STH.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2 A side
+	      (5 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STW.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2 A side
+	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STW.D *") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (C67_map_regn(b) << 18) |	//base reg A0
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
+	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STH.D *") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (C67_map_regn(b) << 18) |	//base reg A0
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
+	      (5 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STB.D *") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (C67_map_regn(b) << 18) |	//base reg A0
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
+	      (3 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "STW.D +*") == s) {
+	ALWAYS_ASSERT(c < 32);
+	C67_g((C67_map_regn(a) << 23) |	//src
+	      (C67_map_regn(b) << 18) |	//base reg A0
+	      (c << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(b) << 7) |	//y D1/D2 base reg side
+	      (7 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of src
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDW.D SP PRE INC") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg B15
+	      (2 << 13) |	//ucst5 (must keep 8 byte boundary)
+	      (9 << 9) |	//mode 9 = pre inc ucst5
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (1 << 7) |	//y D1/D2  B side
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDDW.D SP PRE INC") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg B15
+	      (1 << 13) |	//ucst5 (must keep 8 byte boundary)
+	      (9 << 9) |	//mode 9 = pre inc ucst5
+	      (1 << 8) |	//r (LDDW bit 1)
+	      (1 << 7) |	//y D1/D2  B side
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDW.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2  A side
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDDW.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (1 << 8) |	//r (LDDW bit 1)
+	      (0 << 7) |	//y D1/D2  A side
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDH.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2  A side
+	      (4 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDB.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2  A side
+	      (2 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDHU.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2  A side
+	      (0 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDBU.D *+SP[A0]") == s) {
+	C67_g((C67_map_regn(a) << 23) |	//dst
+	      (15 << 18) |	//base reg A15
+	      (0 << 13) |	//offset reg A0
+	      (5 << 9) |	//mode 5 = pos offset, base reg + off reg
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (0 << 7) |	//y D1/D2  A side
+	      (1 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(a) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDW.D *") == s) {
+	C67_g((C67_map_regn(b) << 23) |	//dst
+	      (C67_map_regn(a) << 18) |	//base reg A15
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDDW.D *") == s) {
+	C67_g((C67_map_regn(b) << 23) |	//dst
+	      (C67_map_regn(a) << 18) |	//base reg A15
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (1 << 8) |	//r (LDDW bit 1)
+	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDH.D *") == s) {
+	C67_g((C67_map_regn(b) << 23) |	//dst
+	      (C67_map_regn(a) << 18) |	//base reg A15
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
+	      (4 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDB.D *") == s) {
+	C67_g((C67_map_regn(b) << 23) |	//dst
+	      (C67_map_regn(a) << 18) |	//base reg A15
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
+	      (2 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDHU.D *") == s) {
+	C67_g((C67_map_regn(b) << 23) |	//dst
+	      (C67_map_regn(a) << 18) |	//base reg A15
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
+	      (0 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDBU.D *") == s) {
+	C67_g((C67_map_regn(b) << 23) |	//dst
+	      (C67_map_regn(a) << 18) |	//base reg A15
+	      (0 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
+	      (1 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "LDW.D +*") == s) {
+	C67_g((C67_map_regn(b) << 23) |	//dst
+	      (C67_map_regn(a) << 18) |	//base reg A15
+	      (1 << 13) |	//cst5
+	      (1 << 9) |	//mode 1 = pos cst offset
+	      (0 << 8) |	//r (LDDW bit 0)
+	      (C67_map_regs(a) << 7) |	//y D1/D2  src side
+	      (6 << 4) |	//ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 
+	      (1 << 2) |	//opcode
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPLTSP") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x3a << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPGTSP") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x39 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPEQSP") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x38 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    }
+
+    else if (strstr(s, "CMPLTDP") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x2a << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPGTDP") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x29 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPEQDP") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x28 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPLT") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x57 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPGT") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x47 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPEQ") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x53 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPLTU") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x5f << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "CMPGTU") == s) {
+	xpath = C67_map_regs(a) ^ C67_map_regs(b);
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1
+	      (xpath << 12) |	//x use cross path for src2
+	      (0x4f << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side for reg c
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "B DISP") == s) {
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//z
+	      (a << 7) |	//cnst
+	      (0x4 << 2) |	//opcode fixed
+	      (0 << 1) |	//S0/S1
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "B.") == s) {
+	xpath = C67_map_regs(c) ^ 1;
+
+	C67_g((C67_map_regc(b) << 29) |	//creg
+	      (a << 28) |	//inv
+	      (0 << 23) |	//dst
+	      (C67_map_regn(c) << 18) |	//src2
+	      (0 << 13) |	//
+	      (xpath << 12) |	//x cross path if !B side
+	      (0xd << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (1 << 1) |	//must be S2
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "MV.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (0 << 13) |	//src1 (cst5)
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x2 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SPTRUNC.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (0 << 13) |	//src1 NA
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0xb << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "DPTRUNC.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      ((C67_map_regn(b) + 1) << 18) |	//src2   WEIRD CPU must specify odd reg for some reason
+	      (0 << 13) |	//src1 NA
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x1 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "INTSP.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2   
+	      (0 << 13) |	//src1 NA
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x4a << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "INTSPU.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2  
+	      (0 << 13) |	//src1 NA
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x49 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "INTDP.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2  
+	      (0 << 13) |	//src1 NA
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x39 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "INTDPU.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      ((C67_map_regn(b) + 1) << 18) |	//src2   WEIRD CPU must specify odd reg for some reason
+	      (0 << 13) |	//src1 NA
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x3b << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SPDP.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (0 << 13) |	//src1 NA
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x2 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "DPSP.L") == s) {
+	ALWAYS_ASSERT(C67_map_regs(b) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      ((C67_map_regn(b) + 1) << 18) |	//src2 WEIRD CPU must specify odd reg for some reason
+	      (0 << 13) |	//src1 NA
+	      (0 << 12) |	//x cross path if opposite sides
+	      (0x9 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "ADD.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x3 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SUB.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x7 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "OR.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x7f << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "AND.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x7b << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "XOR.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x6f << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "ADDSP.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x10 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "ADDDP.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x18 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SUBSP.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x11 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SUBDP.L") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x19 << 5) |	//opcode
+	      (0x6 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "MPYSP.M") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x1c << 7) |	//opcode
+	      (0x0 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "MPYDP.M") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2 (possible x path)
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x0e << 7) |	//opcode
+	      (0x0 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "MPYI.M") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(a) == C67_map_regs(c));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1 (cst5)
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x4 << 7) |	//opcode
+	      (0x0 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SHR.S") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x37 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SHRU.S") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x27 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "SHL.S") == s) {
+	xpath = C67_map_regs(b) ^ C67_map_regs(c);
+
+	ALWAYS_ASSERT(C67_map_regs(c) == C67_map_regs(a));
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(c) << 23) |	//dst
+	      (C67_map_regn(b) << 18) |	//src2
+	      (C67_map_regn(a) << 13) |	//src1 
+	      (xpath << 12) |	//x cross path if opposite sides
+	      (0x33 << 6) |	//opcode
+	      (0x8 << 2) |	//opcode fixed
+	      (C67_map_regs(c) << 1) |	//side of dest
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "||ADDK") == s) {
+	xpath = 0;		// no xpath required just use the side of the src/dst
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(b) << 23) |	//dst
+	      (a << 07) |	//scst16
+	      (0x14 << 2) |	//opcode fixed
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (1 << 0));	//parallel
+    } else if (strstr(s, "ADDK") == s) {
+	xpath = 0;		// no xpath required just use the side of the src/dst
+
+	C67_g((0 << 29) |	//creg
+	      (0 << 28) |	//inv
+	      (C67_map_regn(b) << 23) |	//dst
+	      (a << 07) |	//scst16
+	      (0x14 << 2) |	//opcode fixed
+	      (C67_map_regs(b) << 1) |	//side of dst
+	      (0 << 0));	//parallel
+    } else if (strstr(s, "NOP") == s) {
+	C67_g(((a - 1) << 13) |	//no of cycles
+	      (0 << 0));	//parallel
+    } else
+	ALWAYS_ASSERT(FALSE);
+
+#ifdef ASSEMBLY_LISTING_C67
+    fprintf(f, " %s %d %d %d\n", s, a, b, c);
+#endif
+
+}
+
+//r=reg to load, fr=from reg, symbol for relocation, constant
+
+void C67_MVKL(int r, int fc)
+{
+    C67_asm("MVKL.", fc, r, 0);
+}
+
+void C67_MVKH(int r, int fc)
+{
+    C67_asm("MVKH.", fc, r, 0);
+}
+
+void C67_STB_SP_A0(int r)
+{
+    C67_asm("STB.D *+SP[A0]", r, 0, 0);	// STB  r,*+SP[A0]
+}
+
+void C67_STH_SP_A0(int r)
+{
+    C67_asm("STH.D *+SP[A0]", r, 0, 0);	// STH  r,*+SP[A0]
+}
+
+void C67_STW_SP_A0(int r)
+{
+    C67_asm("STW.D *+SP[A0]", r, 0, 0);	// STW  r,*+SP[A0]
+}
+
+void C67_STB_PTR(int r, int r2)
+{
+    C67_asm("STB.D *", r, r2, 0);	// STB  r, *r2
+}
+
+void C67_STH_PTR(int r, int r2)
+{
+    C67_asm("STH.D *", r, r2, 0);	// STH  r, *r2
+}
+
+void C67_STW_PTR(int r, int r2)
+{
+    C67_asm("STW.D *", r, r2, 0);	// STW  r, *r2
+}
+
+void C67_STW_PTR_PRE_INC(int r, int r2, int n)
+{
+    C67_asm("STW.D +*", r, r2, n);	// STW  r, *+r2
+}
+
+void C67_PUSH(int r)
+{
+    C67_asm("STW.D SP POST DEC", r, 0, 0);	// STW  r,*SP--
+}
+
+void C67_LDW_SP_A0(int r)
+{
+    C67_asm("LDW.D *+SP[A0]", r, 0, 0);	// LDW  *+SP[A0],r
+}
+
+void C67_LDDW_SP_A0(int r)
+{
+    C67_asm("LDDW.D *+SP[A0]", r, 0, 0);	// LDDW  *+SP[A0],r
+}
+
+void C67_LDH_SP_A0(int r)
+{
+    C67_asm("LDH.D *+SP[A0]", r, 0, 0);	// LDH  *+SP[A0],r
+}
+
+void C67_LDB_SP_A0(int r)
+{
+    C67_asm("LDB.D *+SP[A0]", r, 0, 0);	// LDB  *+SP[A0],r
+}
+
+void C67_LDHU_SP_A0(int r)
+{
+    C67_asm("LDHU.D *+SP[A0]", r, 0, 0);	// LDHU  *+SP[A0],r
+}
+
+void C67_LDBU_SP_A0(int r)
+{
+    C67_asm("LDBU.D *+SP[A0]", r, 0, 0);	// LDBU  *+SP[A0],r
+}
+
+void C67_LDW_PTR(int r, int r2)
+{
+    C67_asm("LDW.D *", r, r2, 0);	// LDW  *r,r2
+}
+
+void C67_LDDW_PTR(int r, int r2)
+{
+    C67_asm("LDDW.D *", r, r2, 0);	// LDDW  *r,r2
+}
+
+void C67_LDH_PTR(int r, int r2)
+{
+    C67_asm("LDH.D *", r, r2, 0);	// LDH  *r,r2
+}
+
+void C67_LDB_PTR(int r, int r2)
+{
+    C67_asm("LDB.D *", r, r2, 0);	// LDB  *r,r2
+}
+
+void C67_LDHU_PTR(int r, int r2)
+{
+    C67_asm("LDHU.D *", r, r2, 0);	// LDHU  *r,r2
+}
+
+void C67_LDBU_PTR(int r, int r2)
+{
+    C67_asm("LDBU.D *", r, r2, 0);	// LDBU  *r,r2
+}
+
+void C67_LDW_PTR_PRE_INC(int r, int r2)
+{
+    C67_asm("LDW.D +*", r, r2, 0);	// LDW  *+r,r2
+}
+
+void C67_POP(int r)
+{
+    C67_asm("LDW.D SP PRE INC", r, 0, 0);	// LDW  *++SP,r
+}
+
+void C67_POP_DW(int r)
+{
+    C67_asm("LDDW.D SP PRE INC", r, 0, 0);	// LDDW  *++SP,r
+}
+
+void C67_CMPLT(int s1, int s2, int dst)
+{
+    C67_asm("CMPLT.L1", s1, s2, dst);
+}
+
+void C67_CMPGT(int s1, int s2, int dst)
+{
+    C67_asm("CMPGT.L1", s1, s2, dst);
+}
+
+void C67_CMPEQ(int s1, int s2, int dst)
+{
+    C67_asm("CMPEQ.L1", s1, s2, dst);
+}
+
+void C67_CMPLTU(int s1, int s2, int dst)
+{
+    C67_asm("CMPLTU.L1", s1, s2, dst);
+}
+
+void C67_CMPGTU(int s1, int s2, int dst)
+{
+    C67_asm("CMPGTU.L1", s1, s2, dst);
+}
+
+
+void C67_CMPLTSP(int s1, int s2, int dst)
+{
+    C67_asm("CMPLTSP.S1", s1, s2, dst);
+}
+
+void C67_CMPGTSP(int s1, int s2, int dst)
+{
+    C67_asm("CMPGTSP.S1", s1, s2, dst);
+}
+
+void C67_CMPEQSP(int s1, int s2, int dst)
+{
+    C67_asm("CMPEQSP.S1", s1, s2, dst);
+}
+
+void C67_CMPLTDP(int s1, int s2, int dst)
+{
+    C67_asm("CMPLTDP.S1", s1, s2, dst);
+}
+
+void C67_CMPGTDP(int s1, int s2, int dst)
+{
+    C67_asm("CMPGTDP.S1", s1, s2, dst);
+}
+
+void C67_CMPEQDP(int s1, int s2, int dst)
+{
+    C67_asm("CMPEQDP.S1", s1, s2, dst);
+}
+
+
+void C67_IREG_B_REG(int inv, int r1, int r2)	// [!R] B  r2
+{
+    C67_asm("B.S2", inv, r1, r2);
+}
+
+
+// call with how many 32 bit words to skip
+// (0 would branch to the branch instruction)
+
+void C67_B_DISP(int disp)	//  B  +2  Branch with constant displacement
+{
+    // Branch point is relative to the 8 word fetch packet
+    //
+    // we will assume the text section always starts on an 8 word (32 byte boundary)
+    //
+    // so add in how many words into the fetch packet the branch is
+
+
+    C67_asm("B DISP", disp + ((ind & 31) >> 2), 0, 0);
+}
+
+void C67_NOP(int n)
+{
+    C67_asm("NOP", n, 0, 0);
+}
+
+void C67_ADDK(int n, int r)
+{
+    ALWAYS_ASSERT(abs(n) < 32767);
+
+    C67_asm("ADDK", n, r, 0);
+}
+
+void C67_ADDK_PARALLEL(int n, int r)
+{
+    ALWAYS_ASSERT(abs(n) < 32767);
+
+    C67_asm("||ADDK", n, r, 0);
+}
+
+void C67_Adjust_ADDK(int *inst, int n)
+{
+    ALWAYS_ASSERT(abs(n) < 32767);
+
+    *inst = (*inst & (~(0xffff << 7))) | ((n & 0xffff) << 7);
+}
+
+void C67_MV(int r, int v)
+{
+    C67_asm("MV.L", 0, r, v);
+}
+
+
+void C67_DPTRUNC(int r, int v)
+{
+    C67_asm("DPTRUNC.L", 0, r, v);
+}
+
+void C67_SPTRUNC(int r, int v)
+{
+    C67_asm("SPTRUNC.L", 0, r, v);
+}
+
+void C67_INTSP(int r, int v)
+{
+    C67_asm("INTSP.L", 0, r, v);
+}
+
+void C67_INTDP(int r, int v)
+{
+    C67_asm("INTDP.L", 0, r, v);
+}
+
+void C67_INTSPU(int r, int v)
+{
+    C67_asm("INTSPU.L", 0, r, v);
+}
+
+void C67_INTDPU(int r, int v)
+{
+    C67_asm("INTDPU.L", 0, r, v);
+}
+
+void C67_SPDP(int r, int v)
+{
+    C67_asm("SPDP.L", 0, r, v);
+}
+
+void C67_DPSP(int r, int v)	// note regs must be on the same side
+{
+    C67_asm("DPSP.L", 0, r, v);
+}
+
+void C67_ADD(int r, int v)
+{
+    C67_asm("ADD.L", v, r, v);
+}
+
+void C67_SUB(int r, int v)
+{
+    C67_asm("SUB.L", v, r, v);
+}
+
+void C67_AND(int r, int v)
+{
+    C67_asm("AND.L", v, r, v);
+}
+
+void C67_OR(int r, int v)
+{
+    C67_asm("OR.L", v, r, v);
+}
+
+void C67_XOR(int r, int v)
+{
+    C67_asm("XOR.L", v, r, v);
+}
+
+void C67_ADDSP(int r, int v)
+{
+    C67_asm("ADDSP.L", v, r, v);
+}
+
+void C67_SUBSP(int r, int v)
+{
+    C67_asm("SUBSP.L", v, r, v);
+}
+
+void C67_MPYSP(int r, int v)
+{
+    C67_asm("MPYSP.M", v, r, v);
+}
+
+void C67_ADDDP(int r, int v)
+{
+    C67_asm("ADDDP.L", v, r, v);
+}
+
+void C67_SUBDP(int r, int v)
+{
+    C67_asm("SUBDP.L", v, r, v);
+}
+
+void C67_MPYDP(int r, int v)
+{
+    C67_asm("MPYDP.M", v, r, v);
+}
+
+void C67_MPYI(int r, int v)
+{
+    C67_asm("MPYI.M", v, r, v);
+}
+
+void C67_SHL(int r, int v)
+{
+    C67_asm("SHL.S", r, v, v);
+}
+
+void C67_SHRU(int r, int v)
+{
+    C67_asm("SHRU.S", r, v, v);
+}
+
+void C67_SHR(int r, int v)
+{
+    C67_asm("SHR.S", r, v, v);
+}
+
+
+
+/* load 'r' from value 'sv' */
+void load(int r, SValue * sv)
+{
+    int v, t, ft, fc, fr, size = 0, element;
+    BOOL Unsigned = FALSE;
+    SValue v1;
+
+    fr = sv->r;
+    ft = sv->type.t;
+    fc = sv->c.ul;
+
+    v = fr & VT_VALMASK;
+    if (fr & VT_LVAL) {
+	if (v == VT_LLOCAL) {
+	    v1.type.t = VT_INT;
+	    v1.r = VT_LOCAL | VT_LVAL;
+	    v1.c.ul = fc;
+	    load(r, &v1);
+	    fr = r;
+	} else if ((ft & VT_BTYPE) == VT_LDOUBLE) {
+	    tcc_error("long double not supported");
+	} else if ((ft & VT_TYPE) == VT_BYTE) {
+	    size = 1;
+	} else if ((ft & VT_TYPE) == (VT_BYTE | VT_UNSIGNED)) {
+	    size = 1;
+	    Unsigned = TRUE;
+	} else if ((ft & VT_TYPE) == VT_SHORT) {
+	    size = 2;
+	} else if ((ft & VT_TYPE) == (VT_SHORT | VT_UNSIGNED)) {
+	    size = 2;
+	    Unsigned = TRUE;
+	} else if ((ft & VT_BTYPE) == VT_DOUBLE) {
+	    size = 8;
+	} else {
+	    size = 4;
+	}
+
+	// check if fc is a positive reference on the stack, 
+	// if it is tcc is referencing what it thinks is a parameter
+	// on the stack, so check if it is really in a register.
+
+
+	if (v == VT_LOCAL && fc > 0) {
+	    int stack_pos = 8;
+
+	    for (t = 0; t < NoCallArgsPassedOnStack; t++) {
+		if (fc == stack_pos)
+		    break;
+
+		stack_pos += TranslateStackToReg[t];
+	    }
+
+	    // param has been pushed on stack, get it like a local var
+
+	    fc = ParamLocOnStack[t] - 8;
+	}
+
+	if ((fr & VT_VALMASK) < VT_CONST)	// check for pure indirect
+	{
+	    if (size == 1) {
+		if (Unsigned)
+		    C67_LDBU_PTR(v, r);	// LDBU  *v,r
+		else
+		    C67_LDB_PTR(v, r);	// LDB  *v,r
+	    } else if (size == 2) {
+		if (Unsigned)
+		    C67_LDHU_PTR(v, r);	// LDHU  *v,r
+		else
+		    C67_LDH_PTR(v, r);	// LDH  *v,r
+	    } else if (size == 4) {
+		C67_LDW_PTR(v, r);	// LDW  *v,r
+	    } else if (size == 8) {
+		C67_LDDW_PTR(v, r);	// LDDW  *v,r
+	    }
+
+	    C67_NOP(4);		// NOP 4
+	    return;
+	} else if (fr & VT_SYM) {
+	    greloc(cur_text_section, sv->sym, ind, R_C60LO16);	// rem the inst need to be patched
+	    greloc(cur_text_section, sv->sym, ind + 4, R_C60HI16);
+
+
+	    C67_MVKL(C67_A0, fc);	//r=reg to load,  constant
+	    C67_MVKH(C67_A0, fc);	//r=reg to load,  constant
+
+
+	    if (size == 1) {
+		if (Unsigned)
+		    C67_LDBU_PTR(C67_A0, r);	// LDBU  *A0,r
+		else
+		    C67_LDB_PTR(C67_A0, r);	// LDB  *A0,r
+	    } else if (size == 2) {
+		if (Unsigned)
+		    C67_LDHU_PTR(C67_A0, r);	// LDHU  *A0,r
+		else
+		    C67_LDH_PTR(C67_A0, r);	// LDH  *A0,r
+	    } else if (size == 4) {
+		C67_LDW_PTR(C67_A0, r);	// LDW  *A0,r
+	    } else if (size == 8) {
+		C67_LDDW_PTR(C67_A0, r);	// LDDW  *A0,r
+	    }
+
+	    C67_NOP(4);		// NOP 4
+	    return;
+	} else {
+	    element = size;
+
+	    // divide offset in bytes to create element index
+	    C67_MVKL(C67_A0, (fc / element) + 8 / element);	//r=reg to load,  constant
+	    C67_MVKH(C67_A0, (fc / element) + 8 / element);	//r=reg to load,  constant
+
+	    if (size == 1) {
+		if (Unsigned)
+		    C67_LDBU_SP_A0(r);	// LDBU  r, SP[A0]
+		else
+		    C67_LDB_SP_A0(r);	// LDB  r, SP[A0]
+	    } else if (size == 2) {
+		if (Unsigned)
+		    C67_LDHU_SP_A0(r);	// LDHU  r, SP[A0]
+		else
+		    C67_LDH_SP_A0(r);	// LDH  r, SP[A0]
+	    } else if (size == 4) {
+		C67_LDW_SP_A0(r);	// LDW  r, SP[A0]
+	    } else if (size == 8) {
+		C67_LDDW_SP_A0(r);	// LDDW  r, SP[A0]
+	    }
+
+
+	    C67_NOP(4);		// NOP 4
+	    return;
+	}
+    } else {
+	if (v == VT_CONST) {
+	    if (fr & VT_SYM) {
+		greloc(cur_text_section, sv->sym, ind, R_C60LO16);	// rem the inst need to be patched
+		greloc(cur_text_section, sv->sym, ind + 4, R_C60HI16);
+	    }
+	    C67_MVKL(r, fc);	//r=reg to load, constant
+	    C67_MVKH(r, fc);	//r=reg to load, constant
+	} else if (v == VT_LOCAL) {
+	    C67_MVKL(r, fc + 8);	//r=reg to load, constant C67 stack points to next free
+	    C67_MVKH(r, fc + 8);	//r=reg to load, constant
+	    C67_ADD(C67_FP, r);	// MV v,r   v -> r
+	} else if (v == VT_CMP) {
+	    C67_MV(C67_compare_reg, r);	// MV v,r   v -> r
+	} else if (v == VT_JMP || v == VT_JMPI) {
+	    t = v & 1;
+	    C67_B_DISP(4);	//  Branch with constant displacement, skip over this branch, load, nop, load
+	    C67_MVKL(r, t);	//  r=reg to load, 0 or 1 (do this while branching)
+	    C67_NOP(4);		//  NOP 4
+	    gsym(fc);		//  modifies other branches to branch here
+	    C67_MVKL(r, t ^ 1);	//  r=reg to load, 0 or 1
+	} else if (v != r) {
+	    C67_MV(v, r);	// MV v,r   v -> r
+
+	    if ((ft & VT_BTYPE) == VT_DOUBLE)
+		C67_MV(v + 1, r + 1);	// MV v,r   v -> r
+	}
+    }
+}
+
+
+/* store register 'r' in lvalue 'v' */
+void store(int r, SValue * v)
+{
+    int fr, bt, ft, fc, size, t, element;
+
+    ft = v->type.t;
+    fc = v->c.ul;
+    fr = v->r & VT_VALMASK;
+    bt = ft & VT_BTYPE;
+    /* XXX: incorrect if float reg to reg */
+
+    if (bt == VT_LDOUBLE) {
+	tcc_error("long double not supported");
+    } else {
+	if (bt == VT_SHORT)
+	    size = 2;
+	else if (bt == VT_BYTE)
+	    size = 1;
+	else if (bt == VT_DOUBLE)
+	    size = 8;
+	else
+	    size = 4;
+
+	if ((v->r & VT_VALMASK) == VT_CONST) {
+	    /* constant memory reference */
+
+	    if (v->r & VT_SYM) {
+		greloc(cur_text_section, v->sym, ind, R_C60LO16);	// rem the inst need to be patched
+		greloc(cur_text_section, v->sym, ind + 4, R_C60HI16);
+	    }
+	    C67_MVKL(C67_A0, fc);	//r=reg to load,  constant
+	    C67_MVKH(C67_A0, fc);	//r=reg to load,  constant
+
+	    if (size == 1)
+		C67_STB_PTR(r, C67_A0);	// STB  r, *A0
+	    else if (size == 2)
+		C67_STH_PTR(r, C67_A0);	// STH  r, *A0
+	    else if (size == 4 || size == 8)
+		C67_STW_PTR(r, C67_A0);	// STW  r, *A0
+
+	    if (size == 8)
+		C67_STW_PTR_PRE_INC(r + 1, C67_A0, 1);	// STW  r, *+A0[1]
+	} else if ((v->r & VT_VALMASK) == VT_LOCAL) {
+	    // check case of storing to passed argument that
+	    // tcc thinks is on the stack but for C67 is
+	    // passed as a reg.  However it may have been
+	    // saved to the stack, if that reg was required
+	    // for a call to a child function
+
+	    if (fc > 0)		// argument ??
+	    {
+		// walk through sizes and figure which param
+
+		int stack_pos = 8;
+
+		for (t = 0; t < NoCallArgsPassedOnStack; t++) {
+		    if (fc == stack_pos)
+			break;
+
+		    stack_pos += TranslateStackToReg[t];
+		}
+
+		// param has been pushed on stack, get it like a local var
+		fc = ParamLocOnStack[t] - 8;
+	    }
+
+	    if (size == 8)
+		element = 4;
+	    else
+		element = size;
+
+	    // divide offset in bytes to create word index
+	    C67_MVKL(C67_A0, (fc / element) + 8 / element);	//r=reg to load,  constant
+	    C67_MVKH(C67_A0, (fc / element) + 8 / element);	//r=reg to load,  constant
+
+
+
+	    if (size == 1)
+		C67_STB_SP_A0(r);	// STB  r, SP[A0]
+	    else if (size == 2)
+		C67_STH_SP_A0(r);	// STH  r, SP[A0]
+	    else if (size == 4 || size == 8)
+		C67_STW_SP_A0(r);	// STW  r, SP[A0]
+
+	    if (size == 8) {
+		C67_ADDK(1, C67_A0);	//  ADDK 1,A0
+		C67_STW_SP_A0(r + 1);	//  STW  r, SP[A0]
+	    }
+	} else {
+	    if (size == 1)
+		C67_STB_PTR(r, fr);	// STB  r, *fr
+	    else if (size == 2)
+		C67_STH_PTR(r, fr);	// STH  r, *fr
+	    else if (size == 4 || size == 8)
+		C67_STW_PTR(r, fr);	// STW  r, *fr
+
+	    if (size == 8) {
+		C67_STW_PTR_PRE_INC(r + 1, fr, 1);	// STW  r, *+fr[1]
+	    }
+	}
+    }
+}
+
+/* 'is_jmp' is '1' if it is a jump */
+static void gcall_or_jmp(int is_jmp)
+{
+    int r;
+    Sym *sym;
+
+    if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+	/* constant case */
+	if (vtop->r & VT_SYM) {
+	    /* relocation case */
+
+	    // get add into A0, then start the jump B3
+
+	    greloc(cur_text_section, vtop->sym, ind, R_C60LO16);	// rem the inst need to be patched
+	    greloc(cur_text_section, vtop->sym, ind + 4, R_C60HI16);
+
+	    C67_MVKL(C67_A0, 0);	//r=reg to load, constant
+	    C67_MVKH(C67_A0, 0);	//r=reg to load, constant
+	    C67_IREG_B_REG(0, C67_CREG_ZERO, C67_A0);	//  B.S2x  A0
+
+	    if (is_jmp) {
+		C67_NOP(5);	// simple jump, just put NOP
+	    } else {
+		// Call, must load return address into B3 during delay slots
+
+		sym = get_sym_ref(&char_pointer_type, cur_text_section, ind + 12, 0);	// symbol for return address
+		greloc(cur_text_section, sym, ind, R_C60LO16);	// rem the inst need to be patched
+		greloc(cur_text_section, sym, ind + 4, R_C60HI16);
+		C67_MVKL(C67_B3, 0);	//r=reg to load, constant
+		C67_MVKH(C67_B3, 0);	//r=reg to load, constant
+		C67_NOP(3);	// put remaining NOPs
+	    }
+	} else {
+	    /* put an empty PC32 relocation */
+	    ALWAYS_ASSERT(FALSE);
+	}
+    } else {
+	/* otherwise, indirect call */
+	r = gv(RC_INT);
+	C67_IREG_B_REG(0, C67_CREG_ZERO, r);	//  B.S2x  r
+
+	if (is_jmp) {
+	    C67_NOP(5);		// simple jump, just put NOP
+	} else {
+	    // Call, must load return address into B3 during delay slots
+
+	    sym = get_sym_ref(&char_pointer_type, cur_text_section, ind + 12, 0);	// symbol for return address
+	    greloc(cur_text_section, sym, ind, R_C60LO16);	// rem the inst need to be patched
+	    greloc(cur_text_section, sym, ind + 4, R_C60HI16);
+	    C67_MVKL(C67_B3, 0);	//r=reg to load, constant
+	    C67_MVKH(C67_B3, 0);	//r=reg to load, constant
+	    C67_NOP(3);		// put remaining NOPs
+	}
+    }
+}
+
+/* generate function call with address in (vtop->t, vtop->c) and free function
+   context. Stack entry is popped */
+void gfunc_call(int nb_args)
+{
+    int i, r, size = 0;
+    int args_sizes[NoCallArgsPassedOnStack];
+
+    if (nb_args > NoCallArgsPassedOnStack) {
+	tcc_error("more than 10 function params not currently supported");
+	// handle more than 10, put some on the stack
+    }
+
+    for (i = 0; i < nb_args; i++) {
+	if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+	    ALWAYS_ASSERT(FALSE);
+	} else if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+	    ALWAYS_ASSERT(FALSE);
+	} else {
+	    /* simple type (currently always same size) */
+	    /* XXX: implicit cast ? */
+
+
+	    if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
+		tcc_error("long long not supported");
+	    } else if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+		tcc_error("long double not supported");
+	    } else if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
+		size = 8;
+	    } else {
+		size = 4;
+	    }
+
+	    // put the parameter into the corresponding reg (pair)
+
+	    r = gv(RC_C67_A4 << (2 * i));
+
+	    // must put on stack because with 1 pass compiler , no way to tell
+	    // if an up coming nested call might overwrite these regs
+
+	    C67_PUSH(r);
+
+	    if (size == 8) {
+		C67_STW_PTR_PRE_INC(r + 1, C67_SP, 3);	// STW  r, *+SP[3] (go back and put the other)
+	    }
+	    args_sizes[i] = size;
+	}
+	vtop--;
+    }
+    // POP all the params on the stack into registers for the
+    // immediate call (in reverse order)
+
+    for (i = nb_args - 1; i >= 0; i--) {
+
+	if (args_sizes[i] == 8)
+	    C67_POP_DW(TREG_C67_A4 + i * 2);
+	else
+	    C67_POP(TREG_C67_A4 + i * 2);
+    }
+    gcall_or_jmp(0);
+    vtop--;
+}
+
+
+// to be compatible with Code Composer for the C67
+// the first 10 parameters must be passed in registers
+// (pairs for 64 bits) starting wit; A4:A5, then B4:B5 and
+// ending with B12:B13.
+//
+// When a call is made, if the caller has its parameters
+// in regs A4-B13 these must be saved before/as the call 
+// parameters are loaded and restored upon return (or if/when needed).
+
+/* generate function prolog of type 't' */
+void gfunc_prolog(CType * func_type)
+{
+    int addr, align, size, func_call, i;
+    Sym *sym;
+    CType *type;
+
+    sym = func_type->ref;
+    func_call = sym->r;
+    addr = 8;
+    /* if the function returns a structure, then add an
+       implicit pointer parameter */
+    func_vt = sym->type;
+    if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
+	func_vc = addr;
+	addr += 4;
+    }
+
+    NoOfCurFuncArgs = 0;
+
+    /* define parameters */
+    while ((sym = sym->next) != NULL) {
+	type = &sym->type;
+	sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), addr);
+	size = type_size(type, &align);
+	size = (size + 3) & ~3;
+
+	// keep track of size of arguments so
+	// we can translate where tcc thinks they
+	// are on the stack into the appropriate reg
+
+	TranslateStackToReg[NoOfCurFuncArgs] = size;
+	NoOfCurFuncArgs++;
+
+#ifdef FUNC_STRUCT_PARAM_AS_PTR
+	/* structs are passed as pointer */
+	if ((type->t & VT_BTYPE) == VT_STRUCT) {
+	    size = 4;
+	}
+#endif
+	addr += size;
+    }
+    func_ret_sub = 0;
+    /* pascal type call ? */
+    if (func_call == FUNC_STDCALL)
+	func_ret_sub = addr - 8;
+
+    C67_MV(C67_FP, C67_A0);	//  move FP -> A0
+    C67_MV(C67_SP, C67_FP);	//  move SP -> FP
+
+    // place all the args passed in regs onto the stack
+
+    loc = 0;
+    for (i = 0; i < NoOfCurFuncArgs; i++) {
+
+	ParamLocOnStack[i] = loc;	// remember where the param is
+	loc += -8;
+
+	C67_PUSH(TREG_C67_A4 + i * 2);
+
+	if (TranslateStackToReg[i] == 8) {
+	    C67_STW_PTR_PRE_INC(TREG_C67_A4 + i * 2 + 1, C67_SP, 3);	// STW  r, *+SP[1] (go back and put the other)
+	}
+    }
+
+    TotalBytesPushedOnStack = -loc;
+
+    func_sub_sp_offset = ind;	// remember where we put the stack instruction 
+    C67_ADDK(0, C67_SP);	//  ADDK.L2 loc,SP  (just put zero temporarily)
+
+    C67_PUSH(C67_A0);
+    C67_PUSH(C67_B3);
+}
+
+/* generate function epilog */
+void gfunc_epilog(void)
+{
+    {
+	int local = (-loc + 7) & -8;	// stack must stay aligned to 8 bytes for LDDW instr
+	C67_POP(C67_B3);
+	C67_NOP(4);		// NOP wait for load
+	C67_IREG_B_REG(0, C67_CREG_ZERO, C67_B3);	//  B.S2  B3
+	C67_POP(C67_FP);
+	C67_ADDK(local, C67_SP);	//  ADDK.L2 loc,SP  
+	C67_Adjust_ADDK((int *) (cur_text_section->data +
+				 func_sub_sp_offset),
+			-local + TotalBytesPushedOnStack);
+	C67_NOP(3);		// NOP 
+    }
+}
+
+/* generate a jump to a label */
+int gjmp(int t)
+{
+    int ind1 = ind;
+
+    C67_MVKL(C67_A0, t);	//r=reg to load,  constant
+    C67_MVKH(C67_A0, t);	//r=reg to load,  constant
+    C67_IREG_B_REG(0, C67_CREG_ZERO, C67_A0);	// [!R] B.S2x  A0
+    C67_NOP(5);
+    return ind1;
+}
+
+/* generate a jump to a fixed address */
+void gjmp_addr(int a)
+{
+    Sym *sym;
+    // I guess this routine is used for relative short
+    // local jumps, for now just handle it as the general
+    // case
+
+    // define a label that will be relocated
+
+    sym = get_sym_ref(&char_pointer_type, cur_text_section, a, 0);
+    greloc(cur_text_section, sym, ind, R_C60LO16);
+    greloc(cur_text_section, sym, ind + 4, R_C60HI16);
+
+    gjmp(0);			// place a zero there later the symbol will be added to it
+}
+
+/* generate a test. set 'inv' to invert test. Stack entry is popped */
+int gtst(int inv, int t)
+{
+    int ind1, n;
+    int v, *p;
+
+    v = vtop->r & VT_VALMASK;
+    if (v == VT_CMP) {
+	/* fast case : can jump directly since flags are set */
+	// C67 uses B2 sort of as flags register
+	ind1 = ind;
+	C67_MVKL(C67_A0, t);	//r=reg to load, constant
+	C67_MVKH(C67_A0, t);	//r=reg to load, constant
+
+	if (C67_compare_reg != TREG_EAX &&	// check if not already in a conditional test reg
+	    C67_compare_reg != TREG_EDX &&
+	    C67_compare_reg != TREG_ST0 && C67_compare_reg != C67_B2) {
+	    C67_MV(C67_compare_reg, C67_B2);
+	    C67_compare_reg = C67_B2;
+	}
+
+	C67_IREG_B_REG(C67_invert_test ^ inv, C67_compare_reg, C67_A0);	// [!R] B.S2x  A0
+	C67_NOP(5);
+	t = ind1;		//return where we need to patch
+
+    } else if (v == VT_JMP || v == VT_JMPI) {
+	/* && or || optimization */
+	if ((v & 1) == inv) {
+	    /* insert vtop->c jump list in t */
+	    p = &vtop->c.i;
+
+	    // I guess the idea is to traverse to the
+	    // null at the end of the list and store t
+	    // there
+
+	    n = *p;
+	    while (n != 0) {
+		p = (int *) (cur_text_section->data + n);
+
+		// extract 32 bit address from MVKH/MVKL
+		n = ((*p >> 7) & 0xffff);
+		n |= ((*(p + 1) >> 7) & 0xffff) << 16;
+	    }
+	    *p |= (t & 0xffff) << 7;
+	    *(p + 1) |= ((t >> 16) & 0xffff) << 7;
+	    t = vtop->c.i;
+
+	} else {
+	    t = gjmp(t);
+	    gsym(vtop->c.i);
+	}
+    } else {
+	if (is_float(vtop->type.t)) {
+	    vpushi(0);
+	    gen_op(TOK_NE);
+	}
+	if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+	    /* constant jmp optimization */
+	    if ((vtop->c.i != 0) != inv)
+		t = gjmp(t);
+	} else {
+	    // I think we need to get the value on the stack
+	    // into a register, test it, and generate a branch
+	    // return the address of the branch, so it can be
+	    // later patched
+
+	    v = gv(RC_INT);	// get value into a reg 
+	    ind1 = ind;
+	    C67_MVKL(C67_A0, t);	//r=reg to load, constant
+	    C67_MVKH(C67_A0, t);	//r=reg to load, constant
+
+	    if (v != TREG_EAX &&	// check if not already in a conditional test reg
+		v != TREG_EDX && v != TREG_ST0 && v != C67_B2) {
+		C67_MV(v, C67_B2);
+		v = C67_B2;
+	    }
+
+	    C67_IREG_B_REG(inv, v, C67_A0);	// [!R] B.S2x  A0
+	    C67_NOP(5);
+	    t = ind1;		//return where we need to patch
+	    ind1 = ind;
+	}
+    }
+    vtop--;
+    return t;
+}
+
+/* generate an integer binary operation */
+void gen_opi(int op)
+{
+    int r, fr, opc, t;
+
+    switch (op) {
+    case '+':
+    case TOK_ADDC1:		/* add with carry generation */
+	opc = 0;
+      gen_op8:
+
+
+// C67 can't do const compares, must load into a reg
+// so just go to gv2 directly - tktk
+
+
+
+	if (op >= TOK_ULT && op <= TOK_GT)
+	    gv2(RC_INT_BSIDE, RC_INT);	// make sure r (src1) is on the B Side of CPU
+	else
+	    gv2(RC_INT, RC_INT);
+
+	r = vtop[-1].r;
+	fr = vtop[0].r;
+
+	C67_compare_reg = C67_B2;
+
+
+	if (op == TOK_LT) {
+	    C67_CMPLT(r, fr, C67_B2);
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_GE) {
+	    C67_CMPLT(r, fr, C67_B2);
+	    C67_invert_test = TRUE;
+	} else if (op == TOK_GT) {
+	    C67_CMPGT(r, fr, C67_B2);
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_LE) {
+	    C67_CMPGT(r, fr, C67_B2);
+	    C67_invert_test = TRUE;
+	} else if (op == TOK_EQ) {
+	    C67_CMPEQ(r, fr, C67_B2);
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_NE) {
+	    C67_CMPEQ(r, fr, C67_B2);
+	    C67_invert_test = TRUE;
+	} else if (op == TOK_ULT) {
+	    C67_CMPLTU(r, fr, C67_B2);
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_UGE) {
+	    C67_CMPLTU(r, fr, C67_B2);
+	    C67_invert_test = TRUE;
+	} else if (op == TOK_UGT) {
+	    C67_CMPGTU(r, fr, C67_B2);
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_ULE) {
+	    C67_CMPGTU(r, fr, C67_B2);
+	    C67_invert_test = TRUE;
+	} else if (op == '+')
+	    C67_ADD(fr, r);	// ADD  r,fr,r
+	else if (op == '-')
+	    C67_SUB(fr, r);	// SUB  r,fr,r
+	else if (op == '&')
+	    C67_AND(fr, r);	// AND  r,fr,r
+	else if (op == '|')
+	    C67_OR(fr, r);	// OR  r,fr,r
+	else if (op == '^')
+	    C67_XOR(fr, r);	// XOR  r,fr,r
+	else
+	    ALWAYS_ASSERT(FALSE);
+
+	vtop--;
+	if (op >= TOK_ULT && op <= TOK_GT) {
+	    vtop->r = VT_CMP;
+	    vtop->c.i = op;
+	}
+	break;
+    case '-':
+    case TOK_SUBC1:		/* sub with carry generation */
+	opc = 5;
+	goto gen_op8;
+    case TOK_ADDC2:		/* add with carry use */
+	opc = 2;
+	goto gen_op8;
+    case TOK_SUBC2:		/* sub with carry use */
+	opc = 3;
+	goto gen_op8;
+    case '&':
+	opc = 4;
+	goto gen_op8;
+    case '^':
+	opc = 6;
+	goto gen_op8;
+    case '|':
+	opc = 1;
+	goto gen_op8;
+    case '*':
+    case TOK_UMULL:
+	gv2(RC_INT, RC_INT);
+	r = vtop[-1].r;
+	fr = vtop[0].r;
+	vtop--;
+	C67_MPYI(fr, r);	// 32 bit bultiply  fr,r,fr
+	C67_NOP(8);		// NOP 8 for worst case
+	break;
+    case TOK_SHL:
+	gv2(RC_INT_BSIDE, RC_INT_BSIDE);	// shift amount must be on same side as dst
+	r = vtop[-1].r;
+	fr = vtop[0].r;
+	vtop--;
+	C67_SHL(fr, r);		// arithmetic/logical shift
+	break;
+
+    case TOK_SHR:
+	gv2(RC_INT_BSIDE, RC_INT_BSIDE);	// shift amount must be on same side as dst
+	r = vtop[-1].r;
+	fr = vtop[0].r;
+	vtop--;
+	C67_SHRU(fr, r);	// logical shift
+	break;
+
+    case TOK_SAR:
+	gv2(RC_INT_BSIDE, RC_INT_BSIDE);	// shift amount must be on same side as dst
+	r = vtop[-1].r;
+	fr = vtop[0].r;
+	vtop--;
+	C67_SHR(fr, r);		// arithmetic shift
+	break;
+
+    case '/':
+	t = TOK__divi;
+      call_func:
+	vswap();
+	/* call generic idiv function */
+	vpush_global_sym(&func_old_type, t);
+	vrott(3);
+	gfunc_call(2);
+	vpushi(0);
+	vtop->r = REG_IRET;
+	vtop->r2 = VT_CONST;
+	break;
+    case TOK_UDIV:
+    case TOK_PDIV:
+	t = TOK__divu;
+	goto call_func;
+    case '%':
+	t = TOK__remi;
+	goto call_func;
+    case TOK_UMOD:
+	t = TOK__remu;
+	goto call_func;
+
+    default:
+	opc = 7;
+	goto gen_op8;
+    }
+}
+
+/* generate a floating point operation 'v = t1 op t2' instruction. The
+   two operands are guaranted to have the same floating point type */
+/* XXX: need to use ST1 too */
+void gen_opf(int op)
+{
+    int ft, fc, fr, r;
+
+    if (op >= TOK_ULT && op <= TOK_GT)
+	gv2(RC_EDX, RC_EAX);	// make sure src2 is on b side
+    else
+	gv2(RC_FLOAT, RC_FLOAT);	// make sure src2 is on b side
+
+    ft = vtop->type.t;
+    fc = vtop->c.ul;
+    r = vtop->r;
+    fr = vtop[-1].r;
+
+
+    if ((ft & VT_BTYPE) == VT_LDOUBLE)
+	tcc_error("long doubles not supported");
+
+    if (op >= TOK_ULT && op <= TOK_GT) {
+
+	r = vtop[-1].r;
+	fr = vtop[0].r;
+
+	C67_compare_reg = C67_B2;
+
+	if (op == TOK_LT) {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE)
+		C67_CMPLTDP(r, fr, C67_B2);
+	    else
+		C67_CMPLTSP(r, fr, C67_B2);
+
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_GE) {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE)
+		C67_CMPLTDP(r, fr, C67_B2);
+	    else
+		C67_CMPLTSP(r, fr, C67_B2);
+
+	    C67_invert_test = TRUE;
+	} else if (op == TOK_GT) {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE)
+		C67_CMPGTDP(r, fr, C67_B2);
+	    else
+		C67_CMPGTSP(r, fr, C67_B2);
+
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_LE) {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE)
+		C67_CMPGTDP(r, fr, C67_B2);
+	    else
+		C67_CMPGTSP(r, fr, C67_B2);
+
+	    C67_invert_test = TRUE;
+	} else if (op == TOK_EQ) {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE)
+		C67_CMPEQDP(r, fr, C67_B2);
+	    else
+		C67_CMPEQSP(r, fr, C67_B2);
+
+	    C67_invert_test = FALSE;
+	} else if (op == TOK_NE) {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE)
+		C67_CMPEQDP(r, fr, C67_B2);
+	    else
+		C67_CMPEQSP(r, fr, C67_B2);
+
+	    C67_invert_test = TRUE;
+	} else {
+	    ALWAYS_ASSERT(FALSE);
+	}
+	vtop->r = VT_CMP;	// tell TCC that result is in "flags" actually B2
+    } else {
+	if (op == '+') {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE) {
+		C67_ADDDP(r, fr);	// ADD  fr,r,fr
+		C67_NOP(6);
+	    } else {
+		C67_ADDSP(r, fr);	// ADD  fr,r,fr
+		C67_NOP(3);
+	    }
+	    vtop--;
+	} else if (op == '-') {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE) {
+		C67_SUBDP(r, fr);	// SUB  fr,r,fr
+		C67_NOP(6);
+	    } else {
+		C67_SUBSP(r, fr);	// SUB  fr,r,fr
+		C67_NOP(3);
+	    }
+	    vtop--;
+	} else if (op == '*') {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE) {
+		C67_MPYDP(r, fr);	// MPY  fr,r,fr
+		C67_NOP(9);
+	    } else {
+		C67_MPYSP(r, fr);	// MPY  fr,r,fr
+		C67_NOP(3);
+	    }
+	    vtop--;
+	} else if (op == '/') {
+	    if ((ft & VT_BTYPE) == VT_DOUBLE) {
+		// must call intrinsic DP floating point divide
+		vswap();
+		/* call generic idiv function */
+		vpush_global_sym(&func_old_type, TOK__divd);
+		vrott(3);
+		gfunc_call(2);
+		vpushi(0);
+		vtop->r = REG_FRET;
+		vtop->r2 = REG_LRET;
+
+	    } else {
+		// must call intrinsic SP floating point divide
+		vswap();
+		/* call generic idiv function */
+		vpush_global_sym(&func_old_type, TOK__divf);
+		vrott(3);
+		gfunc_call(2);
+		vpushi(0);
+		vtop->r = REG_FRET;
+		vtop->r2 = VT_CONST;
+	    }
+	} else
+	    ALWAYS_ASSERT(FALSE);
+
+
+    }
+}
+
+
+/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
+   and 'long long' cases. */
+void gen_cvt_itof(int t)
+{
+    int r;
+
+    gv(RC_INT);
+    r = vtop->r;
+
+    if ((t & VT_BTYPE) == VT_DOUBLE) {
+	if (t & VT_UNSIGNED)
+	    C67_INTDPU(r, r);
+	else
+	    C67_INTDP(r, r);
+
+	C67_NOP(4);
+	vtop->type.t = VT_DOUBLE;
+    } else {
+	if (t & VT_UNSIGNED)
+	    C67_INTSPU(r, r);
+	else
+	    C67_INTSP(r, r);
+	C67_NOP(3);
+	vtop->type.t = VT_FLOAT;
+    }
+
+}
+
+/* convert fp to int 't' type */
+/* XXX: handle long long case */
+void gen_cvt_ftoi(int t)
+{
+    int r;
+
+    gv(RC_FLOAT);
+    r = vtop->r;
+
+    if (t != VT_INT)
+	tcc_error("long long not supported");
+    else {
+	if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
+	    C67_DPTRUNC(r, r);
+	    C67_NOP(3);
+	} else {
+	    C67_SPTRUNC(r, r);
+	    C67_NOP(3);
+	}
+
+	vtop->type.t = VT_INT;
+
+    }
+}
+
+/* convert from one floating point type to another */
+void gen_cvt_ftof(int t)
+{
+    int r, r2;
+
+    if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE &&
+	(t & VT_BTYPE) == VT_FLOAT) {
+	// convert double to float
+
+	gv(RC_FLOAT);		// get it in a register pair
+
+	r = vtop->r;
+
+	C67_DPSP(r, r);		// convert it to SP same register
+	C67_NOP(3);
+
+	vtop->type.t = VT_FLOAT;
+	vtop->r2 = VT_CONST;	// set this as unused
+    } else if ((vtop->type.t & VT_BTYPE) == VT_FLOAT &&
+	       (t & VT_BTYPE) == VT_DOUBLE) {
+	// convert float to double
+
+	gv(RC_FLOAT);		// get it in a register
+
+	r = vtop->r;
+
+	if (r == TREG_EAX) {	// make sure the paired reg is avail
+	    r2 = get_reg(RC_ECX);
+	} else if (r == TREG_EDX) {
+	    r2 = get_reg(RC_ST0);
+	} else {
+	    ALWAYS_ASSERT(FALSE);
+            r2 = 0; /* avoid warning */
+        }
+
+	C67_SPDP(r, r);		// convert it to DP same register
+	C67_NOP(1);
+
+	vtop->type.t = VT_DOUBLE;
+	vtop->r2 = r2;		// set this as unused
+    } else {
+	ALWAYS_ASSERT(FALSE);
+    }
+}
+
+/* computed goto support */
+void ggoto(void)
+{
+    gcall_or_jmp(1);
+    vtop--;
+}
+
+/* end of C67 code generator */
+/*************************************************************/
+#endif
+/*************************************************************/
Index: /EcnlProtoTool/trunk/tcc-0.9.26/coff.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/coff.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/coff.h	(revision 279)
@@ -0,0 +1,455 @@
+/**************************************************************************/
+/*  COFF.H                                                                */
+/*     COFF data structures and related definitions used by the linker    */
+/**************************************************************************/
+
+/*------------------------------------------------------------------------*/
+/*  COFF FILE HEADER                                                      */
+/*------------------------------------------------------------------------*/
+struct filehdr {
+        unsigned short  f_magic;        /* magic number */
+        unsigned short  f_nscns;        /* number of sections */
+        long            f_timdat;       /* time & date stamp */
+        long            f_symptr;       /* file pointer to symtab */
+        long            f_nsyms;        /* number of symtab entries */
+        unsigned short  f_opthdr;       /* sizeof(optional hdr) */
+        unsigned short  f_flags;        /* flags */
+        unsigned short  f_TargetID;     /* for C6x = 0x0099 */
+        };
+
+/*------------------------------------------------------------------------*/
+/*  File header flags                                                     */
+/*------------------------------------------------------------------------*/
+#define  F_RELFLG   0x01       /* relocation info stripped from file       */
+#define  F_EXEC     0x02       /* file is executable (no unresolved refs)  */
+#define  F_LNNO     0x04       /* line nunbers stripped from file          */
+#define  F_LSYMS    0x08       /* local symbols stripped from file         */
+#define  F_GSP10    0x10       /* 34010 version                            */
+#define  F_GSP20    0x20       /* 34020 version                            */
+#define  F_SWABD    0x40       /* bytes swabbed (in names)                 */
+#define  F_AR16WR   0x80       /* byte ordering of an AR16WR (PDP-11)      */
+#define  F_LITTLE   0x100      /* byte ordering of an AR32WR (vax)         */
+#define  F_BIG      0x200      /* byte ordering of an AR32W (3B, maxi)     */
+#define  F_PATCH    0x400      /* contains "patch" list in optional header */
+#define  F_NODF     0x400   
+
+#define F_VERSION    (F_GSP10  | F_GSP20)   
+#define F_BYTE_ORDER (F_LITTLE | F_BIG)
+#define FILHDR  struct filehdr
+
+//#define FILHSZ  sizeof(FILHDR) 
+#define FILHSZ  22                // above rounds to align on 4 bytes which causes problems 
+
+#define COFF_C67_MAGIC 0x00c2
+
+/*------------------------------------------------------------------------*/
+/*  Macros to recognize magic numbers                                     */
+/*------------------------------------------------------------------------*/
+#define ISMAGIC(x)      (((unsigned short)(x))==(unsigned short)magic)
+#define ISARCHIVE(x)    ((((unsigned short)(x))==(unsigned short)ARTYPE))
+#define BADMAGIC(x)     (((unsigned short)(x) & 0x8080) && !ISMAGIC(x))
+
+
+
+/*------------------------------------------------------------------------*/
+/*  OPTIONAL FILE HEADER                                                  */
+/*------------------------------------------------------------------------*/
+typedef struct aouthdr {
+        short   magic;          /* see magic.h                          */
+        short   vstamp;         /* version stamp                        */
+        long    tsize;          /* text size in bytes, padded to FW bdry*/
+        long    dsize;          /* initialized data "  "                */
+        long    bsize;          /* uninitialized data "   "             */
+        long    entrypt;        /* entry pt.                            */
+        long    text_start;     /* base of text used for this file      */
+        long    data_start;     /* base of data used for this file      */
+} AOUTHDR;
+
+#define AOUTSZ  sizeof(AOUTHDR)
+
+/*----------------------------------------------------------------------*/
+/*      When a UNIX aout header is to be built in the optional header,  */
+/*      the following magic numbers can appear in that header:          */ 
+/*                                                                      */
+/*              AOUT1MAGIC : default : readonly sharable text segment   */
+/*              AOUT2MAGIC:          : writable text segment            */
+/*              PAGEMAGIC  :         : configured for paging            */
+/*----------------------------------------------------------------------*/
+#define AOUT1MAGIC 0410
+#define AOUT2MAGIC 0407
+#define PAGEMAGIC  0413
+
+
+
+/*------------------------------------------------------------------------*/
+/*  COMMON ARCHIVE FILE STRUCTURES                                        */
+/*                                                                        */
+/*       ARCHIVE File Organization:                                       */
+/*       _______________________________________________                  */
+/*       |__________ARCHIVE_MAGIC_STRING_______________|                  */
+/*       |__________ARCHIVE_FILE_MEMBER_1______________|                  */
+/*       |                                             |                  */
+/*       |       Archive File Header "ar_hdr"          |                  */
+/*       |.............................................|                  */
+/*       |       Member Contents                       |                  */
+/*       |               1. External symbol directory  |                  */
+/*       |               2. Text file                  |                  */
+/*       |_____________________________________________|                  */
+/*       |________ARCHIVE_FILE_MEMBER_2________________|                  */
+/*       |               "ar_hdr"                      |                  */
+/*       |.............................................|                  */
+/*       |       Member Contents (.o or text file)     |                  */
+/*       |_____________________________________________|                  */
+/*       |       .               .               .     |                  */
+/*       |       .               .               .     |                  */
+/*       |       .               .               .     |                  */
+/*       |_____________________________________________|                  */
+/*       |________ARCHIVE_FILE_MEMBER_n________________|                  */
+/*       |               "ar_hdr"                      |                  */
+/*       |.............................................|                  */
+/*       |               Member Contents               |                  */
+/*       |_____________________________________________|                  */
+/*                                                                        */
+/*------------------------------------------------------------------------*/
+
+#define COFF_ARMAG   "!<arch>\n"
+#define SARMAG  8
+#define ARFMAG  "`\n"
+
+struct ar_hdr           /* archive file member header - printable ascii */
+{
+        char    ar_name[16];    /* file member name - `/' terminated */
+        char    ar_date[12];    /* file member date - decimal */
+        char    ar_uid[6];      /* file member user id - decimal */
+        char    ar_gid[6];      /* file member group id - decimal */
+        char    ar_mode[8];     /* file member mode - octal */
+        char    ar_size[10];    /* file member size - decimal */
+        char    ar_fmag[2];     /* ARFMAG - string to end header */
+};
+
+
+
+/*------------------------------------------------------------------------*/
+/*  SECTION HEADER                                                        */
+/*------------------------------------------------------------------------*/
+struct scnhdr {
+        char            s_name[8];      /* section name */
+        long            s_paddr;        /* physical address */
+        long            s_vaddr;        /* virtual address */
+        long            s_size;         /* section size */
+        long            s_scnptr;       /* file ptr to raw data for section */
+        long            s_relptr;       /* file ptr to relocation */
+        long            s_lnnoptr;      /* file ptr to line numbers */
+        unsigned int	s_nreloc;       /* number of relocation entries */
+        unsigned int	s_nlnno;        /* number of line number entries */
+        unsigned int	s_flags;        /* flags */
+		unsigned short	s_reserved;     /* reserved byte */
+		unsigned short  s_page;         /* memory page id */
+        };
+
+#define SCNHDR  struct scnhdr
+#define SCNHSZ  sizeof(SCNHDR)
+
+/*------------------------------------------------------------------------*/
+/* Define constants for names of "special" sections                       */
+/*------------------------------------------------------------------------*/
+//#define _TEXT    ".text"
+#define _DATA    ".data"
+#define _BSS     ".bss"
+#define _CINIT   ".cinit"
+#define _TV      ".tv"
+
+/*------------------------------------------------------------------------*/
+/* The low 4 bits of s_flags is used as a section "type"                  */
+/*------------------------------------------------------------------------*/
+#define STYP_REG    0x00  /* "regular" : allocated, relocated, loaded */
+#define STYP_DSECT  0x01  /* "dummy"   : not allocated, relocated, not loaded */
+#define STYP_NOLOAD 0x02  /* "noload"  : allocated, relocated, not loaded */
+#define STYP_GROUP  0x04  /* "grouped" : formed of input sections */
+#define STYP_PAD    0x08  /* "padding" : not allocated, not relocated, loaded */
+#define STYP_COPY   0x10  /* "copy"    : used for C init tables - 
+                                                not allocated, relocated,
+                                                loaded;  reloc & lineno
+                                                entries processed normally */
+#define STYP_TEXT   0x20   /* section contains text only */
+#define STYP_DATA   0x40   /* section contains data only */
+#define STYP_BSS    0x80   /* section contains bss only */
+
+#define STYP_ALIGN  0x100  /* align flag passed by old version assemblers */
+#define ALIGN_MASK  0x0F00 /* part of s_flags that is used for align vals */
+#define ALIGNSIZE(x) (1 << ((x & ALIGN_MASK) >> 8))
+
+
+
+/*------------------------------------------------------------------------*/
+/*  RELOCATION ENTRIES                                                    */
+/*------------------------------------------------------------------------*/
+struct reloc
+{
+   long            r_vaddr;        /* (virtual) address of reference */
+   short           r_symndx;       /* index into symbol table */
+   unsigned short  r_disp;         /* additional bits for address calculation */
+   unsigned short  r_type;         /* relocation type */
+};
+
+#define RELOC   struct reloc
+#define RELSZ   10                 /* sizeof(RELOC) */
+
+/*--------------------------------------------------------------------------*/
+/*   define all relocation types                                            */
+/*--------------------------------------------------------------------------*/
+
+#define R_ABS           0         /* absolute address - no relocation       */
+#define R_DIR16         01        /* UNUSED                                 */
+#define R_REL16         02        /* UNUSED                                 */
+#define R_DIR24         04        /* UNUSED                                 */
+#define R_REL24         05        /* 24 bits, direct                        */
+#define R_DIR32         06        /* UNUSED                                 */
+#define R_RELBYTE      017        /* 8 bits, direct                         */
+#define R_RELWORD      020        /* 16 bits, direct                        */
+#define R_RELLONG      021        /* 32 bits, direct                        */
+#define R_PCRBYTE      022        /* 8 bits, PC-relative                    */
+#define R_PCRWORD      023        /* 16 bits, PC-relative                   */
+#define R_PCRLONG      024        /* 32 bits, PC-relative                   */
+#define R_OCRLONG      030        /* GSP: 32 bits, one's complement direct  */
+#define R_GSPPCR16     031        /* GSP: 16 bits, PC relative (in words)   */
+#define R_GSPOPR32     032        /* GSP: 32 bits, direct big-endian        */
+#define R_PARTLS16     040        /* Brahma: 16 bit offset of 24 bit address*/
+#define R_PARTMS8      041        /* Brahma: 8 bit page of 24 bit address   */
+#define R_PARTLS7      050        /* DSP: 7 bit offset of 16 bit address    */
+#define R_PARTMS9      051        /* DSP: 9 bit page of 16 bit address      */
+#define R_REL13        052        /* DSP: 13 bits, direct                   */
+
+
+
+/*------------------------------------------------------------------------*/
+/*  LINE NUMBER ENTRIES                                                   */
+/*------------------------------------------------------------------------*/
+struct lineno
+{
+        union
+        {
+                long    l_symndx ;      /* sym. table index of function name
+                                                iff l_lnno == 0      */
+                long    l_paddr ;       /* (physical) address of line number */
+        }               l_addr ;
+        unsigned short  l_lnno ;        /* line number */
+};
+
+#define LINENO  struct lineno
+#define LINESZ  6       /* sizeof(LINENO) */
+
+
+
+/*------------------------------------------------------------------------*/
+/*   STORAGE CLASSES                                                      */
+/*------------------------------------------------------------------------*/
+#define  C_EFCN          -1    /* physical end of function */
+#define  C_NULL          0
+#define  C_AUTO          1     /* automatic variable */
+#define  C_EXT           2     /* external symbol */
+#define  C_STAT          3     /* static */
+#define  C_REG           4     /* register variable */
+#define  C_EXTDEF        5     /* external definition */
+#define  C_LABEL         6     /* label */
+#define  C_ULABEL        7     /* undefined label */
+#define  C_MOS           8     /* member of structure */
+#define  C_ARG           9     /* function argument */
+#define  C_STRTAG        10    /* structure tag */
+#define  C_MOU           11    /* member of union */
+#define  C_UNTAG         12    /* union tag */
+#define  C_TPDEF         13    /* type definition */
+#define C_USTATIC        14    /* undefined static */
+#define  C_ENTAG         15    /* enumeration tag */
+#define  C_MOE           16    /* member of enumeration */
+#define  C_REGPARM       17    /* register parameter */
+#define  C_FIELD         18    /* bit field */
+
+#define  C_BLOCK         100   /* ".bb" or ".eb" */
+#define  C_FCN           101   /* ".bf" or ".ef" */
+#define  C_EOS           102   /* end of structure */
+#define  C_FILE          103   /* file name */
+#define  C_LINE          104   /* dummy sclass for line number entry */
+#define  C_ALIAS         105   /* duplicate tag */
+#define  C_HIDDEN        106   /* special storage class for external */
+                               /* symbols in dmert public libraries  */
+
+
+/*------------------------------------------------------------------------*/
+/*  SYMBOL TABLE ENTRIES                                                  */
+/*------------------------------------------------------------------------*/
+
+#define  SYMNMLEN   8      /*  Number of characters in a symbol name */
+#define  FILNMLEN   14     /*  Number of characters in a file name */
+#define  DIMNUM     4      /*  Number of array dimensions in auxiliary entry */
+
+
+struct syment
+{
+        union
+        {
+                char            _n_name[SYMNMLEN];      /* old COFF version */
+                struct
+                {
+                        long    _n_zeroes;      /* new == 0 */
+                        long    _n_offset;      /* offset into string table */
+                } _n_n;
+                char            *_n_nptr[2];    /* allows for overlaying */
+        } _n;
+        long                    n_value;        /* value of symbol */
+        short                   n_scnum;        /* section number */
+        unsigned short          n_type;         /* type and derived type */
+        char                    n_sclass;       /* storage class */
+        char                    n_numaux;       /* number of aux. entries */
+};
+
+#define n_name          _n._n_name
+#define n_nptr          _n._n_nptr[1]
+#define n_zeroes        _n._n_n._n_zeroes
+#define n_offset        _n._n_n._n_offset
+
+/*------------------------------------------------------------------------*/
+/* Relocatable symbols have a section number of the                       */
+/* section in which they are defined.  Otherwise, section                 */
+/* numbers have the following meanings:                                   */
+/*------------------------------------------------------------------------*/
+#define  N_UNDEF  0                     /* undefined symbol */
+#define  N_ABS    -1                    /* value of symbol is absolute */
+#define  N_DEBUG  -2                    /* special debugging symbol  */
+#define  N_TV     (unsigned short)-3    /* needs transfer vector (preload) */
+#define  P_TV     (unsigned short)-4    /* needs transfer vector (postload) */
+
+
+
+/*------------------------------------------------------------------------*/
+/* The fundamental type of a symbol packed into the low                   */
+/* 4 bits of the word.                                                    */
+/*------------------------------------------------------------------------*/
+#define  _EF    ".ef"
+
+#define  T_NULL     0          /* no type info */
+#define  T_ARG      1          /* function argument (only used by compiler) */
+#define  T_CHAR     2          /* character */
+#define  T_SHORT    3          /* short integer */
+#define  T_INT      4          /* integer */
+#define  T_LONG     5          /* long integer */
+#define  T_FLOAT    6          /* floating point */
+#define  T_DOUBLE   7          /* double word */
+#define  T_STRUCT   8          /* structure  */
+#define  T_UNION    9          /* union  */
+#define  T_ENUM     10         /* enumeration  */
+#define  T_MOE      11         /* member of enumeration */
+#define  T_UCHAR    12         /* unsigned character */
+#define  T_USHORT   13         /* unsigned short */
+#define  T_UINT     14         /* unsigned integer */
+#define  T_ULONG    15         /* unsigned long */
+
+/*------------------------------------------------------------------------*/
+/* derived types are:                                                     */
+/*------------------------------------------------------------------------*/
+#define  DT_NON      0          /* no derived type */
+#define  DT_PTR      1          /* pointer */
+#define  DT_FCN      2          /* function */
+#define  DT_ARY      3          /* array */
+
+#define MKTYPE(basic, d1,d2,d3,d4,d5,d6) \
+       ((basic) | ((d1) <<  4) | ((d2) <<  6) | ((d3) <<  8) |\
+                  ((d4) << 10) | ((d5) << 12) | ((d6) << 14))
+
+/*------------------------------------------------------------------------*/
+/* type packing constants and macros                                      */
+/*------------------------------------------------------------------------*/
+#define  N_BTMASK_COFF     017
+#define  N_TMASK_COFF      060
+#define  N_TMASK1_COFF     0300
+#define  N_TMASK2_COFF     0360
+#define  N_BTSHFT_COFF     4
+#define  N_TSHIFT_COFF     2
+
+#define  BTYPE_COFF(x)  ((x) & N_BTMASK_COFF)  
+#define  ISINT(x)  (((x) >= T_CHAR && (x) <= T_LONG) ||   \
+		    ((x) >= T_UCHAR && (x) <= T_ULONG) || (x) == T_ENUM)
+#define  ISFLT_COFF(x)  ((x) == T_DOUBLE || (x) == T_FLOAT)
+#define  ISPTR_COFF(x)  (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF)) 
+#define  ISFCN_COFF(x)  (((x) & N_TMASK_COFF) == (DT_FCN << N_BTSHFT_COFF))
+#define  ISARY_COFF(x)  (((x) & N_TMASK_COFF) == (DT_ARY << N_BTSHFT_COFF))
+#define  ISTAG_COFF(x)  ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)
+
+#define  INCREF_COFF(x) ((((x)&~N_BTMASK_COFF)<<N_TSHIFT_COFF)|(DT_PTR<<N_BTSHFT_COFF)|(x&N_BTMASK_COFF))
+#define  DECREF_COFF(x) ((((x)>>N_TSHIFT_COFF)&~N_BTMASK_COFF)|((x)&N_BTMASK_COFF))
+
+
+
+/*------------------------------------------------------------------------*/
+/*  AUXILIARY SYMBOL ENTRY                                                */
+/*------------------------------------------------------------------------*/
+union auxent
+{
+	struct
+	{
+		long            x_tagndx;       /* str, un, or enum tag indx */
+		union
+		{
+			struct
+			{
+				unsigned short  x_lnno; /* declaration line number */
+				unsigned short  x_size; /* str, union, array size */
+			} x_lnsz;
+			long    x_fsize;        /* size of function */
+		} x_misc;
+		union
+		{
+			struct                  /* if ISFCN, tag, or .bb */
+			{
+				long    x_lnnoptr;      /* ptr to fcn line # */
+				long    x_endndx;       /* entry ndx past block end */
+			}       x_fcn;
+			struct                  /* if ISARY, up to 4 dimen. */
+			{
+				unsigned short  x_dimen[DIMNUM];
+			}       x_ary;
+		}               x_fcnary;
+		unsigned short  x_regcount;   /* number of registers used by func */
+	}       x_sym;
+	struct
+	{
+		char    x_fname[FILNMLEN];
+	}       x_file;
+	struct
+	{
+		long    x_scnlen;          /* section length */
+		unsigned short  x_nreloc;  /* number of relocation entries */
+		unsigned short  x_nlinno;  /* number of line numbers */
+	}       x_scn;
+};
+
+#define SYMENT  struct syment
+#define SYMESZ  18      /* sizeof(SYMENT) */
+
+#define AUXENT  union auxent
+#define AUXESZ  18      /* sizeof(AUXENT) */
+
+/*------------------------------------------------------------------------*/
+/*  NAMES OF "SPECIAL" SYMBOLS                                            */
+/*------------------------------------------------------------------------*/
+#define _STEXT          ".text"
+#define _ETEXT          "etext"
+#define _SDATA          ".data"
+#define _EDATA          "edata"
+#define _SBSS           ".bss"
+#define _END            "end"
+#define _CINITPTR       "cinit"
+
+/*--------------------------------------------------------------------------*/
+/*  ENTRY POINT SYMBOLS                                                     */
+/*--------------------------------------------------------------------------*/
+#define _START          "_start"
+#define _MAIN           "_main"
+    /*  _CSTART         "_c_int00"          (defined in params.h)  */
+
+
+#define _TVORIG         "_tvorig"
+#define _TORIGIN        "_torigin"
+#define _DORIGIN        "_dorigin"
+
+#define _SORIGIN        "_sorigin"
Index: /EcnlProtoTool/trunk/tcc-0.9.26/config.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/config.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/config.h	(revision 279)
@@ -0,0 +1,10 @@
+/* Automatically generated by configure - do not modify */
+#ifndef CONFIG_TCCDIR
+# define CONFIG_TCCDIR "0:/lib/tcc"
+#endif
+#define GCC_MAJOR 
+#define GCC_MINOR 
+#define HOST_ARM 1
+#define TCC_ARM_VERSION 7
+#define TCC_VERSION "0.9.26"
+#define CONFIG_TCC_STATIC
Index: /EcnlProtoTool/trunk/tcc-0.9.26/config.mak
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/config.mak	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/config.mak	(revision 279)
@@ -0,0 +1,27 @@
+# Automatically generated by configure - do not modify
+prefix=0:
+bindir=$(DESTDIR)0:/bin
+tccdir=$(DESTDIR)0:/lib/tcc
+libdir=$(DESTDIR)0:/lib
+ln_libdir=0:/lib
+includedir=$(DESTDIR)0:/include
+mandir=$(DESTDIR)0:/share/man
+infodir=$(DESTDIR)0:/share/info
+docdir=$(DESTDIR)0:/share/doc/tcc
+CC=arm-none-eabi-gcc
+GCC_MAJOR=
+GCC_MINOR=
+HOST_CC=gcc
+AR=arm-none-eabi-ar
+STRIP=arm-none-eabi-strip -s -R .comment -R .note
+CFLAGS=-Wall -g -O2
+LDFLAGS=
+LIBSUF=.a
+EXESUF=
+ARCH=arm
+TARGETOS=
+VERSION=0.9.26
+SRC_PATH=.
+top_srcdir=$(TOP)
+top_builddir=$(TOP)
+CONFIG_NOLDL=yes
Index: /EcnlProtoTool/trunk/tcc-0.9.26/config.texi
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/config.texi	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/config.texi	(revision 279)
@@ -0,0 +1,1 @@
+@set VERSION 0.9.26
Index: /EcnlProtoTool/trunk/tcc-0.9.26/configure
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/configure	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/configure	(revision 279)
@@ -0,0 +1,542 @@
+#!/bin/sh
+#
+# tcc configure script (c) 2003 Fabrice Bellard
+
+# set temporary file name
+# if test ! -z "$TMPDIR" ; then
+#     TMPDIR1="${TMPDIR}"
+# elif test ! -z "$TEMPDIR" ; then
+#     TMPDIR1="${TEMPDIR}"
+# else
+#     TMPDIR1="/tmp"
+# fi
+#
+# bashism: TMPN="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
+
+TMPN="./conftest-$$"
+TMPH=$TMPN.h
+
+# default parameters
+build_cross="no"
+use_libgcc="no"
+prefix=""
+execprefix=""
+bindir=""
+libdir=""
+tccdir=""
+includedir=""
+mandir=""
+infodir=""
+sysroot=""
+cross_prefix=""
+cc="gcc"
+host_cc="gcc"
+ar="ar"
+strip="strip"
+cygwin="no"
+gprof="no"
+bigendian="no"
+mingw32="no"
+LIBSUF=".a"
+EXESUF=""
+tcc_sysincludepaths=""
+tcc_libpaths=""
+tcc_crtprefix=""
+tcc_elfinterp=""
+tcc_lddir=
+confvars=
+
+#cpu=`uname -m`
+cpu="armv7a"
+
+# OS specific
+#targetos=`uname -s`
+targetos=""
+case $targetos in
+  MINGW32*)  mingw32=yes;;
+  DragonFly) noldl=yes;;
+  OpenBSD)   noldl=yes;;
+  *) ;;
+esac
+
+# find source path
+# XXX: we assume an absolute path is given when launching configure, 
+# except in './configure' case.
+source_path=${0%configure}
+source_path=${source_path%/}
+source_path_used="yes"
+if test -z "$source_path" -o "$source_path" = "." ; then
+    source_path=`pwd`
+    source_path_used="no"
+fi
+
+case "$cpu" in
+  i386|i486|i586|i686|i86pc|BePC|i686-AT386)
+    cpu="x86"
+  ;;
+  x86_64)
+    cpu="x86-64"
+  ;;
+  arm*)
+    case "$cpu" in
+      arm|armv4l)
+        cpuver=4
+      ;;
+      armv5tel|armv5tejl)
+        cpuver=5
+      ;;
+      armv6j|armv6l)
+        cpuver=6
+      ;;
+      armv7a|armv7l)
+        cpuver=7
+      ;;
+    esac
+    cpu="armv4l"
+  ;;
+  alpha)
+    cpu="alpha"
+  ;;
+  "Power Macintosh"|ppc|ppc64)
+    cpu="powerpc"
+  ;;
+  mips)
+    cpu="mips"
+  ;;
+  s390)
+    cpu="s390"
+  ;;
+  *)
+    cpu="unknown"
+  ;;
+esac
+
+for opt do
+  eval opt=\"$opt\"
+  case "$opt" in
+  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --exec-prefix=*) execprefix=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --tccdir=*) tccdir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --bindir=*) bindir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --includedir=*) includedir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --sharedir=*) sharedir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --infodir=*) infodir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --docdir=*) docdir=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
+  ;;
+  --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
+  ;;
+  --extra-libs=*) extralibs=${opt#--extra-libs=}
+  ;;
+  --sysincludepaths=*) tcc_sysincludepaths=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --libpaths=*) tcc_libpaths=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --crtprefix=*) tcc_crtprefix=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --elfinterp=*) tcc_elfinterp=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
+  ;;
+  --enable-gprof) gprof="yes"
+  ;;
+  --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86
+  ;;
+  --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86
+  ;;
+  --enable-cross) build_cross="yes"
+  ;;
+  --disable-static) disable_static="yes"
+  ;;
+  --disable-rpath) disable_rpath="yes"
+  ;;
+  --strip-binaries) strip_binaries="yes"
+  ;;
+  --with-libgcc) use_libgcc="yes"
+  ;;
+  --with-selinux) have_selinux="yes"
+  ;;
+  --help|-h) show_help="yes"
+  ;;
+  *) echo "configure: WARNING: unrecognized option $opt"
+  ;;
+  esac
+done
+
+# Checking for CFLAGS
+if test -z "$CFLAGS"; then
+    CFLAGS="-Wall -g -O2"
+fi
+
+if test "$mingw32" = "yes" ; then
+    if test x"$tccdir" = x""; then
+    tccdir="tcc"
+    fi
+    if test -z "$prefix" ; then
+    prefix="C:/Program Files/${tccdir}"
+    fi
+    if test -z "$sharedir" ; then
+    sharedir="${prefix}"
+    fi
+    execprefix="$prefix"
+    bindir="${prefix}"
+    tccdir="${prefix}"
+    libdir="${prefix}/lib"
+    docdir="${sharedir}/doc"
+    mandir="${sharedir}/man"
+    infodir="${sharedir}/info"
+    LIBSUF=".lib"
+    EXESUF=".exe"
+else
+    if test -z "$prefix" ; then
+    prefix="/usr/local"
+    fi
+    if test -z "$sharedir" ; then
+    sharedir="${prefix}/share"
+    fi
+    if test x"$execprefix" = x""; then
+    execprefix="${prefix}"
+    fi
+    if test x"$libdir" = x""; then
+    libdir="${execprefix}/lib"
+    fi
+    if test x"$bindir" = x""; then
+    bindir="${execprefix}/bin"
+    fi
+    if test x"$tccdir" = x""; then
+    tccdir="tcc"
+    fi
+    if test x"$docdir" = x""; then
+    docdir="${sharedir}/doc/${tccdir}"
+    fi
+    if test x"$mandir" = x""; then
+    mandir="${sharedir}/man"
+    fi
+    if test x"$infodir" = x""; then
+    infodir="${sharedir}/info"
+    fi
+    tccdir="${libdir}/${tccdir}"
+fi # mingw32
+
+if test x"$includedir" = x""; then
+includedir="${prefix}/include"
+fi
+
+if test x"$show_help" = "xyes" ; then
+cat << EOF
+Usage: configure [options]
+Options: [defaults in brackets after descriptions]
+
+Standard options:
+  --help                   print this message
+  --prefix=PREFIX          install in PREFIX [$prefix]
+  --exec-prefix=EPREFIX    install architecture-dependent files in EPREFIX
+                           [same as prefix]
+  --bindir=DIR             user executables in DIR [EPREFIX/bin]
+  --libdir=DIR             object code libraries in DIR [EPREFIX/lib]
+  --tccdir=DIR             installation directory [EPREFIX/lib/tcc]
+  --includedir=DIR         C header files in DIR [PREFIX/include]
+  --sharedir=DIR           documentation root DIR [PREFIX/share]
+  --docdir=DIR             documentation in DIR [SHAREDIR/doc/tcc]
+  --mandir=DIR             man documentation in DIR [SHAREDIR/man]
+  --infodir=DIR            info documentation in DIR [SHAREDIR/info]
+
+Advanced options (experts only):
+  --source-path=PATH       path of source code [$source_path]
+  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
+  --sysroot=PREFIX         prepend PREFIX to library/include paths []
+  --cc=CC                  use C compiler CC [$cc]
+  --extra-cflags=          specify compiler flags [$CFLAGS]
+  --extra-ldflags=         specify linker options []
+  --strip-binaries         strip symbol tables from resulting binaries
+  --disable-static         make libtcc.so instead of libtcc.a
+  --disable-rpath          disable use of -rpath with the above
+  --with-libgcc            use /lib/libgcc_s.so.1 instead of libtcc.a
+  --enable-mingw32         build windows version on linux with mingw32
+  --enable-cygwin          build windows version on windows with cygwin
+  --enable-cross           build cross compilers
+  --with-selinux           use mmap for exec mem [needs writable /tmp]
+  --sysincludepaths=...    specify system include paths, colon separated
+  --libpaths=...           specify system library paths, colon separated
+  --crtprefix=...          specify locations of crt?.o, colon separated
+  --elfinterp=...          specify elf interpreter
+EOF
+#echo "NOTE: The object files are build at the place where configure is launched"
+exit 1
+fi
+
+cc="${cross_prefix}${cc}"
+ar="${cross_prefix}${ar}"
+strip="${cross_prefix}${strip}"
+
+CONFTEST=./conftest$EXESUF
+
+if test -z "$cross_prefix" ; then
+  if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then
+    echo "configure: error: '$cc' failed to compile conftest.c."
+  else
+    bigendian="$($CONFTEST bigendian)"
+    gcc_major="$($CONFTEST version)"
+    gcc_minor="$($CONFTEST minor)"
+    if test "$mingw32" = "no" ; then
+      triplet="$($CONFTEST triplet)"
+      if test -f "/usr/lib/$triplet/crti.o" ; then
+        tcc_lddir="lib/$triplet"
+        multiarch_triplet="$triplet"
+      elif test -f "/usr/lib64/crti.o" ; then
+        tcc_lddir="lib64"
+      fi
+
+      if test "$cpu" = "armv4l" ; then
+        if test "${triplet%eabihf}" != "$triplet" ; then
+           confvars="$confvars arm_eabihf"
+        elif test "${triplet%eabi}" != "$triplet" ; then
+           confvars="$confvars arm_eabi"
+        fi
+        if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then
+           confvars="$confvars arm_vfp"
+        fi
+      fi
+
+#      multiarch_triplet=${libc_dir#*/}
+#      multiarch_triplet=${multiarch_triplet%/}
+#      tcc_lddir="${libc_dir%%/*}"
+#      if test -n "$multiarch_triplet" ; then
+#        tcc_lddir="$tcc_lddir/$multiarch_triplet"
+#      fi
+
+      if test -f "/lib/ld-uClibc.so.0" ; then
+        confvars="$confvars uClibc"
+      fi
+# gr: maybe for after the release:
+#       tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
+       # echo "elfinterp           $tcc_elfinterp"
+
+    fi
+  fi
+else
+  # if cross compiling, cannot launch a program, so make a static guess
+  case $cpu in
+    powerpc|mips|s390)  bigendian=yes;;
+  esac
+fi
+
+cat <<EOF
+Binary  directory   $bindir
+TinyCC directory    $tccdir
+Library directory   $libdir
+Include directory   $includedir
+Manual directory    $mandir
+Info directory      $infodir
+Doc directory       $docdir
+Target root prefix  $sysroot
+Source path      $source_path
+C compiler       $cc
+Target OS        $targetos
+CPU              $cpu
+Big Endian       $bigendian
+gprof enabled    $gprof
+cross compilers  $build_cross
+use libgcc       $use_libgcc
+EOF
+
+echo "Creating config.mak and config.h"
+
+cat >config.mak <<EOF
+# Automatically generated by configure - do not modify
+prefix=$prefix
+bindir=\$(DESTDIR)$bindir
+tccdir=\$(DESTDIR)$tccdir
+libdir=\$(DESTDIR)$libdir
+ln_libdir=$libdir
+includedir=\$(DESTDIR)$includedir
+mandir=\$(DESTDIR)$mandir
+infodir=\$(DESTDIR)$infodir
+docdir=\$(DESTDIR)$docdir
+CC=$cc
+GCC_MAJOR=$gcc_major
+GCC_MINOR=$gcc_minor
+HOST_CC=$host_cc
+AR=$ar
+STRIP=$strip -s -R .comment -R .note
+CFLAGS=$CFLAGS
+LDFLAGS=$LDFLAGS
+LIBSUF=$LIBSUF
+EXESUF=$EXESUF
+EOF
+
+print_inc() {
+  if test -n "$2"; then
+    echo "#ifndef $1" >> $TMPH
+    echo "# define $1 \"$2\"" >> $TMPH
+    echo "#endif" >> $TMPH
+  fi
+}
+print_mak() {
+  if test -n "$2"; then
+    echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
+  fi
+}
+
+echo "/* Automatically generated by configure - do not modify */" > $TMPH
+
+print_inc CONFIG_SYSROOT "$sysroot"
+print_inc CONFIG_TCCDIR "$tccdir"
+print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
+print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths"
+print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
+print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
+print_mak CONFIG_LDDIR "$tcc_lddir"
+print_mak CONFIG_MULTIARCHDIR "$multiarch_triplet"
+
+echo "#define GCC_MAJOR $gcc_major" >> $TMPH
+echo "#define GCC_MINOR $gcc_minor" >> $TMPH
+
+if test "$cpu" = "x86" ; then
+  echo "ARCH=i386" >> config.mak
+  echo "#define HOST_I386 1" >> $TMPH
+elif test "$cpu" = "x86-64" ; then
+  echo "ARCH=x86-64" >> config.mak
+  echo "#define HOST_X86_64 1" >> $TMPH
+elif test "$cpu" = "armv4l" ; then
+  echo "ARCH=arm" >> config.mak
+  echo "#define HOST_ARM 1" >> $TMPH
+  echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
+elif test "$cpu" = "powerpc" ; then
+  echo "ARCH=ppc" >> config.mak
+  echo "#define HOST_PPC 1" >> $TMPH
+elif test "$cpu" = "mips" ; then
+  echo "ARCH=mips" >> config.mak
+  echo "#define HOST_MIPS 1" >> $TMPH
+elif test "$cpu" = "s390" ; then
+  echo "ARCH=s390" >> config.mak
+  echo "#define HOST_S390 1" >> $TMPH
+elif test "$cpu" = "alpha" ; then
+  echo "ARCH=alpha" >> config.mak
+  echo "#define HOST_ALPHA 1" >> $TMPH
+else
+  echo "Unsupported CPU"
+  exit 1
+fi
+
+echo "TARGETOS=$targetos" >> config.mak
+
+for v in $confvars ; do
+  echo "CONFIG_$v=yes" >> config.mak
+done
+if test "$noldl" = "yes" ; then
+  echo "CONFIG_NOLDL=yes" >> config.mak
+fi
+if test "$mingw32" = "yes" ; then
+  echo "CONFIG_WIN32=yes" >> config.mak
+  echo "#define CONFIG_WIN32 1" >> $TMPH
+fi
+if test "$cygwin" = "yes" ; then
+  echo "#ifndef _WIN32" >> $TMPH
+  echo "# define _WIN32" >> $TMPH
+  echo "#endif" >> $TMPH
+  echo "AR=ar" >> config.mak
+fi
+if test "$bigendian" = "yes" ; then
+  echo "WORDS_BIGENDIAN=yes" >> config.mak
+  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
+fi
+if test "$gprof" = "yes" ; then
+  echo "TARGET_GPROF=yes" >> config.mak
+  echo "#define HAVE_GPROF 1" >> $TMPH
+fi
+if test "$build_cross" = "yes" ; then
+  echo "CONFIG_CROSS=yes" >> config.mak
+fi
+if test "$disable_static" = "yes" ; then
+  echo "DISABLE_STATIC=yes" >> config.mak
+fi
+if test "$disable_rpath" = "yes" ; then
+  echo "DISABLE_RPATH=yes" >> config.mak
+fi
+if test "$strip_binaries" = "yes" ; then
+  echo "STRIP_BINARIES=yes" >> config.mak
+fi
+if test "$use_libgcc" = "yes" ; then
+  echo "#define CONFIG_USE_LIBGCC" >> $TMPH
+  echo "CONFIG_USE_LIBGCC=yes" >> config.mak
+fi
+if test "$have_selinux" = "yes" ; then
+  echo "#define HAVE_SELINUX" >> $TMPH
+  echo "HAVE_SELINUX=yes" >> config.mak
+fi
+
+version=`head $source_path/VERSION`
+echo "VERSION=$version" >>config.mak
+echo "#define TCC_VERSION \"$version\"" >> $TMPH
+echo "@set VERSION $version" > config.texi
+echo "SRC_PATH=$source_path" >>config.mak
+
+if test "$source_path_used" = "yes" ; then
+    case $source_path in
+       /*) echo "top_srcdir=$source_path";;
+        *) echo "top_srcdir=\$(TOP)/$source_path";;
+     esac >>config.mak
+else
+     echo 'top_srcdir=$(TOP)' >>config.mak
+fi
+echo 'top_builddir=$(TOP)' >>config.mak
+
+diff $TMPH config.h >/dev/null 2>&1
+if test $? -ne 0 ; then
+    mv -f $TMPH config.h
+else
+    echo "config.h is unchanged"
+fi
+
+rm -f $TMPN* $CONFTEST
+
+# ---------------------------------------------------------------------------
+# build tree in object directory if source path is different from current one
+
+fn_makelink()
+{
+    tgt=$1/$2
+    case $2 in
+    */*) dn=${2%/*}
+         test -d $dn || mkdir -p $dn
+         case $1 in
+         /*) ;;
+          *) while test $dn ; do
+                tgt=../$tgt; dn=${dn#${dn%%/*}}; dn=${dn#/}
+             done
+             ;;
+         esac
+         ;;
+    esac
+    ln -sfn $tgt $2
+}
+
+if test "$source_path_used" = "yes" ; then
+  FILES="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile"
+  for f in $FILES ; do
+    fn_makelink $source_path $f
+  done
+fi
+
+# ---------------------------------------------------------------------------
Index: /EcnlProtoTool/trunk/tcc-0.9.26/conftest.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/conftest.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/conftest.c	(revision 279)
@@ -0,0 +1,71 @@
+#include <stdio.h>
+
+/* Define architecture */
+#if defined(__i386__)
+# define TRIPLET_ARCH "i386"
+#elif defined(__x86_64__)
+# define TRIPLET_ARCH "x86_64"
+#elif defined(__arm__)
+# define TRIPLET_ARCH "arm"
+#else
+# define TRIPLET_ARCH "unknown"
+#endif
+
+/* Define OS */
+#if defined (__linux__)
+# define TRIPLET_OS "linux"
+#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+# define TRIPLET_OS "kfreebsd"
+#elif !defined (__GNU__)
+# define TRIPLET_OS "unknown"
+#endif
+
+/* Define calling convention and ABI */
+#if defined (__ARM_EABI__)
+# if defined (__ARM_PCS_VFP)
+#  define TRIPLET_ABI "gnueabihf"
+# else
+#  define TRIPLET_ABI "gnueabi"
+# endif
+#else
+# define TRIPLET_ABI "gnu"
+#endif
+
+#ifdef __GNU__
+# define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
+#else
+# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
+#endif
+
+int main(int argc, char *argv[])
+{
+    switch(argc == 2 ? argv[1][0] : 0) {
+        case 'b':
+        {
+            volatile unsigned foo = 0x01234567;
+            puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
+            break;
+        }
+#ifdef __GNUC__
+        case 'm':
+            printf("%d\n", __GNUC_MINOR__);
+            break;
+        case 'v':
+            printf("%d\n", __GNUC__);
+            break;
+#else
+        case 'm':
+        case 'v':
+            puts("0");
+            break;
+#endif
+        case 't':
+            puts(TRIPLET);
+            break;
+        case -1:
+            /* to test -Wno-unused-result */
+            fread(NULL, 1, 1, NULL);
+            break;
+    }
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/elf.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/elf.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/elf.h	(revision 279)
@@ -0,0 +1,1731 @@
+/* This file defines standard ELF types, structures, and macros.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ian Lance Taylor <ian@cygnus.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _ELF_H
+#define _ELF_H 1
+
+#ifndef _WIN32
+#include <inttypes.h>
+#else
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef long long int int64_t;
+#endif
+
+typedef unsigned char           uint8_t;
+typedef unsigned short int      uint16_t;
+typedef unsigned int            uint32_t;
+typedef unsigned long long int  uint64_t;
+#endif
+
+/* Standard ELF types.  */
+
+/* Type for a 16-bit quantity.  */
+typedef uint16_t Elf32_Half;
+typedef uint16_t Elf64_Half;
+
+/* Types for signed and unsigned 32-bit quantities.  */
+typedef uint32_t Elf32_Word;
+typedef int32_t  Elf32_Sword;
+typedef uint32_t Elf64_Word;
+typedef int32_t  Elf64_Sword;
+
+/* Types for signed and unsigned 64-bit quantities.  */
+typedef uint64_t Elf32_Xword;
+typedef int64_t  Elf32_Sxword;
+typedef uint64_t Elf64_Xword;
+typedef int64_t  Elf64_Sxword;
+
+/* Type of addresses.  */
+typedef uint32_t Elf32_Addr;
+typedef uint64_t Elf64_Addr;
+
+/* Type of file offsets.  */
+typedef uint32_t Elf32_Off;
+typedef uint64_t Elf64_Off;
+
+/* Type for section indices, which are 16-bit quantities.  */
+typedef uint16_t Elf32_Section;
+typedef uint16_t Elf64_Section;
+
+/* Type of symbol indices.  */
+typedef uint32_t Elf32_Symndx;
+typedef uint64_t Elf64_Symndx;
+
+
+/* The ELF file header.  This appears at the start of every ELF file.  */
+
+#define EI_NIDENT (16)
+
+typedef struct
+{
+  unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
+  Elf32_Half    e_type;                 /* Object file type */
+  Elf32_Half    e_machine;              /* Architecture */
+  Elf32_Word    e_version;              /* Object file version */
+  Elf32_Addr    e_entry;                /* Entry point virtual address */
+  Elf32_Off     e_phoff;                /* Program header table file offset */
+  Elf32_Off     e_shoff;                /* Section header table file offset */
+  Elf32_Word    e_flags;                /* Processor-specific flags */
+  Elf32_Half    e_ehsize;               /* ELF header size in bytes */
+  Elf32_Half    e_phentsize;            /* Program header table entry size */
+  Elf32_Half    e_phnum;                /* Program header table entry count */
+  Elf32_Half    e_shentsize;            /* Section header table entry size */
+  Elf32_Half    e_shnum;                /* Section header table entry count */
+  Elf32_Half    e_shstrndx;             /* Section header string table index */
+} Elf32_Ehdr;
+
+typedef struct
+{
+  unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
+  Elf64_Half    e_type;                 /* Object file type */
+  Elf64_Half    e_machine;              /* Architecture */
+  Elf64_Word    e_version;              /* Object file version */
+  Elf64_Addr    e_entry;                /* Entry point virtual address */
+  Elf64_Off     e_phoff;                /* Program header table file offset */
+  Elf64_Off     e_shoff;                /* Section header table file offset */
+  Elf64_Word    e_flags;                /* Processor-specific flags */
+  Elf64_Half    e_ehsize;               /* ELF header size in bytes */
+  Elf64_Half    e_phentsize;            /* Program header table entry size */
+  Elf64_Half    e_phnum;                /* Program header table entry count */
+  Elf64_Half    e_shentsize;            /* Section header table entry size */
+  Elf64_Half    e_shnum;                /* Section header table entry count */
+  Elf64_Half    e_shstrndx;             /* Section header string table index */
+} Elf64_Ehdr;
+
+/* Fields in the e_ident array.  The EI_* macros are indices into the
+   array.  The macros under each EI_* macro are the values the byte
+   may have.  */
+
+#define EI_MAG0         0               /* File identification byte 0 index */
+#define ELFMAG0         0x7f            /* Magic number byte 0 */
+
+#define EI_MAG1         1               /* File identification byte 1 index */
+#define ELFMAG1         'E'             /* Magic number byte 1 */
+
+#define EI_MAG2         2               /* File identification byte 2 index */
+#define ELFMAG2         'L'             /* Magic number byte 2 */
+
+#define EI_MAG3         3               /* File identification byte 3 index */
+#define ELFMAG3         'F'             /* Magic number byte 3 */
+
+/* Conglomeration of the identification bytes, for easy testing as a word.  */
+#define ELFMAG          "\177ELF"
+#define SELFMAG         4
+
+#define EI_CLASS        4               /* File class byte index */
+#define ELFCLASSNONE    0               /* Invalid class */
+#define ELFCLASS32      1               /* 32-bit objects */
+#define ELFCLASS64      2               /* 64-bit objects */
+#define ELFCLASSNUM     3
+
+#define EI_DATA         5               /* Data encoding byte index */
+#define ELFDATANONE     0               /* Invalid data encoding */
+#define ELFDATA2LSB     1               /* 2's complement, little endian */
+#define ELFDATA2MSB     2               /* 2's complement, big endian */
+#define ELFDATANUM      3
+
+#define EI_VERSION      6               /* File version byte index */
+                                        /* Value must be EV_CURRENT */
+
+#define EI_OSABI        7               /* OS ABI identification */
+#define ELFOSABI_SYSV           0       /* UNIX System V ABI */
+#define ELFOSABI_HPUX           1       /* HP-UX */
+#define ELFOSABI_FREEBSD        9       /* Free BSD */
+#define ELFOSABI_ARM            97      /* ARM */
+#define ELFOSABI_STANDALONE     255     /* Standalone (embedded) application */
+
+#define EI_ABIVERSION   8               /* ABI version */
+
+#define EI_PAD          9               /* Byte index of padding bytes */
+
+/* Legal values for e_type (object file type).  */
+
+#define ET_NONE         0               /* No file type */
+#define ET_REL          1               /* Relocatable file */
+#define ET_EXEC         2               /* Executable file */
+#define ET_DYN          3               /* Shared object file */
+#define ET_CORE         4               /* Core file */
+#define ET_NUM          5               /* Number of defined types */
+#define ET_LOPROC       0xff00          /* Processor-specific */
+#define ET_HIPROC       0xffff          /* Processor-specific */
+
+/* Legal values for e_machine (architecture).  */
+
+#define EM_NONE          0              /* No machine */
+#define EM_M32           1              /* AT&T WE 32100 */
+#define EM_SPARC         2              /* SUN SPARC */
+#define EM_386           3              /* Intel 80386 */
+#define EM_68K           4              /* Motorola m68k family */
+#define EM_88K           5              /* Motorola m88k family */
+#define EM_486           6              /* Intel 80486 */
+#define EM_860           7              /* Intel 80860 */
+#define EM_MIPS          8              /* MIPS R3000 big-endian */
+#define EM_S370          9              /* Amdahl */
+#define EM_MIPS_RS4_BE  10              /* MIPS R4000 big-endian */
+#define EM_RS6000       11              /* RS6000 */
+
+#define EM_PARISC       15              /* HPPA */
+#define EM_nCUBE        16              /* nCUBE */
+#define EM_VPP500       17              /* Fujitsu VPP500 */
+#define EM_SPARC32PLUS  18              /* Sun's "v8plus" */
+#define EM_960          19              /* Intel 80960 */
+#define EM_PPC          20              /* PowerPC */
+
+#define EM_V800         36              /* NEC V800 series */
+#define EM_FR20         37              /* Fujitsu FR20 */
+#define EM_RH32         38              /* TRW RH32 */
+#define EM_RCE          39              /* Motorola RCE */
+#define EM_ARM          40              /* ARM */
+#define EM_FAKE_ALPHA   41              /* Digital Alpha */
+#define EM_SH           42              /* Hitachi SH */
+#define EM_SPARCV9      43              /* SPARC v9 64-bit */
+#define EM_TRICORE      44              /* Siemens Tricore */
+#define EM_ARC          45              /* Argonaut RISC Core */
+#define EM_H8_300       46              /* Hitachi H8/300 */
+#define EM_H8_300H      47              /* Hitachi H8/300H */
+#define EM_H8S          48              /* Hitachi H8S */
+#define EM_H8_500       49              /* Hitachi H8/500 */
+#define EM_IA_64        50              /* Intel Merced */
+#define EM_MIPS_X       51              /* Stanford MIPS-X */
+#define EM_COLDFIRE     52              /* Motorola Coldfire */
+#define EM_68HC12       53              /* Motorola M68HC12 */
+#define EM_MMA          54              /* Fujitsu MMA Multimedia Accelerator*/
+#define EM_PCP          55              /* Siemens PCP */
+#define EM_NCPU         56              /* Sony nCPU embeeded RISC */
+#define EM_NDR1         57              /* Denso NDR1 microprocessor */
+#define EM_STARCORE     58              /* Motorola Start*Core processor */
+#define EM_ME16         59              /* Toyota ME16 processor */
+#define EM_ST100        60              /* STMicroelectronic ST100 processor */
+#define EM_TINYJ        61              /* Advanced Logic Corp. Tinyj emb.fam*/
+#define EM_X86_64       62              /* AMD x86-64 architecture */
+#define EM_PDSP         63              /* Sony DSP Processor */
+#define EM_FX66         66              /* Siemens FX66 microcontroller */
+#define EM_ST9PLUS      67              /* STMicroelectronics ST9+ 8/16 mc */
+#define EM_ST7          68              /* STmicroelectronics ST7 8 bit mc */
+#define EM_68HC16       69              /* Motorola MC68HC16 microcontroller */
+#define EM_68HC11       70              /* Motorola MC68HC11 microcontroller */
+#define EM_68HC08       71              /* Motorola MC68HC08 microcontroller */
+#define EM_68HC05       72              /* Motorola MC68HC05 microcontroller */
+#define EM_SVX          73              /* Silicon Graphics SVx */
+#define EM_ST19         74              /* STMicroelectronics ST19 8 bit mc */
+#define EM_VAX          75              /* Digital VAX */
+#define EM_CRIS         76              /* Axis Communications 32-bit embedded processor */
+#define EM_JAVELIN      77              /* Infineon Technologies 32-bit embedded processor */
+#define EM_FIREPATH     78              /* Element 14 64-bit DSP Processor */
+#define EM_ZSP          79              /* LSI Logic 16-bit DSP Processor */
+#define EM_MMIX         80              /* Donald Knuth's educational 64-bit processor */
+#define EM_HUANY        81              /* Harvard University machine-independent object files */
+#define EM_PRISM        82              /* SiTera Prism */
+#define EM_AVR          83              /* Atmel AVR 8-bit microcontroller */
+#define EM_FR30         84              /* Fujitsu FR30 */
+#define EM_D10V         85              /* Mitsubishi D10V */
+#define EM_D30V         86              /* Mitsubishi D30V */
+#define EM_V850         87              /* NEC v850 */
+#define EM_M32R         88              /* Mitsubishi M32R */
+#define EM_MN10300      89              /* Matsushita MN10300 */
+#define EM_MN10200      90              /* Matsushita MN10200 */
+#define EM_PJ           91              /* picoJava */
+#define EM_OPENRISC     92              /* OpenRISC 32-bit embedded processor */
+#define EM_ARC_A5       93              /* ARC Cores Tangent-A5 */
+#define EM_XTENSA       94              /* Tensilica Xtensa Architecture */
+#define EM_NUM          95
+
+/* If it is necessary to assign new unofficial EM_* values, please
+   pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
+   chances of collision with official or non-GNU unofficial values.  */
+
+#define EM_ALPHA        0x9026
+#define EM_C60          0x9c60
+
+/* Legal values for e_version (version).  */
+
+#define EV_NONE         0               /* Invalid ELF version */
+#define EV_CURRENT      1               /* Current version */
+#define EV_NUM          2
+
+/* Section header.  */
+
+typedef struct
+{
+  Elf32_Word    sh_name;                /* Section name (string tbl index) */
+  Elf32_Word    sh_type;                /* Section type */
+  Elf32_Word    sh_flags;               /* Section flags */
+  Elf32_Addr    sh_addr;                /* Section virtual addr at execution */
+  Elf32_Off     sh_offset;              /* Section file offset */
+  Elf32_Word    sh_size;                /* Section size in bytes */
+  Elf32_Word    sh_link;                /* Link to another section */
+  Elf32_Word    sh_info;                /* Additional section information */
+  Elf32_Word    sh_addralign;           /* Section alignment */
+  Elf32_Word    sh_entsize;             /* Entry size if section holds table */
+} Elf32_Shdr;
+
+typedef struct
+{
+  Elf64_Word    sh_name;                /* Section name (string tbl index) */
+  Elf64_Word    sh_type;                /* Section type */
+  Elf64_Xword   sh_flags;               /* Section flags */
+  Elf64_Addr    sh_addr;                /* Section virtual addr at execution */
+  Elf64_Off     sh_offset;              /* Section file offset */
+  Elf64_Xword   sh_size;                /* Section size in bytes */
+  Elf64_Word    sh_link;                /* Link to another section */
+  Elf64_Word    sh_info;                /* Additional section information */
+  Elf64_Xword   sh_addralign;           /* Section alignment */
+  Elf64_Xword   sh_entsize;             /* Entry size if section holds table */
+} Elf64_Shdr;
+
+/* Special section indices.  */
+
+#define SHN_UNDEF       0               /* Undefined section */
+#define SHN_LORESERVE   0xff00          /* Start of reserved indices */
+#define SHN_LOPROC      0xff00          /* Start of processor-specific */
+#define SHN_HIPROC      0xff1f          /* End of processor-specific */
+#define SHN_ABS         0xfff1          /* Associated symbol is absolute */
+#define SHN_COMMON      0xfff2          /* Associated symbol is common */
+#define SHN_HIRESERVE   0xffff          /* End of reserved indices */
+
+/* Legal values for sh_type (section type).  */
+
+#define SHT_NULL         0              /* Section header table entry unused */
+#define SHT_PROGBITS     1              /* Program data */
+#define SHT_SYMTAB       2              /* Symbol table */
+#define SHT_STRTAB       3              /* String table */
+#define SHT_RELA         4              /* Relocation entries with addends */
+#define SHT_HASH         5              /* Symbol hash table */
+#define SHT_DYNAMIC      6              /* Dynamic linking information */
+#define SHT_NOTE         7              /* Notes */
+#define SHT_NOBITS       8              /* Program space with no data (bss) */
+#define SHT_REL          9              /* Relocation entries, no addends */
+#define SHT_SHLIB        10             /* Reserved */
+#define SHT_DYNSYM       11             /* Dynamic linker symbol table */
+#define SHT_INIT_ARRAY   14             /* Array of constructors */
+#define SHT_FINI_ARRAY   15             /* Array of destructors */
+#define SHT_PREINIT_ARRAY 16            /* Array of pre-constructors */
+#define SHT_GROUP        17             /* Section group */
+#define SHT_SYMTAB_SHNDX 18             /* Extended section indices */
+#define SHT_NUM          19             /* Number of defined types.  */
+#define SHT_LOOS         0x60000000     /* Start OS-specific */
+#define SHT_LOSUNW       0x6ffffffb     /* Sun-specific low bound.  */
+#define SHT_SUNW_COMDAT  0x6ffffffb
+#define SHT_SUNW_syminfo 0x6ffffffc
+#define SHT_GNU_verdef   0x6ffffffd     /* Version definition section.  */
+#define SHT_GNU_verneed  0x6ffffffe     /* Version needs section.  */
+#define SHT_GNU_versym   0x6fffffff     /* Version symbol table.  */
+#define SHT_HISUNW       0x6fffffff     /* Sun-specific high bound.  */
+#define SHT_HIOS         0x6fffffff     /* End OS-specific type */
+#define SHT_LOPROC       0x70000000     /* Start of processor-specific */
+#define SHT_ARM_EXIDX    0x70000001     /* Exception Index table */
+#define SHT_ARM_PREEMPTMAP 0x70000002   /* dynamic linking pre-emption map */
+#define SHT_ARM_ATTRIBUTES 0x70000003   /* Object file compatibility attrs */
+#define SHT_HIPROC       0x7fffffff     /* End of processor-specific */
+#define SHT_LOUSER       0x80000000     /* Start of application-specific */
+#define SHT_HIUSER       0x8fffffff     /* End of application-specific */
+
+/* Legal values for sh_flags (section flags).  */
+
+#define SHF_WRITE       (1 << 0)        /* Writable */
+#define SHF_ALLOC       (1 << 1)        /* Occupies memory during execution */
+#define SHF_EXECINSTR   (1 << 2)        /* Executable */
+#define SHF_MASKPROC    0xf0000000      /* Processor-specific */
+
+#define SHF_MERGE       0x10
+#define SHF_STRINGS     0x20
+#define SHF_INFO_LINK   0x40
+#define SHF_LINK_ORDER  0x80
+#define SHF_OS_NONCONFORMING 0x100
+#define SHF_GROUP       0x200
+#define SHF_TLS         0x400
+#define SHF_MASKOS      0x0ff00000
+#define SHF_ORDERED     0x40000000
+#define SHF_EXCLUDE     0x80000000
+
+/* Symbol table entry.  */
+
+typedef struct
+{
+  Elf32_Word    st_name;                /* Symbol name (string tbl index) */
+  Elf32_Addr    st_value;               /* Symbol value */
+  Elf32_Word    st_size;                /* Symbol size */
+  unsigned char st_info;                /* Symbol type and binding */
+  unsigned char st_other;               /* No defined meaning, 0 */
+  Elf32_Section st_shndx;               /* Section index */
+} Elf32_Sym;
+
+typedef struct
+{
+  Elf64_Word    st_name;                /* Symbol name (string tbl index) */
+  unsigned char st_info;                /* Symbol type and binding */
+  unsigned char st_other;               /* No defined meaning, 0 */
+  Elf64_Section st_shndx;               /* Section index */
+  Elf64_Addr    st_value;               /* Symbol value */
+  Elf64_Xword   st_size;                /* Symbol size */
+} Elf64_Sym;
+
+/* The syminfo section if available contains additional information about
+   every dynamic symbol.  */
+
+typedef struct
+{
+  Elf32_Half si_boundto;                /* Direct bindings, symbol bound to */
+  Elf32_Half si_flags;                  /* Per symbol flags */
+} Elf32_Syminfo;
+
+typedef struct
+{
+  Elf64_Half si_boundto;                /* Direct bindings, symbol bound to */
+  Elf64_Half si_flags;                  /* Per symbol flags */
+} Elf64_Syminfo;
+
+/* Possible values for si_boundto.  */
+#define SYMINFO_BT_SELF         0xffff  /* Symbol bound to self */
+#define SYMINFO_BT_PARENT       0xfffe  /* Symbol bound to parent */
+#define SYMINFO_BT_LOWRESERVE   0xff00  /* Beginning of reserved entries */
+
+/* Possible bitmasks for si_flags.  */
+#define SYMINFO_FLG_DIRECT      0x0001  /* Direct bound symbol */
+#define SYMINFO_FLG_PASSTHRU    0x0002  /* Pass-thru symbol for translator */
+#define SYMINFO_FLG_COPY        0x0004  /* Symbol is a copy-reloc */
+#define SYMINFO_FLG_LAZYLOAD    0x0008  /* Symbol bound to object to be lazy
+                                           loaded */
+/* Syminfo version values.  */
+#define SYMINFO_NONE            0
+#define SYMINFO_CURRENT         1
+#define SYMINFO_NUM             2
+
+
+/* Special section index.  */
+
+#define SHN_UNDEF       0               /* No section, undefined symbol.  */
+
+/* How to extract and insert information held in the st_info field.  */
+
+#define ELF32_ST_BIND(val)              (((unsigned char) (val)) >> 4)
+#define ELF32_ST_TYPE(val)              ((val) & 0xf)
+#define ELF32_ST_INFO(bind, type)       (((bind) << 4) + ((type) & 0xf))
+
+/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field.  */
+#define ELF64_ST_BIND(val)              ELF32_ST_BIND (val)
+#define ELF64_ST_TYPE(val)              ELF32_ST_TYPE (val)
+#define ELF64_ST_INFO(bind, type)       ELF32_ST_INFO ((bind), (type))
+
+/* Legal values for ST_BIND subfield of st_info (symbol binding).  */
+
+#define STB_LOCAL       0               /* Local symbol */
+#define STB_GLOBAL      1               /* Global symbol */
+#define STB_WEAK        2               /* Weak symbol */
+#define STB_NUM         3               /* Number of defined types.  */
+#define STB_LOOS        10              /* Start of OS-specific */
+#define STB_HIOS        12              /* End of OS-specific */
+#define STB_LOPROC      13              /* Start of processor-specific */
+#define STB_HIPROC      15              /* End of processor-specific */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
+
+#define STT_NOTYPE      0               /* Symbol type is unspecified */
+#define STT_OBJECT      1               /* Symbol is a data object */
+#define STT_FUNC        2               /* Symbol is a code object */
+#define STT_SECTION     3               /* Symbol associated with a section */
+#define STT_FILE        4               /* Symbol's name is file name */
+#define STT_NUM         5               /* Number of defined types.  */
+#define STT_GNU_IFUNC   10              /* Symbol is a indirect code object */
+#define STT_LOOS        11              /* Start of OS-specific */
+#define STT_HIOS        12              /* End of OS-specific */
+#define STT_LOPROC      13              /* Start of processor-specific */
+#define STT_HIPROC      15              /* End of processor-specific */
+
+
+/* Symbol table indices are found in the hash buckets and chain table
+   of a symbol hash table section.  This special index value indicates
+   the end of a chain, meaning no further symbols are found in that bucket.  */
+
+#define STN_UNDEF       0               /* End of a chain.  */
+
+
+/* How to extract and insert information held in the st_other field.  */
+
+#define ELF32_ST_VISIBILITY(o)  ((o) & 0x03)
+
+/* For ELF64 the definitions are the same.  */
+#define ELF64_ST_VISIBILITY(o)  ELF32_ST_VISIBILITY (o)
+
+/* Symbol visibility specification encoded in the st_other field.  */
+#define STV_DEFAULT     0               /* Default symbol visibility rules */
+#define STV_INTERNAL    1               /* Processor specific hidden class */
+#define STV_HIDDEN      2               /* Sym unavailable in other modules */
+#define STV_PROTECTED   3               /* Not preemptible, not exported */
+
+
+/* Relocation table entry without addend (in section of type SHT_REL).  */
+
+typedef struct
+{
+  Elf32_Addr    r_offset;               /* Address */
+  Elf32_Word    r_info;                 /* Relocation type and symbol index */
+} Elf32_Rel;
+
+/* I have seen two different definitions of the Elf64_Rel and
+   Elf64_Rela structures, so we'll leave them out until Novell (or
+   whoever) gets their act together.  */
+/* The following, at least, is used on Sparc v9, MIPS, and Alpha.  */
+
+typedef struct
+{
+  Elf64_Addr    r_offset;               /* Address */
+  Elf64_Xword   r_info;                 /* Relocation type and symbol index */
+} Elf64_Rel;
+
+/* Relocation table entry with addend (in section of type SHT_RELA).  */
+
+typedef struct
+{
+  Elf32_Addr    r_offset;               /* Address */
+  Elf32_Word    r_info;                 /* Relocation type and symbol index */
+  Elf32_Sword   r_addend;               /* Addend */
+} Elf32_Rela;
+
+typedef struct
+{
+  Elf64_Addr    r_offset;               /* Address */
+  Elf64_Xword   r_info;                 /* Relocation type and symbol index */
+  Elf64_Sxword  r_addend;               /* Addend */
+} Elf64_Rela;
+
+/* How to extract and insert information held in the r_info field.  */
+
+#define ELF32_R_SYM(val)                ((val) >> 8)
+#define ELF32_R_TYPE(val)               ((val) & 0xff)
+#define ELF32_R_INFO(sym, type)         (((sym) << 8) + ((type) & 0xff))
+
+#define ELF64_R_SYM(i)                  ((i) >> 32)
+#define ELF64_R_TYPE(i)                 ((i) & 0xffffffff)
+#define ELF64_R_INFO(sym,type)          ((((Elf64_Xword)(sym)) << 32) + (type))
+
+/* Program segment header.  */
+
+typedef struct
+{
+  Elf32_Word    p_type;                 /* Segment type */
+  Elf32_Off     p_offset;               /* Segment file offset */
+  Elf32_Addr    p_vaddr;                /* Segment virtual address */
+  Elf32_Addr    p_paddr;                /* Segment physical address */
+  Elf32_Word    p_filesz;               /* Segment size in file */
+  Elf32_Word    p_memsz;                /* Segment size in memory */
+  Elf32_Word    p_flags;                /* Segment flags */
+  Elf32_Word    p_align;                /* Segment alignment */
+} Elf32_Phdr;
+
+typedef struct
+{
+  Elf64_Word    p_type;                 /* Segment type */
+  Elf64_Word    p_flags;                /* Segment flags */
+  Elf64_Off     p_offset;               /* Segment file offset */
+  Elf64_Addr    p_vaddr;                /* Segment virtual address */
+  Elf64_Addr    p_paddr;                /* Segment physical address */
+  Elf64_Xword   p_filesz;               /* Segment size in file */
+  Elf64_Xword   p_memsz;                /* Segment size in memory */
+  Elf64_Xword   p_align;                /* Segment alignment */
+} Elf64_Phdr;
+
+/* Legal values for p_type (segment type).  */
+
+#define PT_NULL         0               /* Program header table entry unused */
+#define PT_LOAD         1               /* Loadable program segment */
+#define PT_DYNAMIC      2               /* Dynamic linking information */
+#define PT_INTERP       3               /* Program interpreter */
+#define PT_NOTE         4               /* Auxiliary information */
+#define PT_SHLIB        5               /* Reserved */
+#define PT_PHDR         6               /* Entry for header table itself */
+#define PT_NUM          7               /* Number of defined types.  */
+#define PT_LOOS         0x60000000      /* Start of OS-specific */
+#define PT_HIOS         0x6fffffff      /* End of OS-specific */
+#define PT_LOPROC       0x70000000      /* Start of processor-specific */
+#define PT_HIPROC       0x7fffffff      /* End of processor-specific */
+
+/* Legal values for p_flags (segment flags).  */
+
+#define PF_X            (1 << 0)        /* Segment is executable */
+#define PF_W            (1 << 1)        /* Segment is writable */
+#define PF_R            (1 << 2)        /* Segment is readable */
+#define PF_MASKPROC     0xf0000000      /* Processor-specific */
+
+/* Legal values for note segment descriptor types for core files. */
+
+#define NT_PRSTATUS     1               /* Contains copy of prstatus struct */
+#define NT_FPREGSET     2               /* Contains copy of fpregset struct */
+#define NT_PRPSINFO     3               /* Contains copy of prpsinfo struct */
+#define NT_PRXREG       4               /* Contains copy of prxregset struct */
+#define NT_PLATFORM     5               /* String from sysinfo(SI_PLATFORM) */
+#define NT_AUXV         6               /* Contains copy of auxv array */
+#define NT_GWINDOWS     7               /* Contains copy of gwindows struct */
+#define NT_PSTATUS      10              /* Contains copy of pstatus struct */
+#define NT_PSINFO       13              /* Contains copy of psinfo struct */
+#define NT_PRCRED       14              /* Contains copy of prcred struct */
+#define NT_UTSNAME      15              /* Contains copy of utsname struct */
+#define NT_LWPSTATUS    16              /* Contains copy of lwpstatus struct */
+#define NT_LWPSINFO     17              /* Contains copy of lwpinfo struct */
+
+/* Legal values for the  note segment descriptor types for object files.  */
+
+#define NT_VERSION      1               /* Contains a version string.  */
+
+
+/* Dynamic section entry.  */
+
+typedef struct
+{
+  Elf32_Sword   d_tag;                  /* Dynamic entry type */
+  union
+    {
+      Elf32_Word d_val;                 /* Integer value */
+      Elf32_Addr d_ptr;                 /* Address value */
+    } d_un;
+} Elf32_Dyn;
+
+typedef struct
+{
+  Elf64_Sxword  d_tag;                  /* Dynamic entry type */
+  union
+    {
+      Elf64_Xword d_val;                /* Integer value */
+      Elf64_Addr d_ptr;                 /* Address value */
+    } d_un;
+} Elf64_Dyn;
+
+/* Legal values for d_tag (dynamic entry type).  */
+
+#define DT_NULL         0               /* Marks end of dynamic section */
+#define DT_NEEDED       1               /* Name of needed library */
+#define DT_PLTRELSZ     2               /* Size in bytes of PLT relocs */
+#define DT_PLTGOT       3               /* Processor defined value */
+#define DT_HASH         4               /* Address of symbol hash table */
+#define DT_STRTAB       5               /* Address of string table */
+#define DT_SYMTAB       6               /* Address of symbol table */
+#define DT_RELA         7               /* Address of Rela relocs */
+#define DT_RELASZ       8               /* Total size of Rela relocs */
+#define DT_RELAENT      9               /* Size of one Rela reloc */
+#define DT_STRSZ        10              /* Size of string table */
+#define DT_SYMENT       11              /* Size of one symbol table entry */
+#define DT_INIT         12              /* Address of init function */
+#define DT_FINI         13              /* Address of termination function */
+#define DT_SONAME       14              /* Name of shared object */
+#define DT_RPATH        15              /* Library search path */
+#define DT_SYMBOLIC     16              /* Start symbol search here */
+#define DT_REL          17              /* Address of Rel relocs */
+#define DT_RELSZ        18              /* Total size of Rel relocs */
+#define DT_RELENT       19              /* Size of one Rel reloc */
+#define DT_PLTREL       20              /* Type of reloc in PLT */
+#define DT_DEBUG        21              /* For debugging; unspecified */
+#define DT_TEXTREL      22              /* Reloc might modify .text */
+#define DT_JMPREL       23              /* Address of PLT relocs */
+#define DT_BIND_NOW     24              /* Process relocations of object */
+#define DT_INIT_ARRAY   25              /* Array with addresses of init fct */
+#define DT_FINI_ARRAY   26              /* Array with addresses of fini fct */
+#define DT_INIT_ARRAYSZ 27              /* Size in bytes of DT_INIT_ARRAY */
+#define DT_FINI_ARRAYSZ 28              /* Size in bytes of DT_FINI_ARRAY */
+#define DT_NUM          29              /* Number used */
+#define DT_LOOS         0x60000000      /* Start of OS-specific */
+#define DT_HIOS         0x6fffffff      /* End of OS-specific */
+#define DT_LOPROC       0x70000000      /* Start of processor-specific */
+#define DT_HIPROC       0x7fffffff      /* End of processor-specific */
+#define DT_PROCNUM      DT_MIPS_NUM     /* Most used by any processor */
+
+/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
+   Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's
+   approach.  */
+#define DT_VALRNGLO     0x6ffffd00
+#define DT_POSFLAG_1    0x6ffffdfd      /* Flags for DT_* entries, effecting
+                                           the following DT_* entry.  */
+#define DT_SYMINSZ      0x6ffffdfe      /* Size of syminfo table (in bytes) */
+#define DT_SYMINENT     0x6ffffdff      /* Entry size of syminfo */
+#define DT_VALRNGHI     0x6ffffdff
+
+/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
+   Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
+
+   If any adjustment is made to the ELF object after it has been
+   built these entries will need to be adjusted.  */
+#define DT_ADDRRNGLO    0x6ffffe00
+#define DT_SYMINFO      0x6ffffeff      /* syminfo table */
+#define DT_ADDRRNGHI    0x6ffffeff
+
+/* The versioning entry types.  The next are defined as part of the
+   GNU extension.  */
+#define DT_VERSYM       0x6ffffff0
+
+/* These were chosen by Sun.  */
+#define DT_FLAGS_1      0x6ffffffb      /* State flags, see DF_1_* below.  */
+#define DT_VERDEF       0x6ffffffc      /* Address of version definition
+                                           table */
+#define DT_VERDEFNUM    0x6ffffffd      /* Number of version definitions */
+#define DT_VERNEED      0x6ffffffe      /* Address of table with needed
+                                           versions */
+#define DT_VERNEEDNUM   0x6fffffff      /* Number of needed versions */
+#define DT_VERSIONTAGIDX(tag)   (DT_VERNEEDNUM - (tag)) /* Reverse order! */
+#define DT_VERSIONTAGNUM 16
+
+/* Sun added these machine-independent extensions in the "processor-specific"
+   range.  Be compatible.  */
+#define DT_AUXILIARY    0x7ffffffd      /* Shared object to load before self */
+#define DT_FILTER       0x7fffffff      /* Shared object to get values from */
+#define DT_EXTRATAGIDX(tag)     ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
+#define DT_EXTRANUM     3
+
+/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
+   entry in the dynamic section.  */
+#define DF_1_NOW        0x00000001      /* Set RTLD_NOW for this object.  */
+#define DF_1_GLOBAL     0x00000002      /* Set RTLD_GLOBAL for this object.  */
+#define DF_1_GROUP      0x00000004      /* Set RTLD_GROUP for this object.  */
+#define DF_1_NODELETE   0x00000008      /* Set RTLD_NODELETE for this object.*/
+#define DF_1_LOADFLTR   0x00000010      /* Trigger filtee loading at runtime.*/
+#define DF_1_INITFIRST  0x00000020      /* Set RTLD_INITFIRST for this object*/
+#define DF_1_NOOPEN     0x00000040      /* Set RTLD_NOOPEN for this object.  */
+
+/* Version definition sections.  */
+
+typedef struct
+{
+  Elf32_Half    vd_version;             /* Version revision */
+  Elf32_Half    vd_flags;               /* Version information */
+  Elf32_Half    vd_ndx;                 /* Version Index */
+  Elf32_Half    vd_cnt;                 /* Number of associated aux entries */
+  Elf32_Word    vd_hash;                /* Version name hash value */
+  Elf32_Word    vd_aux;                 /* Offset in bytes to verdaux array */
+  Elf32_Word    vd_next;                /* Offset in bytes to next verdef
+                                           entry */
+} Elf32_Verdef;
+
+typedef struct
+{
+  Elf64_Half    vd_version;             /* Version revision */
+  Elf64_Half    vd_flags;               /* Version information */
+  Elf64_Half    vd_ndx;                 /* Version Index */
+  Elf64_Half    vd_cnt;                 /* Number of associated aux entries */
+  Elf64_Word    vd_hash;                /* Version name hash value */
+  Elf64_Word    vd_aux;                 /* Offset in bytes to verdaux array */
+  Elf64_Word    vd_next;                /* Offset in bytes to next verdef
+                                           entry */
+} Elf64_Verdef;
+
+
+/* Legal values for vd_version (version revision).  */
+#define VER_DEF_NONE    0               /* No version */
+#define VER_DEF_CURRENT 1               /* Current version */
+#define VER_DEF_NUM     2               /* Given version number */
+
+/* Legal values for vd_flags (version information flags).  */
+#define VER_FLG_BASE    0x1             /* Version definition of file itself */
+#define VER_FLG_WEAK    0x2             /* Weak version identifier */
+
+/* Auxialiary version information.  */
+
+typedef struct
+{
+  Elf32_Word    vda_name;               /* Version or dependency names */
+  Elf32_Word    vda_next;               /* Offset in bytes to next verdaux
+                                           entry */
+} Elf32_Verdaux;
+
+typedef struct
+{
+  Elf64_Word    vda_name;               /* Version or dependency names */
+  Elf64_Word    vda_next;               /* Offset in bytes to next verdaux
+                                           entry */
+} Elf64_Verdaux;
+
+
+/* Version dependency section.  */
+
+typedef struct
+{
+  Elf32_Half    vn_version;             /* Version of structure */
+  Elf32_Half    vn_cnt;                 /* Number of associated aux entries */
+  Elf32_Word    vn_file;                /* Offset of filename for this
+                                           dependency */
+  Elf32_Word    vn_aux;                 /* Offset in bytes to vernaux array */
+  Elf32_Word    vn_next;                /* Offset in bytes to next verneed
+                                           entry */
+} Elf32_Verneed;
+
+typedef struct
+{
+  Elf64_Half    vn_version;             /* Version of structure */
+  Elf64_Half    vn_cnt;                 /* Number of associated aux entries */
+  Elf64_Word    vn_file;                /* Offset of filename for this
+                                           dependency */
+  Elf64_Word    vn_aux;                 /* Offset in bytes to vernaux array */
+  Elf64_Word    vn_next;                /* Offset in bytes to next verneed
+                                           entry */
+} Elf64_Verneed;
+
+
+/* Legal values for vn_version (version revision).  */
+#define VER_NEED_NONE    0              /* No version */
+#define VER_NEED_CURRENT 1              /* Current version */
+#define VER_NEED_NUM     2              /* Given version number */
+
+/* Auxiliary needed version information.  */
+
+typedef struct
+{
+  Elf32_Word    vna_hash;               /* Hash value of dependency name */
+  Elf32_Half    vna_flags;              /* Dependency specific information */
+  Elf32_Half    vna_other;              /* Unused */
+  Elf32_Word    vna_name;               /* Dependency name string offset */
+  Elf32_Word    vna_next;               /* Offset in bytes to next vernaux
+                                           entry */
+} Elf32_Vernaux;
+
+typedef struct
+{
+  Elf64_Word    vna_hash;               /* Hash value of dependency name */
+  Elf64_Half    vna_flags;              /* Dependency specific information */
+  Elf64_Half    vna_other;              /* Unused */
+  Elf64_Word    vna_name;               /* Dependency name string offset */
+  Elf64_Word    vna_next;               /* Offset in bytes to next vernaux
+                                           entry */
+} Elf64_Vernaux;
+
+
+/* Legal values for vna_flags.  */
+#define VER_FLG_WEAK    0x2             /* Weak version identifier */
+
+
+/* Auxiliary vector.  */
+
+/* This vector is normally only used by the program interpreter.  The
+   usual definition in an ABI supplement uses the name auxv_t.  The
+   vector is not usually defined in a standard <elf.h> file, but it
+   can't hurt.  We rename it to avoid conflicts.  The sizes of these
+   types are an arrangement between the exec server and the program
+   interpreter, so we don't fully specify them here.  */
+
+typedef struct
+{
+  int a_type;                   /* Entry type */
+  union
+    {
+      long int a_val;           /* Integer value */
+      void *a_ptr;              /* Pointer value */
+      void (*a_fcn) (void);     /* Function pointer value */
+    } a_un;
+} Elf32_auxv_t;
+
+typedef struct
+{
+  long int a_type;              /* Entry type */
+  union
+    {
+      long int a_val;           /* Integer value */
+      void *a_ptr;              /* Pointer value */
+      void (*a_fcn) (void);     /* Function pointer value */
+    } a_un;
+} Elf64_auxv_t;
+
+/* Legal values for a_type (entry type).  */
+
+#define AT_NULL         0               /* End of vector */
+#define AT_IGNORE       1               /* Entry should be ignored */
+#define AT_EXECFD       2               /* File descriptor of program */
+#define AT_PHDR         3               /* Program headers for program */
+#define AT_PHENT        4               /* Size of program header entry */
+#define AT_PHNUM        5               /* Number of program headers */
+#define AT_PAGESZ       6               /* System page size */
+#define AT_BASE         7               /* Base address of interpreter */
+#define AT_FLAGS        8               /* Flags */
+#define AT_ENTRY        9               /* Entry point of program */
+#define AT_NOTELF       10              /* Program is not ELF */
+#define AT_UID          11              /* Real uid */
+#define AT_EUID         12              /* Effective uid */
+#define AT_GID          13              /* Real gid */
+#define AT_EGID         14              /* Effective gid */
+
+/* Some more special a_type values describing the hardware.  */
+#define AT_PLATFORM     15              /* String identifying platform.  */
+#define AT_HWCAP        16              /* Machine dependent hints about
+                                           processor capabilities.  */
+
+/* This entry gives some information about the FPU initialization
+   performed by the kernel.  */
+#define AT_FPUCW        17              /* Used FPU control word.  */
+
+
+/* Note section contents.  Each entry in the note section begins with
+   a header of a fixed form.  */
+
+typedef struct
+{
+  Elf32_Word n_namesz;                  /* Length of the note's name.  */
+  Elf32_Word n_descsz;                  /* Length of the note's descriptor.  */
+  Elf32_Word n_type;                    /* Type of the note.  */
+} Elf32_Nhdr;
+
+typedef struct
+{
+  Elf64_Word n_namesz;                  /* Length of the note's name.  */
+  Elf64_Word n_descsz;                  /* Length of the note's descriptor.  */
+  Elf64_Word n_type;                    /* Type of the note.  */
+} Elf64_Nhdr;
+
+/* Known names of notes.  */
+
+/* Solaris entries in the note section have this name.  */
+#define ELF_NOTE_SOLARIS        "SUNW Solaris"
+
+/* Note entries for GNU systems have this name.  */
+#define ELF_NOTE_GNU            "GNU"
+
+
+/* Defined types of notes for Solaris.  */
+
+/* Value of descriptor (one word) is desired pagesize for the binary.  */
+#define ELF_NOTE_PAGESIZE_HINT  1
+
+
+/* Defined note types for GNU systems.  */
+
+/* ABI information.  The descriptor consists of words:
+   word 0: OS descriptor
+   word 1: major version of the ABI
+   word 2: minor version of the ABI
+   word 3: subminor version of the ABI
+*/
+#define ELF_NOTE_ABI            1
+
+/* Known OSes.  These value can appear in word 0 of an ELF_NOTE_ABI
+   note section entry.  */
+#define ELF_NOTE_OS_LINUX       0
+#define ELF_NOTE_OS_GNU         1
+#define ELF_NOTE_OS_SOLARIS2    2
+
+
+/* Motorola 68k specific definitions.  */
+
+/* m68k relocs.  */
+
+#define R_68K_NONE      0               /* No reloc */
+#define R_68K_32        1               /* Direct 32 bit  */
+#define R_68K_16        2               /* Direct 16 bit  */
+#define R_68K_8         3               /* Direct 8 bit  */
+#define R_68K_PC32      4               /* PC relative 32 bit */
+#define R_68K_PC16      5               /* PC relative 16 bit */
+#define R_68K_PC8       6               /* PC relative 8 bit */
+#define R_68K_GOT32     7               /* 32 bit PC relative GOT entry */
+#define R_68K_GOT16     8               /* 16 bit PC relative GOT entry */
+#define R_68K_GOT8      9               /* 8 bit PC relative GOT entry */
+#define R_68K_GOT32O    10              /* 32 bit GOT offset */
+#define R_68K_GOT16O    11              /* 16 bit GOT offset */
+#define R_68K_GOT8O     12              /* 8 bit GOT offset */
+#define R_68K_PLT32     13              /* 32 bit PC relative PLT address */
+#define R_68K_PLT16     14              /* 16 bit PC relative PLT address */
+#define R_68K_PLT8      15              /* 8 bit PC relative PLT address */
+#define R_68K_PLT32O    16              /* 32 bit PLT offset */
+#define R_68K_PLT16O    17              /* 16 bit PLT offset */
+#define R_68K_PLT8O     18              /* 8 bit PLT offset */
+#define R_68K_COPY      19              /* Copy symbol at runtime */
+#define R_68K_GLOB_DAT  20              /* Create GOT entry */
+#define R_68K_JMP_SLOT  21              /* Create PLT entry */
+#define R_68K_RELATIVE  22              /* Adjust by program base */
+/* Keep this the last entry.  */
+#define R_68K_NUM       23
+
+/* Intel 80386 specific definitions.  */
+
+/* i386 relocs.  */
+
+#define R_386_NONE      0               /* No reloc */
+#define R_386_32        1               /* Direct 32 bit  */
+#define R_386_PC32      2               /* PC relative 32 bit */
+#define R_386_GOT32     3               /* 32 bit GOT entry */
+#define R_386_PLT32     4               /* 32 bit PLT address */
+#define R_386_COPY      5               /* Copy symbol at runtime */
+#define R_386_GLOB_DAT  6               /* Create GOT entry */
+#define R_386_JMP_SLOT  7               /* Create PLT entry */
+#define R_386_RELATIVE  8               /* Adjust by program base */
+#define R_386_GOTOFF    9               /* 32 bit offset to GOT */
+#define R_386_GOTPC     10              /* 32 bit PC relative offset to GOT */
+/* Keep this the last entry.  */
+#define R_386_NUM       11
+
+/* TCC-specific 16-bit relocs. */
+#define R_386_16        12              /* Direct 16 bit  */
+#define R_386_PC16      13              /* PC relative 16 bit */
+
+/* SUN SPARC specific definitions.  */
+
+/* Values for Elf64_Ehdr.e_flags.  */
+
+#define EF_SPARCV9_MM           3
+#define EF_SPARCV9_TSO          0
+#define EF_SPARCV9_PSO          1
+#define EF_SPARCV9_RMO          2
+#define EF_SPARC_EXT_MASK       0xFFFF00
+#define EF_SPARC_SUN_US1        0x000200
+#define EF_SPARC_HAL_R1         0x000400
+
+/* SPARC relocs.  */
+
+#define R_SPARC_NONE    0               /* No reloc */
+#define R_SPARC_8       1               /* Direct 8 bit */
+#define R_SPARC_16      2               /* Direct 16 bit */
+#define R_SPARC_32      3               /* Direct 32 bit */
+#define R_SPARC_DISP8   4               /* PC relative 8 bit */
+#define R_SPARC_DISP16  5               /* PC relative 16 bit */
+#define R_SPARC_DISP32  6               /* PC relative 32 bit */
+#define R_SPARC_WDISP30 7               /* PC relative 30 bit shifted */
+#define R_SPARC_WDISP22 8               /* PC relative 22 bit shifted */
+#define R_SPARC_HI22    9               /* High 22 bit */
+#define R_SPARC_22      10              /* Direct 22 bit */
+#define R_SPARC_13      11              /* Direct 13 bit */
+#define R_SPARC_LO10    12              /* Truncated 10 bit */
+#define R_SPARC_GOT10   13              /* Truncated 10 bit GOT entry */
+#define R_SPARC_GOT13   14              /* 13 bit GOT entry */
+#define R_SPARC_GOT22   15              /* 22 bit GOT entry shifted */
+#define R_SPARC_PC10    16              /* PC relative 10 bit truncated */
+#define R_SPARC_PC22    17              /* PC relative 22 bit shifted */
+#define R_SPARC_WPLT30  18              /* 30 bit PC relative PLT address */
+#define R_SPARC_COPY    19              /* Copy symbol at runtime */
+#define R_SPARC_GLOB_DAT 20             /* Create GOT entry */
+#define R_SPARC_JMP_SLOT 21             /* Create PLT entry */
+#define R_SPARC_RELATIVE 22             /* Adjust by program base */
+#define R_SPARC_UA32    23              /* Direct 32 bit unaligned */
+
+/* Additional Sparc64 relocs.  */
+
+#define R_SPARC_PLT32   24              /* Direct 32 bit ref to PLT entry */
+#define R_SPARC_HIPLT22 25              /* High 22 bit PLT entry */
+#define R_SPARC_LOPLT10 26              /* Truncated 10 bit PLT entry */
+#define R_SPARC_PCPLT32 27              /* PC rel 32 bit ref to PLT entry */
+#define R_SPARC_PCPLT22 28              /* PC rel high 22 bit PLT entry */
+#define R_SPARC_PCPLT10 29              /* PC rel trunc 10 bit PLT entry */
+#define R_SPARC_10      30              /* Direct 10 bit */
+#define R_SPARC_11      31              /* Direct 11 bit */
+#define R_SPARC_64      32              /* Direct 64 bit */
+#define R_SPARC_OLO10   33              /* ?? */
+#define R_SPARC_HH22    34              /* Top 22 bits of direct 64 bit */
+#define R_SPARC_HM10    35              /* High middle 10 bits of ... */
+#define R_SPARC_LM22    36              /* Low middle 22 bits of ... */
+#define R_SPARC_PC_HH22 37              /* Top 22 bits of pc rel 64 bit */
+#define R_SPARC_PC_HM10 38              /* High middle 10 bit of ... */
+#define R_SPARC_PC_LM22 39              /* Low miggle 22 bits of ... */
+#define R_SPARC_WDISP16 40              /* PC relative 16 bit shifted */
+#define R_SPARC_WDISP19 41              /* PC relative 19 bit shifted */
+#define R_SPARC_7       43              /* Direct 7 bit */
+#define R_SPARC_5       44              /* Direct 5 bit */
+#define R_SPARC_6       45              /* Direct 6 bit */
+#define R_SPARC_DISP64  46              /* PC relative 64 bit */
+#define R_SPARC_PLT64   47              /* Direct 64 bit ref to PLT entry */
+#define R_SPARC_HIX22   48              /* High 22 bit complemented */
+#define R_SPARC_LOX10   49              /* Truncated 11 bit complemented */
+#define R_SPARC_H44     50              /* Direct high 12 of 44 bit */
+#define R_SPARC_M44     51              /* Direct mid 22 of 44 bit */
+#define R_SPARC_L44     52              /* Direct low 10 of 44 bit */
+#define R_SPARC_REGISTER 53             /* Global register usage */
+#define R_SPARC_UA64    54              /* Direct 64 bit unaligned */
+#define R_SPARC_UA16    55              /* Direct 16 bit unaligned */
+/* Keep this the last entry.  */
+#define R_SPARC_NUM     56
+
+/* AMD x86-64 relocations.  */
+#define R_X86_64_NONE		0	/* No reloc */
+#define R_X86_64_64		1	/* Direct 64 bit  */
+#define R_X86_64_PC32		2	/* PC relative 32 bit signed */
+#define R_X86_64_GOT32		3	/* 32 bit GOT entry */
+#define R_X86_64_PLT32		4	/* 32 bit PLT address */
+#define R_X86_64_COPY		5	/* Copy symbol at runtime */
+#define R_X86_64_GLOB_DAT	6	/* Create GOT entry */
+#define R_X86_64_JUMP_SLOT	7	/* Create PLT entry */
+#define R_X86_64_RELATIVE	8	/* Adjust by program base */
+#define R_X86_64_GOTPCREL	9	/* 32 bit signed PC relative
+					   offset to GOT */
+#define R_X86_64_32		10	/* Direct 32 bit zero extended */
+#define R_X86_64_32S		11	/* Direct 32 bit sign extended */
+#define R_X86_64_16		12	/* Direct 16 bit zero extended */
+#define R_X86_64_PC16		13	/* 16 bit sign extended pc relative */
+#define R_X86_64_8		14	/* Direct 8 bit sign extended  */
+#define R_X86_64_PC8		15	/* 8 bit sign extended pc relative */
+#define R_X86_64_DTPMOD64	16	/* ID of module containing symbol */
+#define R_X86_64_DTPOFF64	17	/* Offset in module's TLS block */
+#define R_X86_64_TPOFF64	18	/* Offset in initial TLS block */
+#define R_X86_64_TLSGD		19	/* 32 bit signed PC relative offset
+					   to two GOT entries for GD symbol */
+#define R_X86_64_TLSLD		20	/* 32 bit signed PC relative offset
+					   to two GOT entries for LD symbol */
+#define R_X86_64_DTPOFF32	21	/* Offset in TLS block */
+#define R_X86_64_GOTTPOFF	22	/* 32 bit signed PC relative offset
+					   to GOT entry for IE symbol */
+#define R_X86_64_TPOFF32	23	/* Offset in initial TLS block */
+
+#define R_X86_64_NUM		24
+
+/* For Sparc64, legal values for d_tag of Elf64_Dyn.  */
+
+#define DT_SPARC_REGISTER 0x70000001
+#define DT_SPARC_NUM    2
+
+/* Bits present in AT_HWCAP, primarily for Sparc32.  */
+
+#define HWCAP_SPARC_FLUSH       1       /* The cpu supports flush insn.  */
+#define HWCAP_SPARC_STBAR       2
+#define HWCAP_SPARC_SWAP        4
+#define HWCAP_SPARC_MULDIV      8
+#define HWCAP_SPARC_V9          16      /* The cpu is v9, so v8plus is ok.  */
+
+/* MIPS R3000 specific definitions.  */
+
+/* Legal values for e_flags field of Elf32_Ehdr.  */
+
+#define EF_MIPS_NOREORDER   1           /* A .noreorder directive was used */
+#define EF_MIPS_PIC         2           /* Contains PIC code */
+#define EF_MIPS_CPIC        4           /* Uses PIC calling sequence */
+#define EF_MIPS_XGOT        8
+#define EF_MIPS_64BIT_WHIRL 16
+#define EF_MIPS_ABI2        32
+#define EF_MIPS_ABI_ON32    64
+#define EF_MIPS_ARCH        0xf0000000  /* MIPS architecture level */
+
+/* Legal values for MIPS architecture level.  */
+
+#define EF_MIPS_ARCH_1      0x00000000  /* -mips1 code.  */
+#define EF_MIPS_ARCH_2      0x10000000  /* -mips2 code.  */
+#define EF_MIPS_ARCH_3      0x20000000  /* -mips3 code.  */
+#define EF_MIPS_ARCH_4      0x30000000  /* -mips4 code.  */
+#define EF_MIPS_ARCH_5      0x40000000  /* -mips5 code.  */
+
+/* The following are non-official names and should not be used.  */
+
+#define E_MIPS_ARCH_1     0x00000000    /* -mips1 code.  */
+#define E_MIPS_ARCH_2     0x10000000    /* -mips2 code.  */
+#define E_MIPS_ARCH_3     0x20000000    /* -mips3 code.  */
+#define E_MIPS_ARCH_4     0x30000000    /* -mips4 code.  */
+#define E_MIPS_ARCH_5     0x40000000    /* -mips5 code.  */
+
+/* Special section indices.  */
+
+#define SHN_MIPS_ACOMMON 0xff00         /* Allocated common symbols */
+#define SHN_MIPS_TEXT    0xff01         /* Allocated test symbols.  */
+#define SHN_MIPS_DATA    0xff02         /* Allocated data symbols.  */
+#define SHN_MIPS_SCOMMON 0xff03         /* Small common symbols */
+#define SHN_MIPS_SUNDEFINED 0xff04      /* Small undefined symbols */
+
+/* Legal values for sh_type field of Elf32_Shdr.  */
+
+#define SHT_MIPS_LIBLIST       0x70000000 /* Shared objects used in link */
+#define SHT_MIPS_MSYM          0x70000001
+#define SHT_MIPS_CONFLICT      0x70000002 /* Conflicting symbols */
+#define SHT_MIPS_GPTAB         0x70000003 /* Global data area sizes */
+#define SHT_MIPS_UCODE         0x70000004 /* Reserved for SGI/MIPS compilers */
+#define SHT_MIPS_DEBUG         0x70000005 /* MIPS ECOFF debugging information*/
+#define SHT_MIPS_REGINFO       0x70000006 /* Register usage information */
+#define SHT_MIPS_PACKAGE       0x70000007
+#define SHT_MIPS_PACKSYM       0x70000008
+#define SHT_MIPS_RELD          0x70000009
+#define SHT_MIPS_IFACE         0x7000000b
+#define SHT_MIPS_CONTENT       0x7000000c
+#define SHT_MIPS_OPTIONS       0x7000000d /* Miscellaneous options.  */
+#define SHT_MIPS_SHDR          0x70000010
+#define SHT_MIPS_FDESC         0x70000011
+#define SHT_MIPS_EXTSYM        0x70000012
+#define SHT_MIPS_DENSE         0x70000013
+#define SHT_MIPS_PDESC         0x70000014
+#define SHT_MIPS_LOCSYM        0x70000015
+#define SHT_MIPS_AUXSYM        0x70000016
+#define SHT_MIPS_OPTSYM        0x70000017
+#define SHT_MIPS_LOCSTR        0x70000018
+#define SHT_MIPS_LINE          0x70000019
+#define SHT_MIPS_RFDESC        0x7000001a
+#define SHT_MIPS_DELTASYM      0x7000001b
+#define SHT_MIPS_DELTAINST     0x7000001c
+#define SHT_MIPS_DELTACLASS    0x7000001d
+#define SHT_MIPS_DWARF         0x7000001e /* DWARF debugging information.  */
+#define SHT_MIPS_DELTADECL     0x7000001f
+#define SHT_MIPS_SYMBOL_LIB    0x70000020
+#define SHT_MIPS_EVENTS        0x70000021 /* Event section.  */
+#define SHT_MIPS_TRANSLATE     0x70000022
+#define SHT_MIPS_PIXIE         0x70000023
+#define SHT_MIPS_XLATE         0x70000024
+#define SHT_MIPS_XLATE_DEBUG   0x70000025
+#define SHT_MIPS_WHIRL         0x70000026
+#define SHT_MIPS_EH_REGION     0x70000027
+#define SHT_MIPS_XLATE_OLD     0x70000028
+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
+
+/* Legal values for sh_flags field of Elf32_Shdr.  */
+
+#define SHF_MIPS_GPREL   0x10000000     /* Must be part of global data area */
+#define SHF_MIPS_MERGE   0x20000000
+#define SHF_MIPS_ADDR    0x40000000
+#define SHF_MIPS_STRINGS 0x80000000
+#define SHF_MIPS_NOSTRIP 0x08000000
+#define SHF_MIPS_LOCAL   0x04000000
+#define SHF_MIPS_NAMES   0x02000000
+#define SHF_MIPS_NODUPE  0x01000000
+
+
+/* Symbol tables.  */
+
+/* MIPS specific values for `st_other'.  */
+#define STO_MIPS_DEFAULT                0x0
+#define STO_MIPS_INTERNAL               0x1
+#define STO_MIPS_HIDDEN                 0x2
+#define STO_MIPS_PROTECTED              0x3
+#define STO_MIPS_SC_ALIGN_UNUSED        0xff
+
+/* MIPS specific values for `st_info'.  */
+#define STB_MIPS_SPLIT_COMMON           13
+
+/* Entries found in sections of type SHT_MIPS_GPTAB.  */
+
+typedef union
+{
+  struct
+    {
+      Elf32_Word gt_current_g_value;    /* -G value used for compilation */
+      Elf32_Word gt_unused;             /* Not used */
+    } gt_header;                        /* First entry in section */
+  struct
+    {
+      Elf32_Word gt_g_value;            /* If this value were used for -G */
+      Elf32_Word gt_bytes;              /* This many bytes would be used */
+    } gt_entry;                         /* Subsequent entries in section */
+} Elf32_gptab;
+
+/* Entry found in sections of type SHT_MIPS_REGINFO.  */
+
+typedef struct
+{
+  Elf32_Word    ri_gprmask;             /* General registers used */
+  Elf32_Word    ri_cprmask[4];          /* Coprocessor registers used */
+  Elf32_Sword   ri_gp_value;            /* $gp register value */
+} Elf32_RegInfo;
+
+/* Entries found in sections of type SHT_MIPS_OPTIONS.  */
+
+typedef struct
+{
+  unsigned char kind;           /* Determines interpretation of the
+                                   variable part of descriptor.  */
+  unsigned char size;           /* Size of descriptor, including header.  */
+  Elf32_Section section;        /* Section header index of section affected,
+                                   0 for global options.  */
+  Elf32_Word info;              /* Kind-specific information.  */
+} Elf_Options;
+
+/* Values for `kind' field in Elf_Options.  */
+
+#define ODK_NULL        0       /* Undefined.  */
+#define ODK_REGINFO     1       /* Register usage information.  */
+#define ODK_EXCEPTIONS  2       /* Exception processing options.  */
+#define ODK_PAD         3       /* Section padding options.  */
+#define ODK_HWPATCH     4       /* Hardware workarounds performed */
+#define ODK_FILL        5       /* record the fill value used by the linker. */
+#define ODK_TAGS        6       /* reserve space for desktop tools to write. */
+#define ODK_HWAND       7       /* HW workarounds.  'AND' bits when merging. */
+#define ODK_HWOR        8       /* HW workarounds.  'OR' bits when merging.  */
+
+/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries.  */
+
+#define OEX_FPU_MIN     0x1f    /* FPE's which MUST be enabled.  */
+#define OEX_FPU_MAX     0x1f00  /* FPE's which MAY be enabled.  */
+#define OEX_PAGE0       0x10000 /* page zero must be mapped.  */
+#define OEX_SMM         0x20000 /* Force sequential memory mode?  */
+#define OEX_FPDBUG      0x40000 /* Force floating point debug mode?  */
+#define OEX_PRECISEFP   OEX_FPDBUG
+#define OEX_DISMISS     0x80000 /* Dismiss invalid address faults?  */
+
+#define OEX_FPU_INVAL   0x10
+#define OEX_FPU_DIV0    0x08
+#define OEX_FPU_OFLO    0x04
+#define OEX_FPU_UFLO    0x02
+#define OEX_FPU_INEX    0x01
+
+/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry.  */
+
+#define OHW_R4KEOP      0x1     /* R4000 end-of-page patch.  */
+#define OHW_R8KPFETCH   0x2     /* may need R8000 prefetch patch.  */
+#define OHW_R5KEOP      0x4     /* R5000 end-of-page patch.  */
+#define OHW_R5KCVTL     0x8     /* R5000 cvt.[ds].l bug.  clean=1.  */
+
+#define OPAD_PREFIX     0x1
+#define OPAD_POSTFIX    0x2
+#define OPAD_SYMBOL     0x4
+
+/* Entry found in `.options' section.  */
+
+typedef struct
+{
+  Elf32_Word hwp_flags1;        /* Extra flags.  */
+  Elf32_Word hwp_flags2;        /* Extra flags.  */
+} Elf_Options_Hw;
+
+/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries.  */
+
+#define OHWA0_R4KEOP_CHECKED    0x00000001
+#define OHWA1_R4KEOP_CLEAN      0x00000002
+
+/* MIPS relocs.  */
+
+#define R_MIPS_NONE             0       /* No reloc */
+#define R_MIPS_16               1       /* Direct 16 bit */
+#define R_MIPS_32               2       /* Direct 32 bit */
+#define R_MIPS_REL32            3       /* PC relative 32 bit */
+#define R_MIPS_26               4       /* Direct 26 bit shifted */
+#define R_MIPS_HI16             5       /* High 16 bit */
+#define R_MIPS_LO16             6       /* Low 16 bit */
+#define R_MIPS_GPREL16          7       /* GP relative 16 bit */
+#define R_MIPS_LITERAL          8       /* 16 bit literal entry */
+#define R_MIPS_GOT16            9       /* 16 bit GOT entry */
+#define R_MIPS_PC16             10      /* PC relative 16 bit */
+#define R_MIPS_CALL16           11      /* 16 bit GOT entry for function */
+#define R_MIPS_GPREL32          12      /* GP relative 32 bit */
+
+#define R_MIPS_SHIFT5           16
+#define R_MIPS_SHIFT6           17
+#define R_MIPS_64               18
+#define R_MIPS_GOT_DISP         19
+#define R_MIPS_GOT_PAGE         20
+#define R_MIPS_GOT_OFST         21
+#define R_MIPS_GOT_HI16         22
+#define R_MIPS_GOT_LO16         23
+#define R_MIPS_SUB              24
+#define R_MIPS_INSERT_A         25
+#define R_MIPS_INSERT_B         26
+#define R_MIPS_DELETE           27
+#define R_MIPS_HIGHER           28
+#define R_MIPS_HIGHEST          29
+#define R_MIPS_CALL_HI16        30
+#define R_MIPS_CALL_LO16        31
+#define R_MIPS_SCN_DISP         32
+#define R_MIPS_REL16            33
+#define R_MIPS_ADD_IMMEDIATE    34
+#define R_MIPS_PJUMP            35
+#define R_MIPS_RELGOT           36
+#define R_MIPS_JALR             37
+/* Keep this the last entry.  */
+#define R_MIPS_NUM              38
+
+/* Legal values for p_type field of Elf32_Phdr.  */
+
+#define PT_MIPS_REGINFO 0x70000000      /* Register usage information */
+#define PT_MIPS_RTPROC  0x70000001      /* Runtime procedure table. */
+#define PT_MIPS_OPTIONS 0x70000002
+
+/* Special program header types.  */
+
+#define PF_MIPS_LOCAL   0x10000000
+
+/* Legal values for d_tag field of Elf32_Dyn.  */
+
+#define DT_MIPS_RLD_VERSION  0x70000001 /* Runtime linker interface version */
+#define DT_MIPS_TIME_STAMP   0x70000002 /* Timestamp */
+#define DT_MIPS_ICHECKSUM    0x70000003 /* Checksum */
+#define DT_MIPS_IVERSION     0x70000004 /* Version string (string tbl index) */
+#define DT_MIPS_FLAGS        0x70000005 /* Flags */
+#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
+#define DT_MIPS_MSYM         0x70000007
+#define DT_MIPS_CONFLICT     0x70000008 /* Address of CONFLICT section */
+#define DT_MIPS_LIBLIST      0x70000009 /* Address of LIBLIST section */
+#define DT_MIPS_LOCAL_GOTNO  0x7000000a /* Number of local GOT entries */
+#define DT_MIPS_CONFLICTNO   0x7000000b /* Number of CONFLICT entries */
+#define DT_MIPS_LIBLISTNO    0x70000010 /* Number of LIBLIST entries */
+#define DT_MIPS_SYMTABNO     0x70000011 /* Number of DYNSYM entries */
+#define DT_MIPS_UNREFEXTNO   0x70000012 /* First external DYNSYM */
+#define DT_MIPS_GOTSYM       0x70000013 /* First GOT entry in DYNSYM */
+#define DT_MIPS_HIPAGENO     0x70000014 /* Number of GOT page table entries */
+#define DT_MIPS_RLD_MAP      0x70000016 /* Address of run time loader map.  */
+#define DT_MIPS_DELTA_CLASS  0x70000017 /* Delta C++ class definition.  */
+#define DT_MIPS_DELTA_CLASS_NO    0x70000018 /* Number of entries in
+                                                DT_MIPS_DELTA_CLASS.  */
+#define DT_MIPS_DELTA_INSTANCE    0x70000019 /* Delta C++ class instances.  */
+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
+                                                DT_MIPS_DELTA_INSTANCE.  */
+#define DT_MIPS_DELTA_RELOC  0x7000001b /* Delta relocations.  */
+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
+                                             DT_MIPS_DELTA_RELOC.  */
+#define DT_MIPS_DELTA_SYM    0x7000001d /* Delta symbols that Delta
+                                           relocations refer to.  */
+#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
+                                           DT_MIPS_DELTA_SYM.  */
+#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
+                                             class declaration.  */
+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
+                                                DT_MIPS_DELTA_CLASSSYM.  */
+#define DT_MIPS_CXX_FLAGS    0x70000022 /* Flags indicating for C++ flavor.  */
+#define DT_MIPS_PIXIE_INIT   0x70000023
+#define DT_MIPS_SYMBOL_LIB   0x70000024
+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
+#define DT_MIPS_OPTIONS      0x70000029 /* Address of .options.  */
+#define DT_MIPS_INTERFACE    0x7000002a /* Address of .interface.  */
+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
+#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
+                                                    function stored in GOT.  */
+#define DT_MIPS_PERF_SUFFIX  0x7000002e /* Default suffix of dso to be added
+                                           by rld on dlopen() calls.  */
+#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
+#define DT_MIPS_GP_VALUE     0x70000030 /* GP value for aux GOTs.  */
+#define DT_MIPS_AUX_DYNAMIC  0x70000031 /* Address of aux .dynamic.  */
+#define DT_MIPS_NUM          0x32
+
+/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry.  */
+
+#define RHF_NONE                   0            /* No flags */
+#define RHF_QUICKSTART             (1 << 0)     /* Use quickstart */
+#define RHF_NOTPOT                 (1 << 1)     /* Hash size not power of 2 */
+#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2)     /* Ignore LD_LIBRARY_PATH */
+#define RHF_NO_MOVE                (1 << 3)
+#define RHF_SGI_ONLY               (1 << 4)
+#define RHF_GUARANTEE_INIT         (1 << 5)
+#define RHF_DELTA_C_PLUS_PLUS      (1 << 6)
+#define RHF_GUARANTEE_START_INIT   (1 << 7)
+#define RHF_PIXIE                  (1 << 8)
+#define RHF_DEFAULT_DELAY_LOAD     (1 << 9)
+#define RHF_REQUICKSTART           (1 << 10)
+#define RHF_REQUICKSTARTED         (1 << 11)
+#define RHF_CORD                   (1 << 12)
+#define RHF_NO_UNRES_UNDEF         (1 << 13)
+#define RHF_RLD_ORDER_SAFE         (1 << 14)
+
+/* Entries found in sections of type SHT_MIPS_LIBLIST.  */
+
+typedef struct
+{
+  Elf32_Word l_name;            /* Name (string table index) */
+  Elf32_Word l_time_stamp;      /* Timestamp */
+  Elf32_Word l_checksum;        /* Checksum */
+  Elf32_Word l_version;         /* Interface version */
+  Elf32_Word l_flags;           /* Flags */
+} Elf32_Lib;
+
+typedef struct
+{
+  Elf64_Word l_name;            /* Name (string table index) */
+  Elf64_Word l_time_stamp;      /* Timestamp */
+  Elf64_Word l_checksum;        /* Checksum */
+  Elf64_Word l_version;         /* Interface version */
+  Elf64_Word l_flags;           /* Flags */
+} Elf64_Lib;
+
+
+/* Legal values for l_flags.  */
+
+#define LL_NONE           0
+#define LL_EXACT_MATCH    (1 << 0)      /* Require exact match */
+#define LL_IGNORE_INT_VER (1 << 1)      /* Ignore interface version */
+#define LL_REQUIRE_MINOR  (1 << 2)
+#define LL_EXPORTS        (1 << 3)
+#define LL_DELAY_LOAD     (1 << 4)
+#define LL_DELTA          (1 << 5)
+
+/* Entries found in sections of type SHT_MIPS_CONFLICT.  */
+
+typedef Elf32_Addr Elf32_Conflict;
+
+
+/* HPPA specific definitions.  */
+
+/* Legal values for e_flags field of Elf32_Ehdr.  */
+
+#define EF_PARISC_TRAPNL        1       /* Trap nil pointer dereference.  */
+#define EF_PARISC_EXT           2       /* Program uses arch. extensions.  */
+#define EF_PARISC_ARCH          0xffff0000 /* Architecture version.  */
+/* Defined values are:
+                                0x020b  PA-RISC 1.0 big-endian
+                                0x0210  PA-RISC 1.1 big-endian
+                                0x028b  PA-RISC 1.0 little-endian
+                                0x0290  PA-RISC 1.1 little-endian
+*/
+
+/* Legal values for sh_type field of Elf32_Shdr.  */
+
+#define SHT_PARISC_GOT          0x70000000 /* GOT for external data.  */
+#define SHT_PARISC_ARCH         0x70000001 /* Architecture extensions.  */
+#define SHT_PARISC_GLOBAL       0x70000002 /* Definition of $global$.  */
+#define SHT_PARISC_MILLI        0x70000003 /* Millicode routines.  */
+#define SHT_PARISC_UNWIND       0x70000004 /* Unwind information.  */
+#define SHT_PARISC_PLT          0x70000005 /* Procedure linkage table.  */
+#define SHT_PARISC_SDATA        0x70000006 /* Short initialized data.  */
+#define SHT_PARISC_SBSS         0x70000007 /* Short uninitialized data.  */
+#define SHT_PARISC_SYMEXTN      0x70000008 /* Argument/relocation info.  */
+#define SHT_PARISC_STUBS        0x70000009 /* Linker stubs.  */
+
+/* Legal values for sh_flags field of Elf32_Shdr.  */
+
+#define SHF_PARISC_GLOBAL       0x10000000 /* Section defines dp.  */
+#define SHF_PARISC_SHORT        0x20000000 /* Section with short addressing. */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
+
+#define STT_PARISC_MILLICODE    13      /* Millicode function entry point.  */
+
+/* HPPA relocs.  */
+
+#define R_PARISC_NONE           0       /* No reloc.  */
+#define R_PARISC_DIR32          1       /* Direct 32-bit reference.  */
+#define R_PARISC_DIR21L         2       /* Left 21 bits of eff. address.  */
+#define R_PARISC_DIR17R         3       /* Right 17 bits of eff. address.  */
+#define R_PARISC_DIR14R         4       /* Right 14 bits of eff. address.  */
+#define R_PARISC_PCREL21L       5       /* PC-relative, left 21 bits.  */
+#define R_PARISC_PCREL14R       6       /* PC-relative, right 14 bits.  */
+#define R_PARISC_PCREL17C       7       /* Conditional PC-relative, ignore
+                                           if displacement > 17bits.  */
+#define R_PARISC_PCREL17F       8       /* Conditional PC-relative, must
+                                           fit in 17bits.  */
+#define R_PARISC_DPREL21L       9       /* DP-relative, left 21 bits.  */
+#define R_PARISC_DPREL14R       10      /* DP-relative, right 14 bits.  */
+#define R_PARISC_DPREL14F       11      /* DP-relative, must bit in 14 bits. */
+#define R_PARISC_DLTREL21L      12      /* DLT-relative, left 21 bits.  */
+#define R_PARISC_DLTREL14R      13      /* DLT-relative, right 14 bits.  */
+#define R_PARISC_DLTREL14F      14      /* DLT-relative, must fit in 14 bits.*/
+#define R_PARISC_DLTIND21L      15      /* DLT-relative indirect, left
+                                           21 bits.  */
+#define R_PARISC_DLTIND14R      16      /* DLT-relative indirect, right
+                                           14 bits.  */
+#define R_PARISC_DLTIND14F      17      /* DLT-relative indirect, must fit
+                                           int 14 bits.  */
+#define R_PARISC_PLABEL32       18      /* Direct 32-bit reference to proc.  */
+
+/* Alpha specific definitions.  */
+
+/* Legal values for e_flags field of Elf64_Ehdr.  */
+
+#define EF_ALPHA_32BIT          1       /* All addresses must be < 2GB.  */
+#define EF_ALPHA_CANRELAX       2       /* Relocations for relaxing exist.  */
+
+/* Legal values for sh_type field of Elf64_Shdr.  */
+
+/* These two are primerily concerned with ECOFF debugging info.  */
+#define SHT_ALPHA_DEBUG         0x70000001
+#define SHT_ALPHA_REGINFO       0x70000002
+
+/* Legal values for sh_flags field of Elf64_Shdr.  */
+
+#define SHF_ALPHA_GPREL         0x10000000
+
+/* Legal values for st_other field of Elf64_Sym.  */
+#define STO_ALPHA_NOPV          0x80    /* No PV required.  */
+#define STO_ALPHA_STD_GPLOAD    0x88    /* PV only used for initial ldgp.  */
+
+/* Alpha relocs.  */
+
+#define R_ALPHA_NONE            0       /* No reloc */
+#define R_ALPHA_REFLONG         1       /* Direct 32 bit */
+#define R_ALPHA_REFQUAD         2       /* Direct 64 bit */
+#define R_ALPHA_GPREL32         3       /* GP relative 32 bit */
+#define R_ALPHA_LITERAL         4       /* GP relative 16 bit w/optimization */
+#define R_ALPHA_LITUSE          5       /* Optimization hint for LITERAL */
+#define R_ALPHA_GPDISP          6       /* Add displacement to GP */
+#define R_ALPHA_BRADDR          7       /* PC+4 relative 23 bit shifted */
+#define R_ALPHA_HINT            8       /* PC+4 relative 16 bit shifted */
+#define R_ALPHA_SREL16          9       /* PC relative 16 bit */
+#define R_ALPHA_SREL32          10      /* PC relative 32 bit */
+#define R_ALPHA_SREL64          11      /* PC relative 64 bit */
+#define R_ALPHA_OP_PUSH         12      /* OP stack push */
+#define R_ALPHA_OP_STORE        13      /* OP stack pop and store */
+#define R_ALPHA_OP_PSUB         14      /* OP stack subtract */
+#define R_ALPHA_OP_PRSHIFT      15      /* OP stack right shift */
+#define R_ALPHA_GPVALUE         16
+#define R_ALPHA_GPRELHIGH       17
+#define R_ALPHA_GPRELLOW        18
+#define R_ALPHA_IMMED_GP_16     19
+#define R_ALPHA_IMMED_GP_HI32   20
+#define R_ALPHA_IMMED_SCN_HI32  21
+#define R_ALPHA_IMMED_BR_HI32   22
+#define R_ALPHA_IMMED_LO32      23
+#define R_ALPHA_COPY            24      /* Copy symbol at runtime */
+#define R_ALPHA_GLOB_DAT        25      /* Create GOT entry */
+#define R_ALPHA_JMP_SLOT        26      /* Create PLT entry */
+#define R_ALPHA_RELATIVE        27      /* Adjust by program base */
+/* Keep this the last entry.  */
+#define R_ALPHA_NUM             28
+
+
+/* PowerPC specific declarations */
+
+/* PowerPC relocations defined by the ABIs */
+#define R_PPC_NONE              0
+#define R_PPC_ADDR32            1       /* 32bit absolute address */
+#define R_PPC_ADDR24            2       /* 26bit address, 2 bits ignored.  */
+#define R_PPC_ADDR16            3       /* 16bit absolute address */
+#define R_PPC_ADDR16_LO         4       /* lower 16bit of absolute address */
+#define R_PPC_ADDR16_HI         5       /* high 16bit of absolute address */
+#define R_PPC_ADDR16_HA         6       /* adjusted high 16bit */
+#define R_PPC_ADDR14            7       /* 16bit address, 2 bits ignored */
+#define R_PPC_ADDR14_BRTAKEN    8
+#define R_PPC_ADDR14_BRNTAKEN   9
+#define R_PPC_REL24             10      /* PC relative 26 bit */
+#define R_PPC_REL14             11      /* PC relative 16 bit */
+#define R_PPC_REL14_BRTAKEN     12
+#define R_PPC_REL14_BRNTAKEN    13
+#define R_PPC_GOT16             14
+#define R_PPC_GOT16_LO          15
+#define R_PPC_GOT16_HI          16
+#define R_PPC_GOT16_HA          17
+#define R_PPC_PLTREL24          18
+#define R_PPC_COPY              19
+#define R_PPC_GLOB_DAT          20
+#define R_PPC_JMP_SLOT          21
+#define R_PPC_RELATIVE          22
+#define R_PPC_LOCAL24PC         23
+#define R_PPC_UADDR32           24
+#define R_PPC_UADDR16           25
+#define R_PPC_REL32             26
+#define R_PPC_PLT32             27
+#define R_PPC_PLTREL32          28
+#define R_PPC_PLT16_LO          29
+#define R_PPC_PLT16_HI          30
+#define R_PPC_PLT16_HA          31
+#define R_PPC_SDAREL16          32
+#define R_PPC_SECTOFF           33
+#define R_PPC_SECTOFF_LO        34
+#define R_PPC_SECTOFF_HI        35
+#define R_PPC_SECTOFF_HA        36
+/* Keep this the last entry.  */
+#define R_PPC_NUM               37
+
+/* The remaining relocs are from the Embedded ELF ABI, and are not
+   in the SVR4 ELF ABI.  */
+#define R_PPC_EMB_NADDR32       101
+#define R_PPC_EMB_NADDR16       102
+#define R_PPC_EMB_NADDR16_LO    103
+#define R_PPC_EMB_NADDR16_HI    104
+#define R_PPC_EMB_NADDR16_HA    105
+#define R_PPC_EMB_SDAI16        106
+#define R_PPC_EMB_SDA2I16       107
+#define R_PPC_EMB_SDA2REL       108
+#define R_PPC_EMB_SDA21         109     /* 16 bit offset in SDA */
+#define R_PPC_EMB_MRKREF        110
+#define R_PPC_EMB_RELSEC16      111
+#define R_PPC_EMB_RELST_LO      112
+#define R_PPC_EMB_RELST_HI      113
+#define R_PPC_EMB_RELST_HA      114
+#define R_PPC_EMB_BIT_FLD       115
+#define R_PPC_EMB_RELSDA        116     /* 16 bit relative offset in SDA */
+
+/* Diab tool relocations.  */
+#define R_PPC_DIAB_SDA21_LO     180     /* like EMB_SDA21, but lower 16 bit */
+#define R_PPC_DIAB_SDA21_HI     181     /* like EMB_SDA21, but high 16 bit */
+#define R_PPC_DIAB_SDA21_HA     182     /* like EMB_SDA21, adjusted high 16 */
+#define R_PPC_DIAB_RELSDA_LO    183     /* like EMB_RELSDA, but lower 16 bit */
+#define R_PPC_DIAB_RELSDA_HI    184     /* like EMB_RELSDA, but high 16 bit */
+#define R_PPC_DIAB_RELSDA_HA    185     /* like EMB_RELSDA, adjusted high 16 */
+
+/* This is a phony reloc to handle any old fashioned TOC16 references
+   that may still be in object files.  */
+#define R_PPC_TOC16             255
+
+
+/* ARM specific declarations */
+
+/* Processor specific flags for the ELF header e_flags field.  */
+#define EF_ARM_RELEXEC     0x01
+#define EF_ARM_HASENTRY    0x02
+#define EF_ARM_INTERWORK   0x04
+#define EF_ARM_APCS_26     0x08
+#define EF_ARM_APCS_FLOAT  0x10
+#define EF_ARM_PIC         0x20
+#define EF_ALIGN8          0x40         /* 8-bit structure alignment is in use */
+#define EF_NEW_ABI         0x80
+#define EF_OLD_ABI         0x100
+
+/* Additional symbol types for Thumb */
+#define STT_ARM_TFUNC      0xd
+
+/* ARM-specific values for sh_flags */
+#define SHF_ARM_ENTRYSECT  0x10000000   /* Section contains an entry point */
+#define SHF_ARM_COMDEF     0x80000000   /* Section may be multiply defined
+                                           in the input to a link step */
+
+/* ARM-specific program header flags */
+#define PF_ARM_SB          0x10000000   /* Segment contains the location
+                                           addressed by the static base */
+
+/* ARM relocs.  */
+#define R_ARM_NONE              0       /* No reloc */
+#define R_ARM_PC24              1       /* PC relative 26 bit branch */
+#define R_ARM_ABS32             2       /* Direct 32 bit  */
+#define R_ARM_REL32             3       /* PC relative 32 bit */
+#define R_ARM_PC13              4
+#define R_ARM_ABS16             5       /* Direct 16 bit */
+#define R_ARM_ABS12             6       /* Direct 12 bit */
+#define R_ARM_THM_ABS5          7
+#define R_ARM_ABS8              8       /* Direct 8 bit */
+#define R_ARM_SBREL32           9
+#define R_ARM_THM_CALL          10
+#define R_ARM_THM_PC8           11
+#define R_ARM_AMP_VCALL9        12
+#define R_ARM_SWI24             13
+#define R_ARM_THM_SWI8          14
+#define R_ARM_XPC25             15
+#define R_ARM_THM_XPC22         16
+#define R_ARM_COPY              20      /* Copy symbol at runtime */
+#define R_ARM_GLOB_DAT          21      /* Create GOT entry */
+#define R_ARM_JUMP_SLOT         22      /* Create PLT entry */
+#define R_ARM_RELATIVE          23      /* Adjust by program base */
+#define R_ARM_GOTOFF32          24      /* 32 bit offset to GOT */
+#define R_ARM_BASE_PREL         25      /* 32 bit PC relative offset to GOT */
+#define R_ARM_GOT_BREL          26      /* 32 bit GOT entry */
+#define R_ARM_PLT32             27      /* 32 bit PLT address */
+#define R_ARM_CALL              28
+#define R_ARM_JUMP24            29
+#define R_ARM_THM_JUMP24        30
+#define R_ARM_V4BX              40
+#define R_ARM_PREL31            42
+#define R_ARM_MOVW_ABS_NC       43
+#define R_ARM_MOVT_ABS          44
+#define R_ARM_THM_MOVW_ABS_NC   47
+#define R_ARM_THM_MOVT_ABS      48
+#define R_ARM_GNU_VTENTRY       100
+#define R_ARM_GNU_VTINHERIT     101
+#define R_ARM_THM_PC11          102     /* thumb unconditional branch */
+#define R_ARM_THM_PC9           103     /* thumb conditional branch */
+#define R_ARM_RXPC25            249
+#define R_ARM_RSBREL32          250
+#define R_ARM_THM_RPC22         251
+#define R_ARM_RREL32            252
+#define R_ARM_RABS22            253
+#define R_ARM_RPC24             254
+#define R_ARM_RBASE             255
+/* Keep this the last entry.  */
+#define R_ARM_NUM               256
+
+/* TMS320C67xx specific declarations */
+/* XXX: no ELF standard yet */
+
+/* TMS320C67xx relocs. */
+#define R_C60_32       1
+#define R_C60_GOT32     3               /* 32 bit GOT entry */
+#define R_C60_PLT32     4               /* 32 bit PLT address */
+#define R_C60_COPY      5               /* Copy symbol at runtime */
+#define R_C60_GLOB_DAT  6               /* Create GOT entry */
+#define R_C60_JMP_SLOT  7               /* Create PLT entry */
+#define R_C60_RELATIVE  8               /* Adjust by program base */
+#define R_C60_GOTOFF    9               /* 32 bit offset to GOT */
+#define R_C60_GOTPC     10              /* 32 bit PC relative offset to GOT */
+
+#define R_C60HI16      0x55       // high 16 bit MVKH embedded
+#define R_C60LO16      0x54       // low 16 bit MVKL embedded
+
+#endif  /* elf.h */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex1.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex1.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex1.c	(revision 279)
@@ -0,0 +1,8 @@
+#!/usr/local/bin/tcc -run
+#include <tcclib.h>
+
+int main()
+{
+    printf("Hello World\n");
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex2.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex2.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex2.c	(revision 279)
@@ -0,0 +1,98 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#define N 20
+
+int nb_num;
+int tab[N];
+int stack_ptr;
+int stack_op[N];
+int stack_res[60];
+int result;
+
+int find(int n, int i1, int a, int b, int op)
+{
+    int i, j;
+    int c;
+
+    if (stack_ptr >= 0) {
+        stack_res[3*stack_ptr] = a;
+        stack_op[stack_ptr] = op;
+        stack_res[3*stack_ptr+1] = b;
+        stack_res[3*stack_ptr+2] = n;
+        if (n == result)
+            return 1;
+        tab[i1] = n;
+    }
+
+    for(i=0;i<nb_num;i++) {
+        for(j=i+1;j<nb_num;j++) {
+            a = tab[i];
+            b = tab[j];
+            if (a != 0 && b != 0) {
+
+                tab[j] = 0;
+                stack_ptr++;
+
+                if (find(a + b, i, a, b, '+'))
+                    return 1;
+                if (find(a - b, i, a, b, '-'))
+                    return 1;
+                if (find(b - a, i, b, a, '-'))
+                    return 1;
+                if (find(a * b, i, a, b, '*'))
+                    return 1;
+                if (b != 0) {
+                    c = a / b;
+                    if (find(c, i, a, b, '/'))
+                        return 1;
+                }
+
+                if (a != 0) {
+                    c = b / a;
+                    if (find(c, i, b, a, '/'))
+                        return 1;
+                }
+
+                stack_ptr--;
+                tab[i] = a;
+                tab[j] = b;
+            }
+        }
+    }
+
+    return 0;
+}
+
+int main(int argc, char **argv)
+{
+    int i, res, p;
+
+    if (argc < 3) {
+        printf("usage: %s: result numbers...\n"
+               "Try to find result from numbers with the 4 basic operations.\n", argv[0]);
+        exit(1);
+    }
+
+    p = 1;
+    result = atoi(argv[p]);
+    printf("result=%d\n", result);
+    nb_num = 0;
+    for(i=p+1;i<argc;i++) {
+        tab[nb_num++] = atoi(argv[i]);
+    }
+
+    stack_ptr = -1;
+    res = find(0, 0, 0, 0, ' ');
+    if (res) {
+        for(i=0;i<=stack_ptr;i++) {
+            printf("%d %c %d = %d\n",
+                   stack_res[3*i], stack_op[i],
+                   stack_res[3*i+1], stack_res[3*i+2]);
+        }
+        return 0;
+    } else {
+        printf("Impossible\n");
+        return 1;
+    }
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex3.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex3.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex3.c	(revision 279)
@@ -0,0 +1,24 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int fib(n)
+{
+    if (n <= 2)
+        return 1;
+    else
+        return fib(n-1) + fib(n-2);
+}
+
+int main(int argc, char **argv)
+{
+    int n;
+    if (argc < 2) {
+        printf("usage: fib n\n"
+               "Compute nth Fibonacci number\n");
+        return 1;
+    }
+
+    n = atoi(argv[1]);
+    printf("fib(%d) = %d\n", n, fib(n, 2));
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex4.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex4.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex4.c	(revision 279)
@@ -0,0 +1,26 @@
+#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
+#include <stdlib.h>
+#include <stdio.h>
+#include <X11/Xlib.h>
+
+/* Yes, TCC can use X11 too ! */
+
+int main(int argc, char **argv)
+{
+    Display *display;
+    Screen *screen;
+
+    display = XOpenDisplay("");
+    if (!display) {
+        fprintf(stderr, "Could not open X11 display\n");
+        exit(1);
+    }
+    printf("X11 display opened.\n");
+    screen = XScreenOfDisplay(display, 0);
+    printf("width = %d\nheight = %d\ndepth = %d\n",
+           screen->width,
+           screen->height,
+           screen->root_depth);
+    XCloseDisplay(display);
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex5.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex5.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/examples/ex5.c	(revision 279)
@@ -0,0 +1,8 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int main()
+{
+    printf("Hello World\n");
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/i386-asm.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/i386-asm.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/i386-asm.c	(revision 279)
@@ -0,0 +1,1498 @@
+/*
+ *  i386 specific functions for TCC assembler
+ *
+ *  Copyright (c) 2001, 2002 Fabrice Bellard
+ *  Copyright (c) 2009 Frédéric Feret (x86_64 support)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+// #define NB_ASM_REGS 8
+#define MAX_OPERANDS 3
+#define NB_SAVED_REGS 3
+
+#define TOK_ASM_first TOK_ASM_clc
+#define TOK_ASM_last TOK_ASM_emms
+
+#define OPC_JMP        0x01  /* jmp operand */
+#define OPC_B          0x02  /* only used with OPC_WL */
+#define OPC_WL         0x04  /* accepts w, l or no suffix */
+#define OPC_BWL        (OPC_B | OPC_WL) /* accepts b, w, l or no suffix */
+#define OPC_REG        0x08 /* register is added to opcode */
+#define OPC_MODRM      0x10 /* modrm encoding */
+#define OPC_FWAIT      0x20 /* add fwait opcode */
+#define OPC_TEST       0x40 /* test opcodes */
+#define OPC_SHIFT      0x80 /* shift opcodes */
+#define OPC_D16      0x0100 /* generate data16 prefix */
+#define OPC_ARITH    0x0200 /* arithmetic opcodes */
+#define OPC_SHORTJMP 0x0400 /* short jmp operand */
+#define OPC_FARITH   0x0800 /* FPU arithmetic opcodes */
+#ifdef TCC_TARGET_X86_64
+# define OPC_WLQ     0x1000  /* accepts w, l, q or no suffix */
+# define OPC_BWLQ    (OPC_B | OPC_WLQ) /* accepts b, w, l, q or no suffix */
+# define OPC_WLX     OPC_WLQ
+#else
+# define OPC_WLX     OPC_WL
+#endif
+
+#define OPC_GROUP_SHIFT 13
+
+/* in order to compress the operand type, we use specific operands and
+   we or only with EA  */
+enum {
+    OPT_REG8=0, /* warning: value is hardcoded from TOK_ASM_xxx */
+    OPT_REG16,  /* warning: value is hardcoded from TOK_ASM_xxx */
+    OPT_REG32,  /* warning: value is hardcoded from TOK_ASM_xxx */
+#ifdef TCC_TARGET_X86_64
+    OPT_REG64,  /* warning: value is hardcoded from TOK_ASM_xxx */
+#endif
+    OPT_MMX,    /* warning: value is hardcoded from TOK_ASM_xxx */
+    OPT_SSE,    /* warning: value is hardcoded from TOK_ASM_xxx */
+    OPT_CR,     /* warning: value is hardcoded from TOK_ASM_xxx */
+    OPT_TR,     /* warning: value is hardcoded from TOK_ASM_xxx */
+    OPT_DB,     /* warning: value is hardcoded from TOK_ASM_xxx */
+    OPT_SEG,
+    OPT_ST,
+    OPT_IM8,
+    OPT_IM8S,
+    OPT_IM16,
+    OPT_IM32,
+#ifdef TCC_TARGET_X86_64
+    OPT_IM64,
+#endif
+    OPT_EAX,    /* %al, %ax, %eax or %rax register */
+    OPT_ST0,    /* %st(0) register */
+    OPT_CL,     /* %cl register */
+    OPT_DX,     /* %dx register */
+    OPT_ADDR,   /* OP_EA with only offset */
+    OPT_INDIR,  /* *(expr) */
+    /* composite types */
+    OPT_COMPOSITE_FIRST,
+    OPT_IM,     /* IM8 | IM16 | IM32 | IM64 */
+    OPT_REG,    /* REG8 | REG16 | REG32 | REG64 */
+    OPT_REGW,   /* REG16 | REG32 | REG64 */
+    OPT_IMW,    /* IM16 | IM32 | IM64 */
+#ifdef TCC_TARGET_X86_64
+    OPT_IMNO64, /* IM16 | IM32 */
+#endif
+    /* can be ored with any OPT_xxx */
+    OPT_EA = 0x80
+};
+
+#define OP_REG8   (1 << OPT_REG8)
+#define OP_REG16  (1 << OPT_REG16)
+#define OP_REG32  (1 << OPT_REG32)
+#define OP_MMX    (1 << OPT_MMX)
+#define OP_SSE    (1 << OPT_SSE)
+#define OP_CR     (1 << OPT_CR)
+#define OP_TR     (1 << OPT_TR)
+#define OP_DB     (1 << OPT_DB)
+#define OP_SEG    (1 << OPT_SEG)
+#define OP_ST     (1 << OPT_ST)
+#define OP_IM8    (1 << OPT_IM8)
+#define OP_IM8S   (1 << OPT_IM8S)
+#define OP_IM16   (1 << OPT_IM16)
+#define OP_IM32   (1 << OPT_IM32)
+#define OP_EAX    (1 << OPT_EAX)
+#define OP_ST0    (1 << OPT_ST0)
+#define OP_CL     (1 << OPT_CL)
+#define OP_DX     (1 << OPT_DX)
+#define OP_ADDR   (1 << OPT_ADDR)
+#define OP_INDIR  (1 << OPT_INDIR)
+#ifdef TCC_TARGET_X86_64
+# define OP_REG64  (1 << OPT_REG64)
+# define OP_IM64   (1 << OPT_IM64)
+#else
+# define OP_REG64 0
+# define OP_IM64  0
+#endif
+
+#define OP_EA     0x40000000
+#define OP_REG    (OP_REG8 | OP_REG16 | OP_REG32 | OP_REG64)
+
+#ifdef TCC_TARGET_X86_64
+# define OP_IM      OP_IM64
+# define TREG_XAX   TREG_RAX
+# define TREG_XCX   TREG_RCX
+# define TREG_XDX   TREG_RDX
+#else
+# define OP_IM      OP_IM32
+# define TREG_XAX   TREG_EAX
+# define TREG_XCX   TREG_ECX
+# define TREG_XDX   TREG_EDX
+#endif
+
+typedef struct ASMInstr {
+    uint16_t sym;
+    uint16_t opcode;
+    uint16_t instr_type;
+    uint8_t nb_ops;
+    uint8_t op_type[MAX_OPERANDS]; /* see OP_xxx */
+} ASMInstr;
+
+typedef struct Operand {
+    uint32_t type;
+    int8_t  reg; /* register, -1 if none */
+    int8_t  reg2; /* second register, -1 if none */
+    uint8_t shift;
+    ExprValue e;
+} Operand;
+
+static const uint8_t reg_to_size[9] = {
+/*
+    [OP_REG8] = 0,
+    [OP_REG16] = 1,
+    [OP_REG32] = 2,
+#ifdef TCC_TARGET_X86_64
+    [OP_REG64] = 3,
+#endif
+*/
+    0, 0, 1, 0, 2, 0, 0, 0, 3
+};
+
+#define NB_TEST_OPCODES 30
+
+static const uint8_t test_bits[NB_TEST_OPCODES] = {
+ 0x00, /* o */
+ 0x01, /* no */
+ 0x02, /* b */
+ 0x02, /* c */
+ 0x02, /* nae */
+ 0x03, /* nb */
+ 0x03, /* nc */
+ 0x03, /* ae */
+ 0x04, /* e */
+ 0x04, /* z */
+ 0x05, /* ne */
+ 0x05, /* nz */
+ 0x06, /* be */
+ 0x06, /* na */
+ 0x07, /* nbe */
+ 0x07, /* a */
+ 0x08, /* s */
+ 0x09, /* ns */
+ 0x0a, /* p */
+ 0x0a, /* pe */
+ 0x0b, /* np */
+ 0x0b, /* po */
+ 0x0c, /* l */
+ 0x0c, /* nge */
+ 0x0d, /* nl */
+ 0x0d, /* ge */
+ 0x0e, /* le */
+ 0x0e, /* ng */
+ 0x0f, /* nle */
+ 0x0f, /* g */
+};
+
+static const uint8_t segment_prefixes[] = {
+ 0x26, /* es */
+ 0x2e, /* cs */
+ 0x36, /* ss */
+ 0x3e, /* ds */
+ 0x64, /* fs */
+ 0x65  /* gs */
+};
+
+static const ASMInstr asm_instrs[] = {
+#define ALT(x) x
+#define DEF_ASM_OP0(name, opcode)
+#define DEF_ASM_OP0L(name, opcode, group, instr_type) { TOK_ASM_ ## name, opcode, (instr_type | group << OPC_GROUP_SHIFT), 0 },
+#define DEF_ASM_OP1(name, opcode, group, instr_type, op0) { TOK_ASM_ ## name, opcode, (instr_type | group << OPC_GROUP_SHIFT), 1, { op0 }},
+#define DEF_ASM_OP2(name, opcode, group, instr_type, op0, op1) { TOK_ASM_ ## name, opcode, (instr_type | group << OPC_GROUP_SHIFT), 2, { op0, op1 }},
+#define DEF_ASM_OP3(name, opcode, group, instr_type, op0, op1, op2) { TOK_ASM_ ## name, opcode, (instr_type | group << OPC_GROUP_SHIFT), 3, { op0, op1, op2 }},
+#ifdef TCC_TARGET_X86_64
+# include "x86_64-asm.h"
+#else
+# include "i386-asm.h"
+#endif
+    /* last operation */
+    { 0, },
+};
+
+static const uint16_t op0_codes[] = {
+#define ALT(x)
+#define DEF_ASM_OP0(x, opcode) opcode,
+#define DEF_ASM_OP0L(name, opcode, group, instr_type)
+#define DEF_ASM_OP1(name, opcode, group, instr_type, op0)
+#define DEF_ASM_OP2(name, opcode, group, instr_type, op0, op1)
+#define DEF_ASM_OP3(name, opcode, group, instr_type, op0, op1, op2)
+#ifdef TCC_TARGET_X86_64
+# include "x86_64-asm.h"
+#else
+# include "i386-asm.h"
+#endif
+};
+
+static inline int get_reg_shift(TCCState *s1)
+{
+    int shift, v;
+#ifdef I386_ASM_16
+    if (s1->seg_size == 16)
+        tcc_error("invalid effective address");
+#endif
+    v = asm_int_expr(s1);
+    switch(v) {
+    case 1:
+        shift = 0;
+        break;
+    case 2:
+        shift = 1;
+        break;
+    case 4:
+        shift = 2;
+        break;
+    case 8:
+        shift = 3;
+        break;
+    default:
+        expect("1, 2, 4 or 8 constant");
+        shift = 0;
+        break;
+    }
+    return shift;
+}
+
+static int asm_parse_reg(void)
+{
+    int reg = 0;
+    if (tok != '%')
+        goto error_32;
+    next();
+    if (tok >= TOK_ASM_eax && tok <= TOK_ASM_edi) {
+        reg = tok - TOK_ASM_eax;
+#ifdef TCC_TARGET_X86_64
+    } else if (tok >= TOK_ASM_rax && tok <= TOK_ASM_rdi) {
+        reg = tok - TOK_ASM_rax;
+#endif
+#ifdef I386_ASM_16
+    } else if (tok >= TOK_ASM_ax && tok <= TOK_ASM_di) {
+        reg = tok - TOK_ASM_ax;
+#endif
+    } else {
+    error_32:
+        expect("register");
+    }
+    next();
+    return reg;
+}
+
+static void parse_operand(TCCState *s1, Operand *op)
+{
+    ExprValue e;
+    int reg, indir;
+    const char *p;
+
+    indir = 0;
+    if (tok == '*') {
+        next();
+        indir = OP_INDIR;
+    }
+
+    if (tok == '%') {
+        next();
+        if (tok >= TOK_ASM_al && tok <= TOK_ASM_db7) {
+            reg = tok - TOK_ASM_al;
+            op->type = 1 << (reg >> 3); /* WARNING: do not change constant order */
+            op->reg = reg & 7;
+            if ((op->type & OP_REG) && op->reg == TREG_XAX)
+                op->type |= OP_EAX;
+            else if (op->type == OP_REG8 && op->reg == TREG_XCX)
+                op->type |= OP_CL;
+            else if (op->type == OP_REG16 && op->reg == TREG_XDX)
+                op->type |= OP_DX;
+        } else if (tok >= TOK_ASM_dr0 && tok <= TOK_ASM_dr7) {
+            op->type = OP_DB;
+            op->reg = tok - TOK_ASM_dr0;
+        } else if (tok >= TOK_ASM_es && tok <= TOK_ASM_gs) {
+            op->type = OP_SEG;
+            op->reg = tok - TOK_ASM_es;
+        } else if (tok == TOK_ASM_st) {
+            op->type = OP_ST;
+            op->reg = 0;
+            next();
+            if (tok == '(') {
+                next();
+                if (tok != TOK_PPNUM)
+                    goto reg_error;
+                p = tokc.cstr->data;
+                reg = p[0] - '0';
+                if ((unsigned)reg >= 8 || p[1] != '\0')
+                    goto reg_error;
+                op->reg = reg;
+                next();
+                skip(')');
+            }
+            if (op->reg == 0)
+                op->type |= OP_ST0;
+            goto no_skip;
+        } else {
+        reg_error:
+            tcc_error("unknown register");
+        }
+        next();
+    no_skip: ;
+    } else if (tok == '$') {
+        /* constant value */
+        next();
+        asm_expr(s1, &e);
+        op->type = OP_IM;
+        op->e.v = e.v;
+        op->e.sym = e.sym;
+        if (!op->e.sym) {
+            if (op->e.v == (uint8_t)op->e.v)
+                op->type |= OP_IM8;
+            if (op->e.v == (int8_t)op->e.v)
+                op->type |= OP_IM8S;
+            if (op->e.v == (uint16_t)op->e.v)
+                op->type |= OP_IM16;
+#ifdef TCC_TARGET_X86_64
+            if (op->e.v == (uint32_t)op->e.v)
+                op->type |= OP_IM32;
+#endif
+        }
+    } else {
+        /* address(reg,reg2,shift) with all variants */
+        op->type = OP_EA;
+        op->reg = -1;
+        op->reg2 = -1;
+        op->shift = 0;
+        if (tok != '(') {
+            asm_expr(s1, &e);
+            op->e.v = e.v;
+            op->e.sym = e.sym;
+        } else {
+            next();
+            if (tok == '%') {
+                unget_tok('(');
+                op->e.v = 0;
+                op->e.sym = NULL;
+            } else {
+                /* bracketed offset expression */
+                asm_expr(s1, &e);
+                if (tok != ')')
+                    expect(")");
+                next();
+                op->e.v = e.v;
+                op->e.sym = e.sym;
+            }
+        }
+        if (tok == '(') {
+            next();
+            if (tok != ',') {
+                op->reg = asm_parse_reg();
+            }
+            if (tok == ',') {
+                next();
+                if (tok != ',') {
+                    op->reg2 = asm_parse_reg();
+                }
+                if (tok == ',') {
+                    next();
+                    op->shift = get_reg_shift(s1);
+                }
+            }
+            skip(')');
+        }
+        if (op->reg == -1 && op->reg2 == -1)
+            op->type |= OP_ADDR;
+    }
+    op->type |= indir;
+}
+
+/* XXX: unify with C code output ? */
+ST_FUNC void gen_expr32(ExprValue *pe)
+{
+    gen_addr32(pe->sym ? VT_SYM : 0, pe->sym, pe->v);
+}
+
+#ifdef TCC_TARGET_X86_64
+static void gen_expr64(ExprValue *pe)
+{
+    gen_addr64(pe->sym ? VT_SYM : 0, pe->sym, pe->v);
+}
+#endif
+
+/* XXX: unify with C code output ? */
+static void gen_disp32(ExprValue *pe)
+{
+    Sym *sym = pe->sym;
+    if (sym && sym->r == cur_text_section->sh_num) {
+        /* same section: we can output an absolute value. Note
+           that the TCC compiler behaves differently here because
+           it always outputs a relocation to ease (future) code
+           elimination in the linker */
+        gen_le32(pe->v + sym->jnext - ind - 4);
+    } else {
+        if (sym && sym->type.t == VT_VOID) {
+            sym->type.t = VT_FUNC;
+            sym->type.ref = NULL;
+        }
+        gen_addrpc32(VT_SYM, sym, pe->v);
+    }
+}
+
+#ifdef I386_ASM_16
+static void gen_expr16(ExprValue *pe)
+{
+    if (pe->sym)
+        greloc(cur_text_section, pe->sym, ind, R_386_16);
+    gen_le16(pe->v);
+}
+static void gen_disp16(ExprValue *pe)
+{
+    Sym *sym;
+    sym = pe->sym;
+    if (sym) {
+        if (sym->r == cur_text_section->sh_num) {
+            /* same section: we can output an absolute value. Note
+               that the TCC compiler behaves differently here because
+               it always outputs a relocation to ease (future) code
+               elimination in the linker */
+            gen_le16(pe->v + sym->jnext - ind - 2);
+        } else {
+            greloc(cur_text_section, sym, ind, R_386_PC16);
+            gen_le16(pe->v - 2);
+        }
+    } else {
+        /* put an empty PC32 relocation */
+        put_elf_reloc(symtab_section, cur_text_section,
+                      ind, R_386_PC16, 0);
+        gen_le16(pe->v - 2);
+    }
+}
+#endif
+
+/* generate the modrm operand */
+static inline void asm_modrm(int reg, Operand *op)
+{
+    int mod, reg1, reg2, sib_reg1;
+
+    if (op->type & (OP_REG | OP_MMX | OP_SSE)) {
+        g(0xc0 + (reg << 3) + op->reg);
+    } else if (op->reg == -1 && op->reg2 == -1) {
+        /* displacement only */
+#ifdef I386_ASM_16
+        if (tcc_state->seg_size == 16) {
+            g(0x06 + (reg << 3));
+            gen_expr16(&op->e);
+        } else if (tcc_state->seg_size == 32)
+#endif
+        {
+            g(0x05 + (reg << 3));
+            gen_expr32(&op->e);
+        }
+    } else {
+        sib_reg1 = op->reg;
+        /* fist compute displacement encoding */
+        if (sib_reg1 == -1) {
+            sib_reg1 = 5;
+            mod = 0x00;
+        } else if (op->e.v == 0 && !op->e.sym && op->reg != 5) {
+            mod = 0x00;
+        } else if (op->e.v == (int8_t)op->e.v && !op->e.sym) {
+            mod = 0x40;
+        } else {
+            mod = 0x80;
+        }
+        /* compute if sib byte needed */
+        reg1 = op->reg;
+        if (op->reg2 != -1)
+            reg1 = 4;
+#ifdef I386_ASM_16
+        if (tcc_state->seg_size == 32) {
+#endif
+        g(mod + (reg << 3) + reg1);
+        if (reg1 == 4) {
+            /* add sib byte */
+            reg2 = op->reg2;
+            if (reg2 == -1)
+                reg2 = 4; /* indicate no index */
+            g((op->shift << 6) + (reg2 << 3) + sib_reg1);
+        }
+#ifdef I386_ASM_16
+        } else if (tcc_state->seg_size == 16) {
+            /* edi = 7, esi = 6 --> di = 5, si = 4 */
+            if ((reg1 == 6) || (reg1 == 7)) {
+                reg1 -= 2;
+            /* ebx = 3 --> bx = 7 */
+            } else if (reg1 == 3) {
+                reg1 = 7;
+            /* o32 = 5 --> o16 = 6 */
+            } else if (reg1 == 5) {
+                reg1 = 6;
+            /* sib not valid in 16-bit mode */
+            } else if (reg1 == 4) {
+                reg2 = op->reg2;
+		/* bp + si + offset */
+		if ((sib_reg1 == 5) && (reg2 == 6)) {
+		    reg1 = 2;
+		/* bp + di + offset */
+		} else if ((sib_reg1 == 5) && (reg2 == 7)) {
+		    reg1 = 3;
+		/* bx + si + offset */
+		} else if ((sib_reg1 == 3) && (reg2 == 6)) {
+		    reg1 = 0;
+		/* bx + di + offset */
+		} else if ((sib_reg1 == 3) && (reg2 == 7)) {
+		    reg1 = 1;
+		} else {
+		    tcc_error("invalid effective address");
+		}
+		if (op->e.v == 0)
+		    mod = 0;
+            } else {
+                tcc_error("invalid register");
+            }
+            g(mod + (reg << 3) + reg1);
+        }
+#endif
+        /* add offset */
+        if (mod == 0x40) {
+            g(op->e.v);
+        } else if (mod == 0x80 || op->reg == -1) {
+#ifdef I386_ASM_16
+            if (tcc_state->seg_size == 16)
+                gen_expr16(&op->e);
+            else if (tcc_state->seg_size == 32)
+#endif
+                gen_expr32(&op->e);
+        }
+    }
+}
+
+ST_FUNC void asm_opcode(TCCState *s1, int opcode)
+{
+    const ASMInstr *pa;
+    int i, modrm_index, reg, v, op1, is_short_jmp, seg_prefix;
+    int nb_ops, s;
+    Operand ops[MAX_OPERANDS], *pop;
+    int op_type[3]; /* decoded op type */
+#ifdef I386_ASM_16
+    static int a32 = 0, o32 = 0, addr32 = 0, data32 = 0;
+#endif
+
+    /* force synthetic ';' after prefix instruction, so we can handle */
+    /* one-line things like "rep stosb" instead of only "rep\nstosb" */
+    if (opcode >= TOK_ASM_wait && opcode <= TOK_ASM_repnz)
+        unget_tok(';');
+
+    /* get operands */
+    pop = ops;
+    nb_ops = 0;
+    seg_prefix = 0;
+    for(;;) {
+        if (tok == ';' || tok == TOK_LINEFEED)
+            break;
+        if (nb_ops >= MAX_OPERANDS) {
+            tcc_error("incorrect number of operands");
+        }
+        parse_operand(s1, pop);
+        if (tok == ':') {
+           if (pop->type != OP_SEG || seg_prefix)
+               tcc_error("incorrect prefix");
+           seg_prefix = segment_prefixes[pop->reg];
+           next();
+           parse_operand(s1, pop);
+#ifndef I386_ASM_16
+           if (!(pop->type & OP_EA)) {
+               tcc_error("segment prefix must be followed by memory reference");
+           }
+#endif
+        }
+        pop++;
+        nb_ops++;
+        if (tok != ',')
+            break;
+        next();
+    }
+
+    is_short_jmp = 0;
+    s = 0; /* avoid warning */
+
+    /* optimize matching by using a lookup table (no hashing is needed
+       !) */
+    for(pa = asm_instrs; pa->sym != 0; pa++) {
+        s = 0;
+        if (pa->instr_type & OPC_FARITH) {
+            v = opcode - pa->sym;
+            if (!((unsigned)v < 8 * 6 && (v % 6) == 0))
+                continue;
+        } else if (pa->instr_type & OPC_ARITH) {
+            if (!(opcode >= pa->sym && opcode < pa->sym + 8*NBWLX))
+                continue;
+            s = (opcode - pa->sym) % NBWLX;
+        } else if (pa->instr_type & OPC_SHIFT) {
+            if (!(opcode >= pa->sym && opcode < pa->sym + 7*NBWLX))
+                continue;
+            s = (opcode - pa->sym) % NBWLX;
+        } else if (pa->instr_type & OPC_TEST) {
+            if (!(opcode >= pa->sym && opcode < pa->sym + NB_TEST_OPCODES))
+                continue;
+        } else if (pa->instr_type & OPC_B) {
+            if (!(opcode >= pa->sym && opcode < pa->sym + NBWLX))
+                continue;
+            s = opcode - pa->sym;
+        } else if (pa->instr_type & OPC_WLX) {
+            if (!(opcode >= pa->sym && opcode < pa->sym + NBWLX-1))
+                continue;
+            s = opcode - pa->sym + 1;
+        } else {
+            if (pa->sym != opcode)
+                continue;
+        }
+        if (pa->nb_ops != nb_ops)
+            continue;
+        /* now decode and check each operand */
+        for(i = 0; i < nb_ops; i++) {
+            int op1, op2;
+            op1 = pa->op_type[i];
+            op2 = op1 & 0x1f;
+            switch(op2) {
+            case OPT_IM:
+                v = OP_IM8 | OP_IM16 | OP_IM32 | OP_IM64;
+                break;
+            case OPT_REG:
+                v = OP_REG8 | OP_REG16 | OP_REG32 | OP_REG64;
+                break;
+            case OPT_REGW:
+                v = OP_REG16 | OP_REG32 | OP_REG64;
+                break;
+            case OPT_IMW:
+                v = OP_IM16 | OP_IM32 | OP_IM64;
+                break;
+#ifdef TCC_TARGET_X86_64
+            case OPT_IMNO64:
+                v = OP_IM16 | OP_IM32;
+                break;
+#endif
+            default:
+                v = 1 << op2;
+                break;
+            }
+            if (op1 & OPT_EA)
+                v |= OP_EA;
+            op_type[i] = v;
+            if ((ops[i].type & v) == 0)
+                goto next;
+        }
+        /* all is matching ! */
+        break;
+    next: ;
+    }
+    if (pa->sym == 0) {
+        if (opcode >= TOK_ASM_first && opcode <= TOK_ASM_last) {
+            int b;
+            b = op0_codes[opcode - TOK_ASM_first];
+#ifdef I386_ASM_16
+            if (opcode == TOK_ASM_o32) {
+                if (s1->seg_size == 32)
+                    tcc_error("incorrect prefix");
+                else
+                    o32 = data32 = 1;
+            } else if (opcode == TOK_ASM_a32) {
+                if (s1->seg_size == 32)
+                    tcc_error("incorrect prefix");
+                else
+                    a32 = addr32 = 1;
+            }
+#endif
+            if (b & 0xff00) 
+                g(b >> 8);
+            g(b);
+            return;
+        } else {
+            tcc_error("unknown opcode '%s'",
+                  get_tok_str(opcode, NULL));
+        }
+    }
+    /* if the size is unknown, then evaluate it (OPC_B or OPC_WL case) */
+    if (s == NBWLX-1) {
+        for(i = 0; s == NBWLX-1 && i < nb_ops; i++) {
+            if ((ops[i].type & OP_REG) && !(op_type[i] & (OP_CL | OP_DX)))
+                s = reg_to_size[ops[i].type & OP_REG];
+        }
+        if (s == NBWLX-1) {
+            if ((opcode == TOK_ASM_push || opcode == TOK_ASM_pop) &&
+                (ops[0].type & (OP_SEG | OP_IM8S | OP_IM32 | OP_IM64)))
+                s = 2;
+            else
+                tcc_error("cannot infer opcode suffix");
+        }
+    }
+
+#ifdef I386_ASM_16
+    for(i = 0; i < nb_ops; i++) {
+        if (ops[i].type & OP_REG32) {
+            if (s1->seg_size == 16)
+                o32 = 1;
+        } else if (!(ops[i].type & OP_REG32)) {
+            if (s1->seg_size == 32)
+                o32 = 1;
+        }
+    }
+
+
+    if (s == 1 || (pa->instr_type & OPC_D16)) {
+        if (s1->seg_size == 32)
+            o32 = 1;
+    } else if (s == 2) {
+        if (s1->seg_size == 16) {
+            if (!(pa->instr_type & OPC_D16))
+            o32 = 1;
+        }
+    }
+
+    /* generate a16/a32 prefix if needed */
+    if ((a32 == 1) && (addr32 == 0))
+        g(0x67);
+    /* generate o16/o32 prefix if needed */
+    if ((o32 == 1) && (data32 == 0))
+        g(0x66);
+
+    addr32 = data32 = 0;
+#else
+    /* generate data16 prefix if needed */
+    if (s == 1 || (pa->instr_type & OPC_D16))
+        g(0x66);
+#ifdef TCC_TARGET_X86_64
+    else if (s == 3) {
+        /* generate REX prefix */
+        if ((opcode != TOK_ASM_push && opcode != TOK_ASM_pop)
+            || !(ops[0].type & OP_REG64))
+            g(0x48);
+    }
+#endif
+#endif
+
+    /* now generates the operation */
+    if (pa->instr_type & OPC_FWAIT)
+        g(0x9b);
+    if (seg_prefix)
+        g(seg_prefix);
+
+    v = pa->opcode;
+    if ((v == 0x69 || v == 0x6b) && nb_ops == 2) {
+        /* kludge for imul $im, %reg */
+        nb_ops = 3;
+        ops[2] = ops[1];
+        op_type[2] = op_type[1];
+    } else if (v == 0xcd && ops[0].e.v == 3 && !ops[0].e.sym) {
+        v--; /* int $3 case */
+        nb_ops = 0;
+    } else if ((v == 0x06 || v == 0x07)) {
+        if (ops[0].reg >= 4) {
+            /* push/pop %fs or %gs */
+            v = 0x0fa0 + (v - 0x06) + ((ops[0].reg - 4) << 3);
+        } else {
+            v += ops[0].reg << 3;
+        }
+        nb_ops = 0;
+    } else if (v <= 0x05) {
+        /* arith case */
+        v += ((opcode - TOK_ASM_addb) / NBWLX) << 3;
+    } else if ((pa->instr_type & (OPC_FARITH | OPC_MODRM)) == OPC_FARITH) {
+        /* fpu arith case */
+        v += ((opcode - pa->sym) / 6) << 3;
+    }
+    if (pa->instr_type & OPC_REG) {
+        for(i = 0; i < nb_ops; i++) {
+            if (op_type[i] & (OP_REG | OP_ST)) {
+                v += ops[i].reg;
+                break;
+            }
+        }
+        /* mov $im, %reg case */
+        if (pa->opcode == 0xb0 && s >= 1)
+            v += 7;
+    }
+    if (pa->instr_type & OPC_B)
+        v += s >= 1;
+    if (pa->instr_type & OPC_TEST)
+        v += test_bits[opcode - pa->sym];
+    if (pa->instr_type & OPC_SHORTJMP) {
+        Sym *sym;
+        int jmp_disp;
+
+        /* see if we can really generate the jump with a byte offset */
+        sym = ops[0].e.sym;
+        if (!sym)
+            goto no_short_jump;
+        if (sym->r != cur_text_section->sh_num)
+            goto no_short_jump;
+        jmp_disp = ops[0].e.v + sym->jnext - ind - 2;
+        if (jmp_disp == (int8_t)jmp_disp) {
+            /* OK to generate jump */
+            is_short_jmp = 1;
+            ops[0].e.v = jmp_disp;
+        } else {
+        no_short_jump:
+            if (pa->instr_type & OPC_JMP) {
+                /* long jump will be allowed. need to modify the
+                   opcode slightly */
+                if (v == 0xeb)
+                    v = 0xe9;
+                else
+                    v += 0x0f10;
+            } else {
+                tcc_error("invalid displacement");
+            }
+        }
+    }
+    op1 = v >> 8;
+    if (op1)
+        g(op1);
+    g(v);
+
+    /* search which operand will used for modrm */
+    modrm_index = 0;
+    if (pa->instr_type & OPC_SHIFT) {
+        reg = (opcode - pa->sym) / NBWLX;
+        if (reg == 6)
+            reg = 7;
+    } else if (pa->instr_type & OPC_ARITH) {
+        reg = (opcode - pa->sym) / NBWLX;
+    } else if (pa->instr_type & OPC_FARITH) {
+        reg = (opcode - pa->sym) / 6;
+    } else {
+        reg = (pa->instr_type >> OPC_GROUP_SHIFT) & 7;
+    }
+    if (pa->instr_type & OPC_MODRM) {
+        /* first look for an ea operand */
+        for(i = 0;i < nb_ops; i++) {
+            if (op_type[i] & OP_EA)
+                goto modrm_found;
+        }
+        /* then if not found, a register or indirection (shift instructions) */
+        for(i = 0;i < nb_ops; i++) {
+            if (op_type[i] & (OP_REG | OP_MMX | OP_SSE | OP_INDIR))
+                goto modrm_found;
+        }
+#ifdef ASM_DEBUG
+        tcc_error("bad op table");
+#endif
+    modrm_found:
+        modrm_index = i;
+        /* if a register is used in another operand then it is
+           used instead of group */
+        for(i = 0;i < nb_ops; i++) {
+            v = op_type[i];
+            if (i != modrm_index &&
+                (v & (OP_REG | OP_MMX | OP_SSE | OP_CR | OP_TR | OP_DB | OP_SEG))) {
+                reg = ops[i].reg;
+                break;
+            }
+        }
+
+        asm_modrm(reg, &ops[modrm_index]);
+    }
+
+    /* emit constants */
+#ifndef TCC_TARGET_X86_64
+    if (pa->opcode == 0x9a || pa->opcode == 0xea) {
+        /* ljmp or lcall kludge */
+#ifdef I386_ASM_16
+        if (s1->seg_size == 16 && o32 == 0)
+            gen_expr16(&ops[1].e);
+        else
+#endif
+            gen_expr32(&ops[1].e);
+        if (ops[0].e.sym)
+            tcc_error("cannot relocate");
+        gen_le16(ops[0].e.v);
+        return;
+    }
+#endif
+    for(i = 0;i < nb_ops; i++) {
+        v = op_type[i];
+        if (v & (OP_IM8 | OP_IM16 | OP_IM32 | OP_IM64 | OP_IM8S | OP_ADDR)) {
+            /* if multiple sizes are given it means we must look
+               at the op size */
+            if ((v | OP_IM8 | OP_IM64) == (OP_IM8 | OP_IM16 | OP_IM32 | OP_IM64)) {
+                if (s == 0)
+                    v = OP_IM8;
+                else if (s == 1)
+                    v = OP_IM16;
+                else if (s == 2 || (v & OP_IM64) == 0)
+                    v = OP_IM32;
+                else
+                    v = OP_IM64;
+            }
+            if (v & (OP_IM8 | OP_IM8S)) {
+                if (ops[i].e.sym)
+                    goto error_relocate;
+                g(ops[i].e.v);
+            } else if (v & OP_IM16) {
+#ifdef I386_ASM_16
+                if (s1->seg_size == 16)
+                    gen_expr16(&ops[i].e);
+                else
+#endif
+                if (ops[i].e.sym)
+                error_relocate:
+                    tcc_error("cannot relocate");
+                else
+                    gen_le16(ops[i].e.v);
+            } else {
+                if (pa->instr_type & (OPC_JMP | OPC_SHORTJMP)) {
+                    if (is_short_jmp)
+                        g(ops[i].e.v);
+#ifdef I386_ASM_16
+                    else if (s1->seg_size == 16)
+                        gen_disp16(&ops[i].e);
+#endif
+                    else
+                        gen_disp32(&ops[i].e);
+                } else {
+#ifdef I386_ASM_16
+                    if (s1->seg_size == 16 && !((o32 == 1) && (v & OP_IM32)))
+                        gen_expr16(&ops[i].e);
+                    else
+#endif
+#ifdef TCC_TARGET_X86_64
+                    if (v & OP_IM64)
+                        gen_expr64(&ops[i].e);
+                    else
+#endif
+                        gen_expr32(&ops[i].e);
+                }
+            }
+#ifdef I386_ASM_16
+        } else if (v & (OP_REG16 | OP_REG32)) {
+            if (pa->instr_type & (OPC_JMP | OPC_SHORTJMP)) {
+                /* jmp $r */
+                g(0xE0 + ops[i].reg);
+            }
+#endif
+#ifdef TCC_TARGET_X86_64
+        } else if (v & (OP_REG32 | OP_REG64)) {
+            if (pa->instr_type & (OPC_JMP | OPC_SHORTJMP)) {
+                /* jmp $r */
+                g(0xE0 + ops[i].reg);
+            }
+#endif
+        }
+    }
+#ifdef I386_ASM_16
+    a32 = o32 = 0;
+#endif
+}
+
+/* return the constraint priority (we allocate first the lowest
+   numbered constraints) */
+static inline int constraint_priority(const char *str)
+{
+    int priority, c, pr;
+
+    /* we take the lowest priority */
+    priority = 0;
+    for(;;) {
+        c = *str;
+        if (c == '\0')
+            break;
+        str++;
+        switch(c) {
+        case 'A':
+            pr = 0;
+            break;
+        case 'a':
+        case 'b':
+        case 'c':
+        case 'd':
+        case 'S':
+        case 'D':
+            pr = 1;
+            break;
+        case 'q':
+            pr = 2;
+            break;
+        case 'r':
+            pr = 3;
+            break;
+        case 'N':
+        case 'M':
+        case 'I':
+        case 'i':
+        case 'm':
+        case 'g':
+            pr = 4;
+            break;
+        default:
+            tcc_error("unknown constraint '%c'", c);
+            pr = 0;
+        }
+        if (pr > priority)
+            priority = pr;
+    }
+    return priority;
+}
+
+static const char *skip_constraint_modifiers(const char *p)
+{
+    while (*p == '=' || *p == '&' || *p == '+' || *p == '%')
+        p++;
+    return p;
+}
+
+#define REG_OUT_MASK 0x01
+#define REG_IN_MASK  0x02
+
+#define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask)
+
+ST_FUNC void asm_compute_constraints(ASMOperand *operands,
+                                    int nb_operands, int nb_outputs,
+                                    const uint8_t *clobber_regs,
+                                    int *pout_reg)
+{
+    ASMOperand *op;
+    int sorted_op[MAX_ASM_OPERANDS];
+    int i, j, k, p1, p2, tmp, reg, c, reg_mask;
+    const char *str;
+    uint8_t regs_allocated[NB_ASM_REGS];
+
+    /* init fields */
+    for(i=0;i<nb_operands;i++) {
+        op = &operands[i];
+        op->input_index = -1;
+        op->ref_index = -1;
+        op->reg = -1;
+        op->is_memory = 0;
+        op->is_rw = 0;
+    }
+    /* compute constraint priority and evaluate references to output
+       constraints if input constraints */
+    for(i=0;i<nb_operands;i++) {
+        op = &operands[i];
+        str = op->constraint;
+        str = skip_constraint_modifiers(str);
+        if (isnum(*str) || *str == '[') {
+            /* this is a reference to another constraint */
+            k = find_constraint(operands, nb_operands, str, NULL);
+            if ((unsigned)k >= i || i < nb_outputs)
+                tcc_error("invalid reference in constraint %d ('%s')",
+                      i, str);
+            op->ref_index = k;
+            if (operands[k].input_index >= 0)
+                tcc_error("cannot reference twice the same operand");
+            operands[k].input_index = i;
+            op->priority = 5;
+        } else {
+            op->priority = constraint_priority(str);
+        }
+    }
+
+    /* sort operands according to their priority */
+    for(i=0;i<nb_operands;i++)
+        sorted_op[i] = i;
+    for(i=0;i<nb_operands - 1;i++) {
+        for(j=i+1;j<nb_operands;j++) {
+            p1 = operands[sorted_op[i]].priority;
+            p2 = operands[sorted_op[j]].priority;
+            if (p2 < p1) {
+                tmp = sorted_op[i];
+                sorted_op[i] = sorted_op[j];
+                sorted_op[j] = tmp;
+            }
+        }
+    }
+
+    for(i = 0;i < NB_ASM_REGS; i++) {
+        if (clobber_regs[i])
+            regs_allocated[i] = REG_IN_MASK | REG_OUT_MASK;
+        else
+            regs_allocated[i] = 0;
+    }
+    /* esp cannot be used */
+    regs_allocated[4] = REG_IN_MASK | REG_OUT_MASK;
+    /* ebp cannot be used yet */
+    regs_allocated[5] = REG_IN_MASK | REG_OUT_MASK;
+
+    /* allocate registers and generate corresponding asm moves */
+    for(i=0;i<nb_operands;i++) {
+        j = sorted_op[i];
+        op = &operands[j];
+        str = op->constraint;
+        /* no need to allocate references */
+        if (op->ref_index >= 0)
+            continue;
+        /* select if register is used for output, input or both */
+        if (op->input_index >= 0) {
+            reg_mask = REG_IN_MASK | REG_OUT_MASK;
+        } else if (j < nb_outputs) {
+            reg_mask = REG_OUT_MASK;
+        } else {
+            reg_mask = REG_IN_MASK;
+        }
+    try_next:
+        c = *str++;
+        switch(c) {
+        case '=':
+            goto try_next;
+        case '+':
+            op->is_rw = 1;
+            /* FALL THRU */
+        case '&':
+            if (j >= nb_outputs)
+                tcc_error("'%c' modifier can only be applied to outputs", c);
+            reg_mask = REG_IN_MASK | REG_OUT_MASK;
+            goto try_next;
+        case 'A':
+            /* allocate both eax and edx */
+            if (is_reg_allocated(TREG_XAX) ||
+                is_reg_allocated(TREG_XDX))
+                goto try_next;
+            op->is_llong = 1;
+            op->reg = TREG_XAX;
+            regs_allocated[TREG_XAX] |= reg_mask;
+            regs_allocated[TREG_XDX] |= reg_mask;
+            break;
+        case 'a':
+            reg = TREG_XAX;
+            goto alloc_reg;
+        case 'b':
+            reg = 3;
+            goto alloc_reg;
+        case 'c':
+            reg = TREG_XCX;
+            goto alloc_reg;
+        case 'd':
+            reg = TREG_XDX;
+            goto alloc_reg;
+        case 'S':
+            reg = 6;
+            goto alloc_reg;
+        case 'D':
+            reg = 7;
+        alloc_reg:
+            if (is_reg_allocated(reg))
+                goto try_next;
+            goto reg_found;
+        case 'q':
+            /* eax, ebx, ecx or edx */
+            for(reg = 0; reg < 4; reg++) {
+                if (!is_reg_allocated(reg))
+                    goto reg_found;
+            }
+            goto try_next;
+        case 'r':
+            /* any general register */
+            for(reg = 0; reg < 8; reg++) {
+                if (!is_reg_allocated(reg))
+                    goto reg_found;
+            }
+            goto try_next;
+        reg_found:
+            /* now we can reload in the register */
+            op->is_llong = 0;
+            op->reg = reg;
+            regs_allocated[reg] |= reg_mask;
+            break;
+        case 'i':
+            if (!((op->vt->r & (VT_VALMASK | VT_LVAL)) == VT_CONST))
+                goto try_next;
+            break;
+        case 'I':
+        case 'N':
+        case 'M':
+            if (!((op->vt->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST))
+                goto try_next;
+            break;
+        case 'm':
+        case 'g':
+            /* nothing special to do because the operand is already in
+               memory, except if the pointer itself is stored in a
+               memory variable (VT_LLOCAL case) */
+            /* XXX: fix constant case */
+            /* if it is a reference to a memory zone, it must lie
+               in a register, so we reserve the register in the
+               input registers and a load will be generated
+               later */
+            if (j < nb_outputs || c == 'm') {
+                if ((op->vt->r & VT_VALMASK) == VT_LLOCAL) {
+                    /* any general register */
+                    for(reg = 0; reg < 8; reg++) {
+                        if (!(regs_allocated[reg] & REG_IN_MASK))
+                            goto reg_found1;
+                    }
+                    goto try_next;
+                reg_found1:
+                    /* now we can reload in the register */
+                    regs_allocated[reg] |= REG_IN_MASK;
+                    op->reg = reg;
+                    op->is_memory = 1;
+                }
+            }
+            break;
+        default:
+            tcc_error("asm constraint %d ('%s') could not be satisfied",
+                  j, op->constraint);
+            break;
+        }
+        /* if a reference is present for that operand, we assign it too */
+        if (op->input_index >= 0) {
+            operands[op->input_index].reg = op->reg;
+            operands[op->input_index].is_llong = op->is_llong;
+        }
+    }
+
+    /* compute out_reg. It is used to store outputs registers to memory
+       locations references by pointers (VT_LLOCAL case) */
+    *pout_reg = -1;
+    for(i=0;i<nb_operands;i++) {
+        op = &operands[i];
+        if (op->reg >= 0 &&
+            (op->vt->r & VT_VALMASK) == VT_LLOCAL  &&
+            !op->is_memory) {
+            for(reg = 0; reg < 8; reg++) {
+                if (!(regs_allocated[reg] & REG_OUT_MASK))
+                    goto reg_found2;
+            }
+            tcc_error("could not find free output register for reloading");
+        reg_found2:
+            *pout_reg = reg;
+            break;
+        }
+    }
+
+    /* print sorted constraints */
+#ifdef ASM_DEBUG
+    for(i=0;i<nb_operands;i++) {
+        j = sorted_op[i];
+        op = &operands[j];
+        printf("%%%d [%s]: \"%s\" r=0x%04x reg=%d\n",
+               j,
+               op->id ? get_tok_str(op->id, NULL) : "",
+               op->constraint,
+               op->vt->r,
+               op->reg);
+    }
+    if (*pout_reg >= 0)
+        printf("out_reg=%d\n", *pout_reg);
+#endif
+}
+
+ST_FUNC void subst_asm_operand(CString *add_str,
+                              SValue *sv, int modifier)
+{
+    int r, reg, size, val;
+    char buf[64];
+
+    r = sv->r;
+    if ((r & VT_VALMASK) == VT_CONST) {
+        if (!(r & VT_LVAL) && modifier != 'c' && modifier != 'n')
+            cstr_ccat(add_str, '$');
+        if (r & VT_SYM) {
+            cstr_cat(add_str, get_tok_str(sv->sym->v, NULL));
+            if (sv->c.i != 0) {
+                cstr_ccat(add_str, '+');
+            } else {
+                return;
+            }
+        }
+        val = sv->c.i;
+        if (modifier == 'n')
+            val = -val;
+        snprintf(buf, sizeof(buf), "%d", sv->c.i);
+        cstr_cat(add_str, buf);
+    } else if ((r & VT_VALMASK) == VT_LOCAL) {
+        snprintf(buf, sizeof(buf), "%d(%%ebp)", sv->c.i);
+        cstr_cat(add_str, buf);
+    } else if (r & VT_LVAL) {
+        reg = r & VT_VALMASK;
+        if (reg >= VT_CONST)
+            tcc_error("internal compiler error");
+        snprintf(buf, sizeof(buf), "(%%%s)",
+                 get_tok_str(TOK_ASM_eax + reg, NULL));
+        cstr_cat(add_str, buf);
+    } else {
+        /* register case */
+        reg = r & VT_VALMASK;
+        if (reg >= VT_CONST)
+            tcc_error("internal compiler error");
+
+        /* choose register operand size */
+        if ((sv->type.t & VT_BTYPE) == VT_BYTE)
+            size = 1;
+        else if ((sv->type.t & VT_BTYPE) == VT_SHORT)
+            size = 2;
+#ifdef TCC_TARGET_X86_64
+        else if ((sv->type.t & VT_BTYPE) == VT_LLONG)
+            size = 8;
+#endif
+        else
+            size = 4;
+        if (size == 1 && reg >= 4)
+            size = 4;
+
+        if (modifier == 'b') {
+            if (reg >= 4)
+                tcc_error("cannot use byte register");
+            size = 1;
+        } else if (modifier == 'h') {
+            if (reg >= 4)
+                tcc_error("cannot use byte register");
+            size = -1;
+        } else if (modifier == 'w') {
+            size = 2;
+#ifdef TCC_TARGET_X86_64
+        } else if (modifier == 'q') {
+            size = 8;
+#endif
+        }
+
+        switch(size) {
+        case -1:
+            reg = TOK_ASM_ah + reg;
+            break;
+        case 1:
+            reg = TOK_ASM_al + reg;
+            break;
+        case 2:
+            reg = TOK_ASM_ax + reg;
+            break;
+        default:
+            reg = TOK_ASM_eax + reg;
+            break;
+#ifdef TCC_TARGET_X86_64
+        case 8:
+            reg = TOK_ASM_rax + reg;
+            break;
+#endif
+        }
+        snprintf(buf, sizeof(buf), "%%%s", get_tok_str(reg, NULL));
+        cstr_cat(add_str, buf);
+    }
+}
+
+/* generate prolog and epilog code for asm statment */
+ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands,
+                         int nb_outputs, int is_output,
+                         uint8_t *clobber_regs,
+                         int out_reg)
+{
+    uint8_t regs_allocated[NB_ASM_REGS];
+    ASMOperand *op;
+    int i, reg;
+    static uint8_t reg_saved[NB_SAVED_REGS] = { 3, 6, 7 };
+
+    /* mark all used registers */
+    memcpy(regs_allocated, clobber_regs, sizeof(regs_allocated));
+    for(i = 0; i < nb_operands;i++) {
+        op = &operands[i];
+        if (op->reg >= 0)
+            regs_allocated[op->reg] = 1;
+    }
+    if (!is_output) {
+        /* generate reg save code */
+        for(i = 0; i < NB_SAVED_REGS; i++) {
+            reg = reg_saved[i];
+            if (regs_allocated[reg]) {
+#ifdef I386_ASM_16
+                if (tcc_state->seg_size == 16)
+                    g(0x66);
+#endif
+                g(0x50 + reg);
+            }
+        }
+
+        /* generate load code */
+        for(i = 0; i < nb_operands; i++) {
+            op = &operands[i];
+            if (op->reg >= 0) {
+                if ((op->vt->r & VT_VALMASK) == VT_LLOCAL &&
+                    op->is_memory) {
+                    /* memory reference case (for both input and
+                       output cases) */
+                    SValue sv;
+                    sv = *op->vt;
+                    sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
+                    load(op->reg, &sv);
+                } else if (i >= nb_outputs || op->is_rw) {
+                    /* load value in register */
+                    load(op->reg, op->vt);
+                    if (op->is_llong) {
+                        SValue sv;
+                        sv = *op->vt;
+                        sv.c.ul += 4;
+                        load(TREG_XDX, &sv);
+                    }
+                }
+            }
+        }
+    } else {
+        /* generate save code */
+        for(i = 0 ; i < nb_outputs; i++) {
+            op = &operands[i];
+            if (op->reg >= 0) {
+                if ((op->vt->r & VT_VALMASK) == VT_LLOCAL) {
+                    if (!op->is_memory) {
+                        SValue sv;
+                        sv = *op->vt;
+                        sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
+                        load(out_reg, &sv);
+
+                        sv.r = (sv.r & ~VT_VALMASK) | out_reg;
+                        store(op->reg, &sv);
+                    }
+                } else {
+                    store(op->reg, op->vt);
+                    if (op->is_llong) {
+                        SValue sv;
+                        sv = *op->vt;
+                        sv.c.ul += 4;
+                        store(TREG_XDX, &sv);
+                    }
+                }
+            }
+        }
+        /* generate reg restore code */
+        for(i = NB_SAVED_REGS - 1; i >= 0; i--) {
+            reg = reg_saved[i];
+            if (regs_allocated[reg]) {
+#ifdef I386_ASM_16
+                if (tcc_state->seg_size == 16)
+                    g(0x66);
+#endif
+                g(0x58 + reg);
+            }
+        }
+    }
+}
+
+ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str)
+{
+    int reg;
+    TokenSym *ts;
+
+    if (!strcmp(str, "memory") ||
+        !strcmp(str, "cc"))
+        return;
+    ts = tok_alloc(str, strlen(str));
+    reg = ts->tok;
+    if (reg >= TOK_ASM_eax && reg <= TOK_ASM_edi) {
+        reg -= TOK_ASM_eax;
+    } else if (reg >= TOK_ASM_ax && reg <= TOK_ASM_di) {
+        reg -= TOK_ASM_ax;
+#ifdef TCC_TARGET_X86_64
+    } else if (reg >= TOK_ASM_rax && reg <= TOK_ASM_rdi) {
+        reg -= TOK_ASM_rax;
+#endif
+    } else {
+        tcc_error("invalid clobber register '%s'", str);
+    }
+    clobber_regs[reg] = 1;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/i386-asm.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/i386-asm.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/i386-asm.h	(revision 279)
@@ -0,0 +1,473 @@
+     DEF_ASM_OP0(clc, 0xf8) /* must be first OP0 */
+     DEF_ASM_OP0(cld, 0xfc)
+     DEF_ASM_OP0(cli, 0xfa)
+     DEF_ASM_OP0(clts, 0x0f06)
+     DEF_ASM_OP0(cmc, 0xf5)
+     DEF_ASM_OP0(lahf, 0x9f)
+     DEF_ASM_OP0(sahf, 0x9e)
+     DEF_ASM_OP0(pusha, 0x60)
+     DEF_ASM_OP0(popa, 0x61)
+     DEF_ASM_OP0(pushfl, 0x9c)
+     DEF_ASM_OP0(popfl, 0x9d)
+     DEF_ASM_OP0(pushf, 0x9c)
+     DEF_ASM_OP0(popf, 0x9d)
+     DEF_ASM_OP0(stc, 0xf9)
+     DEF_ASM_OP0(std, 0xfd)
+     DEF_ASM_OP0(sti, 0xfb)
+     DEF_ASM_OP0(aaa, 0x37)
+     DEF_ASM_OP0(aas, 0x3f)
+     DEF_ASM_OP0(daa, 0x27)
+     DEF_ASM_OP0(das, 0x2f)
+     DEF_ASM_OP0(aad, 0xd50a)
+     DEF_ASM_OP0(aam, 0xd40a)
+     DEF_ASM_OP0(cbw, 0x6698)
+     DEF_ASM_OP0(cwd, 0x6699)
+     DEF_ASM_OP0(cwde, 0x98)
+     DEF_ASM_OP0(cdq, 0x99)
+     DEF_ASM_OP0(cbtw, 0x6698)
+     DEF_ASM_OP0(cwtl, 0x98)
+     DEF_ASM_OP0(cwtd, 0x6699)
+     DEF_ASM_OP0(cltd, 0x99)
+     DEF_ASM_OP0(int3, 0xcc)
+     DEF_ASM_OP0(into, 0xce)
+     DEF_ASM_OP0(iret, 0xcf)
+     DEF_ASM_OP0(rsm, 0x0faa)
+     DEF_ASM_OP0(hlt, 0xf4)
+     DEF_ASM_OP0(nop, 0x90)
+     DEF_ASM_OP0(pause, 0xf390)
+     DEF_ASM_OP0(xlat, 0xd7)
+
+     /* strings */
+ALT(DEF_ASM_OP0L(cmpsb, 0xa6, 0, OPC_BWL))
+ALT(DEF_ASM_OP0L(scmpb, 0xa6, 0, OPC_BWL))
+
+ALT(DEF_ASM_OP0L(insb, 0x6c, 0, OPC_BWL))
+ALT(DEF_ASM_OP0L(outsb, 0x6e, 0, OPC_BWL))
+
+ALT(DEF_ASM_OP0L(lodsb, 0xac, 0, OPC_BWL))
+ALT(DEF_ASM_OP0L(slodb, 0xac, 0, OPC_BWL))
+
+ALT(DEF_ASM_OP0L(movsb, 0xa4, 0, OPC_BWL))
+ALT(DEF_ASM_OP0L(smovb, 0xa4, 0, OPC_BWL))
+
+ALT(DEF_ASM_OP0L(scasb, 0xae, 0, OPC_BWL))
+ALT(DEF_ASM_OP0L(sscab, 0xae, 0, OPC_BWL))
+
+ALT(DEF_ASM_OP0L(stosb, 0xaa, 0, OPC_BWL))
+ALT(DEF_ASM_OP0L(sstob, 0xaa, 0, OPC_BWL))
+
+     /* bits */
+     
+ALT(DEF_ASM_OP2(bsfw, 0x0fbc, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(bsrw, 0x0fbd, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))
+
+ALT(DEF_ASM_OP2(btw, 0x0fa3, 0, OPC_MODRM | OPC_WL, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btw, 0x0fba, 4, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW | OPT_EA))
+
+ALT(DEF_ASM_OP2(btsw, 0x0fab, 0, OPC_MODRM | OPC_WL, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btsw, 0x0fba, 5, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW | OPT_EA))
+
+ALT(DEF_ASM_OP2(btrw, 0x0fb3, 0, OPC_MODRM | OPC_WL, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btrw, 0x0fba, 6, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW | OPT_EA))
+
+ALT(DEF_ASM_OP2(btcw, 0x0fbb, 0, OPC_MODRM | OPC_WL, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btcw, 0x0fba, 7, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW | OPT_EA))
+
+     /* prefixes */
+     DEF_ASM_OP0(wait, 0x9b)
+     DEF_ASM_OP0(fwait, 0x9b)
+#ifdef I386_ASM_16
+     DEF_ASM_OP0(a32, 0x67)
+     DEF_ASM_OP0(o32, 0x66)
+#else
+     DEF_ASM_OP0(aword, 0x67)
+     DEF_ASM_OP0(addr16, 0x67)
+     ALT(DEF_ASM_OP0(word, 0x66))
+     DEF_ASM_OP0(data16, 0x66)
+#endif
+     DEF_ASM_OP0(lock, 0xf0)
+     DEF_ASM_OP0(rep, 0xf3)
+     DEF_ASM_OP0(repe, 0xf3)
+     DEF_ASM_OP0(repz, 0xf3)
+     DEF_ASM_OP0(repne, 0xf2)
+     DEF_ASM_OP0(repnz, 0xf2)
+             
+     DEF_ASM_OP0(invd, 0x0f08)
+     DEF_ASM_OP0(wbinvd, 0x0f09)
+     DEF_ASM_OP0(cpuid, 0x0fa2)
+     DEF_ASM_OP0(wrmsr, 0x0f30)
+     DEF_ASM_OP0(rdtsc, 0x0f31)
+     DEF_ASM_OP0(rdmsr, 0x0f32)
+     DEF_ASM_OP0(rdpmc, 0x0f33)
+     DEF_ASM_OP0(ud2, 0x0f0b)
+
+     /* NOTE: we took the same order as gas opcode definition order */
+ALT(DEF_ASM_OP2(movb, 0xa0, 0, OPC_BWL, OPT_ADDR, OPT_EAX))
+ALT(DEF_ASM_OP2(movb, 0xa2, 0, OPC_BWL, OPT_EAX, OPT_ADDR))
+ALT(DEF_ASM_OP2(movb, 0x88, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(movb, 0x8a, 0, OPC_MODRM | OPC_BWL, OPT_EA | OPT_REG, OPT_REG))
+ALT(DEF_ASM_OP2(movb, 0xb0, 0, OPC_REG | OPC_BWL, OPT_IM, OPT_REG))
+ALT(DEF_ASM_OP2(movb, 0xc6, 0, OPC_MODRM | OPC_BWL, OPT_IM, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP2(movw, 0x8c, 0, OPC_MODRM | OPC_WL, OPT_SEG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(movw, 0x8e, 0, OPC_MODRM | OPC_WL, OPT_EA | OPT_REG, OPT_SEG))
+
+ALT(DEF_ASM_OP2(movw, 0x0f20, 0, OPC_MODRM | OPC_WL, OPT_CR, OPT_REG32))
+ALT(DEF_ASM_OP2(movw, 0x0f21, 0, OPC_MODRM | OPC_WL, OPT_DB, OPT_REG32))
+ALT(DEF_ASM_OP2(movw, 0x0f24, 0, OPC_MODRM | OPC_WL, OPT_TR, OPT_REG32))
+ALT(DEF_ASM_OP2(movw, 0x0f22, 0, OPC_MODRM | OPC_WL, OPT_REG32, OPT_CR))
+ALT(DEF_ASM_OP2(movw, 0x0f23, 0, OPC_MODRM | OPC_WL, OPT_REG32, OPT_DB))
+ALT(DEF_ASM_OP2(movw, 0x0f26, 0, OPC_MODRM | OPC_WL, OPT_REG32, OPT_TR))
+
+ALT(DEF_ASM_OP2(movsbl, 0x0fbe, 0, OPC_MODRM, OPT_REG8 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(movsbw, 0x0fbe, 0, OPC_MODRM | OPC_D16, OPT_REG8 | OPT_EA, OPT_REG16))
+ALT(DEF_ASM_OP2(movswl, 0x0fbf, 0, OPC_MODRM, OPT_REG16 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(movzbw, 0x0fb6, 0, OPC_MODRM | OPC_WL, OPT_REG8 | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(movzwl, 0x0fb7, 0, OPC_MODRM, OPT_REG16 | OPT_EA, OPT_REG32))
+
+ALT(DEF_ASM_OP1(pushw, 0x50, 0, OPC_REG | OPC_WL, OPT_REGW))
+ALT(DEF_ASM_OP1(pushw, 0xff, 6, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP1(pushw, 0x6a, 0, OPC_WL, OPT_IM8S))
+ALT(DEF_ASM_OP1(pushw, 0x68, 0, OPC_WL, OPT_IM32))
+ALT(DEF_ASM_OP1(pushw, 0x06, 0, OPC_WL, OPT_SEG))
+
+ALT(DEF_ASM_OP1(popw, 0x58, 0, OPC_REG | OPC_WL, OPT_REGW))
+ALT(DEF_ASM_OP1(popw, 0x8f, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP1(popw, 0x07, 0, OPC_WL, OPT_SEG))
+
+ALT(DEF_ASM_OP2(xchgw, 0x90, 0, OPC_REG | OPC_WL, OPT_REG, OPT_EAX))
+ALT(DEF_ASM_OP2(xchgw, 0x90, 0, OPC_REG | OPC_WL, OPT_EAX, OPT_REG))
+ALT(DEF_ASM_OP2(xchgb, 0x86, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(xchgb, 0x86, 0, OPC_MODRM | OPC_BWL, OPT_EA | OPT_REG, OPT_REG))
+
+ALT(DEF_ASM_OP2(inb, 0xe4, 0, OPC_BWL, OPT_IM8, OPT_EAX))
+ALT(DEF_ASM_OP1(inb, 0xe4, 0, OPC_BWL, OPT_IM8))
+ALT(DEF_ASM_OP2(inb, 0xec, 0, OPC_BWL, OPT_DX, OPT_EAX))
+ALT(DEF_ASM_OP1(inb, 0xec, 0, OPC_BWL, OPT_DX))
+
+ALT(DEF_ASM_OP2(outb, 0xe6, 0, OPC_BWL, OPT_EAX, OPT_IM8))
+ALT(DEF_ASM_OP1(outb, 0xe6, 0, OPC_BWL, OPT_IM8))
+ALT(DEF_ASM_OP2(outb, 0xee, 0, OPC_BWL, OPT_EAX, OPT_DX))
+ALT(DEF_ASM_OP1(outb, 0xee, 0, OPC_BWL, OPT_DX))
+
+ALT(DEF_ASM_OP2(leaw, 0x8d, 0, OPC_MODRM | OPC_WL, OPT_EA, OPT_REG))
+
+ALT(DEF_ASM_OP2(les, 0xc4, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lds, 0xc5, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lss, 0x0fb2, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lfs, 0x0fb4, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lgs, 0x0fb5, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+
+     /* arith */
+ALT(DEF_ASM_OP2(addb, 0x00, 0, OPC_ARITH | OPC_MODRM | OPC_BWL, OPT_REG, OPT_EA | OPT_REG)) /* XXX: use D bit ? */
+ALT(DEF_ASM_OP2(addb, 0x02, 0, OPC_ARITH | OPC_MODRM | OPC_BWL, OPT_EA | OPT_REG, OPT_REG))
+ALT(DEF_ASM_OP2(addb, 0x04, 0, OPC_ARITH | OPC_BWL, OPT_IM, OPT_EAX))
+ALT(DEF_ASM_OP2(addb, 0x80, 0, OPC_ARITH | OPC_MODRM | OPC_BWL, OPT_IM, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(addw, 0x83, 0, OPC_ARITH | OPC_MODRM | OPC_WL, OPT_IM8S, OPT_EA | OPT_REG))
+
+ALT(DEF_ASM_OP2(testb, 0x84, 0, OPC_MODRM | OPC_BWL, OPT_EA | OPT_REG, OPT_REG))
+ALT(DEF_ASM_OP2(testb, 0x84, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(testb, 0xa8, 0, OPC_BWL, OPT_IM, OPT_EAX))
+ALT(DEF_ASM_OP2(testb, 0xf6, 0, OPC_MODRM | OPC_BWL, OPT_IM, OPT_EA | OPT_REG))
+
+ALT(DEF_ASM_OP1(incw, 0x40, 0, OPC_REG | OPC_WL, OPT_REGW))
+ALT(DEF_ASM_OP1(incb, 0xfe, 0, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP1(decw, 0x48, 0, OPC_REG | OPC_WL, OPT_REGW))
+ALT(DEF_ASM_OP1(decb, 0xfe, 1, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP1(notb, 0xf6, 2, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP1(negb, 0xf6, 3, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP1(mulb, 0xf6, 4, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP1(imulb, 0xf6, 5, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP2(imulw, 0x0faf, 0, OPC_MODRM | OPC_WL, OPT_REG | OPT_EA, OPT_REG))
+ALT(DEF_ASM_OP3(imulw, 0x6b, 0, OPC_MODRM | OPC_WL, OPT_IM8S, OPT_REGW | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(imulw, 0x6b, 0, OPC_MODRM | OPC_WL, OPT_IM8S, OPT_REGW))
+ALT(DEF_ASM_OP3(imulw, 0x69, 0, OPC_MODRM | OPC_WL, OPT_IMW, OPT_REGW | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(imulw, 0x69, 0, OPC_MODRM | OPC_WL, OPT_IMW, OPT_REGW))
+
+ALT(DEF_ASM_OP1(divb, 0xf6, 6, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP2(divb, 0xf6, 6, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA, OPT_EAX))
+ALT(DEF_ASM_OP1(idivb, 0xf6, 7, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP2(idivb, 0xf6, 7, OPC_MODRM | OPC_BWL, OPT_REG | OPT_EA, OPT_EAX))
+
+     /* shifts */
+ALT(DEF_ASM_OP2(rolb, 0xc0, 0, OPC_MODRM | OPC_BWL | OPC_SHIFT, OPT_IM8, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(rolb, 0xd2, 0, OPC_MODRM | OPC_BWL | OPC_SHIFT, OPT_CL, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP1(rolb, 0xd0, 0, OPC_MODRM | OPC_BWL | OPC_SHIFT, OPT_EA | OPT_REG))
+
+ALT(DEF_ASM_OP3(shldw, 0x0fa4, 0, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP3(shldw, 0x0fa5, 0, OPC_MODRM | OPC_WL, OPT_CL, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP2(shldw, 0x0fa5, 0, OPC_MODRM | OPC_WL, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP3(shrdw, 0x0fac, 0, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP3(shrdw, 0x0fad, 0, OPC_MODRM | OPC_WL, OPT_CL, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP2(shrdw, 0x0fad, 0, OPC_MODRM | OPC_WL, OPT_REGW, OPT_EA | OPT_REGW))
+
+ALT(DEF_ASM_OP1(call, 0xff, 2, OPC_MODRM, OPT_INDIR))
+ALT(DEF_ASM_OP1(call, 0xe8, 0, OPC_JMP, OPT_ADDR))
+ALT(DEF_ASM_OP1(jmp, 0xff, 4, OPC_MODRM, OPT_INDIR))
+ALT(DEF_ASM_OP1(jmp, 0xeb, 0, OPC_SHORTJMP | OPC_JMP, OPT_ADDR))
+#ifdef I386_ASM_16
+ALT(DEF_ASM_OP1(jmp, 0xff, 0, OPC_JMP | OPC_WL, OPT_REGW))
+#endif
+
+ALT(DEF_ASM_OP2(lcall, 0x9a, 0, 0, OPT_IM16, OPT_IM32))
+ALT(DEF_ASM_OP1(lcall, 0xff, 3, 0, OPT_EA))
+ALT(DEF_ASM_OP2(ljmp, 0xea, 0, 0, OPT_IM16, OPT_IM32))
+ALT(DEF_ASM_OP1(ljmp, 0xff, 5, 0, OPT_EA))
+
+ALT(DEF_ASM_OP1(int, 0xcd, 0, 0, OPT_IM8))
+ALT(DEF_ASM_OP1(seto, 0x0f90, 0, OPC_MODRM | OPC_TEST, OPT_REG8 | OPT_EA))
+    DEF_ASM_OP2(enter, 0xc8, 0, 0, OPT_IM16, OPT_IM8)
+    DEF_ASM_OP0(leave, 0xc9)
+    DEF_ASM_OP0(ret, 0xc3)
+    DEF_ASM_OP0(retl,0xc3)
+ALT(DEF_ASM_OP1(retl,0xc2, 0, 0, OPT_IM16))
+ALT(DEF_ASM_OP1(ret, 0xc2, 0, 0, OPT_IM16))
+    DEF_ASM_OP0(lret, 0xcb)
+ALT(DEF_ASM_OP1(lret, 0xca, 0, 0, OPT_IM16))
+
+ALT(DEF_ASM_OP1(jo, 0x70, 0, OPC_SHORTJMP | OPC_JMP | OPC_TEST, OPT_ADDR))
+    DEF_ASM_OP1(loopne, 0xe0, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loopnz, 0xe0, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loope, 0xe1, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loopz, 0xe1, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loop, 0xe2, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(jecxz, 0xe3, 0, OPC_SHORTJMP, OPT_ADDR)
+     
+     /* float */
+     /* specific fcomp handling */
+ALT(DEF_ASM_OP0L(fcomp, 0xd8d9, 0, 0))
+
+ALT(DEF_ASM_OP1(fadd, 0xd8c0, 0, OPC_FARITH | OPC_REG, OPT_ST))
+ALT(DEF_ASM_OP2(fadd, 0xd8c0, 0, OPC_FARITH | OPC_REG, OPT_ST, OPT_ST0))
+ALT(DEF_ASM_OP2(fadd, 0xdcc0, 0, OPC_FARITH | OPC_REG, OPT_ST0, OPT_ST))
+ALT(DEF_ASM_OP2(fmul, 0xdcc8, 0, OPC_FARITH | OPC_REG, OPT_ST0, OPT_ST))
+ALT(DEF_ASM_OP0L(fadd, 0xdec1, 0, OPC_FARITH))
+ALT(DEF_ASM_OP1(faddp, 0xdec0, 0, OPC_FARITH | OPC_REG, OPT_ST))
+ALT(DEF_ASM_OP2(faddp, 0xdec0, 0, OPC_FARITH | OPC_REG, OPT_ST, OPT_ST0))
+ALT(DEF_ASM_OP2(faddp, 0xdec0, 0, OPC_FARITH | OPC_REG, OPT_ST0, OPT_ST))
+ALT(DEF_ASM_OP0L(faddp, 0xdec1, 0, OPC_FARITH))
+ALT(DEF_ASM_OP1(fadds, 0xd8, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+ALT(DEF_ASM_OP1(fiaddl, 0xda, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+ALT(DEF_ASM_OP1(faddl, 0xdc, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+ALT(DEF_ASM_OP1(fiadds, 0xde, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+
+     DEF_ASM_OP0(fucompp, 0xdae9)
+     DEF_ASM_OP0(ftst, 0xd9e4)
+     DEF_ASM_OP0(fxam, 0xd9e5)
+     DEF_ASM_OP0(fld1, 0xd9e8)
+     DEF_ASM_OP0(fldl2t, 0xd9e9)
+     DEF_ASM_OP0(fldl2e, 0xd9ea)
+     DEF_ASM_OP0(fldpi, 0xd9eb)
+     DEF_ASM_OP0(fldlg2, 0xd9ec)
+     DEF_ASM_OP0(fldln2, 0xd9ed)
+     DEF_ASM_OP0(fldz, 0xd9ee)
+
+     DEF_ASM_OP0(f2xm1, 0xd9f0)
+     DEF_ASM_OP0(fyl2x, 0xd9f1)
+     DEF_ASM_OP0(fptan, 0xd9f2)
+     DEF_ASM_OP0(fpatan, 0xd9f3)
+     DEF_ASM_OP0(fxtract, 0xd9f4)
+     DEF_ASM_OP0(fprem1, 0xd9f5)
+     DEF_ASM_OP0(fdecstp, 0xd9f6)
+     DEF_ASM_OP0(fincstp, 0xd9f7)
+     DEF_ASM_OP0(fprem, 0xd9f8)
+     DEF_ASM_OP0(fyl2xp1, 0xd9f9)
+     DEF_ASM_OP0(fsqrt, 0xd9fa)
+     DEF_ASM_OP0(fsincos, 0xd9fb)
+     DEF_ASM_OP0(frndint, 0xd9fc)
+     DEF_ASM_OP0(fscale, 0xd9fd)
+     DEF_ASM_OP0(fsin, 0xd9fe)
+     DEF_ASM_OP0(fcos, 0xd9ff)
+     DEF_ASM_OP0(fchs, 0xd9e0)
+     DEF_ASM_OP0(fabs, 0xd9e1)
+     DEF_ASM_OP0(fninit, 0xdbe3)
+     DEF_ASM_OP0(fnclex, 0xdbe2)
+     DEF_ASM_OP0(fnop, 0xd9d0)
+
+    /* fp load */
+    DEF_ASM_OP1(fld, 0xd9c0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fldl, 0xd9c0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(flds, 0xd9, 0, OPC_MODRM, OPT_EA)
+ALT(DEF_ASM_OP1(fldl, 0xdd, 0, OPC_MODRM, OPT_EA))
+    DEF_ASM_OP1(fildl, 0xdb, 0, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fildq, 0xdf, 5, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fildll, 0xdf, 5, OPC_MODRM,OPT_EA)
+    DEF_ASM_OP1(fldt, 0xdb, 5, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fbld, 0xdf, 4, OPC_MODRM, OPT_EA)
+    
+    /* fp store */
+    DEF_ASM_OP1(fst, 0xddd0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fstl, 0xddd0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fsts, 0xd9, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fstps, 0xd9, 3, OPC_MODRM, OPT_EA)
+ALT(DEF_ASM_OP1(fstl, 0xdd, 2, OPC_MODRM, OPT_EA))
+    DEF_ASM_OP1(fstpl, 0xdd, 3, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fist, 0xdf, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistp, 0xdf, 3, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistl, 0xdb, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistpl, 0xdb, 3, OPC_MODRM, OPT_EA)
+
+    DEF_ASM_OP1(fstp, 0xddd8, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fistpq, 0xdf, 7, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistpll, 0xdf, 7, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fstpt, 0xdb, 7, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fbstp, 0xdf, 6, OPC_MODRM, OPT_EA)
+
+    /* exchange */
+    DEF_ASM_OP0(fxch, 0xd9c9)
+ALT(DEF_ASM_OP1(fxch, 0xd9c8, 0, OPC_REG, OPT_ST))
+
+    /* misc FPU */
+    DEF_ASM_OP1(fucom, 0xdde0, 0, OPC_REG, OPT_ST )
+    DEF_ASM_OP1(fucomp, 0xdde8, 0, OPC_REG, OPT_ST )
+
+    DEF_ASM_OP0L(finit, 0xdbe3, 0, OPC_FWAIT)
+    DEF_ASM_OP1(fldcw, 0xd9, 5, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fnstcw, 0xd9, 7, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fstcw, 0xd9, 7, OPC_MODRM | OPC_FWAIT, OPT_EA )
+    DEF_ASM_OP0(fnstsw, 0xdfe0)
+ALT(DEF_ASM_OP1(fnstsw, 0xdfe0, 0, 0, OPT_EAX ))
+ALT(DEF_ASM_OP1(fnstsw, 0xdd, 7, OPC_MODRM, OPT_EA ))
+    DEF_ASM_OP1(fstsw, 0xdfe0, 0, OPC_FWAIT, OPT_EAX )
+ALT(DEF_ASM_OP0L(fstsw, 0xdfe0, 0, OPC_FWAIT))
+ALT(DEF_ASM_OP1(fstsw, 0xdd, 7, OPC_MODRM | OPC_FWAIT, OPT_EA ))
+    DEF_ASM_OP0L(fclex, 0xdbe2, 0, OPC_FWAIT)
+    DEF_ASM_OP1(fnstenv, 0xd9, 6, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fstenv, 0xd9, 6, OPC_MODRM | OPC_FWAIT, OPT_EA )
+    DEF_ASM_OP1(fldenv, 0xd9, 4, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fnsave, 0xdd, 6, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fsave, 0xdd, 6, OPC_MODRM | OPC_FWAIT, OPT_EA )
+    DEF_ASM_OP1(frstor, 0xdd, 4, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(ffree, 0xddc0, 4, OPC_REG, OPT_ST )
+    DEF_ASM_OP1(ffreep, 0xdfc0, 4, OPC_REG, OPT_ST )
+    DEF_ASM_OP1(fxsave, 0x0fae, 0, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fxrstor, 0x0fae, 1, OPC_MODRM, OPT_EA )
+
+    /* segments */
+    DEF_ASM_OP2(arpl, 0x63, 0, OPC_MODRM, OPT_REG16, OPT_REG16 | OPT_EA)
+    DEF_ASM_OP2(lar, 0x0f02, 0, OPC_MODRM, OPT_REG32 | OPT_EA, OPT_REG32)
+    DEF_ASM_OP1(lgdt, 0x0f01, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(lidt, 0x0f01, 3, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(lldt, 0x0f00, 2, OPC_MODRM, OPT_EA | OPT_REG)
+    DEF_ASM_OP1(lmsw, 0x0f01, 6, OPC_MODRM, OPT_EA | OPT_REG)
+ALT(DEF_ASM_OP2(lslw, 0x0f03, 0, OPC_MODRM | OPC_WL, OPT_EA | OPT_REG, OPT_REG))
+    DEF_ASM_OP1(ltr, 0x0f00, 3, OPC_MODRM, OPT_EA | OPT_REG)
+    DEF_ASM_OP1(sgdt, 0x0f01, 0, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(sidt, 0x0f01, 1, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(sldt, 0x0f00, 0, OPC_MODRM, OPT_REG | OPT_EA)
+    DEF_ASM_OP1(smsw, 0x0f01, 4, OPC_MODRM, OPT_REG | OPT_EA)
+    DEF_ASM_OP1(str, 0x0f00, 1, OPC_MODRM, OPT_REG16| OPT_EA)
+    DEF_ASM_OP1(verr, 0x0f00, 4, OPC_MODRM, OPT_REG | OPT_EA)
+    DEF_ASM_OP1(verw, 0x0f00, 5, OPC_MODRM, OPT_REG | OPT_EA)
+
+#ifdef I386_ASM_16
+    /* 386 */
+    DEF_ASM_OP0(loadall386, 0x0f07)
+#endif
+
+    /* 486 */
+    DEF_ASM_OP1(bswap, 0x0fc8, 0, OPC_REG, OPT_REG32 )
+ALT(DEF_ASM_OP2(xaddb, 0x0fc0, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_REG | OPT_EA ))
+ALT(DEF_ASM_OP2(cmpxchgb, 0x0fb0, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_REG | OPT_EA ))
+    DEF_ASM_OP1(invlpg, 0x0f01, 7, OPC_MODRM, OPT_EA )
+
+    DEF_ASM_OP2(boundl, 0x62, 0, OPC_MODRM, OPT_REG32, OPT_EA)
+    DEF_ASM_OP2(boundw, 0x62, 0, OPC_MODRM | OPC_D16, OPT_REG16, OPT_EA)
+
+    /* pentium */
+    DEF_ASM_OP1(cmpxchg8b, 0x0fc7, 1, OPC_MODRM, OPT_EA )
+    
+    /* pentium pro */
+    ALT(DEF_ASM_OP2(cmovo, 0x0f40, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+#ifdef I386_ASM_16
+ALT(DEF_ASM_OP2(cmovno, 0x0f41, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovc, 0x0f42, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovnc, 0x0f43, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovz, 0x0f44, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovnz, 0x0f45, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovna, 0x0f46, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmova, 0x0f47, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+#endif
+    DEF_ASM_OP2(fcmovb, 0xdac0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmove, 0xdac8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovbe, 0xdad0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovu, 0xdad8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovnb, 0xdbc0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovne, 0xdbc8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovnbe, 0xdbd0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovnu, 0xdbd8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+
+    DEF_ASM_OP2(fucomi, 0xdbe8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcomi, 0xdbf0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fucomip, 0xdfe8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcomip, 0xdff0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+
+    /* mmx */
+    DEF_ASM_OP0(emms, 0x0f77) /* must be last OP0 */
+
+    DEF_ASM_OP2(movd, 0x0f6e, 0, OPC_MODRM, OPT_EA | OPT_REG32, OPT_MMX )
+ALT(DEF_ASM_OP2(movd, 0x0f7e, 0, OPC_MODRM, OPT_MMX, OPT_EA | OPT_REG32 ))
+    DEF_ASM_OP2(movq, 0x0f6f, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(movq, 0x0f7f, 0, OPC_MODRM, OPT_MMX, OPT_EA | OPT_MMX ))
+    DEF_ASM_OP2(packssdw, 0x0f6b, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(packsswb, 0x0f63, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(packuswb, 0x0f67, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddb, 0x0ffc, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddw, 0x0ffd, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddd, 0x0ffe, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddsb, 0x0fec, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddsw, 0x0fed, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddusb, 0x0fdc, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddusw, 0x0fdd, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pand, 0x0fdb, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pandn, 0x0fdf, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpeqb, 0x0f74, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpeqw, 0x0f75, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpeqd, 0x0f76, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpgtb, 0x0f64, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpgtw, 0x0f65, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpgtd, 0x0f66, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pmaddwd, 0x0ff5, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pmulhw, 0x0fe5, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pmullw, 0x0fd5, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(por, 0x0feb, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psllw, 0x0ff1, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psllw, 0x0f71, 6, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(pslld, 0x0ff2, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(pslld, 0x0f72, 6, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psllq, 0x0ff3, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psllq, 0x0f73, 6, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psraw, 0x0fe1, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psraw, 0x0f71, 4, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrad, 0x0fe2, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrad, 0x0f72, 4, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrlw, 0x0fd1, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrlw, 0x0f71, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrld, 0x0fd2, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrld, 0x0f72, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrlq, 0x0fd3, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrlq, 0x0f73, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psubb, 0x0ff8, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubw, 0x0ff9, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubd, 0x0ffa, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubsb, 0x0fe8, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubsw, 0x0fe9, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubusb, 0x0fd8, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubusw, 0x0fd9, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckhbw, 0x0f68, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckhwd, 0x0f69, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckhdq, 0x0f6a, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpcklbw, 0x0f60, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpcklwd, 0x0f61, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckldq, 0x0f62, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+
+#undef ALT
+#undef DEF_ASM_OP0
+#undef DEF_ASM_OP0L
+#undef DEF_ASM_OP1
+#undef DEF_ASM_OP2
+#undef DEF_ASM_OP3
Index: /EcnlProtoTool/trunk/tcc-0.9.26/i386-gen.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/i386-gen.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/i386-gen.c	(revision 279)
@@ -0,0 +1,1096 @@
+/*
+ *  X86 code generator for TCC
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef TARGET_DEFS_ONLY
+
+/* number of available registers */
+#define NB_REGS         4
+#define NB_ASM_REGS     8
+
+/* a register can belong to several classes. The classes must be
+   sorted from more general to more precise (see gv2() code which does
+   assumptions on it). */
+#define RC_INT     0x0001 /* generic integer register */
+#define RC_FLOAT   0x0002 /* generic float register */
+#define RC_EAX     0x0004
+#define RC_ST0     0x0008 
+#define RC_ECX     0x0010
+#define RC_EDX     0x0020
+#define RC_IRET    RC_EAX /* function return: integer register */
+#define RC_LRET    RC_EDX /* function return: second integer register */
+#define RC_FRET    RC_ST0 /* function return: float register */
+
+/* pretty names for the registers */
+enum {
+    TREG_EAX = 0,
+    TREG_ECX,
+    TREG_EDX,
+    TREG_ST0,
+};
+
+/* return registers for function */
+#define REG_IRET TREG_EAX /* single word int return register */
+#define REG_LRET TREG_EDX /* second word return register (for long long) */
+#define REG_FRET TREG_ST0 /* float return register */
+
+/* defined if function parameters must be evaluated in reverse order */
+#define INVERT_FUNC_PARAMS
+
+/* defined if structures are passed as pointers. Otherwise structures
+   are directly pushed on stack. */
+//#define FUNC_STRUCT_PARAM_AS_PTR
+
+/* pointer size, in bytes */
+#define PTR_SIZE 4
+
+/* long double size and alignment, in bytes */
+#define LDOUBLE_SIZE  12
+#define LDOUBLE_ALIGN 4
+/* maximum alignment (for aligned attribute support) */
+#define MAX_ALIGN     8
+
+
+#define psym oad
+
+/******************************************************/
+/* ELF defines */
+
+#define EM_TCC_TARGET EM_386
+
+/* relocation type for 32 bit data relocation */
+#define R_DATA_32   R_386_32
+#define R_DATA_PTR  R_386_32
+#define R_JMP_SLOT  R_386_JMP_SLOT
+#define R_COPY      R_386_COPY
+
+#define ELF_START_ADDR 0x08048000
+#define ELF_PAGE_SIZE  0x1000
+
+/******************************************************/
+#else /* ! TARGET_DEFS_ONLY */
+/******************************************************/
+#include "tcc.h"
+
+ST_DATA const int reg_classes[NB_REGS] = {
+    /* eax */ RC_INT | RC_EAX,
+    /* ecx */ RC_INT | RC_ECX,
+    /* edx */ RC_INT | RC_EDX,
+    /* st0 */ RC_FLOAT | RC_ST0,
+};
+
+static unsigned long func_sub_sp_offset;
+static int func_ret_sub;
+#ifdef CONFIG_TCC_BCHECK
+static unsigned long func_bound_offset;
+#endif
+
+/* XXX: make it faster ? */
+ST_FUNC void g(int c)
+{
+    int ind1;
+    ind1 = ind + 1;
+    if (ind1 > cur_text_section->data_allocated)
+        section_realloc(cur_text_section, ind1);
+    cur_text_section->data[ind] = c;
+    ind = ind1;
+}
+
+ST_FUNC void o(unsigned int c)
+{
+    while (c) {
+        g(c);
+        c = c >> 8;
+    }
+}
+
+ST_FUNC void gen_le16(int v)
+{
+    g(v);
+    g(v >> 8);
+}
+
+ST_FUNC void gen_le32(int c)
+{
+    g(c);
+    g(c >> 8);
+    g(c >> 16);
+    g(c >> 24);
+}
+
+/* output a symbol and patch all calls to it */
+ST_FUNC void gsym_addr(int t, int a)
+{
+    int n, *ptr;
+    while (t) {
+        ptr = (int *)(cur_text_section->data + t);
+        n = *ptr; /* next value */
+        *ptr = a - t - 4;
+        t = n;
+    }
+}
+
+ST_FUNC void gsym(int t)
+{
+    gsym_addr(t, ind);
+}
+
+/* psym is used to put an instruction with a data field which is a
+   reference to a symbol. It is in fact the same as oad ! */
+#define psym oad
+
+/* instruction + 4 bytes data. Return the address of the data */
+ST_FUNC int oad(int c, int s)
+{
+    int ind1;
+
+    o(c);
+    ind1 = ind + 4;
+    if (ind1 > cur_text_section->data_allocated)
+        section_realloc(cur_text_section, ind1);
+    *(int *)(cur_text_section->data + ind) = s;
+    s = ind;
+    ind = ind1;
+    return s;
+}
+
+/* output constant with relocation if 'r & VT_SYM' is true */
+ST_FUNC void gen_addr32(int r, Sym *sym, int c)
+{
+    if (r & VT_SYM)
+        greloc(cur_text_section, sym, ind, R_386_32);
+    gen_le32(c);
+}
+
+ST_FUNC void gen_addrpc32(int r, Sym *sym, int c)
+{
+    if (r & VT_SYM)
+        greloc(cur_text_section, sym, ind, R_386_PC32);
+    gen_le32(c - 4);
+}
+
+/* generate a modrm reference. 'op_reg' contains the addtionnal 3
+   opcode bits */
+static void gen_modrm(int op_reg, int r, Sym *sym, int c)
+{
+    op_reg = op_reg << 3;
+    if ((r & VT_VALMASK) == VT_CONST) {
+        /* constant memory reference */
+        o(0x05 | op_reg);
+        gen_addr32(r, sym, c);
+    } else if ((r & VT_VALMASK) == VT_LOCAL) {
+        /* currently, we use only ebp as base */
+        if (c == (char)c) {
+            /* short reference */
+            o(0x45 | op_reg);
+            g(c);
+        } else {
+            oad(0x85 | op_reg, c);
+        }
+    } else {
+        g(0x00 | op_reg | (r & VT_VALMASK));
+    }
+}
+
+/* load 'r' from value 'sv' */
+ST_FUNC void load(int r, SValue *sv)
+{
+    int v, t, ft, fc, fr;
+    SValue v1;
+
+#ifdef TCC_TARGET_PE
+    SValue v2;
+    sv = pe_getimport(sv, &v2);
+#endif
+
+    fr = sv->r;
+    ft = sv->type.t;
+    fc = sv->c.ul;
+
+    v = fr & VT_VALMASK;
+    if (fr & VT_LVAL) {
+        if (v == VT_LLOCAL) {
+            v1.type.t = VT_INT;
+            v1.r = VT_LOCAL | VT_LVAL;
+            v1.c.ul = fc;
+            fr = r;
+            if (!(reg_classes[fr] & RC_INT))
+                fr = get_reg(RC_INT);
+            load(fr, &v1);
+        }
+        if ((ft & VT_BTYPE) == VT_FLOAT) {
+            o(0xd9); /* flds */
+            r = 0;
+        } else if ((ft & VT_BTYPE) == VT_DOUBLE) {
+            o(0xdd); /* fldl */
+            r = 0;
+        } else if ((ft & VT_BTYPE) == VT_LDOUBLE) {
+            o(0xdb); /* fldt */
+            r = 5;
+        } else if ((ft & VT_TYPE) == VT_BYTE) {
+            o(0xbe0f);   /* movsbl */
+        } else if ((ft & VT_TYPE) == (VT_BYTE | VT_UNSIGNED)) {
+            o(0xb60f);   /* movzbl */
+        } else if ((ft & VT_TYPE) == VT_SHORT) {
+            o(0xbf0f);   /* movswl */
+        } else if ((ft & VT_TYPE) == (VT_SHORT | VT_UNSIGNED)) {
+            o(0xb70f);   /* movzwl */
+        } else {
+            o(0x8b);     /* movl */
+        }
+        gen_modrm(r, fr, sv->sym, fc);
+    } else {
+        if (v == VT_CONST) {
+            o(0xb8 + r); /* mov $xx, r */
+            gen_addr32(fr, sv->sym, fc);
+        } else if (v == VT_LOCAL) {
+            if (fc) {
+                o(0x8d); /* lea xxx(%ebp), r */
+                gen_modrm(r, VT_LOCAL, sv->sym, fc);
+            } else {
+                o(0x89);
+                o(0xe8 + r); /* mov %ebp, r */
+            }
+        } else if (v == VT_CMP) {
+            oad(0xb8 + r, 0); /* mov $0, r */
+            o(0x0f); /* setxx %br */
+            o(fc);
+            o(0xc0 + r);
+        } else if (v == VT_JMP || v == VT_JMPI) {
+            t = v & 1;
+            oad(0xb8 + r, t); /* mov $1, r */
+            o(0x05eb); /* jmp after */
+            gsym(fc);
+            oad(0xb8 + r, t ^ 1); /* mov $0, r */
+        } else if (v != r) {
+            o(0x89);
+            o(0xc0 + r + v * 8); /* mov v, r */
+        }
+    }
+}
+
+/* store register 'r' in lvalue 'v' */
+ST_FUNC void store(int r, SValue *v)
+{
+    int fr, bt, ft, fc;
+
+#ifdef TCC_TARGET_PE
+    SValue v2;
+    v = pe_getimport(v, &v2);
+#endif
+
+    ft = v->type.t;
+    fc = v->c.ul;
+    fr = v->r & VT_VALMASK;
+    bt = ft & VT_BTYPE;
+    /* XXX: incorrect if float reg to reg */
+    if (bt == VT_FLOAT) {
+        o(0xd9); /* fsts */
+        r = 2;
+    } else if (bt == VT_DOUBLE) {
+        o(0xdd); /* fstpl */
+        r = 2;
+    } else if (bt == VT_LDOUBLE) {
+        o(0xc0d9); /* fld %st(0) */
+        o(0xdb); /* fstpt */
+        r = 7;
+    } else {
+        if (bt == VT_SHORT)
+            o(0x66);
+        if (bt == VT_BYTE || bt == VT_BOOL)
+            o(0x88);
+        else
+            o(0x89);
+    }
+    if (fr == VT_CONST ||
+        fr == VT_LOCAL ||
+        (v->r & VT_LVAL)) {
+        gen_modrm(r, v->r, v->sym, fc);
+    } else if (fr != r) {
+        o(0xc0 + fr + r * 8); /* mov r, fr */
+    }
+}
+
+static void gadd_sp(int val)
+{
+    if (val == (char)val) {
+        o(0xc483);
+        g(val);
+    } else {
+        oad(0xc481, val); /* add $xxx, %esp */
+    }
+}
+
+/* 'is_jmp' is '1' if it is a jump */
+static void gcall_or_jmp(int is_jmp)
+{
+    int r;
+    if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+        /* constant case */
+        if (vtop->r & VT_SYM) {
+            /* relocation case */
+            greloc(cur_text_section, vtop->sym, 
+                   ind + 1, R_386_PC32);
+        } else {
+            /* put an empty PC32 relocation */
+            put_elf_reloc(symtab_section, cur_text_section, 
+                          ind + 1, R_386_PC32, 0);
+        }
+        oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */
+    } else {
+        /* otherwise, indirect call */
+        r = gv(RC_INT);
+        o(0xff); /* call/jmp *r */
+        o(0xd0 + r + (is_jmp << 4));
+    }
+}
+
+static uint8_t fastcall_regs[3] = { TREG_EAX, TREG_EDX, TREG_ECX };
+static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX };
+
+/* Generate function call. The function address is pushed first, then
+   all the parameters in call order. This functions pops all the
+   parameters and the function address. */
+ST_FUNC void gfunc_call(int nb_args)
+{
+    int size, align, r, args_size, i, func_call;
+    Sym *func_sym;
+    
+    args_size = 0;
+    for(i = 0;i < nb_args; i++) {
+        if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+            size = type_size(&vtop->type, &align);
+            /* align to stack align size */
+            size = (size + 3) & ~3;
+            /* allocate the necessary size on stack */
+            oad(0xec81, size); /* sub $xxx, %esp */
+            /* generate structure store */
+            r = get_reg(RC_INT);
+            o(0x89); /* mov %esp, r */
+            o(0xe0 + r);
+            vset(&vtop->type, r | VT_LVAL, 0);
+            vswap();
+            vstore();
+            args_size += size;
+        } else if (is_float(vtop->type.t)) {
+            gv(RC_FLOAT); /* only one float register */
+            if ((vtop->type.t & VT_BTYPE) == VT_FLOAT)
+                size = 4;
+            else if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
+                size = 8;
+            else
+                size = 12;
+            oad(0xec81, size); /* sub $xxx, %esp */
+            if (size == 12)
+                o(0x7cdb);
+            else
+                o(0x5cd9 + size - 4); /* fstp[s|l] 0(%esp) */
+            g(0x24);
+            g(0x00);
+            args_size += size;
+        } else {
+            /* simple type (currently always same size) */
+            /* XXX: implicit cast ? */
+            r = gv(RC_INT);
+            if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
+                size = 8;
+                o(0x50 + vtop->r2); /* push r */
+            } else {
+                size = 4;
+            }
+            o(0x50 + r); /* push r */
+            args_size += size;
+        }
+        vtop--;
+    }
+    save_regs(0); /* save used temporary registers */
+    func_sym = vtop->type.ref;
+    func_call = FUNC_CALL(func_sym->r);
+    /* fast call case */
+    if ((func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) ||
+        func_call == FUNC_FASTCALLW) {
+        int fastcall_nb_regs;
+        uint8_t *fastcall_regs_ptr;
+        if (func_call == FUNC_FASTCALLW) {
+            fastcall_regs_ptr = fastcallw_regs;
+            fastcall_nb_regs = 2;
+        } else {
+            fastcall_regs_ptr = fastcall_regs;
+            fastcall_nb_regs = func_call - FUNC_FASTCALL1 + 1;
+        }
+        for(i = 0;i < fastcall_nb_regs; i++) {
+            if (args_size <= 0)
+                break;
+            o(0x58 + fastcall_regs_ptr[i]); /* pop r */
+            /* XXX: incorrect for struct/floats */
+            args_size -= 4;
+        }
+    }
+    gcall_or_jmp(0);
+
+#ifdef TCC_TARGET_PE
+    if ((func_sym->type.t & VT_BTYPE) == VT_STRUCT)
+        args_size -= 4;
+#endif
+    if (args_size && func_call != FUNC_STDCALL)
+        gadd_sp(args_size);
+    vtop--;
+}
+
+#ifdef TCC_TARGET_PE
+#define FUNC_PROLOG_SIZE 10
+#else
+#define FUNC_PROLOG_SIZE 9
+#endif
+
+/* generate function prolog of type 't' */
+ST_FUNC void gfunc_prolog(CType *func_type)
+{
+    int addr, align, size, func_call, fastcall_nb_regs;
+    int param_index, param_addr;
+    uint8_t *fastcall_regs_ptr;
+    Sym *sym;
+    CType *type;
+
+    sym = func_type->ref;
+    func_call = FUNC_CALL(sym->r);
+    addr = 8;
+    loc = 0;
+    func_vc = 0;
+
+    if (func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) {
+        fastcall_nb_regs = func_call - FUNC_FASTCALL1 + 1;
+        fastcall_regs_ptr = fastcall_regs;
+    } else if (func_call == FUNC_FASTCALLW) {
+        fastcall_nb_regs = 2;
+        fastcall_regs_ptr = fastcallw_regs;
+    } else {
+        fastcall_nb_regs = 0;
+        fastcall_regs_ptr = NULL;
+    }
+    param_index = 0;
+
+    ind += FUNC_PROLOG_SIZE;
+    func_sub_sp_offset = ind;
+    /* if the function returns a structure, then add an
+       implicit pointer parameter */
+    func_vt = sym->type;
+    if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
+        /* XXX: fastcall case ? */
+        func_vc = addr;
+        addr += 4;
+        param_index++;
+    }
+    /* define parameters */
+    while ((sym = sym->next) != NULL) {
+        type = &sym->type;
+        size = type_size(type, &align);
+        size = (size + 3) & ~3;
+#ifdef FUNC_STRUCT_PARAM_AS_PTR
+        /* structs are passed as pointer */
+        if ((type->t & VT_BTYPE) == VT_STRUCT) {
+            size = 4;
+        }
+#endif
+        if (param_index < fastcall_nb_regs) {
+            /* save FASTCALL register */
+            loc -= 4;
+            o(0x89);     /* movl */
+            gen_modrm(fastcall_regs_ptr[param_index], VT_LOCAL, NULL, loc);
+            param_addr = loc;
+        } else {
+            param_addr = addr;
+            addr += size;
+        }
+        sym_push(sym->v & ~SYM_FIELD, type,
+                 VT_LOCAL | lvalue_type(type->t), param_addr);
+        param_index++;
+    }
+    func_ret_sub = 0;
+    /* pascal type call ? */
+    if (func_call == FUNC_STDCALL)
+        func_ret_sub = addr - 8;
+#ifdef TCC_TARGET_PE
+    else if (func_vc)
+        func_ret_sub = 4;
+#endif
+
+#ifdef CONFIG_TCC_BCHECK
+    /* leave some room for bound checking code */
+    if (tcc_state->do_bounds_check) {
+        oad(0xb8, 0); /* lbound section pointer */
+        oad(0xb8, 0); /* call to function */
+        func_bound_offset = lbounds_section->data_offset;
+    }
+#endif
+}
+
+/* generate function epilog */
+ST_FUNC void gfunc_epilog(void)
+{
+    int v, saved_ind;
+
+#ifdef CONFIG_TCC_BCHECK
+    if (tcc_state->do_bounds_check
+     && func_bound_offset != lbounds_section->data_offset) {
+        int saved_ind;
+        int *bounds_ptr;
+        Sym *sym, *sym_data;
+        /* add end of table info */
+        bounds_ptr = section_ptr_add(lbounds_section, sizeof(int));
+        *bounds_ptr = 0;
+        /* generate bound local allocation */
+        saved_ind = ind;
+        ind = func_sub_sp_offset;
+        sym_data = get_sym_ref(&char_pointer_type, lbounds_section, 
+                               func_bound_offset, lbounds_section->data_offset);
+        greloc(cur_text_section, sym_data,
+               ind + 1, R_386_32);
+        oad(0xb8, 0); /* mov %eax, xxx */
+        sym = external_global_sym(TOK___bound_local_new, &func_old_type, 0);
+        greloc(cur_text_section, sym, 
+               ind + 1, R_386_PC32);
+        oad(0xe8, -4);
+        ind = saved_ind;
+        /* generate bound check local freeing */
+        o(0x5250); /* save returned value, if any */
+        greloc(cur_text_section, sym_data,
+               ind + 1, R_386_32);
+        oad(0xb8, 0); /* mov %eax, xxx */
+        sym = external_global_sym(TOK___bound_local_delete, &func_old_type, 0);
+        greloc(cur_text_section, sym, 
+               ind + 1, R_386_PC32);
+        oad(0xe8, -4);
+        o(0x585a); /* restore returned value, if any */
+    }
+#endif
+    o(0xc9); /* leave */
+    if (func_ret_sub == 0) {
+        o(0xc3); /* ret */
+    } else {
+        o(0xc2); /* ret n */
+        g(func_ret_sub);
+        g(func_ret_sub >> 8);
+    }
+    /* align local size to word & save local variables */
+    
+    v = (-loc + 3) & -4; 
+    saved_ind = ind;
+    ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
+#ifdef TCC_TARGET_PE
+    if (v >= 4096) {
+        Sym *sym = external_global_sym(TOK___chkstk, &func_old_type, 0);
+        oad(0xb8, v); /* mov stacksize, %eax */
+        oad(0xe8, -4); /* call __chkstk, (does the stackframe too) */
+        greloc(cur_text_section, sym, ind-4, R_386_PC32);
+    } else
+#endif
+    {
+        o(0xe58955);  /* push %ebp, mov %esp, %ebp */
+        o(0xec81);  /* sub esp, stacksize */
+        gen_le32(v);
+#if FUNC_PROLOG_SIZE == 10
+        o(0x90);  /* adjust to FUNC_PROLOG_SIZE */
+#endif
+    }
+    ind = saved_ind;
+}
+
+/* generate a jump to a label */
+ST_FUNC int gjmp(int t)
+{
+    return psym(0xe9, t);
+}
+
+/* generate a jump to a fixed address */
+ST_FUNC void gjmp_addr(int a)
+{
+    int r;
+    r = a - ind - 2;
+    if (r == (char)r) {
+        g(0xeb);
+        g(r);
+    } else {
+        oad(0xe9, a - ind - 5);
+    }
+}
+
+/* generate a test. set 'inv' to invert test. Stack entry is popped */
+ST_FUNC int gtst(int inv, int t)
+{
+    int v, *p;
+
+    v = vtop->r & VT_VALMASK;
+    if (v == VT_CMP) {
+        /* fast case : can jump directly since flags are set */
+        g(0x0f);
+        t = psym((vtop->c.i - 16) ^ inv, t);
+    } else if (v == VT_JMP || v == VT_JMPI) {
+        /* && or || optimization */
+        if ((v & 1) == inv) {
+            /* insert vtop->c jump list in t */
+            p = &vtop->c.i;
+            while (*p != 0)
+                p = (int *)(cur_text_section->data + *p);
+            *p = t;
+            t = vtop->c.i;
+        } else {
+            t = gjmp(t);
+            gsym(vtop->c.i);
+        }
+    } else {
+        if (is_float(vtop->type.t) || 
+            (vtop->type.t & VT_BTYPE) == VT_LLONG) {
+            vpushi(0);
+            gen_op(TOK_NE);
+        }
+        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+            /* constant jmp optimization */
+            if ((vtop->c.i != 0) != inv) 
+                t = gjmp(t);
+        } else {
+            v = gv(RC_INT);
+            o(0x85);
+            o(0xc0 + v * 9);
+            g(0x0f);
+            t = psym(0x85 ^ inv, t);
+        }
+    }
+    vtop--;
+    return t;
+}
+
+/* generate an integer binary operation */
+ST_FUNC void gen_opi(int op)
+{
+    int r, fr, opc, c;
+
+    switch(op) {
+    case '+':
+    case TOK_ADDC1: /* add with carry generation */
+        opc = 0;
+    gen_op8:
+        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+            /* constant case */
+            vswap();
+            r = gv(RC_INT);
+            vswap();
+            c = vtop->c.i;
+            if (c == (char)c) {
+                /* generate inc and dec for smaller code */
+                if (c==1 && opc==0) {
+                    o (0x40 | r); // inc
+                } else if (c==1 && opc==5) {
+                    o (0x48 | r); // dec
+                } else {
+                    o(0x83);
+                    o(0xc0 | (opc << 3) | r);
+                    g(c);
+                }
+            } else {
+                o(0x81);
+                oad(0xc0 | (opc << 3) | r, c);
+            }
+        } else {
+            gv2(RC_INT, RC_INT);
+            r = vtop[-1].r;
+            fr = vtop[0].r;
+            o((opc << 3) | 0x01);
+            o(0xc0 + r + fr * 8); 
+        }
+        vtop--;
+        if (op >= TOK_ULT && op <= TOK_GT) {
+            vtop->r = VT_CMP;
+            vtop->c.i = op;
+        }
+        break;
+    case '-':
+    case TOK_SUBC1: /* sub with carry generation */
+        opc = 5;
+        goto gen_op8;
+    case TOK_ADDC2: /* add with carry use */
+        opc = 2;
+        goto gen_op8;
+    case TOK_SUBC2: /* sub with carry use */
+        opc = 3;
+        goto gen_op8;
+    case '&':
+        opc = 4;
+        goto gen_op8;
+    case '^':
+        opc = 6;
+        goto gen_op8;
+    case '|':
+        opc = 1;
+        goto gen_op8;
+    case '*':
+        gv2(RC_INT, RC_INT);
+        r = vtop[-1].r;
+        fr = vtop[0].r;
+        vtop--;
+        o(0xaf0f); /* imul fr, r */
+        o(0xc0 + fr + r * 8);
+        break;
+    case TOK_SHL:
+        opc = 4;
+        goto gen_shift;
+    case TOK_SHR:
+        opc = 5;
+        goto gen_shift;
+    case TOK_SAR:
+        opc = 7;
+    gen_shift:
+        opc = 0xc0 | (opc << 3);
+        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+            /* constant case */
+            vswap();
+            r = gv(RC_INT);
+            vswap();
+            c = vtop->c.i & 0x1f;
+            o(0xc1); /* shl/shr/sar $xxx, r */
+            o(opc | r);
+            g(c);
+        } else {
+            /* we generate the shift in ecx */
+            gv2(RC_INT, RC_ECX);
+            r = vtop[-1].r;
+            o(0xd3); /* shl/shr/sar %cl, r */
+            o(opc | r);
+        }
+        vtop--;
+        break;
+    case '/':
+    case TOK_UDIV:
+    case TOK_PDIV:
+    case '%':
+    case TOK_UMOD:
+    case TOK_UMULL:
+        /* first operand must be in eax */
+        /* XXX: need better constraint for second operand */
+        gv2(RC_EAX, RC_ECX);
+        r = vtop[-1].r;
+        fr = vtop[0].r;
+        vtop--;
+        save_reg(TREG_EDX);
+        if (op == TOK_UMULL) {
+            o(0xf7); /* mul fr */
+            o(0xe0 + fr);
+            vtop->r2 = TREG_EDX;
+            r = TREG_EAX;
+        } else {
+            if (op == TOK_UDIV || op == TOK_UMOD) {
+                o(0xf7d231); /* xor %edx, %edx, div fr, %eax */
+                o(0xf0 + fr);
+            } else {
+                o(0xf799); /* cltd, idiv fr, %eax */
+                o(0xf8 + fr);
+            }
+            if (op == '%' || op == TOK_UMOD)
+                r = TREG_EDX;
+            else
+                r = TREG_EAX;
+        }
+        vtop->r = r;
+        break;
+    default:
+        opc = 7;
+        goto gen_op8;
+    }
+}
+
+/* generate a floating point operation 'v = t1 op t2' instruction. The
+   two operands are guaranted to have the same floating point type */
+/* XXX: need to use ST1 too */
+ST_FUNC void gen_opf(int op)
+{
+    int a, ft, fc, swapped, r;
+
+    /* convert constants to memory references */
+    if ((vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+        vswap();
+        gv(RC_FLOAT);
+        vswap();
+    }
+    if ((vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST)
+        gv(RC_FLOAT);
+
+    /* must put at least one value in the floating point register */
+    if ((vtop[-1].r & VT_LVAL) &&
+        (vtop[0].r & VT_LVAL)) {
+        vswap();
+        gv(RC_FLOAT);
+        vswap();
+    }
+    swapped = 0;
+    /* swap the stack if needed so that t1 is the register and t2 is
+       the memory reference */
+    if (vtop[-1].r & VT_LVAL) {
+        vswap();
+        swapped = 1;
+    }
+    if (op >= TOK_ULT && op <= TOK_GT) {
+        /* load on stack second operand */
+        load(TREG_ST0, vtop);
+        save_reg(TREG_EAX); /* eax is used by FP comparison code */
+        if (op == TOK_GE || op == TOK_GT)
+            swapped = !swapped;
+        else if (op == TOK_EQ || op == TOK_NE)
+            swapped = 0;
+        if (swapped)
+            o(0xc9d9); /* fxch %st(1) */
+        o(0xe9da); /* fucompp */
+        o(0xe0df); /* fnstsw %ax */
+        if (op == TOK_EQ) {
+            o(0x45e480); /* and $0x45, %ah */
+            o(0x40fC80); /* cmp $0x40, %ah */
+        } else if (op == TOK_NE) {
+            o(0x45e480); /* and $0x45, %ah */
+            o(0x40f480); /* xor $0x40, %ah */
+            op = TOK_NE;
+        } else if (op == TOK_GE || op == TOK_LE) {
+            o(0x05c4f6); /* test $0x05, %ah */
+            op = TOK_EQ;
+        } else {
+            o(0x45c4f6); /* test $0x45, %ah */
+            op = TOK_EQ;
+        }
+        vtop--;
+        vtop->r = VT_CMP;
+        vtop->c.i = op;
+    } else {
+        /* no memory reference possible for long double operations */
+        if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+            load(TREG_ST0, vtop);
+            swapped = !swapped;
+        }
+        
+        switch(op) {
+        default:
+        case '+':
+            a = 0;
+            break;
+        case '-':
+            a = 4;
+            if (swapped)
+                a++;
+            break;
+        case '*':
+            a = 1;
+            break;
+        case '/':
+            a = 6;
+            if (swapped)
+                a++;
+            break;
+        }
+        ft = vtop->type.t;
+        fc = vtop->c.ul;
+        if ((ft & VT_BTYPE) == VT_LDOUBLE) {
+            o(0xde); /* fxxxp %st, %st(1) */
+            o(0xc1 + (a << 3));
+        } else {
+            /* if saved lvalue, then we must reload it */
+            r = vtop->r;
+            if ((r & VT_VALMASK) == VT_LLOCAL) {
+                SValue v1;
+                r = get_reg(RC_INT);
+                v1.type.t = VT_INT;
+                v1.r = VT_LOCAL | VT_LVAL;
+                v1.c.ul = fc;
+                load(r, &v1);
+                fc = 0;
+            }
+
+            if ((ft & VT_BTYPE) == VT_DOUBLE)
+                o(0xdc);
+            else
+                o(0xd8);
+            gen_modrm(a, r, vtop->sym, fc);
+        }
+        vtop--;
+    }
+}
+
+/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
+   and 'long long' cases. */
+ST_FUNC void gen_cvt_itof(int t)
+{
+    save_reg(TREG_ST0);
+    gv(RC_INT);
+    if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
+        /* signed long long to float/double/long double (unsigned case
+           is handled generically) */
+        o(0x50 + vtop->r2); /* push r2 */
+        o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
+        o(0x242cdf); /* fildll (%esp) */
+        o(0x08c483); /* add $8, %esp */
+    } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == 
+               (VT_INT | VT_UNSIGNED)) {
+        /* unsigned int to float/double/long double */
+        o(0x6a); /* push $0 */
+        g(0x00);
+        o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
+        o(0x242cdf); /* fildll (%esp) */
+        o(0x08c483); /* add $8, %esp */
+    } else {
+        /* int to float/double/long double */
+        o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
+        o(0x2404db); /* fildl (%esp) */
+        o(0x04c483); /* add $4, %esp */
+    }
+    vtop->r = TREG_ST0;
+}
+
+/* convert fp to int 't' type */
+/* XXX: handle long long case */
+ST_FUNC void gen_cvt_ftoi(int t)
+{
+    int r, r2, size;
+    Sym *sym;
+    CType ushort_type;
+
+    ushort_type.t = VT_SHORT | VT_UNSIGNED;
+    ushort_type.ref = 0;
+
+    gv(RC_FLOAT);
+    if (t != VT_INT)
+        size = 8;
+    else 
+        size = 4;
+    
+    o(0x2dd9); /* ldcw xxx */
+    sym = external_global_sym(TOK___tcc_int_fpu_control, 
+                              &ushort_type, VT_LVAL);
+    greloc(cur_text_section, sym, 
+           ind, R_386_32);
+    gen_le32(0);
+    
+    oad(0xec81, size); /* sub $xxx, %esp */
+    if (size == 4)
+        o(0x1cdb); /* fistpl */
+    else
+        o(0x3cdf); /* fistpll */
+    o(0x24);
+    o(0x2dd9); /* ldcw xxx */
+    sym = external_global_sym(TOK___tcc_fpu_control, 
+                              &ushort_type, VT_LVAL);
+    greloc(cur_text_section, sym, 
+           ind, R_386_32);
+    gen_le32(0);
+
+    r = get_reg(RC_INT);
+    o(0x58 + r); /* pop r */
+    if (size == 8) {
+        if (t == VT_LLONG) {
+            vtop->r = r; /* mark reg as used */
+            r2 = get_reg(RC_INT);
+            o(0x58 + r2); /* pop r2 */
+            vtop->r2 = r2;
+        } else {
+            o(0x04c483); /* add $4, %esp */
+        }
+    }
+    vtop->r = r;
+}
+
+/* convert from one floating point type to another */
+ST_FUNC void gen_cvt_ftof(int t)
+{
+    /* all we have to do on i386 is to put the float in a register */
+    gv(RC_FLOAT);
+}
+
+/* computed goto support */
+ST_FUNC void ggoto(void)
+{
+    gcall_or_jmp(1);
+    vtop--;
+}
+
+/* bound check support functions */
+#ifdef CONFIG_TCC_BCHECK
+
+/* generate a bounded pointer addition */
+ST_FUNC void gen_bounded_ptr_add(void)
+{
+    Sym *sym;
+
+    /* prepare fast i386 function call (args in eax and edx) */
+    gv2(RC_EAX, RC_EDX);
+    /* save all temporary registers */
+    vtop -= 2;
+    save_regs(0);
+    /* do a fast function call */
+    sym = external_global_sym(TOK___bound_ptr_add, &func_old_type, 0);
+    greloc(cur_text_section, sym, 
+           ind + 1, R_386_PC32);
+    oad(0xe8, -4);
+    /* returned pointer is in eax */
+    vtop++;
+    vtop->r = TREG_EAX | VT_BOUNDED;
+    /* address of bounding function call point */
+    vtop->c.ul = (cur_text_section->reloc->data_offset - sizeof(Elf32_Rel)); 
+}
+
+/* patch pointer addition in vtop so that pointer dereferencing is
+   also tested */
+ST_FUNC void gen_bounded_ptr_deref(void)
+{
+    int func;
+    int size, align;
+    Elf32_Rel *rel;
+    Sym *sym;
+
+    size = 0;
+    /* XXX: put that code in generic part of tcc */
+    if (!is_float(vtop->type.t)) {
+        if (vtop->r & VT_LVAL_BYTE)
+            size = 1;
+        else if (vtop->r & VT_LVAL_SHORT)
+            size = 2;
+    }
+    if (!size)
+        size = type_size(&vtop->type, &align);
+    switch(size) {
+    case  1: func = TOK___bound_ptr_indir1; break;
+    case  2: func = TOK___bound_ptr_indir2; break;
+    case  4: func = TOK___bound_ptr_indir4; break;
+    case  8: func = TOK___bound_ptr_indir8; break;
+    case 12: func = TOK___bound_ptr_indir12; break;
+    case 16: func = TOK___bound_ptr_indir16; break;
+    default:
+        tcc_error("unhandled size when dereferencing bounded pointer");
+        func = 0;
+        break;
+    }
+
+    /* patch relocation */
+    /* XXX: find a better solution ? */
+    rel = (Elf32_Rel *)(cur_text_section->reloc->data + vtop->c.ul);
+    sym = external_global_sym(func, &func_old_type, 0);
+    if (!sym->c)
+        put_extern_sym(sym, NULL, 0, 0);
+    rel->r_info = ELF32_R_INFO(sym->c, ELF32_R_TYPE(rel->r_info));
+}
+#endif
+
+/* end of X86 code generator */
+/*************************************************************/
+#endif
+/*************************************************************/
Index: /EcnlProtoTool/trunk/tcc-0.9.26/i386-tok.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/i386-tok.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/i386-tok.h	(revision 279)
@@ -0,0 +1,243 @@
+/* ------------------------------------------------------------------ */
+/* WARNING: relative order of tokens is important. */
+
+/* register */
+ DEF_ASM(al)
+ DEF_ASM(cl)
+ DEF_ASM(dl)
+ DEF_ASM(bl)
+ DEF_ASM(ah)
+ DEF_ASM(ch)
+ DEF_ASM(dh)
+ DEF_ASM(bh)
+ DEF_ASM(ax)
+ DEF_ASM(cx)
+ DEF_ASM(dx)
+ DEF_ASM(bx)
+ DEF_ASM(sp)
+ DEF_ASM(bp)
+ DEF_ASM(si)
+ DEF_ASM(di)
+ DEF_ASM(eax)
+ DEF_ASM(ecx)
+ DEF_ASM(edx)
+ DEF_ASM(ebx)
+ DEF_ASM(esp)
+ DEF_ASM(ebp)
+ DEF_ASM(esi)
+ DEF_ASM(edi)
+#ifdef TCC_TARGET_X86_64
+ DEF_ASM(rax)
+ DEF_ASM(rcx)
+ DEF_ASM(rdx)
+ DEF_ASM(rbx)
+ DEF_ASM(rsp)
+ DEF_ASM(rbp)
+ DEF_ASM(rsi)
+ DEF_ASM(rdi)
+#endif
+ DEF_ASM(mm0)
+ DEF_ASM(mm1)
+ DEF_ASM(mm2)
+ DEF_ASM(mm3)
+ DEF_ASM(mm4)
+ DEF_ASM(mm5)
+ DEF_ASM(mm6)
+ DEF_ASM(mm7)
+ DEF_ASM(xmm0)
+ DEF_ASM(xmm1)
+ DEF_ASM(xmm2)
+ DEF_ASM(xmm3)
+ DEF_ASM(xmm4)
+ DEF_ASM(xmm5)
+ DEF_ASM(xmm6)
+ DEF_ASM(xmm7)
+ DEF_ASM(cr0)
+ DEF_ASM(cr1)
+ DEF_ASM(cr2)
+ DEF_ASM(cr3)
+ DEF_ASM(cr4)
+ DEF_ASM(cr5)
+ DEF_ASM(cr6)
+ DEF_ASM(cr7)
+ DEF_ASM(tr0)
+ DEF_ASM(tr1)
+ DEF_ASM(tr2)
+ DEF_ASM(tr3)
+ DEF_ASM(tr4)
+ DEF_ASM(tr5)
+ DEF_ASM(tr6)
+ DEF_ASM(tr7)
+ DEF_ASM(db0)
+ DEF_ASM(db1)
+ DEF_ASM(db2)
+ DEF_ASM(db3)
+ DEF_ASM(db4)
+ DEF_ASM(db5)
+ DEF_ASM(db6)
+ DEF_ASM(db7)
+ DEF_ASM(dr0)
+ DEF_ASM(dr1)
+ DEF_ASM(dr2)
+ DEF_ASM(dr3)
+ DEF_ASM(dr4)
+ DEF_ASM(dr5)
+ DEF_ASM(dr6)
+ DEF_ASM(dr7)
+ DEF_ASM(es)
+ DEF_ASM(cs)
+ DEF_ASM(ss)
+ DEF_ASM(ds)
+ DEF_ASM(fs)
+ DEF_ASM(gs)
+ DEF_ASM(st)
+
+ /* generic two operands */
+ DEF_BWLX(mov)
+
+ DEF_BWLX(add)
+ DEF_BWLX(or)
+ DEF_BWLX(adc)
+ DEF_BWLX(sbb)
+ DEF_BWLX(and)
+ DEF_BWLX(sub)
+ DEF_BWLX(xor)
+ DEF_BWLX(cmp)
+
+ /* unary ops */
+ DEF_BWLX(inc)
+ DEF_BWLX(dec)
+ DEF_BWLX(not)
+ DEF_BWLX(neg)
+ DEF_BWLX(mul)
+ DEF_BWLX(imul)
+ DEF_BWLX(div)
+ DEF_BWLX(idiv)
+
+ DEF_BWLX(xchg)
+ DEF_BWLX(test)
+
+ /* shifts */
+ DEF_BWLX(rol)
+ DEF_BWLX(ror)
+ DEF_BWLX(rcl)
+ DEF_BWLX(rcr)
+ DEF_BWLX(shl)
+ DEF_BWLX(shr)
+ DEF_BWLX(sar)
+
+ DEF_ASM(shldw)
+ DEF_ASM(shldl)
+ DEF_ASM(shld)
+ DEF_ASM(shrdw)
+ DEF_ASM(shrdl)
+ DEF_ASM(shrd)
+
+ DEF_ASM(pushw)
+ DEF_ASM(pushl)
+#ifdef TCC_TARGET_X86_64
+ DEF_ASM(pushq)
+#endif
+ DEF_ASM(push)
+
+ DEF_ASM(popw)
+ DEF_ASM(popl)
+#ifdef TCC_TARGET_X86_64
+ DEF_ASM(popq)
+#endif
+ DEF_ASM(pop)
+
+ DEF_BWL(in)
+ DEF_BWL(out)
+
+ DEF_WL(movzb)
+ DEF_ASM(movzwl)
+ DEF_ASM(movsbw)
+ DEF_ASM(movsbl)
+ DEF_ASM(movswl)
+#ifdef TCC_TARGET_X86_64
+ DEF_ASM(movslq)
+#endif
+
+ DEF_WLX(lea)
+
+ DEF_ASM(les)
+ DEF_ASM(lds)
+ DEF_ASM(lss)
+ DEF_ASM(lfs)
+ DEF_ASM(lgs)
+
+ DEF_ASM(call)
+ DEF_ASM(jmp)
+ DEF_ASM(lcall)
+ DEF_ASM(ljmp)
+
+ DEF_ASMTEST(j)
+
+ DEF_ASMTEST(set)
+ DEF_ASMTEST(cmov)
+
+ DEF_WLX(bsf)
+ DEF_WLX(bsr)
+ DEF_WLX(bt)
+ DEF_WLX(bts)
+ DEF_WLX(btr)
+ DEF_WLX(btc)
+
+ DEF_WLX(lsl)
+
+ /* generic FP ops */
+ DEF_FP(add)
+ DEF_FP(mul)
+
+ DEF_ASM(fcom)
+ DEF_ASM(fcom_1) /* non existant op, just to have a regular table */
+ DEF_FP1(com)
+
+ DEF_FP(comp)
+ DEF_FP(sub)
+ DEF_FP(subr)
+ DEF_FP(div)
+ DEF_FP(divr)
+
+ DEF_BWLX(xadd)
+ DEF_BWLX(cmpxchg)
+
+ /* string ops */
+ DEF_BWLX(cmps)
+ DEF_BWLX(scmp)
+ DEF_BWL(ins)
+ DEF_BWL(outs)
+ DEF_BWLX(lods)
+ DEF_BWLX(slod)
+ DEF_BWLX(movs)
+ DEF_BWLX(smov)
+ DEF_BWLX(scas)
+ DEF_BWLX(ssca)
+ DEF_BWLX(stos)
+ DEF_BWLX(ssto)
+
+ /* generic asm ops */
+#define ALT(x)
+#define DEF_ASM_OP0(name, opcode) DEF_ASM(name)
+#define DEF_ASM_OP0L(name, opcode, group, instr_type)
+#define DEF_ASM_OP1(name, opcode, group, instr_type, op0)
+#define DEF_ASM_OP2(name, opcode, group, instr_type, op0, op1)
+#define DEF_ASM_OP3(name, opcode, group, instr_type, op0, op1, op2)
+#ifdef TCC_TARGET_X86_64
+# include "x86_64-asm.h"
+#else
+# include "i386-asm.h"
+#endif
+
+#define ALT(x)
+#define DEF_ASM_OP0(name, opcode)
+#define DEF_ASM_OP0L(name, opcode, group, instr_type) DEF_ASM(name)
+#define DEF_ASM_OP1(name, opcode, group, instr_type, op0) DEF_ASM(name)
+#define DEF_ASM_OP2(name, opcode, group, instr_type, op0, op1) DEF_ASM(name)
+#define DEF_ASM_OP3(name, opcode, group, instr_type, op0, op1, op2) DEF_ASM(name)
+#ifdef TCC_TARGET_X86_64
+# include "x86_64-asm.h"
+#else
+# include "i386-asm.h"
+#endif
Index: /EcnlProtoTool/trunk/tcc-0.9.26/il-gen.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/il-gen.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/il-gen.c	(revision 279)
@@ -0,0 +1,715 @@
+/*
+ *  CIL code generator for TCC
+ * 
+ *  Copyright (c) 2002 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifdef TARGET_DEFS_ONLY
+
+/* number of available registers */
+#define NB_REGS             3
+#define NB_ASM_REGS         8 // TODO:
+#define ELF_PAGE_SIZE  0x1000 // TODO:
+#define MAX_ALIGN           8 // TODO:
+#define R_DATA_32   R_386_32 // TODO:
+#define R_DATA_PTR  R_386_32 // TODO:
+#define R_JMP_SLOT  R_386_JMP_SLOT // TODO:
+#define R_COPY      R_386_COPY // TODO:
+#define ELF_START_ADDR 0x08048000 // TODO:
+#define EM_TCC_TARGET 0xFF // TODO:
+
+/* a register can belong to several classes. The classes must be
+   sorted from more general to more precise (see gv2() code which does
+   assumptions on it). */
+#define RC_ST      0x0001  /* any stack entry */
+#define RC_ST0     0x0002  /* top of stack */
+#define RC_ST1     0x0004  /* top - 1 */
+
+#define RC_INT     RC_ST
+#define RC_FLOAT   RC_ST
+#define RC_IRET    RC_ST0 /* function return: integer register */
+#define RC_LRET    RC_ST0 /* function return: second integer register */
+#define RC_FRET    RC_ST0 /* function return: float register */
+
+/* pretty names for the registers */
+enum {
+    REG_ST0 = 0,
+    REG_ST1,
+    REG_ST2,
+};
+
+/* return registers for function */
+#define REG_IRET REG_ST0 /* single word int return register */
+#define REG_LRET REG_ST0 /* second word return register (for long long) */
+#define REG_FRET REG_ST0 /* float return register */
+
+/* defined if function parameters must be evaluated in reverse order */
+//#define INVERT_FUNC_PARAMS
+
+/* defined if structures are passed as pointers. Otherwise structures
+   are directly pushed on stack. */
+//#define FUNC_STRUCT_PARAM_AS_PTR
+
+/* pointer size, in bytes */
+#define PTR_SIZE 4
+
+/* long double size and alignment, in bytes */
+#define LDOUBLE_SIZE  8
+#define LDOUBLE_ALIGN 8
+
+/* function call context */
+typedef struct GFuncContext {
+    int func_call; /* func call type (FUNC_STDCALL or FUNC_CDECL) */
+} GFuncContext;
+
+/******************************************************/
+/* opcode definitions */
+
+#define IL_OP_PREFIX 0xFE
+
+enum ILOPCodes {
+#define ENUM_ILOPCODES_DEF
+#define OP(name, str, n) IL_OP_ ## name = n,
+#include "il-opcodes.h"
+#undef OP
+#undef ENUM_ILOPCODES_DEF
+};
+
+/******************************************************/
+#else /* ! TARGET_DEFS_ONLY */
+ /******************************************************/
+#include "tcc.h"
+
+const int reg_classes[NB_REGS] = {
+	/* ST0 */ RC_ST | RC_ST0,
+	/* ST1 */ RC_ST | RC_ST1,
+	/* ST2 */ RC_ST,
+};
+
+char *il_opcodes_str[] = {
+#define OP(name, str, n) /*[n] = */str,
+#include "il-opcodes.h"
+#undef OP
+};
+
+/******************************************************/
+
+/* arguments variable numbers start from there */
+#define ARG_BASE 0x70000000
+
+static FILE *il_outfile;
+
+static void out_byte(int c)
+{
+    int ind1 = ind + 1;
+    if (ind1 > cur_text_section->data_allocated)
+        section_realloc(cur_text_section, ind1);
+    *(char *)(cur_text_section->data + ind) = c;
+    ind++;
+}
+
+static void out_le32(int c)
+{
+    out_byte(c);
+    out_byte(c >> 8);
+    out_byte(c >> 16);
+    out_byte(c >> 24);
+}
+
+static void init_outfile(void)
+{
+    if (!il_outfile) {
+        il_outfile = stdout;
+        fprintf(il_outfile, 
+                ".assembly extern mscorlib\n"
+                "{\n"
+                ".ver 1:0:2411:0\n"
+                "}\n\n");
+    }
+}
+
+static void out_op1(int op)
+{
+    if (op & 0x100)
+        out_byte(IL_OP_PREFIX);
+    out_byte(op & 0xff);
+}
+
+/* output an opcode with prefix */
+static void out_op(int op)
+{
+    out_op1(op);
+    fprintf(il_outfile, " %s\n", il_opcodes_str[op]);
+}
+
+static void out_opb(int op, int c)
+{
+    out_op1(op);
+    out_byte(c);
+    fprintf(il_outfile, " %s %d\n", il_opcodes_str[op], c);
+}
+
+static void out_opi(int op, int c)
+{
+    out_op1(op);
+    out_le32(c);
+    fprintf(il_outfile, " %s 0x%x\n", il_opcodes_str[op], c);
+}
+
+/* XXX: not complete */
+static void il_type_to_str(char *buf, int buf_size, 
+                           int t, const char *varstr)
+{
+    int bt;
+    Sym *s, *sa;
+    char buf1[256];
+    const char *tstr;
+
+    t = t & VT_TYPE;
+    bt = t & VT_BTYPE;
+    buf[0] = '\0';
+    if (t & VT_UNSIGNED)
+        pstrcat(buf, buf_size, "unsigned ");
+    switch(bt) {
+    case VT_VOID:
+        tstr = "void";
+        goto add_tstr;
+    case VT_BOOL:
+        tstr = "bool";
+        goto add_tstr;
+    case VT_BYTE:
+        tstr = "int8";
+        goto add_tstr;
+    case VT_SHORT:
+        tstr = "int16";
+        goto add_tstr;
+    case VT_ENUM:
+    case VT_INT:
+    case VT_LONG:
+        tstr = "int32";
+        goto add_tstr;
+    case VT_LLONG:
+        tstr = "int64";
+        goto add_tstr;
+    case VT_FLOAT:
+        tstr = "float32";
+        goto add_tstr;
+    case VT_DOUBLE:
+    case VT_LDOUBLE:
+        tstr = "float64";
+    add_tstr:
+        pstrcat(buf, buf_size, tstr);
+        break;
+    case VT_STRUCT:
+        tcc_error("structures not handled yet");
+        break;
+    case VT_FUNC:
+        s = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
+        if (s == NULL)
+            break;
+        il_type_to_str(buf, buf_size, s->type.t, varstr);
+        pstrcat(buf, buf_size, "(");
+        sa = s->next;
+        while (sa != NULL) {
+            il_type_to_str(buf1, sizeof(buf1), sa->type.t, NULL);
+            pstrcat(buf, buf_size, buf1);
+            sa = sa->next;
+            if (sa)
+                pstrcat(buf, buf_size, ", ");
+        }
+        pstrcat(buf, buf_size, ")");
+        goto no_var;
+    case VT_PTR:
+        s = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
+        if (s == NULL)
+            break;
+        pstrcpy(buf1, sizeof(buf1), "*");
+        if (varstr)
+            pstrcat(buf1, sizeof(buf1), varstr);
+        il_type_to_str(buf, buf_size, s->type.t, buf1);
+        goto no_var;
+    }
+    if (varstr) {
+        pstrcat(buf, buf_size, " ");
+        pstrcat(buf, buf_size, varstr);
+    }
+ no_var: ;
+}
+
+#define Reloc void
+/* patch relocation entry with value 'val' */
+void greloc_patch1(Reloc *p, int val)
+{
+}
+
+/* output a symbol and patch all calls to it */
+void gsym_addr(t, a)
+{
+}
+
+/* output jump and return symbol */
+static int out_opj(int op, int c)
+{
+    out_op1(op);
+    out_le32(0);
+    if (c == 0) {
+        c = ind - (int)cur_text_section->data;
+    }
+    fprintf(il_outfile, " %s L%d\n", il_opcodes_str[op], c);
+    return c;
+}
+
+void gsym(int t)
+{
+    fprintf(il_outfile, "L%d:\n", t);
+}
+
+/* load 'r' from value 'sv' */
+void load(int r, SValue *sv)
+{
+    int v, fc, ft;
+
+    v = sv->r & VT_VALMASK;
+    fc = sv->c.i;
+    ft = sv->type.t;
+
+    if (sv->r & VT_LVAL) {
+        if (v == VT_LOCAL) {
+            if (fc >= ARG_BASE) {
+                fc -= ARG_BASE;
+                if (fc >= 0 && fc <= 4) {
+                    out_op(IL_OP_LDARG_0 + fc);
+                } else if (fc <= 0xff) {
+                    out_opb(IL_OP_LDARG_S, fc);
+                } else {
+                    out_opi(IL_OP_LDARG, fc);
+                }
+            } else {
+                if (fc >= 0 && fc <= 4) {
+                    out_op(IL_OP_LDLOC_0 + fc);
+                } else if (fc <= 0xff) {
+                    out_opb(IL_OP_LDLOC_S, fc);
+                } else {
+                    out_opi(IL_OP_LDLOC, fc);
+                }
+            }
+        } else if (v == VT_CONST) {
+                /* XXX: handle globals */
+                out_opi(IL_OP_LDSFLD, 0);
+        } else {
+            if ((ft & VT_BTYPE) == VT_FLOAT) {
+                out_op(IL_OP_LDIND_R4);
+            } else if ((ft & VT_BTYPE) == VT_DOUBLE) {
+                out_op(IL_OP_LDIND_R8);
+            } else if ((ft & VT_BTYPE) == VT_LDOUBLE) {
+                out_op(IL_OP_LDIND_R8);
+            } else if ((ft & VT_TYPE) == VT_BYTE)
+                out_op(IL_OP_LDIND_I1);
+            else if ((ft & VT_TYPE) == (VT_BYTE | VT_UNSIGNED))
+                out_op(IL_OP_LDIND_U1);
+            else if ((ft & VT_TYPE) == VT_SHORT)
+                out_op(IL_OP_LDIND_I2);
+            else if ((ft & VT_TYPE) == (VT_SHORT | VT_UNSIGNED))
+                out_op(IL_OP_LDIND_U2);
+            else
+                out_op(IL_OP_LDIND_I4);
+        } 
+    } else {
+        if (v == VT_CONST) {
+            /* XXX: handle globals */
+            if (fc >= -1 && fc <= 8) {
+                out_op(IL_OP_LDC_I4_M1 + fc + 1); 
+            } else {
+                out_opi(IL_OP_LDC_I4, fc);
+            }
+        } else if (v == VT_LOCAL) {
+            if (fc >= ARG_BASE) {
+                fc -= ARG_BASE;
+                if (fc <= 0xff) {
+                    out_opb(IL_OP_LDARGA_S, fc);
+                } else {
+                    out_opi(IL_OP_LDARGA, fc);
+                }
+            } else {
+                if (fc <= 0xff) {
+                    out_opb(IL_OP_LDLOCA_S, fc);
+                } else {
+                    out_opi(IL_OP_LDLOCA, fc);
+                }
+            }
+        } else {
+            /* XXX: do it */
+        }
+    }
+}
+
+/* store register 'r' in lvalue 'v' */
+void store(int r, SValue *sv)
+{
+    int v, fc, ft;
+
+    v = sv->r & VT_VALMASK;
+    fc = sv->c.i;
+    ft = sv->type.t;
+    if (v == VT_LOCAL) {
+        if (fc >= ARG_BASE) {
+            fc -= ARG_BASE;
+            /* XXX: check IL arg store semantics */
+            if (fc <= 0xff) {
+                out_opb(IL_OP_STARG_S, fc);
+            } else {
+                out_opi(IL_OP_STARG, fc);
+            }
+        } else {
+            if (fc >= 0 && fc <= 4) {
+                out_op(IL_OP_STLOC_0 + fc);
+            } else if (fc <= 0xff) {
+                out_opb(IL_OP_STLOC_S, fc);
+            } else {
+                out_opi(IL_OP_STLOC, fc);
+            }
+        }
+    } else if (v == VT_CONST) {
+        /* XXX: handle globals */
+        out_opi(IL_OP_STSFLD, 0);
+    } else {
+        if ((ft & VT_BTYPE) == VT_FLOAT)
+            out_op(IL_OP_STIND_R4);
+        else if ((ft & VT_BTYPE) == VT_DOUBLE)
+            out_op(IL_OP_STIND_R8);
+        else if ((ft & VT_BTYPE) == VT_LDOUBLE)
+            out_op(IL_OP_STIND_R8);
+        else if ((ft & VT_BTYPE) == VT_BYTE)
+            out_op(IL_OP_STIND_I1);
+        else if ((ft & VT_BTYPE) == VT_SHORT)
+            out_op(IL_OP_STIND_I2);
+        else
+            out_op(IL_OP_STIND_I4);
+    }
+}
+
+/* start function call and return function call context */
+void gfunc_start(GFuncContext *c, int func_call)
+{
+    c->func_call = func_call;
+}
+
+/* push function parameter which is in (vtop->t, vtop->c). Stack entry
+   is then popped. */
+void gfunc_param(GFuncContext *c)
+{
+    if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+        tcc_error("structures passed as value not handled yet");
+    } else {
+        /* simply push on stack */
+        gv(RC_ST0);
+    }
+    vtop--;
+}
+
+/* generate function call with address in (vtop->t, vtop->c) and free function
+   context. Stack entry is popped */
+void gfunc_call(GFuncContext *c)
+{
+    char buf[1024];
+
+    if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+        /* XXX: more info needed from tcc */
+        il_type_to_str(buf, sizeof(buf), vtop->type.t, "xxx");
+        fprintf(il_outfile, " call %s\n", buf);
+    } else {
+        /* indirect call */
+        gv(RC_INT);
+        il_type_to_str(buf, sizeof(buf), vtop->type.t, NULL);
+        fprintf(il_outfile, " calli %s\n", buf);
+    }
+    vtop--;
+}
+
+/* generate function prolog of type 't' */
+void gfunc_prolog(int t)
+{
+    int addr, u, func_call;
+    Sym *sym;
+    char buf[1024];
+
+    init_outfile();
+
+    /* XXX: pass function name to gfunc_prolog */
+    il_type_to_str(buf, sizeof(buf), t, funcname);
+    fprintf(il_outfile, ".method static %s il managed\n", buf);
+    fprintf(il_outfile, "{\n");
+    /* XXX: cannot do better now */
+    fprintf(il_outfile, " .maxstack %d\n", NB_REGS);
+    fprintf(il_outfile, " .locals (int32, int32, int32, int32, int32, int32, int32, int32)\n");
+    
+    if (!strcmp(funcname, "main"))
+        fprintf(il_outfile, " .entrypoint\n");
+        
+    sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
+    if (sym == NULL)
+        return;
+
+    addr = ARG_BASE;
+    /* if the function returns a structure, then add an
+       implicit pointer parameter */
+    func_vt = sym->type;
+    if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
+        func_vc = addr;
+        addr++;
+    }
+    /* define parameters */
+    while ((sym = sym->next) != NULL) {
+        u = sym->type.t;
+        sym_push(sym->v & ~SYM_FIELD, u,
+                 VT_LOCAL | lvalue_type(sym->type.t), addr);
+        addr++;
+    }
+}
+
+/* generate function epilog */
+void gfunc_epilog(void)
+{
+    out_op(IL_OP_RET);
+    fprintf(il_outfile, "}\n\n");
+}
+
+/* generate a jump to a label */
+int gjmp(int t)
+{
+    return out_opj(IL_OP_BR, t);
+}
+
+/* generate a jump to a fixed address */
+void gjmp_addr(int a)
+{
+    /* XXX: handle syms */
+    out_opi(IL_OP_BR, a);
+}
+
+/* generate a test. set 'inv' to invert test. Stack entry is popped */
+int gtst(int inv, int t)
+{
+    int v, *p, c;
+
+    v = vtop->r & VT_VALMASK;
+    if (v == VT_CMP) {
+        c = vtop->c.i ^ inv;
+        switch(c) {
+        case TOK_EQ:
+            c = IL_OP_BEQ;
+            break;
+        case TOK_NE:
+            c = IL_OP_BNE_UN;
+            break;
+        case TOK_LT:
+            c = IL_OP_BLT;
+            break;
+        case TOK_LE:
+            c = IL_OP_BLE;
+            break;
+        case TOK_GT:
+            c = IL_OP_BGT;
+            break;
+        case TOK_GE:
+            c = IL_OP_BGE;
+            break;
+        case TOK_ULT:
+            c = IL_OP_BLT_UN;
+            break;
+        case TOK_ULE:
+            c = IL_OP_BLE_UN;
+            break;
+        case TOK_UGT:
+            c = IL_OP_BGT_UN;
+            break;
+        case TOK_UGE:
+            c = IL_OP_BGE_UN;
+            break;
+        }
+        t = out_opj(c, t);
+    } else if (v == VT_JMP || v == VT_JMPI) {
+        /* && or || optimization */
+        if ((v & 1) == inv) {
+            /* insert vtop->c jump list in t */
+            p = &vtop->c.i;
+            while (*p != 0)
+                p = (int *)*p;
+            *p = t;
+            t = vtop->c.i;
+        } else {
+            t = gjmp(t);
+            gsym(vtop->c.i);
+        }
+    } else {
+        if (is_float(vtop->type.t)) {
+            vpushi(0);
+            gen_op(TOK_NE);
+        }
+#define VT_FORWARD 0
+        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST) {
+            /* constant jmp optimization */
+            if ((vtop->c.i != 0) != inv) 
+                t = gjmp(t);
+        } else {
+            v = gv(RC_INT);
+            t = out_opj(IL_OP_BRTRUE - inv, t);
+        }
+    }
+    vtop--;
+    return t;
+}
+
+/* generate an integer binary operation */
+void gen_opi(int op)
+{
+    gv2(RC_ST1, RC_ST0);
+    switch(op) {
+    case '+':
+        out_op(IL_OP_ADD);
+        goto std_op;
+    case '-':
+        out_op(IL_OP_SUB);
+        goto std_op;
+    case '&':
+        out_op(IL_OP_AND);
+        goto std_op;
+    case '^':
+        out_op(IL_OP_XOR);
+        goto std_op;
+    case '|':
+        out_op(IL_OP_OR);
+        goto std_op;
+    case '*':
+        out_op(IL_OP_MUL);
+        goto std_op;
+    case TOK_SHL:
+        out_op(IL_OP_SHL);
+        goto std_op;
+    case TOK_SHR:
+        out_op(IL_OP_SHR_UN);
+        goto std_op;
+    case TOK_SAR:
+        out_op(IL_OP_SHR);
+        goto std_op;
+    case '/':
+    case TOK_PDIV:
+        out_op(IL_OP_DIV);
+        goto std_op;
+    case TOK_UDIV:
+        out_op(IL_OP_DIV_UN);
+        goto std_op;
+    case '%':
+        out_op(IL_OP_REM);
+        goto std_op;
+    case TOK_UMOD:
+        out_op(IL_OP_REM_UN);
+    std_op:
+        vtop--;
+        vtop[0].r = REG_ST0;
+        break;
+    case TOK_EQ:
+    case TOK_NE:
+    case TOK_LT:
+    case TOK_LE:
+    case TOK_GT:
+    case TOK_GE:
+    case TOK_ULT:
+    case TOK_ULE:
+    case TOK_UGT:
+    case TOK_UGE:
+        vtop--;
+        vtop[0].r = VT_CMP;
+        vtop[0].c.i = op;
+        break;
+    }
+}
+
+/* generate a floating point operation 'v = t1 op t2' instruction. The
+   two operands are guaranted to have the same floating point type */
+void gen_opf(int op)
+{
+    /* same as integer */
+    gen_opi(op);
+}
+
+/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
+   and 'long long' cases. */
+void gen_cvt_itof(int t)
+{
+    gv(RC_ST0);
+    if (t == VT_FLOAT)
+        out_op(IL_OP_CONV_R4);
+    else
+        out_op(IL_OP_CONV_R8);
+}
+
+/* convert fp to int 't' type */
+/* XXX: handle long long case */
+void gen_cvt_ftoi(int t)
+{
+    gv(RC_ST0);
+    switch(t) {
+    case VT_INT | VT_UNSIGNED:
+        out_op(IL_OP_CONV_U4);
+        break;
+    case VT_LLONG:
+        out_op(IL_OP_CONV_I8);
+        break;
+    case VT_LLONG | VT_UNSIGNED:
+        out_op(IL_OP_CONV_U8);
+        break;
+    default:
+        out_op(IL_OP_CONV_I4);
+        break;
+    }
+}
+
+/* convert from one floating point type to another */
+void gen_cvt_ftof(int t)
+{
+    gv(RC_ST0);
+    if (t == VT_FLOAT) {
+        out_op(IL_OP_CONV_R4);
+    } else {
+        out_op(IL_OP_CONV_R8);
+    }
+}
+
+void ggoto(void) { }
+void gen_bounded_ptr_add(void) {}
+void gen_bounded_ptr_deref(int t) {}
+void gen_expr32(void) {}
+void asm_opcode(TCCState *s1, int opcode) {}
+void asm_compute_constraints(ASMOperand *operands,
+	int nb_operands, int nb_outputs,
+	const uint8_t *clobber_regs,
+	int *pout_reg) {}
+void subst_asm_operand(CString *add_str,
+	SValue *sv, int modifier) {}
+void asm_gen_code(ASMOperand *operands, int nb_operands,
+	int nb_outputs, int is_output,
+	uint8_t *clobber_regs,
+	int out_reg) {}
+void asm_clobber(uint8_t *clobber_regs, const char *str) {}
+void gen_le32(int c) {}
+void g(int c) {}
+void gen_le16(int v) {}
+
+/* end of CIL code generator */
+/*************************************************************/
+#endif
+/*************************************************************/
Index: /EcnlProtoTool/trunk/tcc-0.9.26/il-opcodes.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/il-opcodes.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/il-opcodes.h	(revision 279)
@@ -0,0 +1,330 @@
+/*
+ *  CIL opcode definition
+ * 
+ *  Copyright (c) 2002 Fabrice Bellard
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+OP(NOP, "nop", 0x00)
+OP(BREAK, "break", 0x01)
+OP(LDARG_0, "ldarg.0", 0x02)
+OP(LDARG_1, "ldarg.1", 0x03)
+OP(LDARG_2, "ldarg.2", 0x04)
+OP(LDARG_3, "ldarg.3", 0x05)
+OP(LDLOC_0, "ldloc.0", 0x06)
+OP(LDLOC_1, "ldloc.1", 0x07)
+OP(LDLOC_2, "ldloc.2", 0x08)
+OP(LDLOC_3, "ldloc.3", 0x09)
+OP(STLOC_0, "stloc.0", 0x0a)
+OP(STLOC_1, "stloc.1", 0x0b)
+OP(STLOC_2, "stloc.2", 0x0c)
+OP(STLOC_3, "stloc.3", 0x0d)
+OP(LDARG_S, "ldarg.s", 0x0e)
+OP(LDARGA_S, "ldarga.s", 0x0f)
+OP(STARG_S, "starg.s", 0x10)
+OP(LDLOC_S, "ldloc.s", 0x11)
+OP(LDLOCA_S, "ldloca.s", 0x12)
+OP(STLOC_S, "stloc.s", 0x13)
+OP(LDNULL, "ldnull", 0x14)
+OP(LDC_I4_M1, "ldc.i4.m1", 0x15)
+OP(LDC_I4_0, "ldc.i4.0", 0x16)
+OP(LDC_I4_1, "ldc.i4.1", 0x17)
+OP(LDC_I4_2, "ldc.i4.2", 0x18)
+OP(LDC_I4_3, "ldc.i4.3", 0x19)
+OP(LDC_I4_4, "ldc.i4.4", 0x1a)
+OP(LDC_I4_5, "ldc.i4.5", 0x1b)
+OP(LDC_I4_6, "ldc.i4.6", 0x1c)
+OP(LDC_I4_7, "ldc.i4.7", 0x1d)
+OP(LDC_I4_8, "ldc.i4.8", 0x1e)
+OP(LDC_I4_S, "ldc.i4.s", 0x1f)
+OP(LDC_I4, "ldc.i4", 0x20)
+OP(LDC_I8, "ldc.i8", 0x21)
+OP(LDC_R4, "ldc.r4", 0x22)
+OP(LDC_R8, "ldc.r8", 0x23)
+OP(LDPTR, "ldptr", 0x24)
+OP(DUP, "dup", 0x25)
+OP(POP, "pop", 0x26)
+OP(JMP, "jmp", 0x27)
+OP(CALL, "call", 0x28)
+OP(CALLI, "calli", 0x29)
+OP(RET, "ret", 0x2a)
+OP(BR_S, "br.s", 0x2b)
+OP(BRFALSE_S, "brfalse.s", 0x2c)
+OP(BRTRUE_S, "brtrue.s", 0x2d)
+OP(BEQ_S, "beq.s", 0x2e)
+OP(BGE_S, "bge.s", 0x2f)
+OP(BGT_S, "bgt.s", 0x30)
+OP(BLE_S, "ble.s", 0x31)
+OP(BLT_S, "blt.s", 0x32)
+OP(BNE_UN_S, "bne.un.s", 0x33)
+OP(BGE_UN_S, "bge.un.s", 0x34)
+OP(BGT_UN_S, "bgt.un.s", 0x35)
+OP(BLE_UN_S, "ble.un.s", 0x36)
+OP(BLT_UN_S, "blt.un.s", 0x37)
+OP(BR, "br", 0x38)
+OP(BRFALSE, "brfalse", 0x39)
+OP(BRTRUE, "brtrue", 0x3a)
+OP(BEQ, "beq", 0x3b)
+OP(BGE, "bge", 0x3c)
+OP(BGT, "bgt", 0x3d)
+OP(BLE, "ble", 0x3e)
+OP(BLT, "blt", 0x3f)
+OP(BNE_UN, "bne.un", 0x40)
+OP(BGE_UN, "bge.un", 0x41)
+OP(BGT_UN, "bgt.un", 0x42)
+OP(BLE_UN, "ble.un", 0x43)
+OP(BLT_UN, "blt.un", 0x44)
+OP(SWITCH, "switch", 0x45)
+OP(LDIND_I1, "ldind.i1", 0x46)
+OP(LDIND_U1, "ldind.u1", 0x47)
+OP(LDIND_I2, "ldind.i2", 0x48)
+OP(LDIND_U2, "ldind.u2", 0x49)
+OP(LDIND_I4, "ldind.i4", 0x4a)
+OP(LDIND_U4, "ldind.u4", 0x4b)
+OP(LDIND_I8, "ldind.i8", 0x4c)
+OP(LDIND_I, "ldind.i", 0x4d)
+OP(LDIND_R4, "ldind.r4", 0x4e)
+OP(LDIND_R8, "ldind.r8", 0x4f)
+OP(LDIND_REF, "ldind.ref", 0x50)
+OP(STIND_REF, "stind.ref", 0x51)
+OP(STIND_I1, "stind.i1", 0x52)
+OP(STIND_I2, "stind.i2", 0x53)
+OP(STIND_I4, "stind.i4", 0x54)
+OP(STIND_I8, "stind.i8", 0x55)
+OP(STIND_R4, "stind.r4", 0x56)
+OP(STIND_R8, "stind.r8", 0x57)
+OP(ADD, "add", 0x58)
+OP(SUB, "sub", 0x59)
+OP(MUL, "mul", 0x5a)
+OP(DIV, "div", 0x5b)
+OP(DIV_UN, "div.un", 0x5c)
+OP(REM, "rem", 0x5d)
+OP(REM_UN, "rem.un", 0x5e)
+OP(AND, "and", 0x5f)
+OP(OR, "or", 0x60)
+OP(XOR, "xor", 0x61)
+OP(SHL, "shl", 0x62)
+OP(SHR, "shr", 0x63)
+OP(SHR_UN, "shr.un", 0x64)
+OP(NEG, "neg", 0x65)
+OP(NOT, "not", 0x66)
+OP(CONV_I1, "conv.i1", 0x67)
+OP(CONV_I2, "conv.i2", 0x68)
+OP(CONV_I4, "conv.i4", 0x69)
+OP(CONV_I8, "conv.i8", 0x6a)
+OP(CONV_R4, "conv.r4", 0x6b)
+OP(CONV_R8, "conv.r8", 0x6c)
+OP(CONV_U4, "conv.u4", 0x6d)
+OP(CONV_U8, "conv.u8", 0x6e)
+OP(CALLVIRT, "callvirt", 0x6f)
+OP(CPOBJ, "cpobj", 0x70)
+OP(LDOBJ, "ldobj", 0x71)
+OP(LDSTR, "ldstr", 0x72)
+OP(NEWOBJ, "newobj", 0x73)
+OP(CASTCLASS, "castclass", 0x74)
+OP(ISINST, "isinst", 0x75)
+OP(CONV_R_UN, "conv.r.un", 0x76)
+OP(ANN_DATA_S, "ann.data.s", 0x77)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0x78)
+#endif
+OP(UNBOX, "unbox", 0x79)
+OP(THROW, "throw", 0x7a)
+OP(LDFLD, "ldfld", 0x7b)
+OP(LDFLDA, "ldflda", 0x7c)
+OP(STFLD, "stfld", 0x7d)
+OP(LDSFLD, "ldsfld", 0x7e)
+OP(LDSFLDA, "ldsflda", 0x7f)
+OP(STSFLD, "stsfld", 0x80)
+OP(STOBJ, "stobj", 0x81)
+OP(CONV_OVF_I1_UN, "conv.ovf.i1.un", 0x82)
+OP(CONV_OVF_I2_UN, "conv.ovf.i2.un", 0x83)
+OP(CONV_OVF_I4_UN, "conv.ovf.i4.un", 0x84)
+OP(CONV_OVF_I8_UN, "conv.ovf.i8.un", 0x85)
+OP(CONV_OVF_U1_UN, "conv.ovf.u1.un", 0x86)
+OP(CONV_OVF_U2_UN, "conv.ovf.u2.un", 0x87)
+OP(CONV_OVF_U4_UN, "conv.ovf.u4.un", 0x88)
+OP(CONV_OVF_U8_UN, "conv.ovf.u8.un", 0x89)
+OP(CONV_OVF_I_UN, "conv.ovf.i.un", 0x8a)
+OP(CONV_OVF_U_UN, "conv.ovf.u.un", 0x8b)
+OP(BOX, "box", 0x8c)
+OP(NEWARR, "newarr", 0x8d)
+OP(LDLEN, "ldlen", 0x8e)
+OP(LDELEMA, "ldelema", 0x8f)
+OP(LDELEM_I1, "ldelem.i1", 0x90)
+OP(LDELEM_U1, "ldelem.u1", 0x91)
+OP(LDELEM_I2, "ldelem.i2", 0x92)
+OP(LDELEM_U2, "ldelem.u2", 0x93)
+OP(LDELEM_I4, "ldelem.i4", 0x94)
+OP(LDELEM_U4, "ldelem.u4", 0x95)
+OP(LDELEM_I8, "ldelem.i8", 0x96)
+OP(LDELEM_I, "ldelem.i", 0x97)
+OP(LDELEM_R4, "ldelem.r4", 0x98)
+OP(LDELEM_R8, "ldelem.r8", 0x99)
+OP(LDELEM_REF, "ldelem.ref", 0x9a)
+OP(STELEM_I, "stelem.i", 0x9b)
+OP(STELEM_I1, "stelem.i1", 0x9c)
+OP(STELEM_I2, "stelem.i2", 0x9d)
+OP(STELEM_I4, "stelem.i4", 0x9e)
+OP(STELEM_I8, "stelem.i8", 0x9f)
+OP(STELEM_R4, "stelem.r4", 0xa0)
+OP(STELEM_R8, "stelem.r8", 0xa1)
+OP(STELEM_REF, "stelem.ref", 0xa2)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0xa3)
+OP(0, NULL, 0xa4)
+OP(0, NULL, 0xa5)
+OP(0, NULL, 0xa6)
+OP(0, NULL, 0xa7)
+OP(0, NULL, 0xa8)
+OP(0, NULL, 0xa9)
+OP(0, NULL, 0xaa)
+OP(0, NULL, 0xab)
+OP(0, NULL, 0xac)
+OP(0, NULL, 0xad)
+OP(0, NULL, 0xae)
+OP(0, NULL, 0xaf)
+OP(0, NULL, 0xb0)
+OP(0, NULL, 0xb1)
+OP(0, NULL, 0xb2)
+#endif
+OP(CONV_OVF_I1, "conv.ovf.i1", 0xb3)
+OP(CONV_OVF_U1, "conv.ovf.u1", 0xb4)
+OP(CONV_OVF_I2, "conv.ovf.i2", 0xb5)
+OP(CONV_OVF_U2, "conv.ovf.u2", 0xb6)
+OP(CONV_OVF_I4, "conv.ovf.i4", 0xb7)
+OP(CONV_OVF_U4, "conv.ovf.u4", 0xb8)
+OP(CONV_OVF_I8, "conv.ovf.i8", 0xb9)
+OP(CONV_OVF_U8, "conv.ovf.u8", 0xba)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0xbb)
+OP(0, NULL, 0xbc)
+OP(0, NULL, 0xbd)
+OP(0, NULL, 0xbe)
+OP(0, NULL, 0xbf)
+OP(0, NULL, 0xc0)
+OP(0, NULL, 0xc1)
+#endif
+OP(REFANYVAL, "refanyval", 0xc2)
+OP(CKFINITE, "ckfinite", 0xc3)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0xc4)
+OP(0, NULL, 0xc5)
+#endif
+OP(MKREFANY, "mkrefany", 0xc6)
+OP(ANN_CALL, "ann.call", 0xc7)
+OP(ANN_CATCH, "ann.catch", 0xc8)
+OP(ANN_DEAD, "ann.dead", 0xc9)
+OP(ANN_HOISTED, "ann.hoisted", 0xca)
+OP(ANN_HOISTED_CALL, "ann.hoisted.call", 0xcb)
+OP(ANN_LAB, "ann.lab", 0xcc)
+OP(ANN_DEF, "ann.def", 0xcd)
+OP(ANN_REF_S, "ann.ref.s", 0xce)
+OP(ANN_PHI, "ann.phi", 0xcf)
+OP(LDTOKEN, "ldtoken", 0xd0)
+OP(CONV_U2, "conv.u2", 0xd1)
+OP(CONV_U1, "conv.u1", 0xd2)
+OP(CONV_I, "conv.i", 0xd3)
+OP(CONV_OVF_I, "conv.ovf.i", 0xd4)
+OP(CONV_OVF_U, "conv.ovf.u", 0xd5)
+OP(ADD_OVF, "add.ovf", 0xd6)
+OP(ADD_OVF_UN, "add.ovf.un", 0xd7)
+OP(MUL_OVF, "mul.ovf", 0xd8)
+OP(MUL_OVF_UN, "mul.ovf.un", 0xd9)
+OP(SUB_OVF, "sub.ovf", 0xda)
+OP(SUB_OVF_UN, "sub.ovf.un", 0xdb)
+OP(ENDFINALLY, "endfinally", 0xdc)
+OP(LEAVE, "leave", 0xdd)
+OP(LEAVE_S, "leave.s", 0xde)
+OP(STIND_I, "stind.i", 0xdf)
+OP(CONV_U, "conv.u", 0xe0)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0xe1)
+OP(0, NULL, 0xe2)
+OP(0, NULL, 0xe3)
+OP(0, NULL, 0xe4)
+OP(0, NULL, 0xe5)
+OP(0, NULL, 0xe6)
+OP(0, NULL, 0xe7)
+OP(0, NULL, 0xe8)
+OP(0, NULL, 0xe9)
+OP(0, NULL, 0xea)
+OP(0, NULL, 0xeb)
+OP(0, NULL, 0xec)
+OP(0, NULL, 0xed)
+OP(0, NULL, 0xee)
+OP(0, NULL, 0xef)
+OP(0, NULL, 0xf0)
+OP(0, NULL, 0xf1)
+OP(0, NULL, 0xf2)
+OP(0, NULL, 0xf3)
+OP(0, NULL, 0xf4)
+OP(0, NULL, 0xf5)
+OP(0, NULL, 0xf6)
+OP(0, NULL, 0xf7)
+OP(0, NULL, 0xf8)
+OP(0, NULL, 0xf9)
+OP(0, NULL, 0xfa)
+OP(0, NULL, 0xfb)
+OP(0, NULL, 0xfc)
+OP(0, NULL, 0xfd)
+OP(0, NULL, 0xfe)
+OP(0, NULL, 0xff)
+#endif
+
+/* prefix instructions. we use an opcode >= 256 to ease coding */
+
+OP(ARGLIST, "arglist", 0x100)
+OP(CEQ, "ceq", 0x101)
+OP(CGT, "cgt", 0x102)
+OP(CGT_UN, "cgt.un", 0x103)
+OP(CLT, "clt", 0x104)
+OP(CLT_UN, "clt.un", 0x105)
+OP(LDFTN, "ldftn", 0x106)
+OP(LDVIRTFTN, "ldvirtftn", 0x107)
+OP(JMPI, "jmpi", 0x108)
+OP(LDARG, "ldarg", 0x109)
+OP(LDARGA, "ldarga", 0x10a)
+OP(STARG, "starg", 0x10b)
+OP(LDLOC, "ldloc", 0x10c)
+OP(LDLOCA, "ldloca", 0x10d)
+OP(STLOC, "stloc", 0x10e)
+OP(LOCALLOC, "localloc", 0x10f)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0x110)
+#endif
+OP(ENDFILTER, "endfilter", 0x111)
+OP(UNALIGNED, "unaligned", 0x112)
+OP(VOLATILE, "volatile", 0x113)
+OP(TAIL, "tail", 0x114)
+OP(INITOBJ, "initobj", 0x115)
+OP(ANN_LIVE, "ann.live", 0x116)
+OP(CPBLK, "cpblk", 0x117)
+OP(INITBLK, "initblk", 0x118)
+OP(ANN_REF, "ann.ref", 0x119)
+OP(RETHROW, "rethrow", 0x11a)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0x11b)
+#endif
+OP(SIZEOF, "sizeof", 0x11c)
+OP(REFANYTYPE, "refanytype", 0x11d)
+#ifndef ENUM_ILOPCODES_DEF
+OP(0, NULL, 0x11e)
+OP(0, NULL, 0x11f)
+OP(0, NULL, 0x120)
+OP(0, NULL, 0x121)
+#endif
+OP(ANN_DATA, "ann.data", 0x122)
+OP(ANN_ARG, "ann.arg", 0x123)
Index: /EcnlProtoTool/trunk/tcc-0.9.26/include/float.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/include/float.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/include/float.h	(revision 279)
@@ -0,0 +1,57 @@
+#ifndef _FLOAT_H_
+#define _FLOAT_H_
+
+#define FLT_RADIX 2
+
+/* IEEE float */
+#define FLT_MANT_DIG 24
+#define FLT_DIG 6
+#define FLT_ROUNDS 1
+#define FLT_EPSILON 1.19209290e-07F
+#define FLT_MIN_EXP (-125)
+#define FLT_MIN 1.17549435e-38F
+#define FLT_MIN_10_EXP (-37)
+#define FLT_MAX_EXP 128
+#define FLT_MAX 3.40282347e+38F
+#define FLT_MAX_10_EXP 38
+
+/* IEEE double */
+#define DBL_MANT_DIG 53
+#define DBL_DIG 15
+#define DBL_EPSILON 2.2204460492503131e-16
+#define DBL_MIN_EXP (-1021)
+#define DBL_MIN 2.2250738585072014e-308
+#define DBL_MIN_10_EXP (-307)
+#define DBL_MAX_EXP 1024
+#define DBL_MAX 1.7976931348623157e+308
+#define DBL_MAX_10_EXP 308
+
+/* horrible intel long double */
+#ifdef __i386__
+
+#define LDBL_MANT_DIG 64
+#define LDBL_DIG 18
+#define LDBL_EPSILON 1.08420217248550443401e-19L
+#define LDBL_MIN_EXP (-16381)
+#define LDBL_MIN 3.36210314311209350626e-4932L
+#define LDBL_MIN_10_EXP (-4931)
+#define LDBL_MAX_EXP 16384
+#define LDBL_MAX 1.18973149535723176502e+4932L
+#define LDBL_MAX_10_EXP 4932
+
+#else
+
+/* same as IEEE double */
+#define LDBL_MANT_DIG 53
+#define LDBL_DIG 15
+#define LDBL_EPSILON 2.2204460492503131e-16
+#define LDBL_MIN_EXP (-1021)
+#define LDBL_MIN 2.2250738585072014e-308
+#define LDBL_MIN_10_EXP (-307)
+#define LDBL_MAX_EXP 1024
+#define LDBL_MAX 1.7976931348623157e+308
+#define LDBL_MAX_10_EXP 308
+
+#endif
+
+#endif /* _FLOAT_H_ */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/include/stdarg.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/include/stdarg.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/include/stdarg.h	(revision 279)
@@ -0,0 +1,41 @@
+#ifndef _STDARG_H
+#define _STDARG_H
+
+#ifdef __x86_64__
+#ifndef _WIN64
+
+typedef void *va_list;
+
+va_list __va_start(void *fp);
+void *__va_arg(va_list ap, int arg_type, int size);
+va_list __va_copy(va_list src);
+void __va_end(va_list ap);
+
+#define va_start(ap, last) ((ap) = __va_start(__builtin_frame_address(0)))
+#define va_arg(ap, type)                                                \
+    (*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type))))
+#define va_copy(dest, src) ((dest) = __va_copy(src))
+#define va_end(ap) __va_end(ap)
+
+#else /* _WIN64 */
+typedef char *va_list;
+#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+7)&~7)
+#define va_arg(ap,type) (ap += (sizeof(type)+7)&~7, *(type *)(ap - ((sizeof(type)+7)&~7)))
+#define va_copy(dest, src) (dest) = (src)
+#define va_end(ap)
+#endif
+
+#else /* __i386__ */
+typedef char *va_list;
+/* only correct for i386 */
+#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
+#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
+#define va_copy(dest, src) (dest) = (src)
+#define va_end(ap)
+#endif
+
+/* fix a buggy dependency on GCC in libio.h */
+typedef va_list __gnuc_va_list;
+#define _VA_LIST_DEFINED
+
+#endif /* _STDARG_H */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/include/stdbool.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/include/stdbool.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/include/stdbool.h	(revision 279)
@@ -0,0 +1,10 @@
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+/* ISOC99 boolean */
+
+#define bool	_Bool
+#define true	1
+#define false	0
+
+#endif /* _STDBOOL_H */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/include/stddef.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/include/stddef.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/include/stddef.h	(revision 279)
@@ -0,0 +1,28 @@
+#ifndef _STDDEF_H
+#define _STDDEF_H
+
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ssize_t;
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __PTRDIFF_TYPE__ intptr_t;
+typedef __SIZE_TYPE__ uintptr_t;
+
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef signed char int8_t;
+typedef signed short int int16_t;
+typedef signed int int32_t;
+typedef signed long long int int64_t;
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long int uint64_t;
+#endif
+
+#define NULL ((void*)0)
+#define offsetof(type, field) ((size_t)&((type *)0)->field)
+
+void *alloca(size_t size);
+
+#endif
Index: /EcnlProtoTool/trunk/tcc-0.9.26/include/tcclib.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/include/tcclib.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/include/tcclib.h	(revision 279)
@@ -0,0 +1,78 @@
+/* Simple libc header for TCC 
+ * 
+ * Add any function you want from the libc there. This file is here
+ * only for your convenience so that you do not need to put the whole
+ * glibc include files on your floppy disk 
+ */
+#ifndef _TCCLIB_H
+#define _TCCLIB_H
+
+#include <stddef.h>
+#include <stdarg.h>
+
+/* stdlib.h */
+void *calloc(size_t nmemb, size_t size);
+void *malloc(size_t size);
+void free(void *ptr);
+void *realloc(void *ptr, size_t size);
+int atoi(const char *nptr);
+long int strtol(const char *nptr, char **endptr, int base);
+unsigned long int strtoul(const char *nptr, char **endptr, int base);
+void exit(int);
+
+/* stdio.h */
+typedef struct __FILE FILE;
+#define EOF (-1)
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+FILE *fopen(const char *path, const char *mode);
+FILE *fdopen(int fildes, const char *mode);
+FILE *freopen(const  char *path, const char *mode, FILE *stream);
+int fclose(FILE *stream);
+size_t  fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
+size_t  fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream);
+int fgetc(FILE *stream);
+char *fgets(char *s, int size, FILE *stream);
+int getc(FILE *stream);
+int getchar(void);
+char *gets(char *s);
+int ungetc(int c, FILE *stream);
+int fflush(FILE *stream);
+
+int printf(const char *format, ...);
+int fprintf(FILE *stream, const char *format, ...);
+int sprintf(char *str, const char *format, ...);
+int snprintf(char *str, size_t size, const  char  *format, ...);
+int asprintf(char **strp, const char *format, ...);
+int dprintf(int fd, const char *format, ...);
+int vprintf(const char *format, va_list ap);
+int vfprintf(FILE  *stream,  const  char *format, va_list ap);
+int vsprintf(char *str, const char *format, va_list ap);
+int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
+int vasprintf(char  **strp,  const  char *format, va_list ap);
+int vdprintf(int fd, const char *format, va_list ap);
+
+void perror(const char *s);
+
+/* string.h */
+char *strcat(char *dest, const char *src);
+char *strchr(const char *s, int c);
+char *strrchr(const char *s, int c);
+char *strcpy(char *dest, const char *src);
+void *memcpy(void *dest, const void *src, size_t n);
+void *memmove(void *dest, const void *src, size_t n);
+void *memset(void *s, int c, size_t n);
+char *strdup(const char *s);
+
+/* dlfcn.h */
+#define RTLD_LAZY       0x001
+#define RTLD_NOW        0x002
+#define RTLD_GLOBAL     0x100
+
+void *dlopen(const char *filename, int flag);
+const char *dlerror(void);
+void *dlsym(void *handle, char *symbol);
+int dlclose(void *handle);
+
+#endif /* _TCCLIB_H */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/include/varargs.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/include/varargs.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/include/varargs.h	(revision 279)
@@ -0,0 +1,12 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within this package.
+ */
+#ifndef _VARARGS_H
+#define _VARARGS_H
+
+#error "TinyCC no longer implements <varargs.h>."
+#error "Revise your code to use <stdarg.h>."
+
+#endif
Index: /EcnlProtoTool/trunk/tcc-0.9.26/lib/Makefile
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/lib/Makefile	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/lib/Makefile	(revision 279)
@@ -0,0 +1,102 @@
+#
+# Tiny C Compiler Makefile for libtcc1.a
+#
+
+TOP = ..
+include $(TOP)/Makefile
+VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
+
+ifndef TARGET
+ ifdef CONFIG_WIN64
+  TARGET = x86_64-win32
+ else
+ ifdef CONFIG_WIN32
+  TARGET = i386-win32
+ else
+ ifeq ($(ARCH),i386)
+  TARGET = i386
+  ifneq ($(TARGETOS),Darwin)
+   XCC = $(CC)
+  endif
+ else
+ ifeq ($(ARCH),x86-64)
+  TARGET = x86_64
+  ifneq ($(TARGETOS),Darwin)
+   XCC = $(CC)
+  endif
+ endif
+ endif
+ endif
+ endif
+ BCHECK_O = bcheck.o
+endif
+
+DIR = $(TARGET)
+
+native : ../libtcc1.a
+cross : $(DIR)/libtcc1.a
+
+native : TCC = $(TOP)/tcc$(EXESUF)
+cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
+
+I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
+X86_64_O = libtcc1.o alloca86_64.o
+WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
+WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
+
+ifeq "$(TARGET)" "i386-win32"
+ OBJ = $(addprefix $(DIR)/,$(WIN32_O))
+ TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
+ XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
+ XAR = $(DIR)/tiny_libmaker$(EXESUF)
+else
+ifeq "$(TARGET)" "x86_64-win32"
+ OBJ = $(addprefix $(DIR)/,$(WIN64_O))
+ TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
+ XCC = $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include
+ XAR = $(DIR)/tiny_libmaker$(EXESUF)
+else
+ifeq "$(TARGET)" "i386"
+ OBJ = $(addprefix $(DIR)/,$(I386_O))
+ TGT = -DTCC_TARGET_I386
+ XCC ?= $(TCC) -B$(TOP)
+else
+ifeq "$(TARGET)" "x86_64"
+ OBJ = $(addprefix $(DIR)/,$(X86_64_O))
+ TGT = -DTCC_TARGET_X86_64
+ XCC ?= $(TCC) -B$(TOP)
+else
+ $(error libtcc1.a not supported on target '$(TARGET)')
+endif
+endif
+endif
+endif
+
+XFLAGS = $(CPPFLAGS) $(CFLAGS) $(TGT)
+
+ifeq ($(TARGETOS),Darwin)
+ XAR = $(DIR)/tiny_libmaker$(EXESUF)
+ XFLAGS += -D_ANSI_SOURCE
+ BCHECK_O =
+endif
+
+ifdef XAR
+AR = $(XAR)
+endif
+
+$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
+	$(AR) rcs $@ $(OBJ)
+$(DIR)/%.o : %.c
+	$(XCC) -c $< -o $@ $(XFLAGS)
+$(DIR)/%.o : %.S
+	$(XCC) -c $< -o $@ $(XFLAGS)
+$(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
+	$(CC) -o $@ $< $(XFLAGS) $(LDFLAGS)
+
+$(OBJ) $(XAR) : $(DIR)/exists
+$(DIR)/exists :
+	mkdir -p $(DIR)
+	@echo $@ > $@
+
+clean :
+	rm -rfv i386-win32 x86_64-win32 i386 x86_64
Index: /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86-bt.S
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86-bt.S	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86-bt.S	(revision 279)
@@ -0,0 +1,47 @@
+/* ---------------------------------------------- */
+/* alloca86-bt.S */
+
+.globl __bound_alloca
+
+__bound_alloca:
+    pop     %edx
+    pop     %eax
+    mov     %eax, %ecx
+    add     $3,%eax
+    and     $-4,%eax
+    jz      p6
+
+#ifdef TCC_TARGET_PE
+p4:
+    cmp     $4096,%eax
+    jle     p5
+    sub     $4096,%esp
+    sub     $4096,%eax
+    test    %eax,(%esp)
+    jmp p4
+
+p5:
+#endif
+
+    sub     %eax,%esp
+    mov     %esp,%eax
+
+    push    %edx
+    push    %eax
+    push    %ecx
+    push    %eax
+    call   __bound_new_region
+    add    $8, %esp
+    pop     %eax
+    pop     %edx
+
+p6:
+    push    %edx
+    push    %edx
+    ret
+
+/* mark stack as nonexecutable */
+#if defined __ELF__ && defined __linux__
+    .section    .note.GNU-stack,"",@progbits
+#endif
+/* ---------------------------------------------- */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86.S
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86.S	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86.S	(revision 279)
@@ -0,0 +1,35 @@
+/* ---------------------------------------------- */
+/* alloca86.S */
+
+.globl alloca
+
+alloca:
+    pop     %edx
+    pop     %eax
+    add     $3,%eax
+    and     $-4,%eax
+    jz      p3
+
+#ifdef TCC_TARGET_PE
+p1:
+    cmp     $4096,%eax
+    jle     p2
+    sub     $4096,%esp
+    sub     $4096,%eax
+    test    %eax,(%esp)
+    jmp p1
+p2:
+#endif
+
+    sub     %eax,%esp
+    mov     %esp,%eax
+p3:
+    push    %edx
+    push    %edx
+    ret
+
+/* mark stack as nonexecutable */
+#if defined __ELF__ && defined __linux__
+    .section    .note.GNU-stack,"",@progbits
+#endif
+/* ---------------------------------------------- */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86_64.S
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86_64.S	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/lib/alloca86_64.S	(revision 279)
@@ -0,0 +1,42 @@
+/* ---------------------------------------------- */
+/* alloca86_64.S */
+
+.globl alloca
+
+alloca:
+    pop     %rdx
+#ifdef TCC_TARGET_PE
+    mov     %rcx,%rax
+#else
+    mov     %rdi,%rax
+#endif
+    add     $15,%rax
+    and     $-16,%rax
+    jz      p3
+
+#ifdef TCC_TARGET_PE
+p1:
+    cmp     $4096,%rax
+    jle     p2
+    sub     $4096,%rsp
+    sub     $4096,%rax
+    test    %rax,(%rsp)
+    jmp p1
+p2:
+#endif
+
+    sub     %rax,%rsp
+    mov     %rsp,%rax
+#ifdef TCC_TARGET_PE
+    add     $32,%rax
+#endif
+
+p3:
+    push    %rdx
+    ret
+
+/* mark stack as nonexecutable */
+#if defined __ELF__ && defined __linux__
+    .section    .note.GNU-stack,"",@progbits
+#endif
+/* ---------------------------------------------- */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/lib/bcheck.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/lib/bcheck.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/lib/bcheck.c	(revision 279)
@@ -0,0 +1,875 @@
+/*
+ *  Tiny C Memory and bounds checker
+ * 
+ *  Copyright (c) 2002 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) \
+    && !defined(__DragonFly__) && !defined(__OpenBSD__)
+#include <malloc.h>
+#endif
+#if !defined(_WIN32)
+#include <unistd.h>
+#endif
+
+//#define BOUND_DEBUG
+
+/* define so that bound array is static (faster, but use memory if
+   bound checking not used) */
+//#define BOUND_STATIC
+
+/* use malloc hooks. Currently the code cannot be reliable if no hooks */
+#define CONFIG_TCC_MALLOC_HOOKS
+#define HAVE_MEMALIGN
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
+    || defined(__DragonFly__) || defined(__dietlibc__) \
+    || defined(__UCLIBC__) || defined(__OpenBSD__) \
+    || defined(_WIN32) || defined(TCC_UCLIBC)
+#warning Bound checking does not support malloc (etc.) in this environment.
+#undef CONFIG_TCC_MALLOC_HOOKS
+#undef HAVE_MEMALIGN
+#endif
+
+#define BOUND_T1_BITS 13
+#define BOUND_T2_BITS 11
+#define BOUND_T3_BITS (32 - BOUND_T1_BITS - BOUND_T2_BITS)
+
+#define BOUND_T1_SIZE (1 << BOUND_T1_BITS)
+#define BOUND_T2_SIZE (1 << BOUND_T2_BITS)
+#define BOUND_T3_SIZE (1 << BOUND_T3_BITS)
+#define BOUND_E_BITS  4
+
+#define BOUND_T23_BITS (BOUND_T2_BITS + BOUND_T3_BITS)
+#define BOUND_T23_SIZE (1 << BOUND_T23_BITS)
+
+
+/* this pointer is generated when bound check is incorrect */
+#define INVALID_POINTER ((void *)(-2))
+/* size of an empty region */
+#define EMPTY_SIZE        0xffffffff
+/* size of an invalid region */
+#define INVALID_SIZE      0
+
+typedef struct BoundEntry {
+    unsigned long start;
+    unsigned long size;
+    struct BoundEntry *next;
+    unsigned long is_invalid; /* true if pointers outside region are invalid */
+} BoundEntry;
+
+/* external interface */
+void __bound_init(void);
+void __bound_new_region(void *p, unsigned long size);
+int __bound_delete_region(void *p);
+
+#define FASTCALL __attribute__((regparm(3)))
+
+void *__bound_malloc(size_t size, const void *caller);
+void *__bound_memalign(size_t size, size_t align, const void *caller);
+void __bound_free(void *ptr, const void *caller);
+void *__bound_realloc(void *ptr, size_t size, const void *caller);
+static void *libc_malloc(size_t size);
+static void libc_free(void *ptr);
+static void install_malloc_hooks(void);
+static void restore_malloc_hooks(void);
+
+#ifdef CONFIG_TCC_MALLOC_HOOKS
+static void *saved_malloc_hook;
+static void *saved_free_hook;
+static void *saved_realloc_hook;
+static void *saved_memalign_hook;
+#endif
+
+/* TCC definitions */
+extern char __bounds_start; /* start of static bounds table */
+/* error message, just for TCC */
+const char *__bound_error_msg;
+
+/* runtime error output */
+extern void rt_error(unsigned long pc, const char *fmt, ...);
+
+#ifdef BOUND_STATIC
+static BoundEntry *__bound_t1[BOUND_T1_SIZE]; /* page table */
+#else
+static BoundEntry **__bound_t1; /* page table */
+#endif
+static BoundEntry *__bound_empty_t2;   /* empty page, for unused pages */
+static BoundEntry *__bound_invalid_t2; /* invalid page, for invalid pointers */
+
+static BoundEntry *__bound_find_region(BoundEntry *e1, void *p)
+{
+    unsigned long addr, tmp;
+    BoundEntry *e;
+
+    e = e1;
+    while (e != NULL) {
+        addr = (unsigned long)p;
+        addr -= e->start;
+        if (addr <= e->size) {
+            /* put region at the head */
+            tmp = e1->start;
+            e1->start = e->start;
+            e->start = tmp;
+            tmp = e1->size;
+            e1->size = e->size;
+            e->size = tmp;
+            return e1;
+        }
+        e = e->next;
+    }
+    /* no entry found: return empty entry or invalid entry */
+    if (e1->is_invalid)
+        return __bound_invalid_t2;
+    else
+        return __bound_empty_t2;
+}
+
+/* print a bound error message */
+static void bound_error(const char *fmt, ...)
+{
+    __bound_error_msg = fmt;
+    *(int *)0 = 0; /* force a runtime error */
+}
+
+static void bound_alloc_error(void)
+{
+    bound_error("not enough memory for bound checking code");
+}
+
+/* return '(p + offset)' for pointer arithmetic (a pointer can reach
+   the end of a region in this case */
+void * FASTCALL __bound_ptr_add(void *p, int offset)
+{
+    unsigned long addr = (unsigned long)p;
+    BoundEntry *e;
+#if defined(BOUND_DEBUG)
+    printf("add: 0x%x %d\n", (int)p, offset);
+#endif
+
+    e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];
+    e = (BoundEntry *)((char *)e + 
+                       ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
+                        ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));
+    addr -= e->start;
+    if (addr > e->size) {
+        e = __bound_find_region(e, p);
+        addr = (unsigned long)p - e->start;
+    }
+    addr += offset;
+    if (addr > e->size)
+        return INVALID_POINTER; /* return an invalid pointer */
+    return p + offset;
+}
+
+/* return '(p + offset)' for pointer indirection (the resulting must
+   be strictly inside the region */
+#define BOUND_PTR_INDIR(dsize)                                          \
+void * FASTCALL __bound_ptr_indir ## dsize (void *p, int offset)        \
+{                                                                       \
+    unsigned long addr = (unsigned long)p;                              \
+    BoundEntry *e;                                                      \
+                                                                        \
+    e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];            \
+    e = (BoundEntry *)((char *)e +                                      \
+                       ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) &      \
+                        ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));        \
+    addr -= e->start;                                                   \
+    if (addr > e->size) {                                               \
+        e = __bound_find_region(e, p);                                  \
+        addr = (unsigned long)p - e->start;                             \
+    }                                                                   \
+    addr += offset + dsize;                                             \
+    if (addr > e->size)                                                 \
+        return INVALID_POINTER; /* return an invalid pointer */         \
+    return p + offset;                                                  \
+}
+
+BOUND_PTR_INDIR(1)
+BOUND_PTR_INDIR(2)
+BOUND_PTR_INDIR(4)
+BOUND_PTR_INDIR(8)
+BOUND_PTR_INDIR(12)
+BOUND_PTR_INDIR(16)
+
+/* return the frame pointer of the caller */
+#define GET_CALLER_FP(fp)\
+{\
+    fp = (unsigned long)__builtin_frame_address(1);\
+}
+
+/* called when entering a function to add all the local regions */
+void FASTCALL __bound_local_new(void *p1) 
+{
+    unsigned long addr, size, fp, *p = p1;
+    GET_CALLER_FP(fp);
+    for(;;) {
+        addr = p[0];
+        if (addr == 0)
+            break;
+        addr += fp;
+        size = p[1];
+        p += 2;
+        __bound_new_region((void *)addr, size);
+    }
+}
+
+/* called when leaving a function to delete all the local regions */
+void FASTCALL __bound_local_delete(void *p1) 
+{
+    unsigned long addr, fp, *p = p1;
+    GET_CALLER_FP(fp);
+    for(;;) {
+        addr = p[0];
+        if (addr == 0)
+            break;
+        addr += fp;
+        p += 2;
+        __bound_delete_region((void *)addr);
+    }
+}
+
+static BoundEntry *__bound_new_page(void)
+{
+    BoundEntry *page;
+    int i;
+
+    page = libc_malloc(sizeof(BoundEntry) * BOUND_T2_SIZE);
+    if (!page)
+        bound_alloc_error();
+    for(i=0;i<BOUND_T2_SIZE;i++) {
+        /* put empty entries */
+        page[i].start = 0;
+        page[i].size = EMPTY_SIZE;
+        page[i].next = NULL;
+        page[i].is_invalid = 0;
+    }
+    return page;
+}
+
+/* currently we use malloc(). Should use bound_new_page() */
+static BoundEntry *bound_new_entry(void)
+{
+    BoundEntry *e;
+    e = libc_malloc(sizeof(BoundEntry));
+    return e;
+}
+
+static void bound_free_entry(BoundEntry *e)
+{
+    libc_free(e);
+}
+
+static inline BoundEntry *get_page(int index)
+{
+    BoundEntry *page;
+    page = __bound_t1[index];
+    if (page == __bound_empty_t2 || page == __bound_invalid_t2) {
+        /* create a new page if necessary */
+        page = __bound_new_page();
+        __bound_t1[index] = page;
+    }
+    return page;
+}
+
+/* mark a region as being invalid (can only be used during init) */
+static void mark_invalid(unsigned long addr, unsigned long size)
+{
+    unsigned long start, end;
+    BoundEntry *page;
+    int t1_start, t1_end, i, j, t2_start, t2_end;
+
+    start = addr;
+    end = addr + size;
+
+    t2_start = (start + BOUND_T3_SIZE - 1) >> BOUND_T3_BITS;
+    if (end != 0)
+        t2_end = end >> BOUND_T3_BITS;
+    else
+        t2_end = 1 << (BOUND_T1_BITS + BOUND_T2_BITS);
+
+#if 0
+    printf("mark_invalid: start = %x %x\n", t2_start, t2_end);
+#endif
+    
+    /* first we handle full pages */
+    t1_start = (t2_start + BOUND_T2_SIZE - 1) >> BOUND_T2_BITS;
+    t1_end = t2_end >> BOUND_T2_BITS;
+
+    i = t2_start & (BOUND_T2_SIZE - 1);
+    j = t2_end & (BOUND_T2_SIZE - 1);
+    
+    if (t1_start == t1_end) {
+        page = get_page(t2_start >> BOUND_T2_BITS);
+        for(; i < j; i++) {
+            page[i].size = INVALID_SIZE;
+            page[i].is_invalid = 1;
+        }
+    } else {
+        if (i > 0) {
+            page = get_page(t2_start >> BOUND_T2_BITS);
+            for(; i < BOUND_T2_SIZE; i++) {
+                page[i].size = INVALID_SIZE;
+                page[i].is_invalid = 1;
+            }
+        }
+        for(i = t1_start; i < t1_end; i++) {
+            __bound_t1[i] = __bound_invalid_t2;
+        }
+        if (j != 0) {
+            page = get_page(t1_end);
+            for(i = 0; i < j; i++) {
+                page[i].size = INVALID_SIZE;
+                page[i].is_invalid = 1;
+            }
+        }
+    }
+}
+
+void __bound_init(void)
+{
+    int i;
+    BoundEntry *page;
+    unsigned long start, size;
+    int *p;
+
+    /* save malloc hooks and install bound check hooks */
+    install_malloc_hooks();
+
+#ifndef BOUND_STATIC
+    __bound_t1 = libc_malloc(BOUND_T1_SIZE * sizeof(BoundEntry *));
+    if (!__bound_t1)
+        bound_alloc_error();
+#endif
+    __bound_empty_t2 = __bound_new_page();
+    for(i=0;i<BOUND_T1_SIZE;i++) {
+        __bound_t1[i] = __bound_empty_t2;
+    }
+
+    page = __bound_new_page();
+    for(i=0;i<BOUND_T2_SIZE;i++) {
+        /* put invalid entries */
+        page[i].start = 0;
+        page[i].size = INVALID_SIZE;
+        page[i].next = NULL;
+        page[i].is_invalid = 1;
+    }
+    __bound_invalid_t2 = page;
+
+    /* invalid pointer zone */
+    start = (unsigned long)INVALID_POINTER & ~(BOUND_T23_SIZE - 1);
+    size = BOUND_T23_SIZE;
+    mark_invalid(start, size);
+
+#if defined(CONFIG_TCC_MALLOC_HOOKS)
+    /* malloc zone is also marked invalid. can only use that with
+     * hooks because all libs should use the same malloc. The solution
+     * would be to build a new malloc for tcc.
+     *
+     * usually heap (= malloc zone) comes right after bss, i.e. after _end, but
+     * not always - either if we are running from under `tcc -b -run`, or if
+     * address space randomization is turned on(a), heap start will be separated
+     * from bss end.
+     *
+     * So sbrk(0) will be a good approximation for start_brk:
+     *
+     *   - if we are a separately compiled program, __bound_init() runs early,
+     *     and sbrk(0) should be equal or very near to start_brk(b) (in case other
+     *     constructors malloc something), or
+     *
+     *   - if we are running from under `tcc -b -run`, sbrk(0) will return
+     *     start of heap portion which is under this program control, and not
+     *     mark as invalid earlier allocated memory.
+     *
+     *
+     * (a) /proc/sys/kernel/randomize_va_space = 2, on Linux;
+     *     usually turned on by default.
+     *
+     * (b) on Linux >= v3.3, the alternative is to read
+     *     start_brk from /proc/self/stat
+     */
+    start = (unsigned long)sbrk(0);
+    size = 128 * 0x100000;
+    mark_invalid(start, size);
+#endif
+
+    /* add all static bound check values */
+    p = (int *)&__bounds_start;
+    while (p[0] != 0) {
+        __bound_new_region((void *)p[0], p[1]);
+        p += 2;
+    }
+}
+
+void __bound_exit(void)
+{
+    restore_malloc_hooks();
+}
+
+static inline void add_region(BoundEntry *e, 
+                              unsigned long start, unsigned long size)
+{
+    BoundEntry *e1;
+    if (e->start == 0) {
+        /* no region : add it */
+        e->start = start;
+        e->size = size;
+    } else {
+        /* already regions in the list: add it at the head */
+        e1 = bound_new_entry();
+        e1->start = e->start;
+        e1->size = e->size;
+        e1->next = e->next;
+        e->start = start;
+        e->size = size;
+        e->next = e1;
+    }
+}
+
+/* create a new region. It should not already exist in the region list */
+void __bound_new_region(void *p, unsigned long size)
+{
+    unsigned long start, end;
+    BoundEntry *page, *e, *e2;
+    int t1_start, t1_end, i, t2_start, t2_end;
+
+    start = (unsigned long)p;
+    end = start + size;
+    t1_start = start >> (BOUND_T2_BITS + BOUND_T3_BITS);
+    t1_end = end >> (BOUND_T2_BITS + BOUND_T3_BITS);
+
+    /* start */
+    page = get_page(t1_start);
+    t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
+        ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
+    t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
+        ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
+#ifdef BOUND_DEBUG
+    printf("new %lx %lx %x %x %x %x\n", 
+           start, end, t1_start, t1_end, t2_start, t2_end);
+#endif
+
+    e = (BoundEntry *)((char *)page + t2_start);
+    add_region(e, start, size);
+
+    if (t1_end == t1_start) {
+        /* same ending page */
+        e2 = (BoundEntry *)((char *)page + t2_end);
+        if (e2 > e) {
+            e++;
+            for(;e<e2;e++) {
+                e->start = start;
+                e->size = size;
+            }
+            add_region(e, start, size);
+        }
+    } else {
+        /* mark until end of page */
+        e2 = page + BOUND_T2_SIZE;
+        e++;
+        for(;e<e2;e++) {
+            e->start = start;
+            e->size = size;
+        }
+        /* mark intermediate pages, if any */
+        for(i=t1_start+1;i<t1_end;i++) {
+            page = get_page(i);
+            e2 = page + BOUND_T2_SIZE;
+            for(e=page;e<e2;e++) {
+                e->start = start;
+                e->size = size;
+            }
+        }
+        /* last page */
+        page = get_page(t1_end);
+        e2 = (BoundEntry *)((char *)page + t2_end);
+        for(e=page;e<e2;e++) {
+            e->start = start;
+            e->size = size;
+        }
+        add_region(e, start, size);
+    }
+}
+
+/* delete a region */
+static inline void delete_region(BoundEntry *e, 
+                                 void *p, unsigned long empty_size)
+{
+    unsigned long addr;
+    BoundEntry *e1;
+
+    addr = (unsigned long)p;
+    addr -= e->start;
+    if (addr <= e->size) {
+        /* region found is first one */
+        e1 = e->next;
+        if (e1 == NULL) {
+            /* no more region: mark it empty */
+            e->start = 0;
+            e->size = empty_size;
+        } else {
+            /* copy next region in head */
+            e->start = e1->start;
+            e->size = e1->size;
+            e->next = e1->next;
+            bound_free_entry(e1);
+        }
+    } else {
+        /* find the matching region */
+        for(;;) {
+            e1 = e;
+            e = e->next;
+            /* region not found: do nothing */
+            if (e == NULL)
+                break;
+            addr = (unsigned long)p - e->start;
+            if (addr <= e->size) {
+                /* found: remove entry */
+                e1->next = e->next;
+                bound_free_entry(e);
+                break;
+            }
+        }
+    }
+}
+
+/* WARNING: 'p' must be the starting point of the region. */
+/* return non zero if error */
+int __bound_delete_region(void *p)
+{
+    unsigned long start, end, addr, size, empty_size;
+    BoundEntry *page, *e, *e2;
+    int t1_start, t1_end, t2_start, t2_end, i;
+
+    start = (unsigned long)p;
+    t1_start = start >> (BOUND_T2_BITS + BOUND_T3_BITS);
+    t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
+        ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
+    
+    /* find region size */
+    page = __bound_t1[t1_start];
+    e = (BoundEntry *)((char *)page + t2_start);
+    addr = start - e->start;
+    if (addr > e->size)
+        e = __bound_find_region(e, p);
+    /* test if invalid region */
+    if (e->size == EMPTY_SIZE || (unsigned long)p != e->start) 
+        return -1;
+    /* compute the size we put in invalid regions */
+    if (e->is_invalid)
+        empty_size = INVALID_SIZE;
+    else
+        empty_size = EMPTY_SIZE;
+    size = e->size;
+    end = start + size;
+
+    /* now we can free each entry */
+    t1_end = end >> (BOUND_T2_BITS + BOUND_T3_BITS);
+    t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
+        ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
+
+    delete_region(e, p, empty_size);
+    if (t1_end == t1_start) {
+        /* same ending page */
+        e2 = (BoundEntry *)((char *)page + t2_end);
+        if (e2 > e) {
+            e++;
+            for(;e<e2;e++) {
+                e->start = 0;
+                e->size = empty_size;
+            }
+            delete_region(e, p, empty_size);
+        }
+    } else {
+        /* mark until end of page */
+        e2 = page + BOUND_T2_SIZE;
+        e++;
+        for(;e<e2;e++) {
+            e->start = 0;
+            e->size = empty_size;
+        }
+        /* mark intermediate pages, if any */
+        /* XXX: should free them */
+        for(i=t1_start+1;i<t1_end;i++) {
+            page = get_page(i);
+            e2 = page + BOUND_T2_SIZE;
+            for(e=page;e<e2;e++) {
+                e->start = 0;
+                e->size = empty_size;
+            }
+        }
+        /* last page */
+        page = get_page(t1_end);
+        e2 = (BoundEntry *)((char *)page + t2_end);
+        for(e=page;e<e2;e++) {
+            e->start = 0;
+            e->size = empty_size;
+        }
+        delete_region(e, p, empty_size);
+    }
+    return 0;
+}
+
+/* return the size of the region starting at p, or EMPTY_SIZE if non
+   existant region. */
+static unsigned long get_region_size(void *p)
+{
+    unsigned long addr = (unsigned long)p;
+    BoundEntry *e;
+
+    e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];
+    e = (BoundEntry *)((char *)e + 
+                       ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) & 
+                        ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));
+    addr -= e->start;
+    if (addr > e->size)
+        e = __bound_find_region(e, p);
+    if (e->start != (unsigned long)p)
+        return EMPTY_SIZE;
+    return e->size;
+}
+
+/* patched memory functions */
+
+/* force compiler to perform stores coded up to this point */
+#define barrier()   __asm__ __volatile__ ("": : : "memory")
+
+static void install_malloc_hooks(void)
+{
+#ifdef CONFIG_TCC_MALLOC_HOOKS
+    saved_malloc_hook = __malloc_hook;
+    saved_free_hook = __free_hook;
+    saved_realloc_hook = __realloc_hook;
+    saved_memalign_hook = __memalign_hook;
+    __malloc_hook = __bound_malloc;
+    __free_hook = __bound_free;
+    __realloc_hook = __bound_realloc;
+    __memalign_hook = __bound_memalign;
+
+    barrier();
+#endif
+}
+
+static void restore_malloc_hooks(void)
+{
+#ifdef CONFIG_TCC_MALLOC_HOOKS
+    __malloc_hook = saved_malloc_hook;
+    __free_hook = saved_free_hook;
+    __realloc_hook = saved_realloc_hook;
+    __memalign_hook = saved_memalign_hook;
+
+    barrier();
+#endif
+}
+
+static void *libc_malloc(size_t size)
+{
+    void *ptr;
+    restore_malloc_hooks();
+    ptr = malloc(size);
+    install_malloc_hooks();
+    return ptr;
+}
+
+static void libc_free(void *ptr)
+{
+    restore_malloc_hooks();
+    free(ptr);
+    install_malloc_hooks();
+}
+
+/* XXX: we should use a malloc which ensure that it is unlikely that
+   two malloc'ed data have the same address if 'free' are made in
+   between. */
+void *__bound_malloc(size_t size, const void *caller)
+{
+    void *ptr;
+    
+    /* we allocate one more byte to ensure the regions will be
+       separated by at least one byte. With the glibc malloc, it may
+       be in fact not necessary */
+    ptr = libc_malloc(size + 1);
+    
+    if (!ptr)
+        return NULL;
+    __bound_new_region(ptr, size);
+    return ptr;
+}
+
+void *__bound_memalign(size_t size, size_t align, const void *caller)
+{
+    void *ptr;
+
+    restore_malloc_hooks();
+
+#ifndef HAVE_MEMALIGN
+    if (align > 4) {
+        /* XXX: handle it ? */
+        ptr = NULL;
+    } else {
+        /* we suppose that malloc aligns to at least four bytes */
+        ptr = malloc(size + 1);
+    }
+#else
+    /* we allocate one more byte to ensure the regions will be
+       separated by at least one byte. With the glibc malloc, it may
+       be in fact not necessary */
+    ptr = memalign(size + 1, align);
+#endif
+    
+    install_malloc_hooks();
+    
+    if (!ptr)
+        return NULL;
+    __bound_new_region(ptr, size);
+    return ptr;
+}
+
+void __bound_free(void *ptr, const void *caller)
+{
+    if (ptr == NULL)
+        return;
+    if (__bound_delete_region(ptr) != 0)
+        bound_error("freeing invalid region");
+
+    libc_free(ptr);
+}
+
+void *__bound_realloc(void *ptr, size_t size, const void *caller)
+{
+    void *ptr1;
+    int old_size;
+
+    if (size == 0) {
+        __bound_free(ptr, caller);
+        return NULL;
+    } else {
+        ptr1 = __bound_malloc(size, caller);
+        if (ptr == NULL || ptr1 == NULL)
+            return ptr1;
+        old_size = get_region_size(ptr);
+        if (old_size == EMPTY_SIZE)
+            bound_error("realloc'ing invalid pointer");
+        memcpy(ptr1, ptr, old_size);
+        __bound_free(ptr, caller);
+        return ptr1;
+    }
+}
+
+#ifndef CONFIG_TCC_MALLOC_HOOKS
+void *__bound_calloc(size_t nmemb, size_t size)
+{
+    void *ptr;
+    size = size * nmemb;
+    ptr = __bound_malloc(size, NULL);
+    if (!ptr)
+        return NULL;
+    memset(ptr, 0, size);
+    return ptr;
+}
+#endif
+
+#if 0
+static void bound_dump(void)
+{
+    BoundEntry *page, *e;
+    int i, j;
+
+    printf("region dump:\n");
+    for(i=0;i<BOUND_T1_SIZE;i++) {
+        page = __bound_t1[i];
+        for(j=0;j<BOUND_T2_SIZE;j++) {
+            e = page + j;
+            /* do not print invalid or empty entries */
+            if (e->size != EMPTY_SIZE && e->start != 0) {
+                printf("%08x:", 
+                       (i << (BOUND_T2_BITS + BOUND_T3_BITS)) + 
+                       (j << BOUND_T3_BITS));
+                do {
+                    printf(" %08lx:%08lx", e->start, e->start + e->size);
+                    e = e->next;
+                } while (e != NULL);
+                printf("\n");
+            }
+        }
+    }
+}
+#endif
+
+/* some useful checked functions */
+
+/* check that (p ... p + size - 1) lies inside 'p' region, if any */
+static void __bound_check(const void *p, size_t size)
+{
+    if (size == 0)
+        return;
+    p = __bound_ptr_add((void *)p, size);
+    if (p == INVALID_POINTER)
+        bound_error("invalid pointer");
+}
+
+void *__bound_memcpy(void *dst, const void *src, size_t size)
+{
+    __bound_check(dst, size);
+    __bound_check(src, size);
+    /* check also region overlap */
+    if (src >= dst && src < dst + size)
+        bound_error("overlapping regions in memcpy()");
+    return memcpy(dst, src, size);
+}
+
+void *__bound_memmove(void *dst, const void *src, size_t size)
+{
+    __bound_check(dst, size);
+    __bound_check(src, size);
+    return memmove(dst, src, size);
+}
+
+void *__bound_memset(void *dst, int c, size_t size)
+{
+    __bound_check(dst, size);
+    return memset(dst, c, size);
+}
+
+/* XXX: could be optimized */
+int __bound_strlen(const char *s)
+{
+    const char *p;
+    int len;
+
+    len = 0;
+    for(;;) {
+        p = __bound_ptr_indir1((char *)s, len);
+        if (p == INVALID_POINTER)
+            bound_error("bad pointer in strlen()");
+        if (*p == '\0')
+            break;
+        len++;
+    }
+    return len;
+}
+
+char *__bound_strcpy(char *dst, const char *src)
+{
+    int len;
+    len = __bound_strlen(src);
+    return __bound_memcpy(dst, src, len + 1);
+}
+
Index: /EcnlProtoTool/trunk/tcc-0.9.26/lib/libtcc1.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/lib/libtcc1.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/lib/libtcc1.c	(revision 279)
@@ -0,0 +1,691 @@
+/* TCC runtime library. 
+   Parts of this code are (c) 2002 Fabrice Bellard 
+
+   Copyright (C) 1987, 1988, 1992, 1994, 1995 Free Software Foundation, Inc.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file.  (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  
+*/
+
+#define W_TYPE_SIZE   32
+#define BITS_PER_UNIT 8
+
+typedef int Wtype;
+typedef unsigned int UWtype;
+typedef unsigned int USItype;
+typedef long long DWtype;
+typedef unsigned long long UDWtype;
+
+struct DWstruct {
+    Wtype low, high;
+};
+
+typedef union
+{
+  struct DWstruct s;
+  DWtype ll;
+} DWunion;
+
+typedef long double XFtype;
+#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
+#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
+
+/* the following deal with IEEE single-precision numbers */
+#define EXCESS		126
+#define SIGNBIT		0x80000000
+#define HIDDEN		(1 << 23)
+#define SIGN(fp)	((fp) & SIGNBIT)
+#define EXP(fp)		(((fp) >> 23) & 0xFF)
+#define MANT(fp)	(((fp) & 0x7FFFFF) | HIDDEN)
+#define PACK(s,e,m)	((s) | ((e) << 23) | (m))
+
+/* the following deal with IEEE double-precision numbers */
+#define EXCESSD		1022
+#define HIDDEND		(1 << 20)
+#define EXPD(fp)	(((fp.l.upper) >> 20) & 0x7FF)
+#define SIGND(fp)	((fp.l.upper) & SIGNBIT)
+#define MANTD(fp)	(((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \
+				(fp.l.lower >> 22))
+#define HIDDEND_LL	((long long)1 << 52)
+#define MANTD_LL(fp)	((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
+#define PACKD_LL(s,e,m)	(((long long)((s)+((e)<<20))<<32)|(m))
+
+/* the following deal with x86 long double-precision numbers */
+#define EXCESSLD	16382
+#define EXPLD(fp)	(fp.l.upper & 0x7fff)
+#define SIGNLD(fp)	((fp.l.upper) & 0x8000)
+
+/* only for x86 */
+union ldouble_long {
+    long double ld;
+    struct {
+        unsigned long long lower;
+        unsigned short upper;
+    } l;
+};
+
+union double_long {
+    double d;
+#if 1
+    struct {
+        unsigned int lower;
+        int upper;
+    } l;
+#else
+    struct {
+        int upper;
+        unsigned int lower;
+    } l;
+#endif
+    long long ll;
+};
+
+union float_long {
+    float f;
+    long l;
+};
+
+/* XXX: we don't support several builtin supports for now */
+#ifndef __x86_64__
+
+/* XXX: use gcc/tcc intrinsic ? */
+#if defined(__i386__)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("subl %5,%1\n\tsbbl %3,%0"					\
+	   : "=r" ((USItype) (sh)),					\
+	     "=&r" ((USItype) (sl))					\
+	   : "0" ((USItype) (ah)),					\
+	     "g" ((USItype) (bh)),					\
+	     "1" ((USItype) (al)),					\
+	     "g" ((USItype) (bl)))
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("mull %3"							\
+	   : "=a" ((USItype) (w0)),					\
+	     "=d" ((USItype) (w1))					\
+	   : "%0" ((USItype) (u)),					\
+	     "rm" ((USItype) (v)))
+#define udiv_qrnnd(q, r, n1, n0, dv) \
+  __asm__ ("divl %4"							\
+	   : "=a" ((USItype) (q)),					\
+	     "=d" ((USItype) (r))					\
+	   : "0" ((USItype) (n0)),					\
+	     "1" ((USItype) (n1)),					\
+	     "rm" ((USItype) (dv)))
+#define count_leading_zeros(count, x) \
+  do {									\
+    USItype __cbtmp;							\
+    __asm__ ("bsrl %1,%0"						\
+	     : "=r" (__cbtmp) : "rm" ((USItype) (x)));			\
+    (count) = __cbtmp ^ 31;						\
+  } while (0)
+#else
+#error unsupported CPU type
+#endif
+
+/* most of this code is taken from libgcc2.c from gcc */
+
+static UDWtype __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
+{
+  DWunion ww;
+  DWunion nn, dd;
+  DWunion rr;
+  UWtype d0, d1, n0, n1, n2;
+  UWtype q0, q1;
+  UWtype b, bm;
+
+  nn.ll = n;
+  dd.ll = d;
+
+  d0 = dd.s.low;
+  d1 = dd.s.high;
+  n0 = nn.s.low;
+  n1 = nn.s.high;
+
+#if !defined(UDIV_NEEDS_NORMALIZATION)
+  if (d1 == 0)
+    {
+      if (d0 > n1)
+	{
+	  /* 0q = nn / 0D */
+
+	  udiv_qrnnd (q0, n0, n1, n0, d0);
+	  q1 = 0;
+
+	  /* Remainder in n0.  */
+	}
+      else
+	{
+	  /* qq = NN / 0d */
+
+	  if (d0 == 0)
+	    d0 = 1 / d0;	/* Divide intentionally by zero.  */
+
+	  udiv_qrnnd (q1, n1, 0, n1, d0);
+	  udiv_qrnnd (q0, n0, n1, n0, d0);
+
+	  /* Remainder in n0.  */
+	}
+
+      if (rp != 0)
+	{
+	  rr.s.low = n0;
+	  rr.s.high = 0;
+	  *rp = rr.ll;
+	}
+    }
+
+#else /* UDIV_NEEDS_NORMALIZATION */
+
+  if (d1 == 0)
+    {
+      if (d0 > n1)
+	{
+	  /* 0q = nn / 0D */
+
+	  count_leading_zeros (bm, d0);
+
+	  if (bm != 0)
+	    {
+	      /* Normalize, i.e. make the most significant bit of the
+		 denominator set.  */
+
+	      d0 = d0 << bm;
+	      n1 = (n1 << bm) | (n0 >> (W_TYPE_SIZE - bm));
+	      n0 = n0 << bm;
+	    }
+
+	  udiv_qrnnd (q0, n0, n1, n0, d0);
+	  q1 = 0;
+
+	  /* Remainder in n0 >> bm.  */
+	}
+      else
+	{
+	  /* qq = NN / 0d */
+
+	  if (d0 == 0)
+	    d0 = 1 / d0;	/* Divide intentionally by zero.  */
+
+	  count_leading_zeros (bm, d0);
+
+	  if (bm == 0)
+	    {
+	      /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
+		 conclude (the most significant bit of n1 is set) /\ (the
+		 leading quotient digit q1 = 1).
+
+		 This special case is necessary, not an optimization.
+		 (Shifts counts of W_TYPE_SIZE are undefined.)  */
+
+	      n1 -= d0;
+	      q1 = 1;
+	    }
+	  else
+	    {
+	      /* Normalize.  */
+
+	      b = W_TYPE_SIZE - bm;
+
+	      d0 = d0 << bm;
+	      n2 = n1 >> b;
+	      n1 = (n1 << bm) | (n0 >> b);
+	      n0 = n0 << bm;
+
+	      udiv_qrnnd (q1, n1, n2, n1, d0);
+	    }
+
+	  /* n1 != d0...  */
+
+	  udiv_qrnnd (q0, n0, n1, n0, d0);
+
+	  /* Remainder in n0 >> bm.  */
+	}
+
+      if (rp != 0)
+	{
+	  rr.s.low = n0 >> bm;
+	  rr.s.high = 0;
+	  *rp = rr.ll;
+	}
+    }
+#endif /* UDIV_NEEDS_NORMALIZATION */
+
+  else
+    {
+      if (d1 > n1)
+	{
+	  /* 00 = nn / DD */
+
+	  q0 = 0;
+	  q1 = 0;
+
+	  /* Remainder in n1n0.  */
+	  if (rp != 0)
+	    {
+	      rr.s.low = n0;
+	      rr.s.high = n1;
+	      *rp = rr.ll;
+	    }
+	}
+      else
+	{
+	  /* 0q = NN / dd */
+
+	  count_leading_zeros (bm, d1);
+	  if (bm == 0)
+	    {
+	      /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
+		 conclude (the most significant bit of n1 is set) /\ (the
+		 quotient digit q0 = 0 or 1).
+
+		 This special case is necessary, not an optimization.  */
+
+	      /* The condition on the next line takes advantage of that
+		 n1 >= d1 (true due to program flow).  */
+	      if (n1 > d1 || n0 >= d0)
+		{
+		  q0 = 1;
+		  sub_ddmmss (n1, n0, n1, n0, d1, d0);
+		}
+	      else
+		q0 = 0;
+
+	      q1 = 0;
+
+	      if (rp != 0)
+		{
+		  rr.s.low = n0;
+		  rr.s.high = n1;
+		  *rp = rr.ll;
+		}
+	    }
+	  else
+	    {
+	      UWtype m1, m0;
+	      /* Normalize.  */
+
+	      b = W_TYPE_SIZE - bm;
+
+	      d1 = (d1 << bm) | (d0 >> b);
+	      d0 = d0 << bm;
+	      n2 = n1 >> b;
+	      n1 = (n1 << bm) | (n0 >> b);
+	      n0 = n0 << bm;
+
+	      udiv_qrnnd (q0, n1, n2, n1, d1);
+	      umul_ppmm (m1, m0, q0, d0);
+
+	      if (m1 > n1 || (m1 == n1 && m0 > n0))
+		{
+		  q0--;
+		  sub_ddmmss (m1, m0, m1, m0, d1, d0);
+		}
+
+	      q1 = 0;
+
+	      /* Remainder in (n1n0 - m1m0) >> bm.  */
+	      if (rp != 0)
+		{
+		  sub_ddmmss (n1, n0, n1, n0, m1, m0);
+		  rr.s.low = (n1 << b) | (n0 >> bm);
+		  rr.s.high = n1 >> bm;
+		  *rp = rr.ll;
+		}
+	    }
+	}
+    }
+
+  ww.s.low = q0;
+  ww.s.high = q1;
+  return ww.ll;
+}
+
+#define __negdi2(a) (-(a))
+
+long long __divdi3(long long u, long long v)
+{
+    int c = 0;
+    DWunion uu, vv;
+    DWtype w;
+    
+    uu.ll = u;
+    vv.ll = v;
+    
+    if (uu.s.high < 0) {
+        c = ~c;
+        uu.ll = __negdi2 (uu.ll);
+    }
+    if (vv.s.high < 0) {
+        c = ~c;
+        vv.ll = __negdi2 (vv.ll);
+    }
+    w = __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) 0);
+    if (c)
+        w = __negdi2 (w);
+    return w;
+}
+
+long long __moddi3(long long u, long long v)
+{
+    int c = 0;
+    DWunion uu, vv;
+    DWtype w;
+    
+    uu.ll = u;
+    vv.ll = v;
+    
+    if (uu.s.high < 0) {
+        c = ~c;
+        uu.ll = __negdi2 (uu.ll);
+    }
+    if (vv.s.high < 0)
+        vv.ll = __negdi2 (vv.ll);
+    
+    __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);
+    if (c)
+        w = __negdi2 (w);
+    return w;
+}
+
+unsigned long long __udivdi3(unsigned long long u, unsigned long long v)
+{
+    return __udivmoddi4 (u, v, (UDWtype *) 0);
+}
+
+unsigned long long __umoddi3(unsigned long long u, unsigned long long v)
+{
+    UDWtype w;
+    
+    __udivmoddi4 (u, v, &w);
+    return w;
+}
+
+/* XXX: fix tcc's code generator to do this instead */
+long long __ashrdi3(long long a, int b)
+{
+#ifdef __TINYC__
+    DWunion u;
+    u.ll = a;
+    if (b >= 32) {
+        u.s.low = u.s.high >> (b - 32);
+        u.s.high = u.s.high >> 31;
+    } else if (b != 0) {
+        u.s.low = ((unsigned)u.s.low >> b) | (u.s.high << (32 - b));
+        u.s.high = u.s.high >> b;
+    }
+    return u.ll;
+#else
+    return a >> b;
+#endif
+}
+
+/* XXX: fix tcc's code generator to do this instead */
+unsigned long long __lshrdi3(unsigned long long a, int b)
+{
+#ifdef __TINYC__
+    DWunion u;
+    u.ll = a;
+    if (b >= 32) {
+        u.s.low = (unsigned)u.s.high >> (b - 32);
+        u.s.high = 0;
+    } else if (b != 0) {
+        u.s.low = ((unsigned)u.s.low >> b) | (u.s.high << (32 - b));
+        u.s.high = (unsigned)u.s.high >> b;
+    }
+    return u.ll;
+#else
+    return a >> b;
+#endif
+}
+
+/* XXX: fix tcc's code generator to do this instead */
+long long __ashldi3(long long a, int b)
+{
+#ifdef __TINYC__
+    DWunion u;
+    u.ll = a;
+    if (b >= 32) {
+        u.s.high = (unsigned)u.s.low << (b - 32);
+        u.s.low = 0;
+    } else if (b != 0) {
+        u.s.high = ((unsigned)u.s.high << b) | ((unsigned)u.s.low >> (32 - b));
+        u.s.low = (unsigned)u.s.low << b;
+    }
+    return u.ll;
+#else
+    return a << b;
+#endif
+}
+
+#if defined(__i386__)
+/* FPU control word for rounding to nearest mode */
+unsigned short __tcc_fpu_control = 0x137f;
+/* FPU control word for round to zero mode for int conversion */
+unsigned short __tcc_int_fpu_control = 0x137f | 0x0c00;
+#endif
+
+#endif /* !__x86_64__ */
+
+/* XXX: fix tcc's code generator to do this instead */
+float __floatundisf(unsigned long long a)
+{
+    DWunion uu; 
+    XFtype r;
+
+    uu.ll = a;
+    if (uu.s.high >= 0) {
+        return (float)uu.ll;
+    } else {
+        r = (XFtype)uu.ll;
+        r += 18446744073709551616.0;
+        return (float)r;
+    }
+}
+
+double __floatundidf(unsigned long long a)
+{
+    DWunion uu; 
+    XFtype r;
+
+    uu.ll = a;
+    if (uu.s.high >= 0) {
+        return (double)uu.ll;
+    } else {
+        r = (XFtype)uu.ll;
+        r += 18446744073709551616.0;
+        return (double)r;
+    }
+}
+
+long double __floatundixf(unsigned long long a)
+{
+    DWunion uu; 
+    XFtype r;
+
+    uu.ll = a;
+    if (uu.s.high >= 0) {
+        return (long double)uu.ll;
+    } else {
+        r = (XFtype)uu.ll;
+        r += 18446744073709551616.0;
+        return (long double)r;
+    }
+}
+
+unsigned long long __fixunssfdi (float a1)
+{
+    register union float_long fl1;
+    register int exp;
+    register unsigned long l;
+
+    fl1.f = a1;
+
+    if (fl1.l == 0)
+	return (0);
+
+    exp = EXP (fl1.l) - EXCESS - 24;
+
+    l = MANT(fl1.l);
+    if (exp >= 41)
+	return (unsigned long long)-1;
+    else if (exp >= 0)
+        return (unsigned long long)l << exp;
+    else if (exp >= -23)
+        return l >> -exp;
+    else
+        return 0;
+}
+
+unsigned long long __fixunsdfdi (double a1)
+{
+    register union double_long dl1;
+    register int exp;
+    register unsigned long long l;
+
+    dl1.d = a1;
+
+    if (dl1.ll == 0)
+	return (0);
+
+    exp = EXPD (dl1) - EXCESSD - 53;
+
+    l = MANTD_LL(dl1);
+
+    if (exp >= 12)
+	return (unsigned long long)-1;
+    else if (exp >= 0)
+        return l << exp;
+    else if (exp >= -52)
+        return l >> -exp;
+    else
+        return 0;
+}
+
+unsigned long long __fixunsxfdi (long double a1)
+{
+    register union ldouble_long dl1;
+    register int exp;
+    register unsigned long long l;
+
+    dl1.ld = a1;
+
+    if (dl1.l.lower == 0 && dl1.l.upper == 0)
+	return (0);
+
+    exp = EXPLD (dl1) - EXCESSLD - 64;
+
+    l = dl1.l.lower;
+
+    if (exp > 0)
+	return (unsigned long long)-1;
+    else if (exp >= -63) 
+        return l >> -exp;
+    else
+        return 0;
+}
+
+#if defined(__x86_64__) && !defined(_WIN64)
+
+/* helper functions for stdarg.h */
+
+#include <stdlib.h>
+#ifndef __TINYC__
+/* gives "incompatible types for redefinition of __va_arg" below */
+#include <stdio.h>
+#endif
+
+enum __va_arg_type {
+    __va_gen_reg, __va_float_reg, __va_stack
+};
+
+/* GCC compatible definition of va_list. */
+struct __va_list_struct {
+    unsigned int gp_offset;
+    unsigned int fp_offset;
+    union {
+        unsigned int overflow_offset;
+        char *overflow_arg_area;
+    };
+    char *reg_save_area;
+};
+
+void *__va_start(void *fp)
+{
+    struct __va_list_struct *ap =
+        (struct __va_list_struct *)malloc(sizeof(struct __va_list_struct));
+    *ap = *(struct __va_list_struct *)((char *)fp - 16);
+    ap->overflow_arg_area = (char *)fp + ap->overflow_offset;
+    ap->reg_save_area = (char *)fp - 176 - 16;
+    return ap;
+}
+
+void *__va_arg(struct __va_list_struct *ap,
+               enum __va_arg_type arg_type,
+               int size)
+{
+    size = (size + 7) & ~7;
+    switch (arg_type) {
+    case __va_gen_reg:
+        if (ap->gp_offset < 48) {
+            ap->gp_offset += 8;
+            return ap->reg_save_area + ap->gp_offset - 8;
+        }
+        size = 8;
+        goto use_overflow_area;
+
+    case __va_float_reg:
+        if (ap->fp_offset < 128 + 48) {
+            ap->fp_offset += 16;
+            return ap->reg_save_area + ap->fp_offset - 16;
+        }
+        size = 8;
+        goto use_overflow_area;
+
+    case __va_stack:
+    use_overflow_area:
+        ap->overflow_arg_area += size;
+        return ap->overflow_arg_area - size;
+
+    default:
+#ifndef __TINYC__
+        fprintf(stderr, "unknown ABI type for __va_arg\n");
+#endif
+        abort();
+    }
+}
+
+void *__va_copy(struct __va_list_struct *src)
+{
+    struct __va_list_struct *dest =
+        (struct __va_list_struct *)malloc(sizeof(struct __va_list_struct));
+    *dest = *src;
+    return dest;
+}
+
+void __va_end(struct __va_list_struct *ap)
+{
+    free(ap);
+}
+
+#endif /* __x86_64__ */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/libtcc.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/libtcc.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/libtcc.c	(revision 279)
@@ -0,0 +1,1951 @@
+/*
+ *  TCC - Tiny C Compiler
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+/********************************************************/
+/* global variables */
+
+/* use GNU C extensions */
+ST_DATA int gnu_ext = 1;
+
+/* use TinyCC extensions */
+ST_DATA int tcc_ext = 1;
+
+/* XXX: get rid of this ASAP */
+ST_DATA struct TCCState *tcc_state;
+
+/********************************************************/
+
+#ifdef ONE_SOURCE
+#include "tccpp.c"
+#include "tccgen.c"
+#include "tccelf.c"
+#include "tccrun.c"
+#ifdef TCC_TARGET_I386
+#include "i386-gen.c"
+#endif
+#ifdef TCC_TARGET_ARM
+#include "arm-gen.c"
+#endif
+#ifdef TCC_TARGET_C67
+#include "c67-gen.c"
+#endif
+#ifdef TCC_TARGET_X86_64
+#include "x86_64-gen.c"
+#endif
+#ifdef TCC_TARGET_IL
+#include "il-gen.c"
+#endif
+#ifdef CONFIG_TCC_ASM
+#include "tccasm.c"
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+#include "i386-asm.c"
+#endif
+#endif
+#ifdef TCC_TARGET_COFF
+#include "tcccoff.c"
+#endif
+#ifdef TCC_TARGET_PE
+#include "tccpe.c"
+#endif
+#endif /* ONE_SOURCE */
+
+/********************************************************/
+#ifndef CONFIG_TCC_ASM
+ST_FUNC void asm_instr(void)
+{
+    tcc_error("inline asm() not supported");
+}
+ST_FUNC void asm_global_instr(void)
+{
+    tcc_error("inline asm() not supported");
+}
+#endif
+
+/********************************************************/
+
+#ifdef _WIN32
+char *normalize_slashes(char *path)
+{
+    char *p;
+    for (p = path; *p; ++p)
+        if (*p == '\\')
+            *p = '/';
+    return path;
+}
+
+#if 0
+static HMODULE tcc_module;
+
+/* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */
+static void tcc_set_lib_path_w32(TCCState *s)
+{
+    char path[1024], *p;
+    GetModuleFileNameA(tcc_module, path, sizeof path);
+    p = tcc_basename(normalize_slashes(strlwr(path)));
+    if (p - 5 > path && 0 == strncmp(p - 5, "/bin/", 5))
+        p -= 5;
+    else if (p > path)
+        p--;
+    *p = 0;
+    tcc_set_lib_path(s, path);
+}
+
+#ifdef TCC_TARGET_PE
+static void tcc_add_systemdir(TCCState *s)
+{
+    char buf[1000];
+    GetSystemDirectory(buf, sizeof buf);
+    tcc_add_library_path(s, normalize_slashes(buf));
+}
+#endif
+
+#ifndef CONFIG_TCC_STATIC
+void dlclose(void *p)
+{
+    FreeLibrary((HMODULE)p);
+}
+#endif
+#else
+extern void tcc_set_lib_path_w32(TCCState *s);
+extern void dlclose(void *p);
+#endif
+
+#ifdef LIBTCC_AS_DLL
+BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
+{
+    if (DLL_PROCESS_ATTACH == dwReason)
+        tcc_module = hDll;
+    return TRUE;
+}
+#endif
+#endif
+
+/********************************************************/
+/* copy a string and truncate it. */
+PUB_FUNC char *pstrcpy(char *buf, int buf_size, const char *s)
+{
+    char *q, *q_end;
+    int c;
+
+    if (buf_size > 0) {
+        q = buf;
+        q_end = buf + buf_size - 1;
+        while (q < q_end) {
+            c = *s++;
+            if (c == '\0')
+                break;
+            *q++ = c;
+        }
+        *q = '\0';
+    }
+    return buf;
+}
+
+/* strcat and truncate. */
+PUB_FUNC char *pstrcat(char *buf, int buf_size, const char *s)
+{
+    int len;
+    len = strlen(buf);
+    if (len < buf_size) 
+        pstrcpy(buf + len, buf_size - len, s);
+    return buf;
+}
+
+PUB_FUNC char *pstrncpy(char *out, const char *in, size_t num)
+{
+    memcpy(out, in, num);
+    out[num] = '\0';
+    return out;
+}
+
+/* extract the basename of a file */
+PUB_FUNC char *tcc_basename(const char *name)
+{
+    char *p = strchr(name, 0);
+    while (p > name && !IS_DIRSEP(p[-1]))
+        --p;
+    return p;
+}
+
+/* extract extension part of a file
+ *
+ * (if no extension, return pointer to end-of-string)
+ */
+PUB_FUNC char *tcc_fileextension (const char *name)
+{
+    char *b = tcc_basename(name);
+    char *e = strrchr(b, '.');
+    return e ? e : strchr(b, 0);
+}
+
+/********************************************************/
+/* memory management */
+
+#undef free
+#undef malloc
+#undef realloc
+
+#ifdef MEM_DEBUG
+ST_DATA int mem_cur_size;
+ST_DATA int mem_max_size;
+unsigned malloc_usable_size(void*);
+#endif
+
+PUB_FUNC void tcc_free(void *ptr)
+{
+#ifdef MEM_DEBUG
+    mem_cur_size -= malloc_usable_size(ptr);
+#endif
+	free(ptr);
+}
+
+PUB_FUNC void *tcc_malloc(unsigned long size)
+{
+    void *ptr;
+    ptr = malloc(size);
+    if (!ptr && size)
+        tcc_error("memory full");
+#ifdef MEM_DEBUG
+    mem_cur_size += malloc_usable_size(ptr);
+    if (mem_cur_size > mem_max_size)
+        mem_max_size = mem_cur_size;
+#endif
+    return ptr;
+}
+
+PUB_FUNC void *tcc_mallocz(unsigned long size)
+{
+    void *ptr;
+    ptr = tcc_malloc(size);
+    memset(ptr, 0, size);
+    return ptr;
+}
+
+PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size)
+{
+    void *ptr1;
+#ifdef MEM_DEBUG
+    mem_cur_size -= malloc_usable_size(ptr);
+#endif
+    ptr1 = realloc(ptr, size);
+    if (!ptr1 && size)
+        tcc_error("memory full");
+#ifdef MEM_DEBUG
+    /* NOTE: count not correct if alloc error, but not critical */
+    mem_cur_size += malloc_usable_size(ptr1);
+    if (mem_cur_size > mem_max_size)
+        mem_max_size = mem_cur_size;
+#endif
+    return ptr1;
+}
+
+PUB_FUNC char *tcc_strdup(const char *str)
+{
+    char *ptr;
+    ptr = tcc_malloc(strlen(str) + 1);
+    strcpy(ptr, str);
+    return ptr;
+}
+
+PUB_FUNC void tcc_memstats(void)
+{
+#ifdef MEM_DEBUG
+    printf("memory: %d bytes, max = %d bytes\n", mem_cur_size, mem_max_size);
+#endif
+}
+
+#define free(p) use_tcc_free(p)
+#define malloc(s) use_tcc_malloc(s)
+#define realloc(p, s) use_tcc_realloc(p, s)
+
+/********************************************************/
+/* dynarrays */
+
+ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data)
+{
+    int nb, nb_alloc;
+    void **pp;
+    
+    nb = *nb_ptr;
+    pp = *ptab;
+    /* every power of two we double array size */
+    if ((nb & (nb - 1)) == 0) {
+        if (!nb)
+            nb_alloc = 1;
+        else
+            nb_alloc = nb * 2;
+        pp = tcc_realloc(pp, nb_alloc * sizeof(void *));
+        *ptab = pp;
+    }
+    pp[nb++] = data;
+    *nb_ptr = nb;
+}
+
+ST_FUNC void dynarray_reset(void *pp, int *n)
+{
+    void **p;
+    for (p = *(void***)pp; *n; ++p, --*n)
+        if (*p)
+            tcc_free(*p);
+    tcc_free(*(void**)pp);
+    *(void**)pp = NULL;
+}
+
+static void tcc_split_path(TCCState *s, void ***p_ary, int *p_nb_ary, const char *in)
+{
+    const char *p;
+    do {
+        int c;
+        CString str;
+
+        cstr_new(&str);
+        for (p = in; c = *p, c != '\0' && c != PATHSEP; ++p) {
+            if (c == '{' && p[1] && p[2] == '}') {
+                c = p[1], p += 2;
+                if (c == 'B')
+                    cstr_cat(&str, s->tcc_lib_path);
+            } else {
+                cstr_ccat(&str, c);
+            }
+        }
+        cstr_ccat(&str, '\0');
+        dynarray_add(p_ary, p_nb_ary, str.data);
+        in = p+1;
+    } while (*p);
+}
+
+/********************************************************/
+
+ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags)
+{
+    Section *sec;
+
+    sec = tcc_mallocz(sizeof(Section) + strlen(name));
+    strcpy(sec->name, name);
+    sec->sh_type = sh_type;
+    sec->sh_flags = sh_flags;
+    switch(sh_type) {
+    case SHT_HASH:
+    case SHT_REL:
+    case SHT_RELA:
+    case SHT_DYNSYM:
+    case SHT_SYMTAB:
+    case SHT_DYNAMIC:
+        sec->sh_addralign = 4;
+        break;
+    case SHT_STRTAB:
+        sec->sh_addralign = 1;
+        break;
+    default:
+        sec->sh_addralign = 32; /* default conservative alignment */
+        break;
+    }
+
+    if (sh_flags & SHF_PRIVATE) {
+        dynarray_add((void ***)&s1->priv_sections, &s1->nb_priv_sections, sec);
+    } else {
+        sec->sh_num = s1->nb_sections;
+        dynarray_add((void ***)&s1->sections, &s1->nb_sections, sec);
+    }
+
+    return sec;
+}
+
+static void free_section(Section *s)
+{
+    tcc_free(s->data);
+}
+
+/* realloc section and set its content to zero */
+ST_FUNC void section_realloc(Section *sec, unsigned long new_size)
+{
+    unsigned long size;
+    unsigned char *data;
+    
+    size = sec->data_allocated;
+    if (size == 0)
+        size = 1;
+    while (size < new_size)
+        size = size * 2;
+    data = tcc_realloc(sec->data, size);
+    memset(data + sec->data_allocated, 0, size - sec->data_allocated);
+    sec->data = data;
+    sec->data_allocated = size;
+}
+
+/* reserve at least 'size' bytes in section 'sec' from
+   sec->data_offset. */
+ST_FUNC void *section_ptr_add(Section *sec, unsigned long size)
+{
+    unsigned long offset, offset1;
+
+    offset = sec->data_offset;
+    offset1 = offset + size;
+    if (offset1 > sec->data_allocated)
+        section_realloc(sec, offset1);
+    sec->data_offset = offset1;
+    return sec->data + offset;
+}
+
+/* reserve at least 'size' bytes from section start */
+ST_FUNC void section_reserve(Section *sec, unsigned long size)
+{
+    if (size > sec->data_allocated)
+        section_realloc(sec, size);
+    if (size > sec->data_offset)
+        sec->data_offset = size;
+}
+
+/* return a reference to a section, and create it if it does not
+   exists */
+ST_FUNC Section *find_section(TCCState *s1, const char *name)
+{
+    Section *sec;
+    int i;
+    for(i = 1; i < s1->nb_sections; i++) {
+        sec = s1->sections[i];
+        if (!strcmp(name, sec->name)) 
+            return sec;
+    }
+    /* sections are created as PROGBITS */
+    return new_section(s1, name, SHT_PROGBITS, SHF_ALLOC);
+}
+
+/* update sym->c so that it points to an external symbol in section
+   'section' with value 'value' */
+ST_FUNC void put_extern_sym2(Sym *sym, Section *section, 
+                            addr_t value, unsigned long size,
+                            int can_add_underscore)
+{
+    int sym_type, sym_bind, sh_num, info, other;
+    ElfW(Sym) *esym;
+    const char *name;
+    char buf1[256];
+
+    if (section == NULL)
+        sh_num = SHN_UNDEF;
+    else if (section == SECTION_ABS) 
+        sh_num = SHN_ABS;
+    else
+        sh_num = section->sh_num;
+
+    if ((sym->type.t & VT_BTYPE) == VT_FUNC) {
+        sym_type = STT_FUNC;
+    } else if ((sym->type.t & VT_BTYPE) == VT_VOID) {
+        sym_type = STT_NOTYPE;
+    } else {
+        sym_type = STT_OBJECT;
+    }
+
+    if (sym->type.t & VT_STATIC)
+        sym_bind = STB_LOCAL;
+    else {
+        if (sym->type.t & VT_WEAK)
+            sym_bind = STB_WEAK;
+        else
+            sym_bind = STB_GLOBAL;
+    }
+
+    if (!sym->c) {
+        name = get_tok_str(sym->v, NULL);
+#ifdef CONFIG_TCC_BCHECK
+        if (tcc_state->do_bounds_check) {
+            char buf[32];
+
+            /* XXX: avoid doing that for statics ? */
+            /* if bound checking is activated, we change some function
+               names by adding the "__bound" prefix */
+            switch(sym->v) {
+#ifdef TCC_TARGET_PE
+            /* XXX: we rely only on malloc hooks */
+            case TOK_malloc: 
+            case TOK_free: 
+            case TOK_realloc: 
+            case TOK_memalign: 
+            case TOK_calloc: 
+#endif
+            case TOK_memcpy: 
+            case TOK_memmove:
+            case TOK_memset:
+            case TOK_strlen:
+            case TOK_strcpy:
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+            case TOK_alloca:
+#endif
+                strcpy(buf, "__bound_");
+                strcat(buf, name);
+                name = buf;
+                break;
+            }
+        }
+#endif
+        other = 0;
+
+#ifdef TCC_TARGET_PE
+        if (sym->type.t & VT_EXPORT)
+            other |= 1;
+        if (sym_type == STT_FUNC && sym->type.ref) {
+            int attr = sym->type.ref->r;
+            if (FUNC_EXPORT(attr))
+                other |= 1;
+            if (FUNC_CALL(attr) == FUNC_STDCALL && can_add_underscore) {
+                sprintf(buf1, "_%s@%d", name, FUNC_ARGS(attr) * PTR_SIZE);
+                name = buf1;
+                other |= 2;
+                can_add_underscore = 0;
+            }
+        } else {
+            if (find_elf_sym(tcc_state->dynsymtab_section, name))
+                other |= 4;
+            if (sym->type.t & VT_IMPORT)
+                other |= 4;
+        }
+#endif
+        if (tcc_state->leading_underscore && can_add_underscore) {
+            buf1[0] = '_';
+            pstrcpy(buf1 + 1, sizeof(buf1) - 1, name);
+            name = buf1;
+        }
+        if (sym->asm_label) {
+            name = sym->asm_label;
+        }
+        info = ELFW(ST_INFO)(sym_bind, sym_type);
+        sym->c = add_elf_sym(symtab_section, value, size, info, other, sh_num, name);
+    } else {
+        esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
+        esym->st_value = value;
+        esym->st_size = size;
+        esym->st_shndx = sh_num;
+    }
+}
+
+ST_FUNC void put_extern_sym(Sym *sym, Section *section, 
+                           addr_t value, unsigned long size)
+{
+    put_extern_sym2(sym, section, value, size, 1);
+}
+
+/* add a new relocation entry to symbol 'sym' in section 's' */
+ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type)
+{
+    int c = 0;
+    if (sym) {
+        if (0 == sym->c)
+            put_extern_sym(sym, NULL, 0, 0);
+        c = sym->c;
+    }
+    /* now we can add ELF relocation info */
+    put_elf_reloc(symtab_section, s, offset, type, c);
+}
+
+/********************************************************/
+
+static void strcat_vprintf(char *buf, int buf_size, const char *fmt, va_list ap)
+{
+    int len;
+    len = strlen(buf);
+    vsnprintf(buf + len, buf_size - len, fmt, ap);
+}
+
+static void strcat_printf(char *buf, int buf_size, const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    strcat_vprintf(buf, buf_size, fmt, ap);
+    va_end(ap);
+}
+
+static void error1(TCCState *s1, int is_warning, const char *fmt, va_list ap)
+{
+    char buf[2048];
+    BufferedFile **pf, *f;
+    
+    buf[0] = '\0';
+    /* use upper file if inline ":asm:" or token ":paste:" */
+    for (f = file; f && f->filename[0] == ':'; f = f->prev);
+    if (f) {
+        for(pf = s1->include_stack; pf < s1->include_stack_ptr; pf++)
+            strcat_printf(buf, sizeof(buf), "In file included from %s:%d:\n",
+                (*pf)->filename, (*pf)->line_num);
+        if (f->line_num > 0) {
+            strcat_printf(buf, sizeof(buf), "%s:%d: ",
+                f->filename, f->line_num);
+        } else {
+            strcat_printf(buf, sizeof(buf), "%s: ",
+                f->filename);
+        }
+    } else {
+        strcat_printf(buf, sizeof(buf), "tcc: ");
+    }
+    if (is_warning)
+        strcat_printf(buf, sizeof(buf), "warning: ");
+    else
+        strcat_printf(buf, sizeof(buf), "error: ");
+    strcat_vprintf(buf, sizeof(buf), fmt, ap);
+
+    if (!s1->error_func) {
+        /* default case: stderr */
+        fprintf(stderr, "%s\n", buf);
+    } else {
+        s1->error_func(s1->error_opaque, buf);
+    }
+    if (!is_warning || s1->warn_error)
+        s1->nb_errors++;
+}
+
+LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque,
+                        void (*error_func)(void *opaque, const char *msg))
+{
+    s->error_opaque = error_opaque;
+    s->error_func = error_func;
+}
+
+/* error without aborting current compilation */
+PUB_FUNC void tcc_error_noabort(const char *fmt, ...)
+{
+    TCCState *s1 = tcc_state;
+    va_list ap;
+
+    va_start(ap, fmt);
+    error1(s1, 0, fmt, ap);
+    va_end(ap);
+}
+
+PUB_FUNC void tcc_error(const char *fmt, ...)
+{
+    TCCState *s1 = tcc_state;
+    va_list ap;
+
+    va_start(ap, fmt);
+    error1(s1, 0, fmt, ap);
+    va_end(ap);
+    /* better than nothing: in some cases, we accept to handle errors */
+    if (s1->error_set_jmp_enabled) {
+        longjmp(s1->error_jmp_buf, 1);
+    } else {
+        /* XXX: eliminate this someday */
+        exit(1);
+    }
+}
+
+PUB_FUNC void tcc_warning(const char *fmt, ...)
+{
+    TCCState *s1 = tcc_state;
+    va_list ap;
+
+    if (s1->warn_none)
+        return;
+
+    va_start(ap, fmt);
+    error1(s1, 1, fmt, ap);
+    va_end(ap);
+}
+
+/********************************************************/
+/* I/O layer */
+
+ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen)
+{
+    BufferedFile *bf;
+    int buflen = initlen ? initlen : IO_BUF_SIZE;
+
+    bf = tcc_malloc(sizeof(BufferedFile) + buflen);
+    bf->buf_ptr = bf->buffer;
+    bf->buf_end = bf->buffer + initlen;
+    bf->buf_end[0] = CH_EOB; /* put eob symbol */
+    pstrcpy(bf->filename, sizeof(bf->filename), filename);
+#ifdef _WIN32
+    normalize_slashes(bf->filename);
+#endif
+    bf->line_num = 1;
+    bf->ifndef_macro = 0;
+    bf->ifdef_stack_ptr = s1->ifdef_stack_ptr;
+    bf->fd = -1;
+    bf->prev = file;
+    file = bf;
+}
+
+ST_FUNC void tcc_close(void)
+{
+    BufferedFile *bf = file;
+    if (bf->fd > 0) {
+        close(bf->fd);
+        total_lines += bf->line_num;
+    }
+    file = bf->prev;
+    tcc_free(bf);
+}
+
+ST_FUNC int tcc_open(TCCState *s1, const char *filename)
+{
+    int fd;
+    if (strcmp(filename, "-") == 0)
+        fd = 0, filename = "stdin";
+    else
+        fd = open(filename, O_RDONLY | O_BINARY);
+    if ((s1->verbose == 2 && fd >= 0) || s1->verbose == 3)
+        printf("%s %*s%s\n", fd < 0 ? "nf":"->",
+               (int)(s1->include_stack_ptr - s1->include_stack), "", filename);
+    if (fd < 0)
+        return -1;
+
+    tcc_open_bf(s1, filename, 0);
+    file->fd = fd;
+    return fd;
+}
+
+/* compile the C file opened in 'file'. Return non zero if errors. */
+static int tcc_compile(TCCState *s1)
+{
+    Sym *define_start;
+    SValue *pvtop;
+    char buf[512];
+    volatile int section_sym;
+
+#ifdef INC_DEBUG
+    printf("%s: **** new file\n", file->filename);
+#endif
+    preprocess_init(s1);
+
+    cur_text_section = NULL;
+    funcname = "";
+    anon_sym = SYM_FIRST_ANOM; 
+
+    /* file info: full path + filename */
+    section_sym = 0; /* avoid warning */
+    if (s1->do_debug) {
+        section_sym = put_elf_sym(symtab_section, 0, 0, 
+                                  ELFW(ST_INFO)(STB_LOCAL, STT_SECTION), 0, 
+                                  text_section->sh_num, NULL);
+        getcwd(buf, sizeof(buf));
+#ifdef _WIN32
+        normalize_slashes(buf);
+#endif
+        pstrcat(buf, sizeof(buf), "/");
+        put_stabs_r(buf, N_SO, 0, 0, 
+                    text_section->data_offset, text_section, section_sym);
+        put_stabs_r(file->filename, N_SO, 0, 0, 
+                    text_section->data_offset, text_section, section_sym);
+    }
+    /* an elf symbol of type STT_FILE must be put so that STB_LOCAL
+       symbols can be safely used */
+    put_elf_sym(symtab_section, 0, 0, 
+                ELFW(ST_INFO)(STB_LOCAL, STT_FILE), 0, 
+                SHN_ABS, file->filename);
+
+    /* define some often used types */
+    int_type.t = VT_INT;
+
+    char_pointer_type.t = VT_BYTE;
+    mk_pointer(&char_pointer_type);
+
+#if PTR_SIZE == 4
+    size_type.t = VT_INT;
+#else
+    size_type.t = VT_LLONG;
+#endif
+
+    func_old_type.t = VT_FUNC;
+    func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD);
+#ifdef TCC_TARGET_ARM
+    arm_init_types();
+#endif
+
+#if 0
+    /* define 'void *alloca(unsigned int)' builtin function */
+    {
+        Sym *s1;
+
+        p = anon_sym++;
+        sym = sym_push(p, mk_pointer(VT_VOID), FUNC_CDECL, FUNC_NEW);
+        s1 = sym_push(SYM_FIELD, VT_UNSIGNED | VT_INT, 0, 0);
+        s1->next = NULL;
+        sym->next = s1;
+        sym_push(TOK_alloca, VT_FUNC | (p << VT_STRUCT_SHIFT), VT_CONST, 0);
+    }
+#endif
+
+    define_start = define_stack;
+    nocode_wanted = 1;
+
+    if (setjmp(s1->error_jmp_buf) == 0) {
+        s1->nb_errors = 0;
+        s1->error_set_jmp_enabled = 1;
+
+        ch = file->buf_ptr[0];
+        tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
+        parse_flags = PARSE_FLAG_PREPROCESS | PARSE_FLAG_TOK_NUM;
+        pvtop = vtop;
+        next();
+        decl(VT_CONST);
+        if (tok != TOK_EOF)
+            expect("declaration");
+        if (pvtop != vtop)
+            tcc_warning("internal compiler error: vstack leak? (%d)", vtop - pvtop);
+
+        /* end of translation unit info */
+        if (s1->do_debug) {
+            put_stabs_r(NULL, N_SO, 0, 0, 
+                        text_section->data_offset, text_section, section_sym);
+        }
+    }
+
+    s1->error_set_jmp_enabled = 0;
+
+    /* reset define stack, but leave -Dsymbols (may be incorrect if
+       they are undefined) */
+    free_defines(define_start); 
+
+    gen_inline_functions();
+
+    sym_pop(&global_stack, NULL);
+    sym_pop(&local_stack, NULL);
+
+    return s1->nb_errors != 0 ? -1 : 0;
+}
+
+LIBTCCAPI int tcc_compile_string(TCCState *s, const char *str)
+{
+    int len, ret;
+    len = strlen(str);
+
+    tcc_open_bf(s, "<string>", len);
+    memcpy(file->buffer, str, len);
+    ret = tcc_compile(s);
+    tcc_close();
+    return ret;
+}
+
+/* define a preprocessor symbol. A value can also be provided with the '=' operator */
+LIBTCCAPI void tcc_define_symbol(TCCState *s1, const char *sym, const char *value)
+{
+    int len1, len2;
+    /* default value */
+    if (!value)
+        value = "1";
+    len1 = strlen(sym);
+    len2 = strlen(value);
+
+    /* init file structure */
+    tcc_open_bf(s1, "<define>", len1 + len2 + 1);
+    memcpy(file->buffer, sym, len1);
+    file->buffer[len1] = ' ';
+    memcpy(file->buffer + len1 + 1, value, len2);
+
+    /* parse with define parser */
+    ch = file->buf_ptr[0];
+    next_nomacro();
+    parse_define();
+
+    tcc_close();
+}
+
+/* undefine a preprocessor symbol */
+LIBTCCAPI void tcc_undefine_symbol(TCCState *s1, const char *sym)
+{
+    TokenSym *ts;
+    Sym *s;
+    ts = tok_alloc(sym, strlen(sym));
+    s = define_find(ts->tok);
+    /* undefine symbol by putting an invalid name */
+    if (s)
+        define_undef(s);
+}
+
+/* cleanup all static data used during compilation */
+static void tcc_cleanup(void)
+{
+    int i, n;
+    if (NULL == tcc_state)
+        return;
+    tcc_state = NULL;
+
+    /* free -D defines */
+    free_defines(NULL);
+
+    /* free tokens */
+    n = tok_ident - TOK_IDENT;
+    for(i = 0; i < n; i++)
+        tcc_free(table_ident[i]);
+    tcc_free(table_ident);
+
+    /* free sym_pools */
+    dynarray_reset(&sym_pools, &nb_sym_pools);
+    /* string buffer */
+    cstr_free(&tokcstr);
+    /* reset symbol stack */
+    sym_free_first = NULL;
+    /* cleanup from error/setjmp */
+    macro_ptr = NULL;
+}
+
+LIBTCCAPI TCCState *tcc_new(void)
+{
+    TCCState *s;
+    char buffer[100];
+    int a,b,c;
+
+    tcc_cleanup();
+
+    s = tcc_mallocz(sizeof(TCCState));
+    if (!s)
+        return NULL;
+    tcc_state = s;
+#ifdef _WIN32
+    tcc_set_lib_path_w32(s);
+#else
+    tcc_set_lib_path(s, CONFIG_TCCDIR);
+#endif
+    s->output_type = TCC_OUTPUT_MEMORY;
+    preprocess_new();
+    s->include_stack_ptr = s->include_stack;
+
+    /* we add dummy defines for some special macros to speed up tests
+       and to have working defined() */
+    define_push(TOK___LINE__, MACRO_OBJ, NULL, NULL);
+    define_push(TOK___FILE__, MACRO_OBJ, NULL, NULL);
+    define_push(TOK___DATE__, MACRO_OBJ, NULL, NULL);
+    define_push(TOK___TIME__, MACRO_OBJ, NULL, NULL);
+
+    /* define __TINYC__ 92X  */
+    sscanf(TCC_VERSION, "%d.%d.%d", &a, &b, &c);
+    sprintf(buffer, "%d", a*10000 + b*100 + c);
+    tcc_define_symbol(s, "__TINYC__", buffer);
+
+    /* standard defines */
+    tcc_define_symbol(s, "__STDC__", NULL);
+    tcc_define_symbol(s, "__STDC_VERSION__", "199901L");
+
+    /* target defines */
+#if defined(TCC_TARGET_I386)
+    tcc_define_symbol(s, "__i386__", NULL);
+    tcc_define_symbol(s, "__i386", NULL);
+    tcc_define_symbol(s, "i386", NULL);
+#elif defined(TCC_TARGET_X86_64)
+    tcc_define_symbol(s, "__x86_64__", NULL);
+#elif defined(TCC_TARGET_ARM)
+    tcc_define_symbol(s, "__ARM_ARCH_4__", NULL);
+    tcc_define_symbol(s, "__arm_elf__", NULL);
+    tcc_define_symbol(s, "__arm_elf", NULL);
+    tcc_define_symbol(s, "arm_elf", NULL);
+    tcc_define_symbol(s, "__arm__", NULL);
+    tcc_define_symbol(s, "__arm", NULL);
+    tcc_define_symbol(s, "arm", NULL);
+    tcc_define_symbol(s, "__APCS_32__", NULL);
+#endif
+
+#ifdef TCC_TARGET_PE
+    tcc_define_symbol(s, "_WIN32", NULL);
+# ifdef TCC_TARGET_X86_64
+    tcc_define_symbol(s, "_WIN64", NULL);
+# endif
+#else
+    tcc_define_symbol(s, "__unix__", NULL);
+    tcc_define_symbol(s, "__unix", NULL);
+    tcc_define_symbol(s, "unix", NULL);
+# if defined(__linux)
+    tcc_define_symbol(s, "__linux__", NULL);
+    tcc_define_symbol(s, "__linux", NULL);
+# endif
+# if defined(__FreeBSD__)
+#  define str(s) #s
+    tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
+#  undef str
+# endif
+# if defined(__FreeBSD_kernel__)
+    tcc_define_symbol(s, "__FreeBSD_kernel__", NULL);
+# endif
+#endif
+
+    /* TinyCC & gcc defines */
+#if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64
+    tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long long");
+    tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long long");
+#else
+    tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long");
+    tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long");
+#endif
+
+#ifdef TCC_TARGET_PE
+    tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
+#else
+    tcc_define_symbol(s, "__WCHAR_TYPE__", "int");
+#endif
+
+#ifndef TCC_TARGET_PE
+    /* glibc defines */
+    tcc_define_symbol(s, "__REDIRECT(name, proto, alias)", "name proto __asm__ (#alias)");
+    tcc_define_symbol(s, "__REDIRECT_NTH(name, proto, alias)", "name proto __asm__ (#alias) __THROW");
+    /* default library paths */
+    tcc_add_library_path(s, CONFIG_TCC_LIBPATHS);
+    /* paths for crt objects */
+    tcc_split_path(s, (void ***)&s->crt_paths, &s->nb_crt_paths, CONFIG_TCC_CRTPREFIX);
+#endif
+
+    /* no section zero */
+    dynarray_add((void ***)&s->sections, &s->nb_sections, NULL);
+
+    /* create standard sections */
+    text_section = new_section(s, ".text", SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR);
+    data_section = new_section(s, ".data", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+    bss_section = new_section(s, ".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
+
+    /* symbols are always generated for linking stage */
+    symtab_section = new_symtab(s, ".symtab", SHT_SYMTAB, 0,
+                                ".strtab",
+                                ".hashtab", SHF_PRIVATE); 
+    strtab_section = symtab_section->link;
+    s->symtab = symtab_section;
+    
+    /* private symbol table for dynamic symbols */
+    s->dynsymtab_section = new_symtab(s, ".dynsymtab", SHT_SYMTAB, SHF_PRIVATE,
+                                      ".dynstrtab", 
+                                      ".dynhashtab", SHF_PRIVATE);
+    s->alacarte_link = 1;
+    s->nocommon = 1;
+    s->section_align = ELF_PAGE_SIZE;
+
+#ifdef CHAR_IS_UNSIGNED
+    s->char_is_unsigned = 1;
+#endif
+    /* enable this if you want symbols with leading underscore on windows: */
+#if 0 //def TCC_TARGET_PE
+    s->leading_underscore = 1;
+#endif
+#ifdef TCC_TARGET_I386
+    s->seg_size = 32;
+#endif
+    return s;
+}
+
+LIBTCCAPI void tcc_delete(TCCState *s1)
+{
+    int i;
+
+    tcc_cleanup();
+
+    /* free all sections */
+    for(i = 1; i < s1->nb_sections; i++)
+        free_section(s1->sections[i]);
+    dynarray_reset(&s1->sections, &s1->nb_sections);
+
+    for(i = 0; i < s1->nb_priv_sections; i++)
+        free_section(s1->priv_sections[i]);
+    dynarray_reset(&s1->priv_sections, &s1->nb_priv_sections);
+        
+    /* free any loaded DLLs */
+    for ( i = 0; i < s1->nb_loaded_dlls; i++) {
+        DLLReference *ref = s1->loaded_dlls[i];
+        if ( ref->handle )
+            dlclose(ref->handle);
+    }
+    
+    /* free loaded dlls array */
+    dynarray_reset(&s1->loaded_dlls, &s1->nb_loaded_dlls);
+
+    /* free library paths */
+    dynarray_reset(&s1->library_paths, &s1->nb_library_paths);
+    dynarray_reset(&s1->crt_paths, &s1->nb_crt_paths);
+
+    /* free include paths */
+    dynarray_reset(&s1->cached_includes, &s1->nb_cached_includes);
+    dynarray_reset(&s1->include_paths, &s1->nb_include_paths);
+    dynarray_reset(&s1->sysinclude_paths, &s1->nb_sysinclude_paths);
+
+    tcc_free(s1->tcc_lib_path);
+    tcc_free(s1->soname);
+    tcc_free(s1->rpath);
+    tcc_free(s1->init_symbol);
+    tcc_free(s1->fini_symbol);
+    tcc_free(s1->outfile);
+    tcc_free(s1->deps_outfile);
+    dynarray_reset(&s1->files, &s1->nb_files);
+    dynarray_reset(&s1->target_deps, &s1->nb_target_deps);
+
+#ifdef TCC_IS_NATIVE
+# ifdef HAVE_SELINUX
+    munmap (s1->write_mem, s1->mem_size);
+    munmap (s1->runtime_mem, s1->mem_size);    
+# else
+    tcc_free(s1->runtime_mem);
+# endif
+#endif
+
+    tcc_free(s1);
+}
+
+LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname)
+{
+    tcc_split_path(s, (void ***)&s->include_paths, &s->nb_include_paths, pathname);
+    return 0;
+}
+
+LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname)
+{
+    tcc_split_path(s, (void ***)&s->sysinclude_paths, &s->nb_sysinclude_paths, pathname);
+    return 0;
+}
+
+ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
+{
+    const char *ext;
+    ElfW(Ehdr) ehdr;
+    int fd, ret, size;
+
+    /* find source file type with extension */
+    ext = tcc_fileextension(filename);
+    if (ext[0])
+        ext++;
+
+#ifdef CONFIG_TCC_ASM
+    /* if .S file, define __ASSEMBLER__ like gcc does */
+    if (!strcmp(ext, "S"))
+        tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
+#endif
+
+    /* open the file */
+    ret = tcc_open(s1, filename);
+    if (ret < 0) {
+        if (flags & AFF_PRINT_ERROR)
+            tcc_error_noabort("file '%s' not found", filename);
+        return ret;
+    }
+
+    /* update target deps */
+    dynarray_add((void ***)&s1->target_deps, &s1->nb_target_deps,
+            tcc_strdup(filename));
+
+    if (flags & AFF_PREPROCESS) {
+        ret = tcc_preprocess(s1);
+        goto the_end;
+    }
+
+    if (!ext[0] || !PATHCMP(ext, "c")) {
+        /* C file assumed */
+        ret = tcc_compile(s1);
+        goto the_end;
+    }
+
+#ifdef CONFIG_TCC_ASM
+    if (!strcmp(ext, "S")) {
+        /* preprocessed assembler */
+        ret = tcc_assemble(s1, 1);
+        goto the_end;
+    }
+
+    if (!strcmp(ext, "s")) {
+        /* non preprocessed assembler */
+        ret = tcc_assemble(s1, 0);
+        goto the_end;
+    }
+#endif
+
+    fd = file->fd;
+    /* assume executable format: auto guess file type */
+    size = read(fd, &ehdr, sizeof(ehdr));
+    lseek(fd, 0, SEEK_SET);
+    if (size <= 0) {
+        tcc_error_noabort("could not read header");
+        goto the_end;
+    }
+
+    if (size == sizeof(ehdr) &&
+        ehdr.e_ident[0] == ELFMAG0 &&
+        ehdr.e_ident[1] == ELFMAG1 &&
+        ehdr.e_ident[2] == ELFMAG2 &&
+        ehdr.e_ident[3] == ELFMAG3) {
+
+        /* do not display line number if error */
+        file->line_num = 0;
+        if (ehdr.e_type == ET_REL) {
+            ret = tcc_load_object_file(s1, fd, 0);
+            goto the_end;
+
+        }
+#ifndef TCC_TARGET_PE
+        if (ehdr.e_type == ET_DYN) {
+            if (s1->output_type == TCC_OUTPUT_MEMORY) {
+#ifdef TCC_IS_NATIVE
+                void *h;
+                h = dlopen(filename, RTLD_GLOBAL | RTLD_LAZY);
+                if (h)
+#endif
+                    ret = 0;
+            } else {
+                ret = tcc_load_dll(s1, fd, filename, 
+                                   (flags & AFF_REFERENCED_DLL) != 0);
+            }
+            goto the_end;
+        }
+#endif
+        tcc_error_noabort("unrecognized ELF file");
+        goto the_end;
+    }
+
+    if (memcmp((char *)&ehdr, ARMAG, 8) == 0) {
+        file->line_num = 0; /* do not display line number if error */
+        ret = tcc_load_archive(s1, fd);
+        goto the_end;
+    }
+
+#ifdef TCC_TARGET_COFF
+    if (*(uint16_t *)(&ehdr) == COFF_C67_MAGIC) {
+        ret = tcc_load_coff(s1, fd);
+        goto the_end;
+    }
+#endif
+
+#ifdef TCC_TARGET_PE
+    ret = pe_load_file(s1, filename, fd);
+#else
+    /* as GNU ld, consider it is an ld script if not recognized */
+    ret = tcc_load_ldscript(s1);
+#endif
+    if (ret < 0)
+        tcc_error_noabort("unrecognized file type");
+
+the_end:
+    tcc_close();
+    return ret;
+}
+
+LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename)
+{
+    if (s->output_type == TCC_OUTPUT_PREPROCESS)
+        return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR | AFF_PREPROCESS);
+    else
+        return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR);
+}
+
+LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname)
+{
+    tcc_split_path(s, (void ***)&s->library_paths, &s->nb_library_paths, pathname);
+    return 0;
+}
+
+static int tcc_add_library_internal(TCCState *s, const char *fmt,
+    const char *filename, int flags, char **paths, int nb_paths)
+{
+    char buf[1024];
+    int i;
+
+    for(i = 0; i < nb_paths; i++) {
+        snprintf(buf, sizeof(buf), fmt, paths[i], filename);
+        if (tcc_add_file_internal(s, buf, flags) == 0)
+            return 0;
+    }
+    return -1;
+}
+
+/* find and load a dll. Return non zero if not found */
+/* XXX: add '-rpath' option support ? */
+ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags)
+{
+    return tcc_add_library_internal(s, "%s/%s", filename, flags,
+        s->library_paths, s->nb_library_paths);
+}
+
+ST_FUNC int tcc_add_crt(TCCState *s, const char *filename)
+{
+    if (-1 == tcc_add_library_internal(s, "%s/%s",
+        filename, 0, s->crt_paths, s->nb_crt_paths))
+        tcc_error_noabort("file '%s' not found", filename);
+    return 0;
+}
+
+/* the library name is the same as the argument of the '-l' option */
+LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
+{
+#ifdef TCC_TARGET_PE
+    const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL };
+    const char **pp = s->static_link ? libs + 4 : libs;
+#else
+    const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL };
+    const char **pp = s->static_link ? libs + 1 : libs;
+#endif
+    while (*pp) {
+        if (0 == tcc_add_library_internal(s, *pp,
+            libraryname, 0, s->library_paths, s->nb_library_paths))
+            return 0;
+        ++pp;
+    }
+    return -1;
+}
+
+LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val)
+{
+#ifdef TCC_TARGET_PE
+    /* On x86_64 'val' might not be reachable with a 32bit offset.
+       So it is handled here as if it were in a DLL. */
+    pe_putimport(s, 0, name, (uintptr_t)val);
+#else
+    /* XXX: Same problem on linux but currently "solved" elsewhere
+       via the rather dirty 'runtime_plt_and_got' hack. */
+    add_elf_sym(symtab_section, (uintptr_t)val, 0,
+        ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+        SHN_ABS, name);
+#endif
+    return 0;
+}
+
+LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
+{
+    s->output_type = output_type;
+
+    if (!s->nostdinc) {
+        /* default include paths */
+        /* -isystem paths have already been handled */
+        tcc_add_sysinclude_path(s, CONFIG_TCC_SYSINCLUDEPATHS);
+    }
+
+    /* if bound checking, then add corresponding sections */
+#ifdef CONFIG_TCC_BCHECK
+    if (s->do_bounds_check) {
+        /* define symbol */
+        tcc_define_symbol(s, "__BOUNDS_CHECKING_ON", NULL);
+        /* create bounds sections */
+        bounds_section = new_section(s, ".bounds", 
+                                     SHT_PROGBITS, SHF_ALLOC);
+        lbounds_section = new_section(s, ".lbounds", 
+                                      SHT_PROGBITS, SHF_ALLOC);
+    }
+#endif
+
+    if (s->char_is_unsigned) {
+        tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL);
+    }
+
+    /* add debug sections */
+    if (s->do_debug) {
+        /* stab symbols */
+        stab_section = new_section(s, ".stab", SHT_PROGBITS, 0);
+        stab_section->sh_entsize = sizeof(Stab_Sym);
+        stabstr_section = new_section(s, ".stabstr", SHT_STRTAB, 0);
+        put_elf_str(stabstr_section, "");
+        stab_section->link = stabstr_section;
+        /* put first entry */
+        put_stabs("", 0, 0, 0, 0);
+    }
+
+#ifdef TCC_TARGET_PE
+    tcc_add_library_path(s, CONFIG_TCC_LIBPATHS);
+# ifdef _WIN32
+    tcc_add_systemdir(s);
+# endif
+#else
+    /* add libc crt1/crti objects */
+    if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&
+        !s->nostdlib) {
+        if (output_type != TCC_OUTPUT_DLL)
+            tcc_add_crt(s, "crt1.o");
+        tcc_add_crt(s, "crti.o");
+    }
+#endif
+    return 0;
+}
+
+LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path)
+{
+    tcc_free(s->tcc_lib_path);
+    s->tcc_lib_path = tcc_strdup(path);
+}
+
+#define WD_ALL    0x0001 /* warning is activated when using -Wall */
+#define FD_INVERT 0x0002 /* invert value before storing */
+
+typedef struct FlagDef {
+    uint16_t offset;
+    uint16_t flags;
+    const char *name;
+} FlagDef;
+
+static const FlagDef warning_defs[] = {
+    { offsetof(TCCState, warn_unsupported), 0, "unsupported" },
+    { offsetof(TCCState, warn_write_strings), 0, "write-strings" },
+    { offsetof(TCCState, warn_error), 0, "error" },
+    { offsetof(TCCState, warn_implicit_function_declaration), WD_ALL,
+      "implicit-function-declaration" },
+};
+
+ST_FUNC int set_flag(TCCState *s, const FlagDef *flags, int nb_flags,
+                    const char *name, int value)
+{
+    int i;
+    const FlagDef *p;
+    const char *r;
+
+    r = name;
+    if (r[0] == 'n' && r[1] == 'o' && r[2] == '-') {
+        r += 3;
+        value = !value;
+    }
+    for(i = 0, p = flags; i < nb_flags; i++, p++) {
+        if (!strcmp(r, p->name))
+            goto found;
+    }
+    return -1;
+ found:
+    if (p->flags & FD_INVERT)
+        value = !value;
+    *(int *)((uint8_t *)s + p->offset) = value;
+    return 0;
+}
+
+/* set/reset a warning */
+static int tcc_set_warning(TCCState *s, const char *warning_name, int value)
+{
+    int i;
+    const FlagDef *p;
+
+    if (!strcmp(warning_name, "all")) {
+        for(i = 0, p = warning_defs; i < countof(warning_defs); i++, p++) {
+            if (p->flags & WD_ALL)
+                *(int *)((uint8_t *)s + p->offset) = 1;
+        }
+        return 0;
+    } else {
+        return set_flag(s, warning_defs, countof(warning_defs),
+                        warning_name, value);
+    }
+}
+
+static const FlagDef flag_defs[] = {
+    { offsetof(TCCState, char_is_unsigned), 0, "unsigned-char" },
+    { offsetof(TCCState, char_is_unsigned), FD_INVERT, "signed-char" },
+    { offsetof(TCCState, nocommon), FD_INVERT, "common" },
+    { offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
+};
+
+/* set/reset a flag */
+static int tcc_set_flag(TCCState *s, const char *flag_name, int value)
+{
+    return set_flag(s, flag_defs, countof(flag_defs),
+                    flag_name, value);
+}
+
+
+static int strstart(const char *val, const char **str)
+{
+    const char *p, *q;
+    p = *str;
+    q = val;
+    while (*q) {
+        if (*p != *q)
+            return 0;
+        p++;
+        q++;
+    }
+    *str = p;
+    return 1;
+}
+
+/* Like strstart, but automatically takes into account that ld options can
+ *
+ * - start with double or single dash (e.g. '--soname' or '-soname')
+ * - arguments can be given as separate or after '=' (e.g. '-Wl,-soname,x.so'
+ *   or '-Wl,-soname=x.so')
+ *
+ * you provide `val` always in 'option[=]' form (no leading -)
+ */
+static int link_option(const char *str, const char *val, const char **ptr)
+{
+    const char *p, *q;
+
+    /* there should be 1 or 2 dashes */
+    if (*str++ != '-')
+        return 0;
+    if (*str == '-')
+        str++;
+
+    /* then str & val should match (potentialy up to '=') */
+    p = str;
+    q = val;
+
+    while (*q != '\0' && *q != '=') {
+        if (*p != *q)
+            return 0;
+        p++;
+        q++;
+    }
+
+    /* '=' near eos means ',' or '=' is ok */
+    if (*q == '=') {
+        if (*p != ',' && *p != '=')
+            return 0;
+        p++;
+        q++;
+    }
+
+    if (ptr)
+        *ptr = p;
+    return 1;
+}
+
+static const char *skip_linker_arg(const char **str)
+{
+    const char *s1 = *str;
+    const char *s2 = strchr(s1, ',');
+    *str = s2 ? s2++ : (s2 = s1 + strlen(s1));
+    return s2;
+}
+
+static char *copy_linker_arg(const char *p)
+{
+    const char *q = p;
+    skip_linker_arg(&q);
+    return pstrncpy(tcc_malloc(q - p + 1), p, q - p);
+}
+
+/* set linker options */
+static int tcc_set_linker(TCCState *s, const char *option)
+{
+    while (option && *option) {
+
+        const char *p = option;
+        char *end = NULL;
+        int ignoring = 0;
+
+        if (link_option(option, "Bsymbolic", &p)) {
+            s->symbolic = 1;
+        } else if (link_option(option, "nostdlib", &p)) {
+            s->nostdlib = 1;
+        } else if (link_option(option, "fini=", &p)) {
+            s->fini_symbol = copy_linker_arg(p);
+            ignoring = 1;
+        } else if (link_option(option, "image-base=", &p)
+                || link_option(option, "Ttext=", &p)) {
+            s->text_addr = strtoull(p, &end, 16);
+            s->has_text_addr = 1;
+        } else if (link_option(option, "init=", &p)) {
+            s->init_symbol = copy_linker_arg(p);
+            ignoring = 1;
+        } else if (link_option(option, "oformat=", &p)) {
+#if defined(TCC_TARGET_PE)
+            if (strstart("pe-", &p)) {
+#elif defined(TCC_TARGET_X86_64)
+            if (strstart("elf64-", &p)) {
+#else
+            if (strstart("elf32-", &p)) {
+#endif
+                s->output_format = TCC_OUTPUT_FORMAT_ELF;
+            } else if (!strcmp(p, "binary")) {
+                s->output_format = TCC_OUTPUT_FORMAT_BINARY;
+#ifdef TCC_TARGET_COFF
+            } else if (!strcmp(p, "coff")) {
+                s->output_format = TCC_OUTPUT_FORMAT_COFF;
+#endif
+            } else
+                goto err;
+
+        } else if (link_option(option, "rpath=", &p)) {
+            s->rpath = copy_linker_arg(p);
+        } else if (link_option(option, "section-alignment=", &p)) {
+            s->section_align = strtoul(p, &end, 16);
+        } else if (link_option(option, "soname=", &p)) {
+            s->soname = copy_linker_arg(p);
+#ifdef TCC_TARGET_PE
+        } else if (link_option(option, "file-alignment=", &p)) {
+            s->pe_file_align = strtoul(p, &end, 16);
+        } else if (link_option(option, "stack=", &p)) {
+            s->pe_stack_size = strtoul(p, &end, 10);
+        } else if (link_option(option, "subsystem=", &p)) {
+#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
+            if (!strcmp(p, "native")) {
+                s->pe_subsystem = 1;
+            } else if (!strcmp(p, "console")) {
+                s->pe_subsystem = 3;
+            } else if (!strcmp(p, "gui")) {
+                s->pe_subsystem = 2;
+            } else if (!strcmp(p, "posix")) {
+                s->pe_subsystem = 7;
+            } else if (!strcmp(p, "efiapp")) {
+                s->pe_subsystem = 10;
+            } else if (!strcmp(p, "efiboot")) {
+                s->pe_subsystem = 11;
+            } else if (!strcmp(p, "efiruntime")) {
+                s->pe_subsystem = 12;
+            } else if (!strcmp(p, "efirom")) {
+                s->pe_subsystem = 13;
+#elif defined(TCC_TARGET_ARM)
+            if (!strcmp(p, "wince")) {
+                s->pe_subsystem = 9;
+#endif
+            } else
+                goto err;
+#endif
+        } else
+            goto err;
+
+        if (ignoring && s->warn_unsupported) err: {
+            char buf[100], *e;
+            pstrcpy(buf, sizeof buf, e = copy_linker_arg(option)), tcc_free(e);
+            if (ignoring)
+                tcc_warning("unsupported linker option '%s'", buf);
+            else
+                tcc_error("unsupported linker option '%s'", buf);
+        }
+        option = skip_linker_arg(&p);
+    }
+    return 0;
+}
+
+typedef struct TCCOption {
+    const char *name;
+    uint16_t index;
+    uint16_t flags;
+} TCCOption;
+
+enum {
+    TCC_OPTION_HELP,
+    TCC_OPTION_I,
+    TCC_OPTION_D,
+    TCC_OPTION_U,
+    TCC_OPTION_L,
+    TCC_OPTION_B,
+    TCC_OPTION_l,
+    TCC_OPTION_bench,
+    TCC_OPTION_bt,
+    TCC_OPTION_b,
+    TCC_OPTION_g,
+    TCC_OPTION_c,
+    TCC_OPTION_static,
+    TCC_OPTION_shared,
+    TCC_OPTION_soname,
+    TCC_OPTION_o,
+    TCC_OPTION_r,
+    TCC_OPTION_s,
+    TCC_OPTION_Wl,
+    TCC_OPTION_W,
+    TCC_OPTION_O,
+    TCC_OPTION_m,
+    TCC_OPTION_f,
+    TCC_OPTION_isystem,
+    TCC_OPTION_nostdinc,
+    TCC_OPTION_nostdlib,
+    TCC_OPTION_print_search_dirs,
+    TCC_OPTION_rdynamic,
+    TCC_OPTION_pedantic,
+    TCC_OPTION_pthread,
+    TCC_OPTION_run,
+    TCC_OPTION_v,
+    TCC_OPTION_w,
+    TCC_OPTION_pipe,
+    TCC_OPTION_E,
+    TCC_OPTION_MD,
+    TCC_OPTION_MF,
+    TCC_OPTION_x,
+    TCC_OPTION_dumpversion,
+};
+
+#define TCC_OPTION_HAS_ARG 0x0001
+#define TCC_OPTION_NOSEP   0x0002 /* cannot have space before option and arg */
+
+static const TCCOption tcc_options[] = {
+    { "h", TCC_OPTION_HELP, 0 },
+    { "-help", TCC_OPTION_HELP, 0 },
+    { "?", TCC_OPTION_HELP, 0 },
+    { "I", TCC_OPTION_I, TCC_OPTION_HAS_ARG },
+    { "D", TCC_OPTION_D, TCC_OPTION_HAS_ARG },
+    { "U", TCC_OPTION_U, TCC_OPTION_HAS_ARG },
+    { "L", TCC_OPTION_L, TCC_OPTION_HAS_ARG },
+    { "B", TCC_OPTION_B, TCC_OPTION_HAS_ARG },
+    { "l", TCC_OPTION_l, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "bench", TCC_OPTION_bench, 0 },
+#ifdef CONFIG_TCC_BACKTRACE
+    { "bt", TCC_OPTION_bt, TCC_OPTION_HAS_ARG },
+#endif
+#ifdef CONFIG_TCC_BCHECK
+    { "b", TCC_OPTION_b, 0 },
+#endif
+    { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "c", TCC_OPTION_c, 0 },
+    { "static", TCC_OPTION_static, 0 },
+    { "shared", TCC_OPTION_shared, 0 },
+    { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },
+    { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
+    { "pedantic", TCC_OPTION_pedantic, 0},
+    { "pthread", TCC_OPTION_pthread, 0},
+    { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "rdynamic", TCC_OPTION_rdynamic, 0 },
+    { "r", TCC_OPTION_r, 0 },
+    { "s", TCC_OPTION_s, 0 },
+    { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "O", TCC_OPTION_O, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "m", TCC_OPTION_m, TCC_OPTION_HAS_ARG },
+    { "f", TCC_OPTION_f, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "isystem", TCC_OPTION_isystem, TCC_OPTION_HAS_ARG },
+    { "nostdinc", TCC_OPTION_nostdinc, 0 },
+    { "nostdlib", TCC_OPTION_nostdlib, 0 },
+    { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, 
+    { "v", TCC_OPTION_v, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
+    { "w", TCC_OPTION_w, 0 },
+    { "pipe", TCC_OPTION_pipe, 0},
+    { "E", TCC_OPTION_E, 0},
+    { "MD", TCC_OPTION_MD, 0},
+    { "MF", TCC_OPTION_MF, TCC_OPTION_HAS_ARG },
+    { "x", TCC_OPTION_x, TCC_OPTION_HAS_ARG },
+    { "dumpversion", TCC_OPTION_dumpversion, 0},
+    { NULL, 0, 0 },
+};
+
+static void parse_option_D(TCCState *s1, const char *optarg)
+{
+    char *sym = tcc_strdup(optarg);
+    char *value = strchr(sym, '=');
+    if (value)
+        *value++ = '\0';
+    tcc_define_symbol(s1, sym, value);
+    tcc_free(sym);
+}
+
+PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
+{
+    const TCCOption *popt;
+    const char *optarg, *r;
+    int run = 0;
+    int pthread = 0;
+    int optind = 0;
+
+    /* collect -Wl options for input such as "-Wl,-rpath -Wl,<path>" */
+    CString linker_arg;
+    cstr_new(&linker_arg);
+
+    while (optind < argc) {
+
+        r = argv[optind++];
+        if (r[0] != '-' || r[1] == '\0') {
+            /* add a new file */
+            dynarray_add((void ***)&s->files, &s->nb_files, tcc_strdup(r));
+            if (run) {
+                optind--;
+                /* argv[0] will be this file */
+                break;
+            }
+            continue;
+        }
+
+        /* find option in table */
+        for(popt = tcc_options; ; ++popt) {
+            const char *p1 = popt->name;
+            const char *r1 = r + 1;
+            if (p1 == NULL)
+                tcc_error("invalid option -- '%s'", r);
+            if (!strstart(p1, &r1))
+                continue;
+            optarg = r1;
+            if (popt->flags & TCC_OPTION_HAS_ARG) {
+                if (*r1 == '\0' && !(popt->flags & TCC_OPTION_NOSEP)) {
+                    if (optind >= argc)
+                        tcc_error("argument to '%s' is missing", r);
+                    optarg = argv[optind++];
+                }
+            } else if (*r1 != '\0')
+                continue;
+            break;
+        }
+
+        switch(popt->index) {
+        case TCC_OPTION_HELP:
+            return 0;
+        case TCC_OPTION_I:
+            if (tcc_add_include_path(s, optarg) < 0)
+                tcc_error("too many include paths");
+            break;
+        case TCC_OPTION_D:
+            parse_option_D(s, optarg);
+            break;
+        case TCC_OPTION_U:
+            tcc_undefine_symbol(s, optarg);
+            break;
+        case TCC_OPTION_L:
+            tcc_add_library_path(s, optarg);
+            break;
+        case TCC_OPTION_B:
+            /* set tcc utilities path (mainly for tcc development) */
+            tcc_set_lib_path(s, optarg);
+            break;
+        case TCC_OPTION_l:
+            dynarray_add((void ***)&s->files, &s->nb_files, tcc_strdup(r));
+            s->nb_libraries++;
+            break;
+        case TCC_OPTION_pthread:
+            parse_option_D(s, "_REENTRANT");
+            pthread = 1;
+            break;
+        case TCC_OPTION_bench:
+            s->do_bench = 1;
+            break;
+#ifdef CONFIG_TCC_BACKTRACE
+        case TCC_OPTION_bt:
+            tcc_set_num_callers(atoi(optarg));
+            break;
+#endif
+#ifdef CONFIG_TCC_BCHECK
+        case TCC_OPTION_b:
+            s->do_bounds_check = 1;
+            s->do_debug = 1;
+            break;
+#endif
+        case TCC_OPTION_g:
+            s->do_debug = 1;
+            break;
+        case TCC_OPTION_c:
+            s->output_type = TCC_OUTPUT_OBJ;
+            break;
+        case TCC_OPTION_static:
+            s->static_link = 1;
+            break;
+        case TCC_OPTION_shared:
+            s->output_type = TCC_OUTPUT_DLL;
+            break;
+        case TCC_OPTION_soname:
+            s->soname = tcc_strdup(optarg);
+            break;
+        case TCC_OPTION_m:
+            s->option_m = tcc_strdup(optarg);
+            break;
+        case TCC_OPTION_o:
+            s->outfile = tcc_strdup(optarg);
+            break;
+        case TCC_OPTION_r:
+            /* generate a .o merging several output files */
+            s->option_r = 1;
+            s->output_type = TCC_OUTPUT_OBJ;
+            break;
+        case TCC_OPTION_isystem:
+            tcc_add_sysinclude_path(s, optarg);
+            break;
+        case TCC_OPTION_nostdinc:
+            s->nostdinc = 1;
+            break;
+        case TCC_OPTION_nostdlib:
+            s->nostdlib = 1;
+            break;
+        case TCC_OPTION_print_search_dirs:
+            s->print_search_dirs = 1;
+            break;
+        case TCC_OPTION_run:
+            s->output_type = TCC_OUTPUT_MEMORY;
+            tcc_set_options(s, optarg);
+            run = 1;
+            break;
+        case TCC_OPTION_v:
+            do ++s->verbose; while (*optarg++ == 'v');
+            break;
+        case TCC_OPTION_f:
+            if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported)
+                goto unsupported_option;
+            break;
+        case TCC_OPTION_W:
+            if (tcc_set_warning(s, optarg, 1) < 0 && 
+                s->warn_unsupported)
+                goto unsupported_option;
+            break;
+        case TCC_OPTION_w:
+            s->warn_none = 1;
+            break;
+        case TCC_OPTION_rdynamic:
+            s->rdynamic = 1;
+            break;
+        case TCC_OPTION_Wl:
+            if (linker_arg.size)
+                --linker_arg.size, cstr_ccat(&linker_arg, ',');
+            cstr_cat(&linker_arg, optarg);
+            cstr_ccat(&linker_arg, '\0');
+            break;
+        case TCC_OPTION_E:
+            s->output_type = TCC_OUTPUT_PREPROCESS;
+            break;
+        case TCC_OPTION_MD:
+            s->gen_deps = 1;
+            break;
+        case TCC_OPTION_MF:
+            s->deps_outfile = tcc_strdup(optarg);
+            break;
+        case TCC_OPTION_dumpversion:
+            printf ("%s\n", TCC_VERSION);
+            exit(0);
+        case TCC_OPTION_O:
+        case TCC_OPTION_pedantic:
+        case TCC_OPTION_pipe:
+        case TCC_OPTION_s:
+        case TCC_OPTION_x:
+            /* ignored */
+            break;
+        default:
+            if (s->warn_unsupported) {
+            unsupported_option:
+                tcc_warning("unsupported option '%s'", r);
+            }
+            break;
+        }
+    }
+
+    if (pthread && s->output_type != TCC_OUTPUT_OBJ)
+        tcc_set_options(s, "-lpthread");
+
+    tcc_set_linker(s, (const char *)linker_arg.data);
+    cstr_free(&linker_arg);
+
+    return optind;
+}
+
+LIBTCCAPI int tcc_set_options(TCCState *s, const char *str)
+{
+    const char *s1;
+    char **argv, *arg;
+    int argc, len;
+    int ret;
+
+    argc = 0, argv = NULL;
+    for(;;) {
+        while (is_space(*str))
+            str++;
+        if (*str == '\0')
+            break;
+        s1 = str;
+        while (*str != '\0' && !is_space(*str))
+            str++;
+        len = str - s1;
+        arg = tcc_malloc(len + 1);
+        pstrncpy(arg, s1, len);
+        dynarray_add((void ***)&argv, &argc, arg);
+    }
+    ret = tcc_parse_args(s, argc, argv);
+    dynarray_reset(&argv, &argc);
+    return ret;
+}
+
+PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time)
+{
+    double tt;
+    tt = (double)total_time / 1000000.0;
+    if (tt < 0.001)
+        tt = 0.001;
+    if (total_bytes < 1)
+        total_bytes = 1;
+    printf("%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n", 
+           tok_ident - TOK_IDENT, total_lines, total_bytes,
+           tt, (int)(total_lines / tt),
+           total_bytes / tt / 1000000.0);
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/libtcc.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/libtcc.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/libtcc.h	(revision 279)
@@ -0,0 +1,100 @@
+#ifndef LIBTCC_H
+#define LIBTCC_H
+
+#ifndef LIBTCCAPI
+# define LIBTCCAPI
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct TCCState;
+
+typedef struct TCCState TCCState;
+
+/* create a new TCC compilation context */
+LIBTCCAPI TCCState *tcc_new(void);
+
+/* free a TCC compilation context */
+LIBTCCAPI void tcc_delete(TCCState *s);
+
+/* set CONFIG_TCCDIR at runtime */
+LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
+
+/* set error/warning display callback */
+LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque,
+    void (*error_func)(void *opaque, const char *msg));
+
+/* set options as from command line (multiple supported) */
+LIBTCCAPI int tcc_set_options(TCCState *s, const char *str);
+
+/*****************************/
+/* preprocessor */
+
+/* add include path */
+LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
+
+/* add in system include path */
+LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
+
+/* define preprocessor symbol 'sym'. Can put optional value */
+LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
+
+/* undefine preprocess symbol 'sym' */
+LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym);
+
+/*****************************/
+/* compiling */
+
+/* add a file (C file, dll, object, library, ld script). Return -1 if error. */
+LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename);
+
+/* compile a string containing a C source. Return -1 if error. */
+LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf);
+
+/*****************************/
+/* linking commands */
+
+/* set output type. MUST BE CALLED before any compilation */
+LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
+#define TCC_OUTPUT_MEMORY   0 /* output will be run in memory (default) */
+#define TCC_OUTPUT_EXE      1 /* executable file */
+#define TCC_OUTPUT_DLL      2 /* dynamic library */
+#define TCC_OUTPUT_OBJ      3 /* object file */
+#define TCC_OUTPUT_PREPROCESS 4 /* only preprocess (used internally) */
+
+/* equivalent to -Lpath option */
+LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
+
+/* the library name is the same as the argument of the '-l' option */
+LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
+
+/* add a symbol to the compiled program */
+LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
+
+/* output an executable, library or object file. DO NOT call
+   tcc_relocate() before. */
+LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename);
+
+/* link and run main() function and return its value. DO NOT call
+   tcc_relocate() before. */
+LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv);
+
+/* do all relocations (needed before using tcc_get_symbol()) */
+LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr);
+/* possible values for 'ptr':
+   - TCC_RELOCATE_AUTO : Allocate and manage memory internally
+   - NULL              : return required memory size for the step below
+   - memory address    : copy code to memory passed by the caller
+   returns -1 if error. */
+#define TCC_RELOCATE_AUTO (void*)1
+
+/* return symbol value or NULL if not found */
+LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /EcnlProtoTool/trunk/tcc-0.9.26/stab.def
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/stab.def	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/stab.def	(revision 279)
@@ -0,0 +1,236 @@
+/* Table of DBX symbol codes for the GNU system.
+   Copyright (C) 1988, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This contains contribution from Cygnus Support.  */
+
+
+/* Global variable.  Only the name is significant.
+   To find the address, look in the corresponding external symbol.  */
+__define_stab (N_GSYM, 0x20, "GSYM")
+
+/* Function name for BSD Fortran.  Only the name is significant.
+   To find the address, look in the corresponding external symbol.  */
+__define_stab (N_FNAME, 0x22, "FNAME")
+
+/* Function name or text-segment variable for C.  Value is its address.
+   Desc is supposedly starting line number, but GCC doesn't set it
+   and DBX seems not to miss it.  */
+__define_stab (N_FUN, 0x24, "FUN")
+
+/* Data-segment variable with internal linkage.  Value is its address.
+   "Static Sym".  */
+__define_stab (N_STSYM, 0x26, "STSYM")
+
+/* BSS-segment variable with internal linkage.  Value is its address.  */
+__define_stab (N_LCSYM, 0x28, "LCSYM")
+
+/* Name of main routine.  Only the name is significant.
+   This is not used in C.  */
+__define_stab (N_MAIN, 0x2a, "MAIN")
+
+/* Global symbol in Pascal.
+   Supposedly the value is its line number; I'm skeptical.  */
+__define_stab (N_PC, 0x30, "PC")
+
+/* Number of symbols:  0, files,,funcs,lines according to Ultrix V4.0. */
+__define_stab (N_NSYMS, 0x32, "NSYMS")
+
+/* "No DST map for sym: name, ,0,type,ignored"  according to Ultrix V4.0. */
+__define_stab (N_NOMAP, 0x34, "NOMAP")
+
+/* New stab from Solaris.  I don't know what it means, but it
+   don't seem to contain useful information.  */
+__define_stab (N_OBJ, 0x38, "OBJ")
+
+/* New stab from Solaris.  I don't know what it means, but it
+   don't seem to contain useful information.  Possibly related to the
+   optimization flags used in this module.  */
+__define_stab (N_OPT, 0x3c, "OPT")
+
+/* Register variable.  Value is number of register.  */
+__define_stab (N_RSYM, 0x40, "RSYM")
+
+/* Modula-2 compilation unit.  Can someone say what info it contains?  */
+__define_stab (N_M2C, 0x42, "M2C")
+
+/* Line number in text segment.  Desc is the line number;
+   value is corresponding address.  */
+__define_stab (N_SLINE, 0x44, "SLINE")
+
+/* Similar, for data segment.  */
+__define_stab (N_DSLINE, 0x46, "DSLINE")
+
+/* Similar, for bss segment.  */
+__define_stab (N_BSLINE, 0x48, "BSLINE")
+
+/* Sun's source-code browser stabs.  ?? Don't know what the fields are.
+   Supposedly the field is "path to associated .cb file".  THIS VALUE
+   OVERLAPS WITH N_BSLINE!  */
+__define_stab (N_BROWS, 0x48, "BROWS")
+
+/* GNU Modula-2 definition module dependency.  Value is the modification time
+   of the definition file.  Other is non-zero if it is imported with the
+   GNU M2 keyword %INITIALIZE.  Perhaps N_M2C can be used if there
+   are enough empty fields? */
+__define_stab(N_DEFD, 0x4a, "DEFD")
+
+/* THE FOLLOWING TWO STAB VALUES CONFLICT.  Happily, one is for Modula-2
+   and one is for C++.   Still,... */
+/* GNU C++ exception variable.  Name is variable name.  */
+__define_stab (N_EHDECL, 0x50, "EHDECL")
+/* Modula2 info "for imc":  name,,0,0,0  according to Ultrix V4.0.  */
+__define_stab (N_MOD2, 0x50, "MOD2")
+
+/* GNU C++ `catch' clause.  Value is its address.  Desc is nonzero if
+   this entry is immediately followed by a CAUGHT stab saying what exception
+   was caught.  Multiple CAUGHT stabs means that multiple exceptions
+   can be caught here.  If Desc is 0, it means all exceptions are caught
+   here.  */
+__define_stab (N_CATCH, 0x54, "CATCH")
+
+/* Structure or union element.  Value is offset in the structure.  */
+__define_stab (N_SSYM, 0x60, "SSYM")
+
+/* Name of main source file.
+   Value is starting text address of the compilation.  */
+__define_stab (N_SO, 0x64, "SO")
+
+/* Automatic variable in the stack.  Value is offset from frame pointer.
+   Also used for type descriptions.  */
+__define_stab (N_LSYM, 0x80, "LSYM")
+
+/* Beginning of an include file.  Only Sun uses this.
+   In an object file, only the name is significant.
+   The Sun linker puts data into some of the other fields.  */
+__define_stab (N_BINCL, 0x82, "BINCL")
+
+/* Name of sub-source file (#include file).
+   Value is starting text address of the compilation.  */
+__define_stab (N_SOL, 0x84, "SOL")
+
+/* Parameter variable.  Value is offset from argument pointer.
+   (On most machines the argument pointer is the same as the frame pointer.  */
+__define_stab (N_PSYM, 0xa0, "PSYM")
+
+/* End of an include file.  No name.
+   This and N_BINCL act as brackets around the file's output.
+   In an object file, there is no significant data in this entry.
+   The Sun linker puts data into some of the fields.  */
+__define_stab (N_EINCL, 0xa2, "EINCL")
+
+/* Alternate entry point.  Value is its address.  */
+__define_stab (N_ENTRY, 0xa4, "ENTRY")
+
+/* Beginning of lexical block.
+   The desc is the nesting level in lexical blocks.
+   The value is the address of the start of the text for the block.
+   The variables declared inside the block *precede* the N_LBRAC symbol.  */
+__define_stab (N_LBRAC, 0xc0, "LBRAC")
+
+/* Place holder for deleted include file.  Replaces a N_BINCL and everything
+   up to the corresponding N_EINCL.  The Sun linker generates these when
+   it finds multiple identical copies of the symbols from an include file.
+   This appears only in output from the Sun linker.  */
+__define_stab (N_EXCL, 0xc2, "EXCL")
+
+/* Modula-2 scope information.  Can someone say what info it contains?  */
+__define_stab (N_SCOPE, 0xc4, "SCOPE")
+
+/* End of a lexical block.  Desc matches the N_LBRAC's desc.
+   The value is the address of the end of the text for the block.  */
+__define_stab (N_RBRAC, 0xe0, "RBRAC")
+
+/* Begin named common block.  Only the name is significant.  */
+__define_stab (N_BCOMM, 0xe2, "BCOMM")
+
+/* End named common block.  Only the name is significant
+   (and it should match the N_BCOMM).  */
+__define_stab (N_ECOMM, 0xe4, "ECOMM")
+
+/* End common (local name): value is address.
+   I'm not sure how this is used.  */
+__define_stab (N_ECOML, 0xe8, "ECOML")
+
+/* These STAB's are used on Gould systems for Non-Base register symbols
+   or something like that.  FIXME.  I have assigned the values at random
+   since I don't have a Gould here.  Fixups from Gould folk welcome... */
+__define_stab (N_NBTEXT, 0xF0, "NBTEXT")
+__define_stab (N_NBDATA, 0xF2, "NBDATA")
+__define_stab (N_NBBSS,  0xF4, "NBBSS")
+__define_stab (N_NBSTS,  0xF6, "NBSTS")
+__define_stab (N_NBLCS,  0xF8, "NBLCS")
+
+/* Second symbol entry containing a length-value for the preceding entry.
+   The value is the length.  */
+__define_stab (N_LENG, 0xfe, "LENG")
+
+
+/* The above information, in matrix format.
+
+			STAB MATRIX
+	_________________________________________________
+	| 00 - 1F are not dbx stab symbols		|
+	| In most cases, the low bit is the EXTernal bit|
+
+	| 00 UNDEF  | 02 ABS	| 04 TEXT   | 06 DATA	|
+	| 01  |EXT  | 03  |EXT	| 05  |EXT  | 07  |EXT	|
+
+	| 08 BSS    | 0A INDR	| 0C FN_SEQ | 0E   	|
+	| 09  |EXT  | 0B 	| 0D	    | 0F	|
+
+	| 10 	    | 12 COMM	| 14 SETA   | 16 SETT	|
+	| 11	    | 13	| 15 	    | 17	|
+
+	| 18 SETD   | 1A SETB	| 1C SETV   | 1E WARNING|
+	| 19	    | 1B	| 1D 	    | 1F FN	|
+
+	|_______________________________________________|
+	| Debug entries with bit 01 set are unused.	|
+	| 20 GSYM   | 22 FNAME	| 24 FUN    | 26 STSYM	|
+	| 28 LCSYM  | 2A MAIN	| 2C	    | 2E	|
+	| 30 PC	    | 32 NSYMS	| 34 NOMAP  | 36	|
+	| 38 OBJ    | 3A	| 3C OPT    | 3E	|
+	| 40 RSYM   | 42 M2C	| 44 SLINE  | 46 DSLINE |
+	| 48 BSLINE*| 4A DEFD	| 4C        | 4E	|
+	| 50 EHDECL*| 52	| 54 CATCH  | 56        |
+	| 58        | 5A        | 5C        | 5E	|
+	| 60 SSYM   | 62	| 64 SO	    | 66 	|
+	| 68 	    | 6A	| 6C	    | 6E	|
+	| 70	    | 72	| 74	    | 76	|
+	| 78	    | 7A	| 7C	    | 7E	|
+	| 80 LSYM   | 82 BINCL	| 84 SOL    | 86	|
+	| 88	    | 8A	| 8C	    | 8E	|
+	| 90	    | 92	| 94	    | 96	|
+	| 98	    | 9A	| 9C	    | 9E	|
+	| A0 PSYM   | A2 EINCL	| A4 ENTRY  | A6	|
+	| A8	    | AA	| AC	    | AE	|
+	| B0	    | B2	| B4	    | B6	|
+	| B8	    | BA	| BC	    | BE	|
+	| C0 LBRAC  | C2 EXCL	| C4 SCOPE  | C6	|
+	| C8	    | CA	| CC	    | CE	|
+	| D0	    | D2	| D4	    | D6	|
+	| D8	    | DA	| DC	    | DE	|
+	| E0 RBRAC  | E2 BCOMM	| E4 ECOMM  | E6	|
+	| E8 ECOML  | EA	| EC	    | EE	|
+	| F0	    | F2	| F4	    | F6	|
+	| F8	    | FA	| FC	    | FE LENG	|
+	+-----------------------------------------------+
+ * 50 EHDECL is also MOD2.
+ * 48 BSLINE is also BROWS.
+ */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/stab.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/stab.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/stab.h	(revision 279)
@@ -0,0 +1,17 @@
+#ifndef __GNU_STAB__
+
+/* Indicate the GNU stab.h is in use.  */
+
+#define __GNU_STAB__
+
+#define __define_stab(NAME, CODE, STRING) NAME=CODE,
+
+enum __stab_debug_code
+{
+#include "stab.def"
+LAST_UNUSED_STAB_CODE
+};
+
+#undef __define_stab
+
+#endif /* __GNU_STAB_ */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tcc-doc.html
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tcc-doc.html	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tcc-doc.html	(revision 279)
@@ -0,0 +1,2332 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
+<html>
+<!-- Created on February 15, 2013 by texi2html 1.82
+texi2html was written by: 
+            Lionel Cons <Lionel.Cons@cern.ch> (original author)
+            Karl Berry  <karl@freefriends.org>
+            Olaf Bachmann <obachman@mathematik.uni-kl.de>
+            and many others.
+Maintained by: Many creative people.
+Send bugs and suggestions to <texi2html-bug@nongnu.org>
+-->
+<head>
+<title>Tiny C Compiler Reference Documentation</title>
+
+<meta name="description" content="Tiny C Compiler Reference Documentation">
+<meta name="keywords" content="Tiny C Compiler Reference Documentation">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2html 1.82">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<style type="text/css">
+<!--
+a.summary-letter {text-decoration: none}
+blockquote.smallquotation {font-size: smaller}
+pre.display {font-family: serif}
+pre.format {font-family: serif}
+pre.menu-comment {font-family: serif}
+pre.menu-preformatted {font-family: serif}
+pre.smalldisplay {font-family: serif; font-size: smaller}
+pre.smallexample {font-size: smaller}
+pre.smallformat {font-family: serif; font-size: smaller}
+pre.smalllisp {font-size: smaller}
+span.roman {font-family:serif; font-weight:normal;}
+span.sansserif {font-family:sans-serif; font-weight:normal;}
+ul.toc {list-style: none}
+-->
+</style>
+
+
+</head>
+
+<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+
+<a name="Top"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="Tiny-C-Compiler-Reference-Documentation"></a>
+<h1 class="settitle">Tiny C Compiler Reference Documentation</h1>
+
+<p>This manual documents version 0.9.26 of the Tiny C Compiler.
+</p>
+<table class="menu" border="0" cellspacing="0">
+<tr><td align="left" valign="top"><a href="#Introduction">1. Introduction</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                Introduction to tcc.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#Invoke">2. Command line invocation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      Invocation of tcc (command line, options).
+</td></tr>
+<tr><td align="left" valign="top"><a href="#Clang">3. C language support</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       ANSI C and extensions.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#asm">4. TinyCC Assembler</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                         Assembler syntax.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#linker">5. TinyCC Linker</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      Output file generation and supported targets.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#Bounds">6. TinyCC Memory and Bound checks</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      Automatic bounds-checking of C code.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#Libtcc">7. The <code>libtcc</code> library</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                      The libtcc library.
+</td></tr>
+<tr><td align="left" valign="top"><a href="#devel">8. Developer&rsquo;s guide</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                       Guide for Developers.
+</td></tr>
+</table>
+
+
+<hr size="1">
+<a name="Introduction"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Top" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Invoke" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Invoke" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="Introduction-1"></a>
+<h1 class="chapter">1. Introduction</h1>
+
+<p>TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
+compilers, it is meant to be self-relying: you do not need an
+external assembler or linker because TCC does that for you.
+</p>
+<p>TCC compiles so <em>fast</em> that even for big projects <code>Makefile</code>s may
+not be necessary.
+</p>
+<p>TCC not only supports ANSI C, but also most of the new ISO C99
+standard and many GNUC extensions including inline assembly.
+</p>
+<p>TCC can also be used to make <em>C scripts</em>, i.e. pieces of C source
+that you run as a Perl or Python script. Compilation is so fast that
+your script will be as fast as if it was an executable.
+</p>
+<p>TCC can also automatically generate memory and bound checks
+(see section <a href="#Bounds">TinyCC Memory and Bound checks</a>) while allowing all C pointers operations. TCC can do
+these checks even if non patched libraries are used.
+</p>
+<p>With <code>libtcc</code>, you can use TCC as a backend for dynamic code
+generation (see section <a href="#Libtcc">The <code>libtcc</code> library</a>).
+</p>
+<p>TCC mainly supports the i386 target on Linux and Windows. There are alpha
+ports for the ARM (<code>arm-tcc</code>) and the TMS320C67xx targets
+(<code>c67-tcc</code>). More information about the ARM port is available at
+<a href="http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html">http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html</a>.
+</p>
+<p>For usage on Windows, see also <a href="tcc-win32.txt">tcc-win32.txt</a>.
+</p>
+<hr size="6">
+<a name="Invoke"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Introduction" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Quick-start" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Introduction" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="Command-line-invocation"></a>
+<h1 class="chapter">2. Command line invocation</h1>
+
+<hr size="6">
+<a name="Quick-start"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Invoke" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Option-summary" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Invoke" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Invoke" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">2.1 Quick start</h2>
+
+<table><tr><td>&nbsp;</td><td><pre class="example">usage: tcc [options] [<var>infile1</var> <var>infile2</var>&hellip;] [&lsquo;<samp>-run</samp>&rsquo; <var>infile</var> <var>args</var>&hellip;]
+</pre></td></tr></table>
+
+<p>TCC options are a very much like gcc options. The main difference is that TCC
+can also execute directly the resulting program and give it runtime
+arguments.
+</p>
+<p>Here are some examples to understand the logic:
+</p>
+<dl compact="compact">
+<dt> <code>&lsquo;<samp>tcc -run a.c</samp>&rsquo;</code></dt>
+<dd><p>Compile &lsquo;<tt>a.c</tt>&rsquo; and execute it directly
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc -run a.c arg1</samp>&rsquo;</code></dt>
+<dd><p>Compile a.c and execute it directly. arg1 is given as first argument to
+the <code>main()</code> of a.c.
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc a.c -run b.c arg1</samp>&rsquo;</code></dt>
+<dd><p>Compile &lsquo;<tt>a.c</tt>&rsquo; and &lsquo;<tt>b.c</tt>&rsquo;, link them together and execute them. arg1 is given
+as first argument to the <code>main()</code> of the resulting program. 
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc -o myprog a.c b.c</samp>&rsquo;</code></dt>
+<dd><p>Compile &lsquo;<tt>a.c</tt>&rsquo; and &lsquo;<tt>b.c</tt>&rsquo;, link them and generate the executable &lsquo;<tt>myprog</tt>&rsquo;.
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc -o myprog a.o b.o</samp>&rsquo;</code></dt>
+<dd><p>link &lsquo;<tt>a.o</tt>&rsquo; and &lsquo;<tt>b.o</tt>&rsquo; together and generate the executable &lsquo;<tt>myprog</tt>&rsquo;.
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc -c a.c</samp>&rsquo;</code></dt>
+<dd><p>Compile &lsquo;<tt>a.c</tt>&rsquo; and generate object file &lsquo;<tt>a.o</tt>&rsquo;.
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc -c asmfile.S</samp>&rsquo;</code></dt>
+<dd><p>Preprocess with C preprocess and assemble &lsquo;<tt>asmfile.S</tt>&rsquo; and generate
+object file &lsquo;<tt>asmfile.o</tt>&rsquo;.
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc -c asmfile.s</samp>&rsquo;</code></dt>
+<dd><p>Assemble (but not preprocess) &lsquo;<tt>asmfile.s</tt>&rsquo; and generate object file
+&lsquo;<tt>asmfile.o</tt>&rsquo;.
+</p>
+</dd>
+<dt> <code>&lsquo;<samp>tcc -r -o ab.o a.c b.c</samp>&rsquo;</code></dt>
+<dd><p>Compile &lsquo;<tt>a.c</tt>&rsquo; and &lsquo;<tt>b.c</tt>&rsquo;, link them together and generate the object file &lsquo;<tt>ab.o</tt>&rsquo;.
+</p>
+</dd>
+</dl>
+
+<p>Scripting:
+</p>
+<p>TCC can be invoked from <em>scripts</em>, just as shell scripts. You just
+need to add <code>#!/usr/local/bin/tcc -run</code> at the start of your C source:
+</p>
+<table><tr><td>&nbsp;</td><td><pre class="example">#!/usr/local/bin/tcc -run
+#include &lt;stdio.h&gt;
+
+int main() 
+{
+    printf(&quot;Hello World\n&quot;);
+    return 0;
+}
+</pre></td></tr></table>
+
+<p>TCC can read C source code from <em>standard input</em> when &lsquo;<samp>-</samp>&rsquo; is used in 
+place of &lsquo;<samp>infile</samp>&rsquo;. Example:
+</p>
+<table><tr><td>&nbsp;</td><td><pre class="example">echo 'main(){puts(&quot;hello&quot;);}' | tcc -run -
+</pre></td></tr></table>
+
+<hr size="6">
+<a name="Option-summary"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Quick-start" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Invoke" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Invoke" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">2.2 Option summary</h2>
+
+<p>General Options:
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-c</samp>&rsquo;</dt>
+<dd><p>Generate an object file.
+</p>
+</dd>
+<dt> &lsquo;<samp>-o outfile</samp>&rsquo;</dt>
+<dd><p>Put object file, executable, or dll into output file &lsquo;<tt>outfile</tt>&rsquo;.
+</p>
+</dd>
+<dt> &lsquo;<samp>-run source [args...]</samp>&rsquo;</dt>
+<dd><p>Compile file <var>source</var> and run it with the command line arguments
+<var>args</var>. In order to be able to give more than one argument to a
+script, several TCC options can be given <em>after</em> the
+&lsquo;<samp>-run</samp>&rsquo; option, separated by spaces:
+</p><table><tr><td>&nbsp;</td><td><pre class="example">tcc &quot;-run -L/usr/X11R6/lib -lX11&quot; ex4.c
+</pre></td></tr></table>
+<p>In a script, it gives the following header:
+</p><table><tr><td>&nbsp;</td><td><pre class="example">#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
+</pre></td></tr></table>
+
+</dd>
+<dt> &lsquo;<samp>-dumpversion</samp>&rsquo;</dt>
+<dd><p>Print only the compiler version and nothing else.
+</p>
+</dd>
+<dt> &lsquo;<samp>-v</samp>&rsquo;</dt>
+<dd><p>Display TCC version.
+</p>
+</dd>
+<dt> &lsquo;<samp>-vv</samp>&rsquo;</dt>
+<dd><p>Show included files.  As sole argument, print search dirs (as below).
+</p>
+</dd>
+<dt> &lsquo;<samp>-bench</samp>&rsquo;</dt>
+<dd><p>Display compilation statistics.
+</p>
+</dd>
+<dt> &lsquo;<samp>-print-search-dirs</samp>&rsquo;</dt>
+<dd><p>Print the configured installation directory and a list of library
+and include directories tcc will search.
+</p>
+</dd>
+</dl>
+
+<p>Preprocessor options:
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-Idir</samp>&rsquo;</dt>
+<dd><p>Specify an additional include path. Include paths are searched in the
+order they are specified.
+</p>
+<p>System include paths are always searched after. The default system
+include paths are: &lsquo;<tt>/usr/local/include</tt>&rsquo;, &lsquo;<tt>/usr/include</tt>&rsquo;
+and &lsquo;<tt>PREFIX/lib/tcc/include</tt>&rsquo;. (&lsquo;<tt>PREFIX</tt>&rsquo; is usually
+&lsquo;<tt>/usr</tt>&rsquo; or &lsquo;<tt>/usr/local</tt>&rsquo;).
+</p>
+</dd>
+<dt> &lsquo;<samp>-Dsym[=val]</samp>&rsquo;</dt>
+<dd><p>Define preprocessor symbol &lsquo;<samp>sym</samp>&rsquo; to
+val. If val is not present, its value is &lsquo;<samp>1</samp>&rsquo;. Function-like macros can
+also be defined: &lsquo;<samp>-DF(a)=a+1</samp>&rsquo;
+</p>
+</dd>
+<dt> &lsquo;<samp>-Usym</samp>&rsquo;</dt>
+<dd><p>Undefine preprocessor symbol &lsquo;<samp>sym</samp>&rsquo;.
+</p></dd>
+</dl>
+
+<p>Compilation flags:
+</p>
+<p>Note: each of the following warning options has a negative form beginning with
+&lsquo;<samp>-fno-</samp>&rsquo;.
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-funsigned-char</samp>&rsquo;</dt>
+<dd><p>Let the <code>char</code> type be unsigned.
+</p>
+</dd>
+<dt> &lsquo;<samp>-fsigned-char</samp>&rsquo;</dt>
+<dd><p>Let the <code>char</code> type be signed.
+</p>
+</dd>
+<dt> &lsquo;<samp>-fno-common</samp>&rsquo;</dt>
+<dd><p>Do not generate common symbols for uninitialized data.
+</p>
+</dd>
+<dt> &lsquo;<samp>-fleading-underscore</samp>&rsquo;</dt>
+<dd><p>Add a leading underscore at the beginning of each C symbol.
+</p>
+</dd>
+</dl>
+
+<p>Warning options:
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-w</samp>&rsquo;</dt>
+<dd><p>Disable all warnings.
+</p>
+</dd>
+</dl>
+
+<p>Note: each of the following warning options has a negative form beginning with
+&lsquo;<samp>-Wno-</samp>&rsquo;.
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-Wimplicit-function-declaration</samp>&rsquo;</dt>
+<dd><p>Warn about implicit function declaration.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Wunsupported</samp>&rsquo;</dt>
+<dd><p>Warn about unsupported GCC features that are ignored by TCC.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Wwrite-strings</samp>&rsquo;</dt>
+<dd><p>Make string constants be of type <code>const char *</code> instead of <code>char
+*</code>.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Werror</samp>&rsquo;</dt>
+<dd><p>Abort compilation if warnings are issued.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Wall</samp>&rsquo; </dt>
+<dd><p>Activate all warnings, except &lsquo;<samp>-Werror</samp>&rsquo;, &lsquo;<samp>-Wunusupported</samp>&rsquo; and
+&lsquo;<samp>-Wwrite-strings</samp>&rsquo;.
+</p>
+</dd>
+</dl>
+
+<p>Linker options:
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-Ldir</samp>&rsquo;</dt>
+<dd><p>Specify an additional static library path for the &lsquo;<samp>-l</samp>&rsquo; option. The
+default library paths are &lsquo;<tt>/usr/local/lib</tt>&rsquo;, &lsquo;<tt>/usr/lib</tt>&rsquo; and &lsquo;<tt>/lib</tt>&rsquo;.
+</p>
+</dd>
+<dt> &lsquo;<samp>-lxxx</samp>&rsquo;</dt>
+<dd><p>Link your program with dynamic library libxxx.so or static library
+libxxx.a. The library is searched in the paths specified by the
+&lsquo;<samp>-L</samp>&rsquo; option.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Bdir</samp>&rsquo;</dt>
+<dd><p>Set the path where the tcc internal libraries (and include files) can be
+found (default is &lsquo;<tt>PREFIX/lib/tcc</tt>&rsquo;).
+</p>
+</dd>
+<dt> &lsquo;<samp>-shared</samp>&rsquo;</dt>
+<dd><p>Generate a shared library instead of an executable.
+</p>
+</dd>
+<dt> &lsquo;<samp>-soname name</samp>&rsquo;</dt>
+<dd><p>set name for shared library to be used at runtime
+</p>
+</dd>
+<dt> &lsquo;<samp>-static</samp>&rsquo;</dt>
+<dd><p>Generate a statically linked executable (default is a shared linked
+executable).
+</p>
+</dd>
+<dt> &lsquo;<samp>-rdynamic</samp>&rsquo;</dt>
+<dd><p>Export global symbols to the dynamic linker. It is useful when a library
+opened with <code>dlopen()</code> needs to access executable symbols.
+</p>
+</dd>
+<dt> &lsquo;<samp>-r</samp>&rsquo;</dt>
+<dd><p>Generate an object file combining all input files.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Wl,-rpath=path</samp>&rsquo;</dt>
+<dd><p>Put custom seatch path for dynamic libraries into executable.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Wl,--oformat=fmt</samp>&rsquo;</dt>
+<dd><p>Use <var>fmt</var> as output format. The supported output formats are:
+</p><dl compact="compact">
+<dt> <code>elf32-i386</code></dt>
+<dd><p>ELF output format (default)
+</p></dd>
+<dt> <code>binary</code></dt>
+<dd><p>Binary image (only for executable output)
+</p></dd>
+<dt> <code>coff</code></dt>
+<dd><p>COFF output format (only for executable output for TMS320C67xx target)
+</p></dd>
+</dl>
+
+</dd>
+<dt> &lsquo;<samp>-Wl,-subsystem=console/gui/wince/...</samp>&rsquo;</dt>
+<dd><p>Set type for PE (Windows) executables.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]</samp>&rsquo;</dt>
+<dd><p>Modify executable layout.
+</p>
+</dd>
+<dt> &lsquo;<samp>-Wl,-Bsymbolic</samp>&rsquo;</dt>
+<dd><p>Set DT_SYMBOLIC tag.
+</p>
+</dd>
+</dl>
+
+<p>Debugger options:
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-g</samp>&rsquo;</dt>
+<dd><p>Generate run time debug information so that you get clear run time
+error messages: <code> test.c:68: in function 'test5()': dereferencing
+invalid pointer</code> instead of the laconic <code>Segmentation
+fault</code>.
+</p>
+</dd>
+<dt> &lsquo;<samp>-b</samp>&rsquo;</dt>
+<dd><p>Generate additional support code to check
+memory allocations and array/pointer bounds. &lsquo;<samp>-g</samp>&rsquo; is implied. Note
+that the generated code is slower and bigger in this case.
+</p>
+<p>Note: &lsquo;<samp>-b</samp>&rsquo; is only available on i386 for the moment.
+</p>
+</dd>
+<dt> &lsquo;<samp>-bt N</samp>&rsquo;</dt>
+<dd><p>Display N callers in stack traces. This is useful with &lsquo;<samp>-g</samp>&rsquo; or
+&lsquo;<samp>-b</samp>&rsquo;.
+</p>
+</dd>
+</dl>
+
+<p>Misc options:
+</p>
+<dl compact="compact">
+<dt> &lsquo;<samp>-MD</samp>&rsquo;</dt>
+<dd><p>Generate makefile fragment with dependencies.
+</p>
+</dd>
+<dt> &lsquo;<samp>-MF depfile</samp>&rsquo;</dt>
+<dd><p>Use &lsquo;<tt>depfile</tt>&rsquo; as output for -MD.
+</p>
+</dd>
+</dl>
+
+<p>Note: GCC options &lsquo;<samp>-Ox</samp>&rsquo;, &lsquo;<samp>-fx</samp>&rsquo; and &lsquo;<samp>-mx</samp>&rsquo; are
+ignored.
+</p>
+
+<hr size="6">
+<a name="Clang"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Option-summary" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#ANSI-C" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Invoke" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="C-language-support"></a>
+<h1 class="chapter">3. C language support</h1>
+
+<hr size="6">
+<a name="ANSI-C"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Clang" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#ISOC99-extensions" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">3.1 ANSI C</h2>
+
+<p>TCC implements all the ANSI C standard, including structure bit fields
+and floating point numbers (<code>long double</code>, <code>double</code>, and
+<code>float</code> fully supported).
+</p>
+<hr size="6">
+<a name="ISOC99-extensions"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#ANSI-C" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#GNU-C-extensions" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">3.2 ISOC99 extensions</h2>
+
+<p>TCC implements many features of the new C standard: ISO C99. Currently
+missing items are: complex and imaginary numbers and variable length
+arrays.
+</p>
+<p>Currently implemented ISOC99 features:
+</p>
+<ul>
+<li> 64 bit <code>long long</code> types are fully supported.
+
+</li><li> The boolean type <code>_Bool</code> is supported.
+
+</li><li> <code>__func__</code> is a string variable containing the current
+function name.
+
+</li><li> Variadic macros: <code>__VA_ARGS__</code> can be used for
+   function-like macros:
+<table><tr><td>&nbsp;</td><td><pre class="example">    #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)
+</pre></td></tr></table>
+
+<p><code>dprintf</code> can then be used with a variable number of parameters.
+</p>
+</li><li> Declarations can appear anywhere in a block (as in C++).
+
+</li><li> Array and struct/union elements can be initialized in any order by
+  using designators:
+<table><tr><td>&nbsp;</td><td><pre class="example">    struct { int x, y; } st[10] = { [0].x = 1, [0].y = 2 };
+
+    int tab[10] = { 1, 2, [5] = 5, [9] = 9};
+</pre></td></tr></table>
+    
+</li><li> Compound initializers are supported:
+<table><tr><td>&nbsp;</td><td><pre class="example">    int *p = (int []){ 1, 2, 3 };
+</pre></td></tr></table>
+<p>to initialize a pointer pointing to an initialized array. The same
+works for structures and strings.
+</p>
+</li><li> Hexadecimal floating point constants are supported:
+<table><tr><td>&nbsp;</td><td><pre class="example">          double d = 0x1234p10;
+</pre></td></tr></table>
+
+<p>is the same as writing 
+</p><table><tr><td>&nbsp;</td><td><pre class="example">          double d = 4771840.0;
+</pre></td></tr></table>
+
+</li><li> <code>inline</code> keyword is ignored.
+
+</li><li> <code>restrict</code> keyword is ignored.
+</li></ul>
+
+<hr size="6">
+<a name="GNU-C-extensions"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#ISOC99-extensions" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#TinyCC-extensions" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">3.3 GNU C extensions</h2>
+
+<p>TCC implements some GNU C extensions:
+</p>
+<ul>
+<li> array designators can be used without &rsquo;=&rsquo;: 
+<table><tr><td>&nbsp;</td><td><pre class="example">    int a[10] = { [0] 1, [5] 2, 3, 4 };
+</pre></td></tr></table>
+
+</li><li> Structure field designators can be a label: 
+<table><tr><td>&nbsp;</td><td><pre class="example">    struct { int x, y; } st = { x: 1, y: 1};
+</pre></td></tr></table>
+<p>instead of
+</p><table><tr><td>&nbsp;</td><td><pre class="example">    struct { int x, y; } st = { .x = 1, .y = 1};
+</pre></td></tr></table>
+
+</li><li> <code>\e</code> is ASCII character 27.
+
+</li><li> case ranges : ranges can be used in <code>case</code>s:
+<table><tr><td>&nbsp;</td><td><pre class="example">    switch(a) {
+    case 1 &hellip; 9:
+          printf(&quot;range 1 to 9\n&quot;);
+          break;
+    default:
+          printf(&quot;unexpected\n&quot;);
+          break;
+    }
+</pre></td></tr></table>
+
+<a name="index-aligned-attribute"></a>
+<a name="index-packed-attribute"></a>
+<a name="index-section-attribute"></a>
+<a name="index-unused-attribute"></a>
+<a name="index-cdecl-attribute"></a>
+<a name="index-stdcall-attribute"></a>
+<a name="index-regparm-attribute"></a>
+<a name="index-dllexport-attribute"></a>
+
+</li><li> The keyword <code>__attribute__</code> is handled to specify variable or
+function attributes. The following attributes are supported:
+  <ul>
+<li> <code>aligned(n)</code>: align a variable or a structure field to n bytes
+(must be a power of two).
+
+  </li><li> <code>packed</code>: force alignment of a variable or a structure field to
+  1.
+
+  </li><li> <code>section(name)</code>: generate function or data in assembly section
+name (name is a string containing the section name) instead of the default
+section.
+
+  </li><li> <code>unused</code>: specify that the variable or the function is unused.
+
+  </li><li> <code>cdecl</code>: use standard C calling convention (default).
+
+  </li><li> <code>stdcall</code>: use Pascal-like calling convention.
+
+  </li><li> <code>regparm(n)</code>: use fast i386 calling convention. <var>n</var> must be
+between 1 and 3. The first <var>n</var> function parameters are respectively put in
+registers <code>%eax</code>, <code>%edx</code> and <code>%ecx</code>.
+
+  </li><li> <code>dllexport</code>: export function from dll/executable (win32 only)
+
+</li></ul>
+
+<p>Here are some examples:
+</p><table><tr><td>&nbsp;</td><td><pre class="example">    int a __attribute__ ((aligned(8), section(&quot;.mysection&quot;)));
+</pre></td></tr></table>
+
+<p>align variable <code>a</code> to 8 bytes and put it in section <code>.mysection</code>.
+</p>
+<table><tr><td>&nbsp;</td><td><pre class="example">    int my_add(int a, int b) __attribute__ ((section(&quot;.mycodesection&quot;))) 
+    {
+        return a + b;
+    }
+</pre></td></tr></table>
+
+<p>generate function <code>my_add</code> in section <code>.mycodesection</code>.
+</p>
+</li><li> GNU style variadic macros:
+<table><tr><td>&nbsp;</td><td><pre class="example">    #define dprintf(fmt, args&hellip;) printf(fmt, ## args)
+
+    dprintf(&quot;no arg\n&quot;);
+    dprintf(&quot;one arg %d\n&quot;, 1);
+</pre></td></tr></table>
+
+</li><li> <code>__FUNCTION__</code> is interpreted as C99 <code>__func__</code> 
+(so it has not exactly the same semantics as string literal GNUC
+where it is a string literal).
+
+</li><li> The <code>__alignof__</code> keyword can be used as <code>sizeof</code> 
+to get the alignment of a type or an expression.
+
+</li><li> The <code>typeof(x)</code> returns the type of <code>x</code>. 
+<code>x</code> is an expression or a type.
+
+</li><li> Computed gotos: <code>&amp;&amp;label</code> returns a pointer of type 
+<code>void *</code> on the goto label <code>label</code>. <code>goto *expr</code> can be
+used to jump on the pointer resulting from <code>expr</code>.
+
+</li><li> Inline assembly with asm instruction:
+<a name="index-inline-assembly"></a>
+<a name="index-assembly_002c-inline"></a>
+<a name="index-_005f_005fasm_005f_005f"></a>
+<table><tr><td>&nbsp;</td><td><pre class="example">static inline void * my_memcpy(void * to, const void * from, size_t n)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+        &quot;rep ; movsl\n\t&quot;
+        &quot;testb $2,%b4\n\t&quot;
+        &quot;je 1f\n\t&quot;
+        &quot;movsw\n&quot;
+        &quot;1:\ttestb $1,%b4\n\t&quot;
+        &quot;je 2f\n\t&quot;
+        &quot;movsb\n&quot;
+        &quot;2:&quot;
+        : &quot;=&amp;c&quot; (d0), &quot;=&amp;D&quot; (d1), &quot;=&amp;S&quot; (d2)
+        :&quot;0&quot; (n/4), &quot;q&quot; (n),&quot;1&quot; ((long) to),&quot;2&quot; ((long) from)
+        : &quot;memory&quot;);
+return (to);
+}
+</pre></td></tr></table>
+
+<a name="index-gas"></a>
+<p>TCC includes its own x86 inline assembler with a <code>gas</code>-like (GNU
+assembler) syntax. No intermediate files are generated. GCC 3.x named
+operands are supported.
+</p>
+</li><li> <code>__builtin_types_compatible_p()</code> and <code>__builtin_constant_p()</code> 
+are supported.
+
+</li><li> <code>#pragma pack</code> is supported for win32 compatibility.
+
+</li></ul>
+
+<hr size="6">
+<a name="TinyCC-extensions"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#GNU-C-extensions" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Clang" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">3.4 TinyCC extensions</h2>
+
+<ul>
+<li> <code>__TINYC__</code> is a predefined macro to <code>1</code> to
+indicate that you use TCC.
+
+</li><li> <code>#!</code> at the start of a line is ignored to allow scripting.
+
+</li><li> Binary digits can be entered (<code>0b101</code> instead of
+<code>5</code>).
+
+</li><li> <code>__BOUNDS_CHECKING_ON</code> is defined if bound checking is activated.
+
+</li></ul>
+
+<hr size="6">
+<a name="asm"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#TinyCC-extensions" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Syntax" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Clang" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="TinyCC-Assembler"></a>
+<h1 class="chapter">4. TinyCC Assembler</h1>
+
+<p>Since version 0.9.16, TinyCC integrates its own assembler. TinyCC
+assembler supports a gas-like syntax (GNU assembler). You can
+desactivate assembler support if you want a smaller TinyCC executable
+(the C compiler does not rely on the assembler).
+</p>
+<p>TinyCC Assembler is used to handle files with &lsquo;<tt>.S</tt>&rsquo; (C
+preprocessed assembler) and &lsquo;<tt>.s</tt>&rsquo; extensions. It is also used to
+handle the GNU inline assembler with the <code>asm</code> keyword.
+</p>
+<hr size="6">
+<a name="Syntax"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#asm" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Expressions" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">4.1 Syntax</h2>
+
+<p>TinyCC Assembler supports most of the gas syntax. The tokens are the
+same as C.
+</p>
+<ul>
+<li> C and C++ comments are supported.
+
+</li><li> Identifiers are the same as C, so you cannot use &rsquo;.&rsquo; or &rsquo;$&rsquo;.
+
+</li><li> Only 32 bit integer numbers are supported.
+
+</li></ul>
+
+<hr size="6">
+<a name="Expressions"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Syntax" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Labels" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">4.2 Expressions</h2>
+
+<ul>
+<li> Integers in decimal, octal and hexa are supported.
+
+</li><li> Unary operators: +, -, ~.
+
+</li><li> Binary operators in decreasing priority order:
+
+<ol>
+<li> *, /, %
+</li><li> &amp;, |, ^
+</li><li> +, -
+</li></ol>
+
+</li><li> A value is either an absolute number or a label plus an offset. 
+All operators accept absolute values except &rsquo;+&rsquo; and &rsquo;-&rsquo;. &rsquo;+&rsquo; or &rsquo;-&rsquo; can be
+used to add an offset to a label. &rsquo;-&rsquo; supports two labels only if they
+are the same or if they are both defined and in the same section.
+
+</li></ul>
+
+<hr size="6">
+<a name="Labels"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Expressions" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Directives" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">4.3 Labels</h2>
+
+<ul>
+<li> All labels are considered as local, except undefined ones.
+
+</li><li> Numeric labels can be used as local <code>gas</code>-like labels. 
+They can be defined several times in the same source. Use &rsquo;b&rsquo;
+(backward) or &rsquo;f&rsquo; (forward) as suffix to reference them:
+
+<table><tr><td>&nbsp;</td><td><pre class="example"> 1:
+      jmp 1b /* jump to '1' label before */
+      jmp 1f /* jump to '1' label after */
+ 1:
+</pre></td></tr></table>
+
+</li></ul>
+
+<hr size="6">
+<a name="Directives"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Labels" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#X86-Assembler" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">4.4 Directives</h2>
+<a name="index-assembler-directives"></a>
+<a name="index-directives_002c-assembler"></a>
+<a name="index-align-directive"></a>
+<a name="index-skip-directive"></a>
+<a name="index-space-directive"></a>
+<a name="index-byte-directive"></a>
+<a name="index-word-directive"></a>
+<a name="index-short-directive"></a>
+<a name="index-int-directive"></a>
+<a name="index-long-directive"></a>
+<a name="index-quad-directive"></a>
+<a name="index-globl-directive"></a>
+<a name="index-global-directive"></a>
+<a name="index-section-directive"></a>
+<a name="index-text-directive"></a>
+<a name="index-data-directive"></a>
+<a name="index-bss-directive"></a>
+<a name="index-fill-directive"></a>
+<a name="index-org-directive"></a>
+<a name="index-previous-directive"></a>
+<a name="index-string-directive"></a>
+<a name="index-asciz-directive"></a>
+<a name="index-ascii-directive"></a>
+
+<p>All directives are preceeded by a &rsquo;.&rsquo;. The following directives are
+supported:
+</p>
+<ul>
+<li> .align n[,value]
+</li><li> .skip n[,value]
+</li><li> .space n[,value]
+</li><li> .byte value1[,...]
+</li><li> .word value1[,...]
+</li><li> .short value1[,...]
+</li><li> .int value1[,...]
+</li><li> .long value1[,...]
+</li><li> .quad immediate_value1[,...]
+</li><li> .globl symbol
+</li><li> .global symbol
+</li><li> .section section
+</li><li> .text
+</li><li> .data
+</li><li> .bss
+</li><li> .fill repeat[,size[,value]]
+</li><li> .org n
+</li><li> .previous
+</li><li> .string string[,...]
+</li><li> .asciz string[,...]
+</li><li> .ascii string[,...]
+</li></ul>
+
+<hr size="6">
+<a name="X86-Assembler"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Directives" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#asm" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">4.5 X86 Assembler</h2>
+<a name="index-assembler"></a>
+
+<p>All X86 opcodes are supported. Only ATT syntax is supported (source
+then destination operand order). If no size suffix is given, TinyCC
+tries to guess it from the operand sizes.
+</p>
+<p>Currently, MMX opcodes are supported but not SSE ones.
+</p>
+<hr size="6">
+<a name="linker"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#X86-Assembler" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#ELF-file-generation" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#asm" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="TinyCC-Linker"></a>
+<h1 class="chapter">5. TinyCC Linker</h1>
+<a name="index-linker"></a>
+
+<hr size="6">
+<a name="ELF-file-generation"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#linker" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#ELF-file-loader" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">5.1 ELF file generation</h2>
+<a name="index-ELF"></a>
+
+<p>TCC can directly output relocatable ELF files (object files),
+executable ELF files and dynamic ELF libraries without relying on an
+external linker.
+</p>
+<p>Dynamic ELF libraries can be output but the C compiler does not generate
+position independent code (PIC). It means that the dynamic library
+code generated by TCC cannot be factorized among processes yet.
+</p>
+<p>TCC linker eliminates unreferenced object code in libraries. A single pass is
+done on the object and library list, so the order in which object files and
+libraries are specified is important (same constraint as GNU ld). No grouping
+options (&lsquo;<samp>--start-group</samp>&rsquo; and &lsquo;<samp>--end-group</samp>&rsquo;) are supported.
+</p>
+<hr size="6">
+<a name="ELF-file-loader"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#ELF-file-generation" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#PE_002di386-file-generation" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">5.2 ELF file loader</h2>
+
+<p>TCC can load ELF object files, archives (.a files) and dynamic
+libraries (.so).
+</p>
+<hr size="6">
+<a name="PE_002di386-file-generation"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#ELF-file-loader" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#GNU-Linker-Scripts" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">5.3 PE-i386 file generation</h2>
+<a name="index-PE_002di386"></a>
+
+<p>TCC for Windows supports the native Win32 executable file format (PE-i386).  It
+generates EXE files (console and gui) and DLL files.
+</p>
+<p>For usage on Windows, see also tcc-win32.txt.
+</p>
+<hr size="6">
+<a name="GNU-Linker-Scripts"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#PE_002di386-file-generation" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Bounds" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#linker" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Bounds" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">5.4 GNU Linker Scripts</h2>
+<a name="index-scripts_002c-linker"></a>
+<a name="index-linker-scripts"></a>
+<a name="index-GROUP_002c-linker-command"></a>
+<a name="index-FILE_002c-linker-command"></a>
+<a name="index-OUTPUT_005fFORMAT_002c-linker-command"></a>
+<a name="index-TARGET_002c-linker-command"></a>
+
+<p>Because on many Linux systems some dynamic libraries (such as
+&lsquo;<tt>/usr/lib/libc.so</tt>&rsquo;) are in fact GNU ld link scripts (horrible!),
+the TCC linker also supports a subset of GNU ld scripts.
+</p>
+<p>The <code>GROUP</code> and <code>FILE</code> commands are supported. <code>OUTPUT_FORMAT</code>
+and <code>TARGET</code> are ignored.
+</p>
+<p>Example from &lsquo;<tt>/usr/lib/libc.so</tt>&rsquo;:
+</p><table><tr><td>&nbsp;</td><td><pre class="example">/* GNU ld script
+   Use the shared library, but some functions are only in
+   the static library, so try that secondarily.  */
+GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
+</pre></td></tr></table>
+
+<hr size="6">
+<a name="Bounds"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#GNU-Linker-Scripts" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Libtcc" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#linker" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Libtcc" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="TinyCC-Memory-and-Bound-checks"></a>
+<h1 class="chapter">6. TinyCC Memory and Bound checks</h1>
+<a name="index-bound-checks"></a>
+<a name="index-memory-checks"></a>
+
+<p>This feature is activated with the &lsquo;<samp>-b</samp>&rsquo; (see section <a href="#Invoke">Command line invocation</a>).
+</p>
+<p>Note that pointer size is <em>unchanged</em> and that code generated
+with bound checks is <em>fully compatible</em> with unchecked
+code. When a pointer comes from unchecked code, it is assumed to be
+valid. Even very obscure C code with casts should work correctly.
+</p>
+<p>For more information about the ideas behind this method, see
+<a href="http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html">http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html</a>.
+</p>
+<p>Here are some examples of caught errors:
+</p>
+<dl compact="compact">
+<dt> Invalid range with standard string function:</dt>
+<dd><table><tr><td>&nbsp;</td><td><pre class="example">{
+    char tab[10];
+    memset(tab, 0, 11);
+}
+</pre></td></tr></table>
+
+</dd>
+<dt> Out of bounds-error in global or local arrays:</dt>
+<dd><table><tr><td>&nbsp;</td><td><pre class="example">{
+    int tab[10];
+    for(i=0;i&lt;11;i++) {
+        sum += tab[i];
+    }
+}
+</pre></td></tr></table>
+
+</dd>
+<dt> Out of bounds-error in malloc&rsquo;ed data:</dt>
+<dd><table><tr><td>&nbsp;</td><td><pre class="example">{
+    int *tab;
+    tab = malloc(20 * sizeof(int));
+    for(i=0;i&lt;21;i++) {
+        sum += tab4[i];
+    }
+    free(tab);
+}
+</pre></td></tr></table>
+
+</dd>
+<dt> Access of freed memory:</dt>
+<dd><table><tr><td>&nbsp;</td><td><pre class="example">{
+    int *tab;
+    tab = malloc(20 * sizeof(int));
+    free(tab);
+    for(i=0;i&lt;20;i++) {
+        sum += tab4[i];
+    }
+}
+</pre></td></tr></table>
+
+</dd>
+<dt> Double free:</dt>
+<dd><table><tr><td>&nbsp;</td><td><pre class="example">{
+    int *tab;
+    tab = malloc(20 * sizeof(int));
+    free(tab);
+    free(tab);
+}
+</pre></td></tr></table>
+
+</dd>
+</dl>
+
+<hr size="6">
+<a name="Libtcc"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Bounds" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Bounds" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="The-libtcc-library"></a>
+<h1 class="chapter">7. The <code>libtcc</code> library</h1>
+
+<p>The <code>libtcc</code> library enables you to use TCC as a backend for
+dynamic code generation. 
+</p>
+<p>Read the &lsquo;<tt>libtcc.h</tt>&rsquo; to have an overview of the API. Read
+&lsquo;<tt>libtcc_test.c</tt>&rsquo; to have a very simple example.
+</p>
+<p>The idea consists in giving a C string containing the program you want
+to compile directly to <code>libtcc</code>. Then you can access to any global
+symbol (function or variable) defined.
+</p>
+<hr size="6">
+<a name="devel"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Libtcc" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#File-reading" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Libtcc" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<a name="Developer_0027s-guide"></a>
+<h1 class="chapter">8. Developer&rsquo;s guide</h1>
+
+<p>This chapter gives some hints to understand how TCC works. You can skip
+it if you do not intend to modify the TCC code.
+</p>
+<hr size="6">
+<a name="File-reading"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#devel" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Lexer" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.1 File reading</h2>
+
+<p>The <code>BufferedFile</code> structure contains the context needed to read a
+file, including the current line number. <code>tcc_open()</code> opens a new
+file and <code>tcc_close()</code> closes it. <code>inp()</code> returns the next
+character.
+</p>
+<hr size="6">
+<a name="Lexer"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#File-reading" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Parser" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.2 Lexer</h2>
+
+<p><code>next()</code> reads the next token in the current
+file. <code>next_nomacro()</code> reads the next token without macro
+expansion.
+</p>
+<p><code>tok</code> contains the current token (see <code>TOK_xxx</code>)
+constants. Identifiers and keywords are also keywords. <code>tokc</code>
+contains additional infos about the token (for example a constant value
+if number or string token).
+</p>
+<hr size="6">
+<a name="Parser"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Lexer" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Types" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.3 Parser</h2>
+
+<p>The parser is hardcoded (yacc is not necessary). It does only one pass,
+except:
+</p>
+<ul>
+<li> For initialized arrays with unknown size, a first pass 
+is done to count the number of elements.
+
+</li><li> For architectures where arguments are evaluated in 
+reverse order, a first pass is done to reverse the argument order.
+
+</li></ul>
+
+<hr size="6">
+<a name="Types"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Parser" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Symbols" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.4 Types</h2>
+
+<p>The types are stored in a single &rsquo;int&rsquo; variable. It was choosen in the
+first stages of development when tcc was much simpler. Now, it may not
+be the best solution.
+</p>
+<table><tr><td>&nbsp;</td><td><pre class="example">#define VT_INT        0  /* integer type */
+#define VT_BYTE       1  /* signed byte type */
+#define VT_SHORT      2  /* short type */
+#define VT_VOID       3  /* void type */
+#define VT_PTR        4  /* pointer */
+#define VT_ENUM       5  /* enum definition */
+#define VT_FUNC       6  /* function type */
+#define VT_STRUCT     7  /* struct/union definition */
+#define VT_FLOAT      8  /* IEEE float */
+#define VT_DOUBLE     9  /* IEEE double */
+#define VT_LDOUBLE   10  /* IEEE long double */
+#define VT_BOOL      11  /* ISOC99 boolean type */
+#define VT_LLONG     12  /* 64 bit integer */
+#define VT_LONG      13  /* long integer (NEVER USED as type, only
+                            during parsing) */
+#define VT_BTYPE      0x000f /* mask for basic type */
+#define VT_UNSIGNED   0x0010  /* unsigned type */
+#define VT_ARRAY      0x0020  /* array type (also has VT_PTR) */
+#define VT_VLA        0x20000 /* VLA type (also has VT_PTR and VT_ARRAY) */
+#define VT_BITFIELD   0x0040  /* bitfield modifier */
+#define VT_CONSTANT   0x0800  /* const modifier */
+#define VT_VOLATILE   0x1000  /* volatile modifier */
+#define VT_SIGNED     0x2000  /* signed type */
+
+#define VT_STRUCT_SHIFT 18   /* structure/enum name shift (14 bits left) */
+</pre></td></tr></table>
+
+<p>When a reference to another type is needed (for pointers, functions and
+structures), the <code>32 - VT_STRUCT_SHIFT</code> high order bits are used to
+store an identifier reference.
+</p>
+<p>The <code>VT_UNSIGNED</code> flag can be set for chars, shorts, ints and long
+longs.
+</p>
+<p>Arrays are considered as pointers <code>VT_PTR</code> with the flag
+<code>VT_ARRAY</code> set. Variable length arrays are considered as special
+arrays and have flag <code>VT_VLA</code> set instead of <code>VT_ARRAY</code>.
+</p>
+<p>The <code>VT_BITFIELD</code> flag can be set for chars, shorts, ints and long
+longs. If it is set, then the bitfield position is stored from bits
+VT_STRUCT_SHIFT to VT_STRUCT_SHIFT + 5 and the bit field size is stored
+from bits VT_STRUCT_SHIFT + 6 to VT_STRUCT_SHIFT + 11.
+</p>
+<p><code>VT_LONG</code> is never used except during parsing.
+</p>
+<p>During parsing, the storage of an object is also stored in the type
+integer:
+</p>
+<table><tr><td>&nbsp;</td><td><pre class="example">#define VT_EXTERN  0x00000080  /* extern definition */
+#define VT_STATIC  0x00000100  /* static variable */
+#define VT_TYPEDEF 0x00000200  /* typedef definition */
+#define VT_INLINE  0x00000400  /* inline definition */
+#define VT_IMPORT  0x00004000  /* win32: extern data imported from dll */
+#define VT_EXPORT  0x00008000  /* win32: data exported from dll */
+#define VT_WEAK    0x00010000  /* win32: data exported from dll */
+</pre></td></tr></table>
+
+<hr size="6">
+<a name="Symbols"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Types" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Sections" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.5 Symbols</h2>
+
+<p>All symbols are stored in hashed symbol stacks. Each symbol stack
+contains <code>Sym</code> structures.
+</p>
+<p><code>Sym.v</code> contains the symbol name (remember
+an idenfier is also a token, so a string is never necessary to store
+it). <code>Sym.t</code> gives the type of the symbol. <code>Sym.r</code> is usually
+the register in which the corresponding variable is stored. <code>Sym.c</code> is
+usually a constant associated to the symbol like its address for normal
+symbols, and the number of entries for symbols representing arrays.
+Variable length array types use <code>Sym.c</code> as a location on the stack
+which holds the runtime sizeof for the type.
+</p>
+<p>Four main symbol stacks are defined:
+</p>
+<dl compact="compact">
+<dt> <code>define_stack</code></dt>
+<dd><p>for the macros (<code>#define</code>s).
+</p>
+</dd>
+<dt> <code>global_stack</code></dt>
+<dd><p>for the global variables, functions and types.
+</p>
+</dd>
+<dt> <code>local_stack</code></dt>
+<dd><p>for the local variables, functions and types.
+</p>
+</dd>
+<dt> <code>global_label_stack</code></dt>
+<dd><p>for the local labels (for <code>goto</code>).
+</p>
+</dd>
+<dt> <code>label_stack</code></dt>
+<dd><p>for GCC block local labels (see the <code>__label__</code> keyword).
+</p>
+</dd>
+</dl>
+
+<p><code>sym_push()</code> is used to add a new symbol in the local symbol
+stack. If no local symbol stack is active, it is added in the global
+symbol stack.
+</p>
+<p><code>sym_pop(st,b)</code> pops symbols from the symbol stack <var>st</var> until
+the symbol <var>b</var> is on the top of stack. If <var>b</var> is NULL, the stack
+is emptied.
+</p>
+<p><code>sym_find(v)</code> return the symbol associated to the identifier
+<var>v</var>. The local stack is searched first from top to bottom, then the
+global stack.
+</p>
+<hr size="6">
+<a name="Sections"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Symbols" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Code-generation" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.6 Sections</h2>
+
+<p>The generated code and datas are written in sections. The structure
+<code>Section</code> contains all the necessary information for a given
+section. <code>new_section()</code> creates a new section. ELF file semantics
+is assumed for each section.
+</p>
+<p>The following sections are predefined:
+</p>
+<dl compact="compact">
+<dt> <code>text_section</code></dt>
+<dd><p>is the section containing the generated code. <var>ind</var> contains the
+current position in the code section.
+</p>
+</dd>
+<dt> <code>data_section</code></dt>
+<dd><p>contains initialized data
+</p>
+</dd>
+<dt> <code>bss_section</code></dt>
+<dd><p>contains uninitialized data
+</p>
+</dd>
+<dt> <code>bounds_section</code></dt>
+<dt> <code>lbounds_section</code></dt>
+<dd><p>are used when bound checking is activated
+</p>
+</dd>
+<dt> <code>stab_section</code></dt>
+<dt> <code>stabstr_section</code></dt>
+<dd><p>are used when debugging is actived to store debug information
+</p>
+</dd>
+<dt> <code>symtab_section</code></dt>
+<dt> <code>strtab_section</code></dt>
+<dd><p>contain the exported symbols (currently only used for debugging).
+</p>
+</dd>
+</dl>
+
+<hr size="6">
+<a name="Code-generation"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Sections" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Introduction-2" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.7 Code generation</h2>
+<a name="index-code-generation"></a>
+
+<hr size="6">
+<a name="Introduction-2"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Code-generation" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#The-value-stack" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h3 class="subsection">8.7.1 Introduction</h3>
+
+<p>The TCC code generator directly generates linked binary code in one
+pass. It is rather unusual these days (see gcc for example which
+generates text assembly), but it can be very fast and surprisingly
+little complicated.
+</p>
+<p>The TCC code generator is register based. Optimization is only done at
+the expression level. No intermediate representation of expression is
+kept except the current values stored in the <em>value stack</em>.
+</p>
+<p>On x86, three temporary registers are used. When more registers are
+needed, one register is spilled into a new temporary variable on the stack.
+</p>
+<hr size="6">
+<a name="The-value-stack"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Introduction-2" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Manipulating-the-value-stack" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h3 class="subsection">8.7.2 The value stack</h3>
+<a name="index-value-stack_002c-introduction"></a>
+
+<p>When an expression is parsed, its value is pushed on the value stack
+(<var>vstack</var>). The top of the value stack is <var>vtop</var>. Each value
+stack entry is the structure <code>SValue</code>.
+</p>
+<p><code>SValue.t</code> is the type. <code>SValue.r</code> indicates how the value is
+currently stored in the generated code. It is usually a CPU register
+index (<code>REG_xxx</code> constants), but additional values and flags are
+defined:
+</p>
+<table><tr><td>&nbsp;</td><td><pre class="example">#define VT_CONST     0x00f0
+#define VT_LLOCAL    0x00f1
+#define VT_LOCAL     0x00f2
+#define VT_CMP       0x00f3
+#define VT_JMP       0x00f4
+#define VT_JMPI      0x00f5
+#define VT_LVAL      0x0100
+#define VT_SYM       0x0200
+#define VT_MUSTCAST  0x0400
+#define VT_MUSTBOUND 0x0800
+#define VT_BOUNDED   0x8000
+#define VT_LVAL_BYTE     0x1000
+#define VT_LVAL_SHORT    0x2000
+#define VT_LVAL_UNSIGNED 0x4000
+#define VT_LVAL_TYPE     (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
+</pre></td></tr></table>
+
+<dl compact="compact">
+<dt> <code>VT_CONST</code></dt>
+<dd><p>indicates that the value is a constant. It is stored in the union
+<code>SValue.c</code>, depending on its type.
+</p>
+</dd>
+<dt> <code>VT_LOCAL</code></dt>
+<dd><p>indicates a local variable pointer at offset <code>SValue.c.i</code> in the
+stack.
+</p>
+</dd>
+<dt> <code>VT_CMP</code></dt>
+<dd><p>indicates that the value is actually stored in the CPU flags (i.e. the
+value is the consequence of a test). The value is either 0 or 1. The
+actual CPU flags used is indicated in <code>SValue.c.i</code>. 
+</p>
+<p>If any code is generated which destroys the CPU flags, this value MUST be
+put in a normal register.
+</p>
+</dd>
+<dt> <code>VT_JMP</code></dt>
+<dt> <code>VT_JMPI</code></dt>
+<dd><p>indicates that the value is the consequence of a conditional jump. For VT_JMP,
+it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
+</p>
+<p>These values are used to compile the <code>||</code> and <code>&amp;&amp;</code> logical
+operators.
+</p>
+<p>If any code is generated, this value MUST be put in a normal
+register. Otherwise, the generated code won&rsquo;t be executed if the jump is
+taken.
+</p>
+</dd>
+<dt> <code>VT_LVAL</code></dt>
+<dd><p>is a flag indicating that the value is actually an lvalue (left value of
+an assignment). It means that the value stored is actually a pointer to
+the wanted value. 
+</p>
+<p>Understanding the use <code>VT_LVAL</code> is very important if you want to
+understand how TCC works.
+</p>
+</dd>
+<dt> <code>VT_LVAL_BYTE</code></dt>
+<dt> <code>VT_LVAL_SHORT</code></dt>
+<dt> <code>VT_LVAL_UNSIGNED</code></dt>
+<dd><p>if the lvalue has an integer type, then these flags give its real
+type. The type alone is not enough in case of cast optimisations.
+</p>
+</dd>
+<dt> <code>VT_LLOCAL</code></dt>
+<dd><p>is a saved lvalue on the stack. <code>VT_LLOCAL</code> should be eliminated
+ASAP because its semantics are rather complicated.
+</p>
+</dd>
+<dt> <code>VT_MUSTCAST</code></dt>
+<dd><p>indicates that a cast to the value type must be performed if the value
+is used (lazy casting).
+</p>
+</dd>
+<dt> <code>VT_SYM</code></dt>
+<dd><p>indicates that the symbol <code>SValue.sym</code> must be added to the constant.
+</p>
+</dd>
+<dt> <code>VT_MUSTBOUND</code></dt>
+<dt> <code>VT_BOUNDED</code></dt>
+<dd><p>are only used for optional bound checking.
+</p>
+</dd>
+</dl>
+
+<hr size="6">
+<a name="Manipulating-the-value-stack"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#The-value-stack" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#CPU-dependent-code-generation" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h3 class="subsection">8.7.3 Manipulating the value stack</h3>
+<a name="index-value-stack"></a>
+
+<p><code>vsetc()</code> and <code>vset()</code> pushes a new value on the value
+stack. If the previous <var>vtop</var> was stored in a very unsafe place(for
+example in the CPU flags), then some code is generated to put the
+previous <var>vtop</var> in a safe storage.
+</p>
+<p><code>vpop()</code> pops <var>vtop</var>. In some cases, it also generates cleanup
+code (for example if stacked floating point registers are used as on
+x86).
+</p>
+<p>The <code>gv(rc)</code> function generates code to evaluate <var>vtop</var> (the
+top value of the stack) into registers. <var>rc</var> selects in which
+register class the value should be put. <code>gv()</code> is the <em>most
+important function</em> of the code generator.
+</p>
+<p><code>gv2()</code> is the same as <code>gv()</code> but for the top two stack
+entries.
+</p>
+<hr size="6">
+<a name="CPU-dependent-code-generation"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Manipulating-the-value-stack" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Optimizations-done" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Code-generation" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h3 class="subsection">8.7.4 CPU dependent code generation</h3>
+<a name="index-CPU-dependent"></a>
+<p>See the &lsquo;<tt>i386-gen.c</tt>&rsquo; file to have an example.
+</p>
+<dl compact="compact">
+<dt> <code>load()</code></dt>
+<dd><p>must generate the code needed to load a stack value into a register.
+</p>
+</dd>
+<dt> <code>store()</code></dt>
+<dd><p>must generate the code needed to store a register into a stack value
+lvalue.
+</p>
+</dd>
+<dt> <code>gfunc_start()</code></dt>
+<dt> <code>gfunc_param()</code></dt>
+<dt> <code>gfunc_call()</code></dt>
+<dd><p>should generate a function call
+</p>
+</dd>
+<dt> <code>gfunc_prolog()</code></dt>
+<dt> <code>gfunc_epilog()</code></dt>
+<dd><p>should generate a function prolog/epilog.
+</p>
+</dd>
+<dt> <code>gen_opi(op)</code></dt>
+<dd><p>must generate the binary integer operation <var>op</var> on the two top
+entries of the stack which are guaranted to contain integer types.
+</p>
+<p>The result value should be put on the stack.
+</p>
+</dd>
+<dt> <code>gen_opf(op)</code></dt>
+<dd><p>same as <code>gen_opi()</code> for floating point operations. The two top
+entries of the stack are guaranted to contain floating point values of
+same types.
+</p>
+</dd>
+<dt> <code>gen_cvt_itof()</code></dt>
+<dd><p>integer to floating point conversion.
+</p>
+</dd>
+<dt> <code>gen_cvt_ftoi()</code></dt>
+<dd><p>floating point to integer conversion.
+</p>
+</dd>
+<dt> <code>gen_cvt_ftof()</code></dt>
+<dd><p>floating point to floating point of different size conversion.
+</p>
+</dd>
+<dt> <code>gen_bounded_ptr_add()</code></dt>
+<dt> <code>gen_bounded_ptr_deref()</code></dt>
+<dd><p>are only used for bounds checking.
+</p>
+</dd>
+</dl>
+
+<hr size="6">
+<a name="Optimizations-done"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#CPU-dependent-code-generation" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next section in reading order"> &gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#devel" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Next chapter"> &gt;&gt; </a>]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h2 class="section">8.8 Optimizations done</h2>
+<a name="index-optimizations"></a>
+<a name="index-constant-propagation"></a>
+<a name="index-strength-reduction"></a>
+<a name="index-comparison-operators"></a>
+<a name="index-caching-processor-flags"></a>
+<a name="index-flags_002c-caching"></a>
+<a name="index-jump-optimization"></a>
+<p>Constant propagation is done for all operations. Multiplications and
+divisions are optimized to shifts when appropriate. Comparison
+operators are optimized by maintaining a special cache for the
+processor flags. &amp;&amp;, || and ! are optimized by maintaining a special
+&rsquo;jump target&rsquo; value. No other jump optimization is currently performed
+because it would require to store the code in a more abstract fashion.
+</p>
+<hr size="6">
+<a name="Concept-Index"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Optimizations-done" title="Previous section in reading order"> &lt; </a>]</td>
+<td valign="middle" align="left">[ &gt; ]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#devel" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
+<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
+<td valign="middle" align="left">[ &gt;&gt; ]</td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left"> &nbsp; </td>
+<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h1 class="unnumbered">Concept Index</h1>
+<table><tr><th valign="top">Jump to: &nbsp; </th><td><a href="#Concept-Index_cp_symbol-1" class="summary-letter"><b>_</b></a>
+ &nbsp; 
+<br>
+<a href="#Concept-Index_cp_letter-A" class="summary-letter"><b>A</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-B" class="summary-letter"><b>B</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-C" class="summary-letter"><b>C</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-D" class="summary-letter"><b>D</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-E" class="summary-letter"><b>E</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-F" class="summary-letter"><b>F</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-G" class="summary-letter"><b>G</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-I" class="summary-letter"><b>I</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-J" class="summary-letter"><b>J</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-L" class="summary-letter"><b>L</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-M" class="summary-letter"><b>M</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-O" class="summary-letter"><b>O</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-P" class="summary-letter"><b>P</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-Q" class="summary-letter"><b>Q</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-R" class="summary-letter"><b>R</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-S" class="summary-letter"><b>S</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-T" class="summary-letter"><b>T</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-U" class="summary-letter"><b>U</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-V" class="summary-letter"><b>V</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-W" class="summary-letter"><b>W</b></a>
+ &nbsp; 
+</td></tr></table>
+<table border="0" class="index-cp">
+<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_symbol-1">_</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-_005f_005fasm_005f_005f">__asm__</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-A">A</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-align-directive">align directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-aligned-attribute">aligned attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-ascii-directive">ascii directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-asciz-directive">asciz directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-assembler">assembler</a></td><td valign="top"><a href="#X86-Assembler">4.5 X86 Assembler</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-assembler-directives">assembler directives</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-assembly_002c-inline">assembly, inline</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-B">B</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-bound-checks">bound checks</a></td><td valign="top"><a href="#Bounds">6. TinyCC Memory and Bound checks</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-bss-directive">bss directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-byte-directive">byte directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-C">C</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-caching-processor-flags">caching processor flags</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-cdecl-attribute">cdecl attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-code-generation">code generation</a></td><td valign="top"><a href="#Code-generation">8.7 Code generation</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-comparison-operators">comparison operators</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-constant-propagation">constant propagation</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-CPU-dependent">CPU dependent</a></td><td valign="top"><a href="#CPU-dependent-code-generation">8.7.4 CPU dependent code generation</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-D">D</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-data-directive">data directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-directives_002c-assembler">directives, assembler</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-dllexport-attribute">dllexport attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-E">E</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-ELF">ELF</a></td><td valign="top"><a href="#ELF-file-generation">5.1 ELF file generation</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-F">F</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-FILE_002c-linker-command">FILE, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-fill-directive">fill directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-flags_002c-caching">flags, caching</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-G">G</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-gas">gas</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-global-directive">global directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-globl-directive">globl directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-GROUP_002c-linker-command">GROUP, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-I">I</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-inline-assembly">inline assembly</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-int-directive">int directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-J">J</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-jump-optimization">jump optimization</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-L">L</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-linker">linker</a></td><td valign="top"><a href="#linker">5. TinyCC Linker</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-linker-scripts">linker scripts</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-long-directive">long directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-M">M</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-memory-checks">memory checks</a></td><td valign="top"><a href="#Bounds">6. TinyCC Memory and Bound checks</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-O">O</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-optimizations">optimizations</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-org-directive">org directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-OUTPUT_005fFORMAT_002c-linker-command">OUTPUT_FORMAT, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-P">P</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-packed-attribute">packed attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-PE_002di386">PE-i386</a></td><td valign="top"><a href="#PE_002di386-file-generation">5.3 PE-i386 file generation</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-previous-directive">previous directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-Q">Q</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-quad-directive">quad directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-R">R</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-regparm-attribute">regparm attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-S">S</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-scripts_002c-linker">scripts, linker</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-section-attribute">section attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-section-directive">section directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-short-directive">short directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-skip-directive">skip directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-space-directive">space directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-stdcall-attribute">stdcall attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-strength-reduction">strength reduction</a></td><td valign="top"><a href="#Optimizations-done">8.8 Optimizations done</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-string-directive">string directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-T">T</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-TARGET_002c-linker-command">TARGET, linker command</a></td><td valign="top"><a href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-text-directive">text directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-U">U</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-unused-attribute">unused attribute</a></td><td valign="top"><a href="#GNU-C-extensions">3.3 GNU C extensions</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-V">V</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-value-stack">value stack</a></td><td valign="top"><a href="#Manipulating-the-value-stack">8.7.3 Manipulating the value stack</a></td></tr>
+<tr><td></td><td valign="top"><a href="#index-value-stack_002c-introduction">value stack, introduction</a></td><td valign="top"><a href="#The-value-stack">8.7.2 The value stack</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+<tr><th><a name="Concept-Index_cp_letter-W">W</a></th><td></td><td></td></tr>
+<tr><td></td><td valign="top"><a href="#index-word-directive">word directive</a></td><td valign="top"><a href="#Directives">4.4 Directives</a></td></tr>
+<tr><td colspan="3"> <hr></td></tr>
+</table>
+<table><tr><th valign="top">Jump to: &nbsp; </th><td><a href="#Concept-Index_cp_symbol-1" class="summary-letter"><b>_</b></a>
+ &nbsp; 
+<br>
+<a href="#Concept-Index_cp_letter-A" class="summary-letter"><b>A</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-B" class="summary-letter"><b>B</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-C" class="summary-letter"><b>C</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-D" class="summary-letter"><b>D</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-E" class="summary-letter"><b>E</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-F" class="summary-letter"><b>F</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-G" class="summary-letter"><b>G</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-I" class="summary-letter"><b>I</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-J" class="summary-letter"><b>J</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-L" class="summary-letter"><b>L</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-M" class="summary-letter"><b>M</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-O" class="summary-letter"><b>O</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-P" class="summary-letter"><b>P</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-Q" class="summary-letter"><b>Q</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-R" class="summary-letter"><b>R</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-S" class="summary-letter"><b>S</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-T" class="summary-letter"><b>T</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-U" class="summary-letter"><b>U</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-V" class="summary-letter"><b>V</b></a>
+ &nbsp; 
+<a href="#Concept-Index_cp_letter-W" class="summary-letter"><b>W</b></a>
+ &nbsp; 
+</td></tr></table>
+
+<hr size="6">
+<a name="SEC_Contents"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h1>Table of Contents</h1>
+<div class="contents">
+
+<ul class="toc">
+  <li><a name="toc-Introduction-1" href="#Introduction">1. Introduction</a></li>
+  <li><a name="toc-Command-line-invocation" href="#Invoke">2. Command line invocation</a>
+  <ul class="toc">
+    <li><a name="toc-Quick-start" href="#Quick-start">2.1 Quick start</a></li>
+    <li><a name="toc-Option-summary" href="#Option-summary">2.2 Option summary</a></li>
+  </ul></li>
+  <li><a name="toc-C-language-support" href="#Clang">3. C language support</a>
+  <ul class="toc">
+    <li><a name="toc-ANSI-C" href="#ANSI-C">3.1 ANSI C</a></li>
+    <li><a name="toc-ISOC99-extensions" href="#ISOC99-extensions">3.2 ISOC99 extensions</a></li>
+    <li><a name="toc-GNU-C-extensions" href="#GNU-C-extensions">3.3 GNU C extensions</a></li>
+    <li><a name="toc-TinyCC-extensions" href="#TinyCC-extensions">3.4 TinyCC extensions</a></li>
+  </ul></li>
+  <li><a name="toc-TinyCC-Assembler" href="#asm">4. TinyCC Assembler</a>
+  <ul class="toc">
+    <li><a name="toc-Syntax" href="#Syntax">4.1 Syntax</a></li>
+    <li><a name="toc-Expressions" href="#Expressions">4.2 Expressions</a></li>
+    <li><a name="toc-Labels" href="#Labels">4.3 Labels</a></li>
+    <li><a name="toc-Directives" href="#Directives">4.4 Directives</a></li>
+    <li><a name="toc-X86-Assembler" href="#X86-Assembler">4.5 X86 Assembler</a></li>
+  </ul></li>
+  <li><a name="toc-TinyCC-Linker" href="#linker">5. TinyCC Linker</a>
+  <ul class="toc">
+    <li><a name="toc-ELF-file-generation" href="#ELF-file-generation">5.1 ELF file generation</a></li>
+    <li><a name="toc-ELF-file-loader" href="#ELF-file-loader">5.2 ELF file loader</a></li>
+    <li><a name="toc-PE_002di386-file-generation" href="#PE_002di386-file-generation">5.3 PE-i386 file generation</a></li>
+    <li><a name="toc-GNU-Linker-Scripts" href="#GNU-Linker-Scripts">5.4 GNU Linker Scripts</a></li>
+  </ul></li>
+  <li><a name="toc-TinyCC-Memory-and-Bound-checks" href="#Bounds">6. TinyCC Memory and Bound checks</a></li>
+  <li><a name="toc-The-libtcc-library" href="#Libtcc">7. The <code>libtcc</code> library</a></li>
+  <li><a name="toc-Developer_0027s-guide" href="#devel">8. Developer&rsquo;s guide</a>
+  <ul class="toc">
+    <li><a name="toc-File-reading" href="#File-reading">8.1 File reading</a></li>
+    <li><a name="toc-Lexer" href="#Lexer">8.2 Lexer</a></li>
+    <li><a name="toc-Parser" href="#Parser">8.3 Parser</a></li>
+    <li><a name="toc-Types" href="#Types">8.4 Types</a></li>
+    <li><a name="toc-Symbols" href="#Symbols">8.5 Symbols</a></li>
+    <li><a name="toc-Sections" href="#Sections">8.6 Sections</a></li>
+    <li><a name="toc-Code-generation" href="#Code-generation">8.7 Code generation</a>
+    <ul class="toc">
+      <li><a name="toc-Introduction-2" href="#Introduction-2">8.7.1 Introduction</a></li>
+      <li><a name="toc-The-value-stack" href="#The-value-stack">8.7.2 The value stack</a></li>
+      <li><a name="toc-Manipulating-the-value-stack" href="#Manipulating-the-value-stack">8.7.3 Manipulating the value stack</a></li>
+      <li><a name="toc-CPU-dependent-code-generation" href="#CPU-dependent-code-generation">8.7.4 CPU dependent code generation</a></li>
+    </ul></li>
+    <li><a name="toc-Optimizations-done" href="#Optimizations-done">8.8 Optimizations done</a></li>
+  </ul></li>
+  <li><a name="toc-Concept-Index" href="#Concept-Index">Concept Index</a></li>
+</ul>
+</div>
+<hr size="1">
+<a name="SEC_About"></a>
+<table cellpadding="1" cellspacing="1" border="0">
+<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
+<td valign="middle" align="left">[<a href="#Concept-Index" title="Index">Index</a>]</td>
+<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
+</tr></table>
+<h1>About This Document</h1>
+<p>
+  This document was generated by <em>Thomas Preud'homme</em> on <em>February 15, 2013</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
+</p>
+<p>
+  The buttons in the navigation panels have the following meaning:
+</p>
+<table border="1">
+  <tr>
+    <th> Button </th>
+    <th> Name </th>
+    <th> Go to </th>
+    <th> From 1.2.3 go to</th>
+  </tr>
+  <tr>
+    <td align="center"> [ &lt; ] </td>
+    <td align="center">Back</td>
+    <td>Previous section in reading order</td>
+    <td>1.2.2</td>
+  </tr>
+  <tr>
+    <td align="center"> [ &gt; ] </td>
+    <td align="center">Forward</td>
+    <td>Next section in reading order</td>
+    <td>1.2.4</td>
+  </tr>
+  <tr>
+    <td align="center"> [ &lt;&lt; ] </td>
+    <td align="center">FastBack</td>
+    <td>Beginning of this chapter or previous chapter</td>
+    <td>1</td>
+  </tr>
+  <tr>
+    <td align="center"> [ Up ] </td>
+    <td align="center">Up</td>
+    <td>Up section</td>
+    <td>1.2</td>
+  </tr>
+  <tr>
+    <td align="center"> [ &gt;&gt; ] </td>
+    <td align="center">FastForward</td>
+    <td>Next chapter</td>
+    <td>2</td>
+  </tr>
+  <tr>
+    <td align="center"> [Top] </td>
+    <td align="center">Top</td>
+    <td>Cover (top) of document</td>
+    <td> &nbsp; </td>
+  </tr>
+  <tr>
+    <td align="center"> [Contents] </td>
+    <td align="center">Contents</td>
+    <td>Table of contents</td>
+    <td> &nbsp; </td>
+  </tr>
+  <tr>
+    <td align="center"> [Index] </td>
+    <td align="center">Index</td>
+    <td>Index</td>
+    <td> &nbsp; </td>
+  </tr>
+  <tr>
+    <td align="center"> [ ? ] </td>
+    <td align="center">About</td>
+    <td>About (help)</td>
+    <td> &nbsp; </td>
+  </tr>
+</table>
+
+<p>
+  where the <strong> Example </strong> assumes that the current position is at <strong> Subsubsection One-Two-Three </strong> of a document of the following structure:
+</p>
+
+<ul>
+  <li> 1. Section One
+    <ul>
+      <li>1.1 Subsection One-One
+        <ul>
+          <li>...</li>
+        </ul>
+      </li>
+      <li>1.2 Subsection One-Two
+        <ul>
+          <li>1.2.1 Subsubsection One-Two-One</li>
+          <li>1.2.2 Subsubsection One-Two-Two</li>
+          <li>1.2.3 Subsubsection One-Two-Three &nbsp; &nbsp;
+            <strong>&lt;== Current Position </strong></li>
+          <li>1.2.4 Subsubsection One-Two-Four</li>
+        </ul>
+      </li>
+      <li>1.3 Subsection One-Three
+        <ul>
+          <li>...</li>
+        </ul>
+      </li>
+      <li>1.4 Subsection One-Four</li>
+    </ul>
+  </li>
+</ul>
+
+<hr size="1">
+<p>
+ <font size="-1">
+  This document was generated by <em>Thomas Preud'homme</em> on <em>February 15, 2013</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
+ </font>
+ <br>
+
+</p>
+</body>
+</html>
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tcc-doc.texi
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tcc-doc.texi	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tcc-doc.texi	(revision 279)
@@ -0,0 +1,1268 @@
+\input texinfo @c -*- texinfo -*-
+@c %**start of header
+@setfilename tcc-doc.info
+@settitle Tiny C Compiler Reference Documentation
+@dircategory Software development
+@direntry
+* TCC: (tcc-doc).               The Tiny C Compiler.
+@end direntry
+@c %**end of header
+
+@include config.texi
+
+@iftex
+@titlepage
+@afourpaper
+@sp 7
+@center @titlefont{Tiny C Compiler Reference Documentation}
+@sp 3
+@end titlepage
+@headings double
+@end iftex
+
+@contents
+
+@node Top, Introduction, (dir), (dir)
+@top Tiny C Compiler Reference Documentation
+
+This manual documents version @value{VERSION} of the Tiny C Compiler.
+
+@menu
+* Introduction::                Introduction to tcc.
+* Invoke::                      Invocation of tcc (command line, options).
+* Clang::                       ANSI C and extensions.
+* asm::                         Assembler syntax.
+* linker::                      Output file generation and supported targets.
+* Bounds::                      Automatic bounds-checking of C code.
+* Libtcc::                      The libtcc library.
+* devel::                       Guide for Developers.
+@end menu
+
+
+@node Introduction
+@chapter Introduction
+
+TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
+compilers, it is meant to be self-relying: you do not need an
+external assembler or linker because TCC does that for you.
+
+TCC compiles so @emph{fast} that even for big projects @code{Makefile}s may
+not be necessary.
+
+TCC not only supports ANSI C, but also most of the new ISO C99
+standard and many GNUC extensions including inline assembly.
+
+TCC can also be used to make @emph{C scripts}, i.e. pieces of C source
+that you run as a Perl or Python script. Compilation is so fast that
+your script will be as fast as if it was an executable.
+
+TCC can also automatically generate memory and bound checks
+(@pxref{Bounds}) while allowing all C pointers operations. TCC can do
+these checks even if non patched libraries are used.
+
+With @code{libtcc}, you can use TCC as a backend for dynamic code
+generation (@pxref{Libtcc}).
+
+TCC mainly supports the i386 target on Linux and Windows. There are alpha
+ports for the ARM (@code{arm-tcc}) and the TMS320C67xx targets
+(@code{c67-tcc}). More information about the ARM port is available at
+@url{http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html}.
+
+For usage on Windows, see also @url{tcc-win32.txt}.
+
+@node Invoke
+@chapter Command line invocation
+
+@section Quick start
+
+@example
+@c man begin SYNOPSIS
+usage: tcc [options] [@var{infile1} @var{infile2}@dots{}] [@option{-run} @var{infile} @var{args}@dots{}]
+@c man end
+@end example
+
+@noindent
+@c man begin DESCRIPTION
+TCC options are a very much like gcc options. The main difference is that TCC
+can also execute directly the resulting program and give it runtime
+arguments.
+
+Here are some examples to understand the logic:
+
+@table @code
+@item @samp{tcc -run a.c}
+Compile @file{a.c} and execute it directly
+
+@item @samp{tcc -run a.c arg1}
+Compile a.c and execute it directly. arg1 is given as first argument to
+the @code{main()} of a.c.
+
+@item @samp{tcc a.c -run b.c arg1}
+Compile @file{a.c} and @file{b.c}, link them together and execute them. arg1 is given
+as first argument to the @code{main()} of the resulting program. 
+@ignore 
+Because multiple C files are specified, @option{--} are necessary to clearly 
+separate the program arguments from the TCC options.
+@end ignore
+
+@item @samp{tcc -o myprog a.c b.c}
+Compile @file{a.c} and @file{b.c}, link them and generate the executable @file{myprog}.
+
+@item @samp{tcc -o myprog a.o b.o}
+link @file{a.o} and @file{b.o} together and generate the executable @file{myprog}.
+
+@item @samp{tcc -c a.c}
+Compile @file{a.c} and generate object file @file{a.o}.
+
+@item @samp{tcc -c asmfile.S}
+Preprocess with C preprocess and assemble @file{asmfile.S} and generate
+object file @file{asmfile.o}.
+
+@item @samp{tcc -c asmfile.s}
+Assemble (but not preprocess) @file{asmfile.s} and generate object file
+@file{asmfile.o}.
+
+@item @samp{tcc -r -o ab.o a.c b.c}
+Compile @file{a.c} and @file{b.c}, link them together and generate the object file @file{ab.o}.
+
+@end table
+
+Scripting:
+
+TCC can be invoked from @emph{scripts}, just as shell scripts. You just
+need to add @code{#!/usr/local/bin/tcc -run} at the start of your C source:
+
+@example
+#!/usr/local/bin/tcc -run
+#include <stdio.h>
+
+int main() 
+@{
+    printf("Hello World\n");
+    return 0;
+@}
+@end example
+
+TCC can read C source code from @emph{standard input} when @option{-} is used in 
+place of @option{infile}. Example:
+
+@example
+echo 'main()@{puts("hello");@}' | tcc -run -
+@end example
+@c man end
+
+@section Option summary
+
+General Options:
+
+@c man begin OPTIONS
+@table @option
+@item -c
+Generate an object file.
+
+@item -o outfile
+Put object file, executable, or dll into output file @file{outfile}.
+
+@item -run source [args...]
+Compile file @var{source} and run it with the command line arguments
+@var{args}. In order to be able to give more than one argument to a
+script, several TCC options can be given @emph{after} the
+@option{-run} option, separated by spaces:
+@example
+tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
+@end example
+In a script, it gives the following header:
+@example
+#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
+@end example
+
+@item -dumpversion
+Print only the compiler version and nothing else.
+
+@item -v
+Display TCC version.
+
+@item -vv
+Show included files.  As sole argument, print search dirs (as below).
+
+@item -bench
+Display compilation statistics.
+
+@item -print-search-dirs
+Print the configured installation directory and a list of library
+and include directories tcc will search.
+
+@end table
+
+Preprocessor options:
+
+@table @option
+@item -Idir
+Specify an additional include path. Include paths are searched in the
+order they are specified.
+
+System include paths are always searched after. The default system
+include paths are: @file{/usr/local/include}, @file{/usr/include}
+and @file{PREFIX/lib/tcc/include}. (@file{PREFIX} is usually
+@file{/usr} or @file{/usr/local}).
+
+@item -Dsym[=val]
+Define preprocessor symbol @samp{sym} to
+val. If val is not present, its value is @samp{1}. Function-like macros can
+also be defined: @option{-DF(a)=a+1}
+
+@item -Usym
+Undefine preprocessor symbol @samp{sym}.
+@end table
+
+Compilation flags:
+
+Note: each of the following warning options has a negative form beginning with
+@option{-fno-}.
+
+@table @option
+@item -funsigned-char
+Let the @code{char} type be unsigned.
+
+@item -fsigned-char
+Let the @code{char} type be signed.
+
+@item -fno-common
+Do not generate common symbols for uninitialized data.
+
+@item -fleading-underscore
+Add a leading underscore at the beginning of each C symbol.
+
+@end table
+
+Warning options:
+
+@table @option
+@item -w
+Disable all warnings.
+
+@end table
+
+Note: each of the following warning options has a negative form beginning with
+@option{-Wno-}.
+
+@table @option
+@item -Wimplicit-function-declaration
+Warn about implicit function declaration.
+
+@item -Wunsupported
+Warn about unsupported GCC features that are ignored by TCC.
+
+@item -Wwrite-strings
+Make string constants be of type @code{const char *} instead of @code{char
+*}.
+
+@item -Werror
+Abort compilation if warnings are issued.
+
+@item -Wall 
+Activate all warnings, except @option{-Werror}, @option{-Wunusupported} and
+@option{-Wwrite-strings}.
+
+@end table
+
+Linker options:
+
+@table @option
+@item -Ldir
+Specify an additional static library path for the @option{-l} option. The
+default library paths are @file{/usr/local/lib}, @file{/usr/lib} and @file{/lib}.
+
+@item -lxxx
+Link your program with dynamic library libxxx.so or static library
+libxxx.a. The library is searched in the paths specified by the
+@option{-L} option.
+
+@item -Bdir
+Set the path where the tcc internal libraries (and include files) can be
+found (default is @file{PREFIX/lib/tcc}).
+
+@item -shared
+Generate a shared library instead of an executable.
+
+@item -soname name
+set name for shared library to be used at runtime
+
+@item -static
+Generate a statically linked executable (default is a shared linked
+executable).
+
+@item -rdynamic
+Export global symbols to the dynamic linker. It is useful when a library
+opened with @code{dlopen()} needs to access executable symbols.
+
+@item -r
+Generate an object file combining all input files.
+
+@item -Wl,-rpath=path
+Put custom seatch path for dynamic libraries into executable.
+
+@item -Wl,--oformat=fmt
+Use @var{fmt} as output format. The supported output formats are:
+@table @code
+@item elf32-i386
+ELF output format (default)
+@item binary
+Binary image (only for executable output)
+@item coff
+COFF output format (only for executable output for TMS320C67xx target)
+@end table
+
+@item -Wl,-subsystem=console/gui/wince/...
+Set type for PE (Windows) executables.
+
+@item -Wl,-[Ttext=# | section-alignment=# | file-alignment=# | image-base=# | stack=#]
+Modify executable layout.
+
+@item -Wl,-Bsymbolic
+Set DT_SYMBOLIC tag.
+
+@end table
+
+Debugger options:
+
+@table @option
+@item -g
+Generate run time debug information so that you get clear run time
+error messages: @code{ test.c:68: in function 'test5()': dereferencing
+invalid pointer} instead of the laconic @code{Segmentation
+fault}.
+
+@item -b
+Generate additional support code to check
+memory allocations and array/pointer bounds. @option{-g} is implied. Note
+that the generated code is slower and bigger in this case.
+
+Note: @option{-b} is only available on i386 for the moment.
+
+@item -bt N
+Display N callers in stack traces. This is useful with @option{-g} or
+@option{-b}.
+
+@end table
+
+Misc options:
+
+@table @option
+@item -MD
+Generate makefile fragment with dependencies.
+
+@item -MF depfile
+Use @file{depfile} as output for -MD.
+
+@end table
+
+Note: GCC options @option{-Ox}, @option{-fx} and @option{-mx} are
+ignored.
+@c man end
+
+@ignore
+
+@setfilename tcc
+@settitle Tiny C Compiler
+
+@c man begin SEEALSO
+gcc(1)
+@c man end
+
+@c man begin AUTHOR
+Fabrice Bellard
+@c man end
+
+@end ignore
+
+@node Clang
+@chapter C language support
+
+@section ANSI C
+
+TCC implements all the ANSI C standard, including structure bit fields
+and floating point numbers (@code{long double}, @code{double}, and
+@code{float} fully supported).
+
+@section ISOC99 extensions
+
+TCC implements many features of the new C standard: ISO C99. Currently
+missing items are: complex and imaginary numbers and variable length
+arrays.
+
+Currently implemented ISOC99 features:
+
+@itemize
+
+@item 64 bit @code{long long} types are fully supported.
+
+@item The boolean type @code{_Bool} is supported.
+
+@item @code{__func__} is a string variable containing the current
+function name.
+
+@item Variadic macros: @code{__VA_ARGS__} can be used for
+   function-like macros:
+@example
+    #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)
+@end example
+
+@noindent
+@code{dprintf} can then be used with a variable number of parameters.
+
+@item Declarations can appear anywhere in a block (as in C++).
+
+@item Array and struct/union elements can be initialized in any order by
+  using designators:
+@example
+    struct @{ int x, y; @} st[10] = @{ [0].x = 1, [0].y = 2 @};
+
+    int tab[10] = @{ 1, 2, [5] = 5, [9] = 9@};
+@end example
+    
+@item Compound initializers are supported:
+@example
+    int *p = (int [])@{ 1, 2, 3 @};
+@end example
+to initialize a pointer pointing to an initialized array. The same
+works for structures and strings.
+
+@item Hexadecimal floating point constants are supported:
+@example
+          double d = 0x1234p10;
+@end example
+
+@noindent
+is the same as writing 
+@example
+          double d = 4771840.0;
+@end example
+
+@item @code{inline} keyword is ignored.
+
+@item @code{restrict} keyword is ignored.
+@end itemize
+
+@section GNU C extensions
+
+TCC implements some GNU C extensions:
+
+@itemize
+
+@item array designators can be used without '=': 
+@example
+    int a[10] = @{ [0] 1, [5] 2, 3, 4 @};
+@end example
+
+@item Structure field designators can be a label: 
+@example
+    struct @{ int x, y; @} st = @{ x: 1, y: 1@};
+@end example
+instead of
+@example
+    struct @{ int x, y; @} st = @{ .x = 1, .y = 1@};
+@end example
+
+@item @code{\e} is ASCII character 27.
+
+@item case ranges : ranges can be used in @code{case}s:
+@example
+    switch(a) @{
+    case 1 @dots{} 9:
+          printf("range 1 to 9\n");
+          break;
+    default:
+          printf("unexpected\n");
+          break;
+    @}
+@end example
+
+@cindex aligned attribute
+@cindex packed attribute
+@cindex section attribute
+@cindex unused attribute
+@cindex cdecl attribute
+@cindex stdcall attribute
+@cindex regparm attribute
+@cindex dllexport attribute
+
+@item The keyword @code{__attribute__} is handled to specify variable or
+function attributes. The following attributes are supported:
+  @itemize
+
+  @item @code{aligned(n)}: align a variable or a structure field to n bytes
+(must be a power of two).
+
+  @item @code{packed}: force alignment of a variable or a structure field to
+  1.
+
+  @item @code{section(name)}: generate function or data in assembly section
+name (name is a string containing the section name) instead of the default
+section.
+
+  @item @code{unused}: specify that the variable or the function is unused.
+
+  @item @code{cdecl}: use standard C calling convention (default).
+
+  @item @code{stdcall}: use Pascal-like calling convention.
+
+  @item @code{regparm(n)}: use fast i386 calling convention. @var{n} must be
+between 1 and 3. The first @var{n} function parameters are respectively put in
+registers @code{%eax}, @code{%edx} and @code{%ecx}.
+
+  @item @code{dllexport}: export function from dll/executable (win32 only)
+
+  @end itemize
+
+Here are some examples:
+@example
+    int a __attribute__ ((aligned(8), section(".mysection")));
+@end example
+
+@noindent
+align variable @code{a} to 8 bytes and put it in section @code{.mysection}.
+
+@example
+    int my_add(int a, int b) __attribute__ ((section(".mycodesection"))) 
+    @{
+        return a + b;
+    @}
+@end example
+
+@noindent
+generate function @code{my_add} in section @code{.mycodesection}.
+
+@item GNU style variadic macros:
+@example
+    #define dprintf(fmt, args@dots{}) printf(fmt, ## args)
+
+    dprintf("no arg\n");
+    dprintf("one arg %d\n", 1);
+@end example
+
+@item @code{__FUNCTION__} is interpreted as C99 @code{__func__} 
+(so it has not exactly the same semantics as string literal GNUC
+where it is a string literal).
+
+@item The @code{__alignof__} keyword can be used as @code{sizeof} 
+to get the alignment of a type or an expression.
+
+@item The @code{typeof(x)} returns the type of @code{x}. 
+@code{x} is an expression or a type.
+
+@item Computed gotos: @code{&&label} returns a pointer of type 
+@code{void *} on the goto label @code{label}. @code{goto *expr} can be
+used to jump on the pointer resulting from @code{expr}.
+
+@item Inline assembly with asm instruction:
+@cindex inline assembly
+@cindex assembly, inline
+@cindex __asm__
+@example
+static inline void * my_memcpy(void * to, const void * from, size_t n)
+@{
+int d0, d1, d2;
+__asm__ __volatile__(
+        "rep ; movsl\n\t"
+        "testb $2,%b4\n\t"
+        "je 1f\n\t"
+        "movsw\n"
+        "1:\ttestb $1,%b4\n\t"
+        "je 2f\n\t"
+        "movsb\n"
+        "2:"
+        : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+        :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+        : "memory");
+return (to);
+@}
+@end example
+
+@noindent
+@cindex gas
+TCC includes its own x86 inline assembler with a @code{gas}-like (GNU
+assembler) syntax. No intermediate files are generated. GCC 3.x named
+operands are supported.
+
+@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()} 
+are supported.
+
+@item @code{#pragma pack} is supported for win32 compatibility.
+
+@end itemize
+
+@section TinyCC extensions
+
+@itemize
+
+@item @code{__TINYC__} is a predefined macro to @code{1} to
+indicate that you use TCC.
+
+@item @code{#!} at the start of a line is ignored to allow scripting.
+
+@item Binary digits can be entered (@code{0b101} instead of
+@code{5}).
+
+@item @code{__BOUNDS_CHECKING_ON} is defined if bound checking is activated.
+
+@end itemize
+
+@node asm
+@chapter TinyCC Assembler
+
+Since version 0.9.16, TinyCC integrates its own assembler. TinyCC
+assembler supports a gas-like syntax (GNU assembler). You can
+desactivate assembler support if you want a smaller TinyCC executable
+(the C compiler does not rely on the assembler).
+
+TinyCC Assembler is used to handle files with @file{.S} (C
+preprocessed assembler) and @file{.s} extensions. It is also used to
+handle the GNU inline assembler with the @code{asm} keyword.
+
+@section Syntax
+
+TinyCC Assembler supports most of the gas syntax. The tokens are the
+same as C.
+
+@itemize
+
+@item C and C++ comments are supported.
+
+@item Identifiers are the same as C, so you cannot use '.' or '$'.
+
+@item Only 32 bit integer numbers are supported.
+
+@end itemize
+
+@section Expressions
+
+@itemize
+
+@item Integers in decimal, octal and hexa are supported.
+
+@item Unary operators: +, -, ~.
+
+@item Binary operators in decreasing priority order:
+
+@enumerate
+@item *, /, %
+@item &, |, ^
+@item +, -
+@end enumerate
+
+@item A value is either an absolute number or a label plus an offset. 
+All operators accept absolute values except '+' and '-'. '+' or '-' can be
+used to add an offset to a label. '-' supports two labels only if they
+are the same or if they are both defined and in the same section.
+
+@end itemize
+
+@section Labels
+
+@itemize
+
+@item All labels are considered as local, except undefined ones.
+
+@item Numeric labels can be used as local @code{gas}-like labels. 
+They can be defined several times in the same source. Use 'b'
+(backward) or 'f' (forward) as suffix to reference them:
+
+@example
+ 1:
+      jmp 1b /* jump to '1' label before */
+      jmp 1f /* jump to '1' label after */
+ 1:
+@end example
+
+@end itemize
+
+@section Directives
+@cindex assembler directives
+@cindex directives, assembler
+@cindex align directive
+@cindex skip directive
+@cindex space directive
+@cindex byte directive
+@cindex word directive
+@cindex short directive
+@cindex int directive
+@cindex long directive
+@cindex quad directive
+@cindex globl directive
+@cindex global directive
+@cindex section directive
+@cindex text directive
+@cindex data directive
+@cindex bss directive
+@cindex fill directive
+@cindex org directive
+@cindex previous directive
+@cindex string directive
+@cindex asciz directive
+@cindex ascii directive
+
+All directives are preceeded by a '.'. The following directives are
+supported:
+
+@itemize
+@item .align n[,value]
+@item .skip n[,value]
+@item .space n[,value]
+@item .byte value1[,...]
+@item .word value1[,...]
+@item .short value1[,...]
+@item .int value1[,...]
+@item .long value1[,...]
+@item .quad immediate_value1[,...]
+@item .globl symbol
+@item .global symbol
+@item .section section
+@item .text
+@item .data
+@item .bss
+@item .fill repeat[,size[,value]]
+@item .org n
+@item .previous
+@item .string string[,...]
+@item .asciz string[,...]
+@item .ascii string[,...]
+@end itemize
+
+@section X86 Assembler
+@cindex assembler
+
+All X86 opcodes are supported. Only ATT syntax is supported (source
+then destination operand order). If no size suffix is given, TinyCC
+tries to guess it from the operand sizes.
+
+Currently, MMX opcodes are supported but not SSE ones.
+
+@node linker
+@chapter TinyCC Linker
+@cindex linker
+
+@section ELF file generation
+@cindex ELF
+
+TCC can directly output relocatable ELF files (object files),
+executable ELF files and dynamic ELF libraries without relying on an
+external linker.
+
+Dynamic ELF libraries can be output but the C compiler does not generate
+position independent code (PIC). It means that the dynamic library
+code generated by TCC cannot be factorized among processes yet.
+
+TCC linker eliminates unreferenced object code in libraries. A single pass is
+done on the object and library list, so the order in which object files and
+libraries are specified is important (same constraint as GNU ld). No grouping
+options (@option{--start-group} and @option{--end-group}) are supported.
+
+@section ELF file loader
+
+TCC can load ELF object files, archives (.a files) and dynamic
+libraries (.so).
+
+@section PE-i386 file generation
+@cindex PE-i386
+
+TCC for Windows supports the native Win32 executable file format (PE-i386).  It
+generates EXE files (console and gui) and DLL files.
+
+For usage on Windows, see also tcc-win32.txt.
+
+@section GNU Linker Scripts
+@cindex scripts, linker
+@cindex linker scripts
+@cindex GROUP, linker command
+@cindex FILE, linker command
+@cindex OUTPUT_FORMAT, linker command
+@cindex TARGET, linker command
+
+Because on many Linux systems some dynamic libraries (such as
+@file{/usr/lib/libc.so}) are in fact GNU ld link scripts (horrible!),
+the TCC linker also supports a subset of GNU ld scripts.
+
+The @code{GROUP} and @code{FILE} commands are supported. @code{OUTPUT_FORMAT}
+and @code{TARGET} are ignored.
+
+Example from @file{/usr/lib/libc.so}:
+@example
+/* GNU ld script
+   Use the shared library, but some functions are only in
+   the static library, so try that secondarily.  */
+GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
+@end example
+
+@node Bounds
+@chapter TinyCC Memory and Bound checks
+@cindex bound checks
+@cindex memory checks
+
+This feature is activated with the @option{-b} (@pxref{Invoke}).
+
+Note that pointer size is @emph{unchanged} and that code generated
+with bound checks is @emph{fully compatible} with unchecked
+code. When a pointer comes from unchecked code, it is assumed to be
+valid. Even very obscure C code with casts should work correctly.
+
+For more information about the ideas behind this method, see
+@url{http://www.doc.ic.ac.uk/~phjk/BoundsChecking.html}.
+
+Here are some examples of caught errors:
+
+@table @asis
+
+@item Invalid range with standard string function:
+@example
+@{
+    char tab[10];
+    memset(tab, 0, 11);
+@}
+@end example
+
+@item Out of bounds-error in global or local arrays:
+@example
+@{
+    int tab[10];
+    for(i=0;i<11;i++) @{
+        sum += tab[i];
+    @}
+@}
+@end example
+
+@item Out of bounds-error in malloc'ed data:
+@example
+@{
+    int *tab;
+    tab = malloc(20 * sizeof(int));
+    for(i=0;i<21;i++) @{
+        sum += tab4[i];
+    @}
+    free(tab);
+@}
+@end example
+
+@item Access of freed memory:
+@example
+@{
+    int *tab;
+    tab = malloc(20 * sizeof(int));
+    free(tab);
+    for(i=0;i<20;i++) @{
+        sum += tab4[i];
+    @}
+@}
+@end example
+
+@item Double free:
+@example
+@{
+    int *tab;
+    tab = malloc(20 * sizeof(int));
+    free(tab);
+    free(tab);
+@}
+@end example
+
+@end table
+
+@node Libtcc
+@chapter The @code{libtcc} library
+
+The @code{libtcc} library enables you to use TCC as a backend for
+dynamic code generation. 
+
+Read the @file{libtcc.h} to have an overview of the API. Read
+@file{libtcc_test.c} to have a very simple example.
+
+The idea consists in giving a C string containing the program you want
+to compile directly to @code{libtcc}. Then you can access to any global
+symbol (function or variable) defined.
+
+@node devel
+@chapter Developer's guide
+
+This chapter gives some hints to understand how TCC works. You can skip
+it if you do not intend to modify the TCC code.
+
+@section File reading
+
+The @code{BufferedFile} structure contains the context needed to read a
+file, including the current line number. @code{tcc_open()} opens a new
+file and @code{tcc_close()} closes it. @code{inp()} returns the next
+character.
+
+@section Lexer
+
+@code{next()} reads the next token in the current
+file. @code{next_nomacro()} reads the next token without macro
+expansion.
+
+@code{tok} contains the current token (see @code{TOK_xxx})
+constants. Identifiers and keywords are also keywords. @code{tokc}
+contains additional infos about the token (for example a constant value
+if number or string token).
+
+@section Parser
+
+The parser is hardcoded (yacc is not necessary). It does only one pass,
+except:
+
+@itemize
+
+@item For initialized arrays with unknown size, a first pass 
+is done to count the number of elements.
+
+@item For architectures where arguments are evaluated in 
+reverse order, a first pass is done to reverse the argument order.
+
+@end itemize
+
+@section Types
+
+The types are stored in a single 'int' variable. It was choosen in the
+first stages of development when tcc was much simpler. Now, it may not
+be the best solution.
+
+@example
+#define VT_INT        0  /* integer type */
+#define VT_BYTE       1  /* signed byte type */
+#define VT_SHORT      2  /* short type */
+#define VT_VOID       3  /* void type */
+#define VT_PTR        4  /* pointer */
+#define VT_ENUM       5  /* enum definition */
+#define VT_FUNC       6  /* function type */
+#define VT_STRUCT     7  /* struct/union definition */
+#define VT_FLOAT      8  /* IEEE float */
+#define VT_DOUBLE     9  /* IEEE double */
+#define VT_LDOUBLE   10  /* IEEE long double */
+#define VT_BOOL      11  /* ISOC99 boolean type */
+#define VT_LLONG     12  /* 64 bit integer */
+#define VT_LONG      13  /* long integer (NEVER USED as type, only
+                            during parsing) */
+#define VT_BTYPE      0x000f /* mask for basic type */
+#define VT_UNSIGNED   0x0010  /* unsigned type */
+#define VT_ARRAY      0x0020  /* array type (also has VT_PTR) */
+#define VT_VLA        0x20000 /* VLA type (also has VT_PTR and VT_ARRAY) */
+#define VT_BITFIELD   0x0040  /* bitfield modifier */
+#define VT_CONSTANT   0x0800  /* const modifier */
+#define VT_VOLATILE   0x1000  /* volatile modifier */
+#define VT_SIGNED     0x2000  /* signed type */
+
+#define VT_STRUCT_SHIFT 18   /* structure/enum name shift (14 bits left) */
+@end example
+
+When a reference to another type is needed (for pointers, functions and
+structures), the @code{32 - VT_STRUCT_SHIFT} high order bits are used to
+store an identifier reference.
+
+The @code{VT_UNSIGNED} flag can be set for chars, shorts, ints and long
+longs.
+
+Arrays are considered as pointers @code{VT_PTR} with the flag
+@code{VT_ARRAY} set. Variable length arrays are considered as special
+arrays and have flag @code{VT_VLA} set instead of @code{VT_ARRAY}.
+
+The @code{VT_BITFIELD} flag can be set for chars, shorts, ints and long
+longs. If it is set, then the bitfield position is stored from bits
+VT_STRUCT_SHIFT to VT_STRUCT_SHIFT + 5 and the bit field size is stored
+from bits VT_STRUCT_SHIFT + 6 to VT_STRUCT_SHIFT + 11.
+
+@code{VT_LONG} is never used except during parsing.
+
+During parsing, the storage of an object is also stored in the type
+integer:
+
+@example
+#define VT_EXTERN  0x00000080  /* extern definition */
+#define VT_STATIC  0x00000100  /* static variable */
+#define VT_TYPEDEF 0x00000200  /* typedef definition */
+#define VT_INLINE  0x00000400  /* inline definition */
+#define VT_IMPORT  0x00004000  /* win32: extern data imported from dll */
+#define VT_EXPORT  0x00008000  /* win32: data exported from dll */
+#define VT_WEAK    0x00010000  /* win32: data exported from dll */
+@end example
+
+@section Symbols
+
+All symbols are stored in hashed symbol stacks. Each symbol stack
+contains @code{Sym} structures.
+
+@code{Sym.v} contains the symbol name (remember
+an idenfier is also a token, so a string is never necessary to store
+it). @code{Sym.t} gives the type of the symbol. @code{Sym.r} is usually
+the register in which the corresponding variable is stored. @code{Sym.c} is
+usually a constant associated to the symbol like its address for normal
+symbols, and the number of entries for symbols representing arrays.
+Variable length array types use @code{Sym.c} as a location on the stack
+which holds the runtime sizeof for the type.
+
+Four main symbol stacks are defined:
+
+@table @code
+
+@item define_stack
+for the macros (@code{#define}s).
+
+@item global_stack
+for the global variables, functions and types.
+
+@item local_stack
+for the local variables, functions and types.
+
+@item global_label_stack
+for the local labels (for @code{goto}).
+
+@item label_stack
+for GCC block local labels (see the @code{__label__} keyword).
+
+@end table
+
+@code{sym_push()} is used to add a new symbol in the local symbol
+stack. If no local symbol stack is active, it is added in the global
+symbol stack.
+
+@code{sym_pop(st,b)} pops symbols from the symbol stack @var{st} until
+the symbol @var{b} is on the top of stack. If @var{b} is NULL, the stack
+is emptied.
+
+@code{sym_find(v)} return the symbol associated to the identifier
+@var{v}. The local stack is searched first from top to bottom, then the
+global stack.
+
+@section Sections
+
+The generated code and datas are written in sections. The structure
+@code{Section} contains all the necessary information for a given
+section. @code{new_section()} creates a new section. ELF file semantics
+is assumed for each section.
+
+The following sections are predefined:
+
+@table @code
+
+@item text_section
+is the section containing the generated code. @var{ind} contains the
+current position in the code section.
+
+@item data_section
+contains initialized data
+
+@item bss_section
+contains uninitialized data
+
+@item bounds_section
+@itemx lbounds_section
+are used when bound checking is activated
+
+@item stab_section
+@itemx stabstr_section
+are used when debugging is actived to store debug information
+
+@item symtab_section
+@itemx strtab_section
+contain the exported symbols (currently only used for debugging).
+
+@end table
+
+@section Code generation
+@cindex code generation
+
+@subsection Introduction
+
+The TCC code generator directly generates linked binary code in one
+pass. It is rather unusual these days (see gcc for example which
+generates text assembly), but it can be very fast and surprisingly
+little complicated.
+
+The TCC code generator is register based. Optimization is only done at
+the expression level. No intermediate representation of expression is
+kept except the current values stored in the @emph{value stack}.
+
+On x86, three temporary registers are used. When more registers are
+needed, one register is spilled into a new temporary variable on the stack.
+
+@subsection The value stack
+@cindex value stack, introduction
+
+When an expression is parsed, its value is pushed on the value stack
+(@var{vstack}). The top of the value stack is @var{vtop}. Each value
+stack entry is the structure @code{SValue}.
+
+@code{SValue.t} is the type. @code{SValue.r} indicates how the value is
+currently stored in the generated code. It is usually a CPU register
+index (@code{REG_xxx} constants), but additional values and flags are
+defined:
+
+@example
+#define VT_CONST     0x00f0
+#define VT_LLOCAL    0x00f1
+#define VT_LOCAL     0x00f2
+#define VT_CMP       0x00f3
+#define VT_JMP       0x00f4
+#define VT_JMPI      0x00f5
+#define VT_LVAL      0x0100
+#define VT_SYM       0x0200
+#define VT_MUSTCAST  0x0400
+#define VT_MUSTBOUND 0x0800
+#define VT_BOUNDED   0x8000
+#define VT_LVAL_BYTE     0x1000
+#define VT_LVAL_SHORT    0x2000
+#define VT_LVAL_UNSIGNED 0x4000
+#define VT_LVAL_TYPE     (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
+@end example
+
+@table @code
+
+@item VT_CONST
+indicates that the value is a constant. It is stored in the union
+@code{SValue.c}, depending on its type.
+
+@item VT_LOCAL
+indicates a local variable pointer at offset @code{SValue.c.i} in the
+stack.
+
+@item VT_CMP
+indicates that the value is actually stored in the CPU flags (i.e. the
+value is the consequence of a test). The value is either 0 or 1. The
+actual CPU flags used is indicated in @code{SValue.c.i}. 
+
+If any code is generated which destroys the CPU flags, this value MUST be
+put in a normal register.
+
+@item VT_JMP
+@itemx VT_JMPI
+indicates that the value is the consequence of a conditional jump. For VT_JMP,
+it is 1 if the jump is taken, 0 otherwise. For VT_JMPI it is inverted.
+
+These values are used to compile the @code{||} and @code{&&} logical
+operators.
+
+If any code is generated, this value MUST be put in a normal
+register. Otherwise, the generated code won't be executed if the jump is
+taken.
+
+@item VT_LVAL
+is a flag indicating that the value is actually an lvalue (left value of
+an assignment). It means that the value stored is actually a pointer to
+the wanted value. 
+
+Understanding the use @code{VT_LVAL} is very important if you want to
+understand how TCC works.
+
+@item VT_LVAL_BYTE
+@itemx VT_LVAL_SHORT
+@itemx VT_LVAL_UNSIGNED
+if the lvalue has an integer type, then these flags give its real
+type. The type alone is not enough in case of cast optimisations.
+
+@item VT_LLOCAL
+is a saved lvalue on the stack. @code{VT_LLOCAL} should be eliminated
+ASAP because its semantics are rather complicated.
+
+@item VT_MUSTCAST
+indicates that a cast to the value type must be performed if the value
+is used (lazy casting).
+
+@item VT_SYM
+indicates that the symbol @code{SValue.sym} must be added to the constant.
+
+@item VT_MUSTBOUND
+@itemx VT_BOUNDED
+are only used for optional bound checking.
+
+@end table
+
+@subsection Manipulating the value stack
+@cindex value stack
+
+@code{vsetc()} and @code{vset()} pushes a new value on the value
+stack. If the previous @var{vtop} was stored in a very unsafe place(for
+example in the CPU flags), then some code is generated to put the
+previous @var{vtop} in a safe storage.
+
+@code{vpop()} pops @var{vtop}. In some cases, it also generates cleanup
+code (for example if stacked floating point registers are used as on
+x86).
+
+The @code{gv(rc)} function generates code to evaluate @var{vtop} (the
+top value of the stack) into registers. @var{rc} selects in which
+register class the value should be put. @code{gv()} is the @emph{most
+important function} of the code generator.
+
+@code{gv2()} is the same as @code{gv()} but for the top two stack
+entries.
+
+@subsection CPU dependent code generation
+@cindex CPU dependent
+See the @file{i386-gen.c} file to have an example.
+
+@table @code
+
+@item load()
+must generate the code needed to load a stack value into a register.
+
+@item store()
+must generate the code needed to store a register into a stack value
+lvalue.
+
+@item gfunc_start()
+@itemx gfunc_param()
+@itemx gfunc_call()
+should generate a function call
+
+@item gfunc_prolog()
+@itemx gfunc_epilog()
+should generate a function prolog/epilog.
+
+@item gen_opi(op)
+must generate the binary integer operation @var{op} on the two top
+entries of the stack which are guaranted to contain integer types.
+
+The result value should be put on the stack.
+
+@item gen_opf(op)
+same as @code{gen_opi()} for floating point operations. The two top
+entries of the stack are guaranted to contain floating point values of
+same types.
+
+@item gen_cvt_itof()
+integer to floating point conversion.
+
+@item gen_cvt_ftoi()
+floating point to integer conversion.
+
+@item gen_cvt_ftof()
+floating point to floating point of different size conversion.
+
+@item gen_bounded_ptr_add()
+@item gen_bounded_ptr_deref()
+are only used for bounds checking.
+
+@end table
+
+@section Optimizations done
+@cindex optimizations
+@cindex constant propagation
+@cindex strength reduction
+@cindex comparison operators
+@cindex caching processor flags
+@cindex flags, caching
+@cindex jump optimization
+Constant propagation is done for all operations. Multiplications and
+divisions are optimized to shifts when appropriate. Comparison
+operators are optimized by maintaining a special cache for the
+processor flags. &&, || and ! are optimized by maintaining a special
+'jump target' value. No other jump optimization is currently performed
+because it would require to store the code in a more abstract fashion.
+
+@unnumbered Concept Index
+@printindex cp
+
+@bye
+
+@c Local variables:
+@c fill-column: 78
+@c texinfo-column-for-description: 32
+@c End:
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tcc.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tcc.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tcc.c	(revision 279)
@@ -0,0 +1,352 @@
+/*
+ *  TCC - Tiny C Compiler
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef ONE_SOURCE
+#include "libtcc.c"
+#else
+#include "tcc.h"
+#endif
+
+static void help(void)
+{
+    printf("tcc version " TCC_VERSION " - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\n"
+           "Usage: tcc [options...] [-o outfile] [-c] infile(s)...\n"
+           "       tcc [options...] -run infile [arguments...]\n"
+           "General options:\n"
+           "  -c          compile only - generate an object file\n"
+           "  -o outfile  set output filename\n"
+           "  -run        run compiled source\n"
+           "  -fflag      set or reset (with 'no-' prefix) 'flag' (see man page)\n"
+           "  -Wwarning   set or reset (with 'no-' prefix) 'warning' (see man page)\n"
+           "  -w          disable all warnings\n"
+           "  -v          show version\n"
+           "  -vv         show included files (as sole argument: show search paths)\n"
+           "  -dumpversion\n"
+           "  -bench      show compilation statistics\n"
+           "Preprocessor options:\n"
+           "  -E          preprocess only\n"
+           "  -Idir       add include path 'dir'\n"
+           "  -Dsym[=val] define 'sym' with value 'val'\n"
+           "  -Usym       undefine 'sym'\n"
+           "Linker options:\n"
+           "  -Ldir       add library path 'dir'\n"
+           "  -llib       link with dynamic or static library 'lib'\n"
+           "  -pthread    link with -lpthread and -D_REENTRANT (POSIX Linux)\n"
+           "  -r          generate (relocatable) object file\n"
+           "  -rdynamic   export all global symbols to dynamic linker\n"
+           "  -shared     generate a shared library\n"
+           "  -soname     set name for shared library to be used at runtime\n"
+           "  -static     static linking\n"
+           "  -Wl,-opt[=val]  set linker option (see manual)\n"
+           "Debugger options:\n"
+           "  -g          generate runtime debug info\n"
+#ifdef CONFIG_TCC_BCHECK
+           "  -b          compile with built-in memory and bounds checker (implies -g)\n"
+#endif
+#ifdef CONFIG_TCC_BACKTRACE
+           "  -bt N       show N callers in stack traces\n"
+#endif
+           "Misc options:\n"
+           "  -nostdinc   do not use standard system include paths\n"
+           "  -nostdlib   do not link with standard crt and libraries\n"
+           "  -Bdir       use 'dir' as tcc internal library and include path\n"
+           "  -MD         generate target dependencies for make\n"
+           "  -MF depfile put generated dependencies here\n"
+           );
+}
+
+/* re-execute the i386/x86_64 cross-compilers with tcc -m32/-m64: */
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+#ifdef _WIN32
+#include <process.h>
+static int execvp_win32(const char *prog, char **argv)
+{
+    int ret = spawnvp(P_NOWAIT, prog, (char const*const*)argv);
+    if (-1 == ret)
+        return ret;
+    cwait(&ret, ret, WAIT_CHILD);
+    exit(ret);
+}
+#define execvp execvp_win32
+#endif
+static void exec_other_tcc(TCCState *s, char **argv, const char *optarg)
+{
+    char child_path[4096], *child_name; const char *target;
+    switch (atoi(optarg)) {
+#ifdef TCC_TARGET_I386
+        case 32: break;
+        case 64: target = "x86_64";
+#else
+        case 64: break;
+        case 32: target = "i386";
+#endif
+            pstrcpy(child_path, sizeof child_path - 40, argv[0]);
+            child_name = tcc_basename(child_path);
+            strcpy(child_name, target);
+#ifdef TCC_TARGET_PE
+            strcat(child_name, "-win32");
+#endif
+            strcat(child_name, "-tcc");
+            if (strcmp(argv[0], child_path)) {
+                if (s->verbose > 0)
+                    printf("tcc: using '%s'\n", child_name), fflush(stdout);
+                execvp(argv[0] = child_path, argv);
+            }
+            tcc_error("'%s' not found", child_name);
+        case 0: /* ignore -march etc. */
+            break;
+        default:
+            tcc_warning("unsupported option \"-m%s\"", optarg);
+    }
+}
+#else
+#define exec_other_tcc(s, argv, optarg)
+#endif
+
+static void gen_makedeps(TCCState *s, const char *target, const char *filename)
+{
+    FILE *depout;
+    char buf[1024], *ext;
+    int i;
+
+    if (!filename) {
+        /* compute filename automatically
+         * dir/file.o -> dir/file.d             */
+        pstrcpy(buf, sizeof(buf), target);
+        ext = tcc_fileextension(buf);
+        pstrcpy(ext, sizeof(buf) - (ext-buf), ".d");
+        filename = buf;
+    }
+
+    if (s->verbose)
+        printf("<- %s\n", filename);
+
+    /* XXX return err codes instead of error() ? */
+    depout = fopen(filename, "w");
+    if (!depout)
+        tcc_error("could not open '%s'", filename);
+
+    fprintf(depout, "%s : \\\n", target);
+    for (i=0; i<s->nb_target_deps; ++i)
+        fprintf(depout, " %s \\\n", s->target_deps[i]);
+    fprintf(depout, "\n");
+    fclose(depout);
+}
+
+static char *default_outputfile(TCCState *s, const char *first_file)
+{
+    char buf[1024];
+    char *ext;
+    const char *name = "a";
+
+    if (first_file && strcmp(first_file, "-"))
+        name = tcc_basename(first_file);
+    pstrcpy(buf, sizeof(buf), name);
+    ext = tcc_fileextension(buf);
+#ifdef TCC_TARGET_PE
+    if (s->output_type == TCC_OUTPUT_DLL)
+        strcpy(ext, ".dll");
+    else
+    if (s->output_type == TCC_OUTPUT_EXE)
+        strcpy(ext, ".exe");
+    else
+#endif
+    if (( (s->output_type == TCC_OUTPUT_OBJ && !s->option_r) ||
+          (s->output_type == TCC_OUTPUT_PREPROCESS) )
+        && *ext)
+        strcpy(ext, ".o");
+    else
+        strcpy(buf, "a.out");
+
+    return tcc_strdup(buf);
+}
+
+static void print_paths(const char *msg, char **paths, int nb_paths)
+{
+    int i;
+    printf("%s:\n%s", msg, nb_paths ? "" : "  -\n");
+    for(i = 0; i < nb_paths; i++)
+        printf("  %s\n", paths[i]);
+}
+
+static void display_info(TCCState *s, int what)
+{
+    switch (what) {
+    case 0:
+        printf("tcc version %s ("
+#ifdef TCC_TARGET_I386
+        "i386"
+# ifdef TCC_TARGET_PE
+        " Win32"
+# endif
+#elif defined TCC_TARGET_X86_64
+        "x86-64"
+# ifdef TCC_TARGET_PE
+        " Win64"
+# endif
+#elif defined TCC_TARGET_ARM
+        "ARM"
+# ifdef TCC_ARM_HARDFLOAT
+        " Hard Float"
+# endif
+# ifdef TCC_TARGET_PE
+        " WinCE"
+# endif
+#endif
+#ifndef TCC_TARGET_PE
+# ifdef __linux
+        " Linux"
+# endif
+#endif
+        ")\n", TCC_VERSION);
+        break;
+    case 1:
+        printf("install: %s/\n", s->tcc_lib_path);
+        /* print_paths("programs", NULL, 0); */
+        print_paths("crt", s->crt_paths, s->nb_crt_paths);
+        print_paths("libraries", s->library_paths, s->nb_library_paths);
+        print_paths("include", s->sysinclude_paths, s->nb_sysinclude_paths);
+        printf("elfinterp:\n  %s\n",  CONFIG_TCC_ELFINTERP);
+        break;
+    }
+}
+
+static int64_t getclock_us(void)
+{
+#if 0//def _WIN32
+    struct _timeb tb;
+    _ftime(&tb);
+    return (tb.time * 1000LL + tb.millitm) * 1000LL;
+#else
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    return tv.tv_sec * 1000000LL + tv.tv_usec;
+#endif
+}
+
+int tcc_main(int argc, char **argv)
+{
+    TCCState *s;
+    int ret, optind, i, bench;
+    int64_t start_time = 0;
+    const char *first_file = NULL;
+
+    s = tcc_new();
+    s->output_type = TCC_OUTPUT_EXE;
+
+    optind = tcc_parse_args(s, argc - 1, argv + 1);
+
+    if (optind == 0) {
+        help();
+        return 1;
+    }
+
+    if (s->option_m)
+        exec_other_tcc(s, argv, s->option_m);
+
+    if (s->verbose)
+        display_info(s, 0);
+
+    if (s->print_search_dirs || (s->verbose == 2 && optind == 1)) {
+        tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
+        display_info(s, 1);
+        return 0;
+    }
+
+    if (s->verbose && optind == 1)
+        return 0;
+
+    if (s->nb_files == 0)
+        tcc_error("no input files\n");
+
+    /* check -c consistency : only single file handled. XXX: checks file type */
+    if (s->output_type == TCC_OUTPUT_OBJ && !s->option_r) {
+        if (s->nb_libraries != 0)
+            tcc_error("cannot specify libraries with -c");
+        /* accepts only a single input file */
+        if (s->nb_files != 1)
+            tcc_error("cannot specify multiple files with -c");
+    }
+    
+    if (s->output_type == TCC_OUTPUT_PREPROCESS) {
+        if (!s->outfile) {
+            s->ppfp = stdout;
+        } else {
+            s->ppfp = fopen(s->outfile, "w");
+            if (!s->ppfp)
+                tcc_error("could not write '%s'", s->outfile);
+        }
+    }
+
+    bench = s->do_bench;
+    if (bench)
+        start_time = getclock_us();
+
+    tcc_set_output_type(s, s->output_type);
+
+    /* compile or add each files or library */
+    for(i = ret = 0; i < s->nb_files && ret == 0; i++) {
+        const char *filename;
+
+        filename = s->files[i];
+        if (filename[0] == '-' && filename[1] == 'l') {
+            if (tcc_add_library(s, filename + 2) < 0) {
+                tcc_error_noabort("cannot find '%s'", filename);
+                ret = 1;
+            }
+        } else {
+            if (1 == s->verbose)
+                printf("-> %s\n", filename);
+            if (tcc_add_file(s, filename) < 0)
+                ret = 1;
+            if (!first_file)
+                first_file = filename;
+        }
+    }
+
+    if (0 == ret) {
+        if (bench)
+            tcc_print_stats(s, getclock_us() - start_time);
+
+        if (s->output_type == TCC_OUTPUT_MEMORY) {
+#ifdef TCC_IS_NATIVE
+            ret = tcc_run(s, argc - 1 - optind, argv + 1 + optind);
+#else
+            tcc_error_noabort("-run is not available in a cross compiler");
+            ret = 1;
+#endif
+        } else if (s->output_type == TCC_OUTPUT_PREPROCESS) {
+             if (s->outfile)
+                fclose(s->ppfp);
+        } else {
+            if (!s->outfile)
+                s->outfile = default_outputfile(s, first_file);
+            ret = !!tcc_output_file(s, s->outfile);
+            /* dump collected dependencies */
+            if (s->gen_deps && !ret)
+                gen_makedeps(s, s->outfile, s->deps_outfile);
+        }
+    }
+
+    tcc_delete(s);
+    if (bench)
+        tcc_memstats();
+    return ret;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tcc.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tcc.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tcc.h	(revision 279)
@@ -0,0 +1,1388 @@
+/*
+ *  TCC - Tiny C Compiler
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _TCC_H
+#define _TCC_H
+
+#define _GNU_SOURCE
+#include "config.h"
+
+#ifdef CONFIG_TCCBOOT
+#include "tccboot.h"
+#define CONFIG_TCC_STATIC
+#else
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <math.h>
+#include <signal.h>
+#define SA_RESETHAND  0x80000000
+#define FPE_INTDIV 1
+#define FPE_FLTDIV 3
+typedef struct { int si_signo, si_errno, si_code; } siginfo_t;
+#include <fcntl.h>
+#include <setjmp.h>
+#include <time.h>
+
+#ifndef _WIN32
+# include <unistd.h>
+# include <sys/time.h>
+/*# include <sys/ucontext.h>*/
+typedef struct __ucontext ucontext_t;
+/*# include <sys/mman.h>*/
+#define	PROT_READ      1
+#define	PROT_WRITE     2
+#define	PROT_EXEC      4
+# ifndef CONFIG_TCC_STATIC
+#  include <dlfcn.h>
+# endif
+#else
+# include <unistd.h>
+# include <sys/time.h>
+# include <sys/ucontext.h>
+# include <sys/mman.h>
+#  include <stdint.h>
+# define inline __inline
+# define inp next_inp
+# ifdef LIBTCC_AS_DLL
+#  define LIBTCCAPI __declspec(dllexport)
+#  define PUB_FUNC LIBTCCAPI
+# endif
+#endif
+
+#endif /* !CONFIG_TCCBOOT */
+
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif
+
+#include "elf.h"
+#ifdef TCC_TARGET_X86_64
+# define ELFCLASSW ELFCLASS64
+# define ElfW(type) Elf##64##_##type
+# define ELFW(type) ELF##64##_##type
+# define ElfW_Rel ElfW(Rela)
+# define SHT_RELX SHT_RELA
+# define REL_SECTION_FMT ".rela%s"
+/* XXX: DLL with PLT would only work with x86-64 for now */
+# define TCC_OUTPUT_DLL_WITH_PLT
+#else
+# define ELFCLASSW ELFCLASS32
+# define ElfW(type) Elf##32##_##type
+# define ELFW(type) ELF##32##_##type
+# define ElfW_Rel ElfW(Rel)
+# define SHT_RELX SHT_REL
+# define REL_SECTION_FMT ".rel%s"
+#endif
+
+/* target address type */
+#define addr_t ElfW(Addr)
+
+#include "stab.h"
+#include "libtcc.h"
+
+/* parser debug */
+//#define PARSE_DEBUG
+/* preprocessor debug */
+//#define PP_DEBUG
+/* include file debug */
+//#define INC_DEBUG
+/* memory leak debug */
+//#define MEM_DEBUG
+/* assembler debug */
+//#define ASM_DEBUG
+
+/* target selection */
+//#define TCC_TARGET_I386   /* i386 code generator */
+//#define TCC_TARGET_ARM    /* ARMv4 code generator */
+//#define TCC_TARGET_C67    /* TMS320C67xx code generator */
+//#define TCC_TARGET_X86_64 /* x86-64 code generator */
+//#define TCC_TARGET_IL   /* IL code generator */
+
+/* default target is I386 */
+#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
+    !defined(TCC_TARGET_C67) && !defined(TCC_TARGET_X86_64) && \
+    !defined(TCC_TARGET_IL) 
+#define TCC_TARGET_I386
+#endif
+
+#if !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
+    !defined(TCC_TARGET_C67) && !defined(TCC_TARGET_X86_64)
+#define CONFIG_TCC_BCHECK /* enable bound checking code */
+#endif
+
+/* define it to include assembler support */
+#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
+#define CONFIG_TCC_ASM
+#endif
+
+/* object format selection */
+#if defined(TCC_TARGET_C67)
+#define TCC_TARGET_COFF
+#endif
+
+/* only native compiler supports -run */
+#if defined _WIN32 == defined TCC_TARGET_PE
+# if (defined __i386__ || defined _X86_) && defined TCC_TARGET_I386
+#  define TCC_IS_NATIVE
+# elif (defined __x86_64__ || defined _AMD64_) && defined TCC_TARGET_X86_64
+#  define TCC_IS_NATIVE
+# elif defined __arm__ && defined TCC_TARGET_ARM
+#  define TCC_IS_NATIVE
+# endif
+#endif
+
+#if defined TCC_IS_NATIVE && !defined CONFIG_TCCBOOT
+# define CONFIG_TCC_BACKTRACE
+#endif
+
+/* ------------ path configuration ------------ */
+
+#ifndef CONFIG_SYSROOT
+# define CONFIG_SYSROOT ""
+#endif
+#ifndef CONFIG_TCCDIR
+# define CONFIG_TCCDIR "."
+#endif
+#ifndef CONFIG_LDDIR
+# define CONFIG_LDDIR "lib"
+#endif
+
+/* path to find crt1.o, crti.o and crtn.o */
+#ifndef CONFIG_TCC_CRTPREFIX
+# define CONFIG_TCC_CRTPREFIX CONFIG_SYSROOT "/usr/" CONFIG_LDDIR
+#endif
+
+/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
+
+/* system include paths */
+#ifndef CONFIG_TCC_SYSINCLUDEPATHS
+# ifdef TCC_TARGET_PE
+#  define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi"
+# elif defined CONFIG_MULTIARCHDIR
+#  define CONFIG_TCC_SYSINCLUDEPATHS \
+        CONFIG_SYSROOT "/usr/local/include" \
+    ":" CONFIG_SYSROOT "/usr/local/include/" CONFIG_MULTIARCHDIR \
+    ":" CONFIG_SYSROOT "/usr/include" \
+    ":" CONFIG_SYSROOT "/usr/include/" CONFIG_MULTIARCHDIR \
+    ":" "{B}/include"
+# else
+#  define CONFIG_TCC_SYSINCLUDEPATHS \
+        CONFIG_SYSROOT "/usr/local/include" \
+    ":" CONFIG_SYSROOT "/usr/include" \
+    ":" "{B}/include"
+# endif
+#endif
+
+/* library search paths */
+#ifndef CONFIG_TCC_LIBPATHS
+# ifdef TCC_TARGET_PE
+#  define CONFIG_TCC_LIBPATHS "{B}/lib"
+# else
+#  define CONFIG_TCC_LIBPATHS \
+        CONFIG_SYSROOT "/usr/" CONFIG_LDDIR \
+    ":" CONFIG_SYSROOT "/" CONFIG_LDDIR \
+    ":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR
+# endif
+#endif
+
+/* name of ELF interpreter */
+#ifndef CONFIG_TCC_ELFINTERP
+# if defined __FreeBSD__
+#  define CONFIG_TCC_ELFINTERP "/libexec/ld-elf.so.1"
+# elif defined __FreeBSD_kernel__
+#  define CONFIG_TCC_ELFINTERP "/lib/ld.so.1"
+# elif defined TCC_ARM_HARDFLOAT
+#  define CONFIG_TCC_ELFINTERP "/lib/ld-linux-armhf.so.3"
+# elif defined TCC_ARM_EABI
+#  define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.3"
+# elif defined(TCC_TARGET_X86_64)
+#  define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"
+# elif defined(TCC_UCLIBC)
+#  define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0"
+# elif defined(TCC_TARGET_PE)
+#  define CONFIG_TCC_ELFINTERP "-"
+# else
+#  define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"
+# endif
+#endif
+
+/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
+#define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/libgcc_s.so.1"
+
+/* -------------------------------------------- */
+/* include the target specific definitions */
+
+#define TARGET_DEFS_ONLY
+#ifdef TCC_TARGET_I386
+# include "i386-gen.c"
+#endif
+#ifdef TCC_TARGET_X86_64
+# include "x86_64-gen.c"
+#endif
+#ifdef TCC_TARGET_ARM
+# include "arm-gen.c"
+#endif
+#ifdef TCC_TARGET_C67
+# include "coff.h"
+# include "c67-gen.c"
+#endif
+#ifdef TCC_TARGET_IL
+#include "il-gen.c"
+#endif
+#undef TARGET_DEFS_ONLY
+
+/* -------------------------------------------- */
+
+#define INCLUDE_STACK_SIZE  32
+#define IFDEF_STACK_SIZE    64
+#define VSTACK_SIZE         256
+#define STRING_MAX_SIZE     1024
+#define PACK_STACK_SIZE     8
+
+#define TOK_HASH_SIZE       8192 /* must be a power of two */
+#define TOK_ALLOC_INCR      512  /* must be a power of two */
+#define TOK_MAX_SIZE        4 /* token max size in int unit when stored in string */
+
+/* token symbol management */
+typedef struct TokenSym {
+    struct TokenSym *hash_next;
+    struct Sym *sym_define; /* direct pointer to define */
+    struct Sym *sym_label; /* direct pointer to label */
+    struct Sym *sym_struct; /* direct pointer to structure */
+    struct Sym *sym_identifier; /* direct pointer to identifier */
+    int tok; /* token number */
+    int len;
+    char str[1];
+} TokenSym;
+
+#ifdef TCC_TARGET_PE
+typedef unsigned short nwchar_t;
+#else
+typedef int nwchar_t;
+#endif
+
+typedef struct CString {
+    int size; /* size in bytes */
+    void *data; /* either 'char *' or 'nwchar_t *' */
+    int size_allocated;
+    void *data_allocated; /* if non NULL, data has been malloced */
+} CString;
+
+/* type definition */
+typedef struct CType {
+    int t;
+    struct Sym *ref;
+} CType;
+
+/* constant value */
+typedef union CValue {
+    long double ld;
+    double d;
+    float f;
+    int i;
+    unsigned int ui;
+    unsigned int ul; /* address (should be unsigned long on 64 bit cpu) */
+    long long ll;
+    unsigned long long ull;
+    struct CString *cstr;
+    void *ptr;
+    int tab[LDOUBLE_SIZE/4];
+} CValue;
+
+/* value on stack */
+typedef struct SValue {
+    CType type;      /* type */
+    unsigned short r;      /* register + flags */
+    unsigned short r2;     /* second register, used for 'long long'
+                              type. If not used, set to VT_CONST */
+    CValue c;              /* constant, if VT_CONST */
+    struct Sym *sym;       /* symbol, if (VT_SYM | VT_CONST) */
+} SValue;
+
+/* symbol management */
+typedef struct Sym {
+    int v;    /* symbol token */
+    char *asm_label;    /* associated asm label */
+    long r;    /* associated register */
+    union {
+        long c;    /* associated number */
+        int *d;   /* define token stream */
+    };
+    CType type;    /* associated type */
+    union {
+        struct Sym *next; /* next related symbol */
+        long jnext; /* next jump label */
+    };
+    struct Sym *prev; /* prev symbol in stack */
+    struct Sym *prev_tok; /* previous symbol for this token */
+} Sym;
+
+/* section definition */
+/* XXX: use directly ELF structure for parameters ? */
+/* special flag to indicate that the section should not be linked to
+   the other ones */
+#define SHF_PRIVATE 0x80000000
+
+/* special flag, too */
+#define SECTION_ABS ((void *)1)
+
+typedef struct Section {
+    unsigned long data_offset; /* current data offset */
+    unsigned char *data;       /* section data */
+    unsigned long data_allocated; /* used for realloc() handling */
+    int sh_name;             /* elf section name (only used during output) */
+    int sh_num;              /* elf section number */
+    int sh_type;             /* elf section type */
+    int sh_flags;            /* elf section flags */
+    int sh_info;             /* elf section info */
+    int sh_addralign;        /* elf section alignment */
+    int sh_entsize;          /* elf entry size */
+    unsigned long sh_size;   /* section size (only used during output) */
+    addr_t sh_addr;          /* address at which the section is relocated */
+    unsigned long sh_offset; /* file offset */
+    int nb_hashed_syms;      /* used to resize the hash table */
+    struct Section *link;    /* link to another section */
+    struct Section *reloc;   /* corresponding section for relocation, if any */
+    struct Section *hash;     /* hash table for symbols */
+    struct Section *next;
+    char name[1];           /* section name */
+} Section;
+
+typedef struct DLLReference {
+    int level;
+    void *handle;
+    char name[1];
+} DLLReference;
+
+/* GNUC attribute definition */
+typedef struct AttributeDef {
+    unsigned
+      func_call     : 3, /* calling convention (0..5), see below */
+      aligned       : 5, /* alignement (0..16) */
+      packed        : 1,
+      func_export   : 1,
+      func_import   : 1,
+      func_args     : 5,
+      mode          : 4,
+      weak          : 1,
+      fill          : 11;
+    struct Section *section;
+    int alias_target;    /* token */
+} AttributeDef;
+
+/* gr: wrappers for casting sym->r for other purposes */
+#define FUNC_CALL(r) (((AttributeDef*)&(r))->func_call)
+#define FUNC_EXPORT(r) (((AttributeDef*)&(r))->func_export)
+#define FUNC_IMPORT(r) (((AttributeDef*)&(r))->func_import)
+#define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args)
+#define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned)
+#define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed)
+#define ATTR_MODE(r)  (((AttributeDef*)&(r))->mode)
+#define INT_ATTR(ad) (*(int*)(ad))
+
+/* -------------------------------------------------- */
+
+#define SYM_STRUCT     0x40000000 /* struct/union/enum symbol space */
+#define SYM_FIELD      0x20000000 /* struct/union field symbol space */
+#define SYM_FIRST_ANOM 0x10000000 /* first anonymous sym */
+
+/* stored in 'Sym.c' field */
+#define FUNC_NEW       1 /* ansi function prototype */
+#define FUNC_OLD       2 /* old function prototype */
+#define FUNC_ELLIPSIS  3 /* ansi function prototype with ... */
+
+/* stored in 'Sym.r' field */
+#define FUNC_CDECL     0 /* standard c call */
+#define FUNC_STDCALL   1 /* pascal c call */
+#define FUNC_FASTCALL1 2 /* first param in %eax */
+#define FUNC_FASTCALL2 3 /* first parameters in %eax, %edx */
+#define FUNC_FASTCALL3 4 /* first parameter in %eax, %edx, %ecx */
+#define FUNC_FASTCALLW 5 /* first parameter in %ecx, %edx */
+
+/* field 'Sym.t' for macros */
+#define MACRO_OBJ      0 /* object like macro */
+#define MACRO_FUNC     1 /* function like macro */
+
+/* field 'Sym.r' for C labels */
+#define LABEL_DEFINED  0 /* label is defined */
+#define LABEL_FORWARD  1 /* label is forward defined */
+#define LABEL_DECLARED 2 /* label is declared but never used */
+
+/* type_decl() types */
+#define TYPE_ABSTRACT  1 /* type without variable */
+#define TYPE_DIRECT    2 /* type with variable */
+
+#define IO_BUF_SIZE 8192
+
+typedef struct BufferedFile {
+    uint8_t *buf_ptr;
+    uint8_t *buf_end;
+    int fd;
+    struct BufferedFile *prev;
+    int line_num;    /* current line number - here to simplify code */
+    int ifndef_macro;  /* #ifndef macro / #endif search */
+    int ifndef_macro_saved; /* saved ifndef_macro */
+    int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
+    char filename[1024];    /* filename */
+    unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
+} BufferedFile;
+
+#define CH_EOB   '\\'       /* end of buffer or '\0' char in file */
+#define CH_EOF   (-1)   /* end of file */
+
+/* parsing state (used to save parser state to reparse part of the
+   source several times) */
+typedef struct ParseState {
+    const int *macro_ptr;
+    int line_num;
+    int tok;
+    CValue tokc;
+} ParseState;
+
+/* used to record tokens */
+typedef struct TokenString {
+    int *str;
+    int len;
+    int allocated_len;
+    int last_line_num;
+} TokenString;
+
+/* inline functions */
+typedef struct InlineFunc {
+    int *token_str;
+    Sym *sym;
+    char filename[1];
+} InlineFunc;
+
+/* include file cache, used to find files faster and also to eliminate
+   inclusion if the include file is protected by #ifndef ... #endif */
+typedef struct CachedInclude {
+    int ifndef_macro;
+    int hash_next; /* -1 if none */
+    char filename[1]; /* path specified in #include */
+} CachedInclude;
+
+#define CACHED_INCLUDES_HASH_SIZE 512
+
+#ifdef CONFIG_TCC_ASM
+typedef struct ExprValue {
+    uint32_t v;
+    Sym *sym;
+} ExprValue;
+
+#define MAX_ASM_OPERANDS 30
+typedef struct ASMOperand {
+    int id; /* GCC 3 optionnal identifier (0 if number only supported */
+    char *constraint;
+    char asm_str[16]; /* computed asm string for operand */
+    SValue *vt; /* C value of the expression */
+    int ref_index; /* if >= 0, gives reference to a output constraint */
+    int input_index; /* if >= 0, gives reference to an input constraint */
+    int priority; /* priority, used to assign registers */
+    int reg; /* if >= 0, register number used for this operand */
+    int is_llong; /* true if double register value */
+    int is_memory; /* true if memory operand */
+    int is_rw;     /* for '+' modifier */
+} ASMOperand;
+#endif
+
+struct sym_attr {
+    unsigned long got_offset;
+#ifdef TCC_TARGET_ARM
+    unsigned char plt_thumb_stub:1;
+#endif
+};
+
+struct TCCState {
+
+    int verbose; /* if true, display some information during compilation */
+    int nostdinc; /* if true, no standard headers are added */
+    int nostdlib; /* if true, no standard libraries are added */
+    int nocommon; /* if true, do not use common symbols for .bss data */
+    int static_link; /* if true, static linking is performed */
+    int rdynamic; /* if true, all symbols are exported */
+    int symbolic; /* if true, resolve symbols in the current module first */
+    int alacarte_link; /* if true, only link in referenced objects from archive */
+
+    char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
+    char *soname; /* as specified on the command line (-soname) */
+    char *rpath; /* as specified on the command line (-Wl,-rpath=) */
+
+    /* output type, see TCC_OUTPUT_XXX */
+    int output_type;
+    /* output format, see TCC_OUTPUT_FORMAT_xxx */
+    int output_format;
+
+    /* C language options */
+    int char_is_unsigned;
+    int leading_underscore;
+    
+    /* warning switches */
+    int warn_write_strings;
+    int warn_unsupported;
+    int warn_error;
+    int warn_none;
+    int warn_implicit_function_declaration;
+
+    /* compile with debug symbol (and use them if error during execution) */
+    int do_debug;
+#ifdef CONFIG_TCC_BCHECK
+    /* compile with built-in memory and bounds checker */
+    int do_bounds_check;
+#endif
+
+    addr_t text_addr; /* address of text section */
+    int has_text_addr;
+
+    unsigned long section_align; /* section alignment */
+
+    char *init_symbol; /* symbols to call at load-time (not used currently) */
+    char *fini_symbol; /* symbols to call at unload-time (not used currently) */
+    
+#ifdef TCC_TARGET_I386
+    int seg_size; /* 32. Can be 16 with i386 assembler (.code16) */
+#endif
+
+    /* array of all loaded dlls (including those referenced by loaded dlls) */
+    DLLReference **loaded_dlls;
+    int nb_loaded_dlls;
+
+    /* include paths */
+    char **include_paths;
+    int nb_include_paths;
+
+    char **sysinclude_paths;
+    int nb_sysinclude_paths;
+
+    /* library paths */
+    char **library_paths;
+    int nb_library_paths;
+
+    /* crt?.o object path */
+    char **crt_paths;
+    int nb_crt_paths;
+
+    /* error handling */
+    void *error_opaque;
+    void (*error_func)(void *opaque, const char *msg);
+    int error_set_jmp_enabled;
+    jmp_buf error_jmp_buf;
+    int nb_errors;
+
+    /* output file for preprocessing (-E) */
+    FILE *ppfp;
+
+    /* for -MD/-MF: collected dependencies for this compilation */
+    char **target_deps;
+    int nb_target_deps;
+
+    /* compilation */
+    BufferedFile *include_stack[INCLUDE_STACK_SIZE];
+    BufferedFile **include_stack_ptr;
+
+    int ifdef_stack[IFDEF_STACK_SIZE];
+    int *ifdef_stack_ptr;
+
+    /* included files enclosed with #ifndef MACRO */
+    int cached_includes_hash[CACHED_INCLUDES_HASH_SIZE];
+    CachedInclude **cached_includes;
+    int nb_cached_includes;
+
+    /* #pragma pack stack */
+    int pack_stack[PACK_STACK_SIZE];
+    int *pack_stack_ptr;
+
+    /* inline functions are stored as token lists and compiled last
+       only if referenced */
+    struct InlineFunc **inline_fns;
+    int nb_inline_fns;
+
+    /* sections */
+    Section **sections;
+    int nb_sections; /* number of sections, including first dummy section */
+
+    Section **priv_sections;
+    int nb_priv_sections; /* number of private sections */
+
+    /* got & plt handling */
+    Section *got;
+    Section *plt;
+    struct sym_attr *sym_attrs;
+    int nb_sym_attrs;
+    /* give the correspondance from symtab indexes to dynsym indexes */
+    int *symtab_to_dynsym;
+
+    /* temporary dynamic symbol sections (for dll loading) */
+    Section *dynsymtab_section;
+    /* exported dynamic symbol section */
+    Section *dynsym;
+    /* copy of the gobal symtab_section variable */
+    Section *symtab;
+    /* tiny assembler state */
+    Sym *asm_labels;
+
+#ifdef TCC_TARGET_PE
+    /* PE info */
+    int pe_subsystem;
+    unsigned pe_file_align;
+    unsigned pe_stack_size;
+# ifdef TCC_TARGET_X86_64
+    Section *uw_pdata;
+    int uw_sym;
+    unsigned uw_offs;
+# endif
+#endif
+
+#ifdef TCC_IS_NATIVE
+    /* for tcc_relocate */
+    void *runtime_mem;
+# ifdef HAVE_SELINUX
+    void *write_mem;
+    unsigned long mem_size;
+# endif
+# if !defined TCC_TARGET_PE && (defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM)
+    /* write PLT and GOT here */
+    char *runtime_plt_and_got;
+    unsigned runtime_plt_and_got_offset;
+#  define TCC_HAS_RUNTIME_PLTGOT
+# endif
+#endif
+
+    /* used by main and tcc_parse_args only */
+    char **files; /* files seen on command line */
+    int nb_files; /* number thereof */
+    int nb_libraries; /* number of libs thereof */
+    char *outfile; /* output filename */
+    char *option_m; /* only -m32/-m64 handled */
+    int print_search_dirs; /* option */
+    int option_r; /* option -r */
+    int do_bench; /* option -bench */
+    int gen_deps; /* option -MD  */
+    char *deps_outfile; /* option -MF */
+};
+
+/* The current value can be: */
+#define VT_VALMASK   0x003f  /* mask for value location, register or: */
+#define VT_CONST     0x0030  /* constant in vc (must be first non register value) */
+#define VT_LLOCAL    0x0031  /* lvalue, offset on stack */
+#define VT_LOCAL     0x0032  /* offset on stack */
+#define VT_CMP       0x0033  /* the value is stored in processor flags (in vc) */
+#define VT_JMP       0x0034  /* value is the consequence of jmp true (even) */
+#define VT_JMPI      0x0035  /* value is the consequence of jmp false (odd) */
+#define VT_REF       0x0040  /* value is pointer to structure rather than address */
+#define VT_LVAL      0x0100  /* var is an lvalue */
+#define VT_SYM       0x0200  /* a symbol value is added */
+#define VT_MUSTCAST  0x0400  /* value must be casted to be correct (used for
+                                char/short stored in integer registers) */
+#define VT_MUSTBOUND 0x0800  /* bound checking must be done before
+                                dereferencing value */
+#define VT_BOUNDED   0x8000  /* value is bounded. The address of the
+                                bounding function call point is in vc */
+#define VT_LVAL_BYTE     0x1000  /* lvalue is a byte */
+#define VT_LVAL_SHORT    0x2000  /* lvalue is a short */
+#define VT_LVAL_UNSIGNED 0x4000  /* lvalue is unsigned */
+#define VT_LVAL_TYPE     (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
+
+/* types */
+#define VT_BTYPE       0x000f  /* mask for basic type */
+#define VT_INT              0  /* integer type */
+#define VT_BYTE             1  /* signed byte type */
+#define VT_SHORT            2  /* short type */
+#define VT_VOID             3  /* void type */
+#define VT_PTR              4  /* pointer */
+#define VT_ENUM             5  /* enum definition */
+#define VT_FUNC             6  /* function type */
+#define VT_STRUCT           7  /* struct/union definition */
+#define VT_FLOAT            8  /* IEEE float */
+#define VT_DOUBLE           9  /* IEEE double */
+#define VT_LDOUBLE         10  /* IEEE long double */
+#define VT_BOOL            11  /* ISOC99 boolean type */
+#define VT_LLONG           12  /* 64 bit integer */
+#define VT_LONG            13  /* long integer (NEVER USED as type, only
+                                  during parsing) */
+#define VT_UNSIGNED    0x0010  /* unsigned type */
+#define VT_ARRAY       0x0020  /* array type (also has VT_PTR) */
+#define VT_BITFIELD    0x0040  /* bitfield modifier */
+#define VT_CONSTANT    0x0800  /* const modifier */
+#define VT_VOLATILE    0x1000  /* volatile modifier */
+#define VT_SIGNED      0x2000  /* signed type */
+#define VT_VLA     0x00020000  /* VLA type (also has VT_PTR and VT_ARRAY) */
+
+/* storage */
+#define VT_EXTERN  0x00000080  /* extern definition */
+#define VT_STATIC  0x00000100  /* static variable */
+#define VT_TYPEDEF 0x00000200  /* typedef definition */
+#define VT_INLINE  0x00000400  /* inline definition */
+#define VT_IMPORT  0x00004000  /* win32: extern data imported from dll */
+#define VT_EXPORT  0x00008000  /* win32: data exported from dll */
+#define VT_WEAK    0x00010000  /* weak symbol */
+
+#define VT_STRUCT_SHIFT 18     /* shift for bitfield shift values (max: 32 - 2*6) */
+
+/* type mask (except storage) */
+#define VT_STORAGE (VT_EXTERN | VT_STATIC | VT_TYPEDEF | VT_INLINE | VT_IMPORT | VT_EXPORT | VT_WEAK)
+#define VT_TYPE (~(VT_STORAGE))
+
+/* token values */
+
+/* warning: the following compare tokens depend on i386 asm code */
+#define TOK_ULT 0x92
+#define TOK_UGE 0x93
+#define TOK_EQ  0x94
+#define TOK_NE  0x95
+#define TOK_ULE 0x96
+#define TOK_UGT 0x97
+#define TOK_Nset 0x98
+#define TOK_Nclear 0x99
+#define TOK_LT  0x9c
+#define TOK_GE  0x9d
+#define TOK_LE  0x9e
+#define TOK_GT  0x9f
+
+#define TOK_LAND  0xa0
+#define TOK_LOR   0xa1
+
+#define TOK_DEC   0xa2
+#define TOK_MID   0xa3 /* inc/dec, to void constant */
+#define TOK_INC   0xa4
+#define TOK_UDIV  0xb0 /* unsigned division */
+#define TOK_UMOD  0xb1 /* unsigned modulo */
+#define TOK_PDIV  0xb2 /* fast division with undefined rounding for pointers */
+#define TOK_CINT   0xb3 /* number in tokc */
+#define TOK_CCHAR 0xb4 /* char constant in tokc */
+#define TOK_STR   0xb5 /* pointer to string in tokc */
+#define TOK_TWOSHARPS 0xb6 /* ## preprocessing token */
+#define TOK_LCHAR    0xb7
+#define TOK_LSTR     0xb8
+#define TOK_CFLOAT   0xb9 /* float constant */
+#define TOK_LINENUM  0xba /* line number info */
+#define TOK_CDOUBLE  0xc0 /* double constant */
+#define TOK_CLDOUBLE 0xc1 /* long double constant */
+#define TOK_UMULL    0xc2 /* unsigned 32x32 -> 64 mul */
+#define TOK_ADDC1    0xc3 /* add with carry generation */
+#define TOK_ADDC2    0xc4 /* add with carry use */
+#define TOK_SUBC1    0xc5 /* add with carry generation */
+#define TOK_SUBC2    0xc6 /* add with carry use */
+#define TOK_CUINT    0xc8 /* unsigned int constant */
+#define TOK_CLLONG   0xc9 /* long long constant */
+#define TOK_CULLONG  0xca /* unsigned long long constant */
+#define TOK_ARROW    0xcb
+#define TOK_DOTS     0xcc /* three dots */
+#define TOK_SHR      0xcd /* unsigned shift right */
+#define TOK_PPNUM    0xce /* preprocessor number */
+#define TOK_NOSUBST  0xcf /* means following token has already been pp'd */
+
+#define TOK_SHL   0x01 /* shift left */
+#define TOK_SAR   0x02 /* signed shift right */
+  
+/* assignement operators : normal operator or 0x80 */
+#define TOK_A_MOD 0xa5
+#define TOK_A_AND 0xa6
+#define TOK_A_MUL 0xaa
+#define TOK_A_ADD 0xab
+#define TOK_A_SUB 0xad
+#define TOK_A_DIV 0xaf
+#define TOK_A_XOR 0xde
+#define TOK_A_OR  0xfc
+#define TOK_A_SHL 0x81
+#define TOK_A_SAR 0x82
+
+#ifndef offsetof
+#define offsetof(type, field) ((size_t) &((type *)0)->field)
+#endif
+
+#ifndef countof
+#define countof(tab) (sizeof(tab) / sizeof((tab)[0]))
+#endif
+
+#define TOK_EOF       (-1)  /* end of file */
+#define TOK_LINEFEED  10    /* line feed */
+
+/* all identificators and strings have token above that */
+#define TOK_IDENT 256
+
+#define DEF_ASM(x) DEF(TOK_ASM_ ## x, #x)
+#define TOK_ASM_int TOK_INT
+#define TOK_ASM_weak TOK_WEAK1
+
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+/* only used for i386 asm opcodes definitions */
+#define DEF_BWL(x) \
+ DEF(TOK_ASM_ ## x ## b, #x "b") \
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
+ DEF(TOK_ASM_ ## x, #x)
+#define DEF_WL(x) \
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
+ DEF(TOK_ASM_ ## x, #x)
+#ifdef TCC_TARGET_X86_64
+# define DEF_BWLQ(x) \
+ DEF(TOK_ASM_ ## x ## b, #x "b") \
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
+ DEF(TOK_ASM_ ## x ## q, #x "q") \
+ DEF(TOK_ASM_ ## x, #x)
+# define DEF_WLQ(x) \
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
+ DEF(TOK_ASM_ ## x ## q, #x "q") \
+ DEF(TOK_ASM_ ## x, #x)
+# define DEF_BWLX DEF_BWLQ
+# define DEF_WLX DEF_WLQ
+/* number of sizes + 1 */
+# define NBWLX 5
+#else
+# define DEF_BWLX DEF_BWL
+# define DEF_WLX DEF_WL
+/* number of sizes + 1 */
+# define NBWLX 4
+#endif
+
+#define DEF_FP1(x) \
+ DEF(TOK_ASM_ ## f ## x ## s, "f" #x "s") \
+ DEF(TOK_ASM_ ## fi ## x ## l, "fi" #x "l") \
+ DEF(TOK_ASM_ ## f ## x ## l, "f" #x "l") \
+ DEF(TOK_ASM_ ## fi ## x ## s, "fi" #x "s")
+
+#define DEF_FP(x) \
+ DEF(TOK_ASM_ ## f ## x, "f" #x ) \
+ DEF(TOK_ASM_ ## f ## x ## p, "f" #x "p") \
+ DEF_FP1(x)
+
+#define DEF_ASMTEST(x) \
+ DEF_ASM(x ## o) \
+ DEF_ASM(x ## no) \
+ DEF_ASM(x ## b) \
+ DEF_ASM(x ## c) \
+ DEF_ASM(x ## nae) \
+ DEF_ASM(x ## nb) \
+ DEF_ASM(x ## nc) \
+ DEF_ASM(x ## ae) \
+ DEF_ASM(x ## e) \
+ DEF_ASM(x ## z) \
+ DEF_ASM(x ## ne) \
+ DEF_ASM(x ## nz) \
+ DEF_ASM(x ## be) \
+ DEF_ASM(x ## na) \
+ DEF_ASM(x ## nbe) \
+ DEF_ASM(x ## a) \
+ DEF_ASM(x ## s) \
+ DEF_ASM(x ## ns) \
+ DEF_ASM(x ## p) \
+ DEF_ASM(x ## pe) \
+ DEF_ASM(x ## np) \
+ DEF_ASM(x ## po) \
+ DEF_ASM(x ## l) \
+ DEF_ASM(x ## nge) \
+ DEF_ASM(x ## nl) \
+ DEF_ASM(x ## ge) \
+ DEF_ASM(x ## le) \
+ DEF_ASM(x ## ng) \
+ DEF_ASM(x ## nle) \
+ DEF_ASM(x ## g)
+
+#endif // defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+
+enum tcc_token {
+    TOK_LAST = TOK_IDENT - 1,
+#define DEF(id, str) id,
+#include "tcctok.h"
+#undef DEF
+};
+
+#define TOK_UIDENT TOK_DEFINE
+
+#if 0//def _WIN32
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#ifndef __GNUC__
+  #define strtold (long double)strtod
+  #define strtof (float)strtod
+  #define strtoll _strtoi64
+  #define strtoull _strtoui64
+#endif
+#else
+/* XXX: need to define this to use them in non ISOC99 context */
+extern float strtof (const char *__nptr, char **__endptr);
+extern long double strtold (const char *__nptr, char **__endptr);
+#endif
+
+#ifdef _WIN32
+#define IS_DIRSEP(c) (c == '/' || c == '\\')
+#define IS_ABSPATH(p) (IS_DIRSEP(p[0]) || (p[0] && p[1] == ':' && IS_DIRSEP(p[2])))
+#define PATHCMP stricmp
+#else
+#define IS_DIRSEP(c) (c == '/')
+#define IS_ABSPATH(p) IS_DIRSEP(p[0])
+#define PATHCMP strcmp
+#endif
+
+#ifdef TCC_TARGET_PE
+#define PATHSEP ';'
+#else
+#define PATHSEP ':'
+#endif
+
+/* space exlcuding newline */
+static inline int is_space(int ch)
+{
+    return ch == ' ' || ch == '\t' || ch == '\v' || ch == '\f' || ch == '\r';
+}
+
+static inline int isid(int c)
+{
+    return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
+}
+
+static inline int isnum(int c)
+{
+    return c >= '0' && c <= '9';
+}
+
+static inline int isoct(int c)
+{
+    return c >= '0' && c <= '7';
+}
+
+static inline int toup(int c)
+{
+    return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c;
+}
+
+#ifndef PUB_FUNC
+# define PUB_FUNC
+#endif
+
+#ifdef ONE_SOURCE
+#define ST_INLN static inline
+#define ST_FUNC static
+#define ST_DATA static
+#else
+#define ST_INLN
+#define ST_FUNC
+#define ST_DATA extern
+#endif
+
+/* ------------ libtcc.c ------------ */
+
+/* use GNU C extensions */
+ST_DATA int gnu_ext;
+/* use Tiny C extensions */
+ST_DATA int tcc_ext;
+/* XXX: get rid of this ASAP */
+ST_DATA struct TCCState *tcc_state;
+
+#ifdef MEM_DEBUG
+ST_DATA int mem_cur_size;
+ST_DATA int mem_max_size;
+#endif
+
+#define AFF_PRINT_ERROR     0x0001 /* print error if file not found */
+#define AFF_REFERENCED_DLL  0x0002 /* load a referenced dll from another dll */
+#define AFF_PREPROCESS      0x0004 /* preprocess file */
+
+/* public functions currently used by the tcc main function */
+PUB_FUNC char *pstrcpy(char *buf, int buf_size, const char *s);
+PUB_FUNC char *pstrcat(char *buf, int buf_size, const char *s);
+PUB_FUNC char *pstrncpy(char *out, const char *in, size_t num);
+PUB_FUNC char *tcc_basename(const char *name);
+PUB_FUNC char *tcc_fileextension (const char *name);
+PUB_FUNC void tcc_free(void *ptr);
+PUB_FUNC void *tcc_malloc(unsigned long size);
+PUB_FUNC void *tcc_mallocz(unsigned long size);
+PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size);
+PUB_FUNC char *tcc_strdup(const char *str);
+#define free(p) use_tcc_free(p)
+#define malloc(s) use_tcc_malloc(s)
+#define realloc(p, s) use_tcc_realloc(p, s)
+#undef strdup
+#define strdup(s) use_tcc_strdup(s)
+PUB_FUNC void tcc_memstats(void);
+PUB_FUNC void tcc_error_noabort(const char *fmt, ...);
+PUB_FUNC void tcc_error(const char *fmt, ...);
+PUB_FUNC void tcc_warning(const char *fmt, ...);
+
+/* other utilities */
+ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data);
+ST_FUNC void dynarray_reset(void *pp, int *n);
+ST_FUNC void cstr_ccat(CString *cstr, int ch);
+ST_FUNC void cstr_cat(CString *cstr, const char *str);
+ST_FUNC void cstr_wccat(CString *cstr, int ch);
+ST_FUNC void cstr_new(CString *cstr);
+ST_FUNC void cstr_free(CString *cstr);
+ST_FUNC void cstr_reset(CString *cstr);
+
+ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags);
+ST_FUNC void section_realloc(Section *sec, unsigned long new_size);
+ST_FUNC void *section_ptr_add(Section *sec, unsigned long size);
+ST_FUNC void section_reserve(Section *sec, unsigned long size);
+ST_FUNC Section *find_section(TCCState *s1, const char *name);
+
+ST_FUNC void put_extern_sym2(Sym *sym, Section *section, addr_t value, unsigned long size, int can_add_underscore);
+ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size);
+ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
+
+ST_INLN void sym_free(Sym *sym);
+ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, long c);
+ST_FUNC Sym *sym_find2(Sym *s, int v);
+ST_FUNC Sym *sym_push(int v, CType *type, int r, int c);
+ST_FUNC void sym_pop(Sym **ptop, Sym *b);
+ST_INLN Sym *struct_find(int v);
+ST_INLN Sym *sym_find(int v);
+ST_FUNC Sym *global_identifier_push(int v, int t, int c);
+
+ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen);
+ST_FUNC int tcc_open(TCCState *s1, const char *filename);
+ST_FUNC void tcc_close(void);
+
+ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags);
+ST_FUNC int tcc_add_crt(TCCState *s, const char *filename);
+ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags);
+
+PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time);
+PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv);
+
+/* ------------ tccpp.c ------------ */
+
+ST_DATA struct BufferedFile *file;
+ST_DATA int ch, tok;
+ST_DATA CValue tokc;
+ST_DATA const int *macro_ptr;
+ST_DATA int parse_flags;
+ST_DATA int tok_flags;
+ST_DATA CString tokcstr; /* current parsed string, if any */
+
+/* display benchmark infos */
+ST_DATA int total_lines;
+ST_DATA int total_bytes;
+ST_DATA int tok_ident;
+ST_DATA TokenSym **table_ident;
+
+#define TOK_FLAG_BOL   0x0001 /* beginning of line before */
+#define TOK_FLAG_BOF   0x0002 /* beginning of file before */
+#define TOK_FLAG_ENDIF 0x0004 /* a endif was found matching starting #ifdef */
+#define TOK_FLAG_EOF   0x0008 /* end of file */
+
+#define PARSE_FLAG_PREPROCESS 0x0001 /* activate preprocessing */
+#define PARSE_FLAG_TOK_NUM    0x0002 /* return numbers instead of TOK_PPNUM */
+#define PARSE_FLAG_LINEFEED   0x0004 /* line feed is returned as a
+                                        token. line feed is also
+                                        returned at eof */
+#define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */
+#define PARSE_FLAG_SPACES     0x0010 /* next() returns space tokens (for -E) */
+
+ST_FUNC TokenSym *tok_alloc(const char *str, int len);
+ST_FUNC char *get_tok_str(int v, CValue *cv);
+ST_FUNC void save_parse_state(ParseState *s);
+ST_FUNC void restore_parse_state(ParseState *s);
+ST_INLN void tok_str_new(TokenString *s);
+ST_FUNC void tok_str_free(int *str);
+ST_FUNC void tok_str_add(TokenString *s, int t);
+ST_FUNC void tok_str_add_tok(TokenString *s);
+ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg);
+ST_FUNC void define_undef(Sym *s);
+ST_INLN Sym *define_find(int v);
+ST_FUNC void free_defines(Sym *b);
+ST_FUNC Sym *label_find(int v);
+ST_FUNC Sym *label_push(Sym **ptop, int v, int flags);
+ST_FUNC void label_pop(Sym **ptop, Sym *slast);
+ST_FUNC void parse_define(void);
+ST_FUNC void preprocess(int is_bof);
+ST_FUNC void next_nomacro(void);
+ST_FUNC void next(void);
+ST_INLN void unget_tok(int last_tok);
+ST_FUNC void preprocess_init(TCCState *s1);
+ST_FUNC void preprocess_new(void);
+ST_FUNC int tcc_preprocess(TCCState *s1);
+ST_FUNC void skip(int c);
+ST_FUNC void expect(const char *msg);
+
+/* ------------ tccgen.c ------------ */
+
+ST_DATA Section *text_section, *data_section, *bss_section; /* predefined sections */
+ST_DATA Section *cur_text_section; /* current section where function code is generated */
+#ifdef CONFIG_TCC_ASM
+ST_DATA Section *last_text_section; /* to handle .previous asm directive */
+#endif
+#ifdef CONFIG_TCC_BCHECK
+/* bound check related sections */
+ST_DATA Section *bounds_section; /* contains global data bound description */
+ST_DATA Section *lbounds_section; /* contains local data bound description */
+#endif
+/* symbol sections */
+ST_DATA Section *symtab_section, *strtab_section;
+/* debug sections */
+ST_DATA Section *stab_section, *stabstr_section;
+
+#define SYM_POOL_NB (8192 / sizeof(Sym))
+ST_DATA Sym *sym_free_first;
+ST_DATA void **sym_pools;
+ST_DATA int nb_sym_pools;
+
+ST_DATA Sym *global_stack;
+ST_DATA Sym *local_stack;
+ST_DATA Sym *local_label_stack;
+ST_DATA Sym *global_label_stack;
+ST_DATA Sym *define_stack;
+ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;
+ST_DATA SValue __vstack[1+/*to make bcheck happy*/ VSTACK_SIZE], *vtop;
+#define vstack  (__vstack + 1)
+ST_DATA int rsym, anon_sym, ind, loc;
+
+ST_DATA int const_wanted; /* true if constant wanted */
+ST_DATA int nocode_wanted; /* true if no code generation wanted for an expression */
+ST_DATA int global_expr;  /* true if compound literals must be allocated globally (used during initializers parsing */
+ST_DATA CType func_vt; /* current function return type (used by return instruction) */
+ST_DATA int func_vc;
+ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and pc */
+ST_DATA char *funcname;
+
+ST_INLN int is_float(int t);
+ST_FUNC int ieee_finite(double d);
+ST_FUNC void test_lvalue(void);
+ST_FUNC void swap(int *p, int *q);
+ST_FUNC void vpushi(int v);
+ST_FUNC Sym *external_global_sym(int v, CType *type, int r);
+ST_FUNC void vset(CType *type, int r, int v);
+ST_FUNC void vswap(void);
+ST_FUNC void vpush_global_sym(CType *type, int v);
+ST_FUNC void vrote(SValue *e, int n);
+ST_FUNC void vrott(int n);
+ST_FUNC void vrotb(int n);
+#ifdef TCC_TARGET_ARM
+ST_FUNC int get_reg_ex(int rc, int rc2);
+ST_FUNC void lexpand_nr(void);
+#endif
+ST_FUNC void vpushv(SValue *v);
+ST_FUNC void save_reg(int r);
+ST_FUNC int get_reg(int rc);
+ST_FUNC void save_regs(int n);
+ST_FUNC int gv(int rc);
+ST_FUNC void gv2(int rc1, int rc2);
+ST_FUNC void vpop(void);
+ST_FUNC void gen_op(int op);
+ST_FUNC int type_size(CType *type, int *a);
+ST_FUNC void mk_pointer(CType *type);
+ST_FUNC void vstore(void);
+ST_FUNC void inc(int post, int c);
+ST_FUNC void parse_asm_str(CString *astr);
+ST_FUNC int lvalue_type(int t);
+ST_FUNC void indir(void);
+ST_FUNC void unary(void);
+ST_FUNC void expr_prod(void);
+ST_FUNC void expr_sum(void);
+ST_FUNC void gexpr(void);
+ST_FUNC int expr_const(void);
+ST_FUNC void gen_inline_functions(void);
+ST_FUNC void decl(int l);
+#if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_C67
+ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size);
+#endif
+
+/* ------------ tccelf.c ------------ */
+
+#define TCC_OUTPUT_FORMAT_ELF    0 /* default output format: ELF */
+#define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */
+#define TCC_OUTPUT_FORMAT_COFF   2 /* COFF */
+
+#define ARMAG  "!<arch>\012"    /* For COFF and a.out archives */
+
+typedef struct {
+    unsigned int n_strx;         /* index into string table of name */
+    unsigned char n_type;         /* type of symbol */
+    unsigned char n_other;        /* misc info (usually empty) */
+    unsigned short n_desc;        /* description field */
+    unsigned int n_value;        /* value of symbol */
+} Stab_Sym;
+
+ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags);
+
+ST_FUNC int put_elf_str(Section *s, const char *sym);
+ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name);
+ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int sh_num, const char *name);
+ST_FUNC int find_elf_sym(Section *s, const char *name);
+ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);
+
+ST_FUNC void put_stabs(const char *str, int type, int other, int desc, unsigned long value);
+ST_FUNC void put_stabs_r(const char *str, int type, int other, int desc, unsigned long value, Section *sec, int sym_index);
+ST_FUNC void put_stabn(int type, int other, int desc, int value);
+ST_FUNC void put_stabd(int type, int other, int desc);
+
+ST_FUNC void relocate_common_syms(void);
+ST_FUNC void relocate_syms(TCCState *s1, int do_resolve);
+ST_FUNC void relocate_section(TCCState *s1, Section *s);
+
+ST_FUNC void tcc_add_linker_symbols(TCCState *s1);
+ST_FUNC int tcc_load_object_file(TCCState *s1, int fd, unsigned long file_offset);
+ST_FUNC int tcc_load_archive(TCCState *s1, int fd);
+ST_FUNC void tcc_add_bcheck(TCCState *s1);
+
+ST_FUNC void build_got_entries(TCCState *s1);
+ST_FUNC void tcc_add_runtime(TCCState *s1);
+
+ST_FUNC addr_t get_elf_sym_addr(TCCState *s, const char *name, int err);
+#ifdef TCC_IS_NATIVE
+ST_FUNC void *tcc_get_symbol_err(TCCState *s, const char *name);
+#endif
+
+#ifndef TCC_TARGET_PE
+ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level);
+ST_FUNC int tcc_load_ldscript(TCCState *s1);
+ST_FUNC uint8_t *parse_comment(uint8_t *p);
+ST_FUNC void minp(void);
+ST_INLN void inp(void);
+ST_FUNC int handle_eob(void);
+#endif
+
+/* ------------ xxx-gen.c ------------ */
+
+#ifdef TCC_TARGET_X86_64
+ST_DATA const int reg_classes[NB_REGS+7];
+#else
+ST_DATA const int reg_classes[NB_REGS];
+#endif
+
+ST_FUNC void gsym_addr(int t, int a);
+ST_FUNC void gsym(int t);
+ST_FUNC void load(int r, SValue *sv);
+ST_FUNC void store(int r, SValue *v);
+ST_FUNC void gfunc_call(int nb_args);
+ST_FUNC void gfunc_prolog(CType *func_type);
+ST_FUNC void gfunc_epilog(void);
+ST_FUNC int gjmp(int t);
+ST_FUNC void gjmp_addr(int a);
+ST_FUNC int gtst(int inv, int t);
+ST_FUNC void gen_opi(int op);
+ST_FUNC void gen_opf(int op);
+ST_FUNC void gen_cvt_ftoi(int t);
+ST_FUNC void gen_cvt_ftof(int t);
+ST_FUNC void ggoto(void);
+#ifndef TCC_TARGET_C67
+ST_FUNC void o(unsigned int c);
+#endif
+#ifndef TCC_TARGET_ARM
+ST_FUNC void gen_cvt_itof(int t);
+#endif
+
+/* ------------ i386-gen.c ------------ */
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+ST_FUNC void g(int c);
+ST_FUNC int oad(int c, int s);
+ST_FUNC void gen_le16(int c);
+ST_FUNC void gen_le32(int c);
+ST_FUNC void gen_addr32(int r, Sym *sym, int c);
+ST_FUNC void gen_addrpc32(int r, Sym *sym, int c);
+#endif
+
+#ifdef CONFIG_TCC_BCHECK
+ST_FUNC void gen_bounded_ptr_add(void);
+ST_FUNC void gen_bounded_ptr_deref(void);
+#endif
+
+/* ------------ x86_64-gen.c ------------ */
+#ifdef TCC_TARGET_X86_64
+ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c);
+ST_FUNC void gen_opl(int op);
+#endif
+
+/* ------------ arm-gen.c ------------ */
+#ifdef TCC_TARGET_ARM
+ST_FUNC void arm_init_types(void);
+ST_FUNC uint32_t encbranch(int pos, int addr, int fail);
+ST_FUNC void gen_cvt_itof1(int t);
+#endif
+
+/* ------------ c67-gen.c ------------ */
+#ifdef TCC_TARGET_C67
+#endif
+
+/* ------------ tcccoff.c ------------ */
+
+#ifdef TCC_TARGET_COFF
+ST_FUNC int tcc_output_coff(TCCState *s1, FILE *f);
+ST_FUNC int tcc_load_coff(TCCState * s1, int fd);
+#endif
+
+/* ------------ tccasm.c ------------ */
+ST_FUNC void asm_instr(void);
+ST_FUNC void asm_global_instr(void);
+#ifdef CONFIG_TCC_ASM
+ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands, const char *name, const char **pp);
+ST_FUNC void asm_expr(TCCState *s1, ExprValue *pe);
+ST_FUNC int asm_int_expr(TCCState *s1);
+ST_FUNC int tcc_assemble(TCCState *s1, int do_preprocess);
+/* ------------ i386-asm.c ------------ */
+ST_FUNC void gen_expr32(ExprValue *pe);
+ST_FUNC void asm_opcode(TCCState *s1, int opcode);
+ST_FUNC void asm_compute_constraints(ASMOperand *operands, int nb_operands, int nb_outputs, const uint8_t *clobber_regs, int *pout_reg);
+ST_FUNC void subst_asm_operand(CString *add_str, SValue *sv, int modifier);
+ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands, int nb_outputs, int is_output, uint8_t *clobber_regs, int out_reg);
+ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str);
+#endif
+
+/* ------------ tccpe.c -------------- */
+#ifdef TCC_TARGET_PE
+ST_FUNC int pe_load_file(struct TCCState *s1, const char *filename, int fd);
+ST_FUNC int pe_output_file(TCCState * s1, const char *filename);
+ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value);
+ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2);
+#ifdef TCC_TARGET_X86_64
+ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack);
+#endif
+#endif
+
+/* ------------ tccrun.c ----------------- */
+#ifdef TCC_IS_NATIVE
+#ifdef CONFIG_TCC_STATIC
+#define RTLD_LAZY       0x001
+#define RTLD_NOW        0x002
+#define RTLD_GLOBAL     0x100
+#define RTLD_DEFAULT    NULL
+/* dummy function for profiling */
+ST_FUNC void *dlopen(const char *filename, int flag);
+ST_FUNC void dlclose(void *p);
+ST_FUNC const char *dlerror(void);
+ST_FUNC void *resolve_sym(TCCState *s1, const char *symbol);
+#elif !defined _WIN32
+ST_FUNC void *resolve_sym(TCCState *s1, const char *symbol);
+#endif
+
+#ifdef CONFIG_TCC_BACKTRACE
+ST_DATA int rt_num_callers;
+ST_DATA const char **rt_bound_error_msg;
+ST_DATA void *rt_prog_main;
+ST_FUNC void tcc_set_num_callers(int n);
+#endif
+#endif
+
+/********************************************************/
+#undef ST_DATA
+#ifdef ONE_SOURCE
+#define ST_DATA static
+#else
+#define ST_DATA
+#endif
+/********************************************************/
+#endif /* _TCC_H */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tccasm.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tccasm.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tccasm.c	(revision 279)
@@ -0,0 +1,1118 @@
+/*
+ *  GAS like assembler for TCC
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+#ifdef CONFIG_TCC_ASM
+
+ST_FUNC int asm_get_local_label_name(TCCState *s1, unsigned int n)
+{
+    char buf[64];
+    TokenSym *ts;
+
+    snprintf(buf, sizeof(buf), "L..%u", n);
+    ts = tok_alloc(buf, strlen(buf));
+    return ts->tok;
+}
+
+ST_FUNC void asm_expr(TCCState *s1, ExprValue *pe);
+
+/* We do not use the C expression parser to handle symbols. Maybe the
+   C expression parser could be tweaked to do so. */
+
+static void asm_expr_unary(TCCState *s1, ExprValue *pe)
+{
+    Sym *sym;
+    int op, n, label;
+    const char *p;
+
+    switch(tok) {
+    case TOK_PPNUM:
+        p = tokc.cstr->data;
+        n = strtoul(p, (char **)&p, 0);
+        if (*p == 'b' || *p == 'f') {
+            /* backward or forward label */
+            label = asm_get_local_label_name(s1, n);
+            sym = label_find(label);
+            if (*p == 'b') {
+                /* backward : find the last corresponding defined label */
+                if (sym && sym->r == 0)
+                    sym = sym->prev_tok;
+                if (!sym)
+                    tcc_error("local label '%d' not found backward", n);
+            } else {
+                /* forward */
+                if (!sym || sym->r) {
+                    /* if the last label is defined, then define a new one */
+                    sym = label_push(&s1->asm_labels, label, 0);
+                    sym->type.t = VT_STATIC | VT_VOID;
+                }
+            }
+            pe->v = 0;
+            pe->sym = sym;
+        } else if (*p == '\0') {
+            pe->v = n;
+            pe->sym = NULL;
+        } else {
+            tcc_error("invalid number syntax");
+        }
+        next();
+        break;
+    case '+':
+        next();
+        asm_expr_unary(s1, pe);
+        break;
+    case '-':
+    case '~':
+        op = tok;
+        next();
+        asm_expr_unary(s1, pe);
+        if (pe->sym)
+            tcc_error("invalid operation with label");
+        if (op == '-')
+            pe->v = -pe->v;
+        else
+            pe->v = ~pe->v;
+        break;
+    case TOK_CCHAR:
+    case TOK_LCHAR:
+	pe->v = tokc.i;
+	pe->sym = NULL;
+	next();
+	break;
+    case '(':
+        next();
+        asm_expr(s1, pe);
+        skip(')');
+        break;
+    default:
+        if (tok >= TOK_IDENT) {
+            /* label case : if the label was not found, add one */
+            sym = label_find(tok);
+            if (!sym) {
+                sym = label_push(&s1->asm_labels, tok, 0);
+                /* NOTE: by default, the symbol is global */
+                sym->type.t = VT_VOID;
+            }
+            if (sym->r == SHN_ABS) {
+                /* if absolute symbol, no need to put a symbol value */
+                pe->v = sym->jnext;
+                pe->sym = NULL;
+            } else {
+                pe->v = 0;
+                pe->sym = sym;
+            }
+            next();
+        } else {
+            tcc_error("bad expression syntax [%s]", get_tok_str(tok, &tokc));
+        }
+        break;
+    }
+}
+    
+static void asm_expr_prod(TCCState *s1, ExprValue *pe)
+{
+    int op;
+    ExprValue e2;
+
+    asm_expr_unary(s1, pe);
+    for(;;) {
+        op = tok;
+        if (op != '*' && op != '/' && op != '%' && 
+            op != TOK_SHL && op != TOK_SAR)
+            break;
+        next();
+        asm_expr_unary(s1, &e2);
+        if (pe->sym || e2.sym)
+            tcc_error("invalid operation with label");
+        switch(op) {
+        case '*':
+            pe->v *= e2.v;
+            break;
+        case '/':  
+            if (e2.v == 0) {
+            div_error:
+                tcc_error("division by zero");
+            }
+            pe->v /= e2.v;
+            break;
+        case '%':  
+            if (e2.v == 0)
+                goto div_error;
+            pe->v %= e2.v;
+            break;
+        case TOK_SHL:
+            pe->v <<= e2.v;
+            break;
+        default:
+        case TOK_SAR:
+            pe->v >>= e2.v;
+            break;
+        }
+    }
+}
+
+static void asm_expr_logic(TCCState *s1, ExprValue *pe)
+{
+    int op;
+    ExprValue e2;
+
+    asm_expr_prod(s1, pe);
+    for(;;) {
+        op = tok;
+        if (op != '&' && op != '|' && op != '^')
+            break;
+        next();
+        asm_expr_prod(s1, &e2);
+        if (pe->sym || e2.sym)
+            tcc_error("invalid operation with label");
+        switch(op) {
+        case '&':
+            pe->v &= e2.v;
+            break;
+        case '|':  
+            pe->v |= e2.v;
+            break;
+        default:
+        case '^':
+            pe->v ^= e2.v;
+            break;
+        }
+    }
+}
+
+static inline void asm_expr_sum(TCCState *s1, ExprValue *pe)
+{
+    int op;
+    ExprValue e2;
+
+    asm_expr_logic(s1, pe);
+    for(;;) {
+        op = tok;
+        if (op != '+' && op != '-')
+            break;
+        next();
+        asm_expr_logic(s1, &e2);
+        if (op == '+') {
+            if (pe->sym != NULL && e2.sym != NULL)
+                goto cannot_relocate;
+            pe->v += e2.v;
+            if (pe->sym == NULL && e2.sym != NULL)
+                pe->sym = e2.sym;
+        } else {
+            pe->v -= e2.v;
+            /* NOTE: we are less powerful than gas in that case
+               because we store only one symbol in the expression */
+            if (!pe->sym && !e2.sym) {
+                /* OK */
+            } else if (pe->sym && !e2.sym) {
+                /* OK */
+            } else if (pe->sym && e2.sym) {
+                if (pe->sym == e2.sym) { 
+                    /* OK */
+                } else if (pe->sym->r == e2.sym->r && pe->sym->r != 0) {
+                    /* we also accept defined symbols in the same section */
+                    pe->v += pe->sym->jnext - e2.sym->jnext;
+                } else {
+                    goto cannot_relocate;
+                }
+                pe->sym = NULL; /* same symbols can be substracted to NULL */
+            } else {
+            cannot_relocate:
+                tcc_error("invalid operation with label");
+            }
+        }
+    }
+}
+
+ST_FUNC void asm_expr(TCCState *s1, ExprValue *pe)
+{
+    asm_expr_sum(s1, pe);
+}
+
+ST_FUNC int asm_int_expr(TCCState *s1)
+{
+    ExprValue e;
+    asm_expr(s1, &e);
+    if (e.sym)
+        expect("constant");
+    return e.v;
+}
+
+/* NOTE: the same name space as C labels is used to avoid using too
+   much memory when storing labels in TokenStrings */
+static void asm_new_label1(TCCState *s1, int label, int is_local,
+                           int sh_num, int value)
+{
+    Sym *sym;
+
+    sym = label_find(label);
+    if (sym) {
+        if (sym->r) {
+            /* the label is already defined */
+            if (!is_local) {
+                tcc_error("assembler label '%s' already defined", 
+                      get_tok_str(label, NULL));
+            } else {
+                /* redefinition of local labels is possible */
+                goto new_label;
+            }
+        }
+    } else {
+    new_label:
+        sym = label_push(&s1->asm_labels, label, 0);
+        sym->type.t = VT_STATIC | VT_VOID;
+    }
+    sym->r = sh_num;
+    sym->jnext = value;
+}
+
+static void asm_new_label(TCCState *s1, int label, int is_local)
+{
+    asm_new_label1(s1, label, is_local, cur_text_section->sh_num, ind);
+}
+
+static void asm_free_labels(TCCState *st)
+{
+    Sym *s, *s1;
+    Section *sec;
+    
+    for(s = st->asm_labels; s != NULL; s = s1) {
+        s1 = s->prev;
+        /* define symbol value in object file */
+        if (s->r) {
+            if (s->r == SHN_ABS)
+                sec = SECTION_ABS;
+            else
+                sec = st->sections[s->r];
+            put_extern_sym2(s, sec, s->jnext, 0, 0);
+        }
+        /* remove label */
+        table_ident[s->v - TOK_IDENT]->sym_label = NULL;
+        sym_free(s);
+    }
+    st->asm_labels = NULL;
+}
+
+static void use_section1(TCCState *s1, Section *sec)
+{
+    cur_text_section->data_offset = ind;
+    cur_text_section = sec;
+    ind = cur_text_section->data_offset;
+}
+
+static void use_section(TCCState *s1, const char *name)
+{
+    Section *sec;
+    sec = find_section(s1, name);
+    use_section1(s1, sec);
+}
+
+static void asm_parse_directive(TCCState *s1)
+{
+    int n, offset, v, size, tok1;
+    Section *sec;
+    uint8_t *ptr;
+
+    /* assembler directive */
+    next();
+    sec = cur_text_section;
+    switch(tok) {
+    case TOK_ASM_align:
+    case TOK_ASM_skip:
+    case TOK_ASM_space:
+        tok1 = tok;
+        next();
+        n = asm_int_expr(s1);
+        if (tok1 == TOK_ASM_align) {
+            if (n < 0 || (n & (n-1)) != 0)
+                tcc_error("alignment must be a positive power of two");
+            offset = (ind + n - 1) & -n;
+            size = offset - ind;
+            /* the section must have a compatible alignment */
+            if (sec->sh_addralign < n)
+                sec->sh_addralign = n;
+        } else {
+            size = n;
+        }
+        v = 0;
+        if (tok == ',') {
+            next();
+            v = asm_int_expr(s1);
+        }
+    zero_pad:
+        if (sec->sh_type != SHT_NOBITS) {
+            sec->data_offset = ind;
+            ptr = section_ptr_add(sec, size);
+            memset(ptr, v, size);
+        }
+        ind += size;
+        break;
+    case TOK_ASM_quad:
+        next();
+        for(;;) {
+            uint64_t vl;
+            const char *p;
+
+            p = tokc.cstr->data;
+            if (tok != TOK_PPNUM) {
+            error_constant:
+                tcc_error("64 bit constant");
+            }
+            vl = strtoll(p, (char **)&p, 0);
+            if (*p != '\0')
+                goto error_constant;
+            next();
+            if (sec->sh_type != SHT_NOBITS) {
+                /* XXX: endianness */
+                gen_le32(vl);
+                gen_le32(vl >> 32);
+            } else {
+                ind += 8;
+            }
+            if (tok != ',')
+                break;
+            next();
+        }
+        break;
+    case TOK_ASM_byte:
+        size = 1;
+        goto asm_data;
+    case TOK_ASM_word:
+    case TOK_SHORT:
+        size = 2;
+        goto asm_data;
+    case TOK_LONG:
+    case TOK_INT:
+        size = 4;
+    asm_data:
+        next();
+        for(;;) {
+            ExprValue e;
+            asm_expr(s1, &e);
+            if (sec->sh_type != SHT_NOBITS) {
+                if (size == 4) {
+                    gen_expr32(&e);
+                } else {
+                    if (e.sym)
+                        expect("constant");
+                    if (size == 1)
+                        g(e.v);
+                    else
+                        gen_le16(e.v);
+                }
+            } else {
+                ind += size;
+            }
+            if (tok != ',')
+                break;
+            next();
+        }
+        break;
+    case TOK_ASM_fill:
+        {
+            int repeat, size, val, i, j;
+            uint8_t repeat_buf[8];
+            next();
+            repeat = asm_int_expr(s1);
+            if (repeat < 0) {
+                tcc_error("repeat < 0; .fill ignored");
+                break;
+            }
+            size = 1;
+            val = 0;
+            if (tok == ',') {
+                next();
+                size = asm_int_expr(s1);
+                if (size < 0) {
+                    tcc_error("size < 0; .fill ignored");
+                    break;
+                }
+                if (size > 8)
+                    size = 8;
+                if (tok == ',') {
+                    next();
+                    val = asm_int_expr(s1);
+                }
+            }
+            /* XXX: endianness */
+            repeat_buf[0] = val;
+            repeat_buf[1] = val >> 8;
+            repeat_buf[2] = val >> 16;
+            repeat_buf[3] = val >> 24;
+            repeat_buf[4] = 0;
+            repeat_buf[5] = 0;
+            repeat_buf[6] = 0;
+            repeat_buf[7] = 0;
+            for(i = 0; i < repeat; i++) {
+                for(j = 0; j < size; j++) {
+                    g(repeat_buf[j]);
+                }
+            }
+        }
+        break;
+    case TOK_ASM_org:
+        {
+            unsigned long n;
+            next();
+            /* XXX: handle section symbols too */
+            n = asm_int_expr(s1);
+            if (n < ind)
+                tcc_error("attempt to .org backwards");
+            v = 0;
+            size = n - ind;
+            goto zero_pad;
+        }
+        break;
+    case TOK_ASM_globl:
+    case TOK_ASM_global:
+    case TOK_ASM_weak:
+    tok1 = tok;
+	do { 
+            Sym *sym;
+
+            next();
+            sym = label_find(tok);
+            if (!sym) {
+                sym = label_push(&s1->asm_labels, tok, 0);
+                sym->type.t = VT_VOID;
+            }
+            sym->type.t &= ~VT_STATIC;
+            if (tok1 == TOK_ASM_weak)
+                sym->type.t |= VT_WEAK;
+            next();
+	} while (tok == ',');
+	break;
+    case TOK_ASM_string:
+    case TOK_ASM_ascii:
+    case TOK_ASM_asciz:
+        {
+            const uint8_t *p;
+            int i, size, t;
+
+            t = tok;
+            next();
+            for(;;) {
+                if (tok != TOK_STR)
+                    expect("string constant");
+                p = tokc.cstr->data;
+                size = tokc.cstr->size;
+                if (t == TOK_ASM_ascii && size > 0)
+                    size--;
+                for(i = 0; i < size; i++)
+                    g(p[i]);
+                next();
+                if (tok == ',') {
+                    next();
+                } else if (tok != TOK_STR) {
+                    break;
+                }
+            }
+	}
+	break;
+    case TOK_ASM_text:
+    case TOK_ASM_data:
+    case TOK_ASM_bss:
+	{ 
+            char sname[64];
+            tok1 = tok;
+            n = 0;
+            next();
+            if (tok != ';' && tok != TOK_LINEFEED) {
+		n = asm_int_expr(s1);
+		next();
+            }
+            sprintf(sname, (n?".%s%d":".%s"), get_tok_str(tok1, NULL), n);
+            use_section(s1, sname);
+	}
+	break;
+    case TOK_ASM_file:
+        {
+            char filename[512];
+
+            filename[0] = '\0';
+            next();
+
+            if (tok == TOK_STR)
+                pstrcat(filename, sizeof(filename), tokc.cstr->data);
+            else
+                pstrcat(filename, sizeof(filename), get_tok_str(tok, NULL));
+
+            if (s1->warn_unsupported)
+                tcc_warning("ignoring .file %s", filename);
+
+            next();
+        }
+        break;
+    case TOK_ASM_ident:
+        {
+            char ident[256];
+
+            ident[0] = '\0';
+            next();
+
+            if (tok == TOK_STR)
+                pstrcat(ident, sizeof(ident), tokc.cstr->data);
+            else
+                pstrcat(ident, sizeof(ident), get_tok_str(tok, NULL));
+
+            if (s1->warn_unsupported)
+                tcc_warning("ignoring .ident %s", ident);
+
+            next();
+        }
+        break;
+    case TOK_ASM_size:
+        { 
+            Sym *sym;
+
+            next();
+            sym = label_find(tok);
+            if (!sym) {
+                tcc_error("label not found: %s", get_tok_str(tok, NULL));
+            }
+
+            next();
+            skip(',');
+            /* XXX .size name,label2-label1 */
+            if (s1->warn_unsupported)
+                tcc_warning("ignoring .size %s,*", get_tok_str(tok, NULL));
+
+            while (tok != '\n' && tok != CH_EOF) {
+                next();
+            }
+        }
+        break;
+    case TOK_ASM_type:
+        { 
+            Sym *sym;
+            const char *newtype;
+
+            next();
+            sym = label_find(tok);
+            if (!sym) {
+                sym = label_push(&s1->asm_labels, tok, 0);
+                sym->type.t = VT_VOID;
+            }
+
+            next();
+            skip(',');
+            if (tok == TOK_STR) {
+                newtype = tokc.cstr->data;
+            } else {
+                if (tok == '@' || tok == '%')
+                    skip(tok);
+                newtype = get_tok_str(tok, NULL);
+            }
+
+            if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) {
+                sym->type.t = VT_FUNC;
+            }
+            else if (s1->warn_unsupported)
+                tcc_warning("change type of '%s' from 0x%x to '%s' ignored", 
+                    get_tok_str(sym->v, NULL), sym->type.t, newtype);
+
+            next();
+        }
+        break;
+    case TOK_SECTION1:
+        {
+            char sname[256];
+
+            /* XXX: support more options */
+            next();
+            sname[0] = '\0';
+            while (tok != ';' && tok != TOK_LINEFEED && tok != ',') {
+                if (tok == TOK_STR)
+                    pstrcat(sname, sizeof(sname), tokc.cstr->data);
+                else
+                    pstrcat(sname, sizeof(sname), get_tok_str(tok, NULL));
+                next();
+            }
+            if (tok == ',') {
+                /* skip section options */
+                next();
+                if (tok != TOK_STR)
+                    expect("string constant");
+                next();
+            }
+            last_text_section = cur_text_section;
+            use_section(s1, sname);
+        }
+        break;
+    case TOK_ASM_previous:
+        { 
+            Section *sec;
+            next();
+            if (!last_text_section)
+                tcc_error("no previous section referenced");
+            sec = cur_text_section;
+            use_section1(s1, last_text_section);
+            last_text_section = sec;
+        }
+        break;
+#ifdef TCC_TARGET_I386
+    case TOK_ASM_code16:
+        {
+            next();
+            s1->seg_size = 16;
+        }
+        break;
+    case TOK_ASM_code32:
+        {
+            next();
+            s1->seg_size = 32;
+        }
+        break;
+#endif
+#ifdef TCC_TARGET_X86_64
+    /* added for compatibility with GAS */
+    case TOK_ASM_code64:
+        next();
+        break;
+#endif
+    default:
+        tcc_error("unknown assembler directive '.%s'", get_tok_str(tok, NULL));
+        break;
+    }
+}
+
+
+/* assemble a file */
+static int tcc_assemble_internal(TCCState *s1, int do_preprocess)
+{
+    int opcode;
+
+#if 0
+    /* print stats about opcodes */
+    {
+        const ASMInstr *pa;
+        int freq[4];
+        int op_vals[500];
+        int nb_op_vals, i, j;
+
+        nb_op_vals = 0;
+        memset(freq, 0, sizeof(freq));
+        for(pa = asm_instrs; pa->sym != 0; pa++) {
+            freq[pa->nb_ops]++;
+            for(i=0;i<pa->nb_ops;i++) {
+                for(j=0;j<nb_op_vals;j++) {
+                    if (pa->op_type[i] == op_vals[j])
+                        goto found;
+                }
+                op_vals[nb_op_vals++] = pa->op_type[i];
+            found: ;
+            }
+        }
+        for(i=0;i<nb_op_vals;i++) {
+            int v = op_vals[i];
+            if ((v & (v - 1)) != 0)
+                printf("%3d: %08x\n", i, v);
+        }
+        printf("size=%d nb=%d f0=%d f1=%d f2=%d f3=%d\n",
+               sizeof(asm_instrs), sizeof(asm_instrs) / sizeof(ASMInstr),
+               freq[0], freq[1], freq[2], freq[3]);
+    }
+#endif
+
+    /* XXX: undefine C labels */
+
+    ch = file->buf_ptr[0];
+    tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
+    parse_flags = PARSE_FLAG_ASM_COMMENTS;
+    if (do_preprocess)
+        parse_flags |= PARSE_FLAG_PREPROCESS;
+    next();
+    for(;;) {
+        if (tok == TOK_EOF)
+            break;
+        parse_flags |= PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */
+    redo:
+        if (tok == '#') {
+            /* horrible gas comment */
+            while (tok != TOK_LINEFEED)
+                next();
+        } else if (tok == '.') {
+            asm_parse_directive(s1);
+        } else if (tok == TOK_PPNUM) {
+            const char *p;
+            int n;
+            p = tokc.cstr->data;
+            n = strtoul(p, (char **)&p, 10);
+            if (*p != '\0')
+                expect("':'");
+            /* new local label */
+            asm_new_label(s1, asm_get_local_label_name(s1, n), 1);
+            next();
+            skip(':');
+            goto redo;
+        } else if (tok >= TOK_IDENT) {
+            /* instruction or label */
+            opcode = tok;
+            next();
+            if (tok == ':') {
+                /* new label */
+                asm_new_label(s1, opcode, 0);
+                next();
+                goto redo;
+            } else if (tok == '=') {
+                int n;
+                next();
+                n = asm_int_expr(s1);
+                asm_new_label1(s1, opcode, 0, SHN_ABS, n);
+                goto redo;
+            } else {
+                asm_opcode(s1, opcode);
+            }
+        }
+        /* end of line */
+        if (tok != ';' && tok != TOK_LINEFEED){
+            expect("end of line");
+        }
+        parse_flags &= ~PARSE_FLAG_LINEFEED; /* XXX: suppress that hack */
+        next();
+    }
+
+    asm_free_labels(s1);
+
+    return 0;
+}
+
+/* Assemble the current file */
+ST_FUNC int tcc_assemble(TCCState *s1, int do_preprocess)
+{
+    Sym *define_start;
+    int ret;
+
+    preprocess_init(s1);
+
+    /* default section is text */
+    cur_text_section = text_section;
+    ind = cur_text_section->data_offset;
+
+    define_start = define_stack;
+
+    /* an elf symbol of type STT_FILE must be put so that STB_LOCAL
+       symbols can be safely used */
+    put_elf_sym(symtab_section, 0, 0,
+                ELFW(ST_INFO)(STB_LOCAL, STT_FILE), 0,
+                SHN_ABS, file->filename);
+
+    ret = tcc_assemble_internal(s1, do_preprocess);
+
+    cur_text_section->data_offset = ind;
+
+    free_defines(define_start); 
+
+    return ret;
+}
+
+/********************************************************************/
+/* GCC inline asm support */
+
+/* assemble the string 'str' in the current C compilation unit without
+   C preprocessing. NOTE: str is modified by modifying the '\0' at the
+   end */
+static void tcc_assemble_inline(TCCState *s1, char *str, int len)
+{
+    int saved_parse_flags;
+    const int *saved_macro_ptr;
+
+    saved_parse_flags = parse_flags;
+    saved_macro_ptr = macro_ptr;
+
+    tcc_open_bf(s1, ":asm:", len);
+    memcpy(file->buffer, str, len);
+
+    macro_ptr = NULL;
+    tcc_assemble_internal(s1, 0);
+    tcc_close();
+
+    parse_flags = saved_parse_flags;
+    macro_ptr = saved_macro_ptr;
+}
+
+/* find a constraint by its number or id (gcc 3 extended
+   syntax). return -1 if not found. Return in *pp in char after the
+   constraint */
+ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands, 
+                           const char *name, const char **pp)
+{
+    int index;
+    TokenSym *ts;
+    const char *p;
+
+    if (isnum(*name)) {
+        index = 0;
+        while (isnum(*name)) {
+            index = (index * 10) + (*name) - '0';
+            name++;
+        }
+        if ((unsigned)index >= nb_operands)
+            index = -1;
+    } else if (*name == '[') {
+        name++;
+        p = strchr(name, ']');
+        if (p) {
+            ts = tok_alloc(name, p - name);
+            for(index = 0; index < nb_operands; index++) {
+                if (operands[index].id == ts->tok)
+                    goto found;
+            }
+            index = -1;
+        found:
+            name = p + 1;
+        } else {
+            index = -1;
+        }
+    } else {
+        index = -1;
+    }
+    if (pp)
+        *pp = name;
+    return index;
+}
+
+static void subst_asm_operands(ASMOperand *operands, int nb_operands, 
+                               int nb_outputs,
+                               CString *out_str, CString *in_str)
+{
+    int c, index, modifier;
+    const char *str;
+    ASMOperand *op;
+    SValue sv;
+
+    cstr_new(out_str);
+    str = in_str->data;
+    for(;;) {
+        c = *str++;
+        if (c == '%') {
+            if (*str == '%') {
+                str++;
+                goto add_char;
+            }
+            modifier = 0;
+            if (*str == 'c' || *str == 'n' ||
+                *str == 'b' || *str == 'w' || *str == 'h')
+                modifier = *str++;
+            index = find_constraint(operands, nb_operands, str, &str);
+            if (index < 0)
+                tcc_error("invalid operand reference after %%");
+            op = &operands[index];
+            sv = *op->vt;
+            if (op->reg >= 0) {
+                sv.r = op->reg;
+                if ((op->vt->r & VT_VALMASK) == VT_LLOCAL && op->is_memory)
+                    sv.r |= VT_LVAL;
+            }
+            subst_asm_operand(out_str, &sv, modifier);
+        } else {
+        add_char:
+            cstr_ccat(out_str, c);
+            if (c == '\0')
+                break;
+        }
+    }
+}
+
+
+static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
+                               int is_output)
+{
+    ASMOperand *op;
+    int nb_operands;
+
+    if (tok != ':') {
+        nb_operands = *nb_operands_ptr;
+        for(;;) {
+            if (nb_operands >= MAX_ASM_OPERANDS)
+                tcc_error("too many asm operands");
+            op = &operands[nb_operands++];
+            op->id = 0;
+            if (tok == '[') {
+                next();
+                if (tok < TOK_IDENT)
+                    expect("identifier");
+                op->id = tok;
+                next();
+                skip(']');
+            }
+            if (tok != TOK_STR)
+                expect("string constant");
+            op->constraint = tcc_malloc(tokc.cstr->size);
+            strcpy(op->constraint, tokc.cstr->data);
+            next();
+            skip('(');
+            gexpr();
+            if (is_output) {
+                test_lvalue();
+            } else {
+                /* we want to avoid LLOCAL case, except when the 'm'
+                   constraint is used. Note that it may come from
+                   register storage, so we need to convert (reg)
+                   case */
+                if ((vtop->r & VT_LVAL) &&
+                    ((vtop->r & VT_VALMASK) == VT_LLOCAL ||
+                     (vtop->r & VT_VALMASK) < VT_CONST) &&
+                    !strchr(op->constraint, 'm')) {
+                    gv(RC_INT);
+                }
+            }
+            op->vt = vtop;
+            skip(')');
+            if (tok == ',') {
+                next();
+            } else {
+                break;
+            }
+        }
+        *nb_operands_ptr = nb_operands;
+    }
+}
+
+/* parse the GCC asm() instruction */
+ST_FUNC void asm_instr(void)
+{
+    CString astr, astr1;
+    ASMOperand operands[MAX_ASM_OPERANDS];
+    int nb_outputs, nb_operands, i, must_subst, out_reg;
+    uint8_t clobber_regs[NB_ASM_REGS];
+
+    next();
+    /* since we always generate the asm() instruction, we can ignore
+       volatile */
+    if (tok == TOK_VOLATILE1 || tok == TOK_VOLATILE2 || tok == TOK_VOLATILE3) {
+        next();
+    }
+    parse_asm_str(&astr);
+    nb_operands = 0;
+    nb_outputs = 0;
+    must_subst = 0;
+    memset(clobber_regs, 0, sizeof(clobber_regs));
+    if (tok == ':') {
+        next();
+        must_subst = 1;
+        /* output args */
+        parse_asm_operands(operands, &nb_operands, 1);
+        nb_outputs = nb_operands;
+        if (tok == ':') {
+            next();
+            if (tok != ')') {
+                /* input args */
+                parse_asm_operands(operands, &nb_operands, 0);
+                if (tok == ':') {
+                    /* clobber list */
+                    /* XXX: handle registers */
+                    next();
+                    for(;;) {
+                        if (tok != TOK_STR)
+                            expect("string constant");
+                        asm_clobber(clobber_regs, tokc.cstr->data);
+                        next();
+                        if (tok == ',') {
+                            next();
+                        } else {
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+    }
+    skip(')');
+    /* NOTE: we do not eat the ';' so that we can restore the current
+       token after the assembler parsing */
+    if (tok != ';')
+        expect("';'");
+    
+    /* save all values in the memory */
+    save_regs(0);
+
+    /* compute constraints */
+    asm_compute_constraints(operands, nb_operands, nb_outputs, 
+                            clobber_regs, &out_reg);
+
+    /* substitute the operands in the asm string. No substitution is
+       done if no operands (GCC behaviour) */
+#ifdef ASM_DEBUG
+    printf("asm: \"%s\"\n", (char *)astr.data);
+#endif
+    if (must_subst) {
+        subst_asm_operands(operands, nb_operands, nb_outputs, &astr1, &astr);
+        cstr_free(&astr);
+    } else {
+        astr1 = astr;
+    }
+#ifdef ASM_DEBUG
+    printf("subst_asm: \"%s\"\n", (char *)astr1.data);
+#endif
+
+    /* generate loads */
+    asm_gen_code(operands, nb_operands, nb_outputs, 0, 
+                 clobber_regs, out_reg);    
+
+    /* assemble the string with tcc internal assembler */
+    tcc_assemble_inline(tcc_state, astr1.data, astr1.size - 1);
+
+    /* restore the current C token */
+    next();
+
+    /* store the output values if needed */
+    asm_gen_code(operands, nb_operands, nb_outputs, 1, 
+                 clobber_regs, out_reg);
+    
+    /* free everything */
+    for(i=0;i<nb_operands;i++) {
+        ASMOperand *op;
+        op = &operands[i];
+        tcc_free(op->constraint);
+        vpop();
+    }
+    cstr_free(&astr1);
+}
+
+ST_FUNC void asm_global_instr(void)
+{
+    CString astr;
+
+    next();
+    parse_asm_str(&astr);
+    skip(')');
+    /* NOTE: we do not eat the ';' so that we can restore the current
+       token after the assembler parsing */
+    if (tok != ';')
+        expect("';'");
+    
+#ifdef ASM_DEBUG
+    printf("asm_global: \"%s\"\n", (char *)astr.data);
+#endif
+    cur_text_section = text_section;
+    ind = cur_text_section->data_offset;
+
+    /* assemble the string with tcc internal assembler */
+    tcc_assemble_inline(tcc_state, astr.data, astr.size - 1);
+    
+    cur_text_section->data_offset = ind;
+
+    /* restore the current C token */
+    next();
+
+    cstr_free(&astr);
+}
+#endif /* CONFIG_TCC_ASM */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tcccoff.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tcccoff.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tcccoff.c	(revision 279)
@@ -0,0 +1,948 @@
+/*
+ *  COFF file handling for TCC
+ * 
+ *  Copyright (c) 2003, 2004 TK
+ *  Copyright (c) 2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+#define MAXNSCNS 255		/* MAXIMUM NUMBER OF SECTIONS         */
+#define MAX_STR_TABLE 1000000
+AOUTHDR o_filehdr;		/* OPTIONAL (A.OUT) FILE HEADER       */
+
+SCNHDR section_header[MAXNSCNS];
+
+#define MAX_FUNCS 1000
+#define MAX_FUNC_NAME_LENGTH 128
+
+int nFuncs;
+char Func[MAX_FUNCS][MAX_FUNC_NAME_LENGTH];
+char AssociatedFile[MAX_FUNCS][MAX_FUNC_NAME_LENGTH];
+int LineNoFilePtr[MAX_FUNCS];
+int EndAddress[MAX_FUNCS];
+int LastLineNo[MAX_FUNCS];
+int FuncEntries[MAX_FUNCS];
+
+int OutputTheSection(Section * sect);
+short int GetCoffFlags(const char *s);
+void SortSymbolTable(void);
+Section *FindSection(TCCState * s1, const char *sname);
+
+int C67_main_entry_point;
+
+int FindCoffSymbolIndex(const char *func_name);
+int nb_syms;
+
+typedef struct {
+    long tag;
+    long size;
+    long fileptr;
+    long nextsym;
+    short int dummy;
+} AUXFUNC;
+
+typedef struct {
+    long regmask;
+    unsigned short lineno;
+    unsigned short nentries;
+    int localframe;
+    int nextentry;
+    short int dummy;
+} AUXBF;
+
+typedef struct {
+    long dummy;
+    unsigned short lineno;
+    unsigned short dummy1;
+    int dummy2;
+    int dummy3;
+    unsigned short dummy4;
+} AUXEF;
+
+ST_FUNC int tcc_output_coff(TCCState *s1, FILE *f)
+{
+    Section *tcc_sect;
+    SCNHDR *coff_sec;
+    int file_pointer;
+    char *Coff_str_table, *pCoff_str_table;
+    int CoffTextSectionNo, coff_nb_syms;
+    FILHDR file_hdr;		/* FILE HEADER STRUCTURE              */
+    Section *stext, *sdata, *sbss;
+    int i, NSectionsToOutput = 0;
+
+    Coff_str_table = pCoff_str_table = NULL;
+
+    stext = FindSection(s1, ".text");
+    sdata = FindSection(s1, ".data");
+    sbss = FindSection(s1, ".bss");
+
+    nb_syms = symtab_section->data_offset / sizeof(Elf32_Sym);
+    coff_nb_syms = FindCoffSymbolIndex("XXXXXXXXXX1");
+
+    file_hdr.f_magic = COFF_C67_MAGIC;	/* magic number */
+    file_hdr.f_timdat = 0;	/* time & date stamp */
+    file_hdr.f_opthdr = sizeof(AOUTHDR);	/* sizeof(optional hdr) */
+    file_hdr.f_flags = 0x1143;	/* flags (copied from what code composer does) */
+    file_hdr.f_TargetID = 0x99;	/* for C6x = 0x0099 */
+
+    o_filehdr.magic = 0x0108;	/* see magic.h                          */
+    o_filehdr.vstamp = 0x0190;	/* version stamp                        */
+    o_filehdr.tsize = stext->data_offset;	/* text size in bytes, padded to FW bdry */
+    o_filehdr.dsize = sdata->data_offset;	/* initialized data "  "                */
+    o_filehdr.bsize = sbss->data_offset;	/* uninitialized data "   "             */
+    o_filehdr.entrypt = C67_main_entry_point;	/* entry pt.                          */
+    o_filehdr.text_start = stext->sh_addr;	/* base of text used for this file      */
+    o_filehdr.data_start = sdata->sh_addr;	/* base of data used for this file      */
+
+
+    // create all the section headers
+
+    file_pointer = FILHSZ + sizeof(AOUTHDR);
+
+    CoffTextSectionNo = -1;
+
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	if (OutputTheSection(tcc_sect)) {
+	    NSectionsToOutput++;
+
+	    if (CoffTextSectionNo == -1 && tcc_sect == stext)
+		CoffTextSectionNo = NSectionsToOutput;	// rem which coff sect number the .text sect is
+
+	    strcpy(coff_sec->s_name, tcc_sect->name);	/* section name */
+
+	    coff_sec->s_paddr = tcc_sect->sh_addr;	/* physical address */
+	    coff_sec->s_vaddr = tcc_sect->sh_addr;	/* virtual address */
+	    coff_sec->s_size = tcc_sect->data_offset;	/* section size */
+	    coff_sec->s_scnptr = 0;	/* file ptr to raw data for section */
+	    coff_sec->s_relptr = 0;	/* file ptr to relocation */
+	    coff_sec->s_lnnoptr = 0;	/* file ptr to line numbers */
+	    coff_sec->s_nreloc = 0;	/* number of relocation entries */
+	    coff_sec->s_flags = GetCoffFlags(coff_sec->s_name);	/* flags */
+	    coff_sec->s_reserved = 0;	/* reserved byte */
+	    coff_sec->s_page = 0;	/* memory page id */
+
+	    file_pointer += sizeof(SCNHDR);
+	}
+    }
+
+    file_hdr.f_nscns = NSectionsToOutput;	/* number of sections */
+
+    // now loop through and determine file pointer locations
+    // for the raw data
+
+
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	if (OutputTheSection(tcc_sect)) {
+	    // put raw data
+	    coff_sec->s_scnptr = file_pointer;	/* file ptr to raw data for section */
+	    file_pointer += coff_sec->s_size;
+	}
+    }
+
+    // now loop through and determine file pointer locations
+    // for the relocation data
+
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	if (OutputTheSection(tcc_sect)) {
+	    // put relocations data
+	    if (coff_sec->s_nreloc > 0) {
+		coff_sec->s_relptr = file_pointer;	/* file ptr to relocation */
+		file_pointer += coff_sec->s_nreloc * sizeof(struct reloc);
+	    }
+	}
+    }
+
+    // now loop through and determine file pointer locations
+    // for the line number data
+
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	coff_sec->s_nlnno = 0;
+	coff_sec->s_lnnoptr = 0;
+
+	if (s1->do_debug && tcc_sect == stext) {
+	    // count how many line nos data
+
+	    // also find association between source file name and function
+	    // so we can sort the symbol table
+
+
+	    Stab_Sym *sym, *sym_end;
+	    char func_name[MAX_FUNC_NAME_LENGTH],
+		last_func_name[MAX_FUNC_NAME_LENGTH];
+	    unsigned long func_addr, last_pc, pc;
+	    const char *incl_files[INCLUDE_STACK_SIZE];
+	    int incl_index, len, last_line_num;
+	    const char *str, *p;
+
+	    coff_sec->s_lnnoptr = file_pointer;	/* file ptr to linno */
+
+
+	    func_name[0] = '\0';
+	    func_addr = 0;
+	    incl_index = 0;
+	    last_func_name[0] = '\0';
+	    last_pc = 0xffffffff;
+	    last_line_num = 1;
+	    sym = (Stab_Sym *) stab_section->data + 1;
+	    sym_end =
+		(Stab_Sym *) (stab_section->data +
+			      stab_section->data_offset);
+
+	    nFuncs = 0;
+	    while (sym < sym_end) {
+		switch (sym->n_type) {
+		    /* function start or end */
+		case N_FUN:
+		    if (sym->n_strx == 0) {
+			// end of function
+
+			coff_sec->s_nlnno++;
+			file_pointer += LINESZ;
+
+			pc = sym->n_value + func_addr;
+			func_name[0] = '\0';
+			func_addr = 0;
+			EndAddress[nFuncs] = pc;
+			FuncEntries[nFuncs] =
+			    (file_pointer -
+			     LineNoFilePtr[nFuncs]) / LINESZ - 1;
+			LastLineNo[nFuncs++] = last_line_num + 1;
+		    } else {
+			// beginning of function
+
+			LineNoFilePtr[nFuncs] = file_pointer;
+			coff_sec->s_nlnno++;
+			file_pointer += LINESZ;
+
+			str =
+			    (const char *) stabstr_section->data +
+			    sym->n_strx;
+
+			p = strchr(str, ':');
+			if (!p) {
+			    pstrcpy(func_name, sizeof(func_name), str);
+			    pstrcpy(Func[nFuncs], sizeof(func_name), str);
+			} else {
+			    len = p - str;
+			    if (len > sizeof(func_name) - 1)
+				len = sizeof(func_name) - 1;
+			    memcpy(func_name, str, len);
+			    memcpy(Func[nFuncs], str, len);
+			    func_name[len] = '\0';
+			}
+
+			// save the file that it came in so we can sort later
+			pstrcpy(AssociatedFile[nFuncs], sizeof(func_name),
+				incl_files[incl_index - 1]);
+
+			func_addr = sym->n_value;
+		    }
+		    break;
+
+		    /* line number info */
+		case N_SLINE:
+		    pc = sym->n_value + func_addr;
+
+		    last_pc = pc;
+		    last_line_num = sym->n_desc;
+
+		    /* XXX: slow! */
+		    strcpy(last_func_name, func_name);
+
+		    coff_sec->s_nlnno++;
+		    file_pointer += LINESZ;
+		    break;
+		    /* include files */
+		case N_BINCL:
+		    str =
+			(const char *) stabstr_section->data + sym->n_strx;
+		  add_incl:
+		    if (incl_index < INCLUDE_STACK_SIZE) {
+			incl_files[incl_index++] = str;
+		    }
+		    break;
+		case N_EINCL:
+		    if (incl_index > 1)
+			incl_index--;
+		    break;
+		case N_SO:
+		    if (sym->n_strx == 0) {
+			incl_index = 0;	/* end of translation unit */
+		    } else {
+			str =
+			    (const char *) stabstr_section->data +
+			    sym->n_strx;
+			/* do not add path */
+			len = strlen(str);
+			if (len > 0 && str[len - 1] != '/')
+			    goto add_incl;
+		    }
+		    break;
+		}
+		sym++;
+	    }
+	}
+
+    }
+
+    file_hdr.f_symptr = file_pointer;	/* file pointer to symtab */
+
+    if (s1->do_debug)
+	file_hdr.f_nsyms = coff_nb_syms;	/* number of symtab entries */
+    else
+	file_hdr.f_nsyms = 0;
+
+    file_pointer += file_hdr.f_nsyms * SYMNMLEN;
+
+    // OK now we are all set to write the file
+
+
+    fwrite(&file_hdr, FILHSZ, 1, f);
+    fwrite(&o_filehdr, sizeof(o_filehdr), 1, f);
+
+    // write section headers
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	if (OutputTheSection(tcc_sect)) {
+	    fwrite(coff_sec, sizeof(SCNHDR), 1, f);
+	}
+    }
+
+    // write raw data
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	if (OutputTheSection(tcc_sect)) {
+	    fwrite(tcc_sect->data, tcc_sect->data_offset, 1, f);
+	}
+    }
+
+    // write relocation data
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	if (OutputTheSection(tcc_sect)) {
+	    // put relocations data
+	    if (coff_sec->s_nreloc > 0) {
+		fwrite(tcc_sect->reloc,
+		       coff_sec->s_nreloc * sizeof(struct reloc), 1, f);
+	    }
+	}
+    }
+
+
+    // group the symbols in order of filename, func1, func2, etc
+    // finally global symbols
+
+    if (s1->do_debug)
+	SortSymbolTable();
+
+    // write line no data
+
+    for (i = 1; i < s1->nb_sections; i++) {
+	coff_sec = &section_header[i];
+	tcc_sect = s1->sections[i];
+
+	if (s1->do_debug && tcc_sect == stext) {
+	    // count how many line nos data
+
+
+	    Stab_Sym *sym, *sym_end;
+	    char func_name[128], last_func_name[128];
+	    unsigned long func_addr, last_pc, pc;
+	    const char *incl_files[INCLUDE_STACK_SIZE];
+	    int incl_index, len, last_line_num;
+	    const char *str, *p;
+
+	    LINENO CoffLineNo;
+
+	    func_name[0] = '\0';
+	    func_addr = 0;
+	    incl_index = 0;
+	    last_func_name[0] = '\0';
+	    last_pc = 0;
+	    last_line_num = 1;
+	    sym = (Stab_Sym *) stab_section->data + 1;
+	    sym_end =
+		(Stab_Sym *) (stab_section->data +
+			      stab_section->data_offset);
+
+	    while (sym < sym_end) {
+		switch (sym->n_type) {
+		    /* function start or end */
+		case N_FUN:
+		    if (sym->n_strx == 0) {
+			// end of function
+
+			CoffLineNo.l_addr.l_paddr = last_pc;
+			CoffLineNo.l_lnno = last_line_num + 1;
+			fwrite(&CoffLineNo, 6, 1, f);
+
+			pc = sym->n_value + func_addr;
+			func_name[0] = '\0';
+			func_addr = 0;
+		    } else {
+			// beginning of function
+
+			str =
+			    (const char *) stabstr_section->data +
+			    sym->n_strx;
+
+
+			p = strchr(str, ':');
+			if (!p) {
+			    pstrcpy(func_name, sizeof(func_name), str);
+			} else {
+			    len = p - str;
+			    if (len > sizeof(func_name) - 1)
+				len = sizeof(func_name) - 1;
+			    memcpy(func_name, str, len);
+			    func_name[len] = '\0';
+			}
+			func_addr = sym->n_value;
+			last_pc = func_addr;
+			last_line_num = -1;
+
+			// output a function begin
+
+			CoffLineNo.l_addr.l_symndx =
+			    FindCoffSymbolIndex(func_name);
+			CoffLineNo.l_lnno = 0;
+
+			fwrite(&CoffLineNo, 6, 1, f);
+		    }
+		    break;
+
+		    /* line number info */
+		case N_SLINE:
+		    pc = sym->n_value + func_addr;
+
+
+		    /* XXX: slow! */
+		    strcpy(last_func_name, func_name);
+
+		    // output a line reference
+
+		    CoffLineNo.l_addr.l_paddr = last_pc;
+
+		    if (last_line_num == -1) {
+			CoffLineNo.l_lnno = sym->n_desc;
+		    } else {
+			CoffLineNo.l_lnno = last_line_num + 1;
+		    }
+
+		    fwrite(&CoffLineNo, 6, 1, f);
+
+		    last_pc = pc;
+		    last_line_num = sym->n_desc;
+
+		    break;
+
+		    /* include files */
+		case N_BINCL:
+		    str =
+			(const char *) stabstr_section->data + sym->n_strx;
+		  add_incl2:
+		    if (incl_index < INCLUDE_STACK_SIZE) {
+			incl_files[incl_index++] = str;
+		    }
+		    break;
+		case N_EINCL:
+		    if (incl_index > 1)
+			incl_index--;
+		    break;
+		case N_SO:
+		    if (sym->n_strx == 0) {
+			incl_index = 0;	/* end of translation unit */
+		    } else {
+			str =
+			    (const char *) stabstr_section->data +
+			    sym->n_strx;
+			/* do not add path */
+			len = strlen(str);
+			if (len > 0 && str[len - 1] != '/')
+			    goto add_incl2;
+		    }
+		    break;
+		}
+		sym++;
+	    }
+	}
+    }
+
+    // write symbol table
+    if (s1->do_debug) {
+	int k;
+	struct syment csym;
+	AUXFUNC auxfunc;
+	AUXBF auxbf;
+	AUXEF auxef;
+	int i;
+	Elf32_Sym *p;
+	const char *name;
+	int nstr;
+	int n = 0;
+
+	Coff_str_table = (char *) tcc_malloc(MAX_STR_TABLE);
+	pCoff_str_table = Coff_str_table;
+	nstr = 0;
+
+	p = (Elf32_Sym *) symtab_section->data;
+
+
+	for (i = 0; i < nb_syms; i++) {
+
+	    name = symtab_section->link->data + p->st_name;
+
+	    for (k = 0; k < 8; k++)
+		csym._n._n_name[k] = 0;
+
+	    if (strlen(name) <= 8) {
+		strcpy(csym._n._n_name, name);
+	    } else {
+		if (pCoff_str_table - Coff_str_table + strlen(name) >
+		    MAX_STR_TABLE - 1)
+		    tcc_error("String table too large");
+
+		csym._n._n_n._n_zeroes = 0;
+		csym._n._n_n._n_offset =
+		    pCoff_str_table - Coff_str_table + 4;
+
+		strcpy(pCoff_str_table, name);
+		pCoff_str_table += strlen(name) + 1;	// skip over null
+		nstr++;
+	    }
+
+	    if (p->st_info == 4) {
+		// put a filename symbol
+		csym.n_value = 33;	// ?????
+		csym.n_scnum = N_DEBUG;
+		csym.n_type = 0;
+		csym.n_sclass = C_FILE;
+		csym.n_numaux = 0;
+		fwrite(&csym, 18, 1, f);
+		n++;
+
+	    } else if (p->st_info == 0x12) {
+		// find the function data
+
+		for (k = 0; k < nFuncs; k++) {
+		    if (strcmp(name, Func[k]) == 0)
+			break;
+		}
+
+		if (k >= nFuncs) {
+		    tcc_error("debug info can't find function: %s", name);
+		}
+		// put a Function Name
+
+		csym.n_value = p->st_value;	// physical address
+		csym.n_scnum = CoffTextSectionNo;
+		csym.n_type = MKTYPE(T_INT, DT_FCN, 0, 0, 0, 0, 0);
+		csym.n_sclass = C_EXT;
+		csym.n_numaux = 1;
+		fwrite(&csym, 18, 1, f);
+
+		// now put aux info
+
+		auxfunc.tag = 0;
+		auxfunc.size = EndAddress[k] - p->st_value;
+		auxfunc.fileptr = LineNoFilePtr[k];
+		auxfunc.nextsym = n + 6;	// tktk
+		auxfunc.dummy = 0;
+		fwrite(&auxfunc, 18, 1, f);
+
+		// put a .bf
+
+		strcpy(csym._n._n_name, ".bf");
+		csym.n_value = p->st_value;	// physical address
+		csym.n_scnum = CoffTextSectionNo;
+		csym.n_type = 0;
+		csym.n_sclass = C_FCN;
+		csym.n_numaux = 1;
+		fwrite(&csym, 18, 1, f);
+
+		// now put aux info
+
+		auxbf.regmask = 0;
+		auxbf.lineno = 0;
+		auxbf.nentries = FuncEntries[k];
+		auxbf.localframe = 0;
+		auxbf.nextentry = n + 6;
+		auxbf.dummy = 0;
+		fwrite(&auxbf, 18, 1, f);
+
+		// put a .ef
+
+		strcpy(csym._n._n_name, ".ef");
+		csym.n_value = EndAddress[k];	// physical address  
+		csym.n_scnum = CoffTextSectionNo;
+		csym.n_type = 0;
+		csym.n_sclass = C_FCN;
+		csym.n_numaux = 1;
+		fwrite(&csym, 18, 1, f);
+
+		// now put aux info
+
+		auxef.dummy = 0;
+		auxef.lineno = LastLineNo[k];
+		auxef.dummy1 = 0;
+		auxef.dummy2 = 0;
+		auxef.dummy3 = 0;
+		auxef.dummy4 = 0;
+		fwrite(&auxef, 18, 1, f);
+
+		n += 6;
+
+	    } else {
+		// try an put some type info
+
+		if ((p->st_other & VT_BTYPE) == VT_DOUBLE) {
+		    csym.n_type = T_DOUBLE;	// int
+		    csym.n_sclass = C_EXT;
+		} else if ((p->st_other & VT_BTYPE) == VT_FLOAT) {
+		    csym.n_type = T_FLOAT;
+		    csym.n_sclass = C_EXT;
+		} else if ((p->st_other & VT_BTYPE) == VT_INT) {
+		    csym.n_type = T_INT;	// int
+		    csym.n_sclass = C_EXT;
+		} else if ((p->st_other & VT_BTYPE) == VT_SHORT) {
+		    csym.n_type = T_SHORT;
+		    csym.n_sclass = C_EXT;
+		} else if ((p->st_other & VT_BTYPE) == VT_BYTE) {
+		    csym.n_type = T_CHAR;
+		    csym.n_sclass = C_EXT;
+		} else {
+		    csym.n_type = T_INT;	// just mark as a label
+		    csym.n_sclass = C_LABEL;
+		}
+
+
+		csym.n_value = p->st_value;
+		csym.n_scnum = 2;
+		csym.n_numaux = 1;
+		fwrite(&csym, 18, 1, f);
+
+		auxfunc.tag = 0;
+		auxfunc.size = 0x20;
+		auxfunc.fileptr = 0;
+		auxfunc.nextsym = 0;
+		auxfunc.dummy = 0;
+		fwrite(&auxfunc, 18, 1, f);
+		n++;
+		n++;
+
+	    }
+
+	    p++;
+	}
+    }
+
+    if (s1->do_debug) {
+	// write string table
+
+	// first write the size
+	i = pCoff_str_table - Coff_str_table;
+	fwrite(&i, 4, 1, f);
+
+	// then write the strings
+	fwrite(Coff_str_table, i, 1, f);
+
+	tcc_free(Coff_str_table);
+    }
+
+    return 0;
+}
+
+
+
+// group the symbols in order of filename, func1, func2, etc
+// finally global symbols
+
+void SortSymbolTable(void)
+{
+    int i, j, k, n = 0;
+    Elf32_Sym *p, *p2, *NewTable;
+    char *name, *name2;
+
+    NewTable = (Elf32_Sym *) tcc_malloc(nb_syms * sizeof(Elf32_Sym));
+
+    p = (Elf32_Sym *) symtab_section->data;
+
+
+    // find a file symbol, copy it over
+    // then scan the whole symbol list and copy any function
+    // symbols that match the file association
+
+    for (i = 0; i < nb_syms; i++) {
+	if (p->st_info == 4) {
+	    name = (char *) symtab_section->link->data + p->st_name;
+
+	    // this is a file symbol, copy it over
+
+	    NewTable[n++] = *p;
+
+	    p2 = (Elf32_Sym *) symtab_section->data;
+
+	    for (j = 0; j < nb_syms; j++) {
+		if (p2->st_info == 0x12) {
+		    // this is a func symbol
+
+		    name2 =
+			(char *) symtab_section->link->data + p2->st_name;
+
+		    // find the function data index
+
+		    for (k = 0; k < nFuncs; k++) {
+			if (strcmp(name2, Func[k]) == 0)
+			    break;
+		    }
+
+		    if (k >= nFuncs) {
+                        tcc_error("debug (sort) info can't find function: %s", name2);
+		    }
+
+		    if (strcmp(AssociatedFile[k], name) == 0) {
+			// yes they match copy it over
+
+			NewTable[n++] = *p2;
+		    }
+		}
+		p2++;
+	    }
+	}
+	p++;
+    }
+
+    // now all the filename and func symbols should have been copied over
+    // copy all the rest over (all except file and funcs)
+
+    p = (Elf32_Sym *) symtab_section->data;
+    for (i = 0; i < nb_syms; i++) {
+	if (p->st_info != 4 && p->st_info != 0x12) {
+	    NewTable[n++] = *p;
+	}
+	p++;
+    }
+
+    if (n != nb_syms)
+	tcc_error("Internal Compiler error, debug info");
+
+    // copy it all back
+
+    p = (Elf32_Sym *) symtab_section->data;
+    for (i = 0; i < nb_syms; i++) {
+	*p++ = NewTable[i];
+    }
+
+    tcc_free(NewTable);
+}
+
+
+int FindCoffSymbolIndex(const char *func_name)
+{
+    int i, n = 0;
+    Elf32_Sym *p;
+    char *name;
+
+    p = (Elf32_Sym *) symtab_section->data;
+
+    for (i = 0; i < nb_syms; i++) {
+
+	name = (char *) symtab_section->link->data + p->st_name;
+
+	if (p->st_info == 4) {
+	    // put a filename symbol
+	    n++;
+	} else if (p->st_info == 0x12) {
+
+	    if (strcmp(func_name, name) == 0)
+		return n;
+
+	    n += 6;
+
+	    // put a Function Name
+
+	    // now put aux info
+
+	    // put a .bf
+
+	    // now put aux info
+
+	    // put a .ef
+
+	    // now put aux info
+
+	} else {
+	    n += 2;
+	}
+
+	p++;
+    }
+
+    return n;			// total number of symbols
+}
+
+int OutputTheSection(Section * sect)
+{
+    const char *s = sect->name;
+
+    if (!strcmp(s, ".text"))
+	return 1;
+    else if (!strcmp(s, ".data"))
+	return 1;
+    else
+	return 0;
+}
+
+short int GetCoffFlags(const char *s)
+{
+    if (!strcmp(s, ".text"))
+	return STYP_TEXT | STYP_DATA | STYP_ALIGN | 0x400;
+    else if (!strcmp(s, ".data"))
+	return STYP_DATA;
+    else if (!strcmp(s, ".bss"))
+	return STYP_BSS;
+    else if (!strcmp(s, ".stack"))
+	return STYP_BSS | STYP_ALIGN | 0x200;
+    else if (!strcmp(s, ".cinit"))
+	return STYP_COPY | STYP_DATA | STYP_ALIGN | 0x200;
+    else
+	return 0;
+}
+
+Section *FindSection(TCCState * s1, const char *sname)
+{
+    Section *s;
+    int i;
+
+    for (i = 1; i < s1->nb_sections; i++) {
+	s = s1->sections[i];
+
+	if (!strcmp(sname, s->name))
+	    return s;
+    }
+
+    tcc_error("could not find section %s", sname);
+    return 0;
+}
+
+ST_FUNC int tcc_load_coff(TCCState * s1, int fd)
+{
+// tktk TokenSym *ts;
+
+    FILE *f;
+    unsigned int str_size;
+    char *Coff_str_table, *name;
+    int i, k;
+    struct syment csym;
+    char name2[9];
+    FILHDR file_hdr;		/* FILE HEADER STRUCTURE              */
+
+    f = fdopen(fd, "rb");
+    if (!f) {
+	tcc_error("Unable to open .out file for input");
+    }
+
+    if (fread(&file_hdr, FILHSZ, 1, f) != 1)
+	tcc_error("error reading .out file for input");
+
+    if (fread(&o_filehdr, sizeof(o_filehdr), 1, f) != 1)
+	tcc_error("error reading .out file for input");
+
+    // first read the string table
+
+    if (fseek(f, file_hdr.f_symptr + file_hdr.f_nsyms * SYMESZ, SEEK_SET))
+	tcc_error("error reading .out file for input");
+
+    if (fread(&str_size, sizeof(int), 1, f) != 1)
+	tcc_error("error reading .out file for input");
+
+
+    Coff_str_table = (char *) tcc_malloc(str_size);
+
+    if (fread(Coff_str_table, str_size - 4, 1, f) != 1)
+	tcc_error("error reading .out file for input");
+
+    // read/process all the symbols
+
+    // seek back to symbols
+
+    if (fseek(f, file_hdr.f_symptr, SEEK_SET))
+	tcc_error("error reading .out file for input");
+
+    for (i = 0; i < file_hdr.f_nsyms; i++) {
+	if (fread(&csym, SYMESZ, 1, f) != 1)
+	    tcc_error("error reading .out file for input");
+
+	if (csym._n._n_n._n_zeroes == 0) {
+	    name = Coff_str_table + csym._n._n_n._n_offset - 4;
+	} else {
+	    name = csym._n._n_name;
+
+	    if (name[7] != 0) {
+		for (k = 0; k < 8; k++)
+		    name2[k] = name[k];
+
+		name2[8] = 0;
+
+		name = name2;
+	    }
+	}
+//              if (strcmp("_DAC_Buffer",name)==0)  // tktk
+//                      name[0]=0;
+
+	if (((csym.n_type & 0x30) == 0x20 && csym.n_sclass == 0x2) || ((csym.n_type & 0x30) == 0x30 && csym.n_sclass == 0x2) || (csym.n_type == 0x4 && csym.n_sclass == 0x2) || (csym.n_type == 0x8 && csym.n_sclass == 0x2) ||	// structures
+	    (csym.n_type == 0x18 && csym.n_sclass == 0x2) ||	// pointer to structure
+	    (csym.n_type == 0x7 && csym.n_sclass == 0x2) ||	// doubles
+	    (csym.n_type == 0x6 && csym.n_sclass == 0x2))	// floats
+	{
+	    // strip off any leading underscore (except for other main routine)
+
+	    if (name[0] == '_' && strcmp(name, "_main") != 0)
+		name++;
+
+	    tcc_add_symbol(s1, name, (void*)(uintptr_t)csym.n_value);
+	}
+	// skip any aux records
+
+	if (csym.n_numaux == 1) {
+	    if (fread(&csym, SYMESZ, 1, f) != 1)
+		tcc_error("error reading .out file for input");
+	    i++;
+	}
+    }
+
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tccelf.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tccelf.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tccelf.c	(revision 279)
@@ -0,0 +1,3134 @@
+/*
+ *  ELF file handling for TCC
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+static int new_undef_sym = 0; /* Is there a new undefined sym since last new_undef_sym() */
+
+ST_FUNC int put_elf_str(Section *s, const char *sym)
+{
+    int offset, len;
+    char *ptr;
+
+    len = strlen(sym) + 1;
+    offset = s->data_offset;
+    ptr = section_ptr_add(s, len);
+    memcpy(ptr, sym, len);
+    return offset;
+}
+
+/* elf symbol hashing function */
+static unsigned long elf_hash(const unsigned char *name)
+{
+    unsigned long h = 0, g;
+    
+    while (*name) {
+        h = (h << 4) + *name++;
+        g = h & 0xf0000000;
+        if (g)
+            h ^= g >> 24;
+        h &= ~g;
+    }
+    return h;
+}
+
+/* rebuild hash table of section s */
+/* NOTE: we do factorize the hash table code to go faster */
+static void rebuild_hash(Section *s, unsigned int nb_buckets)
+{
+    ElfW(Sym) *sym;
+    int *ptr, *hash, nb_syms, sym_index, h;
+    char *strtab;
+
+    strtab = s->link->data;
+    nb_syms = s->data_offset / sizeof(ElfW(Sym));
+
+    s->hash->data_offset = 0;
+    ptr = section_ptr_add(s->hash, (2 + nb_buckets + nb_syms) * sizeof(int));
+    ptr[0] = nb_buckets;
+    ptr[1] = nb_syms;
+    ptr += 2;
+    hash = ptr;
+    memset(hash, 0, (nb_buckets + 1) * sizeof(int));
+    ptr += nb_buckets + 1;
+
+    sym = (ElfW(Sym) *)s->data + 1;
+    for(sym_index = 1; sym_index < nb_syms; sym_index++) {
+        if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
+            h = elf_hash(strtab + sym->st_name) % nb_buckets;
+            *ptr = hash[h];
+            hash[h] = sym_index;
+        } else {
+            *ptr = 0;
+        }
+        ptr++;
+        sym++;
+    }
+}
+
+/* return the symbol number */
+ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size,
+    int info, int other, int shndx, const char *name)
+{
+    int name_offset, sym_index;
+    int nbuckets, h;
+    ElfW(Sym) *sym;
+    Section *hs;
+    
+    sym = section_ptr_add(s, sizeof(ElfW(Sym)));
+    if (name)
+        name_offset = put_elf_str(s->link, name);
+    else
+        name_offset = 0;
+    /* XXX: endianness */
+    sym->st_name = name_offset;
+    sym->st_value = value;
+    sym->st_size = size;
+    sym->st_info = info;
+    sym->st_other = other;
+    sym->st_shndx = shndx;
+    sym_index = sym - (ElfW(Sym) *)s->data;
+    hs = s->hash;
+    if (hs) {
+        int *ptr, *base;
+        ptr = section_ptr_add(hs, sizeof(int));
+        base = (int *)hs->data;
+        /* only add global or weak symbols */
+        if (ELFW(ST_BIND)(info) != STB_LOCAL) {
+            /* add another hashing entry */
+            nbuckets = base[0];
+            h = elf_hash(name) % nbuckets;
+            *ptr = base[2 + h];
+            base[2 + h] = sym_index;
+            base[1]++;
+            /* we resize the hash table */
+            hs->nb_hashed_syms++;
+            if (hs->nb_hashed_syms > 2 * nbuckets) {
+                rebuild_hash(s, 2 * nbuckets);
+            }
+        } else {
+            *ptr = 0;
+            base[1]++;
+        }
+    }
+    return sym_index;
+}
+
+/* find global ELF symbol 'name' and return its index. Return 0 if not
+   found. */
+ST_FUNC int find_elf_sym(Section *s, const char *name)
+{
+    ElfW(Sym) *sym;
+    Section *hs;
+    int nbuckets, sym_index, h;
+    const char *name1;
+    
+    hs = s->hash;
+    if (!hs)
+        return 0;
+    nbuckets = ((int *)hs->data)[0];
+    h = elf_hash(name) % nbuckets;
+    sym_index = ((int *)hs->data)[2 + h];
+    while (sym_index != 0) {
+        sym = &((ElfW(Sym) *)s->data)[sym_index];
+        name1 = s->link->data + sym->st_name;
+        if (!strcmp(name, name1))
+            return sym_index;
+        sym_index = ((int *)hs->data)[2 + nbuckets + sym_index];
+    }
+    return 0;
+}
+
+/* return elf symbol value, signal error if 'err' is nonzero */
+ST_FUNC addr_t get_elf_sym_addr(TCCState *s, const char *name, int err)
+{
+    int sym_index;
+    ElfW(Sym) *sym;
+
+    sym_index = find_elf_sym(s->symtab, name);
+    sym = &((ElfW(Sym) *)s->symtab->data)[sym_index];
+    if (!sym_index || sym->st_shndx == SHN_UNDEF) {
+        if (err)
+            tcc_error("%s not defined", name);
+        return 0;
+    }
+    return sym->st_value;
+}
+
+/* return elf symbol value */
+LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name)
+{
+    return (void*)(uintptr_t)get_elf_sym_addr(s, name, 0);
+}
+
+#ifdef TCC_IS_NATIVE
+/* return elf symbol value or error */
+ST_FUNC void* tcc_get_symbol_err(TCCState *s, const char *name)
+{
+    return (void*)get_elf_sym_addr(s, name, 1);
+}
+#endif
+
+/* add an elf symbol : check if it is already defined and patch
+   it. Return symbol index. NOTE that sh_num can be SHN_UNDEF. */
+ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size,
+                       int info, int other, int sh_num, const char *name)
+{
+    ElfW(Sym) *esym;
+    int sym_bind, sym_index, sym_type, esym_bind;
+    unsigned char sym_vis, esym_vis, new_vis;
+
+    sym_bind = ELFW(ST_BIND)(info);
+    sym_type = ELFW(ST_TYPE)(info);
+    sym_vis = ELFW(ST_VISIBILITY)(other);
+        
+    if (sym_bind != STB_LOCAL) {
+        /* we search global or weak symbols */
+        sym_index = find_elf_sym(s, name);
+        if (!sym_index)
+            goto do_def;
+        esym = &((ElfW(Sym) *)s->data)[sym_index];
+        if (esym->st_shndx != SHN_UNDEF) {
+            esym_bind = ELFW(ST_BIND)(esym->st_info);
+            /* propagate the most constraining visibility */
+            /* STV_DEFAULT(0)<STV_PROTECTED(3)<STV_HIDDEN(2)<STV_INTERNAL(1) */
+            esym_vis = ELFW(ST_VISIBILITY)(esym->st_other);
+            if (esym_vis == STV_DEFAULT) {
+                new_vis = sym_vis;
+            } else if (sym_vis == STV_DEFAULT) {
+                new_vis = esym_vis;
+            } else {
+                new_vis = (esym_vis < sym_vis) ? esym_vis : sym_vis;
+            }
+            esym->st_other = (esym->st_other & ~ELFW(ST_VISIBILITY)(-1))
+                             | new_vis;
+            other = esym->st_other; /* in case we have to patch esym */
+            if (sh_num == SHN_UNDEF) {
+                /* ignore adding of undefined symbol if the
+                   corresponding symbol is already defined */
+            } else if (sym_bind == STB_GLOBAL && esym_bind == STB_WEAK) {
+                /* global overrides weak, so patch */
+                goto do_patch;
+            } else if (sym_bind == STB_WEAK && esym_bind == STB_GLOBAL) {
+                /* weak is ignored if already global */
+            } else if (sym_bind == STB_WEAK && esym_bind == STB_WEAK) {
+                /* keep first-found weak definition, ignore subsequents */
+            } else if (sym_vis == STV_HIDDEN || sym_vis == STV_INTERNAL) {
+                /* ignore hidden symbols after */
+            } else if (esym->st_shndx == SHN_COMMON
+                    && (sh_num < SHN_LORESERVE || sh_num == SHN_COMMON)) {
+                /* gr: Happens with 'tcc ... -static tcctest.c' on e.g. Ubuntu 6.01
+                   No idea if this is the correct solution ... */
+                goto do_patch;
+            } else if (s == tcc_state->dynsymtab_section) {
+                /* we accept that two DLL define the same symbol */
+            } else {
+#if 0
+                printf("new_bind=%x new_shndx=%x new_vis=%x old_bind=%x old_shndx=%x old_vis=%x\n",
+                       sym_bind, sh_num, new_vis, esym_bind, esym->st_shndx, esym_vis);
+#endif
+                tcc_error_noabort("'%s' defined twice", name);
+            }
+        } else {
+        do_patch:
+            esym->st_info = ELFW(ST_INFO)(sym_bind, sym_type);
+            esym->st_shndx = sh_num;
+            new_undef_sym = 1;
+            esym->st_value = value;
+            esym->st_size = size;
+            esym->st_other = other;
+        }
+    } else {
+    do_def:
+        sym_index = put_elf_sym(s, value, size, 
+                                ELFW(ST_INFO)(sym_bind, sym_type), other, 
+                                sh_num, name);
+    }
+    return sym_index;
+}
+
+/* put relocation */
+ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset,
+                          int type, int symbol)
+{
+    char buf[256];
+    Section *sr;
+    ElfW_Rel *rel;
+
+    sr = s->reloc;
+    if (!sr) {
+        /* if no relocation section, create it */
+        snprintf(buf, sizeof(buf), REL_SECTION_FMT, s->name);
+        /* if the symtab is allocated, then we consider the relocation
+           are also */
+        sr = new_section(tcc_state, buf, SHT_RELX, symtab->sh_flags);
+        sr->sh_entsize = sizeof(ElfW_Rel);
+        sr->link = symtab;
+        sr->sh_info = s->sh_num;
+        s->reloc = sr;
+    }
+    rel = section_ptr_add(sr, sizeof(ElfW_Rel));
+    rel->r_offset = offset;
+    rel->r_info = ELFW(R_INFO)(symbol, type);
+#ifdef TCC_TARGET_X86_64
+    rel->r_addend = 0;
+#endif
+}
+
+/* put stab debug information */
+
+ST_FUNC void put_stabs(const char *str, int type, int other, int desc,
+                      unsigned long value)
+{
+    Stab_Sym *sym;
+
+    sym = section_ptr_add(stab_section, sizeof(Stab_Sym));
+    if (str) {
+        sym->n_strx = put_elf_str(stabstr_section, str);
+    } else {
+        sym->n_strx = 0;
+    }
+    sym->n_type = type;
+    sym->n_other = other;
+    sym->n_desc = desc;
+    sym->n_value = value;
+}
+
+ST_FUNC void put_stabs_r(const char *str, int type, int other, int desc, 
+                        unsigned long value, Section *sec, int sym_index)
+{
+    put_stabs(str, type, other, desc, value);
+    put_elf_reloc(symtab_section, stab_section, 
+                  stab_section->data_offset - sizeof(unsigned int),
+                  R_DATA_32, sym_index);
+}
+
+ST_FUNC void put_stabn(int type, int other, int desc, int value)
+{
+    put_stabs(NULL, type, other, desc, value);
+}
+
+ST_FUNC void put_stabd(int type, int other, int desc)
+{
+    put_stabs(NULL, type, other, desc, 0);
+}
+
+/* In an ELF file symbol table, the local symbols must appear below
+   the global and weak ones. Since TCC cannot sort it while generating
+   the code, we must do it after. All the relocation tables are also
+   modified to take into account the symbol table sorting */
+static void sort_syms(TCCState *s1, Section *s)
+{
+    int *old_to_new_syms;
+    ElfW(Sym) *new_syms;
+    int nb_syms, i;
+    ElfW(Sym) *p, *q;
+    ElfW_Rel *rel, *rel_end;
+    Section *sr;
+    int type, sym_index;
+
+    nb_syms = s->data_offset / sizeof(ElfW(Sym));
+    new_syms = tcc_malloc(nb_syms * sizeof(ElfW(Sym)));
+    old_to_new_syms = tcc_malloc(nb_syms * sizeof(int));
+
+    /* first pass for local symbols */
+    p = (ElfW(Sym) *)s->data;
+    q = new_syms;
+    for(i = 0; i < nb_syms; i++) {
+        if (ELFW(ST_BIND)(p->st_info) == STB_LOCAL) {
+            old_to_new_syms[i] = q - new_syms;
+            *q++ = *p;
+        }
+        p++;
+    }
+    /* save the number of local symbols in section header */
+    s->sh_info = q - new_syms;
+
+    /* then second pass for non local symbols */
+    p = (ElfW(Sym) *)s->data;
+    for(i = 0; i < nb_syms; i++) {
+        if (ELFW(ST_BIND)(p->st_info) != STB_LOCAL) {
+            old_to_new_syms[i] = q - new_syms;
+            *q++ = *p;
+        }
+        p++;
+    }
+    
+    /* we copy the new symbols to the old */
+    memcpy(s->data, new_syms, nb_syms * sizeof(ElfW(Sym)));
+    tcc_free(new_syms);
+
+    /* now we modify all the relocations */
+    for(i = 1; i < s1->nb_sections; i++) {
+        sr = s1->sections[i];
+        if (sr->sh_type == SHT_RELX && sr->link == s) {
+            rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
+            for(rel = (ElfW_Rel *)sr->data;
+                rel < rel_end;
+                rel++) {
+                sym_index = ELFW(R_SYM)(rel->r_info);
+                type = ELFW(R_TYPE)(rel->r_info);
+                sym_index = old_to_new_syms[sym_index];
+                rel->r_info = ELFW(R_INFO)(sym_index, type);
+            }
+        }
+    }
+    
+    tcc_free(old_to_new_syms);
+}
+
+/* relocate common symbols in the .bss section */
+ST_FUNC void relocate_common_syms(void)
+{
+    ElfW(Sym) *sym, *sym_end;
+    unsigned long offset, align;
+    
+    sym_end = (ElfW(Sym) *)(symtab_section->data + symtab_section->data_offset);
+    for(sym = (ElfW(Sym) *)symtab_section->data + 1; 
+        sym < sym_end;
+        sym++) {
+        if (sym->st_shndx == SHN_COMMON) {
+            /* align symbol */
+            align = sym->st_value;
+            offset = bss_section->data_offset;
+            offset = (offset + align - 1) & -align;
+            sym->st_value = offset;
+            sym->st_shndx = bss_section->sh_num;
+            offset += sym->st_size;
+            bss_section->data_offset = offset;
+        }
+    }
+}
+
+/* relocate symbol table, resolve undefined symbols if do_resolve is
+   true and output error if undefined symbol. */
+ST_FUNC void relocate_syms(TCCState *s1, int do_resolve)
+{
+    ElfW(Sym) *sym, *esym, *sym_end;
+    int sym_bind, sh_num, sym_index;
+    const char *name;
+
+    sym_end = (ElfW(Sym) *)(symtab_section->data + symtab_section->data_offset);
+    for(sym = (ElfW(Sym) *)symtab_section->data + 1; 
+        sym < sym_end;
+        sym++) {
+        sh_num = sym->st_shndx;
+        if (sh_num == SHN_UNDEF) {
+            name = strtab_section->data + sym->st_name;
+            if (do_resolve) {
+#if defined TCC_IS_NATIVE && !defined _WIN32
+                void *addr;
+                name = symtab_section->link->data + sym->st_name;
+                addr = resolve_sym(s1, name);
+                if (addr) {
+                    sym->st_value = (addr_t)addr;
+                    goto found;
+                }
+#endif
+            } else if (s1->dynsym) {
+                /* if dynamic symbol exist, then use it */
+                sym_index = find_elf_sym(s1->dynsym, name);
+                if (sym_index) {
+                    esym = &((ElfW(Sym) *)s1->dynsym->data)[sym_index];
+                    sym->st_value = esym->st_value;
+                    goto found;
+                }
+            }
+            /* XXX: _fp_hw seems to be part of the ABI, so we ignore
+               it */
+            if (!strcmp(name, "_fp_hw"))
+                goto found;
+            /* only weak symbols are accepted to be undefined. Their
+               value is zero */
+            sym_bind = ELFW(ST_BIND)(sym->st_info);
+            if (sym_bind == STB_WEAK) {
+                sym->st_value = 0;
+            } else {
+                tcc_error_noabort("undefined symbol '%s'", name);
+            }
+        } else if (sh_num < SHN_LORESERVE) {
+            /* add section base */
+            sym->st_value += s1->sections[sym->st_shndx]->sh_addr;
+        }
+    found: ;
+    }
+}
+
+#ifdef TCC_HAS_RUNTIME_PLTGOT
+#ifdef TCC_TARGET_X86_64
+#define JMP_TABLE_ENTRY_SIZE 14
+static addr_t add_jmp_table(TCCState *s1, addr_t val)
+{
+    char *p = s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset;
+    s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE;
+    /* jmp *0x0(%rip) */
+    p[0] = 0xff;
+    p[1] = 0x25;
+    *(int *)(p + 2) = 0;
+    *(addr_t *)(p + 6) = val;
+    return (addr_t)p;
+}
+
+static addr_t add_got_table(TCCState *s1, addr_t val)
+{
+    addr_t *p = (addr_t *)(s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset);
+    s1->runtime_plt_and_got_offset += sizeof(addr_t);
+    *p = val;
+    return (addr_t)p;
+}
+#elif defined TCC_TARGET_ARM
+#define JMP_TABLE_ENTRY_SIZE 8
+static addr_t add_jmp_table(TCCState *s1, int val)
+{
+    uint32_t *p = (uint32_t *)(s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset);
+    s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE;
+    /* ldr pc, [pc, #-4] */
+    p[0] = 0xE51FF004;
+    p[1] = val;
+    return (addr_t)p;
+}
+#endif
+#endif /* def TCC_HAS_RUNTIME_PLTGOT */
+
+/* relocate a given section (CPU dependent) */
+ST_FUNC void relocate_section(TCCState *s1, Section *s)
+{
+    Section *sr;
+    ElfW_Rel *rel, *rel_end, *qrel;
+    ElfW(Sym) *sym;
+    int type, sym_index;
+    unsigned char *ptr;
+    addr_t val, addr;
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+    int esym_index;
+#endif
+
+    sr = s->reloc;
+    rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
+    qrel = (ElfW_Rel *)sr->data;
+    for(rel = qrel;
+        rel < rel_end;
+        rel++) {
+        ptr = s->data + rel->r_offset;
+
+        sym_index = ELFW(R_SYM)(rel->r_info);
+        sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+        val = sym->st_value;
+#ifdef TCC_TARGET_X86_64
+        val += rel->r_addend;
+#endif
+        type = ELFW(R_TYPE)(rel->r_info);
+        addr = s->sh_addr + rel->r_offset;
+
+        /* CPU specific */
+        switch(type) {
+#if defined(TCC_TARGET_I386)
+        case R_386_32:
+            if (s1->output_type == TCC_OUTPUT_DLL) {
+                esym_index = s1->symtab_to_dynsym[sym_index];
+                qrel->r_offset = rel->r_offset;
+                if (esym_index) {
+                    qrel->r_info = ELFW(R_INFO)(esym_index, R_386_32);
+                    qrel++;
+                    break;
+                } else {
+                    qrel->r_info = ELFW(R_INFO)(0, R_386_RELATIVE);
+                    qrel++;
+                }
+            }
+            *(int *)ptr += val;
+            break;
+        case R_386_PC32:
+            if (s1->output_type == TCC_OUTPUT_DLL) {
+                /* DLL relocation */
+                esym_index = s1->symtab_to_dynsym[sym_index];
+                if (esym_index) {
+                    qrel->r_offset = rel->r_offset;
+                    qrel->r_info = ELFW(R_INFO)(esym_index, R_386_PC32);
+                    qrel++;
+                    break;
+                }
+            }
+            *(int *)ptr += val - addr;
+            break;
+        case R_386_PLT32:
+            *(int *)ptr += val - addr;
+            break;
+        case R_386_GLOB_DAT:
+        case R_386_JMP_SLOT:
+            *(int *)ptr = val;
+            break;
+        case R_386_GOTPC:
+            *(int *)ptr += s1->got->sh_addr - addr;
+            break;
+        case R_386_GOTOFF:
+            *(int *)ptr += val - s1->got->sh_addr;
+            break;
+        case R_386_GOT32:
+            /* we load the got offset */
+            *(int *)ptr += s1->sym_attrs[sym_index].got_offset;
+            break;
+        case R_386_16:
+            if (s1->output_format != TCC_OUTPUT_FORMAT_BINARY) {
+            output_file:
+            tcc_error("can only produce 16-bit binary files");
+            }
+            *(short *)ptr += val;
+            break;
+        case R_386_PC16:
+            if (s1->output_format != TCC_OUTPUT_FORMAT_BINARY)
+            goto output_file;
+            *(short *)ptr += val - addr;
+            break;
+#elif defined(TCC_TARGET_ARM)
+        case R_ARM_PC24:
+        case R_ARM_CALL:
+        case R_ARM_JUMP24:
+        case R_ARM_PLT32:
+            {
+                int x, is_thumb, is_call, h, blx_avail;
+                x = (*(int *)ptr)&0xffffff;
+                (*(int *)ptr) &= 0xff000000;
+                if (x & 0x800000)
+                    x -= 0x1000000;
+                x <<= 2;
+                blx_avail = (TCC_ARM_VERSION >= 5);
+                is_thumb = val & 1;
+                is_call = (type == R_ARM_CALL);
+                x += val - addr;
+                h = x & 2;
+#ifdef TCC_HAS_RUNTIME_PLTGOT
+                if (s1->output_type == TCC_OUTPUT_MEMORY) {
+                    if ((x & 3) || x >= 0x2000000 || x < -0x2000000)
+                        if (!(x & 3) || !blx_avail || !is_call) {
+                            x += add_jmp_table(s1, val) - val; /* add veneer */
+                            is_thumb = 0; /* Veneer uses ARM instructions */
+                        }
+                }
+#endif
+                if ((x & 3) || x >= 0x2000000 || x < -0x2000000)
+                    if (!(x & 3) || !blx_avail || !is_call)
+                        tcc_error("can't relocate value at %x",addr);
+                x >>= 2;
+                x &= 0xffffff;
+                /* Only reached if blx is avail and it is a call */
+                if (is_thumb) {
+                    x |= h << 24;
+                    (*(int *)ptr) = 0xfa << 24; /* bl -> blx */
+                }
+                (*(int *)ptr) |= x;
+            }
+            break;
+        /* Since these relocations only concern Thumb-2 and blx instruction was
+           introduced before Thumb-2, we can assume blx is available and not
+           guard its use */
+        case R_ARM_THM_CALL:
+        case R_ARM_THM_JUMP24:
+	    {
+                int x, hi, lo, s, j1, j2, i1, i2, imm10, imm11;
+                int to_thumb, is_call, to_plt, blx_bit = 1 << 12;
+                Section *plt;
+
+                /* weak reference */
+                if (sym->st_shndx == SHN_UNDEF &&
+                    ELFW(ST_BIND)(sym->st_info) == STB_WEAK)
+                    break;
+
+                /* Get initial offset */
+                hi = (*(uint16_t *)ptr);
+                lo = (*(uint16_t *)(ptr+2));
+                s = (hi >> 10) & 1;
+                j1 = (lo >> 13) & 1;
+                j2 = (lo >> 11) & 1;
+                i1 = (j1 ^ s) ^ 1;
+                i2 = (j2 ^ s) ^ 1;
+                imm10 = hi & 0x3ff;
+                imm11 = lo & 0x7ff;
+                x = (s << 24) | (i1 << 23) | (i2 << 22) |
+                    (imm10 << 12) | (imm11 << 1);
+                if (x & 0x01000000)
+                    x -= 0x02000000;
+
+                /* Relocation infos */
+                to_thumb = val & 1;
+                plt = s1->plt;
+                to_plt = (val >= plt->sh_addr) &&
+                         (val < plt->sh_addr + plt->data_offset);
+                is_call = (type == R_ARM_THM_CALL);
+
+                /* Compute final offset */
+                if (to_plt && !is_call) /* Point to 1st instr of Thumb stub */
+                    x -= 4;
+                x += val - addr;
+                if (!to_thumb && is_call) {
+                    blx_bit = 0; /* bl -> blx */
+                    x = (x + 3) & -4; /* Compute offset from aligned PC */
+                }
+
+                /* Check that relocation is possible
+                   * offset must not be out of range
+                   * if target is to be entered in arm mode:
+                     - bit 1 must not set
+                     - instruction must be a call (bl) or a jump to PLT */
+                if (!to_thumb || x >= 0x1000000 || x < -0x1000000)
+                    if (to_thumb || (val & 2) || (!is_call && !to_plt))
+                        tcc_error("can't relocate value at %x",addr);
+
+                /* Compute and store final offset */
+                s = (x >> 24) & 1;
+                i1 = (x >> 23) & 1;
+                i2 = (x >> 22) & 1;
+                j1 = s ^ (i1 ^ 1);
+                j2 = s ^ (i2 ^ 1);
+                imm10 = (x >> 12) & 0x3ff;
+                imm11 = (x >> 1) & 0x7ff;
+                (*(uint16_t *)ptr) = (uint16_t) ((hi & 0xf800) |
+                                     (s << 10) | imm10);
+                (*(uint16_t *)(ptr+2)) = (uint16_t) ((lo & 0xc000) |
+                                (j1 << 13) | blx_bit | (j2 << 11) |
+                                imm11);
+            }
+            break;
+        case R_ARM_MOVT_ABS:
+        case R_ARM_MOVW_ABS_NC:
+            {
+                int x, imm4, imm12;
+                if (type == R_ARM_MOVT_ABS)
+                    val >>= 16;
+                imm12 = val & 0xfff;
+                imm4 = (val >> 12) & 0xf;
+                x = (imm4 << 16) | imm12;
+                if (type == R_ARM_THM_MOVT_ABS)
+                    *(int *)ptr |= x;
+                else
+                    *(int *)ptr += x;
+        }
+            break;
+        case R_ARM_THM_MOVT_ABS:
+        case R_ARM_THM_MOVW_ABS_NC:
+            {
+                int x, i, imm4, imm3, imm8;
+                if (type == R_ARM_THM_MOVT_ABS)
+                    val >>= 16;
+                imm8 = val & 0xff;
+                imm3 = (val >> 8) & 0x7;
+                i = (val >> 11) & 1;
+                imm4 = (val >> 12) & 0xf;
+                x = (imm3 << 28) | (imm8 << 16) | (i << 10) | imm4;
+                if (type == R_ARM_THM_MOVT_ABS)
+                    *(int *)ptr |= x;
+                else
+                    *(int *)ptr += x;
+        }
+            break;
+        case R_ARM_PREL31:
+            {
+                int x;
+                x = (*(int *)ptr) & 0x7fffffff;
+                (*(int *)ptr) &= 0x80000000;
+                x = (x * 2) / 2;
+                x += val - addr;
+                if((x^(x>>1))&0x40000000)
+                    tcc_error("can't relocate value at %x",addr);
+                (*(int *)ptr) |= x & 0x7fffffff;
+            }
+        case R_ARM_ABS32:
+            *(int *)ptr += val;
+            break;
+        case R_ARM_REL32:
+            *(int *)ptr += val - addr;
+            break;
+        case R_ARM_BASE_PREL:
+            *(int *)ptr += s1->got->sh_addr - addr;
+            break;
+        case R_ARM_GOTOFF32:
+            *(int *)ptr += val - s1->got->sh_addr;
+            break;
+        case R_ARM_GOT_BREL:
+            /* we load the got offset */
+            *(int *)ptr += s1->sym_attrs[sym_index].got_offset;
+            break;
+        case R_ARM_COPY:
+            break;
+        case R_ARM_V4BX:
+            /* trade Thumb support for ARMv4 support */
+            if ((0x0ffffff0 & *(int*)ptr) == 0x012FFF10)
+                *(int*)ptr ^= 0xE12FFF10 ^ 0xE1A0F000; /* BX Rm -> MOV PC, Rm */
+            break;
+        default:
+            fprintf(stderr,"FIXME: handle reloc type %x at %x [%p] to %x\n",
+                type, (unsigned)addr, ptr, (unsigned)val);
+            break;
+#elif defined(TCC_TARGET_C67)
+        case R_C60_32:
+            *(int *)ptr += val;
+            break;
+        case R_C60LO16:
+            {
+                uint32_t orig;
+                
+                /* put the low 16 bits of the absolute address */
+                // add to what is already there
+                
+                orig  =   ((*(int *)(ptr  )) >> 7) & 0xffff;
+                orig |=  (((*(int *)(ptr+4)) >> 7) & 0xffff) << 16;
+                
+                //patch both at once - assumes always in pairs Low - High
+                
+                *(int *) ptr    = (*(int *) ptr    & (~(0xffff << 7)) ) |  (((val+orig)      & 0xffff) << 7);
+                *(int *)(ptr+4) = (*(int *)(ptr+4) & (~(0xffff << 7)) ) | ((((val+orig)>>16) & 0xffff) << 7);
+            }
+            break;
+        case R_C60HI16:
+            break;
+        default:
+            fprintf(stderr,"FIXME: handle reloc type %x at %x [%p] to %x\n",
+                type, (unsigned)addr, ptr, (unsigned)val);
+            break;
+#elif defined(TCC_TARGET_X86_64)
+        case R_X86_64_64:
+            if (s1->output_type == TCC_OUTPUT_DLL) {
+                qrel->r_info = ELFW(R_INFO)(0, R_X86_64_RELATIVE);
+                qrel->r_addend = *(long long *)ptr + val;
+                qrel++;
+            }
+            *(long long *)ptr += val;
+            break;
+        case R_X86_64_32:
+        case R_X86_64_32S:
+            if (s1->output_type == TCC_OUTPUT_DLL) {
+                /* XXX: this logic may depend on TCC's codegen
+                   now TCC uses R_X86_64_32 even for a 64bit pointer */
+                qrel->r_info = ELFW(R_INFO)(0, R_X86_64_RELATIVE);
+                qrel->r_addend = *(int *)ptr + val;
+                qrel++;
+            }
+            *(int *)ptr += val;
+            break;
+
+        case R_X86_64_PC32:
+            if (s1->output_type == TCC_OUTPUT_DLL) {
+                /* DLL relocation */
+                esym_index = s1->symtab_to_dynsym[sym_index];
+                if (esym_index) {
+                    qrel->r_offset = rel->r_offset;
+                    qrel->r_info = ELFW(R_INFO)(esym_index, R_X86_64_PC32);
+                    qrel->r_addend = *(int *)ptr;
+                    qrel++;
+                    break;
+                }
+            }
+            /* fall through */
+        case R_X86_64_PLT32: {
+            long long diff;
+            diff = (long long)val - addr;
+            if (diff <= -2147483647 || diff > 2147483647) {
+#ifdef TCC_HAS_RUNTIME_PLTGOT
+                /* XXX: naive support for over 32bit jump */
+                if (s1->output_type == TCC_OUTPUT_MEMORY) {
+                    val = (add_jmp_table(s1, val - rel->r_addend) +
+                           rel->r_addend);
+                    diff = val - addr;
+                }
+#endif
+                if (diff <= -2147483647 || diff > 2147483647) {
+                    tcc_error("internal error: relocation failed");
+                }
+            }
+            *(int *)ptr += diff;
+        }
+            break;
+        case R_X86_64_GLOB_DAT:
+        case R_X86_64_JUMP_SLOT:
+            /* They don't need addend */
+            *(int *)ptr = val - rel->r_addend;
+            break;
+        case R_X86_64_GOTPCREL:
+#ifdef TCC_HAS_RUNTIME_PLTGOT
+            if (s1->output_type == TCC_OUTPUT_MEMORY) {
+                val = add_got_table(s1, val - rel->r_addend) + rel->r_addend;
+                *(int *)ptr += val - addr;
+                break;
+            }
+#endif
+            *(int *)ptr += (s1->got->sh_addr - addr +
+                            s1->sym_attrs[sym_index].got_offset - 4);
+            break;
+        case R_X86_64_GOTTPOFF:
+            *(int *)ptr += val - s1->got->sh_addr;
+            break;
+        case R_X86_64_GOT32:
+            /* we load the got offset */
+            *(int *)ptr += s1->sym_attrs[sym_index].got_offset;
+            break;
+#elif  defined(TCC_TARGET_IL)
+#else
+#error unsupported processor
+#endif
+        }
+    }
+    /* if the relocation is allocated, we change its symbol table */
+    if (sr->sh_flags & SHF_ALLOC)
+        sr->link = s1->dynsym;
+}
+
+/* relocate relocation table in 'sr' */
+static void relocate_rel(TCCState *s1, Section *sr)
+{
+    Section *s;
+    ElfW_Rel *rel, *rel_end;
+    
+    s = s1->sections[sr->sh_info];
+    rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
+    for(rel = (ElfW_Rel *)sr->data;
+        rel < rel_end;
+        rel++) {
+        rel->r_offset += s->sh_addr;
+    }
+}
+
+/* count the number of dynamic relocations so that we can reserve
+   their space */
+static int prepare_dynamic_rel(TCCState *s1, Section *sr)
+{
+    ElfW_Rel *rel, *rel_end;
+    int sym_index, esym_index, type, count;
+
+    count = 0;
+    rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
+    for(rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) {
+        sym_index = ELFW(R_SYM)(rel->r_info);
+        type = ELFW(R_TYPE)(rel->r_info);
+        switch(type) {
+#if defined(TCC_TARGET_I386)
+        case R_386_32:
+#elif defined(TCC_TARGET_X86_64)
+        case R_X86_64_32:
+        case R_X86_64_32S:
+        case R_X86_64_64:
+#endif
+            count++;
+            break;
+#if defined(TCC_TARGET_I386)
+        case R_386_PC32:
+#elif defined(TCC_TARGET_X86_64)
+        case R_X86_64_PC32:
+#endif
+            esym_index = s1->symtab_to_dynsym[sym_index];
+            if (esym_index)
+                count++;
+            break;
+        default:
+            break;
+        }
+    }
+    if (count) {
+        /* allocate the section */
+        sr->sh_flags |= SHF_ALLOC;
+        sr->sh_size = count * sizeof(ElfW_Rel);
+    }
+    return count;
+}
+
+static struct sym_attr *alloc_sym_attr(TCCState *s1, int index)
+{
+    int n;
+    struct sym_attr *tab;
+
+    if (index >= s1->nb_sym_attrs) {
+        /* find immediately bigger power of 2 and reallocate array */
+        n = 1;
+        while (index >= n)
+            n *= 2;
+        tab = tcc_realloc(s1->sym_attrs, n * sizeof(*s1->sym_attrs));
+        s1->sym_attrs = tab;
+        memset(s1->sym_attrs + s1->nb_sym_attrs, 0,
+               (n - s1->nb_sym_attrs) * sizeof(*s1->sym_attrs));
+        s1->nb_sym_attrs = n;
+    }
+    return &s1->sym_attrs[index];
+}
+
+/* XXX: suppress that */
+static void put32(unsigned char *p, uint32_t val)
+{
+    p[0] = val;
+    p[1] = val >> 8;
+    p[2] = val >> 16;
+    p[3] = val >> 24;
+}
+
+#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_ARM) || \
+    defined(TCC_TARGET_X86_64)
+static uint32_t get32(unsigned char *p)
+{
+    return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
+}
+#endif
+
+static void build_got(TCCState *s1)
+{
+    unsigned char *ptr;
+
+    /* if no got, then create it */
+    s1->got = new_section(s1, ".got", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE);
+    s1->got->sh_entsize = 4;
+    add_elf_sym(symtab_section, 0, 4, ELFW(ST_INFO)(STB_GLOBAL, STT_OBJECT), 
+                0, s1->got->sh_num, "_GLOBAL_OFFSET_TABLE_");
+    ptr = section_ptr_add(s1->got, 3 * PTR_SIZE);
+#if PTR_SIZE == 4
+    /* keep space for _DYNAMIC pointer, if present */
+    put32(ptr, 0);
+    /* two dummy got entries */
+    put32(ptr + 4, 0);
+    put32(ptr + 8, 0);
+#else
+    /* keep space for _DYNAMIC pointer, if present */
+    put32(ptr, 0);
+    put32(ptr + 4, 0);
+    /* two dummy got entries */
+    put32(ptr + 8, 0);
+    put32(ptr + 12, 0);
+    put32(ptr + 16, 0);
+    put32(ptr + 20, 0);
+#endif
+}
+
+/* put a got entry corresponding to a symbol in symtab_section. 'size'
+   and 'info' can be modifed if more precise info comes from the DLL */
+static void put_got_entry(TCCState *s1,
+                          int reloc_type, unsigned long size, int info, 
+                          int sym_index)
+{
+    int index;
+    const char *name;
+    ElfW(Sym) *sym;
+    unsigned long offset;
+    int *ptr;
+
+    if (!s1->got)
+        build_got(s1);
+
+    /* if a got entry already exists for that symbol, no need to add one */
+    if (sym_index < s1->nb_sym_attrs &&
+        s1->sym_attrs[sym_index].got_offset)
+        return;
+
+    alloc_sym_attr(s1, sym_index)->got_offset = s1->got->data_offset;
+
+    if (s1->dynsym) {
+        sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+        name = symtab_section->link->data + sym->st_name;
+        offset = sym->st_value;
+#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
+        if (reloc_type ==
+#ifdef TCC_TARGET_X86_64
+            R_X86_64_JUMP_SLOT
+#else
+            R_386_JMP_SLOT
+#endif
+            ) {
+            Section *plt;
+            uint8_t *p;
+            int modrm;
+
+#if defined(TCC_OUTPUT_DLL_WITH_PLT)
+            modrm = 0x25;
+#else
+            /* if we build a DLL, we add a %ebx offset */
+            if (s1->output_type == TCC_OUTPUT_DLL)
+                modrm = 0xa3;
+            else
+                modrm = 0x25;
+#endif
+
+            /* add a PLT entry */
+            plt = s1->plt;
+            if (plt->data_offset == 0) {
+                /* first plt entry */
+                p = section_ptr_add(plt, 16);
+                p[0] = 0xff; /* pushl got + PTR_SIZE */
+                p[1] = modrm + 0x10;
+                put32(p + 2, PTR_SIZE);
+                p[6] = 0xff; /* jmp *(got + PTR_SIZE * 2) */
+                p[7] = modrm;
+                put32(p + 8, PTR_SIZE * 2);
+            }
+
+            p = section_ptr_add(plt, 16);
+            p[0] = 0xff; /* jmp *(got + x) */
+            p[1] = modrm;
+            put32(p + 2, s1->got->data_offset);
+            p[6] = 0x68; /* push $xxx */
+            put32(p + 7, (plt->data_offset - 32) >> 1);
+            p[11] = 0xe9; /* jmp plt_start */
+            put32(p + 12, -(plt->data_offset));
+
+            /* the symbol is modified so that it will be relocated to
+               the PLT */
+#if !defined(TCC_OUTPUT_DLL_WITH_PLT)
+            if (s1->output_type == TCC_OUTPUT_EXE)
+#endif
+                offset = plt->data_offset - 16;
+        }
+#elif defined(TCC_TARGET_ARM)
+        if (reloc_type == R_ARM_JUMP_SLOT) {
+            Section *plt;
+            uint8_t *p;
+            
+            /* if we build a DLL, we add a %ebx offset */
+            if (s1->output_type == TCC_OUTPUT_DLL)
+                tcc_error("DLLs unimplemented!");
+
+            /* add a PLT entry */
+            plt = s1->plt;
+            if (plt->data_offset == 0) {
+                /* first plt entry */
+                p = section_ptr_add(plt, 16);
+                put32(p     , 0xe52de004);
+                put32(p +  4, 0xe59fe010);
+                put32(p +  8, 0xe08fe00e);
+                put32(p + 12, 0xe5bef008);
+            }
+
+            if (s1->sym_attrs[sym_index].plt_thumb_stub) {
+                p = section_ptr_add(plt, 20);
+                put32(p  , 0x4778); // bx pc
+                put32(p+2, 0x46c0); // nop
+                p += 4;
+            } else
+                p = section_ptr_add(plt, 16);
+            put32(p  , 0xe59fc004); // ldr ip, [pc, #4] // offset in GOT
+            put32(p+4, 0xe08fc00c); // add ip, pc, ip // absolute address or offset
+            put32(p+8, 0xe59cf000); // ldr pc, [ip] // load absolute address or load offset
+            put32(p+12, s1->got->data_offset);
+
+            /* the symbol is modified so that it will be relocated to
+               the PLT */
+            if (s1->output_type == TCC_OUTPUT_EXE)
+                offset = plt->data_offset - 16;
+        }
+#elif defined(TCC_TARGET_C67)
+        tcc_error("C67 got not implemented");
+#elif  defined(TCC_TARGET_IL)
+        tcc_error("IL got not implemented");
+#else
+#error unsupported CPU
+#endif
+        index = put_elf_sym(s1->dynsym, offset, 
+                            size, info, 0, sym->st_shndx, name);
+        /* put a got entry */
+        put_elf_reloc(s1->dynsym, s1->got, 
+                      s1->got->data_offset, 
+                      reloc_type, index);
+    }
+    ptr = section_ptr_add(s1->got, PTR_SIZE);
+    *ptr = 0;
+}
+
+/* build GOT and PLT entries */
+ST_FUNC void build_got_entries(TCCState *s1)
+{
+    Section *s;
+    ElfW_Rel *rel, *rel_end;
+    ElfW(Sym) *sym;
+    int i, type, reloc_type, sym_index;
+
+    for(i = 1; i < s1->nb_sections; i++) {
+        s = s1->sections[i];
+        if (s->sh_type != SHT_RELX)
+            continue;
+        /* no need to handle got relocations */
+        if (s->link != symtab_section)
+            continue;
+        rel_end = (ElfW_Rel *)(s->data + s->data_offset);
+        for(rel = (ElfW_Rel *)s->data;
+            rel < rel_end;
+            rel++) {
+            type = ELFW(R_TYPE)(rel->r_info);
+            switch(type) {
+#if defined(TCC_TARGET_I386)
+            case R_386_GOT32:
+            case R_386_GOTOFF:
+            case R_386_GOTPC:
+            case R_386_PLT32:
+                if (!s1->got)
+                    build_got(s1);
+                if (type == R_386_GOT32 || type == R_386_PLT32) {
+                    sym_index = ELFW(R_SYM)(rel->r_info);
+                    sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+                    /* look at the symbol got offset. If none, then add one */
+                    if (type == R_386_GOT32)
+                        reloc_type = R_386_GLOB_DAT;
+                    else
+                        reloc_type = R_386_JMP_SLOT;
+                    put_got_entry(s1, reloc_type, sym->st_size, sym->st_info, 
+                                  sym_index);
+                }
+                break;
+#elif defined(TCC_TARGET_ARM)
+            case R_ARM_GOT_BREL:
+            case R_ARM_GOTOFF32:
+            case R_ARM_BASE_PREL:
+            case R_ARM_PLT32:
+                if (!s1->got)
+                    build_got(s1);
+                if (type == R_ARM_GOT_BREL || type == R_ARM_PLT32) {
+                    sym_index = ELFW(R_SYM)(rel->r_info);
+                    sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+                    /* look at the symbol got offset. If none, then add one */
+                    if (type == R_ARM_GOT_BREL)
+                        reloc_type = R_ARM_GLOB_DAT;
+                    else
+                        reloc_type = R_ARM_JUMP_SLOT;
+                    put_got_entry(s1, reloc_type, sym->st_size, sym->st_info, 
+                                  sym_index);
+                }
+                break;
+#elif defined(TCC_TARGET_C67)
+            case R_C60_GOT32:
+            case R_C60_GOTOFF:
+            case R_C60_GOTPC:
+            case R_C60_PLT32:
+                if (!s1->got)
+                    build_got(s1);
+                if (type == R_C60_GOT32 || type == R_C60_PLT32) {
+                    sym_index = ELFW(R_SYM)(rel->r_info);
+                    sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+                    /* look at the symbol got offset. If none, then add one */
+                    if (type == R_C60_GOT32)
+                        reloc_type = R_C60_GLOB_DAT;
+                    else
+                        reloc_type = R_C60_JMP_SLOT;
+                    put_got_entry(s1, reloc_type, sym->st_size, sym->st_info, 
+                                  sym_index);
+                }
+                break;
+#elif defined(TCC_TARGET_X86_64)
+            case R_X86_64_GOT32:
+            case R_X86_64_GOTTPOFF:
+            case R_X86_64_GOTPCREL:
+            case R_X86_64_PLT32:
+                if (!s1->got)
+                    build_got(s1);
+                if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||
+                    type == R_X86_64_PLT32) {
+                    sym_index = ELFW(R_SYM)(rel->r_info);
+                    sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+                    /* look at the symbol got offset. If none, then add one */
+                    if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL)
+                        reloc_type = R_X86_64_GLOB_DAT;
+                    else
+                        reloc_type = R_X86_64_JUMP_SLOT;
+                    put_got_entry(s1, reloc_type, sym->st_size, sym->st_info, 
+                                  sym_index);
+                }
+                break;
+#elif  defined(TCC_TARGET_IL)
+#else
+#error unsupported CPU
+#endif
+            default:
+                break;
+            }
+        }
+    }
+}
+
+ST_FUNC Section *new_symtab(TCCState *s1,
+                           const char *symtab_name, int sh_type, int sh_flags,
+                           const char *strtab_name, 
+                           const char *hash_name, int hash_sh_flags)
+{
+    Section *symtab, *strtab, *hash;
+    int *ptr, nb_buckets;
+
+    symtab = new_section(s1, symtab_name, sh_type, sh_flags);
+    symtab->sh_entsize = sizeof(ElfW(Sym));
+    strtab = new_section(s1, strtab_name, SHT_STRTAB, sh_flags);
+    put_elf_str(strtab, "");
+    symtab->link = strtab;
+    put_elf_sym(symtab, 0, 0, 0, 0, 0, NULL);
+    
+    nb_buckets = 1;
+
+    hash = new_section(s1, hash_name, SHT_HASH, hash_sh_flags);
+    hash->sh_entsize = sizeof(int);
+    symtab->hash = hash;
+    hash->link = symtab;
+
+    ptr = section_ptr_add(hash, (2 + nb_buckets + 1) * sizeof(int));
+    ptr[0] = nb_buckets;
+    ptr[1] = 1;
+    memset(ptr + 2, 0, (nb_buckets + 1) * sizeof(int));
+    return symtab;
+}
+
+/* put dynamic tag */
+static void put_dt(Section *dynamic, int dt, addr_t val)
+{
+    ElfW(Dyn) *dyn;
+    dyn = section_ptr_add(dynamic, sizeof(ElfW(Dyn)));
+    dyn->d_tag = dt;
+    dyn->d_un.d_val = val;
+}
+
+static void add_init_array_defines(TCCState *s1, const char *section_name)
+{
+    Section *s;
+    long end_offset;
+    char sym_start[1024];
+    char sym_end[1024];
+    
+    snprintf(sym_start, sizeof(sym_start), "__%s_start", section_name + 1);
+    snprintf(sym_end, sizeof(sym_end), "__%s_end", section_name + 1);
+
+    s = find_section(s1, section_name);
+    if (!s) {
+        end_offset = 0;
+        s = data_section;
+    } else {
+        end_offset = s->data_offset;
+    }
+
+    add_elf_sym(symtab_section, 
+                0, 0,
+                ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                s->sh_num, sym_start);
+    add_elf_sym(symtab_section, 
+                end_offset, 0,
+                ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                s->sh_num, sym_end);
+}
+
+ST_FUNC void tcc_add_bcheck(TCCState *s1)
+{
+#ifdef CONFIG_TCC_BCHECK
+    unsigned long *ptr;
+    Section *init_section;
+    unsigned char *pinit;
+    int sym_index;
+
+    if (0 == s1->do_bounds_check)
+        return;
+
+    /* XXX: add an object file to do that */
+    ptr = section_ptr_add(bounds_section, sizeof(unsigned long));
+    *ptr = 0;
+    add_elf_sym(symtab_section, 0, 0,
+                ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                bounds_section->sh_num, "__bounds_start");
+#ifdef TCC_TARGET_I386
+    if (s1->output_type != TCC_OUTPUT_MEMORY) {
+        /* add 'call __bound_init()' in .init section */
+        init_section = find_section(s1, ".init");
+        pinit = section_ptr_add(init_section, 5);
+        pinit[0] = 0xe8;
+        put32(pinit + 1, -4);
+        sym_index = find_elf_sym(symtab_section, "__bound_init");
+        put_elf_reloc(symtab_section, init_section,
+                      init_section->data_offset - 4, R_386_PC32, sym_index);
+    }
+#endif
+#endif
+}
+
+static inline int tcc_add_support(TCCState *s1, const char *filename)
+{
+    char buf[1024];
+    snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
+    return tcc_add_file(s1, buf);
+}
+
+/* add tcc runtime libraries */
+ST_FUNC void tcc_add_runtime(TCCState *s1)
+{
+    tcc_add_bcheck(s1);
+
+    /* add libc */
+    if (!s1->nostdlib) {
+        tcc_add_library(s1, "c");
+#ifdef CONFIG_USE_LIBGCC
+        tcc_add_file(s1, TCC_LIBGCC);
+#elif !defined WITHOUT_LIBTCC
+        tcc_add_support(s1, "libtcc1.a");
+#endif
+        /* add crt end if not memory output */
+        if (s1->output_type != TCC_OUTPUT_MEMORY)
+            tcc_add_crt(s1, "crtn.o");
+    }
+}
+
+/* add various standard linker symbols (must be done after the
+   sections are filled (for example after allocating common
+   symbols)) */
+ST_FUNC void tcc_add_linker_symbols(TCCState *s1)
+{
+    char buf[1024];
+    int i;
+    Section *s;
+
+    add_elf_sym(symtab_section, 
+                text_section->data_offset, 0,
+                ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                text_section->sh_num, "_etext");
+    add_elf_sym(symtab_section, 
+                data_section->data_offset, 0,
+                ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                data_section->sh_num, "_edata");
+    add_elf_sym(symtab_section, 
+                bss_section->data_offset, 0,
+                ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                bss_section->sh_num, "_end");
+    /* horrible new standard ldscript defines */
+    add_init_array_defines(s1, ".preinit_array");
+    add_init_array_defines(s1, ".init_array");
+    add_init_array_defines(s1, ".fini_array");
+    
+    /* add start and stop symbols for sections whose name can be
+       expressed in C */
+    for(i = 1; i < s1->nb_sections; i++) {
+        s = s1->sections[i];
+        if (s->sh_type == SHT_PROGBITS &&
+            (s->sh_flags & SHF_ALLOC)) {
+            const char *p;
+            int ch;
+
+            /* check if section name can be expressed in C */
+            p = s->name;
+            for(;;) {
+                ch = *p;
+                if (!ch)
+                    break;
+                if (!isid(ch) && !isnum(ch))
+                    goto next_sec;
+                p++;
+            }
+            snprintf(buf, sizeof(buf), "__start_%s", s->name);
+            add_elf_sym(symtab_section, 
+                        0, 0,
+                        ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                        s->sh_num, buf);
+            snprintf(buf, sizeof(buf), "__stop_%s", s->name);
+            add_elf_sym(symtab_section,
+                        s->data_offset, 0,
+                        ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                        s->sh_num, buf);
+        }
+    next_sec: ;
+    }
+}
+
+static void tcc_output_binary(TCCState *s1, FILE *f,
+                              const int *section_order)
+{
+    Section *s;
+    int i, offset, size;
+
+    offset = 0;
+    for(i=1;i<s1->nb_sections;i++) {
+        s = s1->sections[section_order[i]];
+        if (s->sh_type != SHT_NOBITS &&
+            (s->sh_flags & SHF_ALLOC)) {
+            while (offset < s->sh_offset) {
+                fputc(0, f);
+                offset++;
+            }
+            size = s->sh_size;
+            fwrite(s->data, 1, size, f);
+            offset += size;
+        }
+    }
+}
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#define	HAVE_PHDR	1
+#define	EXTRA_RELITEMS	14
+
+/* move the relocation value from .dynsym to .got */
+void patch_dynsym_undef(TCCState *s1, Section *s)
+{
+    uint32_t *gotd = (void *)s1->got->data;
+    ElfW(Sym) *sym, *sym_end;
+
+    gotd += 3;	// dummy entries in .got
+    /* relocate symbols in .dynsym */
+    sym_end = (ElfW(Sym) *)(s->data + s->data_offset);
+    for (sym = (ElfW(Sym) *)s->data + 1; sym < sym_end; sym++) {
+	if (sym->st_shndx == SHN_UNDEF) {
+	    *gotd++ = sym->st_value + 6; // XXX 6 is magic ?
+	    sym->st_value = 0;
+	}
+    }
+}
+#else
+#define	HAVE_PHDR	0
+#define	EXTRA_RELITEMS	9
+
+/* zero plt offsets of weak symbols in .dynsym */
+void patch_dynsym_undef(TCCState *s1, Section *s)
+{
+    ElfW(Sym) *sym, *sym_end;
+
+    sym_end = (ElfW(Sym) *)(s->data + s->data_offset);
+    for (sym = (ElfW(Sym) *)s->data + 1; sym < sym_end; sym++)
+        if (sym->st_shndx == SHN_UNDEF && ELFW(ST_BIND)(sym->st_info) == STB_WEAK)
+            sym->st_value = 0;
+}
+#endif
+
+ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel)
+{
+	int sym_index = ELFW(R_SYM) (rel->r_info);
+	ElfW(Sym) *sym = &((ElfW(Sym) *) symtab_section->data)[sym_index];
+	unsigned long offset;
+
+	if (sym_index >= s1->nb_sym_attrs)
+		return;
+	offset = s1->sym_attrs[sym_index].got_offset;
+	section_reserve(s1->got, offset + PTR_SIZE);
+#ifdef TCC_TARGET_X86_64
+	/* only works for x86-64 */
+	put32(s1->got->data + offset + 4, sym->st_value >> 32);
+#endif
+	put32(s1->got->data + offset, sym->st_value & 0xffffffff);
+}
+
+ST_FUNC void fill_got(TCCState *s1)
+{
+	Section *s;
+	ElfW_Rel *rel, *rel_end;
+	int i;
+
+	for(i = 1; i < s1->nb_sections; i++) {
+		s = s1->sections[i];
+		if (s->sh_type != SHT_RELX)
+			continue;
+		/* no need to handle got relocations */
+		if (s->link != symtab_section)
+			continue;
+		rel_end = (ElfW_Rel *) (s->data + s->data_offset);
+		for(rel = (ElfW_Rel *) s->data; rel < rel_end; rel++) {
+			switch (ELFW(R_TYPE) (rel->r_info)) {
+			case R_X86_64_GOT32:
+			case R_X86_64_GOTPCREL:
+			case R_X86_64_PLT32:
+				fill_got_entry(s1, rel);
+				break;
+			}
+		}
+	}
+}
+
+
+/* output an ELF file */
+/* XXX: suppress unneeded sections */
+static int elf_output_file(TCCState *s1, const char *filename)
+{
+    ElfW(Ehdr) ehdr;
+    FILE *f;
+    int fd, mode, ret;
+    int *section_order;
+    int shnum, i, phnum, file_offset, offset, size, j, sh_order_index, k;
+    long long tmp;
+    addr_t addr;
+    Section *strsec, *s;
+    ElfW(Shdr) shdr, *sh;
+    ElfW(Phdr) *phdr, *ph;
+    Section *interp, *dynamic, *dynstr;
+    unsigned long saved_dynamic_data_offset;
+    ElfW(Sym) *sym;
+    int type, file_type;
+    addr_t rel_addr, rel_size;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+    addr_t bss_addr, bss_size;
+#endif
+
+    file_type = s1->output_type;
+    s1->nb_errors = 0;
+
+    if (file_type != TCC_OUTPUT_OBJ) {
+        tcc_add_runtime(s1);
+    }
+
+    phdr = NULL;
+    section_order = NULL;
+    interp = NULL;
+    dynamic = NULL;
+    dynstr = NULL; /* avoid warning */
+    saved_dynamic_data_offset = 0; /* avoid warning */
+    
+    if (file_type != TCC_OUTPUT_OBJ) {
+        relocate_common_syms();
+
+        tcc_add_linker_symbols(s1);
+
+        if (!s1->static_link) {
+            const char *name;
+            int sym_index, index;
+            ElfW(Sym) *esym, *sym_end;
+
+            if (file_type == TCC_OUTPUT_EXE) {
+                char *ptr;
+		/* allow override the dynamic loader */
+		const char *elfint = getenv("LD_SO");
+		if (elfint == NULL)
+		    elfint = CONFIG_TCC_ELFINTERP;
+                /* add interpreter section only if executable */
+                interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC);
+                interp->sh_addralign = 1;
+                ptr = section_ptr_add(interp, 1+strlen(elfint));
+                strcpy(ptr, elfint);
+            }
+
+            /* add dynamic symbol table */
+            s1->dynsym = new_symtab(s1, ".dynsym", SHT_DYNSYM, SHF_ALLOC,
+                                    ".dynstr", 
+                                    ".hash", SHF_ALLOC);
+            dynstr = s1->dynsym->link;
+            
+            /* add dynamic section */
+            dynamic = new_section(s1, ".dynamic", SHT_DYNAMIC, 
+                                  SHF_ALLOC | SHF_WRITE);
+            dynamic->link = dynstr;
+            dynamic->sh_entsize = sizeof(ElfW(Dyn));
+        
+            /* add PLT */
+            s1->plt = new_section(s1, ".plt", SHT_PROGBITS, 
+                                  SHF_ALLOC | SHF_EXECINSTR);
+            s1->plt->sh_entsize = 4;
+
+            build_got(s1);
+
+            /* scan for undefined symbols and see if they are in the
+               dynamic symbols. If a symbol STT_FUNC or STT_GNU_IFUNC
+               is found, then we add it in the PLT. If a symbol
+               STT_OBJECT is found, we add it in the .bss section with
+               a suitable relocation */
+            sym_end = (ElfW(Sym) *)(symtab_section->data + 
+                                    symtab_section->data_offset);
+            if (file_type == TCC_OUTPUT_EXE) {
+                for(sym = (ElfW(Sym) *)symtab_section->data + 1; 
+                    sym < sym_end;
+                    sym++) {
+                    if (sym->st_shndx == SHN_UNDEF) {
+                        name = symtab_section->link->data + sym->st_name;
+                        sym_index = find_elf_sym(s1->dynsymtab_section, name);
+                        if (sym_index) {
+                            esym = &((ElfW(Sym) *)s1->dynsymtab_section->data)[sym_index];
+                            type = ELFW(ST_TYPE)(esym->st_info);
+                            if ((type == STT_FUNC) || (type == STT_GNU_IFUNC)) {
+                                /* Indirect functions shall have STT_FUNC type
+                                 * in executable dynsym section. Indeed, a dlsym
+                                 * call following a lazy resolution would pick
+                                 * the symbol value from the executable dynsym
+                                 * entry which would contain the address of the
+                                 * function wanted by the caller of dlsym
+                                 * instead of the address of the function that
+                                 * would return that address */
+                                put_got_entry(s1, R_JMP_SLOT, esym->st_size, 
+                                              ELFW(ST_INFO)(STB_GLOBAL,STT_FUNC),
+                                              sym - (ElfW(Sym) *)symtab_section->data);
+                            } else if (type == STT_OBJECT) {
+                                unsigned long offset;
+                                ElfW(Sym) *dynsym, *dynsym_end;
+                                offset = bss_section->data_offset;
+                                /* XXX: which alignment ? */
+                                offset = (offset + 16 - 1) & -16;
+                                index = put_elf_sym(s1->dynsym, offset, esym->st_size, 
+                                                    esym->st_info, 0, 
+                                                    bss_section->sh_num, name);
+                                // Ensure R_COPY works for weak symbol aliases
+                                if (ELFW(ST_BIND)(esym->st_info) == STB_WEAK) {
+                                    dynsym_end = (ElfW(Sym) *)
+                                                 (s1->dynsymtab_section->data +
+                                                  s1->dynsymtab_section->data_offset);
+                                    for(dynsym = (ElfW(Sym) *)s1->dynsymtab_section->data + 1;
+                                        dynsym < dynsym_end; dynsym++) {
+                                        if ((dynsym->st_value == esym->st_value)
+                                           && (ELFW(ST_BIND)(dynsym->st_info) == STB_GLOBAL)) {
+                                            char *dynname;
+                                            dynname = s1->dynsymtab_section->link->data
+                                                      + dynsym->st_name;
+                                            put_elf_sym(s1->dynsym, offset,
+                                                        dynsym->st_size,
+                                                        dynsym->st_info, 0,
+                                                        bss_section->sh_num,
+                                                        dynname);
+                                            break;
+                                        }
+                                    }
+                                }
+                                put_elf_reloc(s1->dynsym, bss_section, 
+                                              offset, R_COPY, index);
+                                offset += esym->st_size;
+                                bss_section->data_offset = offset;
+                            }
+                        } else {
+                                /* STB_WEAK undefined symbols are accepted */
+                                /* XXX: _fp_hw seems to be part of the ABI, so we ignore
+                                   it */
+                            if (ELFW(ST_BIND)(sym->st_info) == STB_WEAK ||
+                                !strcmp(name, "_fp_hw")) {
+                            } else {
+                                tcc_error_noabort("undefined symbol '%s'", name);
+                            }
+                        }
+                    } else if (s1->rdynamic && 
+                               ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
+                        /* if -rdynamic option, then export all non
+                           local symbols */
+                        name = symtab_section->link->data + sym->st_name;
+                        put_elf_sym(s1->dynsym, sym->st_value, sym->st_size, 
+                                    sym->st_info, 0, 
+                                    sym->st_shndx, name);
+                    }
+                }
+            
+                if (s1->nb_errors)
+                    goto fail;
+
+                /* now look at unresolved dynamic symbols and export
+                   corresponding symbol */
+                sym_end = (ElfW(Sym) *)(s1->dynsymtab_section->data + 
+                                        s1->dynsymtab_section->data_offset);
+                for(esym = (ElfW(Sym) *)s1->dynsymtab_section->data + 1; 
+                    esym < sym_end;
+                    esym++) {
+                    if (esym->st_shndx == SHN_UNDEF) {
+                        name = s1->dynsymtab_section->link->data + esym->st_name;
+                        sym_index = find_elf_sym(symtab_section, name);
+                        if (sym_index) {
+                            /* XXX: avoid adding a symbol if already
+                               present because of -rdynamic ? */
+                            sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+                            put_elf_sym(s1->dynsym, sym->st_value, sym->st_size, 
+                                        sym->st_info, 0, 
+                                        sym->st_shndx, name);
+                        } else {
+                            if (ELFW(ST_BIND)(esym->st_info) == STB_WEAK) {
+                                /* weak symbols can stay undefined */
+                            } else {
+                                tcc_warning("undefined dynamic symbol '%s'", name);
+                            }
+                        }
+                    }
+                }
+            } else {
+                int nb_syms;
+                /* shared library case : we simply export all the global symbols */
+                nb_syms = symtab_section->data_offset / sizeof(ElfW(Sym));
+                s1->symtab_to_dynsym = tcc_mallocz(sizeof(int) * nb_syms);
+                for(sym = (ElfW(Sym) *)symtab_section->data + 1; 
+                    sym < sym_end;
+                    sym++) {
+                    if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
+#if defined(TCC_OUTPUT_DLL_WITH_PLT)
+                        if ((ELFW(ST_TYPE)(sym->st_info) == STT_FUNC ||
+                            ELFW(ST_TYPE)(sym->st_info) == STT_GNU_IFUNC)
+                            && sym->st_shndx == SHN_UNDEF) {
+                            int visibility = ELFW(ST_BIND)(sym->st_info);
+                            put_got_entry(s1, R_JMP_SLOT, sym->st_size, 
+                                          ELFW(ST_INFO)(visibility,STT_FUNC),
+                                          sym - (ElfW(Sym) *)symtab_section->data);
+                        }
+                        else if (ELFW(ST_TYPE)(sym->st_info) == STT_OBJECT) {
+                            put_got_entry(s1, R_X86_64_GLOB_DAT, sym->st_size, 
+                                          sym->st_info, 
+                                          sym - (ElfW(Sym) *)symtab_section->data);
+                        }
+                        else
+#endif
+                        {
+                            name = symtab_section->link->data + sym->st_name;
+                            index = put_elf_sym(s1->dynsym, sym->st_value, sym->st_size, 
+                                                sym->st_info, 0, 
+                                                sym->st_shndx, name);
+                            s1->symtab_to_dynsym[sym - 
+                                                 (ElfW(Sym) *)symtab_section->data] = 
+                                index;
+                        }
+                    }
+                }
+            }
+
+            build_got_entries(s1);
+        
+            /* add a list of needed dlls */
+            for(i = 0; i < s1->nb_loaded_dlls; i++) {
+                DLLReference *dllref = s1->loaded_dlls[i];
+                if (dllref->level == 0)
+                    put_dt(dynamic, DT_NEEDED, put_elf_str(dynstr, dllref->name));
+            }
+
+            if (s1->rpath)
+                put_dt(dynamic, DT_RPATH, put_elf_str(dynstr, s1->rpath));
+
+            /* XXX: currently, since we do not handle PIC code, we
+               must relocate the readonly segments */
+            if (file_type == TCC_OUTPUT_DLL) {
+                if (s1->soname)
+                    put_dt(dynamic, DT_SONAME, put_elf_str(dynstr, s1->soname));
+                put_dt(dynamic, DT_TEXTREL, 0);
+            }
+
+            if (s1->symbolic)
+                put_dt(dynamic, DT_SYMBOLIC, 0);
+
+            /* add necessary space for other entries */
+            saved_dynamic_data_offset = dynamic->data_offset;
+            dynamic->data_offset += sizeof(ElfW(Dyn)) * EXTRA_RELITEMS;
+        } else {
+            /* still need to build got entries in case of static link */
+            build_got_entries(s1);
+        }
+    }
+
+    memset(&ehdr, 0, sizeof(ehdr));
+
+    /* we add a section for symbols */
+    strsec = new_section(s1, ".shstrtab", SHT_STRTAB, 0);
+    put_elf_str(strsec, "");
+    
+    /* compute number of sections */
+    shnum = s1->nb_sections;
+
+    /* this array is used to reorder sections in the output file */
+    section_order = tcc_malloc(sizeof(int) * shnum);
+    section_order[0] = 0;
+    sh_order_index = 1;
+    
+    /* compute number of program headers */
+    switch(file_type) {
+    default:
+    case TCC_OUTPUT_OBJ:
+        phnum = 0;
+        break;
+    case TCC_OUTPUT_EXE:
+        if (!s1->static_link)
+            phnum = 4 + HAVE_PHDR;
+        else
+            phnum = 2;
+        break;
+    case TCC_OUTPUT_DLL:
+        phnum = 3;
+        break;
+    }
+
+    /* allocate strings for section names and decide if an unallocated
+       section should be output */
+    /* NOTE: the strsec section comes last, so its size is also
+       correct ! */
+    for(i = 1; i < s1->nb_sections; i++) {
+        s = s1->sections[i];
+        s->sh_name = put_elf_str(strsec, s->name);
+#if 0 //gr       
+        printf("section: f=%08x t=%08x i=%08x %s %s\n", 
+               s->sh_flags, 
+               s->sh_type, 
+               s->sh_info, 
+               s->name, 
+               s->reloc ? s->reloc->name : "n"
+               ); 
+#endif
+        /* when generating a DLL, we include relocations but we may
+           patch them */
+        if (file_type == TCC_OUTPUT_DLL && 
+            s->sh_type == SHT_RELX && 
+            !(s->sh_flags & SHF_ALLOC)) {
+            /* //gr: avoid bogus relocs for empty (debug) sections */
+            if (s1->sections[s->sh_info]->sh_flags & SHF_ALLOC)
+                prepare_dynamic_rel(s1, s);
+            else if (s1->do_debug)
+                s->sh_size = s->data_offset;
+        } else if (s1->do_debug ||
+            file_type == TCC_OUTPUT_OBJ || 
+            (s->sh_flags & SHF_ALLOC) ||
+            i == (s1->nb_sections - 1)) {
+            /* we output all sections if debug or object file */
+            s->sh_size = s->data_offset;
+        }
+    }
+
+    /* allocate program segment headers */
+    phdr = tcc_mallocz(phnum * sizeof(ElfW(Phdr)));
+        
+    if (s1->output_format == TCC_OUTPUT_FORMAT_ELF) {
+        file_offset = sizeof(ElfW(Ehdr)) + phnum * sizeof(ElfW(Phdr));
+    } else {
+        file_offset = 0;
+    }
+    if (phnum > 0) {
+        /* compute section to program header mapping */
+        if (s1->has_text_addr) { 
+            int a_offset, p_offset;
+            addr = s1->text_addr;
+            /* we ensure that (addr % ELF_PAGE_SIZE) == file_offset %
+               ELF_PAGE_SIZE */
+            a_offset = (int) (addr & (s1->section_align - 1));
+            p_offset = file_offset & (s1->section_align - 1);
+            if (a_offset < p_offset) 
+                a_offset += s1->section_align;
+            file_offset += (a_offset - p_offset);
+        } else {
+            if (file_type == TCC_OUTPUT_DLL)
+                addr = 0;
+            else
+                addr = ELF_START_ADDR;
+            /* compute address after headers */
+            addr += (file_offset & (s1->section_align - 1));
+        }
+        
+        /* dynamic relocation table information, for .dynamic section */
+        rel_size = 0;
+        rel_addr = 0;
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+        bss_addr = bss_size = 0;
+#endif
+        /* leave one program header for the program interpreter */
+        ph = &phdr[0];
+        if (interp)
+            ph += 1 + HAVE_PHDR;
+
+        for(j = 0; j < 2; j++) {
+            ph->p_type = PT_LOAD;
+            if (j == 0)
+                ph->p_flags = PF_R | PF_X;
+            else
+                ph->p_flags = PF_R | PF_W;
+            ph->p_align = s1->section_align;
+            
+            /* we do the following ordering: interp, symbol tables,
+               relocations, progbits, nobits */
+            /* XXX: do faster and simpler sorting */
+            for(k = 0; k < 5; k++) {
+                for(i = 1; i < s1->nb_sections; i++) {
+                    s = s1->sections[i];
+                    /* compute if section should be included */
+                    if (j == 0) {
+                        if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) != 
+                            SHF_ALLOC)
+                            continue;
+                    } else {
+                        if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) != 
+                            (SHF_ALLOC | SHF_WRITE))
+                            continue;
+                    }
+                    if (s == interp) {
+                        if (k != 0)
+                            continue;
+                    } else if (s->sh_type == SHT_DYNSYM ||
+                               s->sh_type == SHT_STRTAB ||
+                               s->sh_type == SHT_HASH) {
+                        if (k != 1)
+                            continue;
+                    } else if (s->sh_type == SHT_RELX) {
+                        if (k != 2)
+                            continue;
+                    } else if (s->sh_type == SHT_NOBITS) {
+                        if (k != 4)
+                            continue;
+                    } else {
+                        if (k != 3)
+                            continue;
+                    }
+                    section_order[sh_order_index++] = i;
+
+                    /* section matches: we align it and add its size */
+                    tmp = addr;
+                    addr = (addr + s->sh_addralign - 1) & 
+                        ~(s->sh_addralign - 1);
+                    file_offset += (int) ( addr - tmp );
+                    s->sh_offset = file_offset;
+                    s->sh_addr = addr;
+                    
+                    /* update program header infos */
+                    if (ph->p_offset == 0) {
+                        ph->p_offset = file_offset;
+                        ph->p_vaddr = addr;
+                        ph->p_paddr = ph->p_vaddr;
+                    }
+                    /* update dynamic relocation infos */
+                    if (s->sh_type == SHT_RELX) {
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+                        if (!strcmp(strsec->data + s->sh_name, ".rel.got")) { // rel_size == 0) {
+                            rel_addr = addr;
+			    rel_size += s->sh_size;	// XXX only first rel.
+			}
+                        if (!strcmp(strsec->data + s->sh_name, ".rel.bss")) { // rel_size == 0) {
+                            bss_addr = addr;
+			    bss_size = s->sh_size;	// XXX only first rel.
+			}
+#else
+                        if (rel_size == 0)
+                            rel_addr = addr;
+                        rel_size += s->sh_size;
+#endif
+                    }
+                    addr += s->sh_size;
+                    if (s->sh_type != SHT_NOBITS)
+                        file_offset += s->sh_size;
+                }
+            }
+            ph->p_filesz = file_offset - ph->p_offset;
+            ph->p_memsz = addr - ph->p_vaddr;
+            ph++;
+            if (j == 0) {
+                if (s1->output_format == TCC_OUTPUT_FORMAT_ELF) {
+                    /* if in the middle of a page, we duplicate the page in
+                       memory so that one copy is RX and the other is RW */
+                    if ((addr & (s1->section_align - 1)) != 0)
+                        addr += s1->section_align;
+                } else {
+                    addr = (addr + s1->section_align - 1) & ~(s1->section_align - 1);
+                    file_offset = (file_offset + s1->section_align - 1) &
+                        ~(s1->section_align - 1);
+                }
+            }
+        }
+
+        /* if interpreter, then add corresponing program header */
+        if (interp) {
+            ph = &phdr[0];
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+	    {
+		int len = phnum * sizeof(ElfW(Phdr));
+
+		ph->p_type = PT_PHDR;
+		ph->p_offset = sizeof(ElfW(Ehdr));
+		ph->p_vaddr = interp->sh_addr - len;
+		ph->p_paddr = ph->p_vaddr;
+		ph->p_filesz = ph->p_memsz = len;
+		ph->p_flags = PF_R | PF_X;
+		ph->p_align = 4; // interp->sh_addralign;
+		ph++;
+	    }
+#endif
+
+            ph->p_type = PT_INTERP;
+            ph->p_offset = interp->sh_offset;
+            ph->p_vaddr = interp->sh_addr;
+            ph->p_paddr = ph->p_vaddr;
+            ph->p_filesz = interp->sh_size;
+            ph->p_memsz = interp->sh_size;
+            ph->p_flags = PF_R;
+            ph->p_align = interp->sh_addralign;
+        }
+        
+        /* if dynamic section, then add corresponing program header */
+        if (dynamic) {
+            ElfW(Sym) *sym_end;
+
+            ph = &phdr[phnum - 1];
+            
+            ph->p_type = PT_DYNAMIC;
+            ph->p_offset = dynamic->sh_offset;
+            ph->p_vaddr = dynamic->sh_addr;
+            ph->p_paddr = ph->p_vaddr;
+            ph->p_filesz = dynamic->sh_size;
+            ph->p_memsz = dynamic->sh_size;
+            ph->p_flags = PF_R | PF_W;
+            ph->p_align = dynamic->sh_addralign;
+
+            /* put GOT dynamic section address */
+            put32(s1->got->data, dynamic->sh_addr);
+
+            /* relocate the PLT */
+            if (file_type == TCC_OUTPUT_EXE
+#if defined(TCC_OUTPUT_DLL_WITH_PLT)
+                || file_type == TCC_OUTPUT_DLL
+#endif
+                ) {
+                uint8_t *p, *p_end;
+
+                p = s1->plt->data;
+                p_end = p + s1->plt->data_offset;
+                if (p < p_end) {
+#if defined(TCC_TARGET_I386)
+                    put32(p + 2, get32(p + 2) + s1->got->sh_addr);
+                    put32(p + 8, get32(p + 8) + s1->got->sh_addr);
+                    p += 16;
+                    while (p < p_end) {
+                        put32(p + 2, get32(p + 2) + s1->got->sh_addr);
+                        p += 16;
+                    }
+#elif defined(TCC_TARGET_X86_64)
+                    int x = s1->got->sh_addr - s1->plt->sh_addr - 6;
+                    put32(p + 2, get32(p + 2) + x);
+                    put32(p + 8, get32(p + 8) + x - 6);
+                    p += 16;
+                    while (p < p_end) {
+                        put32(p + 2, get32(p + 2) + x + s1->plt->data - p);
+                        p += 16;
+                    }
+#elif defined(TCC_TARGET_ARM)
+                    int x;
+                    x=s1->got->sh_addr - s1->plt->sh_addr - 12;
+                    p += 16;
+                    while (p < p_end) {
+                        if (get32(p) == 0x46c04778) /* PLT Thumb stub present */
+                            p += 4;
+                        put32(p + 12, x + get32(p + 12) + s1->plt->data - p);
+                        p += 16;
+                    }
+#elif defined(TCC_TARGET_C67)
+                    /* XXX: TODO */
+#elif  defined(TCC_TARGET_IL)
+#else
+#error unsupported CPU
+#endif
+                }
+            }
+
+            /* relocate symbols in .dynsym */
+            sym_end = (ElfW(Sym) *)(s1->dynsym->data + s1->dynsym->data_offset);
+            for(sym = (ElfW(Sym) *)s1->dynsym->data + 1; 
+                sym < sym_end;
+                sym++) {
+                if (sym->st_shndx == SHN_UNDEF) {
+                    /* relocate to the PLT if the symbol corresponds
+                       to a PLT entry */
+                    if (sym->st_value)
+                        sym->st_value += s1->plt->sh_addr;
+                } else if (sym->st_shndx < SHN_LORESERVE) {
+                    /* do symbol relocation */
+                    sym->st_value += s1->sections[sym->st_shndx]->sh_addr;
+                }
+            }
+
+            /* put dynamic section entries */
+            dynamic->data_offset = saved_dynamic_data_offset;
+            put_dt(dynamic, DT_HASH, s1->dynsym->hash->sh_addr);
+            put_dt(dynamic, DT_STRTAB, dynstr->sh_addr);
+            put_dt(dynamic, DT_SYMTAB, s1->dynsym->sh_addr);
+            put_dt(dynamic, DT_STRSZ, dynstr->data_offset);
+            put_dt(dynamic, DT_SYMENT, sizeof(ElfW(Sym)));
+#ifdef TCC_TARGET_X86_64
+            put_dt(dynamic, DT_RELA, rel_addr);
+            put_dt(dynamic, DT_RELASZ, rel_size);
+            put_dt(dynamic, DT_RELAENT, sizeof(ElfW_Rel));
+#else
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+            put_dt(dynamic, DT_PLTGOT, s1->got->sh_addr);
+            put_dt(dynamic, DT_PLTRELSZ, rel_size);
+            put_dt(dynamic, DT_JMPREL, rel_addr);
+            put_dt(dynamic, DT_PLTREL, DT_REL);
+            put_dt(dynamic, DT_REL, bss_addr);
+            put_dt(dynamic, DT_RELSZ, bss_size);
+#else
+            put_dt(dynamic, DT_REL, rel_addr);
+            put_dt(dynamic, DT_RELSZ, rel_size);
+            put_dt(dynamic, DT_RELENT, sizeof(ElfW_Rel));
+#endif
+#endif
+            if (s1->do_debug)
+                put_dt(dynamic, DT_DEBUG, 0);
+            put_dt(dynamic, DT_NULL, 0);
+        }
+
+        ehdr.e_phentsize = sizeof(ElfW(Phdr));
+        ehdr.e_phnum = phnum;
+        ehdr.e_phoff = sizeof(ElfW(Ehdr));
+    }
+
+    /* all other sections come after */
+    for(i = 1; i < s1->nb_sections; i++) {
+        s = s1->sections[i];
+        if (phnum > 0 && (s->sh_flags & SHF_ALLOC))
+            continue;
+        section_order[sh_order_index++] = i;
+        
+        file_offset = (file_offset + s->sh_addralign - 1) & 
+            ~(s->sh_addralign - 1);
+        s->sh_offset = file_offset;
+        if (s->sh_type != SHT_NOBITS)
+            file_offset += s->sh_size;
+    }
+    
+    /* if building executable or DLL, then relocate each section
+       except the GOT which is already relocated */
+    if (file_type != TCC_OUTPUT_OBJ) {
+        relocate_syms(s1, 0);
+
+        if (s1->nb_errors != 0) {
+        fail:
+            ret = -1;
+            goto the_end;
+        }
+
+        /* relocate sections */
+        /* XXX: ignore sections with allocated relocations ? */
+        for(i = 1; i < s1->nb_sections; i++) {
+            s = s1->sections[i];
+            if (s->reloc && s != s1->got)
+                relocate_section(s1, s);
+        }
+
+        /* relocate relocation entries if the relocation tables are
+           allocated in the executable */
+        for(i = 1; i < s1->nb_sections; i++) {
+            s = s1->sections[i];
+            if ((s->sh_flags & SHF_ALLOC) &&
+                s->sh_type == SHT_RELX) {
+                relocate_rel(s1, s);
+            }
+        }
+
+        /* get entry point address */
+        if (file_type == TCC_OUTPUT_EXE)
+            ehdr.e_entry = get_elf_sym_addr(s1, "_start", 1);
+        else
+            ehdr.e_entry = text_section->sh_addr; /* XXX: is it correct ? */
+    }
+    if (file_type == TCC_OUTPUT_EXE && s1->static_link)
+        fill_got(s1);
+
+    /* write elf file */
+    if (file_type == TCC_OUTPUT_OBJ)
+        mode = 0666;
+    else
+        mode = 0777;
+    unlink(filename);
+    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode); 
+    if (fd < 0) {
+        tcc_error_noabort("could not write '%s'", filename);
+        goto fail;
+    }
+    f = fdopen(fd, "wb");
+    if (s1->verbose)
+        printf("<- %s\n", filename);
+
+#ifdef TCC_TARGET_COFF
+    if (s1->output_format == TCC_OUTPUT_FORMAT_COFF) {
+        tcc_output_coff(s1, f);
+    } else
+#endif
+    if (s1->output_format == TCC_OUTPUT_FORMAT_ELF) {
+        sort_syms(s1, symtab_section);
+        
+        /* align to 4 */
+        file_offset = (file_offset + 3) & -4;
+    
+        /* fill header */
+        ehdr.e_ident[0] = ELFMAG0;
+        ehdr.e_ident[1] = ELFMAG1;
+        ehdr.e_ident[2] = ELFMAG2;
+        ehdr.e_ident[3] = ELFMAG3;
+        ehdr.e_ident[4] = ELFCLASSW;
+        ehdr.e_ident[5] = ELFDATA2LSB;
+        ehdr.e_ident[6] = EV_CURRENT;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+        ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+#endif
+#ifdef TCC_TARGET_ARM
+#ifdef TCC_ARM_EABI
+        ehdr.e_ident[EI_OSABI] = 0;
+        ehdr.e_flags = 4 << 24;
+#else
+        ehdr.e_ident[EI_OSABI] = ELFOSABI_ARM;
+#endif
+#endif
+        switch(file_type) {
+        default:
+        case TCC_OUTPUT_EXE:
+            ehdr.e_type = ET_EXEC;
+            break;
+        case TCC_OUTPUT_DLL:
+            ehdr.e_type = ET_DYN;
+            break;
+        case TCC_OUTPUT_OBJ:
+            ehdr.e_type = ET_REL;
+            break;
+        }
+        ehdr.e_machine = EM_TCC_TARGET;
+        ehdr.e_version = EV_CURRENT;
+        ehdr.e_shoff = file_offset;
+        ehdr.e_ehsize = sizeof(ElfW(Ehdr));
+        ehdr.e_shentsize = sizeof(ElfW(Shdr));
+        ehdr.e_shnum = shnum;
+        ehdr.e_shstrndx = shnum - 1;
+        
+        fwrite(&ehdr, 1, sizeof(ElfW(Ehdr)), f);
+        fwrite(phdr, 1, phnum * sizeof(ElfW(Phdr)), f);
+        offset = sizeof(ElfW(Ehdr)) + phnum * sizeof(ElfW(Phdr));
+
+        for(i=1;i<s1->nb_sections;i++) {
+            s = s1->sections[section_order[i]];
+            if (s->sh_type != SHT_NOBITS) {
+		if (s->sh_type == SHT_DYNSYM)
+		    patch_dynsym_undef(s1, s);
+                while (offset < s->sh_offset) {
+                    fputc(0, f);
+                    offset++;
+                }
+                size = s->sh_size;
+                fwrite(s->data, 1, size, f);
+                offset += size;
+            }
+        }
+
+        /* output section headers */
+        while (offset < ehdr.e_shoff) {
+            fputc(0, f);
+            offset++;
+        }
+    
+        for(i=0;i<s1->nb_sections;i++) {
+            sh = &shdr;
+            memset(sh, 0, sizeof(ElfW(Shdr)));
+            s = s1->sections[i];
+            if (s) {
+                sh->sh_name = s->sh_name;
+                sh->sh_type = s->sh_type;
+                sh->sh_flags = s->sh_flags;
+                sh->sh_entsize = s->sh_entsize;
+                sh->sh_info = s->sh_info;
+                if (s->link)
+                    sh->sh_link = s->link->sh_num;
+                sh->sh_addralign = s->sh_addralign;
+                sh->sh_addr = s->sh_addr;
+                sh->sh_offset = s->sh_offset;
+                sh->sh_size = s->sh_size;
+            }
+            fwrite(sh, 1, sizeof(ElfW(Shdr)), f);
+        }
+    } else {
+        tcc_output_binary(s1, f, section_order);
+    }
+    fclose(f);
+
+    ret = 0;
+ the_end:
+    tcc_free(s1->symtab_to_dynsym);
+    tcc_free(section_order);
+    tcc_free(phdr);
+    tcc_free(s1->sym_attrs);
+    return ret;
+}
+
+LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename)
+{
+    int ret;
+#ifdef TCC_TARGET_PE
+    if (s->output_type != TCC_OUTPUT_OBJ) {
+        ret = pe_output_file(s, filename);
+    } else
+#endif
+    {
+        ret = elf_output_file(s, filename);
+    }
+    return ret;
+}
+
+static void *load_data(int fd, unsigned long file_offset, unsigned long size)
+{
+    void *data;
+
+    data = tcc_malloc(size);
+    lseek(fd, file_offset, SEEK_SET);
+    read(fd, data, size);
+    return data;
+}
+
+typedef struct SectionMergeInfo {
+    Section *s;            /* corresponding existing section */
+    unsigned long offset;  /* offset of the new section in the existing section */
+    uint8_t new_section;       /* true if section 's' was added */
+    uint8_t link_once;         /* true if link once section */
+} SectionMergeInfo;
+
+/* load an object file and merge it with current files */
+/* XXX: handle correctly stab (debug) info */
+ST_FUNC int tcc_load_object_file(TCCState *s1, 
+                                int fd, unsigned long file_offset)
+{ 
+    ElfW(Ehdr) ehdr;
+    ElfW(Shdr) *shdr, *sh;
+    int size, i, j, offset, offseti, nb_syms, sym_index, ret;
+    unsigned char *strsec, *strtab;
+    int *old_to_new_syms;
+    char *sh_name, *name;
+    SectionMergeInfo *sm_table, *sm;
+    ElfW(Sym) *sym, *symtab;
+    ElfW_Rel *rel, *rel_end;
+    Section *s;
+
+    int stab_index;
+    int stabstr_index;
+
+    stab_index = stabstr_index = 0;
+
+    if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
+        goto fail1;
+    if (ehdr.e_ident[0] != ELFMAG0 ||
+        ehdr.e_ident[1] != ELFMAG1 ||
+        ehdr.e_ident[2] != ELFMAG2 ||
+        ehdr.e_ident[3] != ELFMAG3)
+        goto fail1;
+    /* test if object file */
+    if (ehdr.e_type != ET_REL)
+        goto fail1;
+    /* test CPU specific stuff */
+    if (ehdr.e_ident[5] != ELFDATA2LSB ||
+        ehdr.e_machine != EM_TCC_TARGET) {
+    fail1:
+        tcc_error_noabort("invalid object file");
+        return -1;
+    }
+    /* read sections */
+    shdr = load_data(fd, file_offset + ehdr.e_shoff, 
+                     sizeof(ElfW(Shdr)) * ehdr.e_shnum);
+    sm_table = tcc_mallocz(sizeof(SectionMergeInfo) * ehdr.e_shnum);
+    
+    /* load section names */
+    sh = &shdr[ehdr.e_shstrndx];
+    strsec = load_data(fd, file_offset + sh->sh_offset, sh->sh_size);
+
+    /* load symtab and strtab */
+    old_to_new_syms = NULL;
+    symtab = NULL;
+    strtab = NULL;
+    nb_syms = 0;
+    for(i = 1; i < ehdr.e_shnum; i++) {
+        sh = &shdr[i];
+        if (sh->sh_type == SHT_SYMTAB) {
+            if (symtab) {
+                tcc_error_noabort("object must contain only one symtab");
+            fail:
+                ret = -1;
+                goto the_end;
+            }
+            nb_syms = sh->sh_size / sizeof(ElfW(Sym));
+            symtab = load_data(fd, file_offset + sh->sh_offset, sh->sh_size);
+            sm_table[i].s = symtab_section;
+
+            /* now load strtab */
+            sh = &shdr[sh->sh_link];
+            strtab = load_data(fd, file_offset + sh->sh_offset, sh->sh_size);
+        }
+    }
+        
+    /* now examine each section and try to merge its content with the
+       ones in memory */
+    for(i = 1; i < ehdr.e_shnum; i++) {
+        /* no need to examine section name strtab */
+        if (i == ehdr.e_shstrndx)
+            continue;
+        sh = &shdr[i];
+        sh_name = strsec + sh->sh_name;
+        /* ignore sections types we do not handle */
+        if (sh->sh_type != SHT_PROGBITS &&
+            sh->sh_type != SHT_RELX && 
+#ifdef TCC_ARM_EABI
+            sh->sh_type != SHT_ARM_EXIDX &&
+#endif
+            sh->sh_type != SHT_NOBITS && 
+            sh->sh_type != SHT_PREINIT_ARRAY &&
+            sh->sh_type != SHT_INIT_ARRAY &&
+            sh->sh_type != SHT_FINI_ARRAY &&
+            strcmp(sh_name, ".stabstr")
+            )
+            continue;
+        if (sh->sh_addralign < 1)
+            sh->sh_addralign = 1;
+        /* find corresponding section, if any */
+        for(j = 1; j < s1->nb_sections;j++) {
+            s = s1->sections[j];
+            if (!strcmp(s->name, sh_name)) {
+                if (!strncmp(sh_name, ".gnu.linkonce", 
+                             sizeof(".gnu.linkonce") - 1)) {
+                    /* if a 'linkonce' section is already present, we
+                       do not add it again. It is a little tricky as
+                       symbols can still be defined in
+                       it. */
+                    sm_table[i].link_once = 1;
+                    goto next;
+                } else {
+                    goto found;
+                }
+            }
+        }
+        /* not found: create new section */
+        s = new_section(s1, sh_name, sh->sh_type, sh->sh_flags);
+        /* take as much info as possible from the section. sh_link and
+           sh_info will be updated later */
+        s->sh_addralign = sh->sh_addralign;
+        s->sh_entsize = sh->sh_entsize;
+        sm_table[i].new_section = 1;
+    found:
+        if (sh->sh_type != s->sh_type) {
+            tcc_error_noabort("invalid section type");
+            goto fail;
+        }
+
+        /* align start of section */
+        offset = s->data_offset;
+
+        if (0 == strcmp(sh_name, ".stab")) {
+            stab_index = i;
+            goto no_align;
+        }
+        if (0 == strcmp(sh_name, ".stabstr")) {
+            stabstr_index = i;
+            goto no_align;
+        }
+
+        size = sh->sh_addralign - 1;
+        offset = (offset + size) & ~size;
+        if (sh->sh_addralign > s->sh_addralign)
+            s->sh_addralign = sh->sh_addralign;
+        s->data_offset = offset;
+    no_align:
+        sm_table[i].offset = offset;
+        sm_table[i].s = s;
+        /* concatenate sections */
+        size = sh->sh_size;
+        if (sh->sh_type != SHT_NOBITS) {
+            unsigned char *ptr;
+            lseek(fd, file_offset + sh->sh_offset, SEEK_SET);
+            ptr = section_ptr_add(s, size);
+            read(fd, ptr, size);
+        } else {
+            s->data_offset += size;
+        }
+    next: ;
+    }
+
+    /* //gr relocate stab strings */
+    if (stab_index && stabstr_index) {
+        Stab_Sym *a, *b;
+        unsigned o;
+        s = sm_table[stab_index].s;
+        a = (Stab_Sym *)(s->data + sm_table[stab_index].offset);
+        b = (Stab_Sym *)(s->data + s->data_offset);
+        o = sm_table[stabstr_index].offset;
+        while (a < b) 
+            a->n_strx += o, a++;
+    }
+
+    /* second short pass to update sh_link and sh_info fields of new
+       sections */
+    for(i = 1; i < ehdr.e_shnum; i++) {
+        s = sm_table[i].s;
+        if (!s || !sm_table[i].new_section)
+            continue;
+        sh = &shdr[i];
+        if (sh->sh_link > 0)
+            s->link = sm_table[sh->sh_link].s;
+        if (sh->sh_type == SHT_RELX) {
+            s->sh_info = sm_table[sh->sh_info].s->sh_num;
+            /* update backward link */
+            s1->sections[s->sh_info]->reloc = s;
+        }
+    }
+    sm = sm_table;
+
+    /* resolve symbols */
+    old_to_new_syms = tcc_mallocz(nb_syms * sizeof(int));
+
+    sym = symtab + 1;
+    for(i = 1; i < nb_syms; i++, sym++) {
+        if (sym->st_shndx != SHN_UNDEF &&
+            sym->st_shndx < SHN_LORESERVE) {
+            sm = &sm_table[sym->st_shndx];
+            if (sm->link_once) {
+                /* if a symbol is in a link once section, we use the
+                   already defined symbol. It is very important to get
+                   correct relocations */
+                if (ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
+                    name = strtab + sym->st_name;
+                    sym_index = find_elf_sym(symtab_section, name);
+                    if (sym_index)
+                        old_to_new_syms[i] = sym_index;
+                }
+                continue;
+            }
+            /* if no corresponding section added, no need to add symbol */
+            if (!sm->s)
+                continue;
+            /* convert section number */
+            sym->st_shndx = sm->s->sh_num;
+            /* offset value */
+            sym->st_value += sm->offset;
+        }
+        /* add symbol */
+        name = strtab + sym->st_name;
+        sym_index = add_elf_sym(symtab_section, sym->st_value, sym->st_size, 
+                                sym->st_info, sym->st_other, 
+                                sym->st_shndx, name);
+        old_to_new_syms[i] = sym_index;
+    }
+
+    /* third pass to patch relocation entries */
+    for(i = 1; i < ehdr.e_shnum; i++) {
+        s = sm_table[i].s;
+        if (!s)
+            continue;
+        sh = &shdr[i];
+        offset = sm_table[i].offset;
+        switch(s->sh_type) {
+        case SHT_RELX:
+            /* take relocation offset information */
+            offseti = sm_table[sh->sh_info].offset;
+            rel_end = (ElfW_Rel *)(s->data + s->data_offset);
+            for(rel = (ElfW_Rel *)(s->data + offset);
+                rel < rel_end;
+                rel++) {
+                int type;
+                unsigned sym_index;
+                /* convert symbol index */
+                type = ELFW(R_TYPE)(rel->r_info);
+                sym_index = ELFW(R_SYM)(rel->r_info);
+                /* NOTE: only one symtab assumed */
+                if (sym_index >= nb_syms)
+                    goto invalid_reloc;
+                sym_index = old_to_new_syms[sym_index];
+                /* ignore link_once in rel section. */
+                if (!sym_index && !sm->link_once
+#ifdef TCC_TARGET_ARM
+                    && type != R_ARM_V4BX
+#endif
+                   ) {
+                invalid_reloc:
+                    tcc_error_noabort("Invalid relocation entry [%2d] '%s' @ %.8x",
+                        i, strsec + sh->sh_name, rel->r_offset);
+                    goto fail;
+                }
+                rel->r_info = ELFW(R_INFO)(sym_index, type);
+                /* offset the relocation offset */
+                rel->r_offset += offseti;
+#ifdef TCC_TARGET_ARM
+                /* Jumps and branches from a Thumb code to a PLT entry need
+                   special handling since PLT entries are ARM code.
+                   Unconditional bl instructions referencing PLT entries are
+                   handled by converting these instructions into blx
+                   instructions. Other case of instructions referencing a PLT
+                   entry require to add a Thumb stub before the PLT entry to
+                   switch to ARM mode. We set bit 0 of the got offset of a
+                   symbol to indicate such a case. */
+                if (type == R_ARM_THM_JUMP24)
+                    alloc_sym_attr(s1, sym_index)->plt_thumb_stub = 1;
+#endif
+            }
+            break;
+        default:
+            break;
+        }
+    }
+    
+    ret = 0;
+ the_end:
+    tcc_free(symtab);
+    tcc_free(strtab);
+    tcc_free(old_to_new_syms);
+    tcc_free(sm_table);
+    tcc_free(strsec);
+    tcc_free(shdr);
+    return ret;
+}
+
+typedef struct ArchiveHeader {
+    char ar_name[16];           /* name of this member */
+    char ar_date[12];           /* file mtime */
+    char ar_uid[6];             /* owner uid; printed as decimal */
+    char ar_gid[6];             /* owner gid; printed as decimal */
+    char ar_mode[8];            /* file mode, printed as octal   */
+    char ar_size[10];           /* file size, printed as decimal */
+    char ar_fmag[2];            /* should contain ARFMAG */
+} ArchiveHeader;
+
+static int get_be32(const uint8_t *b)
+{
+    return b[3] | (b[2] << 8) | (b[1] << 16) | (b[0] << 24);
+}
+
+/* load only the objects which resolve undefined symbols */
+static int tcc_load_alacarte(TCCState *s1, int fd, int size)
+{
+    int i, bound, nsyms, sym_index, off, ret;
+    uint8_t *data;
+    const char *ar_names, *p;
+    const uint8_t *ar_index;
+    ElfW(Sym) *sym;
+
+    data = tcc_malloc(size);
+    if (read(fd, data, size) != size)
+        goto fail;
+    nsyms = get_be32(data);
+    ar_index = data + 4;
+    ar_names = ar_index + nsyms * 4;
+
+    do {
+        bound = 0;
+        for(p = ar_names, i = 0; i < nsyms; i++, p += strlen(p)+1) {
+            sym_index = find_elf_sym(symtab_section, p);
+            if(sym_index) {
+                sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
+                if(sym->st_shndx == SHN_UNDEF) {
+                    off = get_be32(ar_index + i * 4) + sizeof(ArchiveHeader);
+#if 0
+                    printf("%5d\t%s\t%08x\n", i, p, sym->st_shndx);
+#endif
+                    ++bound;
+                    lseek(fd, off, SEEK_SET);
+                    if(tcc_load_object_file(s1, fd, off) < 0) {
+                    fail:
+                        ret = -1;
+                        goto the_end;
+                    }
+                }
+            }
+        }
+    } while(bound);
+    ret = 0;
+ the_end:
+    tcc_free(data);
+    return ret;
+}
+
+/* load a '.a' file */
+ST_FUNC int tcc_load_archive(TCCState *s1, int fd)
+{
+    ArchiveHeader hdr;
+    char ar_size[11];
+    char ar_name[17];
+    char magic[8];
+    int size, len, i;
+    unsigned long file_offset;
+
+    /* skip magic which was already checked */
+    read(fd, magic, sizeof(magic));
+    
+    for(;;) {
+        len = read(fd, &hdr, sizeof(hdr));
+        if (len == 0)
+            break;
+        if (len != sizeof(hdr)) {
+            tcc_error_noabort("invalid archive");
+            return -1;
+        }
+        memcpy(ar_size, hdr.ar_size, sizeof(hdr.ar_size));
+        ar_size[sizeof(hdr.ar_size)] = '\0';
+        size = strtol(ar_size, NULL, 0);
+        memcpy(ar_name, hdr.ar_name, sizeof(hdr.ar_name));
+        for(i = sizeof(hdr.ar_name) - 1; i >= 0; i--) {
+            if (ar_name[i] != ' ')
+                break;
+        }
+        ar_name[i + 1] = '\0';
+        //        printf("name='%s' size=%d %s\n", ar_name, size, ar_size);
+        file_offset = lseek(fd, 0, SEEK_CUR);
+        /* align to even */
+        size = (size + 1) & ~1;
+        if (!strcmp(ar_name, "/")) {
+            /* coff symbol table : we handle it */
+            if(s1->alacarte_link)
+                return tcc_load_alacarte(s1, fd, size);
+        } else if (!strcmp(ar_name, "//") ||
+                   !strcmp(ar_name, "__.SYMDEF") ||
+                   !strcmp(ar_name, "__.SYMDEF/") ||
+                   !strcmp(ar_name, "ARFILENAMES/")) {
+            /* skip symbol table or archive names */
+        } else {
+            if (tcc_load_object_file(s1, fd, file_offset) < 0)
+                return -1;
+        }
+        lseek(fd, file_offset + size, SEEK_SET);
+    }
+    return 0;
+}
+
+#ifndef TCC_TARGET_PE
+/* load a DLL and all referenced DLLs. 'level = 0' means that the DLL
+   is referenced by the user (so it should be added as DT_NEEDED in
+   the generated ELF file) */
+ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level)
+{ 
+    ElfW(Ehdr) ehdr;
+    ElfW(Shdr) *shdr, *sh, *sh1;
+    int i, j, nb_syms, nb_dts, sym_bind, ret;
+    ElfW(Sym) *sym, *dynsym;
+    ElfW(Dyn) *dt, *dynamic;
+    unsigned char *dynstr;
+    const char *name, *soname;
+    DLLReference *dllref;
+    
+    read(fd, &ehdr, sizeof(ehdr));
+
+    /* test CPU specific stuff */
+    if (ehdr.e_ident[5] != ELFDATA2LSB ||
+        ehdr.e_machine != EM_TCC_TARGET) {
+        tcc_error_noabort("bad architecture");
+        return -1;
+    }
+
+    /* read sections */
+    shdr = load_data(fd, ehdr.e_shoff, sizeof(ElfW(Shdr)) * ehdr.e_shnum);
+
+    /* load dynamic section and dynamic symbols */
+    nb_syms = 0;
+    nb_dts = 0;
+    dynamic = NULL;
+    dynsym = NULL; /* avoid warning */
+    dynstr = NULL; /* avoid warning */
+    for(i = 0, sh = shdr; i < ehdr.e_shnum; i++, sh++) {
+        switch(sh->sh_type) {
+        case SHT_DYNAMIC:
+            nb_dts = sh->sh_size / sizeof(ElfW(Dyn));
+            dynamic = load_data(fd, sh->sh_offset, sh->sh_size);
+            break;
+        case SHT_DYNSYM:
+            nb_syms = sh->sh_size / sizeof(ElfW(Sym));
+            dynsym = load_data(fd, sh->sh_offset, sh->sh_size);
+            sh1 = &shdr[sh->sh_link];
+            dynstr = load_data(fd, sh1->sh_offset, sh1->sh_size);
+            break;
+        default:
+            break;
+        }
+    }
+    
+    /* compute the real library name */
+    soname = tcc_basename(filename);
+        
+    for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
+        if (dt->d_tag == DT_SONAME) {
+            soname = dynstr + dt->d_un.d_val;
+        }
+    }
+
+    /* if the dll is already loaded, do not load it */
+    for(i = 0; i < s1->nb_loaded_dlls; i++) {
+        dllref = s1->loaded_dlls[i];
+        if (!strcmp(soname, dllref->name)) {
+            /* but update level if needed */
+            if (level < dllref->level)
+                dllref->level = level;
+            ret = 0;
+            goto the_end;
+        }
+    }
+    
+    //    printf("loading dll '%s'\n", soname);
+
+    /* add the dll and its level */
+    dllref = tcc_mallocz(sizeof(DLLReference) + strlen(soname));
+    dllref->level = level;
+    strcpy(dllref->name, soname);
+    dynarray_add((void ***)&s1->loaded_dlls, &s1->nb_loaded_dlls, dllref);
+
+    /* add dynamic symbols in dynsym_section */
+    for(i = 1, sym = dynsym + 1; i < nb_syms; i++, sym++) {
+        sym_bind = ELFW(ST_BIND)(sym->st_info);
+        if (sym_bind == STB_LOCAL)
+            continue;
+        name = dynstr + sym->st_name;
+        add_elf_sym(s1->dynsymtab_section, sym->st_value, sym->st_size,
+                    sym->st_info, sym->st_other, sym->st_shndx, name);
+    }
+
+    /* load all referenced DLLs */
+    for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
+        switch(dt->d_tag) {
+        case DT_NEEDED:
+            name = dynstr + dt->d_un.d_val;
+            for(j = 0; j < s1->nb_loaded_dlls; j++) {
+                dllref = s1->loaded_dlls[j];
+                if (!strcmp(name, dllref->name))
+                    goto already_loaded;
+            }
+            if (tcc_add_dll(s1, name, AFF_REFERENCED_DLL) < 0) {
+                tcc_error_noabort("referenced dll '%s' not found", name);
+                ret = -1;
+                goto the_end;
+            }
+        already_loaded:
+            break;
+        }
+    }
+    ret = 0;
+ the_end:
+    tcc_free(dynstr);
+    tcc_free(dynsym);
+    tcc_free(dynamic);
+    tcc_free(shdr);
+    return ret;
+}
+
+#define LD_TOK_NAME 256
+#define LD_TOK_EOF  (-1)
+
+/* return next ld script token */
+static int ld_next(TCCState *s1, char *name, int name_size)
+{
+    int c;
+    char *q;
+
+ redo:
+    switch(ch) {
+    case ' ':
+    case '\t':
+    case '\f':
+    case '\v':
+    case '\r':
+    case '\n':
+        inp();
+        goto redo;
+    case '/':
+        minp();
+        if (ch == '*') {
+            file->buf_ptr = parse_comment(file->buf_ptr);
+            ch = file->buf_ptr[0];
+            goto redo;
+        } else {
+            q = name;
+            *q++ = '/';
+            goto parse_name;
+        }
+        break;
+    /* case 'a' ... 'z': */
+    case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'f':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'm':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 's':
+       case 't':
+       case 'u':
+       case 'v':
+       case 'w':
+       case 'x':
+       case 'y':
+       case 'z':
+    /* case 'A' ... 'z': */
+    case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'F':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'M':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'S':
+       case 'T':
+       case 'U':
+       case 'V':
+       case 'W':
+       case 'X':
+       case 'Y':
+       case 'Z':
+    case '_':
+    case '\\':
+    case '.':
+    case '$':
+    case '~':
+        q = name;
+    parse_name:
+        for(;;) {
+            if (!((ch >= 'a' && ch <= 'z') ||
+                  (ch >= 'A' && ch <= 'Z') ||
+                  (ch >= '0' && ch <= '9') ||
+                  strchr("/.-_+=$:\\,~", ch)))
+                break;
+            if ((q - name) < name_size - 1) {
+                *q++ = ch;
+            }
+            minp();
+        }
+        *q = '\0';
+        c = LD_TOK_NAME;
+        break;
+    case CH_EOF:
+        c = LD_TOK_EOF;
+        break;
+    default:
+        c = ch;
+        inp();
+        break;
+    }
+#if 0
+    printf("tok=%c %d\n", c, c);
+    if (c == LD_TOK_NAME)
+        printf("  name=%s\n", name);
+#endif
+    return c;
+}
+
+static int ld_add_file(TCCState *s1, const char filename[])
+{
+    int ret;
+
+    ret = tcc_add_file_internal(s1, filename, 0);
+    if (ret)
+        ret = tcc_add_dll(s1, filename, 0);
+    return ret;
+}
+
+static inline int new_undef_syms(void)
+{
+    int ret = 0;
+    ret = new_undef_sym;
+    new_undef_sym = 0;
+    return ret;
+}
+
+static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
+{
+    char filename[1024], libname[1024];
+    int t, group, nblibs = 0, ret = 0;
+    char **libs = NULL;
+
+    group = !strcmp(cmd, "GROUP");
+    if (!as_needed)
+        new_undef_syms();
+    t = ld_next(s1, filename, sizeof(filename));
+    if (t != '(')
+        expect("(");
+    t = ld_next(s1, filename, sizeof(filename));
+    for(;;) {
+        libname[0] = '\0';
+        if (t == LD_TOK_EOF) {
+            tcc_error_noabort("unexpected end of file");
+            ret = -1;
+            goto lib_parse_error;
+        } else if (t == ')') {
+            break;
+        } else if (t == '-') {
+            t = ld_next(s1, filename, sizeof(filename));
+            if ((t != LD_TOK_NAME) || (filename[0] != 'l')) {
+                tcc_error_noabort("library name expected");
+                ret = -1;
+                goto lib_parse_error;
+            }
+            pstrcpy(libname, sizeof libname, &filename[1]);
+            if (s1->static_link) {
+                snprintf(filename, sizeof filename, "lib%s.a", libname);
+            } else {
+                snprintf(filename, sizeof filename, "lib%s.so", libname);
+            }
+        } else if (t != LD_TOK_NAME) {
+            tcc_error_noabort("filename expected");
+            ret = -1;
+            goto lib_parse_error;
+        }
+        if (!strcmp(filename, "AS_NEEDED")) {
+            ret = ld_add_file_list(s1, cmd, 1);
+            if (ret)
+                goto lib_parse_error;
+        } else {
+            /* TODO: Implement AS_NEEDED support. Ignore it for now */
+            if (!as_needed) {
+                ret = ld_add_file(s1, filename);
+                if (ret)
+                    goto lib_parse_error;
+                if (group) {
+                    /* Add the filename *and* the libname to avoid future conversions */
+                    dynarray_add((void ***) &libs, &nblibs, tcc_strdup(filename));
+                    if (libname[0] != '\0')
+                        dynarray_add((void ***) &libs, &nblibs, tcc_strdup(libname));
+                }
+            }
+        }
+        t = ld_next(s1, filename, sizeof(filename));
+        if (t == ',') {
+            t = ld_next(s1, filename, sizeof(filename));
+        }
+    }
+    if (group && !as_needed) {
+        while (new_undef_syms()) {
+            int i;
+
+            for (i = 0; i < nblibs; i ++)
+                ld_add_file(s1, libs[i]);
+        }
+    }
+lib_parse_error:
+    dynarray_reset(&libs, &nblibs);
+    return ret;
+}
+
+/* interpret a subset of GNU ldscripts to handle the dummy libc.so
+   files */
+ST_FUNC int tcc_load_ldscript(TCCState *s1)
+{
+    char cmd[64];
+    char filename[1024];
+    int t, ret;
+    
+    ch = file->buf_ptr[0];
+    ch = handle_eob();
+    for(;;) {
+        t = ld_next(s1, cmd, sizeof(cmd));
+        if (t == LD_TOK_EOF)
+            return 0;
+        else if (t != LD_TOK_NAME)
+            return -1;
+        if (!strcmp(cmd, "INPUT") ||
+            !strcmp(cmd, "GROUP")) {
+            ret = ld_add_file_list(s1, cmd, 0);
+            if (ret)
+                return ret;
+        } else if (!strcmp(cmd, "OUTPUT_FORMAT") ||
+                   !strcmp(cmd, "TARGET")) {
+            /* ignore some commands */
+            t = ld_next(s1, cmd, sizeof(cmd));
+            if (t != '(')
+                expect("(");
+            for(;;) {
+                t = ld_next(s1, filename, sizeof(filename));
+                if (t == LD_TOK_EOF) {
+                    tcc_error_noabort("unexpected end of file");
+                    return -1;
+                } else if (t == ')') {
+                    break;
+                }
+            }
+        } else {
+            return -1;
+        }
+    }
+    return 0;
+}
+#endif /* ndef TCC_TARGET_PE */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tccgen.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tccgen.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tccgen.c	(revision 279)
@@ -0,0 +1,5843 @@
+/*
+ *  TCC - Tiny C Compiler
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+/********************************************************/
+/* global variables */
+
+/* loc : local variable index
+   ind : output code index
+   rsym: return symbol
+   anon_sym: anonymous symbol index
+*/
+ST_DATA int rsym, anon_sym, ind, loc;
+
+ST_DATA Section *text_section, *data_section, *bss_section; /* predefined sections */
+ST_DATA Section *cur_text_section; /* current section where function code is generated */
+#ifdef CONFIG_TCC_ASM
+ST_DATA Section *last_text_section; /* to handle .previous asm directive */
+#endif
+#ifdef CONFIG_TCC_BCHECK
+/* bound check related sections */
+ST_DATA Section *bounds_section; /* contains global data bound description */
+ST_DATA Section *lbounds_section; /* contains local data bound description */
+#endif
+/* symbol sections */
+ST_DATA Section *symtab_section, *strtab_section;
+/* debug sections */
+ST_DATA Section *stab_section, *stabstr_section;
+ST_DATA Sym *sym_free_first;
+ST_DATA void **sym_pools;
+ST_DATA int nb_sym_pools;
+
+ST_DATA Sym *global_stack;
+ST_DATA Sym *local_stack;
+ST_DATA Sym *scope_stack_bottom;
+ST_DATA Sym *define_stack;
+ST_DATA Sym *global_label_stack;
+ST_DATA Sym *local_label_stack;
+
+ST_DATA SValue __vstack[1+VSTACK_SIZE], *vtop;
+
+ST_DATA int const_wanted; /* true if constant wanted */
+ST_DATA int nocode_wanted; /* true if no code generation wanted for an expression */
+ST_DATA int global_expr;  /* true if compound literals must be allocated globally (used during initializers parsing */
+ST_DATA CType func_vt; /* current function return type (used by return instruction) */
+ST_DATA int func_vc;
+ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and pc */
+ST_DATA char *funcname;
+
+ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;
+
+/* ------------------------------------------------------------------------- */
+static void gen_cast(CType *type);
+static inline CType *pointed_type(CType *type);
+static int is_compatible_types(CType *type1, CType *type2);
+static int parse_btype(CType *type, AttributeDef *ad);
+static void type_decl(CType *type, AttributeDef *ad, int *v, int td);
+static void parse_expr_type(CType *type);
+static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only);
+static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg, int is_expr);
+static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, char *asm_label, int scope);
+static int decl0(int l, int is_for_loop_init);
+static void expr_eq(void);
+static void unary_type(CType *type);
+static void vla_runtime_type_size(CType *type, int *a);
+static int is_compatible_parameter_types(CType *type1, CType *type2);
+static void expr_type(CType *type);
+
+ST_INLN int is_float(int t)
+{
+    int bt;
+    bt = t & VT_BTYPE;
+    return bt == VT_LDOUBLE || bt == VT_DOUBLE || bt == VT_FLOAT;
+}
+
+/* we use our own 'finite' function to avoid potential problems with
+   non standard math libs */
+/* XXX: endianness dependent */
+ST_FUNC int ieee_finite(double d)
+{
+    int *p = (int *)&d;
+    return ((unsigned)((p[1] | 0x800fffff) + 1)) >> 31;
+}
+
+ST_FUNC void test_lvalue(void)
+{
+    if (!(vtop->r & VT_LVAL))
+        expect("lvalue");
+}
+
+/* ------------------------------------------------------------------------- */
+/* symbol allocator */
+static Sym *__sym_malloc(void)
+{
+    Sym *sym_pool, *sym, *last_sym;
+    int i;
+
+    sym_pool = tcc_malloc(SYM_POOL_NB * sizeof(Sym));
+    dynarray_add(&sym_pools, &nb_sym_pools, sym_pool);
+
+    last_sym = sym_free_first;
+    sym = sym_pool;
+    for(i = 0; i < SYM_POOL_NB; i++) {
+        sym->next = last_sym;
+        last_sym = sym;
+        sym++;
+    }
+    sym_free_first = last_sym;
+    return last_sym;
+}
+
+static inline Sym *sym_malloc(void)
+{
+    Sym *sym;
+    sym = sym_free_first;
+    if (!sym)
+        sym = __sym_malloc();
+    sym_free_first = sym->next;
+    return sym;
+}
+
+ST_INLN void sym_free(Sym *sym)
+{
+    sym->next = sym_free_first;
+    tcc_free(sym->asm_label);
+    sym_free_first = sym;
+}
+
+/* push, without hashing */
+ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, long c)
+{
+    Sym *s;
+    if (ps == &local_stack) {
+        for (s = *ps; s && s != scope_stack_bottom; s = s->prev)
+            if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM && s->v == v)
+                tcc_error("incompatible types for redefinition of '%s'",
+                          get_tok_str(v, NULL));
+    }
+    s = *ps;
+    s = sym_malloc();
+    s->asm_label = NULL;
+    s->v = v;
+    s->type.t = t;
+    s->type.ref = NULL;
+#ifdef _WIN64
+    s->d = NULL;
+#endif
+    s->c = c;
+    s->next = NULL;
+    /* add in stack */
+    s->prev = *ps;
+    *ps = s;
+    return s;
+}
+
+/* find a symbol and return its associated structure. 's' is the top
+   of the symbol stack */
+ST_FUNC Sym *sym_find2(Sym *s, int v)
+{
+    while (s) {
+        if (s->v == v)
+            return s;
+        s = s->prev;
+    }
+    return NULL;
+}
+
+/* structure lookup */
+ST_INLN Sym *struct_find(int v)
+{
+    v -= TOK_IDENT;
+    if ((unsigned)v >= (unsigned)(tok_ident - TOK_IDENT))
+        return NULL;
+    return table_ident[v]->sym_struct;
+}
+
+/* find an identifier */
+ST_INLN Sym *sym_find(int v)
+{
+    v -= TOK_IDENT;
+    if ((unsigned)v >= (unsigned)(tok_ident - TOK_IDENT))
+        return NULL;
+    return table_ident[v]->sym_identifier;
+}
+
+/* push a given symbol on the symbol stack */
+ST_FUNC Sym *sym_push(int v, CType *type, int r, int c)
+{
+    Sym *s, **ps;
+    TokenSym *ts;
+
+    if (local_stack)
+        ps = &local_stack;
+    else
+        ps = &global_stack;
+    s = sym_push2(ps, v, type->t, c);
+    s->type.ref = type->ref;
+    s->r = r;
+    /* don't record fields or anonymous symbols */
+    /* XXX: simplify */
+    if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM) {
+        /* record symbol in token array */
+        ts = table_ident[(v & ~SYM_STRUCT) - TOK_IDENT];
+        if (v & SYM_STRUCT)
+            ps = &ts->sym_struct;
+        else
+            ps = &ts->sym_identifier;
+        s->prev_tok = *ps;
+        *ps = s;
+    }
+    return s;
+}
+
+/* push a global identifier */
+ST_FUNC Sym *global_identifier_push(int v, int t, int c)
+{
+    Sym *s, **ps;
+    s = sym_push2(&global_stack, v, t, c);
+    /* don't record anonymous symbol */
+    if (v < SYM_FIRST_ANOM) {
+        ps = &table_ident[v - TOK_IDENT]->sym_identifier;
+        /* modify the top most local identifier, so that
+           sym_identifier will point to 's' when popped */
+        while (*ps != NULL)
+            ps = &(*ps)->prev_tok;
+        s->prev_tok = NULL;
+        *ps = s;
+    }
+    return s;
+}
+
+/* pop symbols until top reaches 'b' */
+ST_FUNC void sym_pop(Sym **ptop, Sym *b)
+{
+    Sym *s, *ss, **ps;
+    TokenSym *ts;
+    int v;
+
+    s = *ptop;
+    while(s != b) {
+        ss = s->prev;
+        v = s->v;
+        /* remove symbol in token array */
+        /* XXX: simplify */
+        if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM) {
+            ts = table_ident[(v & ~SYM_STRUCT) - TOK_IDENT];
+            if (v & SYM_STRUCT)
+                ps = &ts->sym_struct;
+            else
+                ps = &ts->sym_identifier;
+            *ps = s->prev_tok;
+        }
+        sym_free(s);
+        s = ss;
+    }
+    *ptop = b;
+}
+
+static void weaken_symbol(Sym *sym)
+{
+    sym->type.t |= VT_WEAK;
+    if (sym->c > 0) {
+        int esym_type;
+        ElfW(Sym) *esym;
+        
+        esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
+        esym_type = ELFW(ST_TYPE)(esym->st_info);
+        esym->st_info = ELFW(ST_INFO)(STB_WEAK, esym_type);
+    }
+}
+
+/* ------------------------------------------------------------------------- */
+
+ST_FUNC void swap(int *p, int *q)
+{
+    int t;
+    t = *p;
+    *p = *q;
+    *q = t;
+}
+
+static void vsetc(CType *type, int r, CValue *vc)
+{
+    int v;
+
+    if (vtop >= vstack + (VSTACK_SIZE - 1))
+        tcc_error("memory full");
+    /* cannot let cpu flags if other instruction are generated. Also
+       avoid leaving VT_JMP anywhere except on the top of the stack
+       because it would complicate the code generator. */
+    if (vtop >= vstack) {
+        v = vtop->r & VT_VALMASK;
+        if (v == VT_CMP || (v & ~1) == VT_JMP)
+            gv(RC_INT);
+    }
+    vtop++;
+    vtop->type = *type;
+    vtop->r = r;
+    vtop->r2 = VT_CONST;
+    vtop->c = *vc;
+}
+
+/* push constant of type "type" with useless value */
+void vpush(CType *type)
+{
+    CValue cval;
+    vsetc(type, VT_CONST, &cval);
+}
+
+/* push integer constant */
+ST_FUNC void vpushi(int v)
+{
+    CValue cval;
+    cval.i = v;
+    vsetc(&int_type, VT_CONST, &cval);
+}
+
+/* push a pointer sized constant */
+static void vpushs(long long v)
+{
+  CValue cval;
+  if (PTR_SIZE == 4)
+    cval.i = (int)v;
+  else
+    cval.ull = v;
+  vsetc(&size_type, VT_CONST, &cval);
+}
+
+/* push arbitrary 64bit constant */
+void vpush64(int ty, unsigned long long v)
+{
+    CValue cval;
+    CType ctype;
+    ctype.t = ty;
+    ctype.ref = NULL;
+    cval.ull = v;
+    vsetc(&ctype, VT_CONST, &cval);
+}
+
+/* push long long constant */
+static inline void vpushll(long long v)
+{
+    vpush64(VT_LLONG, v);
+}
+
+/* Return a static symbol pointing to a section */
+ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
+{
+    int v;
+    Sym *sym;
+
+    v = anon_sym++;
+    sym = global_identifier_push(v, type->t | VT_STATIC, 0);
+    sym->type.ref = type->ref;
+    sym->r = VT_CONST | VT_SYM;
+    put_extern_sym(sym, sec, offset, size);
+    return sym;
+}
+
+/* push a reference to a section offset by adding a dummy symbol */
+static void vpush_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
+{
+    CValue cval;
+
+    cval.ul = 0;
+    vsetc(type, VT_CONST | VT_SYM, &cval);
+    vtop->sym = get_sym_ref(type, sec, offset, size);
+}
+
+/* define a new external reference to a symbol 'v' of type 'u' */
+ST_FUNC Sym *external_global_sym(int v, CType *type, int r)
+{
+    Sym *s;
+
+    s = sym_find(v);
+    if (!s) {
+        /* push forward reference */
+        s = global_identifier_push(v, type->t | VT_EXTERN, 0);
+        s->type.ref = type->ref;
+        s->r = r | VT_CONST | VT_SYM;
+    }
+    return s;
+}
+
+/* define a new external reference to a symbol 'v' with alternate asm
+   name 'asm_label' of type 'u'. 'asm_label' is equal to NULL if there
+   is no alternate name (most cases) */
+static Sym *external_sym(int v, CType *type, int r, char *asm_label)
+{
+    Sym *s;
+
+    s = sym_find(v);
+    if (!s) {
+        /* push forward reference */
+        s = sym_push(v, type, r | VT_CONST | VT_SYM, 0);
+        s->asm_label = asm_label;
+        s->type.t |= VT_EXTERN;
+    } else if (s->type.ref == func_old_type.ref) {
+        s->type.ref = type->ref;
+        s->r = r | VT_CONST | VT_SYM;
+        s->type.t |= VT_EXTERN;
+    } else if (!is_compatible_types(&s->type, type)) {
+        tcc_error("incompatible types for redefinition of '%s'", 
+              get_tok_str(v, NULL));
+    }
+    return s;
+}
+
+/* push a reference to global symbol v */
+ST_FUNC void vpush_global_sym(CType *type, int v)
+{
+    Sym *sym;
+    CValue cval;
+
+    sym = external_global_sym(v, type, 0);
+    cval.ul = 0;
+    vsetc(type, VT_CONST | VT_SYM, &cval);
+    vtop->sym = sym;
+}
+
+ST_FUNC void vset(CType *type, int r, int v)
+{
+    CValue cval;
+
+    cval.i = v;
+    vsetc(type, r, &cval);
+}
+
+static void vseti(int r, int v)
+{
+    CType type;
+    type.t = VT_INT;
+    type.ref = 0;
+    vset(&type, r, v);
+}
+
+ST_FUNC void vswap(void)
+{
+    SValue tmp;
+    /* cannot let cpu flags if other instruction are generated. Also
+       avoid leaving VT_JMP anywhere except on the top of the stack
+       because it would complicate the code generator. */
+    if (vtop >= vstack) {
+        int v = vtop->r & VT_VALMASK;
+        if (v == VT_CMP || (v & ~1) == VT_JMP)
+            gv(RC_INT);
+    }
+    tmp = vtop[0];
+    vtop[0] = vtop[-1];
+    vtop[-1] = tmp;
+
+/* XXX: +2% overall speed possible with optimized memswap
+ *
+ *  memswap(&vtop[0], &vtop[1], sizeof *vtop);
+ */
+}
+
+ST_FUNC void vpushv(SValue *v)
+{
+    if (vtop >= vstack + (VSTACK_SIZE - 1))
+        tcc_error("memory full");
+    vtop++;
+    *vtop = *v;
+}
+
+static void vdup(void)
+{
+    vpushv(vtop);
+}
+
+/* save r to the memory stack, and mark it as being free */
+ST_FUNC void save_reg(int r)
+{
+    int l, saved, size, align;
+    SValue *p, sv;
+    CType *type;
+
+    /* modify all stack values */
+    saved = 0;
+    l = 0;
+    for(p=vstack;p<=vtop;p++) {
+        if ((p->r & VT_VALMASK) == r ||
+            ((p->type.t & VT_BTYPE) == VT_LLONG && (p->r2 & VT_VALMASK) == r)) {
+            /* must save value on stack if not already done */
+            if (!saved) {
+                /* NOTE: must reload 'r' because r might be equal to r2 */
+                r = p->r & VT_VALMASK;
+                /* store register in the stack */
+                type = &p->type;
+                if ((p->r & VT_LVAL) ||
+                    (!is_float(type->t) && (type->t & VT_BTYPE) != VT_LLONG))
+#ifdef TCC_TARGET_X86_64
+                    type = &char_pointer_type;
+#else
+                    type = &int_type;
+#endif
+                size = type_size(type, &align);
+                loc = (loc - size) & -align;
+                sv.type.t = type->t;
+                sv.r = VT_LOCAL | VT_LVAL;
+                sv.c.ul = loc;
+                store(r, &sv);
+#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
+                /* x86 specific: need to pop fp register ST0 if saved */
+                if (r == TREG_ST0) {
+                    o(0xd8dd); /* fstp %st(0) */
+                }
+#endif
+#ifndef TCC_TARGET_X86_64
+                /* special long long case */
+                if ((type->t & VT_BTYPE) == VT_LLONG) {
+                    sv.c.ul += 4;
+                    store(p->r2, &sv);
+                }
+#endif
+                l = loc;
+                saved = 1;
+            }
+            /* mark that stack entry as being saved on the stack */
+            if (p->r & VT_LVAL) {
+                /* also clear the bounded flag because the
+                   relocation address of the function was stored in
+                   p->c.ul */
+                p->r = (p->r & ~(VT_VALMASK | VT_BOUNDED)) | VT_LLOCAL;
+            } else {
+                p->r = lvalue_type(p->type.t) | VT_LOCAL;
+            }
+            p->r2 = VT_CONST;
+            p->c.ul = l;
+        }
+    }
+}
+
+#ifdef TCC_TARGET_ARM
+/* find a register of class 'rc2' with at most one reference on stack.
+ * If none, call get_reg(rc) */
+ST_FUNC int get_reg_ex(int rc, int rc2)
+{
+    int r;
+    SValue *p;
+    
+    for(r=0;r<NB_REGS;r++) {
+        if (reg_classes[r] & rc2) {
+            int n;
+            n=0;
+            for(p = vstack; p <= vtop; p++) {
+                if ((p->r & VT_VALMASK) == r ||
+                    (p->r2 & VT_VALMASK) == r)
+                    n++;
+            }
+            if (n <= 1)
+                return r;
+        }
+    }
+    return get_reg(rc);
+}
+#endif
+
+/* find a free register of class 'rc'. If none, save one register */
+ST_FUNC int get_reg(int rc)
+{
+    int r;
+    SValue *p;
+
+    /* find a free register */
+    for(r=0;r<NB_REGS;r++) {
+        if (reg_classes[r] & rc) {
+            for(p=vstack;p<=vtop;p++) {
+                if ((p->r & VT_VALMASK) == r ||
+                    (p->r2 & VT_VALMASK) == r)
+                    goto notfound;
+            }
+            return r;
+        }
+    notfound: ;
+    }
+    
+    /* no register left : free the first one on the stack (VERY
+       IMPORTANT to start from the bottom to ensure that we don't
+       spill registers used in gen_opi()) */
+    for(p=vstack;p<=vtop;p++) {
+        /* look at second register (if long long) */
+        r = p->r2 & VT_VALMASK;
+        if (r < VT_CONST && (reg_classes[r] & rc))
+            goto save_found;
+        r = p->r & VT_VALMASK;
+        if (r < VT_CONST && (reg_classes[r] & rc)) {
+        save_found:
+            save_reg(r);
+            return r;
+        }
+    }
+    /* Should never comes here */
+    return -1;
+}
+
+/* save registers up to (vtop - n) stack entry */
+ST_FUNC void save_regs(int n)
+{
+    int r;
+    SValue *p, *p1;
+    p1 = vtop - n;
+    for(p = vstack;p <= p1; p++) {
+        r = p->r & VT_VALMASK;
+        if (r < VT_CONST) {
+            save_reg(r);
+        }
+    }
+}
+
+/* move register 's' to 'r', and flush previous value of r to memory
+   if needed */
+static void move_reg(int r, int s)
+{
+    SValue sv;
+
+    if (r != s) {
+        save_reg(r);
+        sv.type.t = VT_INT;
+        sv.r = s;
+        sv.c.ul = 0;
+        load(r, &sv);
+    }
+}
+
+/* get address of vtop (vtop MUST BE an lvalue) */
+static void gaddrof(void)
+{
+    if (vtop->r & VT_REF)
+        gv(RC_INT);
+    vtop->r &= ~VT_LVAL;
+    /* tricky: if saved lvalue, then we can go back to lvalue */
+    if ((vtop->r & VT_VALMASK) == VT_LLOCAL)
+        vtop->r = (vtop->r & ~(VT_VALMASK | VT_LVAL_TYPE)) | VT_LOCAL | VT_LVAL;
+
+
+}
+
+#ifdef CONFIG_TCC_BCHECK
+/* generate lvalue bound code */
+static void gbound(void)
+{
+    int lval_type;
+    CType type1;
+
+    vtop->r &= ~VT_MUSTBOUND;
+    /* if lvalue, then use checking code before dereferencing */
+    if (vtop->r & VT_LVAL) {
+        /* if not VT_BOUNDED value, then make one */
+        if (!(vtop->r & VT_BOUNDED)) {
+            lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);
+            /* must save type because we must set it to int to get pointer */
+            type1 = vtop->type;
+            vtop->type.t = VT_INT;
+            gaddrof();
+            vpushi(0);
+            gen_bounded_ptr_add();
+            vtop->r |= lval_type;
+            vtop->type = type1;
+        }
+        /* then check for dereferencing */
+        gen_bounded_ptr_deref();
+    }
+}
+#endif
+
+/* store vtop a register belonging to class 'rc'. lvalues are
+   converted to values. Cannot be used if cannot be converted to
+   register value (such as structures). */
+ST_FUNC int gv(int rc)
+{
+    int r, bit_pos, bit_size, size, align, i;
+#ifndef TCC_TARGET_X86_64
+    int rc2;
+#endif
+
+    /* NOTE: get_reg can modify vstack[] */
+    if (vtop->type.t & VT_BITFIELD) {
+        CType type;
+        int bits = 32;
+        bit_pos = (vtop->type.t >> VT_STRUCT_SHIFT) & 0x3f;
+        bit_size = (vtop->type.t >> (VT_STRUCT_SHIFT + 6)) & 0x3f;
+        /* remove bit field info to avoid loops */
+        vtop->type.t &= ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT));
+        /* cast to int to propagate signedness in following ops */
+        if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
+            type.t = VT_LLONG;
+            bits = 64;
+        } else
+            type.t = VT_INT;
+        if((vtop->type.t & VT_UNSIGNED) ||
+           (vtop->type.t & VT_BTYPE) == VT_BOOL)
+            type.t |= VT_UNSIGNED;
+        gen_cast(&type);
+        /* generate shifts */
+        vpushi(bits - (bit_pos + bit_size));
+        gen_op(TOK_SHL);
+        vpushi(bits - bit_size);
+        /* NOTE: transformed to SHR if unsigned */
+        gen_op(TOK_SAR);
+        r = gv(rc);
+    } else {
+        if (is_float(vtop->type.t) && 
+            (vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+            Sym *sym;
+            int *ptr;
+            unsigned long offset;
+#if defined(TCC_TARGET_ARM) && !defined(TCC_ARM_VFP)
+            CValue check;
+#endif
+            
+            /* XXX: unify with initializers handling ? */
+            /* CPUs usually cannot use float constants, so we store them
+               generically in data segment */
+            size = type_size(&vtop->type, &align);
+            offset = (data_section->data_offset + align - 1) & -align;
+            data_section->data_offset = offset;
+            /* XXX: not portable yet */
+#if defined(__i386__) || defined(__x86_64__)
+            /* Zero pad x87 tenbyte long doubles */
+            if (size == LDOUBLE_SIZE) {
+                vtop->c.tab[2] &= 0xffff;
+#if LDOUBLE_SIZE == 16
+                vtop->c.tab[3] = 0;
+#endif
+            }
+#endif
+            ptr = section_ptr_add(data_section, size);
+            size = size >> 2;
+#if defined(TCC_TARGET_ARM) && !defined(TCC_ARM_VFP)
+            check.d = 1;
+            if(check.tab[0])
+                for(i=0;i<size;i++)
+                    ptr[i] = vtop->c.tab[size-1-i];
+            else
+#endif
+            for(i=0;i<size;i++)
+                ptr[i] = vtop->c.tab[i];
+            sym = get_sym_ref(&vtop->type, data_section, offset, size << 2);
+            vtop->r |= VT_LVAL | VT_SYM;
+            vtop->sym = sym;
+            vtop->c.ul = 0;
+        }
+#ifdef CONFIG_TCC_BCHECK
+        if (vtop->r & VT_MUSTBOUND) 
+            gbound();
+#endif
+
+        r = vtop->r & VT_VALMASK;
+#ifndef TCC_TARGET_X86_64
+        rc2 = RC_INT;
+        if (rc == RC_IRET)
+            rc2 = RC_LRET;
+#endif
+        /* need to reload if:
+           - constant
+           - lvalue (need to dereference pointer)
+           - already a register, but not in the right class */
+        if (r >= VT_CONST
+         || (vtop->r & VT_LVAL)
+         || !(reg_classes[r] & rc)
+#ifndef TCC_TARGET_X86_64
+         || ((vtop->type.t & VT_BTYPE) == VT_LLONG && !(reg_classes[vtop->r2] & rc2))
+#endif
+            )
+        {
+            r = get_reg(rc);
+#ifndef TCC_TARGET_X86_64
+            if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
+                int r2;
+                unsigned long long ll;
+                /* two register type load : expand to two words
+                   temporarily */
+                if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+                    /* load constant */
+                    ll = vtop->c.ull;
+                    vtop->c.ui = ll; /* first word */
+                    load(r, vtop);
+                    vtop->r = r; /* save register value */
+                    vpushi(ll >> 32); /* second word */
+                } else if (r >= VT_CONST || /* XXX: test to VT_CONST incorrect ? */
+                           (vtop->r & VT_LVAL)) {
+                    /* We do not want to modifier the long long
+                       pointer here, so the safest (and less
+                       efficient) is to save all the other registers
+                       in the stack. XXX: totally inefficient. */
+                    save_regs(1);
+                    /* load from memory */
+                    load(r, vtop);
+                    vdup();
+                    vtop[-1].r = r; /* save register value */
+                    /* increment pointer to get second word */
+                    vtop->type.t = VT_INT;
+                    gaddrof();
+                    vpushi(4);
+                    gen_op('+');
+                    vtop->r |= VT_LVAL;
+                } else {
+                    /* move registers */
+                    load(r, vtop);
+                    vdup();
+                    vtop[-1].r = r; /* save register value */
+                    vtop->r = vtop[-1].r2;
+                }
+                /* Allocate second register. Here we rely on the fact that
+                   get_reg() tries first to free r2 of an SValue. */
+                r2 = get_reg(rc2);
+                load(r2, vtop);
+                vpop();
+                /* write second register */
+                vtop->r2 = r2;
+            } else
+#endif
+            if ((vtop->r & VT_LVAL) && !is_float(vtop->type.t)) {
+                int t1, t;
+                /* lvalue of scalar type : need to use lvalue type
+                   because of possible cast */
+                t = vtop->type.t;
+                t1 = t;
+                /* compute memory access type */
+                if (vtop->r & VT_LVAL_BYTE)
+                    t = VT_BYTE;
+                else if (vtop->r & VT_LVAL_SHORT)
+                    t = VT_SHORT;
+                if (vtop->r & VT_LVAL_UNSIGNED)
+                    t |= VT_UNSIGNED;
+                vtop->type.t = t;
+                load(r, vtop);
+                /* restore wanted type */
+                vtop->type.t = t1;
+            } else {
+                /* one register type load */
+                load(r, vtop);
+            }
+        }
+        vtop->r = r;
+#ifdef TCC_TARGET_C67
+        /* uses register pairs for doubles */
+        if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) 
+            vtop->r2 = r+1;
+#endif
+    }
+    return r;
+}
+
+/* generate vtop[-1] and vtop[0] in resp. classes rc1 and rc2 */
+ST_FUNC void gv2(int rc1, int rc2)
+{
+    int v;
+
+    /* generate more generic register first. But VT_JMP or VT_CMP
+       values must be generated first in all cases to avoid possible
+       reload errors */
+    v = vtop[0].r & VT_VALMASK;
+    if (v != VT_CMP && (v & ~1) != VT_JMP && rc1 <= rc2) {
+        vswap();
+        gv(rc1);
+        vswap();
+        gv(rc2);
+        /* test if reload is needed for first register */
+        if ((vtop[-1].r & VT_VALMASK) >= VT_CONST) {
+            vswap();
+            gv(rc1);
+            vswap();
+        }
+    } else {
+        gv(rc2);
+        vswap();
+        gv(rc1);
+        vswap();
+        /* test if reload is needed for first register */
+        if ((vtop[0].r & VT_VALMASK) >= VT_CONST) {
+            gv(rc2);
+        }
+    }
+}
+
+/* wrapper around RC_FRET to return a register by type */
+static int rc_fret(int t)
+{
+#ifdef TCC_TARGET_X86_64
+    if (t == VT_LDOUBLE) {
+        return RC_ST0;
+    }
+#endif
+    return RC_FRET;
+}
+
+/* wrapper around REG_FRET to return a register by type */
+static int reg_fret(int t)
+{
+#ifdef TCC_TARGET_X86_64
+    if (t == VT_LDOUBLE) {
+        return TREG_ST0;
+    }
+#endif
+    return REG_FRET;
+}
+
+/* expand long long on stack in two int registers */
+static void lexpand(void)
+{
+    int u;
+
+    u = vtop->type.t & VT_UNSIGNED;
+    gv(RC_INT);
+    vdup();
+    vtop[0].r = vtop[-1].r2;
+    vtop[0].r2 = VT_CONST;
+    vtop[-1].r2 = VT_CONST;
+    vtop[0].type.t = VT_INT | u;
+    vtop[-1].type.t = VT_INT | u;
+}
+
+#ifdef TCC_TARGET_ARM
+/* expand long long on stack */
+ST_FUNC void lexpand_nr(void)
+{
+    int u,v;
+
+    u = vtop->type.t & VT_UNSIGNED;
+    vdup();
+    vtop->r2 = VT_CONST;
+    vtop->type.t = VT_INT | u;
+    v=vtop[-1].r & (VT_VALMASK | VT_LVAL);
+    if (v == VT_CONST) {
+      vtop[-1].c.ui = vtop->c.ull;
+      vtop->c.ui = vtop->c.ull >> 32;
+      vtop->r = VT_CONST;
+    } else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) {
+      vtop->c.ui += 4;
+      vtop->r = vtop[-1].r;
+    } else if (v > VT_CONST) {
+      vtop--;
+      lexpand();
+    } else
+      vtop->r = vtop[-1].r2;
+    vtop[-1].r2 = VT_CONST;
+    vtop[-1].type.t = VT_INT | u;
+}
+#endif
+
+/* build a long long from two ints */
+static void lbuild(int t)
+{
+    gv2(RC_INT, RC_INT);
+    vtop[-1].r2 = vtop[0].r;
+    vtop[-1].type.t = t;
+    vpop();
+}
+
+/* rotate n first stack elements to the bottom 
+   I1 ... In -> I2 ... In I1 [top is right]
+*/
+ST_FUNC void vrotb(int n)
+{
+    int i;
+    SValue tmp;
+
+    tmp = vtop[-n + 1];
+    for(i=-n+1;i!=0;i++)
+        vtop[i] = vtop[i+1];
+    vtop[0] = tmp;
+}
+
+/* rotate the n elements before entry e towards the top
+   I1 ... In ... -> In I1 ... I(n-1) ... [top is right]
+ */
+ST_FUNC void vrote(SValue *e, int n)
+{
+    int i;
+    SValue tmp;
+
+    tmp = *e;
+    for(i = 0;i < n - 1; i++)
+        e[-i] = e[-i - 1];
+    e[-n + 1] = tmp;
+}
+
+/* rotate n first stack elements to the top
+   I1 ... In -> In I1 ... I(n-1)  [top is right]
+ */
+ST_FUNC void vrott(int n)
+{
+    vrote(vtop, n);
+}
+
+/* pop stack value */
+ST_FUNC void vpop(void)
+{
+    int v;
+    v = vtop->r & VT_VALMASK;
+#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
+    /* for x86, we need to pop the FP stack */
+    if (v == TREG_ST0 && !nocode_wanted) {
+        o(0xd8dd); /* fstp %st(0) */
+    } else
+#endif
+    if (v == VT_JMP || v == VT_JMPI) {
+        /* need to put correct jump if && or || without test */
+        gsym(vtop->c.ul);
+    }
+    vtop--;
+}
+
+/* convert stack entry to register and duplicate its value in another
+   register */
+static void gv_dup(void)
+{
+    int rc, t, r, r1;
+    SValue sv;
+
+    t = vtop->type.t;
+    if ((t & VT_BTYPE) == VT_LLONG) {
+        lexpand();
+        gv_dup();
+        vswap();
+        vrotb(3);
+        gv_dup();
+        vrotb(4);
+        /* stack: H L L1 H1 */
+        lbuild(t);
+        vrotb(3);
+        vrotb(3);
+        vswap();
+        lbuild(t);
+        vswap();
+    } else {
+        /* duplicate value */
+        rc = RC_INT;
+        sv.type.t = VT_INT;
+        if (is_float(t)) {
+            rc = RC_FLOAT;
+#ifdef TCC_TARGET_X86_64
+            if ((t & VT_BTYPE) == VT_LDOUBLE) {
+                rc = RC_ST0;
+            }
+#endif
+            sv.type.t = t;
+        }
+        r = gv(rc);
+        r1 = get_reg(rc);
+        sv.r = r;
+        sv.c.ul = 0;
+        load(r1, &sv); /* move r to r1 */
+        vdup();
+        /* duplicates value */
+        if (r != r1)
+            vtop->r = r1;
+    }
+}
+
+#ifndef TCC_TARGET_X86_64
+/* generate CPU independent (unsigned) long long operations */
+static void gen_opl(int op)
+{
+    int t, a, b, op1, c, i;
+    int func;
+    unsigned short reg_iret = REG_IRET;
+    unsigned short reg_lret = REG_LRET;
+    SValue tmp;
+
+    switch(op) {
+    case '/':
+    case TOK_PDIV:
+        func = TOK___divdi3;
+        goto gen_func;
+    case TOK_UDIV:
+        func = TOK___udivdi3;
+        goto gen_func;
+    case '%':
+        func = TOK___moddi3;
+        goto gen_mod_func;
+    case TOK_UMOD:
+        func = TOK___umoddi3;
+    gen_mod_func:
+#ifdef TCC_ARM_EABI
+        reg_iret = TREG_R2;
+        reg_lret = TREG_R3;
+#endif
+    gen_func:
+        /* call generic long long function */
+        vpush_global_sym(&func_old_type, func);
+        vrott(3);
+        gfunc_call(2);
+        vpushi(0);
+        vtop->r = reg_iret;
+        vtop->r2 = reg_lret;
+        break;
+    case '^':
+    case '&':
+    case '|':
+    case '*':
+    case '+':
+    case '-':
+        t = vtop->type.t;
+        vswap();
+        lexpand();
+        vrotb(3);
+        lexpand();
+        /* stack: L1 H1 L2 H2 */
+        tmp = vtop[0];
+        vtop[0] = vtop[-3];
+        vtop[-3] = tmp;
+        tmp = vtop[-2];
+        vtop[-2] = vtop[-3];
+        vtop[-3] = tmp;
+        vswap();
+        /* stack: H1 H2 L1 L2 */
+        if (op == '*') {
+            vpushv(vtop - 1);
+            vpushv(vtop - 1);
+            gen_op(TOK_UMULL);
+            lexpand();
+            /* stack: H1 H2 L1 L2 ML MH */
+            for(i=0;i<4;i++)
+                vrotb(6);
+            /* stack: ML MH H1 H2 L1 L2 */
+            tmp = vtop[0];
+            vtop[0] = vtop[-2];
+            vtop[-2] = tmp;
+            /* stack: ML MH H1 L2 H2 L1 */
+            gen_op('*');
+            vrotb(3);
+            vrotb(3);
+            gen_op('*');
+            /* stack: ML MH M1 M2 */
+            gen_op('+');
+            gen_op('+');
+        } else if (op == '+' || op == '-') {
+            /* XXX: add non carry method too (for MIPS or alpha) */
+            if (op == '+')
+                op1 = TOK_ADDC1;
+            else
+                op1 = TOK_SUBC1;
+            gen_op(op1);
+            /* stack: H1 H2 (L1 op L2) */
+            vrotb(3);
+            vrotb(3);
+            gen_op(op1 + 1); /* TOK_xxxC2 */
+        } else {
+            gen_op(op);
+            /* stack: H1 H2 (L1 op L2) */
+            vrotb(3);
+            vrotb(3);
+            /* stack: (L1 op L2) H1 H2 */
+            gen_op(op);
+            /* stack: (L1 op L2) (H1 op H2) */
+        }
+        /* stack: L H */
+        lbuild(t);
+        break;
+    case TOK_SAR:
+    case TOK_SHR:
+    case TOK_SHL:
+        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+            t = vtop[-1].type.t;
+            vswap();
+            lexpand();
+            vrotb(3);
+            /* stack: L H shift */
+            c = (int)vtop->c.i;
+            /* constant: simpler */
+            /* NOTE: all comments are for SHL. the other cases are
+               done by swaping words */
+            vpop();
+            if (op != TOK_SHL)
+                vswap();
+            if (c >= 32) {
+                /* stack: L H */
+                vpop();
+                if (c > 32) {
+                    vpushi(c - 32);
+                    gen_op(op);
+                }
+                if (op != TOK_SAR) {
+                    vpushi(0);
+                } else {
+                    gv_dup();
+                    vpushi(31);
+                    gen_op(TOK_SAR);
+                }
+                vswap();
+            } else {
+                vswap();
+                gv_dup();
+                /* stack: H L L */
+                vpushi(c);
+                gen_op(op);
+                vswap();
+                vpushi(32 - c);
+                if (op == TOK_SHL)
+                    gen_op(TOK_SHR);
+                else
+                    gen_op(TOK_SHL);
+                vrotb(3);
+                /* stack: L L H */
+                vpushi(c);
+                if (op == TOK_SHL)
+                    gen_op(TOK_SHL);
+                else
+                    gen_op(TOK_SHR);
+                gen_op('|');
+            }
+            if (op != TOK_SHL)
+                vswap();
+            lbuild(t);
+        } else {
+            /* XXX: should provide a faster fallback on x86 ? */
+            switch(op) {
+            case TOK_SAR:
+                func = TOK___ashrdi3;
+                goto gen_func;
+            case TOK_SHR:
+                func = TOK___lshrdi3;
+                goto gen_func;
+            case TOK_SHL:
+                func = TOK___ashldi3;
+                goto gen_func;
+            }
+        }
+        break;
+    default:
+        /* compare operations */
+        t = vtop->type.t;
+        vswap();
+        lexpand();
+        vrotb(3);
+        lexpand();
+        /* stack: L1 H1 L2 H2 */
+        tmp = vtop[-1];
+        vtop[-1] = vtop[-2];
+        vtop[-2] = tmp;
+        /* stack: L1 L2 H1 H2 */
+        /* compare high */
+        op1 = op;
+        /* when values are equal, we need to compare low words. since
+           the jump is inverted, we invert the test too. */
+        if (op1 == TOK_LT)
+            op1 = TOK_LE;
+        else if (op1 == TOK_GT)
+            op1 = TOK_GE;
+        else if (op1 == TOK_ULT)
+            op1 = TOK_ULE;
+        else if (op1 == TOK_UGT)
+            op1 = TOK_UGE;
+        a = 0;
+        b = 0;
+        gen_op(op1);
+        if (op1 != TOK_NE) {
+            a = gtst(1, 0);
+        }
+        if (op != TOK_EQ) {
+            /* generate non equal test */
+            /* XXX: NOT PORTABLE yet */
+            if (a == 0) {
+                b = gtst(0, 0);
+            } else {
+#if defined(TCC_TARGET_I386)
+                b = psym(0x850f, 0);
+#elif defined(TCC_TARGET_ARM)
+                b = ind;
+                o(0x1A000000 | encbranch(ind, 0, 1));
+#elif defined(TCC_TARGET_C67)
+                tcc_error("not implemented");
+#elif defined(TCC_TARGET_IL)
+                tcc_error("not implemented");
+#else
+#error not supported
+#endif
+            }
+        }
+        /* compare low. Always unsigned */
+        op1 = op;
+        if (op1 == TOK_LT)
+            op1 = TOK_ULT;
+        else if (op1 == TOK_LE)
+            op1 = TOK_ULE;
+        else if (op1 == TOK_GT)
+            op1 = TOK_UGT;
+        else if (op1 == TOK_GE)
+            op1 = TOK_UGE;
+        gen_op(op1);
+        a = gtst(1, a);
+        gsym(b);
+        vseti(VT_JMPI, a);
+        break;
+    }
+}
+#endif
+
+/* handle integer constant optimizations and various machine
+   independent opt */
+static void gen_opic(int op)
+{
+    int c1, c2, t1, t2, n;
+    SValue *v1, *v2;
+    long long l1, l2;
+    typedef unsigned long long U;
+
+    v1 = vtop - 1;
+    v2 = vtop;
+    t1 = v1->type.t & VT_BTYPE;
+    t2 = v2->type.t & VT_BTYPE;
+
+    if (t1 == VT_LLONG)
+        l1 = v1->c.ll;
+    else if (v1->type.t & VT_UNSIGNED)
+        l1 = v1->c.ui;
+    else
+        l1 = v1->c.i;
+
+    if (t2 == VT_LLONG)
+        l2 = v2->c.ll;
+    else if (v2->type.t & VT_UNSIGNED)
+        l2 = v2->c.ui;
+    else
+        l2 = v2->c.i;
+
+    /* currently, we cannot do computations with forward symbols */
+    c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+    c2 = (v2->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+    if (c1 && c2) {
+        switch(op) {
+        case '+': l1 += l2; break;
+        case '-': l1 -= l2; break;
+        case '&': l1 &= l2; break;
+        case '^': l1 ^= l2; break;
+        case '|': l1 |= l2; break;
+        case '*': l1 *= l2; break;
+
+        case TOK_PDIV:
+        case '/':
+        case '%':
+        case TOK_UDIV:
+        case TOK_UMOD:
+            /* if division by zero, generate explicit division */
+            if (l2 == 0) {
+                if (const_wanted)
+                    tcc_error("division by zero in constant");
+                goto general_case;
+            }
+            switch(op) {
+            default: l1 /= l2; break;
+            case '%': l1 %= l2; break;
+            case TOK_UDIV: l1 = (U)l1 / l2; break;
+            case TOK_UMOD: l1 = (U)l1 % l2; break;
+            }
+            break;
+        case TOK_SHL: l1 <<= l2; break;
+        case TOK_SHR: l1 = (U)l1 >> l2; break;
+        case TOK_SAR: l1 >>= l2; break;
+            /* tests */
+        case TOK_ULT: l1 = (U)l1 < (U)l2; break;
+        case TOK_UGE: l1 = (U)l1 >= (U)l2; break;
+        case TOK_EQ: l1 = l1 == l2; break;
+        case TOK_NE: l1 = l1 != l2; break;
+        case TOK_ULE: l1 = (U)l1 <= (U)l2; break;
+        case TOK_UGT: l1 = (U)l1 > (U)l2; break;
+        case TOK_LT: l1 = l1 < l2; break;
+        case TOK_GE: l1 = l1 >= l2; break;
+        case TOK_LE: l1 = l1 <= l2; break;
+        case TOK_GT: l1 = l1 > l2; break;
+            /* logical */
+        case TOK_LAND: l1 = l1 && l2; break;
+        case TOK_LOR: l1 = l1 || l2; break;
+        default:
+            goto general_case;
+        }
+        v1->c.ll = l1;
+        vtop--;
+    } else {
+        /* if commutative ops, put c2 as constant */
+        if (c1 && (op == '+' || op == '&' || op == '^' || 
+                   op == '|' || op == '*')) {
+            vswap();
+            c2 = c1; //c = c1, c1 = c2, c2 = c;
+            l2 = l1; //l = l1, l1 = l2, l2 = l;
+        }
+        /* Filter out NOP operations like x*1, x-0, x&-1... */
+        if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV || 
+                     op == TOK_PDIV) && 
+                    l2 == 1) ||
+                   ((op == '+' || op == '-' || op == '|' || op == '^' || 
+                     op == TOK_SHL || op == TOK_SHR || op == TOK_SAR) && 
+                    l2 == 0) ||
+                   (op == '&' && 
+                    l2 == -1))) {
+            /* nothing to do */
+            vtop--;
+        } else if (c2 && (op == '*' || op == TOK_PDIV || op == TOK_UDIV)) {
+            /* try to use shifts instead of muls or divs */
+            if (l2 > 0 && (l2 & (l2 - 1)) == 0) {
+                n = -1;
+                while (l2) {
+                    l2 >>= 1;
+                    n++;
+                }
+                vtop->c.ll = n;
+                if (op == '*')
+                    op = TOK_SHL;
+                else if (op == TOK_PDIV)
+                    op = TOK_SAR;
+                else
+                    op = TOK_SHR;
+            }
+            goto general_case;
+        } else if (c2 && (op == '+' || op == '-') &&
+                   (((vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM))
+                    || (vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_LOCAL)) {
+            /* symbol + constant case */
+            if (op == '-')
+                l2 = -l2;
+            vtop--;
+            vtop->c.ll += l2;
+        } else {
+        general_case:
+            if (!nocode_wanted) {
+                /* call low level op generator */
+                if (t1 == VT_LLONG || t2 == VT_LLONG) 
+                    gen_opl(op);
+                else
+                    gen_opi(op);
+            } else {
+                vtop--;
+            }
+        }
+    }
+}
+
+/* generate a floating point operation with constant propagation */
+static void gen_opif(int op)
+{
+    int c1, c2;
+    SValue *v1, *v2;
+    long double f1, f2;
+
+    v1 = vtop - 1;
+    v2 = vtop;
+    /* currently, we cannot do computations with forward symbols */
+    c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+    c2 = (v2->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+    if (c1 && c2) {
+        if (v1->type.t == VT_FLOAT) {
+            f1 = v1->c.f;
+            f2 = v2->c.f;
+        } else if (v1->type.t == VT_DOUBLE) {
+            f1 = v1->c.d;
+            f2 = v2->c.d;
+        } else {
+            f1 = v1->c.ld;
+            f2 = v2->c.ld;
+        }
+
+        /* NOTE: we only do constant propagation if finite number (not
+           NaN or infinity) (ANSI spec) */
+        if (!ieee_finite(f1) || !ieee_finite(f2))
+            goto general_case;
+
+        switch(op) {
+        case '+': f1 += f2; break;
+        case '-': f1 -= f2; break;
+        case '*': f1 *= f2; break;
+        case '/': 
+            if (f2 == 0.0) {
+                if (const_wanted)
+                    tcc_error("division by zero in constant");
+                goto general_case;
+            }
+            f1 /= f2; 
+            break;
+            /* XXX: also handles tests ? */
+        default:
+            goto general_case;
+        }
+        /* XXX: overflow test ? */
+        if (v1->type.t == VT_FLOAT) {
+            v1->c.f = f1;
+        } else if (v1->type.t == VT_DOUBLE) {
+            v1->c.d = f1;
+        } else {
+            v1->c.ld = f1;
+        }
+        vtop--;
+    } else {
+    general_case:
+        if (!nocode_wanted) {
+            gen_opf(op);
+        } else {
+            vtop--;
+        }
+    }
+}
+
+static int pointed_size(CType *type)
+{
+    int align;
+    return type_size(pointed_type(type), &align);
+}
+
+static void vla_runtime_pointed_size(CType *type)
+{
+    int align;
+    vla_runtime_type_size(pointed_type(type), &align);
+}
+
+static inline int is_null_pointer(SValue *p)
+{
+    if ((p->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
+        return 0;
+    return ((p->type.t & VT_BTYPE) == VT_INT && p->c.i == 0) ||
+        ((p->type.t & VT_BTYPE) == VT_LLONG && p->c.ll == 0) ||
+	((p->type.t & VT_BTYPE) == VT_PTR && p->c.ptr == 0);
+}
+
+static inline int is_integer_btype(int bt)
+{
+    return (bt == VT_BYTE || bt == VT_SHORT || 
+            bt == VT_INT || bt == VT_LLONG);
+}
+
+/* check types for comparison or substraction of pointers */
+static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op)
+{
+    CType *type1, *type2, tmp_type1, tmp_type2;
+    int bt1, bt2;
+    
+    /* null pointers are accepted for all comparisons as gcc */
+    if (is_null_pointer(p1) || is_null_pointer(p2))
+        return;
+    type1 = &p1->type;
+    type2 = &p2->type;
+    bt1 = type1->t & VT_BTYPE;
+    bt2 = type2->t & VT_BTYPE;
+    /* accept comparison between pointer and integer with a warning */
+    if ((is_integer_btype(bt1) || is_integer_btype(bt2)) && op != '-') {
+        if (op != TOK_LOR && op != TOK_LAND )
+            tcc_warning("comparison between pointer and integer");
+        return;
+    }
+
+    /* both must be pointers or implicit function pointers */
+    if (bt1 == VT_PTR) {
+        type1 = pointed_type(type1);
+    } else if (bt1 != VT_FUNC) 
+        goto invalid_operands;
+
+    if (bt2 == VT_PTR) {
+        type2 = pointed_type(type2);
+    } else if (bt2 != VT_FUNC) { 
+    invalid_operands:
+        tcc_error("invalid operands to binary %s", get_tok_str(op, NULL));
+    }
+    if ((type1->t & VT_BTYPE) == VT_VOID || 
+        (type2->t & VT_BTYPE) == VT_VOID)
+        return;
+    tmp_type1 = *type1;
+    tmp_type2 = *type2;
+    tmp_type1.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE);
+    tmp_type2.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE);
+    if (!is_compatible_types(&tmp_type1, &tmp_type2)) {
+        /* gcc-like error if '-' is used */
+        if (op == '-')
+            goto invalid_operands;
+        else
+            tcc_warning("comparison of distinct pointer types lacks a cast");
+    }
+}
+
+/* generic gen_op: handles types problems */
+ST_FUNC void gen_op(int op)
+{
+    int u, t1, t2, bt1, bt2, t;
+    CType type1;
+
+    t1 = vtop[-1].type.t;
+    t2 = vtop[0].type.t;
+    bt1 = t1 & VT_BTYPE;
+    bt2 = t2 & VT_BTYPE;
+        
+    if (bt1 == VT_PTR || bt2 == VT_PTR) {
+        /* at least one operand is a pointer */
+        /* relationnal op: must be both pointers */
+        if (op >= TOK_ULT && op <= TOK_LOR) {
+            check_comparison_pointer_types(vtop - 1, vtop, op);
+            /* pointers are handled are unsigned */
+#ifdef TCC_TARGET_X86_64
+            t = VT_LLONG | VT_UNSIGNED;
+#else
+            t = VT_INT | VT_UNSIGNED;
+#endif
+            goto std_op;
+        }
+        /* if both pointers, then it must be the '-' op */
+        if (bt1 == VT_PTR && bt2 == VT_PTR) {
+            if (op != '-')
+                tcc_error("cannot use pointers here");
+            check_comparison_pointer_types(vtop - 1, vtop, op);
+            /* XXX: check that types are compatible */
+            if (vtop[-1].type.t & VT_VLA) {
+                vla_runtime_pointed_size(&vtop[-1].type);
+            } else {
+                vpushi(pointed_size(&vtop[-1].type));
+            }
+            vrott(3);
+            gen_opic(op);
+            /* set to integer type */
+#ifdef TCC_TARGET_X86_64
+            vtop->type.t = VT_LLONG;
+#else
+            vtop->type.t = VT_INT; 
+#endif
+            vswap();
+            gen_op(TOK_PDIV);
+        } else {
+            /* exactly one pointer : must be '+' or '-'. */
+            if (op != '-' && op != '+')
+                tcc_error("cannot use pointers here");
+            /* Put pointer as first operand */
+            if (bt2 == VT_PTR) {
+                vswap();
+                swap(&t1, &t2);
+            }
+            type1 = vtop[-1].type;
+            type1.t &= ~VT_ARRAY;
+            if (vtop[-1].type.t & VT_VLA)
+                vla_runtime_pointed_size(&vtop[-1].type);
+            else {
+                u = pointed_size(&vtop[-1].type);
+                if (u < 0)
+                    tcc_error("unknown array element size");
+#ifdef TCC_TARGET_X86_64
+                vpushll(u);
+#else
+                /* XXX: cast to int ? (long long case) */
+                vpushi(u);
+#endif
+            }
+            gen_op('*');
+#ifdef CONFIG_TCC_BCHECK
+            /* if evaluating constant expression, no code should be
+               generated, so no bound check */
+            if (tcc_state->do_bounds_check && !const_wanted) {
+                /* if bounded pointers, we generate a special code to
+                   test bounds */
+                if (op == '-') {
+                    vpushi(0);
+                    vswap();
+                    gen_op('-');
+                }
+                gen_bounded_ptr_add();
+            } else
+#endif
+            {
+                gen_opic(op);
+            }
+            /* put again type if gen_opic() swaped operands */
+            vtop->type = type1;
+        }
+    } else if (is_float(bt1) || is_float(bt2)) {
+        /* compute bigger type and do implicit casts */
+        if (bt1 == VT_LDOUBLE || bt2 == VT_LDOUBLE) {
+            t = VT_LDOUBLE;
+        } else if (bt1 == VT_DOUBLE || bt2 == VT_DOUBLE) {
+            t = VT_DOUBLE;
+        } else {
+            t = VT_FLOAT;
+        }
+        /* floats can only be used for a few operations */
+        if (op != '+' && op != '-' && op != '*' && op != '/' &&
+            (op < TOK_ULT || op > TOK_GT))
+            tcc_error("invalid operands for binary operation");
+        goto std_op;
+    } else if (op == TOK_SHR || op == TOK_SAR || op == TOK_SHL) {
+        t = bt1 == VT_LLONG ? VT_LLONG : VT_INT;
+        if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (t | VT_UNSIGNED))
+          t |= VT_UNSIGNED;
+        goto std_op;
+    } else if (bt1 == VT_LLONG || bt2 == VT_LLONG) {
+        /* cast to biggest op */
+        t = VT_LLONG;
+        /* convert to unsigned if it does not fit in a long long */
+        if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (VT_LLONG | VT_UNSIGNED) ||
+            (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_LLONG | VT_UNSIGNED))
+            t |= VT_UNSIGNED;
+        goto std_op;
+    } else if (bt1 == VT_STRUCT || bt2 == VT_STRUCT) {
+        tcc_error("comparison of struct");
+    } else {
+        /* integer operations */
+        t = VT_INT;
+        /* convert to unsigned if it does not fit in an integer */
+        if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED) ||
+            (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED))
+            t |= VT_UNSIGNED;
+    std_op:
+        /* XXX: currently, some unsigned operations are explicit, so
+           we modify them here */
+        if (t & VT_UNSIGNED) {
+            if (op == TOK_SAR)
+                op = TOK_SHR;
+            else if (op == '/')
+                op = TOK_UDIV;
+            else if (op == '%')
+                op = TOK_UMOD;
+            else if (op == TOK_LT)
+                op = TOK_ULT;
+            else if (op == TOK_GT)
+                op = TOK_UGT;
+            else if (op == TOK_LE)
+                op = TOK_ULE;
+            else if (op == TOK_GE)
+                op = TOK_UGE;
+        }
+        vswap();
+        type1.t = t;
+        gen_cast(&type1);
+        vswap();
+        /* special case for shifts and long long: we keep the shift as
+           an integer */
+        if (op == TOK_SHR || op == TOK_SAR || op == TOK_SHL)
+            type1.t = VT_INT;
+        gen_cast(&type1);
+        if (is_float(t))
+            gen_opif(op);
+        else
+            gen_opic(op);
+        if (op >= TOK_ULT && op <= TOK_GT) {
+            /* relationnal op: the result is an int */
+            vtop->type.t = VT_INT;
+        } else {
+            vtop->type.t = t;
+        }
+    }
+}
+
+#ifndef TCC_TARGET_ARM
+/* generic itof for unsigned long long case */
+static void gen_cvt_itof1(int t)
+{
+    if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == 
+        (VT_LLONG | VT_UNSIGNED)) {
+
+        if (t == VT_FLOAT)
+            vpush_global_sym(&func_old_type, TOK___floatundisf);
+#if LDOUBLE_SIZE != 8
+        else if (t == VT_LDOUBLE)
+            vpush_global_sym(&func_old_type, TOK___floatundixf);
+#endif
+        else
+            vpush_global_sym(&func_old_type, TOK___floatundidf);
+        vrott(2);
+        gfunc_call(1);
+        vpushi(0);
+        vtop->r = reg_fret(t);
+    } else {
+        gen_cvt_itof(t);
+    }
+}
+#endif
+
+/* generic ftoi for unsigned long long case */
+static void gen_cvt_ftoi1(int t)
+{
+    int st;
+
+    if (t == (VT_LLONG | VT_UNSIGNED)) {
+        /* not handled natively */
+        st = vtop->type.t & VT_BTYPE;
+        if (st == VT_FLOAT)
+            vpush_global_sym(&func_old_type, TOK___fixunssfdi);
+#if LDOUBLE_SIZE != 8
+        else if (st == VT_LDOUBLE)
+            vpush_global_sym(&func_old_type, TOK___fixunsxfdi);
+#endif
+        else
+            vpush_global_sym(&func_old_type, TOK___fixunsdfdi);
+        vrott(2);
+        gfunc_call(1);
+        vpushi(0);
+        vtop->r = REG_IRET;
+        vtop->r2 = REG_LRET;
+    } else {
+        gen_cvt_ftoi(t);
+    }
+}
+
+/* force char or short cast */
+static void force_charshort_cast(int t)
+{
+    int bits, dbt;
+    dbt = t & VT_BTYPE;
+    /* XXX: add optimization if lvalue : just change type and offset */
+    if (dbt == VT_BYTE)
+        bits = 8;
+    else
+        bits = 16;
+    if (t & VT_UNSIGNED) {
+        vpushi((1 << bits) - 1);
+        gen_op('&');
+    } else {
+        bits = 32 - bits;
+        vpushi(bits);
+        gen_op(TOK_SHL);
+        /* result must be signed or the SAR is converted to an SHL
+           This was not the case when "t" was a signed short
+           and the last value on the stack was an unsigned int */
+        vtop->type.t &= ~VT_UNSIGNED;
+        vpushi(bits);
+        gen_op(TOK_SAR);
+    }
+}
+
+/* cast 'vtop' to 'type'. Casting to bitfields is forbidden. */
+static void gen_cast(CType *type)
+{
+    int sbt, dbt, sf, df, c, p;
+
+    /* special delayed cast for char/short */
+    /* XXX: in some cases (multiple cascaded casts), it may still
+       be incorrect */
+    if (vtop->r & VT_MUSTCAST) {
+        vtop->r &= ~VT_MUSTCAST;
+        force_charshort_cast(vtop->type.t);
+    }
+
+    /* bitfields first get cast to ints */
+    if (vtop->type.t & VT_BITFIELD) {
+        gv(RC_INT);
+    }
+
+    dbt = type->t & (VT_BTYPE | VT_UNSIGNED);
+    sbt = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
+
+    if (sbt != dbt) {
+        sf = is_float(sbt);
+        df = is_float(dbt);
+        c = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+        p = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM);
+        if (c) {
+            /* constant case: we can do it now */
+            /* XXX: in ISOC, cannot do it if error in convert */
+            if (sbt == VT_FLOAT)
+                vtop->c.ld = vtop->c.f;
+            else if (sbt == VT_DOUBLE)
+                vtop->c.ld = vtop->c.d;
+
+            if (df) {
+                if ((sbt & VT_BTYPE) == VT_LLONG) {
+                    if (sbt & VT_UNSIGNED)
+                        vtop->c.ld = vtop->c.ull;
+                    else
+                        vtop->c.ld = vtop->c.ll;
+                } else if(!sf) {
+                    if (sbt & VT_UNSIGNED)
+                        vtop->c.ld = vtop->c.ui;
+                    else
+                        vtop->c.ld = vtop->c.i;
+                }
+
+                if (dbt == VT_FLOAT)
+                    vtop->c.f = (float)vtop->c.ld;
+                else if (dbt == VT_DOUBLE)
+                    vtop->c.d = (double)vtop->c.ld;
+            } else if (sf && dbt == (VT_LLONG|VT_UNSIGNED)) {
+                vtop->c.ull = (unsigned long long)vtop->c.ld;
+            } else if (sf && dbt == VT_BOOL) {
+                vtop->c.i = (vtop->c.ld != 0);
+            } else {
+                if(sf)
+                    vtop->c.ll = (long long)vtop->c.ld;
+                else if (sbt == (VT_LLONG|VT_UNSIGNED))
+                    vtop->c.ll = vtop->c.ull;
+                else if (sbt & VT_UNSIGNED)
+                    vtop->c.ll = vtop->c.ui;
+#ifdef TCC_TARGET_X86_64
+                else if (sbt == VT_PTR)
+                    ;
+#endif
+                else if (sbt != VT_LLONG)
+                    vtop->c.ll = vtop->c.i;
+
+                if (dbt == (VT_LLONG|VT_UNSIGNED))
+                    vtop->c.ull = vtop->c.ll;
+                else if (dbt == VT_BOOL)
+                    vtop->c.i = (vtop->c.ll != 0);
+                else if (dbt != VT_LLONG) {
+                    int s = 0;
+                    if ((dbt & VT_BTYPE) == VT_BYTE)
+                        s = 24;
+                    else if ((dbt & VT_BTYPE) == VT_SHORT)
+                        s = 16;
+
+                    if(dbt & VT_UNSIGNED)
+                        vtop->c.ui = ((unsigned int)vtop->c.ll << s) >> s;
+                    else
+                        vtop->c.i = ((int)vtop->c.ll << s) >> s;
+                }
+            }
+        } else if (p && dbt == VT_BOOL) {
+            vtop->r = VT_CONST;
+            vtop->c.i = 1;
+        } else if (!nocode_wanted) {
+            /* non constant case: generate code */
+            if (sf && df) {
+                /* convert from fp to fp */
+                gen_cvt_ftof(dbt);
+            } else if (df) {
+                /* convert int to fp */
+                gen_cvt_itof1(dbt);
+            } else if (sf) {
+                /* convert fp to int */
+                if (dbt == VT_BOOL) {
+                     vpushi(0);
+                     gen_op(TOK_NE);
+                } else {
+                    /* we handle char/short/etc... with generic code */
+                    if (dbt != (VT_INT | VT_UNSIGNED) &&
+                        dbt != (VT_LLONG | VT_UNSIGNED) &&
+                        dbt != VT_LLONG)
+                        dbt = VT_INT;
+                    gen_cvt_ftoi1(dbt);
+                    if (dbt == VT_INT && (type->t & (VT_BTYPE | VT_UNSIGNED)) != dbt) {
+                        /* additional cast for char/short... */
+                        vtop->type.t = dbt;
+                        gen_cast(type);
+                    }
+                }
+#ifndef TCC_TARGET_X86_64
+            } else if ((dbt & VT_BTYPE) == VT_LLONG) {
+                if ((sbt & VT_BTYPE) != VT_LLONG) {
+                    /* scalar to long long */
+                    /* machine independent conversion */
+                    gv(RC_INT);
+                    /* generate high word */
+                    if (sbt == (VT_INT | VT_UNSIGNED)) {
+                        vpushi(0);
+                        gv(RC_INT);
+                    } else {
+                        if (sbt == VT_PTR) {
+                            /* cast from pointer to int before we apply
+                               shift operation, which pointers don't support*/
+                            gen_cast(&int_type);
+                        }
+                        gv_dup();
+                        vpushi(31);
+                        gen_op(TOK_SAR);
+                    }
+                    /* patch second register */
+                    vtop[-1].r2 = vtop->r;
+                    vpop();
+                }
+#else
+            } else if ((dbt & VT_BTYPE) == VT_LLONG ||
+                       (dbt & VT_BTYPE) == VT_PTR ||
+                       (dbt & VT_BTYPE) == VT_FUNC) {
+                if ((sbt & VT_BTYPE) != VT_LLONG &&
+                    (sbt & VT_BTYPE) != VT_PTR &&
+                    (sbt & VT_BTYPE) != VT_FUNC) {
+                    /* need to convert from 32bit to 64bit */
+                    int r = gv(RC_INT);
+                    if (sbt != (VT_INT | VT_UNSIGNED)) {
+                        /* x86_64 specific: movslq */
+                        o(0x6348);
+                        o(0xc0 + (REG_VALUE(r) << 3) + REG_VALUE(r));
+                    }
+                }
+#endif
+            } else if (dbt == VT_BOOL) {
+                /* scalar to bool */
+                vpushi(0);
+                gen_op(TOK_NE);
+            } else if ((dbt & VT_BTYPE) == VT_BYTE || 
+                       (dbt & VT_BTYPE) == VT_SHORT) {
+                if (sbt == VT_PTR) {
+                    vtop->type.t = VT_INT;
+                    tcc_warning("nonportable conversion from pointer to char/short");
+                }
+                force_charshort_cast(dbt);
+            } else if ((dbt & VT_BTYPE) == VT_INT) {
+                /* scalar to int */
+                if (sbt == VT_LLONG) {
+                    /* from long long: just take low order word */
+                    lexpand();
+                    vpop();
+                } 
+                /* if lvalue and single word type, nothing to do because
+                   the lvalue already contains the real type size (see
+                   VT_LVAL_xxx constants) */
+            }
+        }
+    } else if ((dbt & VT_BTYPE) == VT_PTR && !(vtop->r & VT_LVAL)) {
+        /* if we are casting between pointer types,
+           we must update the VT_LVAL_xxx size */
+        vtop->r = (vtop->r & ~VT_LVAL_TYPE)
+                  | (lvalue_type(type->ref->type.t) & VT_LVAL_TYPE);
+    }
+    vtop->type = *type;
+}
+
+/* return type size as known at compile time. Put alignment at 'a' */
+ST_FUNC int type_size(CType *type, int *a)
+{
+    Sym *s;
+    int bt;
+
+    bt = type->t & VT_BTYPE;
+    if (bt == VT_STRUCT) {
+        /* struct/union */
+        s = type->ref;
+        *a = s->r;
+        return s->c;
+    } else if (bt == VT_PTR) {
+        if (type->t & VT_ARRAY) {
+            int ts;
+
+            s = type->ref;
+            ts = type_size(&s->type, a);
+
+            if (ts < 0 && s->c < 0)
+                ts = -ts;
+
+            return ts * s->c;
+        } else {
+            *a = PTR_SIZE;
+            return PTR_SIZE;
+        }
+    } else if (bt == VT_LDOUBLE) {
+        *a = LDOUBLE_ALIGN;
+        return LDOUBLE_SIZE;
+    } else if (bt == VT_DOUBLE || bt == VT_LLONG) {
+#ifdef TCC_TARGET_I386
+#ifdef TCC_TARGET_PE
+        *a = 8;
+#else
+        *a = 4;
+#endif
+#elif defined(TCC_TARGET_ARM)
+#ifdef TCC_ARM_EABI
+        *a = 8; 
+#else
+        *a = 4;
+#endif
+#else
+        *a = 8;
+#endif
+        return 8;
+    } else if (bt == VT_INT || bt == VT_ENUM || bt == VT_FLOAT) {
+        *a = 4;
+        return 4;
+    } else if (bt == VT_SHORT) {
+        *a = 2;
+        return 2;
+    } else {
+        /* char, void, function, _Bool */
+        *a = 1;
+        return 1;
+    }
+}
+
+/* push type size as known at runtime time on top of value stack. Put
+   alignment at 'a' */
+ST_FUNC void vla_runtime_type_size(CType *type, int *a)
+{
+    if (type->t & VT_VLA) {
+        vset(&int_type, VT_LOCAL|VT_LVAL, type->ref->c);
+    } else {
+        vpushi(type_size(type, a));
+    }
+}
+
+/* return the pointed type of t */
+static inline CType *pointed_type(CType *type)
+{
+    return &type->ref->type;
+}
+
+/* modify type so that its it is a pointer to type. */
+ST_FUNC void mk_pointer(CType *type)
+{
+    Sym *s;
+    s = sym_push(SYM_FIELD, type, 0, -1);
+    type->t = VT_PTR | (type->t & ~VT_TYPE);
+    type->ref = s;
+}
+
+/* compare function types. OLD functions match any new functions */
+static int is_compatible_func(CType *type1, CType *type2)
+{
+    Sym *s1, *s2;
+
+    s1 = type1->ref;
+    s2 = type2->ref;
+    if (!is_compatible_types(&s1->type, &s2->type))
+        return 0;
+    /* check func_call */
+    if (FUNC_CALL(s1->r) != FUNC_CALL(s2->r))
+        return 0;
+    /* XXX: not complete */
+    if (s1->c == FUNC_OLD || s2->c == FUNC_OLD)
+        return 1;
+    if (s1->c != s2->c)
+        return 0;
+    while (s1 != NULL) {
+        if (s2 == NULL)
+            return 0;
+        if (!is_compatible_parameter_types(&s1->type, &s2->type))
+            return 0;
+        s1 = s1->next;
+        s2 = s2->next;
+    }
+    if (s2)
+        return 0;
+    return 1;
+}
+
+/* return true if type1 and type2 are the same.  If unqualified is
+   true, qualifiers on the types are ignored.
+
+   - enums are not checked as gcc __builtin_types_compatible_p () 
+ */
+static int compare_types(CType *type1, CType *type2, int unqualified)
+{
+    int bt1, t1, t2;
+
+    t1 = type1->t & VT_TYPE;
+    t2 = type2->t & VT_TYPE;
+    if (unqualified) {
+        /* strip qualifiers before comparing */
+        t1 &= ~(VT_CONSTANT | VT_VOLATILE);
+        t2 &= ~(VT_CONSTANT | VT_VOLATILE);
+    }
+    /* XXX: bitfields ? */
+    if (t1 != t2)
+        return 0;
+    /* test more complicated cases */
+    bt1 = t1 & VT_BTYPE;
+    if (bt1 == VT_PTR) {
+        type1 = pointed_type(type1);
+        type2 = pointed_type(type2);
+        return is_compatible_types(type1, type2);
+    } else if (bt1 == VT_STRUCT) {
+        return (type1->ref == type2->ref);
+    } else if (bt1 == VT_FUNC) {
+        return is_compatible_func(type1, type2);
+    } else {
+        return 1;
+    }
+}
+
+/* return true if type1 and type2 are exactly the same (including
+   qualifiers). 
+*/
+static int is_compatible_types(CType *type1, CType *type2)
+{
+    return compare_types(type1,type2,0);
+}
+
+/* return true if type1 and type2 are the same (ignoring qualifiers).
+*/
+static int is_compatible_parameter_types(CType *type1, CType *type2)
+{
+    return compare_types(type1,type2,1);
+}
+
+/* print a type. If 'varstr' is not NULL, then the variable is also
+   printed in the type */
+/* XXX: union */
+/* XXX: add array and function pointers */
+static void type_to_str(char *buf, int buf_size, 
+                 CType *type, const char *varstr)
+{
+    int bt, v, t;
+    Sym *s, *sa;
+    char buf1[256];
+    const char *tstr;
+
+    t = type->t & VT_TYPE;
+    bt = t & VT_BTYPE;
+    buf[0] = '\0';
+    if (t & VT_CONSTANT)
+        pstrcat(buf, buf_size, "const ");
+    if (t & VT_VOLATILE)
+        pstrcat(buf, buf_size, "volatile ");
+    if (t & VT_UNSIGNED)
+        pstrcat(buf, buf_size, "unsigned ");
+    switch(bt) {
+    case VT_VOID:
+        tstr = "void";
+        goto add_tstr;
+    case VT_BOOL:
+        tstr = "_Bool";
+        goto add_tstr;
+    case VT_BYTE:
+        tstr = "char";
+        goto add_tstr;
+    case VT_SHORT:
+        tstr = "short";
+        goto add_tstr;
+    case VT_INT:
+        tstr = "int";
+        goto add_tstr;
+    case VT_LONG:
+        tstr = "long";
+        goto add_tstr;
+    case VT_LLONG:
+        tstr = "long long";
+        goto add_tstr;
+    case VT_FLOAT:
+        tstr = "float";
+        goto add_tstr;
+    case VT_DOUBLE:
+        tstr = "double";
+        goto add_tstr;
+    case VT_LDOUBLE:
+        tstr = "long double";
+    add_tstr:
+        pstrcat(buf, buf_size, tstr);
+        break;
+    case VT_ENUM:
+    case VT_STRUCT:
+        if (bt == VT_STRUCT)
+            tstr = "struct ";
+        else
+            tstr = "enum ";
+        pstrcat(buf, buf_size, tstr);
+        v = type->ref->v & ~SYM_STRUCT;
+        if (v >= SYM_FIRST_ANOM)
+            pstrcat(buf, buf_size, "<anonymous>");
+        else
+            pstrcat(buf, buf_size, get_tok_str(v, NULL));
+        break;
+    case VT_FUNC:
+        s = type->ref;
+        type_to_str(buf, buf_size, &s->type, varstr);
+        pstrcat(buf, buf_size, "(");
+        sa = s->next;
+        while (sa != NULL) {
+            type_to_str(buf1, sizeof(buf1), &sa->type, NULL);
+            pstrcat(buf, buf_size, buf1);
+            sa = sa->next;
+            if (sa)
+                pstrcat(buf, buf_size, ", ");
+        }
+        pstrcat(buf, buf_size, ")");
+        goto no_var;
+    case VT_PTR:
+        s = type->ref;
+        pstrcpy(buf1, sizeof(buf1), "*");
+        if (varstr)
+            pstrcat(buf1, sizeof(buf1), varstr);
+        type_to_str(buf, buf_size, &s->type, buf1);
+        goto no_var;
+    }
+    if (varstr) {
+        pstrcat(buf, buf_size, " ");
+        pstrcat(buf, buf_size, varstr);
+    }
+ no_var: ;
+}
+
+/* verify type compatibility to store vtop in 'dt' type, and generate
+   casts if needed. */
+static void gen_assign_cast(CType *dt)
+{
+    CType *st, *type1, *type2, tmp_type1, tmp_type2;
+    char buf1[256], buf2[256];
+    int dbt, sbt;
+
+    st = &vtop->type; /* source type */
+    dbt = dt->t & VT_BTYPE;
+    sbt = st->t & VT_BTYPE;
+    if (sbt == VT_VOID)
+        tcc_error("Cannot assign void value");
+    if (dt->t & VT_CONSTANT)
+        tcc_warning("assignment of read-only location");
+    switch(dbt) {
+    case VT_PTR:
+        /* special cases for pointers */
+        /* '0' can also be a pointer */
+        if (is_null_pointer(vtop))
+            goto type_ok;
+        /* accept implicit pointer to integer cast with warning */
+        if (is_integer_btype(sbt)) {
+            tcc_warning("assignment makes pointer from integer without a cast");
+            goto type_ok;
+        }
+        type1 = pointed_type(dt);
+        /* a function is implicitely a function pointer */
+        if (sbt == VT_FUNC) {
+            if ((type1->t & VT_BTYPE) != VT_VOID &&
+                !is_compatible_types(pointed_type(dt), st))
+                tcc_warning("assignment from incompatible pointer type");
+            goto type_ok;
+        }
+        if (sbt != VT_PTR)
+            goto error;
+        type2 = pointed_type(st);
+        if ((type1->t & VT_BTYPE) == VT_VOID || 
+            (type2->t & VT_BTYPE) == VT_VOID) {
+            /* void * can match anything */
+        } else {
+            /* exact type match, except for unsigned */
+            tmp_type1 = *type1;
+            tmp_type2 = *type2;
+            tmp_type1.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE);
+            tmp_type2.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE);
+            if (!is_compatible_types(&tmp_type1, &tmp_type2))
+                tcc_warning("assignment from incompatible pointer type");
+        }
+        /* check const and volatile */
+        if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT)) ||
+            (!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))
+            tcc_warning("assignment discards qualifiers from pointer target type");
+        break;
+    case VT_BYTE:
+    case VT_SHORT:
+    case VT_INT:
+    case VT_LLONG:
+        if (sbt == VT_PTR || sbt == VT_FUNC) {
+            tcc_warning("assignment makes integer from pointer without a cast");
+        }
+        /* XXX: more tests */
+        break;
+    case VT_STRUCT:
+        tmp_type1 = *dt;
+        tmp_type2 = *st;
+        tmp_type1.t &= ~(VT_CONSTANT | VT_VOLATILE);
+        tmp_type2.t &= ~(VT_CONSTANT | VT_VOLATILE);
+        if (!is_compatible_types(&tmp_type1, &tmp_type2)) {
+        error:
+            type_to_str(buf1, sizeof(buf1), st, NULL);
+            type_to_str(buf2, sizeof(buf2), dt, NULL);
+            tcc_error("cannot cast '%s' to '%s'", buf1, buf2);
+        }
+        break;
+    }
+ type_ok:
+    gen_cast(dt);
+}
+
+/* store vtop in lvalue pushed on stack */
+ST_FUNC void vstore(void)
+{
+    int sbt, dbt, ft, r, t, size, align, bit_size, bit_pos, rc, delayed_cast;
+
+    ft = vtop[-1].type.t;
+    sbt = vtop->type.t & VT_BTYPE;
+    dbt = ft & VT_BTYPE;
+    if ((((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) ||
+         (sbt == VT_INT && dbt == VT_SHORT))
+	&& !(vtop->type.t & VT_BITFIELD)) {
+        /* optimize char/short casts */
+        delayed_cast = VT_MUSTCAST;
+        vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT)));
+        /* XXX: factorize */
+        if (ft & VT_CONSTANT)
+            tcc_warning("assignment of read-only location");
+    } else {
+        delayed_cast = 0;
+        if (!(ft & VT_BITFIELD))
+            gen_assign_cast(&vtop[-1].type);
+    }
+
+    if (sbt == VT_STRUCT) {
+        /* if structure, only generate pointer */
+        /* structure assignment : generate memcpy */
+        /* XXX: optimize if small size */
+        if (!nocode_wanted) {
+            size = type_size(&vtop->type, &align);
+
+            /* destination */
+            vswap();
+            vtop->type.t = VT_PTR;
+            gaddrof();
+
+            /* address of memcpy() */
+#ifdef TCC_ARM_EABI
+            if(!(align & 7))
+                vpush_global_sym(&func_old_type, TOK_memcpy8);
+            else if(!(align & 3))
+                vpush_global_sym(&func_old_type, TOK_memcpy4);
+            else
+#endif
+            vpush_global_sym(&func_old_type, TOK_memcpy);
+
+            vswap();
+            /* source */
+            vpushv(vtop - 2);
+            vtop->type.t = VT_PTR;
+            gaddrof();
+            /* type size */
+            vpushi(size);
+            gfunc_call(3);
+        } else {
+            vswap();
+            vpop();
+        }
+        /* leave source on stack */
+    } else if (ft & VT_BITFIELD) {
+        /* bitfield store handling */
+        bit_pos = (ft >> VT_STRUCT_SHIFT) & 0x3f;
+        bit_size = (ft >> (VT_STRUCT_SHIFT + 6)) & 0x3f;
+        /* remove bit field info to avoid loops */
+        vtop[-1].type.t = ft & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT));
+
+        /* duplicate source into other register */
+        gv_dup();
+        vswap();
+        vrott(3);
+
+        if((ft & VT_BTYPE) == VT_BOOL) {
+            gen_cast(&vtop[-1].type);
+            vtop[-1].type.t = (vtop[-1].type.t & ~VT_BTYPE) | (VT_BYTE | VT_UNSIGNED);
+        }
+
+        /* duplicate destination */
+        vdup();
+        vtop[-1] = vtop[-2];
+
+        /* mask and shift source */
+        if((ft & VT_BTYPE) != VT_BOOL) {
+            if((ft & VT_BTYPE) == VT_LLONG) {
+                vpushll((1ULL << bit_size) - 1ULL);
+            } else {
+                vpushi((1 << bit_size) - 1);
+            }
+            gen_op('&');
+        }
+        vpushi(bit_pos);
+        gen_op(TOK_SHL);
+        /* load destination, mask and or with source */
+        vswap();
+        if((ft & VT_BTYPE) == VT_LLONG) {
+            vpushll(~(((1ULL << bit_size) - 1ULL) << bit_pos));
+        } else {
+            vpushi(~(((1 << bit_size) - 1) << bit_pos));
+        }
+        gen_op('&');
+        gen_op('|');
+        /* store result */
+        vstore();
+
+        /* pop off shifted source from "duplicate source..." above */
+        vpop();
+
+    } else {
+#ifdef CONFIG_TCC_BCHECK
+        /* bound check case */
+        if (vtop[-1].r & VT_MUSTBOUND) {
+            vswap();
+            gbound();
+            vswap();
+        }
+#endif
+        if (!nocode_wanted) {
+            rc = RC_INT;
+            if (is_float(ft)) {
+                rc = RC_FLOAT;
+#ifdef TCC_TARGET_X86_64
+                if ((ft & VT_BTYPE) == VT_LDOUBLE) {
+                    rc = RC_ST0;
+                }
+#endif
+            }
+            r = gv(rc);  /* generate value */
+            /* if lvalue was saved on stack, must read it */
+            if ((vtop[-1].r & VT_VALMASK) == VT_LLOCAL) {
+                SValue sv;
+                t = get_reg(RC_INT);
+#ifdef TCC_TARGET_X86_64
+                sv.type.t = VT_PTR;
+#else
+                sv.type.t = VT_INT;
+#endif
+                sv.r = VT_LOCAL | VT_LVAL;
+                sv.c.ul = vtop[-1].c.ul;
+                load(t, &sv);
+                vtop[-1].r = t | VT_LVAL;
+            }
+            store(r, vtop - 1);
+#ifndef TCC_TARGET_X86_64
+            /* two word case handling : store second register at word + 4 */
+            if ((ft & VT_BTYPE) == VT_LLONG) {
+                vswap();
+                /* convert to int to increment easily */
+                vtop->type.t = VT_INT;
+                gaddrof();
+                vpushi(4);
+                gen_op('+');
+                vtop->r |= VT_LVAL;
+                vswap();
+                /* XXX: it works because r2 is spilled last ! */
+                store(vtop->r2, vtop - 1);
+            }
+#endif
+        }
+        vswap();
+        vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
+        vtop->r |= delayed_cast;
+    }
+}
+
+/* post defines POST/PRE add. c is the token ++ or -- */
+ST_FUNC void inc(int post, int c)
+{
+    test_lvalue();
+    vdup(); /* save lvalue */
+    if (post) {
+        gv_dup(); /* duplicate value */
+        vrotb(3);
+        vrotb(3);
+    }
+    /* add constant */
+    vpushi(c - TOK_MID); 
+    gen_op('+');
+    vstore(); /* store value */
+    if (post)
+        vpop(); /* if post op, return saved value */
+}
+
+/* Parse GNUC __attribute__ extension. Currently, the following
+   extensions are recognized:
+   - aligned(n) : set data/function alignment.
+   - packed : force data alignment to 1
+   - section(x) : generate data/code in this section.
+   - unused : currently ignored, but may be used someday.
+   - regparm(n) : pass function parameters in registers (i386 only)
+ */
+static void parse_attribute(AttributeDef *ad)
+{
+    int t, n;
+    
+    while (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2) {
+    next();
+    skip('(');
+    skip('(');
+    while (tok != ')') {
+        if (tok < TOK_IDENT)
+            expect("attribute name");
+        t = tok;
+        next();
+        switch(t) {
+        case TOK_SECTION1:
+        case TOK_SECTION2:
+            skip('(');
+            if (tok != TOK_STR)
+                expect("section name");
+            ad->section = find_section(tcc_state, (char *)tokc.cstr->data);
+            next();
+            skip(')');
+            break;
+        case TOK_ALIAS1:
+        case TOK_ALIAS2:
+            skip('(');
+            if (tok != TOK_STR)
+                expect("alias(\"target\")");
+            ad->alias_target = /* save string as token, for later */
+              tok_alloc((char*)tokc.cstr->data, tokc.cstr->size-1)->tok;
+            next();
+            skip(')');
+            break;
+        case TOK_ALIGNED1:
+        case TOK_ALIGNED2:
+            if (tok == '(') {
+                next();
+                n = expr_const();
+                if (n <= 0 || (n & (n - 1)) != 0) 
+                    tcc_error("alignment must be a positive power of two");
+                skip(')');
+            } else {
+                n = MAX_ALIGN;
+            }
+            ad->aligned = n;
+            break;
+        case TOK_PACKED1:
+        case TOK_PACKED2:
+            ad->packed = 1;
+            break;
+        case TOK_WEAK1:
+        case TOK_WEAK2:
+            ad->weak = 1;
+            break;
+        case TOK_UNUSED1:
+        case TOK_UNUSED2:
+            /* currently, no need to handle it because tcc does not
+               track unused objects */
+            break;
+        case TOK_NORETURN1:
+        case TOK_NORETURN2:
+            /* currently, no need to handle it because tcc does not
+               track unused objects */
+            break;
+        case TOK_CDECL1:
+        case TOK_CDECL2:
+        case TOK_CDECL3:
+            ad->func_call = FUNC_CDECL;
+            break;
+        case TOK_STDCALL1:
+        case TOK_STDCALL2:
+        case TOK_STDCALL3:
+            ad->func_call = FUNC_STDCALL;
+            break;
+#ifdef TCC_TARGET_I386
+        case TOK_REGPARM1:
+        case TOK_REGPARM2:
+            skip('(');
+            n = expr_const();
+            if (n > 3) 
+                n = 3;
+            else if (n < 0)
+                n = 0;
+            if (n > 0)
+                ad->func_call = FUNC_FASTCALL1 + n - 1;
+            skip(')');
+            break;
+        case TOK_FASTCALL1:
+        case TOK_FASTCALL2:
+        case TOK_FASTCALL3:
+            ad->func_call = FUNC_FASTCALLW;
+            break;            
+#endif
+        case TOK_MODE:
+            skip('(');
+            switch(tok) {
+                case TOK_MODE_DI:
+                    ad->mode = VT_LLONG + 1;
+                    break;
+                case TOK_MODE_HI:
+                    ad->mode = VT_SHORT + 1;
+                    break;
+                case TOK_MODE_SI:
+                    ad->mode = VT_INT + 1;
+                    break;
+                default:
+                    tcc_warning("__mode__(%s) not supported\n", get_tok_str(tok, NULL));
+                    break;
+            }
+            next();
+            skip(')');
+            break;
+        case TOK_DLLEXPORT:
+            ad->func_export = 1;
+            break;
+        case TOK_DLLIMPORT:
+            ad->func_import = 1;
+            break;
+        default:
+            if (tcc_state->warn_unsupported)
+                tcc_warning("'%s' attribute ignored", get_tok_str(t, NULL));
+            /* skip parameters */
+            if (tok == '(') {
+                int parenthesis = 0;
+                do {
+                    if (tok == '(') 
+                        parenthesis++;
+                    else if (tok == ')') 
+                        parenthesis--;
+                    next();
+                } while (parenthesis && tok != -1);
+            }
+            break;
+        }
+        if (tok != ',')
+            break;
+        next();
+    }
+    skip(')');
+    skip(')');
+    }
+}
+
+/* enum/struct/union declaration. u is either VT_ENUM or VT_STRUCT */
+static void struct_decl(CType *type, int u)
+{
+    int a, v, size, align, maxalign, c, offset;
+    int bit_size, bit_pos, bsize, bt, lbit_pos, prevbt;
+    Sym *s, *ss, *ass, **ps;
+    AttributeDef ad;
+    CType type1, btype;
+
+    a = tok; /* save decl type */
+    next();
+    if (tok != '{') {
+        v = tok;
+        next();
+        /* struct already defined ? return it */
+        if (v < TOK_IDENT)
+            expect("struct/union/enum name");
+        s = struct_find(v);
+        if (s) {
+            if (s->type.t != a)
+                tcc_error("invalid type");
+            goto do_decl;
+        }
+    } else {
+        v = anon_sym++;
+    }
+    type1.t = a;
+    /* we put an undefined size for struct/union */
+    s = sym_push(v | SYM_STRUCT, &type1, 0, -1);
+    s->r = 0; /* default alignment is zero as gcc */
+    /* put struct/union/enum name in type */
+ do_decl:
+    type->t = u;
+    type->ref = s;
+    
+    if (tok == '{') {
+        next();
+        if (s->c != -1)
+            tcc_error("struct/union/enum already defined");
+        /* cannot be empty */
+        c = 0;
+        /* non empty enums are not allowed */
+        if (a == TOK_ENUM) {
+            for(;;) {
+                v = tok;
+                if (v < TOK_UIDENT)
+                    expect("identifier");
+                next();
+                if (tok == '=') {
+                    next();
+                    c = expr_const();
+                }
+                /* enum symbols have static storage */
+                ss = sym_push(v, &int_type, VT_CONST, c);
+                ss->type.t |= VT_STATIC;
+                if (tok != ',')
+                    break;
+                next();
+                c++;
+                /* NOTE: we accept a trailing comma */
+                if (tok == '}')
+                    break;
+            }
+            skip('}');
+        } else {
+            maxalign = 1;
+            ps = &s->next;
+            prevbt = VT_INT;
+            bit_pos = 0;
+            offset = 0;
+            while (tok != '}') {
+                parse_btype(&btype, &ad);
+                while (1) {
+                    bit_size = -1;
+                    v = 0;
+                    type1 = btype;
+                    if (tok != ':') {
+                        type_decl(&type1, &ad, &v, TYPE_DIRECT | TYPE_ABSTRACT);
+                        if (v == 0 && (type1.t & VT_BTYPE) != VT_STRUCT)
+                            expect("identifier");
+                        if ((type1.t & VT_BTYPE) == VT_FUNC ||
+                            (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))
+                            tcc_error("invalid type for '%s'", 
+                                  get_tok_str(v, NULL));
+                    }
+                    if (tok == ':') {
+                        next();
+                        bit_size = expr_const();
+                        /* XXX: handle v = 0 case for messages */
+                        if (bit_size < 0)
+                            tcc_error("negative width in bit-field '%s'", 
+                                  get_tok_str(v, NULL));
+                        if (v && bit_size == 0)
+                            tcc_error("zero width for bit-field '%s'", 
+                                  get_tok_str(v, NULL));
+                    }
+                    size = type_size(&type1, &align);
+                    if (ad.aligned) {
+                        if (align < ad.aligned)
+                            align = ad.aligned;
+                    } else if (ad.packed) {
+                        align = 1;
+                    } else if (*tcc_state->pack_stack_ptr) {
+                        if (align > *tcc_state->pack_stack_ptr)
+                            align = *tcc_state->pack_stack_ptr;
+                    }
+                    lbit_pos = 0;
+                    if (bit_size >= 0) {
+                        bt = type1.t & VT_BTYPE;
+                        if (bt != VT_INT && 
+                            bt != VT_BYTE && 
+                            bt != VT_SHORT &&
+                            bt != VT_BOOL &&
+                            bt != VT_ENUM &&
+                            bt != VT_LLONG)
+                            tcc_error("bitfields must have scalar type");
+                        bsize = size * 8;
+                        if (bit_size > bsize) {
+                            tcc_error("width of '%s' exceeds its type",
+                                  get_tok_str(v, NULL));
+                        } else if (bit_size == bsize) {
+                            /* no need for bit fields */
+                            bit_pos = 0;
+                        } else if (bit_size == 0) {
+                            /* XXX: what to do if only padding in a
+                               structure ? */
+                            /* zero size: means to pad */
+                            bit_pos = 0;
+                        } else {
+                            /* we do not have enough room ?
+                               did the type change?
+                               is it a union? */
+                            if ((bit_pos + bit_size) > bsize ||
+                                bt != prevbt || a == TOK_UNION)
+                                bit_pos = 0;
+                            lbit_pos = bit_pos;
+                            /* XXX: handle LSB first */
+                            type1.t |= VT_BITFIELD | 
+                                (bit_pos << VT_STRUCT_SHIFT) |
+                                (bit_size << (VT_STRUCT_SHIFT + 6));
+                            bit_pos += bit_size;
+                        }
+                        prevbt = bt;
+                    } else {
+                        bit_pos = 0;
+                    }
+                    if (v != 0 || (type1.t & VT_BTYPE) == VT_STRUCT) {
+                        /* add new memory data only if starting
+                           bit field */
+                        if (lbit_pos == 0) {
+                            if (a == TOK_STRUCT) {
+                                c = (c + align - 1) & -align;
+                                offset = c;
+                                if (size > 0)
+                                    c += size;
+                            } else {
+                                offset = 0;
+                                if (size > c)
+                                    c = size;
+                            }
+                            if (align > maxalign)
+                                maxalign = align;
+                        }
+#if 0
+                        printf("add field %s offset=%d", 
+                               get_tok_str(v, NULL), offset);
+                        if (type1.t & VT_BITFIELD) {
+                            printf(" pos=%d size=%d", 
+                                   (type1.t >> VT_STRUCT_SHIFT) & 0x3f,
+                                   (type1.t >> (VT_STRUCT_SHIFT + 6)) & 0x3f);
+                        }
+                        printf("\n");
+#endif
+                    }
+                    if (v == 0 && (type1.t & VT_BTYPE) == VT_STRUCT) {
+                        ass = type1.ref;
+                        while ((ass = ass->next) != NULL) {
+                           ss = sym_push(ass->v, &ass->type, 0, offset + ass->c);
+                           *ps = ss;
+                           ps = &ss->next;
+                        }
+                    } else if (v) {
+                        ss = sym_push(v | SYM_FIELD, &type1, 0, offset);
+                        *ps = ss;
+                        ps = &ss->next;
+                    }
+                    if (tok == ';' || tok == TOK_EOF)
+                        break;
+                    skip(',');
+                }
+                skip(';');
+            }
+            skip('}');
+            /* store size and alignment */
+            s->c = (c + maxalign - 1) & -maxalign; 
+            s->r = maxalign;
+        }
+    }
+}
+
+/* return 0 if no type declaration. otherwise, return the basic type
+   and skip it. 
+ */
+static int parse_btype(CType *type, AttributeDef *ad)
+{
+    int t, u, type_found, typespec_found, typedef_found;
+    Sym *s;
+    CType type1;
+
+    memset(ad, 0, sizeof(AttributeDef));
+    type_found = 0;
+    typespec_found = 0;
+    typedef_found = 0;
+    t = 0;
+    while(1) {
+        switch(tok) {
+        case TOK_EXTENSION:
+            /* currently, we really ignore extension */
+            next();
+            continue;
+
+            /* basic types */
+        case TOK_CHAR:
+            u = VT_BYTE;
+        basic_type:
+            next();
+        basic_type1:
+            if ((t & VT_BTYPE) != 0)
+                tcc_error("too many basic types");
+            t |= u;
+            typespec_found = 1;
+            break;
+        case TOK_VOID:
+            u = VT_VOID;
+            goto basic_type;
+        case TOK_SHORT:
+            u = VT_SHORT;
+            goto basic_type;
+        case TOK_INT:
+            next();
+            typespec_found = 1;
+            break;
+        case TOK_LONG:
+            next();
+            if ((t & VT_BTYPE) == VT_DOUBLE) {
+#ifndef TCC_TARGET_PE
+                t = (t & ~VT_BTYPE) | VT_LDOUBLE;
+#endif
+            } else if ((t & VT_BTYPE) == VT_LONG) {
+                t = (t & ~VT_BTYPE) | VT_LLONG;
+            } else {
+                u = VT_LONG;
+                goto basic_type1;
+            }
+            break;
+        case TOK_BOOL:
+            u = VT_BOOL;
+            goto basic_type;
+        case TOK_FLOAT:
+            u = VT_FLOAT;
+            goto basic_type;
+        case TOK_DOUBLE:
+            next();
+            if ((t & VT_BTYPE) == VT_LONG) {
+#ifdef TCC_TARGET_PE
+                t = (t & ~VT_BTYPE) | VT_DOUBLE;
+#else
+                t = (t & ~VT_BTYPE) | VT_LDOUBLE;
+#endif
+            } else {
+                u = VT_DOUBLE;
+                goto basic_type1;
+            }
+            break;
+        case TOK_ENUM:
+            struct_decl(&type1, VT_ENUM);
+        basic_type2:
+            u = type1.t;
+            type->ref = type1.ref;
+            goto basic_type1;
+        case TOK_STRUCT:
+        case TOK_UNION:
+            struct_decl(&type1, VT_STRUCT);
+            goto basic_type2;
+
+            /* type modifiers */
+        case TOK_CONST1:
+        case TOK_CONST2:
+        case TOK_CONST3:
+            t |= VT_CONSTANT;
+            next();
+            break;
+        case TOK_VOLATILE1:
+        case TOK_VOLATILE2:
+        case TOK_VOLATILE3:
+            t |= VT_VOLATILE;
+            next();
+            break;
+        case TOK_SIGNED1:
+        case TOK_SIGNED2:
+        case TOK_SIGNED3:
+            typespec_found = 1;
+            t |= VT_SIGNED;
+            next();
+            break;
+        case TOK_REGISTER:
+        case TOK_AUTO:
+        case TOK_RESTRICT1:
+        case TOK_RESTRICT2:
+        case TOK_RESTRICT3:
+            next();
+            break;
+        case TOK_UNSIGNED:
+            t |= VT_UNSIGNED;
+            next();
+            typespec_found = 1;
+            break;
+
+            /* storage */
+        case TOK_EXTERN:
+            t |= VT_EXTERN;
+            next();
+            break;
+        case TOK_STATIC:
+            t |= VT_STATIC;
+            next();
+            break;
+        case TOK_TYPEDEF:
+            t |= VT_TYPEDEF;
+            next();
+            break;
+        case TOK_INLINE1:
+        case TOK_INLINE2:
+        case TOK_INLINE3:
+            t |= VT_INLINE;
+            next();
+            break;
+
+            /* GNUC attribute */
+        case TOK_ATTRIBUTE1:
+        case TOK_ATTRIBUTE2:
+            parse_attribute(ad);
+            if (ad->mode) {
+                u = ad->mode -1;
+                t = (t & ~VT_BTYPE) | u;
+            }
+            break;
+            /* GNUC typeof */
+        case TOK_TYPEOF1:
+        case TOK_TYPEOF2:
+        case TOK_TYPEOF3:
+            next();
+            parse_expr_type(&type1);
+            /* remove all storage modifiers except typedef */
+            type1.t &= ~(VT_STORAGE&~VT_TYPEDEF);
+            goto basic_type2;
+        default:
+            if (typespec_found || typedef_found)
+                goto the_end;
+            s = sym_find(tok);
+            if (!s || !(s->type.t & VT_TYPEDEF))
+                goto the_end;
+            typedef_found = 1;
+            t |= (s->type.t & ~VT_TYPEDEF);
+            type->ref = s->type.ref;
+            if (s->r) {
+                /* get attributes from typedef */
+                if (0 == ad->aligned)
+                    ad->aligned = FUNC_ALIGN(s->r);
+                if (0 == ad->func_call)
+                    ad->func_call = FUNC_CALL(s->r);
+                ad->packed |= FUNC_PACKED(s->r);
+            }
+            next();
+            typespec_found = 1;
+            break;
+        }
+        type_found = 1;
+    }
+the_end:
+    if ((t & (VT_SIGNED|VT_UNSIGNED)) == (VT_SIGNED|VT_UNSIGNED))
+        tcc_error("signed and unsigned modifier");
+    if (tcc_state->char_is_unsigned) {
+        if ((t & (VT_SIGNED|VT_UNSIGNED|VT_BTYPE)) == VT_BYTE)
+            t |= VT_UNSIGNED;
+    }
+    t &= ~VT_SIGNED;
+
+    /* long is never used as type */
+    if ((t & VT_BTYPE) == VT_LONG)
+#if !defined TCC_TARGET_X86_64 || defined TCC_TARGET_PE
+        t = (t & ~VT_BTYPE) | VT_INT;
+#else
+        t = (t & ~VT_BTYPE) | VT_LLONG;
+#endif
+    type->t = t;
+    return type_found;
+}
+
+/* convert a function parameter type (array to pointer and function to
+   function pointer) */
+static inline void convert_parameter_type(CType *pt)
+{
+    /* remove const and volatile qualifiers (XXX: const could be used
+       to indicate a const function parameter */
+    pt->t &= ~(VT_CONSTANT | VT_VOLATILE);
+    /* array must be transformed to pointer according to ANSI C */
+    pt->t &= ~VT_ARRAY;
+    if ((pt->t & VT_BTYPE) == VT_FUNC) {
+        mk_pointer(pt);
+    }
+}
+
+ST_FUNC void parse_asm_str(CString *astr)
+{
+    skip('(');
+    /* read the string */
+    if (tok != TOK_STR)
+        expect("string constant");
+    cstr_new(astr);
+    while (tok == TOK_STR) {
+        /* XXX: add \0 handling too ? */
+        cstr_cat(astr, tokc.cstr->data);
+        next();
+    }
+    cstr_ccat(astr, '\0');
+}
+
+/* Parse an asm label and return the label
+ * Don't forget to free the CString in the caller! */
+static void asm_label_instr(CString *astr)
+{
+    next();
+    parse_asm_str(astr);
+    skip(')');
+#ifdef ASM_DEBUG
+    printf("asm_alias: \"%s\"\n", (char *)astr->data);
+#endif
+}
+
+static void post_type(CType *type, AttributeDef *ad)
+{
+    int n, l, t1, arg_size, align;
+    Sym **plast, *s, *first;
+    AttributeDef ad1;
+    CType pt;
+
+    if (tok == '(') {
+        /* function declaration */
+        next();
+        l = 0;
+        first = NULL;
+        plast = &first;
+        arg_size = 0;
+        if (tok != ')') {
+            for(;;) {
+                /* read param name and compute offset */
+                if (l != FUNC_OLD) {
+                    if (!parse_btype(&pt, &ad1)) {
+                        if (l) {
+                            tcc_error("invalid type");
+                        } else {
+                            l = FUNC_OLD;
+                            goto old_proto;
+                        }
+                    }
+                    l = FUNC_NEW;
+                    if ((pt.t & VT_BTYPE) == VT_VOID && tok == ')')
+                        break;
+                    type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT);
+                    if ((pt.t & VT_BTYPE) == VT_VOID)
+                        tcc_error("parameter declared as void");
+                    arg_size += (type_size(&pt, &align) + PTR_SIZE - 1) / PTR_SIZE;
+                } else {
+                old_proto:
+                    n = tok;
+                    if (n < TOK_UIDENT)
+                        expect("identifier");
+                    pt.t = VT_INT;
+                    next();
+                }
+                convert_parameter_type(&pt);
+                s = sym_push(n | SYM_FIELD, &pt, 0, 0);
+                *plast = s;
+                plast = &s->next;
+                if (tok == ')')
+                    break;
+                skip(',');
+                if (l == FUNC_NEW && tok == TOK_DOTS) {
+                    l = FUNC_ELLIPSIS;
+                    next();
+                    break;
+                }
+            }
+        }
+        /* if no parameters, then old type prototype */
+        if (l == 0)
+            l = FUNC_OLD;
+        skip(')');
+        /* NOTE: const is ignored in returned type as it has a special
+           meaning in gcc / C++ */
+        type->t &= ~VT_CONSTANT; 
+        /* some ancient pre-K&R C allows a function to return an array
+           and the array brackets to be put after the arguments, such 
+           that "int c()[]" means something like "int[] c()" */
+        if (tok == '[') {
+            next();
+            skip(']'); /* only handle simple "[]" */
+            type->t |= VT_PTR;
+        }
+        /* we push a anonymous symbol which will contain the function prototype */
+        ad->func_args = arg_size;
+        s = sym_push(SYM_FIELD, type, INT_ATTR(ad), l);
+        s->next = first;
+        type->t = VT_FUNC;
+        type->ref = s;
+    } else if (tok == '[') {
+        /* array definition */
+        next();
+        if (tok == TOK_RESTRICT1)
+            next();
+        n = -1;
+        t1 = 0;
+        if (tok != ']') {
+            if (!local_stack || nocode_wanted)
+                 vpushi(expr_const());
+            else gexpr();
+            if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+                n = vtop->c.i;
+                if (n < 0)
+                    tcc_error("invalid array size");
+            } else {
+                if (!is_integer_btype(vtop->type.t & VT_BTYPE))
+                    tcc_error("size of variable length array should be an integer");
+                t1 = VT_VLA;
+            }
+        }
+        skip(']');
+        /* parse next post type */
+        post_type(type, ad);
+        t1 |= type->t & VT_VLA;
+        
+        if (t1 & VT_VLA) {
+            loc -= type_size(&int_type, &align);
+            loc &= -align;
+            n = loc;
+
+            vla_runtime_type_size(type, &align);
+            gen_op('*');
+            vset(&int_type, VT_LOCAL|VT_LVAL, loc);
+            vswap();
+            vstore();
+        }
+        if (n != -1)
+            vpop();
+                
+        /* we push an anonymous symbol which will contain the array
+           element type */
+        s = sym_push(SYM_FIELD, type, 0, n);
+        type->t = (t1 ? VT_VLA : VT_ARRAY) | VT_PTR;
+        type->ref = s;
+    }
+}
+
+/* Parse a type declaration (except basic type), and return the type
+   in 'type'. 'td' is a bitmask indicating which kind of type decl is
+   expected. 'type' should contain the basic type. 'ad' is the
+   attribute definition of the basic type. It can be modified by
+   type_decl(). 
+ */
+static void type_decl(CType *type, AttributeDef *ad, int *v, int td)
+{
+    Sym *s;
+    CType type1, *type2;
+    int qualifiers, storage;
+
+    while (tok == '*') {
+        qualifiers = 0;
+    redo:
+        next();
+        switch(tok) {
+        case TOK_CONST1:
+        case TOK_CONST2:
+        case TOK_CONST3:
+            qualifiers |= VT_CONSTANT;
+            goto redo;
+        case TOK_VOLATILE1:
+        case TOK_VOLATILE2:
+        case TOK_VOLATILE3:
+            qualifiers |= VT_VOLATILE;
+            goto redo;
+        case TOK_RESTRICT1:
+        case TOK_RESTRICT2:
+        case TOK_RESTRICT3:
+            goto redo;
+        }
+        mk_pointer(type);
+        type->t |= qualifiers;
+    }
+    
+    /* XXX: clarify attribute handling */
+    if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
+        parse_attribute(ad);
+
+    /* recursive type */
+    /* XXX: incorrect if abstract type for functions (e.g. 'int ()') */
+    type1.t = 0; /* XXX: same as int */
+    if (tok == '(') {
+        next();
+        /* XXX: this is not correct to modify 'ad' at this point, but
+           the syntax is not clear */
+        if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
+            parse_attribute(ad);
+        type_decl(&type1, ad, v, td);
+        skip(')');
+    } else {
+        /* type identifier */
+        if (tok >= TOK_IDENT && (td & TYPE_DIRECT)) {
+            *v = tok;
+            next();
+        } else {
+            if (!(td & TYPE_ABSTRACT))
+                expect("identifier");
+            *v = 0;
+        }
+    }
+    storage = type->t & VT_STORAGE;
+    type->t &= ~VT_STORAGE;
+    if (storage & VT_STATIC) {
+        int saved_nocode_wanted = nocode_wanted;
+        nocode_wanted = 1;
+        post_type(type, ad);
+        nocode_wanted = saved_nocode_wanted;
+    } else
+        post_type(type, ad);
+    type->t |= storage;
+    if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
+        parse_attribute(ad);
+    
+    if (!type1.t)
+        return;
+    /* append type at the end of type1 */
+    type2 = &type1;
+    for(;;) {
+        s = type2->ref;
+        type2 = &s->type;
+        if (!type2->t) {
+            *type2 = *type;
+            break;
+        }
+    }
+    *type = type1;
+}
+
+/* compute the lvalue VT_LVAL_xxx needed to match type t. */
+ST_FUNC int lvalue_type(int t)
+{
+    int bt, r;
+    r = VT_LVAL;
+    bt = t & VT_BTYPE;
+    if (bt == VT_BYTE || bt == VT_BOOL)
+        r |= VT_LVAL_BYTE;
+    else if (bt == VT_SHORT)
+        r |= VT_LVAL_SHORT;
+    else
+        return r;
+    if (t & VT_UNSIGNED)
+        r |= VT_LVAL_UNSIGNED;
+    return r;
+}
+
+/* indirection with full error checking and bound check */
+ST_FUNC void indir(void)
+{
+    if ((vtop->type.t & VT_BTYPE) != VT_PTR) {
+        if ((vtop->type.t & VT_BTYPE) == VT_FUNC)
+            return;
+        expect("pointer");
+    }
+    if ((vtop->r & VT_LVAL) && !nocode_wanted)
+        gv(RC_INT);
+    vtop->type = *pointed_type(&vtop->type);
+    /* Arrays and functions are never lvalues */
+    if (!(vtop->type.t & VT_ARRAY) && !(vtop->type.t & VT_VLA)
+        && (vtop->type.t & VT_BTYPE) != VT_FUNC) {
+        vtop->r |= lvalue_type(vtop->type.t);
+        /* if bound checking, the referenced pointer must be checked */
+#ifdef CONFIG_TCC_BCHECK
+        if (tcc_state->do_bounds_check)
+            vtop->r |= VT_MUSTBOUND;
+#endif
+    }
+}
+
+/* pass a parameter to a function and do type checking and casting */
+static void gfunc_param_typed(Sym *func, Sym *arg)
+{
+    int func_type;
+    CType type;
+
+    func_type = func->c;
+    if (func_type == FUNC_OLD ||
+        (func_type == FUNC_ELLIPSIS && arg == NULL)) {
+        /* default casting : only need to convert float to double */
+        if ((vtop->type.t & VT_BTYPE) == VT_FLOAT) {
+            type.t = VT_DOUBLE;
+            gen_cast(&type);
+        }
+    } else if (arg == NULL) {
+        tcc_error("too many arguments to function");
+    } else {
+        type = arg->type;
+        type.t &= ~VT_CONSTANT; /* need to do that to avoid false warning */
+        gen_assign_cast(&type);
+    }
+}
+
+/* parse an expression of the form '(type)' or '(expr)' and return its
+   type */
+static void parse_expr_type(CType *type)
+{
+    int n;
+    AttributeDef ad;
+
+    skip('(');
+    if (parse_btype(type, &ad)) {
+        type_decl(type, &ad, &n, TYPE_ABSTRACT);
+    } else {
+        expr_type(type);
+    }
+    skip(')');
+}
+
+static void parse_type(CType *type)
+{
+    AttributeDef ad;
+    int n;
+
+    if (!parse_btype(type, &ad)) {
+        expect("type");
+    }
+    type_decl(type, &ad, &n, TYPE_ABSTRACT);
+}
+
+static void vpush_tokc(int t)
+{
+    CType type;
+    type.t = t;
+    type.ref = 0;
+    vsetc(&type, VT_CONST, &tokc);
+}
+
+ST_FUNC void unary(void)
+{
+    int n, t, align, size, r, sizeof_caller;
+    CType type;
+    Sym *s;
+    AttributeDef ad;
+    static int in_sizeof = 0;
+
+    sizeof_caller = in_sizeof;
+    in_sizeof = 0;
+    /* XXX: GCC 2.95.3 does not generate a table although it should be
+       better here */
+ tok_next:
+    switch(tok) {
+    case TOK_EXTENSION:
+        next();
+        goto tok_next;
+    case TOK_CINT:
+    case TOK_CCHAR: 
+    case TOK_LCHAR:
+        vpushi(tokc.i);
+        next();
+        break;
+    case TOK_CUINT:
+        vpush_tokc(VT_INT | VT_UNSIGNED);
+        next();
+        break;
+    case TOK_CLLONG:
+        vpush_tokc(VT_LLONG);
+        next();
+        break;
+    case TOK_CULLONG:
+        vpush_tokc(VT_LLONG | VT_UNSIGNED);
+        next();
+        break;
+    case TOK_CFLOAT:
+        vpush_tokc(VT_FLOAT);
+        next();
+        break;
+    case TOK_CDOUBLE:
+        vpush_tokc(VT_DOUBLE);
+        next();
+        break;
+    case TOK_CLDOUBLE:
+        vpush_tokc(VT_LDOUBLE);
+        next();
+        break;
+    case TOK___FUNCTION__:
+        if (!gnu_ext)
+            goto tok_identifier;
+        /* fall thru */
+    case TOK___FUNC__:
+        {
+            void *ptr;
+            int len;
+            /* special function name identifier */
+            len = strlen(funcname) + 1;
+            /* generate char[len] type */
+            type.t = VT_BYTE;
+            mk_pointer(&type);
+            type.t |= VT_ARRAY;
+            type.ref->c = len;
+            vpush_ref(&type, data_section, data_section->data_offset, len);
+            ptr = section_ptr_add(data_section, len);
+            memcpy(ptr, funcname, len);
+            next();
+        }
+        break;
+    case TOK_LSTR:
+#ifdef TCC_TARGET_PE
+        t = VT_SHORT | VT_UNSIGNED;
+#else
+        t = VT_INT;
+#endif
+        goto str_init;
+    case TOK_STR:
+        /* string parsing */
+        t = VT_BYTE;
+    str_init:
+        if (tcc_state->warn_write_strings)
+            t |= VT_CONSTANT;
+        type.t = t;
+        mk_pointer(&type);
+        type.t |= VT_ARRAY;
+        memset(&ad, 0, sizeof(AttributeDef));
+        decl_initializer_alloc(&type, &ad, VT_CONST, 2, 0, NULL, 0);
+        break;
+    case '(':
+        next();
+        /* cast ? */
+        if (parse_btype(&type, &ad)) {
+            type_decl(&type, &ad, &n, TYPE_ABSTRACT);
+            skip(')');
+            /* check ISOC99 compound literal */
+            if (tok == '{') {
+                    /* data is allocated locally by default */
+                if (global_expr)
+                    r = VT_CONST;
+                else
+                    r = VT_LOCAL;
+                /* all except arrays are lvalues */
+                if (!(type.t & VT_ARRAY))
+                    r |= lvalue_type(type.t);
+                memset(&ad, 0, sizeof(AttributeDef));
+                decl_initializer_alloc(&type, &ad, r, 1, 0, NULL, 0);
+            } else {
+                if (sizeof_caller) {
+                    vpush(&type);
+                    return;
+                }
+                unary();
+                gen_cast(&type);
+            }
+        } else if (tok == '{') {
+            /* save all registers */
+            save_regs(0); 
+            /* statement expression : we do not accept break/continue
+               inside as GCC does */
+            block(NULL, NULL, NULL, NULL, 0, 1);
+            skip(')');
+        } else {
+            gexpr();
+            skip(')');
+        }
+        break;
+    case '*':
+        next();
+        unary();
+        indir();
+        break;
+    case '&':
+        next();
+        unary();
+        /* functions names must be treated as function pointers,
+           except for unary '&' and sizeof. Since we consider that
+           functions are not lvalues, we only have to handle it
+           there and in function calls. */
+        /* arrays can also be used although they are not lvalues */
+        if ((vtop->type.t & VT_BTYPE) != VT_FUNC &&
+            !(vtop->type.t & VT_ARRAY) && !(vtop->type.t & VT_LLOCAL))
+            test_lvalue();
+        mk_pointer(&vtop->type);
+        gaddrof();
+        break;
+    case '!':
+        next();
+        unary();
+        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+            CType boolean;
+            boolean.t = VT_BOOL;
+            gen_cast(&boolean);
+            vtop->c.i = !vtop->c.i;
+        } else if ((vtop->r & VT_VALMASK) == VT_CMP)
+            vtop->c.i = vtop->c.i ^ 1;
+        else {
+            save_regs(1);
+            vseti(VT_JMP, gtst(1, 0));
+        }
+        break;
+    case '~':
+        next();
+        unary();
+        vpushi(-1);
+        gen_op('^');
+        break;
+    case '+':
+        next();
+        /* in order to force cast, we add zero */
+        unary();
+        if ((vtop->type.t & VT_BTYPE) == VT_PTR)
+            tcc_error("pointer not accepted for unary plus");
+        vpushi(0);
+        gen_op('+');
+        break;
+    case TOK_SIZEOF:
+    case TOK_ALIGNOF1:
+    case TOK_ALIGNOF2:
+        t = tok;
+        next();
+        in_sizeof++;
+        unary_type(&type); // Perform a in_sizeof = 0;
+        size = type_size(&type, &align);
+        if (t == TOK_SIZEOF) {
+            if (!(type.t & VT_VLA)) {
+                if (size < 0)
+                    tcc_error("sizeof applied to an incomplete type");
+                vpushs(size);
+            } else {
+                vla_runtime_type_size(&type, &align);
+            }
+        } else {
+            vpushs(align);
+        }
+        vtop->type.t |= VT_UNSIGNED;
+        break;
+
+    case TOK_builtin_types_compatible_p:
+        {
+            CType type1, type2;
+            next();
+            skip('(');
+            parse_type(&type1);
+            skip(',');
+            parse_type(&type2);
+            skip(')');
+            type1.t &= ~(VT_CONSTANT | VT_VOLATILE);
+            type2.t &= ~(VT_CONSTANT | VT_VOLATILE);
+            vpushi(is_compatible_types(&type1, &type2));
+        }
+        break;
+    case TOK_builtin_constant_p:
+        {
+            int saved_nocode_wanted, res;
+            next();
+            skip('(');
+            saved_nocode_wanted = nocode_wanted;
+            nocode_wanted = 1;
+            gexpr();
+            res = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+            vpop();
+            nocode_wanted = saved_nocode_wanted;
+            skip(')');
+            vpushi(res);
+        }
+        break;
+    case TOK_builtin_frame_address:
+        {
+            int level;
+            CType type;
+            next();
+            skip('(');
+            if (tok != TOK_CINT || tokc.i < 0) {
+                tcc_error("__builtin_frame_address only takes positive integers");
+            }
+            level = tokc.i;
+            next();
+            skip(')');
+            type.t = VT_VOID;
+            mk_pointer(&type);
+            vset(&type, VT_LOCAL, 0);       /* local frame */
+            while (level--) {
+                mk_pointer(&vtop->type);
+                indir();                    /* -> parent frame */
+            }
+        }
+        break;
+#ifdef TCC_TARGET_X86_64
+    case TOK_builtin_va_arg_types:
+        {
+            /* This definition must be synced with stdarg.h */
+            enum __va_arg_type {
+                __va_gen_reg, __va_float_reg, __va_stack
+            };
+            CType type;
+            int bt;
+            next();
+            skip('(');
+            parse_type(&type);
+            skip(')');
+            bt = type.t & VT_BTYPE;
+            if (bt == VT_STRUCT || bt == VT_LDOUBLE) {
+                vpushi(__va_stack);
+            } else if (bt == VT_FLOAT || bt == VT_DOUBLE) {
+                vpushi(__va_float_reg);
+            } else {
+                vpushi(__va_gen_reg);
+            }
+        }
+        break;
+#endif
+    case TOK_INC:
+    case TOK_DEC:
+        t = tok;
+        next();
+        unary();
+        inc(0, t);
+        break;
+    case '-':
+        next();
+        vpushi(0);
+        unary();
+        gen_op('-');
+        break;
+    case TOK_LAND:
+        if (!gnu_ext)
+            goto tok_identifier;
+        next();
+        /* allow to take the address of a label */
+        if (tok < TOK_UIDENT)
+            expect("label identifier");
+        s = label_find(tok);
+        if (!s) {
+            s = label_push(&global_label_stack, tok, LABEL_FORWARD);
+        } else {
+            if (s->r == LABEL_DECLARED)
+                s->r = LABEL_FORWARD;
+        }
+        if (!s->type.t) {
+            s->type.t = VT_VOID;
+            mk_pointer(&s->type);
+            s->type.t |= VT_STATIC;
+        }
+        vset(&s->type, VT_CONST | VT_SYM, 0);
+        vtop->sym = s;
+        next();
+        break;
+    
+    // special qnan , snan and infinity values
+    case TOK___NAN__:
+        vpush64(VT_DOUBLE, 0x7ff8000000000000ULL);
+        next();
+        break;
+    case TOK___SNAN__:
+        vpush64(VT_DOUBLE, 0x7ff0000000000001ULL);
+        next();
+        break;
+    case TOK___INF__:
+        vpush64(VT_DOUBLE, 0x7ff0000000000000ULL);
+        next();
+        break;
+
+    default:
+    tok_identifier:
+        t = tok;
+        next();
+        if (t < TOK_UIDENT)
+            expect("identifier");
+        s = sym_find(t);
+        if (!s) {
+            if (tok != '(')
+                tcc_error("'%s' undeclared", get_tok_str(t, NULL));
+            /* for simple function calls, we tolerate undeclared
+               external reference to int() function */
+            if (tcc_state->warn_implicit_function_declaration)
+                tcc_warning("implicit declaration of function '%s'",
+                        get_tok_str(t, NULL));
+            s = external_global_sym(t, &func_old_type, 0); 
+        }
+        if ((s->type.t & (VT_STATIC | VT_INLINE | VT_BTYPE)) ==
+            (VT_STATIC | VT_INLINE | VT_FUNC)) {
+            /* if referencing an inline function, then we generate a
+               symbol to it if not already done. It will have the
+               effect to generate code for it at the end of the
+               compilation unit. Inline function as always
+               generated in the text section. */
+            if (!s->c)
+                put_extern_sym(s, text_section, 0, 0);
+            r = VT_SYM | VT_CONST;
+        } else {
+            r = s->r;
+        }
+        vset(&s->type, r, s->c);
+        /* if forward reference, we must point to s */
+        if (vtop->r & VT_SYM) {
+            vtop->sym = s;
+            vtop->c.ul = 0;
+        }
+        break;
+    }
+    
+    /* post operations */
+    while (1) {
+        if (tok == TOK_INC || tok == TOK_DEC) {
+            inc(1, tok);
+            next();
+        } else if (tok == '.' || tok == TOK_ARROW) {
+            int qualifiers;
+            /* field */ 
+            if (tok == TOK_ARROW) 
+                indir();
+            qualifiers = vtop->type.t & (VT_CONSTANT | VT_VOLATILE);
+            test_lvalue();
+            gaddrof();
+            next();
+            /* expect pointer on structure */
+            if ((vtop->type.t & VT_BTYPE) != VT_STRUCT)
+                expect("struct or union");
+            s = vtop->type.ref;
+            /* find field */
+            tok |= SYM_FIELD;
+            while ((s = s->next) != NULL) {
+                if (s->v == tok)
+                    break;
+            }
+            if (!s)
+                tcc_error("field not found: %s",  get_tok_str(tok & ~SYM_FIELD, NULL));
+            /* add field offset to pointer */
+            vtop->type = char_pointer_type; /* change type to 'char *' */
+            vpushi(s->c);
+            gen_op('+');
+            /* change type to field type, and set to lvalue */
+            vtop->type = s->type;
+            vtop->type.t |= qualifiers;
+            /* an array is never an lvalue */
+            if (!(vtop->type.t & VT_ARRAY)) {
+                vtop->r |= lvalue_type(vtop->type.t);
+#ifdef CONFIG_TCC_BCHECK
+                /* if bound checking, the referenced pointer must be checked */
+                if (tcc_state->do_bounds_check)
+                    vtop->r |= VT_MUSTBOUND;
+#endif
+            }
+            next();
+        } else if (tok == '[') {
+            next();
+            gexpr();
+            gen_op('+');
+            indir();
+            skip(']');
+        } else if (tok == '(') {
+            SValue ret;
+            Sym *sa;
+            int nb_args;
+
+            /* function call  */
+            if ((vtop->type.t & VT_BTYPE) != VT_FUNC) {
+                /* pointer test (no array accepted) */
+                if ((vtop->type.t & (VT_BTYPE | VT_ARRAY)) == VT_PTR) {
+                    vtop->type = *pointed_type(&vtop->type);
+                    if ((vtop->type.t & VT_BTYPE) != VT_FUNC)
+                        goto error_func;
+                } else {
+                error_func:
+                    expect("function pointer");
+                }
+            } else {
+                vtop->r &= ~VT_LVAL; /* no lvalue */
+            }
+            /* get return type */
+            s = vtop->type.ref;
+            next();
+            sa = s->next; /* first parameter */
+            nb_args = 0;
+            ret.r2 = VT_CONST;
+            /* compute first implicit argument if a structure is returned */
+            if ((s->type.t & VT_BTYPE) == VT_STRUCT) {
+                /* get some space for the returned structure */
+                size = type_size(&s->type, &align);
+                loc = (loc - size) & -align;
+                ret.type = s->type;
+                ret.r = VT_LOCAL | VT_LVAL;
+                /* pass it as 'int' to avoid structure arg passing
+                   problems */
+                vseti(VT_LOCAL, loc);
+                ret.c = vtop->c;
+                nb_args++;
+            } else {
+                ret.type = s->type; 
+                /* return in register */
+                if (is_float(ret.type.t)) {
+                    ret.r = reg_fret(ret.type.t);
+                } else {
+                    if ((ret.type.t & VT_BTYPE) == VT_LLONG)
+                        ret.r2 = REG_LRET;
+                    ret.r = REG_IRET;
+                }
+                ret.c.i = 0;
+            }
+            if (tok != ')') {
+                for(;;) {
+                    expr_eq();
+                    gfunc_param_typed(s, sa);
+                    nb_args++;
+                    if (sa)
+                        sa = sa->next;
+                    if (tok == ')')
+                        break;
+                    skip(',');
+                }
+            }
+            if (sa)
+                tcc_error("too few arguments to function");
+            skip(')');
+            if (!nocode_wanted) {
+                gfunc_call(nb_args);
+            } else {
+                vtop -= (nb_args + 1);
+            }
+            /* return value */
+            vsetc(&ret.type, ret.r, &ret.c);
+            vtop->r2 = ret.r2;
+        } else {
+            break;
+        }
+    }
+}
+
+ST_FUNC void expr_prod(void)
+{
+    int t;
+
+    unary();
+    while (tok == '*' || tok == '/' || tok == '%') {
+        t = tok;
+        next();
+        unary();
+        gen_op(t);
+    }
+}
+
+ST_FUNC void expr_sum(void)
+{
+    int t;
+
+    expr_prod();
+    while (tok == '+' || tok == '-') {
+        t = tok;
+        next();
+        expr_prod();
+        gen_op(t);
+    }
+}
+
+static void expr_shift(void)
+{
+    int t;
+
+    expr_sum();
+    while (tok == TOK_SHL || tok == TOK_SAR) {
+        t = tok;
+        next();
+        expr_sum();
+        gen_op(t);
+    }
+}
+
+static void expr_cmp(void)
+{
+    int t;
+
+    expr_shift();
+    while ((tok >= TOK_ULE && tok <= TOK_GT) ||
+           tok == TOK_ULT || tok == TOK_UGE) {
+        t = tok;
+        next();
+        expr_shift();
+        gen_op(t);
+    }
+}
+
+static void expr_cmpeq(void)
+{
+    int t;
+
+    expr_cmp();
+    while (tok == TOK_EQ || tok == TOK_NE) {
+        t = tok;
+        next();
+        expr_cmp();
+        gen_op(t);
+    }
+}
+
+static void expr_and(void)
+{
+    expr_cmpeq();
+    while (tok == '&') {
+        next();
+        expr_cmpeq();
+        gen_op('&');
+    }
+}
+
+static void expr_xor(void)
+{
+    expr_and();
+    while (tok == '^') {
+        next();
+        expr_and();
+        gen_op('^');
+    }
+}
+
+static void expr_or(void)
+{
+    expr_xor();
+    while (tok == '|') {
+        next();
+        expr_xor();
+        gen_op('|');
+    }
+}
+
+/* XXX: fix this mess */
+static void expr_land_const(void)
+{
+    expr_or();
+    while (tok == TOK_LAND) {
+        next();
+        expr_or();
+        gen_op(TOK_LAND);
+    }
+}
+
+/* XXX: fix this mess */
+static void expr_lor_const(void)
+{
+    expr_land_const();
+    while (tok == TOK_LOR) {
+        next();
+        expr_land_const();
+        gen_op(TOK_LOR);
+    }
+}
+
+/* only used if non constant */
+static void expr_land(void)
+{
+    int t;
+
+    expr_or();
+    if (tok == TOK_LAND) {
+        t = 0;
+        save_regs(1);
+        for(;;) {
+            t = gtst(1, t);
+            if (tok != TOK_LAND) {
+                vseti(VT_JMPI, t);
+                break;
+            }
+            next();
+            expr_or();
+        }
+    }
+}
+
+static void expr_lor(void)
+{
+    int t;
+
+    expr_land();
+    if (tok == TOK_LOR) {
+        t = 0;
+        save_regs(1);
+        for(;;) {
+            t = gtst(0, t);
+            if (tok != TOK_LOR) {
+                vseti(VT_JMP, t);
+                break;
+            }
+            next();
+            expr_land();
+        }
+    }
+}
+
+/* XXX: better constant handling */
+static void expr_cond(void)
+{
+    int tt, u, r1, r2, rc, t1, t2, bt1, bt2;
+    SValue sv;
+    CType type, type1, type2;
+
+    if (const_wanted) {
+        expr_lor_const();
+        if (tok == '?') {
+            CType boolean;
+            int c;
+            boolean.t = VT_BOOL;
+            vdup();
+            gen_cast(&boolean);
+            c = vtop->c.i;
+            vpop();
+            next();
+            if (tok != ':' || !gnu_ext) {
+                vpop();
+                gexpr();
+            }
+            if (!c)
+                vpop();
+            skip(':');
+            expr_cond();
+            if (c)
+                vpop();
+        }
+    } else {
+        expr_lor();
+        if (tok == '?') {
+            next();
+            if (vtop != vstack) {
+                /* needed to avoid having different registers saved in
+                   each branch */
+                if (is_float(vtop->type.t)) {
+                    rc = RC_FLOAT;
+#ifdef TCC_TARGET_X86_64
+                    if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+                        rc = RC_ST0;
+                    }
+#endif
+                }
+                else
+                    rc = RC_INT;
+                    gv(rc);
+                    save_regs(1);
+            }
+            if (tok == ':' && gnu_ext) {
+                gv_dup();
+                tt = gtst(1, 0);
+            } else {
+                tt = gtst(1, 0);
+                gexpr();
+            }
+            type1 = vtop->type;
+            sv = *vtop; /* save value to handle it later */
+            vtop--; /* no vpop so that FP stack is not flushed */
+            skip(':');
+            u = gjmp(0);
+            gsym(tt);
+            expr_cond();
+            type2 = vtop->type;
+
+            t1 = type1.t;
+            bt1 = t1 & VT_BTYPE;
+            t2 = type2.t;
+            bt2 = t2 & VT_BTYPE;
+            /* cast operands to correct type according to ISOC rules */
+            if (is_float(bt1) || is_float(bt2)) {
+                if (bt1 == VT_LDOUBLE || bt2 == VT_LDOUBLE) {
+                    type.t = VT_LDOUBLE;
+                } else if (bt1 == VT_DOUBLE || bt2 == VT_DOUBLE) {
+                    type.t = VT_DOUBLE;
+                } else {
+                    type.t = VT_FLOAT;
+                }
+            } else if (bt1 == VT_LLONG || bt2 == VT_LLONG) {
+                /* cast to biggest op */
+                type.t = VT_LLONG;
+                /* convert to unsigned if it does not fit in a long long */
+                if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (VT_LLONG | VT_UNSIGNED) ||
+                    (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_LLONG | VT_UNSIGNED))
+                    type.t |= VT_UNSIGNED;
+            } else if (bt1 == VT_PTR || bt2 == VT_PTR) {
+		/* If one is a null ptr constant the result type
+		   is the other.  */
+		if (is_null_pointer (vtop))
+		  type = type1;
+		else if (is_null_pointer (&sv))
+		  type = type2;
+                /* XXX: test pointer compatibility, C99 has more elaborate
+		   rules here.  */
+		else
+		  type = type1;
+            } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) {
+                /* XXX: test function pointer compatibility */
+                type = bt1 == VT_FUNC ? type1 : type2;
+            } else if (bt1 == VT_STRUCT || bt2 == VT_STRUCT) {
+                /* XXX: test structure compatibility */
+                type = bt1 == VT_STRUCT ? type1 : type2;
+            } else if (bt1 == VT_VOID || bt2 == VT_VOID) {
+                /* NOTE: as an extension, we accept void on only one side */
+                type.t = VT_VOID;
+            } else {
+                /* integer operations */
+                type.t = VT_INT;
+                /* convert to unsigned if it does not fit in an integer */
+                if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED) ||
+                    (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED))
+                    type.t |= VT_UNSIGNED;
+            }
+                
+            /* now we convert second operand */
+            gen_cast(&type);
+            if (VT_STRUCT == (vtop->type.t & VT_BTYPE))
+                gaddrof();
+            rc = RC_INT;
+            if (is_float(type.t)) {
+                rc = RC_FLOAT;
+#ifdef TCC_TARGET_X86_64
+                if ((type.t & VT_BTYPE) == VT_LDOUBLE) {
+                    rc = RC_ST0;
+                }
+#endif
+            } else if ((type.t & VT_BTYPE) == VT_LLONG) {
+                /* for long longs, we use fixed registers to avoid having
+                   to handle a complicated move */
+                rc = RC_IRET; 
+            }
+            
+            r2 = gv(rc);
+            /* this is horrible, but we must also convert first
+               operand */
+            tt = gjmp(0);
+            gsym(u);
+            /* put again first value and cast it */
+            *vtop = sv;
+            gen_cast(&type);
+            if (VT_STRUCT == (vtop->type.t & VT_BTYPE))
+                gaddrof();
+            r1 = gv(rc);
+            move_reg(r2, r1);
+            vtop->r = r2;
+            gsym(tt);
+        }
+    }
+}
+
+static void expr_eq(void)
+{
+    int t;
+    
+    expr_cond();
+    if (tok == '=' ||
+        (tok >= TOK_A_MOD && tok <= TOK_A_DIV) ||
+        tok == TOK_A_XOR || tok == TOK_A_OR ||
+        tok == TOK_A_SHL || tok == TOK_A_SAR) {
+        test_lvalue();
+        t = tok;
+        next();
+        if (t == '=') {
+            expr_eq();
+        } else {
+            vdup();
+            expr_eq();
+            gen_op(t & 0x7f);
+        }
+        vstore();
+    }
+}
+
+ST_FUNC void gexpr(void)
+{
+    while (1) {
+        expr_eq();
+        if (tok != ',')
+            break;
+        vpop();
+        next();
+    }
+}
+
+/* parse an expression and return its type without any side effect. */
+static void expr_type(CType *type)
+{
+    int saved_nocode_wanted;
+
+    saved_nocode_wanted = nocode_wanted;
+    nocode_wanted = 1;
+    gexpr();
+    *type = vtop->type;
+    vpop();
+    nocode_wanted = saved_nocode_wanted;
+}
+
+/* parse a unary expression and return its type without any side
+   effect. */
+static void unary_type(CType *type)
+{
+    int a;
+
+    a = nocode_wanted;
+    nocode_wanted = 1;
+    unary();
+    *type = vtop->type;
+    vpop();
+    nocode_wanted = a;
+}
+
+/* parse a constant expression and return value in vtop.  */
+static void expr_const1(void)
+{
+    int a;
+    a = const_wanted;
+    const_wanted = 1;
+    expr_cond();
+    const_wanted = a;
+}
+
+/* parse an integer constant and return its value. */
+ST_FUNC int expr_const(void)
+{
+    int c;
+    expr_const1();
+    if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
+        expect("constant expression");
+    c = vtop->c.i;
+    vpop();
+    return c;
+}
+
+/* return the label token if current token is a label, otherwise
+   return zero */
+static int is_label(void)
+{
+    int last_tok;
+
+    /* fast test first */
+    if (tok < TOK_UIDENT)
+        return 0;
+    /* no need to save tokc because tok is an identifier */
+    last_tok = tok;
+    next();
+    if (tok == ':') {
+        next();
+        return last_tok;
+    } else {
+        unget_tok(last_tok);
+        return 0;
+    }
+}
+
+static void label_or_decl(int l)
+{
+    int last_tok;
+
+    /* fast test first */
+    if (tok >= TOK_UIDENT)
+      {
+	/* no need to save tokc because tok is an identifier */
+	last_tok = tok;
+	next();
+	if (tok == ':') {
+	    unget_tok(last_tok);
+	    return;
+	}
+	unget_tok(last_tok);
+      }
+    decl(l);
+}
+
+static void block(int *bsym, int *csym, int *case_sym, int *def_sym, 
+                  int case_reg, int is_expr)
+{
+    int a, b, c, d;
+    Sym *s, *frame_bottom;
+
+    /* generate line number info */
+    if (tcc_state->do_debug &&
+        (last_line_num != file->line_num || last_ind != ind)) {
+        put_stabn(N_SLINE, 0, file->line_num, ind - func_ind);
+        last_ind = ind;
+        last_line_num = file->line_num;
+    }
+
+    if (is_expr) {
+        /* default return value is (void) */
+        vpushi(0);
+        vtop->type.t = VT_VOID;
+    }
+
+    if (tok == TOK_IF) {
+        /* if test */
+        next();
+        skip('(');
+        gexpr();
+        skip(')');
+        a = gtst(1, 0);
+        block(bsym, csym, case_sym, def_sym, case_reg, 0);
+        c = tok;
+        if (c == TOK_ELSE) {
+            next();
+            d = gjmp(0);
+            gsym(a);
+            block(bsym, csym, case_sym, def_sym, case_reg, 0);
+            gsym(d); /* patch else jmp */
+        } else
+            gsym(a);
+    } else if (tok == TOK_WHILE) {
+        next();
+        d = ind;
+        skip('(');
+        gexpr();
+        skip(')');
+        a = gtst(1, 0);
+        b = 0;
+        block(&a, &b, case_sym, def_sym, case_reg, 0);
+        gjmp_addr(d);
+        gsym(a);
+        gsym_addr(b, d);
+    } else if (tok == '{') {
+        Sym *llabel;
+        
+        next();
+        /* record local declaration stack position */
+        s = local_stack;
+        frame_bottom = sym_push2(&local_stack, SYM_FIELD, 0, 0);
+        frame_bottom->next = scope_stack_bottom;
+        scope_stack_bottom = frame_bottom;
+        llabel = local_label_stack;
+        /* handle local labels declarations */
+        if (tok == TOK_LABEL) {
+            next();
+            for(;;) {
+                if (tok < TOK_UIDENT)
+                    expect("label identifier");
+                label_push(&local_label_stack, tok, LABEL_DECLARED);
+                next();
+                if (tok == ',') {
+                    next();
+                } else {
+                    skip(';');
+                    break;
+                }
+            }
+        }
+        while (tok != '}') {
+            label_or_decl(VT_LOCAL);
+            if (tok != '}') {
+                if (is_expr)
+                    vpop();
+                block(bsym, csym, case_sym, def_sym, case_reg, is_expr);
+            }
+        }
+        /* pop locally defined labels */
+        label_pop(&local_label_stack, llabel);
+        if(is_expr) {
+            /* XXX: this solution makes only valgrind happy...
+               triggered by gcc.c-torture/execute/20000917-1.c */
+            Sym *p;
+            switch(vtop->type.t & VT_BTYPE) {
+            case VT_PTR:
+            case VT_STRUCT:
+            case VT_ENUM:
+            case VT_FUNC:
+                for(p=vtop->type.ref;p;p=p->prev)
+                    if(p->prev==s)
+                        tcc_error("unsupported expression type");
+            }
+        }
+        /* pop locally defined symbols */
+        scope_stack_bottom = scope_stack_bottom->next;
+        sym_pop(&local_stack, s);
+        next();
+    } else if (tok == TOK_RETURN) {
+        next();
+        if (tok != ';') {
+            gexpr();
+            gen_assign_cast(&func_vt);
+            if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
+                CType type;
+                /* if returning structure, must copy it to implicit
+                   first pointer arg location */
+#ifdef TCC_ARM_EABI
+                int align, size;
+                size = type_size(&func_vt,&align);
+                if(size <= 4)
+                {
+                    if((vtop->r != (VT_LOCAL | VT_LVAL) || (vtop->c.i & 3))
+                       && (align & 3))
+                    {
+                        int addr;
+                        loc = (loc - size) & -4;
+                        addr = loc;
+                        type = func_vt;
+                        vset(&type, VT_LOCAL | VT_LVAL, addr);
+                        vswap();
+                        vstore();
+                        vset(&int_type, VT_LOCAL | VT_LVAL, addr);
+                    }
+                    vtop->type = int_type;
+                    gv(RC_IRET);
+                } else {
+#endif
+                type = func_vt;
+                mk_pointer(&type);
+                vset(&type, VT_LOCAL | VT_LVAL, func_vc);
+                indir();
+                vswap();
+                /* copy structure value to pointer */
+                vstore();
+#ifdef TCC_ARM_EABI
+                }
+#endif
+            } else if (is_float(func_vt.t)) {
+                gv(rc_fret(func_vt.t));
+            } else {
+                gv(RC_IRET);
+            }
+            vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
+        }
+        skip(';');
+        rsym = gjmp(rsym); /* jmp */
+    } else if (tok == TOK_BREAK) {
+        /* compute jump */
+        if (!bsym)
+            tcc_error("cannot break");
+        *bsym = gjmp(*bsym);
+        next();
+        skip(';');
+    } else if (tok == TOK_CONTINUE) {
+        /* compute jump */
+        if (!csym)
+            tcc_error("cannot continue");
+        *csym = gjmp(*csym);
+        next();
+        skip(';');
+    } else if (tok == TOK_FOR) {
+        int e;
+        next();
+        skip('(');
+        s = local_stack;
+        frame_bottom = sym_push2(&local_stack, SYM_FIELD, 0, 0);
+        frame_bottom->next = scope_stack_bottom;
+        scope_stack_bottom = frame_bottom;
+        if (tok != ';') {
+            /* c99 for-loop init decl? */
+            if (!decl0(VT_LOCAL, 1)) {
+                /* no, regular for-loop init expr */
+                gexpr();
+                vpop();
+            }
+        }
+        skip(';');
+        d = ind;
+        c = ind;
+        a = 0;
+        b = 0;
+        if (tok != ';') {
+            gexpr();
+            a = gtst(1, 0);
+        }
+        skip(';');
+        if (tok != ')') {
+            e = gjmp(0);
+            c = ind;
+            gexpr();
+            vpop();
+            gjmp_addr(d);
+            gsym(e);
+        }
+        skip(')');
+        block(&a, &b, case_sym, def_sym, case_reg, 0);
+        gjmp_addr(c);
+        gsym(a);
+        gsym_addr(b, c);
+        scope_stack_bottom = scope_stack_bottom->next;
+        sym_pop(&local_stack, s);
+    } else 
+    if (tok == TOK_DO) {
+        next();
+        a = 0;
+        b = 0;
+        d = ind;
+        block(&a, &b, case_sym, def_sym, case_reg, 0);
+        skip(TOK_WHILE);
+        skip('(');
+        gsym(b);
+        gexpr();
+        c = gtst(0, 0);
+        gsym_addr(c, d);
+        skip(')');
+        gsym(a);
+        skip(';');
+    } else
+    if (tok == TOK_SWITCH) {
+        next();
+        skip('(');
+        gexpr();
+        /* XXX: other types than integer */
+        case_reg = gv(RC_INT);
+        vpop();
+        skip(')');
+        a = 0;
+        b = gjmp(0); /* jump to first case */
+        c = 0;
+        block(&a, csym, &b, &c, case_reg, 0);
+        /* if no default, jmp after switch */
+        if (c == 0)
+            c = ind;
+        /* default label */
+        gsym_addr(b, c);
+        /* break label */
+        gsym(a);
+    } else
+    if (tok == TOK_CASE) {
+        int v1, v2;
+        if (!case_sym)
+            expect("switch");
+        next();
+        v1 = expr_const();
+        v2 = v1;
+        if (gnu_ext && tok == TOK_DOTS) {
+            next();
+            v2 = expr_const();
+            if (v2 < v1)
+                tcc_warning("empty case range");
+        }
+        /* since a case is like a label, we must skip it with a jmp */
+        b = gjmp(0);
+        gsym(*case_sym);
+        vseti(case_reg, 0);
+        vpushi(v1);
+        if (v1 == v2) {
+            gen_op(TOK_EQ);
+            *case_sym = gtst(1, 0);
+        } else {
+            gen_op(TOK_GE);
+            *case_sym = gtst(1, 0);
+            vseti(case_reg, 0);
+            vpushi(v2);
+            gen_op(TOK_LE);
+            *case_sym = gtst(1, *case_sym);
+        }
+        gsym(b);
+        skip(':');
+        is_expr = 0;
+        goto block_after_label;
+    } else 
+    if (tok == TOK_DEFAULT) {
+        next();
+        skip(':');
+        if (!def_sym)
+            expect("switch");
+        if (*def_sym)
+            tcc_error("too many 'default'");
+        *def_sym = ind;
+        is_expr = 0;
+        goto block_after_label;
+    } else
+    if (tok == TOK_GOTO) {
+        next();
+        if (tok == '*' && gnu_ext) {
+            /* computed goto */
+            next();
+            gexpr();
+            if ((vtop->type.t & VT_BTYPE) != VT_PTR)
+                expect("pointer");
+            ggoto();
+        } else if (tok >= TOK_UIDENT) {
+            s = label_find(tok);
+            /* put forward definition if needed */
+            if (!s) {
+                s = label_push(&global_label_stack, tok, LABEL_FORWARD);
+            } else {
+                if (s->r == LABEL_DECLARED)
+                    s->r = LABEL_FORWARD;
+            }
+            /* label already defined */
+            if (s->r & LABEL_FORWARD) 
+                s->jnext = gjmp(s->jnext);
+            else
+                gjmp_addr(s->jnext);
+            next();
+        } else {
+            expect("label identifier");
+        }
+        skip(';');
+    } else if (tok == TOK_ASM1 || tok == TOK_ASM2 || tok == TOK_ASM3) {
+        asm_instr();
+    } else {
+        b = is_label();
+        if (b) {
+            /* label case */
+            s = label_find(b);
+            if (s) {
+                if (s->r == LABEL_DEFINED)
+                    tcc_error("duplicate label '%s'", get_tok_str(s->v, NULL));
+                gsym(s->jnext);
+                s->r = LABEL_DEFINED;
+            } else {
+                s = label_push(&global_label_stack, b, LABEL_DEFINED);
+            }
+            s->jnext = ind;
+            /* we accept this, but it is a mistake */
+        block_after_label:
+            if (tok == '}') {
+                tcc_warning("deprecated use of label at end of compound statement");
+            } else {
+                if (is_expr)
+                    vpop();
+                block(bsym, csym, case_sym, def_sym, case_reg, is_expr);
+            }
+        } else {
+            /* expression case */
+            if (tok != ';') {
+                if (is_expr) {
+                    vpop();
+                    gexpr();
+                } else {
+                    gexpr();
+                    vpop();
+                }
+            }
+            skip(';');
+        }
+    }
+}
+
+/* t is the array or struct type. c is the array or struct
+   address. cur_index/cur_field is the pointer to the current
+   value. 'size_only' is true if only size info is needed (only used
+   in arrays) */
+static void decl_designator(CType *type, Section *sec, unsigned long c, 
+                            int *cur_index, Sym **cur_field, 
+                            int size_only)
+{
+    Sym *s, *f;
+    int notfirst, index, index_last, align, l, nb_elems, elem_size;
+    CType type1;
+
+    notfirst = 0;
+    elem_size = 0;
+    nb_elems = 1;
+    if (gnu_ext && (l = is_label()) != 0)
+        goto struct_field;
+    while (tok == '[' || tok == '.') {
+        if (tok == '[') {
+            if (!(type->t & VT_ARRAY))
+                expect("array type");
+            s = type->ref;
+            next();
+            index = expr_const();
+            if (index < 0 || (s->c >= 0 && index >= s->c))
+                expect("invalid index");
+            if (tok == TOK_DOTS && gnu_ext) {
+                next();
+                index_last = expr_const();
+                if (index_last < 0 || 
+                    (s->c >= 0 && index_last >= s->c) ||
+                    index_last < index)
+                    expect("invalid index");
+            } else {
+                index_last = index;
+            }
+            skip(']');
+            if (!notfirst)
+                *cur_index = index_last;
+            type = pointed_type(type);
+            elem_size = type_size(type, &align);
+            c += index * elem_size;
+            /* NOTE: we only support ranges for last designator */
+            nb_elems = index_last - index + 1;
+            if (nb_elems != 1) {
+                notfirst = 1;
+                break;
+            }
+        } else {
+            next();
+            l = tok;
+            next();
+        struct_field:
+            if ((type->t & VT_BTYPE) != VT_STRUCT)
+                expect("struct/union type");
+            s = type->ref;
+            l |= SYM_FIELD;
+            f = s->next;
+            while (f) {
+                if (f->v == l)
+                    break;
+                f = f->next;
+            }
+            if (!f)
+                expect("field");
+            if (!notfirst)
+                *cur_field = f;
+            /* XXX: fix this mess by using explicit storage field */
+            type1 = f->type;
+            type1.t |= (type->t & ~VT_TYPE);
+            type = &type1;
+            c += f->c;
+        }
+        notfirst = 1;
+    }
+    if (notfirst) {
+        if (tok == '=') {
+            next();
+        } else {
+            if (!gnu_ext)
+                expect("=");
+        }
+    } else {
+        if (type->t & VT_ARRAY) {
+            index = *cur_index;
+            type = pointed_type(type);
+            c += index * type_size(type, &align);
+        } else {
+            f = *cur_field;
+            if (!f)
+                tcc_error("too many field init");
+            /* XXX: fix this mess by using explicit storage field */
+            type1 = f->type;
+            type1.t |= (type->t & ~VT_TYPE);
+            type = &type1;
+            c += f->c;
+        }
+    }
+    decl_initializer(type, sec, c, 0, size_only);
+
+    /* XXX: make it more general */
+    if (!size_only && nb_elems > 1) {
+        unsigned long c_end;
+        uint8_t *src, *dst;
+        int i;
+
+        if (!sec)
+            tcc_error("range init not supported yet for dynamic storage");
+        c_end = c + nb_elems * elem_size;
+        if (c_end > sec->data_allocated)
+            section_realloc(sec, c_end);
+        src = sec->data + c;
+        dst = src;
+        for(i = 1; i < nb_elems; i++) {
+            dst += elem_size;
+            memcpy(dst, src, elem_size);
+        }
+    }
+}
+
+#define EXPR_VAL   0
+#define EXPR_CONST 1
+#define EXPR_ANY   2
+
+/* store a value or an expression directly in global data or in local array */
+static void init_putv(CType *type, Section *sec, unsigned long c, 
+                      int v, int expr_type)
+{
+    int saved_global_expr, bt, bit_pos, bit_size;
+    void *ptr;
+    unsigned long long bit_mask;
+    CType dtype;
+
+    switch(expr_type) {
+    case EXPR_VAL:
+        vpushi(v);
+        break;
+    case EXPR_CONST:
+        /* compound literals must be allocated globally in this case */
+        saved_global_expr = global_expr;
+        global_expr = 1;
+        expr_const1();
+        global_expr = saved_global_expr;
+        /* NOTE: symbols are accepted */
+        if ((vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST)
+            tcc_error("initializer element is not constant");
+        break;
+    case EXPR_ANY:
+        expr_eq();
+        break;
+    }
+    
+    dtype = *type;
+    dtype.t &= ~VT_CONSTANT; /* need to do that to avoid false warning */
+
+    if (sec) {
+        /* XXX: not portable */
+        /* XXX: generate error if incorrect relocation */
+        gen_assign_cast(&dtype);
+        bt = type->t & VT_BTYPE;
+        /* we'll write at most 12 bytes */
+        if (c + 12 > sec->data_allocated) {
+            section_realloc(sec, c + 12);
+        }
+        ptr = sec->data + c;
+        /* XXX: make code faster ? */
+        if (!(type->t & VT_BITFIELD)) {
+            bit_pos = 0;
+            bit_size = 32;
+            bit_mask = -1LL;
+        } else {
+            bit_pos = (vtop->type.t >> VT_STRUCT_SHIFT) & 0x3f;
+            bit_size = (vtop->type.t >> (VT_STRUCT_SHIFT + 6)) & 0x3f;
+            bit_mask = (1LL << bit_size) - 1;
+        }
+        if ((vtop->r & VT_SYM) &&
+            (bt == VT_BYTE ||
+             bt == VT_SHORT ||
+             bt == VT_DOUBLE ||
+             bt == VT_LDOUBLE ||
+             bt == VT_LLONG ||
+             (bt == VT_INT && bit_size != 32)))
+            tcc_error("initializer element is not computable at load time");
+        switch(bt) {
+        case VT_BOOL:
+            vtop->c.i = (vtop->c.i != 0);
+        case VT_BYTE:
+            *(char *)ptr |= (vtop->c.i & bit_mask) << bit_pos;
+            break;
+        case VT_SHORT:
+            *(short *)ptr |= (vtop->c.i & bit_mask) << bit_pos;
+            break;
+        case VT_DOUBLE:
+            *(double *)ptr = vtop->c.d;
+            break;
+        case VT_LDOUBLE:
+            *(long double *)ptr = vtop->c.ld;
+            break;
+        case VT_LLONG:
+            *(long long *)ptr |= (vtop->c.ll & bit_mask) << bit_pos;
+            break;
+        default:
+            if (vtop->r & VT_SYM) {
+                greloc(sec, vtop->sym, c, R_DATA_PTR);
+            }
+            *(int *)ptr |= (vtop->c.i & bit_mask) << bit_pos;
+            break;
+        }
+        vtop--;
+    } else {
+        vset(&dtype, VT_LOCAL|VT_LVAL, c);
+        vswap();
+        vstore();
+        vpop();
+    }
+}
+
+/* put zeros for variable based init */
+static void init_putz(CType *t, Section *sec, unsigned long c, int size)
+{
+    if (sec) {
+        /* nothing to do because globals are already set to zero */
+    } else {
+        vpush_global_sym(&func_old_type, TOK_memset);
+        vseti(VT_LOCAL, c);
+        vpushi(0);
+        vpushi(size);
+        gfunc_call(3);
+    }
+}
+
+/* 't' contains the type and storage info. 'c' is the offset of the
+   object in section 'sec'. If 'sec' is NULL, it means stack based
+   allocation. 'first' is true if array '{' must be read (multi
+   dimension implicit array init handling). 'size_only' is true if
+   size only evaluation is wanted (only for arrays). */
+static void decl_initializer(CType *type, Section *sec, unsigned long c, 
+                             int first, int size_only)
+{
+    int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i;
+    int size1, align1, expr_type;
+    Sym *s, *f;
+    CType *t1;
+
+    if (type->t & VT_VLA) {
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+        int a;
+        CValue retcval;
+
+        vpush_global_sym(&func_old_type, TOK_alloca);
+        vla_runtime_type_size(type, &a);
+        gfunc_call(1);
+
+        /* return value */
+        retcval.i = 0;
+        vsetc(type, REG_IRET, &retcval);
+        vset(type, VT_LOCAL|VT_LVAL, c);
+        vswap();
+        vstore();
+        vpop();
+#else
+        tcc_error("variable length arrays unsupported for this target");
+#endif
+    } else if (type->t & VT_ARRAY) {
+        s = type->ref;
+        n = s->c;
+        array_length = 0;
+        t1 = pointed_type(type);
+        size1 = type_size(t1, &align1);
+
+        no_oblock = 1;
+        if ((first && tok != TOK_LSTR && tok != TOK_STR) || 
+            tok == '{') {
+            if (tok != '{')
+                tcc_error("character array initializer must be a literal,"
+                    " optionally enclosed in braces");
+            skip('{');
+            no_oblock = 0;
+        }
+
+        /* only parse strings here if correct type (otherwise: handle
+           them as ((w)char *) expressions */
+        if ((tok == TOK_LSTR && 
+#ifdef TCC_TARGET_PE
+             (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED)
+#else
+             (t1->t & VT_BTYPE) == VT_INT
+#endif
+            ) || (tok == TOK_STR && (t1->t & VT_BTYPE) == VT_BYTE)) {
+            while (tok == TOK_STR || tok == TOK_LSTR) {
+                int cstr_len, ch;
+                CString *cstr;
+
+                cstr = tokc.cstr;
+                /* compute maximum number of chars wanted */
+                if (tok == TOK_STR)
+                    cstr_len = cstr->size;
+                else
+                    cstr_len = cstr->size / sizeof(nwchar_t);
+                cstr_len--;
+                nb = cstr_len;
+                if (n >= 0 && nb > (n - array_length))
+                    nb = n - array_length;
+                if (!size_only) {
+                    if (cstr_len > nb)
+                        tcc_warning("initializer-string for array is too long");
+                    /* in order to go faster for common case (char
+                       string in global variable, we handle it
+                       specifically */
+                    if (sec && tok == TOK_STR && size1 == 1) {
+                        memcpy(sec->data + c + array_length, cstr->data, nb);
+                    } else {
+                        for(i=0;i<nb;i++) {
+                            if (tok == TOK_STR)
+                                ch = ((unsigned char *)cstr->data)[i];
+                            else
+                                ch = ((nwchar_t *)cstr->data)[i];
+                            init_putv(t1, sec, c + (array_length + i) * size1,
+                                      ch, EXPR_VAL);
+                        }
+                    }
+                }
+                array_length += nb;
+                next();
+            }
+            /* only add trailing zero if enough storage (no
+               warning in this case since it is standard) */
+            if (n < 0 || array_length < n) {
+                if (!size_only) {
+                    init_putv(t1, sec, c + (array_length * size1), 0, EXPR_VAL);
+                }
+                array_length++;
+            }
+        } else {
+            index = 0;
+            while (tok != '}') {
+                decl_designator(type, sec, c, &index, NULL, size_only);
+                if (n >= 0 && index >= n)
+                    tcc_error("index too large");
+                /* must put zero in holes (note that doing it that way
+                   ensures that it even works with designators) */
+                if (!size_only && array_length < index) {
+                    init_putz(t1, sec, c + array_length * size1, 
+                              (index - array_length) * size1);
+                }
+                index++;
+                if (index > array_length)
+                    array_length = index;
+                /* special test for multi dimensional arrays (may not
+                   be strictly correct if designators are used at the
+                   same time) */
+                if (index >= n && no_oblock)
+                    break;
+                if (tok == '}')
+                    break;
+                skip(',');
+            }
+        }
+        if (!no_oblock)
+            skip('}');
+        /* put zeros at the end */
+        if (!size_only && n >= 0 && array_length < n) {
+            init_putz(t1, sec, c + array_length * size1, 
+                      (n - array_length) * size1);
+        }
+        /* patch type size if needed */
+        if (n < 0)
+            s->c = array_length;
+    } else if ((type->t & VT_BTYPE) == VT_STRUCT &&
+               (sec || !first || tok == '{')) {
+        int par_count;
+
+        /* NOTE: the previous test is a specific case for automatic
+           struct/union init */
+        /* XXX: union needs only one init */
+
+        /* XXX: this test is incorrect for local initializers
+           beginning with ( without {. It would be much more difficult
+           to do it correctly (ideally, the expression parser should
+           be used in all cases) */
+        par_count = 0;
+        if (tok == '(') {
+            AttributeDef ad1;
+            CType type1;
+            next();
+            while (tok == '(') {
+                par_count++;
+                next();
+            }
+            if (!parse_btype(&type1, &ad1))
+                expect("cast");
+            type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
+#if 0
+            if (!is_assignable_types(type, &type1))
+                tcc_error("invalid type for cast");
+#endif
+            skip(')');
+        }
+        no_oblock = 1;
+        if (first || tok == '{') {
+            skip('{');
+            no_oblock = 0;
+        }
+        s = type->ref;
+        f = s->next;
+        array_length = 0;
+        index = 0;
+        n = s->c;
+        while (tok != '}') {
+            decl_designator(type, sec, c, NULL, &f, size_only);
+            index = f->c;
+            if (!size_only && array_length < index) {
+                init_putz(type, sec, c + array_length, 
+                          index - array_length);
+            }
+            index = index + type_size(&f->type, &align1);
+            if (index > array_length)
+                array_length = index;
+
+            /* gr: skip fields from same union - ugly. */
+            while (f->next) {
+                ///printf("index: %2d %08x -- %2d %08x\n", f->c, f->type.t, f->next->c, f->next->type.t);
+                /* test for same offset */
+                if (f->next->c != f->c)
+                    break;
+                /* if yes, test for bitfield shift */
+                if ((f->type.t & VT_BITFIELD) && (f->next->type.t & VT_BITFIELD)) {
+                    int bit_pos_1 = (f->type.t >> VT_STRUCT_SHIFT) & 0x3f;
+                    int bit_pos_2 = (f->next->type.t >> VT_STRUCT_SHIFT) & 0x3f;
+                    //printf("bitfield %d %d\n", bit_pos_1, bit_pos_2);
+                    if (bit_pos_1 != bit_pos_2)
+                        break;
+                }
+                f = f->next;
+            }
+
+            f = f->next;
+            if (no_oblock && f == NULL)
+                break;
+            if (tok == '}')
+                break;
+            skip(',');
+        }
+        /* put zeros at the end */
+        if (!size_only && array_length < n) {
+            init_putz(type, sec, c + array_length, 
+                      n - array_length);
+        }
+        if (!no_oblock)
+            skip('}');
+        while (par_count) {
+            skip(')');
+            par_count--;
+        }
+    } else if (tok == '{') {
+        next();
+        decl_initializer(type, sec, c, first, size_only);
+        skip('}');
+    } else if (size_only) {
+        /* just skip expression */
+        parlevel = parlevel1 = 0;
+        while ((parlevel > 0 || parlevel1 > 0 ||
+		(tok != '}' && tok != ',')) &&  tok != -1) {
+            if (tok == '(')
+                parlevel++;
+            else if (tok == ')')
+                parlevel--;
+	    else if (tok == '{')
+		parlevel1++;
+	    else if (tok == '}')
+		parlevel1--;
+            next();
+        }
+    } else {
+        /* currently, we always use constant expression for globals
+           (may change for scripting case) */
+        expr_type = EXPR_CONST;
+        if (!sec)
+            expr_type = EXPR_ANY;
+        init_putv(type, sec, c, 0, expr_type);
+    }
+}
+
+/* parse an initializer for type 't' if 'has_init' is non zero, and
+   allocate space in local or global data space ('r' is either
+   VT_LOCAL or VT_CONST). If 'v' is non zero, then an associated
+   variable 'v' with an associated name represented by 'asm_label' of
+   scope 'scope' is declared before initializers are parsed. If 'v' is
+   zero, then a reference to the new object is put in the value stack.
+   If 'has_init' is 2, a special parsing is done to handle string
+   constants. */
+static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, 
+                                   int has_init, int v, char *asm_label,
+                                   int scope)
+{
+    int size, align, addr, data_offset;
+    int level;
+    ParseState saved_parse_state = {0};
+    TokenString init_str;
+    Section *sec;
+    Sym *flexible_array;
+
+    flexible_array = NULL;
+    if ((type->t & VT_BTYPE) == VT_STRUCT) {
+        Sym *field;
+        field = type->ref;
+        while (field && field->next)
+            field = field->next;
+        if (field->type.t & VT_ARRAY && field->type.ref->c < 0)
+            flexible_array = field;
+    }
+
+    size = type_size(type, &align);
+    /* If unknown size, we must evaluate it before
+       evaluating initializers because
+       initializers can generate global data too
+       (e.g. string pointers or ISOC99 compound
+       literals). It also simplifies local
+       initializers handling */
+    tok_str_new(&init_str);
+    if (size < 0 || (flexible_array && has_init)) {
+        if (!has_init) 
+            tcc_error("unknown type size");
+        /* get all init string */
+        if (has_init == 2) {
+            /* only get strings */
+            while (tok == TOK_STR || tok == TOK_LSTR) {
+                tok_str_add_tok(&init_str);
+                next();
+            }
+        } else {
+            level = 0;
+            while (level > 0 || (tok != ',' && tok != ';')) {
+                if (tok < 0)
+                    tcc_error("unexpected end of file in initializer");
+                tok_str_add_tok(&init_str);
+                if (tok == '{')
+                    level++;
+                else if (tok == '}') {
+                    level--;
+                    if (level <= 0) {
+                        next();
+                        break;
+                    }
+                }
+                next();
+            }
+        }
+        tok_str_add(&init_str, -1);
+        tok_str_add(&init_str, 0);
+        
+        /* compute size */
+        save_parse_state(&saved_parse_state);
+
+        macro_ptr = init_str.str;
+        next();
+        decl_initializer(type, NULL, 0, 1, 1);
+        /* prepare second initializer parsing */
+        macro_ptr = init_str.str;
+        next();
+        
+        /* if still unknown size, error */
+        size = type_size(type, &align);
+        if (size < 0) 
+            tcc_error("unknown type size");
+    }
+    if (flexible_array)
+        size += flexible_array->type.ref->c * pointed_size(&flexible_array->type);
+    /* take into account specified alignment if bigger */
+    if (ad->aligned) {
+        if (ad->aligned > align)
+            align = ad->aligned;
+    } else if (ad->packed) {
+        align = 1;
+    }
+    if ((r & VT_VALMASK) == VT_LOCAL) {
+        sec = NULL;
+#ifdef CONFIG_TCC_BCHECK
+        if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {
+            loc--;
+        }
+#endif
+        loc = (loc - size) & -align;
+        addr = loc;
+#ifdef CONFIG_TCC_BCHECK
+        /* handles bounds */
+        /* XXX: currently, since we do only one pass, we cannot track
+           '&' operators, so we add only arrays */
+        if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {
+            unsigned long *bounds_ptr;
+            /* add padding between regions */
+            loc--;
+            /* then add local bound info */
+            bounds_ptr = section_ptr_add(lbounds_section, 2 * sizeof(unsigned long));
+            bounds_ptr[0] = addr;
+            bounds_ptr[1] = size;
+        }
+#endif
+        if (v) {
+            /* local variable */
+            sym_push(v, type, r, addr);
+        } else {
+            /* push local reference */
+            vset(type, r, addr);
+        }
+    } else {
+        Sym *sym;
+
+        sym = NULL;
+        if (v && scope == VT_CONST) {
+            /* see if the symbol was already defined */
+            sym = sym_find(v);
+            if (sym) {
+                if (!is_compatible_types(&sym->type, type))
+                    tcc_error("incompatible types for redefinition of '%s'", 
+                          get_tok_str(v, NULL));
+                if (sym->type.t & VT_EXTERN) {
+                    /* if the variable is extern, it was not allocated */
+                    sym->type.t &= ~VT_EXTERN;
+                    /* set array size if it was ommited in extern
+                       declaration */
+                    if ((sym->type.t & VT_ARRAY) && 
+                        sym->type.ref->c < 0 &&
+                        type->ref->c >= 0)
+                        sym->type.ref->c = type->ref->c;
+                } else {
+                    /* we accept several definitions of the same
+                       global variable. this is tricky, because we
+                       must play with the SHN_COMMON type of the symbol */
+                    /* XXX: should check if the variable was already
+                       initialized. It is incorrect to initialized it
+                       twice */
+                    /* no init data, we won't add more to the symbol */
+                    if (!has_init)
+                        goto no_alloc;
+                }
+            }
+        }
+
+        /* allocate symbol in corresponding section */
+        sec = ad->section;
+        if (!sec) {
+            if (has_init)
+                sec = data_section;
+            else if (tcc_state->nocommon)
+                sec = bss_section;
+        }
+        if (sec) {
+            data_offset = sec->data_offset;
+            data_offset = (data_offset + align - 1) & -align;
+            addr = data_offset;
+            /* very important to increment global pointer at this time
+               because initializers themselves can create new initializers */
+            data_offset += size;
+#ifdef CONFIG_TCC_BCHECK
+            /* add padding if bound check */
+            if (tcc_state->do_bounds_check)
+                data_offset++;
+#endif
+            sec->data_offset = data_offset;
+            /* allocate section space to put the data */
+            if (sec->sh_type != SHT_NOBITS && 
+                data_offset > sec->data_allocated)
+                section_realloc(sec, data_offset);
+            /* align section if needed */
+            if (align > sec->sh_addralign)
+                sec->sh_addralign = align;
+        } else {
+            addr = 0; /* avoid warning */
+        }
+
+        if (v) {
+            if (scope != VT_CONST || !sym) {
+                sym = sym_push(v, type, r | VT_SYM, 0);
+                sym->asm_label = asm_label;
+            }
+            /* update symbol definition */
+            if (sec) {
+                put_extern_sym(sym, sec, addr, size);
+            } else {
+                ElfW(Sym) *esym;
+                /* put a common area */
+                put_extern_sym(sym, NULL, align, size);
+                /* XXX: find a nicer way */
+                esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
+                esym->st_shndx = SHN_COMMON;
+            }
+        } else {
+            CValue cval;
+
+            /* push global reference */
+            sym = get_sym_ref(type, sec, addr, size);
+            cval.ul = 0;
+            vsetc(type, VT_CONST | VT_SYM, &cval);
+            vtop->sym = sym;
+        }
+        /* patch symbol weakness */
+        if (type->t & VT_WEAK)
+            weaken_symbol(sym);
+#ifdef CONFIG_TCC_BCHECK
+        /* handles bounds now because the symbol must be defined
+           before for the relocation */
+        if (tcc_state->do_bounds_check) {
+            unsigned long *bounds_ptr;
+
+            greloc(bounds_section, sym, bounds_section->data_offset, R_DATA_PTR);
+            /* then add global bound info */
+            bounds_ptr = section_ptr_add(bounds_section, 2 * sizeof(long));
+            bounds_ptr[0] = 0; /* relocated */
+            bounds_ptr[1] = size;
+        }
+#endif
+    }
+    if (has_init || (type->t & VT_VLA)) {
+        decl_initializer(type, sec, addr, 1, 0);
+        /* restore parse state if needed */
+        if (init_str.str) {
+            tok_str_free(init_str.str);
+            restore_parse_state(&saved_parse_state);
+        }
+        /* patch flexible array member size back to -1, */
+        /* for possible subsequent similar declarations */
+        if (flexible_array)
+            flexible_array->type.ref->c = -1;
+    }
+ no_alloc: ;
+}
+
+static void put_func_debug(Sym *sym)
+{
+    char buf[512];
+
+    /* stabs info */
+    /* XXX: we put here a dummy type */
+    snprintf(buf, sizeof(buf), "%s:%c1", 
+             funcname, sym->type.t & VT_STATIC ? 'f' : 'F');
+    put_stabs_r(buf, N_FUN, 0, file->line_num, 0,
+                cur_text_section, sym->c);
+    /* //gr gdb wants a line at the function */
+    put_stabn(N_SLINE, 0, file->line_num, 0); 
+    last_ind = 0;
+    last_line_num = 0;
+}
+
+/* parse an old style function declaration list */
+/* XXX: check multiple parameter */
+static void func_decl_list(Sym *func_sym)
+{
+    AttributeDef ad;
+    int v;
+    Sym *s;
+    CType btype, type;
+
+    /* parse each declaration */
+    while (tok != '{' && tok != ';' && tok != ',' && tok != TOK_EOF &&
+           tok != TOK_ASM1 && tok != TOK_ASM2 && tok != TOK_ASM3) {
+        if (!parse_btype(&btype, &ad)) 
+            expect("declaration list");
+        if (((btype.t & VT_BTYPE) == VT_ENUM ||
+             (btype.t & VT_BTYPE) == VT_STRUCT) && 
+            tok == ';') {
+            /* we accept no variable after */
+        } else {
+            for(;;) {
+                type = btype;
+                type_decl(&type, &ad, &v, TYPE_DIRECT);
+                /* find parameter in function parameter list */
+                s = func_sym->next;
+                while (s != NULL) {
+                    if ((s->v & ~SYM_FIELD) == v)
+                        goto found;
+                    s = s->next;
+                }
+                tcc_error("declaration for parameter '%s' but no such parameter",
+                      get_tok_str(v, NULL));
+            found:
+                /* check that no storage specifier except 'register' was given */
+                if (type.t & VT_STORAGE)
+                    tcc_error("storage class specified for '%s'", get_tok_str(v, NULL)); 
+                convert_parameter_type(&type);
+                /* we can add the type (NOTE: it could be local to the function) */
+                s->type = type;
+                /* accept other parameters */
+                if (tok == ',')
+                    next();
+                else
+                    break;
+            }
+        }
+        skip(';');
+    }
+}
+
+/* parse a function defined by symbol 'sym' and generate its code in
+   'cur_text_section' */
+static void gen_function(Sym *sym)
+{
+    int saved_nocode_wanted = nocode_wanted;
+    nocode_wanted = 0;
+    ind = cur_text_section->data_offset;
+    /* NOTE: we patch the symbol size later */
+    put_extern_sym(sym, cur_text_section, ind, 0);
+    funcname = get_tok_str(sym->v, NULL);
+    func_ind = ind;
+    /* put debug symbol */
+    if (tcc_state->do_debug)
+        put_func_debug(sym);
+    /* push a dummy symbol to enable local sym storage */
+    sym_push2(&local_stack, SYM_FIELD, 0, 0);
+    gfunc_prolog(&sym->type);
+    rsym = 0;
+    block(NULL, NULL, NULL, NULL, 0, 0);
+    gsym(rsym);
+    gfunc_epilog();
+    cur_text_section->data_offset = ind;
+    label_pop(&global_label_stack, NULL);
+    /* reset local stack */
+    scope_stack_bottom = NULL;
+    sym_pop(&local_stack, NULL);
+    /* end of function */
+    /* patch symbol size */
+    ((ElfW(Sym) *)symtab_section->data)[sym->c].st_size = 
+        ind - func_ind;
+    /* patch symbol weakness (this definition overrules any prototype) */
+    if (sym->type.t & VT_WEAK)
+        weaken_symbol(sym);
+    if (tcc_state->do_debug) {
+        put_stabn(N_FUN, 0, 0, ind - func_ind);
+    }
+    /* It's better to crash than to generate wrong code */
+    cur_text_section = NULL;
+    funcname = ""; /* for safety */
+    func_vt.t = VT_VOID; /* for safety */
+    ind = 0; /* for safety */
+    nocode_wanted = saved_nocode_wanted;
+}
+
+ST_FUNC void gen_inline_functions(void)
+{
+    Sym *sym;
+    int *str, inline_generated, i;
+    struct InlineFunc *fn;
+
+    /* iterate while inline function are referenced */
+    for(;;) {
+        inline_generated = 0;
+        for (i = 0; i < tcc_state->nb_inline_fns; ++i) {
+            fn = tcc_state->inline_fns[i];
+            sym = fn->sym;
+            if (sym && sym->c) {
+                /* the function was used: generate its code and
+                   convert it to a normal function */
+                str = fn->token_str;
+                fn->sym = NULL;
+                if (file)
+                    pstrcpy(file->filename, sizeof file->filename, fn->filename);
+                sym->r = VT_SYM | VT_CONST;
+                sym->type.t &= ~VT_INLINE;
+
+                macro_ptr = str;
+                next();
+                cur_text_section = text_section;
+                gen_function(sym);
+                macro_ptr = NULL; /* fail safe */
+
+                inline_generated = 1;
+            }
+        }
+        if (!inline_generated)
+            break;
+    }
+    for (i = 0; i < tcc_state->nb_inline_fns; ++i) {
+        fn = tcc_state->inline_fns[i];
+        str = fn->token_str;
+        tok_str_free(str);
+    }
+    dynarray_reset(&tcc_state->inline_fns, &tcc_state->nb_inline_fns);
+}
+
+/* 'l' is VT_LOCAL or VT_CONST to define default storage type */
+static int decl0(int l, int is_for_loop_init)
+{
+    int v, has_init, r;
+    CType type, btype;
+    Sym *sym;
+    AttributeDef ad;
+
+    while (1) {
+        if (!parse_btype(&btype, &ad)) {
+            if (is_for_loop_init)
+                return 0;
+            /* skip redundant ';' */
+            /* XXX: find more elegant solution */
+            if (tok == ';') {
+                next();
+                continue;
+            }
+            if (l == VT_CONST &&
+                (tok == TOK_ASM1 || tok == TOK_ASM2 || tok == TOK_ASM3)) {
+                /* global asm block */
+                asm_global_instr();
+                continue;
+            }
+            /* special test for old K&R protos without explicit int
+               type. Only accepted when defining global data */
+            if (l == VT_LOCAL || tok < TOK_DEFINE)
+                break;
+            btype.t = VT_INT;
+        }
+        if (((btype.t & VT_BTYPE) == VT_ENUM ||
+             (btype.t & VT_BTYPE) == VT_STRUCT) && 
+            tok == ';') {
+            /* we accept no variable after */
+            next();
+            continue;
+        }
+        while (1) { /* iterate thru each declaration */
+            char *asm_label; // associated asm label
+            type = btype;
+            type_decl(&type, &ad, &v, TYPE_DIRECT);
+#if 0
+            {
+                char buf[500];
+                type_to_str(buf, sizeof(buf), t, get_tok_str(v, NULL));
+                printf("type = '%s'\n", buf);
+            }
+#endif
+            if ((type.t & VT_BTYPE) == VT_FUNC) {
+                if ((type.t & VT_STATIC) && (l == VT_LOCAL)) {
+                    tcc_error("function without file scope cannot be static");
+                }
+                /* if old style function prototype, we accept a
+                   declaration list */
+                sym = type.ref;
+                if (sym->c == FUNC_OLD)
+                    func_decl_list(sym);
+            }
+
+            asm_label = NULL;
+            if (gnu_ext && (tok == TOK_ASM1 || tok == TOK_ASM2 || tok == TOK_ASM3)) {
+                CString astr;
+
+                asm_label_instr(&astr);
+                asm_label = tcc_strdup(astr.data);
+                cstr_free(&astr);
+                
+                /* parse one last attribute list, after asm label */
+                parse_attribute(&ad);
+            }
+
+            if (ad.weak)
+                type.t |= VT_WEAK;
+#ifdef TCC_TARGET_PE
+            if (ad.func_import)
+                type.t |= VT_IMPORT;
+            if (ad.func_export)
+                type.t |= VT_EXPORT;
+#endif
+            if (tok == '{') {
+                if (l == VT_LOCAL)
+                    tcc_error("cannot use local functions");
+                if ((type.t & VT_BTYPE) != VT_FUNC)
+                    expect("function definition");
+
+                /* reject abstract declarators in function definition */
+                sym = type.ref;
+                while ((sym = sym->next) != NULL)
+                    if (!(sym->v & ~SYM_FIELD))
+                       expect("identifier");
+                
+                /* XXX: cannot do better now: convert extern line to static inline */
+                if ((type.t & (VT_EXTERN | VT_INLINE)) == (VT_EXTERN | VT_INLINE))
+                    type.t = (type.t & ~VT_EXTERN) | VT_STATIC;
+                
+                sym = sym_find(v);
+                if (sym) {
+                    if ((sym->type.t & VT_BTYPE) != VT_FUNC)
+                        goto func_error1;
+
+                    r = sym->type.ref->r;
+                    /* use func_call from prototype if not defined */
+                    if (FUNC_CALL(r) != FUNC_CDECL
+                     && FUNC_CALL(type.ref->r) == FUNC_CDECL)
+                        FUNC_CALL(type.ref->r) = FUNC_CALL(r);
+
+                    /* use export from prototype */
+                    if (FUNC_EXPORT(r))
+                        FUNC_EXPORT(type.ref->r) = 1;
+
+                    /* use static from prototype */
+                    if (sym->type.t & VT_STATIC)
+                        type.t = (type.t & ~VT_EXTERN) | VT_STATIC;
+
+                    if (!is_compatible_types(&sym->type, &type)) {
+                    func_error1:
+                        tcc_error("incompatible types for redefinition of '%s'", 
+                              get_tok_str(v, NULL));
+                    }
+                    /* if symbol is already defined, then put complete type */
+                    sym->type = type;
+                } else {
+                    /* put function symbol */
+                    sym = global_identifier_push(v, type.t, 0);
+                    sym->type.ref = type.ref;
+                }
+
+                /* static inline functions are just recorded as a kind
+                   of macro. Their code will be emitted at the end of
+                   the compilation unit only if they are used */
+                if ((type.t & (VT_INLINE | VT_STATIC)) == 
+                    (VT_INLINE | VT_STATIC)) {
+                    TokenString func_str;
+                    int block_level;
+                    struct InlineFunc *fn;
+                    const char *filename;
+                           
+                    tok_str_new(&func_str);
+                    
+                    block_level = 0;
+                    for(;;) {
+                        int t;
+                        if (tok == TOK_EOF)
+                            tcc_error("unexpected end of file");
+                        tok_str_add_tok(&func_str);
+                        t = tok;
+                        next();
+                        if (t == '{') {
+                            block_level++;
+                        } else if (t == '}') {
+                            block_level--;
+                            if (block_level == 0)
+                                break;
+                        }
+                    }
+                    tok_str_add(&func_str, -1);
+                    tok_str_add(&func_str, 0);
+                    filename = file ? file->filename : "";
+                    fn = tcc_malloc(sizeof *fn + strlen(filename));
+                    strcpy(fn->filename, filename);
+                    fn->sym = sym;
+                    fn->token_str = func_str.str;
+                    dynarray_add((void ***)&tcc_state->inline_fns, &tcc_state->nb_inline_fns, fn);
+
+                } else {
+                    /* compute text section */
+                    cur_text_section = ad.section;
+                    if (!cur_text_section)
+                        cur_text_section = text_section;
+                    sym->r = VT_SYM | VT_CONST;
+                    gen_function(sym);
+                }
+                break;
+            } else {
+                if (btype.t & VT_TYPEDEF) {
+                    /* save typedefed type  */
+                    /* XXX: test storage specifiers ? */
+                    sym = sym_push(v, &type, INT_ATTR(&ad), 0);
+                    sym->type.t |= VT_TYPEDEF;
+                } else {
+                    r = 0;
+                    if ((type.t & VT_BTYPE) == VT_FUNC) {
+                        /* external function definition */
+                        /* specific case for func_call attribute */
+                        type.ref->r = INT_ATTR(&ad);
+                    } else if (!(type.t & VT_ARRAY)) {
+                        /* not lvalue if array */
+                        r |= lvalue_type(type.t);
+                    }
+                    has_init = (tok == '=');
+                    if (has_init && (type.t & VT_VLA))
+                        tcc_error("Variable length array cannot be initialized");
+                    if ((btype.t & VT_EXTERN) || ((type.t & VT_BTYPE) == VT_FUNC) ||
+                        ((type.t & VT_ARRAY) && (type.t & VT_STATIC) &&
+                         !has_init && l == VT_CONST && type.ref->c < 0)) {
+                        /* external variable or function */
+                        /* NOTE: as GCC, uninitialized global static
+                           arrays of null size are considered as
+                           extern */
+                        sym = external_sym(v, &type, r, asm_label);
+
+                        if (type.t & VT_WEAK)
+                            weaken_symbol(sym);
+
+                        if (ad.alias_target) {
+                            Section tsec;
+                            Elf32_Sym *esym;
+                            Sym *alias_target;
+
+                            alias_target = sym_find(ad.alias_target);
+                            if (!alias_target || !alias_target->c)
+                                tcc_error("unsupported forward __alias__ attribute");
+                            esym = &((Elf32_Sym *)symtab_section->data)[alias_target->c];
+                            tsec.sh_num = esym->st_shndx;
+                            put_extern_sym2(sym, &tsec, esym->st_value, esym->st_size, 0);
+                        }
+                    } else {
+                        type.t |= (btype.t & VT_STATIC); /* Retain "static". */
+                        if (type.t & VT_STATIC)
+                            r |= VT_CONST;
+                        else
+                            r |= l;
+                        if (has_init)
+                            next();
+                        decl_initializer_alloc(&type, &ad, r, has_init, v, asm_label, l);
+                    }
+                }
+                if (tok != ',') {
+                    if (is_for_loop_init)
+                        return 1;
+                    skip(';');
+                    break;
+                }
+                next();
+            }
+            ad.aligned = 0;
+        }
+    }
+    return 0;
+}
+
+ST_FUNC void decl(int l)
+{
+    decl0(l, 0);
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tccpe.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tccpe.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tccpe.c	(revision 279)
@@ -0,0 +1,1887 @@
+/*
+ *  TCCPE.C - PE file output for the Tiny C Compiler
+ *
+ *  Copyright (c) 2005-2007 grischka
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+#ifndef _WIN32
+#define stricmp strcasecmp
+#define strnicmp strncasecmp
+#endif
+
+#ifndef MAX_PATH
+#define MAX_PATH 260
+#endif
+
+#define PE_MERGE_DATA
+// #define PE_PRINT_SECTIONS
+
+#ifdef TCC_TARGET_X86_64
+# define ADDR3264 ULONGLONG
+#else
+# define ADDR3264 DWORD
+#endif
+
+#ifdef _WIN32
+void dbg_printf (const char *fmt, ...)
+{
+    char buffer[4000];
+    va_list arg;
+    int x;
+    va_start(arg, fmt);
+    x = vsprintf (buffer, fmt, arg);
+    strcpy(buffer+x, "\n");
+    OutputDebugString(buffer);
+}
+#endif
+
+/* ----------------------------------------------------------- */
+#ifndef IMAGE_NT_SIGNATURE
+/* ----------------------------------------------------------- */
+/* definitions below are from winnt.h */
+
+typedef unsigned char BYTE;
+typedef unsigned short WORD;
+typedef unsigned int DWORD;
+typedef unsigned long long ULONGLONG;
+#pragma pack(push, 1)
+
+typedef struct _IMAGE_DOS_HEADER {  /* DOS .EXE header */
+    WORD e_magic;         /* Magic number */
+    WORD e_cblp;          /* Bytes on last page of file */
+    WORD e_cp;            /* Pages in file */
+    WORD e_crlc;          /* Relocations */
+    WORD e_cparhdr;       /* Size of header in paragraphs */
+    WORD e_minalloc;      /* Minimum extra paragraphs needed */
+    WORD e_maxalloc;      /* Maximum extra paragraphs needed */
+    WORD e_ss;            /* Initial (relative) SS value */
+    WORD e_sp;            /* Initial SP value */
+    WORD e_csum;          /* Checksum */
+    WORD e_ip;            /* Initial IP value */
+    WORD e_cs;            /* Initial (relative) CS value */
+    WORD e_lfarlc;        /* File address of relocation table */
+    WORD e_ovno;          /* Overlay number */
+    WORD e_res[4];        /* Reserved words */
+    WORD e_oemid;         /* OEM identifier (for e_oeminfo) */
+    WORD e_oeminfo;       /* OEM information; e_oemid specific */
+    WORD e_res2[10];      /* Reserved words */
+    DWORD e_lfanew;        /* File address of new exe header */
+} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
+
+#define IMAGE_NT_SIGNATURE  0x00004550  /* PE00 */
+#define SIZE_OF_NT_SIGNATURE 4
+
+typedef struct _IMAGE_FILE_HEADER {
+    WORD    Machine;
+    WORD    NumberOfSections;
+    DWORD   TimeDateStamp;
+    DWORD   PointerToSymbolTable;
+    DWORD   NumberOfSymbols;
+    WORD    SizeOfOptionalHeader;
+    WORD    Characteristics;
+} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
+
+
+#define IMAGE_SIZEOF_FILE_HEADER 20
+
+typedef struct _IMAGE_DATA_DIRECTORY {
+    DWORD   VirtualAddress;
+    DWORD   Size;
+} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
+
+
+typedef struct _IMAGE_OPTIONAL_HEADER {
+    /* Standard fields. */
+    WORD    Magic;
+    BYTE    MajorLinkerVersion;
+    BYTE    MinorLinkerVersion;
+    DWORD   SizeOfCode;
+    DWORD   SizeOfInitializedData;
+    DWORD   SizeOfUninitializedData;
+    DWORD   AddressOfEntryPoint;
+    DWORD   BaseOfCode;
+#ifndef TCC_TARGET_X86_64
+    DWORD   BaseOfData;
+#endif
+    /* NT additional fields. */
+    ADDR3264 ImageBase;
+    DWORD   SectionAlignment;
+    DWORD   FileAlignment;
+    WORD    MajorOperatingSystemVersion;
+    WORD    MinorOperatingSystemVersion;
+    WORD    MajorImageVersion;
+    WORD    MinorImageVersion;
+    WORD    MajorSubsystemVersion;
+    WORD    MinorSubsystemVersion;
+    DWORD   Win32VersionValue;
+    DWORD   SizeOfImage;
+    DWORD   SizeOfHeaders;
+    DWORD   CheckSum;
+    WORD    Subsystem;
+    WORD    DllCharacteristics;
+    ADDR3264 SizeOfStackReserve;
+    ADDR3264 SizeOfStackCommit;
+    ADDR3264 SizeOfHeapReserve;
+    ADDR3264 SizeOfHeapCommit;
+    DWORD   LoaderFlags;
+    DWORD   NumberOfRvaAndSizes;
+    IMAGE_DATA_DIRECTORY DataDirectory[16];
+} IMAGE_OPTIONAL_HEADER32, IMAGE_OPTIONAL_HEADER64, IMAGE_OPTIONAL_HEADER;
+
+#define IMAGE_DIRECTORY_ENTRY_EXPORT          0   /* Export Directory */
+#define IMAGE_DIRECTORY_ENTRY_IMPORT          1   /* Import Directory */
+#define IMAGE_DIRECTORY_ENTRY_RESOURCE        2   /* Resource Directory */
+#define IMAGE_DIRECTORY_ENTRY_EXCEPTION       3   /* Exception Directory */
+#define IMAGE_DIRECTORY_ENTRY_SECURITY        4   /* Security Directory */
+#define IMAGE_DIRECTORY_ENTRY_BASERELOC       5   /* Base Relocation Table */
+#define IMAGE_DIRECTORY_ENTRY_DEBUG           6   /* Debug Directory */
+/*      IMAGE_DIRECTORY_ENTRY_COPYRIGHT       7      (X86 usage) */
+#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE    7   /* Architecture Specific Data */
+#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR       8   /* RVA of GP */
+#define IMAGE_DIRECTORY_ENTRY_TLS             9   /* TLS Directory */
+#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG    10   /* Load Configuration Directory */
+#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT   11   /* Bound Import Directory in headers */
+#define IMAGE_DIRECTORY_ENTRY_IAT            12   /* Import Address Table */
+#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT   13   /* Delay Load Import Descriptors */
+#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14   /* COM Runtime descriptor */
+
+/* Section header format. */
+#define IMAGE_SIZEOF_SHORT_NAME         8
+
+typedef struct _IMAGE_SECTION_HEADER {
+    BYTE    Name[IMAGE_SIZEOF_SHORT_NAME];
+    union {
+            DWORD   PhysicalAddress;
+            DWORD   VirtualSize;
+    } Misc;
+    DWORD   VirtualAddress;
+    DWORD   SizeOfRawData;
+    DWORD   PointerToRawData;
+    DWORD   PointerToRelocations;
+    DWORD   PointerToLinenumbers;
+    WORD    NumberOfRelocations;
+    WORD    NumberOfLinenumbers;
+    DWORD   Characteristics;
+} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
+
+#define IMAGE_SIZEOF_SECTION_HEADER     40
+
+typedef struct _IMAGE_EXPORT_DIRECTORY {
+    DWORD Characteristics;
+    DWORD TimeDateStamp;
+    WORD MajorVersion;
+    WORD MinorVersion;
+    DWORD Name;
+    DWORD Base;
+    DWORD NumberOfFunctions;
+    DWORD NumberOfNames;
+    DWORD AddressOfFunctions;
+    DWORD AddressOfNames;
+    DWORD AddressOfNameOrdinals;
+} IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY;
+
+typedef struct _IMAGE_IMPORT_DESCRIPTOR {
+    union {
+        DWORD Characteristics;
+        DWORD OriginalFirstThunk;
+    };
+    DWORD TimeDateStamp;
+    DWORD ForwarderChain;
+    DWORD Name;
+    DWORD FirstThunk;
+} IMAGE_IMPORT_DESCRIPTOR;
+
+typedef struct _IMAGE_BASE_RELOCATION {
+    DWORD   VirtualAddress;
+    DWORD   SizeOfBlock;
+//  WORD    TypeOffset[1];
+} IMAGE_BASE_RELOCATION;
+
+#define IMAGE_SIZEOF_BASE_RELOCATION     8
+
+#define IMAGE_REL_BASED_ABSOLUTE         0
+#define IMAGE_REL_BASED_HIGH             1
+#define IMAGE_REL_BASED_LOW              2
+#define IMAGE_REL_BASED_HIGHLOW          3
+#define IMAGE_REL_BASED_HIGHADJ          4
+#define IMAGE_REL_BASED_MIPS_JMPADDR     5
+#define IMAGE_REL_BASED_SECTION          6
+#define IMAGE_REL_BASED_REL32            7
+
+#pragma pack(pop)
+
+/* ----------------------------------------------------------- */
+#endif /* ndef IMAGE_NT_SIGNATURE */
+/* ----------------------------------------------------------- */
+#pragma pack(push, 1)
+
+struct pe_header
+{
+    IMAGE_DOS_HEADER doshdr;
+    BYTE dosstub[0x40];
+    DWORD nt_sig;
+    IMAGE_FILE_HEADER filehdr;
+#ifdef TCC_TARGET_X86_64
+    IMAGE_OPTIONAL_HEADER64 opthdr;
+#else
+#ifdef _WIN64
+    IMAGE_OPTIONAL_HEADER32 opthdr;
+#else
+    IMAGE_OPTIONAL_HEADER opthdr;
+#endif
+#endif
+};
+
+struct pe_reloc_header {
+    DWORD offset;
+    DWORD size;
+};
+
+struct pe_rsrc_header {
+    struct _IMAGE_FILE_HEADER filehdr;
+    struct _IMAGE_SECTION_HEADER sectionhdr;
+};
+
+struct pe_rsrc_reloc {
+    DWORD offset;
+    DWORD size;
+    WORD type;
+};
+
+#pragma pack(pop)
+
+/* ------------------------------------------------------------- */
+/* internal temporary structures */
+
+/*
+#define IMAGE_SCN_CNT_CODE                  0x00000020
+#define IMAGE_SCN_CNT_INITIALIZED_DATA      0x00000040
+#define IMAGE_SCN_CNT_UNINITIALIZED_DATA    0x00000080
+#define IMAGE_SCN_MEM_DISCARDABLE           0x02000000
+#define IMAGE_SCN_MEM_SHARED                0x10000000
+#define IMAGE_SCN_MEM_EXECUTE               0x20000000
+#define IMAGE_SCN_MEM_READ                  0x40000000
+#define IMAGE_SCN_MEM_WRITE                 0x80000000
+*/
+
+enum {
+    sec_text = 0,
+    sec_data ,
+    sec_bss ,
+    sec_idata ,
+    sec_pdata ,
+    sec_other ,
+    sec_rsrc ,
+    sec_stab ,
+    sec_reloc ,
+    sec_last
+};
+
+static const DWORD pe_sec_flags[] = {
+    0x60000020, /* ".text"     , */
+    0xC0000040, /* ".data"     , */
+    0xC0000080, /* ".bss"      , */
+    0x40000040, /* ".idata"    , */
+    0x40000040, /* ".pdata"    , */
+    0xE0000060, /* < other >   , */
+    0x40000040, /* ".rsrc"     , */
+    0x42000802, /* ".stab"     , */
+    0x42000040, /* ".reloc"    , */
+};
+
+struct section_info {
+    int cls, ord;
+    char name[32];
+    DWORD sh_addr;
+    DWORD sh_size;
+    DWORD sh_flags;
+    unsigned char *data;
+    DWORD data_size;
+    IMAGE_SECTION_HEADER ish;
+};
+
+struct import_symbol {
+    int sym_index;
+    int iat_index;
+    int thk_offset;
+};
+
+struct pe_import_info {
+    int dll_index;
+    int sym_count;
+    struct import_symbol **symbols;
+};
+
+struct pe_info {
+    TCCState *s1;
+    Section *reloc;
+    Section *thunk;
+    const char *filename;
+    int type;
+    DWORD sizeofheaders;
+    ADDR3264 imagebase;
+    DWORD start_addr;
+    DWORD imp_offs;
+    DWORD imp_size;
+    DWORD iat_offs;
+    DWORD iat_size;
+    DWORD exp_offs;
+    DWORD exp_size;
+    int subsystem;
+    DWORD section_align;
+    DWORD file_align;
+    struct section_info *sec_info;
+    int sec_count;
+    struct pe_import_info **imp_info;
+    int imp_count;
+};
+
+#define PE_NUL 0
+#define PE_DLL 1
+#define PE_GUI 2
+#define PE_EXE 3
+#define PE_RUN 4
+
+/* --------------------------------------------*/
+
+static const char *pe_export_name(TCCState *s1, ElfW(Sym) *sym)
+{
+    const char *name = symtab_section->link->data + sym->st_name;
+    if (s1->leading_underscore && name[0] == '_' && !(sym->st_other & 2))
+        return name + 1;
+    return name;
+}
+
+static int pe_find_import(TCCState * s1, ElfW(Sym) *sym)
+{
+    char buffer[200];
+    const char *s, *p;
+    int sym_index = 0, n = 0;
+
+    do {
+        s = pe_export_name(s1, sym);
+        if (n) {
+            /* second try: */
+	    if (sym->st_other & 2) {
+                /* try w/0 stdcall deco (windows API convention) */
+	        p = strrchr(s, '@');
+	        if (!p || s[0] != '_')
+	            break;
+	        strcpy(buffer, s+1)[p-s-1] = 0;
+	    } else if (s[0] != '_') { /* try non-ansi function */
+	        buffer[0] = '_', strcpy(buffer + 1, s);
+	    } else if (0 == memcmp(s, "__imp__", 7)) { /* mingw 2.0 */
+	        strcpy(buffer, s + 6);
+	    } else if (0 == memcmp(s, "_imp___", 7)) { /* mingw 3.7 */
+	        strcpy(buffer, s + 6);
+	    } else {
+	        break;
+	    }
+	    s = buffer;
+        }
+        sym_index = find_elf_sym(s1->dynsymtab_section, s);
+        // printf("find (%d) %d %s\n", n, sym_index, s);
+    } while (0 == sym_index && ++n < 2);
+    return sym_index;
+}
+
+/*----------------------------------------------------------------------------*/
+
+static int dynarray_assoc(void **pp, int n, int key)
+{
+    int i;
+    for (i = 0; i < n; ++i, ++pp)
+    if (key == **(int **) pp)
+        return i;
+    return -1;
+}
+
+#if 0
+ST_FN DWORD umin(DWORD a, DWORD b)
+{
+    return a < b ? a : b;
+}
+#endif
+
+static DWORD umax(DWORD a, DWORD b)
+{
+    return a < b ? b : a;
+}
+
+static DWORD pe_file_align(struct pe_info *pe, DWORD n)
+{
+    return (n + (pe->file_align - 1)) & ~(pe->file_align - 1);
+}
+
+static DWORD pe_virtual_align(struct pe_info *pe, DWORD n)
+{
+    return (n + (pe->section_align - 1)) & ~(pe->section_align - 1);
+}
+
+static void pe_align_section(Section *s, int a)
+{
+    int i = s->data_offset & (a-1);
+    if (i)
+        section_ptr_add(s, a - i);
+}
+
+static void pe_set_datadir(struct pe_header *hdr, int dir, DWORD addr, DWORD size)
+{
+    hdr->opthdr.DataDirectory[dir].VirtualAddress = addr;
+    hdr->opthdr.DataDirectory[dir].Size = size;
+}
+
+static int pe_fwrite(void *data, unsigned len, FILE *fp, DWORD *psum)
+{
+    if (psum) {
+        DWORD sum = *psum;
+        WORD *p = data;
+        int i;
+        for (i = len; i > 0; i -= 2) {
+            sum += (i >= 2) ? *p++ : *(BYTE*)p;
+            sum = (sum + (sum >> 16)) & 0xFFFF;
+        }
+        *psum = sum;
+    }
+    return len == fwrite(data, 1, len, fp) ? 0 : -1;
+}
+
+static void pe_fpad(FILE *fp, DWORD new_pos)
+{
+    DWORD pos = ftell(fp);
+    while (++pos <= new_pos)
+        fputc(0, fp);
+}
+
+/*----------------------------------------------------------------------------*/
+static int pe_write(struct pe_info *pe)
+{
+    static const struct pe_header pe_template = {
+    {
+    /* IMAGE_DOS_HEADER doshdr */
+    0x5A4D, /*WORD e_magic;         Magic number */
+    0x0090, /*WORD e_cblp;          Bytes on last page of file */
+    0x0003, /*WORD e_cp;            Pages in file */
+    0x0000, /*WORD e_crlc;          Relocations */
+
+    0x0004, /*WORD e_cparhdr;       Size of header in paragraphs */
+    0x0000, /*WORD e_minalloc;      Minimum extra paragraphs needed */
+    0xFFFF, /*WORD e_maxalloc;      Maximum extra paragraphs needed */
+    0x0000, /*WORD e_ss;            Initial (relative) SS value */
+
+    0x00B8, /*WORD e_sp;            Initial SP value */
+    0x0000, /*WORD e_csum;          Checksum */
+    0x0000, /*WORD e_ip;            Initial IP value */
+    0x0000, /*WORD e_cs;            Initial (relative) CS value */
+    0x0040, /*WORD e_lfarlc;        File address of relocation table */
+    0x0000, /*WORD e_ovno;          Overlay number */
+    {0,0,0,0}, /*WORD e_res[4];     Reserved words */
+    0x0000, /*WORD e_oemid;         OEM identifier (for e_oeminfo) */
+    0x0000, /*WORD e_oeminfo;       OEM information; e_oemid specific */
+    {0,0,0,0,0,0,0,0,0,0}, /*WORD e_res2[10];      Reserved words */
+    0x00000080  /*DWORD   e_lfanew;        File address of new exe header */
+    },{
+    /* BYTE dosstub[0x40] */
+    /* 14 code bytes + "This program cannot be run in DOS mode.\r\r\n$" + 6 * 0x00 */
+    0x0e,0x1f,0xba,0x0e,0x00,0xb4,0x09,0xcd,0x21,0xb8,0x01,0x4c,0xcd,0x21,0x54,0x68,
+    0x69,0x73,0x20,0x70,0x72,0x6f,0x67,0x72,0x61,0x6d,0x20,0x63,0x61,0x6e,0x6e,0x6f,
+    0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6e,0x20,0x69,0x6e,0x20,0x44,0x4f,0x53,0x20,
+    0x6d,0x6f,0x64,0x65,0x2e,0x0d,0x0d,0x0a,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+    },
+    0x00004550, /* DWORD nt_sig = IMAGE_NT_SIGNATURE */
+    {
+    /* IMAGE_FILE_HEADER filehdr */
+#if defined(TCC_TARGET_I386)
+    0x014C,   /*WORD    Machine; */
+#elif defined(TCC_TARGET_X86_64)
+    0x8664,   /*WORD    Machine; */
+#elif defined(TCC_TARGET_ARM)
+    0x01C0,   /*WORD    Machine; */
+#endif
+    0x0003, /*WORD    NumberOfSections; */
+    0x00000000, /*DWORD   TimeDateStamp; */
+    0x00000000, /*DWORD   PointerToSymbolTable; */
+    0x00000000, /*DWORD   NumberOfSymbols; */
+#if defined(TCC_TARGET_X86_64)
+    0x00F0, /*WORD    SizeOfOptionalHeader; */
+    0x022F  /*WORD    Characteristics; */
+#define CHARACTERISTICS_DLL 0x222E
+#elif defined(TCC_TARGET_I386)
+    0x00E0, /*WORD    SizeOfOptionalHeader; */
+    0x030F  /*WORD    Characteristics; */
+#define CHARACTERISTICS_DLL 0x230E
+#elif defined(TCC_TARGET_ARM)
+    0x00E0, /*WORD    SizeOfOptionalHeader; */
+    0x010F, /*WORD    Characteristics; */
+#define CHARACTERISTICS_DLL 0x230F
+#endif
+},{
+    /* IMAGE_OPTIONAL_HEADER opthdr */
+    /* Standard fields. */
+#ifdef TCC_TARGET_X86_64
+    0x020B, /*WORD    Magic; */
+#else
+    0x010B, /*WORD    Magic; */
+#endif
+    0x06, /*BYTE    MajorLinkerVersion; */
+    0x00, /*BYTE    MinorLinkerVersion; */
+    0x00000000, /*DWORD   SizeOfCode; */
+    0x00000000, /*DWORD   SizeOfInitializedData; */
+    0x00000000, /*DWORD   SizeOfUninitializedData; */
+    0x00000000, /*DWORD   AddressOfEntryPoint; */
+    0x00000000, /*DWORD   BaseOfCode; */
+#ifndef TCC_TARGET_X86_64
+    0x00000000, /*DWORD   BaseOfData; */
+#endif
+    /* NT additional fields. */
+#if defined(TCC_TARGET_ARM)
+    0x00100000,	    /*DWORD   ImageBase; */
+#else
+    0x00400000,	    /*DWORD   ImageBase; */
+#endif
+    0x00001000, /*DWORD   SectionAlignment; */
+    0x00000200, /*DWORD   FileAlignment; */
+    0x0004, /*WORD    MajorOperatingSystemVersion; */
+    0x0000, /*WORD    MinorOperatingSystemVersion; */
+    0x0000, /*WORD    MajorImageVersion; */
+    0x0000, /*WORD    MinorImageVersion; */
+    0x0004, /*WORD    MajorSubsystemVersion; */
+    0x0000, /*WORD    MinorSubsystemVersion; */
+    0x00000000, /*DWORD   Win32VersionValue; */
+    0x00000000, /*DWORD   SizeOfImage; */
+    0x00000200, /*DWORD   SizeOfHeaders; */
+    0x00000000, /*DWORD   CheckSum; */
+    0x0002, /*WORD    Subsystem; */
+    0x0000, /*WORD    DllCharacteristics; */
+    0x00100000, /*DWORD   SizeOfStackReserve; */
+    0x00001000, /*DWORD   SizeOfStackCommit; */
+    0x00100000, /*DWORD   SizeOfHeapReserve; */
+    0x00001000, /*DWORD   SizeOfHeapCommit; */
+    0x00000000, /*DWORD   LoaderFlags; */
+    0x00000010, /*DWORD   NumberOfRvaAndSizes; */
+
+    /* IMAGE_DATA_DIRECTORY DataDirectory[16]; */
+    {{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
+     {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}}
+    }};
+
+    struct pe_header pe_header = pe_template;
+
+    int i;
+    FILE *op;
+    DWORD file_offset, sum;
+    struct section_info *si;
+    IMAGE_SECTION_HEADER *psh;
+
+    op = fopen(pe->filename, "wb");
+    if (NULL == op) {
+        tcc_error_noabort("could not write '%s': %s", pe->filename, strerror(errno));
+        return -1;
+    }
+
+    pe->sizeofheaders = pe_file_align(pe,
+        sizeof (struct pe_header)
+        + pe->sec_count * sizeof (IMAGE_SECTION_HEADER)
+        );
+
+    file_offset = pe->sizeofheaders;
+
+    if (2 == pe->s1->verbose)
+        printf("-------------------------------"
+               "\n  virt   file   size  section" "\n");
+    for (i = 0; i < pe->sec_count; ++i) {
+        DWORD addr, size;
+        const char *sh_name;
+
+        si = pe->sec_info + i;
+        sh_name = si->name;
+        addr = si->sh_addr - pe->imagebase;
+        size = si->sh_size;
+        psh = &si->ish;
+
+        if (2 == pe->s1->verbose)
+            printf("%6x %6x %6x  %s\n",
+                (unsigned)addr, (unsigned)file_offset, (unsigned)size, sh_name);
+
+        switch (si->cls) {
+            case sec_text:
+                pe_header.opthdr.BaseOfCode = addr;
+                pe_header.opthdr.AddressOfEntryPoint = addr + pe->start_addr;
+                break;
+
+            case sec_data:
+#ifndef TCC_TARGET_X86_64
+                pe_header.opthdr.BaseOfData = addr;
+#endif
+                break;
+
+            case sec_bss:
+                break;
+
+            case sec_reloc:
+                pe_set_datadir(&pe_header, IMAGE_DIRECTORY_ENTRY_BASERELOC, addr, size);
+                break;
+
+            case sec_rsrc:
+                pe_set_datadir(&pe_header, IMAGE_DIRECTORY_ENTRY_RESOURCE, addr, size);
+                break;
+
+            case sec_pdata:
+                pe_set_datadir(&pe_header, IMAGE_DIRECTORY_ENTRY_EXCEPTION, addr, size);
+                break;
+
+            case sec_stab:
+                break;
+        }
+
+        if (pe->thunk == pe->s1->sections[si->ord]) {
+            if (pe->imp_size) {
+                pe_set_datadir(&pe_header, IMAGE_DIRECTORY_ENTRY_IMPORT,
+                    pe->imp_offs + addr, pe->imp_size);
+                pe_set_datadir(&pe_header, IMAGE_DIRECTORY_ENTRY_IAT,
+                    pe->iat_offs + addr, pe->iat_size);
+            }
+            if (pe->exp_size) {
+                pe_set_datadir(&pe_header, IMAGE_DIRECTORY_ENTRY_EXPORT,
+                    pe->exp_offs + addr, pe->exp_size);
+            }
+        }
+
+        pstrcpy((char*)psh->Name, sizeof psh->Name, sh_name);
+
+        psh->Characteristics = pe_sec_flags[si->cls];
+        psh->VirtualAddress = addr;
+        psh->Misc.VirtualSize = size;
+        pe_header.opthdr.SizeOfImage =
+            umax(pe_virtual_align(pe, size + addr), pe_header.opthdr.SizeOfImage);
+
+        if (si->data_size) {
+            psh->PointerToRawData = file_offset;
+            file_offset = pe_file_align(pe, file_offset + si->data_size);
+            psh->SizeOfRawData = file_offset - psh->PointerToRawData;
+        }
+    }
+
+    //pe_header.filehdr.TimeDateStamp = time(NULL);
+    pe_header.filehdr.NumberOfSections = pe->sec_count;
+    pe_header.opthdr.SizeOfHeaders = pe->sizeofheaders;
+    pe_header.opthdr.ImageBase = pe->imagebase;
+    pe_header.opthdr.Subsystem = pe->subsystem;
+    if (pe->s1->pe_stack_size)
+        pe_header.opthdr.SizeOfStackReserve = pe->s1->pe_stack_size;
+    if (PE_DLL == pe->type)
+        pe_header.filehdr.Characteristics = CHARACTERISTICS_DLL;
+
+    sum = 0;
+    pe_fwrite(&pe_header, sizeof pe_header, op, &sum);
+    for (i = 0; i < pe->sec_count; ++i)
+        pe_fwrite(&pe->sec_info[i].ish, sizeof(IMAGE_SECTION_HEADER), op, &sum);
+    pe_fpad(op, pe->sizeofheaders);
+    for (i = 0; i < pe->sec_count; ++i) {
+        si = pe->sec_info + i;
+        psh = &si->ish;
+        if (si->data_size) {
+            pe_fwrite(si->data, si->data_size, op, &sum);
+            file_offset = psh->PointerToRawData + psh->SizeOfRawData;
+            pe_fpad(op, file_offset);
+        }
+    }
+
+    pe_header.opthdr.CheckSum = sum + file_offset;
+    fseek(op, offsetof(struct pe_header, opthdr.CheckSum), SEEK_SET);
+    pe_fwrite(&pe_header.opthdr.CheckSum, sizeof pe_header.opthdr.CheckSum, op, NULL);
+    fclose (op);
+
+    if (2 == pe->s1->verbose)
+        printf("-------------------------------\n");
+    if (pe->s1->verbose)
+        printf("<- %s (%u bytes)\n", pe->filename, (unsigned)file_offset);
+
+    return 0;
+}
+
+/*----------------------------------------------------------------------------*/
+
+#if defined(TCC_TARGET_X86_64)
+#define REL_TYPE_DIRECT R_X86_64_64
+#define R_XXX_THUNKFIX R_X86_64_PC32
+#define R_XXX_RELATIVE R_X86_64_RELATIVE
+
+#elif defined(TCC_TARGET_I386)
+#define REL_TYPE_DIRECT R_386_32
+#define R_XXX_THUNKFIX R_386_32
+#define R_XXX_RELATIVE R_386_RELATIVE
+
+#elif defined(TCC_TARGET_ARM)
+#define REL_TYPE_DIRECT R_ARM_ABS32
+#define R_XXX_THUNKFIX R_ARM_ABS32
+#define R_XXX_RELATIVE R_ARM_RELATIVE
+
+#endif
+/*----------------------------------------------------------------------------*/
+
+static struct import_symbol *pe_add_import(struct pe_info *pe, int sym_index)
+{
+    int i;
+    int dll_index;
+    struct pe_import_info *p;
+    struct import_symbol *s;
+    ElfW(Sym) *isym;
+
+    isym = (ElfW(Sym) *)pe->s1->dynsymtab_section->data + sym_index;
+    dll_index = isym->st_size;
+
+    i = dynarray_assoc ((void**)pe->imp_info, pe->imp_count, dll_index);
+    if (-1 != i) {
+        p = pe->imp_info[i];
+        goto found_dll;
+    }
+    p = tcc_mallocz(sizeof *p);
+    p->dll_index = dll_index;
+    dynarray_add((void***)&pe->imp_info, &pe->imp_count, p);
+
+found_dll:
+    i = dynarray_assoc ((void**)p->symbols, p->sym_count, sym_index);
+    if (-1 != i)
+        return p->symbols[i];
+
+    s = tcc_mallocz(sizeof *s);
+    dynarray_add((void***)&p->symbols, &p->sym_count, s);
+    s->sym_index = sym_index;
+    return s;
+}
+
+/*----------------------------------------------------------------------------*/
+static void pe_build_imports(struct pe_info *pe)
+{
+    int thk_ptr, ent_ptr, dll_ptr, sym_cnt, i;
+    DWORD rva_base = pe->thunk->sh_addr - pe->imagebase;
+    int ndlls = pe->imp_count;
+
+    for (sym_cnt = i = 0; i < ndlls; ++i)
+        sym_cnt += pe->imp_info[i]->sym_count;
+
+    if (0 == sym_cnt)
+        return;
+
+    pe_align_section(pe->thunk, 16);
+
+    pe->imp_offs = dll_ptr = pe->thunk->data_offset;
+    pe->imp_size = (ndlls + 1) * sizeof(IMAGE_IMPORT_DESCRIPTOR);
+    pe->iat_offs = dll_ptr + pe->imp_size;
+    pe->iat_size = (sym_cnt + ndlls) * sizeof(ADDR3264);
+    section_ptr_add(pe->thunk, pe->imp_size + 2*pe->iat_size);
+
+    thk_ptr = pe->iat_offs;
+    ent_ptr = pe->iat_offs + pe->iat_size;
+
+    for (i = 0; i < pe->imp_count; ++i) {
+        IMAGE_IMPORT_DESCRIPTOR *hdr;
+        int k, n, dllindex;
+        ADDR3264 v;
+        struct pe_import_info *p = pe->imp_info[i];
+        const char *name;
+        DLLReference *dllref;
+
+        dllindex = p->dll_index;
+        if (dllindex)
+            name = (dllref = pe->s1->loaded_dlls[dllindex-1])->name;
+        else
+            name = "", dllref = NULL;
+
+        /* put the dll name into the import header */
+        v = put_elf_str(pe->thunk, name);
+        hdr = (IMAGE_IMPORT_DESCRIPTOR*)(pe->thunk->data + dll_ptr);
+        hdr->FirstThunk = thk_ptr + rva_base;
+        hdr->OriginalFirstThunk = ent_ptr + rva_base;
+        hdr->Name = v + rva_base;
+
+        for (k = 0, n = p->sym_count; k <= n; ++k) {
+            if (k < n) {
+                int iat_index = p->symbols[k]->iat_index;
+                int sym_index = p->symbols[k]->sym_index;
+                ElfW(Sym) *imp_sym = (ElfW(Sym) *)pe->s1->dynsymtab_section->data + sym_index;
+                ElfW(Sym) *org_sym = (ElfW(Sym) *)symtab_section->data + iat_index;
+                const char *name = pe->s1->dynsymtab_section->link->data + imp_sym->st_name;
+
+                org_sym->st_value = thk_ptr;
+                org_sym->st_shndx = pe->thunk->sh_num;
+                v = pe->thunk->data_offset + rva_base;
+                section_ptr_add(pe->thunk, sizeof(WORD)); /* hint, not used */
+                put_elf_str(pe->thunk, name);
+#ifdef TCC_IS_NATIVE
+                if (pe->type == PE_RUN) {
+                    v = imp_sym->st_value;
+                    if (dllref) {
+                        if ( !dllref->handle )
+                            dllref->handle = LoadLibrary(dllref->name);
+                        v = (ADDR3264)GetProcAddress(dllref->handle, name);
+                    }
+                    if (!v)
+                        tcc_error_noabort("undefined symbol '%s'", name);
+                }
+#endif
+            } else {
+                v = 0; /* last entry is zero */
+            }
+            *(ADDR3264*)(pe->thunk->data+thk_ptr) =
+            *(ADDR3264*)(pe->thunk->data+ent_ptr) = v;
+            thk_ptr += sizeof (ADDR3264);
+            ent_ptr += sizeof (ADDR3264);
+        }
+        dll_ptr += sizeof(IMAGE_IMPORT_DESCRIPTOR);
+        dynarray_reset(&p->symbols, &p->sym_count);
+    }
+    dynarray_reset(&pe->imp_info, &pe->imp_count);
+}
+
+/* ------------------------------------------------------------- */
+
+struct pe_sort_sym
+{
+    int index;
+    const char *name;
+};
+
+static int sym_cmp(const void *va, const void *vb)
+{
+    const char *ca = (*(struct pe_sort_sym**)va)->name;
+    const char *cb = (*(struct pe_sort_sym**)vb)->name;
+    return strcmp(ca, cb);
+}
+
+static void pe_build_exports(struct pe_info *pe)
+{
+    ElfW(Sym) *sym;
+    int sym_index, sym_end;
+    DWORD rva_base, func_o, name_o, ord_o, str_o;
+    IMAGE_EXPORT_DIRECTORY *hdr;
+    int sym_count, ord;
+    struct pe_sort_sym **sorted, *p;
+
+    FILE *op;
+    char buf[MAX_PATH];
+    const char *dllname;
+    const char *name;
+
+    rva_base = pe->thunk->sh_addr - pe->imagebase;
+    sym_count = 0, sorted = NULL, op = NULL;
+
+    sym_end = symtab_section->data_offset / sizeof(ElfW(Sym));
+    for (sym_index = 1; sym_index < sym_end; ++sym_index) {
+        sym = (ElfW(Sym)*)symtab_section->data + sym_index;
+        name = pe_export_name(pe->s1, sym);
+        if ((sym->st_other & 1)
+            /* export only symbols from actually written sections */
+            && pe->s1->sections[sym->st_shndx]->sh_addr) {
+            p = tcc_malloc(sizeof *p);
+            p->index = sym_index;
+            p->name = name;
+            dynarray_add((void***)&sorted, &sym_count, p);
+        }
+#if 0
+        if (sym->st_other & 1)
+            printf("export: %s\n", name);
+        if (sym->st_other & 2)
+            printf("stdcall: %s\n", name);
+#endif
+    }
+
+    if (0 == sym_count)
+        return;
+
+    qsort (sorted, sym_count, sizeof *sorted, sym_cmp);
+
+    pe_align_section(pe->thunk, 16);
+    dllname = tcc_basename(pe->filename);
+
+    pe->exp_offs = pe->thunk->data_offset;
+    func_o = pe->exp_offs + sizeof(IMAGE_EXPORT_DIRECTORY);
+    name_o = func_o + sym_count * sizeof (DWORD);
+    ord_o = name_o + sym_count * sizeof (DWORD);
+    str_o = ord_o + sym_count * sizeof(WORD);
+
+    hdr = section_ptr_add(pe->thunk, str_o - pe->exp_offs);
+    hdr->Characteristics        = 0;
+    hdr->Base                   = 1;
+    hdr->NumberOfFunctions      = sym_count;
+    hdr->NumberOfNames          = sym_count;
+    hdr->AddressOfFunctions     = func_o + rva_base;
+    hdr->AddressOfNames         = name_o + rva_base;
+    hdr->AddressOfNameOrdinals  = ord_o + rva_base;
+    hdr->Name                   = str_o + rva_base;
+    put_elf_str(pe->thunk, dllname);
+
+#if 1
+    /* automatically write exports to <output-filename>.def */
+    pstrcpy(buf, sizeof buf, pe->filename);
+    strcpy(tcc_fileextension(buf), ".def");
+    op = fopen(buf, "w");
+    if (NULL == op) {
+        tcc_error_noabort("could not create '%s': %s", buf, strerror(errno));
+    } else {
+        fprintf(op, "LIBRARY %s\n\nEXPORTS\n", dllname);
+        if (pe->s1->verbose)
+            printf("<- %s (%d symbols)\n", buf, sym_count);
+    }
+#endif
+
+    for (ord = 0; ord < sym_count; ++ord)
+    {
+        p = sorted[ord], sym_index = p->index, name = p->name;
+        /* insert actual address later in pe_relocate_rva */
+        put_elf_reloc(symtab_section, pe->thunk,
+            func_o, R_XXX_RELATIVE, sym_index);
+        *(DWORD*)(pe->thunk->data + name_o)
+            = pe->thunk->data_offset + rva_base;
+        *(WORD*)(pe->thunk->data + ord_o)
+            = ord;
+        put_elf_str(pe->thunk, name);
+        func_o += sizeof (DWORD);
+        name_o += sizeof (DWORD);
+        ord_o += sizeof (WORD);
+        if (op)
+            fprintf(op, "%s\n", name);
+    }
+    pe->exp_size = pe->thunk->data_offset - pe->exp_offs;
+    dynarray_reset(&sorted, &sym_count);
+    if (op)
+        fclose(op);
+}
+
+/* ------------------------------------------------------------- */
+static void pe_build_reloc (struct pe_info *pe)
+{
+    DWORD offset, block_ptr, addr;
+    int count, i;
+    ElfW_Rel *rel, *rel_end;
+    Section *s = NULL, *sr;
+
+    offset = addr = block_ptr = count = i = 0;
+    rel = rel_end = NULL;
+
+    for(;;) {
+        if (rel < rel_end) {
+            int type = ELFW(R_TYPE)(rel->r_info);
+            addr = rel->r_offset + s->sh_addr;
+            ++ rel;
+            if (type != REL_TYPE_DIRECT)
+                continue;
+            if (count == 0) { /* new block */
+                block_ptr = pe->reloc->data_offset;
+                section_ptr_add(pe->reloc, sizeof(struct pe_reloc_header));
+                offset = addr & 0xFFFFFFFF<<12;
+            }
+            if ((addr -= offset)  < (1<<12)) { /* one block spans 4k addresses */
+                WORD *wp = section_ptr_add(pe->reloc, sizeof (WORD));
+                *wp = addr | IMAGE_REL_BASED_HIGHLOW<<12;
+                ++count;
+                continue;
+            }
+            -- rel;
+
+        } else if (i < pe->sec_count) {
+            sr = (s = pe->s1->sections[pe->sec_info[i++].ord])->reloc;
+            if (sr) {
+                rel = (ElfW_Rel *)sr->data;
+                rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
+            }
+            continue;
+        }
+
+        if (count) {
+            /* store the last block and ready for a new one */
+            struct pe_reloc_header *hdr;
+            if (count & 1) /* align for DWORDS */
+                section_ptr_add(pe->reloc, sizeof(WORD)), ++count;
+            hdr = (struct pe_reloc_header *)(pe->reloc->data + block_ptr);
+            hdr -> offset = offset - pe->imagebase;
+            hdr -> size = count * sizeof(WORD) + sizeof(struct pe_reloc_header);
+            count = 0;
+        }
+
+        if (rel >= rel_end)
+            break;
+    }
+}
+
+/* ------------------------------------------------------------- */
+static int pe_section_class(Section *s)
+{
+    int type, flags;
+    const char *name;
+
+    type = s->sh_type;
+    flags = s->sh_flags;
+    name = s->name;
+    if (flags & SHF_ALLOC) {
+        if (type == SHT_PROGBITS) {
+            if (flags & SHF_EXECINSTR)
+                return sec_text;
+            if (flags & SHF_WRITE)
+                return sec_data;
+            if (0 == strcmp(name, ".rsrc"))
+                return sec_rsrc;
+            if (0 == strcmp(name, ".iedat"))
+                return sec_idata;
+            if (0 == strcmp(name, ".pdata"))
+                return sec_pdata;
+            return sec_other;
+        } else if (type == SHT_NOBITS) {
+            if (flags & SHF_WRITE)
+                return sec_bss;
+        }
+    } else {
+        if (0 == strcmp(name, ".reloc"))
+            return sec_reloc;
+        if (0 == strncmp(name, ".stab", 5)) /* .stab and .stabstr */
+            return sec_stab;
+    }
+    return -1;
+}
+
+static int pe_assign_addresses (struct pe_info *pe)
+{
+    int i, k, o, c;
+    DWORD addr;
+    int *section_order;
+    struct section_info *si;
+    Section *s;
+
+    // pe->thunk = new_section(pe->s1, ".iedat", SHT_PROGBITS, SHF_ALLOC);
+
+    section_order = tcc_malloc(pe->s1->nb_sections * sizeof (int));
+    for (o = k = 0 ; k < sec_last; ++k) {
+        for (i = 1; i < pe->s1->nb_sections; ++i) {
+            s = pe->s1->sections[i];
+            if (k == pe_section_class(s)) {
+                // printf("%s %d\n", s->name, k);
+                s->sh_addr = pe->imagebase;
+                section_order[o++] = i;
+            }
+        }
+    }
+
+    pe->sec_info = tcc_mallocz(o * sizeof (struct section_info));
+    addr = pe->imagebase + 1;
+
+    for (i = 0; i < o; ++i)
+    {
+        k = section_order[i];
+        s = pe->s1->sections[k];
+        c = pe_section_class(s);
+        si = &pe->sec_info[pe->sec_count];
+
+#ifdef PE_MERGE_DATA
+        if (c == sec_bss && pe->sec_count && si[-1].cls == sec_data) {
+            /* append .bss to .data */
+            s->sh_addr = addr = ((addr-1) | (s->sh_addralign-1)) + 1;
+            addr += s->data_offset;
+            si[-1].sh_size = addr - si[-1].sh_addr;
+            continue;
+        }
+#endif
+        if (c == sec_stab && 0 == pe->s1->do_debug)
+            continue;
+
+        strcpy(si->name, s->name);
+        si->cls = c;
+        si->ord = k;
+        si->sh_addr = s->sh_addr = addr = pe_virtual_align(pe, addr);
+        si->sh_flags = s->sh_flags;
+
+        if (c == sec_data && NULL == pe->thunk)
+            pe->thunk = s;
+
+        if (s == pe->thunk) {
+            pe_build_imports(pe);
+            pe_build_exports(pe);
+        }
+
+        if (c == sec_reloc)
+            pe_build_reloc (pe);
+
+        if (s->data_offset)
+        {
+            if (s->sh_type != SHT_NOBITS) {
+                si->data = s->data;
+                si->data_size = s->data_offset;
+            }
+
+            addr += s->data_offset;
+            si->sh_size = s->data_offset;
+            ++pe->sec_count;
+        }
+        // printf("%08x %05x %s\n", si->sh_addr, si->sh_size, si->name);
+    }
+
+#if 0
+    for (i = 1; i < pe->s1->nb_sections; ++i) {
+        Section *s = pe->s1->sections[i];
+        int type = s->sh_type;
+        int flags = s->sh_flags;
+        printf("section %-16s %-10s %5x %s,%s,%s\n",
+            s->name,
+            type == SHT_PROGBITS ? "progbits" :
+            type == SHT_NOBITS ? "nobits" :
+            type == SHT_SYMTAB ? "symtab" :
+            type == SHT_STRTAB ? "strtab" :
+            type == SHT_RELX ? "rel" : "???",
+            s->data_offset,
+            flags & SHF_ALLOC ? "alloc" : "",
+            flags & SHF_WRITE ? "write" : "",
+            flags & SHF_EXECINSTR ? "exec" : ""
+            );
+    }
+    pe->s1->verbose = 2;
+#endif
+
+    tcc_free(section_order);
+    return 0;
+}
+
+/* ------------------------------------------------------------- */
+static void pe_relocate_rva (struct pe_info *pe, Section *s)
+{
+    Section *sr = s->reloc;
+    ElfW_Rel *rel, *rel_end;
+    rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
+    for(rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) {
+        if (ELFW(R_TYPE)(rel->r_info) == R_XXX_RELATIVE) {
+            int sym_index = ELFW(R_SYM)(rel->r_info);
+            DWORD addr = s->sh_addr;
+            if (sym_index) {
+                ElfW(Sym) *sym = (ElfW(Sym) *)symtab_section->data + sym_index;
+                addr = sym->st_value;
+            }
+            // printf("reloc rva %08x %08x %s\n", (DWORD)rel->r_offset, addr, s->name);
+            *(DWORD*)(s->data + rel->r_offset) += addr - pe->imagebase;
+        }
+    }
+}
+
+/*----------------------------------------------------------------------------*/
+
+static int pe_isafunc(int sym_index)
+{
+    Section *sr = text_section->reloc;
+    ElfW_Rel *rel, *rel_end;
+    Elf32_Word info = ELF32_R_INFO(sym_index, R_386_PC32);
+    if (!sr)
+        return 0;
+    rel_end = (ElfW_Rel *)(sr->data + sr->data_offset);
+    for (rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++)
+        if (rel->r_info == info)
+            return 1;
+    return 0;
+}
+
+/*----------------------------------------------------------------------------*/
+static int pe_check_symbols(struct pe_info *pe)
+{
+    ElfW(Sym) *sym;
+    int sym_index, sym_end;
+    int ret = 0;
+
+    pe_align_section(text_section, 8);
+
+    sym_end = symtab_section->data_offset / sizeof(ElfW(Sym));
+    for (sym_index = 1; sym_index < sym_end; ++sym_index) {
+
+        sym = (ElfW(Sym) *)symtab_section->data + sym_index;
+        if (sym->st_shndx == SHN_UNDEF) {
+
+            const char *name = symtab_section->link->data + sym->st_name;
+            unsigned type = ELFW(ST_TYPE)(sym->st_info);
+            int imp_sym = pe_find_import(pe->s1, sym);
+            struct import_symbol *is;
+
+            if (0 == imp_sym)
+                goto not_found;
+
+            if (type == STT_NOTYPE) {
+                /* symbols from assembler have no type, find out which */
+                if (pe_isafunc(sym_index))
+                    type = STT_FUNC;
+                else
+                    type = STT_OBJECT;
+            }
+
+            is = pe_add_import(pe, imp_sym);
+
+            if (type == STT_FUNC) {
+                unsigned long offset = is->thk_offset;
+                if (offset) {
+                    /* got aliased symbol, like stricmp and _stricmp */
+
+                } else {
+                    char buffer[100];
+                    WORD *p;
+
+                    offset = text_section->data_offset;
+                    /* add the 'jmp IAT[x]' instruction */
+#ifdef TCC_TARGET_ARM
+                    p = section_ptr_add(text_section, 8+4); // room for code and address
+                    (*(DWORD*)(p)) = 0xE59FC000; // arm code ldr ip, [pc] ; PC+8+0 = 0001xxxx
+                    (*(DWORD*)(p+2)) = 0xE59CF000; // arm code ldr pc, [ip]
+#else
+                    p = section_ptr_add(text_section, 8);
+                    *p = 0x25FF;
+#ifdef TCC_TARGET_X86_64
+                    *(DWORD*)(p+1) = (DWORD)-4;
+#endif
+#endif
+                    /* add a helper symbol, will be patched later in
+                       pe_build_imports */
+                    sprintf(buffer, "IAT.%s", name);
+                    is->iat_index = put_elf_sym(
+                        symtab_section, 0, sizeof(DWORD),
+                        ELFW(ST_INFO)(STB_GLOBAL, STT_OBJECT),
+                        0, SHN_UNDEF, buffer);
+#ifdef TCC_TARGET_ARM
+                    put_elf_reloc(symtab_section, text_section,
+                        offset + 8, R_XXX_THUNKFIX, is->iat_index); // offset to IAT position
+#else
+                    put_elf_reloc(symtab_section, text_section, 
+                        offset + 2, R_XXX_THUNKFIX, is->iat_index);
+#endif
+                    is->thk_offset = offset;
+                }
+
+                /* tcc_realloc might have altered sym's address */
+                sym = (ElfW(Sym) *)symtab_section->data + sym_index;
+
+                /* patch the original symbol */
+                sym->st_value = offset;
+                sym->st_shndx = text_section->sh_num;
+                sym->st_other &= ~1; /* do not export */
+                continue;
+            }
+
+            if (type == STT_OBJECT) { /* data, ptr to that should be */
+                if (0 == is->iat_index) {
+                    /* original symbol will be patched later in pe_build_imports */
+                    is->iat_index = sym_index;
+                    continue;
+                }
+            }
+
+        not_found:
+            tcc_error_noabort("undefined symbol '%s'", name);
+            ret = -1;
+
+        } else if (pe->s1->rdynamic
+                   && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) {
+            /* if -rdynamic option, then export all non local symbols */
+            sym->st_other |= 1;
+        }
+    }
+    return ret;
+}
+
+/*----------------------------------------------------------------------------*/
+#ifdef PE_PRINT_SECTIONS
+static void pe_print_section(FILE * f, Section * s)
+{
+    /* just if you'r curious */
+    BYTE *p, *e, b;
+    int i, n, l, m;
+    p = s->data;
+    e = s->data + s->data_offset;
+    l = e - p;
+
+    fprintf(f, "section  \"%s\"", s->name);
+    if (s->link)
+        fprintf(f, "\nlink     \"%s\"", s->link->name);
+    if (s->reloc)
+        fprintf(f, "\nreloc    \"%s\"", s->reloc->name);
+    fprintf(f, "\nv_addr   %08X", (unsigned)s->sh_addr);
+    fprintf(f, "\ncontents %08X", (unsigned)l);
+    fprintf(f, "\n\n");
+
+    if (s->sh_type == SHT_NOBITS)
+        return;
+
+    if (0 == l)
+        return;
+
+    if (s->sh_type == SHT_SYMTAB)
+        m = sizeof(ElfW(Sym));
+    else if (s->sh_type == SHT_RELX)
+        m = sizeof(ElfW_Rel);
+    else
+        m = 16;
+
+    fprintf(f, "%-8s", "offset");
+    for (i = 0; i < m; ++i)
+        fprintf(f, " %02x", i);
+    n = 56;
+
+    if (s->sh_type == SHT_SYMTAB || s->sh_type == SHT_RELX) {
+        const char *fields1[] = {
+            "name",
+            "value",
+            "size",
+            "bind",
+            "type",
+            "other",
+            "shndx",
+            NULL
+        };
+
+        const char *fields2[] = {
+            "offs",
+            "type",
+            "symb",
+            NULL
+        };
+
+        const char **p;
+
+        if (s->sh_type == SHT_SYMTAB)
+            p = fields1, n = 106;
+        else
+            p = fields2, n = 58;
+
+        for (i = 0; p[i]; ++i)
+            fprintf(f, "%6s", p[i]);
+        fprintf(f, "  symbol");
+    }
+
+    fprintf(f, "\n");
+    for (i = 0; i < n; ++i)
+        fprintf(f, "-");
+    fprintf(f, "\n");
+
+    for (i = 0; i < l;)
+    {
+        fprintf(f, "%08X", i);
+        for (n = 0; n < m; ++n) {
+            if (n + i < l)
+                fprintf(f, " %02X", p[i + n]);
+            else
+                fprintf(f, "   ");
+        }
+
+        if (s->sh_type == SHT_SYMTAB) {
+            ElfW(Sym) *sym = (ElfW(Sym) *) (p + i);
+            const char *name = s->link->data + sym->st_name;
+            fprintf(f, "  %04X  %04X  %04X   %02X    %02X    %02X   %04X  \"%s\"",
+                    (unsigned)sym->st_name,
+                    (unsigned)sym->st_value,
+                    (unsigned)sym->st_size,
+                    (unsigned)ELFW(ST_BIND)(sym->st_info),
+                    (unsigned)ELFW(ST_TYPE)(sym->st_info),
+                    (unsigned)sym->st_other,
+                    (unsigned)sym->st_shndx,
+                    name);
+
+        } else if (s->sh_type == SHT_RELX) {
+            ElfW_Rel *rel = (ElfW_Rel *) (p + i);
+            ElfW(Sym) *sym =
+                (ElfW(Sym) *) s->link->data + ELFW(R_SYM)(rel->r_info);
+            const char *name = s->link->link->data + sym->st_name;
+            fprintf(f, "  %04X   %02X   %04X  \"%s\"",
+                    (unsigned)rel->r_offset,
+                    (unsigned)ELFW(R_TYPE)(rel->r_info),
+                    (unsigned)ELFW(R_SYM)(rel->r_info),
+                    name);
+        } else {
+            fprintf(f, "   ");
+            for (n = 0; n < m; ++n) {
+                if (n + i < l) {
+                    b = p[i + n];
+                    if (b < 32 || b >= 127)
+                        b = '.';
+                    fprintf(f, "%c", b);
+                }
+            }
+        }
+        i += m;
+        fprintf(f, "\n");
+    }
+    fprintf(f, "\n\n");
+}
+
+static void pe_print_sections(TCCState *s1, const char *fname)
+{
+    Section *s;
+    FILE *f;
+    int i;
+    f = fopen(fname, "w");
+    for (i = 1; i < s1->nb_sections; ++i) {
+        s = s1->sections[i];
+        pe_print_section(f, s);
+    }
+    pe_print_section(f, s1->dynsymtab_section);
+    fclose(f);
+}
+#endif
+
+/* ------------------------------------------------------------- */
+/* helper function for load/store to insert one more indirection */
+
+ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2)
+{
+    Sym *sym;
+    ElfW(Sym) *esym;
+    int r2;
+
+    if ((sv->r & (VT_VALMASK|VT_SYM)) != (VT_CONST|VT_SYM) || (sv->r2 != VT_CONST))
+        return sv;
+    sym = sv->sym;
+    if ((sym->type.t & (VT_EXTERN|VT_STATIC)) != VT_EXTERN)
+        return sv;
+    if (!sym->c)
+        put_extern_sym(sym, NULL, 0, 0);
+    esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
+    if (!(esym->st_other & 4))
+        return sv;
+
+    // printf("import %04x %04x %04x %s\n", sv->type.t, sym->type.t, sv->r, get_tok_str(sv->sym->v, NULL));
+
+    memset(v2, 0, sizeof *v2);
+    v2->type.t = VT_PTR;
+    v2->r = VT_CONST | VT_SYM | VT_LVAL;
+    v2->sym = sv->sym;
+
+    r2 = get_reg(RC_INT);
+    load(r2, v2);
+    v2->r = r2;
+
+    if (sv->c.ui) {
+        vpushv(v2);
+        vpushi(sv->c.ui);
+        gen_opi('+');
+        *v2 = *vtop--;
+    }
+
+    v2->type.t = sv->type.t;
+    v2->r |= sv->r & VT_LVAL;
+    return v2;
+}
+
+ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value)
+{
+    return add_elf_sym(
+        s1->dynsymtab_section,
+        value,
+        dllindex, /* st_size */
+        ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE),
+        0,
+        value ? SHN_ABS : SHN_UNDEF,
+        name
+        );
+}
+
+static int add_dllref(TCCState *s1, const char *dllname)
+{
+    DLLReference *dllref;
+    int i;
+    for (i = 0; i < s1->nb_loaded_dlls; ++i)
+        if (0 == strcmp(s1->loaded_dlls[i]->name, dllname))
+            return i + 1;
+    dllref = tcc_mallocz(sizeof(DLLReference) + strlen(dllname));
+    strcpy(dllref->name, dllname);
+    dynarray_add((void ***) &s1->loaded_dlls, &s1->nb_loaded_dlls, dllref);
+    return s1->nb_loaded_dlls;
+}
+
+/* ------------------------------------------------------------- */
+
+static int read_mem(int fd, unsigned offset, void *buffer, unsigned len)
+{
+    lseek(fd, offset, SEEK_SET);
+    return len == read(fd, buffer, len);
+}
+
+/* -------------------------------------------------------------
+ *  This is for compiled windows resources in 'coff' format
+ *  as generated by 'windres.exe -O coff ...'.
+ */
+
+static int pe_load_res(TCCState *s1, int fd)
+{
+    struct pe_rsrc_header hdr;
+    Section *rsrc_section;
+    int i, ret = -1;
+    BYTE *ptr;
+    unsigned offs;
+
+    if (!read_mem(fd, 0, &hdr, sizeof hdr))
+        goto quit;
+
+    if (hdr.filehdr.Machine != 0x014C
+        || hdr.filehdr.NumberOfSections != 1
+        || strcmp(hdr.sectionhdr.Name, ".rsrc") != 0)
+        goto quit;
+
+    rsrc_section = new_section(s1, ".rsrc", SHT_PROGBITS, SHF_ALLOC);
+    ptr = section_ptr_add(rsrc_section, hdr.sectionhdr.SizeOfRawData);
+    offs = hdr.sectionhdr.PointerToRawData;
+    if (!read_mem(fd, offs, ptr, hdr.sectionhdr.SizeOfRawData))
+        goto quit;
+    offs = hdr.sectionhdr.PointerToRelocations;
+    for (i = 0; i < hdr.sectionhdr.NumberOfRelocations; ++i)
+    {
+        struct pe_rsrc_reloc rel;
+        if (!read_mem(fd, offs, &rel, sizeof rel))
+            goto quit;
+        // printf("rsrc_reloc: %x %x %x\n", rel.offset, rel.size, rel.type);
+        if (rel.type != 7) /* DIR32NB */
+            goto quit;
+        put_elf_reloc(symtab_section, rsrc_section,
+            rel.offset, R_XXX_RELATIVE, 0);
+        offs += sizeof rel;
+    }
+    ret = 0;
+quit:
+    return ret;
+}
+
+/* ------------------------------------------------------------- */
+static char *trimfront(char *p)
+{
+    while (*p && (unsigned char)*p <= ' ')
+        ++p;
+    return p;
+}
+
+static char *trimback(char *a, char *e)
+{
+    while (e > a && (unsigned char)e[-1] <= ' ')
+        --e;
+    *e = 0;;
+    return a;
+}
+
+static char *get_line(char *line, int size, int fd)
+{
+    int n;
+    for (n = 0; n < size - 1; )
+        if (read(fd, line + n, 1) < 1 || line[n++] == '\n')
+            break;
+    if (0 == n)
+        return NULL;
+    trimback(line, line + n);
+    return trimfront(line);
+}
+
+/* ------------------------------------------------------------- */
+static int pe_load_def(TCCState *s1, int fd)
+{
+    int state = 0, ret = -1, dllindex = 0;
+    char line[400], dllname[80], *p;
+
+    for (;;) {
+        p = get_line(line, sizeof line, fd);
+        if (NULL == p)
+            break;
+        if (0 == *p || ';' == *p)
+            continue;
+        switch (state) {
+        case 0:
+            if (0 != strnicmp(p, "LIBRARY", 7))
+                goto quit;
+            pstrcpy(dllname, sizeof dllname, trimfront(p+7));
+            ++state;
+            continue;
+
+        case 1:
+            if (0 != stricmp(p, "EXPORTS"))
+                goto quit;
+            ++state;
+            continue;
+
+        case 2:
+            dllindex = add_dllref(s1, dllname);
+            ++state;
+
+        default:
+            pe_putimport(s1, dllindex, p, 0);
+            continue;
+        }
+    }
+    ret = 0;
+quit:
+    return ret;
+}
+
+/* ------------------------------------------------------------- */
+#define TINY_IMPDEF_GET_EXPORT_NAMES_ONLY
+#include "win32/tools/tiny_impdef.c"
+
+static int pe_load_dll(TCCState *s1, const char *dllname, int fd)
+{
+    char *p, *q;
+    int index;
+    p = get_export_names(fd);
+    if (!p)
+        return -1;
+    index = add_dllref(s1, dllname);
+    for (q = p; *q; q += 1 + strlen(q))
+        pe_putimport(s1, index, q, 0);
+    tcc_free(p);
+    return 0;
+}
+
+/* ------------------------------------------------------------- */
+ST_FUNC int pe_load_file(struct TCCState *s1, const char *filename, int fd)
+{
+    int ret = -1;
+    char buf[10];
+    if (0 == strcmp(tcc_fileextension(filename), ".def"))
+        ret = pe_load_def(s1, fd);
+    else if (pe_load_res(s1, fd) == 0)
+        ret = 0;
+    else if (read_mem(fd, 0, buf, sizeof buf) && 0 == strncmp(buf, "MZ", 2))
+        ret = pe_load_dll(s1, tcc_basename(filename), fd);
+    return ret;
+}
+
+/* ------------------------------------------------------------- */
+#ifdef TCC_TARGET_X86_64
+static unsigned pe_add_uwwind_info(TCCState *s1)
+{
+    if (NULL == s1->uw_pdata) {
+        s1->uw_pdata = find_section(tcc_state, ".pdata");
+        s1->uw_pdata->sh_addralign = 4;
+        s1->uw_sym = put_elf_sym(symtab_section, 0, 0, 0, 0, text_section->sh_num, NULL);
+    }
+
+    if (0 == s1->uw_offs) {
+        /* As our functions all have the same stackframe, we use one entry for all */
+        static const unsigned char uw_info[] = {
+            0x01, // UBYTE: 3 Version , UBYTE: 5 Flags
+            0x04, // UBYTE Size of prolog
+            0x02, // UBYTE Count of unwind codes
+            0x05, // UBYTE: 4 Frame Register (rbp), UBYTE: 4 Frame Register offset (scaled)
+            // USHORT * n Unwind codes array
+            // 0x0b, 0x01, 0xff, 0xff, // stack size
+            0x04, 0x03, // set frame ptr (mov rsp -> rbp)
+            0x01, 0x50  // push reg (rbp)
+        };
+
+        Section *s = text_section;
+        unsigned char *p;
+
+        section_ptr_add(s, -s->data_offset & 3); /* align */
+        s1->uw_offs = s->data_offset;
+        p = section_ptr_add(s, sizeof uw_info);
+        memcpy(p, uw_info, sizeof uw_info);
+    }
+
+    return s1->uw_offs;
+}
+
+ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack)
+{
+    TCCState *s1 = tcc_state;
+    Section *pd;
+    unsigned o, n, d;
+    struct /* _RUNTIME_FUNCTION */ {
+      DWORD BeginAddress;
+      DWORD EndAddress;
+      DWORD UnwindData;
+    } *p;
+
+    d = pe_add_uwwind_info(s1);
+    pd = s1->uw_pdata;
+    o = pd->data_offset;
+    p = section_ptr_add(pd, sizeof *p);
+
+    /* record this function */
+    p->BeginAddress = start;
+    p->EndAddress = end;
+    p->UnwindData = d;
+
+    /* put relocations on it */
+    for (n = o + sizeof *p; o < n; o += sizeof p->BeginAddress)
+        put_elf_reloc(symtab_section, pd, o,  R_X86_64_RELATIVE, s1->uw_sym);
+}
+#endif
+/* ------------------------------------------------------------- */
+#ifdef TCC_TARGET_X86_64
+#define PE_STDSYM(n,s) n
+#else
+#define PE_STDSYM(n,s) "_" n s
+#endif
+
+static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
+{
+    const char *start_symbol;
+    ADDR3264 addr = 0;
+    int pe_type = 0;
+
+    if (find_elf_sym(symtab_section, PE_STDSYM("WinMain","@16")))
+        pe_type = PE_GUI;
+    else
+    if (TCC_OUTPUT_DLL == s1->output_type) {
+        pe_type = PE_DLL;
+        /* need this for 'tccelf.c:relocate_section()' */
+        s1->output_type = TCC_OUTPUT_EXE;
+    }
+    else
+        pe_type = PE_EXE;
+
+    start_symbol =
+        TCC_OUTPUT_MEMORY == s1->output_type
+        ? PE_GUI == pe_type ? "__runwinmain" : "_main"
+        : PE_DLL == pe_type ? PE_STDSYM("__dllstart","@12")
+        : PE_GUI == pe_type ? "__winstart" : "__start"
+        ;
+
+    if (!s1->leading_underscore || strchr(start_symbol, '@')) {
+        ++start_symbol;
+        if (start_symbol[0] != '_')
+            start_symbol = NULL;
+    }
+
+    /* grab the startup code from libtcc1 */
+    if (start_symbol)
+        add_elf_sym(symtab_section,
+            0, 0,
+            ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+            SHN_UNDEF, start_symbol);
+
+    if (0 == s1->nostdlib) {
+        static const char *libs[] = {
+            "libtcc1.a", "msvcrt", "kernel32", "", "user32", "gdi32", NULL
+        };
+        const char **pp, *p;
+        for (pp = libs; 0 != (p = *pp); ++pp) {
+            if (0 == *p) {
+                if (PE_DLL != pe_type && PE_GUI != pe_type)
+                    break;
+            } else if (pp == libs ? tcc_add_dll(s1, p, 0) : tcc_add_library(s1, p)) {
+                tcc_error_noabort("cannot find library: %s", p);
+                break;
+            }
+        }
+    }
+
+    if (TCC_OUTPUT_MEMORY == s1->output_type)
+        pe_type = PE_RUN;
+
+    if (start_symbol) {
+        addr = get_elf_sym_addr(s1, start_symbol, 1);
+        if (PE_RUN == pe_type && addr)
+            /* for -run GUI's, put '_runwinmain' instead of 'main' */
+            add_elf_sym(symtab_section,
+                    addr, 0,
+                    ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
+                    text_section->sh_num, "main");
+    }
+
+    pe->type = pe_type;
+    pe->start_addr = addr;
+}
+
+ST_FUNC int pe_output_file(TCCState * s1, const char *filename)
+{
+    int ret;
+    struct pe_info pe;
+    int i;
+
+    memset(&pe, 0, sizeof pe);
+    pe.filename = filename;
+    pe.s1 = s1;
+
+    tcc_add_bcheck(s1);
+    pe_add_runtime(s1, &pe);
+    relocate_common_syms(); /* assign bss adresses */
+    tcc_add_linker_symbols(s1);
+
+    ret = pe_check_symbols(&pe);
+    if (ret)
+        ;
+    else if (filename) {
+        if (PE_DLL == pe.type) {
+            pe.reloc = new_section(pe.s1, ".reloc", SHT_PROGBITS, 0);
+            /* XXX: check if is correct for arm-pe target */
+            pe.imagebase = 0x10000000;
+        } else {
+#if defined(TCC_TARGET_ARM)
+            pe.imagebase = 0x00010000;
+#else
+            pe.imagebase = 0x00400000;
+#endif
+        }
+
+#if defined(TCC_TARGET_ARM)
+        /* we use "console" subsystem by default */
+        pe.subsystem = 9;
+#else
+        if (PE_DLL == pe.type || PE_GUI == pe.type)
+            pe.subsystem = 2;
+        else
+            pe.subsystem = 3;
+#endif
+        /* Allow override via -Wl,-subsystem=... option */
+        if (s1->pe_subsystem != 0)
+            pe.subsystem = s1->pe_subsystem;
+
+        /* set default file/section alignment */
+	if (pe.subsystem == 1) {
+	    pe.section_align = 0x20;
+	    pe.file_align = 0x20;
+	} else {
+	    pe.section_align = 0x1000;
+	    pe.file_align = 0x200;
+	}
+
+        if (s1->section_align != 0)
+            pe.section_align = s1->section_align;
+        if (s1->pe_file_align != 0)
+            pe.file_align = s1->pe_file_align;
+
+        if ((pe.subsystem >= 10) && (pe.subsystem <= 12))
+            pe.imagebase = 0;
+
+        if (s1->has_text_addr)
+            pe.imagebase = s1->text_addr;
+
+        pe_assign_addresses(&pe);
+        relocate_syms(s1, 0);
+        for (i = 1; i < s1->nb_sections; ++i) {
+            Section *s = s1->sections[i];
+            if (s->reloc) {
+                relocate_section(s1, s);
+                pe_relocate_rva(&pe, s);
+            }
+        }
+        if (s1->nb_errors)
+            ret = -1;
+        else
+            ret = pe_write(&pe);
+        tcc_free(pe.sec_info);
+    } else {
+#ifdef TCC_IS_NATIVE
+        pe.thunk = data_section;
+        pe_build_imports(&pe);
+#endif
+    }
+
+#ifdef PE_PRINT_SECTIONS
+    pe_print_sections(s1, "tcc.log");
+#endif
+    return ret;
+}
+
+/* ------------------------------------------------------------- */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tccpp.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tccpp.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tccpp.c	(revision 279)
@@ -0,0 +1,3128 @@
+/*
+ *  TCC - Tiny C Compiler
+ * 
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+/********************************************************/
+/* global variables */
+
+ST_DATA int tok_flags;
+/* additional informations about token */
+#define TOK_FLAG_BOL   0x0001 /* beginning of line before */
+#define TOK_FLAG_BOF   0x0002 /* beginning of file before */
+#define TOK_FLAG_ENDIF 0x0004 /* a endif was found matching starting #ifdef */
+#define TOK_FLAG_EOF   0x0008 /* end of file */
+
+ST_DATA int parse_flags;
+#define PARSE_FLAG_PREPROCESS 0x0001 /* activate preprocessing */
+#define PARSE_FLAG_TOK_NUM    0x0002 /* return numbers instead of TOK_PPNUM */
+#define PARSE_FLAG_LINEFEED   0x0004 /* line feed is returned as a
+                                        token. line feed is also
+                                        returned at eof */
+#define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */
+#define PARSE_FLAG_SPACES     0x0010 /* next() returns space tokens (for -E) */
+
+ST_DATA struct BufferedFile *file;
+ST_DATA int ch, tok;
+ST_DATA CValue tokc;
+ST_DATA const int *macro_ptr;
+ST_DATA CString tokcstr; /* current parsed string, if any */
+
+/* display benchmark infos */
+ST_DATA int total_lines;
+ST_DATA int total_bytes;
+ST_DATA int tok_ident;
+ST_DATA TokenSym **table_ident;
+
+/* ------------------------------------------------------------------------- */
+
+static int *macro_ptr_allocated;
+static const int *unget_saved_macro_ptr;
+static int unget_saved_buffer[TOK_MAX_SIZE + 1];
+static int unget_buffer_enabled;
+static TokenSym *hash_ident[TOK_HASH_SIZE];
+static char token_buf[STRING_MAX_SIZE + 1];
+/* true if isid(c) || isnum(c) */
+static unsigned char isidnum_table[256-CH_EOF];
+
+static const char tcc_keywords[] = 
+#define DEF(id, str) str "\0"
+#include "tcctok.h"
+#undef DEF
+;
+
+/* WARNING: the content of this string encodes token numbers */
+static const unsigned char tok_two_chars[] =
+    "<=\236>=\235!=\225&&\240||\241++\244--\242==\224<<\1>>\2+=\253"
+    "-=\255*=\252/=\257%=\245&=\246^=\336|=\374->\313..\250##\266";
+
+struct macro_level {
+    struct macro_level *prev;
+    const int *p;
+};
+
+ST_FUNC void next_nomacro(void);
+static void next_nomacro_spc(void);
+static void macro_subst(
+    TokenString *tok_str,
+    Sym **nested_list,
+    const int *macro_str,
+    struct macro_level **can_read_stream
+    );
+
+ST_FUNC void skip(int c)
+{
+    if (tok != c)
+        tcc_error("'%c' expected (got \"%s\")", c, get_tok_str(tok, &tokc));
+    next();
+}
+
+ST_FUNC void expect(const char *msg)
+{
+    tcc_error("%s expected", msg);
+}
+
+/* ------------------------------------------------------------------------- */
+/* CString handling */
+static void cstr_realloc(CString *cstr, int new_size)
+{
+    int size;
+    void *data;
+
+    size = cstr->size_allocated;
+    if (size == 0)
+        size = 8; /* no need to allocate a too small first string */
+    while (size < new_size)
+        size = size * 2;
+    data = tcc_realloc(cstr->data_allocated, size);
+    cstr->data_allocated = data;
+    cstr->size_allocated = size;
+    cstr->data = data;
+}
+
+/* add a byte */
+ST_FUNC void cstr_ccat(CString *cstr, int ch)
+{
+    int size;
+    size = cstr->size + 1;
+    if (size > cstr->size_allocated)
+        cstr_realloc(cstr, size);
+    ((unsigned char *)cstr->data)[size - 1] = ch;
+    cstr->size = size;
+}
+
+ST_FUNC void cstr_cat(CString *cstr, const char *str)
+{
+    int c;
+    for(;;) {
+        c = *str;
+        if (c == '\0')
+            break;
+        cstr_ccat(cstr, c);
+        str++;
+    }
+}
+
+/* add a wide char */
+ST_FUNC void cstr_wccat(CString *cstr, int ch)
+{
+    int size;
+    size = cstr->size + sizeof(nwchar_t);
+    if (size > cstr->size_allocated)
+        cstr_realloc(cstr, size);
+    *(nwchar_t *)(((unsigned char *)cstr->data) + size - sizeof(nwchar_t)) = ch;
+    cstr->size = size;
+}
+
+ST_FUNC void cstr_new(CString *cstr)
+{
+    memset(cstr, 0, sizeof(CString));
+}
+
+/* free string and reset it to NULL */
+ST_FUNC void cstr_free(CString *cstr)
+{
+    tcc_free(cstr->data_allocated);
+    cstr_new(cstr);
+}
+
+/* reset string to empty */
+ST_FUNC void cstr_reset(CString *cstr)
+{
+    cstr->size = 0;
+}
+
+/* XXX: unicode ? */
+static void add_char(CString *cstr, int c)
+{
+    if (c == '\'' || c == '\"' || c == '\\') {
+        /* XXX: could be more precise if char or string */
+        cstr_ccat(cstr, '\\');
+    }
+    if (c >= 32 && c <= 126) {
+        cstr_ccat(cstr, c);
+    } else {
+        cstr_ccat(cstr, '\\');
+        if (c == '\n') {
+            cstr_ccat(cstr, 'n');
+        } else {
+            cstr_ccat(cstr, '0' + ((c >> 6) & 7));
+            cstr_ccat(cstr, '0' + ((c >> 3) & 7));
+            cstr_ccat(cstr, '0' + (c & 7));
+        }
+    }
+}
+
+/* ------------------------------------------------------------------------- */
+/* allocate a new token */
+static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len)
+{
+    TokenSym *ts, **ptable;
+    int i;
+
+    if (tok_ident >= SYM_FIRST_ANOM) 
+        tcc_error("memory full");
+
+    /* expand token table if needed */
+    i = tok_ident - TOK_IDENT;
+    if ((i % TOK_ALLOC_INCR) == 0) {
+        ptable = tcc_realloc(table_ident, (i + TOK_ALLOC_INCR) * sizeof(TokenSym *));
+        table_ident = ptable;
+    }
+
+    ts = tcc_malloc(sizeof(TokenSym) + len);
+    table_ident[i] = ts;
+    ts->tok = tok_ident++;
+    ts->sym_define = NULL;
+    ts->sym_label = NULL;
+    ts->sym_struct = NULL;
+    ts->sym_identifier = NULL;
+    ts->len = len;
+    ts->hash_next = NULL;
+    memcpy(ts->str, str, len);
+    ts->str[len] = '\0';
+    *pts = ts;
+    return ts;
+}
+
+#define TOK_HASH_INIT 1
+#define TOK_HASH_FUNC(h, c) ((h) * 263 + (c))
+
+/* find a token and add it if not found */
+ST_FUNC TokenSym *tok_alloc(const char *str, int len)
+{
+    TokenSym *ts, **pts;
+    int i;
+    unsigned int h;
+    
+    h = TOK_HASH_INIT;
+    for(i=0;i<len;i++)
+        h = TOK_HASH_FUNC(h, ((unsigned char *)str)[i]);
+    h &= (TOK_HASH_SIZE - 1);
+
+    pts = &hash_ident[h];
+    for(;;) {
+        ts = *pts;
+        if (!ts)
+            break;
+        if (ts->len == len && !memcmp(ts->str, str, len))
+            return ts;
+        pts = &(ts->hash_next);
+    }
+    return tok_alloc_new(pts, str, len);
+}
+
+/* XXX: buffer overflow */
+/* XXX: float tokens */
+ST_FUNC char *get_tok_str(int v, CValue *cv)
+{
+    static char buf[STRING_MAX_SIZE + 1];
+    static CString cstr_buf;
+    CString *cstr;
+    char *p;
+    int i, len;
+
+    /* NOTE: to go faster, we give a fixed buffer for small strings */
+    cstr_reset(&cstr_buf);
+    cstr_buf.data = buf;
+    cstr_buf.size_allocated = sizeof(buf);
+    p = buf;
+
+    switch(v) {
+    case TOK_CINT:
+    case TOK_CUINT:
+        /* XXX: not quite exact, but only useful for testing */
+        sprintf(p, "%u", cv->ui);
+        break;
+    case TOK_CLLONG:
+    case TOK_CULLONG:
+        /* XXX: not quite exact, but only useful for testing  */
+#ifdef _WIN32
+        sprintf(p, "%u", (unsigned)cv->ull);
+#else
+        sprintf(p, "%Lu", cv->ull);
+#endif
+        break;
+    case TOK_LCHAR:
+        cstr_ccat(&cstr_buf, 'L');
+    case TOK_CCHAR:
+        cstr_ccat(&cstr_buf, '\'');
+        add_char(&cstr_buf, cv->i);
+        cstr_ccat(&cstr_buf, '\'');
+        cstr_ccat(&cstr_buf, '\0');
+        break;
+    case TOK_PPNUM:
+        cstr = cv->cstr;
+        len = cstr->size - 1;
+        for(i=0;i<len;i++)
+            add_char(&cstr_buf, ((unsigned char *)cstr->data)[i]);
+        cstr_ccat(&cstr_buf, '\0');
+        break;
+    case TOK_LSTR:
+        cstr_ccat(&cstr_buf, 'L');
+    case TOK_STR:
+        cstr = cv->cstr;
+        cstr_ccat(&cstr_buf, '\"');
+        if (v == TOK_STR) {
+            len = cstr->size - 1;
+            for(i=0;i<len;i++)
+                add_char(&cstr_buf, ((unsigned char *)cstr->data)[i]);
+        } else {
+            len = (cstr->size / sizeof(nwchar_t)) - 1;
+            for(i=0;i<len;i++)
+                add_char(&cstr_buf, ((nwchar_t *)cstr->data)[i]);
+        }
+        cstr_ccat(&cstr_buf, '\"');
+        cstr_ccat(&cstr_buf, '\0');
+        break;
+    case TOK_LT:
+        v = '<';
+        goto addv;
+    case TOK_GT:
+        v = '>';
+        goto addv;
+    case TOK_DOTS:
+        return strcpy(p, "...");
+    case TOK_A_SHL:
+        return strcpy(p, "<<=");
+    case TOK_A_SAR:
+        return strcpy(p, ">>=");
+    default:
+        if (v < TOK_IDENT) {
+            /* search in two bytes table */
+            const unsigned char *q = tok_two_chars;
+            while (*q) {
+                if (q[2] == v) {
+                    *p++ = q[0];
+                    *p++ = q[1];
+                    *p = '\0';
+                    return buf;
+                }
+                q += 3;
+            }
+        addv:
+            *p++ = v;
+            *p = '\0';
+        } else if (v < tok_ident) {
+            return table_ident[v - TOK_IDENT]->str;
+        } else if (v >= SYM_FIRST_ANOM) {
+            /* special name for anonymous symbol */
+            sprintf(p, "L.%u", v - SYM_FIRST_ANOM);
+        } else {
+            /* should never happen */
+            return NULL;
+        }
+        break;
+    }
+    return cstr_buf.data;
+}
+
+/* fill input buffer and peek next char */
+static int tcc_peekc_slow(BufferedFile *bf)
+{
+    int len;
+    /* only tries to read if really end of buffer */
+    if (bf->buf_ptr >= bf->buf_end) {
+        if (bf->fd != -1) {
+#if defined(PARSE_DEBUG)
+            len = 8;
+#else
+            len = IO_BUF_SIZE;
+#endif
+            len = read(bf->fd, bf->buffer, len);
+            if (len < 0)
+                len = 0;
+        } else {
+            len = 0;
+        }
+        total_bytes += len;
+        bf->buf_ptr = bf->buffer;
+        bf->buf_end = bf->buffer + len;
+        *bf->buf_end = CH_EOB;
+    }
+    if (bf->buf_ptr < bf->buf_end) {
+        return bf->buf_ptr[0];
+    } else {
+        bf->buf_ptr = bf->buf_end;
+        return CH_EOF;
+    }
+}
+
+/* return the current character, handling end of block if necessary
+   (but not stray) */
+ST_FUNC int handle_eob(void)
+{
+    return tcc_peekc_slow(file);
+}
+
+/* read next char from current input file and handle end of input buffer */
+ST_INLN void inp(void)
+{
+    ch = *(++(file->buf_ptr));
+    /* end of buffer/file handling */
+    if (ch == CH_EOB)
+        ch = handle_eob();
+}
+
+/* handle '\[\r]\n' */
+static int handle_stray_noerror(void)
+{
+    while (ch == '\\') {
+        inp();
+        if (ch == '\n') {
+            file->line_num++;
+            inp();
+        } else if (ch == '\r') {
+            inp();
+            if (ch != '\n')
+                goto fail;
+            file->line_num++;
+            inp();
+        } else {
+        fail:
+            return 1;
+        }
+    }
+    return 0;
+}
+
+static void handle_stray(void)
+{
+    if (handle_stray_noerror())
+        tcc_error("stray '\\' in program");
+}
+
+/* skip the stray and handle the \\n case. Output an error if
+   incorrect char after the stray */
+static int handle_stray1(uint8_t *p)
+{
+    int c;
+
+    if (p >= file->buf_end) {
+        file->buf_ptr = p;
+        c = handle_eob();
+        p = file->buf_ptr;
+        if (c == '\\')
+            goto parse_stray;
+    } else {
+    parse_stray:
+        file->buf_ptr = p;
+        ch = *p;
+        handle_stray();
+        p = file->buf_ptr;
+        c = *p;
+    }
+    return c;
+}
+
+/* handle just the EOB case, but not stray */
+#define PEEKC_EOB(c, p)\
+{\
+    p++;\
+    c = *p;\
+    if (c == '\\') {\
+        file->buf_ptr = p;\
+        c = handle_eob();\
+        p = file->buf_ptr;\
+    }\
+}
+
+/* handle the complicated stray case */
+#define PEEKC(c, p)\
+{\
+    p++;\
+    c = *p;\
+    if (c == '\\') {\
+        c = handle_stray1(p);\
+        p = file->buf_ptr;\
+    }\
+}
+
+/* input with '\[\r]\n' handling. Note that this function cannot
+   handle other characters after '\', so you cannot call it inside
+   strings or comments */
+ST_FUNC void minp(void)
+{
+    inp();
+    if (ch == '\\') 
+        handle_stray();
+}
+
+
+/* single line C++ comments */
+static uint8_t *parse_line_comment(uint8_t *p)
+{
+    int c;
+
+    p++;
+    for(;;) {
+        c = *p;
+    redo:
+        if (c == '\n' || c == CH_EOF) {
+            break;
+        } else if (c == '\\') {
+            file->buf_ptr = p;
+            c = handle_eob();
+            p = file->buf_ptr;
+            if (c == '\\') {
+                PEEKC_EOB(c, p);
+                if (c == '\n') {
+                    file->line_num++;
+                    PEEKC_EOB(c, p);
+                } else if (c == '\r') {
+                    PEEKC_EOB(c, p);
+                    if (c == '\n') {
+                        file->line_num++;
+                        PEEKC_EOB(c, p);
+                    }
+                }
+            } else {
+                goto redo;
+            }
+        } else {
+            p++;
+        }
+    }
+    return p;
+}
+
+/* C comments */
+ST_FUNC uint8_t *parse_comment(uint8_t *p)
+{
+    int c;
+    
+    p++;
+    for(;;) {
+        /* fast skip loop */
+        for(;;) {
+            c = *p;
+            if (c == '\n' || c == '*' || c == '\\')
+                break;
+            p++;
+            c = *p;
+            if (c == '\n' || c == '*' || c == '\\')
+                break;
+            p++;
+        }
+        /* now we can handle all the cases */
+        if (c == '\n') {
+            file->line_num++;
+            p++;
+        } else if (c == '*') {
+            p++;
+            for(;;) {
+                c = *p;
+                if (c == '*') {
+                    p++;
+                } else if (c == '/') {
+                    goto end_of_comment;
+                } else if (c == '\\') {
+                    file->buf_ptr = p;
+                    c = handle_eob();
+                    p = file->buf_ptr;
+                    if (c == '\\') {
+                        /* skip '\[\r]\n', otherwise just skip the stray */
+                        while (c == '\\') {
+                            PEEKC_EOB(c, p);
+                            if (c == '\n') {
+                                file->line_num++;
+                                PEEKC_EOB(c, p);
+                            } else if (c == '\r') {
+                                PEEKC_EOB(c, p);
+                                if (c == '\n') {
+                                    file->line_num++;
+                                    PEEKC_EOB(c, p);
+                                }
+                            } else {
+                                goto after_star;
+                            }
+                        }
+                    }
+                } else {
+                    break;
+                }
+            }
+        after_star: ;
+        } else {
+            /* stray, eob or eof */
+            file->buf_ptr = p;
+            c = handle_eob();
+            p = file->buf_ptr;
+            if (c == CH_EOF) {
+                tcc_error("unexpected end of file in comment");
+            } else if (c == '\\') {
+                p++;
+            }
+        }
+    }
+ end_of_comment:
+    p++;
+    return p;
+}
+
+#define cinp minp
+
+static inline void skip_spaces(void)
+{
+    while (is_space(ch))
+        cinp();
+}
+
+static inline int check_space(int t, int *spc) 
+{
+    if (is_space(t)) {
+        if (*spc) 
+            return 1;
+        *spc = 1;
+    } else 
+        *spc = 0;
+    return 0;
+}
+
+/* parse a string without interpreting escapes */
+static uint8_t *parse_pp_string(uint8_t *p,
+                                int sep, CString *str)
+{
+    int c;
+    p++;
+    for(;;) {
+        c = *p;
+        if (c == sep) {
+            break;
+        } else if (c == '\\') {
+            file->buf_ptr = p;
+            c = handle_eob();
+            p = file->buf_ptr;
+            if (c == CH_EOF) {
+            unterminated_string:
+                /* XXX: indicate line number of start of string */
+                tcc_error("missing terminating %c character", sep);
+            } else if (c == '\\') {
+                /* escape : just skip \[\r]\n */
+                PEEKC_EOB(c, p);
+                if (c == '\n') {
+                    file->line_num++;
+                    p++;
+                } else if (c == '\r') {
+                    PEEKC_EOB(c, p);
+                    if (c != '\n')
+                        expect("'\n' after '\r'");
+                    file->line_num++;
+                    p++;
+                } else if (c == CH_EOF) {
+                    goto unterminated_string;
+                } else {
+                    if (str) {
+                        cstr_ccat(str, '\\');
+                        cstr_ccat(str, c);
+                    }
+                    p++;
+                }
+            }
+        } else if (c == '\n') {
+            file->line_num++;
+            goto add_char;
+        } else if (c == '\r') {
+            PEEKC_EOB(c, p);
+            if (c != '\n') {
+                if (str)
+                    cstr_ccat(str, '\r');
+            } else {
+                file->line_num++;
+                goto add_char;
+            }
+        } else {
+        add_char:
+            if (str)
+                cstr_ccat(str, c);
+            p++;
+        }
+    }
+    p++;
+    return p;
+}
+
+/* skip block of text until #else, #elif or #endif. skip also pairs of
+   #if/#endif */
+static void preprocess_skip(void)
+{
+    int a, start_of_line, c, in_warn_or_error;
+    uint8_t *p;
+
+    p = file->buf_ptr;
+    a = 0;
+redo_start:
+    start_of_line = 1;
+    in_warn_or_error = 0;
+    for(;;) {
+    redo_no_start:
+        c = *p;
+        switch(c) {
+        case ' ':
+        case '\t':
+        case '\f':
+        case '\v':
+        case '\r':
+            p++;
+            goto redo_no_start;
+        case '\n':
+            file->line_num++;
+            p++;
+            goto redo_start;
+        case '\\':
+            file->buf_ptr = p;
+            c = handle_eob();
+            if (c == CH_EOF) {
+                expect("#endif");
+            } else if (c == '\\') {
+                ch = file->buf_ptr[0];
+                handle_stray_noerror();
+            }
+            p = file->buf_ptr;
+            goto redo_no_start;
+        /* skip strings */
+        case '\"':
+        case '\'':
+            if (in_warn_or_error)
+                goto _default;
+            p = parse_pp_string(p, c, NULL);
+            break;
+        /* skip comments */
+        case '/':
+            if (in_warn_or_error)
+                goto _default;
+            file->buf_ptr = p;
+            ch = *p;
+            minp();
+            p = file->buf_ptr;
+            if (ch == '*') {
+                p = parse_comment(p);
+            } else if (ch == '/') {
+                p = parse_line_comment(p);
+            }
+            break;
+        case '#':
+            p++;
+            if (start_of_line) {
+                file->buf_ptr = p;
+                next_nomacro();
+                p = file->buf_ptr;
+                if (a == 0 && 
+                    (tok == TOK_ELSE || tok == TOK_ELIF || tok == TOK_ENDIF))
+                    goto the_end;
+                if (tok == TOK_IF || tok == TOK_IFDEF || tok == TOK_IFNDEF)
+                    a++;
+                else if (tok == TOK_ENDIF)
+                    a--;
+                else if( tok == TOK_ERROR || tok == TOK_WARNING)
+                    in_warn_or_error = 1;
+                else if (tok == TOK_LINEFEED)
+                    goto redo_start;
+            }
+            break;
+_default:
+        default:
+            p++;
+            break;
+        }
+        start_of_line = 0;
+    }
+ the_end: ;
+    file->buf_ptr = p;
+}
+
+/* ParseState handling */
+
+/* XXX: currently, no include file info is stored. Thus, we cannot display
+   accurate messages if the function or data definition spans multiple
+   files */
+
+/* save current parse state in 's' */
+ST_FUNC void save_parse_state(ParseState *s)
+{
+    s->line_num = file->line_num;
+    s->macro_ptr = macro_ptr;
+    s->tok = tok;
+    s->tokc = tokc;
+}
+
+/* restore parse state from 's' */
+ST_FUNC void restore_parse_state(ParseState *s)
+{
+    file->line_num = s->line_num;
+    macro_ptr = s->macro_ptr;
+    tok = s->tok;
+    tokc = s->tokc;
+}
+
+/* return the number of additional 'ints' necessary to store the
+   token */
+static inline int tok_ext_size(int t)
+{
+    switch(t) {
+        /* 4 bytes */
+    case TOK_CINT:
+    case TOK_CUINT:
+    case TOK_CCHAR:
+    case TOK_LCHAR:
+    case TOK_CFLOAT:
+    case TOK_LINENUM:
+        return 1;
+    case TOK_STR:
+    case TOK_LSTR:
+    case TOK_PPNUM:
+        tcc_error("unsupported token");
+        return 1;
+    case TOK_CDOUBLE:
+    case TOK_CLLONG:
+    case TOK_CULLONG:
+        return 2;
+    case TOK_CLDOUBLE:
+        return LDOUBLE_SIZE / 4;
+    default:
+        return 0;
+    }
+}
+
+/* token string handling */
+
+ST_INLN void tok_str_new(TokenString *s)
+{
+    s->str = NULL;
+    s->len = 0;
+    s->allocated_len = 0;
+    s->last_line_num = -1;
+}
+
+ST_FUNC void tok_str_free(int *str)
+{
+    tcc_free(str);
+}
+
+static int *tok_str_realloc(TokenString *s)
+{
+    int *str, len;
+
+    if (s->allocated_len == 0) {
+        len = 8;
+    } else {
+        len = s->allocated_len * 2;
+    }
+    str = tcc_realloc(s->str, len * sizeof(int));
+    s->allocated_len = len;
+    s->str = str;
+    return str;
+}
+
+ST_FUNC void tok_str_add(TokenString *s, int t)
+{
+    int len, *str;
+
+    len = s->len;
+    str = s->str;
+    if (len >= s->allocated_len)
+        str = tok_str_realloc(s);
+    str[len++] = t;
+    s->len = len;
+}
+
+static void tok_str_add2(TokenString *s, int t, CValue *cv)
+{
+    int len, *str;
+
+    len = s->len;
+    str = s->str;
+
+    /* allocate space for worst case */
+    if (len + TOK_MAX_SIZE > s->allocated_len)
+        str = tok_str_realloc(s);
+    str[len++] = t;
+    switch(t) {
+    case TOK_CINT:
+    case TOK_CUINT:
+    case TOK_CCHAR:
+    case TOK_LCHAR:
+    case TOK_CFLOAT:
+    case TOK_LINENUM:
+        str[len++] = cv->tab[0];
+        break;
+    case TOK_PPNUM:
+    case TOK_STR:
+    case TOK_LSTR:
+        {
+            int nb_words;
+            CString *cstr;
+
+            nb_words = (sizeof(CString) + cv->cstr->size + 3) >> 2;
+            while ((len + nb_words) > s->allocated_len)
+                str = tok_str_realloc(s);
+            cstr = (CString *)(str + len);
+            cstr->data = NULL;
+            cstr->size = cv->cstr->size;
+            cstr->data_allocated = NULL;
+            cstr->size_allocated = cstr->size;
+            memcpy((char *)cstr + sizeof(CString), 
+                   cv->cstr->data, cstr->size);
+            len += nb_words;
+        }
+        break;
+    case TOK_CDOUBLE:
+    case TOK_CLLONG:
+    case TOK_CULLONG:
+#if LDOUBLE_SIZE == 8
+    case TOK_CLDOUBLE:
+#endif
+        str[len++] = cv->tab[0];
+        str[len++] = cv->tab[1];
+        break;
+#if LDOUBLE_SIZE == 12
+    case TOK_CLDOUBLE:
+        str[len++] = cv->tab[0];
+        str[len++] = cv->tab[1];
+        str[len++] = cv->tab[2];
+#elif LDOUBLE_SIZE == 16
+    case TOK_CLDOUBLE:
+        str[len++] = cv->tab[0];
+        str[len++] = cv->tab[1];
+        str[len++] = cv->tab[2];
+        str[len++] = cv->tab[3];
+#elif LDOUBLE_SIZE != 8
+#error add long double size support
+#endif
+        break;
+    default:
+        break;
+    }
+    s->len = len;
+}
+
+/* add the current parse token in token string 's' */
+ST_FUNC void tok_str_add_tok(TokenString *s)
+{
+    CValue cval;
+
+    /* save line number info */
+    if (file->line_num != s->last_line_num) {
+        s->last_line_num = file->line_num;
+        cval.i = s->last_line_num;
+        tok_str_add2(s, TOK_LINENUM, &cval);
+    }
+    tok_str_add2(s, tok, &tokc);
+}
+
+/* get a token from an integer array and increment pointer
+   accordingly. we code it as a macro to avoid pointer aliasing. */
+static inline void TOK_GET(int *t, const int **pp, CValue *cv)
+{
+    const int *p = *pp;
+    int n, *tab;
+
+    tab = cv->tab;
+    switch(*t = *p++) {
+    case TOK_CINT:
+    case TOK_CUINT:
+    case TOK_CCHAR:
+    case TOK_LCHAR:
+    case TOK_CFLOAT:
+    case TOK_LINENUM:
+        tab[0] = *p++;
+        break;
+    case TOK_STR:
+    case TOK_LSTR:
+    case TOK_PPNUM:
+        cv->cstr = (CString *)p;
+        cv->cstr->data = (char *)p + sizeof(CString);
+        p += (sizeof(CString) + cv->cstr->size + 3) >> 2;
+        break;
+    case TOK_CDOUBLE:
+    case TOK_CLLONG:
+    case TOK_CULLONG:
+        n = 2;
+        goto copy;
+    case TOK_CLDOUBLE:
+#if LDOUBLE_SIZE == 16
+        n = 4;
+#elif LDOUBLE_SIZE == 12
+        n = 3;
+#elif LDOUBLE_SIZE == 8
+        n = 2;
+#else
+# error add long double size support
+#endif
+    copy:
+        do
+            *tab++ = *p++;
+        while (--n);
+        break;
+    default:
+        break;
+    }
+    *pp = p;
+}
+
+static int macro_is_equal(const int *a, const int *b)
+{
+    char buf[STRING_MAX_SIZE + 1];
+    CValue cv;
+    int t;
+    while (*a && *b) {
+        TOK_GET(&t, &a, &cv);
+        pstrcpy(buf, sizeof buf, get_tok_str(t, &cv));
+        TOK_GET(&t, &b, &cv);
+        if (strcmp(buf, get_tok_str(t, &cv)))
+            return 0;
+    }
+    return !(*a || *b);
+}
+
+/* defines handling */
+ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg)
+{
+    Sym *s;
+
+    s = define_find(v);
+    if (s && !macro_is_equal(s->d, str))
+        tcc_warning("%s redefined", get_tok_str(v, NULL));
+
+    s = sym_push2(&define_stack, v, macro_type, 0);
+    s->d = str;
+    s->next = first_arg;
+    table_ident[v - TOK_IDENT]->sym_define = s;
+}
+
+/* undefined a define symbol. Its name is just set to zero */
+ST_FUNC void define_undef(Sym *s)
+{
+    int v;
+    v = s->v;
+    if (v >= TOK_IDENT && v < tok_ident)
+        table_ident[v - TOK_IDENT]->sym_define = NULL;
+    s->v = 0;
+}
+
+ST_INLN Sym *define_find(int v)
+{
+    v -= TOK_IDENT;
+    if ((unsigned)v >= (unsigned)(tok_ident - TOK_IDENT))
+        return NULL;
+    return table_ident[v]->sym_define;
+}
+
+/* free define stack until top reaches 'b' */
+ST_FUNC void free_defines(Sym *b)
+{
+    Sym *top, *top1;
+    int v;
+
+    top = define_stack;
+    while (top != b) {
+        top1 = top->prev;
+        /* do not free args or predefined defines */
+        if (top->d)
+            tok_str_free(top->d);
+        v = top->v;
+        if (v >= TOK_IDENT && v < tok_ident)
+            table_ident[v - TOK_IDENT]->sym_define = NULL;
+        sym_free(top);
+        top = top1;
+    }
+    define_stack = b;
+}
+
+/* label lookup */
+ST_FUNC Sym *label_find(int v)
+{
+    v -= TOK_IDENT;
+    if ((unsigned)v >= (unsigned)(tok_ident - TOK_IDENT))
+        return NULL;
+    return table_ident[v]->sym_label;
+}
+
+ST_FUNC Sym *label_push(Sym **ptop, int v, int flags)
+{
+    Sym *s, **ps;
+    s = sym_push2(ptop, v, 0, 0);
+    s->r = flags;
+    ps = &table_ident[v - TOK_IDENT]->sym_label;
+    if (ptop == &global_label_stack) {
+        /* modify the top most local identifier, so that
+           sym_identifier will point to 's' when popped */
+        while (*ps != NULL)
+            ps = &(*ps)->prev_tok;
+    }
+    s->prev_tok = *ps;
+    *ps = s;
+    return s;
+}
+
+/* pop labels until element last is reached. Look if any labels are
+   undefined. Define symbols if '&&label' was used. */
+ST_FUNC void label_pop(Sym **ptop, Sym *slast)
+{
+    Sym *s, *s1;
+    for(s = *ptop; s != slast; s = s1) {
+        s1 = s->prev;
+        if (s->r == LABEL_DECLARED) {
+            tcc_warning("label '%s' declared but not used", get_tok_str(s->v, NULL));
+        } else if (s->r == LABEL_FORWARD) {
+                tcc_error("label '%s' used but not defined",
+                      get_tok_str(s->v, NULL));
+        } else {
+            if (s->c) {
+                /* define corresponding symbol. A size of
+                   1 is put. */
+                put_extern_sym(s, cur_text_section, s->jnext, 1);
+            }
+        }
+        /* remove label */
+        table_ident[s->v - TOK_IDENT]->sym_label = s->prev_tok;
+        sym_free(s);
+    }
+    *ptop = slast;
+}
+
+/* eval an expression for #if/#elif */
+static int expr_preprocess(void)
+{
+    int c, t;
+    TokenString str;
+    
+    tok_str_new(&str);
+    while (tok != TOK_LINEFEED && tok != TOK_EOF) {
+        next(); /* do macro subst */
+        if (tok == TOK_DEFINED) {
+            next_nomacro();
+            t = tok;
+            if (t == '(') 
+                next_nomacro();
+            c = define_find(tok) != 0;
+            if (t == '(')
+                next_nomacro();
+            tok = TOK_CINT;
+            tokc.i = c;
+        } else if (tok >= TOK_IDENT) {
+            /* if undefined macro */
+            tok = TOK_CINT;
+            tokc.i = 0;
+        }
+        tok_str_add_tok(&str);
+    }
+    tok_str_add(&str, -1); /* simulate end of file */
+    tok_str_add(&str, 0);
+    /* now evaluate C constant expression */
+    macro_ptr = str.str;
+    next();
+    c = expr_const();
+    macro_ptr = NULL;
+    tok_str_free(str.str);
+    return c != 0;
+}
+
+#if defined(PARSE_DEBUG) || defined(PP_DEBUG)
+static void tok_print(int *str)
+{
+    int t;
+    CValue cval;
+
+    printf("<");
+    while (1) {
+        TOK_GET(&t, &str, &cval);
+        if (!t)
+            break;
+        printf("%s", get_tok_str(t, &cval));
+    }
+    printf(">\n");
+}
+#endif
+
+/* parse after #define */
+ST_FUNC void parse_define(void)
+{
+    Sym *s, *first, **ps;
+    int v, t, varg, is_vaargs, spc;
+    TokenString str;
+    
+    v = tok;
+    if (v < TOK_IDENT)
+        tcc_error("invalid macro name '%s'", get_tok_str(tok, &tokc));
+    /* XXX: should check if same macro (ANSI) */
+    first = NULL;
+    t = MACRO_OBJ;
+    /* '(' must be just after macro definition for MACRO_FUNC */
+    next_nomacro_spc();
+    if (tok == '(') {
+        next_nomacro();
+        ps = &first;
+        while (tok != ')') {
+            varg = tok;
+            next_nomacro();
+            is_vaargs = 0;
+            if (varg == TOK_DOTS) {
+                varg = TOK___VA_ARGS__;
+                is_vaargs = 1;
+            } else if (tok == TOK_DOTS && gnu_ext) {
+                is_vaargs = 1;
+                next_nomacro();
+            }
+            if (varg < TOK_IDENT)
+                tcc_error("badly punctuated parameter list");
+            s = sym_push2(&define_stack, varg | SYM_FIELD, is_vaargs, 0);
+            *ps = s;
+            ps = &s->next;
+            if (tok != ',')
+                break;
+            next_nomacro();
+        }
+        if (tok == ')')
+            next_nomacro_spc();
+        t = MACRO_FUNC;
+    }
+    tok_str_new(&str);
+    spc = 2;
+    /* EOF testing necessary for '-D' handling */
+    while (tok != TOK_LINEFEED && tok != TOK_EOF) {
+        /* remove spaces around ## and after '#' */        
+        if (TOK_TWOSHARPS == tok) {
+            if (1 == spc)
+                --str.len;
+            spc = 2;
+        } else if ('#' == tok) {
+            spc = 2;
+        } else if (check_space(tok, &spc)) {
+            goto skip;
+        }
+        tok_str_add2(&str, tok, &tokc);
+    skip:
+        next_nomacro_spc();
+    }
+    if (spc == 1)
+        --str.len; /* remove trailing space */
+    tok_str_add(&str, 0);
+#ifdef PP_DEBUG
+    printf("define %s %d: ", get_tok_str(v, NULL), t);
+    tok_print(str.str);
+#endif
+    define_push(v, t, str.str, first);
+}
+
+static inline int hash_cached_include(const char *filename)
+{
+    const unsigned char *s;
+    unsigned int h;
+
+    h = TOK_HASH_INIT;
+    s = filename;
+    while (*s) {
+        h = TOK_HASH_FUNC(h, *s);
+        s++;
+    }
+    h &= (CACHED_INCLUDES_HASH_SIZE - 1);
+    return h;
+}
+
+static CachedInclude *search_cached_include(TCCState *s1, const char *filename)
+{
+    CachedInclude *e;
+    int i, h;
+    h = hash_cached_include(filename);
+    i = s1->cached_includes_hash[h];
+    for(;;) {
+        if (i == 0)
+            break;
+        e = s1->cached_includes[i - 1];
+        if (0 == PATHCMP(e->filename, filename))
+            return e;
+        i = e->hash_next;
+    }
+    return NULL;
+}
+
+static inline void add_cached_include(TCCState *s1, const char *filename, int ifndef_macro)
+{
+    CachedInclude *e;
+    int h;
+
+    if (search_cached_include(s1, filename))
+        return;
+#ifdef INC_DEBUG
+    printf("adding cached '%s' %s\n", filename, get_tok_str(ifndef_macro, NULL));
+#endif
+    e = tcc_malloc(sizeof(CachedInclude) + strlen(filename));
+    strcpy(e->filename, filename);
+    e->ifndef_macro = ifndef_macro;
+    dynarray_add((void ***)&s1->cached_includes, &s1->nb_cached_includes, e);
+    /* add in hash table */
+    h = hash_cached_include(filename);
+    e->hash_next = s1->cached_includes_hash[h];
+    s1->cached_includes_hash[h] = s1->nb_cached_includes;
+}
+
+static void pragma_parse(TCCState *s1)
+{
+    int val;
+
+    next();
+    if (tok == TOK_pack) {
+        /*
+          This may be:
+          #pragma pack(1) // set
+          #pragma pack() // reset to default
+          #pragma pack(push,1) // push & set
+          #pragma pack(pop) // restore previous
+        */
+        next();
+        skip('(');
+        if (tok == TOK_ASM_pop) {
+            next();
+            if (s1->pack_stack_ptr <= s1->pack_stack) {
+            stk_error:
+                tcc_error("out of pack stack");
+            }
+            s1->pack_stack_ptr--;
+        } else {
+            val = 0;
+            if (tok != ')') {
+                if (tok == TOK_ASM_push) {
+                    next();
+                    if (s1->pack_stack_ptr >= s1->pack_stack + PACK_STACK_SIZE - 1)
+                        goto stk_error;
+                    s1->pack_stack_ptr++;
+                    skip(',');
+                }
+                if (tok != TOK_CINT) {
+                pack_error:
+                    tcc_error("invalid pack pragma");
+                }
+                val = tokc.i;
+                if (val < 1 || val > 16 || (val & (val - 1)) != 0)
+                    goto pack_error;
+                next();
+            }
+            *s1->pack_stack_ptr = val;
+            skip(')');
+        }
+    }
+}
+
+/* is_bof is true if first non space token at beginning of file */
+ST_FUNC void preprocess(int is_bof)
+{
+    TCCState *s1 = tcc_state;
+    int i, c, n, saved_parse_flags;
+    char buf[1024], *q;
+    Sym *s;
+
+    saved_parse_flags = parse_flags;
+    parse_flags = PARSE_FLAG_PREPROCESS | PARSE_FLAG_TOK_NUM | 
+        PARSE_FLAG_LINEFEED;
+    next_nomacro();
+ redo:
+    switch(tok) {
+    case TOK_DEFINE:
+        next_nomacro();
+        parse_define();
+        break;
+    case TOK_UNDEF:
+        next_nomacro();
+        s = define_find(tok);
+        /* undefine symbol by putting an invalid name */
+        if (s)
+            define_undef(s);
+        break;
+    case TOK_INCLUDE:
+    case TOK_INCLUDE_NEXT:
+        ch = file->buf_ptr[0];
+        /* XXX: incorrect if comments : use next_nomacro with a special mode */
+        skip_spaces();
+        if (ch == '<') {
+            c = '>';
+            goto read_name;
+        } else if (ch == '\"') {
+            c = ch;
+        read_name:
+            inp();
+            q = buf;
+            while (ch != c && ch != '\n' && ch != CH_EOF) {
+                if ((q - buf) < sizeof(buf) - 1)
+                    *q++ = ch;
+                if (ch == '\\') {
+                    if (handle_stray_noerror() == 0)
+                        --q;
+                } else
+                    inp();
+            }
+            *q = '\0';
+            minp();
+#if 0
+            /* eat all spaces and comments after include */
+            /* XXX: slightly incorrect */
+            while (ch1 != '\n' && ch1 != CH_EOF)
+                inp();
+#endif
+        } else {
+            /* computed #include : either we have only strings or
+               we have anything enclosed in '<>' */
+            next();
+            buf[0] = '\0';
+            if (tok == TOK_STR) {
+                while (tok != TOK_LINEFEED) {
+                    if (tok != TOK_STR) {
+                    include_syntax:
+                        tcc_error("'#include' expects \"FILENAME\" or <FILENAME>");
+                    }
+                    pstrcat(buf, sizeof(buf), (char *)tokc.cstr->data);
+                    next();
+                }
+                c = '\"';
+            } else {
+                int len;
+                while (tok != TOK_LINEFEED) {
+                    pstrcat(buf, sizeof(buf), get_tok_str(tok, &tokc));
+                    next();
+                }
+                len = strlen(buf);
+                /* check syntax and remove '<>' */
+                if (len < 2 || buf[0] != '<' || buf[len - 1] != '>')
+                    goto include_syntax;
+                memmove(buf, buf + 1, len - 2);
+                buf[len - 2] = '\0';
+                c = '>';
+            }
+        }
+
+        if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE)
+            tcc_error("#include recursion too deep");
+        /* store current file in stack, but increment stack later below */
+        *s1->include_stack_ptr = file;
+
+        n = s1->nb_include_paths + s1->nb_sysinclude_paths;
+        for (i = -2; i < n; ++i) {
+            char buf1[sizeof file->filename];
+            CachedInclude *e;
+            BufferedFile **f;
+            const char *path;
+
+            if (i == -2) {
+                /* check absolute include path */
+                if (!IS_ABSPATH(buf))
+                    continue;
+                buf1[0] = 0;
+                i = n; /* force end loop */
+
+            } else if (i == -1) {
+                /* search in current dir if "header.h" */
+                if (c != '\"')
+                    continue;
+                path = file->filename;
+                pstrncpy(buf1, path, tcc_basename(path) - path);
+
+            } else {
+                /* search in all the include paths */
+                if (i < s1->nb_include_paths)
+                    path = s1->include_paths[i];
+                else
+                    path = s1->sysinclude_paths[i - s1->nb_include_paths];
+                pstrcpy(buf1, sizeof(buf1), path);
+                pstrcat(buf1, sizeof(buf1), "/");
+            }
+
+            pstrcat(buf1, sizeof(buf1), buf);
+
+            if (tok == TOK_INCLUDE_NEXT)
+                for (f = s1->include_stack_ptr; f >= s1->include_stack; --f)
+                    if (0 == PATHCMP((*f)->filename, buf1)) {
+#ifdef INC_DEBUG
+                        printf("%s: #include_next skipping %s\n", file->filename, buf1);
+#endif
+                        goto include_trynext;
+                    }
+
+            e = search_cached_include(s1, buf1);
+            if (e && define_find(e->ifndef_macro)) {
+                /* no need to parse the include because the 'ifndef macro'
+                   is defined */
+#ifdef INC_DEBUG
+                printf("%s: skipping cached %s\n", file->filename, buf1);
+#endif
+                goto include_done;
+            }
+
+            if (tcc_open(s1, buf1) < 0)
+include_trynext:
+                continue;
+
+#ifdef INC_DEBUG
+            printf("%s: including %s\n", file->prev->filename, file->filename);
+#endif
+            /* update target deps */
+            dynarray_add((void ***)&s1->target_deps, &s1->nb_target_deps,
+                    tcc_strdup(buf1));
+            /* push current file in stack */
+            ++s1->include_stack_ptr;
+            /* add include file debug info */
+            if (s1->do_debug)
+                put_stabs(file->filename, N_BINCL, 0, 0, 0);
+            tok_flags |= TOK_FLAG_BOF | TOK_FLAG_BOL;
+            ch = file->buf_ptr[0];
+            goto the_end;
+        }
+        tcc_error("include file '%s' not found", buf);
+include_done:
+        break;
+    case TOK_IFNDEF:
+        c = 1;
+        goto do_ifdef;
+    case TOK_IF:
+        c = expr_preprocess();
+        goto do_if;
+    case TOK_IFDEF:
+        c = 0;
+    do_ifdef:
+        next_nomacro();
+        if (tok < TOK_IDENT)
+            tcc_error("invalid argument for '#if%sdef'", c ? "n" : "");
+        if (is_bof) {
+            if (c) {
+#ifdef INC_DEBUG
+                printf("#ifndef %s\n", get_tok_str(tok, NULL));
+#endif
+                file->ifndef_macro = tok;
+            }
+        }
+        c = (define_find(tok) != 0) ^ c;
+    do_if:
+        if (s1->ifdef_stack_ptr >= s1->ifdef_stack + IFDEF_STACK_SIZE)
+            tcc_error("memory full");
+        *s1->ifdef_stack_ptr++ = c;
+        goto test_skip;
+    case TOK_ELSE:
+        if (s1->ifdef_stack_ptr == s1->ifdef_stack)
+            tcc_error("#else without matching #if");
+        if (s1->ifdef_stack_ptr[-1] & 2)
+            tcc_error("#else after #else");
+        c = (s1->ifdef_stack_ptr[-1] ^= 3);
+        goto test_else;
+    case TOK_ELIF:
+        if (s1->ifdef_stack_ptr == s1->ifdef_stack)
+            tcc_error("#elif without matching #if");
+        c = s1->ifdef_stack_ptr[-1];
+        if (c > 1)
+            tcc_error("#elif after #else");
+        /* last #if/#elif expression was true: we skip */
+        if (c == 1)
+            goto skip;
+        c = expr_preprocess();
+        s1->ifdef_stack_ptr[-1] = c;
+    test_else:
+        if (s1->ifdef_stack_ptr == file->ifdef_stack_ptr + 1)
+            file->ifndef_macro = 0;
+    test_skip:
+        if (!(c & 1)) {
+        skip:
+            preprocess_skip();
+            is_bof = 0;
+            goto redo;
+        }
+        break;
+    case TOK_ENDIF:
+        if (s1->ifdef_stack_ptr <= file->ifdef_stack_ptr)
+            tcc_error("#endif without matching #if");
+        s1->ifdef_stack_ptr--;
+        /* '#ifndef macro' was at the start of file. Now we check if
+           an '#endif' is exactly at the end of file */
+        if (file->ifndef_macro &&
+            s1->ifdef_stack_ptr == file->ifdef_stack_ptr) {
+            file->ifndef_macro_saved = file->ifndef_macro;
+            /* need to set to zero to avoid false matches if another
+               #ifndef at middle of file */
+            file->ifndef_macro = 0;
+            while (tok != TOK_LINEFEED)
+                next_nomacro();
+            tok_flags |= TOK_FLAG_ENDIF;
+            goto the_end;
+        }
+        break;
+    case TOK_LINE:
+        next();
+        if (tok != TOK_CINT)
+            tcc_error("#line");
+        file->line_num = tokc.i - 1; /* the line number will be incremented after */
+        next();
+        if (tok != TOK_LINEFEED) {
+            if (tok != TOK_STR)
+                tcc_error("#line");
+            pstrcpy(file->filename, sizeof(file->filename), 
+                    (char *)tokc.cstr->data);
+        }
+        break;
+    case TOK_ERROR:
+    case TOK_WARNING:
+        c = tok;
+        ch = file->buf_ptr[0];
+        skip_spaces();
+        q = buf;
+        while (ch != '\n' && ch != CH_EOF) {
+            if ((q - buf) < sizeof(buf) - 1)
+                *q++ = ch;
+            if (ch == '\\') {
+                if (handle_stray_noerror() == 0)
+                    --q;
+            } else
+                inp();
+        }
+        *q = '\0';
+        if (c == TOK_ERROR)
+            tcc_error("#error %s", buf);
+        else
+            tcc_warning("#warning %s", buf);
+        break;
+    case TOK_PRAGMA:
+        pragma_parse(s1);
+        break;
+    default:
+        if (tok == TOK_LINEFEED || tok == '!' || tok == TOK_PPNUM) {
+            /* '!' is ignored to allow C scripts. numbers are ignored
+               to emulate cpp behaviour */
+        } else {
+            if (!(saved_parse_flags & PARSE_FLAG_ASM_COMMENTS))
+                tcc_warning("Ignoring unknown preprocessing directive #%s", get_tok_str(tok, &tokc));
+            else {
+                /* this is a gas line comment in an 'S' file. */
+                file->buf_ptr = parse_line_comment(file->buf_ptr);
+                goto the_end;
+            }
+        }
+        break;
+    }
+    /* ignore other preprocess commands or #! for C scripts */
+    while (tok != TOK_LINEFEED)
+        next_nomacro();
+ the_end:
+    parse_flags = saved_parse_flags;
+}
+
+/* evaluate escape codes in a string. */
+static void parse_escape_string(CString *outstr, const uint8_t *buf, int is_long)
+{
+    int c, n;
+    const uint8_t *p;
+
+    p = buf;
+    for(;;) {
+        c = *p;
+        if (c == '\0')
+            break;
+        if (c == '\\') {
+            p++;
+            /* escape */
+            c = *p;
+            switch(c) {
+            case '0': case '1': case '2': case '3':
+            case '4': case '5': case '6': case '7':
+                /* at most three octal digits */
+                n = c - '0';
+                p++;
+                c = *p;
+                if (isoct(c)) {
+                    n = n * 8 + c - '0';
+                    p++;
+                    c = *p;
+                    if (isoct(c)) {
+                        n = n * 8 + c - '0';
+                        p++;
+                    }
+                }
+                c = n;
+                goto add_char_nonext;
+            case 'x':
+            case 'u':
+            case 'U':
+                p++;
+                n = 0;
+                for(;;) {
+                    c = *p;
+                    if (c >= 'a' && c <= 'f')
+                        c = c - 'a' + 10;
+                    else if (c >= 'A' && c <= 'F')
+                        c = c - 'A' + 10;
+                    else if (isnum(c))
+                        c = c - '0';
+                    else
+                        break;
+                    n = n * 16 + c;
+                    p++;
+                }
+                c = n;
+                goto add_char_nonext;
+            case 'a':
+                c = '\a';
+                break;
+            case 'b':
+                c = '\b';
+                break;
+            case 'f':
+                c = '\f';
+                break;
+            case 'n':
+                c = '\n';
+                break;
+            case 'r':
+                c = '\r';
+                break;
+            case 't':
+                c = '\t';
+                break;
+            case 'v':
+                c = '\v';
+                break;
+            case 'e':
+                if (!gnu_ext)
+                    goto invalid_escape;
+                c = 27;
+                break;
+            case '\'':
+            case '\"':
+            case '\\': 
+            case '?':
+                break;
+            default:
+            invalid_escape:
+                if (c >= '!' && c <= '~')
+                    tcc_warning("unknown escape sequence: \'\\%c\'", c);
+                else
+                    tcc_warning("unknown escape sequence: \'\\x%x\'", c);
+                break;
+            }
+        }
+        p++;
+    add_char_nonext:
+        if (!is_long)
+            cstr_ccat(outstr, c);
+        else
+            cstr_wccat(outstr, c);
+    }
+    /* add a trailing '\0' */
+    if (!is_long)
+        cstr_ccat(outstr, '\0');
+    else
+        cstr_wccat(outstr, '\0');
+}
+
+/* we use 64 bit numbers */
+#define BN_SIZE 2
+
+/* bn = (bn << shift) | or_val */
+static void bn_lshift(unsigned int *bn, int shift, int or_val)
+{
+    int i;
+    unsigned int v;
+    for(i=0;i<BN_SIZE;i++) {
+        v = bn[i];
+        bn[i] = (v << shift) | or_val;
+        or_val = v >> (32 - shift);
+    }
+}
+
+static void bn_zero(unsigned int *bn)
+{
+    int i;
+    for(i=0;i<BN_SIZE;i++) {
+        bn[i] = 0;
+    }
+}
+
+/* parse number in null terminated string 'p' and return it in the
+   current token */
+static void parse_number(const char *p)
+{
+    int b, t, shift, frac_bits, s, exp_val, ch;
+    char *q;
+    unsigned int bn[BN_SIZE];
+    double d;
+
+    /* number */
+    q = token_buf;
+    ch = *p++;
+    t = ch;
+    ch = *p++;
+    *q++ = t;
+    b = 10;
+    if (t == '.') {
+        goto float_frac_parse;
+    } else if (t == '0') {
+        if (ch == 'x' || ch == 'X') {
+            q--;
+            ch = *p++;
+            b = 16;
+        } else if (tcc_ext && (ch == 'b' || ch == 'B')) {
+            q--;
+            ch = *p++;
+            b = 2;
+        }
+    }
+    /* parse all digits. cannot check octal numbers at this stage
+       because of floating point constants */
+    while (1) {
+        if (ch >= 'a' && ch <= 'f')
+            t = ch - 'a' + 10;
+        else if (ch >= 'A' && ch <= 'F')
+            t = ch - 'A' + 10;
+        else if (isnum(ch))
+            t = ch - '0';
+        else
+            break;
+        if (t >= b)
+            break;
+        if (q >= token_buf + STRING_MAX_SIZE) {
+        num_too_long:
+            tcc_error("number too long");
+        }
+        *q++ = ch;
+        ch = *p++;
+    }
+    if (ch == '.' ||
+        ((ch == 'e' || ch == 'E') && b == 10) ||
+        ((ch == 'p' || ch == 'P') && (b == 16 || b == 2))) {
+        if (b != 10) {
+            /* NOTE: strtox should support that for hexa numbers, but
+               non ISOC99 libcs do not support it, so we prefer to do
+               it by hand */
+            /* hexadecimal or binary floats */
+            /* XXX: handle overflows */
+            *q = '\0';
+            if (b == 16)
+                shift = 4;
+            else 
+                shift = 2;
+            bn_zero(bn);
+            q = token_buf;
+            while (1) {
+                t = *q++;
+                if (t == '\0') {
+                    break;
+                } else if (t >= 'a') {
+                    t = t - 'a' + 10;
+                } else if (t >= 'A') {
+                    t = t - 'A' + 10;
+                } else {
+                    t = t - '0';
+                }
+                bn_lshift(bn, shift, t);
+            }
+            frac_bits = 0;
+            if (ch == '.') {
+                ch = *p++;
+                while (1) {
+                    t = ch;
+                    if (t >= 'a' && t <= 'f') {
+                        t = t - 'a' + 10;
+                    } else if (t >= 'A' && t <= 'F') {
+                        t = t - 'A' + 10;
+                    } else if (t >= '0' && t <= '9') {
+                        t = t - '0';
+                    } else {
+                        break;
+                    }
+                    if (t >= b)
+                        tcc_error("invalid digit");
+                    bn_lshift(bn, shift, t);
+                    frac_bits += shift;
+                    ch = *p++;
+                }
+            }
+            if (ch != 'p' && ch != 'P')
+                expect("exponent");
+            ch = *p++;
+            s = 1;
+            exp_val = 0;
+            if (ch == '+') {
+                ch = *p++;
+            } else if (ch == '-') {
+                s = -1;
+                ch = *p++;
+            }
+            if (ch < '0' || ch > '9')
+                expect("exponent digits");
+            while (ch >= '0' && ch <= '9') {
+                exp_val = exp_val * 10 + ch - '0';
+                ch = *p++;
+            }
+            exp_val = exp_val * s;
+            
+            /* now we can generate the number */
+            /* XXX: should patch directly float number */
+            d = (double)bn[1] * 4294967296.0 + (double)bn[0];
+            d = ldexp(d, exp_val - frac_bits);
+            t = toup(ch);
+            if (t == 'F') {
+                ch = *p++;
+                tok = TOK_CFLOAT;
+                /* float : should handle overflow */
+                tokc.f = (float)d;
+            } else if (t == 'L') {
+                ch = *p++;
+#ifdef TCC_TARGET_PE
+                tok = TOK_CDOUBLE;
+                tokc.d = d;
+#else
+                tok = TOK_CLDOUBLE;
+                /* XXX: not large enough */
+                tokc.ld = (long double)d;
+#endif
+            } else {
+                tok = TOK_CDOUBLE;
+                tokc.d = d;
+            }
+        } else {
+            /* decimal floats */
+            if (ch == '.') {
+                if (q >= token_buf + STRING_MAX_SIZE)
+                    goto num_too_long;
+                *q++ = ch;
+                ch = *p++;
+            float_frac_parse:
+                while (ch >= '0' && ch <= '9') {
+                    if (q >= token_buf + STRING_MAX_SIZE)
+                        goto num_too_long;
+                    *q++ = ch;
+                    ch = *p++;
+                }
+            }
+            if (ch == 'e' || ch == 'E') {
+                if (q >= token_buf + STRING_MAX_SIZE)
+                    goto num_too_long;
+                *q++ = ch;
+                ch = *p++;
+                if (ch == '-' || ch == '+') {
+                    if (q >= token_buf + STRING_MAX_SIZE)
+                        goto num_too_long;
+                    *q++ = ch;
+                    ch = *p++;
+                }
+                if (ch < '0' || ch > '9')
+                    expect("exponent digits");
+                while (ch >= '0' && ch <= '9') {
+                    if (q >= token_buf + STRING_MAX_SIZE)
+                        goto num_too_long;
+                    *q++ = ch;
+                    ch = *p++;
+                }
+            }
+            *q = '\0';
+            t = toup(ch);
+            errno = 0;
+            if (t == 'F') {
+                ch = *p++;
+                tok = TOK_CFLOAT;
+                tokc.f = strtof(token_buf, NULL);
+            } else if (t == 'L') {
+                ch = *p++;
+#ifdef TCC_TARGET_PE
+                tok = TOK_CDOUBLE;
+                tokc.d = strtod(token_buf, NULL);
+#else
+                tok = TOK_CLDOUBLE;
+                tokc.ld = strtold(token_buf, NULL);
+#endif
+            } else {
+                tok = TOK_CDOUBLE;
+                tokc.d = strtod(token_buf, NULL);
+            }
+        }
+    } else {
+        unsigned long long n, n1;
+        int lcount, ucount;
+
+        /* integer number */
+        *q = '\0';
+        q = token_buf;
+        if (b == 10 && *q == '0') {
+            b = 8;
+            q++;
+        }
+        n = 0;
+        while(1) {
+            t = *q++;
+            /* no need for checks except for base 10 / 8 errors */
+            if (t == '\0') {
+                break;
+            } else if (t >= 'a') {
+                t = t - 'a' + 10;
+            } else if (t >= 'A') {
+                t = t - 'A' + 10;
+            } else {
+                t = t - '0';
+                if (t >= b)
+                    tcc_error("invalid digit");
+            }
+            n1 = n;
+            n = n * b + t;
+            /* detect overflow */
+            /* XXX: this test is not reliable */
+            if (n < n1)
+                tcc_error("integer constant overflow");
+        }
+        
+        /* XXX: not exactly ANSI compliant */
+        if ((n & 0xffffffff00000000LL) != 0) {
+            if ((n >> 63) != 0)
+                tok = TOK_CULLONG;
+            else
+                tok = TOK_CLLONG;
+        } else if (n > 0x7fffffff) {
+            tok = TOK_CUINT;
+        } else {
+            tok = TOK_CINT;
+        }
+        lcount = 0;
+        ucount = 0;
+        for(;;) {
+            t = toup(ch);
+            if (t == 'L') {
+                if (lcount >= 2)
+                    tcc_error("three 'l's in integer constant");
+                lcount++;
+#if !defined TCC_TARGET_X86_64 || defined TCC_TARGET_PE
+                if (lcount == 2) {
+#endif
+                    if (tok == TOK_CINT)
+                        tok = TOK_CLLONG;
+                    else if (tok == TOK_CUINT)
+                        tok = TOK_CULLONG;
+#if !defined TCC_TARGET_X86_64 || defined TCC_TARGET_PE
+                }
+#endif
+                ch = *p++;
+            } else if (t == 'U') {
+                if (ucount >= 1)
+                    tcc_error("two 'u's in integer constant");
+                ucount++;
+                if (tok == TOK_CINT)
+                    tok = TOK_CUINT;
+                else if (tok == TOK_CLLONG)
+                    tok = TOK_CULLONG;
+                ch = *p++;
+            } else {
+                break;
+            }
+        }
+        if (tok == TOK_CINT || tok == TOK_CUINT)
+            tokc.ui = n;
+        else
+            tokc.ull = n;
+    }
+    if (ch)
+        tcc_error("invalid number\n");
+}
+
+
+#define PARSE2(c1, tok1, c2, tok2)              \
+    case c1:                                    \
+        PEEKC(c, p);                            \
+        if (c == c2) {                          \
+            p++;                                \
+            tok = tok2;                         \
+        } else {                                \
+            tok = tok1;                         \
+        }                                       \
+        break;
+
+/* return next token without macro substitution */
+static inline void next_nomacro1(void)
+{
+    int t, c, is_long;
+    TokenSym *ts;
+    uint8_t *p, *p1;
+    unsigned int h;
+
+    p = file->buf_ptr;
+ redo_no_start:
+    c = *p;
+    switch(c) {
+    case ' ':
+    case '\t':
+        tok = c;
+        p++;
+        goto keep_tok_flags;
+    case '\f':
+    case '\v':
+    case '\r':
+        p++;
+        goto redo_no_start;
+    case '\\':
+        /* first look if it is in fact an end of buffer */
+        if (p >= file->buf_end) {
+            file->buf_ptr = p;
+            handle_eob();
+            p = file->buf_ptr;
+            if (p >= file->buf_end)
+                goto parse_eof;
+            else
+                goto redo_no_start;
+        } else {
+            file->buf_ptr = p;
+            ch = *p;
+            handle_stray();
+            p = file->buf_ptr;
+            goto redo_no_start;
+        }
+    parse_eof:
+        {
+            TCCState *s1 = tcc_state;
+            if ((parse_flags & PARSE_FLAG_LINEFEED)
+                && !(tok_flags & TOK_FLAG_EOF)) {
+                tok_flags |= TOK_FLAG_EOF;
+                tok = TOK_LINEFEED;
+                goto keep_tok_flags;
+            } else if (!(parse_flags & PARSE_FLAG_PREPROCESS)) {
+                tok = TOK_EOF;
+            } else if (s1->ifdef_stack_ptr != file->ifdef_stack_ptr) {
+                tcc_error("missing #endif");
+            } else if (s1->include_stack_ptr == s1->include_stack) {
+                /* no include left : end of file. */
+                tok = TOK_EOF;
+            } else {
+                tok_flags &= ~TOK_FLAG_EOF;
+                /* pop include file */
+                
+                /* test if previous '#endif' was after a #ifdef at
+                   start of file */
+                if (tok_flags & TOK_FLAG_ENDIF) {
+#ifdef INC_DEBUG
+                    printf("#endif %s\n", get_tok_str(file->ifndef_macro_saved, NULL));
+#endif
+                    add_cached_include(s1, file->filename, file->ifndef_macro_saved);
+                    tok_flags &= ~TOK_FLAG_ENDIF;
+                }
+
+                /* add end of include file debug info */
+                if (tcc_state->do_debug) {
+                    put_stabd(N_EINCL, 0, 0);
+                }
+                /* pop include stack */
+                tcc_close();
+                s1->include_stack_ptr--;
+                p = file->buf_ptr;
+                goto redo_no_start;
+            }
+        }
+        break;
+
+    case '\n':
+        file->line_num++;
+        tok_flags |= TOK_FLAG_BOL;
+        p++;
+maybe_newline:
+        if (0 == (parse_flags & PARSE_FLAG_LINEFEED))
+            goto redo_no_start;
+        tok = TOK_LINEFEED;
+        goto keep_tok_flags;
+
+    case '#':
+        /* XXX: simplify */
+        PEEKC(c, p);
+        if ((tok_flags & TOK_FLAG_BOL) && 
+            (parse_flags & PARSE_FLAG_PREPROCESS)) {
+            file->buf_ptr = p;
+            preprocess(tok_flags & TOK_FLAG_BOF);
+            p = file->buf_ptr;
+            goto maybe_newline;
+        } else {
+            if (c == '#') {
+                p++;
+                tok = TOK_TWOSHARPS;
+            } else {
+                if (parse_flags & PARSE_FLAG_ASM_COMMENTS) {
+                    p = parse_line_comment(p - 1);
+                    goto redo_no_start;
+                } else {
+                    tok = '#';
+                }
+            }
+        }
+        break;
+
+    case 'a': case 'b': case 'c': case 'd':
+    case 'e': case 'f': case 'g': case 'h':
+    case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p':
+    case 'q': case 'r': case 's': case 't':
+    case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z': 
+    case 'A': case 'B': case 'C': case 'D':
+    case 'E': case 'F': case 'G': case 'H':
+    case 'I': case 'J': case 'K': 
+    case 'M': case 'N': case 'O': case 'P':
+    case 'Q': case 'R': case 'S': case 'T':
+    case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z': 
+    case '_':
+    parse_ident_fast:
+        p1 = p;
+        h = TOK_HASH_INIT;
+        h = TOK_HASH_FUNC(h, c);
+        p++;
+        for(;;) {
+            c = *p;
+            if (!isidnum_table[c-CH_EOF])
+                break;
+            h = TOK_HASH_FUNC(h, c);
+            p++;
+        }
+        if (c != '\\') {
+            TokenSym **pts;
+            int len;
+
+            /* fast case : no stray found, so we have the full token
+               and we have already hashed it */
+            len = p - p1;
+            h &= (TOK_HASH_SIZE - 1);
+            pts = &hash_ident[h];
+            for(;;) {
+                ts = *pts;
+                if (!ts)
+                    break;
+                if (ts->len == len && !memcmp(ts->str, p1, len))
+                    goto token_found;
+                pts = &(ts->hash_next);
+            }
+            ts = tok_alloc_new(pts, p1, len);
+        token_found: ;
+        } else {
+            /* slower case */
+            cstr_reset(&tokcstr);
+
+            while (p1 < p) {
+                cstr_ccat(&tokcstr, *p1);
+                p1++;
+            }
+            p--;
+            PEEKC(c, p);
+        parse_ident_slow:
+            while (isidnum_table[c-CH_EOF]) {
+                cstr_ccat(&tokcstr, c);
+                PEEKC(c, p);
+            }
+            ts = tok_alloc(tokcstr.data, tokcstr.size);
+        }
+        tok = ts->tok;
+        break;
+    case 'L':
+        t = p[1];
+        if (t != '\\' && t != '\'' && t != '\"') {
+            /* fast case */
+            goto parse_ident_fast;
+        } else {
+            PEEKC(c, p);
+            if (c == '\'' || c == '\"') {
+                is_long = 1;
+                goto str_const;
+            } else {
+                cstr_reset(&tokcstr);
+                cstr_ccat(&tokcstr, 'L');
+                goto parse_ident_slow;
+            }
+        }
+        break;
+    case '0': case '1': case '2': case '3':
+    case '4': case '5': case '6': case '7':
+    case '8': case '9':
+
+        cstr_reset(&tokcstr);
+        /* after the first digit, accept digits, alpha, '.' or sign if
+           prefixed by 'eEpP' */
+    parse_num:
+        for(;;) {
+            t = c;
+            cstr_ccat(&tokcstr, c);
+            PEEKC(c, p);
+            if (!(isnum(c) || isid(c) || c == '.' ||
+                  ((c == '+' || c == '-') && 
+                   (t == 'e' || t == 'E' || t == 'p' || t == 'P'))))
+                break;
+        }
+        /* We add a trailing '\0' to ease parsing */
+        cstr_ccat(&tokcstr, '\0');
+        tokc.cstr = &tokcstr;
+        tok = TOK_PPNUM;
+        break;
+    case '.':
+        /* special dot handling because it can also start a number */
+        PEEKC(c, p);
+        if (isnum(c)) {
+            cstr_reset(&tokcstr);
+            cstr_ccat(&tokcstr, '.');
+            goto parse_num;
+        } else if (c == '.') {
+            PEEKC(c, p);
+            if (c != '.')
+                expect("'.'");
+            PEEKC(c, p);
+            tok = TOK_DOTS;
+        } else {
+            tok = '.';
+        }
+        break;
+    case '\'':
+    case '\"':
+        is_long = 0;
+    str_const:
+        {
+            CString str;
+            int sep;
+
+            sep = c;
+
+            /* parse the string */
+            cstr_new(&str);
+            p = parse_pp_string(p, sep, &str);
+            cstr_ccat(&str, '\0');
+            
+            /* eval the escape (should be done as TOK_PPNUM) */
+            cstr_reset(&tokcstr);
+            parse_escape_string(&tokcstr, str.data, is_long);
+            cstr_free(&str);
+
+            if (sep == '\'') {
+                int char_size;
+                /* XXX: make it portable */
+                if (!is_long)
+                    char_size = 1;
+                else
+                    char_size = sizeof(nwchar_t);
+                if (tokcstr.size <= char_size)
+                    tcc_error("empty character constant");
+                if (tokcstr.size > 2 * char_size)
+                    tcc_warning("multi-character character constant");
+                if (!is_long) {
+                    tokc.i = *(int8_t *)tokcstr.data;
+                    tok = TOK_CCHAR;
+                } else {
+                    tokc.i = *(nwchar_t *)tokcstr.data;
+                    tok = TOK_LCHAR;
+                }
+            } else {
+                tokc.cstr = &tokcstr;
+                if (!is_long)
+                    tok = TOK_STR;
+                else
+                    tok = TOK_LSTR;
+            }
+        }
+        break;
+
+    case '<':
+        PEEKC(c, p);
+        if (c == '=') {
+            p++;
+            tok = TOK_LE;
+        } else if (c == '<') {
+            PEEKC(c, p);
+            if (c == '=') {
+                p++;
+                tok = TOK_A_SHL;
+            } else {
+                tok = TOK_SHL;
+            }
+        } else {
+            tok = TOK_LT;
+        }
+        break;
+        
+    case '>':
+        PEEKC(c, p);
+        if (c == '=') {
+            p++;
+            tok = TOK_GE;
+        } else if (c == '>') {
+            PEEKC(c, p);
+            if (c == '=') {
+                p++;
+                tok = TOK_A_SAR;
+            } else {
+                tok = TOK_SAR;
+            }
+        } else {
+            tok = TOK_GT;
+        }
+        break;
+        
+    case '&':
+        PEEKC(c, p);
+        if (c == '&') {
+            p++;
+            tok = TOK_LAND;
+        } else if (c == '=') {
+            p++;
+            tok = TOK_A_AND;
+        } else {
+            tok = '&';
+        }
+        break;
+        
+    case '|':
+        PEEKC(c, p);
+        if (c == '|') {
+            p++;
+            tok = TOK_LOR;
+        } else if (c == '=') {
+            p++;
+            tok = TOK_A_OR;
+        } else {
+            tok = '|';
+        }
+        break;
+
+    case '+':
+        PEEKC(c, p);
+        if (c == '+') {
+            p++;
+            tok = TOK_INC;
+        } else if (c == '=') {
+            p++;
+            tok = TOK_A_ADD;
+        } else {
+            tok = '+';
+        }
+        break;
+        
+    case '-':
+        PEEKC(c, p);
+        if (c == '-') {
+            p++;
+            tok = TOK_DEC;
+        } else if (c == '=') {
+            p++;
+            tok = TOK_A_SUB;
+        } else if (c == '>') {
+            p++;
+            tok = TOK_ARROW;
+        } else {
+            tok = '-';
+        }
+        break;
+
+    PARSE2('!', '!', '=', TOK_NE)
+    PARSE2('=', '=', '=', TOK_EQ)
+    PARSE2('*', '*', '=', TOK_A_MUL)
+    PARSE2('%', '%', '=', TOK_A_MOD)
+    PARSE2('^', '^', '=', TOK_A_XOR)
+        
+        /* comments or operator */
+    case '/':
+        PEEKC(c, p);
+        if (c == '*') {
+            p = parse_comment(p);
+            /* comments replaced by a blank */
+            tok = ' ';
+            goto keep_tok_flags;
+        } else if (c == '/') {
+            p = parse_line_comment(p);
+            tok = ' ';
+            goto keep_tok_flags;
+        } else if (c == '=') {
+            p++;
+            tok = TOK_A_DIV;
+        } else {
+            tok = '/';
+        }
+        break;
+        
+        /* simple tokens */
+    case '(':
+    case ')':
+    case '[':
+    case ']':
+    case '{':
+    case '}':
+    case ',':
+    case ';':
+    case ':':
+    case '?':
+    case '~':
+    case '$': /* only used in assembler */
+    case '@': /* dito */
+        tok = c;
+        p++;
+        break;
+    default:
+        tcc_error("unrecognized character \\x%02x", c);
+        break;
+    }
+    tok_flags = 0;
+keep_tok_flags:
+    file->buf_ptr = p;
+#if defined(PARSE_DEBUG)
+    printf("token = %s\n", get_tok_str(tok, &tokc));
+#endif
+}
+
+/* return next token without macro substitution. Can read input from
+   macro_ptr buffer */
+static void next_nomacro_spc(void)
+{
+    if (macro_ptr) {
+    redo:
+        tok = *macro_ptr;
+        if (tok) {
+            TOK_GET(&tok, &macro_ptr, &tokc);
+            if (tok == TOK_LINENUM) {
+                file->line_num = tokc.i;
+                goto redo;
+            }
+        }
+    } else {
+        next_nomacro1();
+    }
+}
+
+ST_FUNC void next_nomacro(void)
+{
+    do {
+        next_nomacro_spc();
+    } while (is_space(tok));
+}
+ 
+/* substitute args in macro_str and return allocated string */
+static int *macro_arg_subst(Sym **nested_list, const int *macro_str, Sym *args)
+{
+    int last_tok, t, spc;
+    const int *st;
+    Sym *s;
+    CValue cval;
+    TokenString str;
+    CString cstr;
+
+    tok_str_new(&str);
+    last_tok = 0;
+    while(1) {
+        TOK_GET(&t, &macro_str, &cval);
+        if (!t)
+            break;
+        if (t == '#') {
+            /* stringize */
+            TOK_GET(&t, &macro_str, &cval);
+            if (!t)
+                break;
+            s = sym_find2(args, t);
+            if (s) {
+                cstr_new(&cstr);
+                st = s->d;
+                spc = 0;
+                while (*st) {
+                    TOK_GET(&t, &st, &cval);
+                    if (!check_space(t, &spc))
+                        cstr_cat(&cstr, get_tok_str(t, &cval));
+                }
+                cstr.size -= spc;
+                cstr_ccat(&cstr, '\0');
+#ifdef PP_DEBUG
+                printf("stringize: %s\n", (char *)cstr.data);
+#endif
+                /* add string */
+                cval.cstr = &cstr;
+                tok_str_add2(&str, TOK_STR, &cval);
+                cstr_free(&cstr);
+            } else {
+                tok_str_add2(&str, t, &cval);
+            }
+        } else if (t >= TOK_IDENT) {
+            s = sym_find2(args, t);
+            if (s) {
+                st = s->d;
+                /* if '##' is present before or after, no arg substitution */
+                if (*macro_str == TOK_TWOSHARPS || last_tok == TOK_TWOSHARPS) {
+                    /* special case for var arg macros : ## eats the
+                       ',' if empty VA_ARGS variable. */
+                    /* XXX: test of the ',' is not 100%
+                       reliable. should fix it to avoid security
+                       problems */
+                    if (gnu_ext && s->type.t &&
+                        last_tok == TOK_TWOSHARPS && 
+                        str.len >= 2 && str.str[str.len - 2] == ',') {
+                        if (*st == 0) {
+                            /* suppress ',' '##' */
+                            str.len -= 2;
+                        } else {
+                            /* suppress '##' and add variable */
+                            str.len--;
+                            goto add_var;
+                        }
+                    } else {
+                        int t1;
+                    add_var:
+                        for(;;) {
+                            TOK_GET(&t1, &st, &cval);
+                            if (!t1)
+                                break;
+                            tok_str_add2(&str, t1, &cval);
+                        }
+                    }
+                } else {
+                    /* NOTE: the stream cannot be read when macro
+                       substituing an argument */
+                    macro_subst(&str, nested_list, st, NULL);
+                }
+            } else {
+                tok_str_add(&str, t);
+            }
+        } else {
+            tok_str_add2(&str, t, &cval);
+        }
+        last_tok = t;
+    }
+    tok_str_add(&str, 0);
+    return str.str;
+}
+
+static char const ab_month_name[12][4] =
+{
+    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+/* do macro substitution of current token with macro 's' and add
+   result to (tok_str,tok_len). 'nested_list' is the list of all
+   macros we got inside to avoid recursing. Return non zero if no
+   substitution needs to be done */
+static int macro_subst_tok(TokenString *tok_str,
+                           Sym **nested_list, Sym *s, struct macro_level **can_read_stream)
+{
+    Sym *args, *sa, *sa1;
+    int mstr_allocated, parlevel, *mstr, t, t1, spc;
+    const int *p;
+    TokenString str;
+    char *cstrval;
+    CValue cval;
+    CString cstr;
+    char buf[32];
+    
+    /* if symbol is a macro, prepare substitution */
+    /* special macros */
+    if (tok == TOK___LINE__) {
+        snprintf(buf, sizeof(buf), "%d", file->line_num);
+        cstrval = buf;
+        t1 = TOK_PPNUM;
+        goto add_cstr1;
+    } else if (tok == TOK___FILE__) {
+        cstrval = file->filename;
+        goto add_cstr;
+    } else if (tok == TOK___DATE__ || tok == TOK___TIME__) {
+        time_t ti;
+        struct tm *tm;
+
+        time(&ti);
+        tm = localtime(&ti);
+        if (tok == TOK___DATE__) {
+            snprintf(buf, sizeof(buf), "%s %2d %d", 
+                     ab_month_name[tm->tm_mon], tm->tm_mday, tm->tm_year + 1900);
+        } else {
+            snprintf(buf, sizeof(buf), "%02d:%02d:%02d", 
+                     tm->tm_hour, tm->tm_min, tm->tm_sec);
+        }
+        cstrval = buf;
+    add_cstr:
+        t1 = TOK_STR;
+    add_cstr1:
+        cstr_new(&cstr);
+        cstr_cat(&cstr, cstrval);
+        cstr_ccat(&cstr, '\0');
+        cval.cstr = &cstr;
+        tok_str_add2(tok_str, t1, &cval);
+        cstr_free(&cstr);
+    } else {
+        mstr = s->d;
+        mstr_allocated = 0;
+        if (s->type.t == MACRO_FUNC) {
+            /* NOTE: we do not use next_nomacro to avoid eating the
+               next token. XXX: find better solution */
+        redo:
+            if (macro_ptr) {
+                p = macro_ptr;
+                while (is_space(t = *p) || TOK_LINEFEED == t) 
+                    ++p;
+                if (t == 0 && can_read_stream) {
+                    /* end of macro stream: we must look at the token
+                       after in the file */
+                    struct macro_level *ml = *can_read_stream;
+                    macro_ptr = NULL;
+                    if (ml)
+                    {
+                        macro_ptr = ml->p;
+                        ml->p = NULL;
+                        *can_read_stream = ml -> prev;
+                    }
+                    /* also, end of scope for nested defined symbol */
+                    (*nested_list)->v = -1;
+                    goto redo;
+                }
+            } else {
+                ch = file->buf_ptr[0];
+                while (is_space(ch) || ch == '\n' || ch == '/')
+		  {
+		    if (ch == '/')
+		      {
+			int c;
+			uint8_t *p = file->buf_ptr;
+			PEEKC(c, p);
+			if (c == '*') {
+			    p = parse_comment(p);
+			    file->buf_ptr = p - 1;
+			} else if (c == '/') {
+			    p = parse_line_comment(p);
+			    file->buf_ptr = p - 1;
+			} else
+			  break;
+		      }
+		    cinp();
+		  }
+                t = ch;
+            }
+            if (t != '(') /* no macro subst */
+                return -1;
+                    
+            /* argument macro */
+            next_nomacro();
+            next_nomacro();
+            args = NULL;
+            sa = s->next;
+            /* NOTE: empty args are allowed, except if no args */
+            for(;;) {
+                /* handle '()' case */
+                if (!args && !sa && tok == ')')
+                    break;
+                if (!sa)
+                    tcc_error("macro '%s' used with too many args",
+                          get_tok_str(s->v, 0));
+                tok_str_new(&str);
+                parlevel = spc = 0;
+                /* NOTE: non zero sa->t indicates VA_ARGS */
+                while ((parlevel > 0 || 
+                        (tok != ')' && 
+                         (tok != ',' || sa->type.t))) && 
+                       tok != -1) {
+                    if (tok == '(')
+                        parlevel++;
+                    else if (tok == ')')
+                        parlevel--;
+                    if (tok == TOK_LINEFEED)
+                        tok = ' ';
+                    if (!check_space(tok, &spc))
+                        tok_str_add2(&str, tok, &tokc);
+                    next_nomacro_spc();
+                }
+                str.len -= spc;
+                tok_str_add(&str, 0);
+                sa1 = sym_push2(&args, sa->v & ~SYM_FIELD, sa->type.t, 0);
+                sa1->d = str.str;
+                sa = sa->next;
+                if (tok == ')') {
+                    /* special case for gcc var args: add an empty
+                       var arg argument if it is omitted */
+                    if (sa && sa->type.t && gnu_ext)
+                        continue;
+                    else
+                        break;
+                }
+                if (tok != ',')
+                    expect(",");
+                next_nomacro();
+            }
+            if (sa) {
+                tcc_error("macro '%s' used with too few args",
+                      get_tok_str(s->v, 0));
+            }
+
+            /* now subst each arg */
+            mstr = macro_arg_subst(nested_list, mstr, args);
+            /* free memory */
+            sa = args;
+            while (sa) {
+                sa1 = sa->prev;
+                tok_str_free(sa->d);
+                sym_free(sa);
+                sa = sa1;
+            }
+            mstr_allocated = 1;
+        }
+        sym_push2(nested_list, s->v, 0, 0);
+        macro_subst(tok_str, nested_list, mstr, can_read_stream);
+        /* pop nested defined symbol */
+        sa1 = *nested_list;
+        *nested_list = sa1->prev;
+        sym_free(sa1);
+        if (mstr_allocated)
+            tok_str_free(mstr);
+    }
+    return 0;
+}
+
+/* handle the '##' operator. Return NULL if no '##' seen. Otherwise
+   return the resulting string (which must be freed). */
+static inline int *macro_twosharps(const int *macro_str)
+{
+    const int *ptr;
+    int t;
+    TokenString macro_str1;
+    CString cstr;
+    int n, start_of_nosubsts;
+
+    /* we search the first '##' */
+    for(ptr = macro_str;;) {
+        CValue cval;
+        TOK_GET(&t, &ptr, &cval);
+        if (t == TOK_TWOSHARPS)
+            break;
+        /* nothing more to do if end of string */
+        if (t == 0)
+            return NULL;
+    }
+
+    /* we saw '##', so we need more processing to handle it */
+    start_of_nosubsts = -1;
+    tok_str_new(&macro_str1);
+    for(ptr = macro_str;;) {
+        TOK_GET(&tok, &ptr, &tokc);
+        if (tok == 0)
+            break;
+        if (tok == TOK_TWOSHARPS)
+            continue;
+        if (tok == TOK_NOSUBST && start_of_nosubsts < 0)
+            start_of_nosubsts = macro_str1.len;
+        while (*ptr == TOK_TWOSHARPS) {
+            /* given 'a##b', remove nosubsts preceding 'a' */
+            if (start_of_nosubsts >= 0)
+                macro_str1.len = start_of_nosubsts;
+            /* given 'a##b', skip '##' */
+            t = *++ptr;
+            /* given 'a##b', remove nosubsts preceding 'b' */
+            while (t == TOK_NOSUBST)
+                t = *++ptr;
+            if (t && t != TOK_TWOSHARPS) {
+                CValue cval;
+                TOK_GET(&t, &ptr, &cval);
+                /* We concatenate the two tokens */
+                cstr_new(&cstr);
+                cstr_cat(&cstr, get_tok_str(tok, &tokc));
+                n = cstr.size;
+                cstr_cat(&cstr, get_tok_str(t, &cval));
+                cstr_ccat(&cstr, '\0');
+
+                tcc_open_bf(tcc_state, ":paste:", cstr.size);
+                memcpy(file->buffer, cstr.data, cstr.size);
+                for (;;) {
+                    next_nomacro1();
+                    if (0 == *file->buf_ptr)
+                        break;
+                    tok_str_add2(&macro_str1, tok, &tokc);
+                    tcc_warning("pasting \"%.*s\" and \"%s\" does not give a valid preprocessing token",
+                        n, cstr.data, (char*)cstr.data + n);
+                }
+                tcc_close();
+                cstr_free(&cstr);
+            }
+        }
+        if (tok != TOK_NOSUBST) 
+            start_of_nosubsts = -1;
+        tok_str_add2(&macro_str1, tok, &tokc);
+    }
+    tok_str_add(&macro_str1, 0);
+    return macro_str1.str;
+}
+
+
+/* do macro substitution of macro_str and add result to
+   (tok_str,tok_len). 'nested_list' is the list of all macros we got
+   inside to avoid recursing. */
+static void macro_subst(TokenString *tok_str, Sym **nested_list, 
+                        const int *macro_str, struct macro_level ** can_read_stream)
+{
+    Sym *s;
+    int *macro_str1;
+    const int *ptr;
+    int t, ret, spc;
+    CValue cval;
+    struct macro_level ml;
+    int force_blank;
+    
+    /* first scan for '##' operator handling */
+    ptr = macro_str;
+    macro_str1 = macro_twosharps(ptr);
+
+    if (macro_str1) 
+        ptr = macro_str1;
+    spc = 0;
+    force_blank = 0;
+
+    while (1) {
+        /* NOTE: ptr == NULL can only happen if tokens are read from
+           file stream due to a macro function call */
+        if (ptr == NULL)
+            break;
+        TOK_GET(&t, &ptr, &cval);
+        if (t == 0)
+            break;
+        if (t == TOK_NOSUBST) {
+            /* following token has already been subst'd. just copy it on */
+            tok_str_add2(tok_str, TOK_NOSUBST, NULL);
+            TOK_GET(&t, &ptr, &cval);
+            goto no_subst;
+        }
+        s = define_find(t);
+        if (s != NULL) {
+            /* if nested substitution, do nothing */
+            if (sym_find2(*nested_list, t)) {
+                /* and mark it as TOK_NOSUBST, so it doesn't get subst'd again */
+                tok_str_add2(tok_str, TOK_NOSUBST, NULL);
+                goto no_subst;
+            }
+            ml.p = macro_ptr;
+            if (can_read_stream)
+                ml.prev = *can_read_stream, *can_read_stream = &ml;
+            macro_ptr = (int *)ptr;
+            tok = t;
+            ret = macro_subst_tok(tok_str, nested_list, s, can_read_stream);
+            ptr = (int *)macro_ptr;
+            macro_ptr = ml.p;
+            if (can_read_stream && *can_read_stream == &ml)
+                *can_read_stream = ml.prev;
+            if (ret != 0)
+                goto no_subst;
+            if (parse_flags & PARSE_FLAG_SPACES)
+                force_blank = 1;
+        } else {
+        no_subst:
+            if (force_blank) {
+                tok_str_add(tok_str, ' ');
+                spc = 1;
+                force_blank = 0;
+            }
+            if (!check_space(t, &spc)) 
+                tok_str_add2(tok_str, t, &cval);
+        }
+    }
+    if (macro_str1)
+        tok_str_free(macro_str1);
+}
+
+/* return next token with macro substitution */
+ST_FUNC void next(void)
+{
+    Sym *nested_list, *s;
+    TokenString str;
+    struct macro_level *ml;
+
+ redo:
+    if (parse_flags & PARSE_FLAG_SPACES)
+        next_nomacro_spc();
+    else
+        next_nomacro();
+    if (!macro_ptr) {
+        /* if not reading from macro substituted string, then try
+           to substitute macros */
+        if (tok >= TOK_IDENT &&
+            (parse_flags & PARSE_FLAG_PREPROCESS)) {
+            s = define_find(tok);
+            if (s) {
+                /* we have a macro: we try to substitute */
+                tok_str_new(&str);
+                nested_list = NULL;
+                ml = NULL;
+                if (macro_subst_tok(&str, &nested_list, s, &ml) == 0) {
+                    /* substitution done, NOTE: maybe empty */
+                    tok_str_add(&str, 0);
+                    macro_ptr = str.str;
+                    macro_ptr_allocated = str.str;
+                    goto redo;
+                }
+            }
+        }
+    } else {
+        if (tok == 0) {
+            /* end of macro or end of unget buffer */
+            if (unget_buffer_enabled) {
+                macro_ptr = unget_saved_macro_ptr;
+                unget_buffer_enabled = 0;
+            } else {
+                /* end of macro string: free it */
+                tok_str_free(macro_ptr_allocated);
+                macro_ptr_allocated = NULL;
+                macro_ptr = NULL;
+            }
+            goto redo;
+        } else if (tok == TOK_NOSUBST) {
+            /* discard preprocessor's nosubst markers */
+            goto redo;
+        }
+    }
+    
+    /* convert preprocessor tokens into C tokens */
+    if (tok == TOK_PPNUM &&
+        (parse_flags & PARSE_FLAG_TOK_NUM)) {
+        parse_number((char *)tokc.cstr->data);
+    }
+}
+
+/* push back current token and set current token to 'last_tok'. Only
+   identifier case handled for labels. */
+ST_INLN void unget_tok(int last_tok)
+{
+    int i, n;
+    int *q;
+    if (unget_buffer_enabled)
+      {
+        /* assert(macro_ptr == unget_saved_buffer + 1);
+	   assert(*macro_ptr == 0);  */
+      }
+    else
+      {
+	unget_saved_macro_ptr = macro_ptr;
+	unget_buffer_enabled = 1;
+      }
+    q = unget_saved_buffer;
+    macro_ptr = q;
+    *q++ = tok;
+    n = tok_ext_size(tok) - 1;
+    for(i=0;i<n;i++)
+        *q++ = tokc.tab[i];
+    *q = 0; /* end of token string */
+    tok = last_tok;
+}
+
+
+/* better than nothing, but needs extension to handle '-E' option
+   correctly too */
+ST_FUNC void preprocess_init(TCCState *s1)
+{
+    s1->include_stack_ptr = s1->include_stack;
+    /* XXX: move that before to avoid having to initialize
+       file->ifdef_stack_ptr ? */
+    s1->ifdef_stack_ptr = s1->ifdef_stack;
+    file->ifdef_stack_ptr = s1->ifdef_stack_ptr;
+
+    vtop = vstack - 1;
+    s1->pack_stack[0] = 0;
+    s1->pack_stack_ptr = s1->pack_stack;
+}
+
+ST_FUNC void preprocess_new(void)
+{
+    int i, c;
+    const char *p, *r;
+
+    /* init isid table */
+    for(i=CH_EOF;i<256;i++)
+        isidnum_table[i-CH_EOF] = isid(i) || isnum(i);
+
+    /* add all tokens */
+    table_ident = NULL;
+    memset(hash_ident, 0, TOK_HASH_SIZE * sizeof(TokenSym *));
+    
+    tok_ident = TOK_IDENT;
+    p = tcc_keywords;
+    while (*p) {
+        r = p;
+        for(;;) {
+            c = *r++;
+            if (c == '\0')
+                break;
+        }
+        tok_alloc(p, r - p - 1);
+        p = r;
+    }
+}
+
+/* Preprocess the current file */
+ST_FUNC int tcc_preprocess(TCCState *s1)
+{
+    Sym *define_start;
+
+    BufferedFile *file_ref, **iptr, **iptr_new;
+    int token_seen, line_ref, d;
+    const char *s;
+
+    preprocess_init(s1);
+    define_start = define_stack;
+    ch = file->buf_ptr[0];
+    tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
+    parse_flags = PARSE_FLAG_ASM_COMMENTS | PARSE_FLAG_PREPROCESS |
+        PARSE_FLAG_LINEFEED | PARSE_FLAG_SPACES;
+    token_seen = 0;
+    line_ref = 0;
+    file_ref = NULL;
+    iptr = s1->include_stack_ptr;
+
+    for (;;) {
+        next();
+        if (tok == TOK_EOF) {
+            break;
+        } else if (file != file_ref) {
+            goto print_line;
+        } else if (tok == TOK_LINEFEED) {
+            if (!token_seen)
+                continue;
+            ++line_ref;
+            token_seen = 0;
+        } else if (!token_seen) {
+            d = file->line_num - line_ref;
+            if (file != file_ref || d < 0 || d >= 8) {
+print_line:
+                iptr_new = s1->include_stack_ptr;
+                s = iptr_new > iptr ? " 1"
+                  : iptr_new < iptr ? " 2"
+                  : iptr_new > s1->include_stack ? " 3"
+                  : ""
+                  ;
+                iptr = iptr_new;
+                fprintf(s1->ppfp, "# %d \"%s\"%s\n", file->line_num, file->filename, s);
+            } else {
+                while (d)
+                    fputs("\n", s1->ppfp), --d;
+            }
+            line_ref = (file_ref = file)->line_num;
+            token_seen = tok != TOK_LINEFEED;
+            if (!token_seen)
+                continue;
+        }
+        fputs(get_tok_str(tok, &tokc), s1->ppfp);
+    }
+    free_defines(define_start);
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tccrun.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tccrun.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tccrun.c	(revision 279)
@@ -0,0 +1,733 @@
+/*
+ *  TCC - Tiny C Compiler - Support for -run switch
+ *
+ *  Copyright (c) 2001-2004 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "tcc.h"
+
+/* only native compiler supports -run */
+#ifdef TCC_IS_NATIVE
+
+#ifdef CONFIG_TCC_BACKTRACE
+ST_DATA int rt_num_callers = 6;
+ST_DATA const char **rt_bound_error_msg;
+ST_DATA void *rt_prog_main;
+#endif
+
+#ifdef _WIN32
+#define ucontext_t CONTEXT
+#endif
+
+static void set_pages_executable(void *ptr, unsigned long length);
+static void set_exception_handler(void);
+static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level);
+static void rt_error(ucontext_t *uc, const char *fmt, ...);
+static int tcc_relocate_ex(TCCState *s1, void *ptr);
+
+#ifdef _WIN64
+static void win64_add_function_table(TCCState *s1);
+#endif
+
+/* ------------------------------------------------------------- */
+/* Do all relocations (needed before using tcc_get_symbol())
+   Returns -1 on error. */
+
+LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr)
+{
+    int ret;
+
+    if (TCC_RELOCATE_AUTO != ptr)
+        return tcc_relocate_ex(s1, ptr);
+
+    ret = tcc_relocate_ex(s1, NULL);
+    if (ret < 0)
+        return ret;
+
+#ifdef HAVE_SELINUX
+    {   /* Use mmap instead of malloc for Selinux.  Ref:
+           http://www.gnu.org/s/libc/manual/html_node/File-Size.html */
+
+        char tmpfname[] = "/tmp/.tccrunXXXXXX";
+        int fd = mkstemp (tmpfname);
+
+        s1->mem_size = ret;
+        unlink (tmpfname);
+        ftruncate (fd, s1->mem_size);
+
+        s1->write_mem = mmap (NULL, ret, PROT_READ|PROT_WRITE,
+            MAP_SHARED, fd, 0);
+        if (s1->write_mem == MAP_FAILED)
+            tcc_error("/tmp not writeable");
+
+        s1->runtime_mem = mmap (NULL, ret, PROT_READ|PROT_EXEC,
+            MAP_SHARED, fd, 0);
+        if (s1->runtime_mem == MAP_FAILED)
+            tcc_error("/tmp not executable");
+
+        ret = tcc_relocate_ex(s1, s1->write_mem);
+    }
+#else
+    s1->runtime_mem = tcc_malloc(ret);
+    ret = tcc_relocate_ex(s1, s1->runtime_mem);
+#endif
+    return ret;
+}
+
+/* launch the compiled program with the given arguments */
+LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
+{
+    int (*prog_main)(int, char **);
+    int ret;
+
+    if (tcc_relocate(s1, TCC_RELOCATE_AUTO) < 0)
+        return -1;
+
+    prog_main = tcc_get_symbol_err(s1, "main");
+
+#ifdef CONFIG_TCC_BACKTRACE
+    if (s1->do_debug) {
+        set_exception_handler();
+        rt_prog_main = prog_main;
+    }
+#endif
+
+#ifdef CONFIG_TCC_BCHECK
+    if (s1->do_bounds_check) {
+        void (*bound_init)(void);
+        void (*bound_exit)(void);
+        /* set error function */
+        rt_bound_error_msg = tcc_get_symbol_err(s1, "__bound_error_msg");
+        /* XXX: use .init section so that it also work in binary ? */
+        bound_init = tcc_get_symbol_err(s1, "__bound_init");
+        bound_exit = tcc_get_symbol_err(s1, "__bound_exit");
+        bound_init();
+        ret = (*prog_main)(argc, argv);
+        bound_exit();
+    } else
+#endif
+        ret = (*prog_main)(argc, argv);
+    return ret;
+}
+
+/* relocate code. Return -1 on error, required size if ptr is NULL,
+   otherwise copy code into buffer passed by the caller */
+static int tcc_relocate_ex(TCCState *s1, void *ptr)
+{
+    Section *s;
+    unsigned long offset, length;
+    addr_t mem;
+    int i;
+
+    if (NULL == ptr) {
+        s1->nb_errors = 0;
+#ifdef TCC_TARGET_PE
+        pe_output_file(s1, NULL);
+#else
+        tcc_add_runtime(s1);
+        relocate_common_syms();
+        tcc_add_linker_symbols(s1);
+        build_got_entries(s1);
+#endif
+        if (s1->nb_errors)
+            return -1;
+    }
+
+    offset = 0, mem = (addr_t)ptr;
+    for(i = 1; i < s1->nb_sections; i++) {
+        s = s1->sections[i];
+        if (0 == (s->sh_flags & SHF_ALLOC))
+            continue;
+        length = s->data_offset;
+        s->sh_addr = mem ? (mem + offset + 15) & ~15 : 0;
+        offset = (offset + length + 15) & ~15;
+    }
+    offset += 16;
+
+    /* relocate symbols */
+    relocate_syms(s1, 1);
+    if (s1->nb_errors)
+        return -1;
+
+#ifdef TCC_HAS_RUNTIME_PLTGOT
+    s1->runtime_plt_and_got_offset = 0;
+    s1->runtime_plt_and_got = (char *)(mem + offset);
+    /* double the size of the buffer for got and plt entries
+       XXX: calculate exact size for them? */
+    offset *= 2;
+#endif
+
+    if (0 == mem)
+        return offset;
+
+    /* relocate each section */
+    for(i = 1; i < s1->nb_sections; i++) {
+        s = s1->sections[i];
+        if (s->reloc)
+            relocate_section(s1, s);
+    }
+
+    for(i = 1; i < s1->nb_sections; i++) {
+        s = s1->sections[i];
+        if (0 == (s->sh_flags & SHF_ALLOC))
+            continue;
+        length = s->data_offset;
+        // printf("%-12s %08x %04x\n", s->name, s->sh_addr, length);
+        ptr = (void*)s->sh_addr;
+        if (NULL == s->data || s->sh_type == SHT_NOBITS)
+            memset(ptr, 0, length);
+        else
+            memcpy(ptr, s->data, length);
+        /* mark executable sections as executable in memory */
+        if (s->sh_flags & SHF_EXECINSTR)
+            set_pages_executable(ptr, length);
+    }
+
+#ifdef TCC_HAS_RUNTIME_PLTGOT
+    set_pages_executable(s1->runtime_plt_and_got,
+                         s1->runtime_plt_and_got_offset);
+#endif
+
+#ifdef _WIN64
+    win64_add_function_table(s1);
+#endif
+    return 0;
+}
+
+/* ------------------------------------------------------------- */
+/* allow to run code in memory */
+
+static void set_pages_executable(void *ptr, unsigned long length)
+{
+#ifdef _WIN32
+    unsigned long old_protect;
+    VirtualProtect(ptr, length, PAGE_EXECUTE_READWRITE, &old_protect);
+#else
+#ifndef PAGESIZE
+# define PAGESIZE 4096
+#endif
+    addr_t start, end;
+    start = (addr_t)ptr & ~(PAGESIZE - 1);
+    end = (addr_t)ptr + length;
+    end = (end + PAGESIZE - 1) & ~(PAGESIZE - 1);
+    mprotect((void *)start, end - start, PROT_READ | PROT_WRITE | PROT_EXEC);
+#endif
+}
+
+/* ------------------------------------------------------------- */
+#ifdef CONFIG_TCC_BACKTRACE
+
+ST_FUNC void tcc_set_num_callers(int n)
+{
+    rt_num_callers = n;
+}
+
+/* print the position in the source file of PC value 'pc' by reading
+   the stabs debug information */
+static addr_t rt_printline(addr_t wanted_pc, const char *msg)
+{
+    char func_name[128], last_func_name[128];
+    addr_t func_addr, last_pc, pc;
+    const char *incl_files[INCLUDE_STACK_SIZE];
+    int incl_index, len, last_line_num, i;
+    const char *str, *p;
+
+    Stab_Sym *stab_sym = NULL, *stab_sym_end, *sym;
+    int stab_len = 0;
+    char *stab_str = NULL;
+
+    if (stab_section) {
+        stab_len = stab_section->data_offset;
+        stab_sym = (Stab_Sym *)stab_section->data;
+        stab_str = stabstr_section->data;
+    }
+
+    func_name[0] = '\0';
+    func_addr = 0;
+    incl_index = 0;
+    last_func_name[0] = '\0';
+    last_pc = (addr_t)-1;
+    last_line_num = 1;
+
+    if (!stab_sym)
+        goto no_stabs;
+
+    stab_sym_end = (Stab_Sym*)((char*)stab_sym + stab_len);
+    for (sym = stab_sym + 1; sym < stab_sym_end; ++sym) {
+        switch(sym->n_type) {
+            /* function start or end */
+        case N_FUN:
+            if (sym->n_strx == 0) {
+                /* we test if between last line and end of function */
+                pc = sym->n_value + func_addr;
+                if (wanted_pc >= last_pc && wanted_pc < pc)
+                    goto found;
+                func_name[0] = '\0';
+                func_addr = 0;
+            } else {
+                str = stab_str + sym->n_strx;
+                p = strchr(str, ':');
+                if (!p) {
+                    pstrcpy(func_name, sizeof(func_name), str);
+                } else {
+                    len = p - str;
+                    if (len > sizeof(func_name) - 1)
+                        len = sizeof(func_name) - 1;
+                    memcpy(func_name, str, len);
+                    func_name[len] = '\0';
+                }
+                func_addr = sym->n_value;
+            }
+            break;
+            /* line number info */
+        case N_SLINE:
+            pc = sym->n_value + func_addr;
+            if (wanted_pc >= last_pc && wanted_pc < pc)
+                goto found;
+            last_pc = pc;
+            last_line_num = sym->n_desc;
+            /* XXX: slow! */
+            strcpy(last_func_name, func_name);
+            break;
+            /* include files */
+        case N_BINCL:
+            str = stab_str + sym->n_strx;
+        add_incl:
+            if (incl_index < INCLUDE_STACK_SIZE) {
+                incl_files[incl_index++] = str;
+            }
+            break;
+        case N_EINCL:
+            if (incl_index > 1)
+                incl_index--;
+            break;
+        case N_SO:
+            if (sym->n_strx == 0) {
+                incl_index = 0; /* end of translation unit */
+            } else {
+                str = stab_str + sym->n_strx;
+                /* do not add path */
+                len = strlen(str);
+                if (len > 0 && str[len - 1] != '/')
+                    goto add_incl;
+            }
+            break;
+        }
+    }
+
+no_stabs:
+    /* second pass: we try symtab symbols (no line number info) */
+    incl_index = 0;
+    if (symtab_section)
+    {
+        ElfW(Sym) *sym, *sym_end;
+        int type;
+
+        sym_end = (ElfW(Sym) *)(symtab_section->data + symtab_section->data_offset);
+        for(sym = (ElfW(Sym) *)symtab_section->data + 1;
+            sym < sym_end;
+            sym++) {
+            type = ELFW(ST_TYPE)(sym->st_info);
+            if (type == STT_FUNC || type == STT_GNU_IFUNC) {
+                if (wanted_pc >= sym->st_value &&
+                    wanted_pc < sym->st_value + sym->st_size) {
+                    pstrcpy(last_func_name, sizeof(last_func_name),
+                            strtab_section->data + sym->st_name);
+                    func_addr = sym->st_value;
+                    goto found;
+                }
+            }
+        }
+    }
+    /* did not find any info: */
+    fprintf(stderr, "%s %p ???\n", msg, (void*)wanted_pc);
+    fflush(stderr);
+    return 0;
+ found:
+    i = incl_index;
+    if (i > 0)
+        fprintf(stderr, "%s:%d: ", incl_files[--i], last_line_num);
+    fprintf(stderr, "%s %p", msg, (void*)wanted_pc);
+    if (last_func_name[0] != '\0')
+        fprintf(stderr, " %s()", last_func_name);
+    if (--i >= 0) {
+        fprintf(stderr, " (included from ");
+        for (;;) {
+            fprintf(stderr, "%s", incl_files[i]);
+            if (--i < 0)
+                break;
+            fprintf(stderr, ", ");
+        }
+        fprintf(stderr, ")");
+    }
+    fprintf(stderr, "\n");
+    fflush(stderr);
+    return func_addr;
+}
+
+/* emit a run time error at position 'pc' */
+static void rt_error(ucontext_t *uc, const char *fmt, ...)
+{
+    va_list ap;
+    addr_t pc;
+    int i;
+
+    fprintf(stderr, "Runtime error: ");
+    va_start(ap, fmt);
+    vfprintf(stderr, fmt, ap);
+    va_end(ap);
+    fprintf(stderr, "\n");
+
+    for(i=0;i<rt_num_callers;i++) {
+        if (rt_get_caller_pc(&pc, uc, i) < 0)
+            break;
+        pc = rt_printline(pc, i ? "by" : "at");
+        if (pc == (addr_t)rt_prog_main && pc)
+            break;
+    }
+}
+
+/* ------------------------------------------------------------- */
+#ifndef _WIN32
+
+/* signal handler for fatal errors */
+static void sig_error(int signum, siginfo_t *siginf, void *puc)
+{
+    ucontext_t *uc = puc;
+
+    switch(signum) {
+    case SIGFPE:
+        switch(siginf->si_code) {
+        case FPE_INTDIV:
+        case FPE_FLTDIV:
+            rt_error(uc, "division by zero");
+            break;
+        default:
+            rt_error(uc, "floating point exception");
+            break;
+        }
+        break;
+    case SIGBUS:
+    case SIGSEGV:
+        if (rt_bound_error_msg && *rt_bound_error_msg)
+            rt_error(uc, *rt_bound_error_msg);
+        else
+            rt_error(uc, "dereferencing invalid pointer");
+        break;
+    case SIGILL:
+        rt_error(uc, "illegal instruction");
+        break;
+    case SIGABRT:
+        rt_error(uc, "abort() called");
+        break;
+    default:
+        rt_error(uc, "caught signal %d", signum);
+        break;
+    }
+    exit(255);
+}
+
+#ifndef SA_SIGINFO
+# define SA_SIGINFO 0x00000004u
+#endif
+
+/* Generate a stack backtrace when a CPU exception occurs. */
+static void set_exception_handler(void)
+{
+    struct sigaction sigact;
+    /* install TCC signal handlers to print debug info on fatal
+       runtime errors */
+    sigact.sa_flags = SA_SIGINFO | SA_RESETHAND;
+    /*sigact.sa_sigaction = sig_error;*/
+	sigact.sa_handler = sig_error;
+    sigemptyset(&sigact.sa_mask);
+    sigaction(SIGFPE, &sigact, NULL);
+    sigaction(SIGILL, &sigact, NULL);
+    sigaction(SIGSEGV, &sigact, NULL);
+    sigaction(SIGBUS, &sigact, NULL);
+    sigaction(SIGABRT, &sigact, NULL);
+}
+
+/* ------------------------------------------------------------- */
+#ifdef __i386__
+
+/* fix for glibc 2.1 */
+#ifndef REG_EIP
+#define REG_EIP EIP
+#define REG_EBP EBP
+#endif
+
+/* return the PC at frame level 'level'. Return negative if not found */
+static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
+{
+    addr_t fp;
+    int i;
+
+    if (level == 0) {
+#if defined(__APPLE__)
+        *paddr = uc->uc_mcontext->__ss.__eip;
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+        *paddr = uc->uc_mcontext.mc_eip;
+#elif defined(__dietlibc__)
+        *paddr = uc->uc_mcontext.eip;
+#else
+        *paddr = uc->uc_mcontext.gregs[REG_EIP];
+#endif
+        return 0;
+    } else {
+#if defined(__APPLE__)
+        fp = uc->uc_mcontext->__ss.__ebp;
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+        fp = uc->uc_mcontext.mc_ebp;
+#elif defined(__dietlibc__)
+        fp = uc->uc_mcontext.ebp;
+#else
+        fp = uc->uc_mcontext.gregs[REG_EBP];
+#endif
+        for(i=1;i<level;i++) {
+            /* XXX: check address validity with program info */
+            if (fp <= 0x1000 || fp >= 0xc0000000)
+                return -1;
+            fp = ((addr_t *)fp)[0];
+        }
+        *paddr = ((addr_t *)fp)[1];
+        return 0;
+    }
+}
+
+/* ------------------------------------------------------------- */
+#elif defined(__x86_64__)
+
+/* return the PC at frame level 'level'. Return negative if not found */
+static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
+{
+    addr_t fp;
+    int i;
+
+    if (level == 0) {
+        /* XXX: only support linux */
+#if defined(__APPLE__)
+        *paddr = uc->uc_mcontext->__ss.__rip;
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 
+        *paddr = uc->uc_mcontext.mc_rip;
+#else
+        *paddr = uc->uc_mcontext.gregs[REG_RIP];
+#endif
+        return 0;
+    } else {
+#if defined(__APPLE__)
+        fp = uc->uc_mcontext->__ss.__rbp;
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+        fp = uc->uc_mcontext.mc_rbp;
+#else
+        fp = uc->uc_mcontext.gregs[REG_RBP];
+#endif
+        for(i=1;i<level;i++) {
+            /* XXX: check address validity with program info */
+            if (fp <= 0x1000)
+                return -1;
+            fp = ((addr_t *)fp)[0];
+        }
+        *paddr = ((addr_t *)fp)[1];
+        return 0;
+    }
+}
+
+/* ------------------------------------------------------------- */
+#elif defined(__arm__)
+
+/* return the PC at frame level 'level'. Return negative if not found */
+static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
+{
+    addr_t fp, sp;
+    int i;
+
+    if (level == 0) {
+        /* XXX: only supports linux */
+#if defined(__linux__)
+        *paddr = uc->uc_mcontext.arm_pc;
+#else
+        return -1;
+#endif
+        return 0;
+    } else {
+#if defined(__linux__)
+        fp = uc->uc_mcontext.arm_fp;
+        sp = uc->uc_mcontext.arm_sp;
+        if (sp < 0x1000)
+            sp = 0x1000;
+#else
+        return -1;
+#endif
+        /* XXX: specific to tinycc stack frames */
+        if (fp < sp + 12 || fp & 3)
+            return -1;
+        for(i = 1; i < level; i++) {
+            sp = ((addr_t *)fp)[-2];
+            if (sp < fp || sp - fp > 16 || sp & 3)
+                return -1;
+            fp = ((addr_t *)fp)[-3];
+            if (fp <= sp || fp - sp < 12 || fp & 3)
+                return -1;
+        }
+        /* XXX: check address validity with program info */
+        *paddr = ((addr_t *)fp)[-1];
+        return 0;
+    }
+}
+
+/* ------------------------------------------------------------- */
+#else
+
+#warning add arch specific rt_get_caller_pc()
+static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
+{
+    return -1;
+}
+
+#endif /* !__i386__ */
+
+/* ------------------------------------------------------------- */
+#else /* WIN32 */
+
+static long __stdcall cpu_exception_handler(EXCEPTION_POINTERS *ex_info)
+{
+    EXCEPTION_RECORD *er = ex_info->ExceptionRecord;
+    CONTEXT *uc = ex_info->ContextRecord;
+    switch (er->ExceptionCode) {
+    case EXCEPTION_ACCESS_VIOLATION:
+        if (rt_bound_error_msg && *rt_bound_error_msg)
+            rt_error(uc, *rt_bound_error_msg);
+        else
+	    rt_error(uc, "access violation");
+        break;
+    case EXCEPTION_STACK_OVERFLOW:
+        rt_error(uc, "stack overflow");
+        break;
+    case EXCEPTION_INT_DIVIDE_BY_ZERO:
+        rt_error(uc, "division by zero");
+        break;
+    default:
+        rt_error(uc, "exception caught");
+        break;
+    }
+    return EXCEPTION_EXECUTE_HANDLER;
+}
+
+/* Generate a stack backtrace when a CPU exception occurs. */
+static void set_exception_handler(void)
+{
+    SetUnhandledExceptionFilter(cpu_exception_handler);
+}
+
+#ifdef _WIN64
+static void win64_add_function_table(TCCState *s1)
+{
+    RtlAddFunctionTable(
+        (RUNTIME_FUNCTION*)s1->uw_pdata->sh_addr,
+        s1->uw_pdata->data_offset / sizeof (RUNTIME_FUNCTION),
+        text_section->sh_addr
+        );
+}
+#endif
+
+/* return the PC at frame level 'level'. Return non zero if not found */
+static int rt_get_caller_pc(addr_t *paddr, CONTEXT *uc, int level)
+{
+    addr_t fp, pc;
+    int i;
+#ifdef _WIN64
+    pc = uc->Rip;
+    fp = uc->Rbp;
+#else
+    pc = uc->Eip;
+    fp = uc->Ebp;
+#endif
+    if (level > 0) {
+        for(i=1;i<level;i++) {
+	    /* XXX: check address validity with program info */
+	    if (fp <= 0x1000 || fp >= 0xc0000000)
+		return -1;
+	    fp = ((addr_t*)fp)[0];
+	}
+        pc = ((addr_t*)fp)[1];
+    }
+    *paddr = pc;
+    return 0;
+}
+
+#endif /* _WIN32 */
+#endif /* CONFIG_TCC_BACKTRACE */
+/* ------------------------------------------------------------- */
+#ifdef CONFIG_TCC_STATIC
+
+/* dummy function for profiling */
+ST_FUNC void *dlopen(const char *filename, int flag)
+{
+    return NULL;
+}
+
+ST_FUNC void dlclose(void *p)
+{
+}
+
+ST_FUNC const char *dlerror(void)
+{
+    return "error";
+}
+
+typedef struct TCCSyms {
+    char *str;
+    void *ptr;
+} TCCSyms;
+
+
+/* add the symbol you want here if no dynamic linking is done */
+static TCCSyms tcc_syms[] = {
+#if !defined(CONFIG_TCCBOOT)
+#define TCCSYM(a) { #a, &a, },
+    TCCSYM(printf)
+    TCCSYM(fprintf)
+    TCCSYM(fopen)
+    TCCSYM(fclose)
+#undef TCCSYM
+#endif
+    { NULL, NULL },
+};
+
+ST_FUNC void *resolve_sym(TCCState *s1, const char *symbol)
+{
+    TCCSyms *p;
+    p = tcc_syms;
+    while (p->str != NULL) {
+        if (!strcmp(p->str, symbol))
+            return p->ptr;
+        p++;
+    }
+    return NULL;
+}
+
+#elif !defined(_WIN32)
+
+ST_FUNC void *resolve_sym(TCCState *s1, const char *sym)
+{
+    return dlsym(RTLD_DEFAULT, sym);
+}
+
+#endif /* CONFIG_TCC_STATIC */
+#endif /* TCC_IS_NATIVE */
+/* ------------------------------------------------------------- */
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tcctok.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tcctok.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tcctok.h	(revision 279)
@@ -0,0 +1,278 @@
+/* keywords */
+     DEF(TOK_INT, "int")
+     DEF(TOK_VOID, "void")
+     DEF(TOK_CHAR, "char")
+     DEF(TOK_IF, "if")
+     DEF(TOK_ELSE, "else")
+     DEF(TOK_WHILE, "while")
+     DEF(TOK_BREAK, "break")
+     DEF(TOK_RETURN, "return")
+     DEF(TOK_FOR, "for")
+     DEF(TOK_EXTERN, "extern")
+     DEF(TOK_STATIC, "static")
+     DEF(TOK_UNSIGNED, "unsigned")
+     DEF(TOK_GOTO, "goto")
+     DEF(TOK_DO, "do")
+     DEF(TOK_CONTINUE, "continue")
+     DEF(TOK_SWITCH, "switch")
+     DEF(TOK_CASE, "case")
+
+     DEF(TOK_CONST1, "const")
+     DEF(TOK_CONST2, "__const") /* gcc keyword */
+     DEF(TOK_CONST3, "__const__") /* gcc keyword */
+     DEF(TOK_VOLATILE1, "volatile")
+     DEF(TOK_VOLATILE2, "__volatile") /* gcc keyword */
+     DEF(TOK_VOLATILE3, "__volatile__") /* gcc keyword */
+     DEF(TOK_LONG, "long")
+     DEF(TOK_REGISTER, "register")
+     DEF(TOK_SIGNED1, "signed")
+     DEF(TOK_SIGNED2, "__signed") /* gcc keyword */
+     DEF(TOK_SIGNED3, "__signed__") /* gcc keyword */
+     DEF(TOK_AUTO, "auto")
+     DEF(TOK_INLINE1, "inline")
+     DEF(TOK_INLINE2, "__inline") /* gcc keyword */
+     DEF(TOK_INLINE3, "__inline__") /* gcc keyword */
+     DEF(TOK_RESTRICT1, "restrict")
+     DEF(TOK_RESTRICT2, "__restrict")
+     DEF(TOK_RESTRICT3, "__restrict__")
+     DEF(TOK_EXTENSION, "__extension__") /* gcc keyword */
+     
+     DEF(TOK_FLOAT, "float")
+     DEF(TOK_DOUBLE, "double")
+     DEF(TOK_BOOL, "_Bool")
+     DEF(TOK_SHORT, "short")
+     DEF(TOK_STRUCT, "struct")
+     DEF(TOK_UNION, "union")
+     DEF(TOK_TYPEDEF, "typedef")
+     DEF(TOK_DEFAULT, "default")
+     DEF(TOK_ENUM, "enum")
+     DEF(TOK_SIZEOF, "sizeof")
+     DEF(TOK_ATTRIBUTE1, "__attribute")
+     DEF(TOK_ATTRIBUTE2, "__attribute__")
+     DEF(TOK_ALIGNOF1, "__alignof")
+     DEF(TOK_ALIGNOF2, "__alignof__")
+     DEF(TOK_TYPEOF1, "typeof")
+     DEF(TOK_TYPEOF2, "__typeof")
+     DEF(TOK_TYPEOF3, "__typeof__")
+     DEF(TOK_LABEL, "__label__")
+     DEF(TOK_ASM1, "asm")
+     DEF(TOK_ASM2, "__asm")
+     DEF(TOK_ASM3, "__asm__")
+
+/*********************************************************************/
+/* the following are not keywords. They are included to ease parsing */
+/* preprocessor only */
+     DEF(TOK_DEFINE, "define")
+     DEF(TOK_INCLUDE, "include")
+     DEF(TOK_INCLUDE_NEXT, "include_next")
+     DEF(TOK_IFDEF, "ifdef")
+     DEF(TOK_IFNDEF, "ifndef")
+     DEF(TOK_ELIF, "elif")
+     DEF(TOK_ENDIF, "endif")
+     DEF(TOK_DEFINED, "defined")
+     DEF(TOK_UNDEF, "undef")
+     DEF(TOK_ERROR, "error")
+     DEF(TOK_WARNING, "warning")
+     DEF(TOK_LINE, "line")
+     DEF(TOK_PRAGMA, "pragma")
+     DEF(TOK___LINE__, "__LINE__")
+     DEF(TOK___FILE__, "__FILE__")
+     DEF(TOK___DATE__, "__DATE__")
+     DEF(TOK___TIME__, "__TIME__")
+     DEF(TOK___FUNCTION__, "__FUNCTION__")
+     DEF(TOK___VA_ARGS__, "__VA_ARGS__")
+
+/* special identifiers */
+     DEF(TOK___FUNC__, "__func__")
+
+/* special floating point values */
+     DEF(TOK___NAN__, "__nan__")
+     DEF(TOK___SNAN__, "__snan__")
+     DEF(TOK___INF__, "__inf__")
+
+/* attribute identifiers */
+/* XXX: handle all tokens generically since speed is not critical */
+     DEF(TOK_SECTION1, "section")
+     DEF(TOK_SECTION2, "__section__")
+     DEF(TOK_ALIGNED1, "aligned")
+     DEF(TOK_ALIGNED2, "__aligned__")
+     DEF(TOK_PACKED1, "packed")
+     DEF(TOK_PACKED2, "__packed__")
+     DEF(TOK_WEAK1, "weak")
+     DEF(TOK_WEAK2, "__weak__")
+     DEF(TOK_ALIAS1, "alias")
+     DEF(TOK_ALIAS2, "__alias__")
+     DEF(TOK_UNUSED1, "unused")
+     DEF(TOK_UNUSED2, "__unused__")
+     DEF(TOK_CDECL1, "cdecl")
+     DEF(TOK_CDECL2, "__cdecl")
+     DEF(TOK_CDECL3, "__cdecl__")
+     DEF(TOK_STDCALL1, "stdcall")
+     DEF(TOK_STDCALL2, "__stdcall")
+     DEF(TOK_STDCALL3, "__stdcall__")
+     DEF(TOK_FASTCALL1, "fastcall")
+     DEF(TOK_FASTCALL2, "__fastcall")
+     DEF(TOK_FASTCALL3, "__fastcall__")
+     DEF(TOK_MODE, "__mode__")
+     DEF(TOK_MODE_DI, "__DI__")
+     DEF(TOK_MODE_HI, "__HI__")
+     DEF(TOK_MODE_SI, "__SI__")
+     DEF(TOK_DLLEXPORT, "dllexport")
+     DEF(TOK_DLLIMPORT, "dllimport")
+     DEF(TOK_NORETURN1, "noreturn")
+     DEF(TOK_NORETURN2, "__noreturn__")
+     DEF(TOK_builtin_types_compatible_p, "__builtin_types_compatible_p")
+     DEF(TOK_builtin_constant_p, "__builtin_constant_p")
+     DEF(TOK_builtin_frame_address, "__builtin_frame_address")
+#ifdef TCC_TARGET_X86_64
+     DEF(TOK_builtin_va_arg_types, "__builtin_va_arg_types")
+#endif
+     DEF(TOK_REGPARM1, "regparm")
+     DEF(TOK_REGPARM2, "__regparm__")
+
+/* pragma */
+     DEF(TOK_pack, "pack")
+#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_X86_64)
+     /* already defined for assembler */
+     DEF(TOK_ASM_push, "push")
+     DEF(TOK_ASM_pop, "pop")
+#endif
+
+/* builtin functions or variables */
+#ifdef TCC_ARM_EABI
+     DEF(TOK_memcpy, "__aeabi_memcpy")
+     DEF(TOK_memcpy4, "__aeabi_memcpy4")
+     DEF(TOK_memcpy8, "__aeabi_memcpy8")
+     DEF(TOK_memset, "__aeabi_memset")
+     DEF(TOK___aeabi_ldivmod, "__aeabi_ldivmod")
+     DEF(TOK___aeabi_uldivmod, "__aeabi_uldivmod")
+#else
+     DEF(TOK_memcpy, "memcpy")
+     DEF(TOK_memset, "memset")
+     DEF(TOK___divdi3, "__divdi3")
+     DEF(TOK___moddi3, "__moddi3")
+     DEF(TOK___udivdi3, "__udivdi3")
+     DEF(TOK___umoddi3, "__umoddi3")
+#endif
+#if defined(TCC_TARGET_ARM)
+#ifdef TCC_ARM_EABI
+     DEF(TOK___aeabi_idivmod, "__aeabi_idivmod")
+     DEF(TOK___aeabi_uidivmod, "__aeabi_uidivmod")
+     DEF(TOK___divsi3, "__aeabi_idiv")
+     DEF(TOK___udivsi3, "__aeabi_uidiv")
+     DEF(TOK___floatdisf, "__aeabi_l2f")
+     DEF(TOK___floatdidf, "__aeabi_l2d")
+     DEF(TOK___fixsfdi, "__aeabi_f2lz")
+     DEF(TOK___fixdfdi, "__aeabi_d2lz")
+#else
+     DEF(TOK___modsi3, "__modsi3")
+     DEF(TOK___umodsi3, "__umodsi3")
+     DEF(TOK___divsi3, "__divsi3")
+     DEF(TOK___udivsi3, "__udivsi3")
+     DEF(TOK___floatdisf, "__floatdisf")
+     DEF(TOK___floatdidf, "__floatdidf")
+#ifndef TCC_ARM_VFP
+     DEF(TOK___floatdixf, "__floatdixf")
+     DEF(TOK___fixunssfsi, "__fixunssfsi")
+     DEF(TOK___fixunsdfsi, "__fixunsdfsi")
+     DEF(TOK___fixunsxfsi, "__fixunsxfsi")
+     DEF(TOK___fixxfdi, "__fixxfdi")
+#endif
+     DEF(TOK___fixsfdi, "__fixsfdi")
+     DEF(TOK___fixdfdi, "__fixdfdi")
+#endif
+#elif defined(TCC_TARGET_C67)
+     DEF(TOK__divi, "_divi")
+     DEF(TOK__divu, "_divu")
+     DEF(TOK__divf, "_divf")
+     DEF(TOK__divd, "_divd")
+     DEF(TOK__remi, "_remi")
+     DEF(TOK__remu, "_remu")
+#endif
+#ifdef TCC_TARGET_I386
+     DEF(TOK___tcc_int_fpu_control, "__tcc_int_fpu_control")
+     DEF(TOK___tcc_fpu_control, "__tcc_fpu_control")
+#endif
+#ifdef TCC_ARM_EABI
+     DEF(TOK___ashrdi3, "__aeabi_lasr")
+     DEF(TOK___lshrdi3, "__aeabi_llsr")
+     DEF(TOK___ashldi3, "__aeabi_llsl")
+     DEF(TOK___floatundisf, "__aeabi_ul2f")
+     DEF(TOK___floatundidf, "__aeabi_ul2d")
+     DEF(TOK___fixunssfdi, "__aeabi_f2ulz")
+     DEF(TOK___fixunsdfdi, "__aeabi_d2ulz")
+#else
+     DEF(TOK___ashrdi3, "__ashrdi3")
+     DEF(TOK___lshrdi3, "__lshrdi3")
+     DEF(TOK___ashldi3, "__ashldi3")
+     DEF(TOK___floatundisf, "__floatundisf")
+     DEF(TOK___floatundidf, "__floatundidf")
+#ifndef TCC_ARM_VFP
+     DEF(TOK___floatundixf, "__floatundixf")
+     DEF(TOK___fixunsxfdi, "__fixunsxfdi")
+#endif
+     DEF(TOK___fixunssfdi, "__fixunssfdi")
+     DEF(TOK___fixunsdfdi, "__fixunsdfdi")
+#endif
+#ifdef TCC_TARGET_PE
+     DEF(TOK___chkstk, "__chkstk")
+#endif
+
+/* bound checking symbols */
+#ifdef CONFIG_TCC_BCHECK
+     DEF(TOK___bound_ptr_add, "__bound_ptr_add")
+     DEF(TOK___bound_ptr_indir1, "__bound_ptr_indir1")
+     DEF(TOK___bound_ptr_indir2, "__bound_ptr_indir2")
+     DEF(TOK___bound_ptr_indir4, "__bound_ptr_indir4")
+     DEF(TOK___bound_ptr_indir8, "__bound_ptr_indir8")
+     DEF(TOK___bound_ptr_indir12, "__bound_ptr_indir12")
+     DEF(TOK___bound_ptr_indir16, "__bound_ptr_indir16")
+     DEF(TOK___bound_local_new, "__bound_local_new")
+     DEF(TOK___bound_local_delete, "__bound_local_delete")
+#ifdef TCC_TARGET_PE
+     DEF(TOK_malloc, "malloc")
+     DEF(TOK_free, "free")
+     DEF(TOK_realloc, "realloc")
+     DEF(TOK_memalign, "memalign")
+     DEF(TOK_calloc, "calloc")
+#endif
+     DEF(TOK_memmove, "memmove")
+     DEF(TOK_strlen, "strlen")
+     DEF(TOK_strcpy, "strcpy")
+#endif
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+     DEF(TOK_alloca, "alloca")
+#endif
+
+/* Tiny Assembler */
+ DEF_ASM(byte)
+ DEF_ASM(word)
+ DEF_ASM(align)
+ DEF_ASM(skip)
+ DEF_ASM(space)
+ DEF_ASM(string)
+ DEF_ASM(asciz)
+ DEF_ASM(ascii)
+ DEF_ASM(file)
+ DEF_ASM(globl)
+ DEF_ASM(global)
+ DEF_ASM(ident)
+ DEF_ASM(size)
+ DEF_ASM(type)
+ DEF_ASM(text)
+ DEF_ASM(data)
+ DEF_ASM(bss)
+ DEF_ASM(previous)
+ DEF_ASM(fill)
+ DEF_ASM(org)
+ DEF_ASM(quad)
+#if defined(TCC_TARGET_I386)
+ DEF_ASM(code16)
+ DEF_ASM(code32)
+#elif defined(TCC_TARGET_X86_64)
+ DEF_ASM(code64)
+#endif
+
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+#include "i386-tok.h"
+#endif
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tests/Makefile
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tests/Makefile	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tests/Makefile	(revision 279)
@@ -0,0 +1,199 @@
+#
+# Tiny C Compiler Makefile - tests
+#
+
+TOP = ..
+include $(TOP)/Makefile
+VPATH = $(top_srcdir)/tests
+
+# what tests to run
+TESTS = \
+ hello-exe \
+ hello-run \
+ libtest \
+ test3 \
+ moretests
+
+# test4 -- problem with -static
+# asmtest -- minor differences with gcc
+# btest -- works on i386 (including win32)
+# test3 -- win32 does not know how to printf long doubles
+
+# bounds-checking is supported only on i386
+ifneq ($(ARCH),i386)
+ TESTS := $(filter-out btest,$(TESTS))
+endif
+ifdef CONFIG_WIN32
+ TESTS := $(filter-out test3,$(TESTS))
+endif
+ifeq ($(TARGETOS),Darwin)
+ TESTS := $(filter-out hello-exe test3 btest,$(TESTS))
+endif
+
+ifdef DISABLE_STATIC
+ export LD_LIBRARY_PATH:=$(CURDIR)/..
+endif
+
+ifeq ($(TARGETOS),Darwin)
+ CFLAGS+=-Wl,-flat_namespace,-undefined,warning
+ export MACOSX_DEPLOYMENT_TARGET:=10.2
+ NATIVE_DEFINES+=-D_ANSI_SOURCE
+endif
+
+# run local version of tcc with local libraries and includes
+TCCFLAGS = -B$(TOP)
+ifdef CONFIG_WIN32
+ TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)
+endif
+
+TCC = $(TOP)/tcc $(TCCFLAGS)
+RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS)
+
+DISAS = objdump -d
+
+# libtcc test
+ifdef LIBTCC1
+ LIBTCC1:=$(TOP)/$(LIBTCC1)
+endif
+
+all test : $(TESTS)
+
+hello-exe: ../examples/ex1.c
+	@echo ------------ $@ ------------
+	$(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)
+
+hello-run: ../examples/ex1.c
+	@echo ------------ $@ ------------
+	$(TCC) -run $<
+
+libtest: libtcc_test$(EXESUF) $(LIBTCC1)
+	@echo ------------ $@ ------------
+	./libtcc_test$(EXESUF) lib_path=..
+
+libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC)
+	$(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS)
+
+moretests:
+	@echo ------------ $@ ------------
+	$(MAKE) -C tests2
+
+# test.ref - generate using gcc
+# copy only tcclib.h so GCC's stddef and stdarg will be used
+test.ref: tcctest.c
+	cp ../include/tcclib.h .
+	gcc -o tcctest.gcc $< -I. $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS)
+	./tcctest.gcc > $@
+
+# auto test
+test1: test.ref
+	@echo ------------ $@ ------------
+	$(TCC) -run tcctest.c > test.out1
+	@if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi
+
+# iterated test2 (compile tcc then compile tcctest.c !)
+test2: test.ref
+	@echo ------------ $@ ------------
+	$(TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out2
+	@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
+
+# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
+test3: test.ref
+	@echo ------------ $@ ------------
+	$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out3
+	@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
+
+# binary output test
+test4: test.ref
+	@echo ------------ $@ ------------
+# object + link output
+	$(TCC) -c -o tcctest3.o tcctest.c
+	$(TCC) -o tcctest3 tcctest3.o
+	./tcctest3 > test3.out
+	@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
+# dynamic output
+	$(TCC) -o tcctest1 tcctest.c
+	./tcctest1 > test1.out
+	@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
+# dynamic output + bound check
+	$(TCC) -b -o tcctest4 tcctest.c
+	./tcctest4 > test4.out
+	@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
+# static output
+	$(TCC) -static -o tcctest2 tcctest.c
+	./tcctest2 > test2.out
+	@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
+
+# memory and bound check auto test
+BOUNDS_OK  = 1 4 8 10 14
+BOUNDS_FAIL= 2 5 7 9 11 12 13 15
+
+btest: boundtest.c
+	@echo ------------ $@ ------------
+	@for i in $(BOUNDS_OK); do \
+	   echo ; echo --- boundtest $$i ---; \
+	   if $(TCC) -b -run boundtest.c $$i ; then \
+	       echo succeded as expected; \
+	   else\
+	       echo Failed positive test $$i ; exit 1 ; \
+	   fi ;\
+	done ;\
+	for i in $(BOUNDS_FAIL); do \
+	   echo ; echo --- boundtest $$i ---; \
+	   if $(TCC) -b -run boundtest.c $$i ; then \
+	       echo Failed negative test $$i ; exit 1 ;\
+	   else\
+	       echo failed as expected; \
+	   fi ;\
+	done ;\
+	echo; echo Bound test OK
+
+# speed test
+speedtest: ex2 ex3
+	@echo ------------ $@ ------------
+	time ./ex2 1238 2 3 4 10 13 4
+	time $(TCC) -run $(top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4
+	time ./ex3 35
+	time $(TCC) -run $(top_srcdir)/examples/ex3.c 35
+
+weaktest: test.ref
+	$(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)
+	 $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS)
+	objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt
+	objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
+	diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
+
+ex%: $(top_srcdir)/examples/ex%.c
+	$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
+
+# tiny assembler testing
+asmtest.ref: asmtest.S
+	$(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S
+	objdump -D asmtest.ref.o > asmtest.ref
+
+asmtest: asmtest.ref
+	@echo ------------ $@ ------------
+	$(TCC) -c asmtest.S
+	objdump -D asmtest.o > asmtest.out
+	@if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
+
+# targets for development
+%.bin: %.c tcc
+	$(TCC) -g -o $@ $<
+	$(DISAS) $@
+
+instr: instr.o
+	objdump -d instr.o
+
+instr.o: instr.S
+	$(CC) -o $@ -c $< -O2 -Wall -g
+
+cache: tcc_g
+	cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
+	vg_annotate tcc.c > /tmp/linpack.cache.log
+
+# clean
+clean:
+	$(MAKE) -C tests2 $@
+	rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \
+	   hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h
+
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tests/asmtest.S
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tests/asmtest.S	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tests/asmtest.S	(revision 279)
@@ -0,0 +1,609 @@
+# gas comment with ``gnu'' style quotes
+
+/* some directive tests */
+
+   .byte 0xff
+   .byte 1, 2, 3
+   .short 1, 2, 3
+   .word 1, 2, 3
+   .long 1, 2, 3
+   .int 1, 2, 3
+   .align 8
+   .byte 1
+/* .align 16, 0x90 gas is too clever for us with 0x90 fill */
+   .align 16, 0x91 /* 0x91 tests the non-clever behaviour */
+   .skip 3
+   .skip 15, 0x90
+   .string "hello\0world"
+
+/* some label tests */
+
+        movl %eax, %ebx
+L1:
+        movl %eax, %ebx
+        mov 0x10000, %eax
+L2:
+        movl $L2 - L1, %ecx
+var1:
+        nop ; nop ; nop ; nop
+
+        mov var1, %eax
+
+/* instruction tests */
+movl %eax, %ebx
+mov 0x10000, %eax
+mov 0x10000, %ax
+mov 0x10000, %al
+mov %al, 0x10000
+                
+mov $1, %edx
+mov $1, %dx
+mov $1, %dl
+movb $2, 0x100(%ebx,%edx,2)
+movw $2, 0x100(%ebx,%edx,2)
+movl $2, 0x100(%ebx,%edx,2)
+movl %eax, 0x100(%ebx,%edx,2)
+movl 0x100(%ebx,%edx,2), %edx
+movw %ax, 0x100(%ebx,%edx,2)
+
+mov %eax, 0x12(,%edx,2)
+        
+mov %cr3, %edx
+mov %ecx, %cr3
+movl %cr3, %eax
+movl %tr3, %eax
+movl %db3, %ebx
+movl %dr6, %eax
+movl %fs, %ecx
+movl %ebx, %fs
+
+     movsbl 0x1000, %eax
+     movsbw 0x1000, %ax
+     movswl 0x1000, %eax
+
+     movzbl 0x1000, %eax
+     movzbw 0x1000, %ax
+     movzwl 0x1000, %eax
+            
+     movzb 0x1000, %eax
+     movzb 0x1000, %ax
+                
+        
+  pushl %eax
+  pushw %ax
+  push %eax
+  push %cs
+  push %gs
+  push $1
+  push $100
+                                                
+  popl %eax
+  popw %ax
+  pop %eax
+  pop %ds
+  pop %fs
+          
+  xchg %eax, %ecx
+  xchg %edx, %eax
+  xchg %bx, 0x10000
+  xchg 0x10000, %ebx
+  xchg 0x10000, %dl
+
+  in $100, %al               
+  in $100, %ax               
+  in $100, %eax
+  in %dx, %al
+  in %dx, %ax               
+  in %dx, %eax
+  inb %dx
+  inw %dx               
+  inl %dx
+
+  out %al, $100                       
+  out %ax, $100                       
+  out %eax, $100                       
+
+  /* NOTE: gas is bugged here, so size must be added */
+  outb %al, %dx                       
+  outw %ax, %dx                       
+  outl %eax, %dx                       
+
+  leal 0x1000(%ebx), %ecx
+  lea 0x1000(%ebx), %ecx
+
+  les 0x2000, %eax
+  lds 0x2000, %ebx
+  lfs 0x2000, %ecx
+  lgs 0x2000, %edx
+  lss 0x2000, %edx
+
+addl $0x123, %eax
+add $0x123, %ebx
+addl $0x123, 0x100
+addl $0x123, 0x100(%ebx)
+addl $0x123, 0x100(%ebx,%edx,2)
+addl $0x123, 0x100(%esp)
+addl $0x123, (3*8)(%esp)
+addl $0x123, (%ebp)
+addl $0x123, (%esp)
+cmpl $0x123, (%esp)
+
+add %eax, (%ebx)
+add (%ebx), %eax
+                
+or %dx, (%ebx)
+or (%ebx), %si
+        
+add %cl, (%ebx)
+add (%ebx), %dl
+
+    inc %edx
+    incl 0x10000
+    incb 0x10000
+    dec %dx
+  
+  test $1, %al
+  test $1, %cl
+
+  testl $1, 0x1000
+  testb $1, 0x1000
+  testw $1, 0x1000
+  test %eax, %ebx
+  test %eax, 0x1000
+  test 0x1000, %edx
+
+    not %edx
+    notw 0x10000
+    notl 0x10000
+    notb 0x10000
+
+    neg %edx
+    negw 0x10000
+    negl 0x10000
+    negb 0x10000
+
+    imul %ecx
+    mul %edx
+    mulb %cl
+
+    imul %eax, %ecx
+    imul 0x1000, %cx
+    imul $10, %eax, %ecx
+    imul $10, %ax, %cx
+    imul $10, %eax
+    imul $0x1100000, %eax
+    imul $1, %eax
+    
+    idivw 0x1000
+    div %ecx
+    div %bl
+    div %ecx, %eax
+
+
+shl %edx
+shl $10, %edx
+shl %cl, %edx
+
+shld $1, %eax, %edx
+shld %cl, %eax, %edx
+shld %eax, %edx
+
+shrd $1, %eax, %edx
+shrd %cl, %eax, %edx
+shrd %eax, %edx
+
+L4:
+call 0x1000
+call L4
+call *%eax
+call *0x1000
+call func1
+
+.global L5,L6
+
+L5:
+L6:
+
+lcall $0x100, $0x1000
+
+jmp 0x1000
+jmp *%eax
+jmp *0x1000
+
+ljmp $0x100, $0x1000
+
+ret
+retl
+
+ret $10
+retl $10
+
+lret
+
+lret $10
+
+enter $1234, $10
+
+L3:
+ jo 0x1000
+ jnp 0x1001
+ jne 0x1002
+ jg 0x1003
+
+ jo L3
+ jnp L3
+ jne L3
+ jg L3
+
+ loopne L3
+ loopnz L3
+ loope L3
+ loopz L3
+ loop L3
+ jecxz L3
+
+        
+ seto %al
+ setnp 0x1000
+ setl 0xaaaa
+ setg %dl
+
+ fadd
+ fadd %st(1), %st
+ fadd %st(0), %st(1)
+ fadd %st(3)
+
+ fmul %st(0),%st(0)
+ fmul %st(0),%st(1)
+
+ faddp %st(5)
+ faddp
+ faddp %st(1), %st
+
+ fadds 0x1000
+ fiadds 0x1002
+ faddl 0x1004
+ fiaddl 0x1006
+
+ fmul
+ fmul %st(1), %st
+ fmul %st(3)
+
+ fmulp %st(5)
+ fmulp
+ fmulp %st(1), %st
+
+ fmuls 0x1000
+ fimuls 0x1002
+ fmull 0x1004
+ fimull 0x1006
+
+ fsub
+ fsub %st(1), %st
+ fsub %st(3)
+
+ fsubp %st(5)
+ fsubp
+ fsubp %st(1), %st
+
+ fsubs 0x1000
+ fisubs 0x1002
+ fsubl 0x1004
+ fisubl 0x1006
+
+ fsubr
+ fsubr %st(1), %st
+ fsubr %st(3)
+
+ fsubrp %st(5)
+ fsubrp
+ fsubrp %st(1), %st
+
+ fsubrs 0x1000
+ fisubrs 0x1002
+ fsubrl 0x1004
+ fisubrl 0x1006
+
+ fdiv
+ fdiv %st(1), %st
+ fdiv %st(3)
+
+ fdivp %st(5)
+ fdivp
+ fdivp %st(1), %st
+
+ fdivs 0x1000
+ fidivs 0x1002
+ fdivl 0x1004
+ fidivl 0x1006
+
+ fcom %st(3)
+
+ fcoms 0x1000
+ ficoms 0x1002
+ fcoml 0x1004
+ ficoml 0x1006
+
+ fcomp %st(5)
+ fcomp
+ fcompp
+
+ fcomps 0x1000
+ ficomps 0x1002
+ fcompl 0x1004
+ ficompl 0x1006
+
+ fld %st(5)
+ fldl 0x1000
+ flds 0x1002
+ fildl 0x1004
+ fst %st(4)
+ fstp %st(6)
+ fstpt 0x1006
+ fbstp 0x1008
+
+ fxch
+ fxch %st(4)
+
+ fucom %st(6)
+ fucomp %st(3)
+ fucompp
+
+ finit
+ fninit
+ fldcw 0x1000
+ fnstcw 0x1002
+ fstcw 0x1002
+ fnstsw 0x1004
+ fnstsw (%eax)
+ fstsw 0x1004
+ fstsw (%eax)
+ fnclex
+ fclex
+ fnstenv 0x1000
+ fstenv 0x1000
+ fldenv 0x1000
+ fnsave 0x1002
+ fsave 0x1000
+ frstor 0x1000
+ ffree %st(7)
+ ffreep %st(6)
+ 
+    ftst
+    fxam
+    fld1
+    fldl2t
+    fldl2e
+    fldpi
+    fldlg2
+    fldln2
+    fldz
+
+    f2xm1
+    fyl2x
+    fptan
+    fpatan
+    fxtract
+    fprem1
+    fdecstp
+    fincstp
+    fprem
+    fyl2xp1
+    fsqrt
+    fsincos
+    frndint
+    fscale
+    fsin
+    fcos
+    fchs
+    fabs
+    fnop
+    fwait
+
+bswap %edx
+xadd %ecx, %edx
+xaddb %dl, 0x1000
+xaddw %ax, 0x1000
+xaddl %eax, 0x1000
+cmpxchg %ecx, %edx
+cmpxchgb %dl, 0x1000
+cmpxchgw %ax, 0x1000
+cmpxchgl %eax, 0x1000
+invlpg 0x1000
+cmpxchg8b 0x1002
+
+fcmovb %st(5), %st
+fcmove %st(5), %st
+fcmovbe %st(5), %st
+fcmovu %st(5), %st
+fcmovnb %st(5), %st
+fcmovne %st(5), %st
+fcmovnbe %st(5), %st
+fcmovnu %st(5), %st
+fcomi %st(5), %st
+fucomi %st(5), %st
+fcomip %st(5), %st
+fucomip %st(5), %st
+
+
+
+ cmovo 0x1000, %eax
+ cmovs 0x1000, %eax
+ cmovns %edx, %edi
+
+int $3
+int $0x10
+
+    pusha
+    popa
+    clc
+    cld
+    cli
+    clts
+    cmc
+    lahf
+    sahf
+    pushfl
+    popfl
+    pushf
+    popf
+    stc
+    std
+    sti
+    aaa
+    aas
+    daa
+    das
+    aad
+    aam
+    cbw
+    cwd
+    cwde
+    cdq
+    cbtw
+    cwtd
+    cwtl
+    cltd
+    leave
+    int3
+    into
+    iret
+    rsm
+    hlt
+    wait
+    nop
+
+    /* XXX: handle prefixes */
+#if 0
+    aword
+    addr16
+#endif
+    lock
+    rep
+    repe
+    repz
+    repne
+    repnz
+    nop
+
+    lock ;negl (%eax)
+    wait ;pushf
+    rep  ;stosb
+    repe ;lodsb
+    repz ;cmpsb
+    repne;movsb
+    repnz;outsb
+
+    /* handle one-line prefix + ops */
+    lock  negl (%eax)
+    wait  pushf
+    rep   stosb
+    repe  lodsb
+    repz  cmpsb
+    repne movsb
+    repnz outsb
+    
+    invd
+    wbinvd
+    cpuid
+    wrmsr
+    rdtsc
+    rdmsr
+    rdpmc
+    ud2
+
+    emms
+    movd %edx, %mm3
+    movd 0x1000, %mm2
+    movd %mm4, %ecx
+    movd %mm5, 0x1000
+                    
+    movq 0x1000, %mm2
+    movq %mm4, 0x1000
+    
+    pand 0x1000, %mm3
+    pand %mm4, %mm5
+    
+    psllw $1, %mm6
+    psllw 0x1000, %mm7
+    psllw %mm2, %mm7
+
+    xlat
+    cmpsb
+    scmpw
+    insl
+    outsw
+    lodsb
+    slodl
+    movsb
+    movsl
+    smovb
+    scasb
+    sscaw
+    stosw
+    sstol
+
+    bsf 0x1000, %ebx
+    bsr 0x1000, %ebx
+    bt %edx, 0x1000
+    btl $2, 0x1000
+    btc %edx, 0x1000
+    btcl $2, 0x1000
+    btr %edx, 0x1000
+    btrl $2, 0x1000
+    bts %edx, 0x1000
+    btsl $2, 0x1000
+
+        
+        
+    boundl %edx, 0x10000
+    boundw %bx, 0x1000
+    
+    arpl %bx, 0x1000
+    lar 0x1000, %eax
+    lgdt 0x1000
+    lidt 0x1000
+    lldt 0x1000
+    lmsw 0x1000
+    lsl 0x1000, %ecx
+    ltr 0x1000
+    
+    sgdt 0x1000
+    sidt 0x1000
+    sldt 0x1000
+    smsw 0x1000
+    str 0x1000
+    
+    verr 0x1000
+    verw 0x1000
+  
+    push %ds
+    pushw %ds
+    pushl %ds
+    pop %ds
+    popw %ds
+    popl %ds
+    fxsave 1(%ebx)
+    fxrstor 1(%ecx)
+    pushl $1
+    pushw $1
+    push $1
+
+#ifdef __ASSEMBLER__ // should be defined, for S files
+    inc %eax
+#endif
+
+ft1: ft2: ft3: ft4: ft5: ft6: ft7: ft8: ft9:
+    xor %eax, %eax
+    ret
+
+.type ft1,STT_FUNC
+.type ft2,@STT_FUNC
+.type ft3,%STT_FUNC
+.type ft4,"STT_FUNC"
+.type ft5,function
+.type ft6,@function
+.type ft7,%function
+.type ft8,"function"
+
+    pause
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tests/boundtest.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tests/boundtest.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tests/boundtest.c	(revision 279)
@@ -0,0 +1,233 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#define NB_ITS 1000000
+//#define NB_ITS 1
+#define TAB_SIZE 100
+
+int tab[TAB_SIZE];
+int ret_sum;
+char tab3[256];
+
+int test1(void)
+{
+    int i, sum = 0;
+    for(i=0;i<TAB_SIZE;i++) {
+        sum += tab[i];
+    }
+    return sum;
+}
+
+/* error */
+int test2(void)
+{
+    int i, sum = 0;
+    for(i=0;i<TAB_SIZE + 1;i++) {
+        sum += tab[i];
+    }
+    return sum;
+}
+
+/* actually, profiling test */
+int test3(void)
+{
+    int sum;
+    int i, it;
+
+    sum = 0;
+    for(it=0;it<NB_ITS;it++) {
+        for(i=0;i<TAB_SIZE;i++) {
+            sum += tab[i];
+        }
+    }
+    return sum;
+}
+
+/* ok */
+int test4(void)
+{
+    int i, sum = 0;
+    int *tab4;
+
+    tab4 = malloc(20 * sizeof(int));
+    for(i=0;i<20;i++) {
+        sum += tab4[i];
+    }
+    free(tab4);
+
+    return sum;
+}
+
+/* error */
+int test5(void)
+{
+    int i, sum = 0;
+    int *tab4;
+
+    tab4 = malloc(20 * sizeof(int));
+    for(i=0;i<21;i++) {
+        sum += tab4[i];
+    }
+    free(tab4);
+
+    return sum;
+}
+
+/* error */
+/* XXX: currently: bug */
+int test6(void)
+{
+    int i, sum = 0;
+    int *tab4;
+    
+    tab4 = malloc(20 * sizeof(int));
+    free(tab4);
+    for(i=0;i<21;i++) {
+        sum += tab4[i];
+    }
+
+    return sum;
+}
+
+/* error */
+int test7(void)
+{
+    int i, sum = 0;
+    int *p;
+
+    for(i=0;i<TAB_SIZE + 1;i++) {
+        p = &tab[i];
+        if (i == TAB_SIZE)
+            printf("i=%d %x\n", i, p);
+        sum += *p;
+    }
+    return sum;
+}
+
+/* ok */
+int test8(void)
+{
+    int i, sum = 0;
+    int tab[10];
+
+    for(i=0;i<10;i++) {
+        sum += tab[i];
+    }
+    return sum;
+}
+
+/* error */
+int test9(void)
+{
+    int i, sum = 0;
+    char tab[10];
+
+    for(i=0;i<11;i++) {
+        sum += tab[i];
+    }
+    return sum;
+}
+
+/* ok */
+int test10(void)
+{
+    char tab[10];
+    char tab1[10];
+
+    memset(tab, 0, 10);
+    memcpy(tab, tab1, 10);
+    memmove(tab, tab1, 10);
+    return 0;
+}
+
+/* error */
+int test11(void)
+{
+    char tab[10];
+
+    memset(tab, 0, 11);
+    return 0;
+}
+
+/* error */
+int test12(void)
+{
+    void *ptr;
+    ptr = malloc(10);
+    free(ptr);
+    free(ptr);
+    return 0;
+}
+
+/* error */
+int test13(void)
+{
+    char pad1 = 0;
+    char tab[10];
+    char pad2 = 0;
+    memset(tab, 'a', sizeof(tab));
+    return strlen(tab);
+}
+
+int test14(void)
+{
+    char *p = alloca(TAB_SIZE);
+    memset(p, 'a', TAB_SIZE);
+    p[TAB_SIZE-1] = 0;
+    return strlen(p);
+}
+
+/* error */
+int test15(void)
+{
+    char *p = alloca(TAB_SIZE-1);
+    memset(p, 'a', TAB_SIZE);
+    p[TAB_SIZE-1] = 0;
+    return strlen(p);
+}
+
+int (*table_test[])(void) = {
+    test1,
+    test1,
+    test2,
+    test3,
+    test4,
+    test5,
+    test6,
+    test7,
+    test8,
+    test9,
+    test10,
+    test11,
+    test12,
+    test13,
+    test14,
+    test15,
+};
+
+int main(int argc, char **argv)
+{
+    int index;
+    int (*ftest)(void);
+
+    if (argc < 2) {
+        printf("usage: boundtest n\n"
+               "test TCC bound checking system\n"
+               );
+        exit(1);
+    }
+
+    index = 0;
+    if (argc >= 2)
+        index = atoi(argv[1]);
+    /* well, we also use bounds on this ! */
+    ftest = table_test[index];
+    ftest();
+
+    return 0;
+}
+
+/*
+ * without bound   0.77 s
+ * with bounds    4.73
+ */  
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tests/gcctestsuite.sh
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tests/gcctestsuite.sh	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tests/gcctestsuite.sh	(revision 279)
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+TESTSUITE_PATH=$HOME/gcc/gcc-3.2/gcc/testsuite/gcc.c-torture
+TCC="./tcc -B. -I. -DNO_TRAMPOLINES" 
+rm -f tcc.sum tcc.log
+nb_failed="0"
+
+for src in $TESTSUITE_PATH/compile/*.c ; do
+  echo $TCC -o /tmp/test.o -c $src 
+  $TCC -o /tmp/test.o -c $src >> tcc.log 2>&1
+  if [ "$?" = "0" ] ; then
+     result="PASS"
+  else
+     result="FAIL"
+     nb_failed=$(( $nb_failed + 1 ))
+  fi
+  echo "$result: $src"  >> tcc.sum
+done
+
+for src in $TESTSUITE_PATH/execute/*.c ; do
+  echo $TCC $src 
+  $TCC $src >> tcc.log 2>&1
+  if [ "$?" = "0" ] ; then
+     result="PASS"
+  else
+     result="FAIL"
+     nb_failed=$(( $nb_failed + 1 ))
+  fi
+  echo "$result: $src"  >> tcc.sum
+done
+
+echo "$nb_failed test(s) failed." >> tcc.sum
+echo "$nb_failed test(s) failed."
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tests/libtcc_test.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tests/libtcc_test.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tests/libtcc_test.c	(revision 279)
@@ -0,0 +1,76 @@
+/*
+ * Simple Test program for libtcc
+ *
+ * libtcc can be useful to use tcc as a "backend" for a code generator.
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "libtcc.h"
+
+/* this function is called by the generated code */
+int add(int a, int b)
+{
+    return a + b;
+}
+
+char my_program[] =
+"int fib(int n)\n"
+"{\n"
+"    if (n <= 2)\n"
+"        return 1;\n"
+"    else\n"
+"        return fib(n-1) + fib(n-2);\n"
+"}\n"
+"\n"
+"int foo(int n)\n"
+"{\n"
+"    printf(\"Hello World!\\n\");\n"
+"    printf(\"fib(%d) = %d\\n\", n, fib(n));\n"
+"    printf(\"add(%d, %d) = %d\\n\", n, 2 * n, add(n, 2 * n));\n"
+"    return 0;\n"
+"}\n";
+
+int main(int argc, char **argv)
+{
+    TCCState *s;
+    int (*func)(int);
+
+    s = tcc_new();
+    if (!s) {
+        fprintf(stderr, "Could not create tcc state\n");
+        exit(1);
+    }
+
+    /* if tcclib.h and libtcc1.a are not installed, where can we find them */
+    if (argc == 2 && !memcmp(argv[1], "lib_path=",9))
+        tcc_set_lib_path(s, argv[1]+9);
+
+    /* MUST BE CALLED before any compilation */
+    tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
+
+    if (tcc_compile_string(s, my_program) == -1)
+        return 1;
+
+    /* as a test, we add a symbol that the compiled program can use.
+       You may also open a dll with tcc_add_dll() and use symbols from that */
+    tcc_add_symbol(s, "add", add);
+
+    /* relocate the code */
+    if (tcc_relocate(s, TCC_RELOCATE_AUTO) < 0)
+        return 1;
+
+    /* get entry symbol */
+    func = tcc_get_symbol(s, "foo");
+    if (!func)
+        return 1;
+
+    /* run the code */
+    func(32);
+
+    /* delete the state */
+    tcc_delete(s);
+
+    return 0;
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/tests/tcctest.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/tests/tcctest.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/tests/tcctest.c	(revision 279)
@@ -0,0 +1,2721 @@
+/*
+ * TCC auto test program
+ */
+#include "../config.h"
+
+#if GCC_MAJOR >= 3
+
+/* Unfortunately, gcc version < 3 does not handle that! */
+#define ALL_ISOC99
+
+/* only gcc 3 handles _Bool correctly */
+#define BOOL_ISOC99
+
+/* gcc 2.95.3 does not handle correctly CR in strings or after strays */
+#define CORRECT_CR_HANDLING
+
+#endif
+
+/* deprecated and no longer supported in gcc 3.3 */
+//#define ACCEPT_CR_IN_STRINGS
+
+/* __VA_ARGS__ and __func__ support */
+#define C99_MACROS
+
+/* test various include syntaxes */
+
+#define TCCLIB_INC <tcclib.h>
+#define TCCLIB_INC1 <tcclib
+#define TCCLIB_INC2 h>
+#define TCCLIB_INC3 "tcclib"
+
+#include TCCLIB_INC
+
+#include TCCLIB_INC1.TCCLIB_INC2
+
+#include TCCLIB_INC1.h>
+
+/* gcc 3.2 does not accept that (bug ?) */
+//#include TCCLIB_INC3 ".h"
+
+#include <tcclib.h>
+
+#include "tcclib.h"
+
+void string_test();
+void expr_test();
+void macro_test();
+void recursive_macro_test();
+void scope_test();
+void forward_test();
+void funcptr_test();
+void loop_test();
+void switch_test();
+void goto_test();
+void enum_test();
+void typedef_test();
+void struct_test();
+void array_test();
+void expr_ptr_test();
+void bool_test();
+void expr2_test();
+void constant_expr_test();
+void expr_cmp_test();
+void char_short_test();
+void init_test(void);
+void compound_literal_test(void);
+int kr_test();
+void struct_assign_test(void);
+void cast_test(void);
+void bitfield_test(void);
+void c99_bool_test(void);
+void float_test(void);
+void longlong_test(void);
+void manyarg_test(void);
+void stdarg_test(void);
+void whitespace_test(void);
+void relocation_test(void);
+void old_style_function(void);
+void alloca_test(void);
+void c99_vla_test(int size1, int size2);
+void sizeof_test(void);
+void typeof_test(void);
+void local_label_test(void);
+void statement_expr_test(void);
+void asm_test(void);
+void builtin_test(void);
+void weak_test(void);
+void global_data_test(void);
+void cmp_comparison_test(void);
+void math_cmp_test(void);
+void callsave_test(void);
+void builtin_frame_address_test(void);
+
+int fib(int n);
+void num(int n);
+void forward_ref(void);
+int isid(int c);
+
+#define A 2
+#define N 1234 + A
+#define pf printf
+#define M1(a, b)  (a) + (b)
+
+#define str\
+(s) # s
+#define glue(a, b) a ## b
+#define xglue(a, b) glue(a, b)
+#define HIGHLOW "hello"
+#define LOW LOW ", world"
+
+static int onetwothree = 123;
+#define onetwothree4 onetwothree
+#define onetwothree xglue(onetwothree,4)
+
+#define min(a, b) ((a) < (b) ? (a) : (b))
+
+#ifdef C99_MACROS
+#define dprintf(level,...) printf(__VA_ARGS__)
+#endif
+
+/* gcc vararg macros */
+#define dprintf1(level, fmt, args...) printf(fmt, ## args)
+
+#define MACRO_NOARGS()
+
+#define AAA 3
+#undef AAA
+#define AAA 4
+
+#if 1
+#define B3 1
+#elif 1
+#define B3 2
+#elif 0
+#define B3 3
+#else
+#define B3 4
+#endif
+
+#define __INT64_C(c)	c ## LL
+#define INT64_MIN	(-__INT64_C(9223372036854775807)-1)
+
+int qq(int x)
+{
+    return x + 40;
+}
+#define qq(x) x
+
+#define spin_lock(lock) do { } while (0)
+#define wq_spin_lock spin_lock
+#define TEST2() wq_spin_lock(a)
+
+void macro_test(void)
+{
+    printf("macro:\n");
+
+
+    pf("N=%d\n", N);
+    printf("aaa=%d\n", AAA);
+
+    printf("min=%d\n", min(1, min(2, -1)));
+
+    printf("s1=%s\n", glue(HIGH, LOW));
+    printf("s2=%s\n", xglue(HIGH, LOW));
+    printf("s3=%s\n", str("c"));
+    printf("s4=%s\n", str(a1));
+    printf("B3=%d\n", B3);
+
+    printf("onetwothree=%d\n", onetwothree);
+
+#ifdef A
+    printf("A defined\n");
+#endif
+#ifdef B
+    printf("B defined\n");
+#endif
+#ifdef A
+    printf("A defined\n");
+#else
+    printf("A not defined\n");
+#endif
+#ifdef B
+    printf("B defined\n");
+#else
+    printf("B not defined\n");
+#endif
+
+#ifdef A
+    printf("A defined\n");
+#ifdef B
+    printf("B1 defined\n");
+#else
+    printf("B1 not defined\n");
+#endif
+#else
+    printf("A not defined\n");
+#ifdef B
+    printf("B2 defined\n");
+#else
+    printf("B2 not defined\n");
+#endif
+#endif
+
+#if 1+1
+    printf("test true1\n");
+#endif
+#if 0
+    printf("test true2\n");
+#endif
+#if 1-1
+    printf("test true3\n");
+#endif
+#if defined(A)
+    printf("test trueA\n");
+#endif
+#if defined(B)
+    printf("test trueB\n");
+#endif
+
+#if 0
+    printf("test 0\n");
+#elif 0
+    printf("test 1\n");
+#elif 2
+    printf("test 2\n");
+#else
+    printf("test 3\n");
+#endif
+
+    MACRO_NOARGS();
+
+#ifdef __LINE__
+    printf("__LINE__ defined\n");
+#endif
+
+    printf("__LINE__=%d __FILE__=%s\n",
+           __LINE__, __FILE__);
+#line 200
+    printf("__LINE__=%d __FILE__=%s\n",
+           __LINE__, __FILE__);
+#line 203 "test" 
+    printf("__LINE__=%d __FILE__=%s\n",
+           __LINE__, __FILE__);
+#line 227 "tcctest.c"
+
+    /* not strictly preprocessor, but we test it there */
+#ifdef C99_MACROS
+    printf("__func__ = %s\n", __func__);
+    dprintf(1, "vaarg=%d\n", 1);
+#endif
+    dprintf1(1, "vaarg1\n");
+    dprintf1(1, "vaarg1=%d\n", 2);
+    dprintf1(1, "vaarg1=%d %d\n", 1, 2);
+
+    /* gcc extension */
+    printf("func='%s'\n", __FUNCTION__);
+
+    /* complicated macros in glibc */
+    printf("INT64_MIN=%Ld\n", INT64_MIN);
+    {
+        int a;
+        a = 1;
+        glue(a+, +);
+        printf("a=%d\n", a);
+        glue(a <, <= 2);
+        printf("a=%d\n", a);
+    }
+    
+    /* macro function with argument outside the macro string */
+#define MF_s MF_hello
+#define MF_hello(msg) printf("%s\n",msg)
+
+#define MF_t printf("tralala\n"); MF_hello
+
+    MF_s("hi");
+    MF_t("hi");
+    
+    /* test macro substituion inside args (should not eat stream) */
+    printf("qq=%d\n", qq(qq)(2));
+
+    /* test zero argument case. NOTE: gcc 2.95.x does not accept a
+       null argument without a space. gcc 3.2 fixes that. */
+
+#define qq1(x) 1
+    printf("qq1=%d\n", qq1( ));
+
+    /* comment with stray handling *\
+/
+       /* this is a valid *\/ comment */
+       /* this is a valid comment *\*/
+    //  this is a valid\
+comment
+
+    /* test function macro substitution when the function name is
+       substituted */
+    TEST2();
+
+    /* And again when the name and parenthes are separated by a
+       comment.  */
+    TEST2 /* the comment */ ();
+}
+
+
+static void print_num(char *fn, int line, int num) {
+    printf("fn %s, line %d, num %d\n", fn, line, num);
+}
+
+void recursive_macro_test(void)
+{
+
+#define ELF32_ST_TYPE(val)              ((val) & 0xf)
+#define ELF32_ST_INFO(bind, type)       (((bind) << 4) + ((type) & 0xf))
+#define STB_WEAK        2               /* Weak symbol */
+#define ELFW(type) ELF##32##_##type
+    printf("%d\n", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));
+
+#define WRAP(x) x
+    
+#define print_num(x) print_num(__FILE__,__LINE__,x)
+    print_num(123);
+    WRAP(print_num(123));
+    WRAP(WRAP(print_num(123)));
+
+static struct recursive_macro { int rm_field; } G;
+#define rm_field (G.rm_field)
+    printf("rm_field = %d\n", rm_field);
+    printf("rm_field = %d\n", WRAP(rm_field));
+    WRAP((printf("rm_field = %d %d\n", rm_field, WRAP(rm_field))));
+}
+
+int op(a,b)
+{
+    return a / b;
+}
+
+int ret(a)
+{
+    if (a == 2)
+        return 1;
+    if (a == 3)
+        return 2;
+    return 0;
+}
+
+void ps(const char *s)
+{
+    int c;
+    while (1) {
+        c = *s;
+        if (c == 0)
+            break;
+        printf("%c", c);
+        s++;
+    }
+}
+
+const char foo1_string[] = "\
+bar\n\
+test\14\
+1";
+
+void string_test()
+{
+    unsigned int b;
+    printf("string:\n");
+    printf("\141\1423\143\n");/* dezdez test */
+    printf("\x41\x42\x43\x3a\n");
+    printf("c=%c\n", 'r');
+    printf("wc=%C 0x%lx %C\n", L'a', L'\x1234', L'c');
+    printf("foo1_string='%s'\n", foo1_string);
+#if 0
+    printf("wstring=%S\n", L"abc");
+    printf("wstring=%S\n", L"abc" L"def" "ghi");
+    printf("'\\377'=%d '\\xff'=%d\n", '\377', '\xff');
+    printf("L'\\377'=%d L'\\xff'=%d\n", L'\377', L'\xff');
+#endif
+    ps("test\n");
+    b = 32;
+    while ((b = b + 1) < 96) {
+        printf("%c", b);
+    }
+    printf("\n");
+    printf("fib=%d\n", fib(33));
+    b = 262144;
+    while (b != 0x80000000) {
+        num(b);
+        b = b * 2;
+    }
+}
+
+void loop_test()
+{
+    int i;
+    i = 0;
+    while (i < 10)
+        printf("%d", i++);
+    printf("\n");
+    for(i = 0; i < 10;i++)
+        printf("%d", i);
+    printf("\n");
+    i = 0;
+    do {
+        printf("%d", i++);
+    } while (i < 10);
+    printf("\n");
+
+    char count = 123;
+    /* c99 for loop init test */
+    for (size_t count = 1; count < 3; count++)
+        printf("count=%d\n", count);
+    printf("count = %d\n", count);
+
+    /* break/continue tests */
+    i = 0;
+    while (1) {
+        if (i == 6)
+            break;
+        i++;
+        if (i == 3)
+            continue;
+        printf("%d", i);
+    }
+    printf("\n");
+
+    /* break/continue tests */
+    i = 0;
+    do {
+        if (i == 6)
+            break;
+        i++;
+        if (i == 3)
+            continue;
+        printf("%d", i);
+    } while(1);
+    printf("\n");
+
+    for(i = 0;i < 10;i++) {
+        if (i == 3)
+            continue;
+        printf("%d", i);
+    }
+    printf("\n");
+}
+
+typedef int typedef_and_label;
+
+void goto_test()
+{
+    int i;
+    static void *label_table[3] = { &&label1, &&label2, &&label3 };
+
+    printf("goto:\n");
+    i = 0;
+    /* This needs to parse as label, not as start of decl.  */
+ typedef_and_label:
+ s_loop:
+    if (i >= 10) 
+        goto s_end;
+    printf("%d", i);
+    i++;
+    goto s_loop;
+ s_end:
+    printf("\n");
+
+    /* we also test computed gotos (GCC extension) */
+    for(i=0;i<3;i++) {
+        goto *label_table[i];
+    label1:
+        printf("label1\n");
+        goto next;
+    label2:
+        printf("label2\n");
+        goto next;
+    label3:
+        printf("label3\n");
+    next: ;
+    }
+}
+
+enum {
+    E0,
+    E1 = 2,
+    E2 = 4,
+    E3,
+    E4,
+};
+
+enum test {
+    E5 = 1000,
+};
+
+void enum_test()
+{
+    enum test b1;
+    printf("enum:\n%d %d %d %d %d %d\n",
+           E0, E1, E2, E3, E4, E5);
+    b1 = 1;
+    printf("b1=%d\n", b1);
+}
+
+typedef int *my_ptr;
+
+typedef int mytype1;
+typedef int mytype2;
+
+void typedef_test()
+{
+    my_ptr a;
+    mytype1 mytype2;
+    int b;
+
+    a = &b;
+    *a = 1234;
+    printf("typedef:\n");
+    printf("a=%d\n", *a);
+    mytype2 = 2;
+    printf("mytype2=%d\n", mytype2);
+}
+
+void forward_test()
+{
+    printf("forward:\n");
+    forward_ref();
+    forward_ref();
+}
+
+
+void forward_ref(void)
+{
+    printf("forward ok\n");
+}
+
+typedef struct struct1 {
+    int f1;
+    int f2, f3;
+    union union1 {
+        int v1;
+        int v2;
+    } u;
+    char str[3];
+} struct1;
+
+struct struct2 {
+    int a;
+    char b;
+};
+
+union union2 {
+    int w1;
+    int w2;
+};
+
+struct struct1 st1, st2;
+
+int main(int argc, char **argv)
+{
+    string_test();
+    expr_test();
+    macro_test();
+    recursive_macro_test();
+    scope_test();
+    forward_test();
+    funcptr_test();
+    loop_test();
+    switch_test();
+    goto_test();
+    enum_test();
+    typedef_test();
+    struct_test();
+    array_test();
+    expr_ptr_test();
+    bool_test();
+    expr2_test();
+    constant_expr_test();
+    expr_cmp_test();
+    char_short_test();
+    init_test();
+    compound_literal_test();
+    kr_test();
+    struct_assign_test();
+    cast_test();
+    bitfield_test();
+    c99_bool_test();
+    float_test();
+    longlong_test();
+    manyarg_test();
+    stdarg_test();
+    whitespace_test();
+    relocation_test();
+    old_style_function();
+    alloca_test();
+    c99_vla_test(5, 2);
+    sizeof_test();
+    typeof_test();
+    statement_expr_test();
+    local_label_test();
+    asm_test();
+    builtin_test();
+#ifndef _WIN32
+    weak_test();
+#endif
+    global_data_test();
+    cmp_comparison_test();
+    math_cmp_test();
+    callsave_test();
+    builtin_frame_address_test();
+    return 0; 
+}
+
+int tab[3];
+int tab2[3][2];
+
+int g;
+
+void f1(g)
+{
+    printf("g1=%d\n", g);
+}
+
+void scope_test()
+{
+    printf("scope:\n");
+    g = 2;
+    f1(1);
+    printf("g2=%d\n", g);
+    {
+        int g;
+        g = 3;
+        printf("g3=%d\n", g);
+        {
+            int g;
+            g = 4;
+            printf("g4=%d\n", g);
+        }
+    }
+    printf("g5=%d\n", g);
+}
+
+void array_test()
+{
+    int i, j, a[4];
+
+    printf("array:\n");
+    printf("sizeof(a) = %d\n", sizeof(a));
+    printf("sizeof(\"a\") = %d\n", sizeof("a"));
+#ifdef C99_MACROS
+    printf("sizeof(__func__) = %d\n", sizeof(__func__));
+#endif
+    printf("sizeof tab %d\n", sizeof(tab));
+    printf("sizeof tab2 %d\n", sizeof tab2);
+    tab[0] = 1;
+    tab[1] = 2;
+    tab[2] = 3;
+    printf("%d %d %d\n", tab[0], tab[1], tab[2]);
+    for(i=0;i<3;i++)
+        for(j=0;j<2;j++)
+            tab2[i][j] = 10 * i + j;
+    for(i=0;i<3*2;i++) {
+        printf(" %3d", ((int *)tab2)[i]);
+    }
+    printf("\n");
+    printf("sizeof(size_t)=%d\n", sizeof(size_t));
+    printf("sizeof(ptrdiff_t)=%d\n", sizeof(ptrdiff_t));
+}
+
+void expr_test()
+{
+    int a, b;
+    a = 0;
+    printf("%d\n", a += 1);
+    printf("%d\n", a -= 2);
+    printf("%d\n", a *= 31232132);
+    printf("%d\n", a /= 4);
+    printf("%d\n", a %= 20);
+    printf("%d\n", a &= 6);
+    printf("%d\n", a ^= 7);
+    printf("%d\n", a |= 8);
+    printf("%d\n", a >>= 3);
+    printf("%d\n", a <<= 4);
+
+    a = 22321;
+    b = -22321;
+    printf("%d\n", a + 1);
+    printf("%d\n", a - 2);
+    printf("%d\n", a * 312);
+    printf("%d\n", a / 4);
+    printf("%d\n", b / 4);
+    printf("%d\n", (unsigned)b / 4);
+    printf("%d\n", a % 20);
+    printf("%d\n", b % 20);
+    printf("%d\n", (unsigned)b % 20);
+    printf("%d\n", a & 6);
+    printf("%d\n", a ^ 7);
+    printf("%d\n", a | 8);
+    printf("%d\n", a >> 3);
+    printf("%d\n", b >> 3);
+    printf("%d\n", (unsigned)b >> 3);
+    printf("%d\n", a << 4);
+    printf("%d\n", ~a);
+    printf("%d\n", -a);
+    printf("%d\n", +a);
+
+    printf("%d\n", 12 + 1);
+    printf("%d\n", 12 - 2);
+    printf("%d\n", 12 * 312);
+    printf("%d\n", 12 / 4);
+    printf("%d\n", 12 % 20);
+    printf("%d\n", 12 & 6);
+    printf("%d\n", 12 ^ 7);
+    printf("%d\n", 12 | 8);
+    printf("%d\n", 12 >> 2);
+    printf("%d\n", 12 << 4);
+    printf("%d\n", ~12);
+    printf("%d\n", -12);
+    printf("%d\n", +12);
+    printf("%d %d %d %d\n", 
+           isid('a'), 
+           isid('g'), 
+           isid('T'), 
+           isid('('));
+}
+
+int isid(int c)
+{
+    return (c >= 'a' & c <= 'z') | (c >= 'A' & c <= 'Z') | c == '_';
+}
+
+/**********************/
+
+int vstack[10], *vstack_ptr;
+
+void vpush(int vt, int vc)
+{
+    *vstack_ptr++ = vt;
+    *vstack_ptr++ = vc;
+}
+
+void vpop(int *ft, int *fc)
+{
+    *fc = *--vstack_ptr;
+    *ft = *--vstack_ptr;
+}
+
+void expr2_test()
+{
+    int a, b;
+
+    printf("expr2:\n");
+    vstack_ptr = vstack;
+    vpush(1432432, 2);
+    vstack_ptr[-2] &= ~0xffffff80;
+    vpop(&a, &b);
+    printf("res= %d %d\n", a, b);
+}
+
+void constant_expr_test()
+{
+    int a;
+    printf("constant_expr:\n");
+    a = 3;
+    printf("%d\n", a * 16);
+    printf("%d\n", a * 1);
+    printf("%d\n", a + 0);
+}
+
+int tab4[10];
+
+void expr_ptr_test()
+{
+    int *p, *q;
+    int i = -1;
+
+    printf("expr_ptr:\n");
+    p = tab4;
+    q = tab4 + 10;
+    printf("diff=%d\n", q - p);
+    p++;
+    printf("inc=%d\n", p - tab4);
+    p--;
+    printf("dec=%d\n", p - tab4);
+    ++p;
+    printf("inc=%d\n", p - tab4);
+    --p;
+    printf("dec=%d\n", p - tab4);
+    printf("add=%d\n", p + 3 - tab4);
+    printf("add=%d\n", 3 + p - tab4);
+
+    /* check if 64bit support is ok */
+    q = p = 0;
+    q += i;
+    printf("%p %p %ld\n", q, p, p-q);
+    printf("%d %d %d %d %d %d\n",
+           p == q, p != q, p < q, p <= q, p >= q, p > q);
+    i = 0xf0000000;
+    p += i;
+    printf("%p %p %ld\n", q, p, p-q);
+    printf("%d %d %d %d %d %d\n",
+           p == q, p != q, p < q, p <= q, p >= q, p > q);
+    p = (int *)((char *)p + 0xf0000000);
+    printf("%p %p %ld\n", q, p, p-q);
+    printf("%d %d %d %d %d %d\n",
+           p == q, p != q, p < q, p <= q, p >= q, p > q);
+    p += 0xf0000000;
+    printf("%p %p %ld\n", q, p, p-q);
+    printf("%d %d %d %d %d %d\n",
+           p == q, p != q, p < q, p <= q, p >= q, p > q);
+    {
+        struct size12 {
+            int i, j, k;
+        };
+        struct size12 s[2], *sp = s;
+        int i, j;
+        sp->i = 42;
+        sp++;
+        j = -1;
+        printf("%d\n", sp[j].i);
+    }
+}
+
+void expr_cmp_test()
+{
+    int a, b;
+    printf("constant_expr:\n");
+    a = -1;
+    b = 1;
+    printf("%d\n", a == a);
+    printf("%d\n", a != a);
+
+    printf("%d\n", a < b);
+    printf("%d\n", a <= b);
+    printf("%d\n", a <= a);
+    printf("%d\n", b >= a);
+    printf("%d\n", a >= a);
+    printf("%d\n", b > a);
+
+    printf("%d\n", (unsigned)a < b);
+    printf("%d\n", (unsigned)a <= b);
+    printf("%d\n", (unsigned)a <= a);
+    printf("%d\n", (unsigned)b >= a);
+    printf("%d\n", (unsigned)a >= a);
+    printf("%d\n", (unsigned)b > a);
+}
+
+struct empty {
+};
+
+struct aligntest1 {
+    char a[10];
+};
+
+struct aligntest2 {
+    int a;
+    char b[10];
+};
+
+struct aligntest3 {
+    double a, b;
+};
+
+struct aligntest4 {
+    double a[0];
+};
+
+void struct_test()
+{
+    struct1 *s;
+    union union2 u;
+
+    printf("struct:\n");
+    printf("sizes: %d %d %d %d\n",
+           sizeof(struct struct1),
+           sizeof(struct struct2),
+           sizeof(union union1),
+           sizeof(union union2));
+    st1.f1 = 1;
+    st1.f2 = 2;
+    st1.f3 = 3;
+    printf("st1: %d %d %d\n",
+           st1.f1, st1.f2, st1.f3);
+    st1.u.v1 = 1;
+    st1.u.v2 = 2;
+    printf("union1: %d\n", st1.u.v1);
+    u.w1 = 1;
+    u.w2 = 2;
+    printf("union2: %d\n", u.w1);
+    s = &st2;
+    s->f1 = 3;
+    s->f2 = 2;
+    s->f3 = 1;
+    printf("st2: %d %d %d\n",
+           s->f1, s->f2, s->f3);
+    printf("str_addr=%x\n", (int)st1.str - (int)&st1.f1);
+
+    /* align / size tests */
+    printf("aligntest1 sizeof=%d alignof=%d\n",
+           sizeof(struct aligntest1), __alignof__(struct aligntest1));
+    printf("aligntest2 sizeof=%d alignof=%d\n",
+           sizeof(struct aligntest2), __alignof__(struct aligntest2));
+    printf("aligntest3 sizeof=%d alignof=%d\n",
+           sizeof(struct aligntest3), __alignof__(struct aligntest3));
+    printf("aligntest4 sizeof=%d alignof=%d\n",
+           sizeof(struct aligntest4), __alignof__(struct aligntest4));
+           
+    /* empty structures (GCC extension) */
+    printf("sizeof(struct empty) = %d\n", sizeof(struct empty));
+    printf("alignof(struct empty) = %d\n", __alignof__(struct empty));
+}
+
+/* XXX: depend on endianness */
+void char_short_test()
+{
+    int var1, var2;
+
+    printf("char_short:\n");
+
+    var1 = 0x01020304;
+    var2 = 0xfffefdfc;
+    printf("s8=%d %d\n", 
+           *(char *)&var1, *(char *)&var2);
+    printf("u8=%d %d\n", 
+           *(unsigned char *)&var1, *(unsigned char *)&var2);
+    printf("s16=%d %d\n", 
+           *(short *)&var1, *(short *)&var2);
+    printf("u16=%d %d\n", 
+           *(unsigned short *)&var1, *(unsigned short *)&var2);
+    printf("s32=%d %d\n", 
+           *(int *)&var1, *(int *)&var2);
+    printf("u32=%d %d\n", 
+           *(unsigned int *)&var1, *(unsigned int *)&var2);
+    *(char *)&var1 = 0x08;
+    printf("var1=%x\n", var1);
+    *(short *)&var1 = 0x0809;
+    printf("var1=%x\n", var1);
+    *(int *)&var1 = 0x08090a0b;
+    printf("var1=%x\n", var1);
+}
+
+/******************/
+
+typedef struct Sym {
+    int v;
+    int t;
+    int c;
+    struct Sym *next;
+    struct Sym *prev;
+} Sym;
+
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+
+static int toupper1(int a)
+{
+    return TOUPPER(a);
+}
+
+void bool_test()
+{
+    int *s, a, b, t, f, i;
+
+    a = 0;
+    s = (void*)0;
+    printf("!s=%d\n", !s);
+
+    if (!s || !s[0])
+        a = 1;
+    printf("a=%d\n", a);
+
+    printf("a=%d %d %d\n", 0 || 0, 0 || 1, 1 || 1);
+    printf("a=%d %d %d\n", 0 && 0, 0 && 1, 1 && 1);
+    printf("a=%d %d\n", 1 ? 1 : 0, 0 ? 1 : 0);
+#if 1 && 1
+    printf("a1\n");
+#endif
+#if 1 || 0
+    printf("a2\n");
+#endif
+#if 1 ? 0 : 1
+    printf("a3\n");
+#endif
+#if 0 ? 0 : 1
+    printf("a4\n");
+#endif
+
+    a = 4;
+    printf("b=%d\n", a + (0 ? 1 : a / 2));
+
+    /* test register spilling */
+    a = 10;
+    b = 10;
+    a = (a + b) * ((a < b) ?
+                   ((b - a) * (a - b)): a + b);
+    printf("a=%d\n", a);
+
+    /* test complex || or && expressions */
+    t = 1;
+    f = 0;
+    a = 32;
+    printf("exp=%d\n", f == (32 <= a && a <= 3));
+    printf("r=%d\n", (t || f) + (t && f));
+
+    /* test ? : cast */
+    {
+        int aspect_on;
+        int aspect_native = 65536;
+        double bfu_aspect = 1.0;
+        int aspect;
+        for(aspect_on = 0; aspect_on < 2; aspect_on++) {
+            aspect=aspect_on?(aspect_native*bfu_aspect+0.5):65535UL;
+            printf("aspect=%d\n", aspect);
+        }
+    }
+
+    /* test ? : GCC extension */
+    {
+        static int v1 = 34 ? : -1; /* constant case */
+        static int v2 = 0 ? : -1; /* constant case */
+        int a = 30;
+        
+        printf("%d %d\n", v1, v2);
+        printf("%d %d\n", a - 30 ? : a * 2, a + 1 ? : a * 2);
+    }
+
+    /* again complex expression */
+    for(i=0;i<256;i++) {
+        if (toupper1 (i) != TOUPPER (i))
+            printf("error %d\n", i);
+    }
+}
+
+/* GCC accepts that */
+static int tab_reinit[];
+static int tab_reinit[10];
+
+//int cinit1; /* a global variable can be defined several times without error ! */
+int cinit1; 
+int cinit1; 
+int cinit1 = 0;
+int *cinit2 = (int []){3, 2, 1};
+
+void compound_literal_test(void)
+{
+    int *p, i;
+    char *q, *q3;
+
+    printf("compound_test:\n");
+
+    p = (int []){1, 2, 3};
+    for(i=0;i<3;i++)
+        printf(" %d", p[i]);
+    printf("\n");
+
+    for(i=0;i<3;i++)
+        printf("%d", cinit2[i]);
+    printf("\n");
+
+    q = "tralala1";
+    printf("q1=%s\n", q);
+
+    q = (char *){ "tralala2" };
+    printf("q2=%s\n", q);
+
+    q3 = (char *){ q };
+    printf("q3=%s\n", q3);
+
+    q = (char []){ "tralala3" };
+    printf("q4=%s\n", q);
+
+#ifdef ALL_ISOC99
+    p = (int []){1, 2, cinit1 + 3};
+    for(i=0;i<3;i++)
+        printf(" %d", p[i]);
+    printf("\n");
+
+    for(i=0;i<3;i++) {
+        p = (int []){1, 2, 4 + i};
+        printf("%d %d %d\n", 
+               p[0],
+               p[1],
+               p[2]);
+    }
+#endif
+}
+
+/* K & R protos */
+
+kr_func1(a, b)
+{
+    return a + b;
+}
+
+int kr_func2(a, b)
+{
+    return a + b;
+}
+
+kr_test()
+{
+    printf("kr_test:\n");
+    printf("func1=%d\n", kr_func1(3, 4));
+    printf("func2=%d\n", kr_func2(3, 4));
+    return 0;
+}
+
+void num(int n)
+{
+    char *tab, *p;
+    tab = (char*)malloc(20); 
+    p = tab;
+    while (1) {
+        *p = 48 + (n % 10);
+        p++;
+        n = n / 10;
+        if (n == 0)
+            break;
+    }
+    while (p != tab) {
+        p--;
+        printf("%c", *p);
+    }
+    printf("\n");
+    free(tab);
+}
+
+/* structure assignment tests */
+struct structa1 {
+    int f1;
+    char f2;
+};
+
+struct structa1 ssta1;
+
+void struct_assign_test1(struct structa1 s1, int t, float f)
+{
+    printf("%d %d %d %f\n", s1.f1, s1.f2, t, f);
+}
+
+struct structa1 struct_assign_test2(struct structa1 s1, int t)
+{
+    s1.f1 += t;
+    s1.f2 -= t;
+    return s1;
+}
+
+void struct_assign_test(void)
+{
+    struct S {
+      struct structa1 lsta1, lsta2;
+      int i;
+    } s, *ps;
+    
+    ps = &s;
+    ps->i = 4;
+#if 0
+    printf("struct_assign_test:\n");
+
+    s.lsta1.f1 = 1;
+    s.lsta1.f2 = 2;
+    printf("%d %d\n", s.lsta1.f1, s.lsta1.f2);
+    s.lsta2 = s.lsta1;
+    printf("%d %d\n", s.lsta2.f1, s.lsta2.f2);
+#else
+    s.lsta2.f1 = 1;
+    s.lsta2.f2 = 2;
+#endif
+    struct_assign_test1(ps->lsta2, 3, 4.5);
+    
+    printf("before call: %d %d\n", s.lsta2.f1, s.lsta2.f2);
+    ps->lsta2 = struct_assign_test2(ps->lsta2, ps->i);
+    printf("after call: %d %d\n", ps->lsta2.f1, ps->lsta2.f2);
+
+    static struct {
+        void (*elem)();
+    } t[] = {
+        /* XXX: we should allow this even without braces */
+        { struct_assign_test }
+    };
+    printf("%d\n", struct_assign_test == t[0].elem);
+}
+
+/* casts to short/char */
+
+void cast1(char a, short b, unsigned char c, unsigned short d)
+{
+    printf("%d %d %d %d\n", a, b, c, d);
+}
+
+char bcast;
+short scast;
+
+void cast_test()
+{
+    int a;
+    char c;
+    char tab[10];
+    unsigned b,d;
+    short s;
+    char *p = NULL;
+    p -= 0x700000000042;
+
+    printf("cast_test:\n");
+    a = 0xfffff;
+    cast1(a, a, a, a);
+    a = 0xffffe;
+    printf("%d %d %d %d\n",
+           (char)(a + 1),
+           (short)(a + 1),
+           (unsigned char)(a + 1),
+           (unsigned short)(a + 1));
+    printf("%d %d %d %d\n",
+           (char)0xfffff,
+           (short)0xfffff,
+           (unsigned char)0xfffff,
+           (unsigned short)0xfffff);
+
+    a = (bcast = 128) + 1;
+    printf("%d\n", a);
+    a = (scast = 65536) + 1;
+    printf("%d\n", a);
+    
+    printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c));
+    
+    /* test cast from unsigned to signed short to int */
+    b = 0xf000;
+    d = (short)b;
+    printf("((unsigned)(short)0x%08x) = 0x%08x\n", b, d);
+    b = 0xf0f0;
+    d = (char)b;
+    printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d);
+    
+    /* test implicit int casting for array accesses */
+    c = 0;
+    tab[1] = 2;
+    tab[c] = 1;
+    printf("%d %d\n", tab[0], tab[1]);
+
+    /* test implicit casting on some operators */
+    printf("sizeof(+(char)'a') = %d\n", sizeof(+(char)'a'));
+    printf("sizeof(-(char)'a') = %d\n", sizeof(-(char)'a'));
+    printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
+
+    /* from pointer to integer types */
+    printf("%d %d %ld %ld %lld %lld\n",
+           (int)p, (unsigned int)p,
+           (long)p, (unsigned long)p,
+           (long long)p, (unsigned long long)p);
+
+    /* from integers to pointers */
+    printf("%p %p %p %p\n",
+           (void *)a, (void *)b, (void *)c, (void *)d);
+}
+
+/* initializers tests */
+struct structinit1 {
+    int f1;
+    char f2;
+    short f3;
+    int farray[3];
+};
+
+int sinit1 = 2;
+int sinit2 = { 3 };
+int sinit3[3] = { 1, 2, {{3}}, };
+int sinit4[3][2] = { {1, 2}, {3, 4}, {5, 6} };
+int sinit5[3][2] = { 1, 2, 3, 4, 5, 6 };
+int sinit6[] = { 1, 2, 3 };
+int sinit7[] = { [2] = 3, [0] = 1, 2 };
+char sinit8[] = "hello" "trala";
+
+struct structinit1 sinit9 = { 1, 2, 3 };
+struct structinit1 sinit10 = { .f2 = 2, 3, .f1 = 1 };
+struct structinit1 sinit11 = { .f2 = 2, 3, .f1 = 1, 
+#ifdef ALL_ISOC99
+                               .farray[0] = 10,
+                               .farray[1] = 11,
+                               .farray[2] = 12,
+#endif
+};
+
+char *sinit12 = "hello world";
+char *sinit13[] = {
+    "test1",
+    "test2",
+    "test3",
+};
+char sinit14[10] = { "abc" };
+int sinit15[3] = { sizeof(sinit15), 1, 2 };
+
+struct { int a[3], b; } sinit16[] = { { 1 }, 2 };
+
+struct bar {
+        char *s;
+        int len;
+} sinit17[] = {
+        "a1", 4,
+        "a2", 1
+};
+
+int sinit18[10] = {
+    [2 ... 5] = 20,
+    2,
+    [8] = 10,
+};
+
+struct complexinit0 {
+    int a;
+    int b;
+};
+
+struct complexinit {
+    int a;
+    const struct complexinit0 *b;
+};
+
+const static struct complexinit cix[] = {
+    [0] = {
+	.a = 2000,
+	.b = (const struct complexinit0[]) {
+		{ 2001, 2002 },
+		{ 2003, 2003 },
+		{}
+	}
+    }
+};
+
+struct complexinit2 {
+	int a;
+	int b[];
+};
+
+struct complexinit2 cix20;
+
+struct complexinit2 cix21 = {
+	.a = 3000,
+	.b = { 3001, 3002, 3003 }
+};
+
+struct complexinit2 cix22 = {
+	.a = 4000,
+	.b = { 4001, 4002, 4003, 4004, 4005, 4006 }
+};
+
+void init_test(void)
+{
+    int linit1 = 2;
+    int linit2 = { 3 };
+    int linit4[3][2] = { {1, 2}, {3, 4}, {5, 6} };
+    int linit6[] = { 1, 2, 3 };
+    int i, j;
+    char linit8[] = "hello" "trala";
+    int linit12[10] = { 1, 2 };
+    int linit13[10] = { 1, 2, [7] = 3, [3] = 4, };
+    char linit14[10] = "abc";
+    int linit15[10] = { linit1, linit1 + 1, [6] = linit1 + 2, };
+    struct linit16 { int a1, a2, a3, a4; } linit16 = { 1, .a3 = 2 };
+    int linit17 = sizeof(linit17);
+    
+    printf("init_test:\n");
+
+    printf("sinit1=%d\n", sinit1);
+    printf("sinit2=%d\n", sinit2);
+    printf("sinit3=%d %d %d %d\n", 
+           sizeof(sinit3),
+           sinit3[0],
+           sinit3[1],
+           sinit3[2]
+           );
+    printf("sinit6=%d\n", sizeof(sinit6));
+    printf("sinit7=%d %d %d %d\n", 
+           sizeof(sinit7),
+           sinit7[0],
+           sinit7[1],
+           sinit7[2]
+           );
+    printf("sinit8=%s\n", sinit8);
+    printf("sinit9=%d %d %d\n", 
+           sinit9.f1,
+           sinit9.f2,
+           sinit9.f3
+           );
+    printf("sinit10=%d %d %d\n", 
+           sinit10.f1,
+           sinit10.f2,
+           sinit10.f3
+           );
+    printf("sinit11=%d %d %d %d %d %d\n", 
+           sinit11.f1,
+           sinit11.f2,
+           sinit11.f3,
+           sinit11.farray[0],
+           sinit11.farray[1],
+           sinit11.farray[2]
+           );
+
+    for(i=0;i<3;i++)
+        for(j=0;j<2;j++)
+            printf("[%d][%d] = %d %d %d\n", 
+                   i, j, sinit4[i][j], sinit5[i][j], linit4[i][j]);
+    printf("linit1=%d\n", linit1);
+    printf("linit2=%d\n", linit2);
+    printf("linit6=%d\n", sizeof(linit6));
+    printf("linit8=%d %s\n", sizeof(linit8), linit8);
+
+    printf("sinit12=%s\n", sinit12);
+    printf("sinit13=%d %s %s %s\n",
+           sizeof(sinit13), 
+           sinit13[0],
+           sinit13[1],
+           sinit13[2]);
+    printf("sinit14=%s\n", sinit14);
+
+    for(i=0;i<10;i++) printf(" %d", linit12[i]);
+    printf("\n");
+    for(i=0;i<10;i++) printf(" %d", linit13[i]);
+    printf("\n");
+    for(i=0;i<10;i++) printf(" %d", linit14[i]);
+    printf("\n");
+    for(i=0;i<10;i++) printf(" %d", linit15[i]);
+    printf("\n");
+    printf("%d %d %d %d\n", 
+           linit16.a1,
+           linit16.a2,
+           linit16.a3,
+           linit16.a4);
+    /* test that initialisation is done after variable declare */
+    printf("linit17=%d\n", linit17);
+    printf("sinit15=%d\n", sinit15[0]);
+    printf("sinit16=%d %d\n", sinit16[0].a[0], sinit16[1].a[0]);
+    printf("sinit17=%s %d %s %d\n",
+           sinit17[0].s, sinit17[0].len,
+           sinit17[1].s, sinit17[1].len);
+    for(i=0;i<10;i++)
+        printf("%x ", sinit18[i]);
+    printf("\n");
+    /* complex init check */
+    printf("cix: %d %d %d %d %d %d %d\n",
+	cix[0].a,
+	cix[0].b[0].a, cix[0].b[0].b,
+	cix[0].b[1].a, cix[0].b[1].b,
+	cix[0].b[2].a, cix[0].b[2].b);
+    printf("cix2: %d %d\n", cix21.b[2], cix22.b[5]);
+    printf("sizeof cix20 %d, cix21 %d, sizeof cix22 %d\n", sizeof cix20, sizeof cix21, sizeof cix22);
+}
+
+
+void switch_test()
+{
+    int i;
+
+    for(i=0;i<15;i++) {
+        switch(i) {
+        case 0:
+        case 1:
+            printf("a");
+            break;
+        default:
+            printf("%d", i);
+            break;
+        case 8 ... 12:
+            printf("c");
+            break;
+        case 3:
+            printf("b");
+            break;
+        }
+    }
+    printf("\n");
+}
+
+/* ISOC99 _Bool type */
+void c99_bool_test(void)
+{
+#ifdef BOOL_ISOC99
+    int a;
+    _Bool b;
+
+    printf("bool_test:\n");
+    printf("sizeof(_Bool) = %d\n", sizeof(_Bool));
+    a = 3;
+    printf("cast: %d %d %d\n", (_Bool)10, (_Bool)0, (_Bool)a);
+    b = 3;
+    printf("b = %d\n", b);
+    b++;
+    printf("b = %d\n", b);
+#endif
+}
+
+void bitfield_test(void)
+{
+    int a;
+    short sa;
+    unsigned char ca;
+    struct sbf1 {
+        int f1 : 3;
+        int : 2;
+        int f2 : 1;
+        int : 0;
+        int f3 : 5;
+        int f4 : 7;
+        unsigned int f5 : 7;
+    } st1;
+    printf("bitfield_test:");
+    printf("sizeof(st1) = %d\n", sizeof(st1));
+
+    st1.f1 = 3;
+    st1.f2 = 1;
+    st1.f3 = 15;
+    a = 120;
+    st1.f4 = a;
+    st1.f5 = a;
+    st1.f5++;
+    printf("%d %d %d %d %d\n",
+           st1.f1, st1.f2, st1.f3, st1.f4, st1.f5);
+    sa = st1.f5;
+    ca = st1.f5;
+    printf("%d %d\n", sa, ca);
+
+    st1.f1 = 7;
+    if (st1.f1 == -1) 
+        printf("st1.f1 == -1\n");
+    else 
+        printf("st1.f1 != -1\n");
+    if (st1.f2 == -1) 
+        printf("st1.f2 == -1\n");
+    else 
+        printf("st1.f2 != -1\n");
+
+    /* bit sizes below must be bigger than 32 since GCC doesn't allow
+       long-long bitfields whose size is not bigger than int */
+    struct sbf2 {
+        long long f1 : 45;
+        long long : 2;
+        long long f2 : 35;
+        unsigned long long f3 : 38;
+    } st2;
+    st2.f1 = 0x123456789ULL;
+    a = 120;
+    st2.f2 = (long long)a << 25;
+    st2.f3 = a;
+    st2.f2++;
+    printf("%lld %lld %lld\n", st2.f1, st2.f2, st2.f3);
+}
+
+#ifdef __x86_64__
+#define FLOAT_FMT "%f\n"
+#else
+/* x86's float isn't compatible with GCC */
+#define FLOAT_FMT "%.5f\n"
+#endif
+
+/* declare strto* functions as they are C99 */
+double strtod(const char *nptr, char **endptr);
+float strtof(const char *nptr, char **endptr);
+long double strtold(const char *nptr, char **endptr);
+
+#define FTEST(prefix, type, fmt)\
+void prefix ## cmp(type a, type b)\
+{\
+    printf("%d %d %d %d %d %d\n",\
+           a == b,\
+           a != b,\
+           a < b,\
+           a > b,\
+           a >= b,\
+           a <= b);\
+    printf(fmt " " fmt " " fmt " " fmt " " fmt " " fmt " " fmt "\n",\
+           a,\
+           b,\
+           a + b,\
+           a - b,\
+           a * b,\
+           a / b,\
+           -a);\
+    printf(fmt "\n", ++a);\
+    printf(fmt "\n", a++);\
+    printf(fmt "\n", a);\
+    b = 0;\
+    printf("%d %d\n", !a, !b);\
+}\
+void prefix ## fcast(type a)\
+{\
+    float fa;\
+    double da;\
+    long double la;\
+    int ia;\
+    unsigned int ua;\
+    type b;\
+    fa = a;\
+    da = a;\
+    la = a;\
+    printf("ftof: %f %f %Lf\n", fa, da, la);\
+    ia = (int)a;\
+    ua = (unsigned int)a;\
+    printf("ftoi: %d %u\n", ia, ua);\
+    ia = -1234;\
+    ua = 0x81234500;\
+    b = ia;\
+    printf("itof: " fmt "\n", b);\
+    b = ua;\
+    printf("utof: " fmt "\n", b);\
+}\
+\
+float prefix ## retf(type a) { return a; }\
+double prefix ## retd(type a) { return a; }\
+long double prefix ## retld(type a) { return a; }\
+\
+void prefix ## call(void)\
+{\
+    printf("float: " FLOAT_FMT, prefix ## retf(42.123456789));\
+    printf("double: %f\n", prefix ## retd(42.123456789));\
+    printf("long double: %Lf\n", prefix ## retld(42.123456789));\
+    printf("strto%s: %f\n", #prefix, (double)strto ## prefix("1.2", NULL));\
+}\
+\
+void prefix ## test(void)\
+{\
+    printf("testing '%s'\n", #type);\
+    prefix ## cmp(1, 2.5);\
+    prefix ## cmp(2, 1.5);\
+    prefix ## cmp(1, 1);\
+    prefix ## fcast(234.6);\
+    prefix ## fcast(-2334.6);\
+    prefix ## call();\
+}
+
+FTEST(f, float, "%f")
+FTEST(d, double, "%f")
+FTEST(ld, long double, "%Lf")
+
+double ftab1[3] = { 1.2, 3.4, -5.6 };
+
+
+void float_test(void)
+{
+    float fa, fb;
+    double da, db;
+    int a;
+    unsigned int b;
+
+    printf("float_test:\n");
+    printf("sizeof(float) = %d\n", sizeof(float));
+    printf("sizeof(double) = %d\n", sizeof(double));
+    printf("sizeof(long double) = %d\n", sizeof(long double));
+    ftest();
+    dtest();
+    ldtest();
+    printf("%f %f %f\n", ftab1[0], ftab1[1], ftab1[2]);
+    printf("%f %f %f\n", 2.12, .5, 2.3e10);
+    //    printf("%f %f %f\n", 0x1234p12, 0x1e23.23p10, 0x12dp-10);
+    da = 123;
+    printf("da=%f\n", da);
+    fa = 123;
+    printf("fa=%f\n", fa);
+    a = 4000000000;
+    da = a;
+    printf("da = %f\n", da);
+    b = 4000000000;
+    db = b;
+    printf("db = %f\n", db);
+}
+
+int fib(int n)
+{
+    if (n <= 2)
+        return 1;
+    else
+        return fib(n-1) + fib(n-2);
+}
+
+void funcptr_test()
+{
+    void (*func)(int);
+    int a;
+    struct {
+        int dummy;
+        void (*func)(int);
+    } st1;
+
+    printf("funcptr:\n");
+    func = &num;
+    (*func)(12345);
+    func = num;
+    a = 1;
+    a = 1;
+    func(12345);
+    /* more complicated pointer computation */
+    st1.func = num;
+    st1.func(12346);
+    printf("sizeof1 = %d\n", sizeof(funcptr_test));
+    printf("sizeof2 = %d\n", sizeof funcptr_test);
+    printf("sizeof3 = %d\n", sizeof(&funcptr_test));
+    printf("sizeof4 = %d\n", sizeof &funcptr_test);
+}
+
+void lloptest(long long a, long long b)
+{
+    unsigned long long ua, ub;
+
+    ua = a;
+    ub = b;
+    /* arith */
+    printf("arith: %Ld %Ld %Ld\n",
+           a + b,
+           a - b,
+           a * b);
+    
+    if (b != 0) {
+        printf("arith1: %Ld %Ld\n",
+           a / b,
+           a % b);
+    }
+
+    /* binary */
+    printf("bin: %Ld %Ld %Ld\n",
+           a & b,
+           a | b,
+           a ^ b);
+
+    /* tests */
+    printf("test: %d %d %d %d %d %d\n",
+           a == b,
+           a != b,
+           a < b,
+           a > b,
+           a >= b,
+           a <= b);
+    
+    printf("utest: %d %d %d %d %d %d\n",
+           ua == ub,
+           ua != ub,
+           ua < ub,
+           ua > ub,
+           ua >= ub,
+           ua <= ub);
+
+    /* arith2 */
+    a++;
+    b++;
+    printf("arith2: %Ld %Ld\n", a, b);
+    printf("arith2: %Ld %Ld\n", a++, b++);
+    printf("arith2: %Ld %Ld\n", --a, --b);
+    printf("arith2: %Ld %Ld\n", a, b);
+    b = ub = 0;
+    printf("not: %d %d %d %d\n", !a, !ua, !b, !ub);
+}
+
+void llshift(long long a, int b)
+{
+    printf("shift: %Ld %Ld %Ld\n",
+           (unsigned long long)a >> b,
+           a >> b,
+           a << b);
+    printf("shiftc: %Ld %Ld %Ld\n",
+           (unsigned long long)a >> 3,
+           a >> 3,
+           a << 3);
+    printf("shiftc: %Ld %Ld %Ld\n",
+           (unsigned long long)a >> 35,
+           a >> 35,
+           a << 35);
+}
+
+void llfloat(void)
+{
+    float fa;
+    double da;
+    long double lda;
+    long long la, lb, lc;
+    unsigned long long ula, ulb, ulc;
+    la = 0x12345678;
+    ula = 0x72345678;
+    la = (la << 20) | 0x12345;
+    ula = ula << 33;
+    printf("la=%Ld ula=%Lu\n", la, ula);
+
+    fa = la;
+    da = la;
+    lda = la;
+    printf("lltof: %f %f %Lf\n", fa, da, lda);
+
+    la = fa;
+    lb = da;
+    lc = lda;
+    printf("ftoll: %Ld %Ld %Ld\n", la, lb, lc);
+
+    fa = ula;
+    da = ula;
+    lda = ula;
+    printf("ulltof: %f %f %Lf\n", fa, da, lda);
+
+    ula = fa;
+    ulb = da;
+    ulc = lda;
+    printf("ftoull: %Lu %Lu %Lu\n", ula, ulb, ulc);
+}
+
+long long llfunc1(int a)
+{
+    return a * 2;
+}
+
+struct S {
+    int id; 
+    char item;
+};
+
+long long int value(struct S *v)
+{
+    return ((long long int)v->item);
+}
+
+void longlong_test(void)
+{
+    long long a, b, c;
+    int ia;
+    unsigned int ua;
+    printf("longlong_test:\n");
+    printf("sizeof(long long) = %d\n", sizeof(long long));
+    ia = -1;
+    ua = -2;
+    a = ia;
+    b = ua;
+    printf("%Ld %Ld\n", a, b);
+    printf("%Ld %Ld %Ld %Lx\n", 
+           (long long)1, 
+           (long long)-2,
+           1LL,
+           0x1234567812345679);
+    a = llfunc1(-3);
+    printf("%Ld\n", a);
+
+    lloptest(1000, 23);
+    lloptest(0xff, 0x1234);
+    b = 0x72345678 << 10;
+    lloptest(-3, b);
+    llshift(0x123, 5);
+    llshift(-23, 5);
+    b = 0x72345678LL << 10;
+    llshift(b, 47);
+
+    llfloat();
+#if 1
+    b = 0x12345678;
+    a = -1;
+    c = a + b;
+    printf("%Lx\n", c);
+#endif
+
+    /* long long reg spill test */
+    {
+          struct S a;
+
+          a.item = 3;
+          printf("%lld\n", value(&a));
+    }
+    lloptest(0x80000000, 0);
+
+    /* another long long spill test */
+    {
+        long long *p, v;
+        v = 1;
+        p = &v;
+        p[0]++;
+        printf("%lld\n", *p);
+    }
+
+    a = 68719476720LL;
+    b = 4294967295LL;
+    printf("%d %d %d %d\n", a > b, a < b, a >= b, a <= b);
+
+    printf("%Ld\n", 0x123456789LLU);
+}
+
+void manyarg_test(void)
+{
+    long double ld = 1234567891234LL;
+    printf("manyarg_test:\n");
+    printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\n",
+           1, 2, 3, 4, 5, 6, 7, 8,
+           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);
+    printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+           "%Ld %Ld %f %f\n",
+           1, 2, 3, 4, 5, 6, 7, 8,
+           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+           1234567891234LL, 987654321986LL,
+           42.0, 43.0);
+    printf("%Lf %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+           "%Ld %Ld %f %f\n",
+           ld, 1, 2, 3, 4, 5, 6, 7, 8,
+           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+           1234567891234LL, 987654321986LL,
+           42.0, 43.0);
+    /* XXX: known bug of x86-64 */
+#ifndef __x86_64__
+    printf("%d %d %d %d %d %d %d %d %Lf\n",
+           1, 2, 3, 4, 5, 6, 7, 8, ld);
+    printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+           "%Ld %Ld %f %f %Lf\n",
+           1, 2, 3, 4, 5, 6, 7, 8,
+           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+           1234567891234LL, 987654321986LL,
+           42.0, 43.0, ld);
+    printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+           "%Lf %Ld %Ld %f %f %Lf\n",
+           1, 2, 3, 4, 5, 6, 7, 8,
+           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+           ld, 1234567891234LL, 987654321986LL,
+           42.0, 43.0, ld);
+#endif
+}
+
+void vprintf1(const char *fmt, ...)
+{
+    va_list ap, aq;
+    const char *p;
+    int c, i;
+    double d;
+    long long ll;
+    long double ld;
+
+    va_start(aq, fmt);
+    va_copy(ap, aq);
+    
+    p = fmt;
+    for(;;) {
+        c = *p;
+        if (c == '\0')
+            break;
+        p++;
+        if (c == '%') {
+            c = *p;
+            switch(c) {
+            case '\0':
+                goto the_end;
+            case 'd':
+                i = va_arg(ap, int);
+                printf("%d", i);
+                break;
+            case 'f':
+                d = va_arg(ap, double);
+                printf("%f", d);
+                break;
+            case 'l':
+                ll = va_arg(ap, long long);
+                printf("%Ld", ll);
+                break;
+            case 'F':
+                ld = va_arg(ap, long double);
+                printf("%Lf", ld);
+                break;
+            }
+            p++;
+        } else {
+            putchar(c);
+        }
+    }
+ the_end:
+    va_end(aq);
+    va_end(ap);
+}
+
+struct myspace {
+    short int profile;
+};
+
+void stdarg_for_struct(struct myspace bob, ...)
+{
+    struct myspace george, bill;
+    va_list ap;
+    short int validate;
+
+    va_start(ap, bob);
+    bill     = va_arg(ap, struct myspace);
+    george   = va_arg(ap, struct myspace);
+    validate = va_arg(ap, int);
+    printf("stdarg_for_struct: %d %d %d %d\n",
+           bob.profile, bill.profile, george.profile, validate);
+    va_end(ap);
+}
+
+void stdarg_test(void)
+{
+    long double ld = 1234567891234LL;
+    struct myspace bob;
+
+    vprintf1("%d %d %d\n", 1, 2, 3);
+    vprintf1("%f %d %f\n", 1.0, 2, 3.0);
+    vprintf1("%l %l %d %f\n", 1234567891234LL, 987654321986LL, 3, 1234.0);
+    vprintf1("%F %F %F\n", 1.2L, 2.3L, 3.4L);
+#ifdef __x86_64__
+    /* a bug of x86's TCC */
+    vprintf1("%d %f %l %F %d %f %l %F\n",
+             1, 1.2, 3L, 4.5L, 6, 7.8, 9L, 0.1L);
+#endif
+    vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f\n",
+             1, 2, 3, 4, 5, 6, 7, 8,
+             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8);
+    vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\n",
+             1, 2, 3, 4, 5, 6, 7, 8,
+             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);
+    vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+             "%l %l %f %f\n",
+             1, 2, 3, 4, 5, 6, 7, 8,
+             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+             1234567891234LL, 987654321986LL,
+             42.0, 43.0);
+    vprintf1("%F %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+             "%l %l %f %f\n",
+             ld, 1, 2, 3, 4, 5, 6, 7, 8,
+             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+             1234567891234LL, 987654321986LL,
+             42.0, 43.0);
+    vprintf1("%d %d %d %d %d %d %d %d %F\n",
+             1, 2, 3, 4, 5, 6, 7, 8, ld);
+    vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+             "%l %l %f %f %F\n",
+             1, 2, 3, 4, 5, 6, 7, 8,
+             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+             1234567891234LL, 987654321986LL,
+             42.0, 43.0, ld);
+    vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
+             "%F %l %l %f %f %F\n",
+             1, 2, 3, 4, 5, 6, 7, 8,
+             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
+             ld, 1234567891234LL, 987654321986LL,
+             42.0, 43.0, ld);
+
+    bob.profile = 42;
+    stdarg_for_struct(bob, bob, bob, bob.profile);
+}
+
+void whitespace_test(void)
+{
+    char *str;
+
+
+
+
+#if 1
+    pri\
+ntf("whitspace:\n");
+
+
+#endif
+    pf("N=%d\n", 2);
+
+#ifdef CORRECT_CR_HANDLING
+    pri\
+ntf("aaa=%d\n", 3);
+#endif
+
+    pri\
+\
+ntf("min=%d\n", 4);
+
+#ifdef ACCEPT_CR_IN_STRINGS
+    printf("len1=%d\n", strlen("
+"));
+#ifdef CORRECT_CR_HANDLING
+    str = "
+";
+    printf("len1=%d str[0]=%d\n", strlen(str), str[0]);
+#endif
+    printf("len1=%d\n", strlen("
+a
+"));
+#endif /* ACCEPT_CR_IN_STRINGS */
+}
+
+int reltab[3] = { 1, 2, 3 };
+
+int *rel1 = &reltab[1];
+int *rel2 = &reltab[2];
+
+void relocation_test(void)
+{
+    printf("*rel1=%d\n", *rel1);
+    printf("*rel2=%d\n", *rel2);
+}
+
+void old_style_f(a,b,c)
+     int a, b;
+     double c;
+{
+    printf("a=%d b=%d b=%f\n", a, b, c);
+}
+
+void decl_func1(int cmpfn())
+{
+    printf("cmpfn=%lx\n", (long)cmpfn);
+}
+
+void decl_func2(cmpfn)
+int cmpfn();
+{
+    printf("cmpfn=%lx\n", (long)cmpfn);
+}
+
+void old_style_function(void)
+{
+    old_style_f((void *)1, 2, 3.0);
+    decl_func1(NULL);
+    decl_func2(NULL);
+}
+
+void alloca_test()
+{
+#if defined __i386__ || defined __x86_64__
+    char *p = alloca(16);
+    strcpy(p,"123456789012345");
+    printf("alloca: p is %s\n", p);
+    char *demo = "This is only a test.\n";
+    /* Test alloca embedded in a larger expression */
+    printf("alloca: %s\n", strcpy(alloca(strlen(demo)+1),demo) );
+#endif
+}
+
+void *bounds_checking_is_enabled()
+{
+    char ca[10], *cp = ca-1;
+    return (ca != cp + 1) ? cp : NULL;
+}
+
+typedef int constant_negative_array_size_as_compile_time_assertion_idiom[(1 ? 2 : 0) - 1];
+
+void c99_vla_test(int size1, int size2)
+{
+#if defined __i386__ || defined __x86_64__
+    int size = size1 * size2;
+    int tab1[size][2], tab2[10][2];
+    void *tab1_ptr, *tab2_ptr, *bad_ptr;
+
+    /* "size" should have been 'captured' at tab1 declaration, 
+        so modifying it should have no effect on VLA behaviour. */
+    size = size-1;
+    
+    printf("Test C99 VLA 1 (sizeof): ");
+    printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");
+    tab1_ptr = tab1;
+    tab2_ptr = tab2;
+    printf("Test C99 VLA 2 (ptrs substract): ");
+    printf("%s\n", (tab2 - tab1 == (tab2_ptr - tab1_ptr) / (sizeof(int) * 2)) ? "PASSED" : "FAILED");
+    printf("Test C99 VLA 3 (ptr add): ");
+    printf("%s\n", &tab1[5][1] == (tab1_ptr + (5 * 2 + 1) * sizeof(int)) ? "PASSED" : "FAILED");
+    printf("Test C99 VLA 4 (ptr access): ");
+    tab1[size1][1] = 42;
+    printf("%s\n", (*((int *) (tab1_ptr + (size1 * 2 + 1) * sizeof(int))) == 42) ? "PASSED" : "FAILED");
+
+    printf("Test C99 VLA 5 (bounds checking (might be disabled)): ");
+    if (bad_ptr = bounds_checking_is_enabled()) {
+        int *t1 = &tab1[size1 * size2 - 1][3];
+        int *t2 = &tab2[9][3];
+        printf("%s ", bad_ptr == t1 ? "PASSED" : "FAILED");
+        printf("%s ", bad_ptr == t2 ? "PASSED" : "FAILED");
+
+        char*c1 = 1 + sizeof(tab1) + (char*)tab1;
+        char*c2 = 1 + sizeof(tab2) + (char*)tab2;
+        printf("%s ", bad_ptr == c1 ? "PASSED" : "FAILED");
+        printf("%s ", bad_ptr == c2 ? "PASSED" : "FAILED");
+
+        int *i1 = tab1[-1];
+        int *i2 = tab2[-1];
+        printf("%s ", bad_ptr == i1 ? "PASSED" : "FAILED");
+        printf("%s ", bad_ptr == i2 ? "PASSED" : "FAILED");
+
+        int *x1 = tab1[size1 * size2 + 1];
+        int *x2 = tab2[10 + 1];
+        printf("%s ", bad_ptr == x1 ? "PASSED" : "FAILED");
+        printf("%s ", bad_ptr == x2 ? "PASSED" : "FAILED");
+    } else {
+        printf("PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED ");
+    }
+    printf("\n");
+#endif
+}
+
+typedef __SIZE_TYPE__ uintptr_t;
+
+void sizeof_test(void)
+{
+    int a;
+    int **ptr;
+
+    printf("sizeof(int) = %d\n", sizeof(int));
+    printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int));
+    printf("sizeof(long) = %d\n", sizeof(long));
+    printf("sizeof(unsigned long) = %d\n", sizeof(unsigned long));
+    printf("sizeof(short) = %d\n", sizeof(short));
+    printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short));
+    printf("sizeof(char) = %d\n", sizeof(char));
+    printf("sizeof(unsigned char) = %d\n", sizeof(unsigned char));
+    printf("sizeof(func) = %d\n", sizeof sizeof_test());
+    a = 1;
+    printf("sizeof(a++) = %d\n", sizeof a++);
+    printf("a=%d\n", a);
+    ptr = NULL;
+    printf("sizeof(**ptr) = %d\n", sizeof (**ptr));
+
+    /* The type of sizeof should be as large as a pointer, actually
+       it should be size_t.  */
+    printf("sizeof(sizeof(int) = %d\n", sizeof(sizeof(int)));
+    uintptr_t t = 1;
+    uintptr_t t2;
+    /* Effectively <<32, but defined also on 32bit machines.  */
+    t <<= 16;
+    t <<= 16;
+    t++;
+    /* This checks that sizeof really can be used to manipulate 
+       uintptr_t objects, without truncation.  */
+    t2 = t & -sizeof(uintptr_t);
+    printf ("%lu %lu\n", t, t2);
+
+    /* some alignof tests */
+    printf("__alignof__(int) = %d\n", __alignof__(int));
+    printf("__alignof__(unsigned int) = %d\n", __alignof__(unsigned int));
+    printf("__alignof__(short) = %d\n", __alignof__(short));
+    printf("__alignof__(unsigned short) = %d\n", __alignof__(unsigned short));
+    printf("__alignof__(char) = %d\n", __alignof__(char));
+    printf("__alignof__(unsigned char) = %d\n", __alignof__(unsigned char));
+    printf("__alignof__(func) = %d\n", __alignof__ sizeof_test());
+}
+
+void typeof_test(void)
+{
+    double a;
+    typeof(a) b;
+    typeof(float) c;
+
+    a = 1.5;
+    b = 2.5;
+    c = 3.5;
+    printf("a=%f b=%f c=%f\n", a, b, c);
+}
+
+void statement_expr_test(void)
+{
+    int a, i;
+
+    a = 0;
+    for(i=0;i<10;i++) {
+        a += 1 + 
+            ( { int b, j; 
+                b = 0; 
+                for(j=0;j<5;j++) 
+                    b += j; b; 
+            } );
+    }
+    printf("a=%d\n", a);
+    
+}
+
+void local_label_test(void)
+{
+    int a;
+    goto l1;
+ l2:
+    a = 1 + ({
+        __label__ l1, l2, l3, l4;
+        goto l1;
+    l4:
+        printf("aa1\n");
+        goto l3;
+    l2:
+        printf("aa3\n");
+        goto l4;
+    l1:
+        printf("aa2\n");
+        goto l2;
+    l3:;
+        1;
+    });
+    printf("a=%d\n", a);
+    return;
+ l4:
+    printf("bb1\n");
+    goto l2;
+ l1:
+    printf("bb2\n");
+    goto l4;
+}
+
+/* inline assembler test */
+#ifdef __i386__
+
+/* from linux kernel */
+static char * strncat1(char * dest,const char * src,size_t count)
+{
+int d0, d1, d2, d3;
+__asm__ __volatile__(
+	"repne\n\t"
+	"scasb\n\t"
+	"decl %1\n\t"
+	"movl %8,%3\n"
+	"1:\tdecl %3\n\t"
+	"js 2f\n\t"
+	"lodsb\n\t"
+	"stosb\n\t"
+	"testb %%al,%%al\n\t"
+	"jne 1b\n"
+	"2:\txorl %2,%2\n\t"
+	"stosb"
+	: "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
+	: "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count)
+	: "memory");
+return dest;
+}
+
+static char * strncat2(char * dest,const char * src,size_t count)
+{
+int d0, d1, d2, d3;
+__asm__ __volatile__(
+	"repne scasb\n\t" /* one-line repne prefix + string op */
+	"decl %1\n\t"
+	"movl %8,%3\n"
+	"1:\tdecl %3\n\t"
+	"js 2f\n\t"
+	"lodsb\n\t"
+	"stosb\n\t"
+	"testb %%al,%%al\n\t"
+	"jne 1b\n"
+	"2:\txorl %2,%2\n\t"
+	"stosb"
+	: "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
+	: "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count)
+	: "memory");
+return dest;
+}
+
+static inline void * memcpy1(void * to, const void * from, size_t n)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+	"rep ; movsl\n\t"
+	"testb $2,%b4\n\t"
+	"je 1f\n\t"
+	"movsw\n"
+	"1:\ttestb $1,%b4\n\t"
+	"je 2f\n\t"
+	"movsb\n"
+	"2:"
+	: "=&c" (d0), "=&D" (d1), "=&S" (d2)
+	:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+	: "memory");
+return (to);
+}
+
+static inline void * memcpy2(void * to, const void * from, size_t n)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+	"rep movsl\n\t"  /* one-line rep prefix + string op */
+	"testb $2,%b4\n\t"
+	"je 1f\n\t"
+	"movsw\n"
+	"1:\ttestb $1,%b4\n\t"
+	"je 2f\n\t"
+	"movsb\n"
+	"2:"
+	: "=&c" (d0), "=&D" (d1), "=&S" (d2)
+	:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+	: "memory");
+return (to);
+}
+
+static __inline__ void sigaddset1(unsigned int *set, int _sig)
+{
+	__asm__("btsl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc");
+}
+
+static __inline__ void sigdelset1(unsigned int *set, int _sig)
+{
+	asm("btrl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc");
+}
+
+static __inline__ __const__ unsigned int swab32(unsigned int x)
+{
+	__asm__("xchgb %b0,%h0\n\t"	/* swap lower bytes	*/
+		"rorl $16,%0\n\t"	/* swap words		*/
+		"xchgb %b0,%h0"		/* swap higher bytes	*/
+		:"=q" (x)
+		: "0" (x));
+	return x;
+}
+
+static __inline__ unsigned long long mul64(unsigned int a, unsigned int b)
+{
+    unsigned long long res;
+    __asm__("mull %2" : "=A" (res) : "a" (a), "r" (b));
+    return res;
+}
+
+static __inline__ unsigned long long inc64(unsigned long long a)
+{
+    unsigned long long res;
+    __asm__("addl $1, %%eax ; adcl $0, %%edx" : "=A" (res) : "A" (a));
+    return res;
+}
+
+unsigned int set;
+
+void asm_test(void)
+{
+    char buf[128];
+    unsigned int val;
+
+    printf("inline asm:\n");
+    /* test the no operand case */
+    asm volatile ("xorl %eax, %eax");
+
+    memcpy1(buf, "hello", 6);
+    strncat1(buf, " worldXXXXX", 3);
+    printf("%s\n", buf);
+
+    memcpy2(buf, "hello", 6);
+    strncat2(buf, " worldXXXXX", 3);
+    printf("%s\n", buf);
+
+    /* 'A' constraint test */
+    printf("mul64=0x%Lx\n", mul64(0x12345678, 0xabcd1234));
+    printf("inc64=0x%Lx\n", inc64(0x12345678ffffffff));
+
+    set = 0xff;
+    sigdelset1(&set, 2);
+    sigaddset1(&set, 16);
+    /* NOTE: we test here if C labels are correctly restored after the
+       asm statement */
+    goto label1;
+ label2:
+    __asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc");
+#ifdef __GNUC__ // works strange with GCC 4.3
+    set=0x1080fd;
+#endif
+    printf("set=0x%x\n", set);
+    val = 0x01020304;
+    printf("swab32(0x%08x) = 0x%0x\n", val, swab32(val));
+    return;
+ label1:
+    goto label2;
+}
+
+#else
+
+void asm_test(void)
+{
+}
+
+#endif
+
+#define COMPAT_TYPE(type1, type2) \
+{\
+    printf("__builtin_types_compatible_p(%s, %s) = %d\n", #type1, #type2, \
+           __builtin_types_compatible_p (type1, type2));\
+}
+
+int constant_p_var;
+
+void builtin_test(void)
+{
+#if GCC_MAJOR >= 3
+    COMPAT_TYPE(int, int);
+    COMPAT_TYPE(int, unsigned int);
+    COMPAT_TYPE(int, char);
+    COMPAT_TYPE(int, const int);
+    COMPAT_TYPE(int, volatile int);
+    COMPAT_TYPE(int *, int *);
+    COMPAT_TYPE(int *, void *);
+    COMPAT_TYPE(int *, const int *);
+    COMPAT_TYPE(char *, unsigned char *);
+/* space is needed because tcc preprocessor introduces a space between each token */
+    COMPAT_TYPE(char * *, void *); 
+#endif
+    printf("res = %d\n", __builtin_constant_p(1));
+    printf("res = %d\n", __builtin_constant_p(1 + 2));
+    printf("res = %d\n", __builtin_constant_p(&constant_p_var));
+    printf("res = %d\n", __builtin_constant_p(constant_p_var));
+}
+
+#ifndef _WIN32
+extern int __attribute__((weak)) weak_f1(void);
+extern int __attribute__((weak)) weak_f2(void);
+extern int                       weak_f3(void);
+extern int __attribute__((weak)) weak_v1;
+extern int __attribute__((weak)) weak_v2;
+extern int                       weak_v3;
+
+extern int                           (*weak_fpa)() __attribute__((weak));
+extern int __attribute__((weak))     (*weak_fpb)();
+extern     __attribute__((weak)) int (*weak_fpc)();
+
+extern int                     weak_asm_f1(void) asm("weak_asm_f1x") __attribute((weak));
+extern int __attribute((weak)) weak_asm_f2(void) asm("weak_asm_f2x")                    ;
+extern int __attribute((weak)) weak_asm_f3(void) asm("weak_asm_f3x") __attribute((weak));
+extern int                     weak_asm_v1       asm("weak_asm_v1x") __attribute((weak));
+extern int __attribute((weak)) weak_asm_v2       asm("weak_asm_v2x")                    ;
+extern int __attribute((weak)) weak_asm_v3(void) asm("weak_asm_v3x") __attribute((weak));
+
+static const size_t dummy = 0;
+extern __typeof(dummy) weak_dummy1 __attribute__((weak, alias("dummy")));
+extern __typeof(dummy) __attribute__((weak, alias("dummy"))) weak_dummy2;
+extern __attribute__((weak, alias("dummy"))) __typeof(dummy) weak_dummy3;
+
+int some_lib_func(void);
+int dummy_impl_of_slf(void) { return 444; }
+int some_lib_func(void) __attribute__((weak, alias("dummy_impl_of_slf")));
+
+int weak_toolate() __attribute__((weak));
+int weak_toolate() { return 0; }
+
+void __attribute__((weak)) weak_test(void)
+{
+	printf("weak_f1=%d\n", weak_f1 ? weak_f1() : 123);
+	printf("weak_f2=%d\n", weak_f2 ? weak_f2() : 123);
+	printf("weak_f3=%d\n", weak_f3 ? weak_f3() : 123);
+	printf("weak_v1=%d\n",&weak_v1 ? weak_v1   : 123);
+	printf("weak_v2=%d\n",&weak_v2 ? weak_v2   : 123);
+	printf("weak_v3=%d\n",&weak_v3 ? weak_v3   : 123);
+
+	printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);
+	printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);
+	printf("weak_fpc=%d\n",&weak_fpc ? weak_fpc() : 123);
+	
+	printf("weak_asm_f1=%d\n", weak_asm_f1 != NULL);
+	printf("weak_asm_f2=%d\n", weak_asm_f2 != NULL);
+	printf("weak_asm_f3=%d\n", weak_asm_f3 != NULL);
+	printf("weak_asm_v1=%d\n",&weak_asm_v1 != NULL);
+	printf("weak_asm_v2=%d\n",&weak_asm_v2 != NULL);
+	printf("weak_asm_v3=%d\n",&weak_asm_v3 != NULL);
+}
+
+int __attribute__((weak)) weak_f2() { return 222; }
+int __attribute__((weak)) weak_f3() { return 333; }
+int __attribute__((weak)) weak_v2 = 222;
+int __attribute__((weak)) weak_v3 = 333;
+#endif
+
+void const_func(const int a)
+{
+}
+
+void const_warn_test(void)
+{
+    const_func(1);
+}
+
+struct condstruct {
+  int i;
+};
+
+int getme (struct condstruct *s, int i)
+{
+  int i1 = (i == 0 ? 0 : s)->i;
+  int i2 = (i == 0 ? s : 0)->i;
+  int i3 = (i == 0 ? (void*)0 : s)->i;
+  int i4 = (i == 0 ? s : (void*)0)->i;
+  return i1 + i2 + i3 + i4;
+}
+
+struct global_data
+{
+  int a[40];
+  int *b[40];
+};
+
+struct global_data global_data;
+
+int global_data_getstuff (int *, int);
+
+void global_data_callit (int i)
+{
+  *global_data.b[i] = global_data_getstuff (global_data.b[i], 1);
+}
+
+int global_data_getstuff (int *p, int i)
+{
+  return *p + i;
+}
+
+void global_data_test (void)
+{
+  global_data.a[0] = 42;
+  global_data.b[0] = &global_data.a[0];
+  global_data_callit (0);
+  printf ("%d\n", global_data.a[0]);
+}
+
+struct cmpcmpS
+{
+  unsigned char fill : 3;
+  unsigned char b1 : 1;
+  unsigned char b2 : 1;
+  unsigned char fill2 : 3;
+};
+
+int glob1, glob2, glob3;
+
+void compare_comparisons (struct cmpcmpS *s)
+{
+  if (s->b1 != (glob1 == glob2)
+      || (s->b2 != (glob1 == glob3)))
+    printf ("comparing comparisons broken\n");
+}
+
+void cmp_comparison_test(void)
+{
+  struct cmpcmpS s;
+  s.b1 = 1;
+  glob1 = 42; glob2 = 42;
+  s.b2 = 0;
+  glob3 = 43;
+  compare_comparisons (&s);
+}
+
+int fcompare (double a, double b, int code)
+{
+  switch (code) {
+    case 0: return a == b;
+    case 1: return a != b;
+    case 2: return a < b;
+    case 3: return a >= b;
+    case 4: return a > b;
+    case 5: return a <= b;
+  }
+}
+
+void math_cmp_test(void)
+{
+  double nan = 0.0/0.0;
+  double one = 1.0;
+  double two = 2.0;
+  int comp = 0;
+#define bug(a,b,op,iop,part) printf("Test broken: %s %s %s %s %d\n", #a, #b, #op, #iop, part)
+
+  /* This asserts that "a op b" is _not_ true, but "a iop b" is true.
+     And it does this in various ways so that all code generation paths
+     are checked (generating inverted tests, or non-inverted tests, or
+     producing a 0/1 value without jumps (that's done in the fcompare
+     function).  */
+#define FCMP(a,b,op,iop,code) \
+  if (fcompare (a,b,code))    \
+    bug (a,b,op,iop,1); \
+  if (a op b) \
+    bug (a,b,op,iop,2); \
+  if (a iop b) \
+    ; \
+  else \
+    bug (a,b,op,iop,3); \
+  if ((a op b) || comp) \
+    bug (a,b,op,iop,4); \
+  if ((a iop b) || comp) \
+    ; \
+  else \
+    bug (a,b,op,iop,5);
+
+  /* Equality tests.  */
+  FCMP(nan, nan, ==, !=, 0);
+  FCMP(one, two, ==, !=, 0);
+  FCMP(one, one, !=, ==, 1);
+  /* Non-equality is a bit special.  */
+  if (!fcompare (nan, nan, 1))
+    bug (nan, nan, !=, ==, 6);
+
+  /* Relational tests on numbers.  */
+  FCMP(two, one, <, >=, 2);
+  FCMP(one, two, >=, <, 3);
+  FCMP(one, two, >, <=, 4);
+  FCMP(two, one, <=, >, 5);
+
+  /* Relational tests on NaNs.  Note that the inverse op here is
+     always !=, there's no operator in C that is equivalent to !(a < b),
+     when NaNs are involved, same for the other relational ops.  */
+  FCMP(nan, nan, <, !=, 2);
+  FCMP(nan, nan, >=, !=, 3);
+  FCMP(nan, nan, >, !=, 4);
+  FCMP(nan, nan, <=, !=, 5);
+}
+
+double get100 () { return 100.0; }
+
+void callsave_test(void)
+{
+#if defined __i386__ || defined __x86_64__
+  int i, s; double *d; double t;
+  s = sizeof (double);
+  printf ("callsavetest: %d\n", s);
+  d = alloca (sizeof(double));
+  d[0] = 10.0;
+  /* x86-64 had a bug were the next call to get100 would evict
+     the lvalue &d[0] as VT_LLOCAL, and the reload would be done
+     in int type, not pointer type.  When alloca returns a pointer
+     with the high 32 bit set (which is likely on x86-64) the access
+     generates a segfault.  */
+  i = d[0] > get100 ();
+  printf ("%d\n", i);
+#endif
+}
+
+
+void bfa3(ptrdiff_t str_offset)
+{
+    printf("bfa3: %s\n", (char *)__builtin_frame_address(3) + str_offset);
+}
+void bfa2(ptrdiff_t str_offset)
+{
+    printf("bfa2: %s\n", (char *)__builtin_frame_address(2) + str_offset);
+    bfa3(str_offset);
+}
+void bfa1(ptrdiff_t str_offset)
+{
+    printf("bfa1: %s\n", (char *)__builtin_frame_address(1) + str_offset);
+#if defined(__arm__) && !defined(__GNUC__)
+    bfa2(str_offset);
+#endif
+}
+
+void builtin_frame_address_test(void)
+{
+    char str[] = "__builtin_frame_address";
+    char *fp0 = __builtin_frame_address(0);
+
+    printf("str: %s\n", str);
+    bfa1(str-fp0);
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/texi2pod.pl
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/texi2pod.pl	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/texi2pod.pl	(revision 279)
@@ -0,0 +1,427 @@
+#! /usr/bin/perl -w
+
+#   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# This file is part of GNU CC.
+
+# GNU CC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# GNU CC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with GNU CC; see the file COPYING.  If not, write to
+# the Free Software Foundation, 59 Temple Place - Suite 330,
+# Boston MA 02111-1307, USA.
+
+# This does trivial (and I mean _trivial_) conversion of Texinfo
+# markup to Perl POD format.  It's intended to be used to extract
+# something suitable for a manpage from a Texinfo document.
+
+$output = 0;
+$skipping = 0;
+%sects = ();
+$section = "";
+@icstack = ();
+@endwstack = ();
+@skstack = ();
+@instack = ();
+$shift = "";
+%defs = ();
+$fnno = 1;
+$inf = "";
+$ibase = "";
+
+while ($_ = shift) {
+    if (/^-D(.*)$/) {
+	if ($1 ne "") {
+	    $flag = $1;
+	} else {
+	    $flag = shift;
+	}
+	$value = "";
+	($flag, $value) = ($flag =~ /^([^=]+)(?:=(.+))?/);
+	die "no flag specified for -D\n"
+	    unless $flag ne "";
+	die "flags may only contain letters, digits, hyphens, dashes and underscores\n"
+	    unless $flag =~ /^[a-zA-Z0-9_-]+$/;
+	$defs{$flag} = $value;
+    } elsif (/^-/) {
+	usage();
+    } else {
+	$in = $_, next unless defined $in;
+	$out = $_, next unless defined $out;
+	usage();
+    }
+}
+
+if (defined $in) {
+    $inf = gensym();
+    open($inf, "<$in") or die "opening \"$in\": $!\n";
+    $ibase = $1 if $in =~ m|^(.+)/[^/]+$|;
+} else {
+    $inf = \*STDIN;
+}
+
+if (defined $out) {
+    open(STDOUT, ">$out") or die "opening \"$out\": $!\n";
+}
+
+while(defined $inf) {
+while(<$inf>) {
+    # Certain commands are discarded without further processing.
+    /^\@(?:
+	 [a-z]+index		# @*index: useful only in complete manual
+	 |need			# @need: useful only in printed manual
+	 |(?:end\s+)?group	# @group .. @end group: ditto
+	 |page			# @page: ditto
+	 |node			# @node: useful only in .info file
+	 |(?:end\s+)?ifnottex   # @ifnottex .. @end ifnottex: use contents
+	)\b/x and next;
+
+    chomp;
+
+    # Look for filename and title markers.
+    /^\@setfilename\s+([^.]+)/ and $fn = $1, next;
+    /^\@settitle\s+([^.]+)/ and $tl = postprocess($1), next;
+
+    # Identify a man title but keep only the one we are interested in.
+    /^\@c\s+man\s+title\s+([A-Za-z0-9-]+)\s+(.+)/ and do {
+	if (exists $defs{$1}) {
+	    $fn = $1;
+	    $tl = postprocess($2);
+	}
+	next;
+    };
+
+    # Look for blocks surrounded by @c man begin SECTION ... @c man end.
+    # This really oughta be @ifman ... @end ifman and the like, but such
+    # would require rev'ing all other Texinfo translators.
+    /^\@c\s+man\s+begin\s+([A-Z]+)\s+([A-Za-z0-9-]+)/ and do {
+	$output = 1 if exists $defs{$2};
+        $sect = $1;
+	next;
+    };
+    /^\@c\s+man\s+begin\s+([A-Z]+)/ and $sect = $1, $output = 1, next;
+    /^\@c\s+man\s+end/ and do {
+	$sects{$sect} = "" unless exists $sects{$sect};
+	$sects{$sect} .= postprocess($section);
+	$section = "";
+	$output = 0;
+	next;
+    };
+
+    # handle variables
+    /^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do {
+	$defs{$1} = $2;
+	next;
+    };
+    /^\@clear\s+([a-zA-Z0-9_-]+)/ and do {
+	delete $defs{$1};
+	next;
+    };
+
+    next unless $output;
+
+    # Discard comments.  (Can't do it above, because then we'd never see
+    # @c man lines.)
+    /^\@c\b/ and next;
+
+    # End-block handler goes up here because it needs to operate even
+    # if we are skipping.
+    /^\@end\s+([a-z]+)/ and do {
+	# Ignore @end foo, where foo is not an operation which may
+	# cause us to skip, if we are presently skipping.
+	my $ended = $1;
+	next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/;
+
+	die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
+	die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
+
+	$endw = pop @endwstack;
+
+	if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) {
+	    $skipping = pop @skstack;
+	    next;
+	} elsif ($ended =~ /^(?:example|smallexample|display)$/) {
+	    $shift = "";
+	    $_ = "";	# need a paragraph break
+	} elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
+	    $_ = "\n=back\n";
+	    $ic = pop @icstack;
+	} else {
+	    die "unknown command \@end $ended at line $.\n";
+	}
+    };
+
+    # We must handle commands which can cause skipping even while we
+    # are skipping, otherwise we will not process nested conditionals
+    # correctly.
+    /^\@ifset\s+([a-zA-Z0-9_-]+)/ and do {
+	push @endwstack, $endw;
+	push @skstack, $skipping;
+	$endw = "ifset";
+	$skipping = 1 unless exists $defs{$1};
+	next;
+    };
+
+    /^\@ifclear\s+([a-zA-Z0-9_-]+)/ and do {
+	push @endwstack, $endw;
+	push @skstack, $skipping;
+	$endw = "ifclear";
+	$skipping = 1 if exists $defs{$1};
+	next;
+    };
+
+    /^\@(ignore|menu|iftex)\b/ and do {
+	push @endwstack, $endw;
+	push @skstack, $skipping;
+	$endw = $1;
+	$skipping = 1;
+	next;
+    };
+
+    next if $skipping;
+
+    # Character entities.  First the ones that can be replaced by raw text
+    # or discarded outright:
+    s/\@copyright\{\}/(c)/g;
+    s/\@dots\{\}/.../g;
+    s/\@enddots\{\}/..../g;
+    s/\@([.!? ])/$1/g;
+    s/\@[:-]//g;
+    s/\@bullet(?:\{\})?/*/g;
+    s/\@TeX\{\}/TeX/g;
+    s/\@pounds\{\}/\#/g;
+    s/\@minus(?:\{\})?/-/g;
+    s/\\,/,/g;
+
+    # Now the ones that have to be replaced by special escapes
+    # (which will be turned back into text by unmunge())
+    s/&/&amp;/g;
+    s/\@\{/&lbrace;/g;
+    s/\@\}/&rbrace;/g;
+    s/\@\@/&at;/g;
+
+    # Inside a verbatim block, handle @var specially.
+    if ($shift ne "") {
+	s/\@var\{([^\}]*)\}/<$1>/g;
+    }
+
+    # POD doesn't interpret E<> inside a verbatim block.
+    if ($shift eq "") {
+	s/</&lt;/g;
+	s/>/&gt;/g;
+    } else {
+	s/</&LT;/g;
+	s/>/&GT;/g;
+    }
+
+    # Single line command handlers.
+
+    /^\@include\s+(.+)$/ and do {
+	push @instack, $inf;
+	$inf = gensym();
+
+	# Try cwd and $ibase.
+	open($inf, "<" . $1) 
+	    or open($inf, "<" . $ibase . "/" . $1)
+		or die "cannot open $1 or $ibase/$1: $!\n";
+	next;
+    };
+
+    /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/
+	and $_ = "\n=head2 $1\n";
+    /^\@subsection\s+(.+)$/
+	and $_ = "\n=head3 $1\n";
+
+    # Block command handlers:
+    /^\@itemize\s+(\@[a-z]+|\*|-)/ and do {
+	push @endwstack, $endw;
+	push @icstack, $ic;
+	$ic = $1;
+	$_ = "\n=over 4\n";
+	$endw = "itemize";
+    };
+
+    /^\@enumerate(?:\s+([a-zA-Z0-9]+))?/ and do {
+	push @endwstack, $endw;
+	push @icstack, $ic;
+	if (defined $1) {
+	    $ic = $1 . ".";
+	} else {
+	    $ic = "1.";
+	}
+	$_ = "\n=over 4\n";
+	$endw = "enumerate";
+    };
+
+    /^\@([fv]?table)\s+(\@[a-z]+)/ and do {
+	push @endwstack, $endw;
+	push @icstack, $ic;
+	$endw = $1;
+	$ic = $2;
+	$ic =~ s/\@(?:samp|strong|key|gcctabopt|option|env)/B/;
+	$ic =~ s/\@(?:code|kbd)/C/;
+	$ic =~ s/\@(?:dfn|var|emph|cite|i)/I/;
+	$ic =~ s/\@(?:file)/F/;
+	$_ = "\n=over 4\n";
+    };
+
+    /^\@((?:small)?example|display)/ and do {
+	push @endwstack, $endw;
+	$endw = $1;
+	$shift = "\t";
+	$_ = "";	# need a paragraph break
+    };
+
+    /^\@itemx?\s*(.+)?$/ and do {
+	if (defined $1) {
+	    # Entity escapes prevent munging by the <> processing below.
+	    $_ = "\n=item $ic\&LT;$1\&GT;\n";
+	} else {
+	    $_ = "\n=item $ic\n";
+	    $ic =~ y/A-Ya-y/B-Zb-z/;
+	    $ic =~ s/(\d+)/$1 + 1/eg;
+	}
+    };
+
+    $section .= $shift.$_."\n";
+}
+# End of current file.
+close($inf);
+$inf = pop @instack;
+}
+
+die "No filename or title\n" unless defined $fn && defined $tl;
+
+$sects{NAME} = "$fn \- $tl\n";
+$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES};
+
+for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS ENVIRONMENT FILES
+	      BUGS NOTES FOOTNOTES SEEALSO AUTHOR COPYRIGHT)) {
+    if(exists $sects{$sect}) {
+	$head = $sect;
+	$head =~ s/SEEALSO/SEE ALSO/;
+	print "=head1 $head\n\n";
+	print scalar unmunge ($sects{$sect});
+	print "\n";
+    }
+}
+
+sub usage
+{
+    die "usage: $0 [-D toggle...] [infile [outfile]]\n";
+}
+
+sub postprocess
+{
+    local $_ = $_[0];
+
+    # @value{foo} is replaced by whatever 'foo' is defined as.
+    while (m/(\@value\{([a-zA-Z0-9_-]+)\})/g) {
+	if (! exists $defs{$2}) {
+	    print STDERR "Option $2 not defined\n";
+	    s/\Q$1\E//;
+	} else {
+	    $value = $defs{$2};
+	    s/\Q$1\E/$value/;
+	}
+    }
+
+    # Formatting commands.
+    # Temporary escape for @r.
+    s/\@r\{([^\}]*)\}/R<$1>/g;
+    s/\@(?:dfn|var|emph|cite|i)\{([^\}]*)\}/I<$1>/g;
+    s/\@(?:code|kbd)\{([^\}]*)\}/C<$1>/g;
+    s/\@(?:gccoptlist|samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g;
+    s/\@sc\{([^\}]*)\}/\U$1/g;
+    s/\@file\{([^\}]*)\}/F<$1>/g;
+    s/\@w\{([^\}]*)\}/S<$1>/g;
+    s/\@(?:dmn|math)\{([^\}]*)\}/$1/g;
+
+    # Cross references are thrown away, as are @noindent and @refill.
+    # (@noindent is impossible in .pod, and @refill is unnecessary.)
+    # @* is also impossible in .pod; we discard it and any newline that
+    # follows it.  Similarly, our macro @gol must be discarded.
+
+    s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g;
+    s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g;
+    s/;\s+\@pxref\{(?:[^\}]*)\}//g;
+    s/\@noindent\s*//g;
+    s/\@refill//g;
+    s/\@gol//g;
+    s/\@\*\s*\n?//g;
+
+    # @uref can take one, two, or three arguments, with different
+    # semantics each time.  @url and @email are just like @uref with
+    # one argument, for our purposes.
+    s/\@(?:uref|url|email)\{([^\},]*)\}/&lt;B<$1>&gt;/g;
+    s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g;
+    s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
+
+    # Turn B<blah I<blah> blah> into B<blah> I<blah> B<blah> to
+    # match Texinfo semantics of @emph inside @samp.  Also handle @r
+    # inside bold.
+    s/&LT;/</g;
+    s/&GT;/>/g;
+    1 while s/B<((?:[^<>]|I<[^<>]*>)*)R<([^>]*)>/B<$1>${2}B</g;
+    1 while (s/B<([^<>]*)I<([^>]+)>/B<$1>I<$2>B</g);
+    1 while (s/I<([^<>]*)B<([^>]+)>/I<$1>B<$2>I</g);
+    s/[BI]<>//g;
+    s/([BI])<(\s+)([^>]+)>/$2$1<$3>/g;
+    s/([BI])<([^>]+?)(\s+)>/$1<$2>$3/g;
+
+    # Extract footnotes.  This has to be done after all other
+    # processing because otherwise the regexp will choke on formatting
+    # inside @footnote.
+    while (/\@footnote/g) {
+	s/\@footnote\{([^\}]+)\}/[$fnno]/;
+	add_footnote($1, $fnno);
+	$fnno++;
+    }
+
+    return $_;
+}
+
+sub unmunge
+{
+    # Replace escaped symbols with their equivalents.
+    local $_ = $_[0];
+
+    s/&lt;/E<lt>/g;
+    s/&gt;/E<gt>/g;
+    s/&lbrace;/\{/g;
+    s/&rbrace;/\}/g;
+    s/&at;/\@/g;
+    s/&amp;/&/g;
+    return $_;
+}
+
+sub add_footnote
+{
+    unless (exists $sects{FOOTNOTES}) {
+	$sects{FOOTNOTES} = "\n=over 4\n\n";
+    }
+
+    $sects{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++;
+    $sects{FOOTNOTES} .= $_[0];
+    $sects{FOOTNOTES} .= "\n\n";
+}
+
+# stolen from Symbol.pm
+{
+    my $genseq = 0;
+    sub gensym
+    {
+	my $name = "GEN" . $genseq++;
+	my $ref = \*{$name};
+	delete $::{$name};
+	return $ref;
+    }
+}
Index: /EcnlProtoTool/trunk/tcc-0.9.26/x86_64-asm.h
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/x86_64-asm.h	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/x86_64-asm.h	(revision 279)
@@ -0,0 +1,448 @@
+     DEF_ASM_OP0(clc, 0xf8) /* must be first OP0 */
+     DEF_ASM_OP0(cld, 0xfc)
+     DEF_ASM_OP0(cli, 0xfa)
+     DEF_ASM_OP0(clts, 0x0f06)
+     DEF_ASM_OP0(cmc, 0xf5)
+     DEF_ASM_OP0(lahf, 0x9f)
+     DEF_ASM_OP0(sahf, 0x9e)
+     DEF_ASM_OP0(pushfl, 0x9c)
+     DEF_ASM_OP0(popfl, 0x9d)
+     DEF_ASM_OP0(pushf, 0x9c)
+     DEF_ASM_OP0(popf, 0x9d)
+     DEF_ASM_OP0(stc, 0xf9)
+     DEF_ASM_OP0(std, 0xfd)
+     DEF_ASM_OP0(sti, 0xfb)
+     DEF_ASM_OP0(aaa, 0x37)
+     DEF_ASM_OP0(aas, 0x3f)
+     DEF_ASM_OP0(daa, 0x27)
+     DEF_ASM_OP0(das, 0x2f)
+     DEF_ASM_OP0(aad, 0xd50a)
+     DEF_ASM_OP0(aam, 0xd40a)
+     DEF_ASM_OP0(cbw, 0x6698)
+     DEF_ASM_OP0(cwd, 0x6699)
+     DEF_ASM_OP0(cwde, 0x98)
+     DEF_ASM_OP0(cdq, 0x99)
+     DEF_ASM_OP0(cbtw, 0x6698)
+     DEF_ASM_OP0(cwtl, 0x98)
+     DEF_ASM_OP0(cwtd, 0x6699)
+     DEF_ASM_OP0(cltd, 0x99)
+     DEF_ASM_OP0(cqto, 0x4899)
+     DEF_ASM_OP0(int3, 0xcc)
+     DEF_ASM_OP0(into, 0xce)
+     DEF_ASM_OP0(iret, 0xcf)
+     DEF_ASM_OP0(rsm, 0x0faa)
+     DEF_ASM_OP0(hlt, 0xf4)
+     DEF_ASM_OP0(wait, 0x9b)
+     DEF_ASM_OP0(nop, 0x90)
+     DEF_ASM_OP0(xlat, 0xd7)
+
+     /* strings */
+ALT(DEF_ASM_OP0L(cmpsb, 0xa6, 0, OPC_BWLQ))
+ALT(DEF_ASM_OP0L(scmpb, 0xa6, 0, OPC_BWLQ))
+
+ALT(DEF_ASM_OP0L(insb, 0x6c, 0, OPC_BWLQ))
+ALT(DEF_ASM_OP0L(outsb, 0x6e, 0, OPC_BWLQ))
+
+ALT(DEF_ASM_OP0L(lodsb, 0xac, 0, OPC_BWLQ))
+ALT(DEF_ASM_OP0L(slodb, 0xac, 0, OPC_BWLQ))
+
+ALT(DEF_ASM_OP0L(movsb, 0xa4, 0, OPC_BWLQ))
+ALT(DEF_ASM_OP0L(smovb, 0xa4, 0, OPC_BWLQ))
+
+ALT(DEF_ASM_OP0L(scasb, 0xae, 0, OPC_BWLQ))
+ALT(DEF_ASM_OP0L(sscab, 0xae, 0, OPC_BWLQ))
+
+ALT(DEF_ASM_OP0L(stosb, 0xaa, 0, OPC_BWLQ))
+ALT(DEF_ASM_OP0L(sstob, 0xaa, 0, OPC_BWLQ))
+
+     /* bits */
+
+ALT(DEF_ASM_OP2(bsfw, 0x0fbc, 0, OPC_MODRM | OPC_WLQ, OPT_REGW | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(bsrw, 0x0fbd, 0, OPC_MODRM | OPC_WLQ, OPT_REGW | OPT_EA, OPT_REGW))
+
+ALT(DEF_ASM_OP2(btw, 0x0fa3, 0, OPC_MODRM | OPC_WLQ, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btw, 0x0fba, 4, OPC_MODRM | OPC_WLQ, OPT_IM8, OPT_REGW | OPT_EA))
+
+ALT(DEF_ASM_OP2(btsw, 0x0fab, 0, OPC_MODRM | OPC_WLQ, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btsw, 0x0fba, 5, OPC_MODRM | OPC_WLQ, OPT_IM8, OPT_REGW | OPT_EA))
+
+ALT(DEF_ASM_OP2(btrw, 0x0fb3, 0, OPC_MODRM | OPC_WLQ, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btrw, 0x0fba, 6, OPC_MODRM | OPC_WLQ, OPT_IM8, OPT_REGW | OPT_EA))
+
+ALT(DEF_ASM_OP2(btcw, 0x0fbb, 0, OPC_MODRM | OPC_WLQ, OPT_REGW, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP2(btcw, 0x0fba, 7, OPC_MODRM | OPC_WLQ, OPT_IM8, OPT_REGW | OPT_EA))
+
+     /* prefixes */
+     DEF_ASM_OP0(lock, 0xf0)
+     DEF_ASM_OP0(rep, 0xf3)
+     DEF_ASM_OP0(repe, 0xf3)
+     DEF_ASM_OP0(repz, 0xf3)
+     DEF_ASM_OP0(repne, 0xf2)
+     DEF_ASM_OP0(repnz, 0xf2)
+
+     DEF_ASM_OP0(invd, 0x0f08)
+     DEF_ASM_OP0(wbinvd, 0x0f09)
+     DEF_ASM_OP0(cpuid, 0x0fa2)
+     DEF_ASM_OP0(wrmsr, 0x0f30)
+     DEF_ASM_OP0(rdtsc, 0x0f31)
+     DEF_ASM_OP0(rdmsr, 0x0f32)
+     DEF_ASM_OP0(rdpmc, 0x0f33)
+     DEF_ASM_OP0(ud2, 0x0f0b)
+
+     /* NOTE: we took the same order as gas opcode definition order */
+ALT(DEF_ASM_OP2(movb, 0xa0, 0, OPC_BWLQ, OPT_ADDR, OPT_EAX))
+ALT(DEF_ASM_OP2(movb, 0xa2, 0, OPC_BWLQ, OPT_EAX, OPT_ADDR))
+ALT(DEF_ASM_OP2(movb, 0x88, 0, OPC_MODRM | OPC_BWLQ, OPT_REG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(movb, 0x8a, 0, OPC_MODRM | OPC_BWLQ, OPT_EA | OPT_REG, OPT_REG))
+ALT(DEF_ASM_OP2(movb, 0xb0, 0, OPC_REG | OPC_BWLQ, OPT_IM, OPT_REG))
+ALT(DEF_ASM_OP2(movb, 0xc6, 0, OPC_MODRM | OPC_BWLQ, OPT_IM, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP2(movw, 0x8c, 0, OPC_MODRM | OPC_WLQ, OPT_SEG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(movw, 0x8e, 0, OPC_MODRM | OPC_WLQ, OPT_EA | OPT_REG, OPT_SEG))
+
+ALT(DEF_ASM_OP2(movw, 0x0f20, 0, OPC_MODRM | OPC_WLQ, OPT_CR, OPT_REG64))
+ALT(DEF_ASM_OP2(movw, 0x0f21, 0, OPC_MODRM | OPC_WLQ, OPT_DB, OPT_REG64))
+ALT(DEF_ASM_OP2(movw, 0x0f24, 0, OPC_MODRM | OPC_WLQ, OPT_TR, OPT_REG64))
+ALT(DEF_ASM_OP2(movw, 0x0f22, 0, OPC_MODRM | OPC_WLQ, OPT_REG64, OPT_CR))
+ALT(DEF_ASM_OP2(movw, 0x0f23, 0, OPC_MODRM | OPC_WLQ, OPT_REG64, OPT_DB))
+ALT(DEF_ASM_OP2(movw, 0x0f26, 0, OPC_MODRM | OPC_WLQ, OPT_REG64, OPT_TR))
+
+ALT(DEF_ASM_OP2(movsbl, 0x0fbe, 0, OPC_MODRM, OPT_REG8 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(movsbw, 0x0fbe, 0, OPC_MODRM | OPC_D16, OPT_REG8 | OPT_EA, OPT_REG16))
+ALT(DEF_ASM_OP2(movswl, 0x0fbf, 0, OPC_MODRM, OPT_REG16 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(movslq, 0x4863, 0, OPC_MODRM, OPT_REG32 | OPT_EA, OPT_REG))
+ALT(DEF_ASM_OP2(movzbw, 0x0fb6, 0, OPC_MODRM | OPC_WL, OPT_REG8 | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(movzwl, 0x0fb7, 0, OPC_MODRM, OPT_REG16 | OPT_EA, OPT_REG32))
+
+ALT(DEF_ASM_OP1(pushw, 0x50, 0, OPC_REG | OPC_WLQ, OPT_REG64))
+ALT(DEF_ASM_OP1(pushw, 0xff, 6, OPC_MODRM | OPC_WLQ, OPT_REG64 | OPT_EA))
+ALT(DEF_ASM_OP1(pushw, 0x68, 0, OPC_WLQ, OPT_IM32))
+ALT(DEF_ASM_OP1(pushw, 0x06, 0, OPC_WLQ, OPT_SEG))
+    DEF_ASM_OP1(pushb, 0x6a, 0, OPC_B, OPT_IM8S)
+
+ALT(DEF_ASM_OP1(popw, 0x58, 0, OPC_REG | OPC_WLQ, OPT_REGW))
+ALT(DEF_ASM_OP1(popw, 0x8f, 0, OPC_MODRM | OPC_WLQ, OPT_REGW | OPT_EA))
+ALT(DEF_ASM_OP1(popw, 0x07, 0, OPC_WLQ, OPT_SEG))
+
+ALT(DEF_ASM_OP2(xchgw, 0x90, 0, OPC_REG | OPC_WLQ, OPT_REG, OPT_EAX))
+ALT(DEF_ASM_OP2(xchgw, 0x90, 0, OPC_REG | OPC_WLQ, OPT_EAX, OPT_REG))
+ALT(DEF_ASM_OP2(xchgb, 0x86, 0, OPC_MODRM | OPC_BWLQ, OPT_REG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(xchgb, 0x86, 0, OPC_MODRM | OPC_BWLQ, OPT_EA | OPT_REG, OPT_REG))
+
+ALT(DEF_ASM_OP2(inb, 0xe4, 0, OPC_BWL, OPT_IM8, OPT_EAX))
+ALT(DEF_ASM_OP1(inb, 0xe4, 0, OPC_BWL, OPT_IM8))
+ALT(DEF_ASM_OP2(inb, 0xec, 0, OPC_BWL, OPT_DX, OPT_EAX))
+ALT(DEF_ASM_OP1(inb, 0xec, 0, OPC_BWL, OPT_DX))
+
+ALT(DEF_ASM_OP2(outb, 0xe6, 0, OPC_BWL, OPT_EAX, OPT_IM8))
+ALT(DEF_ASM_OP1(outb, 0xe6, 0, OPC_BWL, OPT_IM8))
+ALT(DEF_ASM_OP2(outb, 0xee, 0, OPC_BWL, OPT_EAX, OPT_DX))
+ALT(DEF_ASM_OP1(outb, 0xee, 0, OPC_BWL, OPT_DX))
+
+ALT(DEF_ASM_OP2(leaw, 0x8d, 0, OPC_MODRM | OPC_WLQ, OPT_EA, OPT_REG))
+
+ALT(DEF_ASM_OP2(les, 0xc4, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lds, 0xc5, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lss, 0x0fb2, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lfs, 0x0fb4, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(lgs, 0x0fb5, 0, OPC_MODRM, OPT_EA, OPT_REG32))
+
+     /* arith */
+ALT(DEF_ASM_OP2(addb, 0x00, 0, OPC_ARITH | OPC_MODRM | OPC_BWLQ, OPT_REG, OPT_EA | OPT_REG)) /* XXX: use D bit ? */
+ALT(DEF_ASM_OP2(addb, 0x02, 0, OPC_ARITH | OPC_MODRM | OPC_BWLQ, OPT_EA | OPT_REG, OPT_REG))
+ALT(DEF_ASM_OP2(addb, 0x04, 0, OPC_ARITH | OPC_BWLQ, OPT_IMNO64, OPT_EAX))
+ALT(DEF_ASM_OP2(addb, 0x80, 0, OPC_ARITH | OPC_MODRM | OPC_BWLQ, OPT_IMNO64, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(addw, 0x83, 0, OPC_ARITH | OPC_MODRM | OPC_WLQ, OPT_IM8S, OPT_EA | OPT_REG))
+
+ALT(DEF_ASM_OP2(testb, 0x84, 0, OPC_MODRM | OPC_BWLQ, OPT_EA | OPT_REG, OPT_REG))
+ALT(DEF_ASM_OP2(testb, 0x84, 0, OPC_MODRM | OPC_BWLQ, OPT_REG, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(testb, 0xa8, 0, OPC_BWLQ, OPT_IMNO64, OPT_EAX))
+ALT(DEF_ASM_OP2(testb, 0xf6, 0, OPC_MODRM | OPC_BWLQ, OPT_IMNO64, OPT_EA | OPT_REG))
+
+ALT(DEF_ASM_OP1(incw, 0x40, 0, OPC_REG | OPC_WLQ, OPT_REGW))
+ALT(DEF_ASM_OP1(incb, 0xfe, 0, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP1(decw, 0x48, 0, OPC_REG | OPC_WLQ, OPT_REGW))
+ALT(DEF_ASM_OP1(decb, 0xfe, 1, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP1(notb, 0xf6, 2, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP1(negb, 0xf6, 3, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP1(mulb, 0xf6, 4, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP1(imulb, 0xf6, 5, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+
+ALT(DEF_ASM_OP2(imulw, 0x0faf, 0, OPC_MODRM | OPC_WLQ, OPT_REG | OPT_EA, OPT_REG))
+ALT(DEF_ASM_OP3(imulw, 0x6b, 0, OPC_MODRM | OPC_WLQ, OPT_IM8S, OPT_REGW | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(imulw, 0x6b, 0, OPC_MODRM | OPC_WLQ, OPT_IM8S, OPT_REGW))
+ALT(DEF_ASM_OP3(imulw, 0x69, 0, OPC_MODRM | OPC_WLQ, OPT_IMW, OPT_REGW | OPT_EA, OPT_REGW))
+ALT(DEF_ASM_OP2(imulw, 0x69, 0, OPC_MODRM | OPC_WLQ, OPT_IMW, OPT_REGW))
+
+ALT(DEF_ASM_OP1(divb, 0xf6, 6, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP2(divb, 0xf6, 6, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA, OPT_EAX))
+ALT(DEF_ASM_OP1(idivb, 0xf6, 7, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA))
+ALT(DEF_ASM_OP2(idivb, 0xf6, 7, OPC_MODRM | OPC_BWLQ, OPT_REG | OPT_EA, OPT_EAX))
+
+     /* shifts */
+ALT(DEF_ASM_OP2(rolb, 0xc0, 0, OPC_MODRM | OPC_BWLQ | OPC_SHIFT, OPT_IM8, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP2(rolb, 0xd2, 0, OPC_MODRM | OPC_BWLQ | OPC_SHIFT, OPT_CL, OPT_EA | OPT_REG))
+ALT(DEF_ASM_OP1(rolb, 0xd0, 0, OPC_MODRM | OPC_BWLQ | OPC_SHIFT, OPT_EA | OPT_REG))
+
+ALT(DEF_ASM_OP3(shldw, 0x0fa4, 0, OPC_MODRM | OPC_WLQ, OPT_IM8, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP3(shldw, 0x0fa5, 0, OPC_MODRM | OPC_WLQ, OPT_CL, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP2(shldw, 0x0fa5, 0, OPC_MODRM | OPC_WLQ, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP3(shrdw, 0x0fac, 0, OPC_MODRM | OPC_WLQ, OPT_IM8, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP3(shrdw, 0x0fad, 0, OPC_MODRM | OPC_WLQ, OPT_CL, OPT_REGW, OPT_EA | OPT_REGW))
+ALT(DEF_ASM_OP2(shrdw, 0x0fad, 0, OPC_MODRM | OPC_WLQ, OPT_REGW, OPT_EA | OPT_REGW))
+
+ALT(DEF_ASM_OP1(call, 0xff, 2, OPC_MODRM, OPT_INDIR))
+ALT(DEF_ASM_OP1(call, 0xe8, 0, OPC_JMP, OPT_ADDR))
+ALT(DEF_ASM_OP1(jmp, 0xff, 4, OPC_MODRM, OPT_INDIR))
+ALT(DEF_ASM_OP1(jmp, 0xff, 0, OPC_JMP | OPC_WL, OPT_REGW))
+ALT(DEF_ASM_OP1(jmp, 0xeb, 0, OPC_SHORTJMP | OPC_JMP, OPT_ADDR))
+
+ALT(DEF_ASM_OP1(lcall, 0xff, 3, 0, OPT_EA))
+ALT(DEF_ASM_OP1(ljmp, 0xff, 5, 0, OPT_EA))
+
+ALT(DEF_ASM_OP1(int, 0xcd, 0, 0, OPT_IM8))
+ALT(DEF_ASM_OP1(seto, 0x0f90, 0, OPC_MODRM | OPC_TEST, OPT_REG8 | OPT_EA))
+    DEF_ASM_OP2(enter, 0xc8, 0, 0, OPT_IM16, OPT_IM8)
+    DEF_ASM_OP0(leave, 0xc9)
+    DEF_ASM_OP0(ret, 0xc3)
+ALT(DEF_ASM_OP1(ret, 0xc2, 0, 0, OPT_IM16))
+    DEF_ASM_OP0(lret, 0xcb)
+ALT(DEF_ASM_OP1(lret, 0xca, 0, 0, OPT_IM16))
+
+ALT(DEF_ASM_OP1(jo, 0x70, 0, OPC_SHORTJMP | OPC_JMP | OPC_TEST, OPT_ADDR))
+    DEF_ASM_OP1(loopne, 0xe0, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loopnz, 0xe0, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loope, 0xe1, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loopz, 0xe1, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(loop, 0xe2, 0, OPC_SHORTJMP, OPT_ADDR)
+    DEF_ASM_OP1(jecxz, 0xe3, 0, OPC_SHORTJMP, OPT_ADDR)
+
+     /* float */
+     /* specific fcomp handling */
+ALT(DEF_ASM_OP0L(fcomp, 0xd8d9, 0, 0))
+
+ALT(DEF_ASM_OP1(fadd, 0xd8c0, 0, OPC_FARITH | OPC_REG, OPT_ST))
+ALT(DEF_ASM_OP2(fadd, 0xd8c0, 0, OPC_FARITH | OPC_REG, OPT_ST, OPT_ST0))
+ALT(DEF_ASM_OP0L(fadd, 0xdec1, 0, OPC_FARITH))
+ALT(DEF_ASM_OP1(faddp, 0xdec0, 0, OPC_FARITH | OPC_REG, OPT_ST))
+ALT(DEF_ASM_OP2(faddp, 0xdec0, 0, OPC_FARITH | OPC_REG, OPT_ST, OPT_ST0))
+ALT(DEF_ASM_OP2(faddp, 0xdec0, 0, OPC_FARITH | OPC_REG, OPT_ST0, OPT_ST))
+ALT(DEF_ASM_OP0L(faddp, 0xdec1, 0, OPC_FARITH))
+ALT(DEF_ASM_OP1(fadds, 0xd8, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+ALT(DEF_ASM_OP1(fiaddl, 0xda, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+ALT(DEF_ASM_OP1(faddl, 0xdc, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+ALT(DEF_ASM_OP1(fiadds, 0xde, 0, OPC_FARITH | OPC_MODRM, OPT_EA))
+
+     DEF_ASM_OP0(fucompp, 0xdae9)
+     DEF_ASM_OP0(ftst, 0xd9e4)
+     DEF_ASM_OP0(fxam, 0xd9e5)
+     DEF_ASM_OP0(fld1, 0xd9e8)
+     DEF_ASM_OP0(fldl2t, 0xd9e9)
+     DEF_ASM_OP0(fldl2e, 0xd9ea)
+     DEF_ASM_OP0(fldpi, 0xd9eb)
+     DEF_ASM_OP0(fldlg2, 0xd9ec)
+     DEF_ASM_OP0(fldln2, 0xd9ed)
+     DEF_ASM_OP0(fldz, 0xd9ee)
+
+     DEF_ASM_OP0(f2xm1, 0xd9f0)
+     DEF_ASM_OP0(fyl2x, 0xd9f1)
+     DEF_ASM_OP0(fptan, 0xd9f2)
+     DEF_ASM_OP0(fpatan, 0xd9f3)
+     DEF_ASM_OP0(fxtract, 0xd9f4)
+     DEF_ASM_OP0(fprem1, 0xd9f5)
+     DEF_ASM_OP0(fdecstp, 0xd9f6)
+     DEF_ASM_OP0(fincstp, 0xd9f7)
+     DEF_ASM_OP0(fprem, 0xd9f8)
+     DEF_ASM_OP0(fyl2xp1, 0xd9f9)
+     DEF_ASM_OP0(fsqrt, 0xd9fa)
+     DEF_ASM_OP0(fsincos, 0xd9fb)
+     DEF_ASM_OP0(frndint, 0xd9fc)
+     DEF_ASM_OP0(fscale, 0xd9fd)
+     DEF_ASM_OP0(fsin, 0xd9fe)
+     DEF_ASM_OP0(fcos, 0xd9ff)
+     DEF_ASM_OP0(fchs, 0xd9e0)
+     DEF_ASM_OP0(fabs, 0xd9e1)
+     DEF_ASM_OP0(fninit, 0xdbe3)
+     DEF_ASM_OP0(fnclex, 0xdbe2)
+     DEF_ASM_OP0(fnop, 0xd9d0)
+     DEF_ASM_OP0(fwait, 0x9b)
+
+    /* fp load */
+    DEF_ASM_OP1(fld, 0xd9c0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fldl, 0xd9c0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(flds, 0xd9, 0, OPC_MODRM, OPT_EA)
+ALT(DEF_ASM_OP1(fldl, 0xdd, 0, OPC_MODRM, OPT_EA))
+    DEF_ASM_OP1(fildl, 0xdb, 0, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fildq, 0xdf, 5, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fildll, 0xdf, 5, OPC_MODRM,OPT_EA)
+    DEF_ASM_OP1(fldt, 0xdb, 5, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fbld, 0xdf, 4, OPC_MODRM, OPT_EA)
+
+    /* fp store */
+    DEF_ASM_OP1(fst, 0xddd0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fstl, 0xddd0, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fsts, 0xd9, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fstps, 0xd9, 3, OPC_MODRM, OPT_EA)
+ALT(DEF_ASM_OP1(fstl, 0xdd, 2, OPC_MODRM, OPT_EA))
+    DEF_ASM_OP1(fstpl, 0xdd, 3, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fist, 0xdf, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistp, 0xdf, 3, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistl, 0xdb, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistpl, 0xdb, 3, OPC_MODRM, OPT_EA)
+
+    DEF_ASM_OP1(fstp, 0xddd8, 0, OPC_REG, OPT_ST)
+    DEF_ASM_OP1(fistpq, 0xdf, 7, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fistpll, 0xdf, 7, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fstpt, 0xdb, 7, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(fbstp, 0xdf, 6, OPC_MODRM, OPT_EA)
+
+    /* exchange */
+    DEF_ASM_OP0(fxch, 0xd9c9)
+ALT(DEF_ASM_OP1(fxch, 0xd9c8, 0, OPC_REG, OPT_ST))
+
+    /* misc FPU */
+    DEF_ASM_OP1(fucom, 0xdde0, 0, OPC_REG, OPT_ST )
+    DEF_ASM_OP1(fucomp, 0xdde8, 0, OPC_REG, OPT_ST )
+
+    DEF_ASM_OP0L(finit, 0xdbe3, 0, OPC_FWAIT)
+    DEF_ASM_OP1(fldcw, 0xd9, 5, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fnstcw, 0xd9, 7, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fstcw, 0xd9, 7, OPC_MODRM | OPC_FWAIT, OPT_EA )
+    DEF_ASM_OP0(fnstsw, 0xdfe0)
+ALT(DEF_ASM_OP1(fnstsw, 0xdfe0, 0, 0, OPT_EAX ))
+ALT(DEF_ASM_OP1(fnstsw, 0xdd, 7, OPC_MODRM, OPT_EA ))
+    DEF_ASM_OP1(fstsw, 0xdfe0, 0, OPC_FWAIT, OPT_EAX )
+ALT(DEF_ASM_OP0L(fstsw, 0xdfe0, 0, OPC_FWAIT))
+ALT(DEF_ASM_OP1(fstsw, 0xdd, 7, OPC_MODRM | OPC_FWAIT, OPT_EA ))
+    DEF_ASM_OP0L(fclex, 0xdbe2, 0, OPC_FWAIT)
+    DEF_ASM_OP1(fnstenv, 0xd9, 6, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fstenv, 0xd9, 6, OPC_MODRM | OPC_FWAIT, OPT_EA )
+    DEF_ASM_OP1(fldenv, 0xd9, 4, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fnsave, 0xdd, 6, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fsave, 0xdd, 6, OPC_MODRM | OPC_FWAIT, OPT_EA )
+    DEF_ASM_OP1(frstor, 0xdd, 4, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(ffree, 0xddc0, 4, OPC_REG, OPT_ST )
+    DEF_ASM_OP1(ffreep, 0xdfc0, 4, OPC_REG, OPT_ST )
+    DEF_ASM_OP1(fxsave, 0x0fae, 0, OPC_MODRM, OPT_EA )
+    DEF_ASM_OP1(fxrstor, 0x0fae, 1, OPC_MODRM, OPT_EA )
+
+    /* segments */
+    DEF_ASM_OP2(arpl, 0x63, 0, OPC_MODRM, OPT_REG16, OPT_REG16 | OPT_EA)
+    DEF_ASM_OP2(lar, 0x0f02, 0, OPC_MODRM, OPT_REG32 | OPT_EA, OPT_REG32)
+    DEF_ASM_OP1(lgdt, 0x0f01, 2, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(lidt, 0x0f01, 3, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(lldt, 0x0f00, 2, OPC_MODRM, OPT_EA | OPT_REG)
+    DEF_ASM_OP1(lmsw, 0x0f01, 6, OPC_MODRM, OPT_EA | OPT_REG)
+ALT(DEF_ASM_OP2(lslw, 0x0f03, 0, OPC_MODRM | OPC_WL, OPT_EA | OPT_REG, OPT_REG))
+    DEF_ASM_OP1(ltr, 0x0f00, 3, OPC_MODRM, OPT_EA | OPT_REG)
+    DEF_ASM_OP1(sgdt, 0x0f01, 0, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(sidt, 0x0f01, 1, OPC_MODRM, OPT_EA)
+    DEF_ASM_OP1(sldt, 0x0f00, 0, OPC_MODRM, OPT_REG | OPT_EA)
+    DEF_ASM_OP1(smsw, 0x0f01, 4, OPC_MODRM, OPT_REG | OPT_EA)
+    DEF_ASM_OP1(str, 0x0f00, 1, OPC_MODRM, OPT_REG16| OPT_EA)
+    DEF_ASM_OP1(verr, 0x0f00, 4, OPC_MODRM, OPT_REG | OPT_EA)
+    DEF_ASM_OP1(verw, 0x0f00, 5, OPC_MODRM, OPT_REG | OPT_EA)
+
+    /* 486 */
+    DEF_ASM_OP1(bswap, 0x0fc8, 0, OPC_REG, OPT_REG32 )
+ALT(DEF_ASM_OP2(xaddb, 0x0fc0, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_REG | OPT_EA ))
+ALT(DEF_ASM_OP2(cmpxchgb, 0x0fb0, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_REG | OPT_EA ))
+    DEF_ASM_OP1(invlpg, 0x0f01, 7, OPC_MODRM, OPT_EA )
+
+    DEF_ASM_OP2(boundl, 0x62, 0, OPC_MODRM, OPT_REG32, OPT_EA)
+    DEF_ASM_OP2(boundw, 0x62, 0, OPC_MODRM | OPC_D16, OPT_REG16, OPT_EA)
+
+    /* pentium */
+    DEF_ASM_OP1(cmpxchg8b, 0x0fc7, 1, OPC_MODRM, OPT_EA )
+
+    /* pentium pro */
+ALT(DEF_ASM_OP2(cmovo, 0x0f40, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovno, 0x0f41, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovc, 0x0f42, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovnc, 0x0f43, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovz, 0x0f44, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovnz, 0x0f45, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmovna, 0x0f46, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+ALT(DEF_ASM_OP2(cmova, 0x0f47, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
+
+    DEF_ASM_OP2(fcmovb, 0xdac0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmove, 0xdac8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovbe, 0xdad0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovu, 0xdad8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovnb, 0xdbc0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovne, 0xdbc8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovnbe, 0xdbd0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcmovnu, 0xdbd8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+
+    DEF_ASM_OP2(fucomi, 0xdbe8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcomi, 0xdbf0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fucomip, 0xdfe8, 0, OPC_REG, OPT_ST, OPT_ST0 )
+    DEF_ASM_OP2(fcomip, 0xdff0, 0, OPC_REG, OPT_ST, OPT_ST0 )
+
+    /* mmx */
+    DEF_ASM_OP0(emms, 0x0f77) /* must be last OP0 */
+    DEF_ASM_OP2(movd, 0x0f6e, 0, OPC_MODRM, OPT_EA | OPT_REG32, OPT_MMX )
+ALT(DEF_ASM_OP2(movd, 0x0f7e, 0, OPC_MODRM, OPT_MMX, OPT_EA | OPT_REG32 ))
+ALT(DEF_ASM_OP2(movq, 0x0f6f, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX ))
+ALT(DEF_ASM_OP2(movq, 0x0f7f, 0, OPC_MODRM, OPT_MMX, OPT_EA | OPT_MMX ))
+    DEF_ASM_OP2(packssdw, 0x0f6b, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(packsswb, 0x0f63, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(packuswb, 0x0f67, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddb, 0x0ffc, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddw, 0x0ffd, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddd, 0x0ffe, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddsb, 0x0fec, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddsw, 0x0fed, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddusb, 0x0fdc, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(paddusw, 0x0fdd, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pand, 0x0fdb, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pandn, 0x0fdf, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpeqb, 0x0f74, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpeqw, 0x0f75, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpeqd, 0x0f76, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpgtb, 0x0f64, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpgtw, 0x0f65, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pcmpgtd, 0x0f66, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pmaddwd, 0x0ff5, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pmulhw, 0x0fe5, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pmullw, 0x0fd5, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(por, 0x0feb, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psllw, 0x0ff1, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psllw, 0x0f71, 6, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(pslld, 0x0ff2, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(pslld, 0x0f72, 6, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psllq, 0x0ff3, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psllq, 0x0f73, 6, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psraw, 0x0fe1, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psraw, 0x0f71, 4, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrad, 0x0fe2, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrad, 0x0f72, 4, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrlw, 0x0fd1, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrlw, 0x0f71, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrld, 0x0fd2, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrld, 0x0f72, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psrlq, 0x0fd3, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+ALT(DEF_ASM_OP2(psrlq, 0x0f73, 2, OPC_MODRM, OPT_IM8, OPT_MMX ))
+    DEF_ASM_OP2(psubb, 0x0ff8, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubw, 0x0ff9, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubd, 0x0ffa, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubsb, 0x0fe8, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubsw, 0x0fe9, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubusb, 0x0fd8, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(psubusw, 0x0fd9, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckhbw, 0x0f68, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckhwd, 0x0f69, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckhdq, 0x0f6a, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpcklbw, 0x0f60, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpcklwd, 0x0f61, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(punpckldq, 0x0f62, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+    DEF_ASM_OP2(pxor, 0x0fef, 0, OPC_MODRM, OPT_EA | OPT_MMX, OPT_MMX )
+
+#undef ALT
+#undef DEF_ASM_OP0
+#undef DEF_ASM_OP0L
+#undef DEF_ASM_OP1
+#undef DEF_ASM_OP2
+#undef DEF_ASM_OP3
Index: /EcnlProtoTool/trunk/tcc-0.9.26/x86_64-gen.c
===================================================================
--- /EcnlProtoTool/trunk/tcc-0.9.26/x86_64-gen.c	(revision 279)
+++ /EcnlProtoTool/trunk/tcc-0.9.26/x86_64-gen.c	(revision 279)
@@ -0,0 +1,1701 @@
+/*
+ *  x86-64 code generator for TCC
+ *
+ *  Copyright (c) 2008 Shinichiro Hamaji
+ *
+ *  Based on i386-gen.c by Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef TARGET_DEFS_ONLY
+
+/* number of available registers */
+#define NB_REGS         5
+#define NB_ASM_REGS     8
+
+/* a register can belong to several classes. The classes must be
+   sorted from more general to more precise (see gv2() code which does
+   assumptions on it). */
+#define RC_INT     0x0001 /* generic integer register */
+#define RC_FLOAT   0x0002 /* generic float register */
+#define RC_RAX     0x0004
+#define RC_RCX     0x0008
+#define RC_RDX     0x0010
+#define RC_R8      0x0100
+#define RC_R9      0x0200
+#define RC_R10     0x0400
+#define RC_R11     0x0800
+#define RC_XMM0    0x0020
+#define RC_ST0     0x0040 /* only for long double */
+#define RC_IRET    RC_RAX /* function return: integer register */
+#define RC_LRET    RC_RDX /* function return: second integer register */
+#define RC_FRET    RC_XMM0 /* function return: float register */
+
+/* pretty names for the registers */
+enum {
+    TREG_RAX = 0,
+    TREG_RCX = 1,
+    TREG_RDX = 2,
+    TREG_XMM0 = 3,
+    TREG_ST0 = 4,
+
+    TREG_RSI = 6,
+    TREG_RDI = 7,
+    TREG_R8  = 8,
+    TREG_R9  = 9,
+
+    TREG_R10 = 10,
+    TREG_R11 = 11,
+
+    TREG_MEM = 0x10,
+};
+
+#define REX_BASE(reg) (((reg) >> 3) & 1)
+#define REG_VALUE(reg) ((reg) & 7)
+
+/* return registers for function */
+#define REG_IRET TREG_RAX /* single word int return register */
+#define REG_LRET TREG_RDX /* second word return register (for long long) */
+#define REG_FRET TREG_XMM0 /* float return register */
+
+/* defined if function parameters must be evaluated in reverse order */
+#define INVERT_FUNC_PARAMS
+
+/* pointer size, in bytes */
+#define PTR_SIZE 8
+
+/* long double size and alignment, in bytes */
+#define LDOUBLE_SIZE  16
+#define LDOUBLE_ALIGN 8
+/* maximum alignment (for aligned attribute support) */
+#define MAX_ALIGN     8
+
+/******************************************************/
+/* ELF defines */
+
+#define EM_TCC_TARGET EM_X86_64
+
+/* relocation type for 32 bit data relocation */
+#define R_DATA_32   R_X86_64_32
+#define R_DATA_PTR  R_X86_64_64
+#define R_JMP_SLOT  R_X86_64_JUMP_SLOT
+#define R_COPY      R_X86_64_COPY
+
+#define ELF_START_ADDR 0x08048000
+#define ELF_PAGE_SIZE  0x1000
+
+/******************************************************/
+#else /* ! TARGET_DEFS_ONLY */
+/******************************************************/
+#include "tcc.h"
+#include <assert.h>
+
+ST_DATA const int reg_classes[NB_REGS+7] = {
+    /* eax */ RC_INT | RC_RAX,
+    /* ecx */ RC_INT | RC_RCX,
+    /* edx */ RC_INT | RC_RDX,
+    /* xmm0 */ RC_FLOAT | RC_XMM0,
+    /* st0 */ RC_ST0,
+    0,
+    0,
+    0,
+    RC_INT | RC_R8,
+    RC_INT | RC_R9,
+    RC_INT | RC_R10,
+    RC_INT | RC_R11
+};
+
+static unsigned long func_sub_sp_offset;
+static int func_ret_sub;
+
+/* XXX: make it faster ? */
+void g(int c)
+{
+    int ind1;
+    ind1 = ind + 1;
+    if (ind1 > cur_text_section->data_allocated)
+        section_realloc(cur_text_section, ind1);
+    cur_text_section->data[ind] = c;
+    ind = ind1;
+}
+
+void o(unsigned int c)
+{
+    while (c) {
+        g(c);
+        c = c >> 8;
+    }
+}
+
+void gen_le16(int v)
+{
+    g(v);
+    g(v >> 8);
+}
+
+void gen_le32(int c)
+{
+    g(c);
+    g(c >> 8);
+    g(c >> 16);
+    g(c >> 24);
+}
+
+void gen_le64(int64_t c)
+{
+    g(c);
+    g(c >> 8);
+    g(c >> 16);
+    g(c >> 24);
+    g(c >> 32);
+    g(c >> 40);
+    g(c >> 48);
+    g(c >> 56);
+}
+
+void orex(int ll, int r, int r2, int b)
+{
+    if ((r & VT_VALMASK) >= VT_CONST)
+        r = 0;
+    if ((r2 & VT_VALMASK) >= VT_CONST)
+        r2 = 0;
+    if (ll || REX_BASE(r) || REX_BASE(r2))
+        o(0x40 | REX_BASE(r) | (REX_BASE(r2) << 2) | (ll << 3));
+    o(b);
+}
+
+/* output a symbol and patch all calls to it */
+void gsym_addr(int t, int a)
+{
+    int n, *ptr;
+    while (t) {
+        ptr = (int *)(cur_text_section->data + t);
+        n = *ptr; /* next value */
+        *ptr = a - t - 4;
+        t = n;
+    }
+}
+
+void gsym(int t)
+{
+    gsym_addr(t, ind);
+}
+
+/* psym is used to put an instruction with a data field which is a
+   reference to a symbol. It is in fact the same as oad ! */
+#define psym oad
+
+static int is64_type(int t)
+{
+    return ((t & VT_BTYPE) == VT_PTR ||
+            (t & VT_BTYPE) == VT_FUNC ||
+            (t & VT_BTYPE) == VT_LLONG);
+}
+
+static int is_sse_float(int t) {
+    int bt;
+    bt = t & VT_BTYPE;
+    return bt == VT_DOUBLE || bt == VT_FLOAT;
+}
+
+
+/* instruction + 4 bytes data. Return the address of the data */
+ST_FUNC int oad(int c, int s)
+{
+    int ind1;
+
+    o(c);
+    ind1 = ind + 4;
+    if (ind1 > cur_text_section->data_allocated)
+        section_realloc(cur_text_section, ind1);
+    *(int *)(cur_text_section->data + ind) = s;
+    s = ind;
+    ind = ind1;
+    return s;
+}
+
+ST_FUNC void gen_addr32(int r, Sym *sym, int c)
+{
+    if (r & VT_SYM)
+        greloc(cur_text_section, sym, ind, R_X86_64_32);
+    gen_le32(c);
+}
+
+/* output constant with relocation if 'r & VT_SYM' is true */
+ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c)
+{
+    if (r & VT_SYM)
+        greloc(cur_text_section, sym, ind, R_X86_64_64);
+    gen_le64(c);
+}
+
+/* output constant with relocation if 'r & VT_SYM' is true */
+ST_FUNC void gen_addrpc32(int r, Sym *sym, int c)
+{
+    if (r & VT_SYM)
+        greloc(cur_text_section, sym, ind, R_X86_64_PC32);
+    gen_le32(c-4);
+}
+
+/* output got address with relocation */
+static void gen_gotpcrel(int r, Sym *sym, int c)
+{
+#ifndef TCC_TARGET_PE
+    Section *sr;
+    ElfW(Rela) *rel;
+    greloc(cur_text_section, sym, ind, R_X86_64_GOTPCREL);
+    sr = cur_text_section->reloc;
+    rel = (ElfW(Rela) *)(sr->data + sr->data_offset - sizeof(ElfW(Rela)));
+    rel->r_addend = -4;
+#else
+    printf("picpic: %s %x %x | %02x %02x %02x\n", get_tok_str(sym->v, NULL), c, r,
+        cur_text_section->data[ind-3],
+        cur_text_section->data[ind-2],
+        cur_text_section->data[ind-1]
+        );
+    greloc(cur_text_section, sym, ind, R_X86_64_PC32);
+#endif
+    gen_le32(0);
+    if (c) {
+        /* we use add c, %xxx for displacement */
+        orex(1, r, 0, 0x81);
+        o(0xc0 + REG_VALUE(r));
+        gen_le32(c);
+    }
+}
+
+static void gen_modrm_impl(int op_reg, int r, Sym *sym, int c, int is_got)
+{
+    op_reg = REG_VALUE(op_reg) << 3;
+    if ((r & VT_VALMASK) == VT_CONST) {
+        /* constant memory reference */
+        o(0x05 | op_reg);
+        if (is_got) {
+            gen_gotpcrel(r, sym, c);
+        } else {
+            gen_addrpc32(r, sym, c);
+        }
+    } else if ((r & VT_VALMASK) == VT_LOCAL) {
+        /* currently, we use only ebp as base */
+        if (c == (char)c) {
+            /* short reference */
+            o(0x45 | op_reg);
+            g(c);
+        } else {
+            oad(0x85 | op_reg, c);
+        }
+    } else if ((r & VT_VALMASK) >= TREG_MEM) {
+        if (c) {
+            g(0x80 | op_reg | REG_VALUE(r));
+            gen_le32(c);
+        } else {
+            g(0x00 | op_reg | REG_VALUE(r));
+        }
+    } else {
+        g(0x00 | op_reg | REG_VALUE(r));
+    }
+}
+
+/* generate a modrm reference. 'op_reg' contains the addtionnal 3
+   opcode bits */
+static void gen_modrm(int op_reg, int r, Sym *sym, int c)
+{
+    gen_modrm_impl(op_reg, r, sym, c, 0);
+}
+
+/* generate a modrm reference. 'op_reg' contains the addtionnal 3
+   opcode bits */
+static void gen_modrm64(int opcode, int op_reg, int r, Sym *sym, int c)
+{
+    int is_got;
+    is_got = (op_reg & TREG_MEM) && !(sym->type.t & VT_STATIC);
+    orex(1, r, op_reg, opcode);
+    gen_modrm_impl(op_reg, r, sym, c, is_got);
+}
+
+
+/* load 'r' from value 'sv' */
+void load(int r, SValue *sv)
+{
+    int v, t, ft, fc, fr;
+    SValue v1;
+
+#ifdef TCC_TARGET_PE
+    SValue v2;
+    sv = pe_getimport(sv, &v2);
+#endif
+
+    fr = sv->r;
+    ft = sv->type.t;
+    fc = sv->c.ul;
+
+#ifndef TCC_TARGET_PE
+    /* we use indirect access via got */
+    if ((fr & VT_VALMASK) == VT_CONST && (fr & VT_SYM) &&
+        (fr & VT_LVAL) && !(sv->sym->type.t & VT_STATIC)) {
+        /* use the result register as a temporal register */
+        int tr = r | TREG_MEM;
+        if (is_float(ft)) {
+            /* we cannot use float registers as a temporal register */
+            tr = get_reg(RC_INT) | TREG_MEM;
+        }
+        gen_modrm64(0x8b, tr, fr, sv->sym, 0);
+
+        /* load from the temporal register */
+        fr = tr | VT_LVAL;
+    }
+#endif
+
+    v = fr & VT_VALMASK;
+    if (fr & VT_LVAL) {
+        int b, ll;
+        if (v == VT_LLOCAL) {
+            v1.type.t = VT_PTR;
+            v1.r = VT_LOCAL | VT_LVAL;
+            v1.c.ul = fc;
+            fr = r;
+            if (!(reg_classes[fr] & RC_INT))
+                fr = get_reg(RC_INT);
+            load(fr, &v1);
+        }
+        ll = 0;
+        if ((ft & VT_BTYPE) == VT_FLOAT) {
+            b = 0x6e0f66, r = 0; /* movd */
+        } else if ((ft & VT_BTYPE) == VT_DOUBLE) {
+            b = 0x7e0ff3, r = 0; /* movq */
+        } else if ((ft & VT_BTYPE) == VT_LDOUBLE) {
+            b = 0xdb, r = 5; /* fldt */
+        } else if ((ft & VT_TYPE) == VT_BYTE) {
+            b = 0xbe0f;   /* movsbl */
+        } else if ((ft & VT_TYPE) == (VT_BYTE | VT_UNSIGNED)) {
+            b = 0xb60f;   /* movzbl */
+        } else if ((ft & VT_TYPE) == VT_SHORT) {
+            b = 0xbf0f;   /* movswl */
+        } else if ((ft & VT_TYPE) == (VT_SHORT | VT_UNSIGNED)) {
+            b = 0xb70f;   /* movzwl */
+        } else {
+            ll = is64_type(ft);
+            b = 0x8b;
+        }
+        if (ll) {
+            gen_modrm64(b, r, fr, sv->sym, fc);
+        } else {
+            orex(ll, fr, r, b);
+            gen_modrm(r, fr, sv->sym, fc);
+        }
+    } else {
+        if (v == VT_CONST) {
+            if (fr & VT_SYM) {
+#ifdef TCC_TARGET_PE
+                orex(1,0,r,0x8d);
+                o(0x05 + REG_VALUE(r) * 8); /* lea xx(%rip), r */
+                gen_addrpc32(fr, sv->sym, fc);
+#else
+                if (sv->sym->type.t & VT_STATIC) {
+                    orex(1,0,r,0x8d);
+                    o(0x05 + REG_VALUE(r) * 8); /* lea xx(%rip), r */
+                    gen_addrpc32(fr, sv->sym, fc);
+                } else {
+                    orex(1,0,r,0x8b);
+                    o(0x05 + REG_VALUE(r) * 8); /* mov xx(%rip), r */
+                    gen_gotpcrel(r, sv->sym, fc);
+                }
+#endif
+            } else if (is64_type(ft)) {
+                orex(1,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */
+                gen_le64(sv->c.ull);
+            } else {
+                orex(0,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */
+                gen_le32(fc);
+            }
+        } else if (v == VT_LOCAL) {
+            orex(1,0,r,0x8d); /* lea xxx(%ebp), r */
+            gen_modrm(r, VT_LOCAL, sv->sym, fc);
+        } else if (v == VT_CMP) {
+            orex(0,r,0,0);
+	    if ((fc & ~0x100) != TOK_NE)
+              oad(0xb8 + REG_VALUE(r), 0); /* mov $0, r */
+	    else
+              oad(0xb8 + REG_VALUE(r), 1); /* mov $1, r */
+	    if (fc & 0x100)
+	      {
+	        /* This was a float compare.  If the parity bit is
+		   set the result was unordered, meaning false for everything
+		   except TOK_NE, and true for TOK_NE.  */
+		fc &= ~0x100;
+		o(0x037a + (REX_BASE(r) << 8));
+	      }
+            orex(0,r,0, 0x0f); /* setxx %br */
+            o(fc);
+            o(0xc0 + REG_VALUE(r));
+        } else if (v == VT_JMP || v == VT_JMPI) {
+            t = v & 1;
+            orex(0,r,0,0);
+            oad(0xb8 + REG_VALUE(r), t); /* mov $1, r */
+            o(0x05eb + (REX_BASE(r) << 8)); /* jmp after */
+            gsym(fc);
+            orex(0,r,0,0);
+            oad(0xb8 + REG_VALUE(r), t ^ 1); /* mov $0, r */
+        } else if (v != r) {
+            if (r == TREG_XMM0) {
+                assert(v == TREG_ST0);
+                /* gen_cvt_ftof(VT_DOUBLE); */
+                o(0xf0245cdd); /* fstpl -0x10(%rsp) */
+                /* movsd -0x10(%rsp),%xmm0 */
+                o(0x44100ff2);
+                o(0xf024);
+            } else if (r == TREG_ST0) {
+                assert(v == TREG_XMM0);
+                /* gen_cvt_ftof(VT_LDOUBLE); */
+                /* movsd %xmm0,-0x10(%rsp) */
+                o(0x44110ff2);
+                o(0xf024);
+                o(0xf02444dd); /* fldl -0x10(%rsp) */
+            } else {
+                orex(1,r,v, 0x89);
+                o(0xc0 + REG_VALUE(r) + REG_VALUE(v) * 8); /* mov v, r */
+            }
+        }
+    }
+}
+
+/* store register 'r' in lvalue 'v' */
+void store(int r, SValue *v)
+{
+    int fr, bt, ft, fc;
+    int op64 = 0;
+    /* store the REX prefix in this variable when PIC is enabled */
+    int pic = 0;
+
+#ifdef TCC_TARGET_PE
+    SValue v2;
+    v = pe_getimport(v, &v2);
+#endif
+
+    ft = v->type.t;
+    fc = v->c.ul;
+    fr = v->r & VT_VALMASK;
+    bt = ft & VT_BTYPE;
+
+#ifndef TCC_TARGET_PE
+    /* we need to access the variable via got */
+    if (fr == VT_CONST && (v->r & VT_SYM)) {
+        /* mov xx(%rip), %r11 */
+        o(0x1d8b4c);
+        gen_gotpcrel(TREG_R11, v->sym, v->c.ul);
+        pic = is64_type(bt) ? 0x49 : 0x41;
+    }
+#endif
+
+    /* XXX: incorrect if float reg to reg */
+    if (bt == VT_FLOAT) {
+        o(0x66);
+        o(pic);
+        o(0x7e0f); /* movd */
+        r = 0;
+    } else if (bt == VT_DOUBLE) {
+        o(0x66);
+        o(pic);
+        o(0xd60f); /* movq */
+        r = 0;
+    } else if (bt == VT_LDOUBLE) {
+        o(0xc0d9); /* fld %st(0) */
+        o(pic);
+        o(0xdb); /* fstpt */
+        r = 7;
+    } else {
+        if (bt == VT_SHORT)
+            o(0x66);
+        o(pic);
+        if (bt == VT_BYTE || bt == VT_BOOL)
+            orex(0, 0, r, 0x88);
+        else if (is64_type(bt))
+            op64 = 0x89;
+        else
+            orex(0, 0, r, 0x89);
+    }
+    if (pic) {
+        /* xxx r, (%r11) where xxx is mov, movq, fld, or etc */
+        if (op64)
+            o(op64);
+        o(3 + (r << 3));
+    } else if (op64) {
+        if (fr == VT_CONST || fr == VT_LOCAL || (v->r & VT_LVAL)) {
+            gen_modrm64(op64, r, v->r, v->sym, fc);
+        } else if (fr != r) {
+            /* XXX: don't we really come here? */
+            abort();
+            o(0xc0 + fr + r * 8); /* mov r, fr */
+        }
+    } else {
+        if (fr == VT_CONST || fr == VT_LOCAL || (v->r & VT_LVAL)) {
+            gen_modrm(r, v->r, v->sym, fc);
+        } else if (fr != r) {
+            /* XXX: don't we really come here? */
+            abort();
+            o(0xc0 + fr + r * 8); /* mov r, fr */
+        }
+    }
+}
+
+/* 'is_jmp' is '1' if it is a jump */
+static void gcall_or_jmp(int is_jmp)
+{
+    int r;
+    if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+        /* constant case */
+        if (vtop->r & VT_SYM) {
+            /* relocation case */
+            greloc(cur_text_section, vtop->sym,
+                   ind + 1, R_X86_64_PC32);
+        } else {
+            /* put an empty PC32 relocation */
+            put_elf_reloc(symtab_section, cur_text_section,
+                          ind + 1, R_X86_64_PC32, 0);
+        }
+        oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */
+    } else {
+        /* otherwise, indirect call */
+        r = TREG_R11;
+        load(r, vtop);
+        o(0x41); /* REX */
+        o(0xff); /* call/jmp *r */
+        o(0xd0 + REG_VALUE(r) + (is_jmp << 4));
+    }
+}
+
+#ifdef TCC_TARGET_PE
+
+#define REGN 4
+static const uint8_t arg_regs[] = {
+    TREG_RCX, TREG_RDX, TREG_R8, TREG_R9
+};
+
+static int func_scratch;
+
+/* Generate function call. The function address is pushed first, then
+   all the parameters in call order. This functions pops all the
+   parameters and the function address. */
+
+void gen_offs_sp(int b, int r, int d)
+{
+    orex(1,0,r & 0x100 ? 0 : r, b);
+    if (d == (char)d) {
+        o(0x2444 | (REG_VALUE(r) << 3));
+        g(d);
+    } else {
+        o(0x2484 | (REG_VALUE(r) << 3));
+        gen_le32(d);
+    }
+}
+
+void gfunc_call(int nb_args)
+{
+    int size, align, r, args_size, i, d, j, bt, struct_size;
+    int nb_reg_args, gen_reg;
+
+    nb_reg_args = nb_args;
+    args_size = (nb_reg_args < REGN ? REGN : nb_reg_args) * PTR_SIZE;
+
+    /* for struct arguments, we need to call memcpy and the function
+       call breaks register passing arguments we are preparing.
+       So, we process arguments which will be passed by stack first. */
+    struct_size = args_size;
+    for(i = 0; i < nb_args; i++) {
+        SValue *sv = &vtop[-i];
+        bt = (sv->type.t & VT_BTYPE);
+        if (bt == VT_STRUCT) {
+            size = type_size(&sv->type, &align);
+            /* align to stack align size */
+            size = (size + 15) & ~15;
+            /* generate structure store */
+            r = get_reg(RC_INT);
+            gen_offs_sp(0x8d, r, struct_size);
+            struct_size += size;
+
+            /* generate memcpy call */
+            vset(&sv->type, r | VT_LVAL, 0);
+            vpushv(sv);
+            vstore();
+            --vtop;
+
+        } else if (bt == VT_LDOUBLE) {
+
+            gv(RC_ST0);
+            gen_offs_sp(0xdb, 0x107, struct_size);
+            struct_size += 16;
+
+        }
+    }
+
+    if (func_scratch < struct_size)
+        func_scratch = struct_size;
+#if 1
+    for (i = 0; i < REGN; ++i)
+        save_reg(arg_regs[i]);
+    save_reg(TREG_RAX);
+#endif
+    gen_reg = nb_reg_args;
+    struct_size = args_size;
+
+    for(i = 0; i < nb_args; i++) {
+        bt = (vtop->type.t & VT_BTYPE);
+
+        if (bt == VT_STRUCT || bt == VT_LDOUBLE) {
+            if (bt == VT_LDOUBLE)
+                size = 16;
+            else
+                size = type_size(&vtop->type, &align);
+            /* align to stack align size */
+            size = (size + 15) & ~15;
+            j = --gen_reg;
+            if (j >= REGN) {
+                d = TREG_RAX;
+                gen_offs_sp(0x8d, d, struct_size);
+                gen_offs_sp(0x89, d, j*8);
+            } else {
+                d = arg_regs[j];
+                gen_offs_sp(0x8d, d, struct_size);
+            }
+            struct_size += size;
+
+        } else if (is_sse_float(vtop->type.t)) {
+            gv(RC_FLOAT); /* only one float register */
+            j = --gen_reg;
+            if (j >= REGN) {
+                /* movq %xmm0, j*8(%rsp) */
+                gen_offs_sp(0xd60f66, 0x100, j*8);
+            } else {
+                /* movaps %xmm0, %xmmN */
+                o(0x280f);
+                o(0xc0 + (j << 3));
+                d = arg_regs[j];
+                /* mov %xmm0, %rxx */
+                o(0x66);
+                orex(1,d,0, 0x7e0f);
+                o(0xc0 + REG_VALUE(d));
+            }
+        } else {
+            j = --gen_reg;
+            if (j >= REGN) {
+                r = gv(RC_INT);
+                gen_offs_sp(0x89, r, j*8);
+            } else {
+                d = arg_regs[j];
+                if (d < NB_REGS) {
+                    gv(reg_classes[d] & ~RC_INT);
+                } else {
+                    r = gv(RC_INT);
+                    if (d != r) {
+                        orex(1,d,r, 0x89);
+                        o(0xc0 + REG_VALUE(d) + REG_VALUE(r) * 8);
+                    }
+                }
+
+            }
+        }
+        vtop--;
+    }
+    save_regs(0);
+    gcall_or_jmp(0);
+    vtop--;
+}
+
+
+#define FUNC_PROLOG_SIZE 11
+
+/* generate function prolog of type 't' */
+void gfunc_prolog(CType *func_type)
+{
+    int addr, reg_param_index, bt;
+    Sym *sym;
+    CType *type;
+
+    func_ret_sub = 0;
+    func_scratch = 0;
+    loc = 0;
+
+    addr = PTR_SIZE * 2;
+    ind += FUNC_PROLOG_SIZE;
+    func_sub_sp_offset = ind;
+    reg_param_index = 0;
+
+    sym = func_type->ref;
+
+    /* if the function returns a structure, then add an
+       implicit pointer parameter */
+    func_vt = sym->type;
+    if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
+        gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);
+        reg_param_index++;
+        addr += PTR_SIZE;
+    }
+
+    /* define parameters */
+    while ((sym = sym->next) != NULL) {
+        type = &sym->type;
+        bt = type->t & VT_BTYPE;
+        if (reg_param_index < REGN) {
+            /* save arguments passed by register */
+            gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);
+        }
+        if (bt == VT_STRUCT || bt == VT_LDOUBLE) {
+            sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | VT_LVAL | VT_REF, addr);
+        } else {
+            sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | VT_LVAL, addr);
+        }
+        reg_param_index++;
+        addr += PTR_SIZE;
+    }
+
+    while (reg_param_index < REGN) {
+        if (func_type->ref->c == FUNC_ELLIPSIS)
+            gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);
+        reg_param_index++;
+        addr += PTR_SIZE;
+    }
+}
+
+/* generate function epilog */
+void gfunc_epilog(void)
+{
+    int v, saved_ind;
+
+    o(0xc9); /* leave */
+    if (func_ret_sub == 0) {
+        o(0xc3); /* ret */
+    } else {
+        o(0xc2); /* ret n */
+        g(func_ret_sub);
+        g(func_ret_sub >> 8);
+    }
+
+    saved_ind = ind;
+    ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
+    /* align local size to word & save local variables */
+    v = (func_scratch + -loc + 15) & -16;
+
+    if (v >= 4096) {
+        Sym *sym = external_global_sym(TOK___chkstk, &func_old_type, 0);
+        oad(0xb8, v); /* mov stacksize, %eax */
+        oad(0xe8, -4); /* call __chkstk, (does the stackframe too) */
+        greloc(cur_text_section, sym, ind-4, R_X86_64_PC32);
+        o(0x90); /* fill for FUNC_PROLOG_SIZE = 11 bytes */
+    } else {
+        o(0xe5894855);  /* push %rbp, mov %rsp, %rbp */
+        o(0xec8148);  /* sub rsp, stacksize */
+        gen_le32(v);
+    }
+
+    cur_text_section->data_offset = saved_ind;
+    pe_add_unwind_data(ind, saved_ind, v);
+    ind = cur_text_section->data_offset;
+}
+
+#else
+
+static void gadd_sp(int val)
+{
+    if (val == (char)val) {
+        o(0xc48348);
+        g(val);
+    } else {
+        oad(0xc48148, val); /* add $xxx, %rsp */
+    }
+}
+
+#define REGN 6
+static const uint8_t arg_regs[REGN] = {
+    TREG_RDI, TREG_RSI, TREG_RDX, TREG_RCX, TREG_R8, TREG_R9
+};
+
+/* Generate function call. The function address is pushed first, then
+   all the parameters in call order. This functions pops all the
+   parameters and the function address. */
+void gfunc_call(int nb_args)
+{
+    int size, align, r, args_size, i;
+    int nb_reg_args = 0;
+    int nb_sse_args = 0;
+    int sse_reg, gen_reg;
+
+    /* calculate the number of integer/float arguments */
+    args_size = 0;
+    for(i = 0; i < nb_args; i++) {
+        if ((vtop[-i].type.t & VT_BTYPE) == VT_STRUCT) {
+            args_size += type_size(&vtop[-i].type, &align);
+            args_size = (args_size + 7) & ~7;
+        } else if ((vtop[-i].type.t & VT_BTYPE) == VT_LDOUBLE) {
+            args_size += 16;
+        } else if (is_sse_float(vtop[-i].type.t)) {
+            nb_sse_args++;
+            if (nb_sse_args > 8) args_size += 8;
+        } else {
+            nb_reg_args++;
+            if (nb_reg_args > REGN) args_size += 8;
+        }
+    }
+
+    /* for struct arguments, we need to call memcpy and the function
+       call breaks register passing arguments we are preparing.
+       So, we process arguments which will be passed by stack first. */
+    gen_reg = nb_reg_args;
+    sse_reg = nb_sse_args;
+
+    /* adjust stack to align SSE boundary */
+    if (args_size &= 15) {
+        /* fetch cpu flag before the following sub will change the value */
+        if (vtop >= vstack && (vtop->r & VT_VALMASK) == VT_CMP)
+            gv(RC_INT);
+
+        args_size = 16 - args_size;
+        o(0x48);
+        oad(0xec81, args_size); /* sub $xxx, %rsp */
+    }
+
+    for(i = 0; i < nb_args; i++) {
+	/* Swap argument to top, it will possibly be changed here,
+	   and might use more temps.  All arguments must remain on the
+	   stack, so that get_reg can correctly evict some of them onto
+	   stack.  We could use also use a vrott(nb_args) at the end
+	   of this loop, but this seems faster.  */
+        SValue tmp = vtop[0];
+	vtop[0] = vtop[-i];
+	vtop[-i] = tmp;
+        if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
+            size = type_size(&vtop->type, &align);
+            /* align to stack align size */
+            size = (size + 7) & ~7;
+            /* allocate the necessary size on stack */
+            o(0x48);
+            oad(0xec81, size); /* sub $xxx, %rsp */
+            /* generate structure store */
+            r = get_reg(RC_INT);
+            orex(1, r, 0, 0x89); /* mov %rsp, r */
+            o(0xe0 + REG_VALUE(r));
+	    vset(&vtop->type, r | VT_LVAL, 0);
+	    vswap();
+	    vstore();
+            args_size += size;
+        } else if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+            gv(RC_ST0);
+            size = LDOUBLE_SIZE;
+            oad(0xec8148, size); /* sub $xxx, %rsp */
+            o(0x7cdb); /* fstpt 0(%rsp) */
+            g(0x24);
+            g(0x00);
+            args_size += size;
+        } else if (is_sse_float(vtop->type.t)) {
+            int j = --sse_reg;
+            if (j >= 8) {
+                gv(RC_FLOAT);
+                o(0x50); /* push $rax */
+                /* movq %xmm0, (%rsp) */
+                o(0x04d60f66);
+                o(0x24);
+                args_size += 8;
+            }
+        } else {
+            int j = --gen_reg;
+            /* simple type */
+            /* XXX: implicit cast ? */
+            if (j >= REGN) {
+                r = gv(RC_INT);
+                orex(0,r,0,0x50 + REG_VALUE(r)); /* push r */
+                args_size += 8;
+            }
+        }
+
+	/* And swap the argument back to it's original position.  */
+        tmp = vtop[0];
+	vtop[0] = vtop[-i];
+	vtop[-i] = tmp;
+    }
+
+    /* XXX This should be superfluous.  */
+    save_regs(0); /* save used temporary registers */
+
+    /* then, we prepare register passing arguments.
+       Note that we cannot set RDX and RCX in this loop because gv()
+       may break these temporary registers. Let's use R10 and R11
+       instead of them */
+    gen_reg = nb_reg_args;
+    sse_reg = nb_sse_args;
+    for(i = 0; i < nb_args; i++) {
+        if ((vtop->type.t & VT_BTYPE) == VT_STRUCT ||
+            (vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+        } else if (is_sse_float(vtop->type.t)) {
+            int j = --sse_reg;
+            if (j < 8) {
+                gv(RC_FLOAT); /* only one float register */
+                /* movaps %xmm0, %xmmN */
+                o(0x280f);
+                o(0xc0 + (sse_reg << 3));
+            }
+        } else {
+            int j = --gen_reg;
+            /* simple type */
+            /* XXX: implicit cast ? */
+            if (j < REGN) {
+                int d = arg_regs[j];
+                r = gv(RC_INT);
+                if (j == 2 || j == 3)
+                    /* j=2: r10, j=3: r11 */
+                    d = j + 8;
+                orex(1,d,r,0x89); /* mov */
+                o(0xc0 + REG_VALUE(r) * 8 + REG_VALUE(d));
+            }
+        }
+        vtop--;
+    }
+
+    /* We shouldn't have many operands on the stack anymore, but the
+       call address itself is still there, and it might be in %eax
+       (or edx/ecx) currently, which the below writes would clobber.
+       So evict all remaining operands here.  */
+    save_regs(0);
+
+    /* Copy R10 and R11 into RDX and RCX, respectively */
+    if (nb_reg_args > 2) {
+        o(0xd2894c); /* mov %r10, %rdx */
+        if (nb_reg_args > 3) {
+            o(0xd9894c); /* mov %r11, %rcx */
+        }
+    }
+
+    oad(0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */
+    gcall_or_jmp(0);
+    if (args_size)
+        gadd_sp(args_size);
+    vtop--;
+}
+
+
+#define FUNC_PROLOG_SIZE 11
+
+static void push_arg_reg(int i) {
+    loc -= 8;
+    gen_modrm64(0x89, arg_regs[i], VT_LOCAL, NULL, loc);
+}
+
+/* generate function prolog of type 't' */
+void gfunc_prolog(CType *func_type)
+{
+    int i, addr, align, size;
+    int param_index, param_addr, reg_param_index, sse_param_index;
+    Sym *sym;
+    CType *type;
+
+    sym = func_type->ref;
+    addr = PTR_SIZE * 2;
+    loc = 0;
+    ind += FUNC_PROLOG_SIZE;
+    func_sub_sp_offset = ind;
+    func_ret_sub = 0;
+
+    if (func_type->ref->c == FUNC_ELLIPSIS) {
+        int seen_reg_num, seen_sse_num, seen_stack_size;
+        seen_reg_num = seen_sse_num = 0;
+        /* frame pointer and return address */
+        seen_stack_size = PTR_SIZE * 2;
+        /* count the number of seen parameters */
+        sym = func_type->ref;
+        while ((sym = sym->next) != NULL) {
+            type = &sym->type;
+            if (is_sse_float(type->t)) {
+                if (seen_sse_num < 8) {
+                    seen_sse_num++;
+                } else {
+                    seen_stack_size += 8;
+                }
+            } else if ((type->t & VT_BTYPE) == VT_STRUCT) {
+                size = type_size(type, &align);
+                size = (size + 7) & ~7;
+                seen_stack_size += size;
+            } else if ((type->t & VT_BTYPE) == VT_LDOUBLE) {
+                seen_stack_size += LDOUBLE_SIZE;
+            } else {
+                if (seen_reg_num < REGN) {
+                    seen_reg_num++;
+                } else {
+                    seen_stack_size += 8;
+                }
+            }
+        }
+
+        loc -= 16;
+        /* movl $0x????????, -0x10(%rbp) */
+        o(0xf045c7);
+        gen_le32(seen_reg_num * 8);
+        /* movl $0x????????, -0xc(%rbp) */
+        o(0xf445c7);
+        gen_le32(seen_sse_num * 16 + 48);
+        /* movl $0x????????, -0x8(%rbp) */
+        o(0xf845c7);
+        gen_le32(seen_stack_size);
+
+        /* save all register passing arguments */
+        for (i = 0; i < 8; i++) {
+            loc -= 16;
+            o(0xd60f66); /* movq */
+            gen_modrm(7 - i, VT_LOCAL, NULL, loc);
+            /* movq $0, loc+8(%rbp) */
+            o(0x85c748);
+            gen_le32(loc + 8);
+            gen_le32(0);
+        }
+        for (i = 0; i < REGN; i++) {
+            push_arg_reg(REGN-1-i);
+        }
+    }
+
+    sym = func_type->ref;
+    param_index = 0;
+    reg_param_index = 0;
+    sse_param_index = 0;
+
+    /* if the function returns a structure, then add an
+       implicit pointer parameter */
+    func_vt = sym->type;
+    if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
+        push_arg_reg(reg_param_index);
+        param_addr = loc;
+
+        func_vc = loc;
+        param_index++;
+        reg_param_index++;
+    }
+    /* define parameters */
+    while ((sym = sym->next) != NULL) {
+        type = &sym->type;
+        size = type_size(type, &align);
+        size = (size + 7) & ~7;
+        if (is_sse_float(type->t)) {
+            if (sse_param_index < 8) {
+                /* save arguments passed by register */
+                loc -= 8;
+                o(0xd60f66); /* movq */
+                gen_modrm(sse_param_index, VT_LOCAL, NULL, loc);
+                param_addr = loc;
+            } else {
+                param_addr = addr;
+                addr += size;
+            }
+            sse_param_index++;
+
+        } else if ((type->t & VT_BTYPE) == VT_STRUCT ||
+                   (type->t & VT_BTYPE) == VT_LDOUBLE) {
+            param_addr = addr;
+            addr += size;
+        } else {
+            if (reg_param_index < REGN) {
+                /* save arguments passed by register */
+                push_arg_reg(reg_param_index);
+                param_addr = loc;
+            } else {
+                param_addr = addr;
+                addr += 8;
+            }
+            reg_param_index++;
+        }
+        sym_push(sym->v & ~SYM_FIELD, type,
+                 VT_LOCAL | VT_LVAL, param_addr);
+        param_index++;
+    }
+}
+
+/* generate function epilog */
+void gfunc_epilog(void)
+{
+    int v, saved_ind;
+
+    o(0xc9); /* leave */
+    if (func_ret_sub == 0) {
+        o(0xc3); /* ret */
+    } else {
+        o(0xc2); /* ret n */
+        g(func_ret_sub);
+        g(func_ret_sub >> 8);
+    }
+    /* align local size to word & save local variables */
+    v = (-loc + 15) & -16;
+    saved_ind = ind;
+    ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
+    o(0xe5894855);  /* push %rbp, mov %rsp, %rbp */
+    o(0xec8148);  /* sub rsp, stacksize */
+    gen_le32(v);
+    ind = saved_ind;
+}
+
+#endif /* not PE */
+
+/* generate a jump to a label */
+int gjmp(int t)
+{
+    return psym(0xe9, t);
+}
+
+/* generate a jump to a fixed address */
+void gjmp_addr(int a)
+{
+    int r;
+    r = a - ind - 2;
+    if (r == (char)r) {
+        g(0xeb);
+        g(r);
+    } else {
+        oad(0xe9, a - ind - 5);
+    }
+}
+
+/* generate a test. set 'inv' to invert test. Stack entry is popped */
+int gtst(int inv, int t)
+{
+    int v, *p;
+
+    v = vtop->r & VT_VALMASK;
+    if (v == VT_CMP) {
+        /* fast case : can jump directly since flags are set */
+	if (vtop->c.i & 0x100)
+	  {
+	    /* This was a float compare.  If the parity flag is set
+	       the result was unordered.  For anything except != this
+	       means false and we don't jump (anding both conditions).
+	       For != this means true (oring both).
+	       Take care about inverting the test.  We need to jump
+	       to our target if the result was unordered and test wasn't NE,
+	       otherwise if unordered we don't want to jump.  */
+	    vtop->c.i &= ~0x100;
+	    if (!inv == (vtop->c.i != TOK_NE))
+	      o(0x067a);  /* jp +6 */
+	    else
+	      {
+	        g(0x0f);
+		t = psym(0x8a, t); /* jp t */
+	      }
+	  }
+        g(0x0f);
+        t = psym((vtop->c.i - 16) ^ inv, t);
+    } else if (v == VT_JMP || v == VT_JMPI) {
+        /* && or || optimization */
+        if ((v & 1) == inv) {
+            /* insert vtop->c jump list in t */
+            p = &vtop->c.i;
+            while (*p != 0)
+                p = (int *)(cur_text_section->data + *p);
+            *p = t;
+            t = vtop->c.i;
+        } else {
+            t = gjmp(t);
+            gsym(vtop->c.i);
+        }
+    } else {
+        if (is_float(vtop->type.t) ||
+            (vtop->type.t & VT_BTYPE) == VT_LLONG) {
+            vpushi(0);
+            gen_op(TOK_NE);
+        }
+        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
+            /* constant jmp optimization */
+            if ((vtop->c.i != 0) != inv)
+                t = gjmp(t);
+        } else {
+            v = gv(RC_INT);
+            orex(0,v,v,0x85);
+            o(0xc0 + REG_VALUE(v) * 9);
+            g(0x0f);
+            t = psym(0x85 ^ inv, t);
+        }
+    }
+    vtop--;
+    return t;
+}
+
+/* generate an integer binary operation */
+void gen_opi(int op)
+{
+    int r, fr, opc, c;
+    int ll, uu, cc;
+
+    ll = is64_type(vtop[-1].type.t);
+    uu = (vtop[-1].type.t & VT_UNSIGNED) != 0;
+    cc = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
+
+    switch(op) {
+    case '+':
+    case TOK_ADDC1: /* add with carry generation */
+        opc = 0;
+    gen_op8:
+        if (cc && (!ll || (int)vtop->c.ll == vtop->c.ll)) {
+            /* constant case */
+            vswap();
+            r = gv(RC_INT);
+            vswap();
+            c = vtop->c.i;
+            if (c == (char)c) {
+                /* XXX: generate inc and dec for smaller code ? */
+                orex(ll, r, 0, 0x83);
+                o(0xc0 | (opc << 3) | REG_VALUE(r));
+                g(c);
+            } else {
+                orex(ll, r, 0, 0x81);
+                oad(0xc0 | (opc << 3) | REG_VALUE(r), c);
+            }
+        } else {
+            gv2(RC_INT, RC_INT);
+            r = vtop[-1].r;
+            fr = vtop[0].r;
+            orex(ll, r, fr, (opc << 3) | 0x01);
+            o(0xc0 + REG_VALUE(r) + REG_VALUE(fr) * 8);
+        }
+        vtop--;
+        if (op >= TOK_ULT && op <= TOK_GT) {
+            vtop->r = VT_CMP;
+            vtop->c.i = op;
+        }
+        break;
+    case '-':
+    case TOK_SUBC1: /* sub with carry generation */
+        opc = 5;
+        goto gen_op8;
+    case TOK_ADDC2: /* add with carry use */
+        opc = 2;
+        goto gen_op8;
+    case TOK_SUBC2: /* sub with carry use */
+        opc = 3;
+        goto gen_op8;
+    case '&':
+        opc = 4;
+        goto gen_op8;
+    case '^':
+        opc = 6;
+        goto gen_op8;
+    case '|':
+        opc = 1;
+        goto gen_op8;
+    case '*':
+        gv2(RC_INT, RC_INT);
+        r = vtop[-1].r;
+        fr = vtop[0].r;
+        orex(ll, fr, r, 0xaf0f); /* imul fr, r */
+        o(0xc0 + REG_VALUE(fr) + REG_VALUE(r) * 8);
+        vtop--;
+        break;
+    case TOK_SHL:
+        opc = 4;
+        goto gen_shift;
+    case TOK_SHR:
+        opc = 5;
+        goto gen_shift;
+    case TOK_SAR:
+        opc = 7;
+    gen_shift:
+        opc = 0xc0 | (opc << 3);
+        if (cc) {
+            /* constant case */
+            vswap();
+            r = gv(RC_INT);
+            vswap();
+            orex(ll, r, 0, 0xc1); /* shl/shr/sar $xxx, r */
+            o(opc | REG_VALUE(r));
+            g(vtop->c.i & (ll ? 63 : 31));
+        } else {
+            /* we generate the shift in ecx */
+            gv2(RC_INT, RC_RCX);
+            r = vtop[-1].r;
+            orex(ll, r, 0, 0xd3); /* shl/shr/sar %cl, r */
+            o(opc | REG_VALUE(r));
+        }
+        vtop--;
+        break;
+    case TOK_UDIV:
+    case TOK_UMOD:
+        uu = 1;
+        goto divmod;
+    case '/':
+    case '%':
+    case TOK_PDIV:
+        uu = 0;
+    divmod:
+        /* first operand must be in eax */
+        /* XXX: need better constraint for second operand */
+        gv2(RC_RAX, RC_RCX);
+        r = vtop[-1].r;
+        fr = vtop[0].r;
+        vtop--;
+        save_reg(TREG_RDX);
+        orex(ll, 0, 0, uu ? 0xd231 : 0x99); /* xor %edx,%edx : cqto */
+        orex(ll, fr, 0, 0xf7); /* div fr, %eax */
+        o((uu ? 0xf0 : 0xf8) + REG_VALUE(fr));
+        if (op == '%' || op == TOK_UMOD)
+            r = TREG_RDX;
+        else
+            r = TREG_RAX;
+        vtop->r = r;
+        break;
+    default:
+        opc = 7;
+        goto gen_op8;
+    }
+}
+
+void gen_opl(int op)
+{
+    gen_opi(op);
+}
+
+/* generate a floating point operation 'v = t1 op t2' instruction. The
+   two operands are guaranted to have the same floating point type */
+/* XXX: need to use ST1 too */
+void gen_opf(int op)
+{
+    int a, ft, fc, swapped, r;
+    int float_type =
+        (vtop->type.t & VT_BTYPE) == VT_LDOUBLE ? RC_ST0 : RC_FLOAT;
+
+    /* convert constants to memory references */
+    if ((vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
+        vswap();
+        gv(float_type);
+        vswap();
+    }
+    if ((vtop[0].r & (VT_VALMASK | VT_LVAL)) == VT_CONST)
+        gv(float_type);
+
+    /* must put at least one value in the floating point register */
+    if ((vtop[-1].r & VT_LVAL) &&
+        (vtop[0].r & VT_LVAL)) {
+        vswap();
+        gv(float_type);
+        vswap();
+    }
+    swapped = 0;
+    /* swap the stack if needed so that t1 is the register and t2 is
+       the memory reference */
+    if (vtop[-1].r & VT_LVAL) {
+        vswap();
+        swapped = 1;
+    }
+    if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+        if (op >= TOK_ULT && op <= TOK_GT) {
+            /* load on stack second operand */
+            load(TREG_ST0, vtop);
+            save_reg(TREG_RAX); /* eax is used by FP comparison code */
+            if (op == TOK_GE || op == TOK_GT)
+                swapped = !swapped;
+            else if (op == TOK_EQ || op == TOK_NE)
+                swapped = 0;
+            if (swapped)
+                o(0xc9d9); /* fxch %st(1) */
+            o(0xe9da); /* fucompp */
+            o(0xe0df); /* fnstsw %ax */
+            if (op == TOK_EQ) {
+                o(0x45e480); /* and $0x45, %ah */
+                o(0x40fC80); /* cmp $0x40, %ah */
+            } else if (op == TOK_NE) {
+                o(0x45e480); /* and $0x45, %ah */
+                o(0x40f480); /* xor $0x40, %ah */
+                op = TOK_NE;
+            } else if (op == TOK_GE || op == TOK_LE) {
+                o(0x05c4f6); /* test $0x05, %ah */
+                op = TOK_EQ;
+            } else {
+                o(0x45c4f6); /* test $0x45, %ah */
+                op = TOK_EQ;
+            }
+            vtop--;
+            vtop->r = VT_CMP;
+            vtop->c.i = op;
+        } else {
+            /* no memory reference possible for long double operations */
+            load(TREG_ST0, vtop);
+            swapped = !swapped;
+
+            switch(op) {
+            default:
+            case '+':
+                a = 0;
+                break;
+            case '-':
+                a = 4;
+                if (swapped)
+                    a++;
+                break;
+            case '*':
+                a = 1;
+                break;
+            case '/':
+                a = 6;
+                if (swapped)
+                    a++;
+                break;
+            }
+            ft = vtop->type.t;
+            fc = vtop->c.ul;
+            o(0xde); /* fxxxp %st, %st(1) */
+            o(0xc1 + (a << 3));
+            vtop--;
+        }
+    } else {
+        if (op >= TOK_ULT && op <= TOK_GT) {
+            /* if saved lvalue, then we must reload it */
+            r = vtop->r;
+            fc = vtop->c.ul;
+            if ((r & VT_VALMASK) == VT_LLOCAL) {
+                SValue v1;
+                r = get_reg(RC_INT);
+                v1.type.t = VT_PTR;
+                v1.r = VT_LOCAL | VT_LVAL;
+                v1.c.ul = fc;
+                load(r, &v1);
+                fc = 0;
+            }
+
+            if (op == TOK_EQ || op == TOK_NE) {
+                swapped = 0;
+            } else {
+                if (op == TOK_LE || op == TOK_LT)
+                    swapped = !swapped;
+                if (op == TOK_LE || op == TOK_GE) {
+                    op = 0x93; /* setae */
+                } else {
+                    op = 0x97; /* seta */
+                }
+            }
+
+            if (swapped) {
+                o(0x7e0ff3); /* movq */
+                gen_modrm(1, r, vtop->sym, fc);
+
+                if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
+                    o(0x66);
+                }
+                o(0x2e0f); /* ucomisd %xmm0, %xmm1 */
+                o(0xc8);
+            } else {
+                if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
+                    o(0x66);
+                }
+                o(0x2e0f); /* ucomisd */
+                gen_modrm(0, r, vtop->sym, fc);
+            }
+
+            vtop--;
+            vtop->r = VT_CMP;
+            vtop->c.i = op | 0x100;
+        } else {
+            /* no memory reference possible for long double operations */
+            if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
+                load(TREG_XMM0, vtop);
+                swapped = !swapped;
+            }
+            switch(op) {
+            default:
+            case '+':
+                a = 0;
+                break;
+            case '-':
+                a = 4;
+                break;
+            case '*':
+                a = 1;
+                break;
+            case '/':
+                a = 6;
+                break;
+            }
+            ft = vtop->type.t;
+            fc = vtop->c.ul;
+            if ((ft & VT_BTYPE) == VT_LDOUBLE) {
+                o(0xde); /* fxxxp %st, %st(1) */
+                o(0xc1 + (a << 3));
+            } else {
+                /* if saved lvalue, then we must reload it */
+                r = vtop->r;
+                if ((r & VT_VALMASK) == VT_LLOCAL) {
+                    SValue v1;
+                    r = get_reg(RC_INT);
+                    v1.type.t = VT_PTR;
+                    v1.r = VT_LOCAL | VT_LVAL;
+                    v1.c.ul = fc;
+                    load(r, &v1);
+                    fc = 0;
+                }
+                if (swapped) {
+                    /* movq %xmm0,%xmm1 */
+                    o(0x7e0ff3);
+                    o(0xc8);
+                    load(TREG_XMM0, vtop);
+                    /* subsd  %xmm1,%xmm0 (f2 0f 5c c1) */
+                    if ((ft & VT_BTYPE) == VT_DOUBLE) {
+                        o(0xf2);
+                    } else {
+                        o(0xf3);
+                    }
+                    o(0x0f);
+                    o(0x58 + a);
+                    o(0xc1);
+                } else {
+                    if ((ft & VT_BTYPE) == VT_DOUBLE) {
+                        o(0xf2);
+                    } else {
+                        o(0xf3);
+                    }
+                    o(0x0f);
+                    o(0x58 + a);
+                    gen_modrm(0, r, vtop->sym, fc);
+                }
+            }
+            vtop--;
+        }
+    }
+}
+
+/* convert integers to fp 't' type. Must handle 'int', 'unsigned int'
+   and 'long long' cases. */
+void gen_cvt_itof(int t)
+{
+    if ((t & VT_BTYPE) == VT_LDOUBLE) {
+        save_reg(TREG_ST0);
+        gv(RC_INT);
+        if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
+            /* signed long long to float/double/long double (unsigned case
+               is handled generically) */
+            o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
+            o(0x242cdf); /* fildll (%rsp) */
+            o(0x08c48348); /* add $8, %rsp */
+        } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
+                   (VT_INT | VT_UNSIGNED)) {
+            /* unsigned int to float/double/long double */
+            o(0x6a); /* push $0 */
+            g(0x00);
+            o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
+            o(0x242cdf); /* fildll (%rsp) */
+            o(0x10c48348); /* add $16, %rsp */
+        } else {
+            /* int to float/double/long double */
+            o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
+            o(0x2404db); /* fildl (%rsp) */
+            o(0x08c48348); /* add $8, %rsp */
+        }
+        vtop->r = TREG_ST0;
+    } else {
+        save_reg(TREG_XMM0);
+        gv(RC_INT);
+        o(0xf2 + ((t & VT_BTYPE) == VT_FLOAT));
+        if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
+            (VT_INT | VT_UNSIGNED) ||
+            (vtop->type.t & VT_BTYPE) == VT_LLONG) {
+            o(0x48); /* REX */
+        }
+        o(0x2a0f);
+        o(0xc0 + (vtop->r & VT_VALMASK)); /* cvtsi2sd */
+        vtop->r = TREG_XMM0;
+    }
+}
+
+/* convert from one floating point type to another */
+void gen_cvt_ftof(int t)
+{
+    int ft, bt, tbt;
+
+    ft = vtop->type.t;
+    bt = ft & VT_BTYPE;
+    tbt = t & VT_BTYPE;
+
+    if (bt == VT_FLOAT) {
+        gv(RC_FLOAT);
+        if (tbt == VT_DOUBLE) {
+            o(0xc0140f); /* unpcklps */
+            o(0xc05a0f); /* cvtps2pd */
+        } else if (tbt == VT_LDOUBLE) {
+            /* movss %xmm0,-0x10(%rsp) */
+            o(0x44110ff3);
+            o(0xf024);
+            o(0xf02444d9); /* flds -0x10(%rsp) */
+            vtop->r = TREG_ST0;
+        }
+    } else if (bt == VT_DOUBLE) {
+        gv(RC_FLOAT);
+        if (tbt == VT_FLOAT) {
+            o(0xc0140f66); /* unpcklpd */
+            o(0xc05a0f66); /* cvtpd2ps */
+        } else if (tbt == VT_LDOUBLE) {
+            /* movsd %xmm0,-0x10(%rsp) */
+            o(0x44110ff2);
+            o(0xf024);
+            o(0xf02444dd); /* fldl -0x10(%rsp) */
+            vtop->r = TREG_ST0;
+        }
+    } else {
+        gv(RC_ST0);
+        if (tbt == VT_DOUBLE) {
+            o(0xf0245cdd); /* fstpl -0x10(%rsp) */
+            /* movsd -0x10(%rsp),%xmm0 */
+            o(0x44100ff2);
+            o(0xf024);
+            vtop->r = TREG_XMM0;
+        } else if (tbt == VT_FLOAT) {
+            o(0xf0245cd9); /* fstps -0x10(%rsp) */
+            /* movss -0x10(%rsp),%xmm0 */
+            o(0x44100ff3);
+            o(0xf024);
+            vtop->r = TREG_XMM0;
+        }
+    }
+}
+
+/* convert fp to int 't' type */
+void gen_cvt_ftoi(int t)
+{
+    int ft, bt, size, r;
+    ft = vtop->type.t;
+    bt = ft & VT_BTYPE;
+    if (bt == VT_LDOUBLE) {
+        gen_cvt_ftof(VT_DOUBLE);
+        bt = VT_DOUBLE;
+    }
+
+    gv(RC_FLOAT);
+    if (t != VT_INT)
+        size = 8;
+    else
+        size = 4;
+
+    r = get_reg(RC_INT);
+    if (bt == VT_FLOAT) {
+        o(0xf3);
+    } else if (bt == VT_DOUBLE) {
+        o(0xf2);
+    } else {
+        assert(0);
+    }
+    orex(size == 8, r, 0, 0x2c0f); /* cvttss2si or cvttsd2si */
+    o(0xc0 + (REG_VALUE(r) << 3));
+    vtop->r = r;
+}
+
+/* computed goto support */
+void ggoto(void)
+{
+    gcall_or_jmp(1);
+    vtop--;
+}
+
+/* end of x86-64 code generator */
+/*************************************************************/
+#endif /* ! TARGET_DEFS_ONLY */
+/******************************************************/
Index: /EcnlProtoTool/trunk/tools/.project
===================================================================
--- /EcnlProtoTool/trunk/tools/.project	(revision 279)
+++ /EcnlProtoTool/trunk/tools/.project	(revision 279)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>tools</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
