summaryrefslogtreecommitdiffstats
path: root/debian/htdig/htdig-3.2.0b6/htlib/good_strtok.cc
diff options
context:
space:
mode:
Diffstat (limited to 'debian/htdig/htdig-3.2.0b6/htlib/good_strtok.cc')
-rw-r--r--debian/htdig/htdig-3.2.0b6/htlib/good_strtok.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/debian/htdig/htdig-3.2.0b6/htlib/good_strtok.cc b/debian/htdig/htdig-3.2.0b6/htlib/good_strtok.cc
new file mode 100644
index 00000000..ad537f56
--- /dev/null
+++ b/debian/htdig/htdig-3.2.0b6/htlib/good_strtok.cc
@@ -0,0 +1,46 @@
+//
+// good_strtok.cc
+//
+// good_strtok: The good_strtok() function is very similar to the
+// standard strtok() library function, except that good_strtok()
+// will only skip over 1 separator if it finds one. This is
+// needed when parsing strings with empty fields.
+//
+// Part of the ht://Dig package <http://www.htdig.org/>
+// Copyright (c) 1999-2004 The ht://Dig Group
+// For copyright details, see the file COPYING in your distribution
+// or the GNU Library General Public License (LGPL) version 2 or later
+// <http://www.gnu.org/copyleft/lgpl.html>
+//
+// $Id: good_strtok.cc,v 1.7 2004/05/28 13:15:21 lha Exp $
+//
+
+#ifdef HAVE_CONFIG_H
+#include "htconfig.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "lib.h"
+
+//
+// Perform the same function as the standard strtok() function except that
+// multiple separators are NOT collapsed into one.
+//
+char *good_strtok(char *str, char term)
+{
+ static char *string;
+
+ if (str)
+ {
+ string = str;
+ }
+
+ if (string == NULL || *string == '\0')
+ return NULL;
+
+ char *p = string;
+ while (*string && *string!=term)
+ string++;
+ if (*string)
+ *string++ = '\0';
+ return p;
+}