Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle CRLF line endings #5

Open
osa1 opened this issue Sep 22, 2021 · 1 comment
Open

Handle CRLF line endings #5

osa1 opened this issue Sep 22, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@osa1
Copy link
Owner

osa1 commented Sep 22, 2021

Repro steps:

  • Clone https://github.com/ocaml/ocaml
  • I'm trying with commit 2e065ea2d but I suspect any commit will do
  • Run sg --ocaml -k identifier 1
  • It will print incorrect matches, and then panic

Backtrace:

thread 'main' panicked at 'byte index 35 is out of bounds of `    ('a1, 'b1, 'c1, 'd1, 'e1, 'f1,`', src/main.rs:433:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::str::slice_error_fail
   3: core::str::traits::<impl core::slice::index::SliceIndex<str> for core::ops::range::Range<usize>>::index
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/str/traits.rs:214:21
   4: core::str::traits::<impl core::ops::index::Index<I> for str>::index
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/str/traits.rs:64:9
   5: sg::report_match
             at /home/omer/rust/sg/src/main.rs:433:19
   6: sg::walk_ast
             at /home/omer/rust/sg/src/main.rs:250:17
   7: sg::search_file
             at /home/omer/rust/sg/src/main.rs:198:5
   8: sg::walk_path
             at /home/omer/rust/sg/src/main.rs:174:17
   9: sg::walk_path
             at /home/omer/rust/sg/src/main.rs:171:13
  10: sg::run
             at /home/omer/rust/sg/src/main.rs:130:9
  11: sg::main
             at /home/omer/rust/sg/src/main.rs:50:15
  12: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Same thing happens if I search in Rust files in a large Rust repo (tried with rustc).

@osa1 osa1 added the bug Something isn't working label Sep 22, 2021
osa1 added a commit that referenced this issue Sep 24, 2021
Fixes some of the issues reported in #5, but not all
osa1 added a commit that referenced this issue Sep 24, 2021
…the node

Fixes some of the other issues with #5, but only works when line endings
are one character (i.e. breaks when lines end with "\r\n").
@osa1
Copy link
Owner Author

osa1 commented Sep 24, 2021

Fixed a few issues (code is a mess, will clean later (hopefully)). Need to implement CRLF handling before closing this.

@osa1 osa1 changed the title Incorrect results and panic Handle CRLF line endings Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant