~ubuntu-branches/ubuntu/maverick/texinfo/maverick

« back to all changes in this revision

Viewing changes to info/info.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2005-10-28 15:10:30 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051028151030-ha5ens3pi9e02ksw
Tags: 4.8-2
* Edit the changelog entry for 4.8-1 to include fixes for bugs that
  have been later closed via the email interface.
* Save debian/changelog in utf8 encoding (Closes: #333630)
* replace egrep and fgrep and numerical signals (Closes: #256287)
* include patch to info translations to fix crash on Ctrl-h, and
  regenerate the gmo files on build (Closes: #150710, #199615)
* include documentation into the info package, too (Closes: #261539)
* fix a typo in texinfo.info (Closes: #226898)
* fix a warning of texi2dvi if TEXINPUTS contains a not existent dir
  (Closes: #276006)
* add 50cyrtexinfo.cnf to fmt.d, and write a README.cyrtexinfo how to
  create a cyrillic texinfo format (Closes: #253124)
* Upload sponsored by Frank Küster <frank@debian.org>

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.53 2002/03/02 15:18:58 karl Exp $
 
2
   $Id: info.c,v 1.11 2004/04/11 17:56:45 karl Exp $
3
3
 
4
 
   Copyright (C) 1993, 96, 97, 98, 99, 2000, 01, 02
5
 
   Free Software Foundation, Inc.
 
4
   Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 
5
   2004 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
77
77
/* Non-zero means make default keybindings be loosely modeled on vi(1).  */
78
78
int vi_keys_p = 0;
79
79
 
80
 
/* Non-zero means don't remove ANSI escape sequences from man pages.  */
81
 
int raw_escapes_p = 0;
 
80
/* Non-zero means don't remove ANSI escape sequences.  */
 
81
int raw_escapes_p = 1;
 
82
 
 
83
/* Non-zero means print the absolute location of the file to be loaded.  */
 
84
static int print_where_p = 0;
82
85
 
83
86
#ifdef __MSDOS__
84
87
/* Non-zero indicates that screen output should be made 'speech-friendly'.
99
102
static struct option long_options[] = {
100
103
  { "apropos", 1, 0, APROPOS_OPTION },
101
104
  { "directory", 1, 0, 'd' },
 
105
  { "dribble", 1, 0, DRIBBLE_OPTION },
 
106
  { "file", 1, 0, 'f' },
 
107
  { "help", 0, &print_help_p, 1 },
 
108
  { "index-search", 1, 0, IDXSRCH_OPTION },
 
109
  { "location", 0, &print_where_p, 1 },
102
110
  { "node", 1, 0, 'n' },
103
 
  { "file", 1, 0, 'f' },
104
 
  { "subnodes", 0, &dump_subnodes, 1 },
105
111
  { "output", 1, 0, 'o' },
106
112
  { "raw-escapes", 0, &raw_escapes_p, 1 },
 
113
  { "no-raw-escapes", 0, &raw_escapes_p, 0 },
 
114
  { "restore", 1, 0, RESTORE_OPTION },
107
115
  { "show-options", 0, 0, 'O' },
 
116
  { "subnodes", 0, &dump_subnodes, 1 },
108
117
  { "usage", 0, 0, 'O' },
 
118
  { "version", 0, &print_version_p, 1 },
109
119
  { "vi-keys", 0, &vi_keys_p, 1 },
110
 
  { "help", 0, &print_help_p, 1 },
111
 
  { "version", 0, &print_version_p, 1 },
112
 
  { "dribble", 1, 0, DRIBBLE_OPTION },
113
 
  { "restore", 1, 0, RESTORE_OPTION },
 
120
  { "where", 0, &print_where_p, 1 },
114
121
#ifdef __MSDOS__
115
122
  { "speech-friendly", 0, &speech_friendly, 1 },
116
123
#endif
117
 
  { "index-search", 1, 0, IDXSRCH_OPTION },
118
124
  {NULL, 0, NULL, 0}
119
125
};
120
126
 
121
127
/* String describing the shorthand versions of the long options found above. */
122
128
#ifdef __MSDOS__
123
 
static char *short_options = "d:n:f:o:ORsb";
 
129
static char *short_options = "d:n:f:ho:ORswb";
124
130
#else
125
 
static char *short_options = "d:n:f:o:ORs";
 
131
static char *short_options = "d:n:f:ho:ORws";
126
132
#endif
127
133
 
128
134
/* When non-zero, the Info window system has been initialized. */
129
135
int info_windows_initialized_p = 0;
130
136
 
131
137
/* Some "forward" declarations. */
132
 
static void info_short_help (), remember_info_program_name ();
133
 
static void init_messages ();
134
 
extern void add_file_directory_to_path ();
 
138
static void info_short_help (void);
 
139
static void init_messages (void);
135
140
 
136
141
 
137
142
/* **************************************************************** */
141
146
/* **************************************************************** */
142
147
 
143
148
int
144
 
main (argc, argv)
145
 
     int argc;
146
 
     char **argv;
 
149
main (int argc, char **argv)
147
150
{
148
151
  int getopt_long_index;        /* Index returned by getopt_long (). */
149
152
  NODE *initial_node;           /* First node loaded by Info. */
153
156
  setlocale (LC_ALL, "");
154
157
#endif
155
158
 
 
159
#ifdef ENABLE_NLS
156
160
  /* Set the text message domain.  */
157
161
  bindtextdomain (PACKAGE, LOCALEDIR);
158
162
  textdomain (PACKAGE);
 
163
#endif
159
164
 
160
165
  init_messages ();
161
 
  
 
166
 
162
167
  while (1)
163
168
    {
164
169
      int option_character;
166
171
      option_character = getopt_long
167
172
        (argc, argv, short_options, long_options, &getopt_long_index);
168
173
 
169
 
      /* getopt_long () returns EOF when there are no more long options. */
 
174
      /* getopt_long returns EOF when there are no more long options. */
170
175
      if (option_character == EOF)
171
176
        break;
172
177
 
199
204
          user_filename = xstrdup (optarg);
200
205
          break;
201
206
 
 
207
          /* Treat -h like --help. */
 
208
        case 'h':
 
209
          print_help_p = 1;
 
210
          break;
 
211
 
202
212
          /* User is specifying the name of a file to output to. */
203
213
        case 'o':
204
214
          if (user_output_filename)
224
234
          dump_subnodes = 1;
225
235
          break;
226
236
 
 
237
          /* For compatibility with man, -w is --where.  */
 
238
        case 'w':
 
239
          print_where_p = 1;
 
240
          break;
 
241
 
227
242
#ifdef __MSDOS__
228
243
          /* User wants speech-friendly output.  */
229
244
        case 'b':
276
291
    {
277
292
      printf ("%s (GNU %s) %s\n", program_name, PACKAGE, VERSION);
278
293
      puts ("");
279
 
      printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\
280
 
There is NO warranty.  You may redistribute this software\n\
 
294
      puts ("Copyright (C) 2004 Free Software Foundation, Inc.");
 
295
      printf (_("There is NO warranty.  You may redistribute this software\n\
281
296
under the terms of the GNU General Public License.\n\
282
 
For more information about these matters, see the files named COPYING.\n"),
283
 
                  "2002");
 
297
For more information about these matters, see the files named COPYING.\n"));
284
298
      xexit (0);
285
299
    }
286
300
 
317
331
        {
318
332
          info_add_path (DEFAULT_INFOPATH, INFOPATH_PREPEND);
319
333
#ifdef INFODIR /* from the Makefile */
320
 
         info_add_path (INFODIR, INFOPATH_PREPEND);
 
334
          info_add_path (INFODIR, INFOPATH_PREPEND);
 
335
#endif
 
336
#ifdef INFODIR2 /* from the Makefile, too */
 
337
#  ifdef INFODIR
 
338
          if (!STREQ (INFODIR, INFODIR2))
 
339
#  endif
 
340
            info_add_path (INFODIR2, INFOPATH_PREPEND);
321
341
#endif
322
342
        }
323
343
    }
344
364
  if (!initial_node)
345
365
    {
346
366
      if (info_recent_file_error)
347
 
        info_error (info_recent_file_error);
 
367
        info_error (info_recent_file_error, NULL, NULL);
348
368
      else
349
 
        info_error (msg_cant_find_node,
350
 
                    user_nodenames ? user_nodenames[0] : "Top");
 
369
        info_error ((char *) msg_cant_find_node,
 
370
                    user_nodenames ? user_nodenames[0] : "Top", NULL);
351
371
      xexit (1);
352
372
    }
353
373
 
359
379
    {
360
380
      free (initial_node);
361
381
 
362
 
      if (user_output_filename)
 
382
      if (print_where_p)
 
383
        printf ("%s\n", user_filename ? user_filename : "unknown?!");
 
384
      else if (user_output_filename)
363
385
        dump_nodes_to_file
364
386
          (user_filename, user_nodenames, user_output_filename, dump_subnodes);
365
387
      else
373
395
     file name is either "dir", or the contents of user_filename if one
374
396
     was specified. */
375
397
  {
376
 
    char *errstr, *errarg1, *errarg2;
 
398
    const char *errstr;
 
399
    char *errarg1, *errarg2;
 
400
 
377
401
    NODE *new_initial_node = info_follow_menus (initial_node, argv + optind,
378
 
                                                &errstr, &errarg1, &errarg2);
 
402
        &errstr, &errarg1, &errarg2);
379
403
 
380
404
    if (new_initial_node && new_initial_node != initial_node)
381
405
      initial_node = new_initial_node;
382
406
 
 
407
    if (print_where_p)
 
408
      {
 
409
        if (initial_node->parent)
 
410
          printf ("%s\n", initial_node->parent);
 
411
        else if (initial_node->filename
 
412
            && !is_dir_name (filename_non_directory (initial_node->filename)))
 
413
          printf ("%s\n", initial_node->filename);
 
414
        else
 
415
          xexit (1);
 
416
        xexit (0);
 
417
      }
 
418
 
383
419
    /* If the user specified that this node should be output, then do that
384
420
       now.  Otherwise, start the Info session with this node.  Or act
385
421
       accordingly if the initial node was not found.  */
389
425
          dump_node_to_file (initial_node, user_output_filename,
390
426
                             dump_subnodes);
391
427
        else
392
 
          info_error (errstr, errarg1, errarg2);
 
428
          info_error ((char *) errstr, errarg1, errarg2);
393
429
      }
394
430
    else
395
431
      {
396
432
 
397
433
        if (errstr)
398
 
          begin_info_session_with_error (initial_node, errstr,
399
 
                                         errarg1, errarg2);
 
434
          begin_info_session_with_error (initial_node, (char *) errstr,
 
435
              errarg1, errarg2);
400
436
        /* If the user specified `--index-search=STRING' or
401
437
           --show-options, start the info session in the node
402
438
           corresponding to what they want. */
473
509
 
474
510
    xexit (0);
475
511
  }
 
512
 
 
513
  return 0; /* Avoid bogus warnings.  */
476
514
}
477
515
 
478
516
void
479
 
add_file_directory_to_path (filename)
480
 
     char *filename;
 
517
add_file_directory_to_path (char *filename)
481
518
{
482
519
  char *directory_name = xstrdup (filename);
483
520
  char *temp = filename_non_directory (directory_name);
511
548
   then the message is printed in the echo area.  Otherwise, a message is
512
549
   output to stderr. */
513
550
void
514
 
info_error (format, arg1, arg2)
515
 
     char *format;
516
 
     void *arg1, *arg2;
 
551
info_error (char *format, void *arg1, void *arg2)
517
552
{
518
553
  info_error_was_printed = 1;
519
554
 
549
584
 
550
585
/* Produce a scaled down description of the available options to Info. */
551
586
static void
552
 
info_short_help ()
 
587
info_short_help (void)
553
588
{
554
589
#ifdef __MSDOS__
555
590
  static const char speech_friendly_string[] = N_("\
556
 
 --speech-friendly        be friendly to speech synthesizers.\n");
 
591
  -b, --speech-friendly        be friendly to speech synthesizers.\n");
557
592
#else
558
593
  static const char speech_friendly_string[] = "";
559
594
#endif
560
595
 
561
 
    
 
596
 
562
597
  printf (_("\
563
598
Usage: %s [OPTION]... [MENU-ITEM...]\n\
564
599
\n\
565
600
Read documentation in Info format.\n\
566
601
\n\
567
602
Options:\n\
568
 
 --apropos=SUBJECT        look up SUBJECT in all indices of all manuals.\n\
569
 
 --directory=DIR          add DIR to INFOPATH.\n\
570
 
 --dribble=FILENAME       remember user keystrokes in FILENAME.\n\
571
 
 --file=FILENAME          specify Info file to visit.\n\
572
 
 --help                   display this help and exit.\n\
573
 
 --index-search=STRING    go to node pointed by index entry STRING.\n\
574
 
 --node=NODENAME          specify nodes in first visited Info file.\n\
575
 
 --output=FILENAME        output selected nodes to FILENAME.\n\
576
 
 --raw-escapes            don't remove ANSI escapes from man pages.\n\
577
 
 --restore=FILENAME       read initial keystrokes from FILENAME.\n\
578
 
 --show-options, --usage  go to command-line options node.\n%s\
579
 
 --subnodes               recursively output menu items.\n\
580
 
 --vi-keys                use vi-like and less-like key bindings.\n\
581
 
 --version                display version information and exit.\n\
 
603
      --apropos=STRING         look up STRING in all indices of all manuals.\n\
 
604
  -d, --directory=DIR          add DIR to INFOPATH.\n\
 
605
      --dribble=FILENAME       remember user keystrokes in FILENAME.\n\
 
606
  -f, --file=FILENAME          specify Info file to visit.\n\
 
607
  -h, --help                   display this help and exit.\n\
 
608
      --index-search=STRING    go to node pointed by index entry STRING.\n\
 
609
  -n, --node=NODENAME          specify nodes in first visited Info file.\n\
 
610
  -o, --output=FILENAME        output selected nodes to FILENAME.\n\
 
611
  -R, --raw-escapes            output \"raw\" ANSI escapes (default).\n\
 
612
      --no-raw-escapes         output escapes as literal text.\n\
 
613
      --restore=FILENAME       read initial keystrokes from FILENAME.\n\
 
614
  -O, --show-options, --usage  go to command-line options node.\n%s\
 
615
      --subnodes               recursively output menu items.\n\
 
616
  -w, --where, --location      print physical location of Info file.\n\
 
617
      --vi-keys                use vi-like and less-like key bindings.\n\
 
618
      --version                display version information and exit.\n\
582
619
\n\
583
620
The first non-option argument, if present, is the menu entry to start from;\n\
584
621
it is searched for in all `dir' files along INFOPATH.\n\
592
629
  info emacs buffers         start at buffers node within emacs manual\n\
593
630
  info --show-options emacs  start at node with emacs' command line options\n\
594
631
  info -f ./foo.info         show file ./foo.info, not searching dir\n\
595
 
\n\
 
632
"),
 
633
  program_name, speech_friendly_string);
 
634
 
 
635
  puts (_("\n\
596
636
Email bug reports to bug-texinfo@gnu.org,\n\
597
637
general questions and discussion to help-texinfo@gnu.org.\n\
598
 
"),
599
 
  program_name, speech_friendly_string);
 
638
Texinfo home page: http://www.gnu.org/software/texinfo/"));
600
639
 
601
640
  xexit (0);
602
641
}
607
646
   use them that way.  This also has the advantage that there's only one
608
647
   copy of the strings.  */
609
648
 
610
 
char *msg_cant_find_node;
611
 
char *msg_cant_file_node;
612
 
char *msg_cant_find_window;
613
 
char *msg_cant_find_point;
614
 
char *msg_cant_kill_last;
615
 
char *msg_no_menu_node;
616
 
char *msg_no_foot_node;
617
 
char *msg_no_xref_node;
618
 
char *msg_no_pointer;
619
 
char *msg_unknown_command;
620
 
char *msg_term_too_dumb;
621
 
char *msg_at_node_bottom;
622
 
char *msg_at_node_top;
623
 
char *msg_one_window;
624
 
char *msg_win_too_small;
625
 
char *msg_cant_make_help;
 
649
const char *msg_cant_find_node;
 
650
const char *msg_cant_file_node;
 
651
const char *msg_cant_find_window;
 
652
const char *msg_cant_find_point;
 
653
const char *msg_cant_kill_last;
 
654
const char *msg_no_menu_node;
 
655
const char *msg_no_foot_node;
 
656
const char *msg_no_xref_node;
 
657
const char *msg_no_pointer;
 
658
const char *msg_unknown_command;
 
659
const char *msg_term_too_dumb;
 
660
const char *msg_at_node_bottom;
 
661
const char *msg_at_node_top;
 
662
const char *msg_one_window;
 
663
const char *msg_win_too_small;
 
664
const char *msg_cant_make_help;
626
665
 
627
666
static void
628
 
init_messages ()
 
667
init_messages (void)
629
668
{
630
669
  msg_cant_find_node   = _("Cannot find node `%s'.");
631
670
  msg_cant_file_node   = _("Cannot find node `(%s)%s'.");