Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Differences from cscope

Ripscope takes cscope’s command line and prints cscope’s rows, but it reads C with its own scanner, keeps its own index and updates that index differently. The deliberate differences are explained below. To move an existing setup over, follow Switch from cscope.

Updates and index safety

BehaviorWhat Ripscope does
Complete revisionsAn update commits one SQLite transaction. A query reads one complete revision, and an open session sees a later commit on its next query.
Changed sourcesAn ordinary update compares each file’s size, times and identity, and hashes recently modified files. --verify or -bu reads every file. On Windows, an in-place edit that preserves size and restores modification time can be missed by an ordinary update.
Source removal and read failuresStored symbol queries can answer after sources are deleted. Text searches read the current files and skip unreadable ones with a warning. A failed update keeps the preceding revision. See Check and repair an index.
Existing filesAn index build accepts an absent path, an empty file or a Ripscope index. It refuses a cscope database or unrelated file. The storage it accepts is described in limitations.

An unchanged stored index and a text search of the current files can show different states of the source. Stored and live fields explains when to update.

Corrections: reading C where cscope misreads it

Ripscope reads C the way cscope does, except for specific constructs that cscope gets wrong. Each such change is called a Correction. For every Correction the project keeps the source, what cscope reports and what Ripscope reports, so you can check the claim yourself. Four examples:

Written constructWhat changes
extern "C" { ... } in a C headerThe linkage-block Correction prevents cscope’s declaration state from hiding later definitions. Source, reference, intended reading.
A continued macro with CR LF endingsThe CR LF continuation Correction keeps its body together. Source, reference, intended reading.
A pointer-to-function or pointer-to-array declarationSupported declarator shapes define the member or global name rather than its parameter or type. Source, reference, intended reading.
Parameters of a function typedefRecognised parameter names and types stay out of definition results. Source, reference, intended reading.

Other Corrections cover atomic types, attributes, directive and macro boundaries, initializer entries, function heads and typedef decorations.

Ripscope does not expand macros or resolve types, so an ambiguous construct can still be read wrongly. How Ripscope reads C gives every rule and the shapes it leaves alone.

Field 9 includes supported array initializers, direct named subscript stores and direct named prefix and postfix increments and decrements. It reports written sites, including macro bodies and unevaluated operands, whether or not they run, and does not resolve pointer aliases. The paired subscript-store source and named-mutation source show both tools’ answers. The assignment search decision gives the exact boundary of what is recognised.

Query results

cscope can give different rows for the same search depending on whether its database was built with -q. Ripscope always answers the same way. It reads names in order and gives each occurrence the context it sits in within its file.

CaseRipscope’s reading
A matching type appears before the function name in a headReading continues through every name, so the function still becomes the body’s context.
Alternative function heads under #if share a bodyOnly the latest head is the call’s function context, so a callee query for an earlier alternative head finds no calls.
A macro is defined inside a function bodyCalls in its body use the macro context. Callee queries match that context rather than the surrounding function.
A file ends with an open contextContext does not carry into another file.
More than one definition occurs on a lineA definition query gives one row per matching line.
An include occurs inside a functionThe includer result uses <global>.

The semantics capture records cscope’s rows for these cases, with and without -q. How Ripscope answers stored queries describes the rules in full.

Patterns, bytes and displayed text

  • Patterns use the documented regular-expression dialect. Ripscope anchors a definition-query alternation as a whole and refuses unsupported expressions with a diagnostic. A pattern can contain up to 4,096 bytes.
  • Names are stored, matched and shown whole, including names beyond cscope’s 250-byte buffer. The long-name capture shows what cscope does with them.
  • Stored rows preserve UTF-8 and display control bytes visibly as \xHH. Live text-search rows keep tabs and CR LF endings, while escaping other control bytes. On a Windows console, bytes that are not UTF-8 are escaped too.
  • Editor row parsers written for cscope can split paths at spaces. The JSON interface carries exact path and line bytes, and the Neovim plugin uses it.

Check it yourself

The benchmarks compare both tools’ answers and search times on the Linux kernel, Redis and zlib, and explain every row where they differ. The evidence index lists the inputs behind each difference on this page, and quality and compatibility describes how the project measures them.

The best check is the navigation you need in your own project. Please report an unexpected difference with the source, exact commands and program versions.

Not supported

  • cscope’s full-screen terminal interface and its text-changing feature. Field 5 is a text search, as in cscope’s line mode.
  • Reading or writing cscope databases.
  • -T and -s, which would change the answers. They are refused rather than ignored.

-c, -p N and -F FILE change nothing in line mode, so Ripscope accepts and ignores them, as it does -q, -e, -U and -v (see the command line).

Ripscope is an independent project and is not affiliated with cscope. cscope’s interface and observable behavior are credited in the cscope notice.