texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[5673] remove unused code


From: Gavin D. Smith
Subject: [5673] remove unused code
Date: Thu, 19 Jun 2014 19:17:55 +0000

Revision: 5673
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5673
Author:   gavin
Date:     2014-06-19 19:17:54 +0000 (Thu, 19 Jun 2014)
Log Message:
-----------
remove unused code

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/infokey.c
    trunk/info/infokey.h
    trunk/info/infomap.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-06-19 18:52:49 UTC (rev 5672)
+++ trunk/ChangeLog     2014-06-19 19:17:54 UTC (rev 5673)
@@ -1,5 +1,21 @@
 2014-06-19  Gavin Smith  <address@hidden>
 
+       * info/infokey.c (program_name, print_version_p, print_help_p)
+       (input_filename, output_filename, long_options, mkpath)
+       (write_infokey_file, suggest_help, short_help, main): Remove unused.
+
+       * info/infomap.c (fetch_user_maps): Remove disabled code loading
+       compiled .info file.
+
+       * info/infokey.h (INFOKEY_SRCFILE)
+       (INFOKEY_NMAGIC, INFOKEY_MAGIC_SO, INFOKEY_MAGIC_S1)
+       (INFOKEY_MAGIC_S2, INFOKEY_MAGIC_S3, INFOKEY_SECTION_INFO)
+       (INFOKEY_SECTION_EAe INFOKEY_SECTION_VAR, INFOKEY_MAGIC_EO)
+       (INFOKEY_MAGIC_E1, INFOKEY_MAGIC_E2, INFOKEY_MAGIC_E3)
+       (INFOKEY_MAX_DEFLEN) : Remove unused.
+
+2014-06-19  Gavin Smith  <address@hidden>
+
        * info/Makefile.am (bin_PROGRAMS): infokey removed
        (infokey_LDADD, infokey_SOURCES, nodist_infokey_SOURCES): Removed.
        (check_DATA): Removed.

Modified: trunk/info/infokey.c
===================================================================
--- trunk/info/infokey.c        2014-06-19 18:52:49 UTC (rev 5672)
+++ trunk/info/infokey.c        2014-06-19 19:17:54 UTC (rev 5673)
@@ -25,37 +25,8 @@
 #include "key.h"
 #include "getopt.h"
 
-static char *program_name = "infokey";
+extern char *program_name;  /* in info.c */
 
-/* Non-zero means print version info only. */
-static int print_version_p = 0;
-
-/* Non-zero means print a short description of the options. */
-static int print_help_p = 0;
-
-/* String specifying the source file.  This is set by the user on the
-   command line, or a default is used. */
-static char *input_filename = NULL;
-
-/* String specifying the name of the file to output to.  This is
-   set by the user on the command line, or a default is used. */
-static char *output_filename = NULL;
-
-/* Structure describing the options that Infokey accepts.  We pass this
-   structure to getopt_long ().  If you add or otherwise change this
-   structure, you must also change the string which follows it. */
-static struct option long_options[] =
-{
-  {"output", 1, 0, 'o'},
-  {"help", 0, &print_help_p, 1},
-  {"version", 0, &print_version_p, 1},
-  {NULL, 0, NULL, 0}
-};
-
-/* String describing the shorthand versions of the long options found above. */
-static char *short_options = "o:";
-
-/* Structure for holding the compiled sections. */
 enum sect_e
   {
     info = 0,
@@ -64,199 +35,12 @@
   };
 
 /* Some "forward" declarations. */
-static char *mkpath (const char *dir, const char *file);
 int compile (FILE *fp, const char *filename, struct sect *sections);
-static int write_infokey_file (FILE *fp, struct sect *sections);
 static void syntax_error (const char *filename, unsigned int linenum,
                          const char *fmt, ...) TEXINFO_PRINTFLIKE(3,4);
 void error_message (int error_code, const char *fmt, ...)
   TEXINFO_PRINTFLIKE(2,3);
-static void suggest_help (void);
-static void short_help (void);
-
 
-/* **************************************************************** */
-/*                                                                  */
-/*             Main Entry Point to the Infokey Program              */
-/*                                                                  */
-/* **************************************************************** */
-
-/* Disabled - this file is being linked into the main "info" program. */
-#if 0
-
-int
-main (int argc, char **argv)
-{
-  int getopt_long_index;       /* Index returned by getopt_long (). */
-
-#ifdef HAVE_SETLOCALE
-  /* Set locale via LC_ALL.  */
-  setlocale (LC_ALL, "");
-#endif
-
-#ifdef ENABLE_NLS
-  /* Set the text message domain.  */
-  bindtextdomain (PACKAGE, LOCALEDIR);
-  textdomain (PACKAGE);
-#endif
-
-  while (1)
-    {
-      int option_character;
-
-      option_character = getopt_long
-       (argc, argv, short_options, long_options, &getopt_long_index);
-
-      /* getopt_long () returns EOF when there are no more long options. */
-      if (option_character == EOF)
-       break;
-
-      /* If this is a long option, then get the short version of it. */
-      if (option_character == 0 && long_options[getopt_long_index].flag == 0)
-       option_character = long_options[getopt_long_index].val;
-
-      /* Case on the option that we have received. */
-      switch (option_character)
-       {
-       case 0:
-         break;
-
-         /* User is specifying the name of a file to output to. */
-       case 'o':
-         if (output_filename)
-           free (output_filename);
-         output_filename = xstrdup (optarg);
-         break;
-
-       default:
-         suggest_help ();
-         exit (EXIT_FAILURE);
-       }
-    }
-
-  /* If the user specified --version, then show the version and exit. */
-  if (print_version_p)
-    {
-      printf ("%s (GNU %s) %s\n", program_name, PACKAGE, VERSION);
-      puts ("");
-      printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\
-License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>\n\
-This is free software: you are free to change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law.\n"),
-             "2014");
-      exit (EXIT_SUCCESS);
-    }
-
-  /* If the `--help' option was present, show the help and exit. */
-  if (print_help_p)
-    {
-      short_help ();
-      exit (EXIT_SUCCESS);
-    }
-
-  /* If there is one argument remaining, it is the name of the input
-     file. */
-  if (optind == argc - 1)
-    {
-      if (input_filename)
-       free (input_filename);
-      input_filename = xstrdup (argv[optind]);
-    }
-  else if (optind != argc)
-    {
-      error_message (0, _("incorrect number of arguments"));
-      suggest_help ();
-      exit (EXIT_FAILURE);
-    }
-
-  /* Use default filenames where none given. */
-  {
-    char *homedir;
-
-    homedir = getenv ("HOME");
-#if defined(__MSDOS__) || defined(__MINGW32__)
-    if (!homedir)
-      homedir = ".";
-#endif
-    if (!input_filename)
-      input_filename = mkpath (homedir, INFOKEY_SRCFILE);
-    if (!output_filename)
-      output_filename = mkpath (homedir, INFOKEY_FILE);
-  }
-
-  {
-    FILE *inf;
-    FILE *outf;
-    int write_error;
-    static struct sect sections[3];
-
-    /* Open the input file. */
-    inf = fopen (input_filename, "r");
-    if (!inf)
-      {
-       error_message (errno, _("cannot open input file `%s'"),
-                      input_filename);
-       exit (EXIT_FAILURE);
-      }
-
-    /* Compile the input file to its verious sections, then write the
-       section data to the output file. */
-
-    if (compile (inf, input_filename, sections))
-      {
-       /* Open the output file. */
-       outf = fopen (output_filename, FOPEN_WBIN);
-       if (!outf)
-         {
-           error_message (errno, _("cannot create output file `%s'"),
-                          output_filename);
-           exit (EXIT_FAILURE);
-         }
-
-       /* Write the contents of the output file and close it.  If there is
-          an error writing to the file, delete it and exit with a failure
-          status.  */
-       write_error = 0;
-       if (!write_infokey_file (outf, sections))
-         {
-           error_message (errno, _("error writing to `%s'"),
-                          output_filename);
-           write_error = 1;
-         }
-       if (fclose (outf) == EOF)
-         {
-           error_message (errno, _("error closing output file `%s'"),
-                          output_filename);
-           write_error = 1;
-         }
-       if (write_error)
-         {
-           unlink (output_filename);
-           exit (EXIT_FAILURE);
-         }
-      }
-
-    /* Close the input file. */
-    fclose (inf);
-  }
-
-  return 0;
-}
-#endif
-
-static char *
-mkpath (const char *dir, const char *file)
-{
-  char *p;
-
-  p = xmalloc (strlen (dir) + 1 + strlen (file) + 2);
-  strcpy (p, dir);
-  strcat (p, "/");
-  strcat (p, file);
-  return p;
-}
-
-
 /* Compilation - the real work.
 
        Source file syntax
@@ -795,57 +579,6 @@
   return -1;
 }
 
-/* Put an integer to an infokey file.
-   Integers are stored as two bytes, low order first,
-   in radix INFOKEY_RADIX.
- */
-static int
-putint (int i, FILE *fp)
-{
-  return fputc (i % INFOKEY_RADIX, fp) != EOF
-    && fputc ((i / INFOKEY_RADIX) % INFOKEY_RADIX, fp) != EOF;
-}
-
-/* Write an entire section to an infokey file.  If the section is
-   empty, simply omit it.
- */
-static int
-putsect (struct sect *s, int code, FILE *fp)
-{
-  if (s->cur == 0)
-    return 1;
-  return fputc (code, fp) != EOF
-    && putint (s->cur, fp)
-    && fwrite (s->data, s->cur, 1, fp) == 1;
-}
-
-/* Write an entire infokey file, given an array containing its sections.
- */
-static int
-write_infokey_file (FILE *fp, struct sect *sections)
-{
-  /* Get rid of sections with no effect. */
-  if (sections[info].cur == 1 && sections[info].data[0] == 0)
-    sections[info].cur = 0;
-  if (sections[ea].cur == 1 && sections[ea].data[0] == 0)
-    sections[ea].cur = 0;
-
-  /* Write all parts of the file out in order (no lseeks),
-     checking for errors all the way. */
-  return fputc (INFOKEY_MAGIC_S0, fp) != EOF
-    && fputc (INFOKEY_MAGIC_S1, fp) != EOF
-    && fputc (INFOKEY_MAGIC_S2, fp) != EOF
-    && fputc (INFOKEY_MAGIC_S3, fp) != EOF
-    && fputs (VERSION, fp) != EOF
-    && fputc ('\0', fp) != EOF
-    && putsect (&sections[info], INFOKEY_SECTION_INFO, fp)
-    && putsect (&sections[ea], INFOKEY_SECTION_EA, fp)
-    && putsect (&sections[var], INFOKEY_SECTION_VAR, fp)
-    && fputc (INFOKEY_MAGIC_E0, fp) != EOF
-    && fputc (INFOKEY_MAGIC_E1, fp) != EOF
-    && fputc (INFOKEY_MAGIC_E2, fp) != EOF
-    && fputc (INFOKEY_MAGIC_E3, fp) != EOF;
-}
 
 
 /* Error handling. */
@@ -884,33 +617,4 @@
   fprintf (stderr, "\n");
 }
 
-/* Produce a gentle rtfm. */
-static void
-suggest_help (void)
-{
-  fprintf (stderr, _("Try --help for more information.\n"));
-}
 
-/* Produce a scaled down description of the available options to Info. */
-static void
-short_help (void)
-{
-  printf (_("\
-Usage: %s [OPTION]... [INPUT-FILE]\n\
-\n\
-Compile infokey source file to infokey file.  Reads INPUT-FILE (default\n\
-$HOME/.infokey) and writes compiled key file to (by default) $HOME/.info.\n\
-\n\
-Options:\n\
-  --output FILE        output to FILE instead of $HOME/.info\n\
-  --help               display this help and exit.\n\
-  --version            display version information and exit.\n\
-"), program_name);
-
-  puts (_("\n\
-Email bug reports to address@hidden,\n\
-general questions and discussion to address@hidden
-Texinfo home page: http://www.gnu.org/software/texinfo/";));
-
-  exit (EXIT_SUCCESS);
-}

Modified: trunk/info/infokey.h
===================================================================
--- trunk/info/infokey.h        2014-06-19 18:52:49 UTC (rev 5672)
+++ trunk/info/infokey.h        2014-06-19 19:17:54 UTC (rev 5673)
@@ -27,16 +27,6 @@
    Oh, well.
  */
 
-
-/* Default source file, where user writes text definitions to be
-   compiled to the infokey file.  MS-DOS doesn't allow leading
-   dots in file names.  */
-#ifdef __MSDOS__
-#define INFOKEY_SRCFILE                "_infokey"
-#else
-#define INFOKEY_SRCFILE                ".infokey"
-#endif
-
 /* Default "infokey file", where user defs are kept and read by
    Info.  MS-DOS doesn't allow leading dots in file names.  */
 #ifdef __MSDOS__
@@ -46,19 +36,6 @@
 #endif
 
 /*
-Format of entire infokey file:
-
-       4 bytes         magic number S
-       X bytes         version string
-       1 byte '\0'     terminator
-
-       any number of sections:
-               1 byte          section id
-               2 bytes         section length (N)
-               N bytes         section definitions: format depends on section
-
-       4 bytes         magic number E
-
 Format of INFO and EA sections:
        
        1 byte          flag: 1 == suppress default key bindings
@@ -77,25 +54,8 @@
 
 */
 
-#define        INFOKEY_NMAGIC          8
-
-#define        INFOKEY_MAGIC_S0        '\001'
-#define        INFOKEY_MAGIC_S1        'I'
-#define        INFOKEY_MAGIC_S2        'n'
-#define        INFOKEY_MAGIC_S3        'f'
-
-#define        INFOKEY_SECTION_INFO    'i'
-#define        INFOKEY_SECTION_EA      'e'
-#define        INFOKEY_SECTION_VAR     'v'
-
-#define        INFOKEY_MAGIC_E0        'A'
-#define        INFOKEY_MAGIC_E1        'l'
-#define        INFOKEY_MAGIC_E2        'f'
-#define        INFOKEY_MAGIC_E3        'n'
-
 #define        INFOKEY_RADIX           64
-#define        INFOKEY_MAX_SECTIONLEN  500
-#define        INFOKEY_MAX_DEFLEN      16
+#define        INFOKEY_MAX_SECTIONLEN  500
 
 #define        A_MAX_COMMAND           120
 #define        A_INVALID               121

Modified: trunk/info/infomap.c
===================================================================
--- trunk/info/infomap.c        2014-06-19 18:52:49 UTC (rev 5672)
+++ trunk/info/infomap.c        2014-06-19 19:17:54 UTC (rev 5673)
@@ -919,115 +919,6 @@
   user_vars = sections[2].data;
   user_vars_len = sections[2].cur;
 
-  /* This is done in read_init_file. */
-#if 0
-
-  /* Set Info variables from init file. */
-  if (user_vars_len)
-    section_to_vars (user_vars, user_vars_len);
-#endif
-
-
-  /* Disable - we do not read the .info binary file any more, but .infokey
-     directly. */
-#if 0
-  /* Ensure that the file is a reasonable size. */
-  len = filesize (f);
-  if (len < INFOKEY_NMAGIC + 2 || len > 100 * 1024)
-    {
-      /* Bad file (a valid file must have at least 9 chars, and
-        more than 100 KB is a problem). */
-      if (len < INFOKEY_NMAGIC + 2)
-       info_error (_("Ignoring invalid infokey file `%s' - too small"),
-                  filename);
-      else
-       info_error (_("Ignoring invalid infokey file `%s' - too big"),
-                  filename);
-      close (f);
-      free (filename);
-      return 0;
-    }
-  
-  /* Read the file into a buffer. */
-  buf = xmalloc ((int)len);
-  nread = read (f, buf, (unsigned int) len);
-  close (f);
-  if ((unsigned int) nread != len)
-    {
-      info_error (_("Error reading infokey file `%s' - short read"),
-                           filename);
-      free (buf);
-      free (filename);
-      return 0;
-    }
-  
-  /* Check the header, trailer, and version of the file to increase
-     our confidence that the contents are valid.  */
-  if (buf[0] != INFOKEY_MAGIC_S0 ||
-      buf[1] != INFOKEY_MAGIC_S1 ||
-      buf[2] != INFOKEY_MAGIC_S2 ||
-      buf[3] != INFOKEY_MAGIC_S3 ||
-      buf[len - 4] != INFOKEY_MAGIC_E0 ||
-      buf[len - 3] != INFOKEY_MAGIC_E1 ||
-      buf[len - 2] != INFOKEY_MAGIC_E2 ||
-      buf[len - 1] != INFOKEY_MAGIC_E3)
-    {
-      info_error (_("Invalid infokey file `%s' (bad magic numbers) -- run 
infokey to update it"),
-                filename);
-      free (filename);
-      return 0;
-    }
-  if (len < INFOKEY_NMAGIC + strlen (VERSION) + 1 ||
-      strcmp (VERSION, (char *) (buf + 4)) != 0)
-    {
-      info_error (_("Your infokey file `%s' is out of date -- run infokey to 
update it"),
-                filename);
-      free (filename);
-      return 0;
-    }
-  
-  /* Extract the pieces.  */
-  for (p = buf + 4 + strlen (VERSION) + 1;
-       (unsigned int) (p - buf) < len - 4;
-       p += n)
-    {
-      int s = *p++;
-      
-      n = getint (&p);
-      if (n < 0 || (unsigned int) n > len - 4 - (p - buf))
-       {
-         info_error (_("Invalid infokey file `%s' (bad section length) -- run 
infokey to update it"),
-                    filename);
-         free (filename);
-         return 0;
-       }
-      
-      switch (s)
-       {
-       case INFOKEY_SECTION_INFO:
-         user_info_keys = p;
-         user_info_keys_len = n;
-         break;
-         
-       case INFOKEY_SECTION_EA:
-         user_ea_keys = p;
-         user_ea_keys_len = n;
-         break;
-         
-       case INFOKEY_SECTION_VAR:
-         user_vars = p;
-         user_vars_len = n;
-         break;
-         
-       default:
-         info_error (_("Invalid infokey file `%s' (bad section code) -- run 
infokey to update it"),
-                    filename);
-         free (filename);
-         return 0;
-       }
-    }
-#endif
-  
   free (filename);
   return 1;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]