Initial import from FreeBSD RELENG_4:
[dragonfly.git] / gnu / usr.bin / ptx / doc / ptx.texinfo
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename ptx.info
4 @settitle GNU @code{ptx} reference manual
5 @finalout
6 @c %**end of header
7
8 @ifinfo
9 This file documents the @code{ptx} command, which has the purpose of
10 generated permuted indices for group of files.
11
12 Copyright (C) 1990, 1991, 1993 by the Free Software Foundation, Inc.
13
14 Permission is granted to make and distribute verbatim copies of
15 this manual provided the copyright notice and this permission notice
16 are preserved on all copies.
17
18 @ignore
19 Permission is granted to process this file through TeX and print the
20 results, provided the printed document carries copying permission
21 notice identical to this one except for the removal of this paragraph
22 (this paragraph not being relevant to the printed manual).
23
24 @end ignore
25 Permission is granted to copy and distribute modified versions of this
26 manual under the conditions for verbatim copying, provided that the entire
27 resulting derived work is distributed under the terms of a permission
28 notice identical to this one.
29
30 Permission is granted to copy and distribute translations of this manual
31 into another language, under the above conditions for modified versions,
32 except that this permission notice may be stated in a translation approved
33 by the Foundation.
34 @end ifinfo
35
36 @titlepage
37 @title ptx
38 @subtitle The GNU permuted indexer
39 @subtitle Edition 0.3, for ptx version 0.3
40 @subtitle November 1993
41 @author by Francois Pinard
42
43 @page
44 @vskip 0pt plus 1filll
45 Copyright @copyright{} 1990, 1991, 1993 Free Software Foundation, Inc.
46
47 Permission is granted to make and distribute verbatim copies of
48 this manual provided the copyright notice and this permission notice
49 are preserved on all copies.
50
51 Permission is granted to copy and distribute modified versions of this
52 manual under the conditions for verbatim copying, provided that the entire
53 resulting derived work is distributed under the terms of a permission
54 notice identical to this one.
55
56 Permission is granted to copy and distribute translations of this manual
57 into another language, under the above conditions for modified versions,
58 except that this permission notice may be stated in a translation approved
59 by the Foundation.
60 @end titlepage
61
62 @node Top, Invoking ptx, (dir), (dir)
63 @chapter Introduction
64
65 This is the 0.3 beta release of @code{ptx}, the GNU version of a
66 permuted index generator.  This software has the main goal of providing
67 a replacement for the traditional @code{ptx} as found on System V
68 machines, able to handle small files quickly, while providing a platform
69 for more development.
70
71 This version reimplements and extends traditional @code{ptx}.  Among
72 other things, it can produce a readable @dfn{KWIC} (keywords in their
73 context) without the need of @code{nroff}, there is also an option to
74 produce @TeX{} compatible output.  This version does not handle huge
75 input files, that is, those files which do not fit in memory all at
76 once.
77
78 @emph{Please note} that an overall renaming of all options is
79 foreseeable.  In fact, GNU ptx specifications are not frozen yet.
80
81 @menu
82 * Invoking ptx::                How to use this program
83 * Compatibility::               The GNU extensions to @code{ptx}
84
85  --- The Detailed Node Listing ---
86
87 How to use this program
88
89 * General options::             Options which affect general program behaviour.
90 * Charset selection::           Underlying character set considerations.
91 * Input processing::            Input fields, contexts, and keyword selection.
92 * Output formatting::           Types of output format, and sizing the fields.
93 @end menu
94
95 @node Invoking ptx, Compatibility, Top, Top
96 @chapter How to use this program
97
98 This tool reads a text file and essentially produces a permuted index, with
99 each keyword in its context.  The calling sketch is one of:
100
101 @example
102 ptx [@var{option} @dots{}] [@var{file} @dots{}]
103 @end example
104
105 or:
106
107 @example
108 ptx -G [@var{option} @dots{}] [@var{input} [@var{output}]]
109 @end example
110
111 The @samp{-G} (or its equivalent: @samp{--traditional}) option disables
112 all GNU extensions and revert to traditional mode, thus introducing some
113 limitations, and changes several of the program's default option values.
114 When @samp{-G} is not specified, GNU extensions are always enabled.  GNU
115 extensions to @code{ptx} are documented wherever appropriate in this
116 document.  See @xref{Compatibility} for an explicit list of them.
117
118 Individual options are explained later in this document.
119
120 When GNU extensions are enabled, there may be zero, one or several
121 @var{file} after the options.  If there is no @var{file}, the program
122 reads the standard input.  If there is one or several @var{file}, they
123 give the name of input files which are all read in turn, as if all the
124 input files were concatenated.  However, there is a full contextual
125 break between each file and, when automatic referencing is requested,
126 file names and line numbers refer to individual text input files.  In
127 all cases, the program produces the permuted index onto the standard
128 output.
129   
130 When GNU extensions are @emph{not} enabled, that is, when the program
131 operates in traditional mode, there may be zero, one or two parameters
132 besides the options.  If there is no parameters, the program reads the
133 standard input and produces the permuted index onto the standard output.
134 If there is only one parameter, it names the text @var{input} to be read
135 instead of the standard input.  If two parameters are given, they give
136 respectively the name of the @var{input} file to read and the name of
137 the @var{output} file to produce.  @emph{Be very careful} to note that,
138 in this case, the contents of file given by the second parameter is
139 destroyed.  This behaviour is dictated only by System V @code{ptx}
140 compatibility, because GNU Standards discourage output parameters not
141 introduced by an option.
142
143 Note that for @emph{any} file named as the value of an option or as an
144 input text file, a single dash @kbd{-} may be used, in which case
145 standard input is assumed.  However, it would not make sense to use this
146 convention more than once per program invocation.
147
148 @menu
149 * General options::             Options which affect general program behaviour.
150 * Charset selection::           Underlying character set considerations.
151 * Input processing::            Input fields, contexts, and keyword selection.
152 * Output formatting::           Types of output format, and sizing the fields.
153 @end menu
154
155 @node General options, Charset selection, Invoking ptx, Invoking ptx
156 @section General options
157
158 @table @code
159
160 @item -C
161 @itemx --copyright
162 Prints a short note about the Copyright and copying conditions, then
163 exit without further processing.
164
165 @item -G
166 @itemx --traditional
167 As already explained, this option disables all GNU extensions to
168 @code{ptx} and switch to traditional mode.
169
170 @item --help
171 Prints a short help on standard output, then exit without further
172 processing.
173
174 @item --version
175 Prints the program verison on standard output, then exit without further
176 processing.
177
178 @end table
179
180 @node Charset selection, Input processing, General options, Invoking ptx
181 @section Charset selection
182
183 As it is setup now, the program assumes that the input file is coded
184 using 8-bit ISO 8859-1 code, also known as Latin-1 character set,
185 @emph{unless} if it is compiled for MS-DOS, in which case it uses the
186 character set of the IBM-PC.  (GNU @code{ptx} is not known to work on
187 smaller MS-DOS machines anymore.)  Compared to 7-bit ASCII, the set of
188 characters which are letters is then different, this fact alters the
189 behaviour of regular expression matching.  Thus, the default regular
190 expression for a keyword allows foreign or diacriticized letters.
191 Keyword sorting, however, is still crude; it obeys the underlying
192 character set ordering quite blindly.
193
194 @table @code
195
196 @item -f
197 @itemx --ignore-case
198 Fold lower case letters to upper case for sorting.
199
200 @end table
201
202 @node Input processing, Output formatting, Charset selection, Invoking ptx
203 @section Word selection
204
205 @table @code
206
207 @item -b @var{file}
208 @item --break-file=@var{file}
209
210 This option is an alternative way to option @code{-W} for describing
211 which characters make up words.  This option introduces the name of a
212 file which contains a list of characters which can@emph{not} be part of
213 one word, this file is called the @dfn{Break file}.  Any character which
214 is not part of the Break file is a word constituent.  If both options
215 @code{-b} and @code{-W} are specified, then @code{-W} has precedence and
216 @code{-b} is ignored.
217
218 When GNU extensions are enabled, the only way to avoid newline as a
219 break character is to write all the break characters in the file with no
220 newline at all, not even at the end of the file.  When GNU extensions
221 are disabled, spaces, tabs and newlines are always considered as break
222 characters even if not included in the Break file.
223
224 @item -i @var{file}
225 @itemx --ignore-file=@var{file}
226
227 The file associated with this option contains a list of words which will
228 never be taken as keywords in concordance output.  It is called the
229 @dfn{Ignore file}.  The file contains exactly one word in each line; the
230 end of line separation of words is not subject to the value of the
231 @code{-S} option.
232
233 There is a default Ignore file used by @code{ptx} when this option is
234 not specified, usually found in @file{/usr/local/lib/eign} if this has
235 not been changed at installation time.  If you want to deactivate the
236 default Ignore file, specify @code{/dev/null} instead.
237
238 @item -o @var{file}
239 @itemx --only-file=@var{file}
240
241 The file associated with this option contains a list of words which will
242 be retained in concordance output, any word not mentioned in this file
243 is ignored.  The file is called the @dfn{Only file}.  The file contains
244 exactly one word in each line; the end of line separation of words is
245 not subject to the value of the @code{-S} option.
246
247 There is no default for the Only file.  In the case there are both an
248 Only file and an Ignore file, a word will be subject to be a keyword
249 only if it is given in the Only file and not given in the Ignore file.
250
251 @item -r
252 @itemx --references
253
254 On each input line, the leading sequence of non white characters will be
255 taken to be a reference that has the purpose of identifying this input
256 line on the produced permuted index.  See @xref{Output formatting} for
257 more information about reference production.  Using this option change
258 the default value for option @code{-S}.
259
260 Using this option, the program does not try very hard to remove
261 references from contexts in output, but it succeeds in doing so
262 @emph{when} the context ends exactly at the newline.  If option
263 @code{-r} is used with @code{-S} default value, or when GNU extensions
264 are disabled, this condition is always met and references are completely
265 excluded from the output contexts.
266
267 @item -S @var{regexp}
268 @itemx --sentence-regexp=@var{regexp}
269
270 This option selects which regular expression will describe the end of a
271 line or the end of a sentence.  In fact, there is other distinction
272 between end of lines or end of sentences than the effect of this regular
273 expression, and input line boundaries have no special significance
274 outside this option.  By default, when GNU extensions are enabled and if
275 @code{-r} option is not used, end of sentences are used.  In this
276 case, the precise @var{regex} is imported from GNU emacs:
277
278 @example
279 [.?!][]\"')@}]*\\($\\|\t\\|  \\)[ \t\n]*
280 @end example
281
282 Whenever GNU extensions are disabled or if @code{-r} option is used, end
283 of lines are used; in this case, the default @var{regexp} is just:
284
285 @example
286 \n
287 @end example
288
289 Using an empty REGEXP is equivalent to completely disabling end of line or end
290 of sentence recognition.  In this case, the whole file is considered to
291 be a single big line or sentence.  The user might want to disallow all
292 truncation flag generation as well, through option @code{-F ""}.
293 @xref{Regexps, , Syntax of Regular Expressions, emacs, The GNU Emacs
294 Manual}.
295
296 When the keywords happen to be near the beginning of the input line or
297 sentence, this often creates an unused area at the beginning of the
298 output context line; when the keywords happen to be near the end of the
299 input line or sentence, this often creates an unused area at the end of
300 the output context line.  The program tries to fill those unused areas
301 by wrapping around context in them; the tail of the input line or
302 sentence is used to fill the unused area on the left of the output line;
303 the head of the input line or sentence is used to fill the unused area
304 on the right of the output line.
305
306 As a matter of convenience to the user, many usual backslashed escape
307 sequences, as found in the C language, are recognized and converted to
308 the corresponding characters by @code{ptx} itself.
309
310 @item -W @var{regexp}
311 @itemx --word-regexp=@var{regexp}
312
313 This option selects which regular expression will describe each keyword.
314 By default, if GNU extensions are enabled, a word is a sequence of
315 letters; the @var{regexp} used is @code{\w+}.  When GNU extensions are
316 disabled, a word is by default anything which ends with a space, a tab
317 or a newline; the @var{regexp} used is @code{[^ \t\n]+}.
318
319 An empty REGEXP is equivalent to not using this option, letting the
320 default dive in.  @xref{Regexps, , Syntax of Regular Expressions, emacs,
321 The GNU Emacs Manual}.
322
323 As a matter of convenience to the user, many usual backslashed escape
324 sequences, as found in the C language, are recognized and converted to
325 the corresponding characters by @code{ptx} itself.
326
327 @end table
328
329 @node Output formatting,  , Input processing, Invoking ptx
330 @section Output formatting
331
332 Output format is mainly controlled by @code{-O} and @code{-T} options,
333 described in the table below.  When neither @code{-O} nor @code{-T} is
334 selected, and if GNU extensions are enabled, the program choose an
335 output format suited for a dumb terminal.  Each keyword occurrence is
336 output to the center of one line, surrounded by its left and right
337 contexts.  Each field is properly justified, so the concordance output
338 could readily be observed.  As a special feature, if automatic
339 references are selected by option @code{-A} and are output before the
340 left context, that is, if option @code{-R} is @emph{not} selected, then
341 a colon is added after the reference; this nicely interfaces with GNU
342 Emacs @code{next-error} processing.  In this default output format, each
343 white space character, like newline and tab, is merely changed to
344 exactly one space, with no special attempt to compress consecutive
345 spaces.  This might change in the future.  Except for those white space
346 characters, every other character of the underlying set of 256
347 characters is transmitted verbatim.
348
349 Output format is further controlled by the following options.
350
351 @table @code
352
353 @item -g @var{number}
354 @itemx --gap-size=@var{number}
355
356 Select the size of the minimum white gap between the fields on the output
357 line.
358
359 @item -w @var{number}
360 @itemx --width=@var{number}
361
362 Select the output maximum width of each final line.  If references are
363 used, they are included or excluded from the output maximum width
364 depending on the value of option @code{-R}.  If this option is not
365 selected, that is, when references are output before the left context,
366 the output maximum width takes into account the maximum length of all
367 references.  If this options is selected, that is, when references are
368 output after the right context, the output maximum width does not take
369 into account the space taken by references, nor the gap that precedes
370 them.
371
372 @item -A
373 @itemx --auto-reference
374
375 Select automatic references.  Each input line will have an automatic
376 reference made up of the file name and the line ordinal, with a single
377 colon between them.  However, the file name will be empty when standard
378 input is being read.  If both @code{-A} and @code{-r} are selected, then
379 the input reference is still read and skipped, but the automatic
380 reference is used at output time, overriding the input reference.
381
382 @item -R
383 @itemx --right-side-refs
384
385 In default output format, when option @code{-R} is not used, any
386 reference produced by the effect of options @code{-r} or @code{-A} are
387 given to the far right of output lines, after the right context.  In
388 default output format, when option @code{-R} is specified, references
389 are rather given to the beginning of each output line, before the left
390 context.  For any other output format, option @code{-R} is almost
391 ignored, except for the fact that the width of references is @emph{not}
392 taken into account in total output width given by @code{-w} whenever
393 @code{-R} is selected.
394
395 This option is automatically selected whenever GNU extensions are
396 disabled.
397
398 @item -F @var{string}
399 @itemx --flac-truncation=@var{string}
400
401 This option will request that any truncation in the output be reported
402 using the string @var{string}.  Most output fields theoretically extend
403 towards the beginning or the end of the current line, or current
404 sentence, as selected with option @code{-S}.  But there is a maximum
405 allowed output line width, changeable through option @code{-w}, which is
406 further divided into space for various output fields.  When a field has
407 to be truncated because cannot extend until the beginning or the end of
408 the current line to fit in the, then a truncation occurs.  By default,
409 the string used is a single slash, as in @code{-F /}.
410
411 @var{string} may have more than one character, as in @code{-F ...}.
412 Also, in the particular case @var{string} is empty (@code{-F ""}),
413 truncation flagging is disabled, and no truncation marks are appended in
414 this case.
415
416 As a matter of convenience to the user, many usual backslashed escape
417 sequences, as found in the C language, are recognized and converted to
418 the corresponding characters by @code{ptx} itself.
419
420 @item -M @var{string}
421 @itemx --macro-name=@var{string}
422
423 Select another @var{string} to be used instead of @samp{xx}, while
424 generating output suitable for @code{nroff}, @code{troff} or @TeX{}.
425
426 @item -O
427 @itemx --format=roff
428
429 Choose an output format suitable for @code{nroff} or @code{troff}
430 processing.  Each output line will look like:
431
432 @example
433 .xx "@var{tail}" "@var{before}" "@var{keyword_and_after}" "@var{head}" "@var{ref}"
434 @end example
435
436 so it will be possible to write an @samp{.xx} roff macro to take care of
437 the output typesetting.  This is the default output format when GNU
438 extensions are disabled.  Option @samp{-M} might be used to change
439 @samp{xx} to another macro name.
440
441 In this output format, each non-graphical character, like newline and
442 tab, is merely changed to exactly one space, with no special attempt to
443 compress consecutive spaces.  Each quote character: @kbd{"} is doubled
444 so it will be correctly processed by @code{nroff} or @code{troff}.
445
446 @item -T
447 @itemx --format=tex
448
449 Choose an output format suitable for @TeX{} processing.  Each output
450 line will look like:
451
452 @example
453 \xx @{@var{tail}@}@{@var{before}@}@{@var{keyword}@}@{@var{after}@}@{@var{head}@}@{@var{ref}@}
454 @end example
455
456 @noindent
457 so it will be possible to write write a @code{\xx} definition to take
458 care of the output typesetting.  Note that when references are not being
459 produced, that is, neither option @code{-A} nor option @code{-r} is
460 selected, the last parameter of each @code{\xx} call is inhibited.
461 Option @samp{-M} might be used to change @samp{xx} to another macro
462 name.
463
464 In this output format, some special characters, like @kbd{$}, @kbd{%},
465 @kbd{&}, @kbd{#} and @kbd{_} are automatically protected with a
466 backslash.  Curly brackets @kbd{@{}, @kbd{@}} are also protected with a
467 backslash, but also enclosed in a pair of dollar signs to force
468 mathematical mode.  The backslash itself produces the sequence
469 @code{\backslash@{@}}.  Circumflex and tilde diacritics produce the
470 sequence @code{^\@{ @}} and @code{~\@{ @}} respectively.  Other
471 diacriticized characters of the underlying character set produce an
472 appropriate @TeX{} sequence as far as possible.  The other non-graphical
473 characters, like newline and tab, and all others characters which are
474 not part of ASCII, are merely changed to exactly one space, with no
475 special attempt to compress consecutive spaces.  Let me know how to
476 improve this special character processing for @TeX{}.
477
478 @end table
479
480 @node Compatibility,  , Invoking ptx, Top
481 @chapter The GNU extensions to @code{ptx}
482
483 This version of @code{ptx} contains a few features which do not exist in
484 System V @code{ptx}.  These extra features are suppressed by using the
485 @samp{-G} command line option, unless overridden by other command line
486 options.  Some GNU extensions cannot be recovered by overriding, so the
487 simple rule is to avoid @samp{-G} if you care about GNU extensions.
488 Here are the differences between this program and System V @code{ptx}.
489
490 @itemize @bullet
491
492 @item
493 This program can read many input files at once, it always writes the
494 resulting concordance on standard output.  On the other end, System V
495 @code{ptx} reads only one file and produce the result on standard output
496 or, if a second @var{file} parameter is given on the command, to that
497 @var{file}.
498
499 Having output parameters not introduced by options is a quite dangerous
500 practice which GNU avoids as far as possible.  So, for using @code{ptx}
501 portably between GNU and System V, you should pay attention to always
502 use it with a single input file, and always expect the result on
503 standard output.  You might also want to automatically configure in a
504 @samp{-G} option to @code{ptx} calls in products using @code{ptx}, if
505 the configurator finds that the installed @code{ptx} accepts @samp{-G}.
506
507 @item
508 The only options available in System V @code{ptx} are options @samp{-b},
509 @samp{-f}, @samp{-g}, @samp{-i}, @samp{-o}, @samp{-r}, @samp{-t} and
510 @samp{-w}.  All other options are GNU extensions and are not repeated in
511 this enumeration.  Moreover, some options have a slightly different
512 meaning when GNU extensions are enabled, as explained below.
513
514 @item
515 By default, concordance output is not formatted for @code{troff} or
516 @code{nroff}.  It is rather formatted for a dumb terminal.  @code{troff}
517 or @code{nroff} output may still be selected through option @code{-O}.
518
519 @item
520 Unless @code{-R} option is used, the maximum reference width is
521 subtracted from the total output line width.  With GNU extensions
522 disabled, width of references is not taken into account in the output
523 line width computations.
524
525 @item
526 All 256 characters, even @kbd{NUL}s, are always read and processed from
527 input file with no adverse effect, even if GNU extensions are disabled.
528 However, System V @code{ptx} does not accept 8-bit characters, a few
529 control characters are rejected, and the tilda @kbd{~} is condemned.
530
531 @item
532 Input line length is only limited by available memory, even if GNU
533 extensions are disabled.  However, System V @code{ptx} processes only
534 the first 200 characters in each line.
535
536 @item
537 The break (non-word) characters default to be every character except all
538 letters of the underlying character set, diacriticized or not.  When GNU
539 extensions are disabled, the break characters default to space, tab and
540 newline only.
541
542 @item
543 The program makes better use of output line width.  If GNU extensions
544 are disabled, the program rather tries to imitate System V @code{ptx},
545 but still, there are some slight disposition glitches this program does
546 not completely reproduce.
547
548 @item
549 The user can specify both an Ignore file and an Only file.  This is not
550 allowed with System V @code{ptx}.
551
552 @end itemize
553
554 @bye