summaryrefslogtreecommitdiff
path: root/dict.c
diff options
context:
space:
mode:
Diffstat (limited to 'dict.c')
-rw-r--r--dict.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/dict.c b/dict.c
index 8a54c03..5f48c1d 100644
--- a/dict.c
+++ b/dict.c
@@ -10,11 +10,11 @@
*
* WordExtract 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
+ * 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 WordExtract. If not, see <http://www.gnu.org/licenses/>.
+ * along with WordExtract. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/stat.h>
@@ -25,6 +25,7 @@
#include "main.h"
Word *dict;
+SortedWords dict_words = {0, NULL};
static void create_dict_file(char *path);
@@ -48,14 +49,24 @@ Word *load_dict()
if (strcmp(word, "\0") == 0) /*to not process final blank line*/
break;
word[strlen(word)-1] = '\0';
- root = add_word_record(root, word);
+ root = add_word(root, word);
for (i = 0; i < WORDLENGTH; i++)
word[i] = 0;
}
fclose(fdict);
+ dict_words = get_sorted(root);
return root;
}
+void save_dict(FILE *file, Word *root)
+{
+ if (root != NULL) {
+ fprintf(file, "%s\n", root->word);
+ save_dict(file, root->lsibl);
+ save_dict(file, root->rsibl);
+ }
+}
+
int is_in_dict(char *word, Word *dic_rec)
{
int cond;
@@ -74,7 +85,7 @@ int is_in_dict(char *word, Word *dic_rec)
void create_dict_file(char *path)
{
- mode_t mode_0755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
+ mode_t mode_0755 = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
struct stat st;
FILE *fdict;
char file[PATH_LENGTH] = {0};