summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2005-01-25 16:16:48 +0000
committerAlexander Barton <alex@barton.de>2005-01-25 16:16:48 +0000
commit39f1ddd9d08cdf04bbf67b6e95f0c1ab655d77f4 (patch)
tree4f83b8ecb329ef5a0df1ecbb318fba1ed87ba71f /src
parent34e912d9f2b84621b45a64698caafc220d58302f (diff)
downloadngircd-39f1ddd9d08cdf04bbf67b6e95f0c1ab655d77f4.tar.gz
ngircd-39f1ddd9d08cdf04bbf67b6e95f0c1ab655d77f4.zip
New function ngt_TrimLastChr(), prototype by Florian Westphal.
Diffstat (limited to 'src')
-rw-r--r--src/tool/tool.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/tool/tool.c b/src/tool/tool.c
index 3b66d7f8..2792c7ed 100644
--- a/src/tool/tool.c
+++ b/src/tool/tool.c
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2005 Alexander Barton (alex@barton.de)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: tool.c,v 1.1 2003/01/13 12:20:16 alex Exp $";
+static char UNUSED id[] = "$Id: tool.c,v 1.2 2005/01/25 16:16:48 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -74,4 +74,23 @@ ngt_LowerStr( CHAR *String )
 } /* ngt_LowerStr */
 
 
+GLOBAL VOID
+ngt_TrimLastChr( CHAR *String, CONST CHAR Chr)
+{
+	/* If last character in the string matches Chr, remove it.
+	 * Empty strings are handled correctly. */
+
+        UINT len;
+
+	assert( String != NULL );
+
+	len = strlen( String );
+	if( len == 0 ) return;
+
+	len--;
+
+	if( String[len] == Chr ) String[len] = '\0';
+} /* ngt_TrimLastChr */
+
+
 /* -eof- */