NAME

gen_get_last_token_2 - Parse backwards

SYNOPSIS

#include "l/l_parse.h"

Example compile flags (system dependent):
  -DLINUX_X86_64 -DLINUX_X86_64_OPTERON  -DGNU_COMPILER 
   -I/home/kobus/include
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 


int gen_get_last_token_2
(
	char *input_line,
	char *output_string,
	size_t max_len,
	const char *terminators,
	Trim_order_t trim_order_flag
);

DESCRIPTION

The following may be hard to understand, but it is essentially the same thing as gen_get_token, except that things are happening from the end to the begining. The string input_line is parsed from the end towards the begining. First all characters in "terminators" are ignored until a chacter not in terminators is found. Then the characters are checked for of the charcters in "terminators". If one if found, or if the begining is reached, then the characters not in terminators that have been traversed are copied (forwards!) into output_string, provided that there are less than max_len of them. If there are more than max_len-1, then only max_len-1 are copied. Output_string is then terminated by NULL. A NULL is also placed into the appropriate place of input_line so that the parsed characters are "removed" from the end.

RETURNS

STILL_MORE_TOKENS (1) if there is still more to parse, NO_MORE_TOKENS (0) if there is no more, and ERROR if there is an error (e.g., buffer overflow issue).

MACROS

BUFF_GEN_GET_LAST_TOKEN, BUFF_GEN_GET_LAST_TOKEN_OK

NOTE

We used to return the number of characters copied into output string, but if we use TRIM_AFTER, it is possible that we are interested in parsing out the empty string, but the associated zero return would not mean that we are done. For example, if we are spliting a file from a path, and the path has a trailing slash, then we get an empty string with TRIM_AFTER. But since we would then remove terminators, we would have a non-zero return (unless the input string was already empty).

RELATED

BUFF_GEN_GET_LAST_TOKEN_2, gen_get_last_token, BUFF_GEN_GET_LAST_TOKEN, gen_split_at_last_token

DISCLAIMER

This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.

AUTHOR

Kobus Barnard

DOCUMENTER

Kobus Barnard

SEE ALSO

next_token , const_next_token , get_token , const_get_token , match_quote_get_token , const_match_quote_get_token , match_get_token , const_match_get_token , gen_get_token , const_gen_get_token , gen_char_get_token , gen_match_quote_get_token , const_gen_match_quote_get_token , gen_match_get_token , const_gen_match_get_token , alpha_get_token , gen_get_last_token , gen_split_at_last_token , gen_split_at_last_token_2 , parse_on_string , parse_positive_integer_list , parse_options , free_options , ic_parse_key_words , get_boolean_value , is_no_value_word , parse_path , get_base_name , get_base_path