diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4993f89 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "third_party/chromium/url"] + path = third_party/chromium/url + url = https://github.com/nctl144/url-chromium +[submodule "third_party/chromium/base"] + path = third_party/chromium/base + url = https://github.com/nctl144/base-chromium diff --git a/.travis.yml b/.travis.yml index a13074d..26c851e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: python -sudo: false +sudo: required branches: only: - master @@ -19,24 +19,37 @@ matrix: env: TOXENV=pypy3 - python: 3.6 env: TOXENV=py36 +dist: trusty install: - - | - if [ "$TOXENV" = "pypy" ]; then - export PYPY_VERSION="pypy-6.0.0-linux_x86_64-portable" - wget "https://bitbucket.org/squeaky/portable-pypy/downloads/${PYPY_VERSION}.tar.bz2" - tar -jxf ${PYPY_VERSION}.tar.bz2 - virtualenv --python="$PYPY_VERSION/bin/pypy" "$HOME/virtualenvs/$PYPY_VERSION" - source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate" - fi - if [ "$TOXENV" = "pypy3" ]; then - export PYPY_VERSION="pypy3.5-5.9-beta-linux_x86_64-portable" - wget "https://bitbucket.org/squeaky/portable-pypy/downloads/${PYPY_VERSION}.tar.bz2" - tar -jxf ${PYPY_VERSION}.tar.bz2 - virtualenv --python="$PYPY_VERSION/bin/pypy3" "$HOME/virtualenvs/$PYPY_VERSION" - source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate" - fi - - pip install -U pip tox Cython codecov + - | + if [ "$TOXENV" = "pypy" ]; then + export PYPY_VERSION="pypy-6.0.0-linux_x86_64-portable" + wget "https://bitbucket.org/squeaky/portable-pypy/downloads/${PYPY_VERSION}.tar.bz2" + tar -jxf ${PYPY_VERSION}.tar.bz2 + virtualenv --python="$PYPY_VERSION/bin/pypy" "$HOME/virtualenvs/$PYPY_VERSION" + source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate" + fi + if [ "$TOXENV" = "pypy3" ]; then + export PYPY_VERSION="pypy3.5-5.9-beta-linux_x86_64-portable" + wget "https://bitbucket.org/squeaky/portable-pypy/downloads/${PYPY_VERSION}.tar.bz2" + tar -jxf ${PYPY_VERSION}.tar.bz2 + virtualenv --python="$PYPY_VERSION/bin/pypy3" "$HOME/virtualenvs/$PYPY_VERSION" + source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate" + fi + - pip install -U pip tox Cython codecov +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-5 + - g++-5 +before_install: sudo apt-get update -qq script: - - tox + - sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc + - sudo unlink /usr/bin/g++ && sudo ln -s /usr/bin/g++-5 /usr/bin/g++ + - gcc --version + - g++ --version + - tox after_success: - - codecov + - codecov diff --git a/MANIFEST.in b/MANIFEST.in index 870fdbb..6f21105 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -recursive-include vendor *.cpp *.h *.cc +recursive-include third_party *.cpp *.h *.cc recursive-include scurl *.pxd *.pyx *.cpp include README.md include LICENSE diff --git a/scurl/canonicalize.cpp b/scurl/canonicalize.cpp index 8c5de29..fac6281 100644 --- a/scurl/canonicalize.cpp +++ b/scurl/canonicalize.cpp @@ -4,15 +4,15 @@ { "distutils": { "extra_compile_args": [ - "-std=gnu++0x", - "-I./vendor/gurl/", + "-std=gnu++14", + "-I./third_party/chromium/", "-fPIC", "-Ofast", "-pthread", "-w" ], "extra_link_args": [ - "-std=gnu++0x", + "-std=gnu++14", "-w" ], "include_dirs": [ diff --git a/scurl/cgurl.cpp b/scurl/cgurl.cpp index ea69aae..82e2542 100644 --- a/scurl/cgurl.cpp +++ b/scurl/cgurl.cpp @@ -4,24 +4,25 @@ { "distutils": { "depends": [ - "vendor/gurl/url/gurl.h", - "vendor/gurl/url/third_party/mozilla/url_parse.h", - "vendor/gurl/url/url_canon.h", - "vendor/gurl/url/url_canon_stdstring.h", - "vendor/gurl/url/url_constants.h", - "vendor/gurl/url/url_util.h", - "vendor/gurl/url/url_util_internal.h" + "third_party/chromium/url/gurl.h", + "third_party/chromium/url/third_party/mozilla/url_parse.h", + "third_party/chromium/url/url_canon.h", + "third_party/chromium/url/url_canon_stdstring.h", + "third_party/chromium/url/url_constants.h", + "third_party/chromium/url/url_util.h", + "third_party/chromium/url/url_util_internal.h" ], "extra_compile_args": [ - "-std=gnu++0x", - "-I./vendor/gurl/", + "-std=gnu++14", + "-I./third_party/chromium/", "-fPIC", "-Ofast", "-pthread", - "-w" + "-w", + "-DU_COMMON_IMPLEMENTATION" ], "extra_link_args": [ - "-std=gnu++0x", + "-std=gnu++14", "-w" ], "include_dirs": [ @@ -32,30 +33,35 @@ "name": "scurl.cgurl", "sources": [ "scurl/cgurl.pyx", - "vendor/gurl/base/third_party/icu/icu_utf.cc", - "vendor/gurl/base/strings/string16.cc", - "vendor/gurl/base/strings/string_piece.cc", - "vendor/gurl/base/strings/string_util.cc", - "vendor/gurl/base/strings/utf_string_conversions.cc", - "vendor/gurl/base/strings/utf_string_conversion_utils.cc", - "vendor/gurl/url/gurl.cc", - "vendor/gurl/url/url_canon_etc.cc", - "vendor/gurl/url/url_canon_filesystemurl.cc", - "vendor/gurl/url/url_canon_fileurl.cc", - "vendor/gurl/url/url_canon_host.cc", - "vendor/gurl/url/url_canon_internal.cc", - "vendor/gurl/url/url_canon_ip.cc", - "vendor/gurl/url/url_canon_mailtourl.cc", - "vendor/gurl/url/url_canon_path.cc", - "vendor/gurl/url/url_canon_pathurl.cc", - "vendor/gurl/url/url_canon_query.cc", - "vendor/gurl/url/url_canon_relative.cc", - "vendor/gurl/url/url_canon_stdstring.cc", - "vendor/gurl/url/url_canon_stdurl.cc", - "vendor/gurl/url/url_constants.cc", - "vendor/gurl/url/url_parse_file.cc", - "vendor/gurl/url/url_util.cc", - "vendor/gurl/url/third_party/mozilla/url_parse.cc" + "third_party/chromium/base/callback_internal.cc", + "third_party/chromium/base/at_exit.cc", + "third_party/chromium/base/lazy_instance_helpers.cc", + "third_party/chromium/base/strings/utf_string_conversion_utils.cc", + "third_party/chromium/base/strings/string_piece.cc", + "third_party/chromium/base/strings/string16.cc", + "third_party/chromium/base/strings/string_util.cc", + "third_party/chromium/base/strings/utf_string_conversions.cc", + "third_party/chromium/base/strings/string_util_constants.cc", + "third_party/chromium/base/third_party/icu/icu_utf.cc", + "third_party/chromium/url/gurl.cc", + "third_party/chromium/url/url_canon.cc", + "third_party/chromium/url/url_canon_etc.cc", + "third_party/chromium/url/url_canon_filesystemurl.cc", + "third_party/chromium/url/url_canon_fileurl.cc", + "third_party/chromium/url/url_canon_host.cc", + "third_party/chromium/url/url_canon_internal.cc", + "third_party/chromium/url/url_canon_ip.cc", + "third_party/chromium/url/url_canon_mailtourl.cc", + "third_party/chromium/url/url_canon_path.cc", + "third_party/chromium/url/url_canon_pathurl.cc", + "third_party/chromium/url/url_canon_query.cc", + "third_party/chromium/url/url_canon_relative.cc", + "third_party/chromium/url/url_canon_stdstring.cc", + "third_party/chromium/url/url_canon_stdurl.cc", + "third_party/chromium/url/url_constants.cc", + "third_party/chromium/url/url_parse_file.cc", + "third_party/chromium/url/url_util.cc", + "third_party/chromium/url/third_party/mozilla/url_parse.cc" ] }, "module_name": "scurl.cgurl" @@ -638,19 +644,19 @@ static CYTHON_INLINE float __PYX_NAN() { #define __PYX_HAVE__scurl__cgurl #define __PYX_HAVE_API__scurl__cgurl /* Early includes */ -#include "../vendor/gurl/url/third_party/mozilla/url_parse.h" +#include "../third_party/chromium/url/third_party/mozilla/url_parse.h" #include #include "ios" #include "new" #include "stdexcept" #include "typeinfo" #include -#include "../vendor/gurl/url/gurl.h" -#include "../vendor/gurl/url/url_constants.h" -#include "../vendor/gurl/url/url_util_internal.h" -#include "../vendor/gurl/url/url_canon_stdstring.h" -#include "../vendor/gurl/url/url_canon.h" -#include "../vendor/gurl/url/url_util.h" +#include "../third_party/chromium/url/gurl.h" +#include "../third_party/chromium/url/url_constants.h" +#include "../third_party/chromium/url/url_util_internal.h" +#include "../third_party/chromium/url/url_canon_stdstring.h" +#include "../third_party/chromium/url/url_canon.h" +#include "../third_party/chromium/url/url_util.h" #ifdef _OPENMP #include #endif /* _OPENMP */ diff --git a/scurl/chromium_gurl.pxd b/scurl/chromium_gurl.pxd index 726b0a6..86aaecd 100644 --- a/scurl/chromium_gurl.pxd +++ b/scurl/chromium_gurl.pxd @@ -3,7 +3,7 @@ from libcpp cimport bool from mozilla_url_parse cimport Component, Parsed -cdef extern from "../vendor/gurl/url/gurl.h": +cdef extern from "../third_party/chromium/url/gurl.h": cdef cppclass GURL: GURL() GURL(const string & url_string) diff --git a/scurl/chromium_url_canon.pxd b/scurl/chromium_url_canon.pxd index c2d4aac..f0b3f2e 100644 --- a/scurl/chromium_url_canon.pxd +++ b/scurl/chromium_url_canon.pxd @@ -3,7 +3,7 @@ from mozilla_url_parse cimport Component, Parsed from chromium_url_canon_stdstring cimport StdStringCanonOutput -cdef extern from "../vendor/gurl/url/url_canon.h" namespace "url": +cdef extern from "../third_party/chromium/url/url_canon.h" namespace "url": cdef cppclass CanonOutputT: pass diff --git a/scurl/chromium_url_canon_stdstring.pxd b/scurl/chromium_url_canon_stdstring.pxd index 4e65325..f9c40dd 100644 --- a/scurl/chromium_url_canon_stdstring.pxd +++ b/scurl/chromium_url_canon_stdstring.pxd @@ -1,7 +1,7 @@ from libcpp.string cimport string -cdef extern from "../vendor/gurl/url/url_canon_stdstring.h" namespace "url": +cdef extern from "../third_party/chromium/url/url_canon_stdstring.h" namespace "url": cdef cppclass StdStringCanonOutput: StdStringCanonOutput() StdStringCanonOutput(string* str) diff --git a/scurl/chromium_url_constant.pxd b/scurl/chromium_url_constant.pxd index 997e65c..7297040 100644 --- a/scurl/chromium_url_constant.pxd +++ b/scurl/chromium_url_constant.pxd @@ -5,7 +5,7 @@ from libcpp cimport bool from mozilla_url_parse cimport Component, Parsed -cdef extern from "../vendor/gurl/url/url_constants.h" namespace "url": +cdef extern from "../third_party/chromium/url/url_constants.h" namespace "url": extern const char kAboutBlankURL[]; diff --git a/scurl/chromium_url_util.pxd b/scurl/chromium_url_util.pxd index 78d820e..5ed16c4 100644 --- a/scurl/chromium_url_util.pxd +++ b/scurl/chromium_url_util.pxd @@ -5,7 +5,7 @@ from chromium_url_canon cimport CharsetConverter from chromium_url_canon_stdstring cimport StdStringCanonOutput -cdef extern from "../vendor/gurl/url/url_util.h" namespace "url": +cdef extern from "../third_party/chromium/url/url_util.h" namespace "url": cdef bool IsStandard(const char* spec, const Component& scheme) cdef bool Canonicalize(const char* spec, int spec_len, diff --git a/scurl/chromium_url_util_internal.pxd b/scurl/chromium_url_util_internal.pxd index fbebd7f..d19a5ef 100644 --- a/scurl/chromium_url_util_internal.pxd +++ b/scurl/chromium_url_util_internal.pxd @@ -3,7 +3,7 @@ from libcpp cimport bool from mozilla_url_parse cimport Component, Parsed -cdef extern from "../vendor/gurl/url/url_util_internal.h" namespace "url": +cdef extern from "../third_party/chromium/url/url_util_internal.h" namespace "url": cdef bool CompareSchemeComponent(const char* spec, const Component& component, const char* compare_to) diff --git a/scurl/mozilla_url_parse.pxd b/scurl/mozilla_url_parse.pxd index e4703d1..104b05a 100644 --- a/scurl/mozilla_url_parse.pxd +++ b/scurl/mozilla_url_parse.pxd @@ -1,7 +1,7 @@ from libcpp cimport bool -cdef extern from "../vendor/gurl/url/third_party/mozilla/url_parse.h" namespace "url": +cdef extern from "../third_party/chromium/url/third_party/mozilla/url_parse.h" namespace "url": cdef struct Component: int begin int len diff --git a/setup.py b/setup.py index 844f948..6d111e8 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ from os.path import splitext import logging import platform +from glob import glob VERSION = "0.1.0" ext_macros = [] @@ -24,39 +25,48 @@ logger.warning('Warning: Enabling line tracing in Cython extension.\ This will make the performance of the library less effective!') +ext_sources = [ + 'scurl/cgurl.pyx', + 'third_party/chromium/base/callback_internal.cc', + 'third_party/chromium/base/at_exit.cc', + 'third_party/chromium/base/lazy_instance_helpers.cc', + 'third_party/chromium/base/strings/utf_string_conversion_utils.cc', + 'third_party/chromium/base/strings/string_piece.cc', + 'third_party/chromium/base/strings/string16.cc', + 'third_party/chromium/base/strings/string_util.cc', + 'third_party/chromium/base/strings/utf_string_conversions.cc', + 'third_party/chromium/base/strings/string_util_constants.cc', + 'third_party/chromium/base/third_party/icu/icu_utf.cc', + 'third_party/chromium/url/gurl.cc', + 'third_party/chromium/url/url_canon.cc', + 'third_party/chromium/url/url_canon_etc.cc', + # 'third_party/chromium/url/url_canon_icu.cc', + 'third_party/chromium/url/url_canon_filesystemurl.cc', + 'third_party/chromium/url/url_canon_fileurl.cc', + 'third_party/chromium/url/url_canon_host.cc', + 'third_party/chromium/url/url_canon_internal.cc', + 'third_party/chromium/url/url_canon_ip.cc', + 'third_party/chromium/url/url_canon_mailtourl.cc', + 'third_party/chromium/url/url_canon_path.cc', + 'third_party/chromium/url/url_canon_pathurl.cc', + 'third_party/chromium/url/url_canon_query.cc', + 'third_party/chromium/url/url_canon_relative.cc', + 'third_party/chromium/url/url_canon_stdstring.cc', + 'third_party/chromium/url/url_canon_stdurl.cc', + 'third_party/chromium/url/url_constants.cc', + 'third_party/chromium/url/url_parse_file.cc', + 'third_party/chromium/url/url_util.cc', + 'third_party/chromium/url/third_party/mozilla/url_parse.cc', +] + extension = [ Extension( name="scurl.cgurl", - sources=["scurl/cgurl.pyx", - "vendor/gurl/base/third_party/icu/icu_utf.cc", - "vendor/gurl/base/strings/string16.cc", - "vendor/gurl/base/strings/string_piece.cc", - "vendor/gurl/base/strings/string_util.cc", - "vendor/gurl/base/strings/utf_string_conversions.cc", - "vendor/gurl/base/strings/utf_string_conversion_utils.cc", - "vendor/gurl/url/gurl.cc", - "vendor/gurl/url/url_canon_etc.cc", - "vendor/gurl/url/url_canon_filesystemurl.cc", - "vendor/gurl/url/url_canon_fileurl.cc", - "vendor/gurl/url/url_canon_host.cc", - "vendor/gurl/url/url_canon_internal.cc", - "vendor/gurl/url/url_canon_ip.cc", - "vendor/gurl/url/url_canon_mailtourl.cc", - "vendor/gurl/url/url_canon_path.cc", - "vendor/gurl/url/url_canon_pathurl.cc", - "vendor/gurl/url/url_canon_query.cc", - "vendor/gurl/url/url_canon_relative.cc", - "vendor/gurl/url/url_canon_stdstring.cc", - "vendor/gurl/url/url_canon_stdurl.cc", - "vendor/gurl/url/url_constants.cc", - "vendor/gurl/url/url_parse_file.cc", - "vendor/gurl/url/url_util.cc", - "vendor/gurl/url/third_party/mozilla/url_parse.cc" - ], + sources=ext_sources, language="c++", - extra_compile_args=["-std=gnu++0x", "-I./vendor/gurl/", - "-fPIC", "-Ofast", "-pthread", "-w"], - extra_link_args=["-std=gnu++0x", "-w"], + extra_compile_args=["-std=gnu++14", "-I./third_party/chromium/", + "-fPIC", "-Ofast", "-pthread", "-w", '-DU_COMMON_IMPLEMENTATION'], + extra_link_args=["-std=gnu++14", "-w"], include_dirs=['.'], define_macros=ext_macros ), @@ -64,9 +74,9 @@ name="scurl.canonicalize", sources=["scurl/canonicalize.pyx"], language="c++", - extra_compile_args=["-std=gnu++0x", "-I./vendor/gurl/", + extra_compile_args=["-std=gnu++14", "-I./third_party/chromium/", "-fPIC", "-Ofast", "-pthread", "-w"], - extra_link_args=["-std=gnu++0x", "-w"], + extra_link_args=["-std=gnu++14", "-w"], include_dirs=['.'], define_macros=ext_macros ) diff --git a/third_party/chromium/README.md b/third_party/chromium/README.md new file mode 100644 index 0000000..5f583a0 --- /dev/null +++ b/third_party/chromium/README.md @@ -0,0 +1,16 @@ +## Notes on updating the chromium source for SCURL project + +Updating the source for the project might be a lot of work. But sometimes there might be a lot of functionality +implemented in the chromium source code that we might miss if we don't update it regularly + +Here are the forked repository of the base component and the url component: + ++ [base-chromium](https://github.com/nctl144/base-chromium) ++ [url-chromium](https://github.com/nctl144/url-chromium) + +Since base component is really large and we might not even need all of the components defined in it, there are a +few functions/files that we need to skip: + ++ YieldCurrentThread ++ lock ++ platforms-related components diff --git a/third_party/chromium/base b/third_party/chromium/base new file mode 160000 index 0000000..37af59d --- /dev/null +++ b/third_party/chromium/base @@ -0,0 +1 @@ +Subproject commit 37af59da412893422262ed2ab934ab7d8da929ca diff --git a/vendor/gurl/build/build_config.h b/third_party/chromium/build/build_config.h similarity index 100% rename from vendor/gurl/build/build_config.h rename to third_party/chromium/build/build_config.h diff --git a/third_party/chromium/url b/third_party/chromium/url new file mode 160000 index 0000000..562a6f1 --- /dev/null +++ b/third_party/chromium/url @@ -0,0 +1 @@ +Subproject commit 562a6f1449df504514f02011ef9fa96cabf5c14c diff --git a/vendor/gurl/base/base_export.h b/vendor/gurl/base/base_export.h deleted file mode 100644 index 723b38a..0000000 --- a/vendor/gurl/base/base_export.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_BASE_EXPORT_H_ -#define BASE_BASE_EXPORT_H_ - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(BASE_IMPLEMENTATION) -#define BASE_EXPORT __declspec(dllexport) -#define BASE_EXPORT_PRIVATE __declspec(dllexport) -#else -#define BASE_EXPORT __declspec(dllimport) -#define BASE_EXPORT_PRIVATE __declspec(dllimport) -#endif // defined(BASE_IMPLEMENTATION) - -#else // defined(WIN32) -#if defined(BASE_IMPLEMENTATION) -#define BASE_EXPORT __attribute__((visibility("default"))) -#define BASE_EXPORT_PRIVATE __attribute__((visibility("default"))) -#else -#define BASE_EXPORT -#define BASE_EXPORT_PRIVATE -#endif // defined(BASE_IMPLEMENTATION) -#endif - -#else // defined(COMPONENT_BUILD) -#define BASE_EXPORT -#define BASE_EXPORT_PRIVATE -#endif - -#endif // BASE_BASE_EXPORT_H_ diff --git a/vendor/gurl/base/basictypes.h b/vendor/gurl/base/basictypes.h deleted file mode 100644 index e167466..0000000 --- a/vendor/gurl/base/basictypes.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file contains definitions of our old basic integral types -// ((u)int{8,16,32,64}) and further includes. I recommend that you use the C99 -// standard types instead, and include //etc. as needed. -// Note that the macros and macro-like constructs that were formerly defined in -// this file are now available separately in base/macros.h. - -#ifndef BASE_BASICTYPES_H_ -#define BASE_BASICTYPES_H_ - -#include // So we can set the bounds of our types. -#include // For size_t. -#include // For intptr_t. - -#include "base/macros.h" -#include "build/build_config.h" - -// DEPRECATED: Please use (u)int{8,16,32,64}_t instead (and include ). -typedef int8_t int8; -typedef uint8_t uint8; -typedef int16_t int16; -typedef uint16_t uint16; -typedef int32_t int32; -typedef uint32_t uint32; -typedef int64_t int64; -typedef uint64_t uint64; - -// DEPRECATED: Please use std::numeric_limits (from ) or -// (U)INT{8,16,32,64}_{MIN,MAX} in case of globals (and include ). -const uint8 kuint8max = 0xFF; -const uint16 kuint16max = 0xFFFF; -const uint32 kuint32max = 0xFFFFFFFF; -const uint64 kuint64max = 0xFFFFFFFFFFFFFFFFULL; -const int8 kint8min = -0x7F - 1; -const int8 kint8max = 0x7F; -const int16 kint16min = -0x7FFF - 1; -const int16 kint16max = 0x7FFF; -const int32 kint32min = -0x7FFFFFFF - 1; -const int32 kint32max = 0x7FFFFFFF; -const int64 kint64min = -0x7FFFFFFFFFFFFFFFLL - 1; -const int64 kint64max = 0x7FFFFFFFFFFFFFFFLL; - -#endif // BASE_BASICTYPES_H_ diff --git a/vendor/gurl/base/compiler_specific.h b/vendor/gurl/base/compiler_specific.h deleted file mode 100644 index d5d38b7..0000000 --- a/vendor/gurl/base/compiler_specific.h +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_COMPILER_SPECIFIC_H_ -#define BASE_COMPILER_SPECIFIC_H_ - -#include "build/build_config.h" - -#if defined(COMPILER_MSVC) - -// Macros for suppressing and disabling warnings on MSVC. -// -// Warning numbers are enumerated at: -// http://msdn.microsoft.com/en-us/library/8x5x43k7(VS.80).aspx -// -// The warning pragma: -// http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx -// -// Using __pragma instead of #pragma inside macros: -// http://msdn.microsoft.com/en-us/library/d9x1s805.aspx - -// MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and -// for the next line of the source file. -#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n)) - -// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. -// The warning remains disabled until popped by MSVC_POP_WARNING. -#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ - __pragma(warning(disable:n)) - -// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level -// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all -// warnings. -#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) - -// Pop effects of innermost MSVC_PUSH_* macro. -#define MSVC_POP_WARNING() __pragma(warning(pop)) - -#define MSVC_DISABLE_OPTIMIZE() __pragma(optimize("", off)) -#define MSVC_ENABLE_OPTIMIZE() __pragma(optimize("", on)) - -// Allows exporting a class that inherits from a non-exported base class. -// This uses suppress instead of push/pop because the delimiter after the -// declaration (either "," or "{") has to be placed before the pop macro. -// -// Example usage: -// class EXPORT_API Foo : NON_EXPORTED_BASE(public Bar) { -// -// MSVC Compiler warning C4275: -// non dll-interface class 'Bar' used as base for dll-interface class 'Foo'. -// Note that this is intended to be used only when no access to the base class' -// static data is done through derived classes or inline methods. For more info, -// see http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx -#define NON_EXPORTED_BASE(code) MSVC_SUPPRESS_WARNING(4275) \ - code - -#else // Not MSVC - -#define MSVC_SUPPRESS_WARNING(n) -#define MSVC_PUSH_DISABLE_WARNING(n) -#define MSVC_PUSH_WARNING_LEVEL(n) -#define MSVC_POP_WARNING() -#define MSVC_DISABLE_OPTIMIZE() -#define MSVC_ENABLE_OPTIMIZE() -#define NON_EXPORTED_BASE(code) code - -#endif // COMPILER_MSVC - - -// Annotate a variable indicating it's ok if the variable is not used. -// (Typically used to silence a compiler warning when the assignment -// is important for some other reason.) -// Use like: -// int x = ...; -// ALLOW_UNUSED_LOCAL(x); -#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 - -// Annotate a typedef or function indicating it's ok if it's not used. -// Use like: -// typedef Foo Bar ALLOW_UNUSED_TYPE; -#if defined(COMPILER_GCC) || defined(__clang__) -#define ALLOW_UNUSED_TYPE __attribute__((unused)) -#else -#define ALLOW_UNUSED_TYPE -#endif - -// Annotate a function indicating it should not be inlined. -// Use like: -// NOINLINE void DoStuff() { ... } -#if defined(COMPILER_GCC) -#define NOINLINE __attribute__((noinline)) -#elif defined(COMPILER_MSVC) -#define NOINLINE __declspec(noinline) -#else -#define NOINLINE -#endif - -// Specify memory alignment for structs, classes, etc. -// Use like: -// class ALIGNAS(16) MyClass { ... } -// ALIGNAS(16) int array[4]; -#if defined(COMPILER_MSVC) -#define ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) -#elif defined(COMPILER_GCC) -#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) -#endif - -// Return the byte alignment of the given type (available at compile time). -// Use like: -// ALIGNOF(int32) // this would be 4 -#if defined(COMPILER_MSVC) -#define ALIGNOF(type) __alignof(type) -#elif defined(COMPILER_GCC) -#define ALIGNOF(type) __alignof__(type) -#endif - -// Annotate a function indicating the caller must examine the return value. -// Use like: -// int foo() WARN_UNUSED_RESULT; -// To explicitly ignore a result, see |ignore_result()| in base/macros.h. -// TODO(dcheng): Update //third_party/webrtc's macro definition to match. -#undef WARN_UNUSED_RESULT -#if defined(COMPILER_GCC) || defined(__clang__) -#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -#define WARN_UNUSED_RESULT -#endif - -// Tell the compiler a function is using a printf-style format string. -// |format_param| is the one-based index of the format string parameter; -// |dots_param| is the one-based index of the "..." parameter. -// For v*printf functions (which take a va_list), pass 0 for dots_param. -// (This is undocumented but matches what the system C headers do.) -#if defined(COMPILER_GCC) -#define PRINTF_FORMAT(format_param, dots_param) \ - __attribute__((format(printf, format_param, dots_param))) -#else -#define PRINTF_FORMAT(format_param, dots_param) -#endif - -// WPRINTF_FORMAT is the same, but for wide format strings. -// This doesn't appear to yet be implemented in any compiler. -// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . -#define WPRINTF_FORMAT(format_param, dots_param) -// If available, it would look like: -// __attribute__((format(wprintf, format_param, dots_param))) - -// MemorySanitizer annotations. -#if defined(MEMORY_SANITIZER) && !defined(OS_NACL) -#include - -// Mark a memory region fully initialized. -// Use this to annotate code that deliberately reads uninitialized data, for -// example a GC scavenging root set pointers from the stack. -#define MSAN_UNPOISON(p, size) __msan_unpoison(p, size) - -// Check a memory region for initializedness, as if it was being used here. -// If any bits are uninitialized, crash with an MSan report. -// Use this to sanitize data which MSan won't be able to track, e.g. before -// passing data to another process via shared memory. -#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \ - __msan_check_mem_is_initialized(p, size) -#else // MEMORY_SANITIZER -#define MSAN_UNPOISON(p, size) -#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) -#endif // MEMORY_SANITIZER - -// Macro useful for writing cross-platform function pointers. -#if !defined(CDECL) -#if defined(OS_WIN) -#define CDECL __cdecl -#else // defined(OS_WIN) -#define CDECL -#endif // defined(OS_WIN) -#endif // !defined(CDECL) - -// Macro for hinting that an expression is likely to be false. -#if !defined(UNLIKELY) -#if defined(COMPILER_GCC) -#define UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define UNLIKELY(x) (x) -#endif // defined(COMPILER_GCC) -#endif // !defined(UNLIKELY) - -#endif // BASE_COMPILER_SPECIFIC_H_ diff --git a/vendor/gurl/base/macros.h b/vendor/gurl/base/macros.h deleted file mode 100644 index c5f503f..0000000 --- a/vendor/gurl/base/macros.h +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file contains macros and macro-like constructs (e.g., templates) that -// are commonly used throughout Chromium source. (It may also contain things -// that are closely related to things that are commonly used that belong in this -// file.) - -#ifndef BASE_MACROS_H_ -#define BASE_MACROS_H_ - -#include // For size_t. -#include // For memcpy. - -// Put this in the declarations for a class to be uncopyable. -#define DISALLOW_COPY(TypeName) \ - TypeName(const TypeName&) = delete - -// Put this in the declarations for a class to be unassignable. -#define DISALLOW_ASSIGN(TypeName) \ - void operator=(const TypeName&) = delete - -// A macro to disallow the copy constructor and operator= functions -// This should be used in the private: declarations for a class -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) - -// An older, deprecated, politically incorrect name for the above. -// NOTE: The usage of this macro was banned from our code base, but some -// third_party libraries are yet using it. -// TODO(tfarina): Figure out how to fix the usage of this macro in the -// third_party libraries and get rid of it. -#define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName) - -// A macro to disallow all the implicit constructors, namely the -// default constructor, copy constructor and operator= functions. -// -// This should be used in the private: declarations for a class -// that wants to prevent anyone from instantiating it. This is -// especially useful for classes containing only static methods. -#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName() = delete; \ - DISALLOW_COPY_AND_ASSIGN(TypeName) - -// The arraysize(arr) macro returns the # of elements in an array arr. -// The expression is a compile-time constant, and therefore can be -// used in defining new arrays, for example. If you use arraysize on -// a pointer by mistake, you will get a compile-time error. - -// This template function declaration is used in defining arraysize. -// Note that the function doesn't need an implementation, as we only -// use its type. -template char (&ArraySizeHelper(T (&array)[N]))[N]; -#define arraysize(array) (sizeof(ArraySizeHelper(array))) - -// The COMPILE_ASSERT macro can be used to verify that a compile time -// expression is true. For example, you could use it to verify the -// size of a static array: -// -// COMPILE_ASSERT(arraysize(content_type_names) == CONTENT_NUM_TYPES, -// content_type_names_incorrect_size); -// -// or to make sure a struct is smaller than a certain size: -// -// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); -// -// The second argument to the macro is the name of the variable. If -// the expression is false, most compilers will issue a warning/error -// containing the name of the variable. - -#undef COMPILE_ASSERT -#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) - -// bit_cast is a template function that implements the -// equivalent of "*reinterpret_cast(&source)". We need this in -// very low-level functions like the protobuf library and fast math -// support. -// -// float f = 3.14159265358979; -// int i = bit_cast(f); -// // i = 0x40490fdb -// -// The classical address-casting method is: -// -// // WRONG -// float f = 3.14159265358979; // WRONG -// int i = * reinterpret_cast(&f); // WRONG -// -// The address-casting method actually produces undefined behavior -// according to ISO C++ specification section 3.10 -15 -. Roughly, this -// section says: if an object in memory has one type, and a program -// accesses it with a different type, then the result is undefined -// behavior for most values of "different type". -// -// This is true for any cast syntax, either *(int*)&f or -// *reinterpret_cast(&f). And it is particularly true for -// conversions between integral lvalues and floating-point lvalues. -// -// The purpose of 3.10 -15- is to allow optimizing compilers to assume -// that expressions with different types refer to different memory. gcc -// 4.0.1 has an optimizer that takes advantage of this. So a -// non-conforming program quietly produces wildly incorrect output. -// -// The problem is not the use of reinterpret_cast. The problem is type -// punning: holding an object in memory of one type and reading its bits -// back using a different type. -// -// The C++ standard is more subtle and complex than this, but that -// is the basic idea. -// -// Anyways ... -// -// bit_cast<> calls memcpy() which is blessed by the standard, -// especially by the example in section 3.9 . Also, of course, -// bit_cast<> wraps up the nasty logic in one place. -// -// Fortunately memcpy() is very fast. In optimized mode, with a -// constant size, gcc 2.95.3, gcc 4.0.1, and msvc 7.1 produce inline -// code with the minimal amount of data movement. On a 32-bit system, -// memcpy(d,s,4) compiles to one load and one store, and memcpy(d,s,8) -// compiles to two loads and two stores. -// -// I tested this code with gcc 2.95.3, gcc 4.0.1, icc 8.1, and msvc 7.1. -// -// WARNING: if Dest or Source is a non-POD type, the result of the memcpy -// is likely to surprise you. - -template -inline Dest bit_cast(const Source& source) { - COMPILE_ASSERT(sizeof(Dest) == sizeof(Source), VerifySizesAreEqual); - - Dest dest; - memcpy(&dest, &source, sizeof(dest)); - return dest; -} - -// Used to explicitly mark the return value of a function as unused. If you are -// really sure you don't want to do anything with the return value of a function -// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example: -// -// scoped_ptr my_var = ...; -// if (TakeOwnership(my_var.get()) == SUCCESS) -// ignore_result(my_var.release()); -// -template -inline void ignore_result(const T&) { -} - -// The following enum should be used only as a constructor argument to indicate -// that the variable has static storage class, and that the constructor should -// do nothing to its state. It indicates to the reader that it is legal to -// declare a static instance of the class, provided the constructor is given -// the base::LINKER_INITIALIZED argument. Normally, it is unsafe to declare a -// static variable that has a constructor or a destructor because invocation -// order is undefined. However, IF the type can be initialized by filling with -// zeroes (which the loader does for static variables), AND the destructor also -// does nothing to the storage, AND there are no virtual methods, then a -// constructor declared as -// explicit MyClass(base::LinkerInitialized x) {} -// and invoked as -// static MyClass my_variable_name(base::LINKER_INITIALIZED); -namespace base { -enum LinkerInitialized { LINKER_INITIALIZED }; - -// Use these to declare and define a static local variable (static T;) so that -// it is leaked so that its destructors are not called at exit. If you need -// thread-safe initialization, use base/lazy_instance.h instead. -#define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ - static type& name = *new type arguments - -} // base - -#endif // BASE_MACROS_H_ diff --git a/vendor/gurl/base/memory/scoped_ptr.h b/vendor/gurl/base/memory/scoped_ptr.h deleted file mode 100644 index 2399e95..0000000 --- a/vendor/gurl/base/memory/scoped_ptr.h +++ /dev/null @@ -1,581 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Scopers help you manage ownership of a pointer, helping you easily manage a -// pointer within a scope, and automatically destroying the pointer at the end -// of a scope. There are two main classes you will use, which correspond to the -// operators new/delete and new[]/delete[]. -// -// Example usage (scoped_ptr): -// { -// scoped_ptr foo(new Foo("wee")); -// } // foo goes out of scope, releasing the pointer with it. -// -// { -// scoped_ptr foo; // No pointer managed. -// foo.reset(new Foo("wee")); // Now a pointer is managed. -// foo.reset(new Foo("wee2")); // Foo("wee") was destroyed. -// foo.reset(new Foo("wee3")); // Foo("wee2") was destroyed. -// foo->Method(); // Foo::Method() called. -// foo.get()->Method(); // Foo::Method() called. -// SomeFunc(foo.release()); // SomeFunc takes ownership, foo no longer -// // manages a pointer. -// foo.reset(new Foo("wee4")); // foo manages a pointer again. -// foo.reset(); // Foo("wee4") destroyed, foo no longer -// // manages a pointer. -// } // foo wasn't managing a pointer, so nothing was destroyed. -// -// Example usage (scoped_ptr): -// { -// scoped_ptr foo(new Foo[100]); -// foo.get()->Method(); // Foo::Method on the 0th element. -// foo[10].Method(); // Foo::Method on the 10th element. -// } -// -// These scopers also implement part of the functionality of C++11 unique_ptr -// in that they are "movable but not copyable." You can use the scopers in -// the parameter and return types of functions to signify ownership transfer -// in to and out of a function. When calling a function that has a scoper -// as the argument type, it must be called with the result of an analogous -// scoper's Pass() function or another function that generates a temporary; -// passing by copy will NOT work. Here is an example using scoped_ptr: -// -// void TakesOwnership(scoped_ptr arg) { -// // Do something with arg -// } -// scoped_ptr CreateFoo() { -// // No need for calling Pass() because we are constructing a temporary -// // for the return value. -// return scoped_ptr(new Foo("new")); -// } -// scoped_ptr PassThru(scoped_ptr arg) { -// return arg.Pass(); -// } -// -// { -// scoped_ptr ptr(new Foo("yay")); // ptr manages Foo("yay"). -// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay"). -// scoped_ptr ptr2 = CreateFoo(); // ptr2 owns the return Foo. -// scoped_ptr ptr3 = // ptr3 now owns what was in ptr2. -// PassThru(ptr2.Pass()); // ptr2 is correspondingly nullptr. -// } -// -// Notice that if you do not call Pass() when returning from PassThru(), or -// when invoking TakesOwnership(), the code will not compile because scopers -// are not copyable; they only implement move semantics which require calling -// the Pass() function to signify a destructive transfer of state. CreateFoo() -// is different though because we are constructing a temporary on the return -// line and thus can avoid needing to call Pass(). -// -// Pass() properly handles upcast in initialization, i.e. you can use a -// scoped_ptr to initialize a scoped_ptr: -// -// scoped_ptr foo(new Foo()); -// scoped_ptr parent(foo.Pass()); - -#ifndef BASE_MEMORY_SCOPED_PTR_H_ -#define BASE_MEMORY_SCOPED_PTR_H_ - -// This is an implementation designed to match the anticipated future TR2 -// implementation of the scoped_ptr class. - -#include -#include -#include - -#include // For std::swap(). -#include - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/move.h" -#include "base/template_util.h" - -namespace base { - -namespace subtle { -class RefCountedBase; -class RefCountedThreadSafeBase; -} // namespace subtle - -// Function object which deletes its parameter, which must be a pointer. -// If C is an array type, invokes 'delete[]' on the parameter; otherwise, -// invokes 'delete'. The default deleter for scoped_ptr. -template -struct DefaultDeleter { - DefaultDeleter() {} - template DefaultDeleter(const DefaultDeleter& other) { - // IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor - // if U* is implicitly convertible to T* and U is not an array type. - // - // Correct implementation should use SFINAE to disable this - // constructor. However, since there are no other 1-argument constructors, - // using a COMPILE_ASSERT() based on is_convertible<> and requiring - // complete types is simpler and will cause compile failures for equivalent - // misuses. - // - // Note, the is_convertible check also ensures that U is not an - // array. T is guaranteed to be a non-array, so any U* where U is an array - // cannot convert to T*. - enum { T_must_be_complete = sizeof(T) }; - enum { U_must_be_complete = sizeof(U) }; - COMPILE_ASSERT((base::is_convertible::value), - U_ptr_must_implicitly_convert_to_T_ptr); - } - inline void operator()(T* ptr) const { - enum { type_must_be_complete = sizeof(T) }; - delete ptr; - } -}; - -// Specialization of DefaultDeleter for array types. -template -struct DefaultDeleter { - inline void operator()(T* ptr) const { - enum { type_must_be_complete = sizeof(T) }; - delete[] ptr; - } - - private: - // Disable this operator for any U != T because it is undefined to execute - // an array delete when the static type of the array mismatches the dynamic - // type. - // - // References: - // C++98 [expr.delete]p3 - // http://cplusplus.github.com/LWG/lwg-defects.html#938 - template void operator()(U* array) const; -}; - -template -struct DefaultDeleter { - // Never allow someone to declare something like scoped_ptr. - COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type); -}; - -// Function object which invokes 'free' on its parameter, which must be -// a pointer. Can be used to store malloc-allocated pointers in scoped_ptr: -// -// scoped_ptr foo_ptr( -// static_cast(malloc(sizeof(int)))); -struct FreeDeleter { - inline void operator()(void* ptr) const { - free(ptr); - } -}; - -namespace internal { - -template struct IsNotRefCounted { - enum { - value = !base::is_convertible::value && - !base::is_convertible:: - value - }; -}; - -template -struct ShouldAbortOnSelfReset { - template - static NoType Test(const typename U::AllowSelfReset*); - - template - static YesType Test(...); - - static const bool value = sizeof(Test(0)) == sizeof(YesType); -}; - -// Minimal implementation of the core logic of scoped_ptr, suitable for -// reuse in both scoped_ptr and its specializations. -template -class scoped_ptr_impl { - public: - explicit scoped_ptr_impl(T* p) : data_(p) {} - - // Initializer for deleters that have data parameters. - scoped_ptr_impl(T* p, const D& d) : data_(p, d) {} - - // Templated constructor that destructively takes the value from another - // scoped_ptr_impl. - template - scoped_ptr_impl(scoped_ptr_impl* other) - : data_(other->release(), other->get_deleter()) { - // We do not support move-only deleters. We could modify our move - // emulation to have base::subtle::move() and base::subtle::forward() - // functions that are imperfect emulations of their C++11 equivalents, - // but until there's a requirement, just assume deleters are copyable. - } - - template - void TakeState(scoped_ptr_impl* other) { - // See comment in templated constructor above regarding lack of support - // for move-only deleters. - reset(other->release()); - get_deleter() = other->get_deleter(); - } - - ~scoped_ptr_impl() { - if (data_.ptr != nullptr) { - // Not using get_deleter() saves one function call in non-optimized - // builds. - static_cast(data_)(data_.ptr); - } - } - - void reset(T* p) { - // This is a self-reset, which is no longer allowed for default deleters: - // https://crbug.com/162971 - assert(!ShouldAbortOnSelfReset::value || p == nullptr || p != data_.ptr); - - // Match C++11's definition of unique_ptr::reset(), which requires changing - // the pointer before invoking the deleter on the old pointer. This prevents - // |this| from being accessed after the deleter is run, which may destroy - // |this|. - T* old = data_.ptr; - data_.ptr = p; - if (old != nullptr) - static_cast(data_)(old); - } - - T* get() const { return data_.ptr; } - - D& get_deleter() { return data_; } - const D& get_deleter() const { return data_; } - - void swap(scoped_ptr_impl& p2) { - // Standard swap idiom: 'using std::swap' ensures that std::swap is - // present in the overload set, but we call swap unqualified so that - // any more-specific overloads can be used, if available. - using std::swap; - swap(static_cast(data_), static_cast(p2.data_)); - swap(data_.ptr, p2.data_.ptr); - } - - T* release() { - T* old_ptr = data_.ptr; - data_.ptr = nullptr; - return old_ptr; - } - - private: - // Needed to allow type-converting constructor. - template friend class scoped_ptr_impl; - - // Use the empty base class optimization to allow us to have a D - // member, while avoiding any space overhead for it when D is an - // empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good - // discussion of this technique. - struct Data : public D { - explicit Data(T* ptr_in) : ptr(ptr_in) {} - Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {} - T* ptr; - }; - - Data data_; - - DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl); -}; - -} // namespace internal - -} // namespace base - -// A scoped_ptr is like a T*, except that the destructor of scoped_ptr -// automatically deletes the pointer it holds (if any). -// That is, scoped_ptr owns the T object that it points to. -// Like a T*, a scoped_ptr may hold either nullptr or a pointer to a T -// object. Also like T*, scoped_ptr is thread-compatible, and once you -// dereference it, you get the thread safety guarantees of T. -// -// The size of scoped_ptr is small. On most compilers, when using the -// DefaultDeleter, sizeof(scoped_ptr) == sizeof(T*). Custom deleters will -// increase the size proportional to whatever state they need to have. See -// comments inside scoped_ptr_impl<> for details. -// -// Current implementation targets having a strict subset of C++11's -// unique_ptr<> features. Known deficiencies include not supporting move-only -// deleteres, function pointers as deleters, and deleters with reference -// types. -template > -class scoped_ptr { - MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(scoped_ptr) - - COMPILE_ASSERT(base::internal::IsNotRefCounted::value, - T_is_refcounted_type_and_needs_scoped_refptr); - - public: - // The element and deleter types. - typedef T element_type; - typedef D deleter_type; - - // Constructor. Defaults to initializing with nullptr. - scoped_ptr() : impl_(nullptr) {} - - // Constructor. Takes ownership of p. - explicit scoped_ptr(element_type* p) : impl_(p) {} - - // Constructor. Allows initialization of a stateful deleter. - scoped_ptr(element_type* p, const D& d) : impl_(p, d) {} - - // Constructor. Allows construction from a nullptr. - scoped_ptr(decltype(nullptr)) : impl_(nullptr) {} - - // Constructor. Allows construction from a scoped_ptr rvalue for a - // convertible type and deleter. - // - // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct - // from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor - // has different post-conditions if D is a reference type. Since this - // implementation does not support deleters with reference type, - // we do not need a separate move constructor allowing us to avoid one - // use of SFINAE. You only need to care about this if you modify the - // implementation of scoped_ptr. - template - scoped_ptr(scoped_ptr&& other) - : impl_(&other.impl_) { - COMPILE_ASSERT(!base::is_array::value, U_cannot_be_an_array); - } - - // operator=. Allows assignment from a scoped_ptr rvalue for a convertible - // type and deleter. - // - // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this operator= distinct from - // the normal move assignment operator. By C++11 20.7.1.2.3.4, this templated - // form has different requirements on for move-only Deleters. Since this - // implementation does not support move-only Deleters, we do not need a - // separate move assignment operator allowing us to avoid one use of SFINAE. - // You only need to care about this if you modify the implementation of - // scoped_ptr. - template - scoped_ptr& operator=(scoped_ptr&& rhs) { - COMPILE_ASSERT(!base::is_array::value, U_cannot_be_an_array); - impl_.TakeState(&rhs.impl_); - return *this; - } - - // operator=. Allows assignment from a nullptr. Deletes the currently owned - // object, if any. - scoped_ptr& operator=(decltype(nullptr)) { - reset(); - return *this; - } - - // Reset. Deletes the currently owned object, if any. - // Then takes ownership of a new object, if given. - void reset(element_type* p = nullptr) { impl_.reset(p); } - - // Accessors to get the owned object. - // operator* and operator-> will assert() if there is no current object. - element_type& operator*() const { - assert(impl_.get() != nullptr); - return *impl_.get(); - } - element_type* operator->() const { - assert(impl_.get() != nullptr); - return impl_.get(); - } - element_type* get() const { return impl_.get(); } - - // Access to the deleter. - deleter_type& get_deleter() { return impl_.get_deleter(); } - const deleter_type& get_deleter() const { return impl_.get_deleter(); } - - // Allow scoped_ptr to be used in boolean expressions, but not - // implicitly convertible to a real bool (which is dangerous). - // - // Note that this trick is only safe when the == and != operators - // are declared explicitly, as otherwise "scoped_ptr1 == - // scoped_ptr2" will compile but do the wrong thing (i.e., convert - // to Testable and then do the comparison). - private: - typedef base::internal::scoped_ptr_impl - scoped_ptr::*Testable; - - public: - operator Testable() const { - return impl_.get() ? &scoped_ptr::impl_ : nullptr; - } - - // Comparison operators. - // These return whether two scoped_ptr refer to the same object, not just to - // two different but equal objects. - bool operator==(const element_type* p) const { return impl_.get() == p; } - bool operator!=(const element_type* p) const { return impl_.get() != p; } - - // Swap two scoped pointers. - void swap(scoped_ptr& p2) { - impl_.swap(p2.impl_); - } - - // Release a pointer. - // The return value is the current pointer held by this object. If this object - // holds a nullptr, the return value is nullptr. After this operation, this - // object will hold a nullptr, and will not own the object any more. - element_type* release() WARN_UNUSED_RESULT { - return impl_.release(); - } - - private: - // Needed to reach into |impl_| in the constructor. - template friend class scoped_ptr; - base::internal::scoped_ptr_impl impl_; - - // Forbidden for API compatibility with std::unique_ptr. - explicit scoped_ptr(int disallow_construction_from_null); - - // Forbid comparison of scoped_ptr types. If U != T, it totally - // doesn't make sense, and if U == T, it still doesn't make sense - // because you should never have the same object owned by two different - // scoped_ptrs. - template bool operator==(scoped_ptr const& p2) const; - template bool operator!=(scoped_ptr const& p2) const; -}; - -template -class scoped_ptr { - MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(scoped_ptr) - - public: - // The element and deleter types. - typedef T element_type; - typedef D deleter_type; - - // Constructor. Defaults to initializing with nullptr. - scoped_ptr() : impl_(nullptr) {} - - // Constructor. Stores the given array. Note that the argument's type - // must exactly match T*. In particular: - // - it cannot be a pointer to a type derived from T, because it is - // inherently unsafe in the general case to access an array through a - // pointer whose dynamic type does not match its static type (eg., if - // T and the derived types had different sizes access would be - // incorrectly calculated). Deletion is also always undefined - // (C++98 [expr.delete]p3). If you're doing this, fix your code. - // - it cannot be const-qualified differently from T per unique_ptr spec - // (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting - // to work around this may use const_cast(). - explicit scoped_ptr(element_type* array) : impl_(array) {} - - // Constructor. Allows construction from a nullptr. - scoped_ptr(decltype(nullptr)) : impl_(nullptr) {} - - // Constructor. Allows construction from a scoped_ptr rvalue. - scoped_ptr(scoped_ptr&& other) : impl_(&other.impl_) {} - - // operator=. Allows assignment from a scoped_ptr rvalue. - scoped_ptr& operator=(scoped_ptr&& rhs) { - impl_.TakeState(&rhs.impl_); - return *this; - } - - // operator=. Allows assignment from a nullptr. Deletes the currently owned - // array, if any. - scoped_ptr& operator=(decltype(nullptr)) { - reset(); - return *this; - } - - // Reset. Deletes the currently owned array, if any. - // Then takes ownership of a new object, if given. - void reset(element_type* array = nullptr) { impl_.reset(array); } - - // Accessors to get the owned array. - element_type& operator[](size_t i) const { - assert(impl_.get() != nullptr); - return impl_.get()[i]; - } - element_type* get() const { return impl_.get(); } - - // Access to the deleter. - deleter_type& get_deleter() { return impl_.get_deleter(); } - const deleter_type& get_deleter() const { return impl_.get_deleter(); } - - // Allow scoped_ptr to be used in boolean expressions, but not - // implicitly convertible to a real bool (which is dangerous). - private: - typedef base::internal::scoped_ptr_impl - scoped_ptr::*Testable; - - public: - operator Testable() const { - return impl_.get() ? &scoped_ptr::impl_ : nullptr; - } - - // Comparison operators. - // These return whether two scoped_ptr refer to the same object, not just to - // two different but equal objects. - bool operator==(element_type* array) const { return impl_.get() == array; } - bool operator!=(element_type* array) const { return impl_.get() != array; } - - // Swap two scoped pointers. - void swap(scoped_ptr& p2) { - impl_.swap(p2.impl_); - } - - // Release a pointer. - // The return value is the current pointer held by this object. If this object - // holds a nullptr, the return value is nullptr. After this operation, this - // object will hold a nullptr, and will not own the object any more. - element_type* release() WARN_UNUSED_RESULT { - return impl_.release(); - } - - private: - // Force element_type to be a complete type. - enum { type_must_be_complete = sizeof(element_type) }; - - // Actually hold the data. - base::internal::scoped_ptr_impl impl_; - - // Disable initialization from any type other than element_type*, by - // providing a constructor that matches such an initialization, but is - // private and has no definition. This is disabled because it is not safe to - // call delete[] on an array whose static type does not match its dynamic - // type. - template explicit scoped_ptr(U* array); - explicit scoped_ptr(int disallow_construction_from_null); - - // Disable reset() from any type other than element_type*, for the same - // reasons as the constructor above. - template void reset(U* array); - void reset(int disallow_reset_from_null); - - // Forbid comparison of scoped_ptr types. If U != T, it totally - // doesn't make sense, and if U == T, it still doesn't make sense - // because you should never have the same object owned by two different - // scoped_ptrs. - template bool operator==(scoped_ptr const& p2) const; - template bool operator!=(scoped_ptr const& p2) const; -}; - -// Free functions -template -void swap(scoped_ptr& p1, scoped_ptr& p2) { - p1.swap(p2); -} - -template -bool operator==(T* p1, const scoped_ptr& p2) { - return p1 == p2.get(); -} - -template -bool operator!=(T* p1, const scoped_ptr& p2) { - return p1 != p2.get(); -} - -// A function to convert T* into scoped_ptr -// Doing e.g. make_scoped_ptr(new FooBarBaz(arg)) is a shorter notation -// for scoped_ptr >(new FooBarBaz(arg)) -template -scoped_ptr make_scoped_ptr(T* ptr) { - return scoped_ptr(ptr); -} - -template -std::ostream& operator<<(std::ostream& out, const scoped_ptr& p) { - return out << p.get(); -} - -#endif // BASE_MEMORY_SCOPED_PTR_H_ diff --git a/vendor/gurl/base/move.h b/vendor/gurl/base/move.h deleted file mode 100644 index 87dc52d..0000000 --- a/vendor/gurl/base/move.h +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_MOVE_H_ -#define BASE_MOVE_H_ - -#include "base/compiler_specific.h" - -// Macro with the boilerplate that makes a type move-only in C++03. -// -// USAGE -// -// This macro should be used instead of DISALLOW_COPY_AND_ASSIGN to create -// a "move-only" type. Unlike DISALLOW_COPY_AND_ASSIGN, this macro should be -// the first line in a class declaration. -// -// A class using this macro must call .Pass() (or somehow be an r-value already) -// before it can be: -// -// * Passed as a function argument -// * Used as the right-hand side of an assignment -// * Returned from a function -// -// Each class will still need to define their own "move constructor" and "move -// operator=" to make this useful. Here's an example of the macro, the move -// constructor, and the move operator= from the scoped_ptr class: -// -// template -// class scoped_ptr { -// MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue) -// public: -// scoped_ptr(RValue& other) : ptr_(other.release()) { } -// scoped_ptr& operator=(RValue& other) { -// swap(other); -// return *this; -// } -// }; -// -// Note that the constructor must NOT be marked explicit. -// -// For consistency, the second parameter to the macro should always be RValue -// unless you have a strong reason to do otherwise. It is only exposed as a -// macro parameter so that the move constructor and move operator= don't look -// like they're using a phantom type. -// -// -// HOW THIS WORKS -// -// For a thorough explanation of this technique, see: -// -// http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Move_Constructor -// -// The summary is that we take advantage of 2 properties: -// -// 1) non-const references will not bind to r-values. -// 2) C++ can apply one user-defined conversion when initializing a -// variable. -// -// The first lets us disable the copy constructor and assignment operator -// by declaring private version of them with a non-const reference parameter. -// -// For l-values, direct initialization still fails like in -// DISALLOW_COPY_AND_ASSIGN because the copy constructor and assignment -// operators are private. -// -// For r-values, the situation is different. The copy constructor and -// assignment operator are not viable due to (1), so we are trying to call -// a non-existent constructor and non-existing operator= rather than a private -// one. Since we have not committed an error quite yet, we can provide an -// alternate conversion sequence and a constructor. We add -// -// * a private struct named "RValue" -// * a user-defined conversion "operator RValue()" -// * a "move constructor" and "move operator=" that take the RValue& as -// their sole parameter. -// -// Only r-values will trigger this sequence and execute our "move constructor" -// or "move operator=." L-values will match the private copy constructor and -// operator= first giving a "private in this context" error. This combination -// gives us a move-only type. -// -// For signaling a destructive transfer of data from an l-value, we provide a -// method named Pass() which creates an r-value for the current instance -// triggering the move constructor or move operator=. -// -// Other ways to get r-values is to use the result of an expression like a -// function call. -// -// Here's an example with comments explaining what gets triggered where: -// -// class Foo { -// MOVE_ONLY_TYPE_FOR_CPP_03(Foo, RValue); -// -// public: -// ... API ... -// Foo(RValue other); // Move constructor. -// Foo& operator=(RValue rhs); // Move operator= -// }; -// -// Foo MakeFoo(); // Function that returns a Foo. -// -// Foo f; -// Foo f_copy(f); // ERROR: Foo(Foo&) is private in this context. -// Foo f_assign; -// f_assign = f; // ERROR: operator=(Foo&) is private in this context. -// -// -// Foo f(MakeFoo()); // R-value so alternate conversion executed. -// Foo f_copy(f.Pass()); // R-value so alternate conversion executed. -// f = f_copy.Pass(); // R-value so alternate conversion executed. -// -// -// IMPLEMENTATION SUBTLETIES WITH RValue -// -// The RValue struct is just a container for a pointer back to the original -// object. It should only ever be created as a temporary, and no external -// class should ever declare it or use it in a parameter. -// -// It is tempting to want to use the RValue type in function parameters, but -// excluding the limited usage here for the move constructor and move -// operator=, doing so would mean that the function could take both r-values -// and l-values equially which is unexpected. See COMPARED To Boost.Move for -// more details. -// -// An alternate, and incorrect, implementation of the RValue class used by -// Boost.Move makes RValue a fieldless child of the move-only type. RValue& -// is then used in place of RValue in the various operators. The RValue& is -// "created" by doing *reinterpret_cast(this). This has the appeal -// of never creating a temporary RValue struct even with optimizations -// disabled. Also, by virtue of inheritance you can treat the RValue -// reference as if it were the move-only type itself. Unfortunately, -// using the result of this reinterpret_cast<> is actually undefined behavior -// due to C++98 5.2.10.7. In certain compilers (e.g., NaCl) the optimizer -// will generate non-working code. -// -// In optimized builds, both implementations generate the same assembly so we -// choose the one that adheres to the standard. -// -// -// WHY HAVE typedef void MoveOnlyTypeForCPP03 -// -// Callback<>/Bind() needs to understand movable-but-not-copyable semantics -// to call .Pass() appropriately when it is expected to transfer the value. -// The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check -// easy and automatic in helper templates for Callback<>/Bind(). -// See IsMoveOnlyType template and its usage in base/callback_internal.h -// for more details. -// -// -// COMPARED TO C++11 -// -// In C++11, you would implement this functionality using an r-value reference -// and our .Pass() method would be replaced with a call to std::move(). -// -// This emulation also has a deficiency where it uses up the single -// user-defined conversion allowed by C++ during initialization. This can -// cause problems in some API edge cases. For instance, in scoped_ptr, it is -// impossible to make a function "void Foo(scoped_ptr p)" accept a -// value of type scoped_ptr even if you add a constructor to -// scoped_ptr<> that would make it look like it should work. C++11 does not -// have this deficiency. -// -// -// COMPARED TO Boost.Move -// -// Our implementation similar to Boost.Move, but we keep the RValue struct -// private to the move-only type, and we don't use the reinterpret_cast<> hack. -// -// In Boost.Move, RValue is the boost::rv<> template. This type can be used -// when writing APIs like: -// -// void MyFunc(boost::rv& f) -// -// that can take advantage of rv<> to avoid extra copies of a type. However you -// would still be able to call this version of MyFunc with an l-value: -// -// Foo f; -// MyFunc(f); // Uh oh, we probably just destroyed |f| w/o calling Pass(). -// -// unless someone is very careful to also declare a parallel override like: -// -// void MyFunc(const Foo& f) -// -// that would catch the l-values first. This was declared unsafe in C++11 and -// a C++11 compiler will explicitly fail MyFunc(f). Unfortunately, we cannot -// ensure this in C++03. -// -// Since we have no need for writing such APIs yet, our implementation keeps -// RValue private and uses a .Pass() method to do the conversion instead of -// trying to write a version of "std::move()." Writing an API like std::move() -// would require the RValue struct to be public. -// -// -// CAVEATS -// -// If you include a move-only type as a field inside a class that does not -// explicitly declare a copy constructor, the containing class's implicit -// copy constructor will change from Containing(const Containing&) to -// Containing(Containing&). This can cause some unexpected errors. -// -// http://llvm.org/bugs/show_bug.cgi?id=11528 -// -// The workaround is to explicitly declare your copy constructor. -// -#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \ - private: \ - struct rvalue_type { \ - explicit rvalue_type(type* object) : object(object) {} \ - type* object; \ - }; \ - type(type&); \ - void operator=(type&); \ - public: \ - operator rvalue_type() { return rvalue_type(this); } \ - type Pass() WARN_UNUSED_RESULT { return type(rvalue_type(this)); } \ - typedef void MoveOnlyTypeForCPP03; \ - private: - -#define MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(type) \ - private: \ - type(const type&); \ - void operator=(const type&); \ - public: \ - type&& Pass() WARN_UNUSED_RESULT { return static_cast(*this); } \ - typedef void MoveOnlyTypeForCPP03; \ - private: - -#define TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(type) \ - public: \ - type&& Pass() WARN_UNUSED_RESULT { return static_cast(*this); } \ - private: - -#endif // BASE_MOVE_H_ diff --git a/vendor/gurl/base/strings/cscope.out b/vendor/gurl/base/strings/cscope.out deleted file mode 100644 index 04ca487..0000000 --- a/vendor/gurl/base/strings/cscope.out +++ /dev/null @@ -1,18416 +0,0 @@ -cscope 15 $HOME/Documents/urlparser/google-url/base/strings 0000097235 - @string16.cc - -5  - ~"ba£/¡ršgs/¡ršg16.h -" - -7 #ià -defšed -( -WCHAR_T_IS_UTF16 -) - -9 #”rÜ -This - -fže - -should - -nÙ - -be - -u£d - -Ú - 2- -by‹ - -wch¬_t - -sy¡ems - - -14 #–ià -defšed -( -WCHAR_T_IS_UTF32 -) - -16  - ~ - -20 -Çme¥aû - - gba£ - { - -22  -c16memcmp -(cÚ¡ -ch¬16 -* -s1 -, cÚ¡ ch¬16* -s2 -, -size_t - -n -) { - -24  - gn --- > 0) { - -25 ià(* - gs1 - !ð* -s2 -) { - -27  ((* -s1 - < * -s2 -) ? -1 : 1); - -29 ++ - gs1 -; - -30 ++ - gs2 -; - -35 -size_t - -c16Ën -(cÚ¡ -ch¬16 -* -s -) { - -36 cÚ¡ -ch¬16 - * - gs_Üig - = -s -; - -37 * - gs -) { - -38 ++ - gs -; - -40  - gs - - - gs_Üig -; - -43 cÚ¡ -ch¬16 -* -c16memchr -(cÚ¡ ch¬16* -s -, ch¬16 -c -, -size_t - -n -) { - -44  - gn --- > 0) { - -45 ià(* - gs - =ð -c -) { - -46  -s -; - -48 ++ - gs -; - -53 -ch¬16 -* -c16memmove -(ch¬16* -s1 -, cÚ¡ ch¬16* -s2 -, -size_t - -n -) { - -54  - g¡©ic_ÿ¡ -< - gch¬16 -*>( -memmove -( -s1 -, -s2 -, -n - * ( -ch¬16 -))); - -57 -ch¬16 -* -c16memýy -(ch¬16* -s1 -, cÚ¡ ch¬16* -s2 -, -size_t - -n -) { - -58  - g¡©ic_ÿ¡ -< - gch¬16 -*>( -memýy -( -s1 -, -s2 -, -n - * ( -ch¬16 -))); - -61 -ch¬16 -* -c16mem£t -(ch¬16* -s -, ch¬16 -c -, -size_t - -n -) { - -62 -ch¬16 - * - gs_Üig - = -s -; - -63  - gn --- > 0) { - -64 * - gs - = -c -; - -65 ++ - gs -; - -67  - gs_Üig -; - -80 -‹m¶©e - -þass - - g¡d -:: -basic_¡ršg -< -ba£ -:: -ch¬16 -, - gba£ -:: -¡ršg16_ch¬_Œa™s ->; - - @string16.h - -5 #iâdeà -BASE_STRINGS_STRING16_H_ - - -6  - #BASE_STRINGS_STRING16_H_ - - - ) - -29  - ~<¡dio.h -> - -30  - ~<¡ršg -> - -32  - ~"ba£/ba£_expÜt.h -" - -33  - ~"ba£/basiùy³s.h -" - -35 #ià -defšed -( -WCHAR_T_IS_UTF16 -) - -37 -Çme¥aû - - gba£ - { - -39  -wch¬_t - - tch¬16 -; - -40  - g¡d -:: - tw¡ršg - - t¡ršg16 -; - -41  - g¡d -:: - tch¬_Œa™s -< - twch¬_t -> - t¡ršg16_ch¬_Œa™s -; - -45 #–ià -defšed -( -WCHAR_T_IS_UTF32 -) - -47 -Çme¥aû - - gba£ - { - -49  -ušt16 - - tch¬16 -; - -54 -BASE_EXPORT -  -c16memcmp -(cÚ¡ -ch¬16 -* -s1 -, cÚ¡ ch¬16* -s2 -, -size_t - -n -); - -55 -BASE_EXPORT - -size_t - -c16Ën -(cÚ¡ -ch¬16 -* -s -); - -56 -BASE_EXPORT - cÚ¡ -ch¬16 -* -c16memchr -(cÚ¡ ch¬16* -s -, ch¬16 -c -, -size_t - -n -); - -57 -BASE_EXPORT - -ch¬16 -* -c16memmove -(ch¬16* -s1 -, cÚ¡ ch¬16* -s2 -, -size_t - -n -); - -58 -BASE_EXPORT - -ch¬16 -* -c16memýy -(ch¬16* -s1 -, cÚ¡ ch¬16* -s2 -, -size_t - -n -); - -59 -BASE_EXPORT - -ch¬16 -* -c16mem£t -(ch¬16* -s -, ch¬16 -c -, -size_t - -n -); - -61  - s¡ršg16_ch¬_Œa™s - { - -62  -ch¬16 - - tch¬_ty³ -; - -63  - tšt_ty³ -; - -67 -COMPILE_ASSERT -(( -št_ty³ -è> ( -ch¬_ty³ -), -uÃx³ùed_ty³_width -); - -69  - g¡d -:: - t¡»amoff - - toff_ty³ -; - -70  -mb¡©e_t - - t¡©e_ty³ -; - -71  - g¡d -:: - tåos -< - t¡©e_ty³ -> - tpos_ty³ -; - -73  -assign -( -ch¬_ty³ -& -c1 -, cÚ¡ ch¬_ty³& -c2 -) { - -74 - gc1 - = -c2 -; - -77  -boÞ - -eq -(cÚ¡ -ch¬_ty³ -& -c1 -, cÚ¡ ch¬_ty³& -c2 -) { - -78  - gc1 - =ð -c2 -; - -80  -boÞ - -É -(cÚ¡ -ch¬_ty³ -& -c1 -, cÚ¡ ch¬_ty³& -c2 -) { - -81  - gc1 - < - gc2 -; - -84  -com·» -(cÚ¡ -ch¬_ty³ -* -s1 -, cÚ¡ ch¬_ty³* -s2 -, -size_t - -n -) { - -85  -c16memcmp -( -s1 -, -s2 -, -n -); - -88  -size_t - -Ëngth -(cÚ¡ -ch¬_ty³ -* -s -) { - -89  -c16Ën -( -s -); - -92 cÚ¡ -ch¬_ty³ -* -fšd -(cÚ¡ ch¬_ty³* -s -, -size_t - -n -, - -93 cÚ¡ -ch¬_ty³ -& -a -) { - -94  -c16memchr -( -s -, -a -, -n -); - -97  -ch¬_ty³ -* -move -(ch¬_ty³* -s1 -, cÚ¡ ch¬_ty³* -s2 -, -size_t - -n -) { - -98  -c16memmove -( -s1 -, -s2 -, -n -); - -101  -ch¬_ty³ -* -cÝy -(ch¬_ty³* -s1 -, cÚ¡ ch¬_ty³* -s2 -, -size_t - -n -) { - -102  -c16memýy -( -s1 -, -s2 -, -n -); - -105  -ch¬_ty³ -* -assign -(ch¬_ty³* -s -, -size_t - -n -, ch¬_ty³ -a -) { - -106  -c16mem£t -( -s -, -a -, -n -); - -109  -št_ty³ - -nÙ_eof -(cÚ¡ iÁ_ty³& -c -) { - -110  -eq_št_ty³ -( -c -, -eof -()) ? 0 : c; - -113  -ch¬_ty³ - -to_ch¬_ty³ -(cÚ¡ -št_ty³ -& -c -) { - -114  -ch¬_ty³ -( -c -); - -117  -št_ty³ - -to_št_ty³ -(cÚ¡ -ch¬_ty³ -& -c -) { - -118  -št_ty³ -( -c -); - -121  -boÞ - -eq_št_ty³ -(cÚ¡ -št_ty³ -& -c1 -, cÚ¡ iÁ_ty³& -c2 -) { - -122  - gc1 - =ð -c2 -; - -125  -št_ty³ - -eof -() { - -126  - g¡©ic_ÿ¡ -< - gšt_ty³ ->( - gEOF -); - -130  - g¡d -:: - tbasic_¡ršg -< - tch¬16 -, - tba£ -:: - t¡ršg16_ch¬_Œa™s -> - t¡ršg16 -; - -132 -BASE_EXPORT - -¡d -:: -o¡»am -& -Ý”©Ü -<<(¡d::o¡»am& -out -, - -133 cÚ¡ -¡ršg16 -& -¡r -); - -136 -BASE_EXPORT -  -PrštTo -(cÚ¡ -¡ršg16 -& -¡r -, -¡d -:: -o¡»am -* -out -); - -179 -‹m¶©e - - -180 -þass - -BASE_EXPORT - -¡d -:: -basic_¡ršg -< -ba£ -:: -ch¬16 -, ba£:: -¡ršg16_ch¬_Œa™s ->; - - @string_piece.cc - -6  - ~"ba£/¡ršgs/¡ršg_p›û.h -" - -8  - ~<®gÜ™hm -> - -9  - ~ - -13 -Çme¥aû - - gba£ - { - -14 - gÇme¥aû - { - -24 -šlše -  -BuždLookupTabË -(cÚ¡ -SŒšgP›û -& -ch¬aù”s_wª‹d -, - -25 -boÞ -* -bË -) { - -26 cÚ¡ -size_t - - gËngth - = -ch¬aù”s_wª‹d -. -Ëngth -(); - -27 cÚ¡ * cÚ¡ - gd©a - = -ch¬aù”s_wª‹d -. -d©a -(); - -28  -size_t - - gi - = 0; i < - gËngth -; ++i) { - -29 - gbË -[ -¡©ic_ÿ¡ -<>( -d©a -[ -i -])] = -Œue -; - -36 #ià! -defšed -( -COMPILER_MSVC -) - -37 -‹m¶©e - -þass - - gBasicSŒšgP›û -< - g¡d -:: -¡ršg ->; - -38 -‹m¶©e - -þass - - gBasicSŒšgP›û -< - g¡ršg16 ->; - -41 -boÞ - - gÝ”©Ü -==(cÚ¡ -SŒšgP›û -& -x -, cÚ¡ - gSŒšgP›û -& - gy -) { - -42 ià( - gx -. -size -(è!ð -y -.size()) - -43  -çl£ -; - -45  - gSŒšgP›û -:: -wÜdmemcmp -( -x -. -d©a -(), -y -.d©a(), x. -size -()) == 0; - -48 - g¡d -:: -o¡»am -& -Ý”©Ü -<<( -¡d -::o¡»am& -o -, cÚ¡ - gSŒšgP›û -& - gp›û -) { - -49 - go -. -wr™e -( -p›û -. -d©a -(), -¡©ic_ÿ¡ -< -¡d -:: -¡»amsize ->Õ›û. -size -())); - -50  - go -; - -53 -Çme¥aû - - gš‹º® - { - -55 - g‹m¶©e -< -ty³Çme - - gSTR -> - -56  -CÝyToSŒšgT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, STR* -rg‘ -) { - -57 ià( - g£lf -. -em±y -()) - -58 - grg‘ --> -þ—r -(); - -60 - grg‘ --> -assign -( -£lf -. -d©a -(), s–f. -size -()); - -63  -CÝyToSŒšg -(cÚ¡ -SŒšgP›û -& -£lf -, -¡d -:: -¡ršg -* -rg‘ -) { - -64 -CÝyToSŒšgT -( -£lf -, -rg‘ -); - -67  -CÝyToSŒšg -(cÚ¡ -SŒšgP›û16 -& -£lf -, -¡ršg16 -* -rg‘ -) { - -68 -CÝyToSŒšgT -( -£lf -, -rg‘ -); - -71 - g‹m¶©e -< -ty³Çme - - gSTR -> - -72  -Aµ’dToSŒšgT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, STR* -rg‘ -) { - -73 ià(! - g£lf -. -em±y -()) - -74 - grg‘ --> -­³nd -( -£lf -. -d©a -(), s–f. -size -()); - -77  -Aµ’dToSŒšg -(cÚ¡ -SŒšgP›û -& -£lf -, -¡d -:: -¡ršg -* -rg‘ -) { - -78 -Aµ’dToSŒšgT -( -£lf -, -rg‘ -); - -81  -Aµ’dToSŒšg -(cÚ¡ -SŒšgP›û16 -& -£lf -, -¡ršg16 -* -rg‘ -) { - -82 -Aµ’dToSŒšgT -( -£lf -, -rg‘ -); - -85 - g‹m¶©e -< -ty³Çme - - gSTR -> - -86 -size_t - -cÝyT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -87 -ty³Çme - -STR -:: -v®ue_ty³ -* -buf -, - -88 -size_t - -n -, - -89 -size_t - -pos -) { - -90 -size_t - - g»t - = -¡d -:: -mš -( -£lf -. -size -(è- -pos -, -n -); - -91 -memýy -( -buf -, -£lf -. -d©a -(è+ -pos -, -»t - * ( -ty³Çme - -STR -:: -v®ue_ty³ -)); - -92  - g»t -; - -95 -size_t - -cÝy -(cÚ¡ -SŒšgP›û -& -£lf -, * -buf -, size_ˆ -n -, size_ˆ -pos -) { - -96  -cÝyT -( -£lf -, -buf -, -n -, -pos -); - -99 -size_t - -cÝy -(cÚ¡ -SŒšgP›û16 -& -£lf -, -ch¬16 -* -buf -, size_ˆ -n -, size_ˆ -pos -) { - -100  -cÝyT -( -£lf -, -buf -, -n -, -pos -); - -103 - g‹m¶©e -< -ty³Çme - - gSTR -> - -104 -size_t - -fšdT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -105 cÚ¡ -BasicSŒšgP›û -< -STR ->& -s -, - -106 -size_t - -pos -) { - -107 ià( - gpos - > - g£lf -. -size -()) - -108  - gBasicSŒšgP›û -< - gSTR ->:: -Åos -; - -110 -ty³Çme - - gBasicSŒšgP›û -< - gSTR ->:: -cÚ¡_™”©Ü - -»suÉ - = - -111 -¡d -:: -£¬ch -( -£lf -. -begš -(è+ -pos -, s–f. -’d -(), -s -.begin(), s.end()); - -112 cÚ¡ -size_t - - gxpos - = - -113 -¡©ic_ÿ¡ -< -size_t ->( -»suÉ - - -£lf -. -begš -()); - -114  - gxpos - + - gs -. -size -(è<ð -£lf -.size(è? -xpos - : -BasicSŒšgP›û -< -STR ->:: -Åos -; - -117 -size_t - -fšd -(cÚ¡ -SŒšgP›û -& -£lf -, cÚ¡ SŒšgP›û& -s -, size_ˆ -pos -) { - -118  -fšdT -( -£lf -, -s -, -pos -); - -121 -size_t - -fšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, cÚ¡ SŒšgP›û16& -s -, size_ˆ -pos -) { - -122  -fšdT -( -£lf -, -s -, -pos -); - -125 - g‹m¶©e -< -ty³Çme - - gSTR -> - -126 -size_t - -fšdT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -127 -ty³Çme - -STR -:: -v®ue_ty³ - -c -, - -128 -size_t - -pos -) { - -129 ià( - gpos - >ð -£lf -. -size -()) - -130  -BasicSŒšgP›û -< -STR ->:: -Åos -; - -132 -ty³Çme - - gBasicSŒšgP›û -< - gSTR ->:: -cÚ¡_™”©Ü - -»suÉ - = - -133 -¡d -:: -fšd -( -£lf -. -begš -(è+ -pos -, s–f. -’d -(), -c -); - -134  - g»suÉ - !ð -£lf -. -’d -() ? - -135 -¡©ic_ÿ¡ -< -size_t ->( -»suÉ - - -£lf -. -begš -()è: -BasicSŒšgP›û -< -STR ->:: -Åos -; - -138 -size_t - -fšd -(cÚ¡ -SŒšgP›û -& -£lf -,  -c -, size_ˆ -pos -) { - -139  -fšdT -( -£lf -, -c -, -pos -); - -142 -size_t - -fšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, -ch¬16 - -c -, size_ˆ -pos -) { - -143  -fšdT -( -£lf -, -c -, -pos -); - -146 - g‹m¶©e -< -ty³Çme - - gSTR -> - -147 -size_t - -rfšdT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -148 cÚ¡ -BasicSŒšgP›û -< -STR ->& -s -, - -149 -size_t - -pos -) { - -150 ià( - g£lf -. -size -(è< - gs -.size()) - -151  - gBasicSŒšgP›û -< - gSTR ->:: -Åos -; - -153 ià( - gs -. -em±y -()) - -154  - g¡d -:: -mš -( -£lf -. -size -(), -pos -); - -156 -ty³Çme - - gBasicSŒšgP›û -< - gSTR ->:: -cÚ¡_™”©Ü - -Ï¡ - = - -157 -£lf -. -begš -(è+ -¡d -:: -mš -(£lf. -size -(è- -s -.size(), -pos -è+ - gs -.size(); - -158 -ty³Çme - - gBasicSŒšgP›û -< - gSTR ->:: -cÚ¡_™”©Ü - -»suÉ - = - -159 -¡d -:: -fšd_’d -( -£lf -. -begš -(), -Ï¡ -, -s -.begš(), s. -’d -()); - -160  - g»suÉ - !ð -Ï¡ - ? - -161 -¡©ic_ÿ¡ -< -size_t ->( -»suÉ - - -£lf -. -begš -()è: -BasicSŒšgP›û -< -STR ->:: -Åos -; - -164 -size_t - -rfšd -(cÚ¡ -SŒšgP›û -& -£lf -, cÚ¡ SŒšgP›û& -s -, size_ˆ -pos -) { - -165  -rfšdT -( -£lf -, -s -, -pos -); - -168 -size_t - -rfšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, cÚ¡ SŒšgP›û16& -s -, size_ˆ -pos -) { - -169  -rfšdT -( -£lf -, -s -, -pos -); - -172 - g‹m¶©e -< -ty³Çme - - gSTR -> - -173 -size_t - -rfšdT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -174 -ty³Çme - -STR -:: -v®ue_ty³ - -c -, - -175 -size_t - -pos -) { - -176 ià( - g£lf -. -size -() == 0) - -177  -BasicSŒšgP›û -< -STR ->:: -Åos -; - -179  -size_t - - gi - = -¡d -:: -mš -( -pos -, -£lf -. -size -() - 1); ; - -180 -- - gi -) { - -181 ià( - g£lf -. -d©a -()[ -i -] =ð -c -) - -182  -i -; - -183 ià( - gi - == 0) - -186  - gBasicSŒšgP›û -< - gSTR ->:: -Åos -; - -189 -size_t - -rfšd -(cÚ¡ -SŒšgP›û -& -£lf -,  -c -, size_ˆ -pos -) { - -190  -rfšdT -( -£lf -, -c -, -pos -); - -193 -size_t - -rfšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, -ch¬16 - -c -, size_ˆ -pos -) { - -194  -rfšdT -( -£lf -, -c -, -pos -); - -198 -size_t - -fšd_fœ¡_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -199 cÚ¡ -SŒšgP›û -& -s -, - -200 -size_t - -pos -) { - -201 ià( - g£lf -. -size -(è=ð0 || -s -.size() == 0) - -202  -SŒšgP›û -:: -Åos -; - -205 ià( - gs -. -size -() == 1) - -206  -fšd -( -£lf -, -s -. -d©a -()[0], -pos -); - -208 -boÞ - - glookup -[ -UCHAR_MAX - + 1] = { -çl£ - }; - -209 -BuždLookupTabË -( -s -, -lookup -); - -210  -size_t - - gi - = -pos -; i < - g£lf -. -size -(); ++i) { - -211 ià( - glookup -[ -¡©ic_ÿ¡ -<>( -£lf -. -d©a -()[ -i -])]) { - -212  - gi -; - -215  - gSŒšgP›û -:: -Åos -; - -219 -size_t - -fšd_fœ¡_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -220 cÚ¡ -SŒšgP›û16 -& -s -, - -221 -size_t - -pos -) { - -222 - gSŒšgP›û16 -:: -cÚ¡_™”©Ü - -found - = - -223 -¡d -:: -fšd_fœ¡_of -( -£lf -. -begš -(è+ -pos -, s–f. -’d -(), -s -.begin(), s.end()); - -224 ià( - gfound - =ð -£lf -. -’d -()) - -225  -SŒšgP›û16 -:: -Åos -; - -226  - gfound - - - g£lf -. -begš -(); - -230 -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -231 cÚ¡ -SŒšgP›û -& -s -, - -232 -size_t - -pos -) { - -233 ià( - g£lf -. -size -() == 0) - -234  -SŒšgP›û -:: -Åos -; - -236 ià( - gs -. -size -() == 0) - -240 ià( - gs -. -size -() == 1) - -241  -fšd_fœ¡_nÙ_of -( -£lf -, -s -. -d©a -()[0], -pos -); - -243 -boÞ - - glookup -[ -UCHAR_MAX - + 1] = { -çl£ - }; - -244 -BuždLookupTabË -( -s -, -lookup -); - -245  -size_t - - gi - = -pos -; i < - g£lf -. -size -(); ++i) { - -246 ià(! - glookup -[ -¡©ic_ÿ¡ -<>( -£lf -. -d©a -()[ -i -])]) { - -247  - gi -; - -250  - gSŒšgP›û -:: -Åos -; - -254 -BASE_EXPORT - -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -255 cÚ¡ -SŒšgP›û16 -& -s -, - -256 -size_t - -pos -) { - -257 ià( - g£lf -. -size -() == 0) - -258  -SŒšgP›û16 -:: -Åos -; - -260  -size_t - - g£lf_i - = -pos -; s–f_˜< - g£lf -. -size -(); ++self_i) { - -261 -boÞ - - gfound - = -çl£ -; - -262  -size_t - - gs_i - = 0; s_˜< - gs -. -size -(); ++s_i) { - -263 ià( - g£lf -[ -£lf_i -] =ð -s -[ -s_i -]) { - -264 -found - = -Œue -; - -268 ià(! - gfound -) - -269  - g£lf_i -; - -271  - gSŒšgP›û16 -:: -Åos -; - -274 - g‹m¶©e -< -ty³Çme - - gSTR -> - -275 -size_t - -fšd_fœ¡_nÙ_ofT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -276 -ty³Çme - -STR -:: -v®ue_ty³ - -c -, - -277 -size_t - -pos -) { - -278 ià( - g£lf -. -size -() == 0) - -279  -BasicSŒšgP›û -< -STR ->:: -Åos -; - -281 ; - gpos - < - g£lf -. -size -(); ++pos) { - -282 ià( - g£lf -. -d©a -()[ -pos -] !ð -c -) { - -283  -pos -; - -286  - gBasicSŒšgP›û -< - gSTR ->:: -Åos -; - -289 -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -290  -c -, - -291 -size_t - -pos -) { - -292  -fšd_fœ¡_nÙ_ofT -( -£lf -, -c -, -pos -); - -295 -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -296 -ch¬16 - -c -, - -297 -size_t - -pos -) { - -298  -fšd_fœ¡_nÙ_ofT -( -£lf -, -c -, -pos -); - -302 -size_t - -fšd_Ï¡_of -(cÚ¡ -SŒšgP›û -& -£lf -, cÚ¡ SŒšgP›û& -s -, size_ˆ -pos -) { - -303 ià( - g£lf -. -size -(è=ð0 || -s -.size() == 0) - -304  -SŒšgP›û -:: -Åos -; - -307 ià( - gs -. -size -() == 1) - -308  -rfšd -( -£lf -, -s -. -d©a -()[0], -pos -); - -310 -boÞ - - glookup -[ -UCHAR_MAX - + 1] = { -çl£ - }; - -311 -BuždLookupTabË -( -s -, -lookup -); - -312  -size_t - - gi - = -¡d -:: -mš -( -pos -, -£lf -. -size -() - 1); ; --i) { - -313 ià( - glookup -[ -¡©ic_ÿ¡ -<>( -£lf -. -d©a -()[ -i -])]) - -314  - gi -; - -315 ià( - gi - == 0) - -318  - gSŒšgP›û -:: -Åos -; - -322 -size_t - -fšd_Ï¡_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -323 cÚ¡ -SŒšgP›û16 -& -s -, - -324 -size_t - -pos -) { - -325 ià( - g£lf -. -size -() == 0) - -326  -SŒšgP›û16 -:: -Åos -; - -328  -size_t - - g£lf_i - = -¡d -:: -mš -( -pos -, -£lf -. -size -() - 1); ; - -329 -- - g£lf_i -) { - -330  -size_t - - gs_i - = 0; s_˜< - gs -. -size -(); s_i++) { - -331 ià( - g£lf -. -d©a -()[ -£lf_i -] =ð -s -[ -s_i -]) - -332  -£lf_i -; - -334 ià( - g£lf_i - == 0) - -337  - gSŒšgP›û16 -:: -Åos -; - -341 -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -342 cÚ¡ -SŒšgP›û -& -s -, - -343 -size_t - -pos -) { - -344 ià( - g£lf -. -size -() == 0) - -345  -SŒšgP›û -:: -Åos -; - -347 -size_t - - gi - = -¡d -:: -mš -( -pos -, -£lf -. -size -() - 1); - -348 ià( - gs -. -size -() == 0) - -349  -i -; - -352 ià( - gs -. -size -() == 1) - -353  -fšd_Ï¡_nÙ_of -( -£lf -, -s -. -d©a -()[0], -pos -); - -355 -boÞ - - glookup -[ -UCHAR_MAX - + 1] = { -çl£ - }; - -356 -BuždLookupTabË -( -s -, -lookup -); - -357 ; ; -- - gi -) { - -358 ià(! - glookup -[ -¡©ic_ÿ¡ -<>( -£lf -. -d©a -()[ -i -])]) - -359  - gi -; - -360 ià( - gi - == 0) - -363  - gSŒšgP›û -:: -Åos -; - -367 -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -368 cÚ¡ -SŒšgP›û16 -& -s -, - -369 -size_t - -pos -) { - -370 ià( - g£lf -. -size -() == 0) - -371  -SŒšgP›û -:: -Åos -; - -373  -size_t - - g£lf_i - = -¡d -:: -mš -( -pos -, -£lf -. -size -() - 1); ; --self_i) { - -374 -boÞ - - gfound - = -çl£ -; - -375  -size_t - - gs_i - = 0; s_˜< - gs -. -size -(); s_i++) { - -376 ià( - g£lf -. -d©a -()[ -£lf_i -] =ð -s -[ -s_i -]) { - -377 -found - = -Œue -; - -381 ià(! - gfound -) - -382  - g£lf_i -; - -383 ià( - g£lf_i - == 0) - -386  - gSŒšgP›û16 -:: -Åos -; - -389 - g‹m¶©e -< -ty³Çme - - gSTR -> - -390 -size_t - -fšd_Ï¡_nÙ_ofT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -391 -ty³Çme - -STR -:: -v®ue_ty³ - -c -, - -392 -size_t - -pos -) { - -393 ià( - g£lf -. -size -() == 0) - -394  -BasicSŒšgP›û -< -STR ->:: -Åos -; - -396  -size_t - - gi - = -¡d -:: -mš -( -pos -, -£lf -. -size -() - 1); ; --i) { - -397 ià( - g£lf -. -d©a -()[ -i -] !ð -c -) - -398  -i -; - -399 ià( - gi - == 0) - -402  - gBasicSŒšgP›û -< - gSTR ->:: -Åos -; - -405 -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -406  -c -, - -407 -size_t - -pos -) { - -408  -fšd_Ï¡_nÙ_ofT -( -£lf -, -c -, -pos -); - -411 -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -412 -ch¬16 - -c -, - -413 -size_t - -pos -) { - -414  -fšd_Ï¡_nÙ_ofT -( -£lf -, -c -, -pos -); - -417 - g‹m¶©e -< -ty³Çme - - gSTR -> - -418 - gBasicSŒšgP›û -< - gSTR -> -sub¡rT -(cÚ¡ -BasicSŒšgP›û -< -STR ->& -£lf -, - -419 -size_t - -pos -, - -420 -size_t - -n -) { - -421 ià( - gpos - > - g£lf -. -size -()èpo ð -£lf -.size(); - -422 ià( - gn - > - g£lf -. -size -(è- - gpos -èÀð -£lf -.size(è- -pos -; - -423  - gBasicSŒšgP›û -< - gSTR ->( - g£lf -. -d©a -(è+ - gpos -, - gn -); - -426 -SŒšgP›û - -sub¡r -(cÚ¡ SŒšgP›û& -£lf -, - -427 -size_t - -pos -, - -428 -size_t - -n -) { - -429  -sub¡rT -( -£lf -, -pos -, -n -); - -432 -SŒšgP›û16 - -sub¡r -(cÚ¡ SŒšgP›û16& -£lf -, - -433 -size_t - -pos -, - -434 -size_t - -n -) { - -435  -sub¡rT -( -£lf -, -pos -, -n -); - - @string_piece.h - -22 #iâdeà -BASE_STRINGS_STRING_PIECE_H_ - - -23  - #BASE_STRINGS_STRING_PIECE_H_ - - - ) - -25  - ~<¡ddef.h -> - -27  - ~ - -28  - ~<¡ršg -> - -30  - ~"ba£/ba£_expÜt.h -" - -31  - ~"ba£/basiùy³s.h -" - -33  - ~"ba£/¡ršgs/¡ršg16.h -" - -35 -Çme¥aû - - gba£ - { - -37 - g‹m¶©e - < -ty³Çme - - gSTRING_TYPE -> -þass - - gBasicSŒšgP›û -; - -38  - gBasicSŒšgP›û -< - t¡d -:: - t¡ršg -> - tSŒšgP›û -; - -39  - gBasicSŒšgP›û -< - t¡ršg16 -> - tSŒšgP›û16 -; - -50 -Çme¥aû - - gš‹º® - { - -52 -BASE_EXPORT -  -CÝyToSŒšg -(cÚ¡ -SŒšgP›û -& -£lf -, -¡d -:: -¡ršg -* -rg‘ -); - -53 -BASE_EXPORT -  -CÝyToSŒšg -(cÚ¡ -SŒšgP›û16 -& -£lf -, -¡ršg16 -* -rg‘ -); - -55 -BASE_EXPORT -  -Aµ’dToSŒšg -(cÚ¡ -SŒšgP›û -& -£lf -, -¡d -:: -¡ršg -* -rg‘ -); - -56 -BASE_EXPORT -  -Aµ’dToSŒšg -(cÚ¡ -SŒšgP›û16 -& -£lf -, -¡ršg16 -* -rg‘ -); - -58 -BASE_EXPORT - -size_t - -cÝy -(cÚ¡ -SŒšgP›û -& -£lf -, - -59 * -buf -, - -60 -size_t - -n -, - -61 -size_t - -pos -); - -62 -BASE_EXPORT - -size_t - -cÝy -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -63 -ch¬16 -* -buf -, - -64 -size_t - -n -, - -65 -size_t - -pos -); - -67 -BASE_EXPORT - -size_t - -fšd -(cÚ¡ -SŒšgP›û -& -£lf -, - -68 cÚ¡ -SŒšgP›û -& -s -, - -69 -size_t - -pos -); - -70 -BASE_EXPORT - -size_t - -fšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -71 cÚ¡ -SŒšgP›û16 -& -s -, - -72 -size_t - -pos -); - -73 -BASE_EXPORT - -size_t - -fšd -(cÚ¡ -SŒšgP›û -& -£lf -, - -74  -c -, - -75 -size_t - -pos -); - -76 -BASE_EXPORT - -size_t - -fšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -77 -ch¬16 - -c -, - -78 -size_t - -pos -); - -80 -BASE_EXPORT - -size_t - -rfšd -(cÚ¡ -SŒšgP›û -& -£lf -, - -81 cÚ¡ -SŒšgP›û -& -s -, - -82 -size_t - -pos -); - -83 -BASE_EXPORT - -size_t - -rfšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -84 cÚ¡ -SŒšgP›û16 -& -s -, - -85 -size_t - -pos -); - -86 -BASE_EXPORT - -size_t - -rfšd -(cÚ¡ -SŒšgP›û -& -£lf -, - -87  -c -, - -88 -size_t - -pos -); - -89 -BASE_EXPORT - -size_t - -rfšd -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -90 -ch¬16 - -c -, - -91 -size_t - -pos -); - -93 -BASE_EXPORT - -size_t - -fšd_fœ¡_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -94 cÚ¡ -SŒšgP›û -& -s -, - -95 -size_t - -pos -); - -96 -BASE_EXPORT - -size_t - -fšd_fœ¡_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -97 cÚ¡ -SŒšgP›û16 -& -s -, - -98 -size_t - -pos -); - -100 -BASE_EXPORT - -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -101 cÚ¡ -SŒšgP›û -& -s -, - -102 -size_t - -pos -); - -103 -BASE_EXPORT - -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -104 cÚ¡ -SŒšgP›û16 -& -s -, - -105 -size_t - -pos -); - -106 -BASE_EXPORT - -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -107  -c -, - -108 -size_t - -pos -); - -109 -BASE_EXPORT - -size_t - -fšd_fœ¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -110 -ch¬16 - -c -, - -111 -size_t - -pos -); - -113 -BASE_EXPORT - -size_t - -fšd_Ï¡_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -114 cÚ¡ -SŒšgP›û -& -s -, - -115 -size_t - -pos -); - -116 -BASE_EXPORT - -size_t - -fšd_Ï¡_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -117 cÚ¡ -SŒšgP›û16 -& -s -, - -118 -size_t - -pos -); - -119 -BASE_EXPORT - -size_t - -fšd_Ï¡_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -120  -c -, - -121 -size_t - -pos -); - -122 -BASE_EXPORT - -size_t - -fšd_Ï¡_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -123 -ch¬16 - -c -, - -124 -size_t - -pos -); - -126 -BASE_EXPORT - -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -127 cÚ¡ -SŒšgP›û -& -s -, - -128 -size_t - -pos -); - -129 -BASE_EXPORT - -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -130 cÚ¡ -SŒšgP›û16 -& -s -, - -131 -size_t - -pos -); - -132 -BASE_EXPORT - -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û16 -& -£lf -, - -133 -ch¬16 - -c -, - -134 -size_t - -pos -); - -135 -BASE_EXPORT - -size_t - -fšd_Ï¡_nÙ_of -(cÚ¡ -SŒšgP›û -& -£lf -, - -136  -c -, - -137 -size_t - -pos -); - -139 -BASE_EXPORT - -SŒšgP›û - -sub¡r -(cÚ¡ SŒšgP›û& -£lf -, - -140 -size_t - -pos -, - -141 -size_t - -n -); - -142 -BASE_EXPORT - -SŒšgP›û16 - -sub¡r -(cÚ¡ SŒšgP›û16& -£lf -, - -143 -size_t - -pos -, - -144 -size_t - -n -); - -146 #ià! -defšed -( -NDEBUG -è|| defšed( -DCHECK_ALWAYS_ON -) - -148 -BASE_EXPORT -  -As£¹I‹¿tÜsInOrd” -( -¡d -:: -¡ršg -:: -cÚ¡_™”©Ü - -begš -, - -149 -¡d -:: -¡ršg -:: -cÚ¡_™”©Ü - -’d -); - -150 -BASE_EXPORT -  -As£¹I‹¿tÜsInOrd” -( -¡ršg16 -:: -cÚ¡_™”©Ü - -begš -, - -151 -¡ršg16 -:: -cÚ¡_™”©Ü - -’d -); - -164 - g‹m¶©e - < -ty³Çme - - gSTRING_TYPE -> cÏs  - cBasicSŒšgP›û - { - -165 - gpublic -: - -167  -size_t - - tsize_ty³ -; - -168  -ty³Çme - - tSTRING_TYPE -:: - tv®ue_ty³ - value_type; - -169 cÚ¡ - tv®ue_ty³ -* - tpoš‹r -; - -170 cÚ¡ - tv®ue_ty³ -& - t»ã»nû -; - -171 cÚ¡ - tv®ue_ty³ -& - tcÚ¡_»ã»nû -; - -172  -±rdiff_t - - tdifã»nû_ty³ -; - -173 cÚ¡ - tv®ue_ty³ -* - tcÚ¡_™”©Ü -; - -174  - g¡d -:: - t»v”£_™”©Ü -< - tcÚ¡_™”©Ü -> - tcÚ¡_»v”£_™”©Ü -; - -176 cÚ¡ -size_ty³ - - gÅos -; - -178 - gpublic -: - -182 -BasicSŒšgP›û -(è: -±r_ -( -NULL -), -Ëngth_ -(0) {} - -183 -BasicSŒšgP›û -(cÚ¡ -v®ue_ty³ -* -¡r -) - -184 : -±r_ -( -¡r -), - -185 -Ëngth_ -(( -¡r - =ð -NULL -è? 0 : -STRING_TYPE -:: -Œa™s_ty³ -:: -Ëngth -(str)) {} - -186 -BasicSŒšgP›û -(cÚ¡ -STRING_TYPE -& -¡r -) - -187 : -±r_ -( -¡r -. -d©a -()), -Ëngth_ -(¡r. -size -()) {} - -188 -BasicSŒšgP›û -(cÚ¡ -v®ue_ty³ -* -off£t -, -size_ty³ - -Ën -) - -189 : -±r_ -( -off£t -), -Ëngth_ -( -Ën -) {} - -190 -BasicSŒšgP›û -(cÚ¡ -ty³Çme - -STRING_TYPE -:: -cÚ¡_™”©Ü -& -begš -, - -191 cÚ¡ -ty³Çme - -STRING_TYPE -:: -cÚ¡_™”©Ü -& -’d -) { - -192 #ià! -defšed -( -NDEBUG -è|| defšed( -DCHECK_ALWAYS_ON -) - -195 -š‹º® -:: -As£¹I‹¿tÜsInOrd” -( -begš -, -’d -); - -197 - gËngth_ - = -¡©ic_ÿ¡ -< -size_t ->( -¡d -:: -di¡ªû -( -begš -, -’d -)); - -201 - g±r_ - = -Ëngth_ - > 0 ? &* -begš - : -nuαr -; - -208 cÚ¡ -v®ue_ty³ -* -d©a -(ècÚ¡ {  - g±r_ -; } - -209 -size_ty³ - -size -(ècÚ¡ {  - gËngth_ -; } - -210 -size_ty³ - -Ëngth -(ècÚ¡ {  - gËngth_ -; } - -211 -boÞ - -em±y -(ècÚ¡ {  - gËngth_ - == 0; } - -213  -þ—r -() { - -214 - g±r_ - = -NULL -; - -215 - gËngth_ - = 0; - -217  -£t -(cÚ¡ -v®ue_ty³ -* -d©a -, -size_ty³ - -Ën -) { - -218 - g±r_ - = -d©a -; - -219 - gËngth_ - = -Ën -; - -221  -£t -(cÚ¡ -v®ue_ty³ -* -¡r -) { - -222 - g±r_ - = -¡r -; - -223 - gËngth_ - = -¡r - ? -STRING_TYPE -:: -Œa™s_ty³ -:: -Ëngth -(str) : 0; - -226 -v®ue_ty³ - - gÝ”©Ü -[]( -size_ty³ - - gi -ècÚ¡ {  - g±r_ -[ -i -]; } - -228  -»move_´efix -( -size_ty³ - -n -) { - -229 - g±r_ - +ð -n -; - -230 - gËngth_ - -ð -n -; - -233  -»move_suffix -( -size_ty³ - -n -) { - -234 - gËngth_ - -ð -n -; - -237  -com·» -(cÚ¡ -BasicSŒšgP›û -< -STRING_TYPE ->& -x -) const { - -238  - gr - = -wÜdmemcmp -( - -239 -±r_ -, -x -.±r_, ( -Ëngth_ - < x.length_ ?†ength_ : x.length_)); - -240 ià( - gr - == 0) { - -241 ià( -Ëngth_ - < -x -.Ëngth_è -r - = -1; - -242 ià( - gËngth_ - > - gx -.Ëngth_è - gr - = +1; - -244  - gr -; - -247 -STRING_TYPE - -as_¡ršg -() const { - -249  -em±y -(è? -STRING_TYPE -(è: STRING_TYPE( -d©a -(), -size -()); - -252 -cÚ¡_™”©Ü - -begš -(ècÚ¡ {  - g±r_ -; } - -253 -cÚ¡_™”©Ü - -’d -(ècÚ¡ {  - g±r_ - + - gËngth_ -; } - -254 -cÚ¡_»v”£_™”©Ü - -rbegš -() const { - -255  -cÚ¡_»v”£_™”©Ü -( -±r_ - + -Ëngth_ -); - -257 -cÚ¡_»v”£_™”©Ü - -»nd -() const { - -258  -cÚ¡_»v”£_™”©Ü -( -±r_ -); - -261 -size_ty³ - -max_size -(ècÚ¡ {  - gËngth_ -; } - -262 -size_ty³ - -ÿ·c™y -(ècÚ¡ {  - gËngth_ -; } - -264  -wÜdmemcmp -(cÚ¡ -v®ue_ty³ -* -p -, - -265 cÚ¡ -v®ue_ty³ -* -p2 -, - -266 -size_ty³ - -N -) { - -267  - gSTRING_TYPE -:: -Œa™s_ty³ -:: -com·» -( -p -, -p2 -, -N -); - -272  -CÝyToSŒšg -( -STRING_TYPE -* -rg‘ -) const { - -273 - gš‹º® -:: -CÝyToSŒšg -(* -this -, -rg‘ -); - -276  -Aµ’dToSŒšg -( -STRING_TYPE -* -rg‘ -) const { - -277 - gš‹º® -:: -Aµ’dToSŒšg -(* -this -, -rg‘ -); - -280 -size_ty³ - -cÝy -( -v®ue_ty³ -* -buf -, size_ty³ -n -, size_ty³ -pos - = 0) const { - -281  -š‹º® -:: -cÝy -(* -this -, -buf -, -n -, -pos -); - -285 -boÞ - -¡¬ts_w™h -(cÚ¡ -BasicSŒšgP›û -& -x -) const { - -286  (( - gthis --> - gËngth_ - >ð -x -. -Ëngth_ -) && - -287 ( -wÜdmemcmp -( -this --> -±r_ -, -x -.±r_, x. -Ëngth_ -) == 0)); - -291 -boÞ - -’ds_w™h -(cÚ¡ -BasicSŒšgP›û -& -x -) const { - -292  (( - gthis --> - gËngth_ - >ð -x -. -Ëngth_ -) && - -293 ( -wÜdmemcmp -( -this --> -±r_ - + (this-> -Ëngth_ -- -x -.length_), - -294 -x -. -±r_ -, x. -Ëngth_ -) == 0)); - -298 -size_ty³ - -fšd -(cÚ¡ -BasicSŒšgP›û -< -STRING_TYPE ->& -s -, - -299 -size_ty³ - -pos - = 0) const { - -300  -š‹º® -:: -fšd -(* -this -, -s -, -pos -); - -302 -size_ty³ - -fšd -( -v®ue_ty³ - -c -, size_ty³ -pos - = 0) const { - -303  -š‹º® -:: -fšd -(* -this -, -c -, -pos -); - -307 -size_ty³ - -rfšd -(cÚ¡ -BasicSŒšgP›û -& -s -, - -308 -size_ty³ - -pos - = -BasicSŒšgP›û -:: -Åos -) const { - -309  -š‹º® -:: -rfšd -(* -this -, -s -, -pos -); - -311 -size_ty³ - -rfšd -( -v®ue_ty³ - -c -, size_ty³ -pos - = -BasicSŒšgP›û -:: -Åos -) const { - -312  -š‹º® -:: -rfšd -(* -this -, -c -, -pos -); - -316 -size_ty³ - -fšd_fœ¡_of -(cÚ¡ -BasicSŒšgP›û -& -s -, - -317 -size_ty³ - -pos - = 0) const { - -318  -š‹º® -:: -fšd_fœ¡_of -(* -this -, -s -, -pos -); - -320 -size_ty³ - -fšd_fœ¡_of -( -v®ue_ty³ - -c -, size_ty³ -pos - = 0) const { - -321  -fšd -( -c -, -pos -); - -325 -size_ty³ - -fšd_fœ¡_nÙ_of -(cÚ¡ -BasicSŒšgP›û -& -s -, - -326 -size_ty³ - -pos - = 0) const { - -327  -š‹º® -:: -fšd_fœ¡_nÙ_of -(* -this -, -s -, -pos -); - -329 -size_ty³ - -fšd_fœ¡_nÙ_of -( -v®ue_ty³ - -c -, size_ty³ -pos - = 0) const { - -330  -š‹º® -:: -fšd_fœ¡_nÙ_of -(* -this -, -c -, -pos -); - -334 -size_ty³ - -fšd_Ï¡_of -(cÚ¡ -BasicSŒšgP›û -& -s -, - -335 -size_ty³ - -pos - = -BasicSŒšgP›û -:: -Åos -) const { - -336  -š‹º® -:: -fšd_Ï¡_of -(* -this -, -s -, -pos -); - -338 -size_ty³ - -fšd_Ï¡_of -( -v®ue_ty³ - -c -, - -339 -size_ty³ - -pos - = -BasicSŒšgP›û -:: -Åos -) const { - -340  -rfšd -( -c -, -pos -); - -344 -size_ty³ - -fšd_Ï¡_nÙ_of -(cÚ¡ -BasicSŒšgP›û -& -s -, - -345 -size_ty³ - -pos - = -BasicSŒšgP›û -:: -Åos -) const { - -346  -š‹º® -:: -fšd_Ï¡_nÙ_of -(* -this -, -s -, -pos -); - -348 -size_ty³ - -fšd_Ï¡_nÙ_of -( -v®ue_ty³ - -c -, - -349 -size_ty³ - -pos - = -BasicSŒšgP›û -:: -Åos -) const { - -350  -š‹º® -:: -fšd_Ï¡_nÙ_of -(* -this -, -c -, -pos -); - -354 -BasicSŒšgP›û - -sub¡r -( -size_ty³ - -pos -, - -355 -size_ty³ - -n - = -BasicSŒšgP›û -:: -Åos -) const { - -356  -š‹º® -:: -sub¡r -(* -this -, -pos -, -n -); - -359 - g´Ùeùed -: - -360 cÚ¡ -v®ue_ty³ -* -±r_ -; - -361 -size_ty³ - - gËngth_ -; - -364 - g‹m¶©e - < -ty³Çme - - gSTRING_TYPE -> - -365 cÚ¡ -ty³Çme - - gBasicSŒšgP›û -< - gSTRING_TYPE ->:: -size_ty³ - - -366 -BasicSŒšgP›û -< -STRING_TYPE ->:: -Åos - = - -367 -ty³Çme - -BasicSŒšgP›û -< -STRING_TYPE ->:: -size_ty³ -(-1); - -370 #ià! - $defšed -( -COMPILER_MSVC -) - -371 -‹m¶©e - -þass - -BASE_EXPORT - -BasicSŒšgP›û -< -¡d -:: -¡ršg ->; - -372 -‹m¶©e - -þass - -BASE_EXPORT - -BasicSŒšgP›û -< -¡ršg16 ->; - -377 -BASE_EXPORT - -boÞ - -Ý”©Ü -==(cÚ¡ -SŒšgP›û -& -x -, cÚ¡ SŒšgP›û& -y -); - -379 -šlše - -boÞ - -Ý”©Ü -!=(cÚ¡ -SŒšgP›û -& -x -, cÚ¡ SŒšgP›û& -y -) { - -380  !( -x - =ð -y -); - -381 - } -} - -383 -šlše - -boÞ - - gÝ”©Ü -<(cÚ¡ - gSŒšgP›û -& - gx -, cÚ¡ SŒšgP›û& - gy -) { - -384 cÚ¡  - gr - = -SŒšgP›û -:: -wÜdmemcmp -( - -385 -x -. -d©a -(), -y -.d©a(), (x. -size -() < y.size() ? x.size() : y.size())); - -386  (( - gr - < 0è|| (Ô =ð0è&& ( -x -. -size -(è< -y -.size()))); - -389 -šlše - -boÞ - - gÝ”©Ü ->(cÚ¡ - gSŒšgP›û -& - gx -, cÚ¡ SŒšgP›û& - gy -) { - -390  - gy - < - gx -; - -393 -šlše - -boÞ - - gÝ”©Ü -<=(cÚ¡ -SŒšgP›û -& -x -, cÚ¡ - gSŒšgP›û -& - gy -) { - -394  !( - gx - > - gy -); - -397 -šlše - -boÞ - - gÝ”©Ü ->=(cÚ¡ -SŒšgP›û -& -x -, cÚ¡ - gSŒšgP›û -& - gy -) { - -398  !( - gx - < - gy -); - -403 -šlše - -boÞ - - gÝ”©Ü -==(cÚ¡ -SŒšgP›û16 -& -x -, cÚ¡ - gSŒšgP›û16 -& - gy -) { - -404 ià( - gx -. -size -(è!ð -y -.size()) - -405  -çl£ -; - -407  - gSŒšgP›û16 -:: -wÜdmemcmp -( -x -. -d©a -(), -y -.d©a(), x. -size -()) == 0; - -410 -šlše - -boÞ - - gÝ”©Ü -!=(cÚ¡ -SŒšgP›û16 -& -x -, cÚ¡ - gSŒšgP›û16 -& - gy -) { - -411  !( - gx - =ð -y -); - -414 -šlše - -boÞ - - gÝ”©Ü -<(cÚ¡ - gSŒšgP›û16 -& - gx -, cÚ¡ SŒšgP›û16& - gy -) { - -415 cÚ¡  - gr - = -SŒšgP›û16 -:: -wÜdmemcmp -( - -416 -x -. -d©a -(), -y -.d©a(), (x. -size -() < y.size() ? x.size() : y.size())); - -417  (( - gr - < 0è|| (Ô =ð0è&& ( -x -. -size -(è< -y -.size()))); - -420 -šlše - -boÞ - - gÝ”©Ü ->(cÚ¡ - gSŒšgP›û16 -& - gx -, cÚ¡ SŒšgP›û16& - gy -) { - -421  - gy - < - gx -; - -424 -šlše - -boÞ - - gÝ”©Ü -<=(cÚ¡ -SŒšgP›û16 -& -x -, cÚ¡ - gSŒšgP›û16 -& - gy -) { - -425  !( - gx - > - gy -); - -428 -šlše - -boÞ - - gÝ”©Ü ->=(cÚ¡ -SŒšgP›û16 -& -x -, cÚ¡ - gSŒšgP›û16 -& - gy -) { - -429  !( - gx - < - gy -); - -432 -BASE_EXPORT - - g¡d -:: -o¡»am -& -Ý”©Ü -<<( -¡d -::o¡»am& -o -, - -433 cÚ¡ - gSŒšgP›û -& - gp›û -); - - @/usr/include/stdio.h - -23 #iâdeà -_STDIO_H - - -25 #ià! -defšed - -__Ãed_FILE - && !defšed -__Ãed___FILE - - -26  - #_STDIO_H - 1 - - ) - -27  - ~<ã©u»s.h -> - -29 - g__BEGIN_DECLS - - -31  - #__Ãed_size_t - - - ) - -32  - #__Ãed_NULL - - - ) - -33  - ~<¡ddef.h -> - -35  - ~ - -36  - #__Ãed_FILE - - - ) - -37  - #__Ãed___FILE - - - ) - -41 #ià! -defšed - -__FILE_defšed - && defšed -__Ãed_FILE - - -44  - g_IO_FILE -; - -46 -__BEGIN_NAMESPACE_STD - - -48  -_IO_FILE - - tFILE -; - -49 - g__END_NAMESPACE_STD - - -50 #ià -defšed - -__USE_LARGEFILE64 - || defšed -__USE_SVID - || defšed -__USE_POSIX - \ - -51 || -defšed - - g__USE_BSD - || defšed - g__USE_ISOC99 - || defšed - g__USE_XOPEN - \ - -52 || -defšed - -__USE_POSIX2 - - -53 - $__USING_NAMESPACE_STD -( -FILE -) - -56  - #__FILE_defšed - 1 - - ) - -58 #undeà -__Ãed_FILE - - -61 #ià! -defšed - -____FILE_defšed - && defšed -__Ãed___FILE - - -64  -_IO_FILE - - t__FILE -; - -66  - #____FILE_defšed - 1 - - ) - -68 #undeà -__Ãed___FILE - - -71 #ifdef -_STDIO_H - - -72  - #_STDIO_USES_IOSTREAM - - - ) - -74  - ~ - -76 #ià -defšed - -__USE_XOPEN - || defšed -__USE_XOPEN2K8 - - -77 #ifdeà -__GNUC__ - - -78 #iâdeà -_VA_LIST_DEFINED - - -79  -_G_va_li¡ - - tva_li¡ -; - -80  - #_VA_LIST_DEFINED - - - ) - -83  - ~<¡d¬g.h -> - -87 #ifdeà -__USE_XOPEN2K8 - - -88 #iâdeà -__off_t_defšed - - -89 #iâdeà -__USE_FILE_OFFSET64 - - -90  -__off_t - - toff_t -; - -92  -__off64_t - - toff_t -; - -94  - #__off_t_defšed - - - ) - -96 #ià -defšed - -__USE_LARGEFILE64 - && !defšed -__off64_t_defšed - - -97  -__off64_t - - toff64_t -; - -98  - #__off64_t_defšed - - - ) - -101 #iâdeà -__ssize_t_defšed - - -102  -__ssize_t - - tssize_t -; - -103  - #__ssize_t_defšed - - - ) - -108 -__BEGIN_NAMESPACE_STD - - -109 #iâdeà -__USE_FILE_OFFSET64 - - -110  -_G_åos_t - - tåos_t -; - -112  -_G_åos64_t - - tåos_t -; - -114 -__END_NAMESPACE_STD - - -115 #ifdeà -__USE_LARGEFILE64 - - -116  -_G_åos64_t - - tåos64_t -; - -120  - #_IOFBF - 0 - - ) - -121  - #_IOLBF - 1 - - ) - -122  - #_IONBF - 2 - - ) - -126 #iâdeà -BUFSIZ - - -127  - #BUFSIZ - -_IO_BUFSIZ - - - ) - -133 #iâdeà -EOF - - -134  - #EOF - (-1) - - ) - -140  - #SEEK_SET - 0 - - ) - -141  - #SEEK_CUR - 1 - - ) - -142  - #SEEK_END - 2 - - ) - -143 #ifdeà -__USE_GNU - - -144  - #SEEK_DATA - 3 - - ) - -145  - #SEEK_HOLE - 4 - - ) - -149 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN - - -151  - #P_tmpdœ - "/tmp" - - ) - -164  - ~ - -168  -_IO_FILE - * -¡dš -; - -169  -_IO_FILE - * -¡dout -; - -170  -_IO_FILE - * -¡d”r -; - -172  - #¡dš - -¡dš - - - ) - -173  - #¡dout - -¡dout - - - ) - -174  - #¡d”r - -¡d”r - - - ) - -176 -__BEGIN_NAMESPACE_STD - - -178  - $»move - (cÚ¡ * -__fž’ame -è -__THROW -; - -180  - $»Çme - (cÚ¡ * -__Þd -, cÚ¡ * -__Ãw -è -__THROW -; - -181 -__END_NAMESPACE_STD - - -183 #ifdeà -__USE_ATFILE - - -185  - $»Çm—t - ( -__Þdfd -, cÚ¡ * -__Þd -,  -__Ãwfd -, - -186 cÚ¡ * -__Ãw -è -__THROW -; - -189 -__BEGIN_NAMESPACE_STD - - -194 #iâdeà -__USE_FILE_OFFSET64 - - -195 -FILE - * - $tmpfže - (è -__wur -; - -197 #ifdeà -__REDIRECT - - -198 -FILE - * - `__REDIRECT - ( -tmpfže -, (), -tmpfže64 -è -__wur -; - -200  - #tmpfže - -tmpfže64 - - - ) - -204 #ifdeà -__USE_LARGEFILE64 - - -205 -FILE - * - $tmpfže64 - (è -__wur -; - -209 * - $tm²am - (* -__s -è -__THROW - -__wur -; - -210 -__END_NAMESPACE_STD - - -212 #ifdeà -__USE_MISC - - -215 * - $tm²am_r - (* -__s -è -__THROW - -__wur -; - -219 #ià -defšed - -__USE_SVID - || defšed -__USE_XOPEN - - -227 * - $‹m²am - (cÚ¡ * -__dœ -, cÚ¡ * -__pfx -) - -228 -__THROW - -__©Œibu‹_m®loc__ - -__wur -; - -232 -__BEGIN_NAMESPACE_STD - - -237  - `fþo£ - ( -FILE - * -__¡»am -); - -242  - `fæush - ( -FILE - * -__¡»am -); - -243 -__END_NAMESPACE_STD - - -245 #ifdeà -__USE_MISC - - -252  - `fæush_uÆocked - ( -FILE - * -__¡»am -); - -255 #ifdeà -__USE_GNU - - -262  - `fþo£®l - (); - -266 -__BEGIN_NAMESPACE_STD - - -267 #iâdeà -__USE_FILE_OFFSET64 - - -272 -FILE - * - $fÝ’ - (cÚ¡ * -__»¡riù - -__fž’ame -, - -273 cÚ¡ * -__»¡riù - -__modes -è -__wur -; - -278 -FILE - * - $äeÝ’ - (cÚ¡ * -__»¡riù - -__fž’ame -, - -279 cÚ¡ * -__»¡riù - -__modes -, - -280 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -282 #ifdeà -__REDIRECT - - -283 -FILE - * - `__REDIRECT - ( -fÝ’ -, (cÚ¡ * -__»¡riù - -__fž’ame -, - -284 cÚ¡ * -__»¡riù - -__modes -), -fÝ’64 -) - -285 -__wur -; - -286 -FILE - * - `__REDIRECT - ( -äeÝ’ -, (cÚ¡ * -__»¡riù - -__fž’ame -, - -287 cÚ¡ * -__»¡riù - -__modes -, - -288 -FILE - * -__»¡riù - -__¡»am -), -äeÝ’64 -) - -289 -__wur -; - -291  - #fÝ’ - -fÝ’64 - - - ) - -292  - #äeÝ’ - -äeÝ’64 - - - ) - -295 -__END_NAMESPACE_STD - - -296 #ifdeà -__USE_LARGEFILE64 - - -297 -FILE - * - $fÝ’64 - (cÚ¡ * -__»¡riù - -__fž’ame -, - -298 cÚ¡ * -__»¡riù - -__modes -è -__wur -; - -299 -FILE - * - $äeÝ’64 - (cÚ¡ * -__»¡riù - -__fž’ame -, - -300 cÚ¡ * -__»¡riù - -__modes -, - -301 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -304 #ifdef -__USE_POSIX - - -306 -FILE - * - $fdÝ’ - ( -__fd -, cÚ¡ * -__modes -è -__THROW - -__wur -; - -309 #ifdef -__USE_GNU - - -312 -FILE - * - $fÝ’cook› - (* -__»¡riù - -__magic_cook› -, - -313 cÚ¡ * -__»¡riù - -__modes -, - -314 -_IO_cook›_io_funùiÚs_t - -__io_funcs -è -__THROW - -__wur -; - -317 #ifdeà -__USE_XOPEN2K8 - - -319 -FILE - * - $fmemÝ’ - (* -__s -, -size_t - -__Ën -, cÚ¡ * -__modes -) - -320 -__THROW - -__wur -; - -325 -FILE - * - $Ý’_mem¡»am - (** -__buæoc -, -size_t - * -__siz–oc -è -__THROW - -__wur -; - -329 -__BEGIN_NAMESPACE_STD - - -332  - $£tbuf - ( -FILE - * -__»¡riù - -__¡»am -, *__»¡riù -__buf -è -__THROW -; - -336  - $£tvbuf - ( -FILE - * -__»¡riù - -__¡»am -, *__»¡riù -__buf -, - -337  -__modes -, -size_t - -__n -è -__THROW -; - -338 -__END_NAMESPACE_STD - - -340 #ifdef -__USE_BSD - - -343  - $£tbufãr - ( -FILE - * -__»¡riù - -__¡»am -, *__»¡riù -__buf -, - -344 -size_t - -__size -è -__THROW -; - -347  - $£Žšebuf - ( -FILE - * -__¡»am -è -__THROW -; - -351 -__BEGIN_NAMESPACE_STD - - -356  - `årštf - ( -FILE - * -__»¡riù - -__¡»am -, - -357 cÚ¡ * -__»¡riù - -__fÜm© -, ...); - -362  - `´štf - (cÚ¡ * -__»¡riù - -__fÜm© -, ...); - -364  - $¥rštf - (* -__»¡riù - -__s -, - -365 cÚ¡ * -__»¡riù - -__fÜm© -, ...è -__THROWNL -; - -371  - `vårštf - ( -FILE - * -__»¡riù - -__s -, cÚ¡ *__»¡riù -__fÜm© -, - -372 -_G_va_li¡ - -__¬g -); - -377  - `v´štf - (cÚ¡ * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -); - -379  - $v¥rštf - (* -__»¡riù - -__s -, cÚ¡ *__»¡riù -__fÜm© -, - -380 -_G_va_li¡ - -__¬g -è -__THROWNL -; - -381 -__END_NAMESPACE_STD - - -383 #ià -defšed - -__USE_BSD - || defšed -__USE_ISOC99 - || defšed -__USE_UNIX98 - - -384 -__BEGIN_NAMESPACE_C99 - - -386  - $¢´štf - (* -__»¡riù - -__s -, -size_t - -__maxËn -, - -387 cÚ¡ * -__»¡riù - -__fÜm© -, ...) - -388 -__THROWNL - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 4))); - -390  - $v¢´štf - (* -__»¡riù - -__s -, -size_t - -__maxËn -, - -391 cÚ¡ * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -) - -392 -__THROWNL - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 3, 0))); - -393 -__END_NAMESPACE_C99 - - -396 #ifdeà -__USE_GNU - - -399  - $va¥rštf - (** -__»¡riù - -__±r -, cÚ¡ *__»¡riù -__f -, - -400 -_G_va_li¡ - -__¬g -) - -401 -__THROWNL - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 2, 0))è -__wur -; - -402  - $__a¥rštf - (** -__»¡riù - -__±r -, - -403 cÚ¡ * -__»¡riù - -__fmt -, ...) - -404 -__THROWNL - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 2, 3))è -__wur -; - -405  - $a¥rštf - (** -__»¡riù - -__±r -, - -406 cÚ¡ * -__»¡riù - -__fmt -, ...) - -407 -__THROWNL - - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__´štf__ -, 2, 3))è -__wur -; - -410 #ifdeà -__USE_XOPEN2K8 - - -412  - $vd´štf - ( -__fd -, cÚ¡ * -__»¡riù - -__fmt -, - -413 -_G_va_li¡ - -__¬g -) - -414 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 0))); - -415  - $d´štf - ( -__fd -, cÚ¡ * -__»¡riù - -__fmt -, ...) - -416 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 3))); - -420 -__BEGIN_NAMESPACE_STD - - -425  - $fsÿnf - ( -FILE - * -__»¡riù - -__¡»am -, - -426 cÚ¡ * -__»¡riù - -__fÜm© -, ...è -__wur -; - -431  - $sÿnf - (cÚ¡ * -__»¡riù - -__fÜm© -, ...è -__wur -; - -433  - $ssÿnf - (cÚ¡ * -__»¡riù - -__s -, - -434 cÚ¡ * -__»¡riù - -__fÜm© -, ...è -__THROW -; - -436 #ià -defšed - -__USE_ISOC99 - && !defšed -__USE_GNU - \ - -437 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -438 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -439 #ifdeà -__REDIRECT - - -443  - `__REDIRECT - ( -fsÿnf -, ( -FILE - * -__»¡riù - -__¡»am -, - -444 cÚ¡ * -__»¡riù - -__fÜm© -, ...), - -445 -__isoc99_fsÿnf -è -__wur -; - -446  - `__REDIRECT - ( -sÿnf -, (cÚ¡ * -__»¡riù - -__fÜm© -, ...), - -447 -__isoc99_sÿnf -è -__wur -; - -448  - `__REDIRECT_NTH - ( -ssÿnf -, (cÚ¡ * -__»¡riù - -__s -, - -449 cÚ¡ * -__»¡riù - -__fÜm© -, ...), - -450 -__isoc99_ssÿnf -); - -452  - $__isoc99_fsÿnf - ( -FILE - * -__»¡riù - -__¡»am -, - -453 cÚ¡ * -__»¡riù - -__fÜm© -, ...è -__wur -; - -454  - $__isoc99_sÿnf - (cÚ¡ * -__»¡riù - -__fÜm© -, ...è -__wur -; - -455  - $__isoc99_ssÿnf - (cÚ¡ * -__»¡riù - -__s -, - -456 cÚ¡ * -__»¡riù - -__fÜm© -, ...è -__THROW -; - -457  - #fsÿnf - -__isoc99_fsÿnf - - - ) - -458  - #sÿnf - -__isoc99_sÿnf - - - ) - -459  - #ssÿnf - -__isoc99_ssÿnf - - - ) - -463 -__END_NAMESPACE_STD - - -465 #ifdef -__USE_ISOC99 - - -466 -__BEGIN_NAMESPACE_C99 - - -471  - $vfsÿnf - ( -FILE - * -__»¡riù - -__s -, cÚ¡ *__»¡riù -__fÜm© -, - -472 -_G_va_li¡ - -__¬g -) - -473 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 2, 0))è -__wur -; - -479  - $vsÿnf - (cÚ¡ * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -) - -480 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 1, 0))è -__wur -; - -483  - $vssÿnf - (cÚ¡ * -__»¡riù - -__s -, - -484 cÚ¡ * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -) - -485 -__THROW - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__sÿnf__ -, 2, 0))); - -487 #ià! -defšed - -__USE_GNU - \ - -488 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -489 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -490 #ifdeà -__REDIRECT - - -494  - `__REDIRECT - ( -vfsÿnf -, - -495 ( -FILE - * -__»¡riù - -__s -, - -496 cÚ¡ * -__»¡riù - -__fÜm© -, -_G_va_li¡ - -__¬g -), - -497 -__isoc99_vfsÿnf -) - -498 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 2, 0))è -__wur -; - -499  - `__REDIRECT - ( -vsÿnf -, (cÚ¡ * -__»¡riù - -__fÜm© -, - -500 -_G_va_li¡ - -__¬g -), -__isoc99_vsÿnf -) - -501 - `__©Œibu‹__ - (( - $__fÜm©__ - ( -__sÿnf__ -, 1, 0))è -__wur -; - -502  - `__REDIRECT_NTH - ( -vssÿnf -, - -503 (cÚ¡ * -__»¡riù - -__s -, - -504 cÚ¡ * -__»¡riù - -__fÜm© -, - -505 -_G_va_li¡ - -__¬g -), -__isoc99_vssÿnf -) - -506 - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__sÿnf__ -, 2, 0))); - -508  - $__isoc99_vfsÿnf - ( -FILE - * -__»¡riù - -__s -, - -509 cÚ¡ * -__»¡riù - -__fÜm© -, - -510 -_G_va_li¡ - -__¬g -è -__wur -; - -511  - $__isoc99_vsÿnf - (cÚ¡ * -__»¡riù - -__fÜm© -, - -512 -_G_va_li¡ - -__¬g -è -__wur -; - -513  - $__isoc99_vssÿnf - (cÚ¡ * -__»¡riù - -__s -, - -514 cÚ¡ * -__»¡riù - -__fÜm© -, - -515 -_G_va_li¡ - -__¬g -è -__THROW -; - -516  - #vfsÿnf - -__isoc99_vfsÿnf - - - ) - -517  - #vsÿnf - -__isoc99_vsÿnf - - - ) - -518  - #vssÿnf - -__isoc99_vssÿnf - - - ) - -522 -__END_NAMESPACE_C99 - - -526 -__BEGIN_NAMESPACE_STD - - -531  - `fg‘c - ( -FILE - * -__¡»am -); - -532  - `g‘c - ( -FILE - * -__¡»am -); - -538  - `g‘ch¬ - (); - -539 -__END_NAMESPACE_STD - - -543  - #g‘c -( -_å -è - `_IO_g‘c - (_å) - - ) - -545 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -550  - `g‘c_uÆocked - ( -FILE - * -__¡»am -); - -551  - `g‘ch¬_uÆocked - (); - -554 #ifdeà -__USE_MISC - - -561  - `fg‘c_uÆocked - ( -FILE - * -__¡»am -); - -565 -__BEGIN_NAMESPACE_STD - - -573  - `åutc - ( -__c -, -FILE - * -__¡»am -); - -574  - `putc - ( -__c -, -FILE - * -__¡»am -); - -580  - `putch¬ - ( -__c -); - -581 -__END_NAMESPACE_STD - - -585  - #putc -( -_ch -, -_å -è - `_IO_putc - (_ch, _å) - - ) - -587 #ifdeà -__USE_MISC - - -594  - `åutc_uÆocked - ( -__c -, -FILE - * -__¡»am -); - -597 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -602  - `putc_uÆocked - ( -__c -, -FILE - * -__¡»am -); - -603  - `putch¬_uÆocked - ( -__c -); - -607 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - \ - -608 || ( -defšed - -__USE_XOPEN - && !defšed -__USE_XOPEN2K -) - -610  - `g‘w - ( -FILE - * -__¡»am -); - -613  - `putw - ( -__w -, -FILE - * -__¡»am -); - -617 -__BEGIN_NAMESPACE_STD - - -622 * - $fg‘s - (* -__»¡riù - -__s -,  -__n -, -FILE - *__»¡riù -__¡»am -) - -623 -__wur -; - -625 #ià! -defšed - -__USE_ISOC11 - \ - -626 || ( -defšed - -__ýlu¥lus - && __cplusplus <= 201103L) - -638 * - $g‘s - (* -__s -è -__wur - -__©Œibu‹_d•»ÿ‹d__ -; - -640 -__END_NAMESPACE_STD - - -642 #ifdeà -__USE_GNU - - -649 * - $fg‘s_uÆocked - (* -__»¡riù - -__s -,  -__n -, - -650 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -654 #ifdef -__USE_XOPEN2K8 - - -665 -_IO_ssize_t - - $__g‘d–im - (** -__»¡riù - -__lš•Œ -, - -666 -size_t - * -__»¡riù - -__n -,  -__d–im™” -, - -667 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -668 -_IO_ssize_t - - $g‘d–im - (** -__»¡riù - -__lš•Œ -, - -669 -size_t - * -__»¡riù - -__n -,  -__d–im™” -, - -670 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -678 -_IO_ssize_t - - $g‘lše - (** -__»¡riù - -__lš•Œ -, - -679 -size_t - * -__»¡riù - -__n -, - -680 -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -684 -__BEGIN_NAMESPACE_STD - - -689  - `åuts - (cÚ¡ * -__»¡riù - -__s -, -FILE - *__»¡riù -__¡»am -); - -695  - `puts - (cÚ¡ * -__s -); - -702  - `ung‘c - ( -__c -, -FILE - * -__¡»am -); - -709 -size_t - - $ä—d - (* -__»¡riù - -__±r -, -size_t - -__size -, - -710 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -715 -size_t - - `fwr™e - (cÚ¡ * -__»¡riù - -__±r -, size_ˆ -__size -, - -716 -size_t - -__n -, -FILE - * -__»¡riù - -__s -); - -717 -__END_NAMESPACE_STD - - -719 #ifdeà -__USE_GNU - - -726  - `åuts_uÆocked - (cÚ¡ * -__»¡riù - -__s -, - -727 -FILE - * -__»¡riù - -__¡»am -); - -730 #ifdeà -__USE_MISC - - -737 -size_t - - $ä—d_uÆocked - (* -__»¡riù - -__±r -, -size_t - -__size -, - -738 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -è -__wur -; - -739 -size_t - - `fwr™e_uÆocked - (cÚ¡ * -__»¡riù - -__±r -, size_ˆ -__size -, - -740 -size_t - -__n -, -FILE - * -__»¡riù - -__¡»am -); - -744 -__BEGIN_NAMESPACE_STD - - -749  - `f£ek - ( -FILE - * -__¡»am -,  -__off -,  -__wh’û -); - -754  - $á–l - ( -FILE - * -__¡»am -è -__wur -; - -759  - `»wšd - ( -FILE - * -__¡»am -); - -760 -__END_NAMESPACE_STD - - -767 #ià -defšed - -__USE_LARGEFILE - || defšed -__USE_XOPEN2K - - -768 #iâdeà -__USE_FILE_OFFSET64 - - -773  - `f£eko - ( -FILE - * -__¡»am -, -__off_t - -__off -,  -__wh’û -); - -778 -__off_t - - $á–lo - ( -FILE - * -__¡»am -è -__wur -; - -780 #ifdeà -__REDIRECT - - -781  - `__REDIRECT - ( -f£eko -, - -782 ( -FILE - * -__¡»am -, -__off64_t - -__off -,  -__wh’û -), - -783 -f£eko64 -); - -784 -__off64_t - - `__REDIRECT - ( -á–lo -, ( -FILE - * -__¡»am -), -á–lo64 -); - -786  - #f£eko - -f£eko64 - - - ) - -787  - #á–lo - -á–lo64 - - - ) - -792 -__BEGIN_NAMESPACE_STD - - -793 #iâdeà -__USE_FILE_OFFSET64 - - -798  - `fg‘pos - ( -FILE - * -__»¡riù - -__¡»am -, -åos_t - *__»¡riù -__pos -); - -803  - `f£os - ( -FILE - * -__¡»am -, cÚ¡ -åos_t - * -__pos -); - -805 #ifdeà -__REDIRECT - - -806  - `__REDIRECT - ( -fg‘pos -, ( -FILE - * -__»¡riù - -__¡»am -, - -807 -åos_t - * -__»¡riù - -__pos -), -fg‘pos64 -); - -808  - `__REDIRECT - ( -f£os -, - -809 ( -FILE - * -__¡»am -, cÚ¡ -åos_t - * -__pos -), -f£os64 -); - -811  - #fg‘pos - -fg‘pos64 - - - ) - -812  - #f£os - -f£os64 - - - ) - -815 -__END_NAMESPACE_STD - - -817 #ifdeà -__USE_LARGEFILE64 - - -818  - `f£eko64 - ( -FILE - * -__¡»am -, -__off64_t - -__off -,  -__wh’û -); - -819 -__off64_t - - $á–lo64 - ( -FILE - * -__¡»am -è -__wur -; - -820  - `fg‘pos64 - ( -FILE - * -__»¡riù - -__¡»am -, -åos64_t - *__»¡riù -__pos -); - -821  - `f£os64 - ( -FILE - * -__¡»am -, cÚ¡ -åos64_t - * -__pos -); - -824 -__BEGIN_NAMESPACE_STD - - -826  - $þ—»¼ - ( -FILE - * -__¡»am -è -__THROW -; - -828  - $ãof - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -830  - $ã¼Ü - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -831 -__END_NAMESPACE_STD - - -833 #ifdeà -__USE_MISC - - -835  - $þ—»¼_uÆocked - ( -FILE - * -__¡»am -è -__THROW -; - -836  - $ãof_uÆocked - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -837  - $ã¼Ü_uÆocked - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -841 -__BEGIN_NAMESPACE_STD - - -846  - `³¼Ü - (cÚ¡ * -__s -); - -847 -__END_NAMESPACE_STD - - -853  - ~ - -856 #ifdef -__USE_POSIX - - -858  - $fž’o - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -861 #ifdeà -__USE_MISC - - -863  - $fž’o_uÆocked - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -867 #ià( -defšed - -__USE_POSIX2 - || defšed -__USE_SVID - || defšed -__USE_BSD - || \ - -868 -defšed - -__USE_MISC -) - -873 -FILE - * - $pÝ’ - (cÚ¡ * -__commªd -, cÚ¡ * -__modes -è -__wur -; - -879  - `pþo£ - ( -FILE - * -__¡»am -); - -883 #ifdef -__USE_POSIX - - -885 * - $ù”mid - (* -__s -è -__THROW -; - -889 #ifdeà -__USE_XOPEN - - -891 * - `cu£rid - (* -__s -); - -895 #ifdef -__USE_GNU - - -896  -ob¡ack -; - -899  - $ob¡ack_´štf - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -900 cÚ¡ * -__»¡riù - -__fÜm© -, ...) - -901 -__THROWNL - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 3))); - -902  - $ob¡ack_v´štf - ( -ob¡ack - * -__»¡riù - -__ob¡ack -, - -903 cÚ¡ * -__»¡riù - -__fÜm© -, - -904 -_G_va_li¡ - -__¬gs -) - -905 -__THROWNL - - `__©Œibu‹__ - (( - `__fÜm©__ - ( -__´štf__ -, 2, 0))); - -909 #ià -defšed - -__USE_POSIX - || defšed -__USE_MISC - - -913  - $æockfže - ( -FILE - * -__¡»am -è -__THROW -; - -917  - $árylockfže - ( -FILE - * -__¡»am -è -__THROW - -__wur -; - -920  - $fuÆockfže - ( -FILE - * -__¡»am -è -__THROW -; - -923 #ià -defšed - -__USE_XOPEN - && !defšed -__USE_XOPEN2K - && !defšed -__USE_GNU - - -927  - #__Ãed_g‘Ýt - - - ) - -928  - ~ - -933 #ifdeà -__USE_EXTERN_INLINES - - -934  - ~ - -936 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__ex‹º_®ways_šlše - - -937  - ~ - -939 #ifdeà -__LDBL_COMPAT - - -940  - ~ - -943 -__END_DECLS - - - @/usr/include/features.h - -18 #iâdef -_FEATURES_H - - -19  - #_FEATURES_H - 1 - - ) - -101 #undeà -__USE_ISOC11 - - -102 #undeà -__USE_ISOC99 - - -103 #undeà -__USE_ISOC95 - - -104 #undeà -__USE_ISOCXX11 - - -105 #undeà -__USE_POSIX - - -106 #undeà -__USE_POSIX2 - - -107 #undeà -__USE_POSIX199309 - - -108 #undeà -__USE_POSIX199506 - - -109 #undeà -__USE_XOPEN - - -110 #undeà -__USE_XOPEN_EXTENDED - - -111 #undeà -__USE_UNIX98 - - -112 #undeà -__USE_XOPEN2K - - -113 #undeà -__USE_XOPEN2KXSI - - -114 #undeà -__USE_XOPEN2K8 - - -115 #undeà -__USE_XOPEN2K8XSI - - -116 #undeà -__USE_LARGEFILE - - -117 #undeà -__USE_LARGEFILE64 - - -118 #undeà -__USE_FILE_OFFSET64 - - -119 #undeà -__USE_BSD - - -120 #undeà -__USE_SVID - - -121 #undeà -__USE_MISC - - -122 #undeà -__USE_ATFILE - - -123 #undeà -__USE_GNU - - -124 #undeà -__USE_REENTRANT - - -125 #undeà -__USE_FORTIFY_LEVEL - - -126 #undeà -__KERNEL_STRICT_NAMES - - -130 #iâdeà -_LOOSE_KERNEL_NAMES - - -131  - #__KERNEL_STRICT_NAMES - - - ) - -141 #ià -defšed - -__GNUC__ - && defšed -__GNUC_MINOR__ - - -142  - #__GNUC_PREREQ -( -maj -, -mš -) \ - -143 (( -__GNUC__ - << 16è+ -__GNUC_MINOR__ - >ð(( -maj -è<< 16è+ ( -mš -)) - - ) - -145  - #__GNUC_PREREQ -( -maj -, -mš -è0 - - ) - -150 #ifdeà -_GNU_SOURCE - - -151 #undeà -_ISOC95_SOURCE - - -152  - #_ISOC95_SOURCE - 1 - - ) - -153 #undeà -_ISOC99_SOURCE - - -154  - #_ISOC99_SOURCE - 1 - - ) - -155 #undeà -_ISOC11_SOURCE - - -156  - #_ISOC11_SOURCE - 1 - - ) - -157 #undeà -_POSIX_SOURCE - - -158  - #_POSIX_SOURCE - 1 - - ) - -159 #undeà -_POSIX_C_SOURCE - - -160  - #_POSIX_C_SOURCE - 200809L - - ) - -161 #undeà -_XOPEN_SOURCE - - -162  - #_XOPEN_SOURCE - 700 - - ) - -163 #undeà -_XOPEN_SOURCE_EXTENDED - - -164  - #_XOPEN_SOURCE_EXTENDED - 1 - - ) - -165 #undeà -_LARGEFILE64_SOURCE - - -166  - #_LARGEFILE64_SOURCE - 1 - - ) - -167 #undeà -_DEFAULT_SOURCE - - -168  - #_DEFAULT_SOURCE - 1 - - ) - -169 #undeà -_BSD_SOURCE - - -170  - #_BSD_SOURCE - 1 - - ) - -171 #undeà -_SVID_SOURCE - - -172  - #_SVID_SOURCE - 1 - - ) - -173 #undeà -_ATFILE_SOURCE - - -174  - #_ATFILE_SOURCE - 1 - - ) - -179 #ià( -defšed - -_DEFAULT_SOURCE - \ - -180 || (! -defšed - - g__STRICT_ANSI__ - \ - -181 && ! -defšed - - g_ISOC99_SOURCE - \ - -182 && ! -defšed - - g_POSIX_SOURCE - && !defšed - g_POSIX_C_SOURCE - \ - -183 && ! -defšed - - g_XOPEN_SOURCE - \ - -184 && ! -defšed - - g_BSD_SOURCE - && !defšed - g_SVID_SOURCE -)) - -185 #undeà -_DEFAULT_SOURCE - - -186  - #_DEFAULT_SOURCE - 1 - - ) - -187 #undeà -_BSD_SOURCE - - -188  - #_BSD_SOURCE - 1 - - ) - -189 #undeà -_SVID_SOURCE - - -190  - #_SVID_SOURCE - 1 - - ) - -194 #ià( -defšed - -_ISOC11_SOURCE - \ - -195 || ( -defšed - - g__STDC_VERSION__ - && __STDC_VERSION__ >= 201112L)) - -196  - #__USE_ISOC11 - 1 - - ) - -200 #ià( -defšed - -_ISOC99_SOURCE - || defšed -_ISOC11_SOURCE - \ - -201 || ( -defšed - -__STDC_VERSION__ - && __STDC_VERSION__ >= 199901L)) - -202  - #__USE_ISOC99 - 1 - - ) - -206 #ià( -defšed - -_ISOC99_SOURCE - || defšed -_ISOC11_SOURCE - \ - -207 || ( -defšed - -__STDC_VERSION__ - && __STDC_VERSION__ >= 199409L)) - -208  - #__USE_ISOC95 - 1 - - ) - -215 #ià(( -defšed - -__ýlu¥lus - && __cplusplus >= 201103L) \ - -216 || -defšed - -__GXX_EXPERIMENTAL_CXX0X__ -) - -217  - #__USE_ISOCXX11 - 1 - - ) - -223 #ifdeà -_DEFAULT_SOURCE - - -224 #ià! -defšed - -_POSIX_SOURCE - && !defšed -_POSIX_C_SOURCE - - -225  - #__USE_POSIX_IMPLICITLY - 1 - - ) - -227 #undeà -_POSIX_SOURCE - - -228  - #_POSIX_SOURCE - 1 - - ) - -229 #undeà -_POSIX_C_SOURCE - - -230  - #_POSIX_C_SOURCE - 200809L - - ) - -232 #ià((! -defšed - -__STRICT_ANSI__ - || ( -_XOPEN_SOURCE - - 0) >= 500) && \ - -233 ! -defšed - -_POSIX_SOURCE - && !defšed -_POSIX_C_SOURCE -) - -234  - #_POSIX_SOURCE - 1 - - ) - -235 #ià -defšed - -_XOPEN_SOURCE - && (_XOPEN_SOURCE - 0) < 500 - -236  - #_POSIX_C_SOURCE - 2 - - ) - -237 #–ià -defšed - -_XOPEN_SOURCE - && (_XOPEN_SOURCE - 0) < 600 - -238  - #_POSIX_C_SOURCE - 199506L - - ) - -239 #–ià -defšed - -_XOPEN_SOURCE - && (_XOPEN_SOURCE - 0) < 700 - -240  - #_POSIX_C_SOURCE - 200112L - - ) - -242  - #_POSIX_C_SOURCE - 200809L - - ) - -244  - #__USE_POSIX_IMPLICITLY - 1 - - ) - -247 #ià -defšed - -_POSIX_SOURCE - || -_POSIX_C_SOURCE - >ð1 || defšed -_XOPEN_SOURCE - - -248  - #__USE_POSIX - 1 - - ) - -251 #ià -defšed - -_POSIX_C_SOURCE - && _POSIX_C_SOURCE >ð2 || defšed -_XOPEN_SOURCE - - -252  - #__USE_POSIX2 - 1 - - ) - -255 #ià( -_POSIX_C_SOURCE - - 0) >= 199309L - -256  - #__USE_POSIX199309 - 1 - - ) - -259 #ià( -_POSIX_C_SOURCE - - 0) >= 199506L - -260  - #__USE_POSIX199506 - 1 - - ) - -263 #ià( -_POSIX_C_SOURCE - - 0) >= 200112L - -264  - #__USE_XOPEN2K - 1 - - ) - -265 #undeà -__USE_ISOC95 - - -266  - #__USE_ISOC95 - 1 - - ) - -267 #undeà -__USE_ISOC99 - - -268  - #__USE_ISOC99 - 1 - - ) - -271 #ià( -_POSIX_C_SOURCE - - 0) >= 200809L - -272  - #__USE_XOPEN2K8 - 1 - - ) - -273 #undeà -_ATFILE_SOURCE - - -274  - #_ATFILE_SOURCE - 1 - - ) - -277 #ifdef -_XOPEN_SOURCE - - -278  - #__USE_XOPEN - 1 - - ) - -279 #ià( -_XOPEN_SOURCE - - 0) >= 500 - -280  - #__USE_XOPEN_EXTENDED - 1 - - ) - -281  - #__USE_UNIX98 - 1 - - ) - -282 #undeà -_LARGEFILE_SOURCE - - -283  - #_LARGEFILE_SOURCE - 1 - - ) - -284 #ià( -_XOPEN_SOURCE - - 0) >= 600 - -285 #ià( -_XOPEN_SOURCE - - 0) >= 700 - -286  - #__USE_XOPEN2K8 - 1 - - ) - -287  - #__USE_XOPEN2K8XSI - 1 - - ) - -289  - #__USE_XOPEN2K - 1 - - ) - -290  - #__USE_XOPEN2KXSI - 1 - - ) - -291 #undeà -__USE_ISOC95 - - -292  - #__USE_ISOC95 - 1 - - ) - -293 #undeà -__USE_ISOC99 - - -294  - #__USE_ISOC99 - 1 - - ) - -297 #ifdeà -_XOPEN_SOURCE_EXTENDED - - -298  - #__USE_XOPEN_EXTENDED - 1 - - ) - -303 #ifdeà -_LARGEFILE_SOURCE - - -304  - #__USE_LARGEFILE - 1 - - ) - -307 #ifdeà -_LARGEFILE64_SOURCE - - -308  - #__USE_LARGEFILE64 - 1 - - ) - -311 #ià -defšed - -_FILE_OFFSET_BITS - && _FILE_OFFSET_BITS == 64 - -312  - #__USE_FILE_OFFSET64 - 1 - - ) - -315 #ià -defšed - -_BSD_SOURCE - || defšed -_SVID_SOURCE - - -316  - #__USE_MISC - 1 - - ) - -319 #ifdef -_BSD_SOURCE - - -320  - #__USE_BSD - 1 - - ) - -323 #ifdef -_SVID_SOURCE - - -324  - #__USE_SVID - 1 - - ) - -327 #ifdef -_ATFILE_SOURCE - - -328  - #__USE_ATFILE - 1 - - ) - -331 #ifdef -_GNU_SOURCE - - -332  - #__USE_GNU - 1 - - ) - -335 #ià -defšed - -_REENTRANT - || defšed -_THREAD_SAFE - - -336  - #__USE_REENTRANT - 1 - - ) - -339 #ià -defšed - -_FORTIFY_SOURCE - && _FORTIFY_SOURCE > 0 \ - -340 && -__GNUC_PREREQ - (4, 1è&& -defšed - - g__OPTIMIZE__ - && __OPTIMIZE__ > 0 - -341 #ià -_FORTIFY_SOURCE - > 1 - -342  - #__USE_FORTIFY_LEVEL - 2 - - ) - -344  - #__USE_FORTIFY_LEVEL - 1 - - ) - -347  - #__USE_FORTIFY_LEVEL - 0 - - ) - -352  - ~<¡dc-´edef.h -> - -360 #undeà -__GNU_LIBRARY__ - - -361  - #__GNU_LIBRARY__ - 6 - - ) - -365  - #__GLIBC__ - 2 - - ) - -366  - #__GLIBC_MINOR__ - 19 - - ) - -368  - #__GLIBC_PREREQ -( -maj -, -mš -) \ - -369 (( -__GLIBC__ - << 16è+ -__GLIBC_MINOR__ - >ð(( -maj -è<< 16è+ ( -mš -)) - - ) - -372 #iâdeà -__ASSEMBLER__ - - -373 #iâdeà -_SYS_CDEFS_H - - -374  - ~ - -379 #ià -defšed - -__USE_FILE_OFFSET64 - && !defšed -__REDIRECT - - -380  - #__USE_LARGEFILE - 1 - - ) - -381  - #__USE_LARGEFILE64 - 1 - - ) - -387 #ià -__GNUC_PREREQ - (2, 7è&& -defšed - -__OPTIMIZE__ - \ - -388 && ! -defšed - - g__OPTIMIZE_SIZE__ - && !defšed - g__NO_INLINE__ - \ - -389 && -defšed - - g__ex‹º_šlše - - -390  - #__USE_EXTERN_INLINES - 1 - - ) - -398  - ~ - - @/usr/include/getopt.h - -19 #iâdeà -_GETOPT_H - - -21 #iâdeà -__Ãed_g‘Ýt - - -22  - #_GETOPT_H - 1 - - ) - -32 #ià! -defšed - -__GNU_LIBRARY__ - - -33  - ~<ùy³.h -> - -36 #iâdeà -__THROW - - -37 #iâdeà -__GNUC_PREREQ - - -38  - #__GNUC_PREREQ -( -maj -, -mš -è(0) - - ) - -40 #ià -defšed - -__ýlu¥lus - && -__GNUC_PREREQ - (2,8) - -41  - #__THROW - - `throw - () - - ) - -43  - #__THROW - - - ) - -47 #ifdef -__ýlu¥lus - - -57 * -Ýrg -; - -71  -Ýtšd -; - -76  -Ý‹¼ -; - -80  -ÝtÝt -; - -82 #iâdeà -__Ãed_g‘Ýt - - -104  - sÝtiÚ - - -106 cÚ¡ * - gÇme -; - -109  - ghas_¬g -; - -110 * - gæag -; - -111  - gv® -; - -116  - #no_¬gum’t - 0 - - ) - -117  - #»quœed_¬gum’t - 1 - - ) - -118  - #ÝtiÚ®_¬gum’t - 2 - - ) - -146 #ifdeà -__GNU_LIBRARY__ - - -150  -g‘Ýt - ( -___¬gc -, *cÚ¡ * -___¬gv -, cÚ¡ * -__shÜtÝts -) - -151 -__THROW -; - -153 #ià -defšed - -__Ãed_g‘Ýt - && defšed -__USE_POSIX2 - \ - -154 && ! -defšed - - g__USE_POSIX_IMPLICITLY - && !defšed - g__USE_GNU - - -158 #ifdeà -__REDIRECT - - -159  -__REDIRECT_NTH - ( -g‘Ýt -, ( -___¬gc -, *cÚ¡ * -___¬gv -, - -160 cÚ¡ * -__shÜtÝts -), - -161 -__posix_g‘Ýt -); - -163  -__posix_g‘Ýt - ( -___¬gc -, *cÚ¡ * -___¬gv -, - -164 cÚ¡ * -__shÜtÝts -è -__THROW -; - -165  - #g‘Ýt - -__posix_g‘Ýt - - - ) - -169  -g‘Ýt - (); - -172 #iâdeà -__Ãed_g‘Ýt - - -173  -g‘Ýt_lÚg - ( -___¬gc -, *cÚ¡ * -___¬gv -, - -174 cÚ¡ * -__shÜtÝts -, - -175 cÚ¡  -ÝtiÚ - * -__lÚgÝts -, * -__lÚgšd -) - -176 -__THROW -; - -177  -g‘Ýt_lÚg_Úly - ( -___¬gc -, *cÚ¡ * -___¬gv -, - -178 cÚ¡ * -__shÜtÝts -, - -179 cÚ¡  -ÝtiÚ - * -__lÚgÝts -, * -__lÚgšd -) - -180 -__THROW -; - -184 #ifdef -__ýlu¥lus - - -189 #undeà -__Ãed_g‘Ýt - - - @/usr/include/libio.h - -28 #iâdeà -_IO_STDIO_H - - -29  - #_IO_STDIO_H - - - ) - -31  - ~<_G_cÚfig.h -> - -33  - #_IO_åos_t - -_G_åos_t - - - ) - -34  - #_IO_åos64_t - -_G_åos64_t - - - ) - -35  - #_IO_size_t - -size_t - - - ) - -36  - #_IO_ssize_t - -__ssize_t - - - ) - -37  - #_IO_off_t - -__off_t - - - ) - -38  - #_IO_off64_t - -__off64_t - - - ) - -39  - #_IO_pid_t - -__pid_t - - - ) - -40  - #_IO_uid_t - -__uid_t - - - ) - -41  - #_IO_icÚv_t - -_G_icÚv_t - - - ) - -42  - #_IO_HAVE_ST_BLKSIZE - -_G_HAVE_ST_BLKSIZE - - - ) - -43  - #_IO_BUFSIZ - -_G_BUFSIZ - - - ) - -44  - #_IO_va_li¡ - -_G_va_li¡ - - - ) - -45  - #_IO_wšt_t - -wšt_t - - - ) - -48  - #__Ãed___va_li¡ - - - ) - -49  - ~<¡d¬g.h -> - -50 #ifdeà -__GNUC_VA_LIST - - -51 #undeà -_IO_va_li¡ - - -52  - #_IO_va_li¡ - -__gnuc_va_li¡ - - - ) - -55 #iâdeà -__P - - -56  - ~ - -59  - #_IO_UNIFIED_JUMPTABLES - 1 - - ) - -61 #iâdeà -EOF - - -62  - #EOF - (-1) - - ) - -64 #iâdeà -NULL - - -65 #ià -defšed - -__GNUG__ - && \ - -66 ( - g__GNUC__ - > 2 || (__GNUC__ =ð2 && -__GNUC_MINOR__ - >= 8)) - -67  - #NULL - ( -__nuÎ -) - - ) - -69 #ià! -defšed -( -__ýlu¥lus -) - -70  - #NULL - ((*)0) - - ) - -72  - #NULL - (0) - - ) - -77  - #_IOS_INPUT - 1 - - ) - -78  - #_IOS_OUTPUT - 2 - - ) - -79  - #_IOS_ATEND - 4 - - ) - -80  - #_IOS_APPEND - 8 - - ) - -81  - #_IOS_TRUNC - 16 - - ) - -82  - #_IOS_NOCREATE - 32 - - ) - -83  - #_IOS_NOREPLACE - 64 - - ) - -84  - #_IOS_BIN - 128 - - ) - -92  - #_IO_MAGIC - 0xFBAD0000 - - ) - -93  - #_OLD_STDIO_MAGIC - 0xFABC0000 - - ) - -94  - #_IO_MAGIC_MASK - 0xFFFF0000 - - ) - -95  - #_IO_USER_BUF - 1 - - ) - -96  - #_IO_UNBUFFERED - 2 - - ) - -97  - #_IO_NO_READS - 4 - - ) - -98  - #_IO_NO_WRITES - 8 - - ) - -99  - #_IO_EOF_SEEN - 0x10 - - ) - -100  - #_IO_ERR_SEEN - 0x20 - - ) - -101  - #_IO_DELETE_DONT_CLOSE - 0x40 - - ) - -102  - #_IO_LINKED - 0x80 - - ) - -103  - #_IO_IN_BACKUP - 0x100 - - ) - -104  - #_IO_LINE_BUF - 0x200 - - ) - -105  - #_IO_TIED_PUT_GET - 0x400 - - ) - -106  - #_IO_CURRENTLY_PUTTING - 0x800 - - ) - -107  - #_IO_IS_APPENDING - 0x1000 - - ) - -108  - #_IO_IS_FILEBUF - 0x2000 - - ) - -109  - #_IO_BAD_SEEN - 0x4000 - - ) - -110  - #_IO_USER_LOCK - 0x8000 - - ) - -112  - #_IO_FLAGS2_MMAP - 1 - - ) - -113  - #_IO_FLAGS2_NOTCANCEL - 2 - - ) - -114 #ifdeà -_LIBC - - -115  - #_IO_FLAGS2_FORTIFY - 4 - - ) - -117  - #_IO_FLAGS2_USER_WBUF - 8 - - ) - -118 #ifdeà -_LIBC - - -119  - #_IO_FLAGS2_SCANF_STD - 16 - - ) - -120  - #_IO_FLAGS2_NOCLOSE - 32 - - ) - -121  - #_IO_FLAGS2_CLOEXEC - 64 - - ) - -125  - #_IO_SKIPWS - 01 - - ) - -126  - #_IO_LEFT - 02 - - ) - -127  - #_IO_RIGHT - 04 - - ) - -128  - #_IO_INTERNAL - 010 - - ) - -129  - #_IO_DEC - 020 - - ) - -130  - #_IO_OCT - 040 - - ) - -131  - #_IO_HEX - 0100 - - ) - -132  - #_IO_SHOWBASE - 0200 - - ) - -133  - #_IO_SHOWPOINT - 0400 - - ) - -134  - #_IO_UPPERCASE - 01000 - - ) - -135  - #_IO_SHOWPOS - 02000 - - ) - -136  - #_IO_SCIENTIFIC - 04000 - - ) - -137  - #_IO_FIXED - 010000 - - ) - -138  - #_IO_UNITBUF - 020000 - - ) - -139  - #_IO_STDIO - 040000 - - ) - -140  - #_IO_DONT_CLOSE - 0100000 - - ) - -141  - #_IO_BOOLALPHA - 0200000 - - ) - -144  -_IO_jump_t -;  - g_IO_FILE -; - -147 #ifdeà -_IO_MTSAFE_IO - - -148 #ià -defšed - -__GLIBC__ - && __GLIBC__ >= 2 - -149  - ~ - -154  - t_IO_lock_t -; - -160  - s_IO_m¬k” - { - -161  -_IO_m¬k” - * - m_Ãxt -; - -162  -_IO_FILE - * - m_sbuf -; - -166  - m_pos -; - -168  -£t_¡»ampos -( -¡»ampos - -¥ -è{ - m_¥os - = sp; } - -169  -£t_off£t -( -off£t -è{ - m_pos - = off£t; - m_¥os - = ( -¡»ampos -)(-2); } - -170 - mpublic -: - -171 -¡»amm¬k” -( -¡»ambuf - * -sb -); - -172 ~ -¡»amm¬k” -(); - -173  -§všg -(è{  - m_¥os - == -2; } - -174  -d– -( -¡»amm¬k” -&); - -175  -d– -(); - -180 - e__codecvt_»suÉ - - -182 - m__codecvt_ok -, - -183 - m__codecvt_·¹Ÿl -, - -184 - m__codecvt_”rÜ -, - -185 - m__codecvt_nocÚv - - -188 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -191  - s_IO_codecvt - - -193 (* - m__codecvt_de¡r -è( - m_IO_codecvt - *); - -194 -__codecvt_»suÉ - (* -__codecvt_do_out -è( - m_IO_codecvt - *, - -195 - m__mb¡©e_t - *, - -196 cÚ¡ - mwch¬_t - *, - -197 cÚ¡ - mwch¬_t - *, - -198 cÚ¡ - mwch¬_t - **, *, - -200 -__codecvt_»suÉ - (* -__codecvt_do_unshiá -è( - m_IO_codecvt - *, - -201 - m__mb¡©e_t - *, *, - -203 -__codecvt_»suÉ - (* -__codecvt_do_š -è( - m_IO_codecvt - *, - -204 - m__mb¡©e_t - *, - -206 cÚ¡ **, - mwch¬_t - *, - -207 - mwch¬_t - *, wchar_t **); - -208 (* - m__codecvt_do_’codšg -è( - m_IO_codecvt - *); - -209 (* - m__codecvt_do_®ways_nocÚv -è( - m_IO_codecvt - *); - -210 (* - m__codecvt_do_Ëngth -è( - m_IO_codecvt - *, - m__mb¡©e_t - *, - -211 cÚ¡ *, cÚ¡ *, - m_IO_size_t -); - -212 (* - m__codecvt_do_max_Ëngth -è( - m_IO_codecvt - *); - -214 -_IO_icÚv_t - - m__cd_š -; - -215 -_IO_icÚv_t - - m__cd_out -; - -219  - s_IO_wide_d©a - - -221 -wch¬_t - * - m_IO_»ad_±r -; - -222 -wch¬_t - * - m_IO_»ad_’d -; - -223 -wch¬_t - * - m_IO_»ad_ba£ -; - -224 -wch¬_t - * - m_IO_wr™e_ba£ -; - -225 -wch¬_t - * - m_IO_wr™e_±r -; - -226 -wch¬_t - * - m_IO_wr™e_’d -; - -227 -wch¬_t - * - m_IO_buf_ba£ -; - -228 -wch¬_t - * - m_IO_buf_’d -; - -230 -wch¬_t - * - m_IO_§ve_ba£ -; - -231 -wch¬_t - * - m_IO_backup_ba£ -; - -233 -wch¬_t - * - m_IO_§ve_’d -; - -235 -__mb¡©e_t - - m_IO_¡©e -; - -236 -__mb¡©e_t - - m_IO_Ï¡_¡©e -; - -237  -_IO_codecvt - - m_codecvt -; - -239 -wch¬_t - - m_shÜtbuf -[1]; - -241 cÚ¡  -_IO_jump_t - * - m_wide_vbË -; - -245  - s_IO_FILE - { - -246  - m_æags -; - -247  - #_IO_fže_æags - -_æags - - - ) - -251 * - m_IO_»ad_±r -; - -252 * - m_IO_»ad_’d -; - -253 * - m_IO_»ad_ba£ -; - -254 * - m_IO_wr™e_ba£ -; - -255 * - m_IO_wr™e_±r -; - -256 * - m_IO_wr™e_’d -; - -257 * - m_IO_buf_ba£ -; - -258 * - m_IO_buf_’d -; - -260 * - m_IO_§ve_ba£ -; - -261 * - m_IO_backup_ba£ -; - -262 * - m_IO_§ve_’d -; - -264  -_IO_m¬k” - * - m_m¬k”s -; - -266  -_IO_FILE - * - m_chaš -; - -268  - m_fž’o -; - -270  - m_blksize -; - -272  - m_æags2 -; - -274 -_IO_off_t - - m_Þd_off£t -; - -276  - #__HAVE_COLUMN - - - ) - -278  - m_cur_cÞumn -; - -279 sigÃd  - m_vbË_off£t -; - -280  - m_shÜtbuf -[1]; - -284 -_IO_lock_t - * - m_lock -; - -285 #ifdeà -_IO_USE_OLD_IO_FILE - - -288  - s_IO_FILE_com¶‘e - - -290  -_IO_FILE - - m_fže -; - -292 #ià -defšed - -_G_IO_IO_FILE_VERSION - && _G_IO_IO_FILE_VERSION == 0x20001 - -293 -_IO_off64_t - - m_off£t -; - -294 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -296  -_IO_codecvt - * - m_codecvt -; - -297  -_IO_wide_d©a - * - m_wide_d©a -; - -298  -_IO_FILE - * - m_ä“»s_li¡ -; - -299 * - m_ä“»s_buf -; - -300 -size_t - - m_ä“»s_size -; - -302 * - m__·d1 -; - -303 * - m__·d2 -; - -304 * - m__·d3 -; - -305 * - m__·d4 -; - -306 -size_t - - m__·d5 -; - -308  - m_mode -; - -310  - m_unu£d2 -[15 *  (è- 4 *  (*è-  ( -size_t -)]; - -314 #iâdeà -__ýlu¥lus - - -315  -_IO_FILE - - t_IO_FILE -; - -318  - g_IO_FILE_¶us -; - -320  -_IO_FILE_¶us - -_IO_2_1_¡dš_ -; - -321  -_IO_FILE_¶us - -_IO_2_1_¡dout_ -; - -322  -_IO_FILE_¶us - -_IO_2_1_¡d”r_ -; - -323 #iâdeà -_LIBC - - -324  - #_IO_¡dš - (( -_IO_FILE -*)(& -_IO_2_1_¡dš_ -)) - - ) - -325  - #_IO_¡dout - (( -_IO_FILE -*)(& -_IO_2_1_¡dout_ -)) - - ) - -326  - #_IO_¡d”r - (( -_IO_FILE -*)(& -_IO_2_1_¡d”r_ -)) - - ) - -328 -_IO_FILE - * -_IO_¡dš - -©Œibu‹_hidd’ -; - -329 -_IO_FILE - * -_IO_¡dout - -©Œibu‹_hidd’ -; - -330 -_IO_FILE - * -_IO_¡d”r - -©Œibu‹_hidd’ -; - -338  -__ssize_t - - t__io_»ad_â - (* - t__cook› -, * - t__buf -, - tsize_t - - t__nby‹s -); - -346  -__ssize_t - - t__io_wr™e_â - (* - t__cook› -, cÚ¡ * - t__buf -, - -347 - tsize_t - - t__n -); - -355  - t__io_£ek_â - (* - t__cook› -, - t_IO_off64_t - * - t__pos -,  - t__w -); - -358  - t__io_þo£_â - (* - t__cook› -); - -361 #ifdeà -_GNU_SOURCE - - -363  -__io_»ad_â - - tcook›_»ad_funùiÚ_t -; - -364  -__io_wr™e_â - - tcook›_wr™e_funùiÚ_t -; - -365  -__io_£ek_â - - tcook›_£ek_funùiÚ_t -; - -366  -__io_þo£_â - - tcook›_þo£_funùiÚ_t -; - -371 -__io_»ad_â - * - m»ad -; - -372 -__io_wr™e_â - * - mwr™e -; - -373 -__io_£ek_â - * - m£ek -; - -374 -__io_þo£_â - * - mþo£ -; - -375 } - t_IO_cook›_io_funùiÚs_t -; - -376  -_IO_cook›_io_funùiÚs_t - - tcook›_io_funùiÚs_t -; - -378  - g_IO_cook›_fže -; - -381  -_IO_cook›_š™ - ( -_IO_cook›_fže - * -__cfže -,  -__»ad_wr™e -, - -382 * -__cook› -, -_IO_cook›_io_funùiÚs_t - -__âs -); - -386 #ifdeà -__ýlu¥lus - - -390  -__und”æow - ( -_IO_FILE - *); - -391  -__uæow - ( -_IO_FILE - *); - -392  -__ov”æow - ( -_IO_FILE - *, ); - -393 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -394 -_IO_wšt_t - -__wund”æow - ( -_IO_FILE - *); - -395 -_IO_wšt_t - -__wuæow - ( -_IO_FILE - *); - -396 -_IO_wšt_t - -__wov”æow - ( -_IO_FILE - *, _IO_wint_t); - -399 #ià -__GNUC__ - >= 3 - -400  - #_IO_BE -( -ex´ -, -»s -è - `__bužtš_ex³ù - (Óx´),„es) - - ) - -402  - #_IO_BE -( -ex´ -, -»s -èÓx´) - - ) - -405  - #_IO_g‘c_uÆocked -( -_å -) \ - -406 ( - `_IO_BE - (( -_å -)-> -_IO_»ad_±r - >ð(_å)-> -_IO_»ad_’d -, 0) \ - -407 ? - `__uæow - ( -_å -è: *(*è(_å)-> -_IO_»ad_±r -++) - - ) - -408  - #_IO_³ekc_uÆocked -( -_å -) \ - -409 ( - `_IO_BE - (( -_å -)-> -_IO_»ad_±r - >ð(_å)-> -_IO_»ad_’d -, 0) \ - -410 && - `__und”æow - ( -_å -è=ð -EOF - ? EOF \ - -411 : *(*è( -_å -)-> -_IO_»ad_±r -) - - ) - -412  - #_IO_putc_uÆocked -( -_ch -, -_å -) \ - -413 ( - `_IO_BE - (( -_å -)-> -_IO_wr™e_±r - >ð(_å)-> -_IO_wr™e_’d -, 0) \ - -414 ? - `__ov”æow - ( -_å -, (è( -_ch -)) \ - -415 : (è(*( -_å -)-> -_IO_wr™e_±r -++ = ( -_ch -))) - - ) - -417 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -418  - #_IO_g‘wc_uÆocked -( -_å -) \ - -419 ( - `_IO_BE - (( -_å -)-> -_wide_d©a - =ð -NULL - \ - -420 || (( -_å -)-> -_wide_d©a --> -_IO_»ad_±r - \ - -421 >ð( -_å -)-> -_wide_d©a --> -_IO_»ad_’d -), 0) \ - -422 ? - `__wuæow - ( -_å -è: ( -_IO_wšt_t -è*(_å)-> -_wide_d©a --> -_IO_»ad_±r -++) - - ) - -423  - #_IO_putwc_uÆocked -( -_wch -, -_å -) \ - -424 ( - `_IO_BE - (( -_å -)-> -_wide_d©a - =ð -NULL - \ - -425 || (( -_å -)-> -_wide_d©a --> -_IO_wr™e_±r - \ - -426 >ð( -_å -)-> -_wide_d©a --> -_IO_wr™e_’d -), 0) \ - -427 ? - `__wov”æow - ( -_å -, -_wch -) \ - -428 : ( -_IO_wšt_t -è(*( -_å -)-> -_wide_d©a --> -_IO_wr™e_±r -++ = ( -_wch -))) - - ) - -431  - #_IO_ãof_uÆocked -( -__å -è(((__å)-> -_æags - & -_IO_EOF_SEEN -è!ð0) - - ) - -432  - #_IO_ã¼Ü_uÆocked -( -__å -è(((__å)-> -_æags - & -_IO_ERR_SEEN -è!ð0) - - ) - -434  -_IO_g‘c - ( -_IO_FILE - * -__å -); - -435  -_IO_putc - ( -__c -, -_IO_FILE - * -__å -); - -436  -_IO_ãof - ( -_IO_FILE - * -__å -è -__THROW -; - -437  -_IO_ã¼Ü - ( -_IO_FILE - * -__å -è -__THROW -; - -439  -_IO_³ekc_locked - ( -_IO_FILE - * -__å -); - -442  - #_IO_PENDING_OUTPUT_COUNT -( -_å -) \ - -443 (( -_å -)-> -_IO_wr™e_±r - - (_å)-> -_IO_wr™e_ba£ -) - - ) - -445  -_IO_æockfže - ( -_IO_FILE - *è -__THROW -; - -446  -_IO_fuÆockfže - ( -_IO_FILE - *è -__THROW -; - -447  -_IO_árylockfže - ( -_IO_FILE - *è -__THROW -; - -449 #ifdeà -_IO_MTSAFE_IO - - -450  - #_IO_³ekc -( -_å -è - `_IO_³ekc_locked - (_å) - - ) - -451  - #_IO_æockfže -( -_å -) \ - -452 ià((( -_å -)-> -_æags - & -_IO_USER_LOCK -è=ð0è - `_IO_æockfže - (_å) - - ) - -453  - #_IO_fuÆockfže -( -_å -) \ - -454 ià((( -_å -)-> -_æags - & -_IO_USER_LOCK -è=ð0è - `_IO_fuÆockfže - (_å) - - ) - -456  - #_IO_³ekc -( -_å -è - `_IO_³ekc_uÆocked - (_å) - - ) - -457  - #_IO_æockfže -( -_å -è - - ) - -458  - #_IO_fuÆockfže -( -_å -è - - ) - -459  - #_IO_árylockfže -( -_å -è - - ) - -460  - #_IO_þ—nup_»giÚ_¡¬t -( -_fù -, -_å -è - - ) - -461  - #_IO_þ—nup_»giÚ_’d -( -_Do™ -è - - ) - -464  -_IO_vfsÿnf - ( -_IO_FILE - * -__»¡riù -, const * __restrict, - -465 -_IO_va_li¡ -, * -__»¡riù -); - -466  -_IO_vårštf - ( -_IO_FILE - * -__»¡riù -, const *__restrict, - -467 -_IO_va_li¡ -); - -468 -_IO_ssize_t - -_IO_·dn - ( -_IO_FILE - *, , _IO_ssize_t); - -469 -_IO_size_t - -_IO_sg‘n - ( -_IO_FILE - *, *, _IO_size_t); - -471 -_IO_off64_t - -_IO_£ekoff - ( -_IO_FILE - *, _IO_off64_t, , ); - -472 -_IO_off64_t - -_IO_£ekpos - ( -_IO_FILE - *, _IO_off64_t, ); - -474  -_IO_ä“_backup_¬— - ( -_IO_FILE - *è -__THROW -; - -476 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -477 -_IO_wšt_t - -_IO_g‘wc - ( -_IO_FILE - * -__å -); - -478 -_IO_wšt_t - -_IO_putwc - ( -wch¬_t - -__wc -, -_IO_FILE - * -__å -); - -479  -_IO_fwide - ( -_IO_FILE - * -__å -,  -__mode -è -__THROW -; - -480 #ià -__GNUC__ - >= 2 - -483 #ià -defšed - -_LIBC - && defšed -SHARED - - -484  - ~ - -485 #ià -SHLIB_COMPAT - ( -libc -, -GLIBC_2_0 -, -GLIBC_2_1 -) - -486  - #_IO_fwide_maybe_šcom·tibË - \ - -487 ( - `__bužtš_ex³ù - (& -_IO_¡dš_u£d - =ð -NULL -, 0)) - - ) - -488 cÚ¡  -_IO_¡dš_u£d -; - -489 -w—k_ex‹º - ( -_IO_¡dš_u£d -); - -492 #iâdeà -_IO_fwide_maybe_šcom·tibË - - -493  - #_IO_fwide_maybe_šcom·tibË - (0) - - ) - -497  - #_IO_fwide -( -__å -, -__mode -) \ - -498 ({  -__»suÉ - = ( -__mode -); \ - -499 ià( -__»suÉ - < 0 && ! -_IO_fwide_maybe_šcom·tibË -) \ - -501 ià(( -__å -)-> -_mode - == 0) \ - -503 ( -__å -)-> -_mode - = -1; \ - -504 -__»suÉ - = ( -__å -)-> -_mode -; \ - -506 ià( - `__bužtš_cÚ¡ªt_p - ( -__mode -) && (__mode) == 0) \ - -507 -__»suÉ - = -_IO_fwide_maybe_šcom·tibË - ? -1 : ( -__å -)-> -_mode -; \ - -509 -__»suÉ - = - `_IO_fwide - ( -__å -, __result); \ - -510 -__»suÉ -; }) - - ) - -513  -_IO_vfwsÿnf - ( -_IO_FILE - * -__»¡riù -, cÚ¡ -wch¬_t - * __restrict, - -514 -_IO_va_li¡ -, * -__»¡riù -); - -515  -_IO_vfw´štf - ( -_IO_FILE - * -__»¡riù -, cÚ¡ -wch¬_t - *__restrict, - -516 -_IO_va_li¡ -); - -517 -_IO_ssize_t - -_IO_w·dn - ( -_IO_FILE - *, -wšt_t -, _IO_ssize_t); - -518  -_IO_ä“_wbackup_¬— - ( -_IO_FILE - *è -__THROW -; - -521 #ifdeà -__LDBL_COMPAT - - -522  - ~ - -525 #ifdeà -__ýlu¥lus - - - @/usr/include/_G_config.h - -4 #iâdeà -_G_cÚfig_h - - -5  - #_G_cÚfig_h - 1 - - ) - -9  - ~ - -10  - #__Ãed_size_t - - - ) - -11 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -12  - #__Ãed_wch¬_t - - - ) - -14  - #__Ãed_NULL - - - ) - -15  - ~<¡ddef.h -> - -16  - #__Ãed_mb¡©e_t - - - ) - -17 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -18  - #__Ãed_wšt_t - - - ) - -20  - ~ - -23 -__off_t - - m__pos -; - -24 -__mb¡©e_t - - m__¡©e -; - -25 } - t_G_åos_t -; - -28 -__off64_t - - m__pos -; - -29 -__mb¡©e_t - - m__¡©e -; - -30 } - t_G_åos64_t -; - -31 #ià -defšed - -_LIBC - || defšed -_GLIBCPP_USE_WCHAR_T - - -32  - ~ - -35  -__gcÚv_šfo - - m__cd -; - -38  -__gcÚv_šfo - - m__cd -; - -39  -__gcÚv_¡•_d©a - - m__d©a -; - -40 } - m__combšed -; - -41 } - t_G_icÚv_t -; - -46  - #_G_va_li¡ - -__gnuc_va_li¡ - - - ) - -48  - #_G_HAVE_MMAP - 1 - - ) - -49  - #_G_HAVE_MREMAP - 1 - - ) - -51  - #_G_IO_IO_FILE_VERSION - 0x20001 - - ) - -54  - #_G_HAVE_ST_BLKSIZE - - `defšed - ( -_STATBUF_ST_BLKSIZE -) - - ) - -56  - #_G_BUFSIZ - 8192 - - ) - - @/usr/include/ctype.h - -22 #iâdef -_CTYPE_H - - -23  - #_CTYPE_H - 1 - - ) - -25  - ~<ã©u»s.h -> - -26  - ~ - -28 - g__BEGIN_DECLS - - -30 #iâdeà -_ISb™ - - -39  - ~<’dŸn.h -> - -40 #ià -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -41  - #_ISb™ -( -b™ -è(1 << (b™)) - - ) - -43  - #_ISb™ -( -b™ -è((b™è< 8 ? ((1 << (b™)è<< 8è: ((1 << (b™)è>> 8)) - - ) - -48 - m_ISuµ” - = -_ISb™ - (0), - -49 - m_ISlow” - = -_ISb™ - (1), - -50 - m_IS®pha - = -_ISb™ - (2), - -51 - m_ISdig™ - = -_ISb™ - (3), - -52 - m_ISxdig™ - = -_ISb™ - (4), - -53 - m_IS¥aû - = -_ISb™ - (5), - -54 - m_IS´št - = -_ISb™ - (6), - -55 - m_ISg¿ph - = -_ISb™ - (7), - -56 - m_ISbÏnk - = -_ISb™ - (8), - -57 - m_ISúŒl - = -_ISb™ - (9), - -58 - m_ISpunù - = -_ISb™ - (10), - -59 - m_IS®num - = -_ISb™ - (11) - -79 cÚ¡ ** - $__ùy³_b_loc - () - -80 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -81 cÚ¡ -__št32_t - ** - $__ùy³_tÞow”_loc - () - -82 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -83 cÚ¡ -__št32_t - ** - $__ùy³_touµ”_loc - () - -84 -__THROW - - `__©Œibu‹__ - (( -__cÚ¡__ -)); - -87 #iâdeà -__ýlu¥lus - - -88  - #__isùy³ -( -c -, -ty³ -) \ - -89 ((* - `__ùy³_b_loc - ())[(è( -c -)] & (è -ty³ -) - - ) - -90 #–ià -defšed - -__USE_EXTERN_INLINES - - -91  - #__isùy³_f -( -ty³ -) \ - -92 -__ex‹º_šlše - \ - -93 -is -## - `ty³ - ( -__c -è -__THROW - \ - -95  (* - `__ùy³_b_loc - ())[(è( -__c -)] & (è -_IS -## -ty³ -; \ - -96 - } - - ) -} - -99  - #__i§scii -( -c -è(((cè& ~0x7fè=ð0è - - ) - -100  - #__tßscii -( -c -è((cè& 0x7fè - - ) - -102  - #__exùy³ -( -Çme -è  - `Çme - (è -__THROW - - - ) - -104 -__BEGIN_NAMESPACE_STD - - -110 -__exùy³ - ( -i§Êum -); - -111 -__exùy³ - ( -i§Íha -); - -112 -__exùy³ - ( -isúŒl -); - -113 -__exùy³ - ( -isdig™ -); - -114 -__exùy³ - ( -i¦ow” -); - -115 -__exùy³ - ( -isg¿ph -); - -116 -__exùy³ - ( -i¥ršt -); - -117 -__exùy³ - ( -i¥unù -); - -118 -__exùy³ - ( -is¥aû -); - -119 -__exùy³ - ( -isuµ” -); - -120 -__exùy³ - ( -isxdig™ -); - -124  - $tÞow” - ( -__c -è -__THROW -; - -127  - $touµ” - ( -__c -è -__THROW -; - -129 -__END_NAMESPACE_STD - - -133 #ifdef -__USE_ISOC99 - - -134 -__BEGIN_NAMESPACE_C99 - - -136 - `__exùy³ - ( -isbÏnk -); - -138 -__END_NAMESPACE_C99 - - -141 #ifdeà -__USE_GNU - - -143  - $isùy³ - ( -__c -,  -__mask -è -__THROW -; - -146 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - || defšed -__USE_XOPEN - - -150  - $i§scii - ( -__c -è -__THROW -; - -154  - $tßscii - ( -__c -è -__THROW -; - -158 - `__exùy³ - ( -_touµ” -); - -159 - `__exùy³ - ( -_tÞow” -); - -163  - #__tobody -( -c -, -f -, -a -, -¬gs -) \ - -164 ( -__ex‹nsiÚ__ - \ - -165 ({  -__»s -; \ - -166 ià( ( -c -) > 1) \ - -168 ià( - `__bužtš_cÚ¡ªt_p - ( -c -)) \ - -170  -__c - = ( -c -); \ - -171 -__»s - = -__c - < -128 || __ø> 255 ? __ø: ( -a -)[__c]; \ - -174 -__»s - = -f - -¬gs -; \ - -177 -__»s - = ( -a -)[(è( -c -)]; \ - -178 -__»s -; - } -})) - - ) - -180 #ià! -defšed - -__NO_CTYPE - - -181 #ifdeà -__isùy³_f - - -182 - $__isùy³_f - ( -®num -) - -183 - $__isùy³_f - ( -®pha -) - -184 - $__isùy³_f - ( -úŒl -) - -185 - $__isùy³_f - ( -dig™ -) - -186 - $__isùy³_f - ( -low” -) - -187 - $__isùy³_f - ( -g¿ph -) - -188 - $__isùy³_f - ( -´št -) - -189 - $__isùy³_f - ( -punù -) - -190 - $__isùy³_f - ( -¥aû -) - -191 - $__isùy³_f - ( -uµ” -) - -192 - $__isùy³_f - ( -xdig™ -) - -193 #ifdeà -__USE_ISOC99 - - -194 - $__isùy³_f - ( -bÏnk -) - -196 #–ià -defšed - -__isùy³ - - -197  - #i§Êum -( -c -è - `__isùy³ -((c), -_IS®num -) - - ) - -198  - #i§Íha -( -c -è - `__isùy³ -((c), -_IS®pha -) - - ) - -199  - #isúŒl -( -c -è - `__isùy³ -((c), -_ISúŒl -) - - ) - -200  - #isdig™ -( -c -è - `__isùy³ -((c), -_ISdig™ -) - - ) - -201  - #i¦ow” -( -c -è - `__isùy³ -((c), -_ISlow” -) - - ) - -202  - #isg¿ph -( -c -è - `__isùy³ -((c), -_ISg¿ph -) - - ) - -203  - #i¥ršt -( -c -è - `__isùy³ -((c), -_IS´št -) - - ) - -204  - #i¥unù -( -c -è - `__isùy³ -((c), -_ISpunù -) - - ) - -205  - #is¥aû -( -c -è - `__isùy³ -((c), -_IS¥aû -) - - ) - -206  - #isuµ” -( -c -è - `__isùy³ -((c), -_ISuµ” -) - - ) - -207  - #isxdig™ -( -c -è - `__isùy³ -((c), -_ISxdig™ -) - - ) - -208 #ifdeà -__USE_ISOC99 - - -209  - #isbÏnk -( -c -è - `__isùy³ -((c), -_ISbÏnk -) - - ) - -213 #ifdeà -__USE_EXTERN_INLINES - - -214 -__ex‹º_šlše -  - -215 - `__NTH - ( - $tÞow” - ( -__c -)) - -217  -__c - >ð-128 && __ø< 256 ? (* - `__ùy³_tÞow”_loc - ())[__c] : __c; - -218 - } -} - -220 -__ex‹º_šlše -  - -221 -__NTH - ( - $touµ” - ( -__c -)) - -223  -__c - >ð-128 && __ø< 256 ? (* - `__ùy³_touµ”_loc - ())[__c] : __c; - -224 - } -} - -227 #ià -__GNUC__ - >ð2 && -defšed - -__OPTIMIZE__ - && !defšed -__ýlu¥lus - - -228  - #tÞow” -( -c -è - `__tobody - (c, -tÞow” -, * - `__ùy³_tÞow”_loc - (), (c)) - - ) - -229  - #touµ” -( -c -è - `__tobody - (c, -touµ” -, * - `__ùy³_touµ”_loc - (), (c)) - - ) - -232 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - || defšed -__USE_XOPEN - - -233  - #i§scii -( -c -è - `__i§scii - (c) - - ) - -234  - #tßscii -( -c -è - `__tßscii - (c) - - ) - -236  - #_tÞow” -( -c -è((è(* - `__ùy³_tÞow”_loc - ())[(è(c)]) - - ) - -237  - #_touµ” -( -c -è((è(* - `__ùy³_touµ”_loc - ())[(è(c)]) - - ) - -243 #ifdeà -__USE_XOPEN2K8 - - -257  - ~ - -261  - #__isùy³_l -( -c -, -ty³ -, -loÿË -) \ - -262 (( -loÿË -)-> -__ùy³_b -[(è( -c -)] & (è -ty³ -) - - ) - -264  - #__exùy³_l -( -Çme -) \ - -265  - `Çme - (, -__loÿË_t -è -__THROW - - - ) - -271 -__exùy³_l - ( -i§Êum_l -); - -272 -__exùy³_l - ( -i§Íha_l -); - -273 -__exùy³_l - ( -isúŒl_l -); - -274 -__exùy³_l - ( -isdig™_l -); - -275 -__exùy³_l - ( -i¦ow”_l -); - -276 -__exùy³_l - ( -isg¿ph_l -); - -277 -__exùy³_l - ( -i¥ršt_l -); - -278 -__exùy³_l - ( -i¥unù_l -); - -279 -__exùy³_l - ( -is¥aû_l -); - -280 -__exùy³_l - ( -isuµ”_l -); - -281 -__exùy³_l - ( -isxdig™_l -); - -283 -__exùy³_l - ( -isbÏnk_l -); - -287  - $__tÞow”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -288  - $tÞow”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -291  - $__touµ”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -292  - $touµ”_l - ( -__c -, -__loÿË_t - -__l -è -__THROW -; - -294 #ià -__GNUC__ - >ð2 && -defšed - -__OPTIMIZE__ - && !defšed -__ýlu¥lus - - -295  - #__tÞow”_l -( -c -, -loÿË -) \ - -296 - `__tobody - ( -c -, -__tÞow”_l -, ( -loÿË -)-> -__ùy³_tÞow” -, (c,†oÿË)) - - ) - -297  - #__touµ”_l -( -c -, -loÿË -) \ - -298 - `__tobody - ( -c -, -__touµ”_l -, ( -loÿË -)-> -__ùy³_touµ” -, (c,†oÿË)) - - ) - -299  - #tÞow”_l -( -c -, -loÿË -è - `__tÞow”_l - ((c), (loÿË)) - - ) - -300  - #touµ”_l -( -c -, -loÿË -è - `__touµ”_l - ((c), (loÿË)) - - ) - -304 #iâdeà -__NO_CTYPE - - -305  - #__i§Êum_l -( -c -, -l -è - `__isùy³_l -((c), -_IS®num -, (l)) - - ) - -306  - #__i§Íha_l -( -c -, -l -è - `__isùy³_l -((c), -_IS®pha -, (l)) - - ) - -307  - #__isúŒl_l -( -c -, -l -è - `__isùy³_l -((c), -_ISúŒl -, (l)) - - ) - -308  - #__isdig™_l -( -c -, -l -è - `__isùy³_l -((c), -_ISdig™ -, (l)) - - ) - -309  - #__i¦ow”_l -( -c -, -l -è - `__isùy³_l -((c), -_ISlow” -, (l)) - - ) - -310  - #__isg¿ph_l -( -c -, -l -è - `__isùy³_l -((c), -_ISg¿ph -, (l)) - - ) - -311  - #__i¥ršt_l -( -c -, -l -è - `__isùy³_l -((c), -_IS´št -, (l)) - - ) - -312  - #__i¥unù_l -( -c -, -l -è - `__isùy³_l -((c), -_ISpunù -, (l)) - - ) - -313  - #__is¥aû_l -( -c -, -l -è - `__isùy³_l -((c), -_IS¥aû -, (l)) - - ) - -314  - #__isuµ”_l -( -c -, -l -è - `__isùy³_l -((c), -_ISuµ” -, (l)) - - ) - -315  - #__isxdig™_l -( -c -, -l -è - `__isùy³_l -((c), -_ISxdig™ -, (l)) - - ) - -317  - #__isbÏnk_l -( -c -, -l -è - `__isùy³_l -((c), -_ISbÏnk -, (l)) - - ) - -319 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - - -320  - #__i§scii_l -( -c -, -l -è(Ö), - `__i§scii - (c)) - - ) - -321  - #__tßscii_l -( -c -, -l -è(Ö), - `__tßscii - (c)) - - ) - -324  - #i§Êum_l -( -c -, -l -è - `__i§Êum_l - ((c), (l)) - - ) - -325  - #i§Íha_l -( -c -, -l -è - `__i§Íha_l - ((c), (l)) - - ) - -326  - #isúŒl_l -( -c -, -l -è - `__isúŒl_l - ((c), (l)) - - ) - -327  - #isdig™_l -( -c -, -l -è - `__isdig™_l - ((c), (l)) - - ) - -328  - #i¦ow”_l -( -c -, -l -è - `__i¦ow”_l - ((c), (l)) - - ) - -329  - #isg¿ph_l -( -c -, -l -è - `__isg¿ph_l - ((c), (l)) - - ) - -330  - #i¥ršt_l -( -c -, -l -è - `__i¥ršt_l - ((c), (l)) - - ) - -331  - #i¥unù_l -( -c -, -l -è - `__i¥unù_l - ((c), (l)) - - ) - -332  - #is¥aû_l -( -c -, -l -è - `__is¥aû_l - ((c), (l)) - - ) - -333  - #isuµ”_l -( -c -, -l -è - `__isuµ”_l - ((c), (l)) - - ) - -334  - #isxdig™_l -( -c -, -l -è - `__isxdig™_l - ((c), (l)) - - ) - -336  - #isbÏnk_l -( -c -, -l -è - `__isbÏnk_l - ((c), (l)) - - ) - -338 #ià -defšed - -__USE_SVID - || defšed -__USE_MISC - - -339  - #i§scii_l -( -c -, -l -è - `__i§scii_l - ((c), (l)) - - ) - -340  - #tßscii_l -( -c -, -l -è - `__tßscii_l - ((c), (l)) - - ) - -347 -__END_DECLS - - - @/usr/include/stdc-predef.h - -18 #iâdef -_STDC_PREDEF_H - - -19  - #_STDC_PREDEF_H - 1 - - ) - -36 #ifdeà -__GCC_IEC_559 - - -37 #ià -__GCC_IEC_559 - > 0 - -38  - #__STDC_IEC_559__ - 1 - - ) - -41  - #__STDC_IEC_559__ - 1 - - ) - -44 #ifdeà -__GCC_IEC_559_COMPLEX - - -45 #ià -__GCC_IEC_559_COMPLEX - > 0 - -46  - #__STDC_IEC_559_COMPLEX__ - 1 - - ) - -49  - #__STDC_IEC_559_COMPLEX__ - 1 - - ) - -54  - #__STDC_ISO_10646__ - 201103L - - ) - -57  - #__STDC_NO_THREADS__ - 1 - - ) - - @/usr/include/endian.h - -18 #iâdef -_ENDIAN_H - - -19  - #_ENDIAN_H - 1 - - ) - -21  - ~<ã©u»s.h -> - -31  - #__LITTLE_ENDIAN - 1234 - - ) - -32  - #__BIG_ENDIAN - 4321 - - ) - -33  - #__PDP_ENDIAN - 3412 - - ) - -36  - ~ - -40 #iâdeà -__FLOAT_WORD_ORDER - - -41  - #__FLOAT_WORD_ORDER - -__BYTE_ORDER - - - ) - -44 #ifdef -__USE_BSD - - -45  - #LITTLE_ENDIAN - -__LITTLE_ENDIAN - - - ) - -46  - #BIG_ENDIAN - -__BIG_ENDIAN - - - ) - -47  - #PDP_ENDIAN - -__PDP_ENDIAN - - - ) - -48  - #BYTE_ORDER - -__BYTE_ORDER - - - ) - -51 #ià -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -52  - #__LONG_LONG_PAIR -( -HI -, -LO -èLO, - ) -HI - -53 #–ià -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -54  - #__LONG_LONG_PAIR -( -HI -, -LO -èHI, - ) -LO - -58 #ià -defšed - -__USE_BSD - && !defšed -__ASSEMBLER__ - - -60  - ~ - -62 #ià -__BYTE_ORDER - =ð -__LITTLE_ENDIAN - - -63  - #htobe16 -( -x -è - `__bsw­_16 - (x) - - ) - -64  - #htÞe16 -( -x -è(x) - - ) - -65  - #be16toh -( -x -è - `__bsw­_16 - (x) - - ) - -66  - #Ë16toh -( -x -è(x) - - ) - -68  - #htobe32 -( -x -è - `__bsw­_32 - (x) - - ) - -69  - #htÞe32 -( -x -è(x) - - ) - -70  - #be32toh -( -x -è - `__bsw­_32 - (x) - - ) - -71  - #Ë32toh -( -x -è(x) - - ) - -73  - #htobe64 -( -x -è - `__bsw­_64 - (x) - - ) - -74  - #htÞe64 -( -x -è(x) - - ) - -75  - #be64toh -( -x -è - `__bsw­_64 - (x) - - ) - -76  - #Ë64toh -( -x -è(x) - - ) - -79  - #htobe16 -( -x -è(x) - - ) - -80  - #htÞe16 -( -x -è - `__bsw­_16 - (x) - - ) - -81  - #be16toh -( -x -è(x) - - ) - -82  - #Ë16toh -( -x -è - `__bsw­_16 - (x) - - ) - -84  - #htobe32 -( -x -è(x) - - ) - -85  - #htÞe32 -( -x -è - `__bsw­_32 - (x) - - ) - -86  - #be32toh -( -x -è(x) - - ) - -87  - #Ë32toh -( -x -è - `__bsw­_32 - (x) - - ) - -89  - #htobe64 -( -x -è(x) - - ) - -90  - #htÞe64 -( -x -è - `__bsw­_64 - (x) - - ) - -91  - #be64toh -( -x -è(x) - - ) - -92  - #Ë64toh -( -x -è - `__bsw­_64 - (x) - - ) - - @/usr/include/gconv.h - -22 #iâdeà -_GCONV_H - - -23  - #_GCONV_H - 1 - - ) - -25  - ~<ã©u»s.h -> - -26  - #__Ãed_mb¡©e_t - - - ) - -27  - #__Ãed_wšt_t - - - ) - -28  - ~ - -29  - #__Ãed_size_t - - - ) - -30  - #__Ãed_wch¬_t - - - ) - -31  - ~<¡ddef.h -> - -34  - #__UNKNOWN_10646_CHAR - (( -wch¬_t -è0xfffd) - - ) - -39 - m__GCONV_OK - = 0, - -40 - m__GCONV_NOCONV -, - -41 - m__GCONV_NODB -, - -42 - m__GCONV_NOMEM -, - -44 - m__GCONV_EMPTY_INPUT -, - -45 - m__GCONV_FULL_OUTPUT -, - -46 - m__GCONV_ILLEGAL_INPUT -, - -47 - m__GCONV_INCOMPLETE_INPUT -, - -49 - m__GCONV_ILLEGAL_DESCRIPTOR -, - -50 - m__GCONV_INTERNAL_ERROR - - -57 - m__GCONV_IS_LAST - = 0x0001, - -58 - m__GCONV_IGNORE_ERRORS - = 0x0002, - -59 - m__GCONV_SWAP - = 0x0004 - -64  - g__gcÚv_¡• -; - -65  - g__gcÚv_¡•_d©a -; - -66  - g__gcÚv_lßded_objeù -; - -67  - g__gcÚv_Œªs_d©a -; - -71 (* - t__gcÚv_fù -è( - t__gcÚv_¡• - *,  - t__gcÚv_¡•_d©a - *, - -73 **, - tsize_t - *, , ); - -76  - $wšt_t - (* - t__gcÚv_btowc_fù -è( - t__gcÚv_¡• - *, ); - -79 (* - t__gcÚv_š™_fù -è( - t__gcÚv_¡• - *); - -80 (* - t__gcÚv_’d_fù -è( - t__gcÚv_¡• - *); - -84 (* - t__gcÚv_Œªs_fù -è( - t__gcÚv_¡• - *, - -85  - t__gcÚv_¡•_d©a - *, *, - -89 - tsize_t - *); - -92 (* - t__gcÚv_Œªs_cÚ‹xt_fù -) (*, const *, - -97 (* - t__gcÚv_Œªs_qu”y_fù -) (const *, const ***, - -98 - tsize_t - *); - -101 (* - t__gcÚv_Œªs_š™_fù -) (**, const *); - -102 (* - t__gcÚv_Œªs_’d_fù -) (*); - -104  - s__gcÚv_Œªs_d©a - - -107 -__gcÚv_Œªs_fù - -__Œªs_fù -; - -108 -__gcÚv_Œªs_cÚ‹xt_fù - -__Œªs_cÚ‹xt_fù -; - -109 -__gcÚv_Œªs_’d_fù - -__Œªs_’d_fù -; - -110 * -__d©a -; - -111  -__gcÚv_Œªs_d©a - * -__Ãxt -; - -116  - s__gcÚv_¡• - - -118  -__gcÚv_lßded_objeù - * -__shlib_hªdË -; - -119 cÚ¡ * -__modÇme -; - -121  -__couÁ” -; - -123 * -__äom_Çme -; - -124 * -__to_Çme -; - -126 -__gcÚv_fù - -__fù -; - -127 -__gcÚv_btowc_fù - -__btowc_fù -; - -128 -__gcÚv_š™_fù - -__š™_fù -; - -129 -__gcÚv_’d_fù - -__’d_fù -; - -133  -__mš_Ãeded_äom -; - -134  -__max_Ãeded_äom -; - -135  -__mš_Ãeded_to -; - -136  -__max_Ãeded_to -; - -139  -__¡©eful -; - -141 * -__d©a -; - -146  - s__gcÚv_¡•_d©a - - -148 * -__outbuf -; - -149 * -__outbuãnd -; - -153  -__æags -; - -157  -__švoÿtiÚ_couÁ” -; - -161  -__š‹º®_u£ -; - -163 -__mb¡©e_t - * -__¡©• -; - -164 -__mb¡©e_t - -__¡©e -; - -168  -__gcÚv_Œªs_d©a - * -__Œªs -; - -173  - s__gcÚv_šfo - - -175 -size_t - -__n¡•s -; - -176  -__gcÚv_¡• - * -__¡•s -; - -177 -__ex‹nsiÚ__ -  -__gcÚv_¡•_d©a - -__d©a - -__æex¬r -; - -178 } * - t__gcÚv_t -; - - @/usr/include/wchar.h - -23 #iâdeà -_WCHAR_H - - -25 #ià! -defšed - -__Ãed_mb¡©e_t - && !defšed -__Ãed_wšt_t - - -26  - #_WCHAR_H - 1 - - ) - -27  - ~<ã©u»s.h -> - -30 #ifdeà -_WCHAR_H - - -32  - #__Ãed___FILE - - - ) - -33 #ià -defšed - -__USE_UNIX98 - || defšed -__USE_XOPEN2K - - -34  - #__Ãed_FILE - - - ) - -36  - ~<¡dio.h -> - -38  - #__Ãed___va_li¡ - - - ) - -39  - ~<¡d¬g.h -> - -41  - ~ - -44  - #__Ãed_size_t - - - ) - -45  - #__Ãed_wch¬_t - - - ) - -46  - #__Ãed_NULL - - - ) - -48 #ià -defšed - -_WCHAR_H - || defšed -__Ãed_wšt_t - || !defšed -__WINT_TYPE__ - - -49 #undeà -__Ãed_wšt_t - - -50  - #__Ãed_wšt_t - - - ) - -51  - ~<¡ddef.h -> - -55 #iâdeà -_WINT_T - - -60  - #_WINT_T - - - ) - -61  - twšt_t -; - -65 #ià -defšed - -__ýlu¥lus - && defšed -_GLIBCPP_USE_NAMESPACES - \ - -66 && -defšed - -__WINT_TYPE__ - - -67 -__BEGIN_NAMESPACE_STD - - -68  -__WINT_TYPE__ - - twšt_t -; - -69 - g__END_NAMESPACE_STD - - -74 #ià -defšed - -__ýlu¥lus - && -__GNUC_PREREQ - (4, 4) - -75  - #__CORRECT_ISO_CPP_WCHAR_H_PROTO - - - ) - -79 #ià( -defšed - -_WCHAR_H - || defšed -__Ãed_mb¡©e_t -è&& !defšed -____mb¡©e_t_defšed - - -80  - #____mb¡©e_t_defšed - 1 - - ) - -84  - m__couÁ -; - -87 #ifdeà -__WINT_TYPE__ - - -88 -__WINT_TYPE__ - - m__wch -; - -90 -wšt_t - - m__wch -; - -92  - m__wchb -[4]; - -93 } - m__v®ue -; - -94 } - t__mb¡©e_t -; - -96 #undeà -__Ãed_mb¡©e_t - - -101 #ifdeà -_WCHAR_H - - -103 #iâdeà -__mb¡©e_t_defšed - - -104 -__BEGIN_NAMESPACE_C99 - - -106  -__mb¡©e_t - - tmb¡©e_t -; - -107 - g__END_NAMESPACE_C99 - - -108  - #__mb¡©e_t_defšed - 1 - - ) - -111 #ifdeà -__USE_GNU - - -112 - $__USING_NAMESPACE_C99 -( -mb¡©e_t -) - -115 #iâdeà -WCHAR_MIN - - -117  - #WCHAR_MIN - -__WCHAR_MIN - - - ) - -118  - #WCHAR_MAX - -__WCHAR_MAX - - - ) - -121 #iâdeà -WEOF - - -122  - #WEOF - (0xffffffffu) - - ) - -127 #ià -defšed - -__USE_XOPEN - && !defšed -__USE_UNIX98 - - -128  - ~ - -132 -__BEGIN_DECLS - - -134 -__BEGIN_NAMESPACE_STD - - -137  -tm -; - -138 -__END_NAMESPACE_STD - - -142 - $__USING_NAMESPACE_STD -( -tm -) - -145 -__BEGIN_NAMESPACE_STD - - -147 -wch¬_t - * - $wcsýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -148 cÚ¡ -wch¬_t - * -__»¡riù - -__¤c -è -__THROW -; - -150 -wch¬_t - * - $wc¢ýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -151 cÚ¡ -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -) - -152 -__THROW -; - -155 -wch¬_t - * - $wcsÿt - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -156 cÚ¡ -wch¬_t - * -__»¡riù - -__¤c -è -__THROW -; - -158 -wch¬_t - * - $wc¢ÿt - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -159 cÚ¡ -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -) - -160 -__THROW -; - -163  - $wcscmp - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -) - -164 -__THROW - -__©Œibu‹_pu»__ -; - -166  - $wc¢cmp - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, -size_t - -__n -) - -167 -__THROW - -__©Œibu‹_pu»__ -; - -168 -__END_NAMESPACE_STD - - -170 #ifdeà -__USE_XOPEN2K8 - - -172  - $wcsÿ£cmp - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -è -__THROW -; - -175  - $wc¢ÿ£cmp - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, - -176 -size_t - -__n -è -__THROW -; - -180  - ~ - -182  - $wcsÿ£cmp_l - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, - -183 -__loÿË_t - -__loc -è -__THROW -; - -185  - $wc¢ÿ£cmp_l - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, - -186 -size_t - -__n -, -__loÿË_t - -__loc -è -__THROW -; - -189 -__BEGIN_NAMESPACE_STD - - -192  - $wcscÞl - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -è -__THROW -; - -196 -size_t - - $wcsxäm - ( -wch¬_t - * -__»¡riù - -__s1 -, - -197 cÚ¡ -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -è -__THROW -; - -198 -__END_NAMESPACE_STD - - -200 #ifdeà -__USE_XOPEN2K8 - - -206  - $wcscÞl_l - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, - -207 -__loÿË_t - -__loc -è -__THROW -; - -212 -size_t - - $wcsxäm_l - ( -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, - -213 -size_t - -__n -, -__loÿË_t - -__loc -è -__THROW -; - -216 -wch¬_t - * - $wcsdup - (cÚ¡ -wch¬_t - * -__s -è -__THROW - -__©Œibu‹_m®loc__ -; - -219 -__BEGIN_NAMESPACE_STD - - -221 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -222 "C++" -wch¬_t - * - $wcschr - ( -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -223 -__THROW - - `__asm - ("wcschr"è -__©Œibu‹_pu»__ -; - -224 "C++" cÚ¡ -wch¬_t - * - $wcschr - (cÚ¡ -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -225 -__THROW - - `__asm - ("wcschr"è -__©Œibu‹_pu»__ -; - -227 -wch¬_t - * - $wcschr - (cÚ¡ -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -228 -__THROW - -__©Œibu‹_pu»__ -; - -231 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -232 "C++" -wch¬_t - * - $wc¤chr - ( -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -233 -__THROW - - `__asm - ("wc¤chr"è -__©Œibu‹_pu»__ -; - -234 "C++" cÚ¡ -wch¬_t - * - $wc¤chr - (cÚ¡ -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -235 -__THROW - - `__asm - ("wc¤chr"è -__©Œibu‹_pu»__ -; - -237 -wch¬_t - * - $wc¤chr - (cÚ¡ -wch¬_t - * -__wcs -, wch¬_ˆ -__wc -) - -238 -__THROW - -__©Œibu‹_pu»__ -; - -240 -__END_NAMESPACE_STD - - -242 #ifdeà -__USE_GNU - - -245 -wch¬_t - * - $wcschºul - (cÚ¡ -wch¬_t - * -__s -, wch¬_ˆ -__wc -) - -246 -__THROW - -__©Œibu‹_pu»__ -; - -249 -__BEGIN_NAMESPACE_STD - - -252 -size_t - - $wcsc¥n - (cÚ¡ -wch¬_t - * -__wcs -, cÚ¡ wch¬_ˆ* -__»jeù -) - -253 -__THROW - -__©Œibu‹_pu»__ -; - -256 -size_t - - $wcs¥n - (cÚ¡ -wch¬_t - * -__wcs -, cÚ¡ wch¬_ˆ* -__acû± -) - -257 -__THROW - -__©Œibu‹_pu»__ -; - -259 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -260 "C++" -wch¬_t - * - $wc¥brk - ( -wch¬_t - * -__wcs -, cÚ¡ wch¬_ˆ* -__acû± -) - -261 -__THROW - - `__asm - ("wc¥brk"è -__©Œibu‹_pu»__ -; - -262 "C++" cÚ¡ -wch¬_t - * - $wc¥brk - (cÚ¡ -wch¬_t - * -__wcs -, - -263 cÚ¡ -wch¬_t - * -__acû± -) - -264 -__THROW - - `__asm - ("wc¥brk"è -__©Œibu‹_pu»__ -; - -266 -wch¬_t - * - $wc¥brk - (cÚ¡ -wch¬_t - * -__wcs -, cÚ¡ wch¬_ˆ* -__acû± -) - -267 -__THROW - -__©Œibu‹_pu»__ -; - -270 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -271 "C++" -wch¬_t - * - $wcs¡r - ( -wch¬_t - * -__hay¡ack -, cÚ¡ wch¬_ˆ* -__ÃedË -) - -272 -__THROW - - `__asm - ("wcs¡r"è -__©Œibu‹_pu»__ -; - -273 "C++" cÚ¡ -wch¬_t - * - $wcs¡r - (cÚ¡ -wch¬_t - * -__hay¡ack -, - -274 cÚ¡ -wch¬_t - * -__ÃedË -) - -275 -__THROW - - `__asm - ("wcs¡r"è -__©Œibu‹_pu»__ -; - -277 -wch¬_t - * - $wcs¡r - (cÚ¡ -wch¬_t - * -__hay¡ack -, cÚ¡ wch¬_ˆ* -__ÃedË -) - -278 -__THROW - -__©Œibu‹_pu»__ -; - -282 -wch¬_t - * - $wc¡ok - ( -wch¬_t - * -__»¡riù - -__s -, - -283 cÚ¡ -wch¬_t - * -__»¡riù - -__d–im -, - -284 -wch¬_t - ** -__»¡riù - -__±r -è -__THROW -; - -287 -size_t - - $wc¦’ - (cÚ¡ -wch¬_t - * -__s -è -__THROW - -__©Œibu‹_pu»__ -; - -288 -__END_NAMESPACE_STD - - -290 #ifdeà -__USE_XOPEN - - -292 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -293 "C++" -wch¬_t - * - $wcswcs - ( -wch¬_t - * -__hay¡ack -, cÚ¡ wch¬_ˆ* -__ÃedË -) - -294 -__THROW - - `__asm - ("wcswcs"è -__©Œibu‹_pu»__ -; - -295 "C++" cÚ¡ -wch¬_t - * - $wcswcs - (cÚ¡ -wch¬_t - * -__hay¡ack -, - -296 cÚ¡ -wch¬_t - * -__ÃedË -) - -297 -__THROW - - `__asm - ("wcswcs"è -__©Œibu‹_pu»__ -; - -299 -wch¬_t - * - $wcswcs - (cÚ¡ -wch¬_t - * -__hay¡ack -, cÚ¡ wch¬_ˆ* -__ÃedË -) - -300 -__THROW - -__©Œibu‹_pu»__ -; - -304 #ifdeà -__USE_XOPEN2K8 - - -306 -size_t - - $wc¢Ën - (cÚ¡ -wch¬_t - * -__s -, -size_t - -__maxËn -) - -307 -__THROW - -__©Œibu‹_pu»__ -; - -311 -__BEGIN_NAMESPACE_STD - - -313 #ifdeà -__CORRECT_ISO_CPP_WCHAR_H_PROTO - - -314 "C++" -wch¬_t - * - $wmemchr - ( -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -) - -315 -__THROW - - `__asm - ("wmemchr"è -__©Œibu‹_pu»__ -; - -316 "C++" cÚ¡ -wch¬_t - * - $wmemchr - (cÚ¡ -wch¬_t - * -__s -, wch¬_ˆ -__c -, - -317 -size_t - -__n -) - -318 -__THROW - - `__asm - ("wmemchr"è -__©Œibu‹_pu»__ -; - -320 -wch¬_t - * - $wmemchr - (cÚ¡ -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -) - -321 -__THROW - -__©Œibu‹_pu»__ -; - -325  - $wmemcmp - (cÚ¡ -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, -size_t - -__n -) - -326 -__THROW - -__©Œibu‹_pu»__ -; - -329 -wch¬_t - * - $wmemýy - ( -wch¬_t - * -__»¡riù - -__s1 -, - -330 cÚ¡ -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -è -__THROW -; - -334 -wch¬_t - * - $wmemmove - ( -wch¬_t - * -__s1 -, cÚ¡ wch¬_ˆ* -__s2 -, -size_t - -__n -) - -335 -__THROW -; - -338 -wch¬_t - * - $wmem£t - ( -wch¬_t - * -__s -, wch¬_ˆ -__c -, -size_t - -__n -è -__THROW -; - -339 -__END_NAMESPACE_STD - - -341 #ifdeà -__USE_GNU - - -344 -wch¬_t - * - $wmempýy - ( -wch¬_t - * -__»¡riù - -__s1 -, - -345 cÚ¡ -wch¬_t - * -__»¡riù - -__s2 -, -size_t - -__n -) - -346 -__THROW -; - -350 -__BEGIN_NAMESPACE_STD - - -353 -wšt_t - - $btowc - ( -__c -è -__THROW -; - -357  - $wùob - ( -wšt_t - -__c -è -__THROW -; - -361  - $mbsš™ - (cÚ¡ -mb¡©e_t - * -__ps -è -__THROW - -__©Œibu‹_pu»__ -; - -365 -size_t - - $mb¹owc - ( -wch¬_t - * -__»¡riù - -__pwc -, - -366 cÚ¡ * -__»¡riù - -__s -, -size_t - -__n -, - -367 -mb¡©e_t - * -__»¡riù - -__p -è -__THROW -; - -370 -size_t - - $wütomb - (* -__»¡riù - -__s -, -wch¬_t - -__wc -, - -371 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -374 -size_t - - $__mb¾’ - (cÚ¡ * -__»¡riù - -__s -, -size_t - -__n -, - -375 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -376 -size_t - - $mb¾’ - (cÚ¡ * -__»¡riù - -__s -, -size_t - -__n -, - -377 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -378 -__END_NAMESPACE_STD - - -380 #ifdeà -__USE_EXTERN_INLINES - - -386 -wšt_t - - $__btowc_®Ÿs - ( -__c -è - `__asm - ("btowc"); - -387 -__ex‹º_šlše - -wšt_t - - -388 - `__NTH - ( - $btowc - ( -__c -)) - -389 {  ( - `__bužtš_cÚ¡ªt_p - ( -__c -) && __c >= '\0' && __c <= '\x7f' - -390 ? ( -wšt_t -è -__c - : - `__btowc_®Ÿs - (__c)); - } -} - -392  - $__wùob_®Ÿs - ( -wšt_t - -__c -è - `__asm - ("wctob"); - -393 -__ex‹º_šlše -  - -394 - `__NTH - ( - $wùob - ( -wšt_t - -__wc -)) - -395 {  ( - `__bužtš_cÚ¡ªt_p - ( -__wc -è&& __wø>ð -L -'\0' && __wc <= L'\x7f' - -396 ? (è -__wc - : - `__wùob_®Ÿs - (__wc)); - } -} - -398 -__ex‹º_šlše - -size_t - - -399 -__NTH - ( - $mb¾’ - (cÚ¡ * -__»¡riù - -__s -, -size_t - -__n -, - -400 -mb¡©e_t - * -__»¡riù - -__ps -)) - -401 {  ( -__ps - !ð -NULL - - -402 ? - `mb¹owc - ( -NULL -, -__s -, -__n -, -__ps -è: - `__mb¾’ - (__s, __n, NULL)); - } -} - -405 -__BEGIN_NAMESPACE_STD - - -408 -size_t - - $mb¤towcs - ( -wch¬_t - * -__»¡riù - -__d¡ -, - -409 cÚ¡ ** -__»¡riù - -__¤c -, -size_t - -__Ën -, - -410 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -414 -size_t - - $wc¤tombs - (* -__»¡riù - -__d¡ -, - -415 cÚ¡ -wch¬_t - ** -__»¡riù - -__¤c -, -size_t - -__Ën -, - -416 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -417 -__END_NAMESPACE_STD - - -420 #ifdef -__USE_XOPEN2K8 - - -423 -size_t - - $mb¢¹owcs - ( -wch¬_t - * -__»¡riù - -__d¡ -, - -424 cÚ¡ ** -__»¡riù - -__¤c -, -size_t - -__nmc -, - -425 -size_t - -__Ën -, -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -429 -size_t - - $wc¢¹ombs - (* -__»¡riù - -__d¡ -, - -430 cÚ¡ -wch¬_t - ** -__»¡riù - -__¤c -, - -431 -size_t - -__nwc -, size_ˆ -__Ën -, - -432 -mb¡©e_t - * -__»¡riù - -__ps -è -__THROW -; - -437 #ifdeà -__USE_XOPEN - - -439  - $wcwidth - ( -wch¬_t - -__c -è -__THROW -; - -443  - $wcswidth - (cÚ¡ -wch¬_t - * -__s -, -size_t - -__n -è -__THROW -; - -447 -__BEGIN_NAMESPACE_STD - - -450  - $wc¡od - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -451 -wch¬_t - ** -__»¡riù - -__’d±r -è -__THROW -; - -452 -__END_NAMESPACE_STD - - -454 #ifdeà -__USE_ISOC99 - - -455 -__BEGIN_NAMESPACE_C99 - - -457  - $wc¡of - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -458 -wch¬_t - ** -__»¡riù - -__’d±r -è -__THROW -; - -459  - $wc¡Þd - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -460 -wch¬_t - ** -__»¡riù - -__’d±r -è -__THROW -; - -461 -__END_NAMESPACE_C99 - - -465 -__BEGIN_NAMESPACE_STD - - -468  - $wc¡Þ - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -469 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -è -__THROW -; - -473  - $wc¡oul - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -474 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -) - -475 -__THROW -; - -476 -__END_NAMESPACE_STD - - -478 #ifdeà -__USE_ISOC99 - - -479 -__BEGIN_NAMESPACE_C99 - - -482 -__ex‹nsiÚ__ - - -483  - $wc¡Þl - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -484 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -) - -485 -__THROW -; - -489 -__ex‹nsiÚ__ - - -490  - $wc¡ouÎ - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -491 -wch¬_t - ** -__»¡riù - -__’d±r -, - -492  -__ba£ -è -__THROW -; - -493 -__END_NAMESPACE_C99 - - -496 #ifdeà -__USE_GNU - - -499 -__ex‹nsiÚ__ - - -500  - $wc¡oq - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -501 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -) - -502 -__THROW -; - -506 -__ex‹nsiÚ__ - - -507  - $wc¡ouq - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -508 -wch¬_t - ** -__»¡riù - -__’d±r -, - -509  -__ba£ -è -__THROW -; - -512 #ifdeà -__USE_GNU - - -526  - ~ - -530  - $wc¡Þ_l - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -531 -wch¬_t - ** -__»¡riù - -__’d±r -,  -__ba£ -, - -532 -__loÿË_t - -__loc -è -__THROW -; - -534  - $wc¡oul_l - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -535 -wch¬_t - ** -__»¡riù - -__’d±r -, - -536  -__ba£ -, -__loÿË_t - -__loc -è -__THROW -; - -538 -__ex‹nsiÚ__ - - -539  - $wc¡Þl_l - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -540 -wch¬_t - ** -__»¡riù - -__’d±r -, - -541  -__ba£ -, -__loÿË_t - -__loc -è -__THROW -; - -543 -__ex‹nsiÚ__ - - -544  - $wc¡ouÎ_l - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -545 -wch¬_t - ** -__»¡riù - -__’d±r -, - -546  -__ba£ -, -__loÿË_t - -__loc -) - -547 -__THROW -; - -549  - $wc¡od_l - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -550 -wch¬_t - ** -__»¡riù - -__’d±r -, -__loÿË_t - -__loc -) - -551 -__THROW -; - -553  - $wc¡of_l - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -554 -wch¬_t - ** -__»¡riù - -__’d±r -, -__loÿË_t - -__loc -) - -555 -__THROW -; - -557  - $wc¡Þd_l - (cÚ¡ -wch¬_t - * -__»¡riù - -__ÅŒ -, - -558 -wch¬_t - ** -__»¡riù - -__’d±r -, - -559 -__loÿË_t - -__loc -è -__THROW -; - -563 #ifdeà -__USE_XOPEN2K8 - - -566 -wch¬_t - * - $wýýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -567 cÚ¡ -wch¬_t - * -__»¡riù - -__¤c -è -__THROW -; - -571 -wch¬_t - * - $wýnýy - ( -wch¬_t - * -__»¡riù - -__de¡ -, - -572 cÚ¡ -wch¬_t - * -__»¡riù - -__¤c -, -size_t - -__n -) - -573 -__THROW -; - -580 -__FILE - * - $Ý’_wmem¡»am - ( -wch¬_t - ** -__buæoc -, -size_t - * -__siz–oc -è -__THROW -; - -583 #ià -defšed - -__USE_ISOC95 - || defšed -__USE_UNIX98 - - -584 -__BEGIN_NAMESPACE_STD - - -587  - $fwide - ( -__FILE - * -__å -,  -__mode -è -__THROW -; - -594  - `fw´štf - ( -__FILE - * -__»¡riù - -__¡»am -, - -595 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -601  - `w´štf - (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -604  - $sw´štf - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -605 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -606 -__THROW - ; - -612  - `vfw´štf - ( -__FILE - * -__»¡riù - -__s -, - -613 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -614 -__gnuc_va_li¡ - -__¬g -) - -620  - `vw´štf - (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -621 -__gnuc_va_li¡ - -__¬g -) - -625  - $vsw´štf - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__n -, - -626 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -627 -__gnuc_va_li¡ - -__¬g -) - -628 -__THROW - ; - -635  - `fwsÿnf - ( -__FILE - * -__»¡riù - -__¡»am -, - -636 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -642  - `wsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -645  - $swsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__s -, - -646 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -647 -__THROW - ; - -649 #ià -defšed - -__USE_ISOC99 - && !defšed -__USE_GNU - \ - -650 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -651 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -652 #ifdeà -__REDIRECT - - -656  - `__REDIRECT - ( -fwsÿnf -, ( -__FILE - * -__»¡riù - -__¡»am -, - -657 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...), - -658 -__isoc99_fwsÿnf -) - -660  - `__REDIRECT - ( -wsÿnf -, (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...), - -661 -__isoc99_wsÿnf -) - -663  - `__REDIRECT_NTH - ( -swsÿnf -, (cÚ¡ -wch¬_t - * -__»¡riù - -__s -, - -664 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -665 ...), -__isoc99_swsÿnf -) - -668  - `__isoc99_fwsÿnf - ( -__FILE - * -__»¡riù - -__¡»am -, - -669 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...); - -670  - `__isoc99_wsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...); - -671  - $__isoc99_swsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__s -, - -672 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, ...) - -673 -__THROW -; - -674  - #fwsÿnf - -__isoc99_fwsÿnf - - - ) - -675  - #wsÿnf - -__isoc99_wsÿnf - - - ) - -676  - #swsÿnf - -__isoc99_swsÿnf - - - ) - -680 -__END_NAMESPACE_STD - - -683 #ifdeà -__USE_ISOC99 - - -684 -__BEGIN_NAMESPACE_C99 - - -689  - `vfwsÿnf - ( -__FILE - * -__»¡riù - -__s -, - -690 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -691 -__gnuc_va_li¡ - -__¬g -) - -697  - `vwsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -698 -__gnuc_va_li¡ - -__¬g -) - -701  - $vswsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__s -, - -702 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -703 -__gnuc_va_li¡ - -__¬g -) - -704 -__THROW - ; - -706 #ià! -defšed - -__USE_GNU - \ - -707 && (! -defšed - -__LDBL_COMPAT - || !defšed -__REDIRECT -) \ - -708 && ( -defšed - -__STRICT_ANSI__ - || defšed -__USE_XOPEN2K -) - -709 #ifdeà -__REDIRECT - - -710  - `__REDIRECT - ( -vfwsÿnf -, ( -__FILE - * -__»¡riù - -__s -, - -711 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -712 -__gnuc_va_li¡ - -__¬g -), -__isoc99_vfwsÿnf -) - -714  - `__REDIRECT - ( -vwsÿnf -, (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -715 -__gnuc_va_li¡ - -__¬g -), -__isoc99_vwsÿnf -) - -717  - `__REDIRECT_NTH - ( -vswsÿnf -, (cÚ¡ -wch¬_t - * -__»¡riù - -__s -, - -718 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -719 -__gnuc_va_li¡ - -__¬g -), -__isoc99_vswsÿnf -) - -722  - `__isoc99_vfwsÿnf - ( -__FILE - * -__»¡riù - -__s -, - -723 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -724 -__gnuc_va_li¡ - -__¬g -); - -725  - `__isoc99_vwsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -726 -__gnuc_va_li¡ - -__¬g -); - -727  - $__isoc99_vswsÿnf - (cÚ¡ -wch¬_t - * -__»¡riù - -__s -, - -728 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -729 -__gnuc_va_li¡ - -__¬g -è -__THROW -; - -730  - #vfwsÿnf - -__isoc99_vfwsÿnf - - - ) - -731  - #vwsÿnf - -__isoc99_vwsÿnf - - - ) - -732  - #vswsÿnf - -__isoc99_vswsÿnf - - - ) - -736 -__END_NAMESPACE_C99 - - -740 -__BEGIN_NAMESPACE_STD - - -745 -wšt_t - - `fg‘wc - ( -__FILE - * -__¡»am -); - -746 -wšt_t - - `g‘wc - ( -__FILE - * -__¡»am -); - -752 -wšt_t - - `g‘wch¬ - (); - -759 -wšt_t - - `åutwc - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -760 -wšt_t - - `putwc - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -766 -wšt_t - - `putwch¬ - ( -wch¬_t - -__wc -); - -774 -wch¬_t - * - `fg‘ws - (wch¬_ˆ* -__»¡riù - -__ws -,  -__n -, - -775 -__FILE - * -__»¡riù - -__¡»am -); - -781  - `åutws - (cÚ¡ -wch¬_t - * -__»¡riù - -__ws -, - -782 -__FILE - * -__»¡riù - -__¡»am -); - -789 -wšt_t - - `ung‘wc - (wšt_ˆ -__wc -, -__FILE - * -__¡»am -); - -790 -__END_NAMESPACE_STD - - -793 #ifdeà -__USE_GNU - - -801 -wšt_t - - `g‘wc_uÆocked - ( -__FILE - * -__¡»am -); - -802 -wšt_t - - `g‘wch¬_uÆocked - (); - -810 -wšt_t - - `fg‘wc_uÆocked - ( -__FILE - * -__¡»am -); - -818 -wšt_t - - `åutwc_uÆocked - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -827 -wšt_t - - `putwc_uÆocked - ( -wch¬_t - -__wc -, -__FILE - * -__¡»am -); - -828 -wšt_t - - `putwch¬_uÆocked - ( -wch¬_t - -__wc -); - -837 -wch¬_t - * - `fg‘ws_uÆocked - (wch¬_ˆ* -__»¡riù - -__ws -,  -__n -, - -838 -__FILE - * -__»¡riù - -__¡»am -); - -846  - `åutws_uÆocked - (cÚ¡ -wch¬_t - * -__»¡riù - -__ws -, - -847 -__FILE - * -__»¡riù - -__¡»am -); - -851 -__BEGIN_NAMESPACE_C99 - - -855 -size_t - - $wcsáime - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__maxsize -, - -856 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -857 cÚ¡  -tm - * -__»¡riù - -__ -è -__THROW -; - -858 -__END_NAMESPACE_C99 - - -860 #ifdeà -__USE_GNU - - -861  - ~ - -865 -size_t - - $wcsáime_l - ( -wch¬_t - * -__»¡riù - -__s -, -size_t - -__maxsize -, - -866 cÚ¡ -wch¬_t - * -__»¡riù - -__fÜm© -, - -867 cÚ¡  -tm - * -__»¡riù - -__ -, - -868 -__loÿË_t - -__loc -è -__THROW -; - -877 #ià -defšed - -__USE_UNIX98 - && !defšed -__USE_GNU - - -878  - #__Ãed_iswxxx - - - ) - -879  - ~ - -883 #ià -__USE_FORTIFY_LEVEL - > 0 && -defšed - -__fÜtify_funùiÚ - - -884  - ~ - -887 #ifdeà -__LDBL_COMPAT - - -888  - ~ - -891 -__END_DECLS - - -899 #undeà -__Ãed_mb¡©e_t - - -900 #undeà -__Ãed_wšt_t - - - @/usr/include/xlocale.h - -20 #iâdeà -_XLOCALE_H - - -21  - #_XLOCALE_H - 1 - - ) - -27  - s__loÿË_¡ruù - - -30  -__loÿË_d©a - * - m__loÿËs -[13]; - -33 cÚ¡ * - m__ùy³_b -; - -34 cÚ¡ * - m__ùy³_tÞow” -; - -35 cÚ¡ * - m__ùy³_touµ” -; - -38 cÚ¡ * - m__Çmes -[13]; - -39 } * - t__loÿË_t -; - -42  -__loÿË_t - - tloÿË_t -; - - @/usr/include/wctype.h - -23 #iâdeà -_WCTYPE_H - - -25  - ~<ã©u»s.h -> - -26  - ~ - -28 #iâdeà -__Ãed_iswxxx - - -29  - #_WCTYPE_H - 1 - - ) - -32  - #__Ãed_wšt_t - - - ) - -33  - ~ - -37 #iâdeà -WEOF - - -38  - #WEOF - (0xffffffffu) - - ) - -41 #undeà -__Ãed_iswxxx - - -46 #iâdeà -__iswxxx_defšed - - -47  - #__iswxxx_defšed - 1 - - ) - -49 -__BEGIN_NAMESPACE_C99 - - -52  - twùy³_t -; - -53 - g__END_NAMESPACE_C99 - - -55 #iâdeà -_ISwb™ - - -60  - ~<’dŸn.h -> - -61 #ià -__BYTE_ORDER - =ð -__BIG_ENDIAN - - -62  - #_ISwb™ -( -b™ -è(1 << (b™)) - - ) - -64  - #_ISwb™ -( -b™ -) \ - -65 (( -b™ -) < 8 ? () ((1UL << (bit)) << 24) \ - -66 : (( -b™ -) < 16 ? () ((1UL << (bit)) << 8) \ - -67 : (( -b™ -) < 24 ? () ((1UL << (bit)) >> 8) \ - -68 : (è((1UL << ( -b™ -)è>> 24)))) - - ) - -73 - m__ISwuµ” - = 0, - -74 - m__ISwlow” - = 1, - -75 - m__ISw®pha - = 2, - -76 - m__ISwdig™ - = 3, - -77 - m__ISwxdig™ - = 4, - -78 - m__ISw¥aû - = 5, - -79 - m__ISw´št - = 6, - -80 - m__ISwg¿ph - = 7, - -81 - m__ISwbÏnk - = 8, - -82 - m__ISwúŒl - = 9, - -83 - m__ISwpunù - = 10, - -84 - m__ISw®num - = 11, - -86 - m_ISwuµ” - = -_ISwb™ - ( -__ISwuµ” -), - -87 - m_ISwlow” - = -_ISwb™ - ( -__ISwlow” -), - -88 - m_ISw®pha - = -_ISwb™ - ( -__ISw®pha -), - -89 - m_ISwdig™ - = -_ISwb™ - ( -__ISwdig™ -), - -90 - m_ISwxdig™ - = -_ISwb™ - ( -__ISwxdig™ -), - -91 - m_ISw¥aû - = -_ISwb™ - ( -__ISw¥aû -), - -92 - m_ISw´št - = -_ISwb™ - ( -__ISw´št -), - -93 - m_ISwg¿ph - = -_ISwb™ - ( -__ISwg¿ph -), - -94 - m_ISwbÏnk - = -_ISwb™ - ( -__ISwbÏnk -), - -95 - m_ISwúŒl - = -_ISwb™ - ( -__ISwúŒl -), - -96 - m_ISwpunù - = -_ISwb™ - ( -__ISwpunù -), - -97 - m_ISw®num - = -_ISwb™ - ( -__ISw®num -) - -102 -__BEGIN_DECLS - - -104 -__BEGIN_NAMESPACE_C99 - - -111  - $isw®num - ( -wšt_t - -__wc -è -__THROW -; - -117  - $isw®pha - ( -wšt_t - -__wc -è -__THROW -; - -120  - $iswúŒl - ( -wšt_t - -__wc -è -__THROW -; - -124  - $iswdig™ - ( -wšt_t - -__wc -è -__THROW -; - -128  - $iswg¿ph - ( -wšt_t - -__wc -è -__THROW -; - -133  - $iswlow” - ( -wšt_t - -__wc -è -__THROW -; - -136  - $isw´št - ( -wšt_t - -__wc -è -__THROW -; - -141  - $iswpunù - ( -wšt_t - -__wc -è -__THROW -; - -146  - $isw¥aû - ( -wšt_t - -__wc -è -__THROW -; - -151  - $iswuµ” - ( -wšt_t - -__wc -è -__THROW -; - -156  - $iswxdig™ - ( -wšt_t - -__wc -è -__THROW -; - -161 #ifdeà -__USE_ISOC99 - - -162  - $iswbÏnk - ( -wšt_t - -__wc -è -__THROW -; - -171 -wùy³_t - - $wùy³ - (cÚ¡ * -__´Ý”ty -è -__THROW -; - -175  - $iswùy³ - ( -wšt_t - -__wc -, -wùy³_t - -__desc -è -__THROW -; - -176 -__END_NAMESPACE_C99 - - -183 -__BEGIN_NAMESPACE_C99 - - -186 cÚ¡ - t__št32_t - * - twù¿ns_t -; - -187 -__END_NAMESPACE_C99 - - -188 #ifdeà -__USE_GNU - - -189 - $__USING_NAMESPACE_C99 -( -wù¿ns_t -) - -192 -__BEGIN_NAMESPACE_C99 - - -194 -wšt_t - - $towlow” - ( -wšt_t - -__wc -è -__THROW -; - -197 -wšt_t - - $towuµ” - ( -wšt_t - -__wc -è -__THROW -; - -198 -__END_NAMESPACE_C99 - - -200 -__END_DECLS - - -207 #ifdeà -_WCTYPE_H - - -213 -__BEGIN_DECLS - - -215 -__BEGIN_NAMESPACE_C99 - - -218 -wù¿ns_t - - $wù¿ns - (cÚ¡ * -__´Ý”ty -è -__THROW -; - -221 -wšt_t - - $towù¿ns - ( -wšt_t - -__wc -, -wù¿ns_t - -__desc -è -__THROW -; - -222 -__END_NAMESPACE_C99 - - -224 #ifdeà -__USE_XOPEN2K8 - - -226  - ~ - -230  - $isw®num_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -236  - $isw®pha_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -239  - $iswúŒl_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -243  - $iswdig™_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -247  - $iswg¿ph_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -252  - $iswlow”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -255  - $isw´št_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -260  - $iswpunù_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -265  - $isw¥aû_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -270  - $iswuµ”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -275  - $iswxdig™_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -280  - $iswbÏnk_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -284 -wùy³_t - - $wùy³_l - (cÚ¡ * -__´Ý”ty -, -__loÿË_t - -__loÿË -) - -285 -__THROW -; - -289  - $iswùy³_l - ( -wšt_t - -__wc -, -wùy³_t - -__desc -, -__loÿË_t - -__loÿË -) - -290 -__THROW -; - -298 -wšt_t - - $towlow”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -301 -wšt_t - - $towuµ”_l - ( -wšt_t - -__wc -, -__loÿË_t - -__loÿË -è -__THROW -; - -305 -wù¿ns_t - - $wù¿ns_l - (cÚ¡ * -__´Ý”ty -, -__loÿË_t - -__loÿË -) - -306 -__THROW -; - -309 -wšt_t - - $towù¿ns_l - ( -wšt_t - -__wc -, -wù¿ns_t - -__desc -, - -310 -__loÿË_t - -__loÿË -è -__THROW -; - -314 -__END_DECLS - - - @ -1 -. -1 -/usr/include -16 -324 -string16.cc -string16.h -string_piece.cc -string_piece.h -/usr/include/stdio.h -/usr/include/features.h -/usr/include/getopt.h -/usr/include/libio.h -/usr/include/_G_config.h -/usr/include/ctype.h -/usr/include/stdc-predef.h -/usr/include/endian.h -/usr/include/gconv.h -/usr/include/wchar.h -/usr/include/xlocale.h -/usr/include/wctype.h diff --git a/vendor/gurl/base/strings/string16.cc b/vendor/gurl/base/strings/string16.cc deleted file mode 100644 index 9c9c820..0000000 --- a/vendor/gurl/base/strings/string16.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/strings/string16.h" - -#if defined(WCHAR_T_IS_UTF16) - -#error This file should not be used on 2-byte wchar_t systems -// If this winds up being needed on 2-byte wchar_t systems, either the -// definitions below can be used, or the host system's wide character -// functions like wmemcmp can be wrapped. - -#elif defined(WCHAR_T_IS_UTF32) - -#include - -//#include "base/strings/utf_string_conversions.h" - -namespace base { - -int c16memcmp(const char16* s1, const char16* s2, size_t n) { - // We cannot call memcmp because that changes the semantics. - while (n-- > 0) { - if (*s1 != *s2) { - // We cannot use (*s1 - *s2) because char16 is unsigned. - return ((*s1 < *s2) ? -1 : 1); - } - ++s1; - ++s2; - } - return 0; -} - -size_t c16len(const char16* s) { - const char16 *s_orig = s; - while (*s) { - ++s; - } - return s - s_orig; -} - -const char16* c16memchr(const char16* s, char16 c, size_t n) { - while (n-- > 0) { - if (*s == c) { - return s; - } - ++s; - } - return 0; -} - -char16* c16memmove(char16* s1, const char16* s2, size_t n) { - return static_cast(memmove(s1, s2, n * sizeof(char16))); -} - -char16* c16memcpy(char16* s1, const char16* s2, size_t n) { - return static_cast(memcpy(s1, s2, n * sizeof(char16))); -} - -char16* c16memset(char16* s, char16 c, size_t n) { - char16 *s_orig = s; - while (n-- > 0) { - *s = c; - ++s; - } - return s_orig; -} -/* -std::ostream& operator<<(std::ostream& out, const string16& str) { - return out << UTF16ToUTF8(str); -}*/ -/* -void PrintTo(const string16& str, std::ostream* out) { - *out << str; -}*/ - -} // namespace base - -template class std::basic_string; - -#endif // WCHAR_T_IS_UTF32 diff --git a/vendor/gurl/base/strings/string16.h b/vendor/gurl/base/strings/string16.h deleted file mode 100644 index 1a01a96..0000000 --- a/vendor/gurl/base/strings/string16.h +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_STRINGS_STRING16_H_ -#define BASE_STRINGS_STRING16_H_ - -// WHAT: -// A version of std::basic_string that provides 2-byte characters even when -// wchar_t is not implemented as a 2-byte type. You can access this class as -// string16. We also define char16, which string16 is based upon. -// -// WHY: -// On Windows, wchar_t is 2 bytes, and it can conveniently handle UTF-16/UCS-2 -// data. Plenty of existing code operates on strings encoded as UTF-16. -// -// On many other platforms, sizeof(wchar_t) is 4 bytes by default. We can make -// it 2 bytes by using the GCC flag -fshort-wchar. But then std::wstring fails -// at run time, because it calls some functions (like wcslen) that come from -// the system's native C library -- which was built with a 4-byte wchar_t! -// It's wasteful to use 4-byte wchar_t strings to carry UTF-16 data, and it's -// entirely improper on those systems where the encoding of wchar_t is defined -// as UTF-32. -// -// Here, we define string16, which is similar to std::wstring but replaces all -// libc functions with custom, 2-byte-char compatible routines. It is capable -// of carrying UTF-16-encoded data. - -#include -#include - -#include "base/base_export.h" -#include "base/basictypes.h" - -#if defined(WCHAR_T_IS_UTF16) - -namespace base { - -typedef wchar_t char16; -typedef std::wstring string16; -typedef std::char_traits string16_char_traits; - -} // namespace base - -#elif defined(WCHAR_T_IS_UTF32) - -namespace base { - -typedef uint16 char16; - -// char16 versions of the functions required by string16_char_traits; these -// are based on the wide character functions of similar names ("w" or "wcs" -// instead of "c16"). -BASE_EXPORT int c16memcmp(const char16* s1, const char16* s2, size_t n); -BASE_EXPORT size_t c16len(const char16* s); -BASE_EXPORT const char16* c16memchr(const char16* s, char16 c, size_t n); -BASE_EXPORT char16* c16memmove(char16* s1, const char16* s2, size_t n); -BASE_EXPORT char16* c16memcpy(char16* s1, const char16* s2, size_t n); -BASE_EXPORT char16* c16memset(char16* s, char16 c, size_t n); - -struct string16_char_traits { - typedef char16 char_type; - typedef int int_type; - - // int_type needs to be able to hold each possible value of char_type, and in - // addition, the distinct value of eof(). - COMPILE_ASSERT(sizeof(int_type) > sizeof(char_type), unexpected_type_width); - - typedef std::streamoff off_type; - typedef mbstate_t state_type; - typedef std::fpos pos_type; - - static void assign(char_type& c1, const char_type& c2) { - c1 = c2; - } - - static bool eq(const char_type& c1, const char_type& c2) { - return c1 == c2; - } - static bool lt(const char_type& c1, const char_type& c2) { - return c1 < c2; - } - - static int compare(const char_type* s1, const char_type* s2, size_t n) { - return c16memcmp(s1, s2, n); - } - - static size_t length(const char_type* s) { - return c16len(s); - } - - static const char_type* find(const char_type* s, size_t n, - const char_type& a) { - return c16memchr(s, a, n); - } - - static char_type* move(char_type* s1, const char_type* s2, size_t n) { - return c16memmove(s1, s2, n); - } - - static char_type* copy(char_type* s1, const char_type* s2, size_t n) { - return c16memcpy(s1, s2, n); - } - - static char_type* assign(char_type* s, size_t n, char_type a) { - return c16memset(s, a, n); - } - - static int_type not_eof(const int_type& c) { - return eq_int_type(c, eof()) ? 0 : c; - } - - static char_type to_char_type(const int_type& c) { - return char_type(c); - } - - static int_type to_int_type(const char_type& c) { - return int_type(c); - } - - static bool eq_int_type(const int_type& c1, const int_type& c2) { - return c1 == c2; - } - - static int_type eof() { - return static_cast(EOF); - } -}; - -typedef std::basic_string string16; - -BASE_EXPORT extern std::ostream& operator<<(std::ostream& out, - const string16& str); - -// This is required by googletest to print a readable output on test failures. -BASE_EXPORT extern void PrintTo(const string16& str, std::ostream* out); - -} // namespace base - -// The string class will be explicitly instantiated only once, in string16.cc. -// -// std::basic_string<> in GNU libstdc++ contains a static data member, -// _S_empty_rep_storage, to represent empty strings. When an operation such -// as assignment or destruction is performed on a string, causing its existing -// data member to be invalidated, it must not be freed if this static data -// member is being used. Otherwise, it counts as an attempt to free static -// (and not allocated) data, which is a memory error. -// -// Generally, due to C++ template magic, _S_empty_rep_storage will be marked -// as a coalesced symbol, meaning that the linker will combine multiple -// instances into a single one when generating output. -// -// If a string class is used by multiple shared libraries, a problem occurs. -// Each library will get its own copy of _S_empty_rep_storage. When strings -// are passed across a library boundary for alteration or destruction, memory -// errors will result. GNU libstdc++ contains a configuration option, -// --enable-fully-dynamic-string (_GLIBCXX_FULLY_DYNAMIC_STRING), which -// disables the static data member optimization, but it's a good optimization -// and non-STL code is generally at the mercy of the system's STL -// configuration. Fully-dynamic strings are not the default for GNU libstdc++ -// libstdc++ itself or for the libstdc++ installations on the systems we care -// about, such as Mac OS X and relevant flavors of Linux. -// -// See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 . -// -// To avoid problems, string classes need to be explicitly instantiated only -// once, in exactly one library. All other string users see it via an "extern" -// declaration. This is precisely how GNU libstdc++ handles -// std::basic_string (string) and std::basic_string (wstring). -// -// This also works around a Mac OS X linker bug in ld64-85.2.1 (Xcode 3.1.2), -// in which the linker does not fully coalesce symbols when dead code -// stripping is enabled. This bug causes the memory errors described above -// to occur even when a std::basic_string<> does not cross shared library -// boundaries, such as in statically-linked executables. -// -// TODO(mark): File this bug with Apple and update this note with a bug number. - -extern template -class BASE_EXPORT std::basic_string; - -#endif // WCHAR_T_IS_UTF32 - -#endif // BASE_STRINGS_STRING16_H_ diff --git a/vendor/gurl/base/strings/string_piece.cc b/vendor/gurl/base/strings/string_piece.cc deleted file mode 100644 index e07a754..0000000 --- a/vendor/gurl/base/strings/string_piece.cc +++ /dev/null @@ -1,450 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// Copied from strings/stringpiece.cc with modifications - -#include "base/strings/string_piece.h" - -#include -#include - -//#include "base/logging.h" - -namespace base { -namespace { - -// For each character in characters_wanted, sets the index corresponding -// to the ASCII code of that character to 1 in table. This is used by -// the find_.*_of methods below to tell whether or not a character is in -// the lookup table in constant time. -// The argument `table' must be an array that is large enough to hold all -// the possible values of an unsigned char. Thus it should be be declared -// as follows: -// bool table[UCHAR_MAX + 1] -inline void BuildLookupTable(const StringPiece& characters_wanted, - bool* table) { - const size_t length = characters_wanted.length(); - const char* const data = characters_wanted.data(); - for (size_t i = 0; i < length; ++i) { - table[static_cast(data[i])] = true; - } -} - -} // namespace - -// MSVC doesn't like complex extern templates and DLLs. -#if !defined(COMPILER_MSVC) -template class BasicStringPiece; -template class BasicStringPiece; -#endif - -bool operator==(const StringPiece& x, const StringPiece& y) { - if (x.size() != y.size()) - return false; - - return StringPiece::wordmemcmp(x.data(), y.data(), x.size()) == 0; -} - -std::ostream& operator<<(std::ostream& o, const StringPiece& piece) { - o.write(piece.data(), static_cast(piece.size())); - return o; -} - -namespace internal { - -template -void CopyToStringT(const BasicStringPiece& self, STR* target) { - if (self.empty()) - target->clear(); - else - target->assign(self.data(), self.size()); -} - -void CopyToString(const StringPiece& self, std::string* target) { - CopyToStringT(self, target); -} - -void CopyToString(const StringPiece16& self, string16* target) { - CopyToStringT(self, target); -} - -template -void AppendToStringT(const BasicStringPiece& self, STR* target) { - if (!self.empty()) - target->append(self.data(), self.size()); -} - -void AppendToString(const StringPiece& self, std::string* target) { - AppendToStringT(self, target); -} - -void AppendToString(const StringPiece16& self, string16* target) { - AppendToStringT(self, target); -} - -template -size_t copyT(const BasicStringPiece& self, - typename STR::value_type* buf, - size_t n, - size_t pos) { - size_t ret = std::min(self.size() - pos, n); - memcpy(buf, self.data() + pos, ret * sizeof(typename STR::value_type)); - return ret; -} - -size_t copy(const StringPiece& self, char* buf, size_t n, size_t pos) { - return copyT(self, buf, n, pos); -} - -size_t copy(const StringPiece16& self, char16* buf, size_t n, size_t pos) { - return copyT(self, buf, n, pos); -} - -template -size_t findT(const BasicStringPiece& self, - const BasicStringPiece& s, - size_t pos) { - if (pos > self.size()) - return BasicStringPiece::npos; - - typename BasicStringPiece::const_iterator result = - std::search(self.begin() + pos, self.end(), s.begin(), s.end()); - const size_t xpos = - static_cast(result - self.begin()); - return xpos + s.size() <= self.size() ? xpos : BasicStringPiece::npos; -} - -size_t find(const StringPiece& self, const StringPiece& s, size_t pos) { - return findT(self, s, pos); -} - -size_t find(const StringPiece16& self, const StringPiece16& s, size_t pos) { - return findT(self, s, pos); -} - -template -size_t findT(const BasicStringPiece& self, - typename STR::value_type c, - size_t pos) { - if (pos >= self.size()) - return BasicStringPiece::npos; - - typename BasicStringPiece::const_iterator result = - std::find(self.begin() + pos, self.end(), c); - return result != self.end() ? - static_cast(result - self.begin()) : BasicStringPiece::npos; -} - -size_t find(const StringPiece& self, char c, size_t pos) { - return findT(self, c, pos); -} - -size_t find(const StringPiece16& self, char16 c, size_t pos) { - return findT(self, c, pos); -} - -template -size_t rfindT(const BasicStringPiece& self, - const BasicStringPiece& s, - size_t pos) { - if (self.size() < s.size()) - return BasicStringPiece::npos; - - if (s.empty()) - return std::min(self.size(), pos); - - typename BasicStringPiece::const_iterator last = - self.begin() + std::min(self.size() - s.size(), pos) + s.size(); - typename BasicStringPiece::const_iterator result = - std::find_end(self.begin(), last, s.begin(), s.end()); - return result != last ? - static_cast(result - self.begin()) : BasicStringPiece::npos; -} - -size_t rfind(const StringPiece& self, const StringPiece& s, size_t pos) { - return rfindT(self, s, pos); -} - -size_t rfind(const StringPiece16& self, const StringPiece16& s, size_t pos) { - return rfindT(self, s, pos); -} - -template -size_t rfindT(const BasicStringPiece& self, - typename STR::value_type c, - size_t pos) { - if (self.size() == 0) - return BasicStringPiece::npos; - - for (size_t i = std::min(pos, self.size() - 1); ; - --i) { - if (self.data()[i] == c) - return i; - if (i == 0) - break; - } - return BasicStringPiece::npos; -} - -size_t rfind(const StringPiece& self, char c, size_t pos) { - return rfindT(self, c, pos); -} - -size_t rfind(const StringPiece16& self, char16 c, size_t pos) { - return rfindT(self, c, pos); -} - -// 8-bit version using lookup table. -size_t find_first_of(const StringPiece& self, - const StringPiece& s, - size_t pos) { - if (self.size() == 0 || s.size() == 0) - return StringPiece::npos; - - // Avoid the cost of BuildLookupTable() for a single-character search. - if (s.size() == 1) - return find(self, s.data()[0], pos); - - bool lookup[UCHAR_MAX + 1] = { false }; - BuildLookupTable(s, lookup); - for (size_t i = pos; i < self.size(); ++i) { - if (lookup[static_cast(self.data()[i])]) { - return i; - } - } - return StringPiece::npos; -} - -// 16-bit brute force version. -size_t find_first_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos) { - StringPiece16::const_iterator found = - std::find_first_of(self.begin() + pos, self.end(), s.begin(), s.end()); - if (found == self.end()) - return StringPiece16::npos; - return found - self.begin(); -} - -// 8-bit version using lookup table. -size_t find_first_not_of(const StringPiece& self, - const StringPiece& s, - size_t pos) { - if (self.size() == 0) - return StringPiece::npos; - - if (s.size() == 0) - return 0; - - // Avoid the cost of BuildLookupTable() for a single-character search. - if (s.size() == 1) - return find_first_not_of(self, s.data()[0], pos); - - bool lookup[UCHAR_MAX + 1] = { false }; - BuildLookupTable(s, lookup); - for (size_t i = pos; i < self.size(); ++i) { - if (!lookup[static_cast(self.data()[i])]) { - return i; - } - } - return StringPiece::npos; -} - -// 16-bit brute-force version. -BASE_EXPORT size_t find_first_not_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos) { - if (self.size() == 0) - return StringPiece16::npos; - - for (size_t self_i = pos; self_i < self.size(); ++self_i) { - bool found = false; - for (size_t s_i = 0; s_i < s.size(); ++s_i) { - if (self[self_i] == s[s_i]) { - found = true; - break; - } - } - if (!found) - return self_i; - } - return StringPiece16::npos; -} - -template -size_t find_first_not_ofT(const BasicStringPiece& self, - typename STR::value_type c, - size_t pos) { - if (self.size() == 0) - return BasicStringPiece::npos; - - for (; pos < self.size(); ++pos) { - if (self.data()[pos] != c) { - return pos; - } - } - return BasicStringPiece::npos; -} - -size_t find_first_not_of(const StringPiece& self, - char c, - size_t pos) { - return find_first_not_ofT(self, c, pos); -} - -size_t find_first_not_of(const StringPiece16& self, - char16 c, - size_t pos) { - return find_first_not_ofT(self, c, pos); -} - -// 8-bit version using lookup table. -size_t find_last_of(const StringPiece& self, const StringPiece& s, size_t pos) { - if (self.size() == 0 || s.size() == 0) - return StringPiece::npos; - - // Avoid the cost of BuildLookupTable() for a single-character search. - if (s.size() == 1) - return rfind(self, s.data()[0], pos); - - bool lookup[UCHAR_MAX + 1] = { false }; - BuildLookupTable(s, lookup); - for (size_t i = std::min(pos, self.size() - 1); ; --i) { - if (lookup[static_cast(self.data()[i])]) - return i; - if (i == 0) - break; - } - return StringPiece::npos; -} - -// 16-bit brute-force version. -size_t find_last_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos) { - if (self.size() == 0) - return StringPiece16::npos; - - for (size_t self_i = std::min(pos, self.size() - 1); ; - --self_i) { - for (size_t s_i = 0; s_i < s.size(); s_i++) { - if (self.data()[self_i] == s[s_i]) - return self_i; - } - if (self_i == 0) - break; - } - return StringPiece16::npos; -} - -// 8-bit version using lookup table. -size_t find_last_not_of(const StringPiece& self, - const StringPiece& s, - size_t pos) { - if (self.size() == 0) - return StringPiece::npos; - - size_t i = std::min(pos, self.size() - 1); - if (s.size() == 0) - return i; - - // Avoid the cost of BuildLookupTable() for a single-character search. - if (s.size() == 1) - return find_last_not_of(self, s.data()[0], pos); - - bool lookup[UCHAR_MAX + 1] = { false }; - BuildLookupTable(s, lookup); - for (; ; --i) { - if (!lookup[static_cast(self.data()[i])]) - return i; - if (i == 0) - break; - } - return StringPiece::npos; -} - -// 16-bit brute-force version. -size_t find_last_not_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos) { - if (self.size() == 0) - return StringPiece::npos; - - for (size_t self_i = std::min(pos, self.size() - 1); ; --self_i) { - bool found = false; - for (size_t s_i = 0; s_i < s.size(); s_i++) { - if (self.data()[self_i] == s[s_i]) { - found = true; - break; - } - } - if (!found) - return self_i; - if (self_i == 0) - break; - } - return StringPiece16::npos; -} - -template -size_t find_last_not_ofT(const BasicStringPiece& self, - typename STR::value_type c, - size_t pos) { - if (self.size() == 0) - return BasicStringPiece::npos; - - for (size_t i = std::min(pos, self.size() - 1); ; --i) { - if (self.data()[i] != c) - return i; - if (i == 0) - break; - } - return BasicStringPiece::npos; -} - -size_t find_last_not_of(const StringPiece& self, - char c, - size_t pos) { - return find_last_not_ofT(self, c, pos); -} - -size_t find_last_not_of(const StringPiece16& self, - char16 c, - size_t pos) { - return find_last_not_ofT(self, c, pos); -} - -template -BasicStringPiece substrT(const BasicStringPiece& self, - size_t pos, - size_t n) { - if (pos > self.size()) pos = self.size(); - if (n > self.size() - pos) n = self.size() - pos; - return BasicStringPiece(self.data() + pos, n); -} - -StringPiece substr(const StringPiece& self, - size_t pos, - size_t n) { - return substrT(self, pos, n); -} - -StringPiece16 substr(const StringPiece16& self, - size_t pos, - size_t n) { - return substrT(self, pos, n); -} - -/*#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) -void AssertIteratorsInOrder(std::string::const_iterator begin, - std::string::const_iterator end) { - DCHECK(begin <= end) << "StringPiece iterators swapped or invalid."; -} -void AssertIteratorsInOrder(string16::const_iterator begin, - string16::const_iterator end) { - DCHECK(begin <= end) << "StringPiece iterators swapped or invalid."; -} -#endif*/ - -} // namespace internal -} // namespace base diff --git a/vendor/gurl/base/strings/string_piece.h b/vendor/gurl/base/strings/string_piece.h deleted file mode 100644 index 8d252d2..0000000 --- a/vendor/gurl/base/strings/string_piece.h +++ /dev/null @@ -1,469 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// Copied from strings/stringpiece.h with modifications -// -// A string-like object that points to a sized piece of memory. -// -// You can use StringPiece as a function or method parameter. A StringPiece -// parameter can receive a double-quoted string literal argument, a "const -// char*" argument, a string argument, or a StringPiece argument with no data -// copying. Systematic use of StringPiece for arguments reduces data -// copies and strlen() calls. -// -// Prefer passing StringPieces by value: -// void MyFunction(StringPiece arg); -// If circumstances require, you may also pass by const reference: -// void MyFunction(const StringPiece& arg); // not preferred -// Both of these have the same lifetime semantics. Passing by value -// generates slightly smaller code. For more discussion, Googlers can see -// the thread go/stringpiecebyvalue on c-users. - -#ifndef BASE_STRINGS_STRING_PIECE_H_ -#define BASE_STRINGS_STRING_PIECE_H_ - -#include - -#include -#include - -#include "base/base_export.h" -#include "base/basictypes.h" -//#include "base/containers/hash_tables.h" -#include "base/strings/string16.h" - -namespace base { - -template class BasicStringPiece; -typedef BasicStringPiece StringPiece; -typedef BasicStringPiece StringPiece16; - -// internal -------------------------------------------------------------------- - -// Many of the StringPiece functions use different implementations for the -// 8-bit and 16-bit versions, and we don't want lots of template expansions in -// this (very common) header that will slow down compilation. -// -// So here we define overloaded functions called by the StringPiece template. -// For those that share an implementation, the two versions will expand to a -// template internal to the .cc file. -namespace internal { - -BASE_EXPORT void CopyToString(const StringPiece& self, std::string* target); -BASE_EXPORT void CopyToString(const StringPiece16& self, string16* target); - -BASE_EXPORT void AppendToString(const StringPiece& self, std::string* target); -BASE_EXPORT void AppendToString(const StringPiece16& self, string16* target); - -BASE_EXPORT size_t copy(const StringPiece& self, - char* buf, - size_t n, - size_t pos); -BASE_EXPORT size_t copy(const StringPiece16& self, - char16* buf, - size_t n, - size_t pos); - -BASE_EXPORT size_t find(const StringPiece& self, - const StringPiece& s, - size_t pos); -BASE_EXPORT size_t find(const StringPiece16& self, - const StringPiece16& s, - size_t pos); -BASE_EXPORT size_t find(const StringPiece& self, - char c, - size_t pos); -BASE_EXPORT size_t find(const StringPiece16& self, - char16 c, - size_t pos); - -BASE_EXPORT size_t rfind(const StringPiece& self, - const StringPiece& s, - size_t pos); -BASE_EXPORT size_t rfind(const StringPiece16& self, - const StringPiece16& s, - size_t pos); -BASE_EXPORT size_t rfind(const StringPiece& self, - char c, - size_t pos); -BASE_EXPORT size_t rfind(const StringPiece16& self, - char16 c, - size_t pos); - -BASE_EXPORT size_t find_first_of(const StringPiece& self, - const StringPiece& s, - size_t pos); -BASE_EXPORT size_t find_first_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos); - -BASE_EXPORT size_t find_first_not_of(const StringPiece& self, - const StringPiece& s, - size_t pos); -BASE_EXPORT size_t find_first_not_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos); -BASE_EXPORT size_t find_first_not_of(const StringPiece& self, - char c, - size_t pos); -BASE_EXPORT size_t find_first_not_of(const StringPiece16& self, - char16 c, - size_t pos); - -BASE_EXPORT size_t find_last_of(const StringPiece& self, - const StringPiece& s, - size_t pos); -BASE_EXPORT size_t find_last_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos); -BASE_EXPORT size_t find_last_of(const StringPiece& self, - char c, - size_t pos); -BASE_EXPORT size_t find_last_of(const StringPiece16& self, - char16 c, - size_t pos); - -BASE_EXPORT size_t find_last_not_of(const StringPiece& self, - const StringPiece& s, - size_t pos); -BASE_EXPORT size_t find_last_not_of(const StringPiece16& self, - const StringPiece16& s, - size_t pos); -BASE_EXPORT size_t find_last_not_of(const StringPiece16& self, - char16 c, - size_t pos); -BASE_EXPORT size_t find_last_not_of(const StringPiece& self, - char c, - size_t pos); - -BASE_EXPORT StringPiece substr(const StringPiece& self, - size_t pos, - size_t n); -BASE_EXPORT StringPiece16 substr(const StringPiece16& self, - size_t pos, - size_t n); - -/*#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) -// Asserts that begin <= end to catch some errors with iterator usage. -BASE_EXPORT void AssertIteratorsInOrder(std::string::const_iterator begin, - std::string::const_iterator end); -BASE_EXPORT void AssertIteratorsInOrder(string16::const_iterator begin, - string16::const_iterator end); -#endif*/ - -} // namespace internal - -// BasicStringPiece ------------------------------------------------------------ - -// Defines the types, methods, operators, and data members common to both -// StringPiece and StringPiece16. Do not refer to this class directly, but -// rather to BasicStringPiece, StringPiece, or StringPiece16. -// -// This is templatized by string class type rather than character type, so -// BasicStringPiece or BasicStringPiece. -template class BasicStringPiece { - public: - // Standard STL container boilerplate. - typedef size_t size_type; - typedef typename STRING_TYPE::value_type value_type; - typedef const value_type* pointer; - typedef const value_type& reference; - typedef const value_type& const_reference; - typedef ptrdiff_t difference_type; - typedef const value_type* const_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - static const size_type npos; - - public: - // We provide non-explicit singleton constructors so users can pass - // in a "const char*" or a "string" wherever a "StringPiece" is - // expected (likewise for char16, string16, StringPiece16). - BasicStringPiece() : ptr_(NULL), length_(0) {} - BasicStringPiece(const value_type* str) - : ptr_(str), - length_((str == NULL) ? 0 : STRING_TYPE::traits_type::length(str)) {} - BasicStringPiece(const STRING_TYPE& str) - : ptr_(str.data()), length_(str.size()) {} - BasicStringPiece(const value_type* offset, size_type len) - : ptr_(offset), length_(len) {} - BasicStringPiece(const typename STRING_TYPE::const_iterator& begin, - const typename STRING_TYPE::const_iterator& end) { -/*#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) - // This assertion is done out-of-line to avoid bringing in logging.h and - // instantiating logging macros for every instantiation. - internal::AssertIteratorsInOrder(begin, end); -#endif*/ - length_ = static_cast(std::distance(begin, end)); - - // The length test before assignment is to avoid dereferencing an iterator - // that may point to the end() of a string. - ptr_ = length_ > 0 ? &*begin : nullptr; - } - - // data() may return a pointer to a buffer with embedded NULs, and the - // returned buffer may or may not be null terminated. Therefore it is - // typically a mistake to pass data() to a routine that expects a NUL - // terminated string. - const value_type* data() const { return ptr_; } - size_type size() const { return length_; } - size_type length() const { return length_; } - bool empty() const { return length_ == 0; } - - void clear() { - ptr_ = NULL; - length_ = 0; - } - void set(const value_type* data, size_type len) { - ptr_ = data; - length_ = len; - } - void set(const value_type* str) { - ptr_ = str; - length_ = str ? STRING_TYPE::traits_type::length(str) : 0; - } - - value_type operator[](size_type i) const { return ptr_[i]; } - - void remove_prefix(size_type n) { - ptr_ += n; - length_ -= n; - } - - void remove_suffix(size_type n) { - length_ -= n; - } - - int compare(const BasicStringPiece& x) const { - int r = wordmemcmp( - ptr_, x.ptr_, (length_ < x.length_ ? length_ : x.length_)); - if (r == 0) { - if (length_ < x.length_) r = -1; - else if (length_ > x.length_) r = +1; - } - return r; - } - - STRING_TYPE as_string() const { - // std::string doesn't like to take a NULL pointer even with a 0 size. - return empty() ? STRING_TYPE() : STRING_TYPE(data(), size()); - } - - const_iterator begin() const { return ptr_; } - const_iterator end() const { return ptr_ + length_; } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(ptr_ + length_); - } - const_reverse_iterator rend() const { - return const_reverse_iterator(ptr_); - } - - size_type max_size() const { return length_; } - size_type capacity() const { return length_; } - - static int wordmemcmp(const value_type* p, - const value_type* p2, - size_type N) { - return STRING_TYPE::traits_type::compare(p, p2, N); - } - - // Sets the value of the given string target type to be the current string. - // This saves a temporary over doing |a = b.as_string()| - void CopyToString(STRING_TYPE* target) const { - internal::CopyToString(*this, target); - } - - void AppendToString(STRING_TYPE* target) const { - internal::AppendToString(*this, target); - } - - size_type copy(value_type* buf, size_type n, size_type pos = 0) const { - return internal::copy(*this, buf, n, pos); - } - - // Does "this" start with "x" - bool starts_with(const BasicStringPiece& x) const { - return ((this->length_ >= x.length_) && - (wordmemcmp(this->ptr_, x.ptr_, x.length_) == 0)); - } - - // Does "this" end with "x" - bool ends_with(const BasicStringPiece& x) const { - return ((this->length_ >= x.length_) && - (wordmemcmp(this->ptr_ + (this->length_-x.length_), - x.ptr_, x.length_) == 0)); - } - - // find: Search for a character or substring at a given offset. - size_type find(const BasicStringPiece& s, - size_type pos = 0) const { - return internal::find(*this, s, pos); - } - size_type find(value_type c, size_type pos = 0) const { - return internal::find(*this, c, pos); - } - - // rfind: Reverse find. - size_type rfind(const BasicStringPiece& s, - size_type pos = BasicStringPiece::npos) const { - return internal::rfind(*this, s, pos); - } - size_type rfind(value_type c, size_type pos = BasicStringPiece::npos) const { - return internal::rfind(*this, c, pos); - } - - // find_first_of: Find the first occurence of one of a set of characters. - size_type find_first_of(const BasicStringPiece& s, - size_type pos = 0) const { - return internal::find_first_of(*this, s, pos); - } - size_type find_first_of(value_type c, size_type pos = 0) const { - return find(c, pos); - } - - // find_first_not_of: Find the first occurence not of a set of characters. - size_type find_first_not_of(const BasicStringPiece& s, - size_type pos = 0) const { - return internal::find_first_not_of(*this, s, pos); - } - size_type find_first_not_of(value_type c, size_type pos = 0) const { - return internal::find_first_not_of(*this, c, pos); - } - - // find_last_of: Find the last occurence of one of a set of characters. - size_type find_last_of(const BasicStringPiece& s, - size_type pos = BasicStringPiece::npos) const { - return internal::find_last_of(*this, s, pos); - } - size_type find_last_of(value_type c, - size_type pos = BasicStringPiece::npos) const { - return rfind(c, pos); - } - - // find_last_not_of: Find the last occurence not of a set of characters. - size_type find_last_not_of(const BasicStringPiece& s, - size_type pos = BasicStringPiece::npos) const { - return internal::find_last_not_of(*this, s, pos); - } - size_type find_last_not_of(value_type c, - size_type pos = BasicStringPiece::npos) const { - return internal::find_last_not_of(*this, c, pos); - } - - // substr. - BasicStringPiece substr(size_type pos, - size_type n = BasicStringPiece::npos) const { - return internal::substr(*this, pos, n); - } - - protected: - const value_type* ptr_; - size_type length_; -}; - -template -const typename BasicStringPiece::size_type -BasicStringPiece::npos = - typename BasicStringPiece::size_type(-1); - -// MSVC doesn't like complex extern templates and DLLs. -#if !defined(COMPILER_MSVC) -extern template class BASE_EXPORT BasicStringPiece; -extern template class BASE_EXPORT BasicStringPiece; -#endif - -// StingPiece operators -------------------------------------------------------- - -BASE_EXPORT bool operator==(const StringPiece& x, const StringPiece& y); - -inline bool operator!=(const StringPiece& x, const StringPiece& y) { - return !(x == y); -} - -inline bool operator<(const StringPiece& x, const StringPiece& y) { - const int r = StringPiece::wordmemcmp( - x.data(), y.data(), (x.size() < y.size() ? x.size() : y.size())); - return ((r < 0) || ((r == 0) && (x.size() < y.size()))); -} - -inline bool operator>(const StringPiece& x, const StringPiece& y) { - return y < x; -} - -inline bool operator<=(const StringPiece& x, const StringPiece& y) { - return !(x > y); -} - -inline bool operator>=(const StringPiece& x, const StringPiece& y) { - return !(x < y); -} - -// StringPiece16 operators ----------------------------------------------------- - -inline bool operator==(const StringPiece16& x, const StringPiece16& y) { - if (x.size() != y.size()) - return false; - - return StringPiece16::wordmemcmp(x.data(), y.data(), x.size()) == 0; -} - -inline bool operator!=(const StringPiece16& x, const StringPiece16& y) { - return !(x == y); -} - -inline bool operator<(const StringPiece16& x, const StringPiece16& y) { - const int r = StringPiece16::wordmemcmp( - x.data(), y.data(), (x.size() < y.size() ? x.size() : y.size())); - return ((r < 0) || ((r == 0) && (x.size() < y.size()))); -} - -inline bool operator>(const StringPiece16& x, const StringPiece16& y) { - return y < x; -} - -inline bool operator<=(const StringPiece16& x, const StringPiece16& y) { - return !(x > y); -} - -inline bool operator>=(const StringPiece16& x, const StringPiece16& y) { - return !(x < y); -} - -BASE_EXPORT std::ostream& operator<<(std::ostream& o, - const StringPiece& piece); - -} // namespace base -/* -// Hashing --------------------------------------------------------------------- - -// We provide appropriate hash functions so StringPiece and StringPiece16 can -// be used as keys in hash sets and maps. - -// This hash function is copied from base/containers/hash_tables.h. We don't -// use the ones already defined for string and string16 directly because it -// would require the string constructors to be called, which we don't want. -#define HASH_STRING_PIECE(StringPieceType, string_piece) \ - std::size_t result = 0; \ - for (StringPieceType::const_iterator i = string_piece.begin(); \ - i != string_piece.end(); ++i) \ - result = (result * 131) + *i; \ - return result; \ - -namespace BASE_HASH_NAMESPACE { - -template<> -struct hash { - std::size_t operator()(const base::StringPiece& sp) const { - HASH_STRING_PIECE(base::StringPiece, sp); - } -}; -template<> -struct hash { - std::size_t operator()(const base::StringPiece16& sp16) const { - HASH_STRING_PIECE(base::StringPiece16, sp16); - } -}; - -} // namespace BASE_HASH_NAMESPACE -*/ -#endif // BASE_STRINGS_STRING_PIECE_H_ diff --git a/vendor/gurl/base/strings/string_util.cc b/vendor/gurl/base/strings/string_util.cc deleted file mode 100644 index 784f7c3..0000000 --- a/vendor/gurl/base/strings/string_util.cc +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/strings/string_util.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "base/basictypes.h" -#include "build/build_config.h" - -namespace base { - -namespace { - -template -static inline bool DoLowerCaseEqualsASCII(BasicStringPiece str, - StringPiece lowercase_ascii) { - if (str.size() != lowercase_ascii.size()) - return false; - for (size_t i = 0; i < str.size(); i++) { - if (ToLowerASCII(str[i]) != lowercase_ascii[i]) - return false; - } - return true; -} - -} // nampspace - -// Assuming that a pointer is the size of a "machine word", then -// uintptr_t is an integer type that is also a machine word. -typedef uintptr_t MachineWord; -const uintptr_t kMachineWordAlignmentMask = sizeof(MachineWord) - 1; - -inline bool IsAlignedToMachineWord(const void* pointer) { - return !(reinterpret_cast(pointer) & kMachineWordAlignmentMask); -} - -template inline T* AlignToMachineWord(T* pointer) { - return reinterpret_cast(reinterpret_cast(pointer) & - ~kMachineWordAlignmentMask); -} - -template struct NonASCIIMask; -template<> struct NonASCIIMask<4, char16> { - static inline uint32_t value() { return 0xFF80FF80U; } -}; -template<> struct NonASCIIMask<4, char> { - static inline uint32_t value() { return 0x80808080U; } -}; -template<> struct NonASCIIMask<8, char16> { - static inline uint64_t value() { return 0xFF80FF80FF80FF80ULL; } -}; -template<> struct NonASCIIMask<8, char> { - static inline uint64_t value() { return 0x8080808080808080ULL; } -}; -#if defined(WCHAR_T_IS_UTF32) -template<> struct NonASCIIMask<4, wchar_t> { - static inline uint32_t value() { return 0xFFFFFF80U; } -}; -template<> struct NonASCIIMask<8, wchar_t> { - static inline uint64_t value() { return 0xFFFFFF80FFFFFF80ULL; } -}; -#endif // WCHAR_T_IS_UTF32 - -template -inline bool DoIsStringASCII(const Char* characters, size_t length) { - MachineWord all_char_bits = 0; - const Char* end = characters + length; - - // Prologue: align the input. - while (!IsAlignedToMachineWord(characters) && characters != end) { - all_char_bits |= *characters; - ++characters; - } - - // Compare the values of CPU word size. - const Char* word_end = AlignToMachineWord(end); - const size_t loop_increment = sizeof(MachineWord) / sizeof(Char); - while (characters < word_end) { - all_char_bits |= *(reinterpret_cast(characters)); - characters += loop_increment; - } - - // Process the remaining bytes. - while (characters != end) { - all_char_bits |= *characters; - ++characters; - } - - MachineWord non_ascii_bit_mask = - NonASCIIMask::value(); - return !(all_char_bits & non_ascii_bit_mask); -} - - -bool IsStringASCII(const StringPiece& str) { - return DoIsStringASCII(str.data(), str.length()); -} - -bool IsStringASCII(const StringPiece16& str) { - return DoIsStringASCII(str.data(), str.length()); -} - -bool IsStringASCII(const string16& str) { - return DoIsStringASCII(str.data(), str.length()); -} - -#if defined(WCHAR_T_IS_UTF32) -bool IsStringASCII(const std::wstring& str) { - return DoIsStringASCII(str.data(), str.length()); -} -#endif - -bool LowerCaseEqualsASCII(StringPiece str, StringPiece lowercase_ascii) { - return DoLowerCaseEqualsASCII(str, lowercase_ascii); -} - -bool LowerCaseEqualsASCII(StringPiece16 str, StringPiece lowercase_ascii) { - return DoLowerCaseEqualsASCII(str, lowercase_ascii); -} - -} // namespace base diff --git a/vendor/gurl/base/strings/string_util.h b/vendor/gurl/base/strings/string_util.h deleted file mode 100644 index 2913b85..0000000 --- a/vendor/gurl/base/strings/string_util.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// This file defines utility functions for working with strings. - -#ifndef BASE_STRINGS_STRING_UTIL_H_ -#define BASE_STRINGS_STRING_UTIL_H_ - -#include -#include // va_list - -#include -#include - -#include "base/base_export.h" -#include "base/basictypes.h" -//#include "base/compiler_specific.h" -#include "base/strings/string16.h" -#include "base/strings/string_piece.h" // For implicit conversions. - -namespace base { - -// ASCII-specific tolower. The standard library's tolower is locale sensitive, -// so we don't want to use it here. -inline char ToLowerASCII(char c) { - return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; -} -inline char16 ToLowerASCII(char16 c) { - return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; -} - -// Compare the lower-case form of the given string against the given -// previously-lower-cased ASCII string (typically a constant). -BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece str, - StringPiece lowecase_ascii); -BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece16 str, - StringPiece lowecase_ascii); - -// Returns true if the specified string matches the criteria. How can a wide -// string be 8-bit or UTF8? It contains only characters that are < 256 (in the -// first case) or characters that use only 8-bits and whose 8-bit -// representation looks like a UTF-8 string (the second case). -// -// Note that IsStringUTF8 checks not only if the input is structurally -// valid but also if it doesn't contain any non-character codepoint -// (e.g. U+FFFE). It's done on purpose because all the existing callers want -// to have the maximum 'discriminating' power from other encodings. If -// there's a use case for just checking the structural validity, we have to -// add a new function for that. -// -// IsStringASCII assumes the input is likely all ASCII, and does not leave early -// if it is not the case. -BASE_EXPORT bool IsStringUTF8(const StringPiece& str); -BASE_EXPORT bool IsStringASCII(const StringPiece& str); -BASE_EXPORT bool IsStringASCII(const StringPiece16& str); -// A convenience adaptor for WebStrings, as they don't convert into -// StringPieces directly. -BASE_EXPORT bool IsStringASCII(const string16& str); -#if defined(WCHAR_T_IS_UTF32) -BASE_EXPORT bool IsStringASCII(const std::wstring& str); -#endif - -} // namespace base - -#endif // BASE_STRINGS_STRING_UTIL_H_ diff --git a/vendor/gurl/base/strings/utf_string_conversion_utils.cc b/vendor/gurl/base/strings/utf_string_conversion_utils.cc deleted file mode 100644 index 022c0df..0000000 --- a/vendor/gurl/base/strings/utf_string_conversion_utils.cc +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/strings/utf_string_conversion_utils.h" - -#include "base/third_party/icu/icu_utf.h" - -namespace base { - -// ReadUnicodeCharacter -------------------------------------------------------- - -bool ReadUnicodeCharacter(const char* src, - int32 src_len, - int32* char_index, - uint32* code_point_out) { - // U8_NEXT expects to be able to use -1 to signal an error, so we must - // use a signed type for code_point. But this function returns false - // on error anyway, so code_point_out is unsigned. - int32 code_point; - CBU8_NEXT(src, *char_index, src_len, code_point); - *code_point_out = static_cast(code_point); - - // The ICU macro above moves to the next char, we want to point to the last - // char consumed. - (*char_index)--; - - // Validate the decoded value. - return IsValidCodepoint(code_point); -} - -bool ReadUnicodeCharacter(const char16* src, - int32 src_len, - int32* char_index, - uint32* code_point) { - if (CBU16_IS_SURROGATE(src[*char_index])) { - if (!CBU16_IS_SURROGATE_LEAD(src[*char_index]) || - *char_index + 1 >= src_len || - !CBU16_IS_TRAIL(src[*char_index + 1])) { - // Invalid surrogate pair. - return false; - } - - // Valid surrogate pair. - *code_point = CBU16_GET_SUPPLEMENTARY(src[*char_index], - src[*char_index + 1]); - (*char_index)++; - } else { - // Not a surrogate, just one 16-bit word. - *code_point = src[*char_index]; - } - - return IsValidCodepoint(*code_point); -} - -#if defined(WCHAR_T_IS_UTF32) -bool ReadUnicodeCharacter(const wchar_t* src, - int32 src_len, - int32* char_index, - uint32* code_point) { - // Conversion is easy since the source is 32-bit. - *code_point = src[*char_index]; - - // Validate the value. - return IsValidCodepoint(*code_point); -} -#endif // defined(WCHAR_T_IS_UTF32) - -// WriteUnicodeCharacter ------------------------------------------------------- - -size_t WriteUnicodeCharacter(uint32 code_point, std::string* output) { - if (code_point <= 0x7f) { - // Fast path the common case of one byte. - output->push_back(static_cast(code_point)); - return 1; - } - - - // CBU8_APPEND_UNSAFE can append up to 4 bytes. - size_t char_offset = output->length(); - size_t original_char_offset = char_offset; - output->resize(char_offset + CBU8_MAX_LENGTH); - - CBU8_APPEND_UNSAFE(&(*output)[0], char_offset, code_point); - - // CBU8_APPEND_UNSAFE will advance our pointer past the inserted character, so - // it will represent the new length of the string. - output->resize(char_offset); - return char_offset - original_char_offset; -} - -size_t WriteUnicodeCharacter(uint32 code_point, string16* output) { - if (CBU16_LENGTH(code_point) == 1) { - // Thie code point is in the Basic Multilingual Plane (BMP). - output->push_back(static_cast(code_point)); - return 1; - } - // Non-BMP characters use a double-character encoding. - size_t char_offset = output->length(); - output->resize(char_offset + CBU16_MAX_LENGTH); - CBU16_APPEND_UNSAFE(&(*output)[0], char_offset, code_point); - return CBU16_MAX_LENGTH; -} - -// Generalized Unicode converter ----------------------------------------------- - -template -void PrepareForUTF8Output(const CHAR* src, - size_t src_len, - std::string* output) { - output->clear(); - if (src_len == 0) - return; - if (src[0] < 0x80) { - // Assume that the entire input will be ASCII. - output->reserve(src_len); - } else { - // Assume that the entire input is non-ASCII and will have 3 bytes per char. - output->reserve(src_len * 3); - } -} - -// Instantiate versions we know callers will need. -template void PrepareForUTF8Output(const wchar_t*, size_t, std::string*); -template void PrepareForUTF8Output(const char16*, size_t, std::string*); - -template -void PrepareForUTF16Or32Output(const char* src, - size_t src_len, - STRING* output) { - output->clear(); - if (src_len == 0) - return; - if (static_cast(src[0]) < 0x80) { - // Assume the input is all ASCII, which means 1:1 correspondence. - output->reserve(src_len); - } else { - // Otherwise assume that the UTF-8 sequences will have 2 bytes for each - // character. - output->reserve(src_len / 2); - } -} - -// Instantiate versions we know callers will need. -template void PrepareForUTF16Or32Output(const char*, size_t, std::wstring*); -template void PrepareForUTF16Or32Output(const char*, size_t, string16*); - -} // namespace base diff --git a/vendor/gurl/base/strings/utf_string_conversion_utils.h b/vendor/gurl/base/strings/utf_string_conversion_utils.h deleted file mode 100644 index a1b2e64..0000000 --- a/vendor/gurl/base/strings/utf_string_conversion_utils.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ -#define BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ - -// This should only be used by the various UTF string conversion files. - -#include "base/base_export.h" -#include "base/strings/string16.h" - -namespace base { - -inline bool IsValidCodepoint(uint32 code_point) { - // Excludes the surrogate code points ([0xD800, 0xDFFF]) and - // codepoints larger than 0x10FFFF (the highest codepoint allowed). - // Non-characters and unassigned codepoints are allowed. - return code_point < 0xD800u || - (code_point >= 0xE000u && code_point <= 0x10FFFFu); -} - -inline bool IsValidCharacter(uint32 code_point) { - // Excludes non-characters (U+FDD0..U+FDEF, and all codepoints ending in - // 0xFFFE or 0xFFFF) from the set of valid code points. - return code_point < 0xD800u || (code_point >= 0xE000u && - code_point < 0xFDD0u) || (code_point > 0xFDEFu && - code_point <= 0x10FFFFu && (code_point & 0xFFFEu) != 0xFFFEu); -} - -// ReadUnicodeCharacter -------------------------------------------------------- - -// Reads a UTF-8 stream, placing the next code point into the given output -// |*code_point|. |src| represents the entire string to read, and |*char_index| -// is the character offset within the string to start reading at. |*char_index| -// will be updated to index the last character read, such that incrementing it -// (as in a for loop) will take the reader to the next character. -// -// Returns true on success. On false, |*code_point| will be invalid. -BASE_EXPORT bool ReadUnicodeCharacter(const char* src, - int32 src_len, - int32* char_index, - uint32* code_point_out); - -// Reads a UTF-16 character. The usage is the same as the 8-bit version above. -BASE_EXPORT bool ReadUnicodeCharacter(const char16* src, - int32 src_len, - int32* char_index, - uint32* code_point); - -#if defined(WCHAR_T_IS_UTF32) -// Reads UTF-32 character. The usage is the same as the 8-bit version above. -BASE_EXPORT bool ReadUnicodeCharacter(const wchar_t* src, - int32 src_len, - int32* char_index, - uint32* code_point); -#endif // defined(WCHAR_T_IS_UTF32) - -// WriteUnicodeCharacter ------------------------------------------------------- - -// Appends a UTF-8 character to the given 8-bit string. Returns the number of -// bytes written. -BASE_EXPORT size_t WriteUnicodeCharacter(uint32 code_point, - std::string* output); - -// Appends the given code point as a UTF-16 character to the given 16-bit -// string. Returns the number of 16-bit values written. -BASE_EXPORT size_t WriteUnicodeCharacter(uint32 code_point, string16* output); - -#if defined(WCHAR_T_IS_UTF32) -// Appends the given UTF-32 character to the given 32-bit string. Returns the -// number of 32-bit values written. -inline size_t WriteUnicodeCharacter(uint32 code_point, std::wstring* output) { - // This is the easy case, just append the character. - output->push_back(code_point); - return 1; -} -#endif // defined(WCHAR_T_IS_UTF32) - -// Generalized Unicode converter ----------------------------------------------- - -// Guesses the length of the output in UTF-8 in bytes, clears that output -// string, and reserves that amount of space. We assume that the input -// character types are unsigned, which will be true for UTF-16 and -32 on our -// systems. -template -void PrepareForUTF8Output(const CHAR* src, size_t src_len, std::string* output); - -// Prepares an output buffer (containing either UTF-16 or -32 data) given some -// UTF-8 input that will be converted to it. See PrepareForUTF8Output(). -template -void PrepareForUTF16Or32Output(const char* src, size_t src_len, STRING* output); - -} // namespace base - -#endif // BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ diff --git a/vendor/gurl/base/strings/utf_string_conversions.cc b/vendor/gurl/base/strings/utf_string_conversions.cc deleted file mode 100644 index 1d2ca01..0000000 --- a/vendor/gurl/base/strings/utf_string_conversions.cc +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/strings/utf_string_conversions.h" - -#include "base/strings/string_piece.h" -#include "base/strings/string_util.h" -#include "base/strings/utf_string_conversion_utils.h" - -namespace base { - -namespace { - -// Generalized Unicode converter ----------------------------------------------- - -// Converts the given source Unicode character type to the given destination -// Unicode character type as a STL string. The given input buffer and size -// determine the source, and the given output STL string will be replaced by -// the result. -template -bool ConvertUnicode(const SRC_CHAR* src, - size_t src_len, - DEST_STRING* output) { - // ICU requires 32-bit numbers. - bool success = true; - int32 src_len32 = static_cast(src_len); - for (int32 i = 0; i < src_len32; i++) { - uint32 code_point; - if (ReadUnicodeCharacter(src, src_len32, &i, &code_point)) { - WriteUnicodeCharacter(code_point, output); - } else { - WriteUnicodeCharacter(0xFFFD, output); - success = false; - } - } - - return success; -} - -} // namespace - -// UTF-8 <-> Wide -------------------------------------------------------------- - -bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output) { - if (IsStringASCII(std::wstring(src, src_len))) { - output->assign(src, src + src_len); - return true; - } else { - PrepareForUTF8Output(src, src_len, output); - return ConvertUnicode(src, src_len, output); - } -} - -std::string WideToUTF8(const std::wstring& wide) { - if (IsStringASCII(wide)) { - return std::string(wide.data(), wide.data() + wide.length()); - } - - std::string ret; - PrepareForUTF8Output(wide.data(), wide.length(), &ret); - ConvertUnicode(wide.data(), wide.length(), &ret); - return ret; -} - -bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output) { - if (IsStringASCII(StringPiece(src, src_len))) { - output->assign(src, src + src_len); - return true; - } else { - PrepareForUTF16Or32Output(src, src_len, output); - return ConvertUnicode(src, src_len, output); - } -} - -std::wstring UTF8ToWide(StringPiece utf8) { - if (IsStringASCII(utf8)) { - return std::wstring(utf8.begin(), utf8.end()); - } - - std::wstring ret; - PrepareForUTF16Or32Output(utf8.data(), utf8.length(), &ret); - ConvertUnicode(utf8.data(), utf8.length(), &ret); - return ret; -} - -// UTF-16 <-> Wide ------------------------------------------------------------- - -#if defined(WCHAR_T_IS_UTF16) - -// When wide == UTF-16, then conversions are a NOP. -bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output) { - output->assign(src, src_len); - return true; -} - -string16 WideToUTF16(const std::wstring& wide) { - return wide; -} - -bool UTF16ToWide(const char16* src, size_t src_len, std::wstring* output) { - output->assign(src, src_len); - return true; -} - -std::wstring UTF16ToWide(const string16& utf16) { - return utf16; -} - -#elif defined(WCHAR_T_IS_UTF32) - -bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output) { - output->clear(); - // Assume that normally we won't have any non-BMP characters so the counts - // will be the same. - output->reserve(src_len); - return ConvertUnicode(src, src_len, output); -} - -string16 WideToUTF16(const std::wstring& wide) { - string16 ret; - WideToUTF16(wide.data(), wide.length(), &ret); - return ret; -} - -bool UTF16ToWide(const char16* src, size_t src_len, std::wstring* output) { - output->clear(); - // Assume that normally we won't have any non-BMP characters so the counts - // will be the same. - output->reserve(src_len); - return ConvertUnicode(src, src_len, output); -} - -std::wstring UTF16ToWide(const string16& utf16) { - std::wstring ret; - UTF16ToWide(utf16.data(), utf16.length(), &ret); - return ret; -} - -#endif // defined(WCHAR_T_IS_UTF32) - -// UTF16 <-> UTF8 -------------------------------------------------------------- - -#if defined(WCHAR_T_IS_UTF32) - -bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) { - if (IsStringASCII(StringPiece(src, src_len))) { - output->assign(src, src + src_len); - return true; - } else { - PrepareForUTF16Or32Output(src, src_len, output); - return ConvertUnicode(src, src_len, output); - } -} - -string16 UTF8ToUTF16(StringPiece utf8) { - if (IsStringASCII(utf8)) { - return string16(utf8.begin(), utf8.end()); - } - - string16 ret; - PrepareForUTF16Or32Output(utf8.data(), utf8.length(), &ret); - // Ignore the success flag of this call, it will do the best it can for - // invalid input, which is what we want here. - ConvertUnicode(utf8.data(), utf8.length(), &ret); - return ret; -} - -bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output) { - if (IsStringASCII(StringPiece16(src, src_len))) { - output->assign(src, src + src_len); - return true; - } else { - PrepareForUTF8Output(src, src_len, output); - return ConvertUnicode(src, src_len, output); - } -} - -std::string UTF16ToUTF8(StringPiece16 utf16) { - if (IsStringASCII(utf16)) { - return std::string(utf16.begin(), utf16.end()); - } - - std::string ret; - // Ignore the success flag of this call, it will do the best it can for - // invalid input, which is what we want here. - UTF16ToUTF8(utf16.data(), utf16.length(), &ret); - return ret; -} - -#elif defined(WCHAR_T_IS_UTF16) -// Easy case since we can use the "wide" versions we already wrote above. - -bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) { - return UTF8ToWide(src, src_len, output); -} - -string16 UTF8ToUTF16(StringPiece utf8) { - return UTF8ToWide(utf8); -} - -bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output) { - return WideToUTF8(src, src_len, output); -} - -std::string UTF16ToUTF8(StringPiece16 utf16) { - if (IsStringASCII(utf16)) - return std::string(utf16.data(), utf16.data() + utf16.length()); - - std::string ret; - PrepareForUTF8Output(utf16.data(), utf16.length(), &ret); - ConvertUnicode(utf16.data(), utf16.length(), &ret); - return ret; -} - -#endif - -string16 ASCIIToUTF16(StringPiece ascii) { - //DCHECK(IsStringASCII(ascii)) << ascii; - return string16(ascii.begin(), ascii.end()); -} - -std::string UTF16ToASCII(StringPiece16 utf16) { - //DCHECK(IsStringASCII(utf16)) << UTF16ToUTF8(utf16); - return std::string(utf16.begin(), utf16.end()); -} - -} // namespace base diff --git a/vendor/gurl/base/strings/utf_string_conversions.h b/vendor/gurl/base/strings/utf_string_conversions.h deleted file mode 100644 index 9b15730..0000000 --- a/vendor/gurl/base/strings/utf_string_conversions.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_STRINGS_UTF_STRING_CONVERSIONS_H_ -#define BASE_STRINGS_UTF_STRING_CONVERSIONS_H_ - -#include - -#include "base/base_export.h" -#include "base/strings/string16.h" -#include "base/strings/string_piece.h" - -namespace base { - -// These convert between UTF-8, -16, and -32 strings. They are potentially slow, -// so avoid unnecessary conversions. The low-level versions return a boolean -// indicating whether the conversion was 100% valid. In this case, it will still -// do the best it can and put the result in the output buffer. The versions that -// return strings ignore this error and just return the best conversion -// possible. -BASE_EXPORT bool WideToUTF8(const wchar_t* src, size_t src_len, - std::string* output); -BASE_EXPORT std::string WideToUTF8(const std::wstring& wide); -BASE_EXPORT bool UTF8ToWide(const char* src, size_t src_len, - std::wstring* output); -BASE_EXPORT std::wstring UTF8ToWide(StringPiece utf8); - -BASE_EXPORT bool WideToUTF16(const wchar_t* src, size_t src_len, - string16* output); -BASE_EXPORT string16 WideToUTF16(const std::wstring& wide); -BASE_EXPORT bool UTF16ToWide(const char16* src, size_t src_len, - std::wstring* output); -BASE_EXPORT std::wstring UTF16ToWide(const string16& utf16); - -BASE_EXPORT bool UTF8ToUTF16(const char* src, size_t src_len, string16* output); -BASE_EXPORT string16 UTF8ToUTF16(StringPiece utf8); -BASE_EXPORT bool UTF16ToUTF8(const char16* src, size_t src_len, - std::string* output); -BASE_EXPORT std::string UTF16ToUTF8(StringPiece16 utf16); - -// This converts an ASCII string, typically a hardcoded constant, to a UTF16 -// string. -BASE_EXPORT string16 ASCIIToUTF16(StringPiece ascii); - -// Converts to 7-bit ASCII by truncating. The result must be known to be ASCII -// beforehand. -BASE_EXPORT std::string UTF16ToASCII(StringPiece16 utf16); - -} // namespace base - -#endif // BASE_STRINGS_UTF_STRING_CONVERSIONS_H_ diff --git a/vendor/gurl/base/template_util.h b/vendor/gurl/base/template_util.h deleted file mode 100644 index 83fa322..0000000 --- a/vendor/gurl/base/template_util.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_TEMPLATE_UTIL_H_ -#define BASE_TEMPLATE_UTIL_H_ - -#include // For size_t. - -#include "build/build_config.h" - -namespace base { - -// template definitions from tr1 - -template -struct integral_constant { - static const T value = v; - typedef T value_type; - typedef integral_constant type; -}; - -template const T integral_constant::value; - -typedef integral_constant true_type; -typedef integral_constant false_type; - -template struct is_pointer : false_type {}; -template struct is_pointer : true_type {}; - -// Member function pointer detection. This is built-in to C++ 11's stdlib, and -// we can remove this when we switch to it. -template -struct is_member_function_pointer : false_type {}; - -template -struct is_member_function_pointer : true_type {}; -template -struct is_member_function_pointer : true_type {}; - - -template struct is_same : public false_type {}; -template struct is_same : true_type {}; - -template struct is_array : public false_type {}; -template struct is_array : public true_type {}; -template struct is_array : public true_type {}; - -template struct is_non_const_reference : false_type {}; -template struct is_non_const_reference : true_type {}; -template struct is_non_const_reference : false_type {}; - -template struct is_const : false_type {}; -template struct is_const : true_type {}; - -template struct is_void : false_type {}; -template <> struct is_void : true_type {}; - -namespace internal { - -// Types YesType and NoType are guaranteed such that sizeof(YesType) < -// sizeof(NoType). -typedef char YesType; - -struct NoType { - YesType dummy[2]; -}; - -// This class is an implementation detail for is_convertible, and you -// don't need to know how it works to use is_convertible. For those -// who care: we declare two different functions, one whose argument is -// of type To and one with a variadic argument list. We give them -// return types of different size, so we can use sizeof to trick the -// compiler into telling us which function it would have chosen if we -// had called it with an argument of type From. See Alexandrescu's -// _Modern C++ Design_ for more details on this sort of trick. - -struct ConvertHelper { - template - static YesType Test(To); - - template - static NoType Test(...); - - template - static From& Create(); -}; - -// Used to determine if a type is a struct/union/class. Inspired by Boost's -// is_class type_trait implementation. -struct IsClassHelper { - template - static YesType Test(void(C::*)(void)); - - template - static NoType Test(...); -}; - -} // namespace internal - -// Inherits from true_type if From is convertible to To, false_type otherwise. -// -// Note that if the type is convertible, this will be a true_type REGARDLESS -// of whether or not the conversion would emit a warning. -template -struct is_convertible - : integral_constant( - internal::ConvertHelper::Create())) == - sizeof(internal::YesType)> { -}; - -template -struct is_class - : integral_constant(0)) == - sizeof(internal::YesType)> { -}; - -template -struct enable_if {}; - -template -struct enable_if { typedef T type; }; - -} // namespace base - -#endif // BASE_TEMPLATE_UTIL_H_ diff --git a/vendor/gurl/base/third_party/icu/LICENSE b/vendor/gurl/base/third_party/icu/LICENSE deleted file mode 100644 index 40282f4..0000000 --- a/vendor/gurl/base/third_party/icu/LICENSE +++ /dev/null @@ -1,32 +0,0 @@ -ICU License - ICU 1.8.1 and later - -COPYRIGHT AND PERMISSION NOTICE - -Copyright (c) 1995-2009 International Business Machines Corporation and others - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY -SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER -RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF -CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. diff --git a/vendor/gurl/base/third_party/icu/README.chromium b/vendor/gurl/base/third_party/icu/README.chromium deleted file mode 100644 index 6a9a15a..0000000 --- a/vendor/gurl/base/third_party/icu/README.chromium +++ /dev/null @@ -1,16 +0,0 @@ -Name: ICU -URL: http://site.icu-project.org/ -License: MIT -License File: NOT_SHIPPED - -This file has the relevant components from ICU copied to handle basic -UTF8/16/32 conversions. Components are copied from utf.h utf8.h utf16.h and -utf_impl.c - -The same module appears in third_party/icu, so we don't repeat the license -file here. - -The main change is that U_/U8_/U16_ prefixes have been replaced with -CBU_/CBU8_/CBU16_ (for "Chrome Base") to avoid confusion with the "real" ICU -macros should ICU be in use on the system. For the same reason, the functions -and types have been put in the "base_icu" namespace. diff --git a/vendor/gurl/base/third_party/icu/icu_utf.cc b/vendor/gurl/base/third_party/icu/icu_utf.cc deleted file mode 100644 index b47c8ac..0000000 --- a/vendor/gurl/base/third_party/icu/icu_utf.cc +++ /dev/null @@ -1,228 +0,0 @@ -/* -****************************************************************************** -* -* Copyright (C) 1999-2006, International Business Machines -* Corporation and others. All Rights Reserved. -* -****************************************************************************** -* file name: utf_impl.c -* encoding: US-ASCII -* tab size: 8 (not used) -* indentation:4 -* -* created on: 1999sep13 -* created by: Markus W. Scherer -* -* This file provides implementation functions for macros in the utfXX.h -* that would otherwise be too long as macros. -*/ - -#include "base/third_party/icu/icu_utf.h" - -namespace base_icu { - -/** - * UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8, - * which need 1 or 2 bytes in UTF-8: - * \code - * U+0015 = NAK = Negative Acknowledge, C0 control character - * U+009f = highest C1 control character - * \endcode - * - * These are used by UTF8_..._SAFE macros so that they can return an error value - * that needs the same number of code units (bytes) as were seen by - * a macro. They should be tested with UTF_IS_ERROR() or UTF_IS_VALID(). - * - * @deprecated ICU 2.4. Obsolete, see utf_old.h. - */ -#define CBUTF8_ERROR_VALUE_1 0x15 - -/** - * See documentation on UTF8_ERROR_VALUE_1 for details. - * - * @deprecated ICU 2.4. Obsolete, see utf_old.h. - */ -#define CBUTF8_ERROR_VALUE_2 0x9f - - -/** - * Error value for all UTFs. This code point value will be set by macros with e> - * checking if an error is detected. - * - * @deprecated ICU 2.4. Obsolete, see utf_old.h. - */ -#define CBUTF_ERROR_VALUE 0xffff - -/* - * This table could be replaced on many machines by - * a few lines of assembler code using an - * "index of first 0-bit from msb" instruction and - * one or two more integer instructions. - * - * For example, on an i386, do something like - * - MOV AL, leadByte - * - NOT AL (8-bit, leave b15..b8==0..0, reverse only b7..b0) - * - MOV AH, 0 - * - BSR BX, AX (16-bit) - * - MOV AX, 6 (result) - * - JZ finish (ZF==1 if leadByte==0xff) - * - SUB AX, BX (result) - * -finish: - * (BSR: Bit Scan Reverse, scans for a 1-bit, starting from the MSB) - * - * In Unicode, all UTF-8 byte sequences with more than 4 bytes are illegal; - * lead bytes above 0xf4 are illegal. - * We keep them in this table for skipping long ISO 10646-UTF-8 sequences. - */ -const uint8 -utf8_countTrailBytes[256]={ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, - 3, 3, 3, /* illegal in Unicode */ - 4, 4, 4, 4, /* illegal in Unicode */ - 5, 5, /* illegal in Unicode */ - 0, 0 /* illegal bytes 0xfe and 0xff */ -}; - -static const UChar32 -utf8_minLegal[4]={ 0, 0x80, 0x800, 0x10000 }; - -static const UChar32 -utf8_errorValue[6]={ - CBUTF8_ERROR_VALUE_1, CBUTF8_ERROR_VALUE_2, CBUTF_ERROR_VALUE, 0x10ffff, - 0x3ffffff, 0x7fffffff -}; - -/* - * Handle the non-inline part of the U8_NEXT() macro and its obsolete sibling - * UTF8_NEXT_CHAR_SAFE(). - * - * The "strict" parameter controls the error behavior: - * <0 "Safe" behavior of U8_NEXT(): All illegal byte sequences yield a negative - * code point result. - * 0 Obsolete "safe" behavior of UTF8_NEXT_CHAR_SAFE(..., FALSE): - * All illegal byte sequences yield a positive code point such that this - * result code point would be encoded with the same number of bytes as - * the illegal sequence. - * >0 Obsolete "strict" behavior of UTF8_NEXT_CHAR_SAFE(..., TRUE): - * Same as the obsolete "safe" behavior, but non-characters are also treated - * like illegal sequences. - * - * The special negative (<0) value -2 is used for lenient treatment of surrogate - * code points as legal. Some implementations use this for roundtripping of - * Unicode 16-bit strings that are not well-formed UTF-16, that is, they - * contain unpaired surrogates. - * - * Note that a UBool is the same as an int8_t. - */ -UChar32 -utf8_nextCharSafeBody(const uint8 *s, int32 *pi, int32 length, UChar32 c, UBool strict) { - int32 i=*pi; - uint8 count=CBU8_COUNT_TRAIL_BYTES(c); - if((i)+count<=(length)) { - uint8 trail, illegal=0; - - CBU8_MASK_LEAD_BYTE((c), count); - /* count==0 for illegally leading trail bytes and the illegal bytes 0xfe and 0xff */ - switch(count) { - /* each branch falls through to the next one */ - case 5: - case 4: - /* count>=4 is always illegal: no more than 3 trail bytes in Unicode's UTF-8 */ - illegal=1; - break; - case 3: - trail=s[(i)++]; - (c)=((c)<<6)|(trail&0x3f); - if(c<0x110) { - illegal|=(trail&0xc0)^0x80; - } else { - /* code point>0x10ffff, outside Unicode */ - illegal=1; - break; - } - case 2: - trail=s[(i)++]; - (c)=((c)<<6)|(trail&0x3f); - illegal|=(trail&0xc0)^0x80; - case 1: - trail=s[(i)++]; - (c)=((c)<<6)|(trail&0x3f); - illegal|=(trail&0xc0)^0x80; - break; - case 0: - if(strict>=0) { - return CBUTF8_ERROR_VALUE_1; - } else { - return CBU_SENTINEL; - } - /* no default branch to optimize switch() - all values are covered */ - } - - /* - * All the error handling should return a value - * that needs count bytes so that UTF8_GET_CHAR_SAFE() works right. - * - * Starting with Unicode 3.0.1, non-shortest forms are illegal. - * Starting with Unicode 3.2, surrogate code points must not be - * encoded in UTF-8, and there are no irregular sequences any more. - * - * U8_ macros (new in ICU 2.4) return negative values for error conditions. - */ - - /* correct sequence - all trail bytes have (b7..b6)==(10)? */ - /* illegal is also set if count>=4 */ - if(illegal || (c)0 && CBU8_IS_TRAIL(s[i])) { - ++(i); - --count; - } - if(strict>=0) { - c=utf8_errorValue[errorCount-count]; - } else { - c=CBU_SENTINEL; - } - } else if((strict)>0 && CBU_IS_UNICODE_NONCHAR(c)) { - /* strict: forbid non-characters like U+fffe */ - c=utf8_errorValue[count]; - } - } else /* too few bytes left */ { - /* error handling */ - int32 i0=i; - /* don't just set (i)=(length) in case there is an illegal sequence */ - while((i)<(length) && CBU8_IS_TRAIL(s[i])) { - ++(i); - } - if(strict>=0) { - c=utf8_errorValue[i-i0]; - } else { - c=CBU_SENTINEL; - } - } - *pi=i; - return c; -} - -} // namespace base_icu diff --git a/vendor/gurl/base/third_party/icu/icu_utf.h b/vendor/gurl/base/third_party/icu/icu_utf.h deleted file mode 100644 index 2b993b0..0000000 --- a/vendor/gurl/base/third_party/icu/icu_utf.h +++ /dev/null @@ -1,391 +0,0 @@ -/* -******************************************************************************* -* -* Copyright (C) 1999-2004, International Business Machines -* Corporation and others. All Rights Reserved. -* -******************************************************************************* -* file name: utf.h -* encoding: US-ASCII -* tab size: 8 (not used) -* indentation:4 -* -* created on: 1999sep09 -* created by: Markus W. Scherer -*/ - -#ifndef BASE_THIRD_PARTY_ICU_ICU_UTF_H_ -#define BASE_THIRD_PARTY_ICU_ICU_UTF_H_ - -#include "base/basictypes.h" - -namespace base_icu { - -typedef int32 UChar32; -typedef uint16 UChar; -typedef int8 UBool; - -// General --------------------------------------------------------------------- -// from utf.h - -/** - * This value is intended for sentinel values for APIs that - * (take or) return single code points (UChar32). - * It is outside of the Unicode code point range 0..0x10ffff. - * - * For example, a "done" or "error" value in a new API - * could be indicated with CBU_SENTINEL. - * - * ICU APIs designed before ICU 2.4 usually define service-specific "done" - * values, mostly 0xffff. - * Those may need to be distinguished from - * actual U+ffff text contents by calling functions like - * CharacterIterator::hasNext() or UnicodeString::length(). - * - * @return -1 - * @see UChar32 - * @stable ICU 2.4 - */ -#define CBU_SENTINEL (-1) - -/** - * Is this code point a Unicode noncharacter? - * @param c 32-bit code point - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU_IS_UNICODE_NONCHAR(c) \ - ((c)>=0xfdd0 && \ - ((uint32)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \ - (uint32)(c)<=0x10ffff) - -/** - * Is c a Unicode code point value (0..U+10ffff) - * that can be assigned a character? - * - * Code points that are not characters include: - * - single surrogate code points (U+d800..U+dfff, 2048 code points) - * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points) - * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points) - * - the highest Unicode code point value is U+10ffff - * - * This means that all code points below U+d800 are character code points, - * and that boundary is tested first for performance. - * - * @param c 32-bit code point - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU_IS_UNICODE_CHAR(c) \ - ((uint32)(c)<0xd800 || \ - ((uint32)(c)>0xdfff && \ - (uint32)(c)<=0x10ffff && \ - !CBU_IS_UNICODE_NONCHAR(c))) - -/** - * Is this code point a surrogate (U+d800..U+dfff)? - * @param c 32-bit code point - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800) - -/** - * Assuming c is a surrogate code point (U_IS_SURROGATE(c)), - * is it a lead surrogate? - * @param c 32-bit code point - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU_IS_SURROGATE_LEAD(c) (((c)&0x400)==0) - - -// UTF-8 macros ---------------------------------------------------------------- -// from utf8.h - -extern const uint8 utf8_countTrailBytes[256]; - -/** - * Count the trail bytes for a UTF-8 lead byte. - * @internal - */ -#define CBU8_COUNT_TRAIL_BYTES(leadByte) (base_icu::utf8_countTrailBytes[(uint8)leadByte]) - -/** - * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value. - * @internal - */ -#define CBU8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1) - -/** - * Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)? - * @param c 8-bit code unit (byte) - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU8_IS_SINGLE(c) (((c)&0x80)==0) - -/** - * Is this code unit (byte) a UTF-8 lead byte? - * @param c 8-bit code unit (byte) - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU8_IS_LEAD(c) ((uint8)((c)-0xc0)<0x3e) - -/** - * Is this code unit (byte) a UTF-8 trail byte? - * @param c 8-bit code unit (byte) - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU8_IS_TRAIL(c) (((c)&0xc0)==0x80) - -/** - * How many code units (bytes) are used for the UTF-8 encoding - * of this Unicode code point? - * @param c 32-bit code point - * @return 1..4, or 0 if c is a surrogate or not a Unicode code point - * @stable ICU 2.4 - */ -#define CBU8_LENGTH(c) \ - ((uint32)(c)<=0x7f ? 1 : \ - ((uint32)(c)<=0x7ff ? 2 : \ - ((uint32)(c)<=0xd7ff ? 3 : \ - ((uint32)(c)<=0xdfff || (uint32)(c)>0x10ffff ? 0 : \ - ((uint32)(c)<=0xffff ? 3 : 4)\ - ) \ - ) \ - ) \ - ) - -/** - * The maximum number of UTF-8 code units (bytes) per Unicode code point (U+0000..U+10ffff). - * @return 4 - * @stable ICU 2.4 - */ -#define CBU8_MAX_LENGTH 4 - -/** - * Function for handling "next code point" with error-checking. - * @internal - */ -UChar32 utf8_nextCharSafeBody(const uint8 *s, int32 *pi, int32 length, UChar32 c, UBool strict); - -/** - * Get a code point from a string at a code point boundary offset, - * and advance the offset to the next code point boundary. - * (Post-incrementing forward iteration.) - * "Safe" macro, checks for illegal sequences and for string boundaries. - * - * The offset may point to the lead byte of a multi-byte sequence, - * in which case the macro will read the whole sequence. - * If the offset points to a trail byte or an illegal UTF-8 sequence, then - * c is set to a negative value. - * - * @param s const uint8 * string - * @param i string offset, i=0x80) { \ - if(CBU8_IS_LEAD(c)) { \ - (c)=base_icu::utf8_nextCharSafeBody((const uint8 *)s, &(i), (int32)(length), c, -1); \ - } else { \ - (c)=CBU_SENTINEL; \ - } \ - } \ -} - -/** - * Append a code point to a string, overwriting 1 to 4 bytes. - * The offset points to the current end of the string contents - * and is advanced (post-increment). - * "Unsafe" macro, assumes a valid code point and sufficient space in the string. - * Otherwise, the result is undefined. - * - * @param s const uint8 * string buffer - * @param i string offset - * @param c code point to append - * @see CBU8_APPEND - * @stable ICU 2.4 - */ -#define CBU8_APPEND_UNSAFE(s, i, c) { \ - if((uint32)(c)<=0x7f) { \ - (s)[(i)++]=(uint8)(c); \ - } else { \ - if((uint32)(c)<=0x7ff) { \ - (s)[(i)++]=(uint8)(((c)>>6)|0xc0); \ - } else { \ - if((uint32)(c)<=0xffff) { \ - (s)[(i)++]=(uint8)(((c)>>12)|0xe0); \ - } else { \ - (s)[(i)++]=(uint8)(((c)>>18)|0xf0); \ - (s)[(i)++]=(uint8)((((c)>>12)&0x3f)|0x80); \ - } \ - (s)[(i)++]=(uint8)((((c)>>6)&0x3f)|0x80); \ - } \ - (s)[(i)++]=(uint8)(((c)&0x3f)|0x80); \ - } \ -} - -// UTF-16 macros --------------------------------------------------------------- -// from utf16.h - -/** - * Does this code unit alone encode a code point (BMP, not a surrogate)? - * @param c 16-bit code unit - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU16_IS_SINGLE(c) !CBU_IS_SURROGATE(c) - -/** - * Is this code unit a lead surrogate (U+d800..U+dbff)? - * @param c 16-bit code unit - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800) - -/** - * Is this code unit a trail surrogate (U+dc00..U+dfff)? - * @param c 16-bit code unit - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00) - -/** - * Is this code unit a surrogate (U+d800..U+dfff)? - * @param c 16-bit code unit - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU16_IS_SURROGATE(c) CBU_IS_SURROGATE(c) - -/** - * Assuming c is a surrogate code point (U16_IS_SURROGATE(c)), - * is it a lead surrogate? - * @param c 16-bit code unit - * @return TRUE or FALSE - * @stable ICU 2.4 - */ -#define CBU16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0) - -/** - * Helper constant for CBU16_GET_SUPPLEMENTARY. - * @internal - */ -#define CBU16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000) - -/** - * Get a supplementary code point value (U+10000..U+10ffff) - * from its lead and trail surrogates. - * The result is undefined if the input values are not - * lead and trail surrogates. - * - * @param lead lead surrogate (U+d800..U+dbff) - * @param trail trail surrogate (U+dc00..U+dfff) - * @return supplementary code point (U+10000..U+10ffff) - * @stable ICU 2.4 - */ -#define CBU16_GET_SUPPLEMENTARY(lead, trail) \ - (((base_icu::UChar32)(lead)<<10UL)+(base_icu::UChar32)(trail)-CBU16_SURROGATE_OFFSET) - - -/** - * Get the lead surrogate (0xd800..0xdbff) for a - * supplementary code point (0x10000..0x10ffff). - * @param supplementary 32-bit code point (U+10000..U+10ffff) - * @return lead surrogate (U+d800..U+dbff) for supplementary - * @stable ICU 2.4 - */ -#define CBU16_LEAD(supplementary) \ - (base_icu::UChar)(((supplementary)>>10)+0xd7c0) - -/** - * Get the trail surrogate (0xdc00..0xdfff) for a - * supplementary code point (0x10000..0x10ffff). - * @param supplementary 32-bit code point (U+10000..U+10ffff) - * @return trail surrogate (U+dc00..U+dfff) for supplementary - * @stable ICU 2.4 - */ -#define CBU16_TRAIL(supplementary) \ - (base_icu::UChar)(((supplementary)&0x3ff)|0xdc00) - -/** - * How many 16-bit code units are used to encode this Unicode code point? (1 or 2) - * The result is not defined if c is not a Unicode code point (U+0000..U+10ffff). - * @param c 32-bit code point - * @return 1 or 2 - * @stable ICU 2.4 - */ -#define CBU16_LENGTH(c) ((uint32)(c)<=0xffff ? 1 : 2) - -/** - * The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff). - * @return 2 - * @stable ICU 2.4 - */ -#define CBU16_MAX_LENGTH 2 - -/** - * Get a code point from a string at a code point boundary offset, - * and advance the offset to the next code point boundary. - * (Post-incrementing forward iteration.) - * "Safe" macro, handles unpaired surrogates and checks for string boundaries. - * - * The offset may point to the lead surrogate unit - * for a supplementary code point, in which case the macro will read - * the following trail surrogate as well. - * If the offset points to a trail surrogate or - * to a single, unpaired lead surrogate, then that itself - * will be returned as the code point. - * - * @param s const UChar * string - * @param i string offset, i>10)+0xd7c0); \ - (s)[(i)++]=(uint16)(((c)&0x3ff)|0xdc00); \ - } \ -} - -} // namesapce base_icu - -#endif // BASE_THIRD_PARTY_ICU_ICU_UTF_H_ diff --git a/vendor/gurl/url/gurl.cc b/vendor/gurl/url/gurl.cc deleted file mode 100644 index 3feca8b..0000000 --- a/vendor/gurl/url/gurl.cc +++ /dev/null @@ -1,539 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifdef WIN32 -#include -#else -#include -#endif - -#include -#include - -#include "url/gurl.h" - -//#include "base/logging.h" -#include "base/strings/string_piece.h" -#include "base/strings/string_util.h" -#include "url/url_canon_stdstring.h" -#include "url/url_util.h" - -namespace { - -static std::string* empty_string = NULL; -static GURL* empty_gurl = NULL; - -#ifdef WIN32 - -// Returns a static reference to an empty string for returning a reference -// when there is no underlying string. -const std::string& EmptyStringForGURL() { - // Avoid static object construction/destruction on startup/shutdown. - if (!empty_string) { - // Create the string. Be careful that we don't break in the case that this - // is being called from multiple threads. Statics are not threadsafe. - std::string* new_empty_string = new std::string; - if (InterlockedCompareExchangePointer( - reinterpret_cast(&empty_string), new_empty_string, NULL)) { - // The old value was non-NULL, so no replacement was done. Another - // thread did the initialization out from under us. - delete new_empty_string; - } - } - return *empty_string; -} - -#else - -static pthread_once_t empty_string_once = PTHREAD_ONCE_INIT; -static pthread_once_t empty_gurl_once = PTHREAD_ONCE_INIT; - -void EmptyStringForGURLOnce(void) { - empty_string = new std::string; -} - -const std::string& EmptyStringForGURL() { - // Avoid static object construction/destruction on startup/shutdown. - pthread_once(&empty_string_once, EmptyStringForGURLOnce); - return *empty_string; -} - -#endif // WIN32 - -} // namespace - -GURL::GURL() : is_valid_(false) { -} - -GURL::GURL(const GURL& other) - : spec_(other.spec_), - is_valid_(other.is_valid_), - parsed_(other.parsed_) { - if (other.inner_url_) - inner_url_.reset(new GURL(*other.inner_url_)); - // Valid filesystem urls should always have an inner_url_. - //DCHECK(!is_valid_ || !SchemeIsFileSystem() || inner_url_); -} - -GURL::GURL(const std::string& url_string) { - InitCanonical(url_string, true); -} - -GURL::GURL(const base::string16& url_string) { - InitCanonical(url_string, true); -} - -GURL::GURL(const std::string& url_string, RetainWhiteSpaceSelector) { - InitCanonical(url_string, false); -} - -GURL::GURL(const char* canonical_spec, - size_t canonical_spec_len, - const url::Parsed& parsed, - bool is_valid) - : spec_(canonical_spec, canonical_spec_len), - is_valid_(is_valid), - parsed_(parsed) { - InitializeFromCanonicalSpec(); -} - -GURL::GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid) - : is_valid_(is_valid), - parsed_(parsed) { - spec_.swap(canonical_spec); - InitializeFromCanonicalSpec(); -} - -template -void GURL::InitCanonical(const STR& input_spec, bool trim_path_end) { - // Reserve enough room in the output for the input, plus some extra so that - // we have room if we have to escape a few things without reallocating. - spec_.reserve(input_spec.size() + 32); - url::StdStringCanonOutput output(&spec_); - is_valid_ = url::Canonicalize( - input_spec.data(), static_cast(input_spec.length()), trim_path_end, - NULL, &output, &parsed_); - - output.Complete(); // Must be done before using string. - if (is_valid_ && SchemeIsFileSystem()) { - inner_url_.reset(new GURL(spec_.data(), parsed_.Length(), - *parsed_.inner_parsed(), true)); - } -} - -void GURL::InitializeFromCanonicalSpec() { - if (is_valid_ && SchemeIsFileSystem()) { - inner_url_.reset( - new GURL(spec_.data(), parsed_.Length(), - *parsed_.inner_parsed(), true)); - } - -#ifndef NDEBUG - // For testing purposes, check that the parsed canonical URL is identical to - // what we would have produced. Skip checking for invalid URLs have no meaning - // and we can't always canonicalize then reproducibly. - if (is_valid_) { - url::Component scheme; - // We can't do this check on the inner_url of a filesystem URL, as - // canonical_spec actually points to the start of the outer URL, so we'd - // end up with infinite recursion in this constructor. - if (!url::FindAndCompareScheme(spec_.data(), spec_.length(), - url::kFileSystemScheme, &scheme) || - scheme.begin == parsed_.scheme.begin) { - // We need to retain trailing whitespace on path URLs, as the |parsed_| - // spec we originally received may legitimately contain trailing white- - // space on the path or components e.g. if the #ref has been - // removed from a "foo:hello #ref" URL (see http://crbug.com/291747). - GURL test_url(spec_, RETAIN_TRAILING_PATH_WHITEPACE); - - //DCHECK(test_url.is_valid_ == is_valid_); - //DCHECK(test_url.spec_ == spec_); - - //DCHECK(test_url.parsed_.scheme == parsed_.scheme); - //DCHECK(test_url.parsed_.username == parsed_.username); - //DCHECK(test_url.parsed_.password == parsed_.password); - //DCHECK(test_url.parsed_.host == parsed_.host); - //DCHECK(test_url.parsed_.port == parsed_.port); - //DCHECK(test_url.parsed_.path == parsed_.path); - //DCHECK(test_url.parsed_.query == parsed_.query); - //DCHECK(test_url.parsed_.ref == parsed_.ref); - } - } -#endif -} - -GURL::~GURL() { -} - -GURL& GURL::operator=(GURL other) { - Swap(&other); - return *this; -} - -const std::string& GURL::spec() const { - if (is_valid_ || spec_.empty()) - return spec_; - - //DCHECK(false) << "Trying to get the spec of an invalid URL!"; - return EmptyStringForGURL(); -} - -bool GURL::operator==(const GURL& other) const { - return spec_ == other.spec_; -} - -bool GURL::operator!=(const GURL& other) const { - return spec_ != other.spec_; -} - -bool GURL::operator<(const GURL& other) const { - return spec_ < other.spec_; -} - -bool GURL::operator>(const GURL& other) const { - return spec_ > other.spec_; -} - -// Note: code duplicated below (it's inconvenient to use a template here). -GURL GURL::Resolve(const std::string& relative) const { - // Not allowed for invalid URLs. - if (!is_valid_) - return GURL(); - - GURL result; - - // Reserve enough room in the output for the input, plus some extra so that - // we have room if we have to escape a few things without reallocating. - result.spec_.reserve(spec_.size() + 32); - url::StdStringCanonOutput output(&result.spec_); - - if (!url::ResolveRelative(spec_.data(), static_cast(spec_.length()), - parsed_, relative.data(), - static_cast(relative.length()), - nullptr, &output, &result.parsed_)) { - // Error resolving, return an empty URL. - return GURL(); - } - - output.Complete(); - result.is_valid_ = true; - if (result.SchemeIsFileSystem()) { - result.inner_url_.reset( - new GURL(result.spec_.data(), result.parsed_.Length(), - *result.parsed_.inner_parsed(), true)); - } - return result; -} - -// Note: code duplicated above (it's inconvenient to use a template here). -GURL GURL::Resolve(const base::string16& relative) const { - // Not allowed for invalid URLs. - if (!is_valid_) - return GURL(); - - GURL result; - - // Reserve enough room in the output for the input, plus some extra so that - // we have room if we have to escape a few things without reallocating. - result.spec_.reserve(spec_.size() + 32); - url::StdStringCanonOutput output(&result.spec_); - - if (!url::ResolveRelative(spec_.data(), static_cast(spec_.length()), - parsed_, relative.data(), - static_cast(relative.length()), - nullptr, &output, &result.parsed_)) { - // Error resolving, return an empty URL. - return GURL(); - } - - output.Complete(); - result.is_valid_ = true; - if (result.SchemeIsFileSystem()) { - result.inner_url_.reset( - new GURL(result.spec_.data(), result.parsed_.Length(), - *result.parsed_.inner_parsed(), true)); - } - return result; -} - -// Note: code duplicated below (it's inconvenient to use a template here). -GURL GURL::ReplaceComponents( - const url::Replacements& replacements) const { - GURL result; - - // Not allowed for invalid URLs. - if (!is_valid_) - return GURL(); - - // Reserve enough room in the output for the input, plus some extra so that - // we have room if we have to escape a few things without reallocating. - result.spec_.reserve(spec_.size() + 32); - url::StdStringCanonOutput output(&result.spec_); - - result.is_valid_ = url::ReplaceComponents( - spec_.data(), static_cast(spec_.length()), parsed_, replacements, - NULL, &output, &result.parsed_); - - output.Complete(); - if (result.is_valid_ && result.SchemeIsFileSystem()) { - result.inner_url_.reset(new GURL(spec_.data(), result.parsed_.Length(), - *result.parsed_.inner_parsed(), true)); - } - return result; -} - -// Note: code duplicated above (it's inconvenient to use a template here). -GURL GURL::ReplaceComponents( - const url::Replacements& replacements) const { - GURL result; - - // Not allowed for invalid URLs. - if (!is_valid_) - return GURL(); - - // Reserve enough room in the output for the input, plus some extra so that - // we have room if we have to escape a few things without reallocating. - result.spec_.reserve(spec_.size() + 32); - url::StdStringCanonOutput output(&result.spec_); - - result.is_valid_ = url::ReplaceComponents( - spec_.data(), static_cast(spec_.length()), parsed_, replacements, - NULL, &output, &result.parsed_); - - output.Complete(); - if (result.is_valid_ && result.SchemeIsFileSystem()) { - result.inner_url_.reset(new GURL(spec_.data(), result.parsed_.Length(), - *result.parsed_.inner_parsed(), true)); - } - return result; -} - -GURL GURL::GetOrigin() const { - // This doesn't make sense for invalid or nonstandard URLs, so return - // the empty URL. - if (!is_valid_ || !IsStandard()) - return GURL(); - - if (SchemeIsFileSystem()) - return inner_url_->GetOrigin(); - - url::Replacements replacements; - replacements.ClearUsername(); - replacements.ClearPassword(); - replacements.ClearPath(); - replacements.ClearQuery(); - replacements.ClearRef(); - - return ReplaceComponents(replacements); -} - -GURL GURL::GetAsReferrer() const { - if (!is_valid_ || !SchemeIsHTTPOrHTTPS()) - return GURL(); - - if (!has_ref() && !has_username() && !has_password()) - return GURL(*this); - - url::Replacements replacements; - replacements.ClearRef(); - replacements.ClearUsername(); - replacements.ClearPassword(); - return ReplaceComponents(replacements); -} - -GURL GURL::GetWithEmptyPath() const { - // This doesn't make sense for invalid or nonstandard URLs, so return - // the empty URL. - if (!is_valid_ || !IsStandard()) - return GURL(); - - // We could optimize this since we know that the URL is canonical, and we are - // appending a canonical path, so avoiding re-parsing. - GURL other(*this); - if (parsed_.path.len == 0) - return other; - - // Clear everything after the path. - other.parsed_.query.reset(); - other.parsed_.ref.reset(); - - // Set the path, since the path is longer than one, we can just set the - // first character and resize. - other.spec_[other.parsed_.path.begin] = '/'; - other.parsed_.path.len = 1; - other.spec_.resize(other.parsed_.path.begin + 1); - return other; -} - -bool GURL::IsStandard() const { - return url::IsStandard(spec_.data(), parsed_.scheme); -} - -bool GURL::SchemeIs(base::StringPiece lower_ascii_scheme) const { - //DCHECK(base::IsStringASCII(lower_ascii_scheme)); - //DCHECK(base::ToLowerASCII(lower_ascii_scheme) == lower_ascii_scheme); - - if (parsed_.scheme.len <= 0) - return lower_ascii_scheme.empty(); - return scheme_piece() == lower_ascii_scheme; -} - -bool GURL::SchemeIsHTTPOrHTTPS() const { - return SchemeIs(url::kHttpScheme) || SchemeIs(url::kHttpsScheme); -} - -bool GURL::SchemeIsWSOrWSS() const { - return SchemeIs(url::kWsScheme) || SchemeIs(url::kWssScheme); -} - -int GURL::IntPort() const { - if (parsed_.port.is_nonempty()) - return url::ParsePort(spec_.data(), parsed_.port); - return url::PORT_UNSPECIFIED; -} - -int GURL::EffectiveIntPort() const { - int int_port = IntPort(); - if (int_port == url::PORT_UNSPECIFIED && IsStandard()) - return url::DefaultPortForScheme(spec_.data() + parsed_.scheme.begin, - parsed_.scheme.len); - return int_port; -} - -std::string GURL::ExtractFileName() const { - url::Component file_component; - url::ExtractFileName(spec_.data(), parsed_.path, &file_component); - return ComponentString(file_component); -} - -std::string GURL::PathForRequest() const { - //DCHECK(parsed_.path.len > 0) - //<< "Canonical path for requests should be non-empty"; - if (parsed_.ref.len >= 0) { - // Clip off the reference when it exists. The reference starts after the - // #-sign, so we have to subtract one to also remove it. - return std::string(spec_, parsed_.path.begin, - parsed_.ref.begin - parsed_.path.begin - 1); - } - // Compute the actual path length, rather than depending on the spec's - // terminator. If we're an inner_url, our spec continues on into our outer - // URL's path/query/ref. - int path_len = parsed_.path.len; - if (parsed_.query.is_valid()) - path_len = parsed_.query.end() - parsed_.path.begin; - - return std::string(spec_, parsed_.path.begin, path_len); -} - -std::string GURL::HostNoBrackets() const { - // If host looks like an IPv6 literal, strip the square brackets. - url::Component h(parsed_.host); - if (h.len >= 2 && spec_[h.begin] == '[' && spec_[h.end() - 1] == ']') { - h.begin++; - h.len -= 2; - } - return ComponentString(h); -} - -std::string GURL::GetContent() const { - return is_valid_ ? ComponentString(parsed_.GetContent()) : std::string(); -} - -bool GURL::HostIsIPAddress() const { - if (!is_valid_ || spec_.empty()) - return false; - - url::RawCanonOutputT ignored_output; - url::CanonHostInfo host_info; - url::CanonicalizeIPAddress(spec_.c_str(), parsed_.host, &ignored_output, - &host_info); - return host_info.IsIPAddress(); -} - -#ifdef WIN32 - -const GURL& GURL::EmptyGURL() { - // Avoid static object construction/destruction on startup/shutdown. - if (!empty_gurl) { - // Create the string. Be careful that we don't break in the case that this - // is being called from multiple threads. - GURL* new_empty_gurl = new GURL; - if (InterlockedCompareExchangePointer( - reinterpret_cast(&empty_gurl), new_empty_gurl, NULL)) { - // The old value was non-NULL, so no replacement was done. Another - // thread did the initialization out from under us. - delete new_empty_gurl; - } - } - return *empty_gurl; -} - -#else - -void EmptyGURLOnce(void) { - empty_gurl = new GURL; -} - -const GURL& GURL::EmptyGURL() { - // Avoid static object construction/destruction on startup/shutdown. - pthread_once(&empty_gurl_once, EmptyGURLOnce); - return *empty_gurl; -} - -#endif // WIN32 - -bool GURL::DomainIs(base::StringPiece lower_ascii_domain) const { - if (!is_valid_ || lower_ascii_domain.empty()) - return false; - - // FileSystem URLs have empty parsed_.host, so check this first. - if (SchemeIsFileSystem() && inner_url_) - return inner_url_->DomainIs(lower_ascii_domain); - - if (!parsed_.host.is_nonempty()) - return false; - - // If the host name ends with a dot but the input domain doesn't, - // then we ignore the dot in the host name. - const char* host_last_pos = spec_.data() + parsed_.host.end() - 1; - int host_len = parsed_.host.len; - int domain_len = lower_ascii_domain.length(); - if ('.' == *host_last_pos && '.' != lower_ascii_domain[domain_len - 1]) { - host_last_pos--; - host_len--; - } - - if (host_len < domain_len) - return false; - - // |host_first_pos| is the start of the compared part of the host name, not - // start of the whole host name. - const char* host_first_pos = spec_.data() + parsed_.host.begin + - host_len - domain_len; - - if (!base::LowerCaseEqualsASCII( - base::StringPiece(host_first_pos, domain_len), lower_ascii_domain)) - return false; - - // Make sure there aren't extra characters in host before the compared part; - // if the host name is longer than the input domain name, then the character - // immediately before the compared part should be a dot. For example, - // www.google.com has domain "google.com", but www.iamnotgoogle.com does not. - if ('.' != lower_ascii_domain[0] && host_len > domain_len && - '.' != *(host_first_pos - 1)) - return false; - - return true; -} - -void GURL::Swap(GURL* other) { - spec_.swap(other->spec_); - std::swap(is_valid_, other->is_valid_); - std::swap(parsed_, other->parsed_); - inner_url_.swap(other->inner_url_); -} - -std::ostream& operator<<(std::ostream& out, const GURL& url) { - return out << url.possibly_invalid_spec(); -} diff --git a/vendor/gurl/url/gurl.h b/vendor/gurl/url/gurl.h deleted file mode 100644 index 8c274ea..0000000 --- a/vendor/gurl/url/gurl.h +++ /dev/null @@ -1,440 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_GURL_H_ -#define URL_GURL_H_ - -#include -#include - -#include "base/memory/scoped_ptr.h" -#include "base/strings/string16.h" -#include "base/strings/string_piece.h" -#include "url/third_party/mozilla/url_parse.h" -#include "url/url_canon.h" -#include "url/url_canon_stdstring.h" -#include "url/url_constants.h" -#include "url/url_export.h" - -// Represents a URL. -// -// A parsed canonicalized URL will be guaranteed UTF-8. Only the ref (if -// specified) can be non-ASCII, the host, path, etc. will be guaranteed ASCII -// and any non-ASCII characters will be encoded and % escaped. -// -// The string representation of a URL is called the spec(). Getting the -// spec will assert if the URL is invalid to help protect against malicious -// URLs. If you want the "best effort" canonicalization of an invalid URL, you -// can use possibly_invalid_spec(). Test validity with is_valid(). Data and -// javascript URLs use GetContent() to extract the data. -// -// This class has existence checkers and getters for the various components of -// a URL. Existence is different than being nonempty. "http://www.google.com/?" -// has a query that just happens to be empty, and has_query() will return true -// while the query getters will return the empty string. -// -// Prefer not to modify a URL using string operations (though sometimes this is -// unavoidable). Instead, use ReplaceComponents which can replace or delete -// multiple parts of a URL in one step, doesn't re-canonicalize unchanged -// sections, and avoids some screw-ups. An example is creating a URL with a -// path that contains a literal '#'. Using string concatenation will generate a -// URL with a truncated path and a reference fragment, while ReplaceComponents -// will know to escape this and produce the desired result. -class URL_EXPORT GURL { - public: - typedef url::StringPieceReplacements Replacements; - typedef url::StringPieceReplacements ReplacementsW; - - // Creates an empty, invalid URL. - GURL(); - - // Copy construction is relatively inexpensive, with most of the time going - // to reallocating the string. It does not re-parse. - GURL(const GURL& other); - - // The strings to this contructor should be UTF-8 / UTF-16. - explicit GURL(const std::string& url_string); - explicit GURL(const base::string16& url_string); - - // Constructor for URLs that have already been parsed and canonicalized. This - // is used for conversions from KURL, for example. The caller must supply all - // information associated with the URL, which must be correct and consistent. - GURL(const char* canonical_spec, - size_t canonical_spec_len, - const url::Parsed& parsed, - bool is_valid); - // Notice that we take the canonical_spec by value so that we can convert - // from WebURL without copying the string. When we call this constructor - // we pass in a temporary std::string, which lets the compiler skip the - // copy and just move the std::string into the function argument. In the - // implementation, we use swap to move the data into the GURL itself, - // which means we end up with zero copies. - GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid); - - ~GURL(); - - GURL& operator=(GURL other); - - // Returns true when this object represents a valid parsed URL. When not - // valid, other functions will still succeed, but you will not get canonical - // data out in the format you may be expecting. Instead, we keep something - // "reasonable looking" so that the user can see how it's busted if - // displayed to them. - bool is_valid() const { - return is_valid_; - } - - // Returns true if the URL is zero-length. Note that empty URLs are also - // invalid, and is_valid() will return false for them. This is provided - // because some users may want to treat the empty case differently. - bool is_empty() const { - return spec_.empty(); - } - - // Returns the raw spec, i.e., the full text of the URL, in canonical UTF-8, - // if the URL is valid. If the URL is not valid, this will assert and return - // the empty string (for safety in release builds, to keep them from being - // misused which might be a security problem). - // - // The URL will be ASCII except the reference fragment, which may be UTF-8. - // It is guaranteed to be valid UTF-8. - // - // The exception is for empty() URLs (which are !is_valid()) but this will - // return the empty string without asserting. - // - // Used invalid_spec() below to get the unusable spec of an invalid URL. This - // separation is designed to prevent errors that may cause security problems - // that could result from the mistaken use of an invalid URL. - const std::string& spec() const; - - // Returns the potentially invalid spec for a the URL. This spec MUST NOT be - // modified or sent over the network. It is designed to be displayed in error - // messages to the user, as the appearance of the spec may explain the error. - // If the spec is valid, the valid spec will be returned. - // - // The returned string is guaranteed to be valid UTF-8. - const std::string& possibly_invalid_spec() const { - return spec_; - } - - // Getter for the raw parsed structure. This allows callers to locate parts - // of the URL within the spec themselves. Most callers should consider using - // the individual component getters below. - // - // The returned parsed structure will reference into the raw spec, which may - // or may not be valid. If you are using this to index into the spec, BE - // SURE YOU ARE USING possibly_invalid_spec() to get the spec, and that you - // don't do anything "important" with invalid specs. - const url::Parsed& parsed_for_possibly_invalid_spec() const { - return parsed_; - } - - // Defiant equality operator! - bool operator==(const GURL& other) const; - bool operator!=(const GURL& other) const; - - // Allows GURL to used as a key in STL (for example, a std::set or std::map). - bool operator<(const GURL& other) const; - bool operator>(const GURL& other) const; - - // Resolves a URL that's possibly relative to this object's URL, and returns - // it. Absolute URLs are also handled according to the rules of URLs on web - // pages. - // - // It may be impossible to resolve the URLs properly. If the input is not - // "standard" (IsStandard() == false) and the input looks relative, we can't - // resolve it. In these cases, the result will be an empty, invalid GURL. - // - // The result may also be a nonempty, invalid URL if the input has some kind - // of encoding error. In these cases, we will try to construct a "good" URL - // that may have meaning to the user, but it will be marked invalid. - // - // It is an error to resolve a URL relative to an invalid URL. The result - // will be the empty URL. - GURL Resolve(const std::string& relative) const; - GURL Resolve(const base::string16& relative) const; - - // Creates a new GURL by replacing the current URL's components with the - // supplied versions. See the Replacements class in url_canon.h for more. - // - // These are not particularly quick, so avoid doing mutations when possible. - // Prefer the 8-bit version when possible. - // - // It is an error to replace components of an invalid URL. The result will - // be the empty URL. - // - // Note that we use the more general url::Replacements type to give - // callers extra flexibility rather than our override. - GURL ReplaceComponents(const url::Replacements& replacements) const; - GURL ReplaceComponents( - const url::Replacements& replacements) const; - - // A helper function that is equivalent to replacing the path with a slash - // and clearing out everything after that. We sometimes need to know just the - // scheme and the authority. If this URL is not a standard URL (it doesn't - // have the regular authority and path sections), then the result will be - // an empty, invalid GURL. Note that this *does* work for file: URLs, which - // some callers may want to filter out before calling this. - // - // It is an error to get an empty path on an invalid URL. The result - // will be the empty URL. - GURL GetWithEmptyPath() const; - - // A helper function to return a GURL containing just the scheme, host, - // and port from a URL. Equivalent to clearing any username and password, - // replacing the path with a slash, and clearing everything after that. If - // this URL is not a standard URL, then the result will be an empty, - // invalid GURL. If the URL has neither username nor password, this - // degenerates to GetWithEmptyPath(). - // - // It is an error to get the origin of an invalid URL. The result - // will be the empty URL. - GURL GetOrigin() const; - - // A helper function to return a GURL stripped from the elements that are not - // supposed to be sent as HTTP referrer: username, password and ref fragment. - // For invalid URLs or URLs that no valid referrers, an empty URL will be - // returned. - GURL GetAsReferrer() const; - - // Returns true if the scheme for the current URL is a known "standard-format" - // scheme. A standard-format scheme adheres to what RFC 3986 calls "generic - // URI syntax" (https://tools.ietf.org/html/rfc3986#section-3). This includes - // file: and filesystem:, which some callers may want to filter out explicitly - // by calling SchemeIsFile[System]. - bool IsStandard() const; - - // Returns true if the given parameter (should be lower-case ASCII to match - // the canonicalized scheme) is the scheme for this URL. Do not include a - // colon. - bool SchemeIs(base::StringPiece lower_ascii_scheme) const; - - // Returns true if the scheme is "http" or "https". - bool SchemeIsHTTPOrHTTPS() const; - - // Returns true is the scheme is "ws" or "wss". - bool SchemeIsWSOrWSS() const; - - // We often need to know if this is a file URL. File URLs are "standard", but - // are often treated separately by some programs. - bool SchemeIsFile() const { - return SchemeIs(url::kFileScheme); - } - - // FileSystem URLs need to be treated differently in some cases. - bool SchemeIsFileSystem() const { - return SchemeIs(url::kFileSystemScheme); - } - - // Returns true if the scheme indicates a network connection that uses TLS or - // some other cryptographic protocol (e.g. QUIC) for security. - // - // This function is a not a complete test of whether or not an origin's code - // is minimally trustworthy. For that, see Chromium's |IsOriginSecure| for a - // higher-level and more complete semantics. See that function's documentation - // for more detail. - bool SchemeIsCryptographic() const { - return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme); - } - - // Returns true if the scheme is "blob". - bool SchemeIsBlob() const { - return SchemeIs(url::kBlobScheme); - } - - // The "content" of the URL is everything after the scheme (skipping the - // scheme delimiting colon). It is an error to get the content of an invalid - // URL: the result will be an empty string. - std::string GetContent() const; - - // Returns true if the hostname is an IP address. Note: this function isn't - // as cheap as a simple getter because it re-parses the hostname to verify. - bool HostIsIPAddress() const; - - // Not including the colon. If you are comparing schemes, prefer SchemeIs. - bool has_scheme() const { - return parsed_.scheme.len >= 0; - } - std::string scheme() const { - return ComponentString(parsed_.scheme); - } - base::StringPiece scheme_piece() const { - return ComponentStringPiece(parsed_.scheme); - } - - bool has_username() const { - return parsed_.username.len >= 0; - } - std::string username() const { - return ComponentString(parsed_.username); - } - base::StringPiece username_piece() const { - return ComponentStringPiece(parsed_.username); - } - - bool has_password() const { - return parsed_.password.len >= 0; - } - std::string password() const { - return ComponentString(parsed_.password); - } - base::StringPiece password_piece() const { - return ComponentStringPiece(parsed_.password); - } - - // The host may be a hostname, an IPv4 address, or an IPv6 literal surrounded - // by square brackets, like "[2001:db8::1]". To exclude these brackets, use - // HostNoBrackets() below. - bool has_host() const { - // Note that hosts are special, absence of host means length 0. - return parsed_.host.len > 0; - } - std::string host() const { - return ComponentString(parsed_.host); - } - base::StringPiece host_piece() const { - return ComponentStringPiece(parsed_.host); - } - - // The port if one is explicitly specified. Most callers will want IntPort() - // or EffectiveIntPort() instead of these. The getters will not include the - // ':'. - bool has_port() const { - return parsed_.port.len >= 0; - } - std::string port() const { - return ComponentString(parsed_.port); - } - base::StringPiece port_piece() const { - return ComponentStringPiece(parsed_.port); - } - - // Including first slash following host, up to the query. The URL - // "http://www.google.com/" has a path of "/". - bool has_path() const { - return parsed_.path.len >= 0; - } - std::string path() const { - return ComponentString(parsed_.path); - } - base::StringPiece path_piece() const { - return ComponentStringPiece(parsed_.path); - } - - // Stuff following '?' up to the ref. The getters will not include the '?'. - bool has_query() const { - return parsed_.query.len >= 0; - } - std::string query() const { - return ComponentString(parsed_.query); - } - base::StringPiece query_piece() const { - return ComponentStringPiece(parsed_.query); - } - - // Stuff following '#' to the end of the string. This will be UTF-8 encoded - // (not necessarily ASCII). The getters will not include the '#'. - bool has_ref() const { - return parsed_.ref.len >= 0; - } - std::string ref() const { - return ComponentString(parsed_.ref); - } - base::StringPiece ref_piece() const { - return ComponentStringPiece(parsed_.ref); - } - - // Returns a parsed version of the port. Can also be any of the special - // values defined in Parsed for ExtractPort. - int IntPort() const; - - // Returns the port number of the URL, or the default port number. - // If the scheme has no concept of port (or unknown default) returns - // PORT_UNSPECIFIED. - int EffectiveIntPort() const; - - // Extracts the filename portion of the path and returns it. The filename - // is everything after the last slash in the path. This may be empty. - std::string ExtractFileName() const; - - // Returns the path that should be sent to the server. This is the path, - // parameter, and query portions of the URL. It is guaranteed to be ASCII. - std::string PathForRequest() const; - - // Returns the host, excluding the square brackets surrounding IPv6 address - // literals. This can be useful for passing to getaddrinfo(). - std::string HostNoBrackets() const; - - // Returns true if this URL's host matches or is in the same domain as - // the given input string. For example, if the hostname of the URL is - // "www.google.com", this will return true for "com", "google.com", and - // "www.google.com". - // - // The input domain should be lower-case ASCII to match the canonicalized - // scheme. This call is more efficient than getting the host and check - // whether host has the specific domain or not because no copies or - // object constructions are done. - bool DomainIs(base::StringPiece lower_ascii_domain) const; - - // Swaps the contents of this GURL object with |other|, without doing - // any memory allocations. - void Swap(GURL* other); - - // Returns a reference to a singleton empty GURL. This object is for callers - // who return references but don't have anything to return in some cases. - // If you just want an empty URL for normal use, prefer GURL(). This function - // may be called from any thread. - static const GURL& EmptyGURL(); - - // Returns the inner URL of a nested URL (currently only non-null for - // filesystem URLs). - const GURL* inner_url() const { - return inner_url_.get(); - } - - private: - // Variant of the string parsing constructor that allows the caller to elect - // retain trailing whitespace, if any, on the passed URL spec, but only if - // the scheme is one that allows trailing whitespace. The primary use-case is - // for data: URLs. In most cases, you want to use the single parameter - // constructor above. - enum RetainWhiteSpaceSelector { RETAIN_TRAILING_PATH_WHITEPACE }; - GURL(const std::string& url_string, RetainWhiteSpaceSelector); - - template - void InitCanonical(const STR& input_spec, bool trim_path_end); - - void InitializeFromCanonicalSpec(); - - // Returns the substring of the input identified by the given component. - std::string ComponentString(const url::Component& comp) const { - if (comp.len <= 0) - return std::string(); - return std::string(spec_, comp.begin, comp.len); - } - base::StringPiece ComponentStringPiece(const url::Component& comp) const { - if (comp.len <= 0) - return base::StringPiece(); - return base::StringPiece(&spec_[comp.begin], comp.len); - } - - // The actual text of the URL, in canonical ASCII form. - std::string spec_; - - // Set when the given URL is valid. Otherwise, we may still have a spec and - // components, but they may not identify valid resources (for example, an - // invalid port number, invalid characters in the scheme, etc.). - bool is_valid_; - - // Identified components of the canonical spec. - url::Parsed parsed_; - - // Used for nested schemes [currently only filesystem:]. - scoped_ptr inner_url_; -}; - -// Stream operator so GURL can be used in assertion statements. -URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); - -#endif // URL_GURL_H_ diff --git a/vendor/gurl/url/third_party/mozilla/LICENSE.txt b/vendor/gurl/url/third_party/mozilla/LICENSE.txt deleted file mode 100644 index ac40837..0000000 --- a/vendor/gurl/url/third_party/mozilla/LICENSE.txt +++ /dev/null @@ -1,65 +0,0 @@ -Copyright 2007, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -------------------------------------------------------------------------------- - -The file url_parse.cc is based on nsURLParsers.cc from Mozilla. This file is -licensed separately as follows: - -The contents of this file are subject to the Mozilla Public License Version -1.1 (the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the -License. - -The Original Code is mozilla.org code. - -The Initial Developer of the Original Code is -Netscape Communications Corporation. -Portions created by the Initial Developer are Copyright (C) 1998 -the Initial Developer. All Rights Reserved. - -Contributor(s): - Darin Fisher (original author) - -Alternatively, the contents of this file may be used under the terms of -either the GNU General Public License Version 2 or later (the "GPL"), or -the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -in which case the provisions of the GPL or the LGPL are applicable instead -of those above. If you wish to allow use of your version of this file only -under the terms of either the GPL or the LGPL, and not to allow others to -use your version of this file under the terms of the MPL, indicate your -decision by deleting the provisions above and replace them with the notice -and other provisions required by the GPL or the LGPL. If you do not delete -the provisions above, a recipient may use your version of this file under -the terms of any one of the MPL, the GPL or the LGPL. diff --git a/vendor/gurl/url/third_party/mozilla/README.chromium b/vendor/gurl/url/third_party/mozilla/README.chromium deleted file mode 100644 index ef396d3..0000000 --- a/vendor/gurl/url/third_party/mozilla/README.chromium +++ /dev/null @@ -1,8 +0,0 @@ -Name: url_parse -URL: http://mxr.mozilla.org/comm-central/source/mozilla/netwerk/base/src/nsURLParsers.cpp -License: BSD and MPL 1.1/GPL 2.0/LGPL 2.1 -License File: LICENSE.txt - -Description: - -The file url_parse.cc is based on nsURLParsers.cc from Mozilla. diff --git a/vendor/gurl/url/third_party/mozilla/a.out b/vendor/gurl/url/third_party/mozilla/a.out deleted file mode 100755 index 246f978..0000000 Binary files a/vendor/gurl/url/third_party/mozilla/a.out and /dev/null differ diff --git a/vendor/gurl/url/third_party/mozilla/url_parse.cc b/vendor/gurl/url/third_party/mozilla/url_parse.cc deleted file mode 100644 index 3723d69..0000000 --- a/vendor/gurl/url/third_party/mozilla/url_parse.cc +++ /dev/null @@ -1,945 +0,0 @@ -/* Based on nsURLParsers.cc from Mozilla - * ------------------------------------- - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Darin Fisher (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "url/third_party/mozilla/url_parse.h" - -#include - -//#include "base/logging.h" -#include "url/url_parse_internal.h" -#include "url/url_util.h" -#include "url/url_util_internal.h" - -namespace url { - -namespace { - -// Returns true if the given character is a valid digit to use in a port. -inline bool IsPortDigit(base::char16 ch) { - return ch >= '0' && ch <= '9'; -} - -// Returns the offset of the next authority terminator in the input starting -// from start_offset. If no terminator is found, the return value will be equal -// to spec_len. -template -int FindNextAuthorityTerminator(const CHAR* spec, - int start_offset, - int spec_len) { - for (int i = start_offset; i < spec_len; i++) { - if (IsAuthorityTerminator(spec[i])) - return i; - } - return spec_len; // Not found. -} - -template -void ParseUserInfo(const CHAR* spec, - const Component& user, - Component* username, - Component* password) { - // Find the first colon in the user section, which separates the username and - // password. - int colon_offset = 0; - while (colon_offset < user.len && spec[user.begin + colon_offset] != ':') - colon_offset++; - - if (colon_offset < user.len) { - // Found separator: : - *username = Component(user.begin, colon_offset); - *password = MakeRange(user.begin + colon_offset + 1, - user.begin + user.len); - } else { - // No separator, treat everything as the username - *username = user; - *password = Component(); - } -} - -template -void ParseServerInfo(const CHAR* spec, - const Component& serverinfo, - Component* hostname, - Component* port_num) { - if (serverinfo.len == 0) { - // No server info, host name is empty. - hostname->reset(); - port_num->reset(); - return; - } - - // If the host starts with a left-bracket, assume the entire host is an - // IPv6 literal. Otherwise, assume none of the host is an IPv6 literal. - // This assumption will be overridden if we find a right-bracket. - // - // Our IPv6 address canonicalization code requires both brackets to exist, - // but the ability to locate an incomplete address can still be useful. - int ipv6_terminator = spec[serverinfo.begin] == '[' ? serverinfo.end() : -1; - int colon = -1; - - // Find the last right-bracket, and the last colon. - for (int i = serverinfo.begin; i < serverinfo.end(); i++) { - switch (spec[i]) { - case ']': - ipv6_terminator = i; - break; - case ':': - colon = i; - break; - } - } - - if (colon > ipv6_terminator) { - // Found a port number: : - *hostname = MakeRange(serverinfo.begin, colon); - if (hostname->len == 0) - hostname->reset(); - *port_num = MakeRange(colon + 1, serverinfo.end()); - } else { - // No port: - *hostname = serverinfo; - port_num->reset(); - } -} - -// Given an already-identified auth section, breaks it into its consituent -// parts. The port number will be parsed and the resulting integer will be -// filled into the given *port variable, or -1 if there is no port number or it -// is invalid. -template -void DoParseAuthority(const CHAR* spec, - const Component& auth, - Component* username, - Component* password, - Component* hostname, - Component* port_num) { - //DCHECK(auth.is_valid()) << "We should always get an authority"; - if (auth.len == 0) { - username->reset(); - password->reset(); - hostname->reset(); - port_num->reset(); - return; - } - - // Search backwards for @, which is the separator between the user info and - // the server info. - int i = auth.begin + auth.len - 1; - while (i > auth.begin && spec[i] != '@') - i--; - - if (spec[i] == '@') { - // Found user info: @ - ParseUserInfo(spec, Component(auth.begin, i - auth.begin), - username, password); - ParseServerInfo(spec, MakeRange(i + 1, auth.begin + auth.len), - hostname, port_num); - } else { - // No user info, everything is server info. - username->reset(); - password->reset(); - ParseServerInfo(spec, auth, hostname, port_num); - } -} - -template -inline void FindQueryAndRefParts(const CHAR* spec, - const Component& path, - int* query_separator, - int* ref_separator) { - int path_end = path.begin + path.len; - for (int i = path.begin; i < path_end; i++) { - switch (spec[i]) { - case '?': - // Only match the query string if it precedes the reference fragment - // and when we haven't found one already. - if (*query_separator < 0) - *query_separator = i; - break; - case '#': - // Record the first # sign only. - if (*ref_separator < 0) { - *ref_separator = i; - return; - } - break; - } - } -} - -template -void ParsePath(const CHAR* spec, - const Component& path, - Component* filepath, - Component* query, - Component* ref) { - // path = [/]//<...>/;?# - - // Special case when there is no path. - if (path.len == -1) { - filepath->reset(); - query->reset(); - ref->reset(); - return; - } - //DCHECK(path.len > 0) << "We should never have 0 length paths"; - - // Search for first occurrence of either ? or #. - int query_separator = -1; // Index of the '?' - int ref_separator = -1; // Index of the '#' - FindQueryAndRefParts(spec, path, &query_separator, &ref_separator); - - // Markers pointing to the character after each of these corresponding - // components. The code below words from the end back to the beginning, - // and will update these indices as it finds components that exist. - int file_end, query_end; - - // Ref fragment: from the # to the end of the path. - int path_end = path.begin + path.len; - if (ref_separator >= 0) { - file_end = query_end = ref_separator; - *ref = MakeRange(ref_separator + 1, path_end); - } else { - file_end = query_end = path_end; - ref->reset(); - } - - // Query fragment: everything from the ? to the next boundary (either the end - // of the path or the ref fragment). - if (query_separator >= 0) { - file_end = query_separator; - *query = MakeRange(query_separator + 1, query_end); - } else { - query->reset(); - } - - // File path: treat an empty file path as no file path. - if (file_end != path.begin) - *filepath = MakeRange(path.begin, file_end); - else - filepath->reset(); -} - -template -bool DoExtractScheme(const CHAR* url, - int url_len, - Component* scheme) { - // Skip leading whitespace and control characters. - int begin = 0; - while (begin < url_len && ShouldTrimFromURL(url[begin])) - begin++; - if (begin == url_len) - return false; // Input is empty or all whitespace. - - // Find the first colon character. - for (int i = begin; i < url_len; i++) { - if (url[i] == ':') { - *scheme = MakeRange(begin, i); - return true; - } - } - return false; // No colon found: no scheme -} - -// Fills in all members of the Parsed structure except for the scheme. -// -// |spec| is the full spec being parsed, of length |spec_len|. -// |after_scheme| is the character immediately following the scheme (after the -// colon) where we'll begin parsing. -// -// Compatability data points. I list "host", "path" extracted: -// Input IE6 Firefox Us -// ----- -------------- -------------- -------------- -// http://foo.com/ "foo.com", "/" "foo.com", "/" "foo.com", "/" -// http:foo.com/ "foo.com", "/" "foo.com", "/" "foo.com", "/" -// http:/foo.com/ fail(*) "foo.com", "/" "foo.com", "/" -// http:\foo.com/ fail(*) "\foo.com", "/"(fail) "foo.com", "/" -// http:////foo.com/ "foo.com", "/" "foo.com", "/" "foo.com", "/" -// -// (*) Interestingly, although IE fails to load these URLs, its history -// canonicalizer handles them, meaning if you've been to the corresponding -// "http://foo.com/" link, it will be colored. -template -void DoParseAfterScheme(const CHAR* spec, - int spec_len, - int after_scheme, - Parsed* parsed) { - int num_slashes = CountConsecutiveSlashes(spec, after_scheme, spec_len); - int after_slashes = after_scheme + num_slashes; - - // First split into two main parts, the authority (username, password, host, - // and port) and the full path (path, query, and reference). - Component authority; - Component full_path; - - // Found "//", looks like an authority section. Treat everything - // from there to the next slash (or end of spec) to be the authority. Note - // that we ignore the number of slashes and treat it as the authority. - int end_auth = FindNextAuthorityTerminator(spec, after_slashes, spec_len); - authority = Component(after_slashes, end_auth - after_slashes); - - if (end_auth == spec_len) // No beginning of path found. - full_path = Component(); - else // Everything starting from the slash to the end is the path. - full_path = Component(end_auth, spec_len - end_auth); - - // Now parse those two sub-parts. - DoParseAuthority(spec, authority, &parsed->username, &parsed->password, - &parsed->host, &parsed->port); - ParsePath(spec, full_path, &parsed->path, &parsed->query, &parsed->ref); -} - -// The main parsing function for standard URLs. Standard URLs have a scheme, -// host, path, etc. -template -void DoParseStandardURL(const CHAR* spec, int spec_len, Parsed* parsed) { - //DCHECK(spec_len >= 0); - - // Strip leading & trailing spaces and control characters. - int begin = 0; - TrimURL(spec, &begin, &spec_len); - - int after_scheme; - if (DoExtractScheme(spec, spec_len, &parsed->scheme)) { - after_scheme = parsed->scheme.end() + 1; // Skip past the colon. - } else { - // Say there's no scheme when there is no colon. We could also say that - // everything is the scheme. Both would produce an invalid URL, but this way - // seems less wrong in more cases. - parsed->scheme.reset(); - after_scheme = begin; - } - DoParseAfterScheme(spec, spec_len, after_scheme, parsed); -} - -template -void DoParseFileSystemURL(const CHAR* spec, int spec_len, Parsed* parsed) { - //DCHECK(spec_len >= 0); - - // Get the unused parts of the URL out of the way. - parsed->username.reset(); - parsed->password.reset(); - parsed->host.reset(); - parsed->port.reset(); - parsed->path.reset(); // May use this; reset for convenience. - parsed->ref.reset(); // May use this; reset for convenience. - parsed->query.reset(); // May use this; reset for convenience. - parsed->clear_inner_parsed(); // May use this; reset for convenience. - - // Strip leading & trailing spaces and control characters. - int begin = 0; - TrimURL(spec, &begin, &spec_len); - - // Handle empty specs or ones that contain only whitespace or control chars. - if (begin == spec_len) { - parsed->scheme.reset(); - return; - } - - int inner_start = -1; - - // Extract the scheme. We also handle the case where there is no scheme. - if (DoExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) { - // Offset the results since we gave ExtractScheme a substring. - parsed->scheme.begin += begin; - - if (parsed->scheme.end() == spec_len - 1) - return; - - inner_start = parsed->scheme.end() + 1; - } else { - // No scheme found; that's not valid for filesystem URLs. - parsed->scheme.reset(); - return; - } - - Component inner_scheme; - const CHAR* inner_spec = &spec[inner_start]; - int inner_spec_len = spec_len - inner_start; - - if (DoExtractScheme(inner_spec, inner_spec_len, &inner_scheme)) { - // Offset the results since we gave ExtractScheme a substring. - inner_scheme.begin += inner_start; - - if (inner_scheme.end() == spec_len - 1) - return; - } else { - // No scheme found; that's not valid for filesystem URLs. - // The best we can do is return "filesystem://". - return; - } - - Parsed inner_parsed; - - if (CompareSchemeComponent(spec, inner_scheme, kFileScheme)) { - // File URLs are special. - ParseFileURL(inner_spec, inner_spec_len, &inner_parsed); - } else if (CompareSchemeComponent(spec, inner_scheme, kFileSystemScheme)) { - // Filesystem URLs don't nest. - return; - } else if (IsStandard(spec, inner_scheme)) { - // All "normal" URLs. - DoParseStandardURL(inner_spec, inner_spec_len, &inner_parsed); - } else { - return; - } - - // All members of inner_parsed need to be offset by inner_start. - // If we had any scheme that supported nesting more than one level deep, - // we'd have to recurse into the inner_parsed's inner_parsed when - // adjusting by inner_start. - inner_parsed.scheme.begin += inner_start; - inner_parsed.username.begin += inner_start; - inner_parsed.password.begin += inner_start; - inner_parsed.host.begin += inner_start; - inner_parsed.port.begin += inner_start; - inner_parsed.query.begin += inner_start; - inner_parsed.ref.begin += inner_start; - inner_parsed.path.begin += inner_start; - - // Query and ref move from inner_parsed to parsed. - parsed->query = inner_parsed.query; - inner_parsed.query.reset(); - parsed->ref = inner_parsed.ref; - inner_parsed.ref.reset(); - - parsed->set_inner_parsed(inner_parsed); - if (!inner_parsed.scheme.is_valid() || !inner_parsed.path.is_valid() || - inner_parsed.inner_parsed()) { - return; - } - - // The path in inner_parsed should start with a slash, then have a filesystem - // type followed by a slash. From the first slash up to but excluding the - // second should be what it keeps; the rest goes to parsed. If the path ends - // before the second slash, it's still pretty clear what the user meant, so - // we'll let that through. - if (!IsURLSlash(spec[inner_parsed.path.begin])) { - return; - } - int inner_path_end = inner_parsed.path.begin + 1; // skip the leading slash - while (inner_path_end < spec_len && - !IsURLSlash(spec[inner_path_end])) - ++inner_path_end; - parsed->path.begin = inner_path_end; - int new_inner_path_length = inner_path_end - inner_parsed.path.begin; - parsed->path.len = inner_parsed.path.len - new_inner_path_length; - parsed->inner_parsed()->path.len = new_inner_path_length; -} - -// Initializes a path URL which is merely a scheme followed by a path. Examples -// include "about:foo" and "javascript:alert('bar');" -template -void DoParsePathURL(const CHAR* spec, int spec_len, - bool trim_path_end, - Parsed* parsed) { - // Get the non-path and non-scheme parts of the URL out of the way, we never - // use them. - parsed->username.reset(); - parsed->password.reset(); - parsed->host.reset(); - parsed->port.reset(); - parsed->path.reset(); - parsed->query.reset(); - parsed->ref.reset(); - - // Strip leading & trailing spaces and control characters. - int scheme_begin = 0; - TrimURL(spec, &scheme_begin, &spec_len, trim_path_end); - - // Handle empty specs or ones that contain only whitespace or control chars. - if (scheme_begin == spec_len) { - parsed->scheme.reset(); - parsed->path.reset(); - return; - } - - int path_begin; - // Extract the scheme, with the path being everything following. We also - // handle the case where there is no scheme. - if (ExtractScheme(&spec[scheme_begin], spec_len - scheme_begin, - &parsed->scheme)) { - // Offset the results since we gave ExtractScheme a substring. - parsed->scheme.begin += scheme_begin; - path_begin = parsed->scheme.end() + 1; - } else { - // No scheme case. - parsed->scheme.reset(); - path_begin = scheme_begin; - } - - if (path_begin == spec_len) - return; - //DCHECK_LT(path_begin, spec_len); - - ParsePath(spec, - MakeRange(path_begin, spec_len), - &parsed->path, - &parsed->query, - &parsed->ref); -} - -template -void DoParseMailtoURL(const CHAR* spec, int spec_len, Parsed* parsed) { - //DCHECK(spec_len >= 0); - - // Get the non-path and non-scheme parts of the URL out of the way, we never - // use them. - parsed->username.reset(); - parsed->password.reset(); - parsed->host.reset(); - parsed->port.reset(); - parsed->ref.reset(); - parsed->query.reset(); // May use this; reset for convenience. - - // Strip leading & trailing spaces and control characters. - int begin = 0; - TrimURL(spec, &begin, &spec_len); - - // Handle empty specs or ones that contain only whitespace or control chars. - if (begin == spec_len) { - parsed->scheme.reset(); - parsed->path.reset(); - return; - } - - int path_begin = -1; - int path_end = -1; - - // Extract the scheme, with the path being everything following. We also - // handle the case where there is no scheme. - if (ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) { - // Offset the results since we gave ExtractScheme a substring. - parsed->scheme.begin += begin; - - if (parsed->scheme.end() != spec_len - 1) { - path_begin = parsed->scheme.end() + 1; - path_end = spec_len; - } - } else { - // No scheme found, just path. - parsed->scheme.reset(); - path_begin = begin; - path_end = spec_len; - } - - // Split [path_begin, path_end) into a path + query. - for (int i = path_begin; i < path_end; ++i) { - if (spec[i] == '?') { - parsed->query = MakeRange(i + 1, path_end); - path_end = i; - break; - } - } - - // For compatability with the standard URL parser, treat no path as - // -1, rather than having a length of 0 - if (path_begin == path_end) { - parsed->path.reset(); - } else { - parsed->path = MakeRange(path_begin, path_end); - } -} - -// Converts a port number in a string to an integer. We'd like to just call -// sscanf but our input is not NULL-terminated, which sscanf requires. Instead, -// we copy the digits to a small stack buffer (since we know the maximum number -// of digits in a valid port number) that we can NULL terminate. -template -int DoParsePort(const CHAR* spec, const Component& component) { - // Easy success case when there is no port. - const int kMaxDigits = 5; - if (!component.is_nonempty()) - return PORT_UNSPECIFIED; - - // Skip over any leading 0s. - Component digits_comp(component.end(), 0); - for (int i = 0; i < component.len; i++) { - if (spec[component.begin + i] != '0') { - digits_comp = MakeRange(component.begin + i, component.end()); - break; - } - } - if (digits_comp.len == 0) - return 0; // All digits were 0. - - // Verify we don't have too many digits (we'll be copying to our buffer so - // we need to double-check). - if (digits_comp.len > kMaxDigits) - return PORT_INVALID; - - // Copy valid digits to the buffer. - char digits[kMaxDigits + 1]; // +1 for null terminator - for (int i = 0; i < digits_comp.len; i++) { - CHAR ch = spec[digits_comp.begin + i]; - if (!IsPortDigit(ch)) { - // Invalid port digit, fail. - return PORT_INVALID; - } - digits[i] = static_cast(ch); - } - - // Null-terminate the string and convert to integer. Since we guarantee - // only digits, atoi's lack of error handling is OK. - digits[digits_comp.len] = 0; - int port = atoi(digits); - if (port > 65535) - return PORT_INVALID; // Out of range. - return port; -} - -template -void DoExtractFileName(const CHAR* spec, - const Component& path, - Component* file_name) { - // Handle empty paths: they have no file names. - if (!path.is_nonempty()) { - file_name->reset(); - return; - } - - // Extract the filename range from the path which is between - // the last slash and the following semicolon. - int file_end = path.end(); - for (int i = path.end() - 1; i >= path.begin; i--) { - if (spec[i] == ';') { - file_end = i; - } else if (IsURLSlash(spec[i])) { - // File name is everything following this character to the end - *file_name = MakeRange(i + 1, file_end); - return; - } - } - - // No slash found, this means the input was degenerate (generally paths - // will start with a slash). Let's call everything the file name. - *file_name = MakeRange(path.begin, file_end); - return; -} - -template -bool DoExtractQueryKeyValue(const CHAR* spec, - Component* query, - Component* key, - Component* value) { - if (!query->is_nonempty()) - return false; - - int start = query->begin; - int cur = start; - int end = query->end(); - - // We assume the beginning of the input is the beginning of the "key" and we - // skip to the end of it. - key->begin = cur; - while (cur < end && spec[cur] != '&' && spec[cur] != '=') - cur++; - key->len = cur - key->begin; - - // Skip the separator after the key (if any). - if (cur < end && spec[cur] == '=') - cur++; - - // Find the value part. - value->begin = cur; - while (cur < end && spec[cur] != '&') - cur++; - value->len = cur - value->begin; - - // Finally skip the next separator if any - if (cur < end && spec[cur] == '&') - cur++; - - // Save the new query - *query = MakeRange(cur, end); - return true; -} - -} // namespace - -Parsed::Parsed() : potentially_dangling_markup(false), inner_parsed_(NULL) {} - -Parsed::Parsed(const Parsed& other) - : scheme(other.scheme), - username(other.username), - password(other.password), - host(other.host), - port(other.port), - path(other.path), - query(other.query), - ref(other.ref), - potentially_dangling_markup(other.potentially_dangling_markup), - inner_parsed_(NULL) { - if (other.inner_parsed_) - set_inner_parsed(*other.inner_parsed_); -} - -Parsed& Parsed::operator=(const Parsed& other) { - if (this != &other) { - scheme = other.scheme; - username = other.username; - password = other.password; - host = other.host; - port = other.port; - path = other.path; - query = other.query; - ref = other.ref; - potentially_dangling_markup = other.potentially_dangling_markup; - if (other.inner_parsed_) - set_inner_parsed(*other.inner_parsed_); - else - clear_inner_parsed(); - } - return *this; -} - -Parsed::~Parsed() { - delete inner_parsed_; -} - -int Parsed::Length() const { - if (ref.is_valid()) - return ref.end(); - return CountCharactersBefore(REF, false); -} - -int Parsed::CountCharactersBefore(ComponentType type, - bool include_delimiter) const { - if (type == SCHEME) - return scheme.begin; - - // There will be some characters after the scheme like "://" and we don't - // know how many. Search forwards for the next thing until we find one. - int cur = 0; - if (scheme.is_valid()) - cur = scheme.end() + 1; // Advance over the ':' at the end of the scheme. - - if (username.is_valid()) { - if (type <= USERNAME) - return username.begin; - cur = username.end() + 1; // Advance over the '@' or ':' at the end. - } - - if (password.is_valid()) { - if (type <= PASSWORD) - return password.begin; - cur = password.end() + 1; // Advance over the '@' at the end. - } - - if (host.is_valid()) { - if (type <= HOST) - return host.begin; - cur = host.end(); - } - - if (port.is_valid()) { - if (type < PORT || (type == PORT && include_delimiter)) - return port.begin - 1; // Back over delimiter. - if (type == PORT) - return port.begin; // Don't want delimiter counted. - cur = port.end(); - } - - if (path.is_valid()) { - if (type <= PATH) - return path.begin; - cur = path.end(); - } - - if (query.is_valid()) { - if (type < QUERY || (type == QUERY && include_delimiter)) - return query.begin - 1; // Back over delimiter. - if (type == QUERY) - return query.begin; // Don't want delimiter counted. - cur = query.end(); - } - - if (ref.is_valid()) { - if (type == REF && !include_delimiter) - return ref.begin; // Back over delimiter. - - // When there is a ref and we get here, the component we wanted was before - // this and not found, so we always know the beginning of the ref is right. - return ref.begin - 1; // Don't want delimiter counted. - } - - return cur; -} - -Component Parsed::GetContent() const { - const int begin = CountCharactersBefore(USERNAME, false); - const int len = Length() - begin; - // For compatability with the standard URL parser, we treat no content as - // -1, rather than having a length of 0 (we normally wouldn't care so - // much for these non-standard URLs). - return len ? Component(begin, len) : Component(); -} - -bool ExtractScheme(const char* url, int url_len, Component* scheme) { - return DoExtractScheme(url, url_len, scheme); -} - -bool ExtractScheme(const base::char16* url, int url_len, Component* scheme) { - return DoExtractScheme(url, url_len, scheme); -} - -// This handles everything that may be an authority terminator, including -// backslash. For special backslash handling see DoParseAfterScheme. -bool IsAuthorityTerminator(base::char16 ch) { - return IsURLSlash(ch) || ch == '?' || ch == '#'; -} - -void ExtractFileName(const char* url, - const Component& path, - Component* file_name) { - DoExtractFileName(url, path, file_name); -} - -void ExtractFileName(const base::char16* url, - const Component& path, - Component* file_name) { - DoExtractFileName(url, path, file_name); -} - -bool ExtractQueryKeyValue(const char* url, - Component* query, - Component* key, - Component* value) { - return DoExtractQueryKeyValue(url, query, key, value); -} - -bool ExtractQueryKeyValue(const base::char16* url, - Component* query, - Component* key, - Component* value) { - return DoExtractQueryKeyValue(url, query, key, value); -} - -void ParseAuthority(const char* spec, - const Component& auth, - Component* username, - Component* password, - Component* hostname, - Component* port_num) { - DoParseAuthority(spec, auth, username, password, hostname, port_num); -} - -void ParseAuthority(const base::char16* spec, - const Component& auth, - Component* username, - Component* password, - Component* hostname, - Component* port_num) { - DoParseAuthority(spec, auth, username, password, hostname, port_num); -} - -int ParsePort(const char* url, const Component& port) { - return DoParsePort(url, port); -} - -int ParsePort(const base::char16* url, const Component& port) { - return DoParsePort(url, port); -} - -void ParseStandardURL(const char* url, int url_len, Parsed* parsed) { - DoParseStandardURL(url, url_len, parsed); -} - -void ParseStandardURL(const base::char16* url, int url_len, Parsed* parsed) { - DoParseStandardURL(url, url_len, parsed); -} - -void ParsePathURL(const char* url, - int url_len, - bool trim_path_end, - Parsed* parsed) { - DoParsePathURL(url, url_len, trim_path_end, parsed); -} - -void ParsePathURL(const base::char16* url, - int url_len, - bool trim_path_end, - Parsed* parsed) { - DoParsePathURL(url, url_len, trim_path_end, parsed); -} - -void ParseFileSystemURL(const char* url, int url_len, Parsed* parsed) { - DoParseFileSystemURL(url, url_len, parsed); -} - -void ParseFileSystemURL(const base::char16* url, int url_len, Parsed* parsed) { - DoParseFileSystemURL(url, url_len, parsed); -} - -void ParseMailtoURL(const char* url, int url_len, Parsed* parsed) { - DoParseMailtoURL(url, url_len, parsed); -} - -void ParseMailtoURL(const base::char16* url, int url_len, Parsed* parsed) { - DoParseMailtoURL(url, url_len, parsed); -} - -void ParsePathInternal(const char* spec, - const Component& path, - Component* filepath, - Component* query, - Component* ref) { - ParsePath(spec, path, filepath, query, ref); -} - -void ParsePathInternal(const base::char16* spec, - const Component& path, - Component* filepath, - Component* query, - Component* ref) { - ParsePath(spec, path, filepath, query, ref); -} - -void ParseAfterScheme(const char* spec, - int spec_len, - int after_scheme, - Parsed* parsed) { - DoParseAfterScheme(spec, spec_len, after_scheme, parsed); -} - -void ParseAfterScheme(const base::char16* spec, - int spec_len, - int after_scheme, - Parsed* parsed) { - DoParseAfterScheme(spec, spec_len, after_scheme, parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/third_party/mozilla/url_parse.h b/vendor/gurl/url/third_party/mozilla/url_parse.h deleted file mode 100644 index 6d40d3f..0000000 --- a/vendor/gurl/url/third_party/mozilla/url_parse.h +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_THIRD_PARTY_MOZILLA_URL_PARSE_H_ -#define URL_THIRD_PARTY_MOZILLA_URL_PARSE_H_ - -#include "base/strings/string16.h" -#include "url/url_export.h" - -namespace url { - -// Component ------------------------------------------------------------------ - -// Represents a substring for URL parsing. -struct Component { - Component() : begin(0), len(-1) {} - - // Normal constructor: takes an offset and a length. - Component(int b, int l) : begin(b), len(l) {} - - int end() const { - return begin + len; - } - - // Returns true if this component is valid, meaning the length is given. Even - // valid components may be empty to record the fact that they exist. - bool is_valid() const { - return (len != -1); - } - - // Returns true if the given component is specified on false, the component - // is either empty or invalid. - bool is_nonempty() const { - return (len > 0); - } - - void reset() { - begin = 0; - len = -1; - } - - bool operator==(const Component& other) const { - return begin == other.begin && len == other.len; - } - - int begin; // Byte offset in the string of this component. - int len; // Will be -1 if the component is unspecified. -}; - -// Helper that returns a component created with the given begin and ending -// points. The ending point is non-inclusive. -inline Component MakeRange(int begin, int end) { - return Component(begin, end - begin); -} - -// Parsed --------------------------------------------------------------------- - -// A structure that holds the identified parts of an input URL. This structure -// does NOT store the URL itself. The caller will have to store the URL text -// and its corresponding Parsed structure separately. -// -// Typical usage would be: -// -// Parsed parsed; -// Component scheme; -// if (!ExtractScheme(url, url_len, &scheme)) -// return I_CAN_NOT_FIND_THE_SCHEME_DUDE; -// -// if (IsStandardScheme(url, scheme)) // Not provided by this component -// ParseStandardURL(url, url_len, &parsed); -// else if (IsFileURL(url, scheme)) // Not provided by this component -// ParseFileURL(url, url_len, &parsed); -// else -// ParsePathURL(url, url_len, &parsed); -// -struct URL_EXPORT Parsed { - // Identifies different components. - enum ComponentType { - SCHEME, - USERNAME, - PASSWORD, - HOST, - PORT, - PATH, - QUERY, - REF, - }; - - // The default constructor is sufficient for the components, but inner_parsed_ - // requires special handling. - Parsed(); - Parsed(const Parsed&); - Parsed& operator=(const Parsed&); - ~Parsed(); - - // Returns the length of the URL (the end of the last component). - // - // Note that for some invalid, non-canonical URLs, this may not be the length - // of the string. For example "http://": the parsed structure will only - // contain an entry for the four-character scheme, and it doesn't know about - // the "://". For all other last-components, it will return the real length. - int Length() const; - - // Returns the number of characters before the given component if it exists, - // or where the component would be if it did exist. This will return the - // string length if the component would be appended to the end. - // - // Note that this can get a little funny for the port, query, and ref - // components which have a delimiter that is not counted as part of the - // component. The |include_delimiter| flag controls if you want this counted - // as part of the component or not when the component exists. - // - // This example shows the difference between the two flags for two of these - // delimited components that is present (the port and query) and one that - // isn't (the reference). The components that this flag affects are marked - // with a *. - // 0 1 2 - // 012345678901234567890 - // Example input: http://foo:80/?query - // include_delim=true, ...=false ("<-" indicates different) - // SCHEME: 0 0 - // USERNAME: 5 5 - // PASSWORD: 5 5 - // HOST: 7 7 - // *PORT: 10 11 <- - // PATH: 13 13 - // *QUERY: 14 15 <- - // *REF: 20 20 - // - int CountCharactersBefore(ComponentType type, bool include_delimiter) const; - - // Scheme without the colon: "http://foo"/ would have a scheme of "http". - // The length will be -1 if no scheme is specified ("foo.com"), or 0 if there - // is a colon but no scheme (":foo"). Note that the scheme is not guaranteed - // to start at the beginning of the string if there are preceeding whitespace - // or control characters. - Component scheme; - - // Username. Specified in URLs with an @ sign before the host. See |password| - Component username; - - // Password. The length will be -1 if unspecified, 0 if specified but empty. - // Not all URLs with a username have a password, as in "http://me@host/". - // The password is separated form the username with a colon, as in - // "http://me:secret@host/" - Component password; - - // Host name. - Component host; - - // Port number. - Component port; - - // Path, this is everything following the host name, stopping at the query of - // ref delimiter (if any). Length will be -1 if unspecified. This includes - // the preceeding slash, so the path on http://www.google.com/asdf" is - // "/asdf". As a result, it is impossible to have a 0 length path, it will - // be -1 in cases like "http://host?foo". - // Note that we treat backslashes the same as slashes. - Component path; - - // Stuff between the ? and the # after the path. This does not include the - // preceeding ? character. Length will be -1 if unspecified, 0 if there is - // a question mark but no query string. - Component query; - - // Indicated by a #, this is everything following the hash sign (not - // including it). If there are multiple hash signs, we'll use the last one. - // Length will be -1 if there is no hash sign, or 0 if there is one but - // nothing follows it. - Component ref; - - // The URL spec from the character after the scheme: until the end of the - // URL, regardless of the scheme. This is mostly useful for 'opaque' non- - // hierarchical schemes like data: and javascript: as a convient way to get - // the string with the scheme stripped off. - Component GetContent() const; - - // True if the URL's source contained a raw `<` character, and whitespace was - // removed from the URL during parsing - // - // TODO(mkwst): Link this to something in a spec if - // https://github.com/whatwg/url/pull/284 lands. - bool potentially_dangling_markup; - - // This is used for nested URL types, currently only filesystem. If you - // parse a filesystem URL, the resulting Parsed will have a nested - // inner_parsed_ to hold the parsed inner URL's component information. - // For all other url types [including the inner URL], it will be NULL. - Parsed* inner_parsed() const { - return inner_parsed_; - } - - void set_inner_parsed(const Parsed& inner_parsed) { - if (!inner_parsed_) - inner_parsed_ = new Parsed(inner_parsed); - else - *inner_parsed_ = inner_parsed; - } - - void clear_inner_parsed() { - if (inner_parsed_) { - delete inner_parsed_; - inner_parsed_ = NULL; - } - } - - private: - Parsed* inner_parsed_; // This object is owned and managed by this struct. -}; - -// Initialization functions --------------------------------------------------- -// -// These functions parse the given URL, filling in all of the structure's -// components. These functions can not fail, they will always do their best -// at interpreting the input given. -// -// The string length of the URL MUST be specified, we do not check for NULLs -// at any point in the process, and will actually handle embedded NULLs. -// -// IMPORTANT: These functions do NOT hang on to the given pointer or copy it -// in any way. See the comment above the struct. -// -// The 8-bit versions require UTF-8 encoding. - -// StandardURL is for when the scheme is known to be one that has an -// authority (host) like "http". This function will not handle weird ones -// like "about:" and "javascript:", or do the right thing for "file:" URLs. -URL_EXPORT void ParseStandardURL(const char* url, - int url_len, - Parsed* parsed); -URL_EXPORT void ParseStandardURL(const base::char16* url, - int url_len, - Parsed* parsed); - -// PathURL is for when the scheme is known not to have an authority (host) -// section but that aren't file URLs either. The scheme is parsed, and -// everything after the scheme is considered as the path. This is used for -// things like "about:" and "javascript:" -URL_EXPORT void ParsePathURL(const char* url, - int url_len, - bool trim_path_end, - Parsed* parsed); -URL_EXPORT void ParsePathURL(const base::char16* url, - int url_len, - bool trim_path_end, - Parsed* parsed); - -// FileURL is for file URLs. There are some special rules for interpreting -// these. -URL_EXPORT void ParseFileURL(const char* url, int url_len, Parsed* parsed); -URL_EXPORT void ParseFileURL(const base::char16* url, - int url_len, - Parsed* parsed); - -// Filesystem URLs are structured differently than other URLs. -URL_EXPORT void ParseFileSystemURL(const char* url, - int url_len, - Parsed* parsed); -URL_EXPORT void ParseFileSystemURL(const base::char16* url, - int url_len, - Parsed* parsed); - -// MailtoURL is for mailto: urls. They are made up scheme,path,query -URL_EXPORT void ParseMailtoURL(const char* url, int url_len, Parsed* parsed); -URL_EXPORT void ParseMailtoURL(const base::char16* url, - int url_len, - Parsed* parsed); - -// Helper functions ----------------------------------------------------------- - -// Locates the scheme according to the URL parser's rules. This function is -// designed so the caller can find the scheme and call the correct Init* -// function according to their known scheme types. -// -// It also does not perform any validation on the scheme. -// -// This function will return true if the scheme is found and will put the -// scheme's range into *scheme. False means no scheme could be found. Note -// that a URL beginning with a colon has a scheme, but it is empty, so this -// function will return true but *scheme will = (0,0). -// -// The scheme is found by skipping spaces and control characters at the -// beginning, and taking everything from there to the first colon to be the -// scheme. The character at scheme.end() will be the colon (we may enhance -// this to handle full width colons or something, so don't count on the -// actual character value). The character at scheme.end()+1 will be the -// beginning of the rest of the URL, be it the authority or the path (or the -// end of the string). -// -// The 8-bit version requires UTF-8 encoding. -URL_EXPORT bool ExtractScheme(const char* url, - int url_len, - Component* scheme); -URL_EXPORT bool ExtractScheme(const base::char16* url, - int url_len, - Component* scheme); - -// Returns true if ch is a character that terminates the authority segment -// of a URL. -URL_EXPORT bool IsAuthorityTerminator(base::char16 ch); - -// Does a best effort parse of input |spec|, in range |auth|. If a particular -// component is not found, it will be set to invalid. -URL_EXPORT void ParseAuthority(const char* spec, - const Component& auth, - Component* username, - Component* password, - Component* hostname, - Component* port_num); -URL_EXPORT void ParseAuthority(const base::char16* spec, - const Component& auth, - Component* username, - Component* password, - Component* hostname, - Component* port_num); - -// Computes the integer port value from the given port component. The port -// component should have been identified by one of the init functions on -// |Parsed| for the given input url. -// -// The return value will be a positive integer between 0 and 64K, or one of -// the two special values below. -enum SpecialPort { PORT_UNSPECIFIED = -1, PORT_INVALID = -2 }; -URL_EXPORT int ParsePort(const char* url, const Component& port); -URL_EXPORT int ParsePort(const base::char16* url, const Component& port); - -// Extracts the range of the file name in the given url. The path must -// already have been computed by the parse function, and the matching URL -// and extracted path are provided to this function. The filename is -// defined as being everything from the last slash/backslash of the path -// to the end of the path. -// -// The file name will be empty if the path is empty or there is nothing -// following the last slash. -// -// The 8-bit version requires UTF-8 encoding. -URL_EXPORT void ExtractFileName(const char* url, - const Component& path, - Component* file_name); -URL_EXPORT void ExtractFileName(const base::char16* url, - const Component& path, - Component* file_name); - -// Extract the first key/value from the range defined by |*query|. Updates -// |*query| to start at the end of the extracted key/value pair. This is -// designed for use in a loop: you can keep calling it with the same query -// object and it will iterate over all items in the query. -// -// Some key/value pairs may have the key, the value, or both be empty (for -// example, the query string "?&"). These will be returned. Note that an empty -// last parameter "foo.com?" or foo.com?a&" will not be returned, this case -// is the same as "done." -// -// The initial query component should not include the '?' (this is the default -// for parsed URLs). -// -// If no key/value are found |*key| and |*value| will be unchanged and it will -// return false. -URL_EXPORT bool ExtractQueryKeyValue(const char* url, - Component* query, - Component* key, - Component* value); -URL_EXPORT bool ExtractQueryKeyValue(const base::char16* url, - Component* query, - Component* key, - Component* value); - -} // namespace url - -#endif // URL_THIRD_PARTY_MOZILLA_URL_PARSE_H_ diff --git a/vendor/gurl/url/url_canon.h b/vendor/gurl/url/url_canon.h deleted file mode 100644 index 95d5345..0000000 --- a/vendor/gurl/url/url_canon.h +++ /dev/null @@ -1,892 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_CANON_H_ -#define URL_URL_CANON_H_ - -#include -#include - -#include "base/strings/string16.h" -#include "url/third_party/mozilla/url_parse.h" -#include "url/url_export.h" - -namespace url { - -// Canonicalizer output ------------------------------------------------------- - -// Base class for the canonicalizer output, this maintains a buffer and -// supports simple resizing and append operations on it. -// -// It is VERY IMPORTANT that no virtual function calls be made on the common -// code path. We only have two virtual function calls, the destructor and a -// resize function that is called when the existing buffer is not big enough. -// The derived class is then in charge of setting up our buffer which we will -// manage. -template -class CanonOutputT { - public: - CanonOutputT() : buffer_(NULL), buffer_len_(0), cur_len_(0) { - } - virtual ~CanonOutputT() { - } - - // Implemented to resize the buffer. This function should update the buffer - // pointer to point to the new buffer, and any old data up to |cur_len_| in - // the buffer must be copied over. - // - // The new size |sz| must be larger than buffer_len_. - virtual void Resize(int sz) = 0; - - // Accessor for returning a character at a given position. The input offset - // must be in the valid range. - inline T at(int offset) const { - return buffer_[offset]; - } - - // Sets the character at the given position. The given position MUST be less - // than the length(). - inline void set(int offset, T ch) { - buffer_[offset] = ch; - } - - // Returns the number of characters currently in the buffer. - inline int length() const { - return cur_len_; - } - - // Returns the current capacity of the buffer. The length() is the number of - // characters that have been declared to be written, but the capacity() is - // the number that can be written without reallocation. If the caller must - // write many characters at once, it can make sure there is enough capacity, - // write the data, then use set_size() to declare the new length(). - int capacity() const { - return buffer_len_; - } - - // Called by the user of this class to get the output. The output will NOT - // be NULL-terminated. Call length() to get the - // length. - const T* data() const { - return buffer_; - } - T* data() { - return buffer_; - } - - // Shortens the URL to the new length. Used for "backing up" when processing - // relative paths. This can also be used if an external function writes a lot - // of data to the buffer (when using the "Raw" version below) beyond the end, - // to declare the new length. - // - // This MUST NOT be used to expand the size of the buffer beyond capacity(). - void set_length(int new_len) { - cur_len_ = new_len; - } - - // This is the most performance critical function, since it is called for - // every character. - void push_back(T ch) { - // In VC2005, putting this common case first speeds up execution - // dramatically because this branch is predicted as taken. - if (cur_len_ < buffer_len_) { - buffer_[cur_len_] = ch; - cur_len_++; - return; - } - - // Grow the buffer to hold at least one more item. Hopefully we won't have - // to do this very often. - if (!Grow(1)) - return; - - // Actually do the insertion. - buffer_[cur_len_] = ch; - cur_len_++; - } - - // Appends the given string to the output. - void Append(const T* str, int str_len) { - if (cur_len_ + str_len > buffer_len_) { - if (!Grow(cur_len_ + str_len - buffer_len_)) - return; - } - for (int i = 0; i < str_len; i++) - buffer_[cur_len_ + i] = str[i]; - cur_len_ += str_len; - } - - protected: - // Grows the given buffer so that it can fit at least |min_additional| - // characters. Returns true if the buffer could be resized, false on OOM. - bool Grow(int min_additional) { - static const int kMinBufferLen = 16; - int new_len = (buffer_len_ == 0) ? kMinBufferLen : buffer_len_; - do { - if (new_len >= (1 << 30)) // Prevent overflow below. - return false; - new_len *= 2; - } while (new_len < buffer_len_ + min_additional); - Resize(new_len); - return true; - } - - T* buffer_; - int buffer_len_; - - // Used characters in the buffer. - int cur_len_; -}; - -// Simple implementation of the CanonOutput using new[]. This class -// also supports a static buffer so if it is allocated on the stack, most -// URLs can be canonicalized with no heap allocations. -template -class RawCanonOutputT : public CanonOutputT { - public: - RawCanonOutputT() : CanonOutputT() { - this->buffer_ = fixed_buffer_; - this->buffer_len_ = fixed_capacity; - } - virtual ~RawCanonOutputT() { - if (this->buffer_ != fixed_buffer_) - delete[] this->buffer_; - } - - void Resize(int sz) override { - T* new_buf = new T[sz]; - memcpy(new_buf, this->buffer_, - sizeof(T) * (this->cur_len_ < sz ? this->cur_len_ : sz)); - if (this->buffer_ != fixed_buffer_) - delete[] this->buffer_; - this->buffer_ = new_buf; - this->buffer_len_ = sz; - } - - protected: - T fixed_buffer_[fixed_capacity]; -}; - -// Normally, all canonicalization output is in narrow characters. We support -// the templates so it can also be used internally if a wide buffer is -// required. -typedef CanonOutputT CanonOutput; -typedef CanonOutputT CanonOutputW; - -template -class RawCanonOutput : public RawCanonOutputT {}; -template -class RawCanonOutputW : public RawCanonOutputT {}; - -// Character set converter ---------------------------------------------------- -// -// Converts query strings into a custom encoding. The embedder can supply an -// implementation of this class to interface with their own character set -// conversion libraries. -// -// Embedders will want to see the unit test for the ICU version. - -class URL_EXPORT CharsetConverter { - public: - CharsetConverter() {} - virtual ~CharsetConverter() {} - - // Converts the given input string from UTF-16 to whatever output format the - // converter supports. This is used only for the query encoding conversion, - // which does not fail. Instead, the converter should insert "invalid - // character" characters in the output for invalid sequences, and do the - // best it can. - // - // If the input contains a character not representable in the output - // character set, the converter should append the HTML entity sequence in - // decimal, (such as "你") with escaping of the ampersand, number - // sign, and semicolon (in the previous example it would be - // "%26%2320320%3B"). This rule is based on what IE does in this situation. - virtual void ConvertFromUTF16(const base::char16* input, - int input_len, - CanonOutput* output) = 0; -}; - -// Whitespace ----------------------------------------------------------------- - -// Searches for whitespace that should be removed from the middle of URLs, and -// removes it. Removed whitespace are tabs and newlines, but NOT spaces. Spaces -// are preserved, which is what most browsers do. A pointer to the output will -// be returned, and the length of that output will be in |output_len|. -// -// This should be called before parsing if whitespace removal is desired (which -// it normally is when you are canonicalizing). -// -// If no whitespace is removed, this function will not use the buffer and will -// return a pointer to the input, to avoid the extra copy. If modification is -// required, the given |buffer| will be used and the returned pointer will -// point to the beginning of the buffer. -// -// Therefore, callers should not use the buffer, since it may actually be empty, -// use the computed pointer and |*output_len| instead. -URL_EXPORT const char* RemoveURLWhitespace(const char* input, int input_len, - CanonOutputT* buffer, - int* output_len); -URL_EXPORT const base::char16* RemoveURLWhitespace( - const base::char16* input, - int input_len, - CanonOutputT* buffer, - int* output_len); - -// IDN ------------------------------------------------------------------------ - -// Converts the Unicode input representing a hostname to ASCII using IDN rules. -// The output must fall in the ASCII range, but will be encoded in UTF-16. -// -// On success, the output will be filled with the ASCII host name and it will -// return true. Unlike most other canonicalization functions, this assumes that -// the output is empty. The beginning of the host will be at offset 0, and -// the length of the output will be set to the length of the new host name. -// -// On error, returns false. The output in this case is undefined. -URL_EXPORT bool IDNToASCII(const base::char16* src, - int src_len, - CanonOutputW* output); - -// Piece-by-piece canonicalizers ---------------------------------------------- -// -// These individual canonicalizers append the canonicalized versions of the -// corresponding URL component to the given std::string. The spec and the -// previously-identified range of that component are the input. The range of -// the canonicalized component will be written to the output component. -// -// These functions all append to the output so they can be chained. Make sure -// the output is empty when you start. -// -// These functions returns boolean values indicating success. On failure, they -// will attempt to write something reasonable to the output so that, if -// displayed to the user, they will recognise it as something that's messed up. -// Nothing more should ever be done with these invalid URLs, however. - -// Scheme: Appends the scheme and colon to the URL. The output component will -// indicate the range of characters up to but not including the colon. -// -// Canonical URLs always have a scheme. If the scheme is not present in the -// input, this will just write the colon to indicate an empty scheme. Does not -// append slashes which will be needed before any authority components for most -// URLs. -// -// The 8-bit version requires UTF-8 encoding. -URL_EXPORT bool CanonicalizeScheme(const char* spec, - const Component& scheme, - CanonOutput* output, - Component* out_scheme); -URL_EXPORT bool CanonicalizeScheme(const base::char16* spec, - const Component& scheme, - CanonOutput* output, - Component* out_scheme); - -// User info: username/password. If present, this will add the delimiters so -// the output will be ":@" or "@". Empty -// username/password pairs, or empty passwords, will get converted to -// nonexistent in the canonical version. -// -// The components for the username and password refer to ranges in the -// respective source strings. Usually, these will be the same string, which -// is legal as long as the two components don't overlap. -// -// The 8-bit version requires UTF-8 encoding. -URL_EXPORT bool CanonicalizeUserInfo(const char* username_source, - const Component& username, - const char* password_source, - const Component& password, - CanonOutput* output, - Component* out_username, - Component* out_password); -URL_EXPORT bool CanonicalizeUserInfo(const base::char16* username_source, - const Component& username, - const base::char16* password_source, - const Component& password, - CanonOutput* output, - Component* out_username, - Component* out_password); - -// This structure holds detailed state exported from the IP/Host canonicalizers. -// Additional fields may be added as callers require them. -struct CanonHostInfo { - CanonHostInfo() : family(NEUTRAL), num_ipv4_components(0), out_host() {} - - // Convenience function to test if family is an IP address. - bool IsIPAddress() const { return family == IPV4 || family == IPV6; } - - // This field summarizes how the input was classified by the canonicalizer. - enum Family { - NEUTRAL, // - Doesn't resemble an IP address. As far as the IP - // canonicalizer is concerned, it should be treated as a - // hostname. - BROKEN, // - Almost an IP, but was not canonicalized. This could be an - // IPv4 address where truncation occurred, or something - // containing the special characters :[] which did not parse - // as an IPv6 address. Never attempt to connect to this - // address, because it might actually succeed! - IPV4, // - Successfully canonicalized as an IPv4 address. - IPV6, // - Successfully canonicalized as an IPv6 address. - }; - Family family; - - // If |family| is IPV4, then this is the number of nonempty dot-separated - // components in the input text, from 1 to 4. If |family| is not IPV4, - // this value is undefined. - int num_ipv4_components; - - // Location of host within the canonicalized output. - // CanonicalizeIPAddress() only sets this field if |family| is IPV4 or IPV6. - // CanonicalizeHostVerbose() always sets it. - Component out_host; - - // |address| contains the parsed IP Address (if any) in its first - // AddressLength() bytes, in network order. If IsIPAddress() is false - // AddressLength() will return zero and the content of |address| is undefined. - unsigned char address[16]; - - // Convenience function to calculate the length of an IP address corresponding - // to the current IP version in |family|, if any. For use with |address|. - int AddressLength() const { - return family == IPV4 ? 4 : (family == IPV6 ? 16 : 0); - } -}; - - -// Host. -// -// The 8-bit version requires UTF-8 encoding. Use this version when you only -// need to know whether canonicalization succeeded. -URL_EXPORT bool CanonicalizeHost(const char* spec, - const Component& host, - CanonOutput* output, - Component* out_host); -URL_EXPORT bool CanonicalizeHost(const base::char16* spec, - const Component& host, - CanonOutput* output, - Component* out_host); - -// Extended version of CanonicalizeHost, which returns additional information. -// Use this when you need to know whether the hostname was an IP address. -// A successful return is indicated by host_info->family != BROKEN. See the -// definition of CanonHostInfo above for details. -URL_EXPORT void CanonicalizeHostVerbose(const char* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info); -URL_EXPORT void CanonicalizeHostVerbose(const base::char16* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info); - -// IP addresses. -// -// Tries to interpret the given host name as an IPv4 or IPv6 address. If it is -// an IP address, it will canonicalize it as such, appending it to |output|. -// Additional status information is returned via the |*host_info| parameter. -// See the definition of CanonHostInfo above for details. -// -// This is called AUTOMATICALLY from the host canonicalizer, which ensures that -// the input is unescaped and name-prepped, etc. It should not normally be -// necessary or wise to call this directly. -URL_EXPORT void CanonicalizeIPAddress(const char* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info); -URL_EXPORT void CanonicalizeIPAddress(const base::char16* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info); - -// Port: this function will add the colon for the port if a port is present. -// The caller can pass PORT_UNSPECIFIED as the -// default_port_for_scheme argument if there is no default port. -// -// The 8-bit version requires UTF-8 encoding. -URL_EXPORT bool CanonicalizePort(const char* spec, - const Component& port, - int default_port_for_scheme, - CanonOutput* output, - Component* out_port); -URL_EXPORT bool CanonicalizePort(const base::char16* spec, - const Component& port, - int default_port_for_scheme, - CanonOutput* output, - Component* out_port); - -// Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED -// if the scheme is unknown. -URL_EXPORT int DefaultPortForScheme(const char* scheme, int scheme_len); - -// Path. If the input does not begin in a slash (including if the input is -// empty), we'll prepend a slash to the path to make it canonical. -// -// The 8-bit version assumes UTF-8 encoding, but does not verify the validity -// of the UTF-8 (i.e., you can have invalid UTF-8 sequences, invalid -// characters, etc.). Normally, URLs will come in as UTF-16, so this isn't -// an issue. Somebody giving us an 8-bit path is responsible for generating -// the path that the server expects (we'll escape high-bit characters), so -// if something is invalid, it's their problem. -URL_EXPORT bool CanonicalizePath(const char* spec, - const Component& path, - CanonOutput* output, - Component* out_path); -URL_EXPORT bool CanonicalizePath(const base::char16* spec, - const Component& path, - CanonOutput* output, - Component* out_path); - -// Canonicalizes the input as a file path. This is like CanonicalizePath except -// that it also handles Windows drive specs. For example, the path can begin -// with "c|\" and it will get properly canonicalized to "C:/". -// The string will be appended to |*output| and |*out_path| will be updated. -// -// The 8-bit version requires UTF-8 encoding. -URL_EXPORT bool FileCanonicalizePath(const char* spec, - const Component& path, - CanonOutput* output, - Component* out_path); -URL_EXPORT bool FileCanonicalizePath(const base::char16* spec, - const Component& path, - CanonOutput* output, - Component* out_path); - -// Query: Prepends the ? if needed. -// -// The 8-bit version requires the input to be UTF-8 encoding. Incorrectly -// encoded characters (in UTF-8 or UTF-16) will be replaced with the Unicode -// "invalid character." This function can not fail, we always just try to do -// our best for crazy input here since web pages can set it themselves. -// -// This will convert the given input into the output encoding that the given -// character set converter object provides. The converter will only be called -// if necessary, for ASCII input, no conversions are necessary. -// -// The converter can be NULL. In this case, the output encoding will be UTF-8. -URL_EXPORT void CanonicalizeQuery(const char* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output, - Component* out_query); -URL_EXPORT void CanonicalizeQuery(const base::char16* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output, - Component* out_query); - -// Ref: Prepends the # if needed. The output will be UTF-8 (this is the only -// canonicalizer that does not produce ASCII output). The output is -// guaranteed to be valid UTF-8. -// -// This function will not fail. If the input is invalid UTF-8/UTF-16, we'll use -// the "Unicode replacement character" for the confusing bits and copy the rest. -URL_EXPORT void CanonicalizeRef(const char* spec, - const Component& path, - CanonOutput* output, - Component* out_path); -URL_EXPORT void CanonicalizeRef(const base::char16* spec, - const Component& path, - CanonOutput* output, - Component* out_path); - -// Full canonicalizer --------------------------------------------------------- -// -// These functions replace any string contents, rather than append as above. -// See the above piece-by-piece functions for information specific to -// canonicalizing individual components. -// -// The output will be ASCII except the reference fragment, which may be UTF-8. -// -// The 8-bit versions require UTF-8 encoding. - -// Use for standard URLs with authorities and paths. -URL_EXPORT bool CanonicalizeStandardURL(const char* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool CanonicalizeStandardURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); - -// Use for file URLs. -URL_EXPORT bool CanonicalizeFileURL(const char* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool CanonicalizeFileURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); - -// Use for filesystem URLs. -URL_EXPORT bool CanonicalizeFileSystemURL(const char* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool CanonicalizeFileSystemURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); - -// Use for path URLs such as javascript. This does not modify the path in any -// way, for example, by escaping it. -URL_EXPORT bool CanonicalizePathURL(const char* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool CanonicalizePathURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed); - -// Use for mailto URLs. This "canonicalizes" the URL into a path and query -// component. It does not attempt to merge "to" fields. It uses UTF-8 for -// the query encoding if there is a query. This is because a mailto URL is -// really intended for an external mail program, and the encoding of a page, -// etc. which would influence a query encoding normally are irrelevant. -URL_EXPORT bool CanonicalizeMailtoURL(const char* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool CanonicalizeMailtoURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed); - -// Part replacer -------------------------------------------------------------- - -// Internal structure used for storing separate strings for each component. -// The basic canonicalization functions use this structure internally so that -// component replacement (different strings for different components) can be -// treated on the same code path as regular canonicalization (the same string -// for each component). -// -// A Parsed structure usually goes along with this. Those components identify -// offsets within these strings, so that they can all be in the same string, -// or spread arbitrarily across different ones. -// -// This structures does not own any data. It is the caller's responsibility to -// ensure that the data the pointers point to stays in scope and is not -// modified. -template -struct URLComponentSource { - // Constructor normally used by callers wishing to replace components. This - // will make them all NULL, which is no replacement. The caller would then - // override the components they want to replace. - URLComponentSource() - : scheme(NULL), - username(NULL), - password(NULL), - host(NULL), - port(NULL), - path(NULL), - query(NULL), - ref(NULL) { - } - - // Constructor normally used internally to initialize all the components to - // point to the same spec. - explicit URLComponentSource(const CHAR* default_value) - : scheme(default_value), - username(default_value), - password(default_value), - host(default_value), - port(default_value), - path(default_value), - query(default_value), - ref(default_value) { - } - - const CHAR* scheme; - const CHAR* username; - const CHAR* password; - const CHAR* host; - const CHAR* port; - const CHAR* path; - const CHAR* query; - const CHAR* ref; -}; - -// This structure encapsulates information on modifying a URL. Each component -// may either be left unchanged, replaced, or deleted. -// -// By default, each component is unchanged. For those components that should be -// modified, call either Set* or Clear* to modify it. -// -// The string passed to Set* functions DOES NOT GET COPIED AND MUST BE KEPT -// IN SCOPE BY THE CALLER for as long as this object exists! -// -// Prefer the 8-bit replacement version if possible since it is more efficient. -template -class Replacements { - public: - Replacements() { - } - - // Scheme - void SetScheme(const CHAR* s, const Component& comp) { - sources_.scheme = s; - components_.scheme = comp; - } - // Note: we don't have a ClearScheme since this doesn't make any sense. - bool IsSchemeOverridden() const { return sources_.scheme != NULL; } - - // Username - void SetUsername(const CHAR* s, const Component& comp) { - sources_.username = s; - components_.username = comp; - } - void ClearUsername() { - sources_.username = Placeholder(); - components_.username = Component(); - } - bool IsUsernameOverridden() const { return sources_.username != NULL; } - - // Password - void SetPassword(const CHAR* s, const Component& comp) { - sources_.password = s; - components_.password = comp; - } - void ClearPassword() { - sources_.password = Placeholder(); - components_.password = Component(); - } - bool IsPasswordOverridden() const { return sources_.password != NULL; } - - // Host - void SetHost(const CHAR* s, const Component& comp) { - sources_.host = s; - components_.host = comp; - } - void ClearHost() { - sources_.host = Placeholder(); - components_.host = Component(); - } - bool IsHostOverridden() const { return sources_.host != NULL; } - - // Port - void SetPort(const CHAR* s, const Component& comp) { - sources_.port = s; - components_.port = comp; - } - void ClearPort() { - sources_.port = Placeholder(); - components_.port = Component(); - } - bool IsPortOverridden() const { return sources_.port != NULL; } - - // Path - void SetPath(const CHAR* s, const Component& comp) { - sources_.path = s; - components_.path = comp; - } - void ClearPath() { - sources_.path = Placeholder(); - components_.path = Component(); - } - bool IsPathOverridden() const { return sources_.path != NULL; } - - // Query - void SetQuery(const CHAR* s, const Component& comp) { - sources_.query = s; - components_.query = comp; - } - void ClearQuery() { - sources_.query = Placeholder(); - components_.query = Component(); - } - bool IsQueryOverridden() const { return sources_.query != NULL; } - - // Ref - void SetRef(const CHAR* s, const Component& comp) { - sources_.ref = s; - components_.ref = comp; - } - void ClearRef() { - sources_.ref = Placeholder(); - components_.ref = Component(); - } - bool IsRefOverridden() const { return sources_.ref != NULL; } - - // Getters for the internal data. See the variables below for how the - // information is encoded. - const URLComponentSource& sources() const { return sources_; } - const Parsed& components() const { return components_; } - - private: - // Returns a pointer to a static empty string that is used as a placeholder - // to indicate a component should be deleted (see below). - const CHAR* Placeholder() { - static const CHAR empty_cstr = 0; - return &empty_cstr; - } - - // We support three states: - // - // Action | Source Component - // -----------------------+-------------------------------------------------- - // Don't change component | NULL (unused) - // Replace component | (replacement string) (replacement component) - // Delete component | (non-NULL) (invalid component: (0,-1)) - // - // We use a pointer to the empty string for the source when the component - // should be deleted. - URLComponentSource sources_; - Parsed components_; -}; - -// The base must be an 8-bit canonical URL. -URL_EXPORT bool ReplaceStandardURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool ReplaceStandardURL( - const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); - -// Filesystem URLs can only have the path, query, or ref replaced. -// All other components will be ignored. -URL_EXPORT bool ReplaceFileSystemURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool ReplaceFileSystemURL( - const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); - -// Replacing some parts of a file URL is not permitted. Everything except -// the host, path, query, and ref will be ignored. -URL_EXPORT bool ReplaceFileURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool ReplaceFileURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed); - -// Path URLs can only have the scheme and path replaced. All other components -// will be ignored. -URL_EXPORT bool ReplacePathURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool ReplacePathURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed); - -// Mailto URLs can only have the scheme, path, and query replaced. -// All other components will be ignored. -URL_EXPORT bool ReplaceMailtoURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed); -URL_EXPORT bool ReplaceMailtoURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed); - -// Relative URL --------------------------------------------------------------- - -// Given an input URL or URL fragment |fragment|, determines if it is a -// relative or absolute URL and places the result into |*is_relative|. If it is -// relative, the relevant portion of the URL will be placed into -// |*relative_component| (there may have been trimmed whitespace, for example). -// This value is passed to ResolveRelativeURL. If the input is not relative, -// this value is UNDEFINED (it may be changed by the function). -// -// Returns true on success (we successfully determined the URL is relative or -// not). Failure means that the combination of URLs doesn't make any sense. -// -// The base URL should always be canonical, therefore is ASCII. -URL_EXPORT bool IsRelativeURL(const char* base, - const Parsed& base_parsed, - const char* fragment, - int fragment_len, - bool is_base_hierarchical, - bool* is_relative, - Component* relative_component); -URL_EXPORT bool IsRelativeURL(const char* base, - const Parsed& base_parsed, - const base::char16* fragment, - int fragment_len, - bool is_base_hierarchical, - bool* is_relative, - Component* relative_component); - -// Given a canonical parsed source URL, a URL fragment known to be relative, -// and the identified relevant portion of the relative URL (computed by -// IsRelativeURL), this produces a new parsed canonical URL in |output| and -// |out_parsed|. -// -// It also requires a flag indicating whether the base URL is a file: URL -// which triggers additional logic. -// -// The base URL should be canonical and have a host (may be empty for file -// URLs) and a path. If it doesn't have these, we can't resolve relative -// URLs off of it and will return the base as the output with an error flag. -// Because it is canonical is should also be ASCII. -// -// The query charset converter follows the same rules as CanonicalizeQuery. -// -// Returns true on success. On failure, the output will be "something -// reasonable" that will be consistent and valid, just probably not what -// was intended by the web page author or caller. -URL_EXPORT bool ResolveRelativeURL(const char* base_url, - const Parsed& base_parsed, - bool base_is_file, - const char* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed); -URL_EXPORT bool ResolveRelativeURL(const char* base_url, - const Parsed& base_parsed, - bool base_is_file, - const base::char16* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed); - -} // namespace url - -#endif // URL_URL_CANON_H_ diff --git a/vendor/gurl/url/url_canon_etc.cc b/vendor/gurl/url/url_canon_etc.cc deleted file mode 100644 index e9da94c..0000000 --- a/vendor/gurl/url/url_canon_etc.cc +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Canonicalizers for random bits that aren't big enough for their own files. - -#include - -#include "url/url_canon.h" -#include "url/url_canon_internal.h" - -namespace url { - -namespace { - -// Returns true if the given character should be removed from the middle of a -// URL. -inline bool IsRemovableURLWhitespace(int ch) { - return ch == '\r' || ch == '\n' || ch == '\t'; -} - -// Backend for RemoveURLWhitespace (see declaration in url_canon.h). -// It sucks that we have to do this, since this takes about 13% of the total URL -// canonicalization time. -template -const CHAR* DoRemoveURLWhitespace(const CHAR* input, int input_len, - CanonOutputT* buffer, - int* output_len) { - // Fast verification that there's nothing that needs removal. This is the 99% - // case, so we want it to be fast and don't care about impacting the speed - // when we do find whitespace. - int found_whitespace = false; - for (int i = 0; i < input_len; i++) { - if (!IsRemovableURLWhitespace(input[i])) - continue; - found_whitespace = true; - break; - } - - if (!found_whitespace) { - // Didn't find any whitespace, we don't need to do anything. We can just - // return the input as the output. - *output_len = input_len; - return input; - } - - // Remove the whitespace into the new buffer and return it. - for (int i = 0; i < input_len; i++) { - if (!IsRemovableURLWhitespace(input[i])) - buffer->push_back(input[i]); - } - *output_len = buffer->length(); - return buffer->data(); -} - -// Contains the canonical version of each possible input letter in the scheme -// (basically, lower-cased). The corresponding entry will be 0 if the letter -// is not allowed in a scheme. -const char kSchemeCanonical[0x80] = { -// 00-1f: all are invalid - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// ' ' ! " # $ % & ' ( ) * + , - . / - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '+', 0, '-', '.', 0, -// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0 , 0 , 0 , 0 , 0 , 0 , -// @ A B C D E F G H I J K L M N O - 0 , 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', -// P Q R S T U V W X Y Z [ \ ] ^ _ - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0 , 0, 0 , 0, -// ` a b c d e f g h i j k l m n o - 0 , 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', -// p q r s t u v w x y z { | } ~ - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0 , 0 , 0 , 0 , 0 }; - -// This could be a table lookup as well by setting the high bit for each -// valid character, but it's only called once per URL, and it makes the lookup -// table easier to read not having extra stuff in it. -inline bool IsSchemeFirstChar(unsigned char c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); -} - -template -bool DoScheme(const CHAR* spec, - const Component& scheme, - CanonOutput* output, - Component* out_scheme) { - if (scheme.len <= 0) { - // Scheme is unspecified or empty, convert to empty by appending a colon. - *out_scheme = Component(output->length(), 0); - output->push_back(':'); - return true; - } - - // The output scheme starts from the current position. - out_scheme->begin = output->length(); - - // Danger: it's important that this code does not strip any characters; - // it only emits the canonical version (be it valid or escaped) for each - // of the input characters. Stripping would put it out of sync with - // FindAndCompareScheme, which could cause some security checks on - // schemes to be incorrect. - bool success = true; - int end = scheme.end(); - for (int i = scheme.begin; i < end; i++) { - UCHAR ch = static_cast(spec[i]); - char replacement = 0; - if (ch < 0x80) { - if (i == scheme.begin) { - // Need to do a special check for the first letter of the scheme. - if (IsSchemeFirstChar(static_cast(ch))) - replacement = kSchemeCanonical[ch]; - } else { - replacement = kSchemeCanonical[ch]; - } - } - - if (replacement) { - output->push_back(replacement); - } else if (ch == '%') { - // Canonicalizing the scheme multiple times should lead to the same - // result. Since invalid characters will be escaped, we need to preserve - // the percent to avoid multiple escaping. The scheme will be invalid. - success = false; - output->push_back('%'); - } else { - // Invalid character, store it but mark this scheme as invalid. - success = false; - - // This will escape the output and also handle encoding issues. - // Ignore the return value since we already failed. - AppendUTF8EscapedChar(spec, &i, end, output); - } - } - - // The output scheme ends with the the current position, before appending - // the colon. - out_scheme->len = output->length() - out_scheme->begin; - output->push_back(':'); - return success; -} - -// The username and password components reference ranges in the corresponding -// *_spec strings. Typically, these specs will be the same (we're -// canonicalizing a single source string), but may be different when -// replacing components. -template -bool DoUserInfo(const CHAR* username_spec, - const Component& username, - const CHAR* password_spec, - const Component& password, - CanonOutput* output, - Component* out_username, - Component* out_password) { - if (username.len <= 0 && password.len <= 0) { - // Common case: no user info. We strip empty username/passwords. - *out_username = Component(); - *out_password = Component(); - return true; - } - - // Write the username. - out_username->begin = output->length(); - if (username.len > 0) { - // This will escape characters not valid for the username. - AppendStringOfType(&username_spec[username.begin], username.len, - CHAR_USERINFO, output); - } - out_username->len = output->length() - out_username->begin; - - // When there is a password, we need the separator. Note that we strip - // empty but specified passwords. - if (password.len > 0) { - output->push_back(':'); - out_password->begin = output->length(); - AppendStringOfType(&password_spec[password.begin], password.len, - CHAR_USERINFO, output); - out_password->len = output->length() - out_password->begin; - } else { - *out_password = Component(); - } - - output->push_back('@'); - return true; -} - -// Helper functions for converting port integers to strings. -inline void WritePortInt(char* output, int output_len, int port) { - _itoa_s(port, output, output_len, 10); -} - -// This function will prepend the colon if there will be a port. -template -bool DoPort(const CHAR* spec, - const Component& port, - int default_port_for_scheme, - CanonOutput* output, - Component* out_port) { - int port_num = ParsePort(spec, port); - if (port_num == PORT_UNSPECIFIED || port_num == default_port_for_scheme) { - *out_port = Component(); - return true; // Leave port empty. - } - - if (port_num == PORT_INVALID) { - // Invalid port: We'll copy the text from the input so the user can see - // what the error was, and mark the URL as invalid by returning false. - output->push_back(':'); - out_port->begin = output->length(); - AppendInvalidNarrowString(spec, port.begin, port.end(), output); - out_port->len = output->length() - out_port->begin; - return false; - } - - // Convert port number back to an integer. Max port value is 5 digits, and - // the Parsed::ExtractPort will have made sure the integer is in range. - const int buf_size = 6; - char buf[buf_size]; - WritePortInt(buf, buf_size, port_num); - - // Append the port number to the output, preceded by a colon. - output->push_back(':'); - out_port->begin = output->length(); - for (int i = 0; i < buf_size && buf[i]; i++) - output->push_back(buf[i]); - - out_port->len = output->length() - out_port->begin; - return true; -} - -template -void DoCanonicalizeRef(const CHAR* spec, - const Component& ref, - CanonOutput* output, - Component* out_ref) { - if (ref.len < 0) { - // Common case of no ref. - *out_ref = Component(); - return; - } - - // Append the ref separator. Note that we need to do this even when the ref - // is empty but present. - output->push_back('#'); - out_ref->begin = output->length(); - - // Now iterate through all the characters, converting to UTF-8 and validating. - int end = ref.end(); - for (int i = ref.begin; i < end; i++) { - if (spec[i] == 0) { - // IE just strips NULLs, so we do too. - continue; - } else if (static_cast(spec[i]) < 0x20) { - // Unline IE seems to, we escape control characters. This will probably - // make the reference fragment unusable on a web page, but people - // shouldn't be using control characters in their anchor names. - AppendEscapedChar(static_cast(spec[i]), output); - } else if (static_cast(spec[i]) < 0x80) { - // Normal ASCII characters are just appended. - output->push_back(static_cast(spec[i])); - } else { - // Non-ASCII characters are appended unescaped, but only when they are - // valid. Invalid Unicode characters are replaced with the "invalid - // character" as IE seems to (ReadUTFChar puts the unicode replacement - // character in the output on failure for us). - unsigned code_point; - ReadUTFChar(spec, &i, end, &code_point); - AppendUTF8Value(code_point, output); - } - } - - out_ref->len = output->length() - out_ref->begin; -} - -} // namespace - -const char* RemoveURLWhitespace(const char* input, int input_len, - CanonOutputT* buffer, - int* output_len) { - return DoRemoveURLWhitespace(input, input_len, buffer, output_len); -} - -const base::char16* RemoveURLWhitespace(const base::char16* input, - int input_len, - CanonOutputT* buffer, - int* output_len) { - return DoRemoveURLWhitespace(input, input_len, buffer, output_len); -} - -char CanonicalSchemeChar(base::char16 ch) { - if (ch >= 0x80) - return 0; // Non-ASCII is not supported by schemes. - return kSchemeCanonical[ch]; -} - -bool CanonicalizeScheme(const char* spec, - const Component& scheme, - CanonOutput* output, - Component* out_scheme) { - return DoScheme(spec, scheme, output, out_scheme); -} - -bool CanonicalizeScheme(const base::char16* spec, - const Component& scheme, - CanonOutput* output, - Component* out_scheme) { - return DoScheme(spec, scheme, output, out_scheme); -} - -bool CanonicalizeUserInfo(const char* username_source, - const Component& username, - const char* password_source, - const Component& password, - CanonOutput* output, - Component* out_username, - Component* out_password) { - return DoUserInfo( - username_source, username, password_source, password, - output, out_username, out_password); -} - -bool CanonicalizeUserInfo(const base::char16* username_source, - const Component& username, - const base::char16* password_source, - const Component& password, - CanonOutput* output, - Component* out_username, - Component* out_password) { - return DoUserInfo( - username_source, username, password_source, password, - output, out_username, out_password); -} - -bool CanonicalizePort(const char* spec, - const Component& port, - int default_port_for_scheme, - CanonOutput* output, - Component* out_port) { - return DoPort(spec, port, - default_port_for_scheme, - output, out_port); -} - -bool CanonicalizePort(const base::char16* spec, - const Component& port, - int default_port_for_scheme, - CanonOutput* output, - Component* out_port) { - return DoPort(spec, port, default_port_for_scheme, - output, out_port); -} - -void CanonicalizeRef(const char* spec, - const Component& ref, - CanonOutput* output, - Component* out_ref) { - DoCanonicalizeRef(spec, ref, output, out_ref); -} - -void CanonicalizeRef(const base::char16* spec, - const Component& ref, - CanonOutput* output, - Component* out_ref) { - DoCanonicalizeRef(spec, ref, output, out_ref); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_filesystemurl.cc b/vendor/gurl/url/url_canon_filesystemurl.cc deleted file mode 100644 index 18e9055..0000000 --- a/vendor/gurl/url/url_canon_filesystemurl.cc +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Functions for canonicalizing "filesystem:file:" URLs. - -#include "url/url_canon.h" -#include "url/url_canon_internal.h" -#include "url/url_file.h" -#include "url/url_parse_internal.h" -#include "url/url_util.h" -#include "url/url_util_internal.h" - -namespace url { - -namespace { - -// We use the URLComponentSource for the outer URL, as it can have replacements, -// whereas the inner_url can't, so it uses spec. -template -bool DoCanonicalizeFileSystemURL(const CHAR* spec, - const URLComponentSource& source, - const Parsed& parsed, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* new_parsed) { - // filesystem only uses {scheme, path, query, ref} -- clear the rest. - new_parsed->username.reset(); - new_parsed->password.reset(); - new_parsed->host.reset(); - new_parsed->port.reset(); - - const Parsed* inner_parsed = parsed.inner_parsed(); - Parsed new_inner_parsed; - - // Scheme (known, so we don't bother running it through the more - // complicated scheme canonicalizer). - new_parsed->scheme.begin = output->length(); - output->Append("filesystem:", 11); - new_parsed->scheme.len = 10; - - if (!parsed.inner_parsed() || !parsed.inner_parsed()->scheme.is_valid()) - return false; - - bool success = true; - if (CompareSchemeComponent(spec, inner_parsed->scheme, url::kFileScheme)) { - new_inner_parsed.scheme.begin = output->length(); - output->Append("file://", 7); - new_inner_parsed.scheme.len = 4; - success &= CanonicalizePath(spec, inner_parsed->path, output, - &new_inner_parsed.path); - } else if (IsStandard(spec, inner_parsed->scheme)) { - success = CanonicalizeStandardURL(spec, parsed.inner_parsed()->Length(), - *parsed.inner_parsed(), charset_converter, - output, &new_inner_parsed); - } else { - // TODO(ericu): The URL is wrong, but should we try to output more of what - // we were given? Echoing back filesystem:mailto etc. doesn't seem all that - // useful. - return false; - } - // The filesystem type must be more than just a leading slash for validity. - success &= parsed.inner_parsed()->path.len > 1; - - success &= CanonicalizePath(source.path, parsed.path, output, - &new_parsed->path); - - // Ignore failures for query/ref since the URL can probably still be loaded. - CanonicalizeQuery(source.query, parsed.query, charset_converter, - output, &new_parsed->query); - CanonicalizeRef(source.ref, parsed.ref, output, &new_parsed->ref); - if (success) - new_parsed->set_inner_parsed(new_inner_parsed); - - return success; -} - -} // namespace - -bool CanonicalizeFileSystemURL(const char* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeFileSystemURL( - spec, URLComponentSource(spec), parsed, charset_converter, output, - new_parsed); -} - -bool CanonicalizeFileSystemURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeFileSystemURL( - spec, URLComponentSource(spec), parsed, charset_converter, - output, new_parsed); -} - -bool ReplaceFileSystemURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* new_parsed) { - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupOverrideComponents(base, replacements, &source, &parsed); - return DoCanonicalizeFileSystemURL( - base, source, parsed, charset_converter, output, new_parsed); -} - -bool ReplaceFileSystemURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* new_parsed) { - RawCanonOutput<1024> utf8; - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); - return DoCanonicalizeFileSystemURL( - base, source, parsed, charset_converter, output, new_parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_fileurl.cc b/vendor/gurl/url/url_canon_fileurl.cc deleted file mode 100644 index 6191f8f..0000000 --- a/vendor/gurl/url/url_canon_fileurl.cc +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Functions for canonicalizing "file:" URLs. - -#include "url/url_canon.h" -#include "url/url_canon_internal.h" -#include "url/url_file.h" -#include "url/url_parse_internal.h" - -namespace url { - -namespace { - -#ifdef WIN32 - -// Given a pointer into the spec, this copies and canonicalizes the drive -// letter and colon to the output, if one is found. If there is not a drive -// spec, it won't do anything. The index of the next character in the input -// spec is returned (after the colon when a drive spec is found, the begin -// offset if one is not). -template -int FileDoDriveSpec(const CHAR* spec, int begin, int end, - CanonOutput* output) { - // The path could be one of several things: /foo/bar, c:/foo/bar, /c:/foo, - // (with backslashes instead of slashes as well). - int num_slashes = CountConsecutiveSlashes(spec, begin, end); - int after_slashes = begin + num_slashes; - - if (!DoesBeginWindowsDriveSpec(spec, after_slashes, end)) - return begin; // Haven't consumed any characters - - // A drive spec is the start of a path, so we need to add a slash for the - // authority terminator (typically the third slash). - output->push_back('/'); - - // DoesBeginWindowsDriveSpec will ensure that the drive letter is valid - // and that it is followed by a colon/pipe. - - // Normalize Windows drive letters to uppercase - if (spec[after_slashes] >= 'a' && spec[after_slashes] <= 'z') - output->push_back(static_cast(spec[after_slashes] - 'a' + 'A')); - else - output->push_back(static_cast(spec[after_slashes])); - - // Normalize the character following it to a colon rather than pipe. - output->push_back(':'); - return after_slashes + 2; -} - -#endif // WIN32 - -template -bool DoFileCanonicalizePath(const CHAR* spec, - const Component& path, - CanonOutput* output, - Component* out_path) { - // Copies and normalizes the "c:" at the beginning, if present. - out_path->begin = output->length(); - int after_drive; -#ifdef WIN32 - after_drive = FileDoDriveSpec(spec, path.begin, path.end(), output); -#else - after_drive = path.begin; -#endif - - // Copies the rest of the path, starting from the slash following the - // drive colon (if any, Windows only), or the first slash of the path. - bool success = true; - if (after_drive < path.end()) { - // Use the regular path canonicalizer to canonicalize the rest of the - // path. Give it a fake output component to write into. DoCanonicalizeFile - // will compute the full path component. - Component sub_path = MakeRange(after_drive, path.end()); - Component fake_output_path; - success = CanonicalizePath(spec, sub_path, output, &fake_output_path); - } else { - // No input path, canonicalize to a slash. - output->push_back('/'); - } - - out_path->len = output->length() - out_path->begin; - return success; -} - -template -bool DoCanonicalizeFileURL(const URLComponentSource& source, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - // Things we don't set in file: URLs. - new_parsed->username = Component(); - new_parsed->password = Component(); - new_parsed->port = Component(); - - // Scheme (known, so we don't bother running it through the more - // complicated scheme canonicalizer). - new_parsed->scheme.begin = output->length(); - output->Append("file://", 7); - new_parsed->scheme.len = 4; - - // Append the host. For many file URLs, this will be empty. For UNC, this - // will be present. - // TODO(brettw) This doesn't do any checking for host name validity. We - // should probably handle validity checking of UNC hosts differently than - // for regular IP hosts. - bool success = CanonicalizeHost(source.host, parsed.host, - output, &new_parsed->host); - success &= DoFileCanonicalizePath(source.path, parsed.path, - output, &new_parsed->path); - CanonicalizeQuery(source.query, parsed.query, query_converter, - output, &new_parsed->query); - - // Ignore failure for refs since the URL can probably still be loaded. - CanonicalizeRef(source.ref, parsed.ref, output, &new_parsed->ref); - - return success; -} - -} // namespace - -bool CanonicalizeFileURL(const char* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeFileURL( - URLComponentSource(spec), parsed, query_converter, - output, new_parsed); -} - -bool CanonicalizeFileURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeFileURL( - URLComponentSource(spec), parsed, query_converter, - output, new_parsed); -} - -bool FileCanonicalizePath(const char* spec, - const Component& path, - CanonOutput* output, - Component* out_path) { - return DoFileCanonicalizePath(spec, path, - output, out_path); -} - -bool FileCanonicalizePath(const base::char16* spec, - const Component& path, - CanonOutput* output, - Component* out_path) { - return DoFileCanonicalizePath(spec, path, - output, out_path); -} - -bool ReplaceFileURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupOverrideComponents(base, replacements, &source, &parsed); - return DoCanonicalizeFileURL( - source, parsed, query_converter, output, new_parsed); -} - -bool ReplaceFileURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - RawCanonOutput<1024> utf8; - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); - return DoCanonicalizeFileURL( - source, parsed, query_converter, output, new_parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_host.cc b/vendor/gurl/url/url_canon_host.cc deleted file mode 100644 index 346108c..0000000 --- a/vendor/gurl/url/url_canon_host.cc +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -//#include "base/logging.h" -#include "url/url_canon.h" -#include "url/url_canon_internal.h" - -namespace url { - -namespace { - -// For reference, here's what IE supports: -// Key: 0 (disallowed: failure if present in the input) -// + (allowed either escaped or unescaped, and unmodified) -// U (allowed escaped or unescaped but always unescaped if present in -// escaped form) -// E (allowed escaped or unescaped but always escaped if present in -// unescaped form) -// % (only allowed escaped in the input, will be unmodified). -// I left blank alpha numeric characters. -// -// 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f -// ----------------------------------------------- -// 0 0 E E E E E E E E E E E E E E E -// 1 E E E E E E E E E E E E E E E E -// 2 E + E E + E + + + + + + + U U 0 -// 3 % % E + E 0 <-- Those are : ; < = > ? -// 4 % -// 5 U 0 U U U <-- Those are [ \ ] ^ _ -// 6 E <-- That's ` -// 7 E E E U E <-- Those are { | } ~ (UNPRINTABLE) -// -// NOTE: I didn't actually test all the control characters. Some may be -// disallowed in the input, but they are all accepted escaped except for 0. -// I also didn't test if characters affecting HTML parsing are allowed -// unescaped, e.g. (") or (#), which would indicate the beginning of the path. -// Surprisingly, space is accepted in the input and always escaped. - -// This table lists the canonical version of all characters we allow in the -// input, with 0 indicating it is disallowed. We use the magic kEscapedHostChar -// value to indicate that this character should be escaped. We are a little more -// restrictive than IE, but less restrictive than Firefox. -// -// Note that we disallow the % character. We will allow it when part of an -// escape sequence, of course, but this disallows "%25". Even though IE allows -// it, allowing it would put us in a funny state. If there was an invalid -// escape sequence like "%zz", we'll add "%25zz" to the output and fail. -// Allowing percents means we'll succeed a second time, so validity would change -// based on how many times you run the canonicalizer. We prefer to always report -// the same vailidity, so reject this. -const unsigned char kEsc = 0xff; -const unsigned char kHostCharLookup[0x80] = { -// 00-1f: all are invalid - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// ' ' ! " # $ % & ' ( ) * + , - . / - kEsc,kEsc,kEsc,kEsc,kEsc, 0, kEsc,kEsc,kEsc,kEsc,kEsc, '+',kEsc, '-', '.', 0, -// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', 0 ,kEsc,kEsc,kEsc, 0 , -// @ A B C D E F G H I J K L M N O - kEsc, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', -// P Q R S T U V W X Y Z [ \ ] ^ _ - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', 0 , ']', 0 , '_', -// ` a b c d e f g h i j k l m n o - kEsc, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', -// p q r s t u v w x y z { | } ~ - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',kEsc,kEsc,kEsc, 0 , 0 }; - -const int kTempHostBufferLen = 1024; -typedef RawCanonOutputT StackBuffer; -typedef RawCanonOutputT StackBufferW; - -// Scans a host name and fills in the output flags according to what we find. -// |has_non_ascii| will be true if there are any non-7-bit characters, and -// |has_escaped| will be true if there is a percent sign. -template -void ScanHostname(const CHAR* spec, - const Component& host, - bool* has_non_ascii, - bool* has_escaped) { - int end = host.end(); - *has_non_ascii = false; - *has_escaped = false; - for (int i = host.begin; i < end; i++) { - if (static_cast(spec[i]) >= 0x80) - *has_non_ascii = true; - else if (spec[i] == '%') - *has_escaped = true; - } -} - -// Canonicalizes a host name that is entirely 8-bit characters (even though -// the type holding them may be 16 bits. Escaped characters will be unescaped. -// Non-7-bit characters (for example, UTF-8) will be passed unchanged. -// -// The |*has_non_ascii| flag will be true if there are non-7-bit characters in -// the output. -// -// This function is used in two situations: -// -// * When the caller knows there is no non-ASCII or percent escaped -// characters. This is what DoHost does. The result will be a completely -// canonicalized host since we know nothing weird can happen (escaped -// characters could be unescaped to non-7-bit, so they have to be treated -// with suspicion at this point). It does not use the |has_non_ascii| flag. -// -// * When the caller has an 8-bit string that may need unescaping. -// DoComplexHost calls us this situation to do unescaping and validation. -// After this, it may do other IDN operations depending on the value of the -// |*has_non_ascii| flag. -// -// The return value indicates if the output is a potentially valid host name. -template -bool DoSimpleHost(const INCHAR* host, - int host_len, - CanonOutputT* output, - bool* has_non_ascii) { - *has_non_ascii = false; - - bool success = true; - for (int i = 0; i < host_len; ++i) { - unsigned int source = host[i]; - if (source == '%') { - // Unescape first, if possible. - // Source will be used only if decode operation was successful. - if (!DecodeEscaped(host, &i, host_len, - reinterpret_cast(&source))) { - // Invalid escaped character. There is nothing that can make this - // host valid. We append an escaped percent so the URL looks reasonable - // and mark as failed. - AppendEscapedChar('%', output); - success = false; - continue; - } - } - - if (source < 0x80) { - // We have ASCII input, we can use our lookup table. - unsigned char replacement = kHostCharLookup[source]; - if (!replacement) { - // Invalid character, add it as percent-escaped and mark as failed. - AppendEscapedChar(source, output); - success = false; - } else if (replacement == kEsc) { - // This character is valid but should be escaped. - AppendEscapedChar(source, output); - } else { - // Common case, the given character is valid in a hostname, the lookup - // table tells us the canonical representation of that character (lower - // cased). - output->push_back(replacement); - } - } else { - // It's a non-ascii char. Just push it to the output. - // In case where we have char16 input, and char output it's safe to - // cast char16->char only if input string was converted to ASCII. - output->push_back(static_cast(source)); - *has_non_ascii = true; - } - } - - return success; -} - -// Canonicalizes a host that requires IDN conversion. Returns true on success -bool DoIDNHost(const base::char16* src, int src_len, CanonOutput* output) { - // We need to escape URL before doing IDN conversion, since punicode strings - // cannot be escaped after they are created. - RawCanonOutputW url_escaped_host; - bool has_non_ascii; - DoSimpleHost(src, src_len, &url_escaped_host, &has_non_ascii); - - StackBufferW wide_output; - /*if (!IDNToASCII(url_escaped_host.data(), - url_escaped_host.length(), - &wide_output)) { - // Some error, give up. This will write some reasonable looking - // representation of the string to the output. - AppendInvalidNarrowString(src, 0, src_len, output); - return false; -}*/ - - // Now we check the ASCII output like a normal host. It will also handle - // unescaping. Although we unescaped everything before this function call, if - // somebody does %00 as fullwidth, ICU will convert this to ASCII. - bool success = DoSimpleHost(wide_output.data(), - wide_output.length(), - output, &has_non_ascii); - //DCHECK(!has_non_ascii); - return success; -} - -// 8-bit convert host to its ASCII version: this converts the UTF-8 input to -// UTF-16. The has_escaped flag should be set if the input string requires -// unescaping. -bool DoComplexHost(const char* host, int host_len, - bool has_non_ascii, bool has_escaped, CanonOutput* output) { - // Save the current position in the output. We may write stuff and rewind it - // below, so we need to know where to rewind to. - int begin_length = output->length(); - - // Points to the UTF-8 data we want to convert. This will either be the - // input or the unescaped version written to |*output| if necessary. - const char* utf8_source; - int utf8_source_len; - if (has_escaped) { - // Unescape before converting to UTF-16 for IDN. We write this into the - // output because it most likely does not require IDNization, and we can - // save another huge stack buffer. It will be replaced below if it requires - // IDN. This will also update our non-ASCII flag so we know whether the - // unescaped input requires IDN. - if (!DoSimpleHost(host, host_len, output, &has_non_ascii)) { - // Error with some escape sequence. We'll call the current output - // complete. DoSimpleHost will have written some "reasonable" output. - return false; - } - - // Unescaping may have left us with ASCII input, in which case the - // unescaped version we wrote to output is complete. - if (!has_non_ascii) { - return true; - } - - // Save the pointer into the data was just converted (it may be appended to - // other data in the output buffer). - utf8_source = &output->data()[begin_length]; - utf8_source_len = output->length() - begin_length; - } else { - // We don't need to unescape, use input for IDNization later. (We know the - // input has non-ASCII, or the simple version would have been called - // instead of us.) - utf8_source = host; - utf8_source_len = host_len; - } - - // Non-ASCII input requires IDN, convert to UTF-16 and do the IDN conversion. - // Above, we may have used the output to write the unescaped values to, so - // we have to rewind it to where we started after we convert it to UTF-16. - StackBufferW utf16; - if (!ConvertUTF8ToUTF16(utf8_source, utf8_source_len, &utf16)) { - // In this error case, the input may or may not be the output. - StackBuffer utf8; - for (int i = 0; i < utf8_source_len; i++) - utf8.push_back(utf8_source[i]); - output->set_length(begin_length); - AppendInvalidNarrowString(utf8.data(), 0, utf8.length(), output); - return false; - } - output->set_length(begin_length); - - // This will call DoSimpleHost which will do normal ASCII canonicalization - // and also check for IP addresses in the outpt. - return DoIDNHost(utf16.data(), utf16.length(), output); -} - -// UTF-16 convert host to its ASCII version. The set up is already ready for -// the backend, so we just pass through. The has_escaped flag should be set if -// the input string requires unescaping. -bool DoComplexHost(const base::char16* host, int host_len, - bool has_non_ascii, bool has_escaped, CanonOutput* output) { - if (has_escaped) { - // Yikes, we have escaped characters with wide input. The escaped - // characters should be interpreted as UTF-8. To solve this problem, - // we convert to UTF-8, unescape, then convert back to UTF-16 for IDN. - // - // We don't bother to optimize the conversion in the ASCII case (which - // *could* just be a copy) and use the UTF-8 path, because it should be - // very rare that host names have escaped characters, and it is relatively - // fast to do the conversion anyway. - StackBuffer utf8; - if (!ConvertUTF16ToUTF8(host, host_len, &utf8)) { - AppendInvalidNarrowString(host, 0, host_len, output); - return false; - } - - // Once we convert to UTF-8, we can use the 8-bit version of the complex - // host handling code above. - return DoComplexHost(utf8.data(), utf8.length(), has_non_ascii, - has_escaped, output); - } - - // No unescaping necessary, we can safely pass the input to ICU. This - // function will only get called if we either have escaped or non-ascii - // input, so it's safe to just use ICU now. Even if the input is ASCII, - // this function will do the right thing (just slower than we could). - return DoIDNHost(host, host_len, output); -} - -template -void DoHost(const CHAR* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info) { - if (host.len <= 0) { - // Empty hosts don't need anything. - host_info->family = CanonHostInfo::NEUTRAL; - host_info->out_host = Component(); - return; - } - - bool has_non_ascii, has_escaped; - ScanHostname(spec, host, &has_non_ascii, &has_escaped); - - // Keep track of output's initial length, so we can rewind later. - const int output_begin = output->length(); - - bool success; - if (!has_non_ascii && !has_escaped) { - success = DoSimpleHost(&spec[host.begin], host.len, - output, &has_non_ascii); - //DCHECK(!has_non_ascii); - } else { - success = DoComplexHost(&spec[host.begin], host.len, - has_non_ascii, has_escaped, output); - } - - if (!success) { - // Canonicalization failed. Set BROKEN to notify the caller. - host_info->family = CanonHostInfo::BROKEN; - } else { - // After all the other canonicalization, check if we ended up with an IP - // address. IP addresses are small, so writing into this temporary buffer - // should not cause an allocation. - RawCanonOutput<64> canon_ip; - CanonicalizeIPAddress(output->data(), - MakeRange(output_begin, output->length()), - &canon_ip, host_info); - - // If we got an IPv4/IPv6 address, copy the canonical form back to the - // real buffer. Otherwise, it's a hostname or broken IP, in which case - // we just leave it in place. - if (host_info->IsIPAddress()) { - output->set_length(output_begin); - output->Append(canon_ip.data(), canon_ip.length()); - } - } - - host_info->out_host = MakeRange(output_begin, output->length()); -} - -} // namespace - -bool CanonicalizeHost(const char* spec, - const Component& host, - CanonOutput* output, - Component* out_host) { - CanonHostInfo host_info; - DoHost(spec, host, output, &host_info); - *out_host = host_info.out_host; - return (host_info.family != CanonHostInfo::BROKEN); -} - -bool CanonicalizeHost(const base::char16* spec, - const Component& host, - CanonOutput* output, - Component* out_host) { - CanonHostInfo host_info; - DoHost(spec, host, output, &host_info); - *out_host = host_info.out_host; - return (host_info.family != CanonHostInfo::BROKEN); -} - -void CanonicalizeHostVerbose(const char* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info) { - DoHost(spec, host, output, host_info); -} - -void CanonicalizeHostVerbose(const base::char16* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info) { - DoHost(spec, host, output, host_info); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_internal.cc b/vendor/gurl/url/url_canon_internal.cc deleted file mode 100644 index 164c6cf..0000000 --- a/vendor/gurl/url/url_canon_internal.cc +++ /dev/null @@ -1,432 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "url/url_canon_internal.h" - -#include -#include - -#include -#include - -#include "base/strings/utf_string_conversion_utils.h" - -namespace url { - -namespace { - -template -void DoAppendStringOfType(const CHAR* source, int length, - SharedCharTypes type, - CanonOutput* output) { - for (int i = 0; i < length; i++) { - if (static_cast(source[i]) >= 0x80) { - // ReadChar will fill the code point with kUnicodeReplacementCharacter - // when the input is invalid, which is what we want. - unsigned code_point; - ReadUTFChar(source, &i, length, &code_point); - AppendUTF8EscapedValue(code_point, output); - } else { - // Just append the 7-bit character, possibly escaping it. - unsigned char uch = static_cast(source[i]); - if (!IsCharOfType(uch, type)) - AppendEscapedChar(uch, output); - else - output->push_back(uch); - } - } -} - -// This function assumes the input values are all contained in 8-bit, -// although it allows any type. Returns true if input is valid, false if not. -template -void DoAppendInvalidNarrowString(const CHAR* spec, int begin, int end, - CanonOutput* output) { - for (int i = begin; i < end; i++) { - UCHAR uch = static_cast(spec[i]); - if (uch >= 0x80) { - // Handle UTF-8/16 encodings. This call will correctly handle the error - // case by appending the invalid character. - AppendUTF8EscapedChar(spec, &i, end, output); - } else if (uch <= ' ' || uch == 0x7f) { - // This function is for error handling, so we escape all control - // characters and spaces, but not anything else since we lack - // context to do something more specific. - AppendEscapedChar(static_cast(uch), output); - } else { - output->push_back(static_cast(uch)); - } - } -} - -// Overrides one component, see the Replacements structure for -// what the various combionations of source pointer and component mean. -void DoOverrideComponent(const char* override_source, - const Component& override_component, - const char** dest, - Component* dest_component) { - if (override_source) { - *dest = override_source; - *dest_component = override_component; - } -} - -// Similar to DoOverrideComponent except that it takes a UTF-16 input and does -// not actually set the output character pointer. -// -// The input is converted to UTF-8 at the end of the given buffer as a temporary -// holding place. The component identifying the portion of the buffer used in -// the |utf8_buffer| will be specified in |*dest_component|. -// -// This will not actually set any |dest| pointer like DoOverrideComponent -// does because all of the pointers will point into the |utf8_buffer|, which -// may get resized while we're overriding a subsequent component. Instead, the -// caller should use the beginning of the |utf8_buffer| as the string pointer -// for all components once all overrides have been prepared. -bool PrepareUTF16OverrideComponent(const base::char16* override_source, - const Component& override_component, - CanonOutput* utf8_buffer, - Component* dest_component) { - bool success = true; - if (override_source) { - if (!override_component.is_valid()) { - // Non-"valid" component (means delete), so we need to preserve that. - *dest_component = Component(); - } else { - // Convert to UTF-8. - dest_component->begin = utf8_buffer->length(); - success = ConvertUTF16ToUTF8(&override_source[override_component.begin], - override_component.len, utf8_buffer); - dest_component->len = utf8_buffer->length() - dest_component->begin; - } - } - return success; -} - -} // namespace - -// See the header file for this array's declaration. -const unsigned char kSharedCharTypeTable[0x100] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 - 0x0f - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 - 0x1f - 0, // 0x20 ' ' (escape spaces in queries) - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x21 ! - 0, // 0x22 " - 0, // 0x23 # (invalid in query since it marks the ref) - CHAR_QUERY | CHAR_USERINFO, // 0x24 $ - CHAR_QUERY | CHAR_USERINFO, // 0x25 % - CHAR_QUERY | CHAR_USERINFO, // 0x26 & - 0, // 0x27 ' (Try to prevent XSS.) - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x28 ( - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x29 ) - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x2a * - CHAR_QUERY | CHAR_USERINFO, // 0x2b + - CHAR_QUERY | CHAR_USERINFO, // 0x2c , - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x2d - - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_COMPONENT, // 0x2e . - CHAR_QUERY, // 0x2f / - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x30 0 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x31 1 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x32 2 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x33 3 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x34 4 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x35 5 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x36 6 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_OCT | CHAR_COMPONENT, // 0x37 7 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_COMPONENT, // 0x38 8 - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_DEC | CHAR_COMPONENT, // 0x39 9 - CHAR_QUERY, // 0x3a : - CHAR_QUERY, // 0x3b ; - 0, // 0x3c < (Try to prevent certain types of XSS.) - CHAR_QUERY, // 0x3d = - 0, // 0x3e > (Try to prevent certain types of XSS.) - CHAR_QUERY, // 0x3f ? - CHAR_QUERY, // 0x40 @ - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x41 A - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x42 B - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x43 C - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x44 D - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x45 E - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x46 F - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x47 G - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x48 H - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x49 I - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x4a J - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x4b K - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x4c L - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x4d M - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x4e N - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x4f O - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x50 P - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x51 Q - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x52 R - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x53 S - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x54 T - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x55 U - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x56 V - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x57 W - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_COMPONENT, // 0x58 X - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x59 Y - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x5a Z - CHAR_QUERY, // 0x5b [ - CHAR_QUERY, // 0x5c '\' - CHAR_QUERY, // 0x5d ] - CHAR_QUERY, // 0x5e ^ - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x5f _ - CHAR_QUERY, // 0x60 ` - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x61 a - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x62 b - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x63 c - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x64 d - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x65 e - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_HEX | CHAR_COMPONENT, // 0x66 f - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x67 g - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x68 h - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x69 i - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x6a j - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x6b k - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x6c l - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x6d m - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x6e n - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x6f o - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x70 p - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x71 q - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x72 r - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x73 s - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x74 t - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x75 u - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x76 v - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x77 w - CHAR_QUERY | CHAR_USERINFO | CHAR_IPV4 | CHAR_COMPONENT, // 0x78 x - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x79 y - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x7a z - CHAR_QUERY, // 0x7b { - CHAR_QUERY, // 0x7c | - CHAR_QUERY, // 0x7d } - CHAR_QUERY | CHAR_USERINFO | CHAR_COMPONENT, // 0x7e ~ - 0, // 0x7f - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 - 0x8f - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90 - 0x9f - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 - 0xaf - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 - 0xbf - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0 - 0xcf - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0 - 0xdf - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 - 0xef - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0 - 0xff -}; - -const char kHexCharLookup[0x10] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', -}; - -const char kCharToHexLookup[8] = { - 0, // 0x00 - 0x1f - '0', // 0x20 - 0x3f: digits 0 - 9 are 0x30 - 0x39 - 'A' - 10, // 0x40 - 0x5f: letters A - F are 0x41 - 0x46 - 'a' - 10, // 0x60 - 0x7f: letters a - f are 0x61 - 0x66 - 0, // 0x80 - 0x9F - 0, // 0xA0 - 0xBF - 0, // 0xC0 - 0xDF - 0, // 0xE0 - 0xFF -}; - -const base::char16 kUnicodeReplacementCharacter = 0xfffd; - -void AppendStringOfType(const char* source, int length, - SharedCharTypes type, - CanonOutput* output) { - DoAppendStringOfType(source, length, type, output); -} - -void AppendStringOfType(const base::char16* source, int length, - SharedCharTypes type, - CanonOutput* output) { - DoAppendStringOfType( - source, length, type, output); -} - -bool ReadUTFChar(const char* str, int* begin, int length, - unsigned* code_point_out) { - // This depends on ints and int32s being the same thing. If they're not, it - // will fail to compile. - // TODO(mmenke): This should probably be fixed. - if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) || - !base::IsValidCharacter(*code_point_out)) { - *code_point_out = kUnicodeReplacementCharacter; - return false; - } - return true; -} - -bool ReadUTFChar(const base::char16* str, int* begin, int length, - unsigned* code_point_out) { - // This depends on ints and int32s being the same thing. If they're not, it - // will fail to compile. - // TODO(mmenke): This should probably be fixed. - if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) || - !base::IsValidCharacter(*code_point_out)) { - *code_point_out = kUnicodeReplacementCharacter; - return false; - } - return true; -} - -void AppendInvalidNarrowString(const char* spec, int begin, int end, - CanonOutput* output) { - DoAppendInvalidNarrowString(spec, begin, end, output); -} - -void AppendInvalidNarrowString(const base::char16* spec, int begin, int end, - CanonOutput* output) { - DoAppendInvalidNarrowString( - spec, begin, end, output); -} - -bool ConvertUTF16ToUTF8(const base::char16* input, int input_len, - CanonOutput* output) { - bool success = true; - for (int i = 0; i < input_len; i++) { - unsigned code_point; - success &= ReadUTFChar(input, &i, input_len, &code_point); - AppendUTF8Value(code_point, output); - } - return success; -} - -bool ConvertUTF8ToUTF16(const char* input, int input_len, - CanonOutputT* output) { - bool success = true; - for (int i = 0; i < input_len; i++) { - unsigned code_point; - success &= ReadUTFChar(input, &i, input_len, &code_point); - AppendUTF16Value(code_point, output); - } - return success; -} - -void SetupOverrideComponents(const char* base, - const Replacements& repl, - URLComponentSource* source, - Parsed* parsed) { - // Get the source and parsed structures of the things we are replacing. - const URLComponentSource& repl_source = repl.sources(); - const Parsed& repl_parsed = repl.components(); - - DoOverrideComponent(repl_source.scheme, repl_parsed.scheme, - &source->scheme, &parsed->scheme); - DoOverrideComponent(repl_source.username, repl_parsed.username, - &source->username, &parsed->username); - DoOverrideComponent(repl_source.password, repl_parsed.password, - &source->password, &parsed->password); - - // Our host should be empty if not present, so override the default setup. - DoOverrideComponent(repl_source.host, repl_parsed.host, - &source->host, &parsed->host); - if (parsed->host.len == -1) - parsed->host.len = 0; - - DoOverrideComponent(repl_source.port, repl_parsed.port, - &source->port, &parsed->port); - DoOverrideComponent(repl_source.path, repl_parsed.path, - &source->path, &parsed->path); - DoOverrideComponent(repl_source.query, repl_parsed.query, - &source->query, &parsed->query); - DoOverrideComponent(repl_source.ref, repl_parsed.ref, - &source->ref, &parsed->ref); -} - -bool SetupUTF16OverrideComponents(const char* base, - const Replacements& repl, - CanonOutput* utf8_buffer, - URLComponentSource* source, - Parsed* parsed) { - bool success = true; - - // Get the source and parsed structures of the things we are replacing. - const URLComponentSource& repl_source = repl.sources(); - const Parsed& repl_parsed = repl.components(); - - success &= PrepareUTF16OverrideComponent( - repl_source.scheme, repl_parsed.scheme, - utf8_buffer, &parsed->scheme); - success &= PrepareUTF16OverrideComponent( - repl_source.username, repl_parsed.username, - utf8_buffer, &parsed->username); - success &= PrepareUTF16OverrideComponent( - repl_source.password, repl_parsed.password, - utf8_buffer, &parsed->password); - success &= PrepareUTF16OverrideComponent( - repl_source.host, repl_parsed.host, - utf8_buffer, &parsed->host); - success &= PrepareUTF16OverrideComponent( - repl_source.port, repl_parsed.port, - utf8_buffer, &parsed->port); - success &= PrepareUTF16OverrideComponent( - repl_source.path, repl_parsed.path, - utf8_buffer, &parsed->path); - success &= PrepareUTF16OverrideComponent( - repl_source.query, repl_parsed.query, - utf8_buffer, &parsed->query); - success &= PrepareUTF16OverrideComponent( - repl_source.ref, repl_parsed.ref, - utf8_buffer, &parsed->ref); - - // PrepareUTF16OverrideComponent will not have set the data pointer since the - // buffer could be resized, invalidating the pointers. We set the data - // pointers for affected components now that the buffer is finalized. - if (repl_source.scheme) source->scheme = utf8_buffer->data(); - if (repl_source.username) source->username = utf8_buffer->data(); - if (repl_source.password) source->password = utf8_buffer->data(); - if (repl_source.host) source->host = utf8_buffer->data(); - if (repl_source.port) source->port = utf8_buffer->data(); - if (repl_source.path) source->path = utf8_buffer->data(); - if (repl_source.query) source->query = utf8_buffer->data(); - if (repl_source.ref) source->ref = utf8_buffer->data(); - - return success; -} - -#ifndef WIN32 - -int _itoa_s(int value, char* buffer, size_t size_in_chars, int radix) { - const char* format_str; - if (radix == 10) - format_str = "%d"; - else if (radix == 16) - format_str = "%x"; - else - return EINVAL; - - int written = snprintf(buffer, size_in_chars, format_str, value); - if (static_cast(written) >= size_in_chars) { - // Output was truncated, or written was negative. - return EINVAL; - } - return 0; -} - -int _itow_s(int value, base::char16* buffer, size_t size_in_chars, int radix) { - if (radix != 10) - return EINVAL; - - // No more than 12 characters will be required for a 32-bit integer. - // Add an extra byte for the terminating null. - char temp[13]; - int written = snprintf(temp, sizeof(temp), "%d", value); - if (static_cast(written) >= size_in_chars) { - // Output was truncated, or written was negative. - return EINVAL; - } - - for (int i = 0; i < written; ++i) { - buffer[i] = static_cast(temp[i]); - } - buffer[written] = '\0'; - return 0; -} - -#endif // !WIN32 - -} // namespace url diff --git a/vendor/gurl/url/url_canon_internal.h b/vendor/gurl/url/url_canon_internal.h deleted file mode 100644 index 9d580ac..0000000 --- a/vendor/gurl/url/url_canon_internal.h +++ /dev/null @@ -1,433 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_CANON_INTERNAL_H_ -#define URL_URL_CANON_INTERNAL_H_ - -// This file is intended to be included in another C++ file where the character -// types are defined. This allows us to write mostly generic code, but not have -// template bloat because everything is inlined when anybody calls any of our -// functions. - -#include - -//#include "base/logging.h" -#include "url/url_canon.h" - -namespace url { - -// Character type handling ----------------------------------------------------- - -// Bits that identify different character types. These types identify different -// bits that are set for each 8-bit character in the kSharedCharTypeTable. -enum SharedCharTypes { - // Characters that do not require escaping in queries. Characters that do - // not have this flag will be escaped; see url_canon_query.cc - CHAR_QUERY = 1, - - // Valid in the username/password field. - CHAR_USERINFO = 2, - - // Valid in a IPv4 address (digits plus dot and 'x' for hex). - CHAR_IPV4 = 4, - - // Valid in an ASCII-representation of a hex digit (as in %-escaped). - CHAR_HEX = 8, - - // Valid in an ASCII-representation of a decimal digit. - CHAR_DEC = 16, - - // Valid in an ASCII-representation of an octal digit. - CHAR_OCT = 32, - - // Characters that do not require escaping in encodeURIComponent. Characters - // that do not have this flag will be escaped; see url_util.cc. - CHAR_COMPONENT = 64, -}; - -// This table contains the flags in SharedCharTypes for each 8-bit character. -// Some canonicalization functions have their own specialized lookup table. -// For those with simple requirements, we have collected the flags in one -// place so there are fewer lookup tables to load into the CPU cache. -// -// Using an unsigned char type has a small but measurable performance benefit -// over using a 32-bit number. -extern const unsigned char kSharedCharTypeTable[0x100]; - -// More readable wrappers around the character type lookup table. -inline bool IsCharOfType(unsigned char c, SharedCharTypes type) { - return !!(kSharedCharTypeTable[c] & type); -} -inline bool IsQueryChar(unsigned char c) { - return IsCharOfType(c, CHAR_QUERY); -} -inline bool IsIPv4Char(unsigned char c) { - return IsCharOfType(c, CHAR_IPV4); -} -inline bool IsHexChar(unsigned char c) { - return IsCharOfType(c, CHAR_HEX); -} -inline bool IsComponentChar(unsigned char c) { - return IsCharOfType(c, CHAR_COMPONENT); -} - -// Appends the given string to the output, escaping characters that do not -// match the given |type| in SharedCharTypes. -void AppendStringOfType(const char* source, int length, - SharedCharTypes type, - CanonOutput* output); -void AppendStringOfType(const base::char16* source, int length, - SharedCharTypes type, - CanonOutput* output); - -// Maps the hex numerical values 0x0 to 0xf to the corresponding ASCII digit -// that will be used to represent it. -URL_EXPORT extern const char kHexCharLookup[0x10]; - -// This lookup table allows fast conversion between ASCII hex letters and their -// corresponding numerical value. The 8-bit range is divided up into 8 -// regions of 0x20 characters each. Each of the three character types (numbers, -// uppercase, lowercase) falls into different regions of this range. The table -// contains the amount to subtract from characters in that range to get at -// the corresponding numerical value. -// -// See HexDigitToValue for the lookup. -extern const char kCharToHexLookup[8]; - -// Assumes the input is a valid hex digit! Call IsHexChar before using this. -inline unsigned char HexCharToValue(unsigned char c) { - return c - kCharToHexLookup[c / 0x20]; -} - -// Indicates if the given character is a dot or dot equivalent, returning the -// number of characters taken by it. This will be one for a literal dot, 3 for -// an escaped dot. If the character is not a dot, this will return 0. -template -inline int IsDot(const CHAR* spec, int offset, int end) { - if (spec[offset] == '.') { - return 1; - } else if (spec[offset] == '%' && offset + 3 <= end && - spec[offset + 1] == '2' && - (spec[offset + 2] == 'e' || spec[offset + 2] == 'E')) { - // Found "%2e" - return 3; - } - return 0; -} - -// Returns the canonicalized version of the input character according to scheme -// rules. This is implemented alongside the scheme canonicalizer, and is -// required for relative URL resolving to test for scheme equality. -// -// Returns 0 if the input character is not a valid scheme character. -char CanonicalSchemeChar(base::char16 ch); - -// Write a single character, escaped, to the output. This always escapes: it -// does no checking that thee character requires escaping. -// Escaping makes sense only 8 bit chars, so code works in all cases of -// input parameters (8/16bit). -template -inline void AppendEscapedChar(UINCHAR ch, - CanonOutputT* output) { - output->push_back('%'); - output->push_back(kHexCharLookup[(ch >> 4) & 0xf]); - output->push_back(kHexCharLookup[ch & 0xf]); -} - -// The character we'll substitute for undecodable or invalid characters. -extern const base::char16 kUnicodeReplacementCharacter; - -// UTF-8 functions ------------------------------------------------------------ - -// Reads one character in UTF-8 starting at |*begin| in |str| and places -// the decoded value into |*code_point|. If the character is valid, we will -// return true. If invalid, we'll return false and put the -// kUnicodeReplacementCharacter into |*code_point|. -// -// |*begin| will be updated to point to the last character consumed so it -// can be incremented in a loop and will be ready for the next character. -// (for a single-byte ASCII character, it will not be changed). -URL_EXPORT bool ReadUTFChar(const char* str, int* begin, int length, - unsigned* code_point_out); - -// Generic To-UTF-8 converter. This will call the given append method for each -// character that should be appended, with the given output method. Wrappers -// are provided below for escaped and non-escaped versions of this. -// -// The char_value must have already been checked that it's a valid Unicode -// character. -template -inline void DoAppendUTF8(unsigned char_value, Output* output) { - if (char_value <= 0x7f) { - Appender(static_cast(char_value), output); - } else if (char_value <= 0x7ff) { - // 110xxxxx 10xxxxxx - Appender(static_cast(0xC0 | (char_value >> 6)), - output); - Appender(static_cast(0x80 | (char_value & 0x3f)), - output); - } else if (char_value <= 0xffff) { - // 1110xxxx 10xxxxxx 10xxxxxx - Appender(static_cast(0xe0 | (char_value >> 12)), - output); - Appender(static_cast(0x80 | ((char_value >> 6) & 0x3f)), - output); - Appender(static_cast(0x80 | (char_value & 0x3f)), - output); - } else if (char_value <= 0x10FFFF) { // Max Unicode code point. - // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - Appender(static_cast(0xf0 | (char_value >> 18)), - output); - Appender(static_cast(0x80 | ((char_value >> 12) & 0x3f)), - output); - Appender(static_cast(0x80 | ((char_value >> 6) & 0x3f)), - output); - Appender(static_cast(0x80 | (char_value & 0x3f)), - output); - } else { - // Invalid UTF-8 character (>20 bits). - //NOTREACHED(); - } -} - -// Helper used by AppendUTF8Value below. We use an unsigned parameter so there -// are no funny sign problems with the input, but then have to convert it to -// a regular char for appending. -inline void AppendCharToOutput(unsigned char ch, CanonOutput* output) { - output->push_back(static_cast(ch)); -} - -// Writes the given character to the output as UTF-8. This does NO checking -// of the validity of the Unicode characters; the caller should ensure that -// the value it is appending is valid to append. -inline void AppendUTF8Value(unsigned char_value, CanonOutput* output) { - DoAppendUTF8(char_value, output); -} - -// Writes the given character to the output as UTF-8, escaping ALL -// characters (even when they are ASCII). This does NO checking of the -// validity of the Unicode characters; the caller should ensure that the value -// it is appending is valid to append. -inline void AppendUTF8EscapedValue(unsigned char_value, CanonOutput* output) { - DoAppendUTF8(char_value, output); -} - -// UTF-16 functions ----------------------------------------------------------- - -// Reads one character in UTF-16 starting at |*begin| in |str| and places -// the decoded value into |*code_point|. If the character is valid, we will -// return true. If invalid, we'll return false and put the -// kUnicodeReplacementCharacter into |*code_point|. -// -// |*begin| will be updated to point to the last character consumed so it -// can be incremented in a loop and will be ready for the next character. -// (for a single-16-bit-word character, it will not be changed). -URL_EXPORT bool ReadUTFChar(const base::char16* str, int* begin, int length, - unsigned* code_point_out); - -// Equivalent to U16_APPEND_UNSAFE in ICU but uses our output method. -inline void AppendUTF16Value(unsigned code_point, - CanonOutputT* output) { - if (code_point > 0xffff) { - output->push_back(static_cast((code_point >> 10) + 0xd7c0)); - output->push_back(static_cast((code_point & 0x3ff) | 0xdc00)); - } else { - output->push_back(static_cast(code_point)); - } -} - -// Escaping functions --------------------------------------------------------- - -// Writes the given character to the output as UTF-8, escaped. Call this -// function only when the input is wide. Returns true on success. Failure -// means there was some problem with the encoding, we'll still try to -// update the |*begin| pointer and add a placeholder character to the -// output so processing can continue. -// -// We will append the character starting at ch[begin] with the buffer ch -// being |length|. |*begin| will be updated to point to the last character -// consumed (we may consume more than one for UTF-16) so that if called in -// a loop, incrementing the pointer will move to the next character. -// -// Every single output character will be escaped. This means that if you -// give it an ASCII character as input, it will be escaped. Some code uses -// this when it knows that a character is invalid according to its rules -// for validity. If you don't want escaping for ASCII characters, you will -// have to filter them out prior to calling this function. -// -// Assumes that ch[begin] is within range in the array, but does not assume -// that any following characters are. -inline bool AppendUTF8EscapedChar(const base::char16* str, int* begin, - int length, CanonOutput* output) { - // UTF-16 input. ReadUTFChar will handle invalid characters for us and give - // us the kUnicodeReplacementCharacter, so we don't have to do special - // checking after failure, just pass through the failure to the caller. - unsigned char_value; - bool success = ReadUTFChar(str, begin, length, &char_value); - AppendUTF8EscapedValue(char_value, output); - return success; -} - -// Handles UTF-8 input. See the wide version above for usage. -inline bool AppendUTF8EscapedChar(const char* str, int* begin, int length, - CanonOutput* output) { - // ReadUTF8Char will handle invalid characters for us and give us the - // kUnicodeReplacementCharacter, so we don't have to do special checking - // after failure, just pass through the failure to the caller. - unsigned ch; - bool success = ReadUTFChar(str, begin, length, &ch); - AppendUTF8EscapedValue(ch, output); - return success; -} - -// Given a '%' character at |*begin| in the string |spec|, this will decode -// the escaped value and put it into |*unescaped_value| on success (returns -// true). On failure, this will return false, and will not write into -// |*unescaped_value|. -// -// |*begin| will be updated to point to the last character of the escape -// sequence so that when called with the index of a for loop, the next time -// through it will point to the next character to be considered. On failure, -// |*begin| will be unchanged. -inline bool Is8BitChar(char c) { - return true; // this case is specialized to avoid a warning -} -inline bool Is8BitChar(base::char16 c) { - return c <= 255; -} - -template -inline bool DecodeEscaped(const CHAR* spec, int* begin, int end, - unsigned char* unescaped_value) { - if (*begin + 3 > end || - !Is8BitChar(spec[*begin + 1]) || !Is8BitChar(spec[*begin + 2])) { - // Invalid escape sequence because there's not enough room, or the - // digits are not ASCII. - return false; - } - - unsigned char first = static_cast(spec[*begin + 1]); - unsigned char second = static_cast(spec[*begin + 2]); - if (!IsHexChar(first) || !IsHexChar(second)) { - // Invalid hex digits, fail. - return false; - } - - // Valid escape sequence. - *unescaped_value = (HexCharToValue(first) << 4) + HexCharToValue(second); - *begin += 2; - return true; -} - -// Appends the given substring to the output, escaping "some" characters that -// it feels may not be safe. It assumes the input values are all contained in -// 8-bit although it allows any type. -// -// This is used in error cases to append invalid output so that it looks -// approximately correct. Non-error cases should not call this function since -// the escaping rules are not guaranteed! -void AppendInvalidNarrowString(const char* spec, int begin, int end, - CanonOutput* output); -void AppendInvalidNarrowString(const base::char16* spec, int begin, int end, - CanonOutput* output); - -// Misc canonicalization helpers ---------------------------------------------- - -// Converts between UTF-8 and UTF-16, returning true on successful conversion. -// The output will be appended to the given canonicalizer output (so make sure -// it's empty if you want to replace). -// -// On invalid input, this will still write as much output as possible, -// replacing the invalid characters with the "invalid character". It will -// return false in the failure case, and the caller should not continue as -// normal. -URL_EXPORT bool ConvertUTF16ToUTF8(const base::char16* input, int input_len, - CanonOutput* output); -URL_EXPORT bool ConvertUTF8ToUTF16(const char* input, int input_len, - CanonOutputT* output); - -// Converts from UTF-16 to 8-bit using the character set converter. If the -// converter is NULL, this will use UTF-8. -void ConvertUTF16ToQueryEncoding(const base::char16* input, - const Component& query, - CharsetConverter* converter, - CanonOutput* output); - -// Applies the replacements to the given component source. The component source -// should be pre-initialized to the "old" base. That is, all pointers will -// point to the spec of the old URL, and all of the Parsed components will -// be indices into that string. -// -// The pointers and components in the |source| for all non-NULL strings in the -// |repl| (replacements) will be updated to reference those strings. -// Canonicalizing with the new |source| and |parsed| can then combine URL -// components from many different strings. -void SetupOverrideComponents(const char* base, - const Replacements& repl, - URLComponentSource* source, - Parsed* parsed); - -// Like the above 8-bit version, except that it additionally converts the -// UTF-16 input to UTF-8 before doing the overrides. -// -// The given utf8_buffer is used to store the converted components. They will -// be appended one after another, with the parsed structure identifying the -// appropriate substrings. This buffer is a parameter because the source has -// no storage, so the buffer must have the same lifetime as the source -// parameter owned by the caller. -// -// THE CALLER MUST NOT ADD TO THE |utf8_buffer| AFTER THIS CALL. Members of -// |source| will point into this buffer, which could be invalidated if -// additional data is added and the CanonOutput resizes its buffer. -// -// Returns true on success. False means that the input was not valid UTF-16, -// although we will have still done the override with "invalid characters" in -// place of errors. -bool SetupUTF16OverrideComponents(const char* base, - const Replacements& repl, - CanonOutput* utf8_buffer, - URLComponentSource* source, - Parsed* parsed); - -// Implemented in url_canon_path.cc, these are required by the relative URL -// resolver as well, so we declare them here. -bool CanonicalizePartialPath(const char* spec, - const Component& path, - int path_begin_in_output, - CanonOutput* output); -bool CanonicalizePartialPath(const base::char16* spec, - const Component& path, - int path_begin_in_output, - CanonOutput* output); - -#ifndef WIN32 - -// Implementations of Windows' int-to-string conversions -URL_EXPORT int _itoa_s(int value, char* buffer, size_t size_in_chars, - int radix); -URL_EXPORT int _itow_s(int value, base::char16* buffer, size_t size_in_chars, - int radix); - -// Secure template overloads for these functions -template -inline int _itoa_s(int value, char (&buffer)[N], int radix) { - return _itoa_s(value, buffer, N, radix); -} - -template -inline int _itow_s(int value, base::char16 (&buffer)[N], int radix) { - return _itow_s(value, buffer, N, radix); -} - -// _strtoui64 and strtoull behave the same -inline unsigned long long _strtoui64(const char* nptr, - char** endptr, int base) { - return strtoull(nptr, endptr, base); -} - -#endif // WIN32 - -} // namespace url - -#endif // URL_URL_CANON_INTERNAL_H_ diff --git a/vendor/gurl/url/url_canon_ip.cc b/vendor/gurl/url/url_canon_ip.cc deleted file mode 100644 index 51dca08..0000000 --- a/vendor/gurl/url/url_canon_ip.cc +++ /dev/null @@ -1,711 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "url/url_canon_ip.h" - -#include -#include -#include - -//#include "base/logging.h" -#include "url/url_canon_internal.h" - -namespace url { - -namespace { - -// Converts one of the character types that represent a numerical base to the -// corresponding base. -int BaseForType(SharedCharTypes type) { - switch (type) { - case CHAR_HEX: - return 16; - case CHAR_DEC: - return 10; - case CHAR_OCT: - return 8; - default: - return 0; - } -} - -template -bool DoFindIPv4Components(const CHAR* spec, - const Component& host, - Component components[4]) { - if (!host.is_nonempty()) - return false; - - int cur_component = 0; // Index of the component we're working on. - int cur_component_begin = host.begin; // Start of the current component. - int end = host.end(); - for (int i = host.begin; /* nothing */; i++) { - if (i >= end || spec[i] == '.') { - // Found the end of the current component. - int component_len = i - cur_component_begin; - components[cur_component] = Component(cur_component_begin, component_len); - - // The next component starts after the dot. - cur_component_begin = i + 1; - cur_component++; - - // Don't allow empty components (two dots in a row), except we may - // allow an empty component at the end (this would indicate that the - // input ends in a dot). We also want to error if the component is - // empty and it's the only component (cur_component == 1). - if (component_len == 0 && (i < end || cur_component == 1)) - return false; - - if (i >= end) - break; // End of the input. - - if (cur_component == 4) { - // Anything else after the 4th component is an error unless it is a - // dot that would otherwise be treated as the end of input. - if (spec[i] == '.' && i + 1 == end) - break; - return false; - } - } else if (static_cast(spec[i]) >= 0x80 || - !IsIPv4Char(static_cast(spec[i]))) { - // Invalid character for an IPv4 address. - return false; - } - } - - // Fill in any unused components. - while (cur_component < 4) - components[cur_component++] = Component(); - return true; -} - -// Converts an IPv4 component to a 32-bit number, while checking for overflow. -// -// Possible return values: -// - IPV4 - The number was valid, and did not overflow. -// - BROKEN - The input was numeric, but too large for a 32-bit field. -// - NEUTRAL - Input was not numeric. -// -// The input is assumed to be ASCII. FindIPv4Components should have stripped -// out any input that is greater than 7 bits. The components are assumed -// to be non-empty. -template -CanonHostInfo::Family IPv4ComponentToNumber(const CHAR* spec, - const Component& component, - uint32_t* number) { - // Figure out the base - SharedCharTypes base; - int base_prefix_len = 0; // Size of the prefix for this base. - if (spec[component.begin] == '0') { - // Either hex or dec, or a standalone zero. - if (component.len == 1) { - base = CHAR_DEC; - } else if (spec[component.begin + 1] == 'X' || - spec[component.begin + 1] == 'x') { - base = CHAR_HEX; - base_prefix_len = 2; - } else { - base = CHAR_OCT; - base_prefix_len = 1; - } - } else { - base = CHAR_DEC; - } - - // Extend the prefix to consume all leading zeros. - while (base_prefix_len < component.len && - spec[component.begin + base_prefix_len] == '0') - base_prefix_len++; - - // Put the component, minus any base prefix, into a NULL-terminated buffer so - // we can call the standard library. Because leading zeros have already been - // discarded, filling the entire buffer is guaranteed to trigger the 32-bit - // overflow check. - const int kMaxComponentLen = 16; - char buf[kMaxComponentLen + 1]; // digits + '\0' - int dest_i = 0; - for (int i = component.begin + base_prefix_len; i < component.end(); i++) { - // We know the input is 7-bit, so convert to narrow (if this is the wide - // version of the template) by casting. - char input = static_cast(spec[i]); - - // Validate that this character is OK for the given base. - if (!IsCharOfType(input, base)) - return CanonHostInfo::NEUTRAL; - - // Fill the buffer, if there's space remaining. This check allows us to - // verify that all characters are numeric, even those that don't fit. - if (dest_i < kMaxComponentLen) - buf[dest_i++] = input; - } - - buf[dest_i] = '\0'; - - // Use the 64-bit strtoi so we get a big number (no hex, decimal, or octal - // number can overflow a 64-bit number in <= 16 characters). - uint64_t num = _strtoui64(buf, NULL, BaseForType(base)); - - // Check for 32-bit overflow. - if (num > std::numeric_limits::max()) - return CanonHostInfo::BROKEN; - - // No overflow. Success! - *number = static_cast(num); - return CanonHostInfo::IPV4; -} - -// See declaration of IPv4AddressToNumber for documentation. -template -CanonHostInfo::Family DoIPv4AddressToNumber(const CHAR* spec, - const Component& host, - unsigned char address[4], - int* num_ipv4_components) { - // The identified components. Not all may exist. - Component components[4]; - if (!FindIPv4Components(spec, host, components)) - return CanonHostInfo::NEUTRAL; - - // Convert existing components to digits. Values up to - // |existing_components| will be valid. - uint32_t component_values[4]; - int existing_components = 0; - - // Set to true if one or more components are BROKEN. BROKEN is only - // returned if all components are IPV4 or BROKEN, so, for example, - // 12345678912345.de returns NEUTRAL rather than broken. - bool broken = false; - for (int i = 0; i < 4; i++) { - if (components[i].len <= 0) - continue; - CanonHostInfo::Family family = IPv4ComponentToNumber( - spec, components[i], &component_values[existing_components]); - - if (family == CanonHostInfo::BROKEN) { - broken = true; - } else if (family != CanonHostInfo::IPV4) { - // Stop if we hit a non-BROKEN invalid non-empty component. - return family; - } - - existing_components++; - } - - if (broken) - return CanonHostInfo::BROKEN; - - // Use that sequence of numbers to fill out the 4-component IP address. - - // First, process all components but the last, while making sure each fits - // within an 8-bit field. - for (int i = 0; i < existing_components - 1; i++) { - if (component_values[i] > std::numeric_limits::max()) - return CanonHostInfo::BROKEN; - address[i] = static_cast(component_values[i]); - } - - // Next, consume the last component to fill in the remaining bytes. - // Work around a gcc 4.9 bug. crbug.com/392872 -#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" -#endif - uint32_t last_value = component_values[existing_components - 1]; -#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4) -#pragma GCC diagnostic pop -#endif - for (int i = 3; i >= existing_components - 1; i--) { - address[i] = static_cast(last_value); - last_value >>= 8; - } - - // If the last component has residual bits, report overflow. - if (last_value != 0) - return CanonHostInfo::BROKEN; - - // Tell the caller how many components we saw. - *num_ipv4_components = existing_components; - - // Success! - return CanonHostInfo::IPV4; -} - -// Return true if we've made a final IPV4/BROKEN decision, false if the result -// is NEUTRAL, and we could use a second opinion. -template -bool DoCanonicalizeIPv4Address(const CHAR* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info) { - host_info->family = IPv4AddressToNumber( - spec, host, host_info->address, &host_info->num_ipv4_components); - - switch (host_info->family) { - case CanonHostInfo::IPV4: - // Definitely an IPv4 address. - host_info->out_host.begin = output->length(); - AppendIPv4Address(host_info->address, output); - host_info->out_host.len = output->length() - host_info->out_host.begin; - return true; - case CanonHostInfo::BROKEN: - // Definitely broken. - return true; - default: - // Could be IPv6 or a hostname. - return false; - } -} - -// Helper class that describes the main components of an IPv6 input string. -// See the following examples to understand how it breaks up an input string: -// -// [Example 1]: input = "[::aa:bb]" -// ==> num_hex_components = 2 -// ==> hex_components[0] = Component(3,2) "aa" -// ==> hex_components[1] = Component(6,2) "bb" -// ==> index_of_contraction = 0 -// ==> ipv4_component = Component(0, -1) -// -// [Example 2]: input = "[1:2::3:4:5]" -// ==> num_hex_components = 5 -// ==> hex_components[0] = Component(1,1) "1" -// ==> hex_components[1] = Component(3,1) "2" -// ==> hex_components[2] = Component(6,1) "3" -// ==> hex_components[3] = Component(8,1) "4" -// ==> hex_components[4] = Component(10,1) "5" -// ==> index_of_contraction = 2 -// ==> ipv4_component = Component(0, -1) -// -// [Example 3]: input = "[::ffff:192.168.0.1]" -// ==> num_hex_components = 1 -// ==> hex_components[0] = Component(3,4) "ffff" -// ==> index_of_contraction = 0 -// ==> ipv4_component = Component(8, 11) "192.168.0.1" -// -// [Example 4]: input = "[1::]" -// ==> num_hex_components = 1 -// ==> hex_components[0] = Component(1,1) "1" -// ==> index_of_contraction = 1 -// ==> ipv4_component = Component(0, -1) -// -// [Example 5]: input = "[::192.168.0.1]" -// ==> num_hex_components = 0 -// ==> index_of_contraction = 0 -// ==> ipv4_component = Component(8, 11) "192.168.0.1" -// -struct IPv6Parsed { - // Zero-out the parse information. - void reset() { - num_hex_components = 0; - index_of_contraction = -1; - ipv4_component.reset(); - } - - // There can be up to 8 hex components (colon separated) in the literal. - Component hex_components[8]; - - // The count of hex components present. Ranges from [0,8]. - int num_hex_components; - - // The index of the hex component that the "::" contraction precedes, or - // -1 if there is no contraction. - int index_of_contraction; - - // The range of characters which are an IPv4 literal. - Component ipv4_component; -}; - -// Parse the IPv6 input string. If parsing succeeded returns true and fills -// |parsed| with the information. If parsing failed (because the input is -// invalid) returns false. -template -bool DoParseIPv6(const CHAR* spec, const Component& host, IPv6Parsed* parsed) { - // Zero-out the info. - parsed->reset(); - - if (!host.is_nonempty()) - return false; - - // The index for start and end of address range (no brackets). - int begin = host.begin; - int end = host.end(); - - int cur_component_begin = begin; // Start of the current component. - - // Scan through the input, searching for hex components, "::" contractions, - // and IPv4 components. - for (int i = begin; /* i <= end */; i++) { - bool is_colon = spec[i] == ':'; - bool is_contraction = is_colon && i < end - 1 && spec[i + 1] == ':'; - - // We reached the end of the current component if we encounter a colon - // (separator between hex components, or start of a contraction), or end of - // input. - if (is_colon || i == end) { - int component_len = i - cur_component_begin; - - // A component should not have more than 4 hex digits. - if (component_len > 4) - return false; - - // Don't allow empty components. - if (component_len == 0) { - // The exception is when contractions appear at beginning of the - // input or at the end of the input. - if (!((is_contraction && i == begin) || (i == end && - parsed->index_of_contraction == parsed->num_hex_components))) - return false; - } - - // Add the hex component we just found to running list. - if (component_len > 0) { - // Can't have more than 8 components! - if (parsed->num_hex_components >= 8) - return false; - - parsed->hex_components[parsed->num_hex_components++] = - Component(cur_component_begin, component_len); - } - } - - if (i == end) - break; // Reached the end of the input, DONE. - - // We found a "::" contraction. - if (is_contraction) { - // There can be at most one contraction in the literal. - if (parsed->index_of_contraction != -1) - return false; - parsed->index_of_contraction = parsed->num_hex_components; - ++i; // Consume the colon we peeked. - } - - if (is_colon) { - // Colons are separators between components, keep track of where the - // current component started (after this colon). - cur_component_begin = i + 1; - } else { - if (static_cast(spec[i]) >= 0x80) - return false; // Not ASCII. - - if (!IsHexChar(static_cast(spec[i]))) { - // Regular components are hex numbers. It is also possible for - // a component to be an IPv4 address in dotted form. - if (IsIPv4Char(static_cast(spec[i]))) { - // Since IPv4 address can only appear at the end, assume the rest - // of the string is an IPv4 address. (We will parse this separately - // later). - parsed->ipv4_component = - Component(cur_component_begin, end - cur_component_begin); - break; - } else { - // The character was neither a hex digit, nor an IPv4 character. - return false; - } - } - } - } - - return true; -} - -// Verifies the parsed IPv6 information, checking that the various components -// add up to the right number of bits (hex components are 16 bits, while -// embedded IPv4 formats are 32 bits, and contractions are placeholdes for -// 16 or more bits). Returns true if sizes match up, false otherwise. On -// success writes the length of the contraction (if any) to -// |out_num_bytes_of_contraction|. -bool CheckIPv6ComponentsSize(const IPv6Parsed& parsed, - int* out_num_bytes_of_contraction) { - // Each group of four hex digits contributes 16 bits. - int num_bytes_without_contraction = parsed.num_hex_components * 2; - - // If an IPv4 address was embedded at the end, it contributes 32 bits. - if (parsed.ipv4_component.is_valid()) - num_bytes_without_contraction += 4; - - // If there was a "::" contraction, its size is going to be: - // MAX([16bits], [128bits] - num_bytes_without_contraction). - int num_bytes_of_contraction = 0; - if (parsed.index_of_contraction != -1) { - num_bytes_of_contraction = 16 - num_bytes_without_contraction; - if (num_bytes_of_contraction < 2) - num_bytes_of_contraction = 2; - } - - // Check that the numbers add up. - if (num_bytes_without_contraction + num_bytes_of_contraction != 16) - return false; - - *out_num_bytes_of_contraction = num_bytes_of_contraction; - return true; -} - -// Converts a hex component into a number. This cannot fail since the caller has -// already verified that each character in the string was a hex digit, and -// that there were no more than 4 characters. -template -uint16_t IPv6HexComponentToNumber(const CHAR* spec, - const Component& component) { - //DCHECK(component.len <= 4); - - // Copy the hex string into a C-string. - char buf[5]; - for (int i = 0; i < component.len; ++i) - buf[i] = static_cast(spec[component.begin + i]); - buf[component.len] = '\0'; - - // Convert it to a number (overflow is not possible, since with 4 hex - // characters we can at most have a 16 bit number). - return static_cast(_strtoui64(buf, NULL, 16)); -} - -// Converts an IPv6 address to a 128-bit number (network byte order), returning -// true on success. False means that the input was not a valid IPv6 address. -template -bool DoIPv6AddressToNumber(const CHAR* spec, - const Component& host, - unsigned char address[16]) { - // Make sure the component is bounded by '[' and ']'. - int end = host.end(); - if (!host.is_nonempty() || spec[host.begin] != '[' || spec[end - 1] != ']') - return false; - - // Exclude the square brackets. - Component ipv6_comp(host.begin + 1, host.len - 2); - - // Parse the IPv6 address -- identify where all the colon separated hex - // components are, the "::" contraction, and the embedded IPv4 address. - IPv6Parsed ipv6_parsed; - if (!DoParseIPv6(spec, ipv6_comp, &ipv6_parsed)) - return false; - - // Do some basic size checks to make sure that the address doesn't - // specify more than 128 bits or fewer than 128 bits. This also resolves - // how may zero bytes the "::" contraction represents. - int num_bytes_of_contraction; - if (!CheckIPv6ComponentsSize(ipv6_parsed, &num_bytes_of_contraction)) - return false; - - int cur_index_in_address = 0; - - // Loop through each hex components, and contraction in order. - for (int i = 0; i <= ipv6_parsed.num_hex_components; ++i) { - // Append the contraction if it appears before this component. - if (i == ipv6_parsed.index_of_contraction) { - for (int j = 0; j < num_bytes_of_contraction; ++j) - address[cur_index_in_address++] = 0; - } - // Append the hex component's value. - if (i != ipv6_parsed.num_hex_components) { - // Get the 16-bit value for this hex component. - uint16_t number = IPv6HexComponentToNumber( - spec, ipv6_parsed.hex_components[i]); - // Append to |address|, in network byte order. - address[cur_index_in_address++] = (number & 0xFF00) >> 8; - address[cur_index_in_address++] = (number & 0x00FF); - } - } - - // If there was an IPv4 section, convert it into a 32-bit number and append - // it to |address|. - if (ipv6_parsed.ipv4_component.is_valid()) { - // Append the 32-bit number to |address|. - int ignored_num_ipv4_components; - if (CanonHostInfo::IPV4 != - IPv4AddressToNumber(spec, - ipv6_parsed.ipv4_component, - &address[cur_index_in_address], - &ignored_num_ipv4_components)) - return false; - } - - return true; -} - -// Searches for the longest sequence of zeros in |address|, and writes the -// range into |contraction_range|. The run of zeros must be at least 16 bits, -// and if there is a tie the first is chosen. -void ChooseIPv6ContractionRange(const unsigned char address[16], - Component* contraction_range) { - // The longest run of zeros in |address| seen so far. - Component max_range; - - // The current run of zeros in |address| being iterated over. - Component cur_range; - - for (int i = 0; i < 16; i += 2) { - // Test for 16 bits worth of zero. - bool is_zero = (address[i] == 0 && address[i + 1] == 0); - - if (is_zero) { - // Add the zero to the current range (or start a new one). - if (!cur_range.is_valid()) - cur_range = Component(i, 0); - cur_range.len += 2; - } - - if (!is_zero || i == 14) { - // Just completed a run of zeros. If the run is greater than 16 bits, - // it is a candidate for the contraction. - if (cur_range.len > 2 && cur_range.len > max_range.len) { - max_range = cur_range; - } - cur_range.reset(); - } - } - *contraction_range = max_range; -} - -// Return true if we've made a final IPV6/BROKEN decision, false if the result -// is NEUTRAL, and we could use a second opinion. -template -bool DoCanonicalizeIPv6Address(const CHAR* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info) { - // Turn the IP address into a 128 bit number. - if (!IPv6AddressToNumber(spec, host, host_info->address)) { - // If it's not an IPv6 address, scan for characters that should *only* - // exist in an IPv6 address. - for (int i = host.begin; i < host.end(); i++) { - switch (spec[i]) { - case '[': - case ']': - case ':': - host_info->family = CanonHostInfo::BROKEN; - return true; - } - } - - // No invalid characters. Could still be IPv4 or a hostname. - host_info->family = CanonHostInfo::NEUTRAL; - return false; - } - - host_info->out_host.begin = output->length(); - output->push_back('['); - AppendIPv6Address(host_info->address, output); - output->push_back(']'); - host_info->out_host.len = output->length() - host_info->out_host.begin; - - host_info->family = CanonHostInfo::IPV6; - return true; -} - -} // namespace - -void AppendIPv4Address(const unsigned char address[4], CanonOutput* output) { - for (int i = 0; i < 4; i++) { - char str[16]; - _itoa_s(address[i], str, 10); - - for (int ch = 0; str[ch] != 0; ch++) - output->push_back(str[ch]); - - if (i != 3) - output->push_back('.'); - } -} - -void AppendIPv6Address(const unsigned char address[16], CanonOutput* output) { - // We will output the address according to the rules in: - // http://tools.ietf.org/html/draft-kawamura-ipv6-text-representation-01#section-4 - - // Start by finding where to place the "::" contraction (if any). - Component contraction_range; - ChooseIPv6ContractionRange(address, &contraction_range); - - for (int i = 0; i <= 14;) { - // We check 2 bytes at a time, from bytes (0, 1) to (14, 15), inclusive. - //DCHECK(i % 2 == 0); - if (i == contraction_range.begin && contraction_range.len > 0) { - // Jump over the contraction. - if (i == 0) - output->push_back(':'); - output->push_back(':'); - i = contraction_range.end(); - } else { - // Consume the next 16 bits from |address|. - int x = address[i] << 8 | address[i + 1]; - - i += 2; - - // Stringify the 16 bit number (at most requires 4 hex digits). - char str[5]; - _itoa_s(x, str, 16); - for (int ch = 0; str[ch] != 0; ++ch) - output->push_back(str[ch]); - - // Put a colon after each number, except the last. - if (i < 16) - output->push_back(':'); - } - } -} - -bool FindIPv4Components(const char* spec, - const Component& host, - Component components[4]) { - return DoFindIPv4Components(spec, host, components); -} - -bool FindIPv4Components(const base::char16* spec, - const Component& host, - Component components[4]) { - return DoFindIPv4Components( - spec, host, components); -} - -void CanonicalizeIPAddress(const char* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info) { - if (DoCanonicalizeIPv4Address( - spec, host, output, host_info)) - return; - if (DoCanonicalizeIPv6Address( - spec, host, output, host_info)) - return; -} - -void CanonicalizeIPAddress(const base::char16* spec, - const Component& host, - CanonOutput* output, - CanonHostInfo* host_info) { - if (DoCanonicalizeIPv4Address( - spec, host, output, host_info)) - return; - if (DoCanonicalizeIPv6Address( - spec, host, output, host_info)) - return; -} - -CanonHostInfo::Family IPv4AddressToNumber(const char* spec, - const Component& host, - unsigned char address[4], - int* num_ipv4_components) { - return DoIPv4AddressToNumber(spec, host, address, num_ipv4_components); -} - -CanonHostInfo::Family IPv4AddressToNumber(const base::char16* spec, - const Component& host, - unsigned char address[4], - int* num_ipv4_components) { - return DoIPv4AddressToNumber( - spec, host, address, num_ipv4_components); -} - -bool IPv6AddressToNumber(const char* spec, - const Component& host, - unsigned char address[16]) { - return DoIPv6AddressToNumber(spec, host, address); -} - -bool IPv6AddressToNumber(const base::char16* spec, - const Component& host, - unsigned char address[16]) { - return DoIPv6AddressToNumber(spec, host, address); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_ip.h b/vendor/gurl/url/url_canon_ip.h deleted file mode 100644 index 937bd46..0000000 --- a/vendor/gurl/url/url_canon_ip.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_CANON_IP_H_ -#define URL_URL_CANON_IP_H_ - -#include "base/strings/string16.h" -#include "url/third_party/mozilla/url_parse.h" -#include "url/url_canon.h" -#include "url/url_export.h" - -namespace url { - -// Writes the given IPv4 address to |output|. -URL_EXPORT void AppendIPv4Address(const unsigned char address[4], - CanonOutput* output); - -// Writes the given IPv6 address to |output|. -URL_EXPORT void AppendIPv6Address(const unsigned char address[16], - CanonOutput* output); - -// Searches the host name for the portions of the IPv4 address. On success, -// each component will be placed into |components| and it will return true. -// It will return false if the host can not be separated as an IPv4 address -// or if there are any non-7-bit characters or other characters that can not -// be in an IP address. (This is important so we fail as early as possible for -// common non-IP hostnames.) -// -// Not all components may exist. If there are only 3 components, for example, -// the last one will have a length of -1 or 0 to indicate it does not exist. -// -// Note that many platforms' inet_addr will ignore everything after a space -// in certain circumstances if the stuff before the space looks like an IP -// address. IE6 is included in this. We do NOT handle this case. In many cases, -// the browser's canonicalization will get run before this which converts -// spaces to %20 (in the case of IE7) or rejects them (in the case of Mozilla), -// so this code path never gets hit. Our host canonicalization will notice -// these spaces and escape them, which will make IP address finding fail. This -// seems like better behavior than stripping after a space. -URL_EXPORT bool FindIPv4Components(const char* spec, - const Component& host, - Component components[4]); -URL_EXPORT bool FindIPv4Components(const base::char16* spec, - const Component& host, - Component components[4]); - -// Converts an IPv4 address to a 32-bit number (network byte order). -// -// Possible return values: -// IPV4 - IPv4 address was successfully parsed. -// BROKEN - Input was formatted like an IPv4 address, but overflow occurred -// during parsing. -// NEUTRAL - Input couldn't possibly be interpreted as an IPv4 address. -// It might be an IPv6 address, or a hostname. -// -// On success, |num_ipv4_components| will be populated with the number of -// components in the IPv4 address. -URL_EXPORT CanonHostInfo::Family IPv4AddressToNumber(const char* spec, - const Component& host, - unsigned char address[4], - int* num_ipv4_components); -URL_EXPORT CanonHostInfo::Family IPv4AddressToNumber(const base::char16* spec, - const Component& host, - unsigned char address[4], - int* num_ipv4_components); - -// Converts an IPv6 address to a 128-bit number (network byte order), returning -// true on success. False means that the input was not a valid IPv6 address. -// -// NOTE that |host| is expected to be surrounded by square brackets. -// i.e. "[::1]" rather than "::1". -URL_EXPORT bool IPv6AddressToNumber(const char* spec, - const Component& host, - unsigned char address[16]); -URL_EXPORT bool IPv6AddressToNumber(const base::char16* spec, - const Component& host, - unsigned char address[16]); - -} // namespace url - -#endif // URL_URL_CANON_IP_H_ diff --git a/vendor/gurl/url/url_canon_mailtourl.cc b/vendor/gurl/url/url_canon_mailtourl.cc deleted file mode 100644 index fb6bc9a..0000000 --- a/vendor/gurl/url/url_canon_mailtourl.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Functions for canonicalizing "mailto:" URLs. - -#include "url/url_canon.h" -#include "url/url_canon_internal.h" -#include "url/url_file.h" -#include "url/url_parse_internal.h" - -namespace url { - -namespace { - -template -bool DoCanonicalizeMailtoURL(const URLComponentSource& source, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed) { - // mailto: only uses {scheme, path, query} -- clear the rest. - new_parsed->username = Component(); - new_parsed->password = Component(); - new_parsed->host = Component(); - new_parsed->port = Component(); - new_parsed->ref = Component(); - - // Scheme (known, so we don't bother running it through the more - // complicated scheme canonicalizer). - new_parsed->scheme.begin = output->length(); - output->Append("mailto:", 7); - new_parsed->scheme.len = 6; - - bool success = true; - - // Path - if (parsed.path.is_valid()) { - new_parsed->path.begin = output->length(); - - // Copy the path using path URL's more lax escaping rules. - // We convert to UTF-8 and escape non-ASCII, but leave all - // ASCII characters alone. - int end = parsed.path.end(); - for (int i = parsed.path.begin; i < end; ++i) { - UCHAR uch = static_cast(source.path[i]); - if (uch < 0x20 || uch >= 0x80) - success &= AppendUTF8EscapedChar(source.path, &i, end, output); - else - output->push_back(static_cast(uch)); - } - - new_parsed->path.len = output->length() - new_parsed->path.begin; - } else { - // No path at all - new_parsed->path.reset(); - } - - // Query -- always use the default UTF8 charset converter. - CanonicalizeQuery(source.query, parsed.query, NULL, - output, &new_parsed->query); - - return success; -} - -} // namespace - -bool CanonicalizeMailtoURL(const char* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeMailtoURL( - URLComponentSource(spec), parsed, output, new_parsed); -} - -bool CanonicalizeMailtoURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeMailtoURL( - URLComponentSource(spec), parsed, output, new_parsed); -} - -bool ReplaceMailtoURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed) { - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupOverrideComponents(base, replacements, &source, &parsed); - return DoCanonicalizeMailtoURL( - source, parsed, output, new_parsed); -} - -bool ReplaceMailtoURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed) { - RawCanonOutput<1024> utf8; - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); - return DoCanonicalizeMailtoURL( - source, parsed, output, new_parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_path.cc b/vendor/gurl/url/url_canon_path.cc deleted file mode 100644 index 71536f7..0000000 --- a/vendor/gurl/url/url_canon_path.cc +++ /dev/null @@ -1,435 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -//#include "base/logging.h" -#include "url/url_canon.h" -#include "url/url_canon_internal.h" -#include "url/url_parse_internal.h" - -namespace url { - -namespace { - -enum CharacterFlags { - // Pass through unchanged, whether escaped or unescaped. This doesn't - // actually set anything so you can't OR it to check, it's just to make the - // table below more clear when neither ESCAPE or UNESCAPE is set. - PASS = 0, - - // This character requires special handling in DoPartialPath. Doing this test - // first allows us to filter out the common cases of regular characters that - // can be directly copied. - SPECIAL = 1, - - // This character must be escaped in the canonical output. Note that all - // escaped chars also have the "special" bit set so that the code that looks - // for this is triggered. Not valid with PASS or ESCAPE - ESCAPE_BIT = 2, - ESCAPE = ESCAPE_BIT | SPECIAL, - - // This character must be unescaped in canonical output. Not valid with - // ESCAPE or PASS. We DON'T set the SPECIAL flag since if we encounter these - // characters unescaped, they should just be copied. - UNESCAPE = 4, - - // This character is disallowed in URLs. Note that the "special" bit is also - // set to trigger handling. - INVALID_BIT = 8, - INVALID = INVALID_BIT | SPECIAL, -}; - -// This table contains one of the above flag values. Note some flags are more -// than one bits because they also turn on the "special" flag. Special is the -// only flag that may be combined with others. -// -// This table is designed to match exactly what IE does with the characters. -// -// Dot is even more special, and the escaped version is handled specially by -// IsDot. Therefore, we don't need the "escape" flag, and even the "unescape" -// bit is never handled (we just need the "special") bit. -const unsigned char kPathCharLookup[0x100] = { -// NULL control chars... - INVALID, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, -// control chars... - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, -// ' ' ! " # $ % & ' ( ) * + , - . / - ESCAPE, PASS, ESCAPE, ESCAPE, PASS, ESCAPE, PASS, PASS, PASS, PASS, PASS, PASS, PASS, UNESCAPE,SPECIAL, PASS, -// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? - UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,PASS, PASS, ESCAPE, PASS, ESCAPE, ESCAPE, -// @ A B C D E F G H I J K L M N O - PASS, UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE, -// P Q R S T U V W X Y Z [ \ ] ^ _ - UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,PASS, ESCAPE, PASS, ESCAPE, UNESCAPE, -// ` a b c d e f g h i j k l m n o - ESCAPE, UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE, -// p q r s t u v w x y z { | } ~ - UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,UNESCAPE,ESCAPE, ESCAPE, ESCAPE, UNESCAPE,ESCAPE, -// ...all the high-bit characters are escaped - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, - ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE, ESCAPE}; - -enum DotDisposition { - // The given dot is just part of a filename and is not special. - NOT_A_DIRECTORY, - - // The given dot is the current directory. - DIRECTORY_CUR, - - // The given dot is the first of a double dot that should take us up one. - DIRECTORY_UP -}; - -// When the path resolver finds a dot, this function is called with the -// character following that dot to see what it is. The return value -// indicates what type this dot is (see above). This code handles the case -// where the dot is at the end of the input. -// -// |*consumed_len| will contain the number of characters in the input that -// express what we found. -// -// If the input is "../foo", |after_dot| = 1, |end| = 6, and -// at the end, |*consumed_len| = 2 for the "./" this function consumed. The -// original dot length should be handled by the caller. -template -DotDisposition ClassifyAfterDot(const CHAR* spec, int after_dot, - int end, int* consumed_len) { - if (after_dot == end) { - // Single dot at the end. - *consumed_len = 0; - return DIRECTORY_CUR; - } - if (IsURLSlash(spec[after_dot])) { - // Single dot followed by a slash. - *consumed_len = 1; // Consume the slash - return DIRECTORY_CUR; - } - - int second_dot_len = IsDot(spec, after_dot, end); - if (second_dot_len) { - int after_second_dot = after_dot + second_dot_len; - if (after_second_dot == end) { - // Double dot at the end. - *consumed_len = second_dot_len; - return DIRECTORY_UP; - } - if (IsURLSlash(spec[after_second_dot])) { - // Double dot followed by a slash. - *consumed_len = second_dot_len + 1; - return DIRECTORY_UP; - } - } - - // The dots are followed by something else, not a directory. - *consumed_len = 0; - return NOT_A_DIRECTORY; -} - -// Rewinds the output to the previous slash. It is assumed that the output -// ends with a slash and this doesn't count (we call this when we are -// appending directory paths, so the previous path component has and ending -// slash). -// -// This will stop at the first slash (assumed to be at position -// |path_begin_in_output| and not go any higher than that. Some web pages -// do ".." too many times, so we need to handle that brokenness. -// -// It searches for a literal slash rather than including a backslash as well -// because it is run only on the canonical output. -// -// The output is guaranteed to end in a slash when this function completes. -void BackUpToPreviousSlash(int path_begin_in_output, - CanonOutput* output) { - //DCHECK(output->length() > 0); - - int i = output->length() - 1; - //DCHECK(output->at(i) == '/'); - if (i == path_begin_in_output) - return; // We're at the first slash, nothing to do. - - // Now back up (skipping the trailing slash) until we find another slash. - i--; - while (output->at(i) != '/' && i > path_begin_in_output) - i--; - - // Now shrink the output to just include that last slash we found. - output->set_length(i + 1); -} - -// Looks for problematic nested escape sequences and escapes the output as -// needed to ensure they can't be misinterpreted. -// -// Our concern is that in input escape sequence that's invalid because it -// contains nested escape sequences might look valid once those are unescaped. -// For example, "%%300" is not a valid escape sequence, but after unescaping the -// inner "%30" this becomes "%00" which is valid. Leaving this in the output -// string can result in callers re-canonicalizing the string and unescaping this -// sequence, thus resulting in something fundamentally different than the -// original input here. This can cause a variety of problems. -// -// This function is called after we've just unescaped a sequence that's within -// two output characters of a previous '%' that we know didn't begin a valid -// escape sequence in the input string. We look for whether the output is going -// to turn into a valid escape sequence, and if so, convert the initial '%' into -// an escaped "%25" so the output can't be misinterpreted. -// -// |spec| is the input string we're canonicalizing. -// |next_input_index| is the index of the next unprocessed character in |spec|. -// |input_len| is the length of |spec|. -// |last_invalid_percent_index| is the index in |output| of a previously-seen -// '%' character. The caller knows this '%' character isn't followed by a valid -// escape sequence in the input string. -// |output| is the canonicalized output thus far. The caller guarantees this -// ends with a '%' followed by one or two characters, and the '%' is the one -// pointed to by |last_invalid_percent_index|. The last character in the string -// was just unescaped. -template -void CheckForNestedEscapes(const CHAR* spec, - int next_input_index, - int input_len, - int last_invalid_percent_index, - CanonOutput* output) { - const int length = output->length(); - const char last_unescaped_char = output->at(length - 1); - - // If |output| currently looks like "%c", we need to try appending the next - // input character to see if this will result in a problematic escape - // sequence. Note that this won't trigger on the first nested escape of a - // two-escape sequence like "%%30%30" -- we'll allow the conversion to - // "%0%30" -- but the second nested escape will be caught by this function - // when it's called again in that case. - const bool append_next_char = last_invalid_percent_index == length - 2; - if (append_next_char) { - // If the input doesn't contain a 7-bit character next, this case won't be a - // problem. - if ((next_input_index == input_len) || (spec[next_input_index] >= 0x80)) - return; - output->push_back(static_cast(spec[next_input_index])); - } - - // Now output ends like "%cc". Try to unescape this. - int begin = last_invalid_percent_index; - unsigned char temp; - if (DecodeEscaped(output->data(), &begin, output->length(), &temp)) { - // New escape sequence found. Overwrite the characters following the '%' - // with "25", and push_back() the one or two characters that were following - // the '%' when we were called. - if (!append_next_char) - output->push_back(output->at(last_invalid_percent_index + 1)); - output->set(last_invalid_percent_index + 1, '2'); - output->set(last_invalid_percent_index + 2, '5'); - output->push_back(last_unescaped_char); - } else if (append_next_char) { - // Not a valid escape sequence, but we still need to undo appending the next - // source character so the caller can process it normally. - output->set_length(length); - } -} - -// Appends the given path to the output. It assumes that if the input path -// starts with a slash, it should be copied to the output. If no path has -// already been appended to the output (the case when not resolving -// relative URLs), the path should begin with a slash. -// -// If there are already path components (this mode is used when appending -// relative paths for resolving), it assumes that the output already has -// a trailing slash and that if the input begins with a slash, it should be -// copied to the output. -// -// We do not collapse multiple slashes in a row to a single slash. It seems -// no web browsers do this, and we don't want incompatibilities, even though -// it would be correct for most systems. -template -bool DoPartialPath(const CHAR* spec, - const Component& path, - int path_begin_in_output, - CanonOutput* output) { - int end = path.end(); - - // We use this variable to minimize the amount of work done when unescaping -- - // we'll only call CheckForNestedEscapes() when this points at one of the last - // couple of characters in |output|. - int last_invalid_percent_index = INT_MIN; - - bool success = true; - for (int i = path.begin; i < end; i++) { - UCHAR uch = static_cast(spec[i]); - if (sizeof(CHAR) > 1 && uch >= 0x80) { - // We only need to test wide input for having non-ASCII characters. For - // narrow input, we'll always just use the lookup table. We don't try to - // do anything tricky with decoding/validating UTF-8. This function will - // read one or two UTF-16 characters and append the output as UTF-8. This - // call will be removed in 8-bit mode. - success &= AppendUTF8EscapedChar(spec, &i, end, output); - } else { - // Normal ASCII character or 8-bit input, use the lookup table. - unsigned char out_ch = static_cast(uch); - unsigned char flags = kPathCharLookup[out_ch]; - if (flags & SPECIAL) { - // Needs special handling of some sort. - int dotlen; - if ((dotlen = IsDot(spec, i, end)) > 0) { - // See if this dot was preceded by a slash in the output. We - // assume that when canonicalizing paths, they will always - // start with a slash and not a dot, so we don't have to - // bounds check the output. - // - // Note that we check this in the case of dots so we don't have to - // special case slashes. Since slashes are much more common than - // dots, this actually increases performance measurably (though - // slightly). - //DCHECK(output->length() > path_begin_in_output); - if (output->length() > path_begin_in_output && - output->at(output->length() - 1) == '/') { - // Slash followed by a dot, check to see if this is means relative - int consumed_len; - switch (ClassifyAfterDot(spec, i + dotlen, end, - &consumed_len)) { - case NOT_A_DIRECTORY: - // Copy the dot to the output, it means nothing special. - output->push_back('.'); - i += dotlen - 1; - break; - case DIRECTORY_CUR: // Current directory, just skip the input. - i += dotlen + consumed_len - 1; - break; - case DIRECTORY_UP: - BackUpToPreviousSlash(path_begin_in_output, output); - i += dotlen + consumed_len - 1; - break; - } - } else { - // This dot is not preceded by a slash, it is just part of some - // file name. - output->push_back('.'); - i += dotlen - 1; - } - - } else if (out_ch == '\\') { - // Convert backslashes to forward slashes - output->push_back('/'); - - } else if (out_ch == '%') { - // Handle escape sequences. - unsigned char unescaped_value; - if (DecodeEscaped(spec, &i, end, &unescaped_value)) { - // Valid escape sequence, see if we keep, reject, or unescape it. - // Note that at this point DecodeEscape() will have advanced |i| to - // the last character of the escape sequence. - char unescaped_flags = kPathCharLookup[unescaped_value]; - - if (unescaped_flags & UNESCAPE) { - // This escaped value shouldn't be escaped. Try to copy it. - output->push_back(unescaped_value); - // If we just unescaped a value within 2 output characters of the - // '%' from a previously-detected invalid escape sequence, we - // might have an input string with problematic nested escape - // sequences; detect and fix them. - if (last_invalid_percent_index >= (output->length() - 3)) { - CheckForNestedEscapes(spec, i + 1, end, - last_invalid_percent_index, output); - } - } else { - // Either this is an invalid escaped character, or it's a valid - // escaped character we should keep escaped. In the first case we - // should just copy it exactly and remember the error. In the - // second we also copy exactly in case the server is sensitive to - // changing the case of any hex letters. - output->push_back('%'); - output->push_back(static_cast(spec[i - 1])); - output->push_back(static_cast(spec[i])); - if (unescaped_flags & INVALID_BIT) - success = false; - } - } else { - // Invalid escape sequence. IE7+ rejects any URLs with such - // sequences, while other browsers pass them through unchanged. We - // use the permissive behavior. - // TODO(brettw): Consider testing IE's strict behavior, which would - // allow removing the code to handle nested escapes above. - last_invalid_percent_index = output->length(); - output->push_back('%'); - } - - } else if (flags & INVALID_BIT) { - // For NULLs, etc. fail. - AppendEscapedChar(out_ch, output); - success = false; - - } else if (flags & ESCAPE_BIT) { - // This character should be escaped. - AppendEscapedChar(out_ch, output); - } - } else { - // Nothing special about this character, just append it. - output->push_back(out_ch); - } - } - } - return success; -} - -template -bool DoPath(const CHAR* spec, - const Component& path, - CanonOutput* output, - Component* out_path) { - bool success = true; - out_path->begin = output->length(); - if (path.len > 0) { - // Write out an initial slash if the input has none. If we just parse a URL - // and then canonicalize it, it will of course have a slash already. This - // check is for the replacement and relative URL resolving cases of file - // URLs. - if (!IsURLSlash(spec[path.begin])) - output->push_back('/'); - - success = DoPartialPath(spec, path, out_path->begin, output); - } else { - // No input, canonical path is a slash. - output->push_back('/'); - } - out_path->len = output->length() - out_path->begin; - return success; -} - -} // namespace - -bool CanonicalizePath(const char* spec, - const Component& path, - CanonOutput* output, - Component* out_path) { - return DoPath(spec, path, output, out_path); -} - -bool CanonicalizePath(const base::char16* spec, - const Component& path, - CanonOutput* output, - Component* out_path) { - return DoPath(spec, path, output, out_path); -} - -bool CanonicalizePartialPath(const char* spec, - const Component& path, - int path_begin_in_output, - CanonOutput* output) { - return DoPartialPath(spec, path, path_begin_in_output, - output); -} - -bool CanonicalizePartialPath(const base::char16* spec, - const Component& path, - int path_begin_in_output, - CanonOutput* output) { - return DoPartialPath(spec, path, - path_begin_in_output, - output); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_pathurl.cc b/vendor/gurl/url/url_canon_pathurl.cc deleted file mode 100644 index 494fbda..0000000 --- a/vendor/gurl/url/url_canon_pathurl.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Functions for canonicalizing "path" URLs. Not to be confused with the path -// of a URL, these are URLs that have no authority section, only a path. For -// example, "javascript:" and "data:". - -#include "url/url_canon.h" -#include "url/url_canon_internal.h" - -namespace url { - -namespace { - -// Canonicalize the given |component| from |source| into |output| and -// |new_component|. If |separator| is non-zero, it is pre-pended to |output| -// prior to the canonicalized component; i.e. for the '?' or '#' characters. -template -bool DoCanonicalizePathComponent(const CHAR* source, - const Component& component, - char separator, - CanonOutput* output, - Component* new_component) { - bool success = true; - if (component.is_valid()) { - if (separator) - output->push_back(separator); - // Copy the path using path URL's more lax escaping rules (think for - // javascript:). We convert to UTF-8 and escape non-ASCII, but leave all - // ASCII characters alone. This helps readability of JavaStript. - new_component->begin = output->length(); - int end = component.end(); - for (int i = component.begin; i < end; i++) { - UCHAR uch = static_cast(source[i]); - if (uch < 0x20 || uch >= 0x80) - success &= AppendUTF8EscapedChar(source, &i, end, output); - else - output->push_back(static_cast(uch)); - } - new_component->len = output->length() - new_component->begin; - } else { - // Empty part. - new_component->reset(); - } - return success; -} - -template -bool DoCanonicalizePathURL(const URLComponentSource& source, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed) { - // Scheme: this will append the colon. - bool success = CanonicalizeScheme(source.scheme, parsed.scheme, - output, &new_parsed->scheme); - - // We assume there's no authority for path URLs. Note that hosts should never - // have -1 length. - new_parsed->username.reset(); - new_parsed->password.reset(); - new_parsed->host.reset(); - new_parsed->port.reset(); - // We allow path URLs to have the path, query and fragment components, but we - // will canonicalize each of the via the weaker path URL rules. - success &= DoCanonicalizePathComponent( - source.path, parsed.path, '\0', output, &new_parsed->path); - success &= DoCanonicalizePathComponent( - source.query, parsed.query, '?', output, &new_parsed->query); - success &= DoCanonicalizePathComponent( - source.ref, parsed.ref, '#', output, &new_parsed->ref); - - return success; -} - -} // namespace - -bool CanonicalizePathURL(const char* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizePathURL( - URLComponentSource(spec), parsed, output, new_parsed); -} - -bool CanonicalizePathURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizePathURL( - URLComponentSource(spec), parsed, output, new_parsed); -} - -bool ReplacePathURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed) { - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupOverrideComponents(base, replacements, &source, &parsed); - return DoCanonicalizePathURL( - source, parsed, output, new_parsed); -} - -bool ReplacePathURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CanonOutput* output, - Parsed* new_parsed) { - RawCanonOutput<1024> utf8; - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); - return DoCanonicalizePathURL( - source, parsed, output, new_parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_query.cc b/vendor/gurl/url/url_canon_query.cc deleted file mode 100644 index bf59d10..0000000 --- a/vendor/gurl/url/url_canon_query.cc +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "url/url_canon.h" -#include "url/url_canon_internal.h" - -// Query canonicalization in IE -// ---------------------------- -// IE is very permissive for query parameters specified in links on the page -// (in contrast to links that it constructs itself based on form data). It does -// not unescape any character. It does not reject any escape sequence (be they -// invalid like "%2y" or freaky like %00). -// -// IE only escapes spaces and nothing else. Embedded NULLs, tabs (0x09), -// LF (0x0a), and CR (0x0d) are removed (this probably happens at an earlier -// layer since they are removed from all portions of the URL). All other -// characters are passed unmodified. Invalid UTF-16 sequences are preserved as -// well, with each character in the input being converted to UTF-8. It is the -// server's job to make sense of this invalid query. -// -// Invalid multibyte sequences (for example, invalid UTF-8 on a UTF-8 page) -// are converted to the invalid character and sent as unescaped UTF-8 (0xef, -// 0xbf, 0xbd). This may not be canonicalization, the parser may generate these -// strings before the URL handler ever sees them. -// -// Our query canonicalization -// -------------------------- -// We escape all non-ASCII characters and control characters, like Firefox. -// This is more conformant to the URL spec, and there do not seem to be many -// problems relating to Firefox's behavior. -// -// Like IE, we will never unescape (although the application may want to try -// unescaping to present the user with a more understandable URL). We will -// replace all invalid sequences (including invalid UTF-16 sequences, which IE -// doesn't) with the "invalid character," and we will escape it. - -namespace url { - -namespace { - -// Returns true if the characters starting at |begin| and going until |end| -// (non-inclusive) are all representable in 7-bits. -template -bool IsAllASCII(const CHAR* spec, const Component& query) { - int end = query.end(); - for (int i = query.begin; i < end; i++) { - if (static_cast(spec[i]) >= 0x80) - return false; - } - return true; -} - -// Appends the given string to the output, escaping characters that do not -// match the given |type| in SharedCharTypes. This version will accept 8 or 16 -// bit characters, but assumes that they have only 7-bit values. It also assumes -// that all UTF-8 values are correct, so doesn't bother checking -template -void AppendRaw8BitQueryString(const CHAR* source, int length, - CanonOutput* output) { - for (int i = 0; i < length; i++) { - if (!IsQueryChar(static_cast(source[i]))) - AppendEscapedChar(static_cast(source[i]), output); - else // Doesn't need escaping. - output->push_back(static_cast(source[i])); - } -} - -// Runs the converter on the given UTF-8 input. Since the converter expects -// UTF-16, we have to convert first. The converter must be non-NULL. -void RunConverter(const char* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output) { - // This function will replace any misencoded values with the invalid - // character. This is what we want so we don't have to check for error. - RawCanonOutputW<1024> utf16; - ConvertUTF8ToUTF16(&spec[query.begin], query.len, &utf16); - converter->ConvertFromUTF16(utf16.data(), utf16.length(), output); -} - -// Runs the converter with the given UTF-16 input. We don't have to do -// anything, but this overridden function allows us to use the same code -// for both UTF-8 and UTF-16 input. -void RunConverter(const base::char16* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output) { - converter->ConvertFromUTF16(&spec[query.begin], query.len, output); -} - -template -void DoConvertToQueryEncoding(const CHAR* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output) { - if (IsAllASCII(spec, query)) { - // Easy: the input can just appended with no character set conversions. - AppendRaw8BitQueryString(&spec[query.begin], query.len, output); - - } else { - // Harder: convert to the proper encoding first. - if (converter) { - // Run the converter to get an 8-bit string, then append it, escaping - // necessary values. - RawCanonOutput<1024> eight_bit; - RunConverter(spec, query, converter, &eight_bit); - AppendRaw8BitQueryString(eight_bit.data(), eight_bit.length(), output); - - } else { - // No converter, do our own UTF-8 conversion. - AppendStringOfType(&spec[query.begin], query.len, CHAR_QUERY, output); - } - } -} - -template -void DoCanonicalizeQuery(const CHAR* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output, - Component* out_query) { - if (query.len < 0) { - *out_query = Component(); - return; - } - - output->push_back('?'); - out_query->begin = output->length(); - - DoConvertToQueryEncoding(spec, query, converter, output); - - out_query->len = output->length() - out_query->begin; -} - -} // namespace - -void CanonicalizeQuery(const char* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output, - Component* out_query) { - DoCanonicalizeQuery(spec, query, converter, - output, out_query); -} - -void CanonicalizeQuery(const base::char16* spec, - const Component& query, - CharsetConverter* converter, - CanonOutput* output, - Component* out_query) { - DoCanonicalizeQuery(spec, query, converter, - output, out_query); -} - -void ConvertUTF16ToQueryEncoding(const base::char16* input, - const Component& query, - CharsetConverter* converter, - CanonOutput* output) { - DoConvertToQueryEncoding(input, query, - converter, output); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_relative.cc b/vendor/gurl/url/url_canon_relative.cc deleted file mode 100644 index 18c9051..0000000 --- a/vendor/gurl/url/url_canon_relative.cc +++ /dev/null @@ -1,560 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Canonicalizer functions for working with and resolving relative URLs. - -//#include "base/logging.h" -#include "url/url_canon.h" -#include "url/url_canon_internal.h" -#include "url/url_constants.h" -#include "url/url_file.h" -#include "url/url_parse_internal.h" -#include "url/url_util_internal.h" - -namespace url { - -namespace { - -// Firefox does a case-sensitive compare (which is probably wrong--Mozilla bug -// 379034), whereas IE is case-insensitive. -// -// We choose to be more permissive like IE. We don't need to worry about -// unescaping or anything here: neither IE or Firefox allow this. We also -// don't have to worry about invalid scheme characters since we are comparing -// against the canonical scheme of the base. -// -// The base URL should always be canonical, therefore it should be ASCII. -template -bool AreSchemesEqual(const char* base, - const Component& base_scheme, - const CHAR* cmp, - const Component& cmp_scheme) { - if (base_scheme.len != cmp_scheme.len) - return false; - for (int i = 0; i < base_scheme.len; i++) { - // We assume the base is already canonical, so we don't have to - // canonicalize it. - if (CanonicalSchemeChar(cmp[cmp_scheme.begin + i]) != - base[base_scheme.begin + i]) - return false; - } - return true; -} - -#ifdef WIN32 - -// Here, we also allow Windows paths to be represented as "/C:/" so we can be -// consistent about URL paths beginning with slashes. This function is like -// DoesBeginWindowsDrivePath except that it also requires a slash at the -// beginning. -template -bool DoesBeginSlashWindowsDriveSpec(const CHAR* spec, int start_offset, - int spec_len) { - if (start_offset >= spec_len) - return false; - return IsURLSlash(spec[start_offset]) && - DoesBeginWindowsDriveSpec(spec, start_offset + 1, spec_len); -} - -#endif // WIN32 - -// See IsRelativeURL in the header file for usage. -template -bool DoIsRelativeURL(const char* base, - const Parsed& base_parsed, - const CHAR* url, - int url_len, - bool is_base_hierarchical, - bool* is_relative, - Component* relative_component) { - *is_relative = false; // So we can default later to not relative. - - // Trim whitespace and construct a new range for the substring. - int begin = 0; - TrimURL(url, &begin, &url_len); - if (begin >= url_len) { - // Empty URLs are relative, but do nothing. - *relative_component = Component(begin, 0); - *is_relative = true; - return true; - } - -#ifdef WIN32 - // We special case paths like "C:\foo" so they can link directly to the - // file on Windows (IE compatibility). The security domain stuff should - // prevent a link like this from actually being followed if its on a - // web page. - // - // We treat "C:/foo" as an absolute URL. We can go ahead and treat "/c:/" - // as relative, as this will just replace the path when the base scheme - // is a file and the answer will still be correct. - // - // We require strict backslashes when detecting UNC since two forward - // slashes should be treated a a relative URL with a hostname. - if (DoesBeginWindowsDriveSpec(url, begin, url_len) || - DoesBeginUNCPath(url, begin, url_len, true)) - return true; -#endif // WIN32 - - // See if we've got a scheme, if not, we know this is a relative URL. - // BUT, just because we have a scheme, doesn't make it absolute. - // "http:foo.html" is a relative URL with path "foo.html". If the scheme is - // empty, we treat it as relative (":foo"), like IE does. - Component scheme; - const bool scheme_is_empty = - !ExtractScheme(url, url_len, &scheme) || scheme.len == 0; - if (scheme_is_empty) { - if (url[begin] == '#') { - // |url| is a bare fragment (e.g. "#foo"). This can be resolved against - // any base. Fall-through. - } else if (!is_base_hierarchical) { - // Don't allow relative URLs if the base scheme doesn't support it. - return false; - } - - *relative_component = MakeRange(begin, url_len); - *is_relative = true; - return true; - } - - // If the scheme isn't valid, then it's relative. - int scheme_end = scheme.end(); - for (int i = scheme.begin; i < scheme_end; i++) { - if (!CanonicalSchemeChar(url[i])) { - if (!is_base_hierarchical) { - // Don't allow relative URLs if the base scheme doesn't support it. - return false; - } - *relative_component = MakeRange(begin, url_len); - *is_relative = true; - return true; - } - } - - // If the scheme is not the same, then we can't count it as relative. - if (!AreSchemesEqual(base, base_parsed.scheme, url, scheme)) - return true; - - // When the scheme that they both share is not hierarchical, treat the - // incoming scheme as absolute (this way with the base of "data:foo", - // "data:bar" will be reported as absolute. - if (!is_base_hierarchical) - return true; - - int colon_offset = scheme.end(); - - // If it's a filesystem URL, the only valid way to make it relative is not to - // supply a scheme. There's no equivalent to e.g. http:index.html. - if (CompareSchemeComponent(url, scheme, kFileSystemScheme)) - return true; - - // ExtractScheme guarantees that the colon immediately follows what it - // considers to be the scheme. CountConsecutiveSlashes will handle the - // case where the begin offset is the end of the input. - int num_slashes = CountConsecutiveSlashes(url, colon_offset + 1, url_len); - - if (num_slashes == 0 || num_slashes == 1) { - // No slashes means it's a relative path like "http:foo.html". One slash - // is an absolute path. "http:/home/foo.html" - *is_relative = true; - *relative_component = MakeRange(colon_offset + 1, url_len); - return true; - } - - // Two or more slashes after the scheme we treat as absolute. - return true; -} - -// Copies all characters in the range [begin, end) of |spec| to the output, -// up until and including the last slash. There should be a slash in the -// range, if not, nothing will be copied. -// -// For stardard URLs the input should be canonical, but when resolving relative -// URLs on a non-standard base (like "data:") the input can be anything. -void CopyToLastSlash(const char* spec, - int begin, - int end, - CanonOutput* output) { - // Find the last slash. - int last_slash = -1; - for (int i = end - 1; i >= begin; i--) { - if (spec[i] == '/' || spec[i] == '\\') { - last_slash = i; - break; - } - } - if (last_slash < 0) - return; // No slash. - - // Copy. - for (int i = begin; i <= last_slash; i++) - output->push_back(spec[i]); -} - -// Copies a single component from the source to the output. This is used -// when resolving relative URLs and a given component is unchanged. Since the -// source should already be canonical, we don't have to do anything special, -// and the input is ASCII. -void CopyOneComponent(const char* source, - const Component& source_component, - CanonOutput* output, - Component* output_component) { - if (source_component.len < 0) { - // This component is not present. - *output_component = Component(); - return; - } - - output_component->begin = output->length(); - int source_end = source_component.end(); - for (int i = source_component.begin; i < source_end; i++) - output->push_back(source[i]); - output_component->len = output->length() - output_component->begin; -} - -#ifdef WIN32 - -// Called on Windows when the base URL is a file URL, this will copy the "C:" -// to the output, if there is a drive letter and if that drive letter is not -// being overridden by the relative URL. Otherwise, do nothing. -// -// It will return the index of the beginning of the next character in the -// base to be processed: if there is a "C:", the slash after it, or if -// there is no drive letter, the slash at the beginning of the path, or -// the end of the base. This can be used as the starting offset for further -// path processing. -template -int CopyBaseDriveSpecIfNecessary(const char* base_url, - int base_path_begin, - int base_path_end, - const CHAR* relative_url, - int path_start, - int relative_url_len, - CanonOutput* output) { - if (base_path_begin >= base_path_end) - return base_path_begin; // No path. - - // If the relative begins with a drive spec, don't do anything. The existing - // drive spec in the base will be replaced. - if (DoesBeginWindowsDriveSpec(relative_url, path_start, relative_url_len)) { - return base_path_begin; // Relative URL path is "C:/foo" - } - - // The path should begin with a slash (as all canonical paths do). We check - // if it is followed by a drive letter and copy it. - if (DoesBeginSlashWindowsDriveSpec(base_url, - base_path_begin, - base_path_end)) { - // Copy the two-character drive spec to the output. It will now look like - // "file:///C:" so the rest of it can be treated like a standard path. - output->push_back('/'); - output->push_back(base_url[base_path_begin + 1]); - output->push_back(base_url[base_path_begin + 2]); - return base_path_begin + 3; - } - - return base_path_begin; -} - -#endif // WIN32 - -// A subroutine of DoResolveRelativeURL, this resolves the URL knowning that -// the input is a relative path or less (qyuery or ref). -template -bool DoResolveRelativePath(const char* base_url, - const Parsed& base_parsed, - bool base_is_file, - const CHAR* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed) { - bool success = true; - - // We know the authority section didn't change, copy it to the output. We - // also know we have a path so can copy up to there. - Component path, query, ref; - ParsePathInternal(relative_url, relative_component, &path, &query, &ref); - // Canonical URLs always have a path, so we can use that offset. - output->Append(base_url, base_parsed.path.begin); - - if (path.len > 0) { - // The path is replaced or modified. - int true_path_begin = output->length(); - - // For file: URLs on Windows, we don't want to treat the drive letter and - // colon as part of the path for relative file resolution when the - // incoming URL does not provide a drive spec. We save the true path - // beginning so we can fix it up after we are done. - int base_path_begin = base_parsed.path.begin; -#ifdef WIN32 - if (base_is_file) { - base_path_begin = CopyBaseDriveSpecIfNecessary( - base_url, base_parsed.path.begin, base_parsed.path.end(), - relative_url, relative_component.begin, relative_component.end(), - output); - // Now the output looks like either "file://" or "file:///C:" - // and we can start appending the rest of the path. |base_path_begin| - // points to the character in the base that comes next. - } -#endif // WIN32 - - if (IsURLSlash(relative_url[path.begin])) { - // Easy case: the path is an absolute path on the server, so we can - // just replace everything from the path on with the new versions. - // Since the input should be canonical hierarchical URL, we should - // always have a path. - success &= CanonicalizePath(relative_url, path, - output, &out_parsed->path); - } else { - // Relative path, replace the query, and reference. We take the - // original path with the file part stripped, and append the new path. - // The canonicalizer will take care of resolving ".." and "." - int path_begin = output->length(); - CopyToLastSlash(base_url, base_path_begin, base_parsed.path.end(), - output); - success &= CanonicalizePartialPath(relative_url, path, path_begin, - output); - out_parsed->path = MakeRange(path_begin, output->length()); - - // Copy the rest of the stuff after the path from the relative path. - } - - // Finish with the query and reference part (these can't fail). - CanonicalizeQuery(relative_url, query, query_converter, - output, &out_parsed->query); - CanonicalizeRef(relative_url, ref, output, &out_parsed->ref); - - // Fix the path beginning to add back the "C:" we may have written above. - out_parsed->path = MakeRange(true_path_begin, out_parsed->path.end()); - return success; - } - - // If we get here, the path is unchanged: copy to output. - CopyOneComponent(base_url, base_parsed.path, output, &out_parsed->path); - - if (query.is_valid()) { - // Just the query specified, replace the query and reference (ignore - // failures for refs) - CanonicalizeQuery(relative_url, query, query_converter, - output, &out_parsed->query); - CanonicalizeRef(relative_url, ref, output, &out_parsed->ref); - return success; - } - - // If we get here, the query is unchanged: copy to output. Note that the - // range of the query parameter doesn't include the question mark, so we - // have to add it manually if there is a component. - if (base_parsed.query.is_valid()) - output->push_back('?'); - CopyOneComponent(base_url, base_parsed.query, output, &out_parsed->query); - - if (ref.is_valid()) { - // Just the reference specified: replace it (ignoring failures). - CanonicalizeRef(relative_url, ref, output, &out_parsed->ref); - return success; - } - - // We should always have something to do in this function, the caller checks - // that some component is being replaced. - //DCHECK(false) << "Not reached"; - return success; -} - -// Resolves a relative URL that contains a host. Typically, these will -// be of the form "//www.google.com/foo/bar?baz#ref" and the only thing which -// should be kept from the original URL is the scheme. -template -bool DoResolveRelativeHost(const char* base_url, - const Parsed& base_parsed, - const CHAR* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed) { - // Parse the relative URL, just like we would for anything following a - // scheme. - Parsed relative_parsed; // Everything but the scheme is valid. - ParseAfterScheme(relative_url, relative_component.end(), - relative_component.begin, &relative_parsed); - - // Now we can just use the replacement function to replace all the necessary - // parts of the old URL with the new one. - Replacements replacements; - replacements.SetUsername(relative_url, relative_parsed.username); - replacements.SetPassword(relative_url, relative_parsed.password); - replacements.SetHost(relative_url, relative_parsed.host); - replacements.SetPort(relative_url, relative_parsed.port); - replacements.SetPath(relative_url, relative_parsed.path); - replacements.SetQuery(relative_url, relative_parsed.query); - replacements.SetRef(relative_url, relative_parsed.ref); - - return ReplaceStandardURL(base_url, base_parsed, replacements, - query_converter, output, out_parsed); -} - -// Resolves a relative URL that happens to be an absolute file path. Examples -// include: "//hostname/path", "/c:/foo", and "//hostname/c:/foo". -template -bool DoResolveAbsoluteFile(const CHAR* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed) { - // Parse the file URL. The file URl parsing function uses the same logic - // as we do for determining if the file is absolute, in which case it will - // not bother to look for a scheme. - Parsed relative_parsed; - ParseFileURL(&relative_url[relative_component.begin], relative_component.len, - &relative_parsed); - - return CanonicalizeFileURL(&relative_url[relative_component.begin], - relative_component.len, relative_parsed, - query_converter, output, out_parsed); -} - -// TODO(brettw) treat two slashes as root like Mozilla for FTP? -template -bool DoResolveRelativeURL(const char* base_url, - const Parsed& base_parsed, - bool base_is_file, - const CHAR* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed) { - // Starting point for our output parsed. We'll fix what we change. - *out_parsed = base_parsed; - - // Sanity check: the input should have a host or we'll break badly below. - // We can only resolve relative URLs with base URLs that have hosts and - // paths (even the default path of "/" is OK). - // - // We allow hosts with no length so we can handle file URLs, for example. - if (base_parsed.path.len <= 0) { - // On error, return the input (resolving a relative URL on a non-relative - // base = the base). - int base_len = base_parsed.Length(); - for (int i = 0; i < base_len; i++) - output->push_back(base_url[i]); - return false; - } - - if (relative_component.len <= 0) { - // Empty relative URL, leave unchanged, only removing the ref component. - int base_len = base_parsed.Length(); - base_len -= base_parsed.ref.len + 1; - out_parsed->ref.reset(); - output->Append(base_url, base_len); - return true; - } - - int num_slashes = CountConsecutiveSlashes( - relative_url, relative_component.begin, relative_component.end()); - -#ifdef WIN32 - // On Windows, two slashes for a file path (regardless of which direction - // they are) means that it's UNC. Two backslashes on any base scheme mean - // that it's an absolute UNC path (we use the base_is_file flag to control - // how strict the UNC finder is). - // - // We also allow Windows absolute drive specs on any scheme (for example - // "c:\foo") like IE does. There must be no preceding slashes in this - // case (we reject anything like "/c:/foo") because that should be treated - // as a path. For file URLs, we allow any number of slashes since that would - // be setting the path. - // - // This assumes the absolute path resolver handles absolute URLs like this - // properly. DoCanonicalize does this. - int after_slashes = relative_component.begin + num_slashes; - if (DoesBeginUNCPath(relative_url, relative_component.begin, - relative_component.end(), !base_is_file) || - ((num_slashes == 0 || base_is_file) && - DoesBeginWindowsDriveSpec( - relative_url, after_slashes, relative_component.end()))) { - return DoResolveAbsoluteFile(relative_url, relative_component, - query_converter, output, out_parsed); - } -#else - // Other platforms need explicit handling for file: URLs with multiple - // slashes because the generic scheme parsing always extracts a host, but a - // file: URL only has a host if it has exactly 2 slashes. Even if it does - // have a host, we want to use the special host detection logic for file - // URLs provided by DoResolveAbsoluteFile(), as opposed to the generic host - // detection logic, for consistency with parsing file URLs from scratch. - // This also handles the special case where the URL is only slashes, - // since that doesn't have a host part either. - if (base_is_file && - (num_slashes >= 2 || num_slashes == relative_component.len)) { - return DoResolveAbsoluteFile(relative_url, relative_component, - query_converter, output, out_parsed); - } -#endif - - // Any other double-slashes mean that this is relative to the scheme. - if (num_slashes >= 2) { - return DoResolveRelativeHost(base_url, base_parsed, - relative_url, relative_component, - query_converter, output, out_parsed); - } - - // When we get here, we know that the relative URL is on the same host. - return DoResolveRelativePath(base_url, base_parsed, base_is_file, - relative_url, relative_component, - query_converter, output, out_parsed); -} - -} // namespace - -bool IsRelativeURL(const char* base, - const Parsed& base_parsed, - const char* fragment, - int fragment_len, - bool is_base_hierarchical, - bool* is_relative, - Component* relative_component) { - return DoIsRelativeURL( - base, base_parsed, fragment, fragment_len, is_base_hierarchical, - is_relative, relative_component); -} - -bool IsRelativeURL(const char* base, - const Parsed& base_parsed, - const base::char16* fragment, - int fragment_len, - bool is_base_hierarchical, - bool* is_relative, - Component* relative_component) { - return DoIsRelativeURL( - base, base_parsed, fragment, fragment_len, is_base_hierarchical, - is_relative, relative_component); -} - -bool ResolveRelativeURL(const char* base_url, - const Parsed& base_parsed, - bool base_is_file, - const char* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed) { - return DoResolveRelativeURL( - base_url, base_parsed, base_is_file, relative_url, - relative_component, query_converter, output, out_parsed); -} - -bool ResolveRelativeURL(const char* base_url, - const Parsed& base_parsed, - bool base_is_file, - const base::char16* relative_url, - const Component& relative_component, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* out_parsed) { - return DoResolveRelativeURL( - base_url, base_parsed, base_is_file, relative_url, - relative_component, query_converter, output, out_parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_stdstring.cc b/vendor/gurl/url/url_canon_stdstring.cc deleted file mode 100644 index 366a2e0..0000000 --- a/vendor/gurl/url/url_canon_stdstring.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "url/url_canon_stdstring.h" - -namespace url { - -StdStringCanonOutput::StdStringCanonOutput(std::string* str) - : CanonOutput(), str_(str) { - cur_len_ = static_cast(str_->size()); // Append to existing data. - str_->resize(str_->capacity()); - buffer_ = str_->empty() ? NULL : &(*str_)[0]; - buffer_len_ = static_cast(str_->size()); -} - -StdStringCanonOutput::~StdStringCanonOutput() { - // Nothing to do, we don't own the string. -} - -void StdStringCanonOutput::Complete() { - str_->resize(cur_len_); - buffer_len_ = cur_len_; -} - -void StdStringCanonOutput::Resize(int sz) { - str_->resize(sz); - buffer_ = str_->empty() ? NULL : &(*str_)[0]; - buffer_len_ = sz; -} - -} // namespace url diff --git a/vendor/gurl/url/url_canon_stdstring.h b/vendor/gurl/url/url_canon_stdstring.h deleted file mode 100644 index 662cac7..0000000 --- a/vendor/gurl/url/url_canon_stdstring.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_CANON_STDSTRING_H_ -#define URL_URL_CANON_STDSTRING_H_ - -// This header file defines a canonicalizer output method class for STL -// strings. Because the canonicalizer tries not to be dependent on the STL, -// we have segregated it here. - -#include - -#include "base/compiler_specific.h" -#include "base/strings/string_piece.h" -#include "url/url_canon.h" -#include "url/url_export.h" - -namespace url { - -// Write into a std::string given in the constructor. This object does not own -// the string itself, and the user must ensure that the string stays alive -// throughout the lifetime of this object. -// -// The given string will be appended to; any existing data in the string will -// be preserved. The caller should reserve() the amount of data in the string -// they expect to be written. We will resize if necessary, but that's slow. -// -// Note that when canonicalization is complete, the string will likely have -// unused space at the end because we make the string very big to start out -// with (by |initial_size|). This ends up being important because resize -// operations are slow, and because the base class needs to write directly -// into the buffer. -// -// Therefore, the user should call Complete() before using the string that -// this class wrote into. -class URL_EXPORT StdStringCanonOutput : public CanonOutput { - public: - StdStringCanonOutput(std::string* str); - ~StdStringCanonOutput() override; - - // Must be called after writing has completed but before the string is used. - void Complete(); - - void Resize(int sz) override; - - protected: - std::string* str_; -}; - -// An extension of the Replacements class that allows the setters to use -// StringPieces (implicitly allowing strings or char*s). -// -// The contents of the StringPieces are not copied and must remain valid until -// the StringPieceReplacements object goes out of scope. -template -class StringPieceReplacements : public Replacements { - public: - void SetSchemeStr(const base::BasicStringPiece& s) { - this->SetScheme(s.data(), Component(0, static_cast(s.length()))); - } - void SetUsernameStr(const base::BasicStringPiece& s) { - this->SetUsername(s.data(), Component(0, static_cast(s.length()))); - } - void SetPasswordStr(const base::BasicStringPiece& s) { - this->SetPassword(s.data(), Component(0, static_cast(s.length()))); - } - void SetHostStr(const base::BasicStringPiece& s) { - this->SetHost(s.data(), Component(0, static_cast(s.length()))); - } - void SetPortStr(const base::BasicStringPiece& s) { - this->SetPort(s.data(), Component(0, static_cast(s.length()))); - } - void SetPathStr(const base::BasicStringPiece& s) { - this->SetPath(s.data(), Component(0, static_cast(s.length()))); - } - void SetQueryStr(const base::BasicStringPiece& s) { - this->SetQuery(s.data(), Component(0, static_cast(s.length()))); - } - void SetRefStr(const base::BasicStringPiece& s) { - this->SetRef(s.data(), Component(0, static_cast(s.length()))); - } -}; - -} // namespace url - -#endif // URL_URL_CANON_STDSTRING_H_ diff --git a/vendor/gurl/url/url_canon_stdurl.cc b/vendor/gurl/url/url_canon_stdurl.cc deleted file mode 100644 index 7d1758b..0000000 --- a/vendor/gurl/url/url_canon_stdurl.cc +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Functions to canonicalize "standard" URLs, which are ones that have an -// authority section including a host name. - -#include "url/url_canon.h" -#include "url/url_canon_internal.h" -#include "url/url_constants.h" - -namespace url { - -namespace { - -template -bool DoCanonicalizeStandardURL(const URLComponentSource& source, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - // Scheme: this will append the colon. - bool success = CanonicalizeScheme(source.scheme, parsed.scheme, - output, &new_parsed->scheme); - - // Authority (username, password, host, port) - bool have_authority; - if (parsed.username.is_valid() || parsed.password.is_valid() || - parsed.host.is_nonempty() || parsed.port.is_valid()) { - have_authority = true; - - // Only write the authority separators when we have a scheme. - if (parsed.scheme.is_valid()) { - output->push_back('/'); - output->push_back('/'); - } - - // User info: the canonicalizer will handle the : and @. - success &= CanonicalizeUserInfo(source.username, parsed.username, - source.password, parsed.password, - output, - &new_parsed->username, - &new_parsed->password); - - success &= CanonicalizeHost(source.host, parsed.host, - output, &new_parsed->host); - - // Host must not be empty for standard URLs. - if (!parsed.host.is_nonempty()) - success = false; - - // Port: the port canonicalizer will handle the colon. - int default_port = DefaultPortForScheme( - &output->data()[new_parsed->scheme.begin], new_parsed->scheme.len); - success &= CanonicalizePort(source.port, parsed.port, default_port, - output, &new_parsed->port); - } else { - // No authority, clear the components. - have_authority = false; - new_parsed->host.reset(); - new_parsed->username.reset(); - new_parsed->password.reset(); - new_parsed->port.reset(); - success = false; // Standard URLs must have an authority. - } - - // Path - if (parsed.path.is_valid()) { - success &= CanonicalizePath(source.path, parsed.path, - output, &new_parsed->path); - } else if (have_authority || - parsed.query.is_valid() || parsed.ref.is_valid()) { - // When we have an empty path, make up a path when we have an authority - // or something following the path. The only time we allow an empty - // output path is when there is nothing else. - new_parsed->path = Component(output->length(), 1); - output->push_back('/'); - } else { - // No path at all - new_parsed->path.reset(); - } - - // Query - CanonicalizeQuery(source.query, parsed.query, query_converter, - output, &new_parsed->query); - - // Ref: ignore failure for this, since the page can probably still be loaded. - CanonicalizeRef(source.ref, parsed.ref, output, &new_parsed->ref); - - return success; -} - -} // namespace - - -// Returns the default port for the given canonical scheme, or PORT_UNSPECIFIED -// if the scheme is unknown. -int DefaultPortForScheme(const char* scheme, int scheme_len) { - int default_port = PORT_UNSPECIFIED; - switch (scheme_len) { - case 4: - if (!strncmp(scheme, kHttpScheme, scheme_len)) - default_port = 80; - break; - case 5: - if (!strncmp(scheme, kHttpsScheme, scheme_len)) - default_port = 443; - break; - case 3: - if (!strncmp(scheme, kFtpScheme, scheme_len)) - default_port = 21; - else if (!strncmp(scheme, kWssScheme, scheme_len)) - default_port = 443; - break; - case 6: - if (!strncmp(scheme, kGopherScheme, scheme_len)) - default_port = 70; - break; - case 2: - if (!strncmp(scheme, kWsScheme, scheme_len)) - default_port = 80; - break; - } - return default_port; -} - -bool CanonicalizeStandardURL(const char* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeStandardURL( - URLComponentSource(spec), parsed, query_converter, - output, new_parsed); -} - -bool CanonicalizeStandardURL(const base::char16* spec, - int spec_len, - const Parsed& parsed, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - return DoCanonicalizeStandardURL( - URLComponentSource(spec), parsed, query_converter, - output, new_parsed); -} - -// It might be nice in the future to optimize this so unchanged components don't -// need to be recanonicalized. This is especially true since the common case for -// ReplaceComponents is removing things we don't want, like reference fragments -// and usernames. These cases can become more efficient if we can assume the -// rest of the URL is OK with these removed (or only the modified parts -// recanonicalized). This would be much more complex to implement, however. -// -// You would also need to update DoReplaceComponents in url_util.cc which -// relies on this re-checking everything (see the comment there for why). -bool ReplaceStandardURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupOverrideComponents(base, replacements, &source, &parsed); - return DoCanonicalizeStandardURL( - source, parsed, query_converter, output, new_parsed); -} - -// For 16-bit replacements, we turn all the replacements into UTF-8 so the -// regular code path can be used. -bool ReplaceStandardURL(const char* base, - const Parsed& base_parsed, - const Replacements& replacements, - CharsetConverter* query_converter, - CanonOutput* output, - Parsed* new_parsed) { - RawCanonOutput<1024> utf8; - URLComponentSource source(base); - Parsed parsed(base_parsed); - SetupUTF16OverrideComponents(base, replacements, &utf8, &source, &parsed); - return DoCanonicalizeStandardURL( - source, parsed, query_converter, output, new_parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/url_constants.cc b/vendor/gurl/url/url_constants.cc deleted file mode 100644 index 2dc1478..0000000 --- a/vendor/gurl/url/url_constants.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "url/url_constants.h" - -namespace url { - -const char kAboutBlankURL[] = "about:blank"; - -const char kAboutScheme[] = "about"; -const char kBlobScheme[] = "blob"; -const char kContentScheme[] = "content"; -const char kDataScheme[] = "data"; -const char kFileScheme[] = "file"; -const char kFileSystemScheme[] = "filesystem"; -const char kFtpScheme[] = "ftp"; -const char kGopherScheme[] = "gopher"; -const char kHttpScheme[] = "http"; -const char kHttpsScheme[] = "https"; -const char kJavaScriptScheme[] = "javascript"; -const char kMailToScheme[] = "mailto"; -const char kWsScheme[] = "ws"; -const char kWssScheme[] = "wss"; - -const char kStandardSchemeSeparator[] = "://"; - -} // namespace url diff --git a/vendor/gurl/url/url_constants.h b/vendor/gurl/url/url_constants.h deleted file mode 100644 index c48dafc..0000000 --- a/vendor/gurl/url/url_constants.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_CONSTANTS_H_ -#define URL_URL_CONSTANTS_H_ - -#include "url/url_export.h" - -namespace url { - -URL_EXPORT extern const char kAboutBlankURL[]; - -URL_EXPORT extern const char kAboutScheme[]; -URL_EXPORT extern const char kBlobScheme[]; -// The content scheme is specific to Android for identifying a stored file. -URL_EXPORT extern const char kContentScheme[]; -URL_EXPORT extern const char kDataScheme[]; -URL_EXPORT extern const char kFileScheme[]; -URL_EXPORT extern const char kFileSystemScheme[]; -URL_EXPORT extern const char kFtpScheme[]; -URL_EXPORT extern const char kGopherScheme[]; -URL_EXPORT extern const char kHttpScheme[]; -URL_EXPORT extern const char kHttpsScheme[]; -URL_EXPORT extern const char kJavaScriptScheme[]; -URL_EXPORT extern const char kMailToScheme[]; -URL_EXPORT extern const char kWsScheme[]; -URL_EXPORT extern const char kWssScheme[]; - -// Used to separate a standard scheme and the hostname: "://". -URL_EXPORT extern const char kStandardSchemeSeparator[]; - -} // namespace url - -#endif // URL_URL_CONSTANTS_H_ diff --git a/vendor/gurl/url/url_export.h b/vendor/gurl/url/url_export.h deleted file mode 100644 index 15ef19e..0000000 --- a/vendor/gurl/url/url_export.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_EXPORT_H_ -#define URL_URL_EXPORT_H_ - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(URL_IMPLEMENTATION) -#define URL_EXPORT __declspec(dllexport) -#else -#define URL_EXPORT __declspec(dllimport) -#endif // defined(URL_IMPLEMENTATION) - -#else // !defined(WIN32) - -#if defined(URL_IMPLEMENTATION) -#define URL_EXPORT __attribute__((visibility("default"))) -#else -#define URL_EXPORT -#endif // defined(URL_IMPLEMENTATION) - -#endif // defined(WIN32) - -#else // !defined(COMPONENT_BUILD) - -#define URL_EXPORT - -#endif // define(COMPONENT_BUILD) - -#endif // URL_URL_EXPORT_H_ diff --git a/vendor/gurl/url/url_file.h b/vendor/gurl/url/url_file.h deleted file mode 100644 index 540cb25..0000000 --- a/vendor/gurl/url/url_file.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_FILE_H_ -#define URL_URL_FILE_H_ - -// Provides shared functions used by the internals of the parser and -// canonicalizer for file URLs. Do not use outside of these modules. - -#include "url/url_parse_internal.h" - -namespace url { - -#ifdef WIN32 - -// We allow both "c:" and "c|" as drive identifiers. -inline bool IsWindowsDriveSeparator(base::char16 ch) { - return ch == ':' || ch == '|'; -} -inline bool IsWindowsDriveLetter(base::char16 ch) { - return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); -} - -#endif // WIN32 - -// Returns the index of the next slash in the input after the given index, or -// spec_len if the end of the input is reached. -template -inline int FindNextSlash(const CHAR* spec, int begin_index, int spec_len) { - int idx = begin_index; - while (idx < spec_len && !IsURLSlash(spec[idx])) - idx++; - return idx; -} - -#ifdef WIN32 - -// Returns true if the start_offset in the given spec looks like it begins a -// drive spec, for example "c:". This function explicitly handles start_offset -// values that are equal to or larger than the spec_len to simplify callers. -// -// If this returns true, the spec is guaranteed to have a valid drive letter -// plus a colon starting at |start_offset|. -template -inline bool DoesBeginWindowsDriveSpec(const CHAR* spec, int start_offset, - int spec_len) { - int remaining_len = spec_len - start_offset; - if (remaining_len < 2) - return false; // Not enough room. - if (!IsWindowsDriveLetter(spec[start_offset])) - return false; // Doesn't start with a valid drive letter. - if (!IsWindowsDriveSeparator(spec[start_offset + 1])) - return false; // Isn't followed with a drive separator. - return true; -} - -// Returns true if the start_offset in the given text looks like it begins a -// UNC path, for example "\\". This function explicitly handles start_offset -// values that are equal to or larger than the spec_len to simplify callers. -// -// When strict_slashes is set, this function will only accept backslashes as is -// standard for Windows. Otherwise, it will accept forward slashes as well -// which we use for a lot of URL handling. -template -inline bool DoesBeginUNCPath(const CHAR* text, - int start_offset, - int len, - bool strict_slashes) { - int remaining_len = len - start_offset; - if (remaining_len < 2) - return false; - - if (strict_slashes) - return text[start_offset] == '\\' && text[start_offset + 1] == '\\'; - return IsURLSlash(text[start_offset]) && IsURLSlash(text[start_offset + 1]); -} - -#endif // WIN32 - -} // namespace url - -#endif // URL_URL_FILE_H_ diff --git a/vendor/gurl/url/url_parse_file.cc b/vendor/gurl/url/url_parse_file.cc deleted file mode 100644 index 10d589e..0000000 --- a/vendor/gurl/url/url_parse_file.cc +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -//#include "base/logging.h" -#include "url/third_party/mozilla/url_parse.h" -#include "url/url_file.h" -#include "url/url_parse_internal.h" - -// Interesting IE file:isms... -// -// INPUT OUTPUT -// ========================= ============================== -// file:/foo/bar file:///foo/bar -// The result here seems totally invalid!?!? This isn't UNC. -// -// file:/ -// file:// or any other number of slashes -// IE6 doesn't do anything at all if you click on this link. No error: -// nothing. IE6's history system seems to always color this link, so I'm -// guessing that it maps internally to the empty URL. -// -// C:\ file:///C:/ -// When on a file: URL source page, this link will work. When over HTTP, -// the file: URL will appear in the status bar but the link will not work -// (security restriction for all file URLs). -// -// file:foo/ file:foo/ (invalid?!?!?) -// file:/foo/ file:///foo/ (invalid?!?!?) -// file://foo/ file://foo/ (UNC to server "foo") -// file:///foo/ file:///foo/ (invalid, seems to be a file) -// file:////foo/ file://foo/ (UNC to server "foo") -// Any more than four slashes is also treated as UNC. -// -// file:C:/ file://C:/ -// file:/C:/ file://C:/ -// The number of slashes after "file:" don't matter if the thing following -// it looks like an absolute drive path. Also, slashes and backslashes are -// equally valid here. - -namespace url { - -namespace { - -// A subcomponent of DoInitFileURL, the input of this function should be a UNC -// path name, with the index of the first character after the slashes following -// the scheme given in |after_slashes|. This will initialize the host, path, -// query, and ref, and leave the other output components untouched -// (DoInitFileURL handles these for us). -template -void DoParseUNC(const CHAR* spec, - int after_slashes, - int spec_len, - Parsed* parsed) { - int next_slash = FindNextSlash(spec, after_slashes, spec_len); - if (next_slash == spec_len) { - // No additional slash found, as in "file://foo", treat the text as the - // host with no path (this will end up being UNC to server "foo"). - int host_len = spec_len - after_slashes; - if (host_len) - parsed->host = Component(after_slashes, host_len); - else - parsed->host.reset(); - parsed->path.reset(); - return; - } - -#ifdef WIN32 - // See if we have something that looks like a path following the first - // component. As in "file://localhost/c:/", we get "c:/" out. We want to - // treat this as a having no host but the path given. Works on Windows only. - if (DoesBeginWindowsDriveSpec(spec, next_slash + 1, spec_len)) { - parsed->host.reset(); - ParsePathInternal(spec, MakeRange(next_slash, spec_len), - &parsed->path, &parsed->query, &parsed->ref); - return; - } -#endif - - // Otherwise, everything up until that first slash we found is the host name, - // which will end up being the UNC host. For example "file://foo/bar.txt" - // will get a server name of "foo" and a path of "/bar". Later, on Windows, - // this should be treated as the filename "\\foo\bar.txt" in proper UNC - // notation. - int host_len = next_slash - after_slashes; - if (host_len) - parsed->host = MakeRange(after_slashes, next_slash); - else - parsed->host.reset(); - if (next_slash < spec_len) { - ParsePathInternal(spec, MakeRange(next_slash, spec_len), - &parsed->path, &parsed->query, &parsed->ref); - } else { - parsed->path.reset(); - } -} - -// A subcomponent of DoParseFileURL, the input should be a local file, with the -// beginning of the path indicated by the index in |path_begin|. This will -// initialize the host, path, query, and ref, and leave the other output -// components untouched (DoInitFileURL handles these for us). -template -void DoParseLocalFile(const CHAR* spec, - int path_begin, - int spec_len, - Parsed* parsed) { - parsed->host.reset(); - ParsePathInternal(spec, MakeRange(path_begin, spec_len), - &parsed->path, &parsed->query, &parsed->ref); -} - -// Backend for the external functions that operates on either char type. -// Handles cases where there is a scheme, but also when handed the first -// character following the "file:" at the beginning of the spec. If so, -// this is usually a slash, but needn't be; we allow paths like "file:c:\foo". -template -void DoParseFileURL(const CHAR* spec, int spec_len, Parsed* parsed) { - //DCHECK(spec_len >= 0); - - // Get the parts we never use for file URLs out of the way. - parsed->username.reset(); - parsed->password.reset(); - parsed->port.reset(); - - // Many of the code paths don't set these, so it's convenient to just clear - // them. We'll write them in those cases we need them. - parsed->query.reset(); - parsed->ref.reset(); - - // Strip leading & trailing spaces and control characters. - int begin = 0; - TrimURL(spec, &begin, &spec_len); - - // Find the scheme, if any. - int num_slashes = CountConsecutiveSlashes(spec, begin, spec_len); - int after_scheme; - int after_slashes; -#ifdef WIN32 - // See how many slashes there are. We want to handle cases like UNC but also - // "/c:/foo". This is when there is no scheme, so we can allow pages to do - // links like "c:/foo/bar" or "//foo/bar". This is also called by the - // relative URL resolver when it determines there is an absolute URL, which - // may give us input like "/c:/foo". - after_slashes = begin + num_slashes; - if (DoesBeginWindowsDriveSpec(spec, after_slashes, spec_len)) { - // Windows path, don't try to extract the scheme (for example, "c:\foo"). - parsed->scheme.reset(); - after_scheme = after_slashes; - } else if (DoesBeginUNCPath(spec, begin, spec_len, false)) { - // Windows UNC path: don't try to extract the scheme, but keep the slashes. - parsed->scheme.reset(); - after_scheme = begin; - } else -#endif - { - // ExtractScheme doesn't understand the possibility of filenames with - // colons in them, in which case it returns the entire spec up to the - // colon as the scheme. So handle /foo.c:5 as a file but foo.c:5 as - // the foo.c: scheme. - if (!num_slashes && - ExtractScheme(&spec[begin], spec_len - begin, &parsed->scheme)) { - // Offset the results since we gave ExtractScheme a substring. - parsed->scheme.begin += begin; - after_scheme = parsed->scheme.end() + 1; - } else { - // No scheme found, remember that. - parsed->scheme.reset(); - after_scheme = begin; - } - } - - // Handle empty specs ones that contain only whitespace or control chars, - // or that are just the scheme (for example "file:"). - if (after_scheme == spec_len) { - parsed->host.reset(); - parsed->path.reset(); - return; - } - - num_slashes = CountConsecutiveSlashes(spec, after_scheme, spec_len); - after_slashes = after_scheme + num_slashes; -#ifdef WIN32 - // Check whether the input is a drive again. We checked above for windows - // drive specs, but that's only at the very beginning to see if we have a - // scheme at all. This test will be duplicated in that case, but will - // additionally handle all cases with a real scheme such as "file:///C:/". - if (!DoesBeginWindowsDriveSpec(spec, after_slashes, spec_len) && - num_slashes != 3) { - // Anything not beginning with a drive spec ("c:\") on Windows is treated - // as UNC, with the exception of three slashes which always means a file. - // Even IE7 treats file:///foo/bar as "/foo/bar", which then fails. - DoParseUNC(spec, after_slashes, spec_len, parsed); - return; - } -#else - // file: URL with exactly 2 slashes is considered to have a host component. - if (num_slashes == 2) { - DoParseUNC(spec, after_slashes, spec_len, parsed); - return; - } -#endif // WIN32 - - // Easy and common case, the full path immediately follows the scheme - // (modulo slashes), as in "file://c:/foo". Just treat everything from - // there to the end as the path. Empty hosts have 0 length instead of -1. - // We include the last slash as part of the path if there is one. - DoParseLocalFile(spec, - num_slashes > 0 ? after_scheme + num_slashes - 1 : after_scheme, - spec_len, parsed); -} - -} // namespace - -void ParseFileURL(const char* url, int url_len, Parsed* parsed) { - DoParseFileURL(url, url_len, parsed); -} - -void ParseFileURL(const base::char16* url, int url_len, Parsed* parsed) { - DoParseFileURL(url, url_len, parsed); -} - -} // namespace url diff --git a/vendor/gurl/url/url_parse_internal.h b/vendor/gurl/url/url_parse_internal.h deleted file mode 100644 index 7630878..0000000 --- a/vendor/gurl/url/url_parse_internal.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_PARSE_INTERNAL_H_ -#define URL_URL_PARSE_INTERNAL_H_ - -// Contains common inline helper functions used by the URL parsing routines. - -#include "url/third_party/mozilla/url_parse.h" - -namespace url { - -// We treat slashes and backslashes the same for IE compatibility. -inline bool IsURLSlash(base::char16 ch) { - return ch == '/' || ch == '\\'; -} - -// Returns true if we should trim this character from the URL because it is a -// space or a control character. -inline bool ShouldTrimFromURL(base::char16 ch) { - return ch <= ' '; -} - -// Given an already-initialized begin index and length, this shrinks the range -// to eliminate "should-be-trimmed" characters. Note that the length does *not* -// indicate the length of untrimmed data from |*begin|, but rather the position -// in the input string (so the string starts at character |*begin| in the spec, -// and goes until |*len|). -template -inline void TrimURL(const CHAR* spec, int* begin, int* len, - bool trim_path_end = true) { - // Strip leading whitespace and control characters. - while (*begin < *len && ShouldTrimFromURL(spec[*begin])) - (*begin)++; - - if (trim_path_end) { - // Strip trailing whitespace and control characters. We need the >i test - // for when the input string is all blanks; we don't want to back past the - // input. - while (*len > *begin && ShouldTrimFromURL(spec[*len - 1])) - (*len)--; - } -} - -// Counts the number of consecutive slashes starting at the given offset -// in the given string of the given length. -template -inline int CountConsecutiveSlashes(const CHAR *str, - int begin_offset, int str_len) { - int count = 0; - while (begin_offset + count < str_len && - IsURLSlash(str[begin_offset + count])) - ++count; - return count; -} - -// Internal functions in url_parse.cc that parse the path, that is, everything -// following the authority section. The input is the range of everything -// following the authority section, and the output is the identified ranges. -// -// This is designed for the file URL parser or other consumers who may do -// special stuff at the beginning, but want regular path parsing, it just -// maps to the internal parsing function for paths. -void ParsePathInternal(const char* spec, - const Component& path, - Component* filepath, - Component* query, - Component* ref); -void ParsePathInternal(const base::char16* spec, - const Component& path, - Component* filepath, - Component* query, - Component* ref); - - -// Given a spec and a pointer to the character after the colon following the -// scheme, this parses it and fills in the structure, Every item in the parsed -// structure is filled EXCEPT for the scheme, which is untouched. -void ParseAfterScheme(const char* spec, - int spec_len, - int after_scheme, - Parsed* parsed); -void ParseAfterScheme(const base::char16* spec, - int spec_len, - int after_scheme, - Parsed* parsed); - -} // namespace url - -#endif // URL_URL_PARSE_INTERNAL_H_ diff --git a/vendor/gurl/url/url_util.cc b/vendor/gurl/url/url_util.cc deleted file mode 100644 index bc16010..0000000 --- a/vendor/gurl/url/url_util.cc +++ /dev/null @@ -1,583 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "url/url_util.h" - -#include -#include - -//#include "base/debug/leak_annotations.h" -//#include "base/logging.h" -#include "base/strings/string_util.h" -#include "url/url_canon_internal.h" -#include "url/url_file.h" -#include "url/url_util_internal.h" - -namespace url { - -namespace { - -const int kNumStandardURLSchemes = 8; -const SchemeWithType kStandardURLSchemes[kNumStandardURLSchemes] = { - {kHttpScheme, SCHEME_WITH_PORT}, - {kHttpsScheme, SCHEME_WITH_PORT}, - // Yes, file URLs can have a hostname, so file URLs should be handled as - // "standard". File URLs never have a port as specified by the SchemeType - // field. - {kFileScheme, SCHEME_WITHOUT_PORT}, - {kFtpScheme, SCHEME_WITH_PORT}, - {kGopherScheme, SCHEME_WITH_PORT}, - {kWsScheme, SCHEME_WITH_PORT}, // WebSocket. - {kWssScheme, SCHEME_WITH_PORT}, // WebSocket secure. - {kFileSystemScheme, SCHEME_WITHOUT_AUTHORITY}, -}; - -// List of the currently installed standard schemes. This list is lazily -// initialized by InitStandardSchemes and is leaked on shutdown to prevent -// any destructors from being called that will slow us down or cause problems. -std::vector* standard_schemes = NULL; - -// See the LockStandardSchemes declaration in the header. -bool standard_schemes_locked = false; - -// This template converts a given character type to the corresponding -// StringPiece type. -template struct CharToStringPiece { -}; -template<> struct CharToStringPiece { - typedef base::StringPiece Piece; -}; -template<> struct CharToStringPiece { - typedef base::StringPiece16 Piece; -}; - -// Ensures that the standard_schemes list is initialized, does nothing if it -// already has values. -void InitStandardSchemes() { - if (standard_schemes) - return; - standard_schemes = new std::vector; - for (int i = 0; i < kNumStandardURLSchemes; i++) - standard_schemes->push_back(kStandardURLSchemes[i]); -} - -// Given a string and a range inside the string, compares it to the given -// lower-case |compare_to| buffer. -template -inline bool DoCompareSchemeComponent(const CHAR* spec, - const Component& component, - const char* compare_to) { - if (!component.is_nonempty()) - return compare_to[0] == 0; // When component is empty, match empty scheme. - return base::LowerCaseEqualsASCII( - typename CharToStringPiece::Piece( - &spec[component.begin], component.len), - compare_to); -} - -// Returns true and sets |type| to the SchemeType of the given scheme -// identified by |scheme| within |spec| if the scheme is one of the registered -// "standard" schemes. -template -bool DoIsStandard(const CHAR* spec, - const Component& scheme, - SchemeType* type) { - if (!scheme.is_nonempty()) - return false; // Empty or invalid schemes are non-standard. - - InitStandardSchemes(); - for (size_t i = 0; i < standard_schemes->size(); i++) { - if (base::LowerCaseEqualsASCII( - typename CharToStringPiece::Piece( - &spec[scheme.begin], scheme.len), - standard_schemes->at(i).scheme)) { - *type = standard_schemes->at(i).type; - return true; - } - } - return false; -} - -template -bool DoFindAndCompareScheme(const CHAR* str, - int str_len, - const char* compare, - Component* found_scheme) { - // Before extracting scheme, canonicalize the URL to remove any whitespace. - // This matches the canonicalization done in DoCanonicalize function. - RawCanonOutputT whitespace_buffer; - int spec_len; - const CHAR* spec = RemoveURLWhitespace(str, str_len, - &whitespace_buffer, &spec_len); - - Component our_scheme; - if (!ExtractScheme(spec, spec_len, &our_scheme)) { - // No scheme. - if (found_scheme) - *found_scheme = Component(); - return false; - } - if (found_scheme) - *found_scheme = our_scheme; - return DoCompareSchemeComponent(spec, our_scheme, compare); -} - -template -bool DoCanonicalize(const CHAR* in_spec, - int in_spec_len, - bool trim_path_end, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed) { - // Remove any whitespace from the middle of the relative URL, possibly - // copying to the new buffer. - RawCanonOutputT whitespace_buffer; - int spec_len; - const CHAR* spec = RemoveURLWhitespace(in_spec, in_spec_len, - &whitespace_buffer, &spec_len); - - Parsed parsed_input; -#ifdef WIN32 - // For Windows, we allow things that look like absolute Windows paths to be - // fixed up magically to file URLs. This is done for IE compatibility. For - // example, this will change "c:/foo" into a file URL rather than treating - // it as a URL with the protocol "c". It also works for UNC ("\\foo\bar.txt"). - // There is similar logic in url_canon_relative.cc for - // - // For Max & Unix, we don't do this (the equivalent would be "/foo/bar" which - // has no meaning as an absolute path name. This is because browsers on Mac - // & Unix don't generally do this, so there is no compatibility reason for - // doing so. - if (DoesBeginUNCPath(spec, 0, spec_len, false) || - DoesBeginWindowsDriveSpec(spec, 0, spec_len)) { - ParseFileURL(spec, spec_len, &parsed_input); - return CanonicalizeFileURL(spec, spec_len, parsed_input, charset_converter, - output, output_parsed); - } -#endif - - Component scheme; - if (!ExtractScheme(spec, spec_len, &scheme)) - return false; - - // This is the parsed version of the input URL, we have to canonicalize it - // before storing it in our object. - bool success; - SchemeType unused_scheme_type = SCHEME_WITH_PORT; - if (DoCompareSchemeComponent(spec, scheme, url::kFileScheme)) { - // File URLs are special. - ParseFileURL(spec, spec_len, &parsed_input); - success = CanonicalizeFileURL(spec, spec_len, parsed_input, - charset_converter, output, output_parsed); - } else if (DoCompareSchemeComponent(spec, scheme, url::kFileSystemScheme)) { - // Filesystem URLs are special. - ParseFileSystemURL(spec, spec_len, &parsed_input); - success = CanonicalizeFileSystemURL(spec, spec_len, parsed_input, - charset_converter, output, - output_parsed); - - } else if (DoIsStandard(spec, scheme, &unused_scheme_type)) { - // All "normal" URLs. - ParseStandardURL(spec, spec_len, &parsed_input); - success = CanonicalizeStandardURL(spec, spec_len, parsed_input, - charset_converter, output, output_parsed); - - } else if (DoCompareSchemeComponent(spec, scheme, url::kMailToScheme)) { - // Mailto URLs are treated like standard URLs, with only a scheme, path, - // and query. - ParseMailtoURL(spec, spec_len, &parsed_input); - success = CanonicalizeMailtoURL(spec, spec_len, parsed_input, output, - output_parsed); - - } else { - // "Weird" URLs like data: and javascript:. - ParsePathURL(spec, spec_len, trim_path_end, &parsed_input); - success = CanonicalizePathURL(spec, spec_len, parsed_input, output, - output_parsed); - } - return success; -} - -template -bool DoResolveRelative(const char* base_spec, - int base_spec_len, - const Parsed& base_parsed, - const CHAR* in_relative, - int in_relative_length, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed) { - // Remove any whitespace from the middle of the relative URL, possibly - // copying to the new buffer. - RawCanonOutputT whitespace_buffer; - int relative_length; - const CHAR* relative = RemoveURLWhitespace(in_relative, in_relative_length, - &whitespace_buffer, - &relative_length); - bool base_is_authority_based = false; - bool base_is_hierarchical = false; - if (base_spec && - base_parsed.scheme.is_nonempty()) { - int after_scheme = base_parsed.scheme.end() + 1; // Skip past the colon. - int num_slashes = CountConsecutiveSlashes(base_spec, after_scheme, - base_spec_len); - base_is_authority_based = num_slashes > 1; - base_is_hierarchical = num_slashes > 0; - } - - SchemeType unused_scheme_type = SCHEME_WITH_PORT; - bool standard_base_scheme = - base_parsed.scheme.is_nonempty() && - DoIsStandard(base_spec, base_parsed.scheme, &unused_scheme_type); - - bool is_relative; - Component relative_component; - if (!IsRelativeURL(base_spec, base_parsed, relative, relative_length, - (base_is_hierarchical || standard_base_scheme), - &is_relative, &relative_component)) { - // Error resolving. - return false; - } - - // Pretend for a moment that |base_spec| is a standard URL. Normally - // non-standard URLs are treated as PathURLs, but if the base has an - // authority we would like to preserve it. - if (is_relative && base_is_authority_based && !standard_base_scheme) { - Parsed base_parsed_authority; - ParseStandardURL(base_spec, base_spec_len, &base_parsed_authority); - if (base_parsed_authority.host.is_nonempty()) { - RawCanonOutputT temporary_output; - bool did_resolve_succeed = - ResolveRelativeURL(base_spec, base_parsed_authority, false, relative, - relative_component, charset_converter, - &temporary_output, output_parsed); - // The output_parsed is incorrect at this point (because it was built - // based on base_parsed_authority instead of base_parsed) and needs to be - // re-created. - DoCanonicalize(temporary_output.data(), temporary_output.length(), true, - charset_converter, output, output_parsed); - return did_resolve_succeed; - } - } else if (is_relative) { - // Relative, resolve and canonicalize. - bool file_base_scheme = base_parsed.scheme.is_nonempty() && - DoCompareSchemeComponent(base_spec, base_parsed.scheme, kFileScheme); - return ResolveRelativeURL(base_spec, base_parsed, file_base_scheme, relative, - relative_component, charset_converter, output, - output_parsed); - } - - // Not relative, canonicalize the input. - return DoCanonicalize(relative, relative_length, true, charset_converter, - output, output_parsed); -} - -template -bool DoReplaceComponents(const char* spec, - int spec_len, - const Parsed& parsed, - const Replacements& replacements, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* out_parsed) { - // If the scheme is overridden, just do a simple string substitution and - // re-parse the whole thing. There are lots of edge cases that we really don't - // want to deal with. Like what happens if I replace "http://e:8080/foo" - // with a file. Does it become "file:///E:/8080/foo" where the port number - // becomes part of the path? Parsing that string as a file URL says "yes" - // but almost no sane rule for dealing with the components individually would - // come up with that. - // - // Why allow these crazy cases at all? Programatically, there is almost no - // case for replacing the scheme. The most common case for hitting this is - // in JS when building up a URL using the location object. In this case, the - // JS code expects the string substitution behavior: - // http://www.w3.org/TR/2008/WD-html5-20080610/structured.html#common3 - if (replacements.IsSchemeOverridden()) { - // Canonicalize the new scheme so it is 8-bit and can be concatenated with - // the existing spec. - RawCanonOutput<128> scheme_replaced; - Component scheme_replaced_parsed; - CanonicalizeScheme(replacements.sources().scheme, - replacements.components().scheme, - &scheme_replaced, &scheme_replaced_parsed); - - // We can assume that the input is canonicalized, which means it always has - // a colon after the scheme (or where the scheme would be). - int spec_after_colon = parsed.scheme.is_valid() ? parsed.scheme.end() + 1 - : 1; - if (spec_len - spec_after_colon > 0) { - scheme_replaced.Append(&spec[spec_after_colon], - spec_len - spec_after_colon); - } - - // We now need to completely re-parse the resulting string since its meaning - // may have changed with the different scheme. - RawCanonOutput<128> recanonicalized; - Parsed recanonicalized_parsed; - DoCanonicalize(scheme_replaced.data(), scheme_replaced.length(), true, - charset_converter, - &recanonicalized, &recanonicalized_parsed); - - // Recurse using the version with the scheme already replaced. This will now - // use the replacement rules for the new scheme. - // - // Warning: this code assumes that ReplaceComponents will re-check all - // components for validity. This is because we can't fail if DoCanonicalize - // failed above since theoretically the thing making it fail could be - // getting replaced here. If ReplaceComponents didn't re-check everything, - // we wouldn't know if something *not* getting replaced is a problem. - // If the scheme-specific replacers are made more intelligent so they don't - // re-check everything, we should instead re-canonicalize the whole thing - // after this call to check validity (this assumes replacing the scheme is - // much much less common than other types of replacements, like clearing the - // ref). - Replacements replacements_no_scheme = replacements; - replacements_no_scheme.SetScheme(NULL, Component()); - return DoReplaceComponents(recanonicalized.data(), recanonicalized.length(), - recanonicalized_parsed, replacements_no_scheme, - charset_converter, output, out_parsed); - } - - // If we get here, then we know the scheme doesn't need to be replaced, so can - // just key off the scheme in the spec to know how to do the replacements. - if (DoCompareSchemeComponent(spec, parsed.scheme, url::kFileScheme)) { - return ReplaceFileURL(spec, parsed, replacements, charset_converter, output, - out_parsed); - } - if (DoCompareSchemeComponent(spec, parsed.scheme, url::kFileSystemScheme)) { - return ReplaceFileSystemURL(spec, parsed, replacements, charset_converter, - output, out_parsed); - } - SchemeType unused_scheme_type = SCHEME_WITH_PORT; - if (DoIsStandard(spec, parsed.scheme, &unused_scheme_type)) { - return ReplaceStandardURL(spec, parsed, replacements, charset_converter, - output, out_parsed); - } - if (DoCompareSchemeComponent(spec, parsed.scheme, url::kMailToScheme)) { - return ReplaceMailtoURL(spec, parsed, replacements, output, out_parsed); - } - - // Default is a path URL. - return ReplacePathURL(spec, parsed, replacements, output, out_parsed); -} - -} // namespace - -void Initialize() { - InitStandardSchemes(); -} - -void Shutdown() { - if (standard_schemes) { - delete standard_schemes; - standard_schemes = NULL; - } -} - -void AddStandardScheme(const char* new_scheme, - SchemeType type) { - // If this assert triggers, it means you've called AddStandardScheme after - // LockStandardSchemes have been called (see the header file for - // LockStandardSchemes for more). - // - // This normally means you're trying to set up a new standard scheme too late - // in your application's init process. Locate where your app does this - // initialization and calls LockStandardSchemes, and add your new standard - // scheme there. - //DCHECK(!standard_schemes_locked) << - "Trying to add a standard scheme after the list has been locked."; - - size_t scheme_len = strlen(new_scheme); - if (scheme_len == 0) - return; - - // Duplicate the scheme into a new buffer and add it to the list of standard - // schemes. This pointer will be leaked on shutdown. - char* dup_scheme = new char[scheme_len + 1]; - //ANNOTATE_LEAKING_OBJECT_PTR(dup_scheme); - memcpy(dup_scheme, new_scheme, scheme_len + 1); - - InitStandardSchemes(); - SchemeWithType scheme_with_type; - scheme_with_type.scheme = dup_scheme; - scheme_with_type.type = type; - standard_schemes->push_back(scheme_with_type); -} - -void LockStandardSchemes() { - standard_schemes_locked = true; -} - -bool IsStandard(const char* spec, const Component& scheme) { - SchemeType unused_scheme_type; - return DoIsStandard(spec, scheme, &unused_scheme_type); -} - -bool GetStandardSchemeType(const char* spec, - const Component& scheme, - SchemeType* type) { - return DoIsStandard(spec, scheme, type); -} - -bool IsStandard(const base::char16* spec, const Component& scheme) { - SchemeType unused_scheme_type; - return DoIsStandard(spec, scheme, &unused_scheme_type); -} - -bool FindAndCompareScheme(const char* str, - int str_len, - const char* compare, - Component* found_scheme) { - return DoFindAndCompareScheme(str, str_len, compare, found_scheme); -} - -bool FindAndCompareScheme(const base::char16* str, - int str_len, - const char* compare, - Component* found_scheme) { - return DoFindAndCompareScheme(str, str_len, compare, found_scheme); -} - -bool Canonicalize(const char* spec, - int spec_len, - bool trim_path_end, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed) { - return DoCanonicalize(spec, spec_len, trim_path_end, charset_converter, - output, output_parsed); -} - -bool Canonicalize(const base::char16* spec, - int spec_len, - bool trim_path_end, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed) { - return DoCanonicalize(spec, spec_len, trim_path_end, charset_converter, - output, output_parsed); -} - -bool ResolveRelative(const char* base_spec, - int base_spec_len, - const Parsed& base_parsed, - const char* relative, - int relative_length, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed) { - return DoResolveRelative(base_spec, base_spec_len, base_parsed, - relative, relative_length, - charset_converter, output, output_parsed); -} - -bool ResolveRelative(const char* base_spec, - int base_spec_len, - const Parsed& base_parsed, - const base::char16* relative, - int relative_length, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed) { - return DoResolveRelative(base_spec, base_spec_len, base_parsed, - relative, relative_length, - charset_converter, output, output_parsed); -} - -bool ReplaceComponents(const char* spec, - int spec_len, - const Parsed& parsed, - const Replacements& replacements, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* out_parsed) { - return DoReplaceComponents(spec, spec_len, parsed, replacements, - charset_converter, output, out_parsed); -} - -bool ReplaceComponents(const char* spec, - int spec_len, - const Parsed& parsed, - const Replacements& replacements, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* out_parsed) { - return DoReplaceComponents(spec, spec_len, parsed, replacements, - charset_converter, output, out_parsed); -} - -void DecodeURLEscapeSequences(const char* input, - int length, - CanonOutputW* output) { - RawCanonOutputT unescaped_chars; - for (int i = 0; i < length; i++) { - if (input[i] == '%') { - unsigned char ch; - if (DecodeEscaped(input, &i, length, &ch)) { - unescaped_chars.push_back(ch); - } else { - // Invalid escape sequence, copy the percent literal. - unescaped_chars.push_back('%'); - } - } else { - // Regular non-escaped 8-bit character. - unescaped_chars.push_back(input[i]); - } - } - - // Convert that 8-bit to UTF-16. It's not clear IE does this at all to - // JavaScript URLs, but Firefox and Safari do. - for (int i = 0; i < unescaped_chars.length(); i++) { - unsigned char uch = static_cast(unescaped_chars.at(i)); - if (uch < 0x80) { - // Non-UTF-8, just append directly - output->push_back(uch); - } else { - // next_ch will point to the last character of the decoded - // character. - int next_character = i; - unsigned code_point; - if (ReadUTFChar(unescaped_chars.data(), &next_character, - unescaped_chars.length(), &code_point)) { - // Valid UTF-8 character, convert to UTF-16. - AppendUTF16Value(code_point, output); - i = next_character; - } else { - // If there are any sequences that are not valid UTF-8, we keep - // invalid code points and promote to UTF-16. We copy all characters - // from the current position to the end of the identified sequence. - while (i < next_character) { - output->push_back(static_cast(unescaped_chars.at(i))); - i++; - } - output->push_back(static_cast(unescaped_chars.at(i))); - } - } - } -} - -void EncodeURIComponent(const char* input, int length, CanonOutput* output) { - for (int i = 0; i < length; ++i) { - unsigned char c = static_cast(input[i]); - if (IsComponentChar(c)) - output->push_back(c); - else - AppendEscapedChar(c, output); - } -} - -bool CompareSchemeComponent(const char* spec, - const Component& component, - const char* compare_to) { - return DoCompareSchemeComponent(spec, component, compare_to); -} - -bool CompareSchemeComponent(const base::char16* spec, - const Component& component, - const char* compare_to) { - return DoCompareSchemeComponent(spec, component, compare_to); -} - -} // namespace url diff --git a/vendor/gurl/url/url_util.h b/vendor/gurl/url/url_util.h deleted file mode 100644 index 04a6ef4..0000000 --- a/vendor/gurl/url/url_util.h +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_UTIL_H_ -#define URL_URL_UTIL_H_ - -#include - -#include "base/strings/string16.h" -#include "url/third_party/mozilla/url_parse.h" -#include "url/url_canon.h" -#include "url/url_constants.h" -#include "url/url_export.h" - -namespace url { - -// Init ------------------------------------------------------------------------ - -// Initialization is NOT required, it will be implicitly initialized when first -// used. However, this implicit initialization is NOT threadsafe. If you are -// using this library in a threaded environment and don't have a consistent -// "first call" (an example might be calling AddStandardScheme with your special -// application-specific schemes) then you will want to call initialize before -// spawning any threads. -// -// It is OK to call this function more than once, subsequent calls will be -// no-ops, unless Shutdown was called in the mean time. This will also be a -// no-op if other calls to the library have forced an initialization beforehand. -URL_EXPORT void Initialize(); - -// Cleanup is not required, except some strings may leak. For most user -// applications, this is fine. If you're using it in a library that may get -// loaded and unloaded, you'll want to unload to properly clean up your -// library. -URL_EXPORT void Shutdown(); - -// Schemes -------------------------------------------------------------------- - -// Types of a scheme representing the requirements on the data represented by -// the authority component of a URL with the scheme. -enum SchemeType { - // The authority component of a URL with the scheme, if any, has the port - // (the default values may be omitted in a serialization). - SCHEME_WITH_PORT, - // The authority component of a URL with the scheme, if any, doesn't have a - // port. - SCHEME_WITHOUT_PORT, - // A URL with the scheme doesn't have the authority component. - SCHEME_WITHOUT_AUTHORITY, -}; - -// A pair for representing a standard scheme name and the SchemeType for it. -struct URL_EXPORT SchemeWithType { - const char* scheme; - SchemeType type; -}; - -// Adds an application-defined scheme to the internal list of "standard-format" -// URL schemes. A standard-format scheme adheres to what RFC 3986 calls "generic -// URI syntax" (https://tools.ietf.org/html/rfc3986#section-3). -// -// This function is not threadsafe and can not be called concurrently with any -// other url_util function. It will assert if the list of standard schemes has -// been locked (see LockStandardSchemes). -URL_EXPORT void AddStandardScheme(const char* new_scheme, - SchemeType scheme_type); - -// Sets a flag to prevent future calls to AddStandardScheme from succeeding. -// -// This is designed to help prevent errors for multithreaded applications. -// Normal usage would be to call AddStandardScheme for your custom schemes at -// the beginning of program initialization, and then LockStandardSchemes. This -// prevents future callers from mistakenly calling AddStandardScheme when the -// program is running with multiple threads, where such usage would be -// dangerous. -// -// We could have had AddStandardScheme use a lock instead, but that would add -// some platform-specific dependencies we don't otherwise have now, and is -// overkill considering the normal usage is so simple. -URL_EXPORT void LockStandardSchemes(); - -// Locates the scheme in the given string and places it into |found_scheme|, -// which may be NULL to indicate the caller does not care about the range. -// -// Returns whether the given |compare| scheme matches the scheme found in the -// input (if any). The |compare| scheme must be a valid canonical scheme or -// the result of the comparison is undefined. -URL_EXPORT bool FindAndCompareScheme(const char* str, - int str_len, - const char* compare, - Component* found_scheme); -URL_EXPORT bool FindAndCompareScheme(const base::char16* str, - int str_len, - const char* compare, - Component* found_scheme); -inline bool FindAndCompareScheme(const std::string& str, - const char* compare, - Component* found_scheme) { - return FindAndCompareScheme(str.data(), static_cast(str.size()), - compare, found_scheme); -} -inline bool FindAndCompareScheme(const base::string16& str, - const char* compare, - Component* found_scheme) { - return FindAndCompareScheme(str.data(), static_cast(str.size()), - compare, found_scheme); -} - -// Returns true if the given scheme identified by |scheme| within |spec| is in -// the list of known standard-format schemes (see AddStandardScheme). -URL_EXPORT bool IsStandard(const char* spec, const Component& scheme); -URL_EXPORT bool IsStandard(const base::char16* spec, const Component& scheme); - -// Returns true and sets |type| to the SchemeType of the given scheme -// identified by |scheme| within |spec| if the scheme is in the list of known -// standard-format schemes (see AddStandardScheme). -URL_EXPORT bool GetStandardSchemeType(const char* spec, - const Component& scheme, - SchemeType* type); - -// URL library wrappers ------------------------------------------------------- - -// Parses the given spec according to the extracted scheme type. Normal users -// should use the URL object, although this may be useful if performance is -// critical and you don't want to do the heap allocation for the std::string. -// -// As with the Canonicalize* functions, the charset converter can -// be NULL to use UTF-8 (it will be faster in this case). -// -// Returns true if a valid URL was produced, false if not. On failure, the -// output and parsed structures will still be filled and will be consistent, -// but they will not represent a loadable URL. -URL_EXPORT bool Canonicalize(const char* spec, - int spec_len, - bool trim_path_end, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed); -URL_EXPORT bool Canonicalize(const base::char16* spec, - int spec_len, - bool trim_path_end, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed); - -// Resolves a potentially relative URL relative to the given parsed base URL. -// The base MUST be valid. The resulting canonical URL and parsed information -// will be placed in to the given out variables. -// -// The relative need not be relative. If we discover that it's absolute, this -// will produce a canonical version of that URL. See Canonicalize() for more -// about the charset_converter. -// -// Returns true if the output is valid, false if the input could not produce -// a valid URL. -URL_EXPORT bool ResolveRelative(const char* base_spec, - int base_spec_len, - const Parsed& base_parsed, - const char* relative, - int relative_length, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed); -URL_EXPORT bool ResolveRelative(const char* base_spec, - int base_spec_len, - const Parsed& base_parsed, - const base::char16* relative, - int relative_length, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* output_parsed); - -// Replaces components in the given VALID input URL. The new canonical URL info -// is written to output and out_parsed. -// -// Returns true if the resulting URL is valid. -URL_EXPORT bool ReplaceComponents(const char* spec, - int spec_len, - const Parsed& parsed, - const Replacements& replacements, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* out_parsed); -URL_EXPORT bool ReplaceComponents( - const char* spec, - int spec_len, - const Parsed& parsed, - const Replacements& replacements, - CharsetConverter* charset_converter, - CanonOutput* output, - Parsed* out_parsed); - -// String helper functions ---------------------------------------------------- - -// Unescapes the given string using URL escaping rules. -URL_EXPORT void DecodeURLEscapeSequences(const char* input, - int length, - CanonOutputW* output); - -// Escapes the given string as defined by the JS method encodeURIComponent. See -// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent -URL_EXPORT void EncodeURIComponent(const char* input, - int length, - CanonOutput* output); - -} // namespace url - -#endif // URL_URL_UTIL_H_ diff --git a/vendor/gurl/url/url_util_internal.h b/vendor/gurl/url/url_util_internal.h deleted file mode 100644 index 756c736..0000000 --- a/vendor/gurl/url/url_util_internal.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef URL_URL_UTIL_INTERNAL_H_ -#define URL_URL_UTIL_INTERNAL_H_ - -#include - -#include "base/strings/string16.h" -#include "url/third_party/mozilla/url_parse.h" - -namespace url { - -// Given a string and a range inside the string, compares it to the given -// lower-case |compare_to| buffer. -bool CompareSchemeComponent(const char* spec, - const Component& component, - const char* compare_to); -bool CompareSchemeComponent(const base::char16* spec, - const Component& component, - const char* compare_to); - -} // namespace url - -#endif // URL_URL_UTIL_INTERNAL_H_