~ubuntu-branches/ubuntu/gutsy/findutils/gutsy-proposed

« back to all changes in this revision

Viewing changes to locate/code.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2005-07-04 11:37:37 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050704113737-ll89ui8be35r0pir
Tags: 4.2.22-2
* Remove locatedb on purge. (Closes: #315343)
* revert regex-syntax back to emacs-re. (Closes: #315136) Future versions
  will allow to select this by commandline parameter.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
   You should have received a copy of the GNU General Public License
15
15
   along with this program; if not, write to the Free Software
16
 
   Foundation, Inc., 9 Temple Place - Suite 330, Boston, MA 02111-1307,
 
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
17
   USA.
18
18
*/
19
19
 
43
43
   32-127       single character (printable) ASCII remainder
44
44
 
45
45
   Written by James A. Woods <jwoods@adobe.com>.
46
 
   Modified by David MacKenzie <djm@gnu.ai.mit.edu>.  */
 
46
   Modified by David MacKenzie <djm@gnu.org>.  */
47
47
 
48
 
#include <gnulib/config.h>
49
 
#undef VERSION
50
 
#undef PACKAGE_VERSION
51
 
#undef PACKAGE_TARNAME
52
 
#undef PACKAGE_STRING
53
 
#undef PACKAGE_NAME
54
 
#undef PACKAGE
55
48
#include <config.h>
56
49
#include <stdio.h>
57
50
#include <sys/types.h>
77
70
#ifdef gettext_noop
78
71
# define N_(String) gettext_noop (String)
79
72
#else
80
 
# define N_(String) (String)
 
73
/* See locate.c for explanation as to why not use (String) */
 
74
# define N_(String) String
81
75
#endif
82
76
 
83
77
#include "locatedb.h"
84
78
#include <getline.h>
 
79
#include "closeout.h"
85
80
 
86
81
char *xmalloc PARAMS((size_t));
87
82
 
124
119
  return s1 - start;
125
120
}
126
121
 
 
122
extern char *version_string;
 
123
 
 
124
static void
 
125
usage (FILE *stream)
 
126
{
 
127
  fprintf (stream, _("\
 
128
Usage: %s [--version | --help]\n\
 
129
or     %s most_common_bigrams < file-list > locate-database\n"),
 
130
           program_name, program_name);
 
131
  fputs (_("\nReport bugs to <bug-findutils@gnu.org>.\n"), stream);
 
132
}
 
133
 
 
134
 
127
135
int
128
136
main (int argc, char **argv)
129
137
{
137
145
  int line_len;                 /* Length of input line.  */
138
146
 
139
147
  program_name = argv[0];
 
148
  atexit (close_stdout);
140
149
 
141
150
  bigram[2] = '\0';
142
151
 
143
152
  if (argc != 2)
144
153
    {
145
 
      fprintf (stderr, _("Usage: %s most_common_bigrams < list > coded_list\n"),
146
 
               argv[0]);
147
 
      exit (2);
148
 
    }
149
 
 
 
154
      usage(stderr);
 
155
      return 2;
 
156
    }
 
157
  
 
158
  if (0 == strcmp(argv[1], "--help"))
 
159
    {
 
160
      usage(stdout);
 
161
      return 0;
 
162
    }
 
163
  else if (0 == strcmp(argv[1], "--version"))
 
164
    {
 
165
      printf (_("GNU findutils version %s\n"), version_string);
 
166
      return 0;
 
167
    }
 
168
  
150
169
  fp = fopen (argv[1], "r");
151
170
  if (fp == NULL)
152
171
    {
153
172
      fprintf (stderr, "%s: ", argv[0]);
154
173
      perror (argv[1]);
155
 
      exit (1);
 
174
      return 1;
156
175
    }
157
176
 
158
177
  pathsize = oldpathsize = 1026; /* Increased as necessary by getline.  */
229
248
  free (path);
230
249
  free (oldpath);
231
250
 
232
 
  exit (0);
 
251
  return 0;
233
252
}