summaryrefslogtreecommitdiffstats
path: root/base/strings
Commit message (Collapse)AuthorAgeFilesLines
* Switch the offset conversion routines from an "offsets point at characters"pkasting@chromium.org2013-09-113-27/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | worldview to an "offsets point between characters" worldview. This more closely aligns with how the omnibox autocomplete code (which is what this was originally written for) expects things to behave. Direct fallout from this change: * An input offset of 0 will always map to an output offset of 0. * An input offset of (length of string) will always map to the length of the output string, instead of npos. * It's possible for multiple unique input offsets to map to a single non-npos output offset, if they e.g. point to the start and end of a collapsed sequence. * Input offsets pointing into the middle of a completely-removed sequence may not be set to npos if they fall on the boundaries of a subsequence processed by the transformer. For example, when running FormatUrlWithOffsets() on "http://user:pass@domain.com/" and directing it to omit both the scheme and username/password, an input offset of "7" that points in between the scheme and the username/password will be transformed to an output offset of 0 instead of npos. Indirect fallout: * A caller like SearchProvider::NavigationToMatch() will now mark certain matches as "allowed to be default" that it didn't before. Specifically, if the user's input string ends at the same point as the desired |fill_into_edit|, the autocomplete offset will be calculated as (length of string) instead of npos, and thus the match will be thought of as "inlinable" and thus "allowed to be default". BUG=284781 TEST=none R=msw@chromium.org, willchan@chromium.org Review URL: https://codereview.chromium.org/23619016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222426 0039d316-1c4b-4281-b951-d872f2087c98
* Second attempt at introducing SafeSPrintf().markus@chromium.org2013-09-054-0/+1886
| | | | | | | | | | | | | | | | | | | | | | | | | | | See original discussion at https://codereview.chromium.org/18656004/ Reverted as: https://codereview.chromium.org/23463010/ Added a new base::strings::SafeSPrintf() function that can safely be called from all restricted (e.g. async-signal-safe) environments. It is roughly equivalent to snprintf(). But it is easier to use, as it uses C++ to be type-safe. In release builds, this function is guaranteed to never call any other library function nor any system calls. In debug builds, we call RAW_CHECK() in some circumstances. This code is needed for (at least) the seccomp sandbox and to clean up code in the stack tracer. Those changes are pending and will be submitted as separate CLs. BUG=285499 TEST=base_unittests TBR=willchan@chromium.org NOTRY=true Review URL: https://chromiumcodereview.appspot.com/23777003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221322 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "Added a new base::strings::SafeSPrintf() function that can"tkent@chromium.org2013-09-024-1890/+0
| | | | | | | | | | | | | | | Revert "Disable EmitNULL test for Widows x64." This reverts r220773 and 220746. r220746 broke ChromiumOS build. BUG=283595 TBR=markus@chromium.org Review URL: https://codereview.chromium.org/23463010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220777 0039d316-1c4b-4281-b951-d872f2087c98
* Disable EmitNULL test for Widows x64.tkent@chromium.org2013-09-021-1/+7
| | | | | | | | | TBR=markus@chromium.org BUG=283595 Review URL: https://codereview.chromium.org/23851004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220773 0039d316-1c4b-4281-b951-d872f2087c98
* Added a new base::strings::SafeSPrintf() function that canmarkus@chromium.org2013-09-014-0/+1884
| | | | | | | | | | | | | | | | | | | | | safely be called from all restricted (e.g. async-signal-safe) environments. It is roughly equivalent to snprintf(). But it is easier to use, as it uses C++ to be type-safe. In release builds, this function is guaranteed to never call any other library function nor any system calls. In debug builds, we call RAW_CHECK() in some circumstances. This code is needed for (at least) the seccomp sandbox and to clean up code in the stack tracer. Those changes are pending and will be submitted as separate CLs. BUG=none TEST=base_unittests Review URL: https://chromiumcodereview.appspot.com/18656004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220746 0039d316-1c4b-4281-b951-d872f2087c98
* Omnibox: Create DemoteByType Experimentmpearson@chromium.org2013-08-092-8/+9
| | | | | | | | | | | | | | | | | | | | This experiment, which runs as part of the bundled omnibox field trial, uses the field trial parameters to demote results of particular types (e.g., HISTORY_TITLE results), possibly depending on context (e.g., search results page doing search term replacement). It also improves the testing framework for field trial parameters, allowing them to be cleared between consecutive TEST_F()s. Tested via unit tests and by setting up my local variations server with some parameters and making sure results can be demoted or omitted. BUG=264066 Review URL: https://chromiumcodereview.appspot.com/22031002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216633 0039d316-1c4b-4281-b951-d872f2087c98
* mac: Replace base::mac::ScopedCFTypeRef with base::ScopedCFTypeRef.thakis@chromium.org2013-06-241-8/+7
| | | | | | | | | | | | | | | | | This CL was created fully mechanically by running git grep -l base::mac::ScopedCFTypeRef | xargs sed -i -e 's/base::mac::ScopedCFTypeRef/base::ScopedCFTypeRef/g' git commit -a -m. git clang-format HEAD^ --style=Chromium git commit -a -m. git cl upload -t $TITLE BUG=251957 TBR=mark@chromium.org Review URL: https://codereview.chromium.org/16917011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208245 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of strings headers, delete some strings forwarding headers.avi@chromium.org2013-06-201-1/+1
| | | | | | | | | | BUG=247723 TEST=everything compiles OK TBR=ben@chromium.org Review URL: https://codereview.chromium.org/17390010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207507 0039d316-1c4b-4281-b951-d872f2087c98
* Remove "using" from nullable string now that all users are updated.avi@chromium.org2013-06-191-4/+0
| | | | | | | | | | BUG=247723 TEST=compile works TBR=brettw@chromium.org Review URL: https://chromiumcodereview.appspot.com/17385006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207165 0039d316-1c4b-4281-b951-d872f2087c98
* Replace base::NullableString16(bool) usage with default constructor.darin@chromium.org2013-06-181-1/+0
| | | | | | Review URL: https://chromiumcodereview.appspot.com/17327004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206922 0039d316-1c4b-4281-b951-d872f2087c98
* Add support using EXPECT_EQ with NullableString16 objects.darin@chromium.org2013-06-173-1/+67
| | | | | | | | | | Change the default constructor to set is_null_ to true. This makes NullableString16 act more like a WebKit::WebString, which is really the reason NullableString16 exists at all. R=brettw@chromium.org Review URL: https://codereview.chromium.org/17289005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206805 0039d316-1c4b-4281-b951-d872f2087c98
* Move nullable_string16.h to the string subdirectory.avi@chromium.org2013-06-131-0/+37
| | | | | | | | | | BUG=247723 TEST=no change TBR=brettw@chromium.org Review URL: https://codereview.chromium.org/16415016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206066 0039d316-1c4b-4281-b951-d872f2087c98
* add more string -> unsigned number conversion unit tests (attempt 2)mostynb@opera.com2013-06-131-1/+206
| | | | | | | | | | | Add unit tests for the following functions in base: StringToUint StringToUint64 StringToSizeT Review URL: https://chromiumcodereview.appspot.com/15521004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206031 0039d316-1c4b-4281-b951-d872f2087c98
* Rename base/hash_tables to base/containers/hash_tables.brettw@chromium.org2013-06-111-4/+4
| | | | | | | | | | | Remove forwarding header BUG= R=avi@chromium.org Review URL: https://codereview.chromium.org/16667019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205584 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of strings headers in base/.avi@chromium.org2013-06-1014-16/+16
| | | | | | | | | | BUG=247723 TEST=none TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/16320009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205284 0039d316-1c4b-4281-b951-d872f2087c98
* Move string files in base/ to the string subdirectory.avi@chromium.org2013-06-0812-0/+3708
| | | | | | | | | BUG=247723 TEST=no change Review URL: https://chromiumcodereview.appspot.com/16331011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205050 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of utf_string_conversions.h in android_webview/, apps/, ↵avi@chromium.org2013-06-077-7/+7
| | | | | | | | | | | ash/, base/. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/15735027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204874 0039d316-1c4b-4281-b951-d872f2087c98
* Move latin1_string_conversions to baseabarth@chromium.org2013-05-292-0/+51
| | | | | | | | | | | | | | | | Unfortunately, we can't keep this function in webkit/glue because not everyone who links in Blink depends on webkit/glue. For example, cc uses WebString but doesn't depend on webkit/glue. IMHO, the best solution to all these constraints is to put this function in base. It's concerned with concepts that make sense in base (strings and character sets). The only thing odd about the function is that it accepts Latin-1 or UTF-16, which is because of the underlying string representation in Blink. Review URL: https://chromiumcodereview.appspot.com/15732022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203003 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 201204 "add more string -> unsigned number conversion uni..."hashimoto@chromium.org2013-05-211-197/+0
| | | | | | | | | | | | | | | | | | | This change generates "integer constant is too large for 'unsigned long' type" compile error on "Google Chrome Linux" buildbot > add more string -> unsigned number conversion unit tests > > Add unit tests for the following functions in base: > StringToUint > StringToUint64 > StringToSizeT > > Review URL: https://chromiumcodereview.appspot.com/14794002 TBR=mostynb@opera.com Review URL: https://codereview.chromium.org/15464016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201237 0039d316-1c4b-4281-b951-d872f2087c98
* add more string -> unsigned number conversion unit testsmostynb@opera.com2013-05-211-0/+197
| | | | | | | | | | | Add unit tests for the following functions in base: StringToUint StringToUint64 StringToSizeT Review URL: https://chromiumcodereview.appspot.com/14794002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201204 0039d316-1c4b-4281-b951-d872f2087c98
* Move utf_string_conversions to strings/ and add namespace.brettw@chromium.org2013-05-063-0/+468
| | | | | | | | | | | This keeps a forwarding header in the old location and adds "using" statements to avoid changing all callers. BUG=None R=tfarina@chromium.org Review URL: https://codereview.chromium.org/14126006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198542 0039d316-1c4b-4281-b951-d872f2087c98
* Stop overwriting errno in base::StringPrintf, StringAppendV, and StringToDouble.yusukes@chromium.org2013-05-022-1/+8
| | | | | | | | | BUG=None TEST=new tests added Review URL: https://chromiumcodereview.appspot.com/14749003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198001 0039d316-1c4b-4281-b951-d872f2087c98
* Feeding negative numbers to the HexStringToUInt64 should fail, with output 0 ↵mostynb@opera.com2013-05-013-8/+12
| | | | | | | | (the closest value in the datatype's range). Review URL: https://chromiumcodereview.appspot.com/14109020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197614 0039d316-1c4b-4281-b951-d872f2087c98
* Avoid C++11 narrowing errors.raphael.kubo.da.costa@intel.com2013-04-191-4/+4
| | | | | | | | | | | | | C++11 is picker about narrowing inside initializers. Avoid errors related to that by explicitly casting to the appropriate types or changing the types in function declarations where possible. BUG= TEST=Build with gcc and -Wnarrowing. Review URL: https://chromiumcodereview.appspot.com/13878015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195114 0039d316-1c4b-4281-b951-d872f2087c98
* Fix build bustage.michaeln@google.com2013-04-121-3/+3
| | | | | | | TBR:felipeg1 Review URL: https://codereview.chromium.org/13956013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193966 0039d316-1c4b-4281-b951-d872f2087c98
* Add support for unsigned int64 in string_number_conversionsfelipeg@chromium.org2013-04-123-1/+81
| | | | | | | | BUG= Review URL: https://chromiumcodereview.appspot.com/14103008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193933 0039d316-1c4b-4281-b951-d872f2087c98
* Rewrite std::string("") to std::string(), Linux edition.dcheng@chromium.org2013-04-092-12/+15
| | | | | | | | | | | | | | | | | | | This patch was generated by running the empty_string clang tool across the Chromium Linux compilation database. Implicitly or explicitly constructing std::string() with a "" argument is inefficient as the caller needs to emit extra instructions to pass an argument, and the constructor needlessly copies a byte into internal storage. Rewriting these instances to simply call the default constructor appears to save ~14-18 kilobytes on an optimized release build. BUG=none Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=193020 Review URL: https://codereview.chromium.org/13145003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193040 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "Rewrite std::string("") to std::string(), Linux edition."dcheng@chromium.org2013-04-092-15/+12
| | | | | | | | | | | | | | This reverts commit e59558b78e8c6a1b0bd916a724724b638c3c91b6. Revert "Fix build after r193020." This reverts commit 558a35897f6b3ffbcaefde927c1f150b815d140a. Revert "Really fix build after r193020." This reverts commit e3748a79b523a8d365d4a33ef986eebb4186fa78. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193030 0039d316-1c4b-4281-b951-d872f2087c98
* Rewrite std::string("") to std::string(), Linux edition.dcheng@chromium.org2013-04-092-12/+15
| | | | | | | | | | | | | | | | | This patch was generated by running the empty_string clang tool across the Chromium Linux compilation database. Implicitly or explicitly constructing std::string() with a "" argument is inefficient as the caller needs to emit extra instructions to pass an argument, and the constructor needlessly copies a byte into internal storage. Rewriting these instances to simply call the default constructor appears to save ~14-18 kilobytes on an optimized release build. BUG=none Review URL: https://codereview.chromium.org/13145003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193020 0039d316-1c4b-4281-b951-d872f2087c98
* base: Update the include paths of base/string_piece.h to its new location.tfarina@chromium.org2013-03-3010-10/+10
| | | | | | | | | | | string_piece.h was moved into base/strings/ in r191206 - https://chromiumcodereview.appspot.com/12982018/ TBR=brettw@chromium.org Review URL: https://codereview.chromium.org/13374002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191508 0039d316-1c4b-4281-b951-d872f2087c98
* Move string_piece.h to base/strings.brettw@chromium.org2013-03-283-0/+1383
| | | | | | | | | | This keeps a forwarding header and does not update any code to use the new location. This will be updated in a later pass. BUG= Review URL: https://codereview.chromium.org/12982018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191206 0039d316-1c4b-4281-b951-d872f2087c98
* Update the header guard macro.wtc@chromium.org2013-03-201-3/+3
| | | | | | | | | | | | | This header was moved in r181161 (https://codereview.chromium.org/12092078) but the header guard macro wasn't updated. R=brettw@chromium.org BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/12648009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189280 0039d316-1c4b-4281-b951-d872f2087c98
* Move string_split to base/strings.tfarina@chromium.org2013-02-073-0/+616
| | | | | | | | | R=brettw@chromium.org Review URL: https://chromiumcodereview.appspot.com/12218059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181380 0039d316-1c4b-4281-b951-d872f2087c98
* Move sys_string_conversions to base/strings.brettw@chromium.org2013-02-076-0/+709
| | | | | | | | This updates callers in base but I left a forwarding header so I can the rest in pieces (there are >300). Review URL: https://codereview.chromium.org/12213061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181345 0039d316-1c4b-4281-b951-d872f2087c98
* Move utf_offset_string_conversions and utf_string_conversion_utils to strings.brettw@chromium.org2013-02-075-0/+658
| | | | | | Review URL: https://codereview.chromium.org/12087115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181183 0039d316-1c4b-4281-b951-d872f2087c98
* Move string_number_conversions to base/strings.brettw@chromium.org2013-02-073-0/+1055
| | | | | | | | | | This only updates includes in base and keeps a forwarding header for now to keep the change under control. BUG= Review URL: https://codereview.chromium.org/12092078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181161 0039d316-1c4b-4281-b951-d872f2087c98
* Move string tokenizer to base/strings.brettw@chromium.org2013-02-022-0/+494
| | | | | | | | BUG= Review URL: https://codereview.chromium.org/12087091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180211 0039d316-1c4b-4281-b951-d872f2087c98
* Move stringize_macros to base/strings.brettw@chromium.org2013-01-312-0/+60
This removes the unused L-string macros in the file. BUG= Review URL: https://codereview.chromium.org/12090083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179926 0039d316-1c4b-4281-b951-d872f2087c98