diff --git "a/train/github-29-87204935.jsonl" "b/train/github-29-87204935.jsonl"
new file mode 100644--- /dev/null
+++ "b/train/github-29-87204935.jsonl"
@@ -0,0 +1,725 @@
+{"text": "# List of the ChibiOS/RT Cortex-M0 LPC43xx port files.\r\nPORTSRC = $(CHIBIOS)/os/ports/GCC/ARMCMx/crt0.c \\\r\n $(CHIBIOS_PORTAPACK)/os/ports/GCC/ARMCMx/LPC43xx_M0/vectors.c \\\r\n ${CHIBIOS}/os/ports/GCC/ARMCMx/chcore.c \\\r\n ${CHIBIOS}/os/ports/GCC/ARMCMx/chcore_v6m.c \\\r\n ${CHIBIOS}/os/ports/common/ARMCMx/nvic.c\r\n\r\nPORTASM =\r\n\r\nPORTINC = ${CHIBIOS}/os/ports/common/ARMCMx/CMSIS/include \\\r\n ${CHIBIOS}/os/ports/common/ARMCMx \\\r\n ${CHIBIOS}/os/ports/GCC/ARMCMx \\\r\n ${CHIBIOS_PORTAPACK}/os/ports/GCC/ARMCMx/LPC43xx_M0\r\n\r\nPORTLD = ${CHIBIOS_PORTAPACK}/os/ports/GCC/ARMCMx/LPC43xx_M0/ld\r\n"}
+{"text": "/**\n * Copyright (c) 2005-2013 by Appcelerator, Inc. All Rights Reserved.\n * Licensed under the terms of the Eclipse Public License (EPL).\n * Please see the license.txt included with this distribution for details.\n * Any modifications to this file must keep this entire header intact.\n */\npackage org.python.pydev.parser.fastparser;\n\nimport junit.framework.TestCase;\n\nimport org.eclipse.jface.text.Document;\nimport org.eclipse.jface.text.Region;\nimport org.python.pydev.shared_core.parsing.Scopes;\n\n/**\n * @author fabioz\n *\n */\npublic class ScopesParserTest extends TestCase {\n\n public static void main(String[] args) {\n try {\n ScopesParserTest test = new ScopesParserTest();\n test.setUp();\n test.testScopes4();\n test.tearDown();\n junit.textui.TestRunner.run(ScopesParserTest.class);\n\n } catch (Throwable e) {\n e.printStackTrace();\n }\n }\n\n public void testScopes() throws Exception {\n Document doc = new Document(\"\" +\n \"#comment\\n\" +\n \"class Foo(object):\\n\" +\n \" def method(self, a=(10,20)):\\n\"\n +\n \" '''\\n\" +\n \" multi string\\n\" +\n \" '''\\n\");\n Scopes scopes = new ScopesParser().createScopes(doc);\n assertEquals(\"\" +\n \"[1 [2 #comment 2]\\n\" +\n \"[4 class Foo([3 object 3]):\\n\"\n +\n \" [5 [8 def method([6 self, a=([7 10,20 7]) 6]):\\n\" +\n \" [9 [10 '''\\n\"\n +\n \" multi string\\n\" +\n \" ''' 10]\\n\" +\n \" 4] 5] 8] 9] 1]\" +\n \"\", scopes.debugString(doc)\n .toString());\n }\n\n public void testScopes2() throws Exception {\n Document doc = new Document(\"a().o\");\n Scopes scopes = new ScopesParser().createScopes(doc);\n assertEquals(new Region(0, 5), scopes.getScopeForSelection(2, 0));\n }\n\n public void testScopes4() throws Exception {\n Document doc = new Document(\"(1\\n\" +\n \"\\n\" +\n \"class Bar(object):\\n\" +\n \" call\" +\n \"\");\n Scopes scopes = new ScopesParser().createScopes(doc);\n assertEquals(\"\" +\n \"[1 (1\\n\" +\n \"\\n\" +\n \"[3 class Bar([2 object 2]):\\n\" +\n \" [4 call 3] 4] 1]\" +\n \"\", scopes\n .debugString(doc).toString());\n }\n\n public void testScopes3() throws Exception {\n Document doc = new Document(\"a(.o\");\n Scopes scopes = new ScopesParser().createScopes(doc);\n assertEquals(new Region(0, 4), scopes.getScopeForSelection(2, 0));\n }\n\n public void testScopes1() throws Exception {\n Document doc = new Document(\"\" +\n \"#comment\\n\" +\n \"class Foo(object):\\n\"\n +\n \" def method(self, a=(bb,(cc,dd))):\\n\" +\n \" '''\\n\" +\n \" multi string\\n\" +\n \" '''\\n\"\n +\n \"class Class2:\\n\" +\n \" if True:\\n\" +\n \" a = \\\\\\n\" +\n \"xx\\n\" +\n \" else:\\n\" +\n \" pass\");\n Scopes scopes = new ScopesParser().createScopes(doc);\n assertEquals(\"\" +\n \"[1 [2 #comment 2]\\n\" +\n \"[4 class Foo([3 object 3]):\\n\"\n +\n \" [5 [9 def method([6 self, a=([7 bb,([8 cc,dd 8]) 7]) 6]):\\n\" +\n \" [10 [11 '''\\n\"\n +\n \" multi string\\n\" +\n \" ''' 4] 5] 9] 10] 11]\\n\" +\n \"[12 class Class2:\\n\"\n +\n \" [13 [14 if True:\\n\" +\n \" [15 a = \\\\\\n\" +\n \"xx 14] 15]\\n\" +\n \" [16 else:\\n\"\n +\n \" [17 pass 12] 13] 16] 17] 1]\" +\n \"\", scopes.debugString(doc).toString());\n\n assertEquals(new Region(0, 8), scopes.getScopeForSelection(0, 2));\n assertEquals(new Region(19, 6), scopes.getScopeForSelection(20, 0));\n }\n}\n"}
+{"text": "require('../../modules/es6.string.blink');\nmodule.exports = require('../../modules/_core').String.blink;\n"}
+{"text": "import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\n\nimport FormGroup from '../components/FormGroup';\nimport withUniqueId from '../hocs/withUniqueId';\nimport { fileRecordPropType } from '../types';\nimport prettyPrintBytes from '../utils/prettyPrintBytes';\n\nclass FileInput extends Component {\n static propTypes = {\n id: PropTypes.string.isRequired,\n label: PropTypes.node,\n name: PropTypes.string,\n value: fileRecordPropType,\n accept: PropTypes.string,\n defaultText: PropTypes.node,\n disabled: PropTypes.bool,\n buttonText: PropTypes.node,\n validator: PropTypes.func,\n onChange: PropTypes.func,\n onLoad: PropTypes.func,\n isValidFileType: PropTypes.func\n };\n\n static defaultProps = {\n label: 'File',\n defaultText: 'Select file...',\n disabled: false,\n buttonText: 'Browse...',\n validator: () => ({ valid: true }),\n onChange: () => {},\n onLoad: () => {},\n isValidFileType: () => true\n };\n\n constructor(props) {\n super(props);\n\n this.handleChange = this.handleChange.bind(this);\n }\n\n handleChange(e) {\n if (!(window.File && window.FileReader)) {\n console.error(\n 'The File APIs are not fully supported in this browser.'\n );\n\n return;\n }\n\n const { name, onChange, onLoad, isValidFileType } = this.props;\n\n const file = e.target.files[0];\n\n if (!file) {\n console.error(\n 'No file was uploaded.'\n );\n\n return;\n }\n\n if (!isValidFileType(file.type)) {\n console.error(\n 'Invalid file type.'\n );\n\n return;\n }\n\n onChange(name, {\n url: '',\n file: file\n });\n\n const reader = new FileReader();\n\n reader.addEventListener('load', (e) => {\n onLoad(name, {\n url: e.target.result,\n file: file\n });\n });\n\n reader.readAsDataURL(file);\n }\n\n render () {\n const {\n id,\n label,\n name,\n value,\n accept,\n defaultText,\n disabled,\n buttonText,\n validator\n } = this.props;\n\n const { valid, feedback } = validator(value);\n const feedbackId = feedback ? `${id}-feedback` : null;\n\n const file = value && value.file || null;\n\n return (\n \n \n\n
\n \n\n
\n \n\n
\n {buttonText}\n
\n
\n
\n \n );\n }\n}\n\nexport default withUniqueId(FileInput);\n"}
+{"text": "#!/usr/bin/perl\n\nuse strict;\nuse Test::More tests => 1;\nuse FindBin qw($Bin);\nuse lib \"$Bin/lib\";\nuse MemcachedTest;\n\nmy $server = new_memcached('-B binary');\nmy $sock = $server->sock;\n\n$SIG{ALRM} = sub { die \"alarm\\n\" };\nalarm(2);\nprint $sock \"Here's a bunch of garbage that doesn't look like the bin prot.\";\nmy $rv = <$sock>;\nok(1, \"Either the above worked and quit, or hung forever.\");\n"}
+{"text": "/*\n * Copyright (C) 2012 Google Inc. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following disclaimer\n * in the documentation and/or other materials provided with the\n * distribution.\n * * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/**\n * @constructor\n */\nWebInspector.FileMapping = function()\n{\n this._mappingEntriesSetting = WebInspector.settings.createSetting(\"fileMappingEntries\", []);\n /** @type {Array.} */\n this._entries = [];\n this._loadFromSettings();\n}\n\nWebInspector.FileMapping.prototype = {\n /**\n * @param {string} url\n * @return {?WebInspector.FileMapping.Entry}\n */\n mappingEntryForURL: function(url)\n {\n for (var i = 0; i < this._entries.length; ++i) {\n var entry = this._entries[i];\n if (url.startsWith(entry.urlPrefix))\n return entry;\n }\n return null;\n },\n\n /**\n * @param {string} path\n * @return {?WebInspector.FileMapping.Entry}\n */\n mappingEntryForPath: function(path)\n {\n for (var i = 0; i < this._entries.length; ++i) {\n var entry = this._entries[i];\n if (path.startsWith(entry.pathPrefix))\n return entry;\n }\n return null;\n },\n\n /**\n * @return {Array.}\n */\n mappingEntries: function()\n {\n return this._entries.slice();\n },\n\n /**\n * @param {Array.} mappingEntries\n */\n setMappingEntries: function(mappingEntries)\n {\n this._entries = mappingEntries;\n this._mappingEntriesSetting.set(mappingEntries);\n },\n\n _loadFromSettings: function()\n {\n var savedEntries = this._mappingEntriesSetting.get();\n this._entries = [];\n for (var i = 0; i < savedEntries.length; ++i) {\n var entry = new WebInspector.FileMapping.Entry(savedEntries[i].urlPrefix, savedEntries[i].pathPrefix);\n this._entries.push(entry);\n }\n },\n\n __proto__: WebInspector.Object.prototype\n}\n\n/**\n * @constructor\n * @param {string} urlPrefix\n * @param {string} pathPrefix\n */\nWebInspector.FileMapping.Entry = function(urlPrefix, pathPrefix)\n{\n this.urlPrefix = urlPrefix;\n this.pathPrefix = pathPrefix;\n}\n\n/**\n * @type {?WebInspector.FileMapping}\n */\nWebInspector.fileMapping = null;\n"}
+{"text": "\r\n\r\n\r\n \r\n B. wysoka jakość dźwięku\r\n Wysoka jakość dźwięku\r\n Oszczędność baterii\r\n \r\n \r\n Początkujący\r\n Standardowy\r\n Zaawansowany\r\n \r\n \r\n Normalny\r\n Kompatybilny\r\n \r\n \r\n Delikatna\r\n Poziom 1\r\n Poziom 2\r\n Poziom 3\r\n Poziom 4\r\n Poziom 5\r\n Poziom 6\r\n Poziom 7\r\n Mocna\r\n \r\n \r\n Delikatna\r\n Poziom 1\r\n Poziom 2\r\n Poziom 3\r\n Poziom 4\r\n Poziom 5\r\n Poziom 6\r\n Poziom 7\r\n Poziom 8\r\n Poziom 9\r\n Mocna\r\n \r\n \r\n 0 procent\r\n 5 procent\r\n 10 procent\r\n 15 procent\r\n 20 procent\r\n 25 procent\r\n 30 procent\r\n 35 procent\r\n 40 procent\r\n 45 procent\r\n 50 procent\r\n 55 procent\r\n 60 procent\r\n 70 procent\r\n 80 procent\r\n \r\n \r\n 25 m2\r\n 36 m2\r\n 49 m2\r\n 64 m2\r\n 81 m2\r\n 100 m2\r\n 121 m2\r\n 203 m2\r\n 347 m2\r\n 652 m2\r\n 1200 m2\r\n \r\n \r\n 5 m\r\n 6 m\r\n 7 m\r\n 8 m\r\n 9 m\r\n 10 m\r\n 11 m\r\n 14 m\r\n 19 m\r\n 26 m\r\n 36 m\r\n \r\n \r\n 0 procent\r\n 10 procent\r\n 20 procent\r\n 30 procent\r\n 40 procent\r\n 50 procent\r\n 60 procent\r\n 70 procent\r\n 80 procent\r\n 90 procent\r\n 100 procent\r\n \r\n \r\n Delikatny\r\n Umiarkowany\r\n Mocny\r\n \r\n \r\n Poziom 1\r\n Poziom 2\r\n Poziom 3\r\n Poziom 4\r\n Poziom 5\r\n \r\n \r\n Delikatna\r\n Umiarkowana\r\n Mocna\r\n \r\n \r\n Delikatna\r\n Umiarkowana\r\n Mocna\r\n \r\n \r\n 1x\r\n 2x\r\n 3x\r\n 4x\r\n 5x\r\n 6x\r\n 7x\r\n 8x\r\n 9x\r\n 10x\r\n Inf\r\n \r\n \r\n 0 dB\r\n 3.5 dB\r\n 6.0 dB\r\n 9.5 dB\r\n 12.0 dB\r\n 14.0 dB\r\n 18.0 dB\r\n 20.0 dB\r\n \r\n \r\n 0 dB\r\n -1.0 dB\r\n -1.9 dB\r\n -3.0 dB\r\n -6.0 dB\r\n -10.5 dB\r\n \r\n \r\n 6.0 dB\r\n 5.6 dB\r\n 5.1 dB\r\n 4.6 dB\r\n 4.1 dB\r\n 3.5 dB\r\n 2.9 dB\r\n 2.3 dB\r\n 1.6 dB\r\n 0.8 dB\r\n 0 dB\r\n -1.0 dB\r\n -1.9 dB\r\n -3.0 dB\r\n -4.4 dB\r\n -6.0 dB\r\n -8.0 dB\r\n -10.5 dB\r\n -14.0 dB\r\n -20.0 dB\r\n -26.0 dB\r\n -40.0 dB\r\n \r\n \r\n 0 procent\r\n 1 procent\r\n 2 procent\r\n 3 procent\r\n 4 procent\r\n 5 procent\r\n 6 procent\r\n 7 procent\r\n 8 procent\r\n 9 procent\r\n 10 procent\r\n 12 procent\r\n 14 procent\r\n 16 procent\r\n 18 procent\r\n 20 procent\r\n 22 procent\r\n 24 procent\r\n 26 procent\r\n 28 procent\r\n 30 procent\r\n 33 procent\r\n 36 procent\r\n 40 procent\r\n 45 procent\r\n 50 procent\r\n 55 procent\r\n 60 procent\r\n 70 procent\r\n 80 procent\r\n 90 procent\r\n 100 procent\r\n \r\n \r\n Nauszne z mocnym basem (v2)\r\n Nauszne wysokiej klasy (v2)\r\n Nauszne uniwersalne (v2)\r\n Nauszne niskiej klasy (v2)\r\n Douszne uniwersalne (v2)\r\n Nauszne z mocnym basem (v1)\r\n Nauszne wysokiej klasy (v1)\r\n Nauszne uniwersalne (v1)\r\n Douszne uniwersalne (v1)\r\n Douszne Apple\r\n Douszne Monster\r\n Douszne Motoroli\r\n Douszne Philips\r\n Philips SHP 2000\r\n Philips SHP 9000\r\n Nieznany typ I\r\n Nieznany typ II\r\n Nieznany typ III\r\n Nieznany typ IV\r\n \r\n \r\n Naturalny Bas\r\n Czysty Bas+\r\n Subwoofer\r\n \r\n \r\n 30 Hz\r\n 40 Hz\r\n 50 Hz\r\n 60 Hz\r\n 66 Hz\r\n 78 Hz\r\n 80 Hz\r\n 100 Hz\r\n \r\n \r\n 3.5 dB\r\n 6.0 dB\r\n 8.0 dB\r\n 10.0 dB\r\n 11.0 dB\r\n 12.0 dB\r\n 13.0 dB\r\n 14.0 dB\r\n 14.8 dB\r\n 15.6 dB\r\n 16.3 dB\r\n 17.0 dB\r\n \r\n \r\n Naturalna\r\n OZone+\r\n XHiFi\r\n \r\n \r\n Domyślnie\r\n 3.5 dB\r\n 6.0 dB\r\n 8.0 dB\r\n 10.0 dB\r\n 11.0 dB\r\n 12.0 dB\r\n 13.0 dB\r\n 14.0 dB\r\n 14.8 dB\r\n \r\n \r\n 100 Hz\r\n 140 Hz\r\n 180 Hz\r\n 200 Hz\r\n 220 Hz\r\n \r\n \r\n 3000 Hz\r\n 4000 Hz\r\n 5000 Hz\r\n 6000 Hz\r\n 7000 Hz\r\n 8000 Hz\r\n \r\n\r\n\r\n"}
+{"text": "HTML.Doctype\nTYPE: string/null\nDEFAULT: NULL\n--DESCRIPTION--\nDoctype to use during filtering. Technically speaking this is not actually\na doctype (as it does not identify a corresponding DTD), but we are using\nthis name for sake of simplicity. When non-blank, this will override any\nolder directives like %HTML.XHTML or %HTML.Strict.\n--ALLOWED--\n'HTML 4.01 Transitional', 'HTML 4.01 Strict', 'XHTML 1.0 Transitional', 'XHTML 1.0 Strict', 'XHTML 1.1'\n--# vim: et sw=4 sts=4\n"}
+{"text": "/*\n * Copyright 2013-2018 consulo.io\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage consulo.unity3d.packages;\n\nimport com.google.gson.Gson;\nimport com.intellij.openapi.project.Project;\nimport com.intellij.openapi.util.Comparing;\nimport com.intellij.psi.util.CachedValueProvider;\nimport com.intellij.psi.util.CachedValuesManager;\nimport com.intellij.psi.util.PsiModificationTracker;\nimport consulo.logging.Logger;\n\nimport javax.annotation.Nonnull;\nimport java.io.Reader;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.util.Collections;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\n\n/**\n * @author VISTALL\n * @since 2018-09-19\n */\npublic class Unity3dManifest\n{\n\tprivate static final Logger LOG = Logger.getInstance(Unity3dManifest.class);\n\n\tprivate static final Unity3dManifest EMPTY = new Unity3dManifest();\n\n\t@Nonnull\n\tpublic static Unity3dManifest parse(@Nonnull Project project)\n\t{\n\t\treturn CachedValuesManager.getManager(project).getCachedValue(project, () ->\n\t\t{\n\t\t\tPath projectPath = Paths.get(project.getBasePath());\n\t\t\tPath manifestJson = projectPath.resolve(Paths.get(\"Packages\", \"manifest.json\"));\n\t\t\tif(Files.exists(manifestJson))\n\t\t\t{\n\t\t\t\tGson gson = new Gson();\n\t\t\t\ttry (Reader reader = Files.newBufferedReader(manifestJson))\n\t\t\t\t{\n\t\t\t\t\treturn CachedValueProvider.Result.create(gson.fromJson(reader, Unity3dManifest.class), PsiModificationTracker.MODIFICATION_COUNT);\n\t\t\t\t}\n\t\t\t\tcatch(Exception e)\n\t\t\t\t{\n\t\t\t\t\tLOG.error(e);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn CachedValueProvider.Result.create(EMPTY, PsiModificationTracker.MODIFICATION_COUNT);\n\t\t});\n\t}\n\n\tprivate Map dependencies = Collections.emptyMap();\n\n\tpublic boolean isExcluded(@Nonnull String id)\n\t{\n\t\treturn Comparing.equal(dependencies.get(id), \"excluded\");\n\t}\n\n\t@Nonnull\n\tpublic Map getFilteredDependencies()\n\t{\n\t\tif(dependencies.isEmpty())\n\t\t{\n\t\t\treturn Collections.emptyMap();\n\t\t}\n\t\tMap map = new LinkedHashMap<>();\n\t\tfor(Map.Entry entry : dependencies.entrySet())\n\t\t{\n\t\t\tif(\"excluded\".equals(entry.getValue()))\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmap.put(entry.getKey(), entry.getValue());\n\t\t}\n\t\treturn map;\n\t}\n}\n"}
+{"text": "package yaml\n\nconst (\n\t// The size of the input raw buffer.\n\tinput_raw_buffer_size = 512\n\n\t// The size of the input buffer.\n\t// It should be possible to decode the whole raw buffer.\n\tinput_buffer_size = input_raw_buffer_size * 3\n\n\t// The size of the output buffer.\n\toutput_buffer_size = 128\n\n\t// The size of the output raw buffer.\n\t// It should be possible to encode the whole output buffer.\n\toutput_raw_buffer_size = (output_buffer_size*2 + 2)\n\n\t// The size of other stacks and queues.\n\tinitial_stack_size = 16\n\tinitial_queue_size = 16\n\tinitial_string_size = 16\n)\n\n// Check if the character at the specified position is an alphabetical\n// character, a digit, '_', or '-'.\nfunc is_alpha(b []byte, i int) bool {\n\treturn b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-'\n}\n\n// Check if the character at the specified position is a digit.\nfunc is_digit(b []byte, i int) bool {\n\treturn b[i] >= '0' && b[i] <= '9'\n}\n\n// Get the value of a digit.\nfunc as_digit(b []byte, i int) int {\n\treturn int(b[i]) - '0'\n}\n\n// Check if the character at the specified position is a hex-digit.\nfunc is_hex(b []byte, i int) bool {\n\treturn b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f'\n}\n\n// Get the value of a hex-digit.\nfunc as_hex(b []byte, i int) int {\n\tbi := b[i]\n\tif bi >= 'A' && bi <= 'F' {\n\t\treturn int(bi) - 'A' + 10\n\t}\n\tif bi >= 'a' && bi <= 'f' {\n\t\treturn int(bi) - 'a' + 10\n\t}\n\treturn int(bi) - '0'\n}\n\n// Check if the character is ASCII.\nfunc is_ascii(b []byte, i int) bool {\n\treturn b[i] <= 0x7F\n}\n\n// Check if the character at the start of the buffer can be printed unescaped.\nfunc is_printable(b []byte, i int) bool {\n\treturn ((b[i] == 0x0A) || // . == #x0A\n\t\t(b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E\n\t\t(b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF\n\t\t(b[i] > 0xC2 && b[i] < 0xED) ||\n\t\t(b[i] == 0xED && b[i+1] < 0xA0) ||\n\t\t(b[i] == 0xEE) ||\n\t\t(b[i] == 0xEF && // #xE000 <= . <= #xFFFD\n\t\t\t!(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF\n\t\t\t!(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF))))\n}\n\n// Check if the character at the specified position is NUL.\nfunc is_z(b []byte, i int) bool {\n\treturn b[i] == 0x00\n}\n\n// Check if the beginning of the buffer is a BOM.\nfunc is_bom(b []byte, i int) bool {\n\treturn b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF\n}\n\n// Check if the character at the specified position is space.\nfunc is_space(b []byte, i int) bool {\n\treturn b[i] == ' '\n}\n\n// Check if the character at the specified position is tab.\nfunc is_tab(b []byte, i int) bool {\n\treturn b[i] == '\\t'\n}\n\n// Check if the character at the specified position is blank (space or tab).\nfunc is_blank(b []byte, i int) bool {\n\t//return is_space(b, i) || is_tab(b, i)\n\treturn b[i] == ' ' || b[i] == '\\t'\n}\n\n// Check if the character at the specified position is a line break.\nfunc is_break(b []byte, i int) bool {\n\treturn (b[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029)\n}\n\nfunc is_crlf(b []byte, i int) bool {\n\treturn b[i] == '\\r' && b[i+1] == '\\n'\n}\n\n// Check if the character is a line break or NUL.\nfunc is_breakz(b []byte, i int) bool {\n\t//return is_break(b, i) || is_z(b, i)\n\treturn ( // is_break:\n\tb[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)\n\t\t// is_z:\n\t\tb[i] == 0)\n}\n\n// Check if the character is a line break, space, or NUL.\nfunc is_spacez(b []byte, i int) bool {\n\t//return is_space(b, i) || is_breakz(b, i)\n\treturn ( // is_space:\n\tb[i] == ' ' ||\n\t\t// is_breakz:\n\t\tb[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)\n\t\tb[i] == 0)\n}\n\n// Check if the character is a line break, space, tab, or NUL.\nfunc is_blankz(b []byte, i int) bool {\n\t//return is_blank(b, i) || is_breakz(b, i)\n\treturn ( // is_blank:\n\tb[i] == ' ' || b[i] == '\\t' ||\n\t\t// is_breakz:\n\t\tb[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)\n\t\tb[i] == 0)\n}\n\n// Determine the width of the character.\nfunc width(b byte) int {\n\t// Don't replace these by a switch without first\n\t// confirming that it is being inlined.\n\tif b&0x80 == 0x00 {\n\t\treturn 1\n\t}\n\tif b&0xE0 == 0xC0 {\n\t\treturn 2\n\t}\n\tif b&0xF0 == 0xE0 {\n\t\treturn 3\n\t}\n\tif b&0xF8 == 0xF0 {\n\t\treturn 4\n\t}\n\treturn 0\n\n}\n"}
+{"text": "\n\n\n\n
\n\t
\n\t\t
\n
\n \n \n
套餐{$comboTab.$key}
\n \n
套餐{$comboTab.$key}
\n \n \n
\n
\n\t\t\n\t\t
\n\t\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n
\n\n\n\n"}
+{"text": "/* global document */\n( function( document ) {\n \"use strict\";\n var root;\n var stepids = [];\n\n // Get stepids from the steps under impress root\n var getSteps = function() {\n stepids = [];\n var steps = root.querySelectorAll( \".step\" );\n for ( var i = 0; i < steps.length; i++ )\n {\n stepids[ i + 1 ] = steps[ i ].id;\n }\n };\n\n // Wait for impress.js to be initialized\n document.addEventListener( \"impress:init\", function( event ) {\n root = event.target;\n getSteps();\n var gc = event.detail.api.lib.gc;\n gc.pushCallback( function() {\n stepids = [];\n if ( progressbar ) {\n progressbar.style.width = \"\";\n }\n if ( progress ) {\n progress.innerHTML = \"\";\n }\n } );\n } );\n\n var progressbar = document.querySelector( \"div.impress-progressbar div\" );\n var progress = document.querySelector( \"div.impress-progress\" );\n\n if ( null !== progressbar || null !== progress ) {\n document.addEventListener( \"impress:stepleave\", function( event ) {\n updateProgressbar( event.detail.next.id );\n } );\n\n document.addEventListener( \"impress:steprefresh\", function( event ) {\n getSteps();\n updateProgressbar( event.target.id );\n } );\n\n }\n\n function updateProgressbar( slideId ) {\n var slideNumber = stepids.indexOf( slideId );\n if ( null !== progressbar ) {\n var width = 100 / ( stepids.length - 1 ) * ( slideNumber );\n progressbar.style.width = width.toFixed( 2 ) + \"%\";\n }\n if ( null !== progress ) {\n progress.innerHTML = slideNumber + \"/\" + ( stepids.length - 1 );\n }\n }\n} )( document );\n"}
+{"text": "..\n **************************************************\n * *\n * Automatically generated file, do not edit! *\n * *\n **************************************************\n\n.. _amdgpu_synid9_data_smem_atomic64:\n\nsdata\n===========================\n\nInput data for an atomic instruction.\n\nOptionally may serve as an output data:\n\n* If :ref:`glc` is specified, gets the memory value before the operation.\n\n*Size:* 2 dwords.\n\n*Operands:* :ref:`s`, :ref:`flat_scratch`, :ref:`xnack`, :ref:`vcc`, :ref:`ttmp`\n"}
+{"text": "authenticate:\n idp:\n provider: REPLACEME\n url: REPLACEME\n clientID: REPLACEME\n clientSecret: REPLACEME\n\nconfig:\n rootDomain: localhost.pomerium.io\n sharedSecret: R0+XRoGVpcoi4PfB8tMlvnrS5XUasO+D1frAEdYcYjs=\n cookieSecret: FLPCOQKigK5EQnyXlBhchl5fgzNKqi3ubtvOGt477Dg=\n generateTLS: true\n policy:\n - from: https://hello.localhost.pomerium.io\n to: http://hello-nginx\n allowed_domains:\n - gmail.com\ningress:\n annotations:\n traefik.ingress.kubernetes.io/router.tls: \"true\"\n secretName: wildcard-tls\nforwardAuth:\n enabled: true\n internal: true\n"}
+{"text": "\"\"\"\nViewing Stanford 3D Scanning Repository dragon model\n\"\"\"\n# Copyright (c) 2014-2020, Enthought, Inc.\n# Standard library imports\nimport os\nfrom os.path import join\n\n# Enthought library imports\nfrom mayavi import mlab\n\n### Download the dragon data, if not already on disk ############################\nif not os.path.exists('dragon.tar.gz'):\n # Download the data\n try:\n from urllib import urlopen\n except ImportError:\n from urllib.request import urlopen\n print(\"Downloading dragon model, Please Wait (11MB)\")\n opener = urlopen(\n 'http://graphics.stanford.edu/pub/3Dscanrep/dragon/dragon_recon.tar.gz')\n open('dragon.tar.gz', 'wb').write(opener.read())\n\n# Extract the data\nimport tarfile\ndragon_tar_file = tarfile.open('dragon.tar.gz')\ntry:\n os.mkdir('dragon_data')\nexcept:\n pass\ndragon_tar_file.extractall('dragon_data')\ndragon_tar_file.close()\n\n# Path to the dragon ply file\ndragon_ply_file = join('dragon_data', 'dragon_recon', 'dragon_vrip.ply')\n\n# Render the dragon ply file\nmlab.pipeline.surface(mlab.pipeline.open(dragon_ply_file))\nmlab.show()\n\nimport shutil\nshutil.rmtree('dragon_data')\n"}
+{"text": "# Copyright (C) 2018 The NeoVintageous Team (NeoVintageous).\n#\n# This file is part of NeoVintageous.\n#\n# NeoVintageous is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# NeoVintageous is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with NeoVintageous. If not, see .\n\nimport os\n\nfrom NeoVintageous.tests import unittest\n\nfrom NeoVintageous.nv.settings import get_cmdline_cwd\nfrom NeoVintageous.nv.settings import set_cmdline_cwd\n\n\nclass TestCmdlineCwd(unittest.ViewTestCase):\n\n @unittest.mock.patch('NeoVintageous.nv.settings.active_window')\n @unittest.mock.patch.dict('NeoVintageous.nv.session._session', clear=True)\n def test_returns_cwd(self, active_window, *args):\n active_window.return_value = None\n self.assertEqual(get_cmdline_cwd(), os.getcwd())\n\n @unittest.mock.patch('sublime.Window.extract_variables')\n @unittest.mock.patch.dict('NeoVintageous.nv.session._session', clear=True)\n def test_returns_cwd_when_no_folder_variable_found(self, extract_variables):\n extract_variables.return_value = {}\n self.assertEqual(get_cmdline_cwd(), os.getcwd())\n\n @unittest.mock.patch('sublime.Window.extract_variables')\n @unittest.mock.patch.dict('NeoVintageous.nv.session._session', clear=True)\n def test_returns_cwd_folder_variable(self, extract_variables):\n extract_variables.return_value = {'folder': '/tmp/folder'}\n self.assertEqual(get_cmdline_cwd(), '/tmp/folder')\n\n def test_returns_set_cwd(self):\n set_cmdline_cwd('/tmp/fizz')\n self.assertEqual(get_cmdline_cwd(), '/tmp/fizz')\n"}
+{"text": "# OpenSesame help\n\n*This is the offline help page. If you are connected to the Internet,\nyou can find the online documentation at .*\n\n## Introduction\n\nOpenSesame is a graphical experiment builder for the social sciences. With OpenSesame you can easily create experiments using a point-and-click graphical interface. For complex tasks, OpenSesame supports [Python] scripting.\n\n## Getting started\n\nThe best way to get started is by walking through a tutorial. Tutorials, and much more, can be found online:\n\n- \n\n## Citation\n\nTo cite OpenSesame in your work, please use the following reference:\n\n- Mathôt, S., Schreij, D., & Theeuwes, J. (2012). OpenSesame: An open-source, graphical experiment builder for the social sciences. *Behavior Research Methods*, *44*(2), 314-324. doi:[10.3758/s13428-011-0168-7](http://dx.doi.org/10.3758/s13428-011-0168-7)\n\n## Interface\n\nThe graphical interface has the following components. You can get\ncontext-sensitive help by clicking on the help icons at the top-right of\neach tab.\n\n- The *menu* (at the top of the window) shows common options, such as opening and saving files, closing the program, and showing this help page.\n- The *main toolbar* (the big buttons below the menu) offers a selection of the most relevant options from the menu.\n- The *item toolbar* (the big buttons on the left of the window) shows available items. To add an item to your experiment, drag it from the item toolbar onto the overview area.\n- The *overview area* (Control + \\\\) shows a tree-like overview of your experiment.\n- The *tab area* contains the tabs for editing items. If you click on an item in the overview area, a corresponding tab opens in the tab area. Help is displayed in the tab area as well.\n- The [file pool](opensesame://help.pool) (Control + P) shows files that are bundled with your experiment.\n- The [variable inspector](opensesame://help.extension.variable_inspector) (Control + I) shows all detected variables.\n- The [debug window](opensesame://help.stdout). (Control + D) is an [IPython] terminal. Everything that your experiment prints to the standard output (i.e. using `print()`) is shown here.\n\n## Items\n\nItems are the building blocks of your experiment. Ten core items provide basic functionality for creating an experiment. To add items to your experiment, drag them from the item toolbar into the overview area.\n\n- The [loop](opensesame://help.loop) item runs another item multiple times. You can also define independent variables in the LOOP item.\n- The [sequence](opensesame://help.sequence) item runs multiple other items in sequence.\n- The [sketchpad](opensesame://help.sketchpad) item presents visual stimuli. Built-in drawing tools allow you to easily create stimulus displays.\n- The [feedback](opensesame://help.feedback) item is similar to the `sketchpad`, but is not prepared in advance. Therefore, FEEDBACK items can be used to provide feedback to participants.\n- The [sampler](opensesame://help.sampler) item plays a single sound file.\n- The [synth](opensesame://help.synth) item generates a single sound.\n- The [keyboard_response](opensesame://help.keyboard_response) item collects key-press responses.\n- The [mouse_response](opensesame://help.mouse_response) item collects mouse-click responses.\n- The [logger](opensesame://help.logger) item writes variables to the log file.\n- The [inline_script](opensesame://help.inline_script) embeds Python code in your experiment.\n\nIf installed, plug-in items provide additional functionality. Plug-ins appear alongside the core items in the item toolbar.\n\n## Running your experiment\n\nYou can run your experiment in:\n\n- Full-screen mode (*Control+R* or *Run -> Run fullscreen*)\n- Window mode (*Control+W* or *Run -> Run in window*)\n- Quick-run mode (*Control+Shift+W* or *Run -> Quick run*)\n\nIn quick-run mode, the experiments starts immediately in a window, using log file `quickrun.csv`, and subject number 999. This is useful during development.\n\n[python]: http://www.python.org/\n[ipython]: http://www.ipython.org/\n"}
+{"text": "0.3.0\n"}
+{"text": "/*\n # This file is part of libkd.\n # Licensed under a 3-clause BSD style license - see LICENSE\n */\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \"cutest.h\"\n\n#include \"dualtree_nearestneighbour.h\"\n#include \"mathutil.h\"\n#include \"tic.h\"\n\nvoid test_nn_1(CuTest* tc) {\n //int NX = 5000;\n //int NY = 6000;\n //double maxr2 = 0.01;\n\n int NX = 8;\n int NY = 10;\n double maxr2 = 0.5;\n\n int D = 3;\n int Nleaf = 5;\n\n int i, j;\n\n kdtree_t* xkd;\n kdtree_t* ykd;\n\n double* xdata;\n double* ydata;\n\n double* nearest_d2 = NULL;\n int* nearest_ind = NULL;\n\n double* true_nearest_d2;\n int* true_nearest_ind;\n\n double t0;\n\n srand(0);\n\n xdata = malloc(NX * D * sizeof(double));\n ydata = malloc(NY * D * sizeof(double));\n\n for (i=0; i<(NX*D); i++)\n xdata[i] = rand() / (double)RAND_MAX;\n for (i=0; i<(NY*D); i++)\n ydata[i] = rand() / (double)RAND_MAX;\n\n true_nearest_d2 = malloc(NY * sizeof(double));\n true_nearest_ind = malloc(NY * sizeof(int));\n t0 = timenow();\n for (j=0; j(?[\\\\d.]+)-[\\\\d]+)\\\\.win32\",\r\n \"url\": \"https://sourceforge.net/projects/smartmontools/files/smartmontools/\"\r\n },\r\n \"autoupdate\": {\r\n \"url\": \"https://downloads.sourceforge.net/project/smartmontools/smartmontools/$matchShort/smartmontools-$version.win32-setup.exe\"\r\n }\r\n}\r\n"}
+{"text": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-\n *\n * ***** BEGIN LICENSE BLOCK *****\n * Version: MPL 1.1/GPL 2.0/LGPL 2.1\n *\n * The contents of this file are subject to the Mozilla Public License Version\n * 1.1 (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n * http://www.mozilla.org/MPL/\n *\n * Software distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\n * for the specific language governing rights and limitations under the\n * License.\n *\n * The Original Code is Mozilla Communicator client code, released\n * March 31, 1998.\n *\n * The Initial Developer of the Original Code is\n * Netscape Communications Corporation.\n * Portions created by the Initial Developer are Copyright (C) 1998\n * the Initial Developer. All Rights Reserved.\n *\n * Contributor(s):\n *\n * Alternatively, the contents of this file may be used under the terms of\n * either of the GNU General Public License Version 2 or later (the \"GPL\"),\n * or the GNU Lesser General Public License Version 2.1 or later (the \"LGPL\"),\n * in which case the provisions of the GPL or the LGPL are applicable instead\n * of those above. If you wish to allow use of your version of this file only\n * under the terms of either the GPL or the LGPL, and not to allow others to\n * use your version of this file under the terms of the MPL, indicate your\n * decision by deleting the provisions above and replace them with the notice\n * and other provisions required by the GPL or the LGPL. If you do not delete\n * the provisions above, a recipient may use your version of this file under\n * the terms of any one of the MPL, the GPL or the LGPL.\n *\n * ***** END LICENSE BLOCK ***** */\n\n#ifndef jsstr_h___\n#define jsstr_h___\n/*\n * JS string type implementation.\n *\n * A JS string is a counted array of unicode characters. To support handoff\n * of API client memory, the chars are allocated separately from the length,\n * necessitating a pointer after the count, to form a separately allocated\n * string descriptor. String descriptors are GC'ed, while their chars are\n * allocated from the malloc heap.\n */\n#include \n#include \"jspubtd.h\"\n#include \"jsprvtd.h\"\n\nJS_BEGIN_EXTERN_C\n\n/*\n * The GC-thing \"string\" type.\n *\n * When the JSSTRFLAG_DEPENDENT bit of the length field is unset, the u.chars\n * field points to a flat character array owned by its GC-thing descriptor.\n * The array is terminated at index length by a zero character and the size of\n * the array in bytes is (length + 1) * sizeof(jschar). The terminator is\n * purely a backstop, in case the chars pointer flows out to native code that\n * requires \\u0000 termination.\n *\n * A flat string with JSSTRFLAG_MUTABLE set means that the string is accessible\n * only from one thread and it is possible to turn it into a dependent string\n * of the same length to optimize js_ConcatStrings. It is also possible to grow\n * such a string, but extreme care must be taken to ensure that no other code\n * relies on the original length of the string.\n *\n * A flat string with JSSTRFLAG_ATOMIZED set means that the string is hashed as\n * an atom. This flag is used to avoid re-hashing the already-atomized string.\n *\n * When JSSTRFLAG_DEPENDENT is set, the string depends on characters of another\n * string strongly referenced by the u.base field. The base member may point to\n * another dependent string if JSSTRING_CHARS has not been called yet.\n *\n * JSSTRFLAG_PREFIX determines the kind of the dependent string. When the flag\n * is unset, the length field encodes both starting position relative to the\n * base string and the number of characters in the dependent string, see\n * JSSTRDEP_START_MASK and JSSTRDEP_LENGTH_MASK macros below for details.\n *\n * When JSSTRFLAG_PREFIX is set, the dependent string is a prefix of the base\n * string. The number of characters in the prefix is encoded using all non-flag\n * bits of the length field and spans the same 0 .. SIZE_T_MAX/4 range as the\n * length of the flat string.\n *\n * NB: Always use the JSSTRING_LENGTH and JSSTRING_CHARS accessor macros.\n */\nstruct JSString {\n size_t length;\n union {\n jschar *chars;\n JSString *base;\n } u;\n};\n\n/*\n * Definitions for flags stored in the high order bits of JSString.length.\n * JSSTRFLAG_PREFIX and JSSTRFLAG_MUTABLE are two aliases for the same value.\n * JSSTRFLAG_PREFIX should be used only if JSSTRFLAG_DEPENDENT is set and\n * JSSTRFLAG_MUTABLE should be used only if the string is flat.\n * JSSTRFLAG_ATOMIZED is used only with the flat immutable strings.\n */\n#define JSSTRFLAG_DEPENDENT JSSTRING_BIT(JS_BITS_PER_WORD - 1)\n#define JSSTRFLAG_PREFIX JSSTRING_BIT(JS_BITS_PER_WORD - 2)\n#define JSSTRFLAG_MUTABLE JSSTRFLAG_PREFIX\n#define JSSTRFLAG_ATOMIZED JSSTRING_BIT(JS_BITS_PER_WORD - 3)\n\n#define JSSTRING_LENGTH_BITS (JS_BITS_PER_WORD - 3)\n#define JSSTRING_LENGTH_MASK JSSTRING_BITMASK(JSSTRING_LENGTH_BITS)\n\n/* Universal JSString type inquiry and accessor macros. */\n#define JSSTRING_BIT(n) ((size_t)1 << (n))\n#define JSSTRING_BITMASK(n) (JSSTRING_BIT(n) - 1)\n#define JSSTRING_HAS_FLAG(str,flg) ((str)->length & (flg))\n#define JSSTRING_IS_DEPENDENT(str) JSSTRING_HAS_FLAG(str, JSSTRFLAG_DEPENDENT)\n#define JSSTRING_IS_FLAT(str) (!JSSTRING_IS_DEPENDENT(str))\n#define JSSTRING_IS_MUTABLE(str) (((str)->length & (JSSTRFLAG_DEPENDENT | \\\n JSSTRFLAG_MUTABLE)) == \\\n JSSTRFLAG_MUTABLE)\n#define JSSTRING_IS_ATOMIZED(str) (((str)->length & (JSSTRFLAG_DEPENDENT | \\\n JSSTRFLAG_ATOMIZED)) ==\\\n JSSTRFLAG_ATOMIZED)\n\n#define JSSTRING_CHARS(str) (JSSTRING_IS_DEPENDENT(str) \\\n ? JSSTRDEP_CHARS(str) \\\n : JSFLATSTR_CHARS(str))\n#define JSSTRING_LENGTH(str) (JSSTRING_IS_DEPENDENT(str) \\\n ? JSSTRDEP_LENGTH(str) \\\n : JSFLATSTR_LENGTH(str))\n\n#define JSSTRING_CHARS_AND_LENGTH(str, chars_, length_) \\\n ((void)(JSSTRING_IS_DEPENDENT(str) \\\n ? ((length_) = JSSTRDEP_LENGTH(str), \\\n (chars_) = JSSTRDEP_CHARS(str)) \\\n : ((length_) = JSFLATSTR_LENGTH(str), \\\n (chars_) = JSFLATSTR_CHARS(str))))\n\n#define JSSTRING_CHARS_AND_END(str, chars_, end) \\\n ((void)((end) = JSSTRING_IS_DEPENDENT(str) \\\n ? JSSTRDEP_LENGTH(str) + ((chars_) = JSSTRDEP_CHARS(str)) \\\n : JSFLATSTR_LENGTH(str) + ((chars_) = JSFLATSTR_CHARS(str))))\n\n/* Specific flat string initializer and accessor macros. */\n#define JSFLATSTR_INIT(str, chars_, length_) \\\n ((void)(JS_ASSERT(((length_) & ~JSSTRING_LENGTH_MASK) == 0), \\\n (str)->length = (length_), (str)->u.chars = (chars_)))\n\n#define JSFLATSTR_LENGTH(str) \\\n (JS_ASSERT(JSSTRING_IS_FLAT(str)), (str)->length & JSSTRING_LENGTH_MASK)\n\n#define JSFLATSTR_CHARS(str) \\\n (JS_ASSERT(JSSTRING_IS_FLAT(str)), (str)->u.chars)\n\n/*\n * Macros to manipulate atomized and mutable flags of flat strings. It is safe\n * to use these without extra locking due to the following properties:\n *\n * * We do not have a macro like JSFLATSTR_CLEAR_ATOMIZED as a string\n * remains atomized until the GC collects it.\n *\n * * A thread may call JSFLATSTR_SET_MUTABLE only when it is the only thread\n * accessing the string until a later call to JSFLATSTR_CLEAR_MUTABLE.\n *\n * * Multiple threads can call JSFLATSTR_CLEAR_MUTABLE but the macro\n * actually clears the mutable flag only when the flag is set -- in which\n * case only one thread can access the string (see previous property).\n *\n * Thus, when multiple threads access the string, JSFLATSTR_SET_ATOMIZED is\n * the only macro that can update the length field of the string by changing\n * the mutable bit from 0 to 1. We call the macro only after the string has\n * been hashed. When some threads in js_ValueToStringId see that the flag is\n * set, it knows that the string was atomized.\n *\n * On the other hand, if the thread sees that the flag is unset, it could be\n * seeing a stale value when another thread has just atomized the string and\n * set the flag. But this can lead only to an extra call to js_AtomizeString.\n * This function would find that the string was already hashed and return it\n * with the atomized bit set.\n */\n#define JSFLATSTR_SET_ATOMIZED(str) \\\n ((void)(JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_MUTABLE(str)), \\\n (str)->length |= JSSTRFLAG_ATOMIZED))\n\n#define JSFLATSTR_SET_MUTABLE(str) \\\n ((void)(JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_ATOMIZED(str)), \\\n (str)->length |= JSSTRFLAG_MUTABLE))\n\n#define JSFLATSTR_CLEAR_MUTABLE(str) \\\n ((void)(JS_ASSERT(JSSTRING_IS_FLAT(str)), \\\n JSSTRING_HAS_FLAG(str, JSSTRFLAG_MUTABLE) && \\\n ((str)->length &= ~JSSTRFLAG_MUTABLE)))\n\n/* Specific dependent string shift/mask accessor and mutator macros. */\n#define JSSTRDEP_START_BITS (JSSTRING_LENGTH_BITS-JSSTRDEP_LENGTH_BITS)\n#define JSSTRDEP_START_SHIFT JSSTRDEP_LENGTH_BITS\n#define JSSTRDEP_START_MASK JSSTRING_BITMASK(JSSTRDEP_START_BITS)\n#define JSSTRDEP_LENGTH_BITS (JSSTRING_LENGTH_BITS / 2)\n#define JSSTRDEP_LENGTH_MASK JSSTRING_BITMASK(JSSTRDEP_LENGTH_BITS)\n\n#define JSSTRDEP_IS_PREFIX(str) JSSTRING_HAS_FLAG(str, JSSTRFLAG_PREFIX)\n\n#define JSSTRDEP_START(str) (JSSTRDEP_IS_PREFIX(str) ? 0 \\\n : (((str)->length \\\n >> JSSTRDEP_START_SHIFT) \\\n & JSSTRDEP_START_MASK))\n#define JSSTRDEP_LENGTH(str) ((str)->length \\\n & (JSSTRDEP_IS_PREFIX(str) \\\n ? JSSTRING_LENGTH_MASK \\\n : JSSTRDEP_LENGTH_MASK))\n\n#define JSSTRDEP_INIT(str,bstr,off,len) \\\n ((str)->length = JSSTRFLAG_DEPENDENT \\\n | ((off) << JSSTRDEP_START_SHIFT) \\\n | (len), \\\n (str)->u.base = (bstr))\n\n#define JSPREFIX_INIT(str,bstr,len) \\\n ((str)->length = JSSTRFLAG_DEPENDENT | JSSTRFLAG_PREFIX | (len), \\\n (str)->u.base = (bstr))\n\n#define JSSTRDEP_BASE(str) ((str)->u.base)\n#define JSPREFIX_BASE(str) JSSTRDEP_BASE(str)\n#define JSPREFIX_SET_BASE(str,bstr) ((str)->u.base = (bstr))\n\n#define JSSTRDEP_CHARS(str) \\\n (JSSTRING_IS_DEPENDENT(JSSTRDEP_BASE(str)) \\\n ? js_GetDependentStringChars(str) \\\n : JSFLATSTR_CHARS(JSSTRDEP_BASE(str)) + JSSTRDEP_START(str))\n\nextern size_t\njs_MinimizeDependentStrings(JSString *str, int level, JSString **basep);\n\nextern jschar *\njs_GetDependentStringChars(JSString *str);\n\nextern const jschar *\njs_GetStringChars(JSContext *cx, JSString *str);\n\nextern JSString * JS_FASTCALL\njs_ConcatStrings(JSContext *cx, JSString *left, JSString *right);\n\nextern const jschar *\njs_UndependString(JSContext *cx, JSString *str);\n\nextern JSBool\njs_MakeStringImmutable(JSContext *cx, JSString *str);\n\nextern JSString* JS_FASTCALL\njs_toLowerCase(JSContext *cx, JSString *str);\n\nextern JSString* JS_FASTCALL\njs_toUpperCase(JSContext *cx, JSString *str);\n\ntypedef struct JSCharBuffer {\n size_t length;\n jschar *chars;\n} JSCharBuffer;\n\nstruct JSSubString {\n size_t length;\n const jschar *chars;\n};\n\nextern jschar js_empty_ucstr[];\nextern JSSubString js_EmptySubString;\n\n/* Unicode character attribute lookup tables. */\nextern const uint8 js_X[];\nextern const uint8 js_Y[];\nextern const uint32 js_A[];\n\n/* Enumerated Unicode general category types. */\ntypedef enum JSCharType {\n JSCT_UNASSIGNED = 0,\n JSCT_UPPERCASE_LETTER = 1,\n JSCT_LOWERCASE_LETTER = 2,\n JSCT_TITLECASE_LETTER = 3,\n JSCT_MODIFIER_LETTER = 4,\n JSCT_OTHER_LETTER = 5,\n JSCT_NON_SPACING_MARK = 6,\n JSCT_ENCLOSING_MARK = 7,\n JSCT_COMBINING_SPACING_MARK = 8,\n JSCT_DECIMAL_DIGIT_NUMBER = 9,\n JSCT_LETTER_NUMBER = 10,\n JSCT_OTHER_NUMBER = 11,\n JSCT_SPACE_SEPARATOR = 12,\n JSCT_LINE_SEPARATOR = 13,\n JSCT_PARAGRAPH_SEPARATOR = 14,\n JSCT_CONTROL = 15,\n JSCT_FORMAT = 16,\n JSCT_PRIVATE_USE = 18,\n JSCT_SURROGATE = 19,\n JSCT_DASH_PUNCTUATION = 20,\n JSCT_START_PUNCTUATION = 21,\n JSCT_END_PUNCTUATION = 22,\n JSCT_CONNECTOR_PUNCTUATION = 23,\n JSCT_OTHER_PUNCTUATION = 24,\n JSCT_MATH_SYMBOL = 25,\n JSCT_CURRENCY_SYMBOL = 26,\n JSCT_MODIFIER_SYMBOL = 27,\n JSCT_OTHER_SYMBOL = 28\n} JSCharType;\n\n/* Character classifying and mapping macros, based on java.lang.Character. */\n#define JS_CCODE(c) (js_A[js_Y[(js_X[(uint16)(c)>>6]<<6)|((c)&0x3F)]])\n#define JS_CTYPE(c) (JS_CCODE(c) & 0x1F)\n\n#define JS_ISALPHA(c) ((((1 << JSCT_UPPERCASE_LETTER) | \\\n (1 << JSCT_LOWERCASE_LETTER) | \\\n (1 << JSCT_TITLECASE_LETTER) | \\\n (1 << JSCT_MODIFIER_LETTER) | \\\n (1 << JSCT_OTHER_LETTER)) \\\n >> JS_CTYPE(c)) & 1)\n\n#define JS_ISALNUM(c) ((((1 << JSCT_UPPERCASE_LETTER) | \\\n (1 << JSCT_LOWERCASE_LETTER) | \\\n (1 << JSCT_TITLECASE_LETTER) | \\\n (1 << JSCT_MODIFIER_LETTER) | \\\n (1 << JSCT_OTHER_LETTER) | \\\n (1 << JSCT_DECIMAL_DIGIT_NUMBER)) \\\n >> JS_CTYPE(c)) & 1)\n\n/* A unicode letter, suitable for use in an identifier. */\n#define JS_ISLETTER(c) ((((1 << JSCT_UPPERCASE_LETTER) | \\\n (1 << JSCT_LOWERCASE_LETTER) | \\\n (1 << JSCT_TITLECASE_LETTER) | \\\n (1 << JSCT_MODIFIER_LETTER) | \\\n (1 << JSCT_OTHER_LETTER) | \\\n (1 << JSCT_LETTER_NUMBER)) \\\n >> JS_CTYPE(c)) & 1)\n\n/*\n * 'IdentifierPart' from ECMA grammar, is Unicode letter or combining mark or\n * digit or connector punctuation.\n */\n#define JS_ISIDPART(c) ((((1 << JSCT_UPPERCASE_LETTER) | \\\n (1 << JSCT_LOWERCASE_LETTER) | \\\n (1 << JSCT_TITLECASE_LETTER) | \\\n (1 << JSCT_MODIFIER_LETTER) | \\\n (1 << JSCT_OTHER_LETTER) | \\\n (1 << JSCT_LETTER_NUMBER) | \\\n (1 << JSCT_NON_SPACING_MARK) | \\\n (1 << JSCT_COMBINING_SPACING_MARK) | \\\n (1 << JSCT_DECIMAL_DIGIT_NUMBER) | \\\n (1 << JSCT_CONNECTOR_PUNCTUATION)) \\\n >> JS_CTYPE(c)) & 1)\n\n/* Unicode control-format characters, ignored in input */\n#define JS_ISFORMAT(c) (((1 << JSCT_FORMAT) >> JS_CTYPE(c)) & 1)\n\n/*\n * Per ECMA-262 15.10.2.6, these characters are the only ones that make up a\n * \"word\", as far as a RegExp is concerned. If we want a Unicode-friendlier\n * definition of \"word\", we should rename this macro to something regexp-y.\n */\n#define JS_ISWORD(c) ((c) < 128 && (isalnum(c) || (c) == '_'))\n\n#define JS_ISIDSTART(c) (JS_ISLETTER(c) || (c) == '_' || (c) == '$')\n#define JS_ISIDENT(c) (JS_ISIDPART(c) || (c) == '_' || (c) == '$')\n\n#define JS_ISXMLSPACE(c) ((c) == ' ' || (c) == '\\t' || (c) == '\\r' || \\\n (c) == '\\n')\n#define JS_ISXMLNSSTART(c) ((JS_CCODE(c) & 0x00000100) || (c) == '_')\n#define JS_ISXMLNS(c) ((JS_CCODE(c) & 0x00000080) || (c) == '.' || \\\n (c) == '-' || (c) == '_')\n#define JS_ISXMLNAMESTART(c) (JS_ISXMLNSSTART(c) || (c) == ':')\n#define JS_ISXMLNAME(c) (JS_ISXMLNS(c) || (c) == ':')\n\n#define JS_ISDIGIT(c) (JS_CTYPE(c) == JSCT_DECIMAL_DIGIT_NUMBER)\n\n/* XXXbe unify on A/X/Y tbls, avoid ctype.h? */\n/* XXXbe fs, etc. ? */\n#define JS_ISSPACE(c) ((JS_CCODE(c) & 0x00070000) == 0x00040000)\n#define JS_ISPRINT(c) ((c) < 128 && isprint(c))\n\n#define JS_ISUPPER(c) (JS_CTYPE(c) == JSCT_UPPERCASE_LETTER)\n#define JS_ISLOWER(c) (JS_CTYPE(c) == JSCT_LOWERCASE_LETTER)\n\n#define JS_TOUPPER(c) ((jschar) ((JS_CCODE(c) & 0x00100000) \\\n ? (c) - ((int32)JS_CCODE(c) >> 22) \\\n : (c)))\n#define JS_TOLOWER(c) ((jschar) ((JS_CCODE(c) & 0x00200000) \\\n ? (c) + ((int32)JS_CCODE(c) >> 22) \\\n : (c)))\n\n/*\n * Shorthands for ASCII (7-bit) decimal and hex conversion.\n * Manually inline isdigit for performance; MSVC doesn't do this for us.\n */\n#define JS7_ISDEC(c) ((((unsigned)(c)) - '0') <= 9)\n#define JS7_UNDEC(c) ((c) - '0')\n#define JS7_ISHEX(c) ((c) < 128 && isxdigit(c))\n#define JS7_UNHEX(c) (uintN)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')\n#define JS7_ISLET(c) ((c) < 128 && isalpha(c))\n\n/* Initialize per-runtime string state for the first context in the runtime. */\nextern JSBool\njs_InitRuntimeStringState(JSContext *cx);\n\nextern JSBool\njs_InitDeflatedStringCache(JSRuntime *rt);\n\n/*\n * Maximum character code for which we will create a pinned unit string on\n * demand -- see JSRuntime.unitStrings in jscntxt.h.\n */\n#define UNIT_STRING_LIMIT 256U\n\n/*\n * Get the independent string containing only character code at index in str\n * (backstopped with a zero character as usual for independent strings).\n */\nextern JSString *\njs_GetUnitString(JSContext *cx, JSString *str, size_t index);\n\n/*\n * Get the independent string containing only the character code c, which must\n * be less than UNIT_STRING_LIMIT.\n */\nextern JSString *\njs_GetUnitStringForChar(JSContext *cx, jschar c);\n\nextern void\njs_FinishUnitStrings(JSRuntime *rt);\n\nextern void\njs_FinishRuntimeStringState(JSContext *cx);\n\nextern void\njs_FinishDeflatedStringCache(JSRuntime *rt);\n\n/* Initialize the String class, returning its prototype object. */\nextern JSClass js_StringClass;\n\nextern JSObject *\njs_InitStringClass(JSContext *cx, JSObject *obj);\n\nextern const char js_escape_str[];\nextern const char js_unescape_str[];\nextern const char js_uneval_str[];\nextern const char js_decodeURI_str[];\nextern const char js_encodeURI_str[];\nextern const char js_decodeURIComponent_str[];\nextern const char js_encodeURIComponent_str[];\n\n/* GC-allocate a string descriptor for the given malloc-allocated chars. */\nextern JSString *\njs_NewString(JSContext *cx, jschar *chars, size_t length);\n\nextern JSString *\njs_NewDependentString(JSContext *cx, JSString *base, size_t start,\n size_t length);\n\n/* Copy a counted string and GC-allocate a descriptor for it. */\nextern JSString *\njs_NewStringCopyN(JSContext *cx, const jschar *s, size_t n);\n\n/* Copy a C string and GC-allocate a descriptor for it. */\nextern JSString *\njs_NewStringCopyZ(JSContext *cx, const jschar *s);\n\n/*\n * Free the chars held by str when it is finalized by the GC. When type is\n * less then zero, it denotes an internal string. Otherwise it denotes the\n * type of the external string allocated with JS_NewExternalString.\n *\n * This function always needs rt but can live with null cx.\n */\nextern void\njs_FinalizeStringRT(JSRuntime *rt, JSString *str, intN type, JSContext *cx);\n\n/*\n * Convert a value to a printable C string.\n */\ntypedef JSString *(*JSValueToStringFun)(JSContext *cx, jsval v);\n\nextern JS_FRIEND_API(const char *)\njs_ValueToPrintable(JSContext *cx, jsval v, JSValueToStringFun v2sfun);\n\n#define js_ValueToPrintableString(cx,v) \\\n js_ValueToPrintable(cx, v, js_ValueToString)\n\n#define js_ValueToPrintableSource(cx,v) \\\n js_ValueToPrintable(cx, v, js_ValueToSource)\n\n/*\n * Convert a value to a string, returning null after reporting an error,\n * otherwise returning a new string reference.\n */\nextern JS_FRIEND_API(JSString *)\njs_ValueToString(JSContext *cx, jsval v);\n\n/*\n * Convert a value to its source expression, returning null after reporting\n * an error, otherwise returning a new string reference.\n */\nextern JS_FRIEND_API(JSString *)\njs_ValueToSource(JSContext *cx, jsval v);\n\n/*\n * Compute a hash function from str. The caller can call this function even if\n * str is not a GC-allocated thing.\n */\nextern uint32\njs_HashString(JSString *str);\n\n/*\n * Test if strings are equal. The caller can call the function even if str1\n * or str2 are not GC-allocated things.\n */\nextern JSBool JS_FASTCALL\njs_EqualStrings(JSString *str1, JSString *str2);\n\n/*\n * Return less than, equal to, or greater than zero depending on whether\n * str1 is less than, equal to, or greater than str2.\n */\nextern int32 JS_FASTCALL\njs_CompareStrings(JSString *str1, JSString *str2);\n\n/*\n * Boyer-Moore-Horspool superlinear search for pat:patlen in text:textlen.\n * The patlen argument must be positive and no greater than BMH_PATLEN_MAX.\n * The start argument tells where in text to begin the search.\n *\n * Return the index of pat in text, or -1 if not found.\n */\n#define BMH_CHARSET_SIZE 256 /* ISO-Latin-1 */\n#define BMH_PATLEN_MAX 255 /* skip table element is uint8 */\n\n#define BMH_BAD_PATTERN (-2) /* return value if pat is not ISO-Latin-1 */\n\nextern jsint\njs_BoyerMooreHorspool(const jschar *text, jsint textlen,\n const jschar *pat, jsint patlen,\n jsint start);\n\nextern size_t\njs_strlen(const jschar *s);\n\nextern jschar *\njs_strchr(const jschar *s, jschar c);\n\nextern jschar *\njs_strchr_limit(const jschar *s, jschar c, const jschar *limit);\n\n#define js_strncpy(t, s, n) memcpy((t), (s), (n) * sizeof(jschar))\n\n/*\n * Return s advanced past any Unicode white space characters.\n */\nextern const jschar *\njs_SkipWhiteSpace(const jschar *s, const jschar *end);\n\n/*\n * Inflate bytes to JS chars and vice versa. Report out of memory via cx\n * and return null on error, otherwise return the jschar or byte vector that\n * was JS_malloc'ed. length is updated with the length of the new string in jschars.\n */\nextern jschar *\njs_InflateString(JSContext *cx, const char *bytes, size_t *length);\n\nextern char *\njs_DeflateString(JSContext *cx, const jschar *chars, size_t length);\n\n/*\n * Inflate bytes to JS chars into a buffer. 'chars' must be large enough for\n * 'length' jschars. The buffer is NOT null-terminated. The destination length\n * must be be initialized with the buffer size and will contain on return the\n * number of copied chars.\n */\nextern JSBool\njs_InflateStringToBuffer(JSContext* cx, const char *bytes, size_t length,\n jschar *chars, size_t* charsLength);\n\n/*\n * Get number of bytes in the deflated sequence of characters.\n */\nextern size_t\njs_GetDeflatedStringLength(JSContext *cx, const jschar *chars,\n size_t charsLength);\n\n/*\n * Deflate JS chars to bytes into a buffer. 'bytes' must be large enough for\n * 'length chars. The buffer is NOT null-terminated. The destination length\n * must to be initialized with the buffer size and will contain on return the\n * number of copied bytes.\n */\nextern JSBool\njs_DeflateStringToBuffer(JSContext* cx, const jschar *chars,\n size_t charsLength, char *bytes, size_t* length);\n\n/*\n * Associate bytes with str in the deflated string cache, returning true on\n * successful association, false on out of memory.\n */\nextern JSBool\njs_SetStringBytes(JSContext *cx, JSString *str, char *bytes, size_t length);\n\n/*\n * Find or create a deflated string cache entry for str that contains its\n * characters chopped from Unicode code points into bytes.\n */\nextern const char *\njs_GetStringBytes(JSContext *cx, JSString *str);\n\n/* Remove a deflated string cache entry associated with str if any. */\nextern void\njs_PurgeDeflatedStringCache(JSRuntime *rt, JSString *str);\n\n/* Export a few natives and a helper to other files in SpiderMonkey. */\nextern JSBool\njs_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,\n jsval *rval);\n\nextern JSBool\njs_StringMatchHelper(JSContext *cx, uintN argc, jsval *vp, jsbytecode *pc);\n\nextern JSBool\njs_StringReplaceHelper(JSContext *cx, uintN argc, JSObject *lambda,\n JSString *repstr, jsval *vp);\n\n/*\n * Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at\n * least 6 bytes long. Return the number of UTF-8 bytes of data written.\n */\nextern int\njs_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char);\n\n/*\n * Write str into buffer escaping any non-printable or non-ASCII character.\n * Guarantees that a NUL is at the end of the buffer. Returns the length of\n * the written output, NOT including the NUL. If buffer is null, just returns\n * the length of the output. If quote is not 0, it must be a single or double\n * quote character that will quote the output.\n *\n * The function is only defined for debug builds.\n*/\n#define js_PutEscapedString(buffer, bufferSize, str, quote) \\\n js_PutEscapedStringImpl(buffer, bufferSize, NULL, str, quote)\n\n/*\n * Write str into file escaping any non-printable or non-ASCII character.\n * Returns the number of bytes written to file. If quote is not 0, it must\n * be a single or double quote character that will quote the output.\n *\n * The function is only defined for debug builds.\n*/\n#define js_FileEscapedString(file, str, quote) \\\n (JS_ASSERT(file), js_PutEscapedStringImpl(NULL, 0, file, str, quote))\n\nextern JS_FRIEND_API(size_t)\njs_PutEscapedStringImpl(char *buffer, size_t bufferSize, FILE *fp,\n JSString *str, uint32 quote);\n\nJS_END_EXTERN_C\n\n#endif /* jsstr_h___ */\n"}
+{"text": ",\n Tassilo Philipp \n\n Permission to use, copy, modify, and distribute this software for any\n purpose with or without fee is hereby granted, provided that the above\n copyright notice and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n*/\n\n#define d double\nvoid d40(\n d,d,d,d,\n d,d,d,d,\n d,d,d,d,\n d,d,d,d,\n d,d,d,d,\n d,d,d,d,\n d,d,d,d,\n d,d,d,d,\n d,d,d,d,\n d,d,d,d\n);\nvoid t()\n{\n\td40(\n\t0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,\n\t0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19\n\t);\t\n}\n"}
+{"text": "// license:BSD-3-Clause\n// copyright-holders:Juergen Buchmueller\n/*****************************************************************************\n *\n * Xerox AltoII cursor task (CURT)\n *\n *****************************************************************************/\n#ifdef ALTO2_DEFINE_CONSTANTS\n\n#else // ALTO2_DEFINE_CONSTANTS\n#ifndef MAME_CPU_ALTO2_A2CURT_H\n#define MAME_CPU_ALTO2_A2CURT_H\n\n//! F2 functions for cursor task\nenum {\n\tf2_curt_load_xpreg = f2_task_10, //!< f2 10: load x position register\n\tf2_curt_load_csr = f2_task_11 //!< f2 11: load cursor shift register\n};\n\nvoid f1_early_curt_block(); //!< f1_curt_block early: disable the cursor task and set the curt_blocks flag\nvoid f2_late_load_xpreg(); //!< f2_load_xpreg late: load the x position register from BUS[6-15]\nvoid f2_late_load_csr(); //!< f2_load_csr late: load the cursor shift register from BUS[0-15]\nvoid activate_curt(); //!< curt_activate: called by the CPU when the cursor task becomes active\nvoid init_curt(int task = task_curt); //!< initialize cursor task\nvoid exit_curt(); //!< deinitialize cursor task\nvoid reset_curt(); //!< reset cursor task\n#endif // MAME_CPU_A2CURT_H\n#endif // ALTO2_DEFINE_CONSTANTS\n"}
+{"text": "#!/usr/bin/env bash\n\nset -e\necho \"\" > coverage.txt\n\nfor d in $(go list ./... | grep -v vendor); do\n go test -coverprofile=profile.out -coverpkg=github.com/modern-go/concurrent $d\n if [ -f profile.out ]; then\n cat profile.out >> coverage.txt\n rm profile.out\n fi\ndone\n"}
+{"text": "var baseInRange = require('./_baseInRange'),\n toFinite = require('./toFinite'),\n toNumber = require('./toNumber');\n\n/**\n * Checks if `n` is between `start` and up to, but not including, `end`. If\n * `end` is not specified, it's set to `start` with `start` then set to `0`.\n * If `start` is greater than `end` the params are swapped to support\n * negative ranges.\n *\n * @static\n * @memberOf _\n * @since 3.3.0\n * @category Number\n * @param {number} number The number to check.\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n * @see _.range, _.rangeRight\n * @example\n *\n * _.inRange(3, 2, 4);\n * // => true\n *\n * _.inRange(4, 8);\n * // => true\n *\n * _.inRange(4, 2);\n * // => false\n *\n * _.inRange(2, 2);\n * // => false\n *\n * _.inRange(1.2, 2);\n * // => true\n *\n * _.inRange(5.2, 4);\n * // => false\n *\n * _.inRange(-3, -2, -6);\n * // => true\n */\nfunction inRange(number, start, end) {\n start = toFinite(start);\n if (end === undefined) {\n end = start;\n start = 0;\n } else {\n end = toFinite(end);\n }\n number = toNumber(number);\n return baseInRange(number, start, end);\n}\n\nmodule.exports = inRange;\n"}
+{"text": "using System.Threading.Tasks;\r\nusing ICSharpCode.CodeConverter.Tests.TestRunners;\r\nusing ICSharpCode.CodeConverter.VB;\r\nusing Xunit;\r\nusing static ICSharpCode.CodeConverter.CommandLine.CodeConvProgram;\r\n\r\nnamespace ICSharpCode.CodeConverter.Tests.VB\r\n{\r\n /// \r\n /// for info on how these tests work.\r\n /// \r\n [Collection(MultiFileTestFixture.Collection)]\r\n public class MultiFileSolutionAndProjectTests\r\n {\r\n private readonly MultiFileTestFixture _multiFileTestFixture;\r\n\r\n public MultiFileSolutionAndProjectTests(MultiFileTestFixture multiFileTestFixture)\r\n {\r\n _multiFileTestFixture = multiFileTestFixture;\r\n }\r\n\r\n [Fact]\r\n public async Task ConvertWholeSolutionAsync()\r\n {\r\n await _multiFileTestFixture.ConvertProjectsWhereAsync(p => true, Language.VB);\r\n }\r\n\r\n [Fact]\r\n public async Task ConvertCSharpConsoleAppOnlyAsync()\r\n {\r\n await _multiFileTestFixture.ConvertProjectsWhereAsync(p => p.Name == \"CSharpConsoleApp\", Language.VB);\r\n }\r\n }\r\n}\r\n"}
+{"text": "// -*- c++ -*-\n#ifndef LIBUSB_WRAPPERS_H\n#define LIBUSB_WRAPPERS_H\n\n#include \n#include \n\nclass LIBUSBError : public std::exception {\npublic:\n\tconst libusb_error rawError;\n\n\tLIBUSBError(libusb_error error)\n\t\t: rawError(error)\n\t{}\n\n\tvirtual const char *what() const throw() {\n\t\treturn libusb_error_name(rawError);\n\t}\n};\n\ninline void LIBUSBHandleError(int ret) throw (LIBUSBError) {\n\tlibusb_error rawError = (libusb_error) ret;\n\tthrow LIBUSBError(rawError);\n}\n\ntemplate \ninline T LIBUSBCheckResult(T value) throw (LIBUSBError) {\n\tif (value < 0)\n\t\tLIBUSBHandleError(value);\n\treturn value;\n}\n\nclass USBDevice {\n\tlibusb_device *mDevice;\n\npublic:\n\tUSBDevice()\n\t{\n\t}\n\n\tUSBDevice(libusb_device *dev)\n\t\t: mDevice(dev)\n\t{\n\t\tlibusb_ref_device(mDevice);\n\t}\n\n\tUSBDevice& operator=(const USBDevice& other) {\n\t\tif (other.mDevice == mDevice)\n\t\t\treturn *this;\n\n\t\tif (mDevice)\n\t\t\tlibusb_unref_device(mDevice);\n\n\t\tmDevice = libusb_ref_device(other.mDevice);\n\t\treturn *this;\n\t}\n\n\tvirtual ~USBDevice() {\n\t\tif (mDevice)\n\t\t\tlibusb_unref_device(mDevice);\n\t}\n\n\tUSBDevice(const USBDevice& other)\n\t\t: mDevice(libusb_ref_device(other.mDevice))\n\t{}\n\n\toperator libusb_device*() const {\n\t\treturn mDevice;\n\t}\n};\n\nclass USBDeviceHandle {\n\tlibusb_device_handle *mDeviceHandle;\n\n\tUSBDeviceHandle(libusb_device_handle *handle);\n\npublic:\n\tUSBDeviceHandle(libusb_device *dev) throw (LIBUSBError)\n\t{\n\t\tLIBUSBCheckResult(libusb_open(dev, &mDeviceHandle));\n\t}\n\n\tvirtual ~USBDeviceHandle() {\n\t\tlibusb_close(mDeviceHandle);\n\t}\n\n\toperator libusb_device_handle*() {\n\t\treturn mDeviceHandle;\n\t}\n};\n\n#endif\n"}
+{"text": "import torch\nimport torch.nn as nn\n\n\nclass BalanceCrossEntropyLoss(nn.Module):\n '''\n Balanced cross entropy loss.\n Shape:\n - Input: :math:`(N, 1, H, W)`\n - GT: :math:`(N, 1, H, W)`, same shape as the input\n - Mask: :math:`(N, H, W)`, same spatial shape as the input\n - Output: scalar.\n\n Examples::\n\n >>> m = nn.Sigmoid()\n >>> loss = nn.BCELoss()\n >>> input = torch.randn(3, requires_grad=True)\n >>> target = torch.empty(3).random_(2)\n >>> output = loss(m(input), target)\n >>> output.backward()\n '''\n\n def __init__(self, negative_ratio=3.0, eps=1e-6):\n super(BalanceCrossEntropyLoss, self).__init__()\n self.negative_ratio = negative_ratio\n self.eps = eps\n\n def forward(self,\n pred: torch.Tensor,\n gt: torch.Tensor,\n mask: torch.Tensor,\n return_origin=False):\n '''\n Args:\n pred: shape :math:`(N, 1, H, W)`, the prediction of network\n gt: shape :math:`(N, 1, H, W)`, the target\n mask: shape :math:`(N, H, W)`, the mask indicates positive regions\n '''\n positive = (gt * mask).byte()\n negative = ((1 - gt) * mask).byte()\n positive_count = int(positive.float().sum())\n negative_count = min(int(negative.float().sum()),\n int(positive_count * self.negative_ratio))\n loss = nn.functional.binary_cross_entropy(\n pred, gt, reduction='none')[:, 0, :, :]\n positive_loss = loss * positive.float()\n negative_loss = loss * negative.float()\n negative_loss, _ = torch.topk(negative_loss.view(-1), negative_count)\n\n balance_loss = (positive_loss.sum() + negative_loss.sum()) /\\\n (positive_count + negative_count + self.eps)\n\n if return_origin:\n return balance_loss, loss\n return balance_loss\n"}
+{"text": "// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights\n// reserved. Use of this source code is governed by a BSD-style license that\n// can be found in the LICENSE file.\n//\n// ---------------------------------------------------------------------------\n//\n// This file was generated by the CEF translator tool. If making changes by\n// hand only do so within the body of existing method and function\n// implementations. See the translator.README.txt file in the tools directory\n// for more information.\n//\n\n#include \"libcef_dll/ctocpp/auth_callback_ctocpp.h\"\n\n\n// VIRTUAL METHODS - Body may be edited by hand.\n\nvoid CefAuthCallbackCToCpp::Continue(const CefString& username,\n const CefString& password) {\n cef_auth_callback_t* _struct = GetStruct();\n if (CEF_MEMBER_MISSING(_struct, cont))\n return;\n\n // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING\n\n // Verify param: username; type: string_byref_const\n DCHECK(!username.empty());\n if (username.empty())\n return;\n // Verify param: password; type: string_byref_const\n DCHECK(!password.empty());\n if (password.empty())\n return;\n\n // Execute\n _struct->cont(_struct,\n username.GetStruct(),\n password.GetStruct());\n}\n\nvoid CefAuthCallbackCToCpp::Cancel() {\n cef_auth_callback_t* _struct = GetStruct();\n if (CEF_MEMBER_MISSING(_struct, cancel))\n return;\n\n // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING\n\n // Execute\n _struct->cancel(_struct);\n}\n\n\n// CONSTRUCTOR - Do not edit by hand.\n\nCefAuthCallbackCToCpp::CefAuthCallbackCToCpp() {\n}\n\ntemplate<> cef_auth_callback_t* CefCToCppRefCounted::UnwrapDerived(CefWrapperType type,\n CefAuthCallback* c) {\n NOTREACHED() << \"Unexpected class type: \" << type;\n return NULL;\n}\n\n#if DCHECK_IS_ON()\ntemplate<> base::AtomicRefCount CefCToCppRefCounted::DebugObjCt = 0;\n#endif\n\ntemplate<> CefWrapperType CefCToCppRefCounted::kWrapperType = WT_AUTH_CALLBACK;\n"}
+{"text": "42\nhello world\n5\n4\n3\n2\n1\nhello\nworld\n0\n"}
+{"text": "19\n comment:c\nC 1.7711771 1.9985000 0.6137610\nC -1.4146240 1.1372570 -1.2290050\nC -1.3621570 -0.1783360 -1.0396900\nC 1.9153720 -1.0550430 0.3013840\nC 2.3186500 -0.1271630 -0.5674850\nC 1.9434890 1.2969980 -0.5093410\nH 2.2358899 -2.0890679 0.2130410\nH 2.9541740 -0.4216600 -1.4024709\nH -1.2646140 -0.8704770 -1.8708260\nH -1.3355780 1.5694309 -2.2223461\nH 1.2397890 -0.8231110 1.1220030\nH 1.9521750 1.5559500 1.5915630\nH 1.8173510 1.7989070 -1.4693830\nH 1.4881300 3.0475571 0.5894880\nH -1.5660650 1.8414670 -0.4130180\nC -1.5330120 -0.8416660 0.2877910\nO -1.1943340 -0.1112680 1.3777530\nH -0.6833450 0.6649400 1.0976650\nO -1.9665550 -1.9574890 0.4038710\n"}
+{"text": "\n/* pngwutil.c - utilities to write a PNG file\n *\n * Last changed in libpng 1.2.9 April 14, 2006\n * For conditions of distribution and use, see copyright notice in png.h\n * Copyright (c) 1998-2006 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n */\n\n#define PNG_INTERNAL\n#include \"png.h\"\n#ifdef PNG_WRITE_SUPPORTED\n\n/* Place a 32-bit number into a buffer in PNG byte order. We work\n * with unsigned numbers for convenience, although one supported\n * ancillary chunk uses signed (two's complement) numbers.\n */\nvoid PNGAPI\npng_save_uint_32(png_bytep buf, png_uint_32 i)\n{\n buf[0] = (png_byte)((i >> 24) & 0xff);\n buf[1] = (png_byte)((i >> 16) & 0xff);\n buf[2] = (png_byte)((i >> 8) & 0xff);\n buf[3] = (png_byte)(i & 0xff);\n}\n\n/* The png_save_int_32 function assumes integers are stored in two's\n * complement format. If this isn't the case, then this routine needs to\n * be modified to write data in two's complement format.\n */\nvoid PNGAPI\npng_save_int_32(png_bytep buf, png_int_32 i)\n{\n buf[0] = (png_byte)((i >> 24) & 0xff);\n buf[1] = (png_byte)((i >> 16) & 0xff);\n buf[2] = (png_byte)((i >> 8) & 0xff);\n buf[3] = (png_byte)(i & 0xff);\n}\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\nvoid PNGAPI\npng_save_uint_16(png_bytep buf, unsigned int i)\n{\n buf[0] = (png_byte)((i >> 8) & 0xff);\n buf[1] = (png_byte)(i & 0xff);\n}\n\n/* Write a PNG chunk all at once. The type is an array of ASCII characters\n * representing the chunk name. The array must be at least 4 bytes in\n * length, and does not need to be null terminated. To be safe, pass the\n * pre-defined chunk names here, and if you need a new one, define it\n * where the others are defined. The length is the length of the data.\n * All the data must be present. If that is not possible, use the\n * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()\n * functions instead.\n */\nvoid PNGAPI\npng_write_chunk(png_structp png_ptr, png_bytep chunk_name,\n png_bytep data, png_size_t length)\n{\n png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);\n png_write_chunk_data(png_ptr, data, length);\n png_write_chunk_end(png_ptr);\n}\n\n/* Write the start of a PNG chunk. The type is the chunk type.\n * The total_length is the sum of the lengths of all the data you will be\n * passing in png_write_chunk_data().\n */\nvoid PNGAPI\npng_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,\n png_uint_32 length)\n{\n png_byte buf[4];\n png_debug2(0, \"Writing %s chunk (%lu bytes)\\n\", chunk_name, length);\n\n /* write the length */\n png_save_uint_32(buf, length);\n png_write_data(png_ptr, buf, (png_size_t)4);\n\n /* write the chunk name */\n png_write_data(png_ptr, chunk_name, (png_size_t)4);\n /* reset the crc and run it over the chunk name */\n png_reset_crc(png_ptr);\n png_calculate_crc(png_ptr, chunk_name, (png_size_t)4);\n}\n\n/* Write the data of a PNG chunk started with png_write_chunk_start().\n * Note that multiple calls to this function are allowed, and that the\n * sum of the lengths from these calls *must* add up to the total_length\n * given to png_write_chunk_start().\n */\nvoid PNGAPI\npng_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n /* write the data, and run the CRC over it */\n if (data != NULL && length > 0)\n {\n png_calculate_crc(png_ptr, data, length);\n png_write_data(png_ptr, data, length);\n }\n}\n\n/* Finish a chunk started with png_write_chunk_start(). */\nvoid PNGAPI\npng_write_chunk_end(png_structp png_ptr)\n{\n png_byte buf[4];\n\n /* write the crc */\n png_save_uint_32(buf, png_ptr->crc);\n\n png_write_data(png_ptr, buf, (png_size_t)4);\n}\n\n/* Simple function to write the signature. If we have already written\n * the magic bytes of the signature, or more likely, the PNG stream is\n * being embedded into another stream and doesn't need its own signature,\n * we should call png_set_sig_bytes() to tell libpng how many of the\n * bytes have already been written.\n */\nvoid /* PRIVATE */\npng_write_sig(png_structp png_ptr)\n{\n png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};\n /* write the rest of the 8 byte signature */\n png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],\n (png_size_t)8 - png_ptr->sig_bytes);\n if(png_ptr->sig_bytes < 3)\n png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;\n}\n\n#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED)\n/*\n * This pair of functions encapsulates the operation of (a) compressing a\n * text string, and (b) issuing it later as a series of chunk data writes.\n * The compression_state structure is shared context for these functions\n * set up by the caller in order to make the whole mess thread-safe.\n */\n\ntypedef struct\n{\n char *input; /* the uncompressed input data */\n int input_len; /* its length */\n int num_output_ptr; /* number of output pointers used */\n int max_output_ptr; /* size of output_ptr */\n png_charpp output_ptr; /* array of pointers to output */\n} compression_state;\n\n/* compress given text into storage in the png_ptr structure */\nstatic int /* PRIVATE */\npng_text_compress(png_structp png_ptr,\n png_charp text, png_size_t text_len, int compression,\n compression_state *comp)\n{\n int ret;\n\n comp->num_output_ptr = 0;\n comp->max_output_ptr = 0;\n comp->output_ptr = NULL;\n comp->input = NULL;\n comp->input_len = 0;\n\n /* we may just want to pass the text right through */\n if (compression == PNG_TEXT_COMPRESSION_NONE)\n {\n comp->input = text;\n comp->input_len = text_len;\n return((int)text_len);\n }\n\n if (compression >= PNG_TEXT_COMPRESSION_LAST)\n {\n#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)\n char msg[50];\n sprintf(msg, \"Unknown compression type %d\", compression);\n png_warning(png_ptr, msg);\n#else\n png_warning(png_ptr, \"Unknown compression type\");\n#endif\n }\n\n /* We can't write the chunk until we find out how much data we have,\n * which means we need to run the compressor first and save the\n * output. This shouldn't be a problem, as the vast majority of\n * comments should be reasonable, but we will set up an array of\n * malloc'd pointers to be sure.\n *\n * If we knew the application was well behaved, we could simplify this\n * greatly by assuming we can always malloc an output buffer large\n * enough to hold the compressed text ((1001 * text_len / 1000) + 12)\n * and malloc this directly. The only time this would be a bad idea is\n * if we can't malloc more than 64K and we have 64K of random input\n * data, or if the input string is incredibly large (although this\n * wouldn't cause a failure, just a slowdown due to swapping).\n */\n\n /* set up the compression buffers */\n png_ptr->zstream.avail_in = (uInt)text_len;\n png_ptr->zstream.next_in = (Bytef *)text;\n png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;\n\n /* this is the same compression loop as in png_write_row() */\n do\n {\n /* compress the data */\n ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);\n if (ret != Z_OK)\n {\n /* error */\n if (png_ptr->zstream.msg != NULL)\n png_error(png_ptr, png_ptr->zstream.msg);\n else\n png_error(png_ptr, \"zlib error\");\n }\n /* check to see if we need more room */\n if (!(png_ptr->zstream.avail_out))\n {\n /* make sure the output array has room */\n if (comp->num_output_ptr >= comp->max_output_ptr)\n {\n int old_max;\n\n old_max = comp->max_output_ptr;\n comp->max_output_ptr = comp->num_output_ptr + 4;\n if (comp->output_ptr != NULL)\n {\n png_charpp old_ptr;\n\n old_ptr = comp->output_ptr;\n comp->output_ptr = (png_charpp)png_malloc(png_ptr,\n (png_uint_32)(comp->max_output_ptr *\n png_sizeof (png_charpp)));\n png_memcpy(comp->output_ptr, old_ptr, old_max\n * png_sizeof (png_charp));\n png_free(png_ptr, old_ptr);\n }\n else\n comp->output_ptr = (png_charpp)png_malloc(png_ptr,\n (png_uint_32)(comp->max_output_ptr *\n png_sizeof (png_charp)));\n }\n\n /* save the data */\n comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr,\n (png_uint_32)png_ptr->zbuf_size);\n png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,\n png_ptr->zbuf_size);\n comp->num_output_ptr++;\n\n /* and reset the buffer */\n png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n png_ptr->zstream.next_out = png_ptr->zbuf;\n }\n /* continue until we don't have any more to compress */\n } while (png_ptr->zstream.avail_in);\n\n /* finish the compression */\n do\n {\n /* tell zlib we are finished */\n ret = deflate(&png_ptr->zstream, Z_FINISH);\n\n if (ret == Z_OK)\n {\n /* check to see if we need more room */\n if (!(png_ptr->zstream.avail_out))\n {\n /* check to make sure our output array has room */\n if (comp->num_output_ptr >= comp->max_output_ptr)\n {\n int old_max;\n\n old_max = comp->max_output_ptr;\n comp->max_output_ptr = comp->num_output_ptr + 4;\n if (comp->output_ptr != NULL)\n {\n png_charpp old_ptr;\n\n old_ptr = comp->output_ptr;\n /* This could be optimized to realloc() */\n comp->output_ptr = (png_charpp)png_malloc(png_ptr,\n (png_uint_32)(comp->max_output_ptr *\n png_sizeof (png_charpp)));\n png_memcpy(comp->output_ptr, old_ptr,\n old_max * png_sizeof (png_charp));\n png_free(png_ptr, old_ptr);\n }\n else\n comp->output_ptr = (png_charpp)png_malloc(png_ptr,\n (png_uint_32)(comp->max_output_ptr *\n png_sizeof (png_charp)));\n }\n\n /* save off the data */\n comp->output_ptr[comp->num_output_ptr] =\n (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size);\n png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,\n png_ptr->zbuf_size);\n comp->num_output_ptr++;\n\n /* and reset the buffer pointers */\n png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n png_ptr->zstream.next_out = png_ptr->zbuf;\n }\n }\n else if (ret != Z_STREAM_END)\n {\n /* we got an error */\n if (png_ptr->zstream.msg != NULL)\n png_error(png_ptr, png_ptr->zstream.msg);\n else\n png_error(png_ptr, \"zlib error\");\n }\n } while (ret != Z_STREAM_END);\n\n /* text length is number of buffers plus last buffer */\n text_len = png_ptr->zbuf_size * comp->num_output_ptr;\n if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)\n text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out;\n\n return((int)text_len);\n}\n\n/* ship the compressed text out via chunk writes */\nstatic void /* PRIVATE */\npng_write_compressed_data_out(png_structp png_ptr, compression_state *comp)\n{\n int i;\n\n /* handle the no-compression case */\n if (comp->input)\n {\n png_write_chunk_data(png_ptr, (png_bytep)comp->input,\n (png_size_t)comp->input_len);\n return;\n }\n\n /* write saved output buffers, if any */\n for (i = 0; i < comp->num_output_ptr; i++)\n {\n png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i],\n png_ptr->zbuf_size);\n png_free(png_ptr, comp->output_ptr[i]);\n comp->output_ptr[i]=NULL;\n }\n if (comp->max_output_ptr != 0)\n png_free(png_ptr, comp->output_ptr);\n comp->output_ptr=NULL;\n /* write anything left in zbuf */\n if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)\n png_write_chunk_data(png_ptr, png_ptr->zbuf,\n png_ptr->zbuf_size - png_ptr->zstream.avail_out);\n\n /* reset zlib for another zTXt/iTXt or image data */\n deflateReset(&png_ptr->zstream);\n png_ptr->zstream.data_type = Z_BINARY;\n}\n#endif\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information. Note that the rest of this code depends upon this\n * information being correct.\n */\nvoid /* PRIVATE */\npng_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,\n int bit_depth, int color_type, int compression_type, int filter_type,\n int interlace_type)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_IHDR;\n#endif\n png_byte buf[13]; /* buffer to store the IHDR info */\n\n png_debug(1, \"in png_write_IHDR\\n\");\n /* Check that we have valid input data from the application info */\n switch (color_type)\n {\n case PNG_COLOR_TYPE_GRAY:\n switch (bit_depth)\n {\n case 1:\n case 2:\n case 4:\n case 8:\n case 16: png_ptr->channels = 1; break;\n default: png_error(png_ptr,\"Invalid bit depth for grayscale image\");\n }\n break;\n case PNG_COLOR_TYPE_RGB:\n if (bit_depth != 8 && bit_depth != 16)\n png_error(png_ptr, \"Invalid bit depth for RGB image\");\n png_ptr->channels = 3;\n break;\n case PNG_COLOR_TYPE_PALETTE:\n switch (bit_depth)\n {\n case 1:\n case 2:\n case 4:\n case 8: png_ptr->channels = 1; break;\n default: png_error(png_ptr, \"Invalid bit depth for paletted image\");\n }\n break;\n case PNG_COLOR_TYPE_GRAY_ALPHA:\n if (bit_depth != 8 && bit_depth != 16)\n png_error(png_ptr, \"Invalid bit depth for grayscale+alpha image\");\n png_ptr->channels = 2;\n break;\n case PNG_COLOR_TYPE_RGB_ALPHA:\n if (bit_depth != 8 && bit_depth != 16)\n png_error(png_ptr, \"Invalid bit depth for RGBA image\");\n png_ptr->channels = 4;\n break;\n default:\n png_error(png_ptr, \"Invalid image color type specified\");\n }\n\n if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n {\n png_warning(png_ptr, \"Invalid compression type specified\");\n compression_type = PNG_COMPRESSION_TYPE_BASE;\n }\n\n /* Write filter_method 64 (intrapixel differencing) only if\n * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and\n * 2. Libpng did not write a PNG signature (this filter_method is only\n * used in PNG datastreams that are embedded in MNG datastreams) and\n * 3. The application called png_permit_mng_features with a mask that\n * included PNG_FLAG_MNG_FILTER_64 and\n * 4. The filter_method is 64 and\n * 5. The color_type is RGB or RGBA\n */\n if (\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&\n (color_type == PNG_COLOR_TYPE_RGB ||\n color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&\n (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&\n#endif\n filter_type != PNG_FILTER_TYPE_BASE)\n {\n png_warning(png_ptr, \"Invalid filter type specified\");\n filter_type = PNG_FILTER_TYPE_BASE;\n }\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n if (interlace_type != PNG_INTERLACE_NONE &&\n interlace_type != PNG_INTERLACE_ADAM7)\n {\n png_warning(png_ptr, \"Invalid interlace type specified\");\n interlace_type = PNG_INTERLACE_ADAM7;\n }\n#else\n interlace_type=PNG_INTERLACE_NONE;\n#endif\n\n /* save off the relevent information */\n png_ptr->bit_depth = (png_byte)bit_depth;\n png_ptr->color_type = (png_byte)color_type;\n png_ptr->interlaced = (png_byte)interlace_type;\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n png_ptr->filter_type = (png_byte)filter_type;\n#endif\n png_ptr->compression_type = (png_byte)compression_type;\n png_ptr->width = width;\n png_ptr->height = height;\n\n png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);\n png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);\n /* set the usr info, so any transformations can modify it */\n png_ptr->usr_width = png_ptr->width;\n png_ptr->usr_bit_depth = png_ptr->bit_depth;\n png_ptr->usr_channels = png_ptr->channels;\n\n /* pack the header information into the buffer */\n png_save_uint_32(buf, width);\n png_save_uint_32(buf + 4, height);\n buf[8] = (png_byte)bit_depth;\n buf[9] = (png_byte)color_type;\n buf[10] = (png_byte)compression_type;\n buf[11] = (png_byte)filter_type;\n buf[12] = (png_byte)interlace_type;\n\n /* write the chunk */\n png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);\n\n /* initialize zlib with PNG info */\n png_ptr->zstream.zalloc = png_zalloc;\n png_ptr->zstream.zfree = png_zfree;\n png_ptr->zstream.opaque = (voidpf)png_ptr;\n if (!(png_ptr->do_filter))\n {\n if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||\n png_ptr->bit_depth < 8)\n png_ptr->do_filter = PNG_FILTER_NONE;\n else\n png_ptr->do_filter = PNG_ALL_FILTERS;\n }\n if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY))\n {\n if (png_ptr->do_filter != PNG_FILTER_NONE)\n png_ptr->zlib_strategy = Z_FILTERED;\n else\n png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY;\n }\n if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL))\n png_ptr->zlib_level = Z_DEFAULT_COMPRESSION;\n if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL))\n png_ptr->zlib_mem_level = 8;\n if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS))\n png_ptr->zlib_window_bits = 15;\n if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))\n png_ptr->zlib_method = 8;\n deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,\n png_ptr->zlib_method, png_ptr->zlib_window_bits,\n png_ptr->zlib_mem_level, png_ptr->zlib_strategy);\n png_ptr->zstream.next_out = png_ptr->zbuf;\n png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n /* libpng is not interested in zstream.data_type */\n /* set it to a predefined value, to avoid its evaluation inside zlib */\n png_ptr->zstream.data_type = Z_BINARY;\n\n png_ptr->mode = PNG_HAVE_IHDR;\n}\n\n/* write the palette. We are careful not to trust png_color to be in the\n * correct order for PNG, so people can redefine it to any convenient\n * structure.\n */\nvoid /* PRIVATE */\npng_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_PLTE;\n#endif\n png_uint_32 i;\n png_colorp pal_ptr;\n png_byte buf[3];\n\n png_debug(1, \"in png_write_PLTE\\n\");\n if ((\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&\n#endif\n num_pal == 0) || num_pal > 256)\n {\n if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n {\n png_error(png_ptr, \"Invalid number of colors in palette\");\n }\n else\n {\n png_warning(png_ptr, \"Invalid number of colors in palette\");\n return;\n }\n }\n\n if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))\n {\n png_warning(png_ptr,\n \"Ignoring request to write a PLTE chunk in grayscale PNG\");\n return;\n }\n\n png_ptr->num_palette = (png_uint_16)num_pal;\n png_debug1(3, \"num_palette = %d\\n\", png_ptr->num_palette);\n\n png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3);\n#ifndef PNG_NO_POINTER_INDEXING\n for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)\n {\n buf[0] = pal_ptr->red;\n buf[1] = pal_ptr->green;\n buf[2] = pal_ptr->blue;\n png_write_chunk_data(png_ptr, buf, (png_size_t)3);\n }\n#else\n /* This is a little slower but some buggy compilers need to do this instead */\n pal_ptr=palette;\n for (i = 0; i < num_pal; i++)\n {\n buf[0] = pal_ptr[i].red;\n buf[1] = pal_ptr[i].green;\n buf[2] = pal_ptr[i].blue;\n png_write_chunk_data(png_ptr, buf, (png_size_t)3);\n }\n#endif\n png_write_chunk_end(png_ptr);\n png_ptr->mode |= PNG_HAVE_PLTE;\n}\n\n/* write an IDAT chunk */\nvoid /* PRIVATE */\npng_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_IDAT;\n#endif\n png_debug(1, \"in png_write_IDAT\\n\");\n\n /* Optimize the CMF field in the zlib stream. */\n /* This hack of the zlib stream is compliant to the stream specification. */\n if (!(png_ptr->mode & PNG_HAVE_IDAT) &&\n png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)\n {\n unsigned int z_cmf = data[0]; /* zlib compression method and flags */\n if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)\n {\n /* Avoid memory underflows and multiplication overflows. */\n /* The conditions below are practically always satisfied;\n however, they still must be checked. */\n if (length >= 2 &&\n png_ptr->height < 16384 && png_ptr->width < 16384)\n {\n png_uint_32 uncompressed_idat_size = png_ptr->height *\n ((png_ptr->width *\n png_ptr->channels * png_ptr->bit_depth + 15) >> 3);\n unsigned int z_cinfo = z_cmf >> 4;\n unsigned int half_z_window_size = 1 << (z_cinfo + 7);\n while (uncompressed_idat_size <= half_z_window_size &&\n half_z_window_size >= 256)\n {\n z_cinfo--;\n half_z_window_size >>= 1;\n }\n z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);\n if (data[0] != (png_byte)z_cmf)\n {\n data[0] = (png_byte)z_cmf;\n data[1] &= 0xe0;\n data[1] += (png_byte)(0x1f - ((z_cmf << 8) + data[1]) % 0x1f);\n }\n }\n }\n else\n png_error(png_ptr,\n \"Invalid zlib compression method or flags in IDAT\");\n }\n\n png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);\n png_ptr->mode |= PNG_HAVE_IDAT;\n}\n\n/* write an IEND chunk */\nvoid /* PRIVATE */\npng_write_IEND(png_structp png_ptr)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_IEND;\n#endif\n png_debug(1, \"in png_write_IEND\\n\");\n png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,\n (png_size_t)0);\n png_ptr->mode |= PNG_HAVE_IEND;\n}\n\n#if defined(PNG_WRITE_gAMA_SUPPORTED)\n/* write a gAMA chunk */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid /* PRIVATE */\npng_write_gAMA(png_structp png_ptr, double file_gamma)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_gAMA;\n#endif\n png_uint_32 igamma;\n png_byte buf[4];\n\n png_debug(1, \"in png_write_gAMA\\n\");\n /* file_gamma is saved in 1/100,000ths */\n igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);\n png_save_uint_32(buf, igamma);\n png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);\n}\n#endif\n#ifdef PNG_FIXED_POINT_SUPPORTED\nvoid /* PRIVATE */\npng_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_gAMA;\n#endif\n png_byte buf[4];\n\n png_debug(1, \"in png_write_gAMA\\n\");\n /* file_gamma is saved in 1/100,000ths */\n png_save_uint_32(buf, (png_uint_32)file_gamma);\n png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);\n}\n#endif\n#endif\n\n#if defined(PNG_WRITE_sRGB_SUPPORTED)\n/* write a sRGB chunk */\nvoid /* PRIVATE */\npng_write_sRGB(png_structp png_ptr, int srgb_intent)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_sRGB;\n#endif\n png_byte buf[1];\n\n png_debug(1, \"in png_write_sRGB\\n\");\n if(srgb_intent >= PNG_sRGB_INTENT_LAST)\n png_warning(png_ptr,\n \"Invalid sRGB rendering intent specified\");\n buf[0]=(png_byte)srgb_intent;\n png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1);\n}\n#endif\n\n#if defined(PNG_WRITE_iCCP_SUPPORTED)\n/* write an iCCP chunk */\nvoid /* PRIVATE */\npng_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,\n png_charp profile, int profile_len)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_iCCP;\n#endif\n png_size_t name_len;\n png_charp new_name;\n compression_state comp;\n\n png_debug(1, \"in png_write_iCCP\\n\");\n\n comp.num_output_ptr = 0;\n comp.max_output_ptr = 0;\n comp.output_ptr = NULL;\n comp.input = NULL;\n comp.input_len = 0;\n\n if (name == NULL || (name_len = png_check_keyword(png_ptr, name,\n &new_name)) == 0)\n {\n png_warning(png_ptr, \"Empty keyword in iCCP chunk\");\n return;\n }\n\n if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n png_warning(png_ptr, \"Unknown compression type in iCCP chunk\");\n\n if (profile == NULL)\n profile_len = 0;\n\n if (profile_len)\n profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,\n PNG_COMPRESSION_TYPE_BASE, &comp);\n\n /* make sure we include the NULL after the name and the compression type */\n png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,\n (png_uint_32)name_len+profile_len+2);\n new_name[name_len+1]=0x00;\n png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);\n\n if (profile_len)\n png_write_compressed_data_out(png_ptr, &comp);\n\n png_write_chunk_end(png_ptr);\n png_free(png_ptr, new_name);\n}\n#endif\n\n#if defined(PNG_WRITE_sPLT_SUPPORTED)\n/* write a sPLT chunk */\nvoid /* PRIVATE */\npng_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_sPLT;\n#endif\n png_size_t name_len;\n png_charp new_name;\n png_byte entrybuf[10];\n int entry_size = (spalette->depth == 8 ? 6 : 10);\n int palette_size = entry_size * spalette->nentries;\n png_sPLT_entryp ep;\n#ifdef PNG_NO_POINTER_INDEXING\n int i;\n#endif\n\n png_debug(1, \"in png_write_sPLT\\n\");\n if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr,\n spalette->name, &new_name))==0)\n {\n png_warning(png_ptr, \"Empty keyword in sPLT chunk\");\n return;\n }\n\n /* make sure we include the NULL after the name */\n png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,\n (png_uint_32)(name_len + 2 + palette_size));\n png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);\n png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);\n\n /* loop through each palette entry, writing appropriately */\n#ifndef PNG_NO_POINTER_INDEXING\n for (ep = spalette->entries; epentries+spalette->nentries; ep++)\n {\n if (spalette->depth == 8)\n {\n entrybuf[0] = (png_byte)ep->red;\n entrybuf[1] = (png_byte)ep->green;\n entrybuf[2] = (png_byte)ep->blue;\n entrybuf[3] = (png_byte)ep->alpha;\n png_save_uint_16(entrybuf + 4, ep->frequency);\n }\n else\n {\n png_save_uint_16(entrybuf + 0, ep->red);\n png_save_uint_16(entrybuf + 2, ep->green);\n png_save_uint_16(entrybuf + 4, ep->blue);\n png_save_uint_16(entrybuf + 6, ep->alpha);\n png_save_uint_16(entrybuf + 8, ep->frequency);\n }\n png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);\n }\n#else\n ep=spalette->entries;\n for (i=0; i>spalette->nentries; i++)\n {\n if (spalette->depth == 8)\n {\n entrybuf[0] = (png_byte)ep[i].red;\n entrybuf[1] = (png_byte)ep[i].green;\n entrybuf[2] = (png_byte)ep[i].blue;\n entrybuf[3] = (png_byte)ep[i].alpha;\n png_save_uint_16(entrybuf + 4, ep[i].frequency);\n }\n else\n {\n png_save_uint_16(entrybuf + 0, ep[i].red);\n png_save_uint_16(entrybuf + 2, ep[i].green);\n png_save_uint_16(entrybuf + 4, ep[i].blue);\n png_save_uint_16(entrybuf + 6, ep[i].alpha);\n png_save_uint_16(entrybuf + 8, ep[i].frequency);\n }\n png_write_chunk_data(png_ptr, entrybuf, entry_size);\n }\n#endif\n\n png_write_chunk_end(png_ptr);\n png_free(png_ptr, new_name);\n}\n#endif\n\n#if defined(PNG_WRITE_sBIT_SUPPORTED)\n/* write the sBIT chunk */\nvoid /* PRIVATE */\npng_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_sBIT;\n#endif\n png_byte buf[4];\n png_size_t size;\n\n png_debug(1, \"in png_write_sBIT\\n\");\n /* make sure we don't depend upon the order of PNG_COLOR_8 */\n if (color_type & PNG_COLOR_MASK_COLOR)\n {\n png_byte maxbits;\n\n maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 :\n png_ptr->usr_bit_depth);\n if (sbit->red == 0 || sbit->red > maxbits ||\n sbit->green == 0 || sbit->green > maxbits ||\n sbit->blue == 0 || sbit->blue > maxbits)\n {\n png_warning(png_ptr, \"Invalid sBIT depth specified\");\n return;\n }\n buf[0] = sbit->red;\n buf[1] = sbit->green;\n buf[2] = sbit->blue;\n size = 3;\n }\n else\n {\n if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth)\n {\n png_warning(png_ptr, \"Invalid sBIT depth specified\");\n return;\n }\n buf[0] = sbit->gray;\n size = 1;\n }\n\n if (color_type & PNG_COLOR_MASK_ALPHA)\n {\n if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)\n {\n png_warning(png_ptr, \"Invalid sBIT depth specified\");\n return;\n }\n buf[size++] = sbit->alpha;\n }\n\n png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size);\n}\n#endif\n\n#if defined(PNG_WRITE_cHRM_SUPPORTED)\n/* write the cHRM chunk */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid /* PRIVATE */\npng_write_cHRM(png_structp png_ptr, double white_x, double white_y,\n double red_x, double red_y, double green_x, double green_y,\n double blue_x, double blue_y)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_cHRM;\n#endif\n png_byte buf[32];\n png_uint_32 itemp;\n\n png_debug(1, \"in png_write_cHRM\\n\");\n /* each value is saved in 1/100,000ths */\n if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 ||\n white_x + white_y > 1.0)\n {\n png_warning(png_ptr, \"Invalid cHRM white point specified\");\n#if !defined(PNG_NO_CONSOLE_IO)\n fprintf(stderr,\"white_x=%f, white_y=%f\\n\",white_x, white_y);\n#endif\n return;\n }\n itemp = (png_uint_32)(white_x * 100000.0 + 0.5);\n png_save_uint_32(buf, itemp);\n itemp = (png_uint_32)(white_y * 100000.0 + 0.5);\n png_save_uint_32(buf + 4, itemp);\n\n if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0)\n {\n png_warning(png_ptr, \"Invalid cHRM red point specified\");\n return;\n }\n itemp = (png_uint_32)(red_x * 100000.0 + 0.5);\n png_save_uint_32(buf + 8, itemp);\n itemp = (png_uint_32)(red_y * 100000.0 + 0.5);\n png_save_uint_32(buf + 12, itemp);\n\n if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0)\n {\n png_warning(png_ptr, \"Invalid cHRM green point specified\");\n return;\n }\n itemp = (png_uint_32)(green_x * 100000.0 + 0.5);\n png_save_uint_32(buf + 16, itemp);\n itemp = (png_uint_32)(green_y * 100000.0 + 0.5);\n png_save_uint_32(buf + 20, itemp);\n\n if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0)\n {\n png_warning(png_ptr, \"Invalid cHRM blue point specified\");\n return;\n }\n itemp = (png_uint_32)(blue_x * 100000.0 + 0.5);\n png_save_uint_32(buf + 24, itemp);\n itemp = (png_uint_32)(blue_y * 100000.0 + 0.5);\n png_save_uint_32(buf + 28, itemp);\n\n png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);\n}\n#endif\n#ifdef PNG_FIXED_POINT_SUPPORTED\nvoid /* PRIVATE */\npng_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,\n png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y,\n png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x,\n png_fixed_point blue_y)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_cHRM;\n#endif\n png_byte buf[32];\n\n png_debug(1, \"in png_write_cHRM\\n\");\n /* each value is saved in 1/100,000ths */\n if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L)\n {\n png_warning(png_ptr, \"Invalid fixed cHRM white point specified\");\n#if !defined(PNG_NO_CONSOLE_IO)\n fprintf(stderr,\"white_x=%ld, white_y=%ld\\n\",white_x, white_y);\n#endif\n return;\n }\n png_save_uint_32(buf, (png_uint_32)white_x);\n png_save_uint_32(buf + 4, (png_uint_32)white_y);\n\n if (red_x + red_y > 100000L)\n {\n png_warning(png_ptr, \"Invalid cHRM fixed red point specified\");\n return;\n }\n png_save_uint_32(buf + 8, (png_uint_32)red_x);\n png_save_uint_32(buf + 12, (png_uint_32)red_y);\n\n if (green_x + green_y > 100000L)\n {\n png_warning(png_ptr, \"Invalid fixed cHRM green point specified\");\n return;\n }\n png_save_uint_32(buf + 16, (png_uint_32)green_x);\n png_save_uint_32(buf + 20, (png_uint_32)green_y);\n\n if (blue_x + blue_y > 100000L)\n {\n png_warning(png_ptr, \"Invalid fixed cHRM blue point specified\");\n return;\n }\n png_save_uint_32(buf + 24, (png_uint_32)blue_x);\n png_save_uint_32(buf + 28, (png_uint_32)blue_y);\n\n png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);\n}\n#endif\n#endif\n\n#if defined(PNG_WRITE_tRNS_SUPPORTED)\n/* write the tRNS chunk */\nvoid /* PRIVATE */\npng_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,\n int num_trans, int color_type)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_tRNS;\n#endif\n png_byte buf[6];\n\n png_debug(1, \"in png_write_tRNS\\n\");\n if (color_type == PNG_COLOR_TYPE_PALETTE)\n {\n if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)\n {\n png_warning(png_ptr,\"Invalid number of transparent colors specified\");\n return;\n }\n /* write the chunk out as it is */\n png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans);\n }\n else if (color_type == PNG_COLOR_TYPE_GRAY)\n {\n /* one 16 bit value */\n if(tran->gray >= (1 << png_ptr->bit_depth))\n {\n png_warning(png_ptr,\n \"Ignoring attempt to write tRNS chunk out-of-range for bit_depth\");\n return;\n }\n png_save_uint_16(buf, tran->gray);\n png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);\n }\n else if (color_type == PNG_COLOR_TYPE_RGB)\n {\n /* three 16 bit values */\n png_save_uint_16(buf, tran->red);\n png_save_uint_16(buf + 2, tran->green);\n png_save_uint_16(buf + 4, tran->blue);\n if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))\n {\n png_warning(png_ptr,\n \"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8\");\n return;\n }\n png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);\n }\n else\n {\n png_warning(png_ptr, \"Can't write tRNS with an alpha channel\");\n }\n}\n#endif\n\n#if defined(PNG_WRITE_bKGD_SUPPORTED)\n/* write the background chunk */\nvoid /* PRIVATE */\npng_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_bKGD;\n#endif\n png_byte buf[6];\n\n png_debug(1, \"in png_write_bKGD\\n\");\n if (color_type == PNG_COLOR_TYPE_PALETTE)\n {\n if (\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n (png_ptr->num_palette ||\n (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&\n#endif\n back->index > png_ptr->num_palette)\n {\n png_warning(png_ptr, \"Invalid background palette index\");\n return;\n }\n buf[0] = back->index;\n png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1);\n }\n else if (color_type & PNG_COLOR_MASK_COLOR)\n {\n png_save_uint_16(buf, back->red);\n png_save_uint_16(buf + 2, back->green);\n png_save_uint_16(buf + 4, back->blue);\n if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))\n {\n png_warning(png_ptr,\n \"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8\");\n return;\n }\n png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6);\n }\n else\n {\n if(back->gray >= (1 << png_ptr->bit_depth))\n {\n png_warning(png_ptr,\n \"Ignoring attempt to write bKGD chunk out-of-range for bit_depth\");\n return;\n }\n png_save_uint_16(buf, back->gray);\n png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2);\n }\n}\n#endif\n\n#if defined(PNG_WRITE_hIST_SUPPORTED)\n/* write the histogram */\nvoid /* PRIVATE */\npng_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_hIST;\n#endif\n int i;\n png_byte buf[3];\n\n png_debug(1, \"in png_write_hIST\\n\");\n if (num_hist > (int)png_ptr->num_palette)\n {\n png_debug2(3, \"num_hist = %d, num_palette = %d\\n\", num_hist,\n png_ptr->num_palette);\n png_warning(png_ptr, \"Invalid number of histogram entries specified\");\n return;\n }\n\n png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2));\n for (i = 0; i < num_hist; i++)\n {\n png_save_uint_16(buf, hist[i]);\n png_write_chunk_data(png_ptr, buf, (png_size_t)2);\n }\n png_write_chunk_end(png_ptr);\n}\n#endif\n\n#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \\\n defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)\n/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,\n * and if invalid, correct the keyword rather than discarding the entire\n * chunk. The PNG 1.0 specification requires keywords 1-79 characters in\n * length, forbids leading or trailing whitespace, multiple internal spaces,\n * and the non-break space (0x80) from ISO 8859-1. Returns keyword length.\n *\n * The new_key is allocated to hold the corrected keyword and must be freed\n * by the calling routine. This avoids problems with trying to write to\n * static keywords without having to have duplicate copies of the strings.\n */\npng_size_t /* PRIVATE */\npng_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)\n{\n png_size_t key_len;\n png_charp kp, dp;\n int kflag;\n int kwarn=0;\n\n png_debug(1, \"in png_check_keyword\\n\");\n *new_key = NULL;\n\n if (key == NULL || (key_len = png_strlen(key)) == 0)\n {\n png_warning(png_ptr, \"zero length keyword\");\n return ((png_size_t)0);\n }\n\n png_debug1(2, \"Keyword to be checked is '%s'\\n\", key);\n\n *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2));\n if (*new_key == NULL)\n {\n png_warning(png_ptr, \"Out of memory while procesing keyword\");\n return ((png_size_t)0);\n }\n\n /* Replace non-printing characters with a blank and print a warning */\n for (kp = key, dp = *new_key; *kp != '\\0'; kp++, dp++)\n {\n if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1))\n {\n#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)\n char msg[40];\n\n sprintf(msg, \"invalid keyword character 0x%02X\", *kp);\n png_warning(png_ptr, msg);\n#else\n png_warning(png_ptr, \"invalid character in keyword\");\n#endif\n *dp = ' ';\n }\n else\n {\n *dp = *kp;\n }\n }\n *dp = '\\0';\n\n /* Remove any trailing white space. */\n kp = *new_key + key_len - 1;\n if (*kp == ' ')\n {\n png_warning(png_ptr, \"trailing spaces removed from keyword\");\n\n while (*kp == ' ')\n {\n *(kp--) = '\\0';\n key_len--;\n }\n }\n\n /* Remove any leading white space. */\n kp = *new_key;\n if (*kp == ' ')\n {\n png_warning(png_ptr, \"leading spaces removed from keyword\");\n\n while (*kp == ' ')\n {\n kp++;\n key_len--;\n }\n }\n\n png_debug1(2, \"Checking for multiple internal spaces in '%s'\\n\", kp);\n\n /* Remove multiple internal spaces. */\n for (kflag = 0, dp = *new_key; *kp != '\\0'; kp++)\n {\n if (*kp == ' ' && kflag == 0)\n {\n *(dp++) = *kp;\n kflag = 1;\n }\n else if (*kp == ' ')\n {\n key_len--;\n kwarn=1;\n }\n else\n {\n *(dp++) = *kp;\n kflag = 0;\n }\n }\n *dp = '\\0';\n if(kwarn)\n png_warning(png_ptr, \"extra interior spaces removed from keyword\");\n\n if (key_len == 0)\n {\n png_free(png_ptr, *new_key);\n *new_key=NULL;\n png_warning(png_ptr, \"Zero length keyword\");\n }\n\n if (key_len > 79)\n {\n png_warning(png_ptr, \"keyword length must be 1 - 79 characters\");\n new_key[79] = '\\0';\n key_len = 79;\n }\n\n return (key_len);\n}\n#endif\n\n#if defined(PNG_WRITE_tEXt_SUPPORTED)\n/* write a tEXt chunk */\nvoid /* PRIVATE */\npng_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,\n png_size_t text_len)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_tEXt;\n#endif\n png_size_t key_len;\n png_charp new_key;\n\n png_debug(1, \"in png_write_tEXt\\n\");\n if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)\n {\n png_warning(png_ptr, \"Empty keyword in tEXt chunk\");\n return;\n }\n\n if (text == NULL || *text == '\\0')\n text_len = 0;\n else\n text_len = png_strlen(text);\n\n /* make sure we include the 0 after the key */\n png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1);\n /*\n * We leave it to the application to meet PNG-1.0 requirements on the\n * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of\n * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.\n * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.\n */\n png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);\n if (text_len)\n png_write_chunk_data(png_ptr, (png_bytep)text, text_len);\n\n png_write_chunk_end(png_ptr);\n png_free(png_ptr, new_key);\n}\n#endif\n\n#if defined(PNG_WRITE_zTXt_SUPPORTED)\n/* write a compressed text chunk */\nvoid /* PRIVATE */\npng_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,\n png_size_t text_len, int compression)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_zTXt;\n#endif\n png_size_t key_len;\n char buf[1];\n png_charp new_key;\n compression_state comp;\n\n png_debug(1, \"in png_write_zTXt\\n\");\n\n comp.num_output_ptr = 0;\n comp.max_output_ptr = 0;\n comp.output_ptr = NULL;\n comp.input = NULL;\n comp.input_len = 0;\n\n if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)\n {\n png_warning(png_ptr, \"Empty keyword in zTXt chunk\");\n return;\n }\n\n if (text == NULL || *text == '\\0' || compression==PNG_TEXT_COMPRESSION_NONE)\n {\n png_write_tEXt(png_ptr, new_key, text, (png_size_t)0);\n png_free(png_ptr, new_key);\n return;\n }\n\n text_len = png_strlen(text);\n\n png_free(png_ptr, new_key);\n\n /* compute the compressed data; do it now for the length */\n text_len = png_text_compress(png_ptr, text, text_len, compression,\n &comp);\n\n /* write start of chunk */\n png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)\n (key_len+text_len+2));\n /* write key */\n png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1);\n buf[0] = (png_byte)compression;\n /* write compression */\n png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);\n /* write the compressed data */\n png_write_compressed_data_out(png_ptr, &comp);\n\n /* close the chunk */\n png_write_chunk_end(png_ptr);\n}\n#endif\n\n#if defined(PNG_WRITE_iTXt_SUPPORTED)\n/* write an iTXt chunk */\nvoid /* PRIVATE */\npng_write_iTXt(png_structp png_ptr, int compression, png_charp key,\n png_charp lang, png_charp lang_key, png_charp text)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_iTXt;\n#endif\n png_size_t lang_len, key_len, lang_key_len, text_len;\n png_charp new_lang, new_key;\n png_byte cbuf[2];\n compression_state comp;\n\n png_debug(1, \"in png_write_iTXt\\n\");\n\n comp.num_output_ptr = 0;\n comp.max_output_ptr = 0;\n comp.output_ptr = NULL;\n comp.input = NULL;\n\n if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)\n {\n png_warning(png_ptr, \"Empty keyword in iTXt chunk\");\n return;\n }\n if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0)\n {\n png_warning(png_ptr, \"Empty language field in iTXt chunk\");\n new_lang = NULL;\n lang_len = 0;\n }\n\n if (lang_key == NULL)\n lang_key_len = 0;\n else\n lang_key_len = png_strlen(lang_key);\n\n if (text == NULL)\n text_len = 0;\n else\n text_len = png_strlen(text);\n\n /* compute the compressed data; do it now for the length */\n text_len = png_text_compress(png_ptr, text, text_len, compression-2,\n &comp);\n\n\n /* make sure we include the compression flag, the compression byte,\n * and the NULs after the key, lang, and lang_key parts */\n\n png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,\n (png_uint_32)(\n 5 /* comp byte, comp flag, terminators for key, lang and lang_key */\n + key_len\n + lang_len\n + lang_key_len\n + text_len));\n\n /*\n * We leave it to the application to meet PNG-1.0 requirements on the\n * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of\n * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.\n * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.\n */\n png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);\n\n /* set the compression flag */\n if (compression == PNG_ITXT_COMPRESSION_NONE || \\\n compression == PNG_TEXT_COMPRESSION_NONE)\n cbuf[0] = 0;\n else /* compression == PNG_ITXT_COMPRESSION_zTXt */\n cbuf[0] = 1;\n /* set the compression method */\n cbuf[1] = 0;\n png_write_chunk_data(png_ptr, cbuf, 2);\n\n cbuf[0] = 0;\n png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1);\n png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1);\n png_write_compressed_data_out(png_ptr, &comp);\n\n png_write_chunk_end(png_ptr);\n png_free(png_ptr, new_key);\n if (new_lang)\n png_free(png_ptr, new_lang);\n}\n#endif\n\n#if defined(PNG_WRITE_oFFs_SUPPORTED)\n/* write the oFFs chunk */\nvoid /* PRIVATE */\npng_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,\n int unit_type)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_oFFs;\n#endif\n png_byte buf[9];\n\n png_debug(1, \"in png_write_oFFs\\n\");\n if (unit_type >= PNG_OFFSET_LAST)\n png_warning(png_ptr, \"Unrecognized unit type for oFFs chunk\");\n\n png_save_int_32(buf, x_offset);\n png_save_int_32(buf + 4, y_offset);\n buf[8] = (png_byte)unit_type;\n\n png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);\n}\n#endif\n\n#if defined(PNG_WRITE_pCAL_SUPPORTED)\n/* write the pCAL chunk (described in the PNG extensions document) */\nvoid /* PRIVATE */\npng_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,\n png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_pCAL;\n#endif\n png_size_t purpose_len, units_len, total_len;\n png_uint_32p params_len;\n png_byte buf[10];\n png_charp new_purpose;\n int i;\n\n png_debug1(1, \"in png_write_pCAL (%d parameters)\\n\", nparams);\n if (type >= PNG_EQUATION_LAST)\n png_warning(png_ptr, \"Unrecognized equation type for pCAL chunk\");\n\n purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1;\n png_debug1(3, \"pCAL purpose length = %d\\n\", (int)purpose_len);\n units_len = png_strlen(units) + (nparams == 0 ? 0 : 1);\n png_debug1(3, \"pCAL units length = %d\\n\", (int)units_len);\n total_len = purpose_len + units_len + 10;\n\n params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams\n *png_sizeof(png_uint_32)));\n\n /* Find the length of each parameter, making sure we don't count the\n null terminator for the last parameter. */\n for (i = 0; i < nparams; i++)\n {\n params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1);\n png_debug2(3, \"pCAL parameter %d length = %lu\\n\", i, params_len[i]);\n total_len += (png_size_t)params_len[i];\n }\n\n png_debug1(3, \"pCAL total length = %d\\n\", (int)total_len);\n png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);\n png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);\n png_save_int_32(buf, X0);\n png_save_int_32(buf + 4, X1);\n buf[8] = (png_byte)type;\n buf[9] = (png_byte)nparams;\n png_write_chunk_data(png_ptr, buf, (png_size_t)10);\n png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len);\n\n png_free(png_ptr, new_purpose);\n\n for (i = 0; i < nparams; i++)\n {\n png_write_chunk_data(png_ptr, (png_bytep)params[i],\n (png_size_t)params_len[i]);\n }\n\n png_free(png_ptr, params_len);\n png_write_chunk_end(png_ptr);\n}\n#endif\n\n#if defined(PNG_WRITE_sCAL_SUPPORTED)\n/* write the sCAL chunk */\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)\nvoid /* PRIVATE */\npng_write_sCAL(png_structp png_ptr, int unit, double width,double height)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_sCAL;\n#endif\n png_size_t total_len;\n char wbuf[32], hbuf[32];\n png_byte bunit = (png_byte)unit;\n\n png_debug(1, \"in png_write_sCAL\\n\");\n\n#if defined(_WIN32_WCE)\n/* sprintf() function is not supported on WindowsCE */\n {\n wchar_t wc_buf[32];\n swprintf(wc_buf, TEXT(\"%12.12e\"), width);\n WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, wbuf, 32, NULL, NULL);\n swprintf(wc_buf, TEXT(\"%12.12e\"), height);\n WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, hbuf, 32, NULL, NULL);\n }\n#else\n sprintf(wbuf, \"%12.12e\", width);\n sprintf(hbuf, \"%12.12e\", height);\n#endif\n total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);\n\n png_debug1(3, \"sCAL total length = %d\\n\", (int)total_len);\n png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);\n png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1);\n png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);\n png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));\n\n png_write_chunk_end(png_ptr);\n}\n#else\n#ifdef PNG_FIXED_POINT_SUPPORTED\nvoid /* PRIVATE */\npng_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,\n png_charp height)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_sCAL;\n#endif\n png_size_t total_len;\n char wbuf[32], hbuf[32];\n png_byte bunit = unit;\n\n png_debug(1, \"in png_write_sCAL_s\\n\");\n\n png_strcpy(wbuf,(const char *)width);\n png_strcpy(hbuf,(const char *)height);\n total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);\n\n png_debug1(3, \"sCAL total length = %d\\n\", total_len);\n png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);\n png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1);\n png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);\n png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));\n\n png_write_chunk_end(png_ptr);\n}\n#endif\n#endif\n#endif\n\n#if defined(PNG_WRITE_pHYs_SUPPORTED)\n/* write the pHYs chunk */\nvoid /* PRIVATE */\npng_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,\n png_uint_32 y_pixels_per_unit,\n int unit_type)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_pHYs;\n#endif\n png_byte buf[9];\n\n png_debug(1, \"in png_write_pHYs\\n\");\n if (unit_type >= PNG_RESOLUTION_LAST)\n png_warning(png_ptr, \"Unrecognized unit type for pHYs chunk\");\n\n png_save_uint_32(buf, x_pixels_per_unit);\n png_save_uint_32(buf + 4, y_pixels_per_unit);\n buf[8] = (png_byte)unit_type;\n\n png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9);\n}\n#endif\n\n#if defined(PNG_WRITE_tIME_SUPPORTED)\n/* Write the tIME chunk. Use either png_convert_from_struct_tm()\n * or png_convert_from_time_t(), or fill in the structure yourself.\n */\nvoid /* PRIVATE */\npng_write_tIME(png_structp png_ptr, png_timep mod_time)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n PNG_tIME;\n#endif\n png_byte buf[7];\n\n png_debug(1, \"in png_write_tIME\\n\");\n if (mod_time->month > 12 || mod_time->month < 1 ||\n mod_time->day > 31 || mod_time->day < 1 ||\n mod_time->hour > 23 || mod_time->second > 60)\n {\n png_warning(png_ptr, \"Invalid time specified for tIME chunk\");\n return;\n }\n\n png_save_uint_16(buf, mod_time->year);\n buf[2] = mod_time->month;\n buf[3] = mod_time->day;\n buf[4] = mod_time->hour;\n buf[5] = mod_time->minute;\n buf[6] = mod_time->second;\n\n png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7);\n}\n#endif\n\n/* initializes the row writing capability of libpng */\nvoid /* PRIVATE */\npng_write_start_row(png_structp png_ptr)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n /* start of interlace block */\n int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n /* offset to next interlace block */\n int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n /* start of interlace block in the y direction */\n int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n /* offset to next interlace block in the y direction */\n int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n png_size_t buf_size;\n\n png_debug(1, \"in png_write_start_row\\n\");\n buf_size = (png_size_t)(PNG_ROWBYTES(\n png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1);\n\n /* set up row buffer */\n png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);\n png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;\n\n /* set up filtering buffer, if using this filter */\n if (png_ptr->do_filter & PNG_FILTER_SUB)\n {\n png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,\n (png_ptr->rowbytes + 1));\n png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;\n }\n\n /* We only need to keep the previous row if we are using one of these. */\n if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))\n {\n /* set up previous row buffer */\n png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);\n png_memset(png_ptr->prev_row, 0, buf_size);\n\n if (png_ptr->do_filter & PNG_FILTER_UP)\n {\n png_ptr->up_row = (png_bytep )png_malloc(png_ptr,\n (png_ptr->rowbytes + 1));\n png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;\n }\n\n if (png_ptr->do_filter & PNG_FILTER_AVG)\n {\n png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,\n (png_ptr->rowbytes + 1));\n png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;\n }\n\n if (png_ptr->do_filter & PNG_FILTER_PAETH)\n {\n png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,\n (png_ptr->rowbytes + 1));\n png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;\n }\n }\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n /* if interlaced, we need to set up width and height of pass */\n if (png_ptr->interlaced)\n {\n if (!(png_ptr->transformations & PNG_INTERLACE))\n {\n png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -\n png_pass_ystart[0]) / png_pass_yinc[0];\n png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 -\n png_pass_start[0]) / png_pass_inc[0];\n }\n else\n {\n png_ptr->num_rows = png_ptr->height;\n png_ptr->usr_width = png_ptr->width;\n }\n }\n else\n#endif\n {\n png_ptr->num_rows = png_ptr->height;\n png_ptr->usr_width = png_ptr->width;\n }\n png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n png_ptr->zstream.next_out = png_ptr->zbuf;\n}\n\n/* Internal use only. Called when finished processing a row of data. */\nvoid /* PRIVATE */\npng_write_finish_row(png_structp png_ptr)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n /* start of interlace block */\n int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n /* offset to next interlace block */\n int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n /* start of interlace block in the y direction */\n int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n /* offset to next interlace block in the y direction */\n int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n int ret;\n\n png_debug(1, \"in png_write_finish_row\\n\");\n /* next row */\n png_ptr->row_number++;\n\n /* see if we are done */\n if (png_ptr->row_number < png_ptr->num_rows)\n return;\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n /* if interlaced, go to next pass */\n if (png_ptr->interlaced)\n {\n png_ptr->row_number = 0;\n if (png_ptr->transformations & PNG_INTERLACE)\n {\n png_ptr->pass++;\n }\n else\n {\n /* loop until we find a non-zero width or height pass */\n do\n {\n png_ptr->pass++;\n if (png_ptr->pass >= 7)\n break;\n png_ptr->usr_width = (png_ptr->width +\n png_pass_inc[png_ptr->pass] - 1 -\n png_pass_start[png_ptr->pass]) /\n png_pass_inc[png_ptr->pass];\n png_ptr->num_rows = (png_ptr->height +\n png_pass_yinc[png_ptr->pass] - 1 -\n png_pass_ystart[png_ptr->pass]) /\n png_pass_yinc[png_ptr->pass];\n if (png_ptr->transformations & PNG_INTERLACE)\n break;\n } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);\n\n }\n\n /* reset the row above the image for the next pass */\n if (png_ptr->pass < 7)\n {\n if (png_ptr->prev_row != NULL)\n png_memset(png_ptr->prev_row, 0,\n (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*\n png_ptr->usr_bit_depth,png_ptr->width))+1);\n return;\n }\n }\n#endif\n\n /* if we get here, we've just written the last row, so we need\n to flush the compressor */\n do\n {\n /* tell the compressor we are done */\n ret = deflate(&png_ptr->zstream, Z_FINISH);\n /* check for an error */\n if (ret == Z_OK)\n {\n /* check to see if we need more room */\n if (!(png_ptr->zstream.avail_out))\n {\n png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);\n png_ptr->zstream.next_out = png_ptr->zbuf;\n png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n }\n }\n else if (ret != Z_STREAM_END)\n {\n if (png_ptr->zstream.msg != NULL)\n png_error(png_ptr, png_ptr->zstream.msg);\n else\n png_error(png_ptr, \"zlib error\");\n }\n } while (ret != Z_STREAM_END);\n\n /* write any extra space */\n if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)\n {\n png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size -\n png_ptr->zstream.avail_out);\n }\n\n deflateReset(&png_ptr->zstream);\n png_ptr->zstream.data_type = Z_BINARY;\n}\n\n#if defined(PNG_WRITE_INTERLACING_SUPPORTED)\n/* Pick out the correct pixels for the interlace pass.\n * The basic idea here is to go through the row with a source\n * pointer and a destination pointer (sp and dp), and copy the\n * correct pixels for the pass. As the row gets compacted,\n * sp will always be >= dp, so we should never overwrite anything.\n * See the default: case for the easiest code to understand.\n */\nvoid /* PRIVATE */\npng_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)\n{\n#ifdef PNG_USE_LOCAL_ARRAYS\n /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n /* start of interlace block */\n int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n /* offset to next interlace block */\n int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n#endif\n\n png_debug(1, \"in png_do_write_interlace\\n\");\n /* we don't have to do anything on the last pass (6) */\n#if defined(PNG_USELESS_TESTS_SUPPORTED)\n if (row != NULL && row_info != NULL && pass < 6)\n#else\n if (pass < 6)\n#endif\n {\n /* each pixel depth is handled separately */\n switch (row_info->pixel_depth)\n {\n case 1:\n {\n png_bytep sp;\n png_bytep dp;\n int shift;\n int d;\n int value;\n png_uint_32 i;\n png_uint_32 row_width = row_info->width;\n\n dp = row;\n d = 0;\n shift = 7;\n for (i = png_pass_start[pass]; i < row_width;\n i += png_pass_inc[pass])\n {\n sp = row + (png_size_t)(i >> 3);\n value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01;\n d |= (value << shift);\n\n if (shift == 0)\n {\n shift = 7;\n *dp++ = (png_byte)d;\n d = 0;\n }\n else\n shift--;\n\n }\n if (shift != 7)\n *dp = (png_byte)d;\n break;\n }\n case 2:\n {\n png_bytep sp;\n png_bytep dp;\n int shift;\n int d;\n int value;\n png_uint_32 i;\n png_uint_32 row_width = row_info->width;\n\n dp = row;\n shift = 6;\n d = 0;\n for (i = png_pass_start[pass]; i < row_width;\n i += png_pass_inc[pass])\n {\n sp = row + (png_size_t)(i >> 2);\n value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03;\n d |= (value << shift);\n\n if (shift == 0)\n {\n shift = 6;\n *dp++ = (png_byte)d;\n d = 0;\n }\n else\n shift -= 2;\n }\n if (shift != 6)\n *dp = (png_byte)d;\n break;\n }\n case 4:\n {\n png_bytep sp;\n png_bytep dp;\n int shift;\n int d;\n int value;\n png_uint_32 i;\n png_uint_32 row_width = row_info->width;\n\n dp = row;\n shift = 4;\n d = 0;\n for (i = png_pass_start[pass]; i < row_width;\n i += png_pass_inc[pass])\n {\n sp = row + (png_size_t)(i >> 1);\n value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f;\n d |= (value << shift);\n\n if (shift == 0)\n {\n shift = 4;\n *dp++ = (png_byte)d;\n d = 0;\n }\n else\n shift -= 4;\n }\n if (shift != 4)\n *dp = (png_byte)d;\n break;\n }\n default:\n {\n png_bytep sp;\n png_bytep dp;\n png_uint_32 i;\n png_uint_32 row_width = row_info->width;\n png_size_t pixel_bytes;\n\n /* start at the beginning */\n dp = row;\n /* find out how many bytes each pixel takes up */\n pixel_bytes = (row_info->pixel_depth >> 3);\n /* loop through the row, only looking at the pixels that\n matter */\n for (i = png_pass_start[pass]; i < row_width;\n i += png_pass_inc[pass])\n {\n /* find out where the original pixel is */\n sp = row + (png_size_t)i * pixel_bytes;\n /* move the pixel */\n if (dp != sp)\n png_memcpy(dp, sp, pixel_bytes);\n /* next pixel */\n dp += pixel_bytes;\n }\n break;\n }\n }\n /* set new row width */\n row_info->width = (row_info->width +\n png_pass_inc[pass] - 1 -\n png_pass_start[pass]) /\n png_pass_inc[pass];\n row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,\n row_info->width);\n }\n}\n#endif\n\n/* This filters the row, chooses which filter to use, if it has not already\n * been specified by the application, and then writes the row out with the\n * chosen filter.\n */\n#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)\n#define PNG_HISHIFT 10\n#define PNG_LOMASK ((png_uint_32)0xffffL)\n#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))\nvoid /* PRIVATE */\npng_write_find_filter(png_structp png_ptr, png_row_infop row_info)\n{\n png_bytep prev_row, best_row, row_buf;\n png_uint_32 mins, bpp;\n png_byte filter_to_do = png_ptr->do_filter;\n png_uint_32 row_bytes = row_info->rowbytes;\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n int num_p_filters = (int)png_ptr->num_prev_filters;\n#endif\n\n png_debug(1, \"in png_write_find_filter\\n\");\n /* find out how many bytes offset each pixel is */\n bpp = (row_info->pixel_depth + 7) >> 3;\n\n prev_row = png_ptr->prev_row;\n best_row = row_buf = png_ptr->row_buf;\n mins = PNG_MAXSUM;\n\n /* The prediction method we use is to find which method provides the\n * smallest value when summing the absolute values of the distances\n * from zero, using anything >= 128 as negative numbers. This is known\n * as the \"minimum sum of absolute differences\" heuristic. Other\n * heuristics are the \"weighted minimum sum of absolute differences\"\n * (experimental and can in theory improve compression), and the \"zlib\n * predictive\" method (not implemented yet), which does test compressions\n * of lines using different filter methods, and then chooses the\n * (series of) filter(s) that give minimum compressed data size (VERY\n * computationally expensive).\n *\n * GRR 980525: consider also\n * (1) minimum sum of absolute differences from running average (i.e.,\n * keep running sum of non-absolute differences & count of bytes)\n * [track dispersion, too? restart average if dispersion too large?]\n * (1b) minimum sum of absolute differences from sliding average, probably\n * with window size <= deflate window (usually 32K)\n * (2) minimum sum of squared differences from zero or running average\n * (i.e., ~ root-mean-square approach)\n */\n\n\n /* We don't need to test the 'no filter' case if this is the only filter\n * that has been chosen, as it doesn't actually do anything to the data.\n */\n if ((filter_to_do & PNG_FILTER_NONE) &&\n filter_to_do != PNG_FILTER_NONE)\n {\n png_bytep rp;\n png_uint_32 sum = 0;\n png_uint_32 i;\n int v;\n\n for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)\n {\n v = *rp;\n sum += (v < 128) ? v : 256 - v;\n }\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n png_uint_32 sumhi, sumlo;\n int j;\n sumlo = sum & PNG_LOMASK;\n sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */\n\n /* Reduce the sum if we match any of the previous rows */\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)\n {\n sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n /* Factor in the cost of this filter (this is here for completeness,\n * but it makes no sense to have a \"cost\" for the NONE filter, as\n * it has the minimum possible computational cost - none).\n */\n sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>\n PNG_COST_SHIFT;\n sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>\n PNG_COST_SHIFT;\n\n if (sumhi > PNG_HIMASK)\n sum = PNG_MAXSUM;\n else\n sum = (sumhi << PNG_HISHIFT) + sumlo;\n }\n#endif\n mins = sum;\n }\n\n /* sub filter */\n if (filter_to_do == PNG_FILTER_SUB)\n /* it's the only filter so no testing is needed */\n {\n png_bytep rp, lp, dp;\n png_uint_32 i;\n for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n i++, rp++, dp++)\n {\n *dp = *rp;\n }\n for (lp = row_buf + 1; i < row_bytes;\n i++, rp++, lp++, dp++)\n {\n *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n }\n best_row = png_ptr->sub_row;\n }\n\n else if (filter_to_do & PNG_FILTER_SUB)\n {\n png_bytep rp, dp, lp;\n png_uint_32 sum = 0, lmins = mins;\n png_uint_32 i;\n int v;\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n /* We temporarily increase the \"minimum sum\" by the factor we\n * would reduce the sum of this filter, so that we can do the\n * early exit comparison without scaling the sum each time.\n */\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 lmhi, lmlo;\n lmlo = lmins & PNG_LOMASK;\n lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)\n {\n lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n PNG_COST_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n PNG_COST_SHIFT;\n\n if (lmhi > PNG_HIMASK)\n lmins = PNG_MAXSUM;\n else\n lmins = (lmhi << PNG_HISHIFT) + lmlo;\n }\n#endif\n\n for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n i++, rp++, dp++)\n {\n v = *dp = *rp;\n\n sum += (v < 128) ? v : 256 - v;\n }\n for (lp = row_buf + 1; i < row_bytes;\n i++, rp++, lp++, dp++)\n {\n v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n\n sum += (v < 128) ? v : 256 - v;\n\n if (sum > lmins) /* We are already worse, don't continue. */\n break;\n }\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 sumhi, sumlo;\n sumlo = sum & PNG_LOMASK;\n sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)\n {\n sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n PNG_COST_SHIFT;\n sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n PNG_COST_SHIFT;\n\n if (sumhi > PNG_HIMASK)\n sum = PNG_MAXSUM;\n else\n sum = (sumhi << PNG_HISHIFT) + sumlo;\n }\n#endif\n\n if (sum < mins)\n {\n mins = sum;\n best_row = png_ptr->sub_row;\n }\n }\n\n /* up filter */\n if (filter_to_do == PNG_FILTER_UP)\n {\n png_bytep rp, dp, pp;\n png_uint_32 i;\n\n for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n pp = prev_row + 1; i < row_bytes;\n i++, rp++, pp++, dp++)\n {\n *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);\n }\n best_row = png_ptr->up_row;\n }\n\n else if (filter_to_do & PNG_FILTER_UP)\n {\n png_bytep rp, dp, pp;\n png_uint_32 sum = 0, lmins = mins;\n png_uint_32 i;\n int v;\n\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 lmhi, lmlo;\n lmlo = lmins & PNG_LOMASK;\n lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)\n {\n lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>\n PNG_COST_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>\n PNG_COST_SHIFT;\n\n if (lmhi > PNG_HIMASK)\n lmins = PNG_MAXSUM;\n else\n lmins = (lmhi << PNG_HISHIFT) + lmlo;\n }\n#endif\n\n for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n pp = prev_row + 1; i < row_bytes; i++)\n {\n v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n sum += (v < 128) ? v : 256 - v;\n\n if (sum > lmins) /* We are already worse, don't continue. */\n break;\n }\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 sumhi, sumlo;\n sumlo = sum & PNG_LOMASK;\n sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)\n {\n sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>\n PNG_COST_SHIFT;\n sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>\n PNG_COST_SHIFT;\n\n if (sumhi > PNG_HIMASK)\n sum = PNG_MAXSUM;\n else\n sum = (sumhi << PNG_HISHIFT) + sumlo;\n }\n#endif\n\n if (sum < mins)\n {\n mins = sum;\n best_row = png_ptr->up_row;\n }\n }\n\n /* avg filter */\n if (filter_to_do == PNG_FILTER_AVG)\n {\n png_bytep rp, dp, pp, lp;\n png_uint_32 i;\n for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n pp = prev_row + 1; i < bpp; i++)\n {\n *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);\n }\n for (lp = row_buf + 1; i < row_bytes; i++)\n {\n *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))\n & 0xff);\n }\n best_row = png_ptr->avg_row;\n }\n\n else if (filter_to_do & PNG_FILTER_AVG)\n {\n png_bytep rp, dp, pp, lp;\n png_uint_32 sum = 0, lmins = mins;\n png_uint_32 i;\n int v;\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 lmhi, lmlo;\n lmlo = lmins & PNG_LOMASK;\n lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG)\n {\n lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>\n PNG_COST_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>\n PNG_COST_SHIFT;\n\n if (lmhi > PNG_HIMASK)\n lmins = PNG_MAXSUM;\n else\n lmins = (lmhi << PNG_HISHIFT) + lmlo;\n }\n#endif\n\n for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n pp = prev_row + 1; i < bpp; i++)\n {\n v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);\n\n sum += (v < 128) ? v : 256 - v;\n }\n for (lp = row_buf + 1; i < row_bytes; i++)\n {\n v = *dp++ =\n (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);\n\n sum += (v < 128) ? v : 256 - v;\n\n if (sum > lmins) /* We are already worse, don't continue. */\n break;\n }\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 sumhi, sumlo;\n sumlo = sum & PNG_LOMASK;\n sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)\n {\n sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>\n PNG_COST_SHIFT;\n sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>\n PNG_COST_SHIFT;\n\n if (sumhi > PNG_HIMASK)\n sum = PNG_MAXSUM;\n else\n sum = (sumhi << PNG_HISHIFT) + sumlo;\n }\n#endif\n\n if (sum < mins)\n {\n mins = sum;\n best_row = png_ptr->avg_row;\n }\n }\n\n /* Paeth filter */\n if (filter_to_do == PNG_FILTER_PAETH)\n {\n png_bytep rp, dp, pp, cp, lp;\n png_uint_32 i;\n for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n pp = prev_row + 1; i < bpp; i++)\n {\n *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n }\n\n for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n {\n int a, b, c, pa, pb, pc, p;\n\n b = *pp++;\n c = *cp++;\n a = *lp++;\n\n p = b - c;\n pc = a - c;\n\n#ifdef PNG_USE_ABS\n pa = abs(p);\n pb = abs(pc);\n pc = abs(p + pc);\n#else\n pa = p < 0 ? -p : p;\n pb = pc < 0 ? -pc : pc;\n pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n\n p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n\n *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n }\n best_row = png_ptr->paeth_row;\n }\n\n else if (filter_to_do & PNG_FILTER_PAETH)\n {\n png_bytep rp, dp, pp, cp, lp;\n png_uint_32 sum = 0, lmins = mins;\n png_uint_32 i;\n int v;\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 lmhi, lmlo;\n lmlo = lmins & PNG_LOMASK;\n lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)\n {\n lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n PNG_COST_SHIFT;\n lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n PNG_COST_SHIFT;\n\n if (lmhi > PNG_HIMASK)\n lmins = PNG_MAXSUM;\n else\n lmins = (lmhi << PNG_HISHIFT) + lmlo;\n }\n#endif\n\n for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n pp = prev_row + 1; i < bpp; i++)\n {\n v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n sum += (v < 128) ? v : 256 - v;\n }\n\n for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n {\n int a, b, c, pa, pb, pc, p;\n\n b = *pp++;\n c = *cp++;\n a = *lp++;\n\n#ifndef PNG_SLOW_PAETH\n p = b - c;\n pc = a - c;\n#ifdef PNG_USE_ABS\n pa = abs(p);\n pb = abs(pc);\n pc = abs(p + pc);\n#else\n pa = p < 0 ? -p : p;\n pb = pc < 0 ? -pc : pc;\n pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n#else /* PNG_SLOW_PAETH */\n p = a + b - c;\n pa = abs(p - a);\n pb = abs(p - b);\n pc = abs(p - c);\n if (pa <= pb && pa <= pc)\n p = a;\n else if (pb <= pc)\n p = b;\n else\n p = c;\n#endif /* PNG_SLOW_PAETH */\n\n v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n\n sum += (v < 128) ? v : 256 - v;\n\n if (sum > lmins) /* We are already worse, don't continue. */\n break;\n }\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n {\n int j;\n png_uint_32 sumhi, sumlo;\n sumlo = sum & PNG_LOMASK;\n sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n for (j = 0; j < num_p_filters; j++)\n {\n if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)\n {\n sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n PNG_WEIGHT_SHIFT;\n }\n }\n\n sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n PNG_COST_SHIFT;\n sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n PNG_COST_SHIFT;\n\n if (sumhi > PNG_HIMASK)\n sum = PNG_MAXSUM;\n else\n sum = (sumhi << PNG_HISHIFT) + sumlo;\n }\n#endif\n\n if (sum < mins)\n {\n best_row = png_ptr->paeth_row;\n }\n }\n\n /* Do the actual writing of the filtered row data from the chosen filter. */\n\n png_write_filtered_row(png_ptr, best_row);\n\n#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)\n /* Save the type of filter we picked this time for future calculations */\n if (png_ptr->num_prev_filters > 0)\n {\n int j;\n for (j = 1; j < num_p_filters; j++)\n {\n png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];\n }\n png_ptr->prev_filters[j] = best_row[0];\n }\n#endif\n}\n\n\n/* Do the actual writing of a previously filtered row. */\nvoid /* PRIVATE */\npng_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)\n{\n png_debug(1, \"in png_write_filtered_row\\n\");\n png_debug1(2, \"filter = %d\\n\", filtered_row[0]);\n /* set up the zlib input buffer */\n\n png_ptr->zstream.next_in = filtered_row;\n png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1;\n /* repeat until we have compressed all the data */\n do\n {\n int ret; /* return of zlib */\n\n /* compress the data */\n ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);\n /* check for compression errors */\n if (ret != Z_OK)\n {\n if (png_ptr->zstream.msg != NULL)\n png_error(png_ptr, png_ptr->zstream.msg);\n else\n png_error(png_ptr, \"zlib error\");\n }\n\n /* see if it is time to write another IDAT */\n if (!(png_ptr->zstream.avail_out))\n {\n /* write the IDAT and reset the zlib output buffer */\n png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);\n png_ptr->zstream.next_out = png_ptr->zbuf;\n png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n }\n /* repeat until all data has been compressed */\n } while (png_ptr->zstream.avail_in);\n\n /* swap the current and previous rows */\n if (png_ptr->prev_row != NULL)\n {\n png_bytep tptr;\n\n tptr = png_ptr->prev_row;\n png_ptr->prev_row = png_ptr->row_buf;\n png_ptr->row_buf = tptr;\n }\n\n /* finish row - updates counters and flushes zlib if last row */\n png_write_finish_row(png_ptr);\n\n#if defined(PNG_WRITE_FLUSH_SUPPORTED)\n png_ptr->flush_rows++;\n\n if (png_ptr->flush_dist > 0 &&\n png_ptr->flush_rows >= png_ptr->flush_dist)\n {\n png_write_flush(png_ptr);\n }\n#endif\n}\n#endif /* PNG_WRITE_SUPPORTED */\n"}
+{"text": "simulateModel(\"Buildings.Fluid.MixingVolumes.Examples.MixingVolumePrescribedHeatFlowRate\", tolerance=1E-6, method=\"CVode\", stopTime=1.0, resultFile=\"MixingVolumePrescribedHeatFlowRate\");\nremovePlots();\ncreatePlot(id = 5,\n position = {27, 22, 400, 440},\n y = {\"vol.ports[1].m_flow\"},\n filename = \"MixingVolumePrescribedHeatFlowRate.mat\",\n range = {0.0, 1.0, 0.02, -0.02},\n autoscale = true,\n autoerase = true,\n autoreplot = true,\n grid = true,\n color = true,\n leftTitleType = 1,\n bottomTitleType = 1);\ncreatePlot(id = 5,\n position = {27, 22, 400, 143},\n y = {\"vol.heatPort.Q_flow\"},\n range = {0.0, 1.0, 100.0, -200.0},\n autoscale = true,\n autoerase = true,\n autoreplot = true,\n grid = true,\n color = true,\n subPlot = 3,\n leftTitleType = 1,\n bottomTitleType = 1);\ncreatePlot(id = 5,\n position = {27, 22, 400, 144},\n y = {\"vol.heatPort.T\"},\n range = {0.0, 1.0, 40.0, 10.0},\n autoscale = true,\n autoerase = true,\n autoreplot = true,\n grid = true,\n color = true,\n subPlot = 2,\n leftTitleType = 1,\n bottomTitleType = 1);\n"}
+{"text": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n <script type=\"text/javascript\">\n\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-7064407-3']);\n _gaq.push(['_trackPageview']);\n\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n\n</script>\n"}
+{"text": "/*\n * Wire\n * Copyright (C) 2019 Wire Swiss GmbH\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see http://www.gnu.org/licenses/.\n *\n */\n\nconst {createLogger} = require('redux-logger');\nimport {APIClient} from '@wireapp/api-client';\nimport type {TypeUtil} from '@wireapp/commons';\nimport {Account} from '@wireapp/core';\nimport Cookies, {CookiesStatic} from 'js-cookie';\nimport configureStore from 'redux-mock-store';\nimport thunk from 'redux-thunk';\n\nimport type {RootState, ThunkDispatch} from '../..//module/reducer';\nimport {ActionRoot, actionRoot} from '../../module/action/';\n\nexport interface MockStoreParameters {\n actions?: TypeUtil.RecursivePartial;\n apiClient?: TypeUtil.RecursivePartial;\n cookieStore?: CookiesStatic