~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/third_party/libstemmer_c/libstemmer/libstemmer_c.in

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include <stdlib.h>
 
3
#include <string.h>
 
4
#include "../include/libstemmer.h"
 
5
#include "../runtime/api.h"
 
6
#include "@MODULES_H@"
 
7
 
 
8
struct sb_stemmer {
 
9
    struct SN_env * (*create)(void);
 
10
    void (*close)(struct SN_env *);
 
11
    int (*stem)(struct SN_env *);
 
12
 
 
13
    struct SN_env * env;
 
14
};
 
15
 
 
16
extern const char **
 
17
sb_stemmer_list(void)
 
18
{
 
19
    return algorithm_names;
 
20
}
 
21
 
 
22
static stemmer_encoding_t
 
23
sb_getenc(const char * charenc)
 
24
{
 
25
    struct stemmer_encoding * encoding;
 
26
    if (charenc == NULL) return ENC_UTF_8;
 
27
    for (encoding = encodings; encoding->name != 0; encoding++) {
 
28
        if (strcmp(encoding->name, charenc) == 0) break;
 
29
    }
 
30
    if (encoding->name == NULL) return ENC_UNKNOWN;
 
31
    return encoding->enc;
 
32
}
 
33
 
 
34
extern struct sb_stemmer *
 
35
sb_stemmer_new(const char * algorithm, const char * charenc)
 
36
{
 
37
    stemmer_encoding_t enc;
 
38
    struct stemmer_modules * module;
 
39
    struct sb_stemmer * stemmer;
 
40
 
 
41
    enc = sb_getenc(charenc);
 
42
    if (enc == ENC_UNKNOWN) return NULL;
 
43
 
 
44
    for (module = modules; module->name != 0; module++) {
 
45
        if (strcmp(module->name, algorithm) == 0 && module->enc == enc) break;
 
46
    }
 
47
    if (module->name == NULL) return NULL;
 
48
    
 
49
    stemmer = (struct sb_stemmer *) malloc(sizeof(struct sb_stemmer));
 
50
    if (stemmer == NULL) return NULL;
 
51
 
 
52
    stemmer->create = module->create;
 
53
    stemmer->close = module->close;
 
54
    stemmer->stem = module->stem;
 
55
 
 
56
    stemmer->env = stemmer->create();
 
57
    if (stemmer->env == NULL)
 
58
    {
 
59
        sb_stemmer_delete(stemmer);
 
60
        return NULL;
 
61
    }
 
62
 
 
63
    return stemmer;
 
64
}
 
65
 
 
66
void
 
67
sb_stemmer_delete(struct sb_stemmer * stemmer)
 
68
{
 
69
    if (stemmer == 0) return;
 
70
    if (stemmer->close == 0) return;
 
71
    stemmer->close(stemmer->env);
 
72
    stemmer->close = 0;
 
73
    free(stemmer);
 
74
}
 
75
 
 
76
const sb_symbol *
 
77
sb_stemmer_stem(struct sb_stemmer * stemmer, const sb_symbol * word, int size)
 
78
{
 
79
    int ret;
 
80
    if (SN_set_current(stemmer->env, size, (const symbol *)(word)))
 
81
    {
 
82
        stemmer->env->l = 0;
 
83
        return NULL;
 
84
    }
 
85
    ret = stemmer->stem(stemmer->env);
 
86
    if (ret < 0) return NULL;
 
87
    stemmer->env->p[stemmer->env->l] = 0;
 
88
    return (const sb_symbol *)(stemmer->env->p);
 
89
}
 
90
 
 
91
int
 
92
sb_stemmer_length(struct sb_stemmer * stemmer)
 
93
{
 
94
    return stemmer->env->l;
 
95
}