MCPcopy Index your code
hub / github.com/RustPython/RustPython / lstrip_sql

Function lstrip_sql

crates/stdlib/src/_sqlite3.rs:3530–3578  ·  view source on GitHub ↗
(sql: &[u8])

Source from the content-addressed store, hash-verified

3528 }
3529
3530 fn lstrip_sql(sql: &[u8]) -> Option<&[u8]> {
3531 let mut pos = 0;
3532
3533 // This loop is borrowed from the SQLite source code.
3534 while let Some(t_char) = sql.get(pos) {
3535 match t_char {
3536 b' ' | b'\t' | b'\x0c' | b'\n' | b'\r' => {
3537 // Skip whitespace.
3538 pos += 1;
3539 }
3540 b'-' => {
3541 // Skip line comments.
3542 if sql.get(pos + 1) == Some(&b'-') {
3543 pos += 2;
3544 while let Some(&ch) = sql.get(pos) {
3545 if ch == b'\n' {
3546 break;
3547 }
3548 pos += 1;
3549 }
3550 let _ = sql.get(pos)?;
3551 } else {
3552 return Some(&sql[pos..]);
3553 }
3554 }
3555 b'/' => {
3556 // Skip C style comments.
3557 if sql.get(pos + 1) == Some(&b'*') {
3558 pos += 2;
3559 while let Some(&ch) = sql.get(pos) {
3560 if ch == b'*' && sql.get(pos + 1) == Some(&b'/') {
3561 break;
3562 }
3563 pos += 1;
3564 }
3565 let _ = sql.get(pos)?;
3566 pos += 2;
3567 } else {
3568 return Some(&sql[pos..]);
3569 }
3570 }
3571 _ => {
3572 return Some(&sql[pos..]);
3573 }
3574 }
3575 }
3576
3577 None
3578 }
3579}

Callers 1

newMethod · 0.85

Calls 2

SomeClass · 0.50
getMethod · 0.45

Tested by

no test coverage detected