/[eliot]/eliot/dic/listdic.c
ViewVC logotype

Diff of /eliot/dic/listdic.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by ipkiss, Sun Oct 23 14:53:43 2005 UTC revision 1.5 by ipkiss, Fri Nov 4 20:00:06 2005 UTC
# Line 17  Line 17 
17  /* along with this program; if not, write to the Free Software               */  /* along with this program; if not, write to the Free Software               */
18  /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */  /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
19    
 /*  
  * $Id$  
  */  
   
20  #include <string.h>  #include <string.h>
21  #include <stdlib.h>  #include <stdlib.h>
22  #include <stdio.h>  #include <stdio.h>
# Line 34  print_dic_rec(FILE* out, Dictionary dic, Line 30  print_dic_rec(FILE* out, Dictionary dic,
30    if (i.term)  /* edge points at a complete word */    if (i.term)  /* edge points at a complete word */
31      {      {
32        *s = '\0';        *s = '\0';
33        fprintf (out,"%s\n", buf);            fprintf (out,"%s\n", buf);
34      }      }
35    if (i.ptr)      if (i.ptr)
36      {           /* Compute index: is it non-zero ? */      {           /* Compute index: is it non-zero ? */
37        Dawg_edge *p = dic->dawg + i.ptr;        Dawg_edge *p = dic->dawg + i.ptr;
38        do {                         /* for each edge out of this node */        do {                         /* for each edge out of this node */
39          *s = p->chr + 'a' - 1;          *s = p->chr + 'a' - 1;
40          print_dic_rec (out,dic,buf,s + 1, *p);          print_dic_rec (out,dic,buf,s + 1, *p);
41        }        }
42        while (!(*p++).last);        while (!(*p++).last);
43      }      }
44  }  }
45    
46  void  void
47  dic_load(Dictionary* dic, char* filename)  dic_load(Dictionary* dic, char* filename)
48  {  {
49    int res;    int res;
50    if ((res = Dic_load(dic, filename)) != 0)    if ((res = Dic_load(dic, filename)) != 0)
51      {      {
52        switch (res) {        switch (res) {
53        case 1: printf("chargement: problème d'ouverture de %s\n",filename); break;        case 1: printf("chargement: problème d'ouverture de %s\n",filename); break;
# Line 71  print_dic_list(char* filename, char* out Line 67  print_dic_list(char* filename, char* out
67    FILE* fout;    FILE* fout;
68    Dictionary dic;    Dictionary dic;
69    static char buf[80];    static char buf[80];
70      
71    dic_load(&dic,filename);    dic_load(&dic,filename);
72    
73    if (strcmp(out,"stdout") == 0)    if (strcmp(out,"stdout") == 0)
# Line 173  print_dic_hex(char* filename) Line 169  print_dic_hex(char* filename)
169    int i;    int i;
170    Dictionary dic;    Dictionary dic;
171    dic_load(&dic,filename);    dic_load(&dic,filename);
172      
173    printf("offs binary       structure         \n");    printf("offs binary       structure         \n");
174    printf("---- -------- |   ------------------\n");    printf("---- -------- |   ------------------\n");
175    for(i=0; i < (dic->nedges + 1); i++)    for(i=0; i < (dic->nedges + 1); i++)
# Line 192  usage(char* name) Line 188  usage(char* name)
188  }  }
189    
190    
191  int  int
192  main(int argc, char *argv[])  main(int argc, char *argv[])
193  {  {
194    int arg_count;    int arg_count;
# Line 201  main(int argc, char *argv[]) Line 197  main(int argc, char *argv[])
197    int option_print_dic_hex  = 0;    int option_print_dic_hex  = 0;
198    int option_print_dic_list = 0;    int option_print_dic_list = 0;
199    
200    if (argc < 2)    if (argc < 2)
201      {      {
202        usage(argv[0]);        usage(argv[0]);
203        exit(1);        exit(1);
204      }      }
205        
206    arg_count = 1;    arg_count = 1;
207    while(argv[arg_count][0] == '-')    while(argv[arg_count][0] == '-')
208      {      {
# Line 221  main(int argc, char *argv[]) Line 217  main(int argc, char *argv[])
217          }          }
218        arg_count++;        arg_count++;
219      }      }
220        
221    if (option_print_header || option_print_all)    if (option_print_header || option_print_all)
222      {      {
223        print_header(argv[arg_count]);        print_header(argv[arg_count]);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26