2008-01-08 14:52:32 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* Eliot
|
|
|
|
* Copyright (C) 1999-2007 Antoine Fraboulet & Olivier Teulière
|
|
|
|
* Authors: Antoine Fraboulet <antoine.fraboulet @@ free.fr>
|
|
|
|
* Olivier Teulière <ipkiss @@ gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
#include "encoding.h"
|
2010-09-18 15:07:39 +02:00
|
|
|
#include "header.h"
|
2008-01-08 14:52:32 +01:00
|
|
|
#include "dic_internals.h"
|
|
|
|
#include "dic.h"
|
2010-09-18 15:07:39 +02:00
|
|
|
#include "listdic.h"
|
2008-01-08 14:52:32 +01:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2010-09-18 15:07:39 +02:00
|
|
|
static void printDicRec(ostream &out, const Dictionary &iDic, const wchar_t * const buf, wchar_t *s, DicEdge edge)
|
2008-01-08 14:52:32 +01:00
|
|
|
{
|
2010-09-18 15:07:39 +02:00
|
|
|
if (edge.term) /* edge points at a complete word */
|
2008-01-08 14:52:32 +01:00
|
|
|
{
|
|
|
|
*s = '\0';
|
2011-07-30 21:48:05 +02:00
|
|
|
out << lfw(buf) << endl;
|
2008-01-08 14:52:32 +01:00
|
|
|
}
|
2010-09-18 15:07:39 +02:00
|
|
|
if (edge.ptr)
|
2008-01-08 14:52:32 +01:00
|
|
|
{ /* Compute index: is it non-zero ? */
|
2010-09-18 15:07:39 +02:00
|
|
|
const DicEdge *p = iDic.getEdgeAt(edge.ptr);
|
2008-01-08 14:52:32 +01:00
|
|
|
do
|
|
|
|
{ /* for each edge out of this node */
|
|
|
|
*s = iDic.getHeader().getCharFromCode(p->chr);
|
2010-09-18 15:07:39 +02:00
|
|
|
printDicRec(out, iDic, buf, s + 1, *p);
|
2008-01-08 14:52:32 +01:00
|
|
|
}
|
|
|
|
while (!(*p++).last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-18 15:07:39 +02:00
|
|
|
void ListDic::printWords(ostream &out, const Dictionary &iDic)
|
2008-01-08 14:52:32 +01:00
|
|
|
{
|
2010-09-18 15:07:39 +02:00
|
|
|
wchar_t buf[100];
|
|
|
|
printDicRec(out, iDic, buf, buf, *iDic.getEdgeAt(iDic.getRoot()));
|
2008-01-08 14:52:32 +01:00
|
|
|
}
|
2008-11-22 14:09:28 +01:00
|
|
|
|