PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
header.h File Reference
#include <limits.h>
#include "api.h"
Include dependency graph for header.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  among
 

Macros

#define MAXINT   INT_MAX
 
#define MININT   INT_MIN
 
#define HEAD   2*sizeof(int)
 
#define SIZE(p)   ((int *)(p))[-1]
 
#define SET_SIZE(p, n)   ((int *)(p))[-1] = n
 
#define CAPACITY(p)   ((int *)(p))[-2]
 

Functions

symbolcreate_s (void)
 
void lose_s (symbol *p)
 
int skip_utf8 (const symbol *p, int c, int limit, int n)
 
int skip_b_utf8 (const symbol *p, int c, int limit, int n)
 
int in_grouping_U (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int in_grouping_b_U (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int out_grouping_U (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int out_grouping_b_U (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int in_grouping (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int in_grouping_b (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int out_grouping (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int out_grouping_b (struct SN_env *z, const unsigned char *s, int min, int max, int repeat)
 
int eq_s (struct SN_env *z, int s_size, const symbol *s)
 
int eq_s_b (struct SN_env *z, int s_size, const symbol *s)
 
int eq_v (struct SN_env *z, const symbol *p)
 
int eq_v_b (struct SN_env *z, const symbol *p)
 
int find_among (struct SN_env *z, const struct among *v, int v_size)
 
int find_among_b (struct SN_env *z, const struct among *v, int v_size)
 
int replace_s (struct SN_env *z, int c_bra, int c_ket, int s_size, const symbol *s, int *adjptr)
 
int slice_from_s (struct SN_env *z, int s_size, const symbol *s)
 
int slice_from_v (struct SN_env *z, const symbol *p)
 
int slice_del (struct SN_env *z)
 
int insert_s (struct SN_env *z, int bra, int ket, int s_size, const symbol *s)
 
int insert_v (struct SN_env *z, int bra, int ket, const symbol *p)
 
symbolslice_to (struct SN_env *z, symbol *p)
 
symbolassign_to (struct SN_env *z, symbol *p)
 
int len_utf8 (const symbol *p)
 
void debug (struct SN_env *z, int number, int line_count)
 

Macro Definition Documentation

◆ CAPACITY

#define CAPACITY (   p)    ((int *)(p))[-2]

Definition at line 13 of file header.h.

◆ HEAD

#define HEAD   2*sizeof(int)

Definition at line 9 of file header.h.

◆ MAXINT

#define MAXINT   INT_MAX

Definition at line 6 of file header.h.

◆ MININT

#define MININT   INT_MIN

Definition at line 7 of file header.h.

◆ SET_SIZE

#define SET_SIZE (   p,
 
)    ((int *)(p))[-1] = n

Definition at line 12 of file header.h.

◆ SIZE

#define SIZE (   p)    ((int *)(p))[-1]

Definition at line 11 of file header.h.

Function Documentation

◆ assign_to()

symbol* assign_to ( struct SN_env z,
symbol p 
)

Definition at line 466 of file utilities.c.

466  {
467  int len = z->l;
468  if (CAPACITY(p) < len) {
469  p = increase_size(p, len);
470  if (p == NULL)
471  return NULL;
472  }
473  memmove(p, z->p, len * sizeof(symbol));
474  SET_SIZE(p, len);
475  return p;
476 }
unsigned char symbol
Definition: api.h:2
#define CAPACITY(p)
Definition: header.h:13
#define SET_SIZE(p, n)
Definition: header.h:12
const void size_t len
symbol * p
Definition: api.h:15
int l
Definition: api.h:16
static symbol * increase_size(symbol *p, int n)
Definition: utilities.c:355

References CAPACITY, increase_size(), SN_env::l, len, SN_env::p, and SET_SIZE.

◆ create_s()

symbol* create_s ( void  )

Definition at line 5 of file utilities.c.

5  {
6  symbol * p;
7  void * mem = malloc(HEAD + (CREATE_SIZE + 1) * sizeof(symbol));
8  if (mem == NULL) return NULL;
9  p = (symbol *) (HEAD + (char *) mem);
10  CAPACITY(p) = CREATE_SIZE;
11  SET_SIZE(p, 0);
12  return p;
13 }
#define malloc(a)
Definition: header.h:50
#define HEAD
Definition: header.h:9
#define CREATE_SIZE
Definition: utilities.c:3

References CAPACITY, CREATE_SIZE, HEAD, malloc, and SET_SIZE.

Referenced by replace_s(), and SN_create_env().

◆ debug()

void debug ( struct SN_env z,
int  number,
int  line_count 
)

◆ eq_s()

int eq_s ( struct SN_env z,
int  s_size,
const symbol s 
)

Definition at line 215 of file utilities.c.

215  {
216  if (z->l - z->c < s_size || memcmp(z->p + z->c, s, s_size * sizeof(symbol)) != 0) return 0;
217  z->c += s_size; return 1;
218 }
int c
Definition: api.h:16

References SN_env::c, SN_env::l, and SN_env::p.

Referenced by eq_v(), r_fix_va_start(), r_KER(), r_mark_regions(), r_Prefix_Step2(), r_prelude(), r_remove_pronoun_prefixes(), r_remove_question_prefixes(), and russian_UTF_8_stem().

◆ eq_s_b()

◆ eq_v()

int eq_v ( struct SN_env z,
const symbol p 
)

Definition at line 225 of file utilities.c.

225  {
226  return eq_s(z, SIZE(p), p);
227 }
#define SIZE(p)
Definition: header.h:11
int eq_s(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.c:215

References eq_s(), and SIZE.

◆ eq_v_b()

int eq_v_b ( struct SN_env z,
const symbol p 
)

Definition at line 229 of file utilities.c.

229  {
230  return eq_s_b(z, SIZE(p), p);
231 }
int eq_s_b(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.c:220

References eq_s_b(), and SIZE.

Referenced by r_tidy(), and r_undouble().

◆ find_among()

int find_among ( struct SN_env z,
const struct among v,
int  v_size 
)

Definition at line 233 of file utilities.c.

233  {
234 
235  int i = 0;
236  int j = v_size;
237 
238  int c = z->c; int l = z->l;
239  const symbol * q = z->p + c;
240 
241  const struct among * w;
242 
243  int common_i = 0;
244  int common_j = 0;
245 
246  int first_key_inspected = 0;
247 
248  while (1) {
249  int k = i + ((j - i) >> 1);
250  int diff = 0;
251  int common = common_i < common_j ? common_i : common_j; /* smaller */
252  w = v + k;
253  {
254  int i2; for (i2 = common; i2 < w->s_size; i2++) {
255  if (c + common == l) { diff = -1; break; }
256  diff = q[common] - w->s[i2];
257  if (diff != 0) break;
258  common++;
259  }
260  }
261  if (diff < 0) {
262  j = k;
263  common_j = common;
264  } else {
265  i = k;
266  common_i = common;
267  }
268  if (j - i <= 1) {
269  if (i > 0) break; /* v->s has been inspected */
270  if (j == i) break; /* only one item in v */
271 
272  /* - but now we need to go round once more to get
273  v->s inspected. This looks messy, but is actually
274  the optimal approach. */
275 
276  if (first_key_inspected) break;
277  first_key_inspected = 1;
278  }
279  }
280  while (1) {
281  w = v + i;
282  if (common_i >= w->s_size) {
283  z->c = c + w->s_size;
284  if (w->function == 0) return w->result;
285  {
286  int res = w->function(z);
287  z->c = c + w->s_size;
288  if (res) return w->result;
289  }
290  }
291  i = w->substring_i;
292  if (i < 0) return 0;
293  }
294 }
int j
Definition: isn.c:73
int i
Definition: isn.c:72
char * c
Definition: header.h:16
int result
Definition: header.h:19
int substring_i
Definition: header.h:18
int s_size
Definition: header.h:16
const symbol * s
Definition: header.h:17
int(* function)(struct SN_env *)
Definition: header.h:20

References SN_env::c, among::function, i, j, SN_env::l, SN_env::p, res, among::result, among::s, among::s_size, and among::substring_i.

Referenced by r_Checks1(), r_cleaning(), r_cyr_to_lat(), r_exception1(), r_initial_morph(), r_mark_regions(), r_Normalize_post(), r_Normalize_pre(), r_postlude(), r_Prefix_Step1(), r_Prefix_Step2(), r_Prefix_Step3_Verb(), r_Prefix_Step3a_Noun(), r_Prefix_Step3b_Noun(), r_Prefix_Step4_Verb(), r_prelude(), r_remove_first_order_prefix(), r_remove_pronoun_prefixes(), r_remove_question_prefixes(), and r_remove_second_order_prefix().

◆ find_among_b()

int find_among_b ( struct SN_env z,
const struct among v,
int  v_size 
)

Definition at line 298 of file utilities.c.

298  {
299 
300  int i = 0;
301  int j = v_size;
302 
303  int c = z->c; int lb = z->lb;
304  const symbol * q = z->p + c - 1;
305 
306  const struct among * w;
307 
308  int common_i = 0;
309  int common_j = 0;
310 
311  int first_key_inspected = 0;
312 
313  while (1) {
314  int k = i + ((j - i) >> 1);
315  int diff = 0;
316  int common = common_i < common_j ? common_i : common_j;
317  w = v + k;
318  {
319  int i2; for (i2 = w->s_size - 1 - common; i2 >= 0; i2--) {
320  if (c - common == lb) { diff = -1; break; }
321  diff = q[- common] - w->s[i2];
322  if (diff != 0) break;
323  common++;
324  }
325  }
326  if (diff < 0) { j = k; common_j = common; }
327  else { i = k; common_i = common; }
328  if (j - i <= 1) {
329  if (i > 0) break;
330  if (j == i) break;
331  if (first_key_inspected) break;
332  first_key_inspected = 1;
333  }
334  }
335  while (1) {
336  w = v + i;
337  if (common_i >= w->s_size) {
338  z->c = c - w->s_size;
339  if (w->function == 0) return w->result;
340  {
341  int res = w->function(z);
342  z->c = c - w->s_size;
343  if (res) return w->result;
344  }
345  }
346  i = w->substring_i;
347  if (i < 0) return 0;
348  }
349 }

References SN_env::c, among::function, i, j, SN_env::lb, SN_env::p, res, among::result, among::s, among::s_size, and among::substring_i.

Referenced by hindi_UTF_8_stem(), r_aditzak(), r_adjectival(), r_adjective(), r_adjetiboak(), r_attached_pronoun(), r_case(), r_case_ending(), r_case_other(), r_case_special(), r_check_category_2(), r_combo_suffix(), r_consonant_pair(), r_deriv(), r_derivational(), r_double(), r_ending(), r_exception2(), r_factive(), r_fix_chdz(), r_fix_conflicts(), r_fix_ending(), r_fix_gd(), r_i_plural(), r_i_verb_suffix(), r_instrum(), r_izenak(), r_LONG(), r_main_suffix(), r_mark_cAsInA(), r_mark_DA(), r_mark_DAn(), r_mark_DUr(), r_mark_lAr(), r_mark_lArI(), r_mark_nA(), r_mark_ncA(), r_mark_ndA(), r_mark_ndAn(), r_mark_nU(), r_mark_nUn(), r_mark_nUz(), r_mark_possessives(), r_mark_sUn(), r_mark_sUnUz(), r_mark_yA(), r_mark_yDU(), r_mark_ylA(), r_mark_ymUs_(), r_mark_ysA(), r_mark_yUm(), r_mark_yUz(), r_Normalize_post(), r_noun(), r_noun_sfx(), r_other_endings(), r_other_suffix(), r_owned(), r_particle_etc(), r_perfective_gerund(), r_plur_owner(), r_plural(), r_possessive(), r_post_process_last_consonants(), r_reflexive(), r_remove_category_1(), r_remove_category_2(), r_remove_category_3(), r_remove_command_suffixes(), r_remove_common_word_endings(), r_remove_particle(), r_remove_plural_suffix(), r_remove_possessive_pronoun(), r_remove_question_suffixes(), r_remove_suffix(), r_remove_tense_suffix(), r_remove_vetrumai_urupukal(), r_residual_form(), r_residual_suffix(), r_sing_owner(), r_standard_suffix(), r_step1(), r_step2(), r_step2a(), r_step2b(), r_step2c(), r_step2d(), r_step3(), r_step4(), r_step5a(), r_step5b(), r_step5c(), r_step5d(), r_step5e(), r_step5f(), r_step5g(), r_step5h(), r_step5i(), r_step5j(), r_step5k(), r_step5l(), r_step5m(), r_step6(), r_step7(), r_step_0(), r_Step_1(), r_Step_1a(), r_Step_1b(), r_Step_2(), r_Step_3(), r_Step_4(), r_Step_5(), r_steps1(), r_steps10(), r_steps2(), r_steps3(), r_steps4(), r_steps5(), r_steps6(), r_steps7(), r_steps8(), r_steps9(), r_Suffix_All_alef_maqsura(), r_Suffix_Noun_Step1a(), r_Suffix_Noun_Step1b(), r_Suffix_Noun_Step2a(), r_Suffix_Noun_Step2b(), r_Suffix_Noun_Step2c1(), r_Suffix_Noun_Step2c2(), r_Suffix_Noun_Step3(), r_Suffix_Verb_Step1(), r_Suffix_Verb_Step2a(), r_Suffix_Verb_Step2b(), r_Suffix_Verb_Step2c(), r_t_plural(), r_tidy_up(), r_tolower(), r_un_double(), r_undouble(), r_v_ending(), r_verb(), r_verb_sfx(), r_verb_suffix(), r_vowel_suffix(), and r_y_verb_suffix().

◆ in_grouping()

int in_grouping ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 167 of file utilities.c.

167  {
168  do {
169  int ch;
170  if (z->c >= z->l) return -1;
171  ch = z->p[z->c];
172  if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0)
173  return 1;
174  z->c++;
175  } while (repeat);
176  return 0;
177 }
Datum repeat(PG_FUNCTION_ARGS)

References SN_env::c, SN_env::l, SN_env::p, and repeat().

Referenced by porter_ISO_8859_1_stem(), r_mark_regions(), r_prelude(), r_remove_first_order_prefix(), and r_VOWEL().

◆ in_grouping_b()

int in_grouping_b ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 179 of file utilities.c.

179  {
180  do {
181  int ch;
182  if (z->c <= z->lb) return -1;
183  ch = z->p[z->c - 1];
184  if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0)
185  return 1;
186  z->c--;
187  } while (repeat);
188  return 0;
189 }

References SN_env::c, SN_env::lb, SN_env::p, and repeat().

Referenced by r_case_ending(), r_main_suffix(), r_particle_etc(), r_shortv(), r_standard_suffix(), r_Step_2(), r_t_plural(), r_tidy(), r_undouble(), r_VI(), and r_vowel_suffix().

◆ in_grouping_b_U()

int in_grouping_b_U ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 129 of file utilities.c.

129  {
130  do {
131  int ch;
132  int w = get_b_utf8(z->p, z->c, z->lb, & ch);
133  if (!w) return -1;
134  if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0)
135  return w;
136  z->c -= w;
137  } while (repeat);
138  return 0;
139 }
static int get_b_utf8(const symbol *p, int c, int lb, int *slot)
Definition: utilities.c:93

References SN_env::c, get_b_utf8(), SN_env::lb, SN_env::p, and repeat().

Referenced by r_case_ending(), r_CONSONANT(), r_main_suffix(), r_mark_sU(), r_mark_suffix_with_optional_n_consonant(), r_mark_suffix_with_optional_s_consonant(), r_mark_suffix_with_optional_U_vowel(), r_mark_suffix_with_optional_y_consonant(), r_mark_yU(), r_particle_etc(), r_shortv(), r_standard_suffix(), r_step3(), r_step4(), r_step5b(), r_step5c(), r_Step_2(), r_t_plural(), r_tidy(), r_undouble(), r_VI(), and r_vowel_suffix().

◆ in_grouping_U()

int in_grouping_U ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 117 of file utilities.c.

117  {
118  do {
119  int ch;
120  int w = get_utf8(z->p, z->c, z->l, & ch);
121  if (!w) return -1;
122  if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0)
123  return w;
124  z->c += w;
125  } while (repeat);
126  return 0;
127 }
static int get_utf8(const symbol *p, int c, int l, int *slot)
Definition: utilities.c:71

References SN_env::c, get_utf8(), SN_env::l, SN_env::p, and repeat().

Referenced by lithuanian_UTF_8_stem(), porter_UTF_8_stem(), r_mark_regions(), r_prelude(), r_remove_first_order_prefix(), and r_VOWEL().

◆ insert_s()

int insert_s ( struct SN_env z,
int  bra,
int  ket,
int  s_size,
const symbol s 
)

Definition at line 435 of file utilities.c.

435  {
436  int adjustment;
437  if (replace_s(z, bra, ket, s_size, s, &adjustment))
438  return -1;
439  if (bra <= z->bra) z->bra += adjustment;
440  if (bra <= z->ket) z->ket += adjustment;
441  return 0;
442 }
int ket
Definition: api.h:16
int bra
Definition: api.h:16
int replace_s(struct SN_env *z, int c_bra, int c_ket, int s_size, const symbol *s, int *adjptr)
Definition: utilities.c:374

References SN_env::bra, SN_env::ket, replace_s(), among::s, and among::s_size.

Referenced by insert_v(), r_append_U_to_stems_ending_with_d_or_g(), r_step2a(), and r_Step_1b().

◆ insert_v()

int insert_v ( struct SN_env z,
int  bra,
int  ket,
const symbol p 
)

Definition at line 444 of file utilities.c.

444  {
445  return insert_s(z, bra, ket, SIZE(p), p);
446 }
int insert_s(struct SN_env *z, int bra, int ket, int s_size, const symbol *s)
Definition: utilities.c:435

References insert_s(), and SIZE.

◆ len_utf8()

◆ lose_s()

void lose_s ( symbol p)

Definition at line 15 of file utilities.c.

15  {
16  if (p == NULL) return;
17  free((char *) p - HEAD);
18 }
#define free(a)
Definition: header.h:65

References free, and HEAD.

Referenced by increase_size(), slice_to(), and SN_close_env().

◆ out_grouping()

int out_grouping ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 191 of file utilities.c.

191  {
192  do {
193  int ch;
194  if (z->c >= z->l) return -1;
195  ch = z->p[z->c];
196  if (!(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0))
197  return 1;
198  z->c++;
199  } while (repeat);
200  return 0;
201 }

References SN_env::c, SN_env::l, SN_env::p, and repeat().

Referenced by indonesian_ISO_8859_1_stem(), porter_ISO_8859_1_stem(), r_KER(), and r_mark_regions().

◆ out_grouping_b()

int out_grouping_b ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 203 of file utilities.c.

203  {
204  do {
205  int ch;
206  if (z->c <= z->lb) return -1;
207  ch = z->p[z->c - 1];
208  if (!(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0))
209  return 1;
210  z->c--;
211  } while (repeat);
212  return 0;
213 }

References SN_env::c, SN_env::lb, SN_env::p, and repeat().

Referenced by r_e_ending(), r_en_ending(), r_i_verb_suffix(), r_main_suffix(), r_residual_suffix(), r_shortv(), r_standard_suffix(), r_Step_1a(), r_Step_1b(), r_Step_1c(), r_un_accent(), and r_verb_suffix().

◆ out_grouping_b_U()

int out_grouping_b_U ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 153 of file utilities.c.

153  {
154  do {
155  int ch;
156  int w = get_b_utf8(z->p, z->c, z->lb, & ch);
157  if (!w) return -1;
158  if (!(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0))
159  return w;
160  z->c -= w;
161  } while (repeat);
162  return 0;
163 }

References SN_env::c, get_b_utf8(), SN_env::lb, SN_env::p, and repeat().

Referenced by r_append_U_to_stems_ending_with_d_or_g(), r_check_vowel_harmony(), r_e_ending(), r_en_ending(), r_i_verb_suffix(), r_main_suffix(), r_mark_suffix_with_optional_U_vowel(), r_residual_suffix(), r_shortv(), r_standard_suffix(), r_Step_1a(), r_Step_1b(), r_Step_1c(), r_un_accent(), and r_verb_suffix().

◆ out_grouping_U()

int out_grouping_U ( struct SN_env z,
const unsigned char *  s,
int  min,
int  max,
int  repeat 
)

Definition at line 141 of file utilities.c.

141  {
142  do {
143  int ch;
144  int w = get_utf8(z->p, z->c, z->l, & ch);
145  if (!w) return -1;
146  if (!(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0))
147  return w;
148  z->c += w;
149  } while (repeat);
150  return 0;
151 }

References SN_env::c, get_utf8(), SN_env::l, SN_env::p, and repeat().

Referenced by indonesian_UTF_8_stem(), lithuanian_UTF_8_stem(), porter_UTF_8_stem(), r_KER(), r_mark_regions(), and r_more_than_one_syllable_word().

◆ replace_s()

int replace_s ( struct SN_env z,
int  c_bra,
int  c_ket,
int  s_size,
const symbol s,
int *  adjptr 
)

Definition at line 374 of file utilities.c.

375 {
376  int adjustment;
377  int len;
378  if (z->p == NULL) {
379  z->p = create_s();
380  if (z->p == NULL) return -1;
381  }
382  adjustment = s_size - (c_ket - c_bra);
383  len = SIZE(z->p);
384  if (adjustment != 0) {
385  if (adjustment + len > CAPACITY(z->p)) {
386  z->p = increase_size(z->p, adjustment + len);
387  if (z->p == NULL) return -1;
388  }
389  memmove(z->p + c_ket + adjustment,
390  z->p + c_ket,
391  (len - c_ket) * sizeof(symbol));
392  SET_SIZE(z->p, adjustment + len);
393  z->l += adjustment;
394  if (z->c >= c_ket)
395  z->c += adjustment;
396  else if (z->c > c_bra)
397  z->c = c_bra;
398  }
399  if (s_size) memmove(z->p + c_bra, s, s_size * sizeof(symbol));
400  if (adjptr != NULL)
401  *adjptr = adjustment;
402  return 0;
403 }
symbol * create_s(void)
Definition: utilities.c:5

References SN_env::c, CAPACITY, create_s(), increase_size(), SN_env::l, len, SN_env::p, among::s, among::s_size, SET_SIZE, and SIZE.

Referenced by insert_s(), slice_from_s(), and SN_set_current().

◆ skip_b_utf8()

int skip_b_utf8 ( const symbol p,
int  c,
int  limit,
int  n 
)

Definition at line 52 of file utilities.c.

52  {
53  int b;
54  if (n < 0) return -1;
55  for (; n > 0; n--) {
56  if (c <= limit) return -1;
57  b = p[--c];
58  if (b >= 0x80) { /* 1000 0000 */
59  while (c > limit) {
60  b = p[c];
61  if (b >= 0xC0) break; /* 1100 0000 */
62  c--;
63  }
64  }
65  }
66  return c;
67 }

References b.

Referenced by arabic_UTF_8_stem(), r_case_ending(), r_consonant_pair(), r_mark_suffix_with_optional_n_consonant(), r_mark_suffix_with_optional_s_consonant(), r_mark_suffix_with_optional_U_vowel(), r_mark_suffix_with_optional_y_consonant(), r_standard_suffix(), r_Step_1a(), r_Step_1b(), r_tidy(), r_tolower(), r_un_double(), and r_undouble().

◆ skip_utf8()

int skip_utf8 ( const symbol p,
int  c,
int  limit,
int  n 
)

Definition at line 27 of file utilities.c.

27  {
28  int b;
29  if (n < 0) return -1;
30  for (; n > 0; n--) {
31  if (c >= limit) return -1;
32  b = p[c++];
33  if (b >= 0xC0) { /* 1100 0000 */
34  while (c < limit) {
35  b = p[c];
36  if (b >= 0xC0 || b < 0x80) break;
37  /* break unless b is 10------ */
38  c++;
39  }
40  }
41  }
42  return c;
43 }

References b.

Referenced by english_UTF_8_stem(), hindi_UTF_8_stem(), lithuanian_UTF_8_stem(), porter_UTF_8_stem(), r_cleaning(), r_cyr_to_lat(), r_mark_regions(), r_Normalize_post(), r_Normalize_pre(), r_postlude(), r_prelude(), and russian_UTF_8_stem().

◆ slice_del()

int slice_del ( struct SN_env z)

Definition at line 431 of file utilities.c.

431  {
432  return slice_from_s(z, 0, 0);
433 }
int slice_from_s(struct SN_env *z, int s_size, const symbol *s)
Definition: utilities.c:422

References slice_from_s().

Referenced by hindi_UTF_8_stem(), portuguese_ISO_8859_1_stem(), portuguese_UTF_8_stem(), r_aditzak(), r_adjectival(), r_adjective(), r_adjetiboak(), r_attached_pronoun(), r_case(), r_case_ending(), r_case_other(), r_consonant_pair(), r_deriv(), r_derivational(), r_e_ending(), r_en_ending(), r_ending(), r_factive(), r_fix_ending(), r_i_plural(), r_i_verb_suffix(), r_initial_morph(), r_instrum(), r_izenak(), r_main_suffix(), r_Normalize_pre(), r_noun(), r_noun_sfx(), r_other_endings(), r_other_suffix(), r_owned(), r_particle_etc(), r_perfective_gerund(), r_plur_owner(), r_plural(), r_possessive(), r_postlude(), r_Prefix_Step2(), r_Prefix_Step3a_Noun(), r_Prefix_Step3b_Noun(), r_prelude(), r_reflexive(), r_remove_category_1(), r_remove_category_2(), r_remove_category_3(), r_remove_command_suffixes(), r_remove_common_word_endings(), r_remove_first_order_prefix(), r_remove_particle(), r_remove_plural_suffix(), r_remove_possessive_pronoun(), r_remove_pronoun_prefixes(), r_remove_question_prefixes(), r_remove_second_order_prefix(), r_remove_suffix(), r_remove_tense_suffix(), r_remove_vetrumai_urupukal(), r_residual_form(), r_residual_suffix(), r_sing_owner(), r_standard_suffix(), r_stem_nominal_verb_suffixes(), r_stem_noun_suffixes(), r_stem_suffix_chain_before_ki(), r_step1(), r_step2(), r_step2a(), r_step2b(), r_step2c(), r_step2d(), r_step3(), r_step4(), r_step5a(), r_step5b(), r_step5c(), r_step5d(), r_step5e(), r_step5f(), r_step5g(), r_step5h(), r_step5i(), r_step5j(), r_step5k(), r_step5l(), r_step5m(), r_step6(), r_step7(), r_step_0(), r_Step_1a(), r_Step_1b(), r_Step_2(), r_Step_3(), r_Step_4(), r_Step_5(), r_Step_5a(), r_Step_5b(), r_steps1(), r_steps10(), r_steps2(), r_steps3(), r_steps4(), r_steps5(), r_steps6(), r_steps7(), r_steps8(), r_steps9(), r_Suffix_Noun_Step1a(), r_Suffix_Noun_Step1b(), r_Suffix_Noun_Step2a(), r_Suffix_Noun_Step2b(), r_Suffix_Noun_Step2c1(), r_Suffix_Noun_Step2c2(), r_Suffix_Noun_Step3(), r_Suffix_Verb_Step1(), r_Suffix_Verb_Step2a(), r_Suffix_Verb_Step2b(), r_Suffix_Verb_Step2c(), r_t_plural(), r_tidy(), r_tidy_up(), r_un_double(), r_undouble(), r_verb(), r_verb_sfx(), r_verb_suffix(), r_vowel_suffix(), r_y_verb_suffix(), russian_KOI8_R_stem(), and russian_UTF_8_stem().

◆ slice_from_s()

int slice_from_s ( struct SN_env z,
int  s_size,
const symbol s 
)

Definition at line 422 of file utilities.c.

422  {
423  if (slice_check(z)) return -1;
424  return replace_s(z, z->bra, z->ket, s_size, s, NULL);
425 }
static int slice_check(struct SN_env *z)
Definition: utilities.c:405

References SN_env::bra, SN_env::ket, replace_s(), among::s, among::s_size, and slice_check().

Referenced by french_ISO_8859_1_stem(), french_UTF_8_stem(), porter_ISO_8859_1_stem(), porter_UTF_8_stem(), r_aditzak(), r_adjetiboak(), r_attached_pronoun(), r_case_other(), r_case_special(), r_cleaning(), r_combo_suffix(), r_cyr_to_lat(), r_deriv(), r_exception1(), r_fix_chdz(), r_fix_conflicts(), r_fix_ending(), r_fix_gd(), r_fix_va_start(), r_initial_morph(), r_izenak(), r_main_suffix(), r_mark_regions(), r_Normalize_post(), r_Normalize_pre(), r_other_suffix(), r_owned(), r_plur_owner(), r_plural(), r_possessive(), r_post_process_last_consonants(), r_postlude(), r_Prefix_Step1(), r_Prefix_Step3_Verb(), r_Prefix_Step3b_Noun(), r_Prefix_Step4_Verb(), r_prelude(), r_remove_common_word_endings(), r_remove_first_order_prefix(), r_remove_plural_suffix(), r_remove_question_suffixes(), r_remove_second_order_prefix(), r_remove_tense_suffix(), r_remove_um(), r_remove_vetrumai_urupukal(), r_residual_form(), r_residual_suffix(), r_sing_owner(), r_standard_suffix(), r_step1(), r_step2b(), r_step2c(), r_step2d(), r_step3(), r_step4(), r_step5a(), r_step5b(), r_step5c(), r_step5d(), r_step5e(), r_step5f(), r_step5g(), r_step5h(), r_step5i(), r_step5j(), r_step5k(), r_step5l(), r_step5m(), r_step6(), r_step_0(), r_Step_1(), r_Step_1a(), r_Step_1b(), r_Step_1c(), r_Step_2(), r_Step_3(), r_steps1(), r_steps10(), r_steps2(), r_steps3(), r_steps4(), r_steps5(), r_steps6(), r_steps7(), r_steps8(), r_steps9(), r_Suffix_All_alef_maqsura(), r_tolower(), r_un_accent(), r_v_ending(), russian_KOI8_R_stem(), russian_UTF_8_stem(), slice_del(), and slice_from_v().

◆ slice_from_v()

int slice_from_v ( struct SN_env z,
const symbol p 
)

Definition at line 427 of file utilities.c.

427  {
428  return slice_from_s(z, SIZE(p), p);
429 }

References SIZE, and slice_from_s().

◆ slice_to()

symbol* slice_to ( struct SN_env z,
symbol p 
)

Definition at line 448 of file utilities.c.

448  {
449  if (slice_check(z)) {
450  lose_s(p);
451  return NULL;
452  }
453  {
454  int len = z->ket - z->bra;
455  if (CAPACITY(p) < len) {
456  p = increase_size(p, len);
457  if (p == NULL)
458  return NULL;
459  }
460  memmove(p, z->p + z->bra, len * sizeof(symbol));
461  SET_SIZE(p, len);
462  }
463  return p;
464 }
void lose_s(symbol *p)
Definition: utilities.c:15

References SN_env::bra, CAPACITY, increase_size(), SN_env::ket, len, lose_s(), SN_env::p, SET_SIZE, and slice_check().

Referenced by r_tidy(), and r_undouble().