new private support functions _lasttoken and _wlasttoken to support strtok and wcstok respectively.
fixed lib/msvcrt/stdio/vfscanf.c to remove unnecessary globals.
svn path=/trunk/; revision=5142
+2003-07-16 Royce Mitchell III <royce3@ev1.net>
+
+ * modifed strtok & wcstok in msvcrt so that crtdll can use it.
+ * new private support functions _lasttoken and _wlasttoken to support
+ strtok and wcstok respectively.
+ * fixed lib/msvcrt/stdio/vfscanf.c to remove unnecessary globals.
+
2003-07-16 Royce Mitchell III <royce3@ev1.net>
* fixed warnings at lib/msvcrt/stdio/fputs.c:79
-# $Id: makefile,v 1.57 2003/07/15 19:27:24 royce Exp $
+# $Id: makefile,v 1.58 2003/07/16 21:54:22 royce Exp $
PATH_TO_TOP = ../..
$(PATH_TO_MSVCRT)/stdio/tmpnam.o \
$(PATH_TO_MSVCRT)/stdio/ungetc.o \
stdio/vfprintf.o \
- stdio/vfscanf.o \
+ $(PATH_TO_MSVCRT)/stdio/vfscanf.o \
stdio/vfwprint.o \
$(PATH_TO_MSVCRT)/stdio/vprintf.o \
$(PATH_TO_MSVCRT)/stdio/vscanf.o \
$(PATH_TO_MSVCRT)/stdlib/wcstomb.o \
STRING_OBJECTS = \
- string/strtok.o \
+ string/lasttok.o \
+ $(PATH_TO_MSVCRT)/string/strtok.o \
string/str_old.o \
string/strerror.o \
$(PATH_TO_MSVCRT)/time/strtime.o \
time/tz_vars.o \
-WSTRING_OBJECTS =
+WSTRING_OBJECTS = \
+ $(PATH_TO_MSVCRT)/wstring/wcstok.o \
+ wchar/wlasttok.o
# wchar/wcscoll.o \
# wchar/wcstod.o \
--- /dev/null
+#include <msvcrt/string.h>
+
+/*
+ * This is a CRTDLL internal function to return the lasttoken
+ * bit of data used by strtok. The reason for it's existence is
+ * so that CRTDLL can use MSVCRT's implementation of strtok.
+ */
+char** _lasttoken()
+{
+ static char *lasttoken = NULL;
+ return &lasttoken;
+}
--- /dev/null
+#include <msvcrt/wchar.h>
+
+/*
+ * This is a CRTDLL internal function to return the lasttoken
+ * bit of data used by wcstok. The reason for it's existence is
+ * so that CRTDLL can use MSVCRT's implementation of wcstok.
+ */
+wchar_t** _wlasttoken()
+{
+ static wchar_t *wlasttoken = NULL;
+ return &wlasttoken;
+}
-# $Id: Makefile,v 1.37 2003/07/16 13:29:01 royce Exp $
+# $Id: Makefile,v 1.38 2003/07/16 21:54:22 royce Exp $
PATH_TO_TOP = ../..
stdlib/wtoi64.o
STRING_OBJECTS = \
+ string/lasttok.o \
string/memicmp.o \
string/strcoll.o \
string/strdup.o \
wstring/wcsstr.o \
wstring/wcstok.o \
wstring/wcsupr.o \
- wstring/wcsxfrm.o
+ wstring/wcsxfrm.o \
+ wstring/wlasttok.o
OBJECTS = \
$(CONIO_OBJECTS) \
# define flockfile(S) /* nothing */
# define funlockfile(S) /* nothing */
- char *wp = NULL; /* Workspace. */
- size_t wpmax = 0; /* Maximal size of workspace. */
- size_t wpsize = 0; /* Currently used bytes in workspace. */
-
-
-void ADDW(int Ch) \
-{
- if (wpsize == wpmax)
- {
- char *old = wp;
- wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax;
- wp = (char *) malloc (wpmax);
- if (old != NULL) {
- memcpy (wp, old, wpsize);
- free(old);
- }
- }
- wp[wpsize++] = (Ch);
-}
+# define ADDW(Ch) \
+do{ \
+ if (wpsize == wpmax) \
+ { \
+ char *old = wp; \
+ wpmax = UCHAR_MAX > 2 * wpmax ? UCHAR_MAX : 2 * wpmax; \
+ wp = (char *) malloc (wpmax); \
+ if (old != NULL) \
+ { \
+ memcpy (wp, old, wpsize); \
+ free(old); \
+ } \
+ } \
+ wp[wpsize++] = (Ch); \
+}while(0)
int __vfscanf (FILE *s, const char *format, va_list argptr)
available anymore. */
int skip_space = 0;
/* Workspace. */
+ char *wp = NULL; /* Workspace. */
+ size_t wpmax = 0; /* Maximal size of workspace. */
+ size_t wpsize = 0; /* Currently used bytes in workspace. */
char *tw; /* Temporary pointer. */
#ifdef __va_copy
--- /dev/null
+#include <msvcrt/internal/tls.h>
+
+/*
+ * This is an MSVCRT internal function to return the lasttoken
+ * bit of data used by strtok. The reason for it's existence is
+ * so that CRTDLL can use the strtok source code in the same
+ * file.
+ */
+char** _lasttoken()
+{
+ PTHREADDATA ptd = GetThreadData();
+ _assert(ptd);
+ return &(ptd->lasttoken);
+}
#include <msvcrt/string.h>
#include <msvcrt/internal/tls.h>
+char** _lasttoken(); /* lasttok.c */
+
/*
* @implemented
*/
const char *spanp;
int c, sc;
char *tok;
+#if 1
+ char ** lasttoken = _lasttoken();
+#else
PTHREADDATA ThreadData = GetThreadData();
+ char ** lasttoken = &ThreadData->lasttoken;
+#endif
- if (s == NULL && (s = ThreadData->lasttoken) == NULL)
+ if (s == NULL && (s = *lasttoken) == NULL)
return (NULL);
/*
}
if (c == 0) { /* no non-delimiter characters */
- ThreadData->lasttoken = NULL;
+ *lasttoken = NULL;
return (NULL);
}
tok = s - 1;
s = NULL;
else
s[-1] = 0;
- ThreadData->lasttoken = s;
+ *lasttoken = s;
return (tok);
}
} while (sc != 0);
#include <msvcrt/string.h>
#include <msvcrt/internal/tls.h>
+wchar_t** _wlasttoken(); /* wlasttok.c */
+
/*
* @implemented
*/
const wchar_t *spanp;
int c, sc;
wchar_t *tok;
+#if 1
+ wchar_t ** wlasttoken = _wlasttoken();
+#else
PTHREADDATA ThreadData = GetThreadData();
+ wchar_t ** wlasttoken = &ThreadData->wlasttoken;
+#endif
- if (s == NULL && (s = ThreadData->wlasttoken) == NULL)
+ if (s == NULL && (s = *wlasttoken) == NULL)
return (NULL);
/*
}
if (c == 0) { /* no non-ctiter characters */
- ThreadData->wlasttoken = NULL;
+ *wlasttoken = NULL;
return (NULL);
}
tok = s - 2;
s = NULL;
else
s[-1] = 0;
- ThreadData->wlasttoken = s;
+ *wlasttoken = s;
return (tok);
}
spanp+=2;
--- /dev/null
+#include <msvcrt/internal/tls.h>
+
+/*
+ * This is an MSVCRT internal function to return the lasttoken
+ * bit of data used by wcstok. The reason for it's existence is
+ * so that CRTDLL can use the wcstok source code in the same
+ * file.
+ */
+wchar_t** _wlasttoken()
+{
+ PTHREADDATA ptd = GetThreadData();
+ _assert(ptd);
+ return &(ptd->wlasttoken);
+}