Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

ffstring.c File Reference

Implements the operations (declared in ffstring.h) related to the ffstring string data type. More...

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include "ffstring.h"

Go to the source code of this file.

Functions

ffint32 ffstring_create (const ffchar *source, ffstring *target)
 Creates a new ffstring from a C-style string.
ffint32 ffstring_delete (ffstring *target)
 Deletes an ffstring.
ffint32 ffstring_copy (const ffstring *source, ffstring *target)
 Creates a copy of an ffstring.
ffint32 ffstring_move_and_delete (ffstring *source, ffstring *target)
ffint32 ffstring_dfe (ffstring *target, ffuint32 count)
 Deletes count characters from the end of the target string.
ffint32 ffstring_rfe (ffstring *target, ffuint32 count, char *append)
ffint32 ffstring_rfe_ff (ffstring *target, ffuint32 count, const ffstring *append)
 Replaces the last count characters from the end of the target string with the ffstring append.
ffint32 ffstring_append (ffstring *target, char *append)
ffint32 ffstring_append_ff (ffstring *target, const ffstring *source)
 Append a ffstring to the target ffstring.
ffint32 ffstring_instcount ()
 Returns the current number of ffstring instances.
ffint32 ffstring_tail (const ffstring *source, ffint32 count, ffstring *target)
 Creates a new ffstring from at most count characters (not including the terminating null byte) from the head of the source ffstring.
ffint32 ffstring_tolower (ffstring *target)
 Converts a ffstring to lowercase.
ffint32 ffstring_lower (const ffstring *source, ffstring *target)
 Creates a lowercase copy of an ffstring.
ffint32 ffstring_compare (const ffstring *left, const ffchar *right)
 Case-sensitively compares an ffstring to a C-style string using strcmp(3).
ffint32 ffstring_compare_ci (const ffstring *left, const ffchar *right)
 Case-insensitively compares an ffstring to a C-style string using tolower(3) and strcmp(3).
ffint32 ffstring_compare_ff (const ffstring *left, const ffstring *right)
 Case-sensitively compares an ffstring to another using strcmp(3).
ffint32 ffstring_compare_ff_ci (const ffstring *left, const ffstring *right)
 Case-insensitively compares an ffstring to another string using tolower(3) and strcmp(3).
ffint32 ffstring_decinst ()
 Decreases the ffstring instance counter.
ffint32 ffstring_compare_tail (const ffstring *left, ffuint32 count, const ffchar *right)
 Case-sensitively compares the specified number of last characters of the given ffstring to a C-style string.
ffint32 ffstring_compare_tail_ci (const ffstring *left, ffuint32 count, const ffchar *right)
 Case-insensitively compares the specified number of last characters of the given ffstring to a C-style string.
ffint32 ffstring_compare_tail_ff (const ffstring *left, ffuint32 count, const ffstring *right)
 Case-sensitively compares the specified number of last characters of the given ffstring to another ffstring.
ffint32 ffstring_compare_tail_ff_ci (const ffstring *left, ffuint32 count, const ffstring *right)
 Case-insensitively compares the specified number of last characters of the given ffstring to another ffstring.
ffchar ffstring_last (const ffstring *source)
 Returns the last character of the given ffstring.
ffint32 ffstring_compare_last (const ffstring *left, const ffchar right)
 Case-sensitively compares the last character of the given ffstring to a given character.
ffint32 ffstring_compare_last_ci (const ffstring *left, const ffchar right)
 Case-insensitively compares the last character of the given ffstring to a given character.
ffbool ffstring_equals (const ffstring *left, const ffchar *right)
 Checks if the given ffstring and C-style string are the same.
ffbool ffstring_equals_ci (const ffstring *left, const ffchar *right)
 Case-insensitively checks if the given ffstring and C-style string are the same.
ffbool ffstring_equals_ff (const ffstring *left, const ffstring *right)
 Checks if the two given ffstrings are the same.
ffbool ffstring_equals_ff_ci (const ffstring *left, const ffstring *right)
 Case-insensitively checks if the two given ffstrings are the same.
ffbool ffstring_tail_equals (const ffstring *left, const ffint32 count, const ffchar *right)
 Checks if the tail of the given ffstring is the same as the given C-style string.
ffbool ffstring_tail_equals_ci (const ffstring *left, const ffint32 count, const ffchar *right)
 Case-insensitively checks if the tail of the given ffstring is the same as the given C-style string.
ffbool ffstring_tail_equals_ff (const ffstring *left, const ffint32 count, const ffstring *right)
 Checks if the tail of the given ffstring equals the other given ffstring.
ffbool ffstring_tail_equals_ff_ci (const ffstring *left, const ffint32 count, const ffstring *right)
 Case-insensitively checks if the tail of the given ffstring equals the other given ffstring.
ffbool ffstring_last_equals (const ffstring *left, ffchar right)
 Checks if the last character of the given string matches the given character.
ffbool ffstring_last_equals_ci (const ffstring *left, ffchar right)
 Case-insensitively checks if the last character of the given string matches the given character.

Variables

static ffint32 _ffstring_instance_counter = 0


Detailed Description

Implements the operations (declared in ffstring.h) related to the ffstring string data type.

Definition in file ffstring.c.


Function Documentation

ffint32 ffstring_append ffstring target,
char *  append
 

Definition at line 160 of file ffstring.c.

Referenced by ffpriv_abessive_plural(), ffpriv_abessive_singular(), ffpriv_ablative_plural(), ffpriv_ablative_singular(), ffpriv_adessive_plural(), ffpriv_adessive_singular(), ffpriv_allative_plural(), ffpriv_allative_singular(), ffpriv_comitative_plural(), ffpriv_elative_plural(), ffpriv_elative_singular(), ffpriv_essive_plural(), ffpriv_essive_singular(), ffpriv_general_illative(), ffpriv_genitive_plural(), ffpriv_genitive_singular(), ffpriv_genitive_stem(), ffpriv_inessive_plural(), ffpriv_inessive_singular(), ffpriv_instructive_plural(), ffpriv_instructive_singular(), ffpriv_nominative_plural(), ffpriv_partitive_plural(), ffpriv_partitive_singular(), ffpriv_partitive_stem(), ffpriv_plural_stem(), ffpriv_translative_plural(), ffpriv_translative_singular(), ffstring_append_ff(), and main().

ffint32 ffstring_append_ff ffstring target,
const ffstring source
 

Append a ffstring to the target ffstring.

Todo:
We already know the length of the source ffstring, so why not create an optimized version?

Definition at line 181 of file ffstring.c.

References ffstring_append().

ffint32 ffstring_compare const ffstring left,
const ffchar right
 

Case-sensitively compares an ffstring to a C-style string using strcmp(3).

Parameters:
left The first string
right The second string
Returns:
below zero if left < right, 0 if left == right, above zero if left > right

Definition at line 221 of file ffstring.c.

Referenced by ffpriv_ie_list_get(), ffpriv_ss_genitive(), ffstring_compare_tail(), and ffstring_equals().

ffint32 ffstring_compare_ci const ffstring left,
const ffchar right
 

Case-insensitively compares an ffstring to a C-style string using tolower(3) and strcmp(3).

Parameters:
left The first string
right The second string
Returns:
below zero if left < right, 0 if left == right, above zero if left > right

Definition at line 226 of file ffstring.c.

Referenced by ffpriv_genitive_stem(), ffstring_compare_tail_ci(), and ffstring_equals_ci().

ffint32 ffstring_compare_ff const ffstring left,
const ffstring right
 

Case-sensitively compares an ffstring to another using strcmp(3).

Parameters:
left The first string
right The second string
Returns:
below zero if left < right, 0 if left == right, above zero if left > right

Definition at line 231 of file ffstring.c.

Referenced by ffstring_compare_tail_ff(), ffstring_equals_ff(), and main().

ffint32 ffstring_compare_ff_ci const ffstring left,
const ffstring right
 

Case-insensitively compares an ffstring to another string using tolower(3) and strcmp(3).

Parameters:
left The first string
right The second string
Returns:
below zero if left < right, 0 if left == right, above zero if left > right

Definition at line 236 of file ffstring.c.

Referenced by ffstring_compare_tail_ff_ci(), ffstring_equals_ff_ci(), and main().

ffint32 ffstring_compare_last const ffstring left,
const ffchar  right
 

Case-sensitively compares the last character of the given ffstring to a given character.

Todo:
Umlauts

Definition at line 307 of file ffstring.c.

References ffstring_last().

Referenced by ffstring_last_equals().

ffint32 ffstring_compare_last_ci const ffstring left,
const ffchar  right
 

Case-insensitively compares the last character of the given ffstring to a given character.

Todo:
Umlauts

Definition at line 322 of file ffstring.c.

References ffstring_last().

Referenced by ffstring_last_equals_ci().

ffint32 ffstring_compare_tail const ffstring left,
ffuint32  count,
const ffchar right
 

Case-sensitively compares the specified number of last characters of the given ffstring to a C-style string.

Parameters:
left The string whose tail we're going to compare
count The number of characters to compare
right The C-style string to compare to
Returns:
below zero if the extracted tail < right, 0 if they're the same, above zero otherwise

Definition at line 251 of file ffstring.c.

References ffstring_compare(), ffstring_delete(), and ffstring_tail().

Referenced by ffpriv_genitive_plural(), and ffstring_tail_equals().

ffint32 ffstring_compare_tail_ci const ffstring left,
ffuint32  count,
const ffchar right
 

Case-insensitively compares the specified number of last characters of the given ffstring to a C-style string.

Parameters:
left The string whose tail we're going to compare
count The number of characters to compare
right The C-style string to compare to
Returns:
below zero if the extracted tail < right, 0 if they're the same, above zero otherwise

Definition at line 263 of file ffstring.c.

References ffstring_compare_ci(), ffstring_delete(), and ffstring_tail().

Referenced by ffpriv_genitive_stem(), and ffstring_tail_equals_ci().

ffint32 ffstring_compare_tail_ff const ffstring left,
ffuint32  count,
const ffstring right
 

Case-sensitively compares the specified number of last characters of the given ffstring to another ffstring.

Parameters:
left The string whose tail we're going to compare
count The number of characters to compare
right The ffstring to compare to
Returns:
below zero if the extracted tail < right, 0 if they're the same, above zero otherwise

Definition at line 275 of file ffstring.c.

References ffstring_compare_ff(), ffstring_delete(), and ffstring_tail().

Referenced by ffstring_tail_equals_ff().

ffint32 ffstring_compare_tail_ff_ci const ffstring left,
ffuint32  count,
const ffstring right
 

Case-insensitively compares the specified number of last characters of the given ffstring to another ffstring.

Parameters:
left The string whose tail we're going to compare
count The number of characters to compare
right The ffstring to compare to
Returns:
below zero if the extracted tail < right, 0 if they're the same, above zero otherwise

Definition at line 287 of file ffstring.c.

References ffstring_compare_ff_ci(), ffstring_delete(), and ffstring_tail().

Referenced by ffstring_tail_equals_ff_ci().

ffint32 ffstring_copy const ffstring source,
ffstring target
 

Creates a copy of an ffstring.

The caller should take care of disposing of it.

Parameters:
source String to be copied
target Pointer to uninitialized ffstring.
Returns:
0 on success or the error number returned by ffstring_create.

Definition at line 71 of file ffstring.c.

References ffstring_create().

Referenced by ffpriv_essive_stem(), ffpriv_general_illative(), ffpriv_partitive_plural(), ffpriv_plural_stem(), ffstring_move_and_delete(), ffword_copy(), and main().

ffint32 ffstring_create const ffchar source,
ffstring target
 

Creates a new ffstring from a C-style string.

Parameters:
source The default content for the new ffstring. Must be a valid C-style string.
target Pointer to an uninitialized ffstring.
Returns:
0 on success. -1 on memory error.

Definition at line 42 of file ffstring.c.

References _ffstring_instance_counter.

Referenced by ffpriv_ie_list_get(), ffpriv_ss_genitive(), ffstring_copy(), ffstring_lower(), ffstring_tail(), ffword_create(), and main().

ffint32 ffstring_decinst  ) 
 

Decreases the ffstring instance counter.

This function is meant to be used when an ffstring struct ceases to exist but the real string data (ffstring.str) remains. USE WITH CAUTION!

Returns:
0 on success, -1 if the instance counter would go negative if decreased

Definition at line 241 of file ffstring.c.

References _ffstring_instance_counter.

Referenced by ffword_finalize().

ffint32 ffstring_delete ffstring target  ) 
 

Deletes an ffstring.

Parameters:
target The ffstring to be deleted.
Returns:
0 on success.

Definition at line 61 of file ffstring.c.

References _ffstring_instance_counter.

Referenced by ffpriv_consonant_gradation(), ffpriv_essive_stem(), ffpriv_general_illative(), ffpriv_ie_list_get(), ffpriv_partitive_plural(), ffpriv_plural_stem(), ffpriv_ss_genitive(), ffstring_compare_tail(), ffstring_compare_tail_ci(), ffstring_compare_tail_ff(), ffstring_compare_tail_ff_ci(), ffstring_move_and_delete(), ffword_delete(), ffword_swap_delete(), and main().

ffint32 ffstring_dfe ffstring target,
ffuint32  count
 

Deletes count characters from the end of the target string.

count must smaller or equal to current length or an error is returned. The original data remains unchanged if an error occures. (DFE == Delete From End)

Parameters:
target String from where characters are deleted
count How many characters are deleted
Returns:
0 on success. -1 on memory error. -2 on argument error.

Definition at line 88 of file ffstring.c.

Referenced by ffpriv_genitive_plural(), and main().

ffbool ffstring_equals const ffstring left,
const ffchar right
 

Checks if the given ffstring and C-style string are the same.

Parameters:
left The first string
right The second string
Returns:
1 if the strings are the same; 0 if they're not.

Definition at line 338 of file ffstring.c.

References ffstring_compare().

Referenced by ffpriv_ie_list_get(), and ffpriv_ss_genitive().

ffbool ffstring_equals_ci const ffstring left,
const ffchar right
 

Case-insensitively checks if the given ffstring and C-style string are the same.

Parameters:
left The first string
right The second string
Returns:
1 if the strings are the same; 0 if they're not.

Definition at line 343 of file ffstring.c.

References ffstring_compare_ci().

ffbool ffstring_equals_ff const ffstring left,
const ffstring right
 

Checks if the two given ffstrings are the same.

Parameters:
left The first string
right The second string
Returns:
1 if the strings are the same; 0 if they're not.

Definition at line 348 of file ffstring.c.

References ffstring_compare_ff().

ffbool ffstring_equals_ff_ci const ffstring left,
const ffstring right
 

Case-insensitively checks if the two given ffstrings are the same.

Parameters:
left The first string
right The second string
Returns:
1 if the strings are the same; 0 if they're not.

Definition at line 353 of file ffstring.c.

References ffstring_compare_ff_ci().

ffint32 ffstring_instcount  ) 
 

Returns the current number of ffstring instances.

Returns:
The current number of ffstring instances.

Definition at line 191 of file ffstring.c.

References _ffstring_instance_counter.

Referenced by main().

ffchar ffstring_last const ffstring source  ) 
 

Returns the last character of the given ffstring.

Parameters:
source The source ffstring
Returns:
The last character
Todo:
Wrong description

Definition at line 299 of file ffstring.c.

Referenced by ffpriv_essive_stem(), ffpriv_general_illative(), ffpriv_genitive_stem(), ffpriv_partitive_plural(), ffpriv_partitive_singular(), ffpriv_plural_stem(), ffstring_compare_last(), and ffstring_compare_last_ci().

ffbool ffstring_last_equals const ffstring left,
ffchar  right
 

Checks if the last character of the given string matches the given character.

Parameters:
left The string whose last character we are going to compare
right The character to compare to

Definition at line 378 of file ffstring.c.

References ffstring_compare_last().

Referenced by ffpriv_genitive_plural(), and ffpriv_partitive_stem().

ffbool ffstring_last_equals_ci const ffstring left,
ffchar  right
 

Case-insensitively checks if the last character of the given string matches the given character.

Parameters:
left The string whose last character we are going to compare
right The character to compare to

Definition at line 383 of file ffstring.c.

References ffstring_compare_last_ci().

Referenced by ffpriv_essive_stem(), ffpriv_genitive_stem(), and ffpriv_plural_stem().

ffint32 ffstring_lower const ffstring source,
ffstring target
 

Creates a lowercase copy of an ffstring.

The caller has to take care of disposing of the new ffstring.

Parameters:
source The source ffstring
target The uninitialized target ffstring
Returns:
0 on success, -1 on memory error

Definition at line 213 of file ffstring.c.

References ffstring_create(), and ffstring_tolower().

Referenced by main().

ffint32 ffstring_move_and_delete ffstring source,
ffstring target
 

Definition at line 76 of file ffstring.c.

References ffstring_copy(), and ffstring_delete().

Referenced by ffpriv_essive_stem().

ffint32 ffstring_rfe ffstring target,
ffuint32  count,
char *  append
 

Definition at line 118 of file ffstring.c.

Referenced by ffpriv_essive_stem(), ffpriv_genitive_stem(), ffpriv_partitive_plural(), ffpriv_partitive_stem(), ffpriv_plural_stem(), ffstring_rfe_ff(), and main().

ffint32 ffstring_rfe_ff ffstring target,
ffuint32  count,
const ffstring append
 

Replaces the last count characters from the end of the target string with the ffstring append.

(RFE == Replace From End)

Parameters:
target The ffstring to modify
count Number of characters to delete
append The ffstring to append
Returns:
0 on success. -1 on memory error. -2 on argument error.

Definition at line 155 of file ffstring.c.

References ffstring_rfe().

Referenced by ffpriv_consonant_gradation().

ffint32 ffstring_tail const ffstring source,
ffint32  count,
ffstring target
 

Creates a new ffstring from at most count characters (not including the terminating null byte) from the head of the source ffstring.

The caller should take care of disposing of the new ffstring.

Parameters:
source The source ffstring
count The number of characters to extract
target The target ffstring
Returns:
0 on success, -1 on memory error, -2 on argument terror

Definition at line 196 of file ffstring.c.

References ffstring_create().

Referenced by ffpriv_consonant_gradation(), ffstring_compare_tail(), ffstring_compare_tail_ci(), ffstring_compare_tail_ff(), ffstring_compare_tail_ff_ci(), and main().

ffbool ffstring_tail_equals const ffstring left,
const ffint32  count,
const ffchar right
 

Checks if the tail of the given ffstring is the same as the given C-style string.

Parameters:
left The string whose tail we are going to compare
count The length of the tail to be compared
right The string we're comparing to

Definition at line 358 of file ffstring.c.

References ffstring_compare_tail().

Referenced by ffpriv_plural_stem().

ffbool ffstring_tail_equals_ci const ffstring left,
const ffint32  count,
const ffchar right
 

Case-insensitively checks if the tail of the given ffstring is the same as the given C-style string.

Parameters:
left The string whose tail we are going to compare
count The length of the tail to be compared
right The string we're comparing to

Definition at line 363 of file ffstring.c.

References ffstring_compare_tail_ci().

Referenced by ffpriv_essive_stem(), ffpriv_genitive_stem(), ffpriv_partitive_singular(), ffpriv_partitive_stem(), and ffpriv_plural_stem().

ffbool ffstring_tail_equals_ff const ffstring left,
const ffint32  count,
const ffstring right
 

Checks if the tail of the given ffstring equals the other given ffstring.

Parameters:
left The string whose tail we are going to compare
count The length of the tail to be compared
right The string we're comparing to

Definition at line 368 of file ffstring.c.

References ffstring_compare_tail_ff().

ffbool ffstring_tail_equals_ff_ci const ffstring left,
const ffint32  count,
const ffstring right
 

Case-insensitively checks if the tail of the given ffstring equals the other given ffstring.

Parameters:
left The string whose tail we are going to compare
count The length of the tail to be compared
right The string we're comparing to

Definition at line 373 of file ffstring.c.

References ffstring_compare_tail_ff_ci().

ffint32 ffstring_tolower ffstring target  ) 
 

Converts a ffstring to lowercase.

Parameters:
target The ffstring to convert.
Returns:
0 on success, -1 on error.

Definition at line 205 of file ffstring.c.

Referenced by ffstring_lower(), and main().


Variable Documentation

ffint32 _ffstring_instance_counter = 0 [static]
 

Definition at line 40 of file ffstring.c.

Referenced by ffstring_create(), ffstring_decinst(), ffstring_delete(), and ffstring_instcount().


Generated on Sun May 15 21:50:47 2005 for FinFlect by  doxygen 1.4.1