Fossil SCM

Fix compiler warnings on windows. Fix the file_directory_size() function so that it works on windows.

drh 2018-06-26 11:54 trunk
Commit 6a7d2ad8f1dd5c542eba0b885418328803d8d80252382c3fb36b8c02803dd3ce
+1 -2
--- src/email.c
+++ src/email.c
@@ -1177,12 +1177,12 @@
11771177
if( PB("st") ) ssub[nsub++] = 't';
11781178
if( PB("sw") ) ssub[nsub++] = 'w';
11791179
ssub[nsub] = 0;
11801180
if( g.perm.Admin ){
11811181
const char *suname = PT("suname");
1182
- if( suname && suname[0]==0 ) suname = 0;
11831182
int sverified = PB("sverified");
1183
+ if( suname && suname[0]==0 ) suname = 0;
11841184
db_multi_exec(
11851185
"UPDATE subscriber SET"
11861186
" sdonotcall=%d,"
11871187
" sdigest=%d,"
11881188
" ssub=%Q,"
@@ -2035,11 +2035,10 @@
20352035
** to the entire mailing list (including people who have elected to
20362036
** receive no announcements or notifications of any kind, or to
20372037
** individual email to anyone.
20382038
*/
20392039
void announce_page(void){
2040
- const char *zTo = PT("to");
20412040
login_check_credentials();
20422041
if( !g.perm.Announce ){
20432042
login_needed(0);
20442043
return;
20452044
}
20462045
--- src/email.c
+++ src/email.c
@@ -1177,12 +1177,12 @@
1177 if( PB("st") ) ssub[nsub++] = 't';
1178 if( PB("sw") ) ssub[nsub++] = 'w';
1179 ssub[nsub] = 0;
1180 if( g.perm.Admin ){
1181 const char *suname = PT("suname");
1182 if( suname && suname[0]==0 ) suname = 0;
1183 int sverified = PB("sverified");
 
1184 db_multi_exec(
1185 "UPDATE subscriber SET"
1186 " sdonotcall=%d,"
1187 " sdigest=%d,"
1188 " ssub=%Q,"
@@ -2035,11 +2035,10 @@
2035 ** to the entire mailing list (including people who have elected to
2036 ** receive no announcements or notifications of any kind, or to
2037 ** individual email to anyone.
2038 */
2039 void announce_page(void){
2040 const char *zTo = PT("to");
2041 login_check_credentials();
2042 if( !g.perm.Announce ){
2043 login_needed(0);
2044 return;
2045 }
2046
--- src/email.c
+++ src/email.c
@@ -1177,12 +1177,12 @@
1177 if( PB("st") ) ssub[nsub++] = 't';
1178 if( PB("sw") ) ssub[nsub++] = 'w';
1179 ssub[nsub] = 0;
1180 if( g.perm.Admin ){
1181 const char *suname = PT("suname");
 
1182 int sverified = PB("sverified");
1183 if( suname && suname[0]==0 ) suname = 0;
1184 db_multi_exec(
1185 "UPDATE subscriber SET"
1186 " sdonotcall=%d,"
1187 " sdigest=%d,"
1188 " ssub=%Q,"
@@ -2035,11 +2035,10 @@
2035 ** to the entire mailing list (including people who have elected to
2036 ** receive no announcements or notifications of any kind, or to
2037 ** individual email to anyone.
2038 */
2039 void announce_page(void){
 
2040 login_check_credentials();
2041 if( !g.perm.Announce ){
2042 login_needed(0);
2043 return;
2044 }
2045
+7 -2
--- src/file.c
+++ src/file.c
@@ -1621,11 +1621,11 @@
16211621
** Count the number of objects (files and subdirectores) in a given
16221622
** directory. Return the count. Return -1 of the object is not a
16231623
** directory.
16241624
*/
16251625
int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
1626
- char *zNative;
1626
+ void *zNative;
16271627
DIR *d;
16281628
int n = -1;
16291629
zNative = fossil_utf8_to_path(zDir,1);
16301630
d = opendir(zNative);
16311631
if( d ){
@@ -1632,11 +1632,16 @@
16321632
struct dirent *pEntry;
16331633
n = 0;
16341634
while( (pEntry=readdir(d))!=0 ){
16351635
if( pEntry->d_name[0]==0 ) continue;
16361636
if( omitDotFiles && pEntry->d_name[0]=='.' ) continue;
1637
- if( zGlob && sqlite3_strglob(zGlob, pEntry->d_name)!=0 ) continue;
1637
+ if( zGlob ){
1638
+ char *zUtf8 = fossil_path_to_utf8(pEntry->d_name);
1639
+ int rc = sqlite3_strglob(zGlob, zUtf8);
1640
+ fossil_path_free(zUtf8);
1641
+ if( rc ) continue;
1642
+ }
16381643
n++;
16391644
}
16401645
closedir(d);
16411646
}
16421647
fossil_path_free(zNative);
16431648
--- src/file.c
+++ src/file.c
@@ -1621,11 +1621,11 @@
1621 ** Count the number of objects (files and subdirectores) in a given
1622 ** directory. Return the count. Return -1 of the object is not a
1623 ** directory.
1624 */
1625 int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
1626 char *zNative;
1627 DIR *d;
1628 int n = -1;
1629 zNative = fossil_utf8_to_path(zDir,1);
1630 d = opendir(zNative);
1631 if( d ){
@@ -1632,11 +1632,16 @@
1632 struct dirent *pEntry;
1633 n = 0;
1634 while( (pEntry=readdir(d))!=0 ){
1635 if( pEntry->d_name[0]==0 ) continue;
1636 if( omitDotFiles && pEntry->d_name[0]=='.' ) continue;
1637 if( zGlob && sqlite3_strglob(zGlob, pEntry->d_name)!=0 ) continue;
 
 
 
 
 
1638 n++;
1639 }
1640 closedir(d);
1641 }
1642 fossil_path_free(zNative);
1643
--- src/file.c
+++ src/file.c
@@ -1621,11 +1621,11 @@
1621 ** Count the number of objects (files and subdirectores) in a given
1622 ** directory. Return the count. Return -1 of the object is not a
1623 ** directory.
1624 */
1625 int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
1626 void *zNative;
1627 DIR *d;
1628 int n = -1;
1629 zNative = fossil_utf8_to_path(zDir,1);
1630 d = opendir(zNative);
1631 if( d ){
@@ -1632,11 +1632,16 @@
1632 struct dirent *pEntry;
1633 n = 0;
1634 while( (pEntry=readdir(d))!=0 ){
1635 if( pEntry->d_name[0]==0 ) continue;
1636 if( omitDotFiles && pEntry->d_name[0]=='.' ) continue;
1637 if( zGlob ){
1638 char *zUtf8 = fossil_path_to_utf8(pEntry->d_name);
1639 int rc = sqlite3_strglob(zGlob, zUtf8);
1640 fossil_path_free(zUtf8);
1641 if( rc ) continue;
1642 }
1643 n++;
1644 }
1645 closedir(d);
1646 }
1647 fossil_path_free(zNative);
1648
+4 -2
--- src/forum.c
+++ src/forum.c
@@ -77,16 +77,17 @@
7777
forum_verify_schema();
7878
style_header("Forum");
7979
itemId = atoi(PD("item","0"));
8080
if( itemId>0 ){
8181
int iUp;
82
+ double rNow;
8283
style_submenu_element("Topics", "%R/forum");
8384
iUp = db_int(0, "SELECT inreplyto FROM forumpost WHERE mpostid=%d", itemId);
8485
if( iUp ){
8586
style_submenu_element("Parent", "%R/forum?item=%d", iUp);
8687
}
87
- double rNow = db_double(0.0, "SELECT julianday('now')");
88
+ rNow = db_double(0.0, "SELECT julianday('now')");
8889
/* Show the post given by itemId and all its descendents */
8990
db_prepare(&q,
9091
"WITH RECURSIVE"
9192
" post(id,uname,mstat,mime,ipaddr,parent,mbody,depth,mtime) AS ("
9293
" SELECT mpostid, uname, mstatus, mimetype, ipaddr, inreplyto, mbody,"
@@ -254,13 +255,14 @@
254255
*/
255256
void forum_edit_page(void){
256257
int itemId;
257258
int parentId;
258259
char *zErr = 0;
259
- login_check_credentials();
260260
const char *zMime;
261261
const char *zSub;
262
+
263
+ login_check_credentials();
262264
if( !g.perm.WrForum ){ login_needed(g.anon.WrForum); return; }
263265
forum_verify_schema();
264266
itemId = atoi(PD("item","0"));
265267
parentId = atoi(PD("replyto","0"));
266268
if( P("cancel")!=0 ){
267269
--- src/forum.c
+++ src/forum.c
@@ -77,16 +77,17 @@
77 forum_verify_schema();
78 style_header("Forum");
79 itemId = atoi(PD("item","0"));
80 if( itemId>0 ){
81 int iUp;
 
82 style_submenu_element("Topics", "%R/forum");
83 iUp = db_int(0, "SELECT inreplyto FROM forumpost WHERE mpostid=%d", itemId);
84 if( iUp ){
85 style_submenu_element("Parent", "%R/forum?item=%d", iUp);
86 }
87 double rNow = db_double(0.0, "SELECT julianday('now')");
88 /* Show the post given by itemId and all its descendents */
89 db_prepare(&q,
90 "WITH RECURSIVE"
91 " post(id,uname,mstat,mime,ipaddr,parent,mbody,depth,mtime) AS ("
92 " SELECT mpostid, uname, mstatus, mimetype, ipaddr, inreplyto, mbody,"
@@ -254,13 +255,14 @@
254 */
255 void forum_edit_page(void){
256 int itemId;
257 int parentId;
258 char *zErr = 0;
259 login_check_credentials();
260 const char *zMime;
261 const char *zSub;
 
 
262 if( !g.perm.WrForum ){ login_needed(g.anon.WrForum); return; }
263 forum_verify_schema();
264 itemId = atoi(PD("item","0"));
265 parentId = atoi(PD("replyto","0"));
266 if( P("cancel")!=0 ){
267
--- src/forum.c
+++ src/forum.c
@@ -77,16 +77,17 @@
77 forum_verify_schema();
78 style_header("Forum");
79 itemId = atoi(PD("item","0"));
80 if( itemId>0 ){
81 int iUp;
82 double rNow;
83 style_submenu_element("Topics", "%R/forum");
84 iUp = db_int(0, "SELECT inreplyto FROM forumpost WHERE mpostid=%d", itemId);
85 if( iUp ){
86 style_submenu_element("Parent", "%R/forum?item=%d", iUp);
87 }
88 rNow = db_double(0.0, "SELECT julianday('now')");
89 /* Show the post given by itemId and all its descendents */
90 db_prepare(&q,
91 "WITH RECURSIVE"
92 " post(id,uname,mstat,mime,ipaddr,parent,mbody,depth,mtime) AS ("
93 " SELECT mpostid, uname, mstatus, mimetype, ipaddr, inreplyto, mbody,"
@@ -254,13 +255,14 @@
255 */
256 void forum_edit_page(void){
257 int itemId;
258 int parentId;
259 char *zErr = 0;
 
260 const char *zMime;
261 const char *zSub;
262
263 login_check_credentials();
264 if( !g.perm.WrForum ){ login_needed(g.anon.WrForum); return; }
265 forum_verify_schema();
266 itemId = atoi(PD("item","0"));
267 parentId = atoi(PD("replyto","0"));
268 if( P("cancel")!=0 ){
269
--- src/security_audit.c
+++ src/security_audit.c
@@ -407,14 +407,14 @@
407407
**
408408
** Show the content of the error log. Only the administrator can view
409409
** this page.
410410
*/
411411
void errorlog_page(void){
412
- login_check_credentials();
413412
i64 szFile;
414413
FILE *in;
415414
char z[10000];
415
+ login_check_credentials();
416416
if( !g.perm.Setup && !g.perm.Admin ){
417417
login_needed(0);
418418
return;
419419
}
420420
style_header("Server Error Log");
421421
--- src/security_audit.c
+++ src/security_audit.c
@@ -407,14 +407,14 @@
407 **
408 ** Show the content of the error log. Only the administrator can view
409 ** this page.
410 */
411 void errorlog_page(void){
412 login_check_credentials();
413 i64 szFile;
414 FILE *in;
415 char z[10000];
 
416 if( !g.perm.Setup && !g.perm.Admin ){
417 login_needed(0);
418 return;
419 }
420 style_header("Server Error Log");
421
--- src/security_audit.c
+++ src/security_audit.c
@@ -407,14 +407,14 @@
407 **
408 ** Show the content of the error log. Only the administrator can view
409 ** this page.
410 */
411 void errorlog_page(void){
 
412 i64 szFile;
413 FILE *in;
414 char z[10000];
415 login_check_credentials();
416 if( !g.perm.Setup && !g.perm.Admin ){
417 login_needed(0);
418 return;
419 }
420 style_header("Server Error Log");
421

Keyboard Shortcuts

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