~ubuntu-branches/ubuntu/oneiric/texinfo/oneiric

« back to all changes in this revision

Viewing changes to info/info.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2009-03-09 15:50:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090309155003-3k9a07mt2jqnuudg
Tags: 4.13a.dfsg.1-1
* new upstream releases (Closes: #500301)
  - fix (wrongly) added leading spaces in direntries (Closes: #457741)
  -  work with ~ in th epath (Closes: #495577)
  - disable the patch fix-direntry and fix-texi2dvi-bashism, 
    included upstream
* update the list of files to be installed (new translations, pdftexi2dvi)
* mange version in the watch file to remove the .dfsg.N part
* use quilt.make (first step in direction of source format 3.0, but that
  is broken)
* add README.Debian to info package (Closes: #513187)
* add README.source, bump standards version to 3.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* info.c -- Display nodes of Info files in multiple windows.
2
 
   $Id: info.c,v 1.20 2007/09/01 00:05:23 karl Exp $
 
2
   $Id: info.c,v 1.33 2008/08/14 17:36:13 karl Exp $
3
3
 
4
4
   Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
5
 
   2004, 2005, 2007 Free Software Foundation, Inc.
 
5
   2004, 2005, 2007, 2008 Free Software Foundation, Inc.
6
6
 
7
7
   This program is free software: you can redistribute it and/or modify
8
8
   it under the terms of the GNU General Public License as published by
17
17
   You should have received a copy of the GNU General Public License
18
18
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
 
   Written by Brian Fox (bfox@ai.mit.edu). */
 
20
   Originally written by Brian Fox (bfox@ai.mit.edu). */
21
21
 
22
22
#include "info.h"
23
23
#include "indices.h"
33
33
static int apropos_p = 0;
34
34
 
35
35
/* Variable containing the string to search for when apropos_p is non-zero. */
36
 
static char *apropos_search_string = (char *)NULL;
 
36
static char *apropos_search_string = NULL;
37
37
 
38
38
/* Non-zero means search all indices for INDEX_SEARCH_STRING.  Unlike
39
39
   apropos, this puts the user at the node, running info. */
46
46
 
47
47
/* Variable containing the string to search for when index_search_p is
48
48
   non-zero. */
49
 
static char *index_search_string = (char *)NULL;
 
49
static char *index_search_string = NULL;
50
50
 
51
51
/* Non-zero means print version info only. */
52
52
static int print_version_p = 0;
56
56
 
57
57
/* Array of the names of nodes that the user specified with "--node" on the
58
58
   command line. */
59
 
static char **user_nodenames = (char **)NULL;
 
59
static char **user_nodenames = NULL;
60
60
static int user_nodenames_index = 0;
61
61
static int user_nodenames_slots = 0;
62
62
 
63
63
/* String specifying the first file to load.  This string can only be set
64
64
   by the user specifying "--file" on the command line. */
65
 
static char *user_filename = (char *)NULL;
 
65
static char *user_filename = NULL;
66
66
 
67
67
/* String specifying the name of the file to dump nodes to.  This value is
68
68
   filled if the user speficies "--output" on the command line. */
69
 
static char *user_output_filename = (char *)NULL;
 
69
static char *user_output_filename = NULL;
70
70
 
71
71
/* Non-zero indicates that when "--output" is specified, all of the menu
72
72
   items of the specified nodes (and their subnodes as well) should be
94
94
/* Structure describing the options that Info accepts.  We pass this structure
95
95
   to getopt_long ().  If you add or otherwise change this structure, you must
96
96
   also change the string which follows it. */
97
 
#define APROPOS_OPTION 1
98
97
#define DRIBBLE_OPTION 2
99
98
#define RESTORE_OPTION 3
100
99
#define IDXSRCH_OPTION 4
101
100
static struct option long_options[] = {
102
 
  { "apropos", 1, 0, APROPOS_OPTION },
 
101
  { "apropos", 1, 0, 'k' },
103
102
  { "directory", 1, 0, 'd' },
104
103
  { "dribble", 1, 0, DRIBBLE_OPTION },
105
104
  { "file", 1, 0, 'f' },
110
109
  { "output", 1, 0, 'o' },
111
110
  { "raw-escapes", 0, &raw_escapes_p, 1 },
112
111
  { "no-raw-escapes", 0, &raw_escapes_p, 0 },
 
112
  { "show-malformed-multibytes", 0, &show_malformed_multibyte_p, 1 },
 
113
  { "no-show-malformed-multibytes", 0, &show_malformed_multibyte_p, 0 },
113
114
  { "restore", 1, 0, RESTORE_OPTION },
114
115
  { "show-options", 0, 0, 'O' },
115
116
  { "subnodes", 0, &dump_subnodes, 1 },
125
126
 
126
127
/* String describing the shorthand versions of the long options found above. */
127
128
#ifdef __MSDOS__
128
 
static char *short_options = "d:n:f:ho:ORswb";
 
129
static char *short_options = "k:d:n:f:ho:ORswb";
129
130
#else
130
 
static char *short_options = "d:n:f:ho:ORws";
 
131
static char *short_options = "k:d:n:f:ho:ORws";
131
132
#endif
132
133
 
133
134
/* When non-zero, the Info window system has been initialized. */
145
146
/* **************************************************************** */
146
147
 
147
148
int
148
 
main (int argc, char **argv)
 
149
main (int argc, char *argv[])
149
150
{
150
151
  int getopt_long_index;        /* Index returned by getopt_long (). */
151
152
  NODE *initial_node;           /* First node loaded by Info. */
153
154
#ifdef HAVE_SETLOCALE
154
155
  /* Set locale via LC_ALL.  */
155
156
  setlocale (LC_ALL, "");
156
 
 
157
 
  /* But don't use translated messages in the case when
158
 
     string width and length can differ */
159
 
  if (MB_CUR_MAX > 1)
160
 
    {
161
 
      setenv("LANGUAGE", "C", 1);
162
 
      setenv("LANG", "C", 1);
163
 
#ifdef LC_MESSAGES
164
 
      setlocale (LC_MESSAGES, "C");
165
 
#endif
166
 
      setenv("LC_CTYPE", "C", 1);
167
 
      setenv("LC_ALL", "C", 1);
168
 
    }
169
157
#endif /* HAVE_SETLOCALE */
170
158
 
171
159
#ifdef ENABLE_NLS
259
247
#endif /* __MSDOS__ */
260
248
 
261
249
          /* User has specified a string to search all indices for. */
262
 
        case APROPOS_OPTION:
 
250
        case 'k':
263
251
          apropos_p = 1;
264
252
          maybe_free (apropos_search_string);
265
253
          apropos_search_string = xstrdup (optarg);
292
280
  /* If the output device is not a terminal, and no output filename has been
293
281
     specified, make user_output_filename be "-", so that the info is written
294
282
     to stdout, and turn on the dumping of subnodes. */
295
 
  if ((!isatty (fileno (stdout))) && (user_output_filename == (char *)NULL))
 
283
  if ((!isatty (fileno (stdout))) && (user_output_filename == NULL))
296
284
    {
297
285
      user_output_filename = xstrdup ("-");
298
286
      dump_subnodes = 1;
307
295
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
308
296
This is free software: you are free to change and redistribute it.\n\
309
297
There is NO WARRANTY, to the extent permitted by law.\n"),
310
 
              "2007");
 
298
              "2008");
311
299
      xexit (0);
312
300
    }
313
301
 
379
367
      if (info_recent_file_error)
380
368
        info_error (info_recent_file_error, NULL, NULL);
381
369
      else
382
 
        info_error ((char *) msg_cant_find_node,
 
370
        info_error (msg_cant_find_node,
383
371
                    user_nodenames ? user_nodenames[0] : "Top", NULL);
384
372
      xexit (1);
385
373
    }
410
398
  {
411
399
    const char *errstr;
412
400
    char *errarg1, *errarg2;
413
 
 
414
 
    NODE *new_initial_node = info_follow_menus (initial_node, argv + optind,
 
401
    NODE *new_initial_node;
 
402
 
 
403
   /* If they say info -O info, we want to show them the invocation node
 
404
      for standalone info; there's nothing useful in info.texi.  */
 
405
   if (goto_invocation_p && argv[optind]
 
406
       && mbscasecmp (argv[optind], "info") == 0)
 
407
     argv[optind] = "info-stnd";
 
408
 
 
409
    new_initial_node = info_follow_menus (initial_node, argv + optind,
415
410
        &errstr, &errarg1, &errarg2);
416
411
 
417
412
    if (new_initial_node && new_initial_node != initial_node)
438
433
          dump_node_to_file (initial_node, user_output_filename,
439
434
                             dump_subnodes);
440
435
        else
441
 
          info_error ((char *) errstr, errarg1, errarg2);
 
436
          info_error (errstr, errarg1, errarg2);
442
437
      }
443
438
    else
444
439
      {
445
440
 
446
441
        if (errstr)
447
 
          begin_info_session_with_error (initial_node, (char *) errstr,
 
442
          begin_info_session_with_error (initial_node, errstr,
448
443
              errarg1, errarg2);
449
444
        /* If the user specified `--index-search=STRING' or
450
445
           --show-options, start the info session in the node
460
455
              {
461
456
                terminal_prep_terminal ();
462
457
                terminal_clear_screen ();
463
 
                info_last_executed_command = (VFunction *)NULL;
 
458
                info_last_executed_command = NULL;
464
459
 
465
460
                if (index_search_p)
466
461
                  do_info_index_search (windows, 0, index_search_string);
561
556
   then the message is printed in the echo area.  Otherwise, a message is
562
557
   output to stderr. */
563
558
void
564
 
info_error (char *format, void *arg1, void *arg2)
 
559
info_error (const char *format, void *arg1, void *arg2)
565
560
{
566
561
  info_error_was_printed = 1;
567
562
 
568
563
  if (!info_windows_initialized_p || display_inhibited)
569
564
    {
570
565
      fprintf (stderr, "%s: ", program_name);
571
 
      fprintf (stderr, format, arg1, arg2);
 
566
      if (arg1)
 
567
        fprintf (stderr, format, arg1, arg2);
 
568
      else
 
569
        /* If we're passed a string, just print it.  Otherwise a % in a
 
570
           filename gets treated as a format specifier.  */
 
571
        fputs (format, stderr);
572
572
      fprintf (stderr, "\n");
573
573
      fflush (stderr);
574
574
    }
582
582
        }
583
583
      else
584
584
        {
585
 
          NODE *temp;
586
 
 
587
 
          temp = build_message_node (format, arg1, arg2);
 
585
          NODE *temp = build_message_node (format, arg1, arg2);
588
586
          if (info_error_rings_bell_p)
589
587
            terminal_ring_bell ();
590
588
          inform_in_echo_area (temp->contents);
599
597
static void
600
598
info_short_help (void)
601
599
{
602
 
#ifdef __MSDOS__
603
 
  static const char speech_friendly_string[] = N_("\
604
 
  -b, --speech-friendly        be friendly to speech synthesizers.\n");
605
 
#else
606
 
  static const char speech_friendly_string[] = "";
607
 
#endif
608
 
 
609
 
 
610
600
  printf (_("\
611
601
Usage: %s [OPTION]... [MENU-ITEM...]\n\
612
602
\n\
613
 
Read documentation in Info format.\n\
614
 
\n\
 
603
Read documentation in Info format.\n"), program_name);
 
604
  puts ("");
 
605
 
 
606
  puts (_("\
615
607
Options:\n\
616
 
      --apropos=STRING         look up STRING in all indices of all manuals.\n\
 
608
  -k, --apropos=STRING         look up STRING in all indices of all manuals.\n\
617
609
  -d, --directory=DIR          add DIR to INFOPATH.\n\
618
610
      --dribble=FILENAME       remember user keystrokes in FILENAME.\n\
619
 
  -f, --file=FILENAME          specify Info file to visit.\n\
 
611
  -f, --file=FILENAME          specify Info file to visit."));
 
612
 
 
613
  puts (_("\
620
614
  -h, --help                   display this help and exit.\n\
621
615
      --index-search=STRING    go to node pointed by index entry STRING.\n\
622
616
  -n, --node=NODENAME          specify nodes in first visited Info file.\n\
623
 
  -o, --output=FILENAME        output selected nodes to FILENAME.\n\
 
617
  -o, --output=FILENAME        output selected nodes to FILENAME."));
 
618
 
 
619
  puts (_("\
624
620
  -R, --raw-escapes            output \"raw\" ANSI escapes (default).\n\
625
621
      --no-raw-escapes         output escapes as literal text.\n\
626
622
      --restore=FILENAME       read initial keystrokes from FILENAME.\n\
627
 
  -O, --show-options, --usage  go to command-line options node.\n%s\
 
623
  -O, --show-options, --usage  go to command-line options node."));
 
624
 
 
625
#ifdef __MSDOS__
 
626
  puts (_("\
 
627
  -b, --speech-friendly        be friendly to speech synthesizers."));
 
628
#endif
 
629
 
 
630
  puts (_("\
628
631
      --subnodes               recursively output menu items.\n\
629
 
  -w, --where, --location      print physical location of Info file.\n\
630
632
      --vi-keys                use vi-like and less-like key bindings.\n\
631
633
      --version                display version information and exit.\n\
632
 
\n\
 
634
  -w, --where, --location      print physical location of Info file."));
 
635
 
 
636
  puts (_("\n\
633
637
The first non-option argument, if present, is the menu entry to start from;\n\
634
638
it is searched for in all `dir' files along INFOPATH.\n\
635
639
If it is not present, info merges all `dir' files and shows the result.\n\
636
640
Any remaining arguments are treated as the names of menu\n\
637
 
items relative to the initial node visited.\n\
638
 
\n\
 
641
items relative to the initial node visited."));
 
642
 
 
643
  puts (_("\n\
 
644
For a summary of key bindings, type h within Info."));
 
645
 
 
646
  puts (_("\n\
639
647
Examples:\n\
640
648
  info                       show top-level dir menu\n\
 
649
  info info                  show the general manual for Info readers\n\
 
650
  info info-stnd             show the manual specific to this Info program\n\
641
651
  info emacs                 start at emacs node from top-level dir\n\
642
652
  info emacs buffers         start at buffers node within emacs manual\n\
643
653
  info --show-options emacs  start at node with emacs' command line options\n\
644
654
  info --subnodes -o out.txt emacs  dump entire manual to out.txt\n\
645
 
  info -f ./foo.info         show file ./foo.info, not searching dir\n\
646
 
"),
647
 
  program_name, speech_friendly_string);
 
655
  info -f ./foo.info         show file ./foo.info, not searching dir"));
648
656
 
649
657
  puts (_("\n\
650
658
Email bug reports to bug-texinfo@gnu.org,\n\