src/sentence.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Mon, 09 Sep 2013 15:54:09 +0200
changeset 4 be4de85337e5
parent 0 06dd3b8d90ad
permissions -rw-r--r--
Small changes committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
/**
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     2
 *  $Id: sentence.c 53 2008-01-10 00:19:41Z mbroeker $
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     3
 * $URL: http://localhost/svn/c/VirtualReader/trunk/src/sentence.c $
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
 */
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
#include <sentence.h>
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     8
int words (char *ptr)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
{
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    10
    char *buffer = NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    11
    char *token;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    12
    int count = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
    if (ptr != NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
        buffer = strdup (ptr);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
    if (buffer == NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    18
        return -1;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    20
    token = strtok (buffer, " ");
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
    while (token != NULL) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    22
        token = strtok (NULL, " ");
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    23
        count++;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    24
    }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    25
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    26
    if (buffer != NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    27
        free (buffer);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    28
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    29
    return count;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    30
}
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    31
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    32
int *parse (char *buf)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    33
{
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    34
    int count = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    35
    int i;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    36
    int *s_ptr = NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    37
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    38
    s_ptr = malloc (2 * sizeof (int));
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    39
    s_ptr[count++] = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    40
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    41
    for (i = 0; i < strlen (buf); i++)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    42
        switch (buf[i]) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    43
        case '\n':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    44
        case '\t':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    45
        case '"':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    46
        case '\'':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    47
            buf[i] = ' ';
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    48
            break;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    49
        case '.':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    50
        case '!':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    51
        case '?':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    52
            s_ptr = realloc (s_ptr, (count + 2) * sizeof (int));
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    53
            if (s_ptr == NULL) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    54
                printf ("Not enough memory\n");
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    55
                return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    56
            }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    57
            s_ptr[count++] = ++i;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    58
            break;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    59
        default:
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    60
            break;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    61
        }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    62
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    63
    s_ptr[count] = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    64
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    65
    return s_ptr;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    66
}
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    67
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    68
char *readbuffer (char *fname)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    69
{
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    70
    FILE *f;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    71
    char *text = NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    72
    char buffer[201];
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    73
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    74
    if ((f = fopen (fname, "r")) == NULL) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    75
        fprintf (stderr, "ERROR: Cannot open %s for reading!\n", fname);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    76
        return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    77
    }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    78
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    79
    text = malloc (2);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    80
    *text = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    81
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    82
    while (fgets (buffer, 200, f) != 0) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    83
        if ((text = realloc (text, strlen (text) + strlen (buffer) + 1)) == NULL) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    84
            printf ("Not enough memory\n");
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    85
            return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    86
        };
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    87
        strcat (text, buffer);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    88
        *buffer = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    89
    }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    90
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    91
    fclose (f);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    92
    return text;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    93
}
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    94
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    95
char *getSentence (char *text, int start, int end)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    96
{
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    97
    int i;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    98
    char *value = NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    99
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   100
    if ((i = end - start) < 0)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   101
        return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   102
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   103
    value = malloc (i + 1);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   104
    if (value == NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   105
        return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   106
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   107
    i = 1;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   108
    while (i) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   109
        switch (text[start]) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   110
        case '.':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   111
        case ',':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   112
        case '!':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   113
        case '?':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   114
        case '(':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   115
        case ')':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   116
        case '\n':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   117
        case ' ':
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   118
            start++;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   119
            break;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   120
        default:
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   121
            i = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   122
            break;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   123
        }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   124
    }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   125
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   126
    for (i = start; i < end; i++) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   127
        value[i - start] = text[i];
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   128
    }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   129
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   130
    value[i - start] = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   131
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   132
    return value;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   133
}
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   134
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   135
char **getstrings (char *Text, int *value)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   136
{
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   137
    char *ptr;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   138
    int i = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   139
    int count = 0;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   140
    char **sentences = NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   141
    int *s_ptr;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   142
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   143
    if ((s_ptr = parse (Text)) == NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   144
        return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   145
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   146
    while (s_ptr[i + 1] > 0) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   147
        if ((ptr = getSentence (Text, s_ptr[i], s_ptr[i + 1])) == NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   148
            return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   149
        if (strlen (ptr) > 0) {
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   150
            if ((sentences = realloc (sentences, (count + 1) * sizeof (char *) + 1)) == NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   151
                return NULL;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   152
            sentences[count++] = strdup (ptr);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   153
        }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   154
        if (ptr != NULL)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   155
            free (ptr);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   156
        i++;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   157
    }
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   158
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   159
    if (s_ptr)
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   160
        free (s_ptr);
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   161
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   162
    *value = count;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   163
    return sentences;
06dd3b8d90ad Virtual Reader
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
   164
}