Fossil SCM

Fix build on mingw-w64 (which DOES have strtok_r)

jan.nijtmans 2017-03-14 14:38 trunk
Commit 6f52316955f4ba148b241a58e3f82dc3112145f899fbe5ddefe87691c89fb8e3
2 files changed +7 -6 +1 -1
+7 -6
--- src/login.c
+++ src/login.c
@@ -49,28 +49,28 @@
4949
# define sleep Sleep /* windows does not have sleep, but Sleep */
5050
# endif
5151
#endif
5252
#include <time.h>
5353
54
-#if defined(__MINGW32__) || defined(_MSC_VER)
54
+#ifdef _WIN32
5555
/*
5656
** MinGW doesn't have strtok_r in its libc. Here's a public domain one
5757
** found at StackOverflow as a work-around, with formatting adjusted to
5858
** make it more like the usual style here. This is certainly the wrong
5959
** place for it, which is emphasized by making the function static.
60
-**
60
+**
6161
** See http://stackoverflow.com/a/12979321/68204
62
-**
62
+**
6363
** public domain strtok_r() by Charlie Gordon
6464
** from comp.lang.c 9/14/2007
6565
** http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
6666
** (Declaration that it's public domain):
6767
** http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
6868
*/
69
-static char* strtok_r(
70
- char *str,
71
- const char *delim,
69
+static char* win32_strtok_r(
70
+ char *str,
71
+ const char *delim,
7272
char **nextp
7373
){
7474
char *ret;
7575
if( str == NULL ){
7676
str = *nextp;
@@ -85,10 +85,11 @@
8585
*str++ = '\0';
8686
}
8787
*nextp = str;
8888
return ret;
8989
}
90
+#define strtok_r win32_strtok_r
9091
#endif
9192
9293
/*
9394
** Return the login-group name. Or return 0 if this repository is
9495
** not a member of a login-group.
9596
--- src/login.c
+++ src/login.c
@@ -49,28 +49,28 @@
49 # define sleep Sleep /* windows does not have sleep, but Sleep */
50 # endif
51 #endif
52 #include <time.h>
53
54 #if defined(__MINGW32__) || defined(_MSC_VER)
55 /*
56 ** MinGW doesn't have strtok_r in its libc. Here's a public domain one
57 ** found at StackOverflow as a work-around, with formatting adjusted to
58 ** make it more like the usual style here. This is certainly the wrong
59 ** place for it, which is emphasized by making the function static.
60 **
61 ** See http://stackoverflow.com/a/12979321/68204
62 **
63 ** public domain strtok_r() by Charlie Gordon
64 ** from comp.lang.c 9/14/2007
65 ** http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
66 ** (Declaration that it's public domain):
67 ** http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
68 */
69 static char* strtok_r(
70 char *str,
71 const char *delim,
72 char **nextp
73 ){
74 char *ret;
75 if( str == NULL ){
76 str = *nextp;
@@ -85,10 +85,11 @@
85 *str++ = '\0';
86 }
87 *nextp = str;
88 return ret;
89 }
 
90 #endif
91
92 /*
93 ** Return the login-group name. Or return 0 if this repository is
94 ** not a member of a login-group.
95
--- src/login.c
+++ src/login.c
@@ -49,28 +49,28 @@
49 # define sleep Sleep /* windows does not have sleep, but Sleep */
50 # endif
51 #endif
52 #include <time.h>
53
54 #ifdef _WIN32
55 /*
56 ** MinGW doesn't have strtok_r in its libc. Here's a public domain one
57 ** found at StackOverflow as a work-around, with formatting adjusted to
58 ** make it more like the usual style here. This is certainly the wrong
59 ** place for it, which is emphasized by making the function static.
60 **
61 ** See http://stackoverflow.com/a/12979321/68204
62 **
63 ** public domain strtok_r() by Charlie Gordon
64 ** from comp.lang.c 9/14/2007
65 ** http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684
66 ** (Declaration that it's public domain):
67 ** http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
68 */
69 static char* win32_strtok_r(
70 char *str,
71 const char *delim,
72 char **nextp
73 ){
74 char *ret;
75 if( str == NULL ){
76 str = *nextp;
@@ -85,10 +85,11 @@
85 *str++ = '\0';
86 }
87 *nextp = str;
88 return ret;
89 }
90 #define strtok_r win32_strtok_r
91 #endif
92
93 /*
94 ** Return the login-group name. Or return 0 if this repository is
95 ** not a member of a login-group.
96
+1 -1
--- src/stat.c
+++ src/stat.c
@@ -400,11 +400,11 @@
400400
style_submenu_element("Stat", "stat");
401401
style_submenu_element("URLs", "urllist");
402402
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
403403
style_submenu_element("Table Sizes", "repo-tabsize");
404404
}
405
- blob_init(&sql,
405
+ blob_init(&sql,
406406
"SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
407407
if( zArg ){
408408
style_submenu_element("All", "repo_schema");
409409
blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
410410
}
411411
--- src/stat.c
+++ src/stat.c
@@ -400,11 +400,11 @@
400 style_submenu_element("Stat", "stat");
401 style_submenu_element("URLs", "urllist");
402 if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
403 style_submenu_element("Table Sizes", "repo-tabsize");
404 }
405 blob_init(&sql,
406 "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
407 if( zArg ){
408 style_submenu_element("All", "repo_schema");
409 blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
410 }
411
--- src/stat.c
+++ src/stat.c
@@ -400,11 +400,11 @@
400 style_submenu_element("Stat", "stat");
401 style_submenu_element("URLs", "urllist");
402 if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
403 style_submenu_element("Table Sizes", "repo-tabsize");
404 }
405 blob_init(&sql,
406 "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
407 if( zArg ){
408 style_submenu_element("All", "repo_schema");
409 blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
410 }
411

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button