File: corlist.c

package info (click to toggle)
hspell 1.2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,444 kB
  • ctags: 343
  • sloc: ansic: 2,811; perl: 1,988; makefile: 264; sh: 109; awk: 15
file content (36 lines) | stat: -rw-r--r-- 686 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Copyright (C) 2003 Nadav Har'El and Dan Kenigsberg */

/* a silly implementation of a list of correction words */

#include <string.h>

#include "hspell.h"

int
corlist_init(struct corlist *cl)
{
	cl->n=0;
	return 1;
}

int
corlist_free(struct corlist *cl)
{
	/* no need to do anything in this implementation */
	cl->n=0; /* not necessary */
	return 1;
}

int
corlist_add(struct corlist *cl, const char *s)
{
	int i;
	for(i=0; i<cl->n; i++){
		if(!strcmp(cl->correction[i],s))
			return 1; /* already in list! */
	}
	if(cl->n==(sizeof(cl->correction)/sizeof(cl->correction[0])))
		return 0; /* no room */
	strncpy(cl->correction[cl->n++], s, sizeof(cl->correction[0]));
	return 1;
}