Fossil SCM

Remove dependencies on test_windirent.h from the SQLite-supplied shell.c source file, so that the build will work on MinGW.

drh 2018-01-07 21:59 trunk
Commit 14e94ad326d0ebd133cfb138ab5bceaf272dfd09e7c2fe3a2497dc2063b2e310
3 files changed +160 -3 +2 -2 +1 -1
+160 -3
--- src/shell.c
+++ src/shell.c
@@ -904,10 +904,168 @@
904904
*/
905905
#define SQLITE_EXTENSION_INIT1
906906
#define SQLITE_EXTENSION_INIT2(X) (void)(X)
907907
908908
#if defined(_WIN32) && defined(_MSC_VER)
909
+/************************* Begin test_windirent.h ******************/
910
+/*
911
+** 2015 November 30
912
+**
913
+** The author disclaims copyright to this source code. In place of
914
+** a legal notice, here is a blessing:
915
+**
916
+** May you do good and not evil.
917
+** May you find forgiveness for yourself and forgive others.
918
+** May you share freely, never taking more than you give.
919
+**
920
+*************************************************************************
921
+** This file contains declarations for most of the opendir() family of
922
+** POSIX functions on Win32 using the MSVCRT.
923
+*/
924
+
925
+#if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H)
926
+#define SQLITE_WINDIRENT_H
927
+
928
+/*
929
+** We need several data types from the Windows SDK header.
930
+*/
931
+
932
+#define WIN32_LEAN_AND_MEAN
933
+#include "windows.h"
934
+
935
+/*
936
+** We need several support functions from the SQLite core.
937
+*/
938
+
939
+
940
+/*
941
+** We need several things from the ANSI and MSVCRT headers.
942
+*/
943
+
944
+#include <stdio.h>
945
+#include <stdlib.h>
946
+#include <errno.h>
947
+#include <io.h>
948
+#include <limits.h>
949
+#include <sys/types.h>
950
+#include <sys/stat.h>
951
+
952
+/*
953
+** We may need several defines that should have been in "sys/stat.h".
954
+*/
955
+
956
+#ifndef S_ISREG
957
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
958
+#endif
959
+
960
+#ifndef S_ISDIR
961
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
962
+#endif
963
+
964
+#ifndef S_ISLNK
965
+#define S_ISLNK(mode) (0)
966
+#endif
967
+
968
+/*
969
+** We may need to provide the "mode_t" type.
970
+*/
971
+
972
+#ifndef MODE_T_DEFINED
973
+ #define MODE_T_DEFINED
974
+ typedef unsigned short mode_t;
975
+#endif
976
+
977
+/*
978
+** We may need to provide the "ino_t" type.
979
+*/
980
+
981
+#ifndef INO_T_DEFINED
982
+ #define INO_T_DEFINED
983
+ typedef unsigned short ino_t;
984
+#endif
985
+
986
+/*
987
+** We need to define "NAME_MAX" if it was not present in "limits.h".
988
+*/
989
+
990
+#ifndef NAME_MAX
991
+# ifdef FILENAME_MAX
992
+# define NAME_MAX (FILENAME_MAX)
993
+# else
994
+# define NAME_MAX (260)
995
+# endif
996
+#endif
997
+
998
+/*
999
+** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
1000
+*/
1001
+
1002
+#ifndef NULL_INTPTR_T
1003
+# define NULL_INTPTR_T ((intptr_t)(0))
1004
+#endif
1005
+
1006
+#ifndef BAD_INTPTR_T
1007
+# define BAD_INTPTR_T ((intptr_t)(-1))
1008
+#endif
1009
+
1010
+/*
1011
+** We need to provide the necessary structures and related types.
1012
+*/
1013
+
1014
+#ifndef DIRENT_DEFINED
1015
+#define DIRENT_DEFINED
1016
+typedef struct DIRENT DIRENT;
1017
+typedef DIRENT *LPDIRENT;
1018
+struct DIRENT {
1019
+ ino_t d_ino; /* Sequence number, do not use. */
1020
+ unsigned d_attributes; /* Win32 file attributes. */
1021
+ char d_name[NAME_MAX + 1]; /* Name within the directory. */
1022
+};
1023
+#endif
1024
+
1025
+#ifndef DIR_DEFINED
1026
+#define DIR_DEFINED
1027
+typedef struct DIR DIR;
1028
+typedef DIR *LPDIR;
1029
+struct DIR {
1030
+ intptr_t d_handle; /* Value returned by "_findfirst". */
1031
+ DIRENT d_first; /* DIRENT constructed based on "_findfirst". */
1032
+ DIRENT d_next; /* DIRENT constructed based on "_findnext". */
1033
+};
1034
+#endif
1035
+
1036
+/*
1037
+** Provide a macro, for use by the implementation, to determine if a
1038
+** particular directory entry should be skipped over when searching for
1039
+** the next directory entry that should be returned by the readdir() or
1040
+** readdir_r() functions.
1041
+*/
1042
+
1043
+#ifndef is_filtered
1044
+# define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
1045
+#endif
1046
+
1047
+/*
1048
+** Provide the function prototype for the POSIX compatiable getenv()
1049
+** function. This function is not thread-safe.
1050
+*/
1051
+
1052
+extern const char *windirent_getenv(const char *name);
1053
+
1054
+/*
1055
+** Finally, we can provide the function prototypes for the opendir(),
1056
+** readdir(), readdir_r(), and closedir() POSIX functions.
1057
+*/
1058
+
1059
+extern LPDIR opendir(const char *dirname);
1060
+extern LPDIRENT readdir(LPDIR dirp);
1061
+extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);
1062
+extern INT closedir(LPDIR dirp);
1063
+
1064
+#endif /* defined(WIN32) && defined(_MSC_VER) */
1065
+
1066
+/************************* End test_windirent.h ********************/
9091067
/************************* Begin test_windirent.c ******************/
9101068
/*
9111069
** 2015 November 30
9121070
**
9131071
** The author disclaims copyright to this source code. In place of
@@ -921,12 +1079,11 @@
9211079
** This file contains code to implement most of the opendir() family of
9221080
** POSIX functions on Win32 using the MSVCRT.
9231081
*/
9241082
9251083
#if defined(_WIN32) && defined(_MSC_VER)
926
-
927
-#include "test_windirent.h"
1084
+/* #include "test_windirent.h" */
9281085
9291086
/*
9301087
** Implementation of the POSIX getenv() function using the Win32 API.
9311088
** This function is not thread-safe.
9321089
*/
@@ -1909,11 +2066,11 @@
19092066
# include <utime.h>
19102067
#else
19112068
# include "windows.h"
19122069
# include <io.h>
19132070
# include <direct.h>
1914
-# include "test_windirent.h"
2071
+/* # include "test_windirent.h" */
19152072
# define dirent DIRENT
19162073
# define timespec TIMESPEC
19172074
# define stat _stat
19182075
# define mkdir(path,mode) _mkdir(path)
19192076
# define lstat(path,buf) _stat(path,buf)
19202077
--- src/shell.c
+++ src/shell.c
@@ -904,10 +904,168 @@
904 */
905 #define SQLITE_EXTENSION_INIT1
906 #define SQLITE_EXTENSION_INIT2(X) (void)(X)
907
908 #if defined(_WIN32) && defined(_MSC_VER)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
909 /************************* Begin test_windirent.c ******************/
910 /*
911 ** 2015 November 30
912 **
913 ** The author disclaims copyright to this source code. In place of
@@ -921,12 +1079,11 @@
921 ** This file contains code to implement most of the opendir() family of
922 ** POSIX functions on Win32 using the MSVCRT.
923 */
924
925 #if defined(_WIN32) && defined(_MSC_VER)
926
927 #include "test_windirent.h"
928
929 /*
930 ** Implementation of the POSIX getenv() function using the Win32 API.
931 ** This function is not thread-safe.
932 */
@@ -1909,11 +2066,11 @@
1909 # include <utime.h>
1910 #else
1911 # include "windows.h"
1912 # include <io.h>
1913 # include <direct.h>
1914 # include "test_windirent.h"
1915 # define dirent DIRENT
1916 # define timespec TIMESPEC
1917 # define stat _stat
1918 # define mkdir(path,mode) _mkdir(path)
1919 # define lstat(path,buf) _stat(path,buf)
1920
--- src/shell.c
+++ src/shell.c
@@ -904,10 +904,168 @@
904 */
905 #define SQLITE_EXTENSION_INIT1
906 #define SQLITE_EXTENSION_INIT2(X) (void)(X)
907
908 #if defined(_WIN32) && defined(_MSC_VER)
909 /************************* Begin test_windirent.h ******************/
910 /*
911 ** 2015 November 30
912 **
913 ** The author disclaims copyright to this source code. In place of
914 ** a legal notice, here is a blessing:
915 **
916 ** May you do good and not evil.
917 ** May you find forgiveness for yourself and forgive others.
918 ** May you share freely, never taking more than you give.
919 **
920 *************************************************************************
921 ** This file contains declarations for most of the opendir() family of
922 ** POSIX functions on Win32 using the MSVCRT.
923 */
924
925 #if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H)
926 #define SQLITE_WINDIRENT_H
927
928 /*
929 ** We need several data types from the Windows SDK header.
930 */
931
932 #define WIN32_LEAN_AND_MEAN
933 #include "windows.h"
934
935 /*
936 ** We need several support functions from the SQLite core.
937 */
938
939
940 /*
941 ** We need several things from the ANSI and MSVCRT headers.
942 */
943
944 #include <stdio.h>
945 #include <stdlib.h>
946 #include <errno.h>
947 #include <io.h>
948 #include <limits.h>
949 #include <sys/types.h>
950 #include <sys/stat.h>
951
952 /*
953 ** We may need several defines that should have been in "sys/stat.h".
954 */
955
956 #ifndef S_ISREG
957 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
958 #endif
959
960 #ifndef S_ISDIR
961 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
962 #endif
963
964 #ifndef S_ISLNK
965 #define S_ISLNK(mode) (0)
966 #endif
967
968 /*
969 ** We may need to provide the "mode_t" type.
970 */
971
972 #ifndef MODE_T_DEFINED
973 #define MODE_T_DEFINED
974 typedef unsigned short mode_t;
975 #endif
976
977 /*
978 ** We may need to provide the "ino_t" type.
979 */
980
981 #ifndef INO_T_DEFINED
982 #define INO_T_DEFINED
983 typedef unsigned short ino_t;
984 #endif
985
986 /*
987 ** We need to define "NAME_MAX" if it was not present in "limits.h".
988 */
989
990 #ifndef NAME_MAX
991 # ifdef FILENAME_MAX
992 # define NAME_MAX (FILENAME_MAX)
993 # else
994 # define NAME_MAX (260)
995 # endif
996 #endif
997
998 /*
999 ** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
1000 */
1001
1002 #ifndef NULL_INTPTR_T
1003 # define NULL_INTPTR_T ((intptr_t)(0))
1004 #endif
1005
1006 #ifndef BAD_INTPTR_T
1007 # define BAD_INTPTR_T ((intptr_t)(-1))
1008 #endif
1009
1010 /*
1011 ** We need to provide the necessary structures and related types.
1012 */
1013
1014 #ifndef DIRENT_DEFINED
1015 #define DIRENT_DEFINED
1016 typedef struct DIRENT DIRENT;
1017 typedef DIRENT *LPDIRENT;
1018 struct DIRENT {
1019 ino_t d_ino; /* Sequence number, do not use. */
1020 unsigned d_attributes; /* Win32 file attributes. */
1021 char d_name[NAME_MAX + 1]; /* Name within the directory. */
1022 };
1023 #endif
1024
1025 #ifndef DIR_DEFINED
1026 #define DIR_DEFINED
1027 typedef struct DIR DIR;
1028 typedef DIR *LPDIR;
1029 struct DIR {
1030 intptr_t d_handle; /* Value returned by "_findfirst". */
1031 DIRENT d_first; /* DIRENT constructed based on "_findfirst". */
1032 DIRENT d_next; /* DIRENT constructed based on "_findnext". */
1033 };
1034 #endif
1035
1036 /*
1037 ** Provide a macro, for use by the implementation, to determine if a
1038 ** particular directory entry should be skipped over when searching for
1039 ** the next directory entry that should be returned by the readdir() or
1040 ** readdir_r() functions.
1041 */
1042
1043 #ifndef is_filtered
1044 # define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
1045 #endif
1046
1047 /*
1048 ** Provide the function prototype for the POSIX compatiable getenv()
1049 ** function. This function is not thread-safe.
1050 */
1051
1052 extern const char *windirent_getenv(const char *name);
1053
1054 /*
1055 ** Finally, we can provide the function prototypes for the opendir(),
1056 ** readdir(), readdir_r(), and closedir() POSIX functions.
1057 */
1058
1059 extern LPDIR opendir(const char *dirname);
1060 extern LPDIRENT readdir(LPDIR dirp);
1061 extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);
1062 extern INT closedir(LPDIR dirp);
1063
1064 #endif /* defined(WIN32) && defined(_MSC_VER) */
1065
1066 /************************* End test_windirent.h ********************/
1067 /************************* Begin test_windirent.c ******************/
1068 /*
1069 ** 2015 November 30
1070 **
1071 ** The author disclaims copyright to this source code. In place of
@@ -921,12 +1079,11 @@
1079 ** This file contains code to implement most of the opendir() family of
1080 ** POSIX functions on Win32 using the MSVCRT.
1081 */
1082
1083 #if defined(_WIN32) && defined(_MSC_VER)
1084 /* #include "test_windirent.h" */
 
1085
1086 /*
1087 ** Implementation of the POSIX getenv() function using the Win32 API.
1088 ** This function is not thread-safe.
1089 */
@@ -1909,11 +2066,11 @@
2066 # include <utime.h>
2067 #else
2068 # include "windows.h"
2069 # include <io.h>
2070 # include <direct.h>
2071 /* # include "test_windirent.h" */
2072 # define dirent DIRENT
2073 # define timespec TIMESPEC
2074 # define stat _stat
2075 # define mkdir(path,mode) _mkdir(path)
2076 # define lstat(path,buf) _stat(path,buf)
2077
+2 -2
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
11471147
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11481148
** [sqlite_version()] and [sqlite_source_id()].
11491149
*/
11501150
#define SQLITE_VERSION "3.22.0"
11511151
#define SQLITE_VERSION_NUMBER 3022000
1152
-#define SQLITE_SOURCE_ID "2018-01-07 20:38:10 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4"
1152
+#define SQLITE_SOURCE_ID "2018-01-07 21:58:17 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b"
11531153
11541154
/*
11551155
** CAPI3REF: Run-Time Library Version Numbers
11561156
** KEYWORDS: sqlite3_version sqlite3_sourceid
11571157
**
@@ -207211,10 +207211,10 @@
207211207211
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
207212207212
207213207213
/************** End of stmt.c ************************************************/
207214207214
#if __LINE__!=207214
207215207215
#undef SQLITE_SOURCE_ID
207216
-#define SQLITE_SOURCE_ID "2018-01-07 20:38:10 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece1647alt2"
207216
+#define SQLITE_SOURCE_ID "2018-01-07 21:58:17 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4alt2"
207217207217
#endif
207218207218
/* Return the source-id for this library */
207219207219
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
207220207220
/************************** End of sqlite3.c ******************************/
207221207221
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
1147 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1148 ** [sqlite_version()] and [sqlite_source_id()].
1149 */
1150 #define SQLITE_VERSION "3.22.0"
1151 #define SQLITE_VERSION_NUMBER 3022000
1152 #define SQLITE_SOURCE_ID "2018-01-07 20:38:10 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4"
1153
1154 /*
1155 ** CAPI3REF: Run-Time Library Version Numbers
1156 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1157 **
@@ -207211,10 +207211,10 @@
207211 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
207212
207213 /************** End of stmt.c ************************************************/
207214 #if __LINE__!=207214
207215 #undef SQLITE_SOURCE_ID
207216 #define SQLITE_SOURCE_ID "2018-01-07 20:38:10 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece1647alt2"
207217 #endif
207218 /* Return the source-id for this library */
207219 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
207220 /************************** End of sqlite3.c ******************************/
207221
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1147,11 +1147,11 @@
1147 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1148 ** [sqlite_version()] and [sqlite_source_id()].
1149 */
1150 #define SQLITE_VERSION "3.22.0"
1151 #define SQLITE_VERSION_NUMBER 3022000
1152 #define SQLITE_SOURCE_ID "2018-01-07 21:58:17 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b"
1153
1154 /*
1155 ** CAPI3REF: Run-Time Library Version Numbers
1156 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1157 **
@@ -207211,10 +207211,10 @@
207211 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
207212
207213 /************** End of stmt.c ************************************************/
207214 #if __LINE__!=207214
207215 #undef SQLITE_SOURCE_ID
207216 #define SQLITE_SOURCE_ID "2018-01-07 21:58:17 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4alt2"
207217 #endif
207218 /* Return the source-id for this library */
207219 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
207220 /************************** End of sqlite3.c ******************************/
207221
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.22.0"
127127
#define SQLITE_VERSION_NUMBER 3022000
128
-#define SQLITE_SOURCE_ID "2018-01-07 20:38:10 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4"
128
+#define SQLITE_SOURCE_ID "2018-01-07 21:58:17 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
134134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.22.0"
127 #define SQLITE_VERSION_NUMBER 3022000
128 #define SQLITE_SOURCE_ID "2018-01-07 20:38:10 67c4a8c6881e33b830aa27c80e7e3d697a4222939edd77cd5ca77ece16471ea4"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.22.0"
127 #define SQLITE_VERSION_NUMBER 3022000
128 #define SQLITE_SOURCE_ID "2018-01-07 21:58:17 0a50c9e3bb0dbdaaec819ac6453276ba287b475ea322918ddda1ab3a1ec4b58b"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134

Keyboard Shortcuts

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