Update of /cvsroot/com0com/com0com/setup
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15064
Modified Files:
utils.cpp utils.h
Log Message:
Added STRTOK_R()
Index: utils.cpp
===================================================================
RCS file: /cvsroot/com0com/com0com/setup/utils.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** utils.cpp 3 Nov 2006 13:17:28 -0000 1.3
--- utils.cpp 11 Jan 2007 15:03:43 -0000 1.4
***************
*** 2,6 ****
* $Id$
*
! * Copyright (c) 2006 Vyacheslav Frolov
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* $Id$
*
! * Copyright (c) 2006-2007 Vyacheslav Frolov
*
* This program is free software; you can redistribute it and/or modify
***************
*** 20,23 ****
--- 20,26 ----
*
* $Log$
+ * Revision 1.4 2007/01/11 15:03:43 vfrolov
+ * Added STRTOK_R()
+ *
* Revision 1.3 2006/11/03 13:17:28 vfrolov
* Fixed LocalReAlloc() usage
***************
*** 63,66 ****
--- 66,105 ----
}
///////////////////////////////////////////////////////////////
+ static BOOL IsDelim(char c, const char *pDelims)
+ {
+ while (*pDelims) {
+ if (c == *pDelims++)
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ char *STRTOK_R(char *pStr, const char *pDelims, char **ppSave)
+ {
+ if (!pStr)
+ pStr = *ppSave;
+
+ while (IsDelim(*pStr, pDelims))
+ pStr++;
+
+ if (!*pStr) {
+ *ppSave = pStr;
+ return NULL;
+ }
+
+ char *pToken = pStr;
+
+ while (*pStr && !IsDelim(*pStr, pDelims))
+ pStr++;
+
+ if (*pStr)
+ *pStr++ = 0;
+
+ *ppSave = pStr;
+
+ return pToken;
+ }
+ ///////////////////////////////////////////////////////////////
BOOL StrToInt(const char *pStr, int *pNum)
{
Index: utils.h
===================================================================
RCS file: /cvsroot/com0com/com0com/setup/utils.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** utils.h 3 Nov 2006 13:17:28 -0000 1.3
--- utils.h 11 Jan 2007 15:03:43 -0000 1.4
***************
*** 2,6 ****
* $Id$
*
! * Copyright (c) 2006 Vyacheslav Frolov
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* $Id$
*
! * Copyright (c) 2006-2007 Vyacheslav Frolov
*
* This program is free software; you can redistribute it and/or modify
***************
*** 20,23 ****
--- 20,26 ----
*
* $Log$
+ * Revision 1.4 2007/01/11 15:03:43 vfrolov
+ * Added STRTOK_R()
+ *
* Revision 1.3 2006/11/03 13:17:28 vfrolov
* Fixed LocalReAlloc() usage
***************
*** 37,40 ****
--- 40,44 ----
int VSNPRINTF(char *pBuf, int size, const char *pFmt, va_list va);
int SNPRINTF(char *pBuf, int size, const char *pFmt, ...);
+ char *STRTOK_R(char *pStr, const char *pDelims, char **ppSave);
BOOL StrToInt(const char *pStr, int *pNum);
|