fix off by 1 error
[rrdtool.git] / src / win32comp.c
index 590e478..457e69e 100644 (file)
@@ -1,67 +1,82 @@
-// compatibility routines, non reentrant ....\r
-\r
-#include <string.h> \r
-#include <time.h>\r
-\r
-struct tm* localtime_r(const time_t* t, struct tm* r) {\r
-  struct tm * temp;\r
-  temp = localtime(t);\r
-  memcpy(r,temp,sizeof(struct tm));\r
-  return(r);\r
-}\r
-\r
-struct tm* gmtime_r(const time_t* t, struct tm* r) {\r
-  struct tm * temp;\r
-  temp = gmtime(t);\r
-  memcpy(r,temp,sizeof(struct tm));\r
-  return r;\r
-}\r
-\r
-char* ctime_r (const time_t* t, char* buf) {\r
-  char * temp;\r
-  temp = asctime(localtime(t));\r
-  strcpy(buf,temp);\r
-  return(buf);\r
-}\r
-\r
-/*\r
-       s  \r
-       Points to the string from which to extract tokens. \r
-\r
-       delim  \r
-       Points to a null-terminated set of delimiter characters. \r
-\r
-       save_ptr\r
-       Is a value-return parameter used by strtok_r() to record its progress through s1. \r
-*/\r
-\r
-\r
-char * strtok_r (char *s, const char *delim, char **save_ptr) {\r
-  char *token;\r
-\r
-  if (s == NULL)  s = *save_ptr;\r
-\r
-  /* Scan leading delimiters.  */\r
-  s += strspn(s, delim);\r
-  if (*s == '\0')\r
-    {\r
-      *save_ptr = s;\r
-      return NULL;\r
-    }\r
-\r
-  /* Find the end of the token.  */\r
-  token = s;\r
-  s = strpbrk (token, delim);\r
-  if (s == NULL) {\r
-    /* This token finishes the string.  */\r
-         *save_ptr = token;\r
-         while (**save_ptr != '\0') (*save_ptr)++;\r
-  }  else\r
-    {\r
-      /* Terminate the token and make *SAVE_PTR point past it.  */\r
-      *s = '\0';\r
-      *save_ptr = s + 1;\r
-    }\r
-  return token;\r
-}\r
-\r
+/* compatibility routines, non reentrant .... */
+
+#include <string.h>
+#include <time.h>
+
+struct tm *localtime_r(
+    const time_t *t,
+    struct tm *r)
+{
+    struct tm *temp;
+
+    temp = localtime(t);
+    memcpy(r, temp, sizeof(struct tm));
+    return (r);
+}
+
+struct tm *gmtime_r(
+    const time_t *t,
+    struct tm *r)
+{
+    struct tm *temp;
+
+    temp = gmtime(t);
+    memcpy(r, temp, sizeof(struct tm));
+    return r;
+}
+
+char     *ctime_r(
+    const time_t *t,
+    char *buf)
+{
+    char     *temp;
+
+    temp = asctime(localtime(t));
+    strcpy(buf, temp);
+    return (buf);
+}
+
+/*
+       s  
+       Points to the string from which to extract tokens. 
+
+       delim  
+       Points to a null-terminated set of delimiter characters. 
+
+       save_ptr
+       Is a value-return parameter used by strtok_r() to record its progress through s1. 
+*/
+
+
+char     *strtok_r(
+    char *s,
+    const char *delim,
+    char **save_ptr)
+{
+    char     *token;
+
+    if (s == NULL)
+        s = *save_ptr;
+
+    /* Scan leading delimiters.  */
+    s += strspn(s, delim);
+    if (*s == '\0') {
+        *save_ptr = s;
+        return NULL;
+    }
+
+    /* Find the end of the token.  */
+    token = s;
+    s = strpbrk(token, delim);
+    if (s == NULL) {
+        /* This token finishes the string.  */
+        *save_ptr = token;
+        while (**save_ptr != '\0')
+            (*save_ptr)++;
+    } else {
+        /* Terminate the token and make *SAVE_PTR point past it.  */
+        *s = '\0';
+        *save_ptr = s + 1;
+    }
+    return token;
+}