1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

Update Snowball. I have to update it because of

old version doesn't available on Snowball's site and new version
of stemmers can't be compiled with old interface.
This commit is contained in:
Teodor Sigaev
2005-09-15 11:56:58 +00:00
parent 8080e8e8ce
commit b4d107a777
11 changed files with 2223 additions and 2305 deletions

View File

@@ -1,89 +1,69 @@
#include <stdlib.h>
#include <stdlib.h> /* for calloc, free */
#include "header.h"
struct SN_env *
SN_create_env(int S_size, int I_size, int B_size)
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size)
{
struct SN_env *z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
struct SN_env *z2 = z;
struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
if (z == NULL) return NULL;
z->p = create_s();
if (z->p == NULL) goto error;
if (S_size)
{
int i;
z->S = (symbol * *) calloc(S_size, sizeof(symbol *));
if (z->S == NULL) goto error;
if (!z)
return z;
for (i = 0; i < S_size; i++)
{
z->S[i] = create_s();
if (z->S[i] == NULL) goto error;
}
z->S_size = S_size;
}
z->p = create_s();
if (!z->p)
z = NULL;
if (I_size)
{
z->I = (int *) calloc(I_size, sizeof(int));
if (z->I == NULL) goto error;
z->I_size = I_size;
}
if (z && S_size)
{
if ((z->S = (symbol * *) calloc(S_size, sizeof(symbol *))))
{
int i;
if (B_size)
{
z->B = (symbol *) calloc(B_size, sizeof(symbol));
if (z->B == NULL) goto error;
z->B_size = B_size;
}
for (i = 0; i < S_size; i++)
{
if (!(z->S[i] = create_s()))
{
z = NULL;
break;
}
}
z2->S_size = i;
}
else
z = NULL;
}
if (z && I_size)
{
z->I = (int *) calloc(I_size, sizeof(int));
if (z->I)
z->I_size = I_size;
else
z = NULL;
}
if (z && B_size)
{
z->B = (symbol *) calloc(B_size, sizeof(symbol));
if (z->B)
z->B_size = B_size;
else
z = NULL;
}
if (!z)
SN_close_env(z2);
return z;
return z;
error:
SN_close_env(z);
return NULL;
}
void
SN_close_env(struct SN_env * z)
extern void SN_close_env(struct SN_env * z)
{
if (z->S && z->S_size)
{
{
int i;
for (i = 0; i < z->S_size; i++)
lose_s(z->S[i]);
}
free(z->S);
}
if (z->I_size)
free(z->I);
if (z->B_size)
free(z->B);
if (z->p)
lose_s(z->p);
free(z);
if (z == NULL) return;
if (z->S_size)
{
int i;
for (i = 0; i < z->S_size; i++)
{
lose_s(z->S[i]);
}
free(z->S);
}
if (z->I_size) free(z->I);
if (z->B_size) free(z->B);
if (z->p) lose_s(z->p);
free(z);
}
void
SN_set_current(struct SN_env * z, int size, const symbol * s)
extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
{
replace_s(z, 0, z->l, size, s);
z->c = 0;
int err = replace_s(z, 0, z->l, size, s, NULL);
z->c = 0;
return err;
}