Skip to content

Commit

Permalink
update function's doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 21, 2025
1 parent 39d5465 commit 63c1d68
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cpp-linter/src/common_fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,17 @@ impl FileObj {
}
}

/// Gets the line and column number from a given `offset` (of bytes) for given
/// `file_path`.
/// Gets the line number for a given `offset` (of bytes) from given the
/// byte array `contents`.
///
/// This computes the line and column numbers from a buffer of bytes read from the
/// `file_path`. In non-UTF-8 encoded files, this does not guarantee that a word
/// This computes the line number from a buffer of bytes.
/// In non-UTF-8 encoded files, this does not guarantee that a word
/// boundary exists at the returned column number. However, the `offset` given to this
/// function is expected to originate from diagnostic information provided by
/// clang-format or clang-tidy.
/// clang-format.
pub fn get_line_count_from_offset(contents: &[u8], offset: u32) -> u32 {
let offset = (offset as usize).min(contents.len());
let lines = contents[0..offset].split(|byte| byte == &b'\n');

lines.count() as u32
}

Expand Down

0 comments on commit 63c1d68

Please sign in to comment.