Permalink
Browse files

- Move virtual cwd to TSRM.

  In the least this still doesn't work on Windows.
  • Loading branch information...
1 parent b378ecd commit daf926cf5b3354ec838d2413651ea68259282483 @andigutmans andigutmans committed Sep 3, 2000
Showing with 992 additions and 1 deletion.
  1. +1 −1 TSRM/Makefile.am
  2. +6 −0 TSRM/configure.in
  3. +62 −0 TSRM/tsrm_strtok_r.c
  4. +6 −0 TSRM/tsrm_strtok_r.h
  5. +772 −0 TSRM/tsrm_virtual_cwd.c
  6. +145 −0 TSRM/tsrm_virtual_cwd.h
View
@@ -1,6 +1,6 @@
## process this file with automake to produce Makefile.am
AUTOMAKE_OPTIONS=foreign
noinst_LTLIBRARIES=libtsrm.la
-libtsrm_la_SOURCES = TSRM.c
+libtsrm_la_SOURCES = TSRM.c tsrm_strtok_r.c tsrm_virtual_cwd.c
depend:
View
@@ -19,6 +19,12 @@ fi
dnl TSRM_PTHREAD
+AC_CHECK_HEADERS(
+utime.h \
+dirent.h \
+stdarg.h
+)
+
AC_DEFINE(ZTS,1,[ ])
AC_OUTPUT(Makefile)
View
@@ -0,0 +1,62 @@
+#include "tsrm_strtok_r.h"
+
+#include <stdio.h>
+
+static inline int in_character_class(char ch, const char *delim)
+{
+ while (*delim) {
+ if (*delim == ch) {
+ return 1;
+ }
+ delim++;
+ }
+ return 0;
+}
+
+char *tsrm_strtok_r(char *s, const char *delim, char **last)
+{
+ char *token;
+
+ if (s == NULL) {
+ s = *last;
+ }
+
+ while (*s && in_character_class(*s, delim)) {
+ s++;
+ }
+ if (!*s) {
+ return NULL;
+ }
+
+ token = s;
+
+ while (*s && !in_character_class(*s, delim)) {
+ s++;
+ }
+ if (!*s) {
+ *last = s;
+ } else {
+ *s = '\0';
+ *last = s + 1;
+ }
+ return token;
+}
+
+#if 0
+
+main()
+{
+ char foo[] = "/foo/bar//\\barbara";
+ char *last;
+ char *token;
+
+ token = tsrm_strtok_r(foo, "/\\", &last);
+ while (token) {
+ printf ("Token = '%s'\n", token);
+ token = tsrm_strtok_r(NULL, "/\\", &last);
+ }
+
+ return 0;
+}
+
+#endif
@@ -0,0 +1,6 @@
+#ifndef TSRM_STRTOK_R
+#define TSRM_STRTOK_R
+
+char *tsrm_strtok_r(char *s, const char *delim, char **last);
+
+#endif
Oops, something went wrong.

0 comments on commit daf926c

Please sign in to comment.