Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add some "const" keywords in appropriate places. No change in functionality. Eliminates some compiler warnings. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
a6fd491d3a44d308ffc92610450e8a01 |
| User & Date: | jan.nijtmans 2015-09-16 09:18:29.235 |
Context
|
2015-09-16
| ||
| 10:49 | eliminate many unnessary type-casts check-in: 5b456cfa6b user: jan.nijtmans tags: trunk | |
| 09:18 | Add some "const" keywords in appropriate places. No change in functionality. Eliminates some compiler warnings. check-in: a6fd491d3a user: jan.nijtmans tags: trunk | |
| 08:57 | Remove unnecessary end-of-line spacing in various places check-in: 4db19dccd3 user: jan.nijtmans tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
1991 1992 1993 1994 1995 1996 1997 | ** repository and local databases. ** ** If no such variable exists, return zDefault. Or, if zName is the name ** of a setting, then the zDefault is ignored and the default value of the ** setting is returned instead. If zName is a versioned setting, then ** versioned value takes priority. */ | | | 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 |
** repository and local databases.
**
** If no such variable exists, return zDefault. Or, if zName is the name
** of a setting, then the zDefault is ignored and the default value of the
** setting is returned instead. If zName is a versioned setting, then
** versioned value takes priority.
*/
char *db_get(const char *zName, const char *zDefault){
char *z = 0;
const Setting *pSetting = db_find_setting(zName, 0);
if( g.repositoryOpen ){
z = db_text(0, "SELECT value FROM config WHERE name=%Q", zName);
}
if( z==0 && g.zConfigDbName ){
db_swap_connections();
|
| ︙ | ︙ | |||
2016 2017 2018 2019 2020 2021 2022 |
z = fossil_strdup(pSetting->def);
}else{
z = fossil_strdup(zDefault);
}
}
return z;
}
| | | | 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 |
z = fossil_strdup(pSetting->def);
}else{
z = fossil_strdup(zDefault);
}
}
return z;
}
const char *db_get_mtime(const char *zName, const char *zFormat, const char *zDefault){
const char *z = 0;
if( g.repositoryOpen ){
z = db_text(0, "SELECT mtime FROM config WHERE name=%Q", zName);
}
if( z==0 ){
z = zDefault;
}else if( zFormat!=0 ){
z = db_text(0, "SELECT strftime(%Q,%Q,'unixepoch');", zFormat, z);
|
| ︙ | ︙ | |||
2108 2109 2110 2111 2112 2113 2114 |
}
int db_get_boolean(const char *zName, int dflt){
char *zVal = db_get(zName, dflt ? "on" : "off");
if( is_truth(zVal) ) return 1;
if( is_false(zVal) ) return 0;
return dflt;
}
| | | | 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 |
}
int db_get_boolean(const char *zName, int dflt){
char *zVal = db_get(zName, dflt ? "on" : "off");
if( is_truth(zVal) ) return 1;
if( is_false(zVal) ) return 0;
return dflt;
}
char *db_lget(const char *zName, const char *zDefault){
return db_text(zDefault,
"SELECT value FROM vvar WHERE name=%Q", zName);
}
void db_lset(const char *zName, const char *zValue){
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%Q)", zName, zValue);
}
int db_lget_int(const char *zName, int dflt){
return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
|
| ︙ | ︙ |
Changes to src/delta.c.
| ︙ | ︙ | |||
618 619 620 621 622 623 624 |
(void)getInt(&zDelta, &lenDelta);
if( *zDelta!='\n' ){
/* ERROR: size integer not terminated by "\n" */
return -1;
}
zDelta++; lenDelta--;
while( *zDelta && lenDelta>0 ){
| | | | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
(void)getInt(&zDelta, &lenDelta);
if( *zDelta!='\n' ){
/* ERROR: size integer not terminated by "\n" */
return -1;
}
zDelta++; lenDelta--;
while( *zDelta && lenDelta>0 ){
unsigned int cnt;
cnt = getInt(&zDelta, &lenDelta);
switch( zDelta[0] ){
case '@': {
zDelta++; lenDelta--;
(void)getInt(&zDelta, &lenDelta);
if( lenDelta>0 && zDelta[0]!=',' ){
/* ERROR: copy command not terminated by ',' */
return -1;
}
zDelta++; lenDelta--;
nCopy += cnt;
break;
|
| ︙ | ︙ |
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
427 428 429 430 431 432 433 |
free(zToFree);
}
db_finalize(&q);
db_end_transaction(1); /* ROLLBACK */
}
/*
| | | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
free(zToFree);
}
db_finalize(&q);
db_end_transaction(1); /* ROLLBACK */
}
/*
** Do a diff of a single file named in zFile against the
** version of this file held in the undo buffer.
**
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
** command zDiffCmd to do the diffing.
**
** When using an external diff program, zBinGlob contains the GLOB patterns
** for file names to treat as binary. If fIncludeBinary is zero, these files
|
| ︙ | ︙ |
Changes to src/doc.c.
| ︙ | ︙ | |||
542 543 544 545 546 547 548 |
Blob filebody; /* Content of the documentation file */
Blob title; /* Document title */
int nMiss = (-1); /* Failed attempts to find the document */
static const char *const azSuffix[] = {
"index.html", "index.wiki", "index.md"
#ifdef FOSSIL_ENABLE_TH1_DOCS
, "index.th1"
| | | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
Blob filebody; /* Content of the documentation file */
Blob title; /* Document title */
int nMiss = (-1); /* Failed attempts to find the document */
static const char *const azSuffix[] = {
"index.html", "index.wiki", "index.md"
#ifdef FOSSIL_ENABLE_TH1_DOCS
, "index.th1"
#endif
};
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
blob_init(&title, 0, 0);
db_begin_transaction();
while( rid==0 && (++nMiss)<=ArraySize(azSuffix) ){
|
| ︙ | ︙ |
Changes to src/json.c.
| ︙ | ︙ | |||
695 696 697 698 699 700 701 |
*/
void json_main_bootstrap(){
cson_value * v;
assert( (NULL == g.json.gc.v) &&
"json_main_bootstrap() was called twice!" );
g.json.timerId = fossil_timer_start();
| | | 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 |
*/
void json_main_bootstrap(){
cson_value * v;
assert( (NULL == g.json.gc.v) &&
"json_main_bootstrap() was called twice!" );
g.json.timerId = fossil_timer_start();
/* g.json.gc is our "garbage collector" - where we put JSON values
which need a long lifetime but don't have a logical parent to put
them in.
*/
v = cson_value_new_array();
g.json.gc.v = v;
g.json.gc.a = cson_value_get_array(v);
|
| ︙ | ︙ |
Changes to src/linenoise.c.
| ︙ | ︙ | |||
116 117 118 119 120 121 122 | #include <sys/types.h> #include <sys/ioctl.h> #include <unistd.h> #include "linenoise.h" #define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100 #define LINENOISE_MAX_LINE 4096 | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "linenoise.h"
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
#define LINENOISE_MAX_LINE 4096
static const char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
static linenoiseCompletionCallback *completionCallback = NULL;
static struct termios orig_termios; /* In order to restore at exit.*/
static int rawmode = 0; /* For atexit() function to check if restore is needed*/
static int mlmode = 0; /* Multi line mode. Default is single line. */
static int atexit_registered = 0; /* Register atexit just 1 time. */
static int history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN;
|
| ︙ | ︙ | |||
918 919 920 921 922 923 924 |
nread = read(STDIN_FILENO,&c,1);
if (nread <= 0) continue;
memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */
quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
printf("'%c' %02x (%d) (type quit to exit)\n",
| | | 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 |
nread = read(STDIN_FILENO,&c,1);
if (nread <= 0) continue;
memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */
quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
printf("'%c' %02x (%d) (type quit to exit)\n",
isprint((int)c) ? c : '?', (int)c, (int)c);
printf("\r"); /* Go left edge manually, we are in raw mode. */
fflush(stdout);
}
disableRawMode(STDIN_FILENO);
}
/* This function calls the line editing function linenoiseEdit() using
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
876 877 878 879 880 881 882 |
break;
}
}
return zReturn;
}
/*
| | | 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
break;
}
}
return zReturn;
}
/*
** Look for multiple occurrences of a command-line option with the
** corresponding argument.
**
** Return a malloc allocated array of pointers to the arguments.
**
** pnUsedArgs is used to store the number of matched arguments.
**
** Caller is responsible to free allocated memory.
|
| ︙ | ︙ |
Changes to src/skins.c.
| ︙ | ︙ | |||
248 249 250 251 252 253 254 |
unsigned int skin_id(const char *zResource){
unsigned int h = 0;
if( zAltSkinDir ){
h = skin_hash(0, zAltSkinDir);
}else if( pAltSkin ){
h = skin_hash(0, pAltSkin->zLabel);
}else{
| | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
unsigned int skin_id(const char *zResource){
unsigned int h = 0;
if( zAltSkinDir ){
h = skin_hash(0, zAltSkinDir);
}else if( pAltSkin ){
h = skin_hash(0, pAltSkin->zLabel);
}else{
const char *zMTime = db_get_mtime(zResource, 0, 0);
h = skin_hash(0, zMTime);
fossil_free(zMTime);
}
h = skin_hash(h, MANIFEST_UUID);
return h;
}
|
| ︙ | ︙ |