]> arthur.barton.de Git - ngircd-alex.git/commitdiff
New function ngt_TrimLastChr(), prototype by Florian Westphal.
authorAlexander Barton <alex@barton.de>
Tue, 25 Jan 2005 16:16:48 +0000 (16:16 +0000)
committerAlexander Barton <alex@barton.de>
Tue, 25 Jan 2005 16:16:48 +0000 (16:16 +0000)
src/tool/tool.c

index 3b66d7f8315634614a867c3ac16db3949d8784ce..2792c7edf63acea5e932b410aaa8ccd2e37b159b 100644 (file)
@@ -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- */