Skip to content
Snippets Groups Projects
Commit d72b0cd2 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add contains_invalid_attr() - checks string for invalid attr Ctrl-A codes

Other Ctrl-A codes (e.g. ^A\) might be valid, but they're not attribute
control codes, so their existence would cause this function to return true.
parent b84c583a
No related branches found
No related tags found
No related merge requests found
......@@ -534,6 +534,24 @@ size_t strip_invalid_attr(char *str)
return(a);
}
/****************************************************************************/
/* Detects invalid Ctrl-Ax "attribute" sequences in str */
/* Returns number of ^A's in line */
/****************************************************************************/
bool contains_invalid_attr(const char *str)
{
while(*str != '\0') {
if(*str == CTRL_A) {
++str;
if(!valid_ctrl_a_attr(*str))
return true;
}
++str;
}
return false;
}
/****************************************************************************/
/****************************************************************************/
char exascii_to_ascii_char(uchar ch)
......
......@@ -57,6 +57,7 @@ DLLEXPORT char * strip_char(const char* str, char* dest, char);
DLLEXPORT bool valid_ctrl_a_attr(char a);
DLLEXPORT bool valid_ctrl_a_code(char a);
DLLEXPORT size_t strip_invalid_attr(char *str);
DLLEXPORT bool contains_invalid_attr(const char*);
DLLEXPORT char * u32toac(uint32_t, char*, char sep);
DLLEXPORT char * u64toac(uint64_t, char*, char sep);
DLLEXPORT char * rot13(char* str);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment