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

« back to all changes in this revision

Viewing changes to info/indices.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2005-10-28 15:10:30 UTC
  • mto: (2.1.1 dapper) (3.1.4 hardy)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051028151030-9nsf2s2k2z3fktjt
Tags: upstream-4.8
ImportĀ upstreamĀ versionĀ 4.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* indices.c -- deal with an Info file index.
2
 
   $Id: indices.c,v 1.14 1999/09/25 16:10:04 karl Exp $
 
2
   $Id: indices.c,v 1.5 2004/04/11 17:56:45 karl Exp $
3
3
 
4
 
   Copyright (C) 1993, 97, 98, 99 Free Software Foundation, Inc.
 
4
   Copyright (C) 1993, 1997, 1998, 1999, 2002, 2003, 2004 Free Software
 
5
   Foundation, Inc.
5
6
 
6
7
   This program is free software; you can redistribute it and/or modify
7
8
   it under the terms of the GNU General Public License as published by
17
18
   along with this program; if not, write to the Free Software
18
19
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20
 
20
 
   Written by Brian Fox (bfox@ai.mit.edu). */
 
21
   Originally written by Brian Fox (bfox@ai.mit.edu). */
21
22
 
22
23
#include "info.h"
23
24
#include "indices.h"
54
55
/* Add the name of NODE, and the range of the associated index elements
55
56
   (passed in ARRAY) to index_nodenames. */
56
57
static void
57
 
add_index_to_index_nodenames (array, node)
58
 
     REFERENCE **array;
59
 
     NODE *node;
 
58
add_index_to_index_nodenames (REFERENCE **array, NODE *node)
60
59
{
61
60
  register int i, last;
62
61
  INDEX_NAME_ASSOC *assoc;
63
62
 
64
 
  for (last = 0; array[last]; last++);
 
63
  for (last = 0; array[last + 1]; last++);
65
64
  assoc = (INDEX_NAME_ASSOC *)xmalloc (sizeof (INDEX_NAME_ASSOC));
66
65
  assoc->name = xstrdup (node->nodename);
67
66
 
87
86
   indices are concatenated and the result returned.  If WINDOW's info file
88
87
   doesn't have any indices, a NULL pointer is returned. */
89
88
REFERENCE **
90
 
info_indices_of_window (window)
91
 
     WINDOW *window;
 
89
info_indices_of_window (WINDOW *window)
92
90
{
93
91
  FILE_BUFFER *fb;
94
92
 
98
96
}
99
97
 
100
98
REFERENCE **
101
 
info_indices_of_file_buffer (file_buffer)
102
 
     FILE_BUFFER *file_buffer;
 
99
info_indices_of_file_buffer (FILE_BUFFER *file_buffer)
103
100
{
104
101
  register int i;
105
102
  REFERENCE **result = (REFERENCE **)NULL;
180
177
/* Look up SEARCH_STRING in the index for this file.  If SEARCH_STRING
181
178
   is NULL, prompt user for input.  */ 
182
179
void
183
 
do_info_index_search (window, count, search_string)
184
 
     WINDOW *window;
185
 
     int count;
186
 
     char *search_string;
 
180
do_info_index_search (WINDOW *window, int count, char *search_string)
187
181
{
188
182
  FILE_BUFFER *fb;
189
183
  char *line;
202
196
      (FILENAME_CMP (initial_index_filename, fb->filename) != 0))
203
197
    {
204
198
      info_free_references (index_index);
205
 
      window_message_in_echo_area (_("Finding index entries..."));
 
199
      window_message_in_echo_area ((char *) _("Finding index entries..."),
 
200
          NULL, NULL);
206
201
      index_index = info_indices_of_file_buffer (fb);
207
202
    }
208
203
 
209
204
  /* If there is no index, quit now. */
210
205
  if (!index_index)
211
206
    {
212
 
      info_error (_("No indices found."));
 
207
      info_error ((char *) _("No indices found."), NULL, NULL);
213
208
      return;
214
209
    }
215
210
 
219
214
    line = xstrdup (search_string);
220
215
  else
221
216
    {
222
 
      line = info_read_maybe_completing (window, _("Index entry: "),
 
217
      line = info_read_maybe_completing (window, (char *) _("Index entry: "),
223
218
                                         index_index);
224
219
      window = active_window;
225
220
 
282
277
}
283
278
 
284
279
int
285
 
index_entry_exists (window, string)
286
 
     WINDOW *window;
287
 
     char *string;
 
280
index_entry_exists (WINDOW *window, char *string)
288
281
{
289
282
  register int i;
290
283
  FILE_BUFFER *fb;
339
332
     yet. */
340
333
  if (!index_search)
341
334
    {
342
 
      info_error (_("No previous index search string."));
 
335
      info_error ((char *) _("No previous index search string."), NULL, NULL);
343
336
      return;
344
337
    }
345
338
 
346
339
  /* If there is no index, that is an error. */
347
340
  if (!index_index)
348
341
    {
349
 
      info_error (_("No index entries."));
 
342
      info_error ((char *) _("No index entries."), NULL, NULL);
350
343
      return;
351
344
    }
352
345
 
379
372
  /* If that failed, print an error. */
380
373
  if ((i < 0) || (!index_index[i]))
381
374
    {
382
 
      info_error (_("No %sindex entries containing \"%s\"."),
383
 
                  index_offset > 0 ? _("more ") : "", index_search);
 
375
      info_error ((char *) _("No %sindex entries containing `%s'."),
 
376
                  index_offset > 0 ? (char *) _("more ") : "", index_search);
384
377
      return;
385
378
    }
386
379
 
390
383
  /* Report to the user on what we have found. */
391
384
  {
392
385
    register int j;
393
 
    char *name = _("CAN'T SEE THIS");
 
386
    const char *name = _("CAN'T SEE THIS");
394
387
    char *match;
395
388
 
396
389
    for (j = 0; index_nodenames[j]; j++)
409
402
 
410
403
    if (partial && show_index_match)
411
404
      {
412
 
        int j, ls, start, upper;
 
405
        int k, ls, start, upper;
413
406
 
414
407
        ls = strlen (index_search);
415
408
        start = partial - ls;
416
409
        upper = isupper (match[start]) ? 1 : 0;
417
410
 
418
 
        for (j = 0; j < ls; j++)
 
411
        for (k = 0; k < ls; k++)
419
412
          if (upper)
420
 
            match[j + start] = info_tolower (match[j + start]);
 
413
            match[k + start] = info_tolower (match[k + start]);
421
414
          else
422
 
            match[j + start] = info_toupper (match[j + start]);
 
415
            match[k + start] = info_toupper (match[k + start]);
423
416
      }
424
417
 
425
418
    {
426
419
      char *format;
427
420
 
428
421
      format = replace_in_documentation
429
 
        (_("Found \"%s\" in %s. (`\\[next-index-match]' tries to find next.)"));
 
422
        ((char *) _("Found `%s' in %s. (`\\[next-index-match]' tries to find next.)"),
 
423
         0);
430
424
 
431
 
      window_message_in_echo_area (format, match, name);
 
425
      window_message_in_echo_area (format, match, (char *) name);
432
426
    }
433
427
 
434
428
    free (match);
439
433
 
440
434
  if (!node)
441
435
    {
442
 
      info_error (msg_cant_file_node,
 
436
      info_error ((char *) msg_cant_file_node,
443
437
                  index_index[i]->filename, index_index[i]->nodename);
444
438
      return;
445
439
    }
470
464
/* For every menu item in DIR, search the indices of that file for
471
465
   SEARCH_STRING. */
472
466
REFERENCE **
473
 
apropos_in_all_indices (search_string, inform)
474
 
     char *search_string;
475
 
     int inform;
 
467
apropos_in_all_indices (char *search_string, int inform)
476
468
{
477
469
  register int i, dir_index;
478
470
  REFERENCE **all_indices = (REFERENCE **)NULL;
546
538
          }
547
539
 
548
540
        if (this_fb && inform)
549
 
          message_in_echo_area (_("Scanning indices of \"%s\"..."), files_name);
 
541
          message_in_echo_area ((char *) _("Scanning indices of `%s'..."),
 
542
              files_name, NULL);
550
543
 
551
544
        this_index = info_indices_of_file_buffer (this_fb);
552
545
        free (this_node);
600
593
}
601
594
 
602
595
#define APROPOS_NONE \
603
 
   N_("No available info files have \"%s\" in their indices.")
 
596
   N_("No available info files have `%s' in their indices.")
604
597
 
605
598
void
606
 
info_apropos (string)
607
 
     char *string;
 
599
info_apropos (char *string)
608
600
{
609
601
  REFERENCE **apropos_list;
610
602
 
611
603
  apropos_list = apropos_in_all_indices (string, 0);
612
604
 
613
605
  if (!apropos_list)
614
 
    {
615
 
      info_error (_(APROPOS_NONE), string);
616
 
    }
 
606
    info_error ((char *) _(APROPOS_NONE), string, NULL);
617
607
  else
618
608
    {
619
609
      register int i;
633
623
{
634
624
  char *line;
635
625
 
636
 
  line = info_read_in_echo_area (window, _("Index apropos: "));
 
626
  line = info_read_in_echo_area (window, (char *) _("Index apropos: "));
637
627
 
638
628
  window = active_window;
639
629
 
653
643
      apropos_list = apropos_in_all_indices (line, 1);
654
644
 
655
645
      if (!apropos_list)
656
 
        {
657
 
          info_error (_(APROPOS_NONE), line);
658
 
        }
 
646
        info_error ((char *) _(APROPOS_NONE), line, NULL);
659
647
      else
660
648
        {
661
649
          register int i;
663
651
 
664
652
          initialize_message_buffer ();
665
653
          printf_to_message_buffer
666
 
            (_("\n* Menu: Nodes whoses indices contain \"%s\":\n"), line);
 
654
            ((char *) _("\n* Menu: Nodes whose indices contain `%s':\n"),
 
655
             line, NULL, NULL);
667
656
          line_buffer = (char *)xmalloc (500);
668
657
 
669
658
          for (i = 0; apropos_list[i]; i++)
677
666
              len = pad_to (40, line_buffer);
678
667
              sprintf (line_buffer + len, "(%s)%s.",
679
668
                       apropos_list[i]->filename, apropos_list[i]->nodename);
680
 
              printf_to_message_buffer ("%s\n", line_buffer);
 
669
              printf_to_message_buffer ("%s\n", line_buffer, NULL, NULL);
681
670
            }
682
671
          free (line_buffer);
683
672
        }
744
733
  if (!info_error_was_printed)
745
734
    window_clear_echo_area ();
746
735
}
747