home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GERLIB_DEV08B.LHA / gerlib / libg++ / etc / trie-gen / main.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  1.6 KB  |  59 lines

  1. #ifdef amiga
  2. #include <use_standard_argc_argv.h>
  3. #endif
  4.  
  5. /* Driver routine for the minimal-prefix trie generator.
  6.  
  7.    Copyright (C) 1989 Free Software Foundation, Inc.
  8.    written by Douglas C. Schmidt (schmidt@ics.uci.edu)
  9.    
  10.    This file is part of GNU TRIE-GEN.
  11.    
  12.    GNU TRIE-GEN is free software; you can redistribute it and/or modify
  13.    it under the terms of the GNU General Public License as published by
  14.    the Free Software Foundation; either version 1, or (at your option)
  15.    any later version.
  16.    
  17.    GNU TRIE-GEN is distributed in the hope that it will be useful,
  18.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.    GNU General Public License for more details.
  21.    
  22.    You should have received a copy of the GNU General Public License
  23.    along with GNU trie-gen; see the file COPYING.  If not, write to
  24.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  25.  
  26. #include <_G_config.h>
  27. #if _G_HAVE_SYS_RESOURCE
  28. #include <sys/resource.h>
  29. #endif
  30. #include <iostream.h>
  31. #include "options.h"
  32. #include "trie.h"
  33.  
  34. int
  35. main (int argc, char **argv)
  36. {
  37.   option (argc, argv);
  38.  
  39. #if defined(RLIMIT_STACK) && _G_HAVE_SYS_RESOURCE
  40.   /* Get rid of any avoidable limit on stack size.  */
  41.   {
  42.     struct rlimit rlim;
  43.  
  44.     /* Set the stack limit huge so that alloca does not fail. */
  45.     getrlimit (RLIMIT_STACK, &rlim);
  46.     rlim.rlim_cur = rlim.rlim_max;
  47.     setrlimit (RLIMIT_STACK, &rlim);
  48.   }
  49. #endif /* RLIMIT_STACK */
  50.  
  51.   Trie  trie;
  52.   char *buf;
  53.  
  54.   for (int i = 0; cin.gets (&buf); i++)
  55.     trie.insert (buf, cin.gcount ());
  56.  
  57.   trie.output ();
  58. }
  59.