From 19ec3ab02940f56b4e927ff0e67ebcbab718ceb4 Mon Sep 17 00:00:00 2001 From: Christopher Schwarz Date: Sat, 10 Oct 2009 19:18:21 +0000 Subject: * (bug 3998) linewrap cp, parse newlines in cp and motd --- src/qcommon/q_shared.c | 7 +++++++ src/qcommon/q_shared.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'src/qcommon') diff --git a/src/qcommon/q_shared.c b/src/qcommon/q_shared.c index 5b74badd..6da13ad0 100644 --- a/src/qcommon/q_shared.c +++ b/src/qcommon/q_shared.c @@ -935,6 +935,13 @@ int Q_CountChar(const char *string, char tocount) return count; } +void Q_ParseNewlines( char *dest, const char *src, int destsize ) +{ + for( ; *src && destsize > 1; src++, destsize-- ) + *dest++ = ( ( *src == '\\' && *( ++src ) == 'n' ) ? '\n' : *src ); + *dest++ = '\0'; +} + void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) { int len; va_list argptr; diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h index 5aaf0878..34f3e471 100644 --- a/src/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -791,6 +791,8 @@ void Q_strcat( char *dest, int size, const char *src ); int Q_PrintStrlen( const char *string ); // removes color sequences from string char *Q_CleanStr( char *string ); +// parse "\n" into '\n' +void Q_ParseNewlines( char *dest, const char *src, int destsize ); // Count the number of char tocount encountered in string int Q_CountChar(const char *string, char tocount); -- cgit