/[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.2.2 by afrab, Sun Oct 23 18:38:18 2005 UTC revision 1.4.2.3 by ipkiss, Sun Oct 23 20:58:19 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  /**  /**
21   *  \file   listdic.c   *  \file   listdic.c
22   *  \brief  Program used to list a dictionary   *  \brief  Program used to list a dictionary
# Line 39  print_dic_rec(FILE* out, Dictionary dic, Line 37  print_dic_rec(FILE* out, Dictionary dic,
37    if (i.term)  /* edge points at a complete word */    if (i.term)  /* edge points at a complete word */
38      {      {
39        *s = '\0';        *s = '\0';
40        fprintf (out,"%s\n", buf);            fprintf (out,"%s\n", buf);
41      }      }
42    if (i.ptr)      if (i.ptr)
43      {           /* Compute index: is it non-zero ? */      {           /* Compute index: is it non-zero ? */
44        Dawg_edge *p = dic->dawg + i.ptr;        Dawg_edge *p = dic->dawg + i.ptr;
45        do {                         /* for each edge out of this node */        do {                         /* for each edge out of this node */
46          *s = p->chr + 'a' - 1;          *s = p->chr + 'a' - 1;
47          print_dic_rec (out,dic,buf,s + 1, *p);          print_dic_rec (out,dic,buf,s + 1, *p);
48        }        }
49        while (!(*p++).last);        while (!(*p++).last);
50      }      }
51  }  }
52    
53  void  void
54  dic_load(Dictionary* dic, char* filename)  dic_load(Dictionary* dic, char* filename)
55  {  {
56    int res;    int res;
57    if ((res = Dic_load(dic, filename)) != 0)    if ((res = Dic_load(dic, filename)) != 0)
58      {      {
59        switch (res) {        switch (res) {
60        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 76  print_dic_list(char* filename, char* out Line 74  print_dic_list(char* filename, char* out
74    FILE* fout;    FILE* fout;
75    Dictionary dic;    Dictionary dic;
76    static char buf[80];    static char buf[80];
77      
78    dic_load(&dic,filename);    dic_load(&dic,filename);
79    
80    if (strcmp(out,"stdout") == 0)    if (strcmp(out,"stdout") == 0)
# Line 178  print_dic_hex(char* filename) Line 176  print_dic_hex(char* filename)
176    int i;    int i;
177    Dictionary dic;    Dictionary dic;
178    dic_load(&dic,filename);    dic_load(&dic,filename);
179      
180    printf("offs binary       structure         \n");    printf("offs binary       structure         \n");
181    printf("---- -------- |   ------------------\n");    printf("---- -------- |   ------------------\n");
182    for(i=0; i < (dic->nedges + 1); i++)    for(i=0; i < (dic->nedges + 1); i++)
# Line 197  usage(char* name) Line 195  usage(char* name)
195  }  }
196    
197    
198  int  int
199  main(int argc, char *argv[])  main(int argc, char *argv[])
200  {  {
201    int arg_count;    int arg_count;
# Line 206  main(int argc, char *argv[]) Line 204  main(int argc, char *argv[])
204    int option_print_dic_hex  = 0;    int option_print_dic_hex  = 0;
205    int option_print_dic_list = 0;    int option_print_dic_list = 0;
206    
207    if (argc < 2)    if (argc < 2)
208      {      {
209        usage(argv[0]);        usage(argv[0]);
210        exit(1);        exit(1);
211      }      }
212        
213    arg_count = 1;    arg_count = 1;
214    while(argv[arg_count][0] == '-')    while(argv[arg_count][0] == '-')
215      {      {
# Line 226  main(int argc, char *argv[]) Line 224  main(int argc, char *argv[])
224          }          }
225        arg_count++;        arg_count++;
226      }      }
227        
228    if (option_print_header || option_print_all)    if (option_print_header || option_print_all)
229      {      {
230        print_header(argv[arg_count]);        print_header(argv[arg_count]);

Legend:
Removed from v.1.4.2.2  
changed lines
  Added in v.1.4.2.3

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