Fossil SCM

Add some "const" keywords in appropriate places. No change in functionality. Eliminates some compiler warnings.

jan.nijtmans 2015-09-16 09:18 trunk
Commit a6fd491d3a44d308ffc92610450e8a0140b3f1e7
+5 -5
--- src/db.c
+++ src/db.c
@@ -1993,11 +1993,11 @@
19931993
** If no such variable exists, return zDefault. Or, if zName is the name
19941994
** of a setting, then the zDefault is ignored and the default value of the
19951995
** setting is returned instead. If zName is a versioned setting, then
19961996
** versioned value takes priority.
19971997
*/
1998
-char *db_get(const char *zName, char *zDefault){
1998
+char *db_get(const char *zName, const char *zDefault){
19991999
char *z = 0;
20002000
const Setting *pSetting = db_find_setting(zName, 0);
20012001
if( g.repositoryOpen ){
20022002
z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName);
20032003
}
@@ -2018,12 +2018,12 @@
20182018
z = fossil_strdup(zDefault);
20192019
}
20202020
}
20212021
return z;
20222022
}
2023
-char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
2024
- char *z = 0;
2023
+const char *db_get_mtime(const char *zName, const char *zFormat, const char *zDefault){
2024
+ const char *z = 0;
20252025
if( g.repositoryOpen ){
20262026
z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
20272027
}
20282028
if( z==0 ){
20292029
z = zDefault;
@@ -2110,12 +2110,12 @@
21102110
char *zVal = db_get(zName, dflt ? "on" : "off");
21112111
if( is_truth(zVal) ) return 1;
21122112
if( is_false(zVal) ) return 0;
21132113
return dflt;
21142114
}
2115
-char *db_lget(const char *zName, char *zDefault){
2116
- return db_text((char*)zDefault,
2115
+char *db_lget(const char *zName, const char *zDefault){
2116
+ return db_text(zDefault,
21172117
"SELECT value FROM vvar WHERE name=%Q", zName);
21182118
}
21192119
void db_lset(const char *zName, const char *zValue){
21202120
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%Q)", zName, zValue);
21212121
}
21222122
--- src/db.c
+++ src/db.c
@@ -1993,11 +1993,11 @@
1993 ** If no such variable exists, return zDefault. Or, if zName is the name
1994 ** of a setting, then the zDefault is ignored and the default value of the
1995 ** setting is returned instead. If zName is a versioned setting, then
1996 ** versioned value takes priority.
1997 */
1998 char *db_get(const char *zName, char *zDefault){
1999 char *z = 0;
2000 const Setting *pSetting = db_find_setting(zName, 0);
2001 if( g.repositoryOpen ){
2002 z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName);
2003 }
@@ -2018,12 +2018,12 @@
2018 z = fossil_strdup(zDefault);
2019 }
2020 }
2021 return z;
2022 }
2023 char *db_get_mtime(const char *zName, char *zFormat, char *zDefault){
2024 char *z = 0;
2025 if( g.repositoryOpen ){
2026 z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
2027 }
2028 if( z==0 ){
2029 z = zDefault;
@@ -2110,12 +2110,12 @@
2110 char *zVal = db_get(zName, dflt ? "on" : "off");
2111 if( is_truth(zVal) ) return 1;
2112 if( is_false(zVal) ) return 0;
2113 return dflt;
2114 }
2115 char *db_lget(const char *zName, char *zDefault){
2116 return db_text((char*)zDefault,
2117 "SELECT value FROM vvar WHERE name=%Q", zName);
2118 }
2119 void db_lset(const char *zName, const char *zValue){
2120 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%Q)", zName, zValue);
2121 }
2122
--- src/db.c
+++ src/db.c
@@ -1993,11 +1993,11 @@
1993 ** If no such variable exists, return zDefault. Or, if zName is the name
1994 ** of a setting, then the zDefault is ignored and the default value of the
1995 ** setting is returned instead. If zName is a versioned setting, then
1996 ** versioned value takes priority.
1997 */
1998 char *db_get(const char *zName, const char *zDefault){
1999 char *z = 0;
2000 const Setting *pSetting = db_find_setting(zName, 0);
2001 if( g.repositoryOpen ){
2002 z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName);
2003 }
@@ -2018,12 +2018,12 @@
2018 z = fossil_strdup(zDefault);
2019 }
2020 }
2021 return z;
2022 }
2023 const char *db_get_mtime(const char *zName, const char *zFormat, const char *zDefault){
2024 const char *z = 0;
2025 if( g.repositoryOpen ){
2026 z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
2027 }
2028 if( z==0 ){
2029 z = zDefault;
@@ -2110,12 +2110,12 @@
2110 char *zVal = db_get(zName, dflt ? "on" : "off");
2111 if( is_truth(zVal) ) return 1;
2112 if( is_false(zVal) ) return 0;
2113 return dflt;
2114 }
2115 char *db_lget(const char *zName, const char *zDefault){
2116 return db_text(zDefault,
2117 "SELECT value FROM vvar WHERE name=%Q", zName);
2118 }
2119 void db_lset(const char *zName, const char *zValue){
2120 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%Q)", zName, zValue);
2121 }
2122
+2 -2
--- src/delta.c
+++ src/delta.c
@@ -620,16 +620,16 @@
620620
/* ERROR: size integer not terminated by "\n" */
621621
return -1;
622622
}
623623
zDelta++; lenDelta--;
624624
while( *zDelta && lenDelta>0 ){
625
- unsigned int cnt, ofst;
625
+ unsigned int cnt;
626626
cnt = getInt(&zDelta, &lenDelta);
627627
switch( zDelta[0] ){
628628
case '@': {
629629
zDelta++; lenDelta--;
630
- ofst = getInt(&zDelta, &lenDelta);
630
+ (void)getInt(&zDelta, &lenDelta);
631631
if( lenDelta>0 && zDelta[0]!=',' ){
632632
/* ERROR: copy command not terminated by ',' */
633633
return -1;
634634
}
635635
zDelta++; lenDelta--;
636636
--- src/delta.c
+++ src/delta.c
@@ -620,16 +620,16 @@
620 /* ERROR: size integer not terminated by "\n" */
621 return -1;
622 }
623 zDelta++; lenDelta--;
624 while( *zDelta && lenDelta>0 ){
625 unsigned int cnt, ofst;
626 cnt = getInt(&zDelta, &lenDelta);
627 switch( zDelta[0] ){
628 case '@': {
629 zDelta++; lenDelta--;
630 ofst = getInt(&zDelta, &lenDelta);
631 if( lenDelta>0 && zDelta[0]!=',' ){
632 /* ERROR: copy command not terminated by ',' */
633 return -1;
634 }
635 zDelta++; lenDelta--;
636
--- src/delta.c
+++ src/delta.c
@@ -620,16 +620,16 @@
620 /* ERROR: size integer not terminated by "\n" */
621 return -1;
622 }
623 zDelta++; lenDelta--;
624 while( *zDelta && lenDelta>0 ){
625 unsigned int cnt;
626 cnt = getInt(&zDelta, &lenDelta);
627 switch( zDelta[0] ){
628 case '@': {
629 zDelta++; lenDelta--;
630 (void)getInt(&zDelta, &lenDelta);
631 if( lenDelta>0 && zDelta[0]!=',' ){
632 /* ERROR: copy command not terminated by ',' */
633 return -1;
634 }
635 zDelta++; lenDelta--;
636
+1 -1
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -429,11 +429,11 @@
429429
db_finalize(&q);
430430
db_end_transaction(1); /* ROLLBACK */
431431
}
432432
433433
/*
434
-** Do a diff of a single file named in zFile against the
434
+** Do a diff of a single file named in zFile against the
435435
** version of this file held in the undo buffer.
436436
**
437437
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
438438
** command zDiffCmd to do the diffing.
439439
**
440440
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -429,11 +429,11 @@
429 db_finalize(&q);
430 db_end_transaction(1); /* ROLLBACK */
431 }
432
433 /*
434 ** Do a diff of a single file named in zFile against the
435 ** version of this file held in the undo buffer.
436 **
437 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
438 ** command zDiffCmd to do the diffing.
439 **
440
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -429,11 +429,11 @@
429 db_finalize(&q);
430 db_end_transaction(1); /* ROLLBACK */
431 }
432
433 /*
434 ** Do a diff of a single file named in zFile against the
435 ** version of this file held in the undo buffer.
436 **
437 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
438 ** command zDiffCmd to do the diffing.
439 **
440
+1 -1
--- src/doc.c
+++ src/doc.c
@@ -544,11 +544,11 @@
544544
int nMiss = (-1); /* Failed attempts to find the document */
545545
static const char *const azSuffix[] = {
546546
"index.html", "index.wiki", "index.md"
547547
#ifdef FOSSIL_ENABLE_TH1_DOCS
548548
, "index.th1"
549
-#endif
549
+#endif
550550
};
551551
552552
login_check_credentials();
553553
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
554554
blob_init(&title, 0, 0);
555555
--- src/doc.c
+++ src/doc.c
@@ -544,11 +544,11 @@
544 int nMiss = (-1); /* Failed attempts to find the document */
545 static const char *const azSuffix[] = {
546 "index.html", "index.wiki", "index.md"
547 #ifdef FOSSIL_ENABLE_TH1_DOCS
548 , "index.th1"
549 #endif
550 };
551
552 login_check_credentials();
553 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
554 blob_init(&title, 0, 0);
555
--- src/doc.c
+++ src/doc.c
@@ -544,11 +544,11 @@
544 int nMiss = (-1); /* Failed attempts to find the document */
545 static const char *const azSuffix[] = {
546 "index.html", "index.wiki", "index.md"
547 #ifdef FOSSIL_ENABLE_TH1_DOCS
548 , "index.th1"
549 #endif
550 };
551
552 login_check_credentials();
553 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
554 blob_init(&title, 0, 0);
555
+1 -1
--- src/json.c
+++ src/json.c
@@ -697,11 +697,11 @@
697697
cson_value * v;
698698
assert( (NULL == g.json.gc.v) &&
699699
"json_main_bootstrap() was called twice!" );
700700
701701
g.json.timerId = fossil_timer_start();
702
-
702
+
703703
/* g.json.gc is our "garbage collector" - where we put JSON values
704704
which need a long lifetime but don't have a logical parent to put
705705
them in.
706706
*/
707707
v = cson_value_new_array();
708708
--- src/json.c
+++ src/json.c
@@ -697,11 +697,11 @@
697 cson_value * v;
698 assert( (NULL == g.json.gc.v) &&
699 "json_main_bootstrap() was called twice!" );
700
701 g.json.timerId = fossil_timer_start();
702
703 /* g.json.gc is our "garbage collector" - where we put JSON values
704 which need a long lifetime but don't have a logical parent to put
705 them in.
706 */
707 v = cson_value_new_array();
708
--- src/json.c
+++ src/json.c
@@ -697,11 +697,11 @@
697 cson_value * v;
698 assert( (NULL == g.json.gc.v) &&
699 "json_main_bootstrap() was called twice!" );
700
701 g.json.timerId = fossil_timer_start();
702
703 /* g.json.gc is our "garbage collector" - where we put JSON values
704 which need a long lifetime but don't have a logical parent to put
705 them in.
706 */
707 v = cson_value_new_array();
708
+2 -2
--- src/linenoise.c
+++ src/linenoise.c
@@ -118,11 +118,11 @@
118118
#include <unistd.h>
119119
#include "linenoise.h"
120120
121121
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
122122
#define LINENOISE_MAX_LINE 4096
123
-static char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
123
+static const char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
124124
static linenoiseCompletionCallback *completionCallback = NULL;
125125
126126
static struct termios orig_termios; /* In order to restore at exit.*/
127127
static int rawmode = 0; /* For atexit() function to check if restore is needed*/
128128
static int mlmode = 0; /* Multi line mode. Default is single line. */
@@ -920,11 +920,11 @@
920920
memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */
921921
quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
922922
if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
923923
924924
printf("'%c' %02x (%d) (type quit to exit)\n",
925
- isprint(c) ? c : '?', (int)c, (int)c);
925
+ isprint((int)c) ? c : '?', (int)c, (int)c);
926926
printf("\r"); /* Go left edge manually, we are in raw mode. */
927927
fflush(stdout);
928928
}
929929
disableRawMode(STDIN_FILENO);
930930
}
931931
--- src/linenoise.c
+++ src/linenoise.c
@@ -118,11 +118,11 @@
118 #include <unistd.h>
119 #include "linenoise.h"
120
121 #define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
122 #define LINENOISE_MAX_LINE 4096
123 static char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
124 static linenoiseCompletionCallback *completionCallback = NULL;
125
126 static struct termios orig_termios; /* In order to restore at exit.*/
127 static int rawmode = 0; /* For atexit() function to check if restore is needed*/
128 static int mlmode = 0; /* Multi line mode. Default is single line. */
@@ -920,11 +920,11 @@
920 memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */
921 quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
922 if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
923
924 printf("'%c' %02x (%d) (type quit to exit)\n",
925 isprint(c) ? c : '?', (int)c, (int)c);
926 printf("\r"); /* Go left edge manually, we are in raw mode. */
927 fflush(stdout);
928 }
929 disableRawMode(STDIN_FILENO);
930 }
931
--- src/linenoise.c
+++ src/linenoise.c
@@ -118,11 +118,11 @@
118 #include <unistd.h>
119 #include "linenoise.h"
120
121 #define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
122 #define LINENOISE_MAX_LINE 4096
123 static const char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
124 static linenoiseCompletionCallback *completionCallback = NULL;
125
126 static struct termios orig_termios; /* In order to restore at exit.*/
127 static int rawmode = 0; /* For atexit() function to check if restore is needed*/
128 static int mlmode = 0; /* Multi line mode. Default is single line. */
@@ -920,11 +920,11 @@
920 memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */
921 quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
922 if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
923
924 printf("'%c' %02x (%d) (type quit to exit)\n",
925 isprint((int)c) ? c : '?', (int)c, (int)c);
926 printf("\r"); /* Go left edge manually, we are in raw mode. */
927 fflush(stdout);
928 }
929 disableRawMode(STDIN_FILENO);
930 }
931
+1 -1
--- src/main.c
+++ src/main.c
@@ -878,11 +878,11 @@
878878
}
879879
return zReturn;
880880
}
881881
882882
/*
883
-** Look for multiple occurrences of a command-line option with the
883
+** Look for multiple occurrences of a command-line option with the
884884
** corresponding argument.
885885
**
886886
** Return a malloc allocated array of pointers to the arguments.
887887
**
888888
** pnUsedArgs is used to store the number of matched arguments.
889889
--- src/main.c
+++ src/main.c
@@ -878,11 +878,11 @@
878 }
879 return zReturn;
880 }
881
882 /*
883 ** Look for multiple occurrences of a command-line option with the
884 ** corresponding argument.
885 **
886 ** Return a malloc allocated array of pointers to the arguments.
887 **
888 ** pnUsedArgs is used to store the number of matched arguments.
889
--- src/main.c
+++ src/main.c
@@ -878,11 +878,11 @@
878 }
879 return zReturn;
880 }
881
882 /*
883 ** Look for multiple occurrences of a command-line option with the
884 ** corresponding argument.
885 **
886 ** Return a malloc allocated array of pointers to the arguments.
887 **
888 ** pnUsedArgs is used to store the number of matched arguments.
889
+1 -1
--- src/skins.c
+++ src/skins.c
@@ -250,11 +250,11 @@
250250
if( zAltSkinDir ){
251251
h = skin_hash(0, zAltSkinDir);
252252
}else if( pAltSkin ){
253253
h = skin_hash(0, pAltSkin->zLabel);
254254
}else{
255
- char *zMTime = db_get_mtime(zResource, 0, 0);
255
+ const char *zMTime = db_get_mtime(zResource, 0, 0);
256256
h = skin_hash(0, zMTime);
257257
fossil_free(zMTime);
258258
}
259259
h = skin_hash(h, MANIFEST_UUID);
260260
return h;
261261
--- src/skins.c
+++ src/skins.c
@@ -250,11 +250,11 @@
250 if( zAltSkinDir ){
251 h = skin_hash(0, zAltSkinDir);
252 }else if( pAltSkin ){
253 h = skin_hash(0, pAltSkin->zLabel);
254 }else{
255 char *zMTime = db_get_mtime(zResource, 0, 0);
256 h = skin_hash(0, zMTime);
257 fossil_free(zMTime);
258 }
259 h = skin_hash(h, MANIFEST_UUID);
260 return h;
261
--- src/skins.c
+++ src/skins.c
@@ -250,11 +250,11 @@
250 if( zAltSkinDir ){
251 h = skin_hash(0, zAltSkinDir);
252 }else if( pAltSkin ){
253 h = skin_hash(0, pAltSkin->zLabel);
254 }else{
255 const char *zMTime = db_get_mtime(zResource, 0, 0);
256 h = skin_hash(0, zMTime);
257 fossil_free(zMTime);
258 }
259 h = skin_hash(h, MANIFEST_UUID);
260 return h;
261

Keyboard Shortcuts

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