mirror of
https://github.com/matrix-construct/construct
synced 2025-02-16 16:50:12 +01:00
ircd: Remove legacy stringops.
This commit is contained in:
parent
497b4ec552
commit
09dc4acf06
2 changed files with 0 additions and 123 deletions
|
@ -105,11 +105,6 @@ namespace ircd
|
|||
|
||||
// Truncate view at maximum length
|
||||
string_view trunc(const string_view &, const size_t &max);
|
||||
|
||||
// Legacy
|
||||
char *strip_colour(char *string);
|
||||
char *strip_unprintable(char *string);
|
||||
char *reconstruct_parv(int parc, const char **parv);
|
||||
}
|
||||
|
||||
inline ircd::string_view
|
||||
|
|
118
ircd/lexical.cc
118
ircd/lexical.cc
|
@ -692,121 +692,3 @@ ircd::u2a(const mutable_buffer &out,
|
|||
|
||||
return { data(out), size_t(p - data(out)) };
|
||||
}
|
||||
|
||||
/*
|
||||
* strip_colour - remove colour codes from a string
|
||||
* -asuffield (?)
|
||||
*/
|
||||
char *
|
||||
ircd::strip_colour(char *string)
|
||||
{
|
||||
char *c = string;
|
||||
char *c2 = string;
|
||||
char *last_non_space = NULL;
|
||||
|
||||
/* c is source, c2 is target */
|
||||
for(; c && *c; c++)
|
||||
switch (*c)
|
||||
{
|
||||
case 3:
|
||||
if(rfc1459::is_digit(c[1]))
|
||||
{
|
||||
c++;
|
||||
if(rfc1459::is_digit(c[1]))
|
||||
c++;
|
||||
if(c[1] == ',' && rfc1459::is_digit(c[2]))
|
||||
{
|
||||
c += 2;
|
||||
if(rfc1459::is_digit(c[1]))
|
||||
c++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 7:
|
||||
case 15:
|
||||
case 22:
|
||||
case 23:
|
||||
case 27:
|
||||
case 29:
|
||||
case 31:
|
||||
break;
|
||||
case 32:
|
||||
*c2++ = *c;
|
||||
break;
|
||||
default:
|
||||
*c2++ = *c;
|
||||
last_non_space = c2;
|
||||
break;
|
||||
}
|
||||
|
||||
*c2 = '\0';
|
||||
|
||||
if(last_non_space)
|
||||
*last_non_space = '\0';
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
char *
|
||||
ircd::strip_unprintable(char *string)
|
||||
{
|
||||
char *c = string;
|
||||
char *c2 = string;
|
||||
char *last_non_space = NULL;
|
||||
|
||||
/* c is source, c2 is target */
|
||||
for(; c && *c; c++)
|
||||
switch (*c)
|
||||
{
|
||||
case 3:
|
||||
if(rfc1459::is_digit(c[1]))
|
||||
{
|
||||
c++;
|
||||
if(rfc1459::is_digit(c[1]))
|
||||
c++;
|
||||
if(c[1] == ',' && rfc1459::is_digit(c[2]))
|
||||
{
|
||||
c += 2;
|
||||
if(rfc1459::is_digit(c[1]))
|
||||
c++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
*c2++ = *c;
|
||||
break;
|
||||
default:
|
||||
if (*c < 32)
|
||||
break;
|
||||
*c2++ = *c;
|
||||
last_non_space = c2;
|
||||
break;
|
||||
}
|
||||
|
||||
*c2 = '\0';
|
||||
|
||||
if(last_non_space)
|
||||
*last_non_space = '\0';
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
// This is from the old parse.c and does not ensure the trailing :is added
|
||||
// NOTE: Deprecated. Use formal grammar.
|
||||
char *
|
||||
ircd::reconstruct_parv(int parc, const char *parv[])
|
||||
{
|
||||
static char tmpbuf[BUFSIZE];
|
||||
|
||||
strlcpy(tmpbuf, parv[0], BUFSIZE);
|
||||
for (int i = 1; i < parc; i++)
|
||||
{
|
||||
strlcat(tmpbuf, " ", BUFSIZE);
|
||||
strlcat(tmpbuf, parv[i], BUFSIZE);
|
||||
}
|
||||
|
||||
return tmpbuf;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue