diff --git a/src/aztec/encoder/state.rs b/src/aztec/encoder/state.rs index a6333ab..d072ea6 100644 --- a/src/aztec/encoder/state.rs +++ b/src/aztec/encoder/state.rs @@ -76,9 +76,9 @@ impl State { let result = self.shiftAndAppend(HighLevelEncoder::MODE_PUNCT as u32, 0); // 0: FLG(n) let mut token = result.token; let mut bits_added = 3; - if eci < 0 { + /*if eci < 0 { token.add(0, 3); // 0: FNC1 - } else if eci > 999999 { + } else */if eci > 999999 { return Err(Exceptions::IllegalArgumentException( "ECI code must be between 0 and 999999".to_owned(), )); diff --git a/src/client/result/ResultParser.rs b/src/client/result/ResultParser.rs index 35da8a4..ed79f6e 100644 --- a/src/client/result/ResultParser.rs +++ b/src/client/result/ResultParser.rs @@ -239,7 +239,7 @@ pub fn isStringOfDigits(value: &str, length: usize) -> bool { } pub fn isSubstringOfDigits(value: &str, offset: usize, length: usize) -> bool { - if value.is_empty() || length <= 0 { + if value.is_empty() || length == 0 { return false; } let max = offset as usize + length; diff --git a/src/client/result/VCardResultParser.rs b/src/client/result/VCardResultParser.rs index 1985452..a3c4767 100644 --- a/src/client/result/VCardResultParser.rs +++ b/src/client/result/VCardResultParser.rs @@ -173,8 +173,8 @@ pub fn matchVCardPrefixedField( parseFieldDivider: bool, ) -> Option>> { let mut matches: Vec> = Vec::new(); - let mut i = 0; - let max = rawText.len(); + let mut i = 0_isize; + let max = rawText.len() as isize; // let equals_regex = Regex::new(EQUALS).unwrap(); // let unescaped_semis = fancy_regex::Regex::new(UNESCAPED_SEMICOLONS).unwrap(); @@ -195,14 +195,14 @@ pub fn matchVCardPrefixedField( if i > 0 { i -= 1; // Find from i-1 not i since looking at the preceding character } - let cap_text = &rawText[i..]; + let cap_text = &rawText[i as usize..]; let cap_maybe = matcher_primary.captures(cap_text); //let matcher_maybe = matcher_primary.find_at(&lower_case_raw_text, i); if cap_maybe.is_none() { break; } let matcher = cap_maybe?; - i += matcher.get(0)?.end(); // group 0 = whole pattern; end(0) is past final colon + i += matcher.get(0)?.end() as isize; // group 0 = whole pattern; end(0) is past final colon let metadataString = matcher.get(1); // group 1 = metadata substring let mut metadata: Vec = Vec::new(); @@ -236,18 +236,18 @@ pub fn matchVCardPrefixedField( } let matchStart = i; // Found the start of a match here - while let Some(pos) = rawText[i..].find('\n') { + while let Some(pos) = rawText[i as usize..].find('\n') { // Really, end in \r\n - i += pos; // + i; + i += pos as isize; // + i; // while (i = rawText.indexOf('\n', i)) >= 0 { // Really, end in \r\n - if i < rawText.len() - 1 && // But if followed by tab or space, - (rawText.chars().nth(i + 1)? == ' ' || // this is only a continuation - rawText.chars().nth(i + 1)? == '\t') + if i < rawText.len() as isize- 1 && // But if followed by tab or space, + (rawText.chars().nth(i as usize+ 1)? == ' ' || // this is only a continuation + rawText.chars().nth(i as usize+ 1)? == '\t') { i += 2; // Skip \n and continutation whitespace } else if quotedPrintable && // If preceded by = in quoted printable - ((i >= 1 && rawText.chars().nth(i - 1)? == '=') || // this is a continuation - (i >= 2 && rawText.chars().nth(i - 2)? == '=')) + ((i >= 1 && rawText.chars().nth(i as usize- 1)? == '=') || // this is a continuation + (i >= 2 && rawText.chars().nth(i as usize - 2)? == '=')) { i += 1; // Skip \n } else { @@ -263,10 +263,10 @@ pub fn matchVCardPrefixedField( // if matches == null { // matches = new ArrayList<>(1); // lazy init // } - if i >= 1 && rawText.chars().nth(i - 1)? == '\r' { + if i >= 1 && rawText.chars().nth(i as usize- 1)? == '\r' { i -= 1; // Back up over \r, which really should be there } - let mut element = rawText[matchStart..i].to_owned(); + let mut element = rawText[matchStart as usize..i as usize].to_owned(); if trim { element = element.trim().to_owned(); } diff --git a/src/common/mod.rs b/src/common/mod.rs index 7a77628..aa2e9b0 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -2342,7 +2342,7 @@ impl GridSampler for DefaultGridSampler { dimensionY: u32, transform: &PerspectiveTransform, ) -> Result { - if dimensionX <= 0 || dimensionY <= 0 { + if dimensionX == 0 || dimensionY == 0 { return Err(Exceptions::NotFoundException( "getNotFoundInstance".to_owned(), )); @@ -3227,7 +3227,7 @@ impl ECIInput for MinimalECIInput { if index >= self.length() as u32 { return Err(Exceptions::IndexOutOfBoundsException(index.to_string())); } - Ok(self.bytes[index as usize] > 255 && self.bytes[index as usize] <= u16::MAX) + Ok(self.bytes[index as usize] > 255)// && self.bytes[index as usize] <= u16::MAX) } /** diff --git a/src/common/reedsolomon/mod.rs b/src/common/reedsolomon/mod.rs index 7b0d0b2..3dccd6d 100644 --- a/src/common/reedsolomon/mod.rs +++ b/src/common/reedsolomon/mod.rs @@ -967,7 +967,7 @@ impl ReedSolomonEncoder { )); } let data_bytes = to_encode.len() - ec_bytes; - if data_bytes <= 0 { + if data_bytes == 0 { return Err(Exceptions::IllegalArgumentException( "No data bytes provided".to_owned(), ));