mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-17 18:03:06 +09:00
Bug 1352082 - Avoid shifting a signed integer left in C++.
Tag UXP Issue #1344
This commit is contained in:
parent
c0e1a6e397
commit
2d6fd63895
6 changed files with 53 additions and 9 deletions
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Mozilla Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Applied to an integer type to generate the unsigned variant in C++.
|
||||
*/
|
||||
package nu.validator.htmlparser.annotation;
|
||||
|
||||
public @interface Unsigned {
|
||||
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ import nu.validator.htmlparser.annotation.NoLength;
|
|||
import nu.validator.htmlparser.annotation.NsUri;
|
||||
import nu.validator.htmlparser.annotation.Prefix;
|
||||
import nu.validator.htmlparser.annotation.QName;
|
||||
import nu.validator.htmlparser.annotation.Unsigned;
|
||||
import nu.validator.htmlparser.annotation.Virtual;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
||||
|
|
@ -278,7 +279,7 @@ public final class AttributeName
|
|||
// ]NOCPP]
|
||||
, Interner interner) {
|
||||
// XXX deal with offset
|
||||
int hash = AttributeName.bufToHash(buf, length);
|
||||
@Unsigned int hash = AttributeName.bufToHash(buf, length);
|
||||
int index = Arrays.binarySearch(AttributeName.ATTRIBUTE_HASHES, hash);
|
||||
if (index < 0) {
|
||||
return AttributeName.createAttributeName(
|
||||
|
|
@ -312,9 +313,9 @@ public final class AttributeName
|
|||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private static int bufToHash(@NoLength char[] buf, int len) {
|
||||
int hash2 = 0;
|
||||
int hash = len;
|
||||
private static @Unsigned int bufToHash(@NoLength char[] buf, int len) {
|
||||
@Unsigned int hash2 = 0;
|
||||
@Unsigned int hash = len;
|
||||
hash <<= 5;
|
||||
hash += buf[0] - 0x60;
|
||||
int j = len;
|
||||
|
|
@ -396,7 +397,7 @@ public final class AttributeName
|
|||
@Local @NoLength String[] local, @Prefix @NoLength String[] prefix
|
||||
// [NOCPP[
|
||||
, int flags
|
||||
// ]NOCPP]
|
||||
// ]NOCPP]
|
||||
) {
|
||||
this.uri = uri;
|
||||
this.local = local;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import java.util.Arrays;
|
|||
import nu.validator.htmlparser.annotation.Inline;
|
||||
import nu.validator.htmlparser.annotation.Local;
|
||||
import nu.validator.htmlparser.annotation.NoLength;
|
||||
import nu.validator.htmlparser.annotation.Unsigned;
|
||||
import nu.validator.htmlparser.annotation.Virtual;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
||||
|
|
@ -110,7 +111,7 @@ public final class ElementName
|
|||
}
|
||||
|
||||
static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) {
|
||||
int hash = ElementName.bufToHash(buf, length);
|
||||
@Unsigned int hash = ElementName.bufToHash(buf, length);
|
||||
int index = Arrays.binarySearch(ElementName.ELEMENT_HASHES, hash);
|
||||
if (index < 0) {
|
||||
return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner));
|
||||
|
|
@ -133,8 +134,8 @@ public final class ElementName
|
|||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private static int bufToHash(@NoLength char[] buf, int len) {
|
||||
int hash = len;
|
||||
private static @Unsigned int bufToHash(@NoLength char[] buf, int len) {
|
||||
@Unsigned int hash = len;
|
||||
hash <<= 5;
|
||||
hash += buf[0] - 0x60;
|
||||
int j = len;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue