11 return sscanf(from,
"%s", to) == 1;
33 int printed = vsprintf(buffer, format, parg);
38 return strndup(buffer, printed);
41 void throw_errorf(
int error_num,
const char *error_messagef, ...) {
47 int printed = vsprintf(buffer, error_messagef, parg);
51 if (printed >= BUFSIZE) {
52 throw_errorf(998,
"Internal buffer overflow (while formatting error #%i '%s')", error_num, error_messagef);
59 bool Warnings::show_warnings =
true;
61 void warning(
int warning_num,
const char *warning_message) {
64 fprintf(stderr,
"WARNING(%d): %s\n", warning_num, warning_message);
66 void warningf(
int warning_num,
const char *warning_messagef, ...) {
73 int printed = vsprintf(buffer, warning_messagef, parg);
77 if (printed >= BUFSIZE) {
78 throw_errorf(997,
"Internal buffer overflow (while formatting warning #%i '%s')", warning_num, warning_messagef);
87 while (line[index] ==
' ' || line[index] ==
'\t')
97 for (; (c = getchar()) !=
'\n' && indi < (linenum - 1); line[indi++] = c) {}
104 int newlen = len1+len2;
106 memcpy(string1+len1, string2, len2);
119 if (len == 1)
return;
121 if (str[len-2] == ch)
return;
123 char temp[] = { ch,
'\n' };
129 if (len1 && string1[len1-1] ==
'\n') len1--;
132 else { string1[len1] = 0; }
137 if (len1 && string1[len1-1] ==
'\n') string1[len1-1] =
' ';
141 void Append(
char*& string1,
const char *string2) {
152 for (
int i = 0; str[i]; ++i) str[i] = toupper(str[i]);
158 for (
int i = 0; i<len; ++i) {
159 if (!str[i])
return i;
175 if (text && pattern) {
176 for (
int t = 0; text[t]; ++t) {
177 bool mismatch =
false;
180 for (; !mismatch && pattern[p]; ++p) {
181 mismatch = tolower(text[t+p]) != tolower(pattern[p]);
205 for (p = 0; offset == -1 && pattern[p]; ++p) {
211 if (str[offset] != expect_behind) {
232 const char *subspecies_pattern[] = {
"subspecies",
"sub-species",
"subsp.",
NULp };
237 const char *strain_pattern[] = {
"strain",
"str.",
NULp };
250 const char *
stristr(
const char *
str,
const char *substring) {
252 return offset >= 0 ? str+offset :
NULp;
255 int ___lookup_keyword(
const char *keyword,
const char *
const *lookup_table,
int lookup_table_size) {
259 for (
int i = 0; i<lookup_table_size; ++i) {
260 if (
str_equal(keyword, lookup_table[i]))
return i;
297 name_ = nulldup(Name);
CONSTEXPR_INLINE int str0len(const char *str)
int find_subspecies(const char *str, char expect_behind)
void warning(int warning_num, const char *warning_message)
AliDataPtr format(AliDataPtr data, const size_t wanted_len, GB_ERROR &error)
void Append(char *&string1, const char *string2)
void skip_eolnl_and_append_spaced(char *&string1, const char *string2)
int skip_pattern(const char *text, const char *pattern)
void Getstr(char *line, int linenum)
char * ARB_strdup(const char *str)
void warningf(int warning_num, const char *warning_messagef,...)
void append_known_len(char *&string1, int len1, const char *string2, int len2)
int fputs_len(const char *str, int len, Writer &write)
int ___lookup_keyword(const char *keyword, const char *const *lookup_table, int lookup_table_size)
char buffer[MESSAGE_BUFFERSIZE]
int find_strain(const char *str, char expect_behind)
const char * stristr(const char *str, const char *substring)
int skip_strain(const char *str, char expect_behind)
void skip_eolnl_and_append(char *&string1, const char *string2)
void scan_token_or_die(char *to, const char *from)
virtual void out(char ch)=0
int Skip_white_space(const char *line, int index)
static int findStrain(const char *str, char expect_behind, FindMode mode)
int find_pattern(const char *text, const char *pattern)
int parse_key_word(const char *line, char *key, const char *separator)
bool scan_token(char *to, const char *from)
static int findSubspecies(const char *str, char expect_behind, FindMode mode)
static int findPattern(const char *text, const char *pattern, FindMode mode)
char * strf(const char *format,...)
void throw_errorf(int error_num, const char *error_messagef,...)
static cstr error_message
static int findMultipattern(const char *str, const char **const &pattern, char expect_behind, FindMode mode)
void ARB_realloc(TYPE *&tgt, size_t nelem)
CONSTEXPR_INLINE bool str_equal(const char *s1, const char *s2)
static int pattern[maxsites+1]
const char * line() const
void terminate_with(char *&str, char ch)
char * strndup(const char *str, int len)
void throw_error(int error_num, const char *error_message)
int skip_subspecies(const char *str, char expect_behind)
bool occurs_in(char ch, const char *in)