| 1 |
\input texinfo |
| 2 |
@comment %**start of header |
| 3 |
@setfilename idutils.info |
| 4 |
@settitle ID database utilities |
| 5 |
@comment %**end of header |
| 6 |
|
| 7 |
@include version.texi |
| 8 |
|
| 9 |
@c Define new indices for file names and options. |
| 10 |
@defcodeindex fl |
| 11 |
@defcodeindex op |
| 12 |
|
| 13 |
@c Put everything in one index (arbitrarily chosen to be the concept index). |
| 14 |
@syncodeindex fl cp |
| 15 |
@syncodeindex fn cp |
| 16 |
@syncodeindex ky cp |
| 17 |
@syncodeindex op cp |
| 18 |
@syncodeindex pg cp |
| 19 |
@syncodeindex vr cp |
| 20 |
|
| •21 |
@dircategory Development |
| 22 |
@ifinfo |
| 23 |
@format |
| 24 |
START-INFO-DIR-ENTRY |
| 25 |
* ID utilities: (idutils). Indexing and searching utilities. |
| 26 |
* mkid: (idutils)mkid invocation. Creating an ID database. |
| 27 |
* lid: (idutils)lid invocation. Matching words and patterns. |
| 28 |
* fid: (idutils)fid invocation. Listing a file's tokens. |
| 29 |
* gid: (idutils)gid invocation. Token-based grep. |
| 30 |
* fnid: (idutils)fnid invocation. Looking up file names. |
| 31 |
* xtokid: (idutils)xtokid invocation. Testing mkid scanners. |
| 32 |
END-INFO-DIR-ENTRY |
| 33 |
@end format |
| 34 |
@end ifinfo |
| 35 |
|
| 36 |
@copying |
| 37 |
This file documents the @file{idutils} database utilities. |
| 38 |
|
| 39 |
Copyright @copyright{} 1996--2020 Free Software Foundation, Inc. |
| 40 |
|
| 41 |
@quotation |
| 42 |
Permission is granted to copy, distribute and/or modify this document |
| 43 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 44 |
any later version published by the Free Software Foundation; with no |
| 45 |
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover |
| 46 |
Texts. A copy of the license is included in the section entitled ``GNU |
| 47 |
Free Documentation License'' in the Emacs manual. |
| 48 |
|
| 49 |
This document is part of a collection distributed under the GNU Free |
| 50 |
Documentation License. If you want to distribute this document |
| 51 |
separately from the collection, you can do so by adding a copy of the |
| 52 |
license to the document, as described in section 6 of the license. |
| 53 |
@end quotation |
| 54 |
@end copying |
| 55 |
|
| 56 |
@titlepage |
| 57 |
@title ID database utilities |
| 58 |
@subtitle Programs for simple, fast, high-capacity cross-referencing |
| 59 |
@subtitle for version @value{VERSION} |
| 60 |
@author Greg McGary |
| 61 |
@author Tom Horsley |
| 62 |
@end titlepage |
| 63 |
|
| 64 |
@c ************* gkm ********************************************************* |
| 65 |
@node Top |
| 66 |
@top ID utilities |
| 67 |
|
| 68 |
This manual documents version @value{VERSION} of the ID utilities. |
| 69 |
|
| 70 |
@menu |
| 71 |
* Introduction:: Overview of the tools with tutorial. |
| 72 |
* Quick start:: Quick start procedure. |
| 73 |
* Common options:: Common command-line options. |
| 74 |
* mkid invocation:: Creating an ID database. |
| 75 |
* lid invocation:: Querying an ID database by token. |
| 76 |
* fid invocation:: Listing a file's tokens. |
| 77 |
* fnid invocation:: Looking up file names. |
| 78 |
* gid invocation:: Token-based grep |
| 79 |
* xtokid invocation:: Testing language scanners. |
| 80 |
* Past and Future:: History and future directions. |
| 81 |
* Index:: General index. |
| 82 |
@end menu |
| 83 |
|
| 84 |
@c ************* gkm ********************************************************* |
| 85 |
@node Introduction |
| 86 |
@chapter Introduction |
| 87 |
|
| 88 |
@cindex overview |
| 89 |
@cindex introduction |
| 90 |
@cindex ID database, definition of |
| 91 |
|
| 92 |
An @dfn{ID database} is a binary file containing a list of file names, a |
| 93 |
list of tokens, and a sparse matrix indicating which tokens |
| 94 |
appear in which files. |
| 95 |
|
| 96 |
With this database and some tools to query it (described in this |
| 97 |
manual), many text-searching tasks become simpler and faster. For |
| 98 |
example, you can list all files that reference a particular |
| 99 |
@code{#include} file throughout a huge source hierarchy, search for all |
| 100 |
the memos containing references to a project, or automatically invoke an |
| 101 |
editor on all files containing references to some function or variable. |
| 102 |
Anyone with a large software project to maintain, or a large set of text |
| 103 |
files to organize, can benefit from the ID utilities. |
| 104 |
|
| 105 |
Although the name `ID' is short for `identifier', the ID utilities |
| 106 |
handle more than just identifiers; they also treat other kinds of |
| 107 |
tokens, most notably numeric constants, and the contents of certain |
| 108 |
character strings. Thus, this manual will use the word @dfn{token} as a |
| 109 |
term that is inclusive of identifiers, numbers and strings. |
| 110 |
|
| 111 |
There are several programs in the ID utilities family: |
| 112 |
|
| 113 |
@table @file |
| 114 |
|
| 115 |
@item mkid |
| 116 |
scans files for tokens and builds the ID database file. |
| 117 |
|
| 118 |
@item lid |
| 119 |
queries the ID database for tokens, then reports matching file names or |
| 120 |
matching lines. |
| 121 |
|
| 122 |
@item fid |
| 123 |
lists all tokens recorded in the database for given files, or |
| 124 |
tokens common to two files. |
| 125 |
|
| 126 |
@item fnid |
| 127 |
matches the file names in the database, rather than the tokens. |
| 128 |
|
| 129 |
@item xtokid |
| 130 |
extracts raw tokens---helps with testing of new @file{mkid} scanners. |
| 131 |
|
| 132 |
@end table |
| 133 |
|
| 134 |
In addition, the ID utilities have historically provided several query |
| 135 |
programs which are specializations of @file{lid}: |
| 136 |
|
| 137 |
@table @file |
| 138 |
|
| 139 |
@item gid |
| 140 |
(alias for @samp{lid -R grep}) |
| 141 |
lists all lines containing the requested pattern. |
| 142 |
|
| 143 |
@item eid |
| 144 |
(alias for @samp{lid -R edit}) |
| 145 |
invokes an editor on all files containing the requested pattern, and |
| 146 |
if possible, initiates a text search for that pattern. |
| 147 |
|
| 148 |
@item aid |
| 149 |
(alias for @samp{lid -ils}) treats the requested pattern |
| 150 |
as a case-insensitive literal substring. |
| 151 |
|
| 152 |
@end table |
| 153 |
|
| 154 |
@cindex bugs, reporting |
| 155 |
Please report bugs to @samp{bug-idutils@@gnu.org}. Remember to |
| 156 |
include the version number, machine architecture, input files, and any |
| 157 |
other information needed to reproduce the bug: your input, what you |
| 158 |
expected, what you got, and why it is wrong. Diffs are welcome, but |
| 159 |
please include a description of the problem as well, since this is |
| 160 |
sometimes difficult to infer. @xref{Bugs, , , gcc, GNU CC}. |
| 161 |
|
| 162 |
@c ************* gkm ********************************************************* |
| 163 |
@node Quick start |
| 164 |
@chapter Quick Start Procedure |
| 165 |
|
| 166 |
@itemize @bullet |
| 167 |
|
| 168 |
@item |
| 169 |
Unpack the distribution. |
| 170 |
|
| 171 |
@item |
| 172 |
Type @file{./configure} |
| 173 |
|
| 174 |
@item |
| 175 |
Type @samp{make} |
| 176 |
|
| 177 |
@item |
| 178 |
Type @samp{make install} as a user with the appropriate privileges |
| 179 |
(e.g., @samp{bin} or perhaps even @samp{root}). |
| 180 |
|
| 181 |
@item |
| 182 |
Type @samp{cd /usr/include; mkid} to build an ID database covering |
| 183 |
all of the system header files. |
| 184 |
|
| 185 |
@item |
| 186 |
Type @samp{lid FILE}, then @samp{gid strtok}, then @samp{aid stdout}. |
| 187 |
|
| 188 |
@end itemize |
| 189 |
|
| 190 |
You have just built, installed and used the most common commands of the |
| 191 |
GNU ID utilities. If you ever need help remembering which system header |
| 192 |
files contain a particular declaration, or reference a particular symbol, |
| 193 |
you'll want to keep the ID file you built in @file{/usr/include} for |
| 194 |
later use. If your working directory is elsewhere at the time, simply |
| 195 |
provide the @samp{-f /usr/include} option to @file{lid} (@pxref{Reading |
| 196 |
options}). |
| 197 |
|
| 198 |
@c ************* gkm ********************************************************* |
| 199 |
@node Common options |
| 200 |
@chapter Common command-line options |
| 201 |
|
| 202 |
@cindex common command-line options |
| 203 |
|
| 204 |
Certain options, and regular expression syntax, are shared by various |
| 205 |
groupings of the ID utilities. We describe these in the sections below, |
| 206 |
rather than repeating them for each program. |
| 207 |
|
| 208 |
@menu |
| 209 |
* Universal options:: Options common to all programs. |
| 210 |
* Reading options:: Options for programs that read ID databases. |
| 211 |
* Writing options:: Options for programs that write ID databases. |
| 212 |
* Walker options:: Options for programs that walk file and directory trees. |
| 213 |
* File listing options:: Options for programs that list file names. |
| 214 |
* Extraction options:: Options for programs that extract tokens from source files. |
| 215 |
@end menu |
| 216 |
|
| 217 |
@c ************* gkm ********************************************************* |
| 218 |
@node Universal options |
| 219 |
@section Options Common to All Programs |
| 220 |
|
| 221 |
@table @samp |
| 222 |
|
| 223 |
@item --help |
| 224 |
@opindex --help |
| 225 |
@cindex help, online |
| 226 |
Print a usage message listing all available options, then exit successfully. |
| 227 |
|
| 228 |
@item --version |
| 229 |
@opindex --version |
| 230 |
@cindex version number, finding |
| 231 |
Print the version number, then exit successfully. |
| 232 |
|
| 233 |
@end table |
| 234 |
|
| 235 |
@c ************* gkm ********************************************************* |
| 236 |
@node Reading options |
| 237 |
@section Options for Programs that Read ID Databases |
| 238 |
|
| 239 |
@table @samp |
| 240 |
|
| 241 |
@item -f @var{filename} |
| 242 |
@itemx --file=@var{filename} |
| 243 |
@opindex -f |
| 244 |
@opindex --file |
| 245 |
@cindex ID database file name |
| 246 |
|
| 247 |
@var{Filename} is the ID database to read when processing queries. At |
| 248 |
present, only a single @samp{--file} option is processed, but in future |
| 249 |
releases, more than one ID database may be named on the command line. |
| 250 |
|
| 251 |
@item $IDPATH |
| 252 |
@cindex ID database file name |
| 253 |
|
| 254 |
@samp{IDPATH} is an environment variable that contains a |
| 255 |
colon-separated list of ID database names. If this variable is present, |
| 256 |
and no @samp{--file} options are presented on the command line, the ID |
| 257 |
databases named in @samp{IDPATH} are implied.@footnote{At present, this |
| 258 |
feature isn't fully implemented, since only the first of a list of ID |
| 259 |
database names is processed.} |
| 260 |
|
| 261 |
@end table |
| 262 |
|
| 263 |
If no ID databases are specified either on the command line or via the |
| 264 |
@samp{IDPATH} environment variable, then the ID utilities search for a |
| 265 |
file named @file{ID} in the current working directory, and then in |
| 266 |
successive parent directories. |
| 267 |
|
| 268 |
@c ************* gkm ********************************************************* |
| 269 |
@node Writing options |
| 270 |
@section Options for Programs that Write ID Databases |
| 271 |
|
| 272 |
@table @samp |
| 273 |
|
| 274 |
@item -o @var{filename} |
| 275 |
@itemx --output=@var{filename} |
| 276 |
@opindex -o |
| 277 |
@opindex --output |
| 278 |
@cindex ID database file name |
| 279 |
|
| 280 |
The @samp{--output} option names the file in which to write a new ID |
| 281 |
database. If no @samp{--output} (or @samp{--file}) option is present, |
| 282 |
an output file named @file{ID} is implied. |
| 283 |
|
| 284 |
@item -f @var{filename} |
| 285 |
@itemx --file=@var{filename} |
| 286 |
@opindex -f |
| 287 |
@opindex --file |
| 288 |
@cindex ID database file name |
| 289 |
|
| 290 |
This is a synonym for @samp{--output} |
| 291 |
|
| 292 |
@end table |
| 293 |
|
| 294 |
@c ************* gkm ********************************************************* |
| 295 |
@node Walker options |
| 296 |
@section Options for Programs that Walk File and Directory Trees. |
| 297 |
|
| 298 |
The programs @file{mkid} and @file{xtokid} accept the names of files and |
| 299 |
directories on the command line. Files are scanned if there is a |
| 300 |
scanner available and enabled for the file's source language. |
| 301 |
Directories are recursively descended, searching for files whose names |
| 302 |
match the rules listed in the @emph{language map} file (@pxref{Language |
| 303 |
map}). |
| 304 |
|
| 305 |
The following option controls the file tree walker: |
| 306 |
|
| 307 |
@table @samp |
| 308 |
|
| 309 |
@item -p @var{names} |
| 310 |
@itemx --prune=@var{names} |
| 311 |
@opindex -p |
| 312 |
@opindex --prune |
| 313 |
@cindex file tree pruning |
| 314 |
|
| 315 |
One or more file or directory names may appear in @var{names}. The file |
| 316 |
tree walker will stop short at these files and directories and their |
| 317 |
contents will not be scanned. |
| 318 |
|
| 319 |
@item --files0-from=@var{FILE} |
| 320 |
@opindex --files0-from=@var{FILE} |
| 321 |
Rather than processing files named on the command line, process those |
| 322 |
named in file @var{FILE}; each name is terminated by a null byte. |
| 323 |
This is useful when the list of file names is so long that it may |
| 324 |
exceed a command line length limitation. |
| 325 |
One way to produce a list of null-byte-terminated file names is with |
| 326 |
@sc{gnu} @command{find}, using its @option{-print0} predicate. Do not |
| 327 |
specify any @var{FILE} on the command line when using this option. |
| 328 |
|
| 329 |
|
| 330 |
@end table |
| 331 |
|
| 332 |
@c ************* gkm ********************************************************* |
| 333 |
@node File listing options |
| 334 |
@section Options for Programs that List File Names |
| 335 |
|
| 336 |
The programs @file{lid} and @file{fnid} can print lists of file names as |
| 337 |
the result of queries. The following option controls how these lists |
| 338 |
are formatted: |
| 339 |
|
| 340 |
@table @samp |
| 341 |
|
| 342 |
@item -S @var{style} |
| 343 |
@itemx --separator=@var{style} |
| 344 |
@opindex -S |
| 345 |
@opindex --separator |
| 346 |
@cindex file name separator |
| 347 |
|
| 348 |
@var{Style} may be one of @samp{braces}, @samp{space} or @samp{newline}. |
| 349 |
|
| 350 |
The @var{style} of @samp{braces} means that file names with common |
| 351 |
directory prefix and common suffix are printed using the shell's brace |
| 352 |
notation in order to compress the output. For example, |
| 353 |
@file{../src/foo.c ../src/bar.c} can be printed in brace notation as |
| 354 |
@file{../src/@{foo,bar@}.c}. |
| 355 |
|
| 356 |
The @var{style}s of @samp{space} and @samp{newline} mean that file names |
| 357 |
are separated spaces or by newlines, respectively. |
| 358 |
|
| 359 |
If the list of files is being printed on a terminal, brace notation is |
| 360 |
the default. If not, file names are separated by spaces if the |
| 361 |
@var{key} is included in the output, and by newlines the @var{key style} |
| 362 |
is @samp{none} (@pxref{lid invocation}). |
| 363 |
|
| 364 |
@end table |
| 365 |
|
| 366 |
@c ************* gkm ********************************************************* |
| 367 |
@node Extraction options |
| 368 |
@section Options for Programs that Scan Source Files |
| 369 |
|
| 370 |
@file{mkid} and @file{xtokid} walk file trees, select source files by |
| 371 |
name, and extract tokens from source files. They accept the following |
| 372 |
options: |
| 373 |
|
| 374 |
@table @samp |
| 375 |
|
| 376 |
@item -m @var{mapfile} |
| 377 |
@itemx --lang-map=@var{mapfile} |
| 378 |
@opindex -m |
| 379 |
@opindex --lang-map |
| 380 |
@cindex language map file |
| 381 |
|
| 382 |
@var{mapfile} contains rules for determining the source languages from |
| 383 |
file names. @xref{Language map}. |
| 384 |
|
| 385 |
@item -i @var{languages} |
| 386 |
@itemx --include=@var{languages} |
| 387 |
@opindex -i |
| 388 |
@opindex --include |
| 389 |
@cindex include languages |
| 390 |
|
| 391 |
The @samp{--include} option names @var{languages} whose source files |
| 392 |
should be scanned and incorporated into the ID database. By default, |
| 393 |
all languages known to the ID utilities are enabled. |
| 394 |
|
| 395 |
@item -x @var{languages} |
| 396 |
@itemx --exclude=@var{languages} |
| 397 |
@opindex -x |
| 398 |
@opindex --exclude |
| 399 |
@cindex exclude languages |
| 400 |
|
| 401 |
The @samp{--exclude} option names @var{languages} whose source files |
| 402 |
should @var{not} be scanned. The default list of excluded languages is |
| 403 |
empty. Note that only one of @samp{--include} or @samp{--exclude} may |
| 404 |
be specified on the command line for a single run. |
| 405 |
|
| 406 |
@item -l @var{language}:@var{options} |
| 407 |
@itemx --lang-option=@var{language}:@var{options} |
| 408 |
@opindex -l |
| 409 |
@opindex --lang-option |
| 410 |
@cindex language-specific option |
| 411 |
|
| 412 |
Language-specific scanners also accept options. @var{Language} denotes |
| 413 |
the desired scanner, and @var{option} is the command-line option that |
| 414 |
should be passed through to it. For example, to pass the @var{-x foo |
| 415 |
--coke-bottle} options to the scanner for the language @var{swizzle}, |
| 416 |
use one of the next two forms, or a mixture of both: |
| 417 |
|
| 418 |
@example |
| 419 |
$ mkid -l swizzle:"-x foo" -l swizzle:--coke-bottle |
| 420 |
$ mkid --lang-option=swizzle:"-x foo" --lang-option=swizzle:--coke-bottle |
| 421 |
@end example |
| 422 |
|
| 423 |
Note the use of quotes when passing an option with arguments. Quoting is |
| 424 |
optional for options without arguments. |
| 425 |
|
| 426 |
Use the @samp{--help} option to see the command-line option summary for each |
| 427 |
language. |
| 428 |
|
| 429 |
@end table |
| 430 |
|
| 431 |
@cindex scanners |
| 432 |
|
| 433 |
To determine which tokens to extract from a file and store in the |
| 434 |
database, @file{mkid} calls a @dfn{scanner}; we say a scanner |
| 435 |
@dfn{recognizes} a particular language. Scanners for several languages |
| 436 |
are built-in to @file{mkid}; you can add your own scanners as well, as |
| 437 |
explained in @ref{Defining scanners}. |
| 438 |
|
| 439 |
The ID utilities determine which scanner to use for a particular file by |
| 440 |
consulting the language-map file. Scanners for several are already |
| 441 |
built-in to the ID utilities. You can see which languages have built-in |
| 442 |
scanners, and examine their language-specific options by invoking |
| 443 |
@samp{mkid --help} or @samp{xtokid --help}. |
| 444 |
|
| 445 |
@menu |
| 446 |
* Language map:: Mapping file names to source languages. |
| 447 |
* C Cpp Java scanner:: For the C, C++ and Java programming languages. |
| 448 |
* Assembler scanner:: For assembly language. |
| 449 |
* Text scanner:: For documents or other non-source code. |
| 450 |
* Perl scanner:: For Perl language (experimental). |
| 451 |
* Lisp scanner:: For the Lisp language (experimental). |
| 452 |
* Defining scanners:: Defining new scanners in the source code. |
| 453 |
@end menu |
| 454 |
|
| 455 |
@c ************* gkm ********************************************************* |
| 456 |
@node Language map |
| 457 |
@subsection Mapping file names to source languages |
| 458 |
|
| 459 |
The file @file{id-lang.map}, installed by default in |
| 460 |
@file{$(prefix)/share/id-lang.map}, contains rules for mapping file |
| 461 |
names to source languages. Each rule comprises three parts: a shell |
| 462 |
@var{glob} pattern, a language name, and language-specific scanner |
| 463 |
options. |
| 464 |
|
| 465 |
The special pattern @samp{**} denotes the default source language. This is |
| 466 |
the language that's assigned to file names that don't match any other |
| 467 |
pattern. |
| 468 |
|
| 469 |
The special pattern @samp{***} should be followed by a file name. The |
| 470 |
named file should contain more language-map rules and is included at |
| 471 |
this point. |
| 472 |
|
| 473 |
The order in which rules are presented in a language-map file is |
| 474 |
significant. This order influences the order in which files are |
| 475 |
displayed as the result of queries. For example, the distributed |
| 476 |
language-map file places all rules for C @var{.h} files ahead of |
| 477 |
@var{.c} files, so that in general, declarations will precede |
| 478 |
definitions in query output. The same thing is done for C++ and its |
| 479 |
many different source file name extensions. |
| 480 |
|
| 481 |
Here is a pared-down version of the @file{id-lang.map} file distributed |
| 482 |
with the ID utilities: |
| 483 |
|
| 484 |
@example |
| 485 |
|
| 486 |
# Default language |
| 487 |
** IGNORE # Although this is listed first, |
| 488 |
# the default language pattern is |
| 489 |
# logically matched last. |
| 490 |
|
| 491 |
# Backup files |
| 492 |
*~ IGNORE |
| 493 |
*.bak IGNORE |
| 494 |
*.bk[0-9] IGNORE |
| 495 |
|
| 496 |
# SCCS files |
| 497 |
[sp].* IGNORE |
| 498 |
|
| 499 |
# list header files before code files |
| 500 |
*.h C |
| 501 |
*.h.in C |
| 502 |
*.H C++ |
| 503 |
*.hh C++ |
| 504 |
*.hpp C++ |
| 505 |
*.hxx C++ |
| 506 |
|
| 507 |
# list C `meta' files next |
| 508 |
*.l C |
| 509 |
*.lex C |
| 510 |
*.y C |
| 511 |
*.yacc C |
| 512 |
|
| 513 |
# list C code files after header files |
| 514 |
*.c C |
| 515 |
*.C C++ |
| 516 |
*.cc C++ |
| 517 |
*.cpp C++ |
| 518 |
*.cxx C++ |
| 519 |
|
| 520 |
# list assembly language after C |
| 521 |
*.[sS] asm --comment=; |
| 522 |
*.asm asm --comment=; |
| 523 |
|
| 524 |
# [nt]roff |
| 525 |
*.[0-9] roff |
| 526 |
*.ms roff |
| 527 |
*.me roff |
| 528 |
*.mm roff |
| 529 |
|
| 530 |
# TeX and friends |
| 531 |
*.tex TeX |
| 532 |
*.ltx TeX |
| 533 |
*.texi texinfo |
| 534 |
*.texinfo texinfo |
| 535 |
|
| 536 |
@end example |
| 537 |
|
| 538 |
@c ************* gkm ********************************************************* |
| 539 |
@node C Cpp Java scanner |
| 540 |
@subsection C Cpp Java Language Scanner |
| 541 |
|
| 542 |
@cindex C scanner, predefined |
| 543 |
|
| 544 |
The C scanner is the most commonly used. Files that match the glob |
| 545 |
pattern @file{*.h}, @file{*.c}, as well as @file{yacc} files that match |
| 546 |
@file{*.y} or @file{*.yacc}, and @file{lex} files that match @file{*.l} |
| 547 |
or @file{*.lex}, are processed with this scanner. |
| 548 |
|
| 549 |
Scanner-specific options (Note, these options are presented |
| 550 |
@var{without} the required @samp{-l} or @samp{--lang-option=} prefix): |
| 551 |
|
| 552 |
@table @samp |
| 553 |
|
| 554 |
@item -k @var{character-class} |
| 555 |
@itemx --keep=@var{character-class} |
| 556 |
@opindex -k |
| 557 |
@opindex --keep |
| 558 |
@opindex -l C:-k |
| 559 |
@opindex -l C:--keep |
| 560 |
@opindex --lang-option=C:-k |
| 561 |
@opindex --lang-option=C:--keep |
| 562 |
|
| 563 |
Consider the characters in @var{character-class} as valid constituents of |
| 564 |
identifier names. For example, if you are indexing C code that contains |
| 565 |
@samp{$} in some of its identifiers, you can include these by using |
| 566 |
@samp{--lang-option=C:--keep=$}, or @samp{-l C:"-k $"} (if you don't like |
| 567 |
to type so much). |
| 568 |
|
| 569 |
@item -i @var{character-class} |
| 570 |
@itemx --ignore=@var{character-class} |
| 571 |
@opindex -i |
| 572 |
@opindex --ignore |
| 573 |
@opindex -l C:-i |
| 574 |
@opindex -l C:--ignore |
| 575 |
@opindex --lang-option=C:-i |
| 576 |
@opindex --lang-option=C:--ignore |
| 577 |
|
| 578 |
Consider the characters in @var{character-class} as valid constituents of |
| 579 |
identifier names, but discard all tokens containing these characters. |
| 580 |
For example, if some C code has identifiers containing @samp{$}, but you |
| 581 |
don't want these cluttering up your ID database, use |
| 582 |
@samp{--lang-option=C:--ignore=$}, or the terser equivalent @samp{-l |
| 583 |
C:"-i $"}. |
| 584 |
|
| 585 |
@item -u |
| 586 |
@itemx --strip-underscore |
| 587 |
@opindex -u |
| 588 |
@opindex --strip-underscore |
| 589 |
@opindex -l C:-u |
| 590 |
@opindex -l C:--strip-underscore |
| 591 |
@opindex --lang-option=C:-u |
| 592 |
@opindex --lang-option=C:--strip-underscore |
| 593 |
|
| 594 |
Strip one leading underscore from C identifiers encapsulated as |
| 595 |
character strings. This option is useful if you are indexing C code |
| 596 |
that contains symbol-table name strings for systems that prepend an |
| 597 |
underscore to external symbols. By default, the leading underscore is |
| 598 |
retained. |
| 599 |
|
| 600 |
@end table |
| 601 |
|
| 602 |
@c ************* gkm ********************************************************* |
| 603 |
@node Assembler scanner |
| 604 |
@subsection Assembly Language Scanner |
| 605 |
|
| 606 |
@cindex assembler scanner |
| 607 |
@cindex assembly language scanner |
| 608 |
|
| 609 |
Assembly languages use a variety of commenting conventions, and allow a |
| 610 |
variety of special characters to @emph{dirty up} local symbols, |
| 611 |
preventing name space conflicts with symbols defined by higher-level |
| 612 |
languages. Also, some compilation systems prepend an underscore to |
| 613 |
external symbols. The options listed below are designed to address |
| 614 |
these differences. |
| 615 |
|
| 616 |
@table @samp |
| 617 |
|
| 618 |
@item -c @var{character-class} |
| 619 |
@itemx --comment=@var{character-class} |
| 620 |
@opindex -c |
| 621 |
@opindex --comment |
| 622 |
@opindex -l asm:-c |
| 623 |
@opindex -l asm:--comment |
| 624 |
@opindex --lang-option=asm:-c |
| 625 |
@opindex --lang-option=asm:--comment |
| 626 |
|
| 627 |
The characters in @var{character-class} are considered left delimiters |
| 628 |
for comments that extend until the end of the current line. |
| 629 |
|
| 630 |
@item -k @var{character-class} |
| 631 |
@itemx --keep=@var{character-class} |
| 632 |
@opindex -k |
| 633 |
@opindex --keep |
| 634 |
@opindex -l asm:-k |
| 635 |
@opindex -l asm:--keep |
| 636 |
@opindex --lang-option=asm:-k |
| 637 |
@opindex --lang-option=asm:--keep |
| 638 |
|
| 639 |
Consider the characters of @var{character-class} as valid constituents of |
| 640 |
identifier names. For example, if you are indexing assembly code that |
| 641 |
prepends @samp{.} to assembler directives, and prepends @samp{%} to |
| 642 |
register names, you can keep these characters in the tokens by specifying |
| 643 |
@samp{--lang-option=asm:--keep=.%}, or @samp{-l asm:"-k .%"}. |
| 644 |
|
| 645 |
@item -i @var{character-class} |
| 646 |
@itemx --ignore=@var{character-class} |
| 647 |
@opindex -i |
| 648 |
@opindex --ignore |
| 649 |
@opindex -l asm:-i |
| 650 |
@opindex -l asm:--ignore |
| 651 |
@opindex --lang-option=asm:-i |
| 652 |
@opindex --lang-option=asm:--ignore |
| 653 |
|
| 654 |
Consider the characters of @var{character-class} as valid constituents |
| 655 |
of identifier names, but discard all tokens containing these characters. |
| 656 |
For example, if you don't want to clutter your ID database with |
| 657 |
assembler directives that begin with a leading @samp{.} or with |
| 658 |
assembler labels that contain @samp{@@}, use |
| 659 |
@samp{--lang-option=asm:--ignore=.@@}, or @samp{-l asm:"-i .@@"}. |
| 660 |
|
| 661 |
@item -u |
| 662 |
@itemx --strip-underscore |
| 663 |
@opindex -u |
| 664 |
@opindex --strip-underscore |
| 665 |
@opindex -l asm:-u |
| 666 |
@opindex -l asm:--strip-underscore |
| 667 |
@opindex --lang-option=asm:-u |
| 668 |
@opindex --lang-option=asm:--strip-underscore |
| 669 |
|
| 670 |
Strip one leading underscore from identifiers. This option is useful if |
| 671 |
your compilation system prepends an underscore to external symbols. By |
| 672 |
stripping the underscore, you can canonicalize such names and bring them |
| 673 |
into conformance the way they are expressed in the C language. By |
| 674 |
default, the leading underscore is retained. |
| 675 |
|
| 676 |
@item -n |
| 677 |
@itemx --no-cpp |
| 678 |
@opindex -n |
| 679 |
@opindex --no-cpp |
| 680 |
@opindex -l asm:-n |
| 681 |
@opindex -l asm:--no-cpp |
| 682 |
@opindex --lang-option=asm:-n |
| 683 |
@opindex --lang-option=asm:--no-cpp |
| 684 |
|
| 685 |
Do not recognize C preprocessor directives. By default, such lines are |
| 686 |
handled in the same way as they are by the C language scanner. |
| 687 |
|
| 688 |
@end table |
| 689 |
|
| 690 |
@c ************* gkm ********************************************************* |
| 691 |
@node Text scanner |
| 692 |
@subsection Text Scanner |
| 693 |
|
| 694 |
@cindex text scanner |
| 695 |
|
| 696 |
The plain text scanner is intended for human-language documents, or as the |
| 697 |
scanner of last resort for files that have no scanner that is more |
| 698 |
specific. It is customizable to the extent that character classes can |
| 699 |
be designated as token constituents or as token delimiters. The default |
| 700 |
token constituents are the alpha-numerics; all other characters are |
| 701 |
considered token delimiters. |
| 702 |
|
| 703 |
@table @samp |
| 704 |
|
| 705 |
@item -i @var{character-class} |
| 706 |
@itemx --include=@var{character-class} |
| 707 |
@opindex -i |
| 708 |
@opindex --include |
| 709 |
@opindex -l text:-i |
| 710 |
@opindex -l text:--include |
| 711 |
@opindex --lang-option=text:-i |
| 712 |
@opindex --lang-option=text:--include |
| 713 |
|
| 714 |
Include characters belonging to @var{character-class} in tokens. |
| 715 |
|
| 716 |
@item -x @var{character-class} |
| 717 |
@itemx --exclude=@var{character-class} |
| 718 |
@opindex -x |
| 719 |
@opindex --exclude |
| 720 |
@opindex -l text:-x |
| 721 |
@opindex -l text:--exclude |
| 722 |
@opindex --lang-option=text:-x |
| 723 |
@opindex --lang-option=text:--exclude |
| 724 |
|
| 725 |
Exclude characters belonging to @var{character-class} from tokens, i.e., treat |
| 726 |
them as token delimiters. |
| 727 |
|
| 728 |
@end table |
| 729 |
|
| 730 |
@c ************* gkm ********************************************************* |
| 731 |
@node Perl scanner |
| 732 |
@subsection Perl Scanner |
| 733 |
|
| 734 |
@cindex perl scanner |
| 735 |
(EXPERIMENTAL) |
| 736 |
|
| 737 |
The perl scanner is intended for perl-language documents. Tokens are all |
| 738 |
words, Perl Keywords are included. Comments & string declarations are |
| 739 |
ignored, as well as the documentation. It is customizable to the extent |
| 740 |
that character classes can be designated as token constituents or as |
| 741 |
token delimiters. The default token constituents are the alpha-numerics; |
| 742 |
all other characters are considered token delimiters. |
| 743 |
|
| 744 |
Perl support has been originally written by Madhu Gogulapati. |
| 745 |
This scanner is considered experimental; please report any problems you |
| 746 |
should encounter to @samp{bug-idutils@@gnu.org} . |
| 747 |
|
| 748 |
@table @samp |
| 749 |
|
| 750 |
@item -i @var{character-class} |
| 751 |
@itemx --include=@var{character-class} |
| 752 |
@opindex -i |
| 753 |
@opindex --include |
| 754 |
@opindex -l perl:-i |
| 755 |
@opindex -l perl:--include |
| 756 |
@opindex --lang-option=perl:-i |
| 757 |
@opindex --lang-option=perl:--include |
| 758 |
|
| 759 |
Include characters belonging to @var{character-class} in tokens. |
| 760 |
|
| 761 |
@item -x @var{character-class} |
| 762 |
@itemx --exclude=@var{character-class} |
| 763 |
@opindex -x |
| 764 |
@opindex --exclude |
| 765 |
@opindex -l perl:-x |
| 766 |
@opindex -l perl:--exclude |
| 767 |
@opindex --lang-option=perl:-x |
| 768 |
@opindex --lang-option=perl:--exclude |
| 769 |
|
| 770 |
Exclude characters belonging to @var{character-class} from tokens, i.e., treat |
| 771 |
them as token delimiters. |
| 772 |
|
| 773 |
@item -d |
| 774 |
@itemx --dtags |
| 775 |
@opindex -d |
| 776 |
@opindex --dtags |
| 777 |
@opindex -l asm:-d |
| 778 |
@opindex -l asm:--dtags |
| 779 |
@opindex --lang-option=perl:-d |
| 780 |
@opindex --lang-option=perl:--dtags |
| 781 |
|
| 782 |
Include tokens from the documentation. By default, the tokens in the |
| 783 |
documentation are ignored. |
| 784 |
|
| 785 |
@end table |
| 786 |
|
| 787 |
@c ************* gkm ********************************************************* |
| 788 |
@node Lisp scanner |
| 789 |
@subsection Lisp Scanner |
| 790 |
|
| 791 |
@cindex lisp scanner |
| 792 |
(EXPERIMENTAL) |
| 793 |
|
| 794 |
The lisp scanner has been originally written by Edouard G. Parmelan, |
| 795 |
and after many years it was posthumously integrated with the main idutils |
| 796 |
code. It is intended for Lisp and Emacs Lisp files (.lisp, .el, .elc, .scm). |
| 797 |
No options are currently available for this scanner. |
| 798 |
|
| 799 |
This scanner is considered experimental; please report any problems you |
| 800 |
should encounter to @samp{bug-idutils@@gnu.org} . |
| 801 |
|
| 802 |
@c ************* gkm ********************************************************* |
| 803 |
@node Defining scanners |
| 804 |
@subsection Defining New Scanners in the Source Code |
| 805 |
|
| 806 |
@flindex scanners.c |
| 807 |
@cindex scanners, defining in source code |
| 808 |
|
| 809 |
@vindex languages_0 |
| 810 |
|
| 811 |
To add a new scanner in source code, you should add a new section to the |
| 812 |
file @file{scanners.c}. It might be easiest to clone one of the |
| 813 |
existing scanners and modify it as necessary. For the hypothetical |
| 814 |
language @var{foo}, you must define the functions @code{get_token_foo}, |
| 815 |
@code{parse_args_foo}, @code{help_me_foo}, as well as the tables |
| 816 |
@code{long_options_foo} and @code{args_foo}. If your scanner is |
| 817 |
modeled after one of the existing scanners, you'll also need a |
| 818 |
character-attribute table @code{ctype_foo}. |
| 819 |
|
| 820 |
This is not a terribly difficult programming task, but it requires |
| 821 |
recompiling and installing the new version of @file{mkid} and @file{xtokid}. |
| 822 |
You should use @file{xtokid} to test the operation of the new scanner. |
| 823 |
|
| 824 |
Once these functions and tables are ready, add function prototypes and |
| 825 |
an entry to the @code{languages_0} table near the beginning of the file. |
| 826 |
|
| 827 |
Be warned that the existing scanners are built for speed, not elegance |
| 828 |
or readability. You might wish to create a new scanner that's easier to |
| 829 |
read and understand if you don't feel that speed is so important. |
| 830 |
|
| 831 |
@c ************* gkm ********************************************************* |
| 832 |
@node mkid invocation |
| 833 |
@chapter @samp{mkid}: Creating an ID Database |
| 834 |
@cindex creating databases |
| 835 |
@cindex databases, creating |
| 836 |
@cindex ID file format |
| 837 |
@cindex architecture-independence |
| 838 |
@cindex sharing ID files |
| 839 |
|
| 840 |
@file{mkid} builds an ID database. It accepts the names of files and/or |
| 841 |
directories on the command line, selects files that have an enabled |
| 842 |
scanner, then extracts and stores tokens from those files. The |
| 843 |
resulting ID database is architecture- and byte-order-independent so it |
| 844 |
can be shared among all systems. |
| 845 |
|
| 846 |
The primary virtues of @file{mkid} are speed and high capacity. The |
| 847 |
size of the source trees it can index is limited only by available |
| 848 |
system memory. @file{mkid}'s indexing algorithm is very space-efficient |
| 849 |
and exhibits excellent locality-of-reference, and so is capable of |
| 850 |
operating with a working-set size that is only half the size of its |
| 851 |
virtual address space. A typical @sc{unix}-like operating system with |
| 852 |
16 megabytes of system memory should be able to build an ID database |
| 853 |
covering approximately 12,000-14,000 source files totaling |
| 854 |
approximately 50--100 Megabytes. A 66 MHz 486 computer can build such |
| 855 |
a large ID database in approximately 10-15 minutes. |
| 856 |
|
| 857 |
@pindex cron |
| 858 |
In a future release, @file{mkid} will be able to incrementally update an |
| 859 |
ID database much faster than it can build one from scratch. Until this |
| 860 |
feature becomes available, it might be a good idea to schedule a |
| 861 |
@file{cron} job to regularly update large ID databases during off-hours. |
| 862 |
|
| 863 |
@file{mkid} writes the ID file, therefore it accepts the @samp{--output} |
| 864 |
(and @samp{--file}) options as described in @ref{Writing options}. |
| 865 |
@file{mkid} extracts tokens from source files, therefore it accepts the |
| 866 |
@samp{--lang-map}, @samp{--include}, @samp{--exclude}, and |
| 867 |
@samp{--lang-option} options, as well as the language-specific scanner |
| 868 |
options, all of which are described in @ref{Extraction options}. |
| 869 |
@file{mkid} walks file trees, therefore it handles file and directory |
| 870 |
names on its command line and the @samp{--prune} option as described in |
| 871 |
@ref{Walker options}. |
| 872 |
|
| 873 |
In addition, @file{mkid} accepts the following command-line options: |
| 874 |
|
| 875 |
@table @samp |
| 876 |
|
| 877 |
@item -s |
| 878 |
@itemx --statistics |
| 879 |
@opindex -s |
| 880 |
@opindex --statistics |
| 881 |
@cindex statistics |
| 882 |
|
| 883 |
@file{mkid} reports statistics about resource usage at the end of its |
| 884 |
run. |
| 885 |
|
| 886 |
@item -v |
| 887 |
@itemx --verbose |
| 888 |
@opindex -v |
| 889 |
@opindex --verbose |
| 890 |
@cindex @file{mkid} progress |
| 891 |
|
| 892 |
@file{mkid} reports statistics about each file as it is scanned, and |
| 893 |
about the resource usage of its indexing algorithm at regular intervals. |
| 894 |
|
| 895 |
@end table |
| 896 |
|
| 897 |
@c ************* gkm ********************************************************* |
| 898 |
@node lid invocation |
| 899 |
@chapter @code{lid}: Querying an ID Database by Token |
| 900 |
|
| 901 |
The @file{lid} program accepts @var{patterns} on the command line which |
| 902 |
it matches against the tokens stored in an ID database. The |
| 903 |
interpretation of a @var{pattern} is determined by the makeup of the |
| 904 |
@var{pattern} string itself, or can be overridden by command-line |
| 905 |
options. If a @var{pattern} contains regular expression meta-characters, |
| 906 |
it is used to perform a regular-expression substring search. If no such |
| 907 |
meta-characters are present, @var{pattern} is used to perform a literal |
| 908 |
word search. (By default, all searches are sensitive to alphabetic |
| 909 |
case.) If no @var{pattern} is supplied on the command line, @file{lid} |
| 910 |
lists every entry in the ID database. |
| 911 |
|
| 912 |
@file{lid} reads the ID database, therefore it accepts the @samp{--file} |
| 913 |
option, and consults the @samp{IDPATH} environment variable, as |
| 914 |
described in @ref{Reading options}. @file{lid} lists file names, |
| 915 |
therefore it accepts the @samp{--separator} option, as described in |
| 916 |
@ref{File listing options}. |
| 917 |
|
| 918 |
In addition, @code{lid} accepts the following command-line options: |
| 919 |
|
| 920 |
@table @samp |
| 921 |
|
| 922 |
@item -i |
| 923 |
@itemx --ignore-case |
| 924 |
@opindex -i |
| 925 |
@opindex --ignore-case |
| 926 |
@cindex alphabetic case, ignoring differences in |
| 927 |
@cindex ignoring differences in alphabetic case |
| 928 |
|
| 929 |
Ignoring differences in alphabetic case between the @var{pattern} and |
| 930 |
the tokens in the ID database. |
| 931 |
|
| 932 |
@item -l |
| 933 |
@itemx --literal |
| 934 |
@opindex -l |
| 935 |
@opindex --literal |
| 936 |
|
| 937 |
Match @var{pattern} as a literal string. Use this option if |
| 938 |
@var{pattern} contains regular-expression meta-characters, but you don't |
| 939 |
wish to perform a regular-expression search. |
| 940 |
|
| 941 |
@item -r |
| 942 |
@itemx --regexp |
| 943 |
@opindex -r |
| 944 |
@opindex --regexp |
| 945 |
|
| 946 |
Match @var{pattern} as an @emph{extended} regular expression@footnote{Extended |
| 947 |
regular expressions are the same as those accepted by @file{egrep}.}. |
| 948 |
Use this option if no regular-expression expression meta-characters are |
| 949 |
present in @var{pattern}, but you wish to force a regular-expression |
| 950 |
search (note: in this case, a @emph{literal substring} search might be |
| 951 |
faster). |
| 952 |
|
| 953 |
@item -w |
| 954 |
@itemx --word |
| 955 |
@opindex -w |
| 956 |
@opindex --word |
| 957 |
|
| 958 |
Match @var{pattern} using a word-delimited (non substring) search. This |
| 959 |
is the default for literal searches. |
| 960 |
|
| 961 |
@item -s |
| 962 |
@itemx --substring |
| 963 |
@opindex -s |
| 964 |
@opindex --substring |
| 965 |
|
| 966 |
Match @var{pattern} using a substring (non word-delimited) search. This |
| 967 |
is the default for regular expression searches. |
| 968 |
|
| 969 |
@item -k @var{style} |
| 970 |
@itemx --key=@var{style} |
| 971 |
@opindex -k |
| 972 |
@opindex --substring |
| 973 |
|
| 974 |
@var{Style} can be one of @samp{token}, @samp{pattern} or @samp{none}. |
| 975 |
This option controls how the subject of the query is presented. This is |
| 976 |
best illustrated by example: |
| 977 |
|
| 978 |
@example |
| 979 |
$ lid --key=token '^dest.' |
| 980 |
destaddr libsys/memcpy.c |
| 981 |
destination libsys/regex.c |
| 982 |
destlst libsys/rx.c |
| 983 |
destpos libsys/rx.c |
| 984 |
destset libsys/rx.h libsys/rx.c |
| 985 |
|
| 986 |
$ lid --key=pattern '^dest.' |
| 987 |
^dest. libsys/rx.h libsys/@{memcpy,regex,rx@}.c |
| 988 |
|
| 989 |
$ lid --key=none '^dest.' |
| 990 |
libsys/rx.h libsys/@{memcpy,regex,rx@}.c |
| 991 |
@end example |
| 992 |
|
| 993 |
When @samp{--key} is either @samp{token} or @samp{pattern}, the first |
| 994 |
column of output is a @var{token} or @var{pattern}, respectively. When |
| 995 |
@samp{--key} is @samp{none}, neither of these is printed, and the file |
| 996 |
name list begins immediately. The default is @samp{token}. |
| 997 |
|
| 998 |
@item -R @var{style} |
| 999 |
@itemx --result=@var{style} |
| 1000 |
@opindex -R |
| 1001 |
@opindex --result |
| 1002 |
|
| 1003 |
@var{Style} can be one of @samp{filenames}, @samp{grep}, @samp{edit} or |
| 1004 |
@samp{none}. This option controls how the value associated with the |
| 1005 |
query's @var{key} presented. When @var{style} is @samp{filenames}, a |
| 1006 |
list of file names is printed (this is the default). When @var{style} |
| 1007 |
is @samp{grep}, the lines that match @var{pattern} are printed in the |
| 1008 |
same format as @samp{egrep -n}. When @var{style} is @samp{edit}, the |
| 1009 |
file names are passed to an editor, and if possible @var{pattern} is |
| 1010 |
passed as an initial search string (@pxref{eid invocation}). When |
| 1011 |
@var{style} is @samp{none}, the file names are not processed in any way. |
| 1012 |
This can be useful if you wish to see what tokens match a @var{pattern}, |
| 1013 |
but don't care about where they reside. |
| 1014 |
|
| 1015 |
@item -d |
| 1016 |
@itemx -o |
| 1017 |
@itemx -x |
| 1018 |
@opindex -d |
| 1019 |
@opindex -o |
| 1020 |
@opindex -x |
| 1021 |
@cindex radix of numeric matches, specifying |
| 1022 |
@cindex numeric matches, specifying radix of |
| 1023 |
|
| 1024 |
These options may be used in any combination to specify the radix of |
| 1025 |
numeric matches. @samp{-d} allows matching on decimal numbers, |
| 1026 |
@samp{-o} on octal numbers, and @samp{-x} on hexadecimal numbers. Any |
| 1027 |
combination of these options may be used. The default is to match all |
| 1028 |
three radixes. |
| 1029 |
|
| 1030 |
@item -F @var{range} |
| 1031 |
@itemx --frequency=@var{range} |
| 1032 |
@opindex -F |
| 1033 |
@opindex --frequency |
| 1034 |
@cindex single matches, showing |
| 1035 |
|
| 1036 |
Match tokens whose occurrence count falls in @var{range}. @var{Range} |
| 1037 |
may be expressed as a single number @var{n}, or as a range |
| 1038 |
@var{n@code{..}m}. Either limit of the range may be omitted (e.g., |
| 1039 |
@var{@code{..}m}, or @var{n..@code{..}}). If the lower limit @var{n} is |
| 1040 |
omitted, it defaults to @code{1}. If the upper limit is omitted, it |
| 1041 |
defaults in the present implementation to @code{65535}, the maximum |
| 1042 |
value of an unsigned 16-bit integer. |
| 1043 |
|
| 1044 |
Particularly useful queries are @samp{lid -F1}, which helps locate |
| 1045 |
identifiers that are defined but never used, or are used but never |
| 1046 |
defined. Similarly, @code{lid -F2} can help find functions that possess |
| 1047 |
a prototype declaration and a definition, but are never called. |
| 1048 |
|
| 1049 |
@item -a @var{number} |
| 1050 |
@itemx --ambiguous=@var{number} |
| 1051 |
@opindex -a |
| 1052 |
@opindex --ambiguous |
| 1053 |
@cindex ambiguous identifier names, finding |
| 1054 |
|
| 1055 |
List identifiers (not numbers) that are ambiguous for the first |
| 1056 |
@var{number} characters. This feature might be in useful when porting |
| 1057 |
programs to ancient pea-brained compilers that don't support long |
| 1058 |
identifier names. However, the best long-term option is to set such |
| 1059 |
systems on fire. |
| 1060 |
|
| 1061 |
@end table |
| 1062 |
|
| 1063 |
@menu |
| 1064 |
* lid aliases:: Aliases for specialized lid queries |
| 1065 |
* Emacs gid interface:: GNU Emacs query interface |
| 1066 |
* eid invocation:: Invoking an editor on query results |
| 1067 |
@end menu |
| 1068 |
|
| 1069 |
@c ************* gkm ********************************************************* |
| 1070 |
@node lid aliases |
| 1071 |
@section Aliases for Specialized @file{lid} Queries |
| 1072 |
|
| 1073 |
Historically, the ID utilities have provided several query interfaces |
| 1074 |
which are specializations of @code{lid} (@pxref{lid invocation}). |
| 1075 |
|
| 1076 |
@table @file |
| 1077 |
|
| 1078 |
@item gid |
| 1079 |
(alias for @samp{lid -R grep}) |
| 1080 |
lists all lines containing the requested pattern. |
| 1081 |
|
| 1082 |
@item eid |
| 1083 |
(alias for @samp{lid -R edit}) |
| 1084 |
invokes an editor on all files containing the requested pattern, and |
| 1085 |
optionally initiates a text search for that pattern. |
| 1086 |
|
| 1087 |
@item aid |
| 1088 |
(alias for @samp{lid -ils}) treats the requested pattern |
| 1089 |
as a case-insensitive literal substring. |
| 1090 |
|
| 1091 |
@end table |
| 1092 |
|
| 1093 |
@c *************************************************************************** |
| 1094 |
@node Emacs gid interface |
| 1095 |
@section GNU Emacs query interface |
| 1096 |
|
| 1097 |
@cindex Emacs interface to @code{gid} |
| 1098 |
@flindex idutils.el @r{interface to Emacs} |
| 1099 |
|
| 1100 |
@vindex load-path |
| 1101 |
The @code{idutils} source distribution comes with a file @file{idutils.el}, |
| 1102 |
which defines a GNU Emacs interface to @code{gid}. To install it, put |
| 1103 |
@file{idutils.el} somewhere that Emacs will find it (i.e., in your |
| 1104 |
@code{load-path}) and put |
| 1105 |
|
| 1106 |
@example |
| •1107 |
(autoload 'gid "id-utils" "Id Utilities; get id" t) |
| 1108 |
@end example |
| 1109 |
|
| 1110 |
@noindent in one of Emacs' initialization files, e.g., @file{~/.emacs}. |
| 1111 |
You will then be able to use @kbd{M-x gid} to run the command. |
| 1112 |
|
| 1113 |
@findex gid @r{Emacs function} |
| 1114 |
The @code{gid} function prompts you with the word around point. If you |
| 1115 |
want to search for something else, simply delete the line and type the |
| 1116 |
pattern of interest. |
| 1117 |
|
| 1118 |
@flindex *compilation* @r{Emacs buffer} |
| 1119 |
The function then runs the @code{gid} program in a @samp{*compilation*} |
| 1120 |
buffer, so the normal @code{next-error} function can be used to visit |
| 1121 |
all the places the identifier is found (@pxref{Compilation,,, emacs, The |
| 1122 |
GNU Emacs Manual}). |
| 1123 |
|
| 1124 |
@c ************* gkm ********************************************************* |
| 1125 |
@node eid invocation |
| 1126 |
@section @code{eid}: Invoking an Editor on Query Results |
| 1127 |
|
| 1128 |
@pindex eid |
| 1129 |
|
| 1130 |
@samp{lid -R edit} is an editing interface for the ID utilities that is |
| 1131 |
most commonly used with @file{vi}. Emacs users should use the interface |
| 1132 |
defined in @code{idutils.el} (@pxref{Emacs gid interface}). The ID |
| 1133 |
utilities include an alias called @file{eid}, and for the sake of |
| 1134 |
brevity, we'll use this alias for the remainder of this section. |
| 1135 |
@file{eid} performs a @file{lid}-style, then asks if you wish to edit |
| 1136 |
the files. If your query yields more than one line of output, you will |
| 1137 |
be prompted after each line. This is the prompt you'll see: |
| 1138 |
|
| 1139 |
@example |
| 1140 |
Edit? [y1-9^S/nq] |
| 1141 |
@end example |
| 1142 |
|
| 1143 |
@noindent |
| 1144 |
You may respond with: |
| 1145 |
|
| 1146 |
@table @samp |
| 1147 |
|
| 1148 |
@item y |
| 1149 |
Edit all files listed. |
| 1150 |
|
| 1151 |
@item 1@dots{}9 |
| 1152 |
Edit all files starting at the @math{@var{n} + 1}'st file. |
| 1153 |
|
| 1154 |
@item /@var{string} @r{or} @kbd{CTRL-S}@var{regexp} |
| 1155 |
Search into the file list, and begin editing with the first file name |
| 1156 |
that matches the regular expression @var{regexp}. |
| 1157 |
|
| 1158 |
@item n |
| 1159 |
Don't edit any files. If another line of query output is pending, |
| 1160 |
advance to that line, for which another @samp{Edit?} prompt will appear. |
| 1161 |
|
| 1162 |
@item q |
| 1163 |
Quit---don't edit any files, and don't process any more lines of query |
| 1164 |
output. |
| 1165 |
|
| 1166 |
@end table |
| 1167 |
|
| 1168 |
Here is an example: |
| 1169 |
|
| 1170 |
@example |
| 1171 |
prompt$ eid FILE \^print |
| 1172 |
FILE @{ansi2knr,fid,filenames,idfile,idx,lid,misc,@dots{}@}.c |
| 1173 |
Edit? [y1-9^S/nq] n |
| 1174 |
^print @{ansi2knr,fid,getopt,getopt1,lid,mkid,regex,scanners@}.c |
| 1175 |
Edit? [y1-9^S/nq] 2 |
| 1176 |
@end example |
| 1177 |
|
| 1178 |
@noindent This will start editing at @file{getopt}.c. |
| 1179 |
|
| 1180 |
@code{eid} invokes the editor defined by the environment variable |
| 1181 |
@samp{VISUAL}. If @samp{VISUAL} is undefined, it uses the environment |
| 1182 |
variable @samp{EDITOR} instead. If @samp{EDITOR} is undefined, it |
| 1183 |
defaults to @file{vi}. It is possible for @file{eid} to pass the editor |
| 1184 |
an initial search pattern so that your cursor will immediately alight on |
| 1185 |
the token of interest. This feature is controlled by the following |
| 1186 |
environment variables: |
| 1187 |
|
| 1188 |
@table @samp |
| 1189 |
|
| 1190 |
@item EIDARG |
| 1191 |
@vindex EIDARG |
| 1192 |
@cindex search for token, initial |
| 1193 |
A printf(3) format string for the editor argument to search for the |
| 1194 |
matching token. For @code{vi}, this should be @samp{+/%s/}. |
| 1195 |
|
| 1196 |
@item EIDLDEL |
| 1197 |
@vindex EIDLDEL |
| 1198 |
@cindex left delimiter editor argument |
| 1199 |
@cindex beginning-of-word editor argument |
| 1200 |
The regular-expression meta-character(s) for delimiting the beginning of |
| 1201 |
a word (the `@file{eid} Left DELimiter'). @code{eid} inserts this in |
| 1202 |
front of the matching token when a word-search is desired. For |
| 1203 |
@file{vi}, this should be @samp{\<}. |
| 1204 |
|
| 1205 |
@item EIDRDEL |
| 1206 |
@vindex EIDRDEL |
| 1207 |
@cindex right delimiter editor argument |
| 1208 |
@cindex end-of-word editor argument |
| 1209 |
The regular-expression meta-character(s) for delimiting the end of |
| 1210 |
a word (the `@file{eid} Right DELimiter'). @code{eid} inserts this in |
| 1211 |
end of the matching token when a word-search is desired. For |
| 1212 |
@file{vi}, this should be @samp{\>}. |
| 1213 |
|
| 1214 |
@end table |
| 1215 |
|
| 1216 |
@c ************* gkm ********************************************************* |
| 1217 |
@node fid invocation |
| 1218 |
@chapter @code{fid}: Listing a file's tokens |
| 1219 |
|
| 1220 |
@pindex fid |
| 1221 |
@cindex tokens in a file |
| 1222 |
@cindex tokens common to two files |
| 1223 |
|
| 1224 |
@file{fid} prints the tokens found in a given file. If two file names |
| 1225 |
are passed on the command line, @file{fid} prints the tokens that are |
| 1226 |
common to both files (i.e., the @emph{set intersection} of the two token |
| 1227 |
sets). |
| 1228 |
|
| 1229 |
@file{fid} reads the ID database, therefore it accepts the @samp{--file} |
| 1230 |
option, and consults the @samp{IDPATH} environment variable, as |
| 1231 |
described in @ref{Reading options}. |
| 1232 |
|
| 1233 |
If the standard output is attached to a terminal, the printed tokens are |
| 1234 |
separated by spaces. Otherwise, the tokens are printed one per line. |
| 1235 |
|
| 1236 |
@c ************* gkm ********************************************************* |
| 1237 |
@node fnid invocation |
| 1238 |
@chapter @code{fnid}: Looking up filenames |
| 1239 |
|
| 1240 |
@pindex fnid |
| 1241 |
@cindex filenames, matching |
| 1242 |
@cindex matching filenames |
| 1243 |
|
| 1244 |
@file{fnid} queries the list of file names stored in the ID database. |
| 1245 |
It accepts shell @emph{wildcard} patterns on the command line. If no |
| 1246 |
pattern is supplied, @file{*} is implied. @file{fnid} prints the |
| 1247 |
file names that match the given patterns. |
| 1248 |
|
| 1249 |
@file{fnid} prints file names, and as such accepts the |
| 1250 |
@samp{--separator} option as described in @ref{File listing options}. |
| 1251 |
|
| 1252 |
For example, the command: |
| 1253 |
|
| 1254 |
@example |
| 1255 |
fnid \*.c |
| 1256 |
@end example |
| 1257 |
|
| 1258 |
@noindent lists all the @file{.c} files in the database. (The @samp{\} |
| 1259 |
here protects the @samp{*} from being expanded by the shell.) |
| 1260 |
|
| 1261 |
@c ************* gkm ********************************************************* |
| 1262 |
@node gid invocation |
| 1263 |
@chapter @code{gid}: Token-based grep |
| 1264 |
|
| 1265 |
@pindex gid |
| 1266 |
@cindex searching files, grep |
| 1267 |
|
| 1268 |
@file{gid} lists each line containing one of the specified tokens. |
| 1269 |
|
| 1270 |
Running @command{gid} is equivalent to @samp{lid -R grep}) |
| 1271 |
|
| 1272 |
For example, the command: |
| 1273 |
|
| 1274 |
@example |
| 1275 |
gid important_variable |
| 1276 |
@end example |
| 1277 |
|
| 1278 |
@noindent lists each line of each file in the database that contains that token. |
| 1279 |
|
| 1280 |
@c ************* gkm ********************************************************* |
| 1281 |
@node xtokid invocation |
| 1282 |
@chapter @file{xtokid}: Testing Language Scanners |
| 1283 |
|
| 1284 |
@file{xtokid} accepts the names of files and/or directories on the |
| 1285 |
command line, then extracts and prints a stream of tokens from those |
| 1286 |
files for which it has a valid, enabled scanner. This is useful |
| 1287 |
primarily for debugging new @file{mkid} scanners (@pxref{Defining |
| 1288 |
scanners}). |
| 1289 |
|
| 1290 |
@file{xtokid} extracts tokens from source files, therefore it accepts |
| 1291 |
the @samp{--lang-map}, @samp{--include}, @samp{--exclude}, and |
| 1292 |
@samp{--lang-option} options, as well as the language-specific scanner |
| 1293 |
options, all of which are described in @ref{Extraction options}. |
| 1294 |
@file{xtokid} walks file trees, therefore it handles file and directory |
| 1295 |
names on its command line and the @samp{--prune} option as described in |
| 1296 |
@ref{Walker options}. |
| 1297 |
|
| 1298 |
The name @samp{xtokid} indicates that it is the ``eXtract TOKens ID |
| 1299 |
utility''. |
| 1300 |
|
| 1301 |
@c ************* gkm ********************************************************* |
| 1302 |
@node Past and Future |
| 1303 |
@chapter Past and Future |
| 1304 |
|
| 1305 |
@cindex history |
| 1306 |
|
| 1307 |
@pindex look @r{and @file{mkid} 1} |
| 1308 |
@cindex McGary, Greg |
| 1309 |
Greg McGary conceived of the ideas behind the ID utilities when he |
| 1310 |
began working on the Unix kernel in 1984. He needed a navigation tool |
| 1311 |
to help him find his way around the expansive, unfamiliar landscape. |
| 1312 |
The first @code{idutils}-like tools were shell scripts, and produced an |
| 1313 |
ASCII database that looks much like the output of @samp{lid ".*"}. It |
| 1314 |
took over an hour on a @sc{vax 11/750} to build a database for a |
| 1315 |
@sc{4.1bsd} derived kernel. The first version of @file{lid} used the |
| 1316 |
@sc{unix} system utility @code{look}, modified to handle very long |
| 1317 |
lines. |
| 1318 |
|
| 1319 |
In 1986, Greg rewrote the shell scripts in C to improve performance. |
| 1320 |
Build times for the ID file were shortened by an order of magnitude. |
| 1321 |
The ID utilities were first posted to @samp{comp.sources.unix} in |
| 1322 |
September 1987 under the name @code{id}. |
| 1323 |
|
| 1324 |
@cindex Horsley, Tom |
| 1325 |
@cindex Scofield, Doug |
| 1326 |
@cindex Leonard, Bill |
| 1327 |
@cindex Berry, Karl |
| 1328 |
Over the next few years, several versions diverged from the original |
| 1329 |
source. Tom Horsley at Harris Computer Systems Division stepped forward |
| 1330 |
to take over maintenance and integrated some of the fixes from divergent |
| 1331 |
versions. A first release of the renamed @file{mkid} @w{version 2} was |
| 1332 |
posted to @file{alt.sources} near the end of 1990. At that time, Tom |
| 1333 |
wrote a Texinfo manual with the encouragement of the net community. |
| 1334 |
(Tom especially thanks Doug Scofield and Bill Leonard whom he dragooned |
| 1335 |
into helping proofread and edit---they found several problems in the |
| 1336 |
initial version.) Karl Berry revamped the manual for Texinfo style, |
| 1337 |
indexing, and organization in 1995. |
| 1338 |
|
| 1339 |
In January 1995, Greg McGary reemerged as the primary maintainer and |
| 1340 |
launched development of @file{mkid} version 3, whose primary new feature |
| 1341 |
is an efficient algorithm for building databases that is linear in both |
| 1342 |
time and space over the size of the input text. (The old algorithm was |
| 1343 |
quadratic in space so it was incapable of handling very large source |
| 1344 |
trees.) For the first time, the code was released under the GNU Public |
| 1345 |
License. |
| 1346 |
|
| 1347 |
In June 1996, the package was renamed again to @code{id-utils} and was |
| 1348 |
released for the first time under FSF copyright as part of the GNU |
| 1349 |
system. All programs had their command-line arguments completely |
| 1350 |
revised. The @file{mkid} and @file{xtokid} programs also gained a |
| 1351 |
file-tree walker, so that directory names can be passed on the command |
| 1352 |
line instead of the names of every individual file. Greg reorganized |
| 1353 |
and rewrote most of the Texinfo manual to reflect these changes. |
| 1354 |
|
| 1355 |
In 2006, Claudio Fontana modernized the build system and the code itself, |
| 1356 |
and analyzed and integrated various pending patches. Package name had a |
| 1357 |
minor change from @code{id-utils} to @code{idutils}, to be more consistent |
| 1358 |
with the other GNU package names. |
| 1359 |
|
| 1360 |
@pindex cscope |
| 1361 |
@pindex grep |
| 1362 |
@cindex future |
| 1363 |
Future releases of @code{idutils} might include: |
| 1364 |
|
| 1365 |
@itemize @bullet |
| 1366 |
|
| 1367 |
@item |
| 1368 |
an optional coupling with GNU @code{grep}, so that @code{grep} can use |
| 1369 |
an ID database for hints |
| 1370 |
|
| 1371 |
@item |
| 1372 |
a @code{cscope} work-alike query interface |
| 1373 |
|
| 1374 |
@item |
| 1375 |
incremental update of the ID database. |
| 1376 |
|
| 1377 |
@end itemize |
| 1378 |
|
| 1379 |
@c *************************************************************************** |
| 1380 |
@node Index |
| 1381 |
@unnumbered Index |
| 1382 |
|
| 1383 |
@printindex cp |
| 1384 |
|
| 1385 |
@contents |
| 1386 |
@bye |