Fossil SCM

Eliminate some unused variables. "int const" -> "const int" and "char const" -> "const char"

jan.nijtmans 2013-07-22 09:37 trunk
Commit b2640f61d7849fdbfa0f6df92714628bab36b20d
1 file changed +22 -25
+22 -25
--- src/timeline.c
+++ src/timeline.c
@@ -1841,11 +1841,11 @@
18411841
/*
18421842
** Helper for stats_report_by_month_year(), which generates a list of
18431843
** week numbers. zTimeframe should be either a timeframe in the form YYYY
18441844
** or YYYY-MM.
18451845
*/
1846
-static void stats_report_output_week_links(char const * zTimeframe){
1846
+static void stats_report_output_week_links(const char * zTimeframe){
18471847
Stmt stWeek = empty_Stmt;
18481848
char yearPart[5] = {0,0,0,0,0};
18491849
memcpy(yearPart, zTimeframe, 4);
18501850
db_prepare(&stWeek,
18511851
"SELECT DISTINCT strftime('%%W',mtime) AS wk, "
@@ -1855,12 +1855,12 @@
18551855
"WHERE ym=%Q AND mtime < current_timestamp "
18561856
"GROUP BY wk ORDER BY wk",
18571857
strlen(zTimeframe),
18581858
zTimeframe);
18591859
while( SQLITE_ROW == db_step(&stWeek) ){
1860
- char const * zWeek = db_column_text(&stWeek,0);
1861
- int const nCount = db_column_int(&stWeek,1);
1860
+ const char * zWeek = db_column_text(&stWeek,0);
1861
+ const int nCount = db_column_int(&stWeek,1);
18621862
cgi_printf("<a href='%s/timeline?"
18631863
"yw=%t-%t&n=%d'>%s</a>",
18641864
g.zTop, yearPart, zWeek,
18651865
nCount, zWeek);
18661866
}
@@ -1874,19 +1874,18 @@
18741874
** then the report is restricted to events created by the named user
18751875
** account.
18761876
*/
18771877
static void stats_report_by_month_year(char includeMonth,
18781878
char includeWeeks,
1879
- char const * zUserName){
1879
+ const char * zUserName){
18801880
Stmt query = empty_Stmt;
1881
- int const nPixelsPerEvent = 1; /* for sizing the "graph" part */
18821881
int nRowNumber = 0; /* current TR number */
18831882
int nEventTotal = 0; /* Total event count */
18841883
int rowClass = 0; /* counter for alternating
18851884
row colors */
18861885
Blob sql = empty_blob; /* SQL */
1887
- char const * zTimeLabel = includeMonth ? "Year/Month" : "Year";
1886
+ const char * zTimeLabel = includeMonth ? "Year/Month" : "Year";
18881887
char zPrevYear[5] = {0}; /* For keeping track of when
18891888
we change years while looping */
18901889
int nEventsPerYear = 0; /* Total event count for the
18911890
current year */
18921891
char showYearTotal = 0; /* Flag telling us when to show
@@ -1924,20 +1923,20 @@
19241923
Run the query twice. The first time we calculate the maximum
19251924
number of events for a given row. Maybe someone with better SQL
19261925
Fu can re-implement this with a single query.
19271926
*/
19281927
while( SQLITE_ROW == db_step(&query) ){
1929
- int const nCount = db_column_int(&query, 1);
1928
+ const int nCount = db_column_int(&query, 1);
19301929
if(nCount>nMaxEvents){
19311930
nMaxEvents = nCount;
19321931
}
19331932
}
19341933
db_reset(&query);
19351934
while( SQLITE_ROW == db_step(&query) ){
1936
- char const * zTimeframe = db_column_text(&query, 0);
1937
- int const nCount = db_column_int(&query, 1);
1938
- int const nSize = nCount
1935
+ const char * zTimeframe = db_column_text(&query, 0);
1936
+ const int nCount = db_column_int(&query, 1);
1937
+ const int nSize = nCount
19391938
? (int)(100 * nCount / nMaxEvents)
19401939
: 1;
19411940
showYearTotal = 0;
19421941
if(includeMonth){
19431942
/* For Month/year view, add a separator for each distinct year. */
@@ -2025,11 +2024,10 @@
20252024
/*
20262025
** Implements the "byuser" view for /stats_report.
20272026
*/
20282027
static void stats_report_by_user(){
20292028
Stmt query = empty_Stmt;
2030
- int const nPixelsPerEvent = 1; /* for sizing the "graph" part */
20312029
int nRowNumber = 0; /* current TR number */
20322030
int nEventTotal = 0; /* Total event count */
20332031
int rowClass = 0; /* counter for alternating
20342032
row colors */
20352033
Blob sql = empty_blob; /* SQL */
@@ -2050,20 +2048,20 @@
20502048
@ <th>User</th>
20512049
@ <th>Events</th>
20522050
@ <th width='90%%'><!-- relative commits graph --></th>
20532051
@ </tr></thead><tbody>
20542052
while( SQLITE_ROW == db_step(&query) ){
2055
- int const nCount = db_column_int(&query, 1);
2053
+ const int nCount = db_column_int(&query, 1);
20562054
if(nCount>nMaxEvents){
20572055
nMaxEvents = nCount;
20582056
}
20592057
}
20602058
db_reset(&query);
20612059
while( SQLITE_ROW == db_step(&query) ){
2062
- char const * zUser = db_column_text(&query, 0);
2063
- int const nCount = db_column_int(&query, 1);
2064
- int const nSize = nCount
2060
+ const char * zUser = db_column_text(&query, 0);
2061
+ const int nCount = db_column_int(&query, 1);
2062
+ const int nSize = nCount
20652063
? (int)(100 * nCount / nMaxEvents)
20662064
: 0;
20672065
if(!nCount) continue /* arguable! Possible? */;
20682066
rowClass = ++nRowNumber % 2;
20692067
nEventTotal += nCount;
@@ -2090,12 +2088,12 @@
20902088
/*
20912089
** Helper for stats_report_by_month_year(), which generates a list of
20922090
** week numbers. zTimeframe should be either a timeframe in the form YYYY
20932091
** or YYYY-MM.
20942092
*/
2095
-static void stats_report_year_weeks(char const * zUserName){
2096
- char const * zYear = P("y");
2093
+static void stats_report_year_weeks(const char * zUserName){
2094
+ const char * zYear = P("y");
20972095
int nYear = zYear ? strlen(zYear) : 0;
20982096
int i = 0;
20992097
Stmt qYears = empty_Stmt;
21002098
char * zDefaultYear = NULL;
21012099
Blob sql = empty_blob;
@@ -2111,11 +2109,11 @@
21112109
}
21122110
blob_append(&sql,"GROUP BY y ORDER BY y", -1);
21132111
db_prepare(&qYears, blob_str(&sql));
21142112
blob_reset(&sql);
21152113
while( SQLITE_ROW == db_step(&qYears) ){
2116
- char const * zT = db_column_text(&qYears, 0);
2114
+ const char * zT = db_column_text(&qYears, 0);
21172115
if( i++ ){
21182116
cgi_printf(" ");
21192117
}
21202118
cgi_printf("<a href='?view=byweek&y=%s", zT);
21212119
if(zUserName && *zUserName){
@@ -2129,11 +2127,10 @@
21292127
zDefaultYear = db_text("????", "SELECT strftime('%%Y')");
21302128
zYear = zDefaultYear;
21312129
nYear = 4;
21322130
}
21332131
if(4 == nYear){
2134
- int const nPixelsPerEvent = 3; /* for sizing the "graph" part */
21352132
Stmt stWeek = empty_Stmt;
21362133
int rowCount = 0;
21372134
int total = 0;
21382135
Blob header = empty_blob;
21392136
blob_appendf(&header, "Timeline events for the calendar weeks "
@@ -2162,20 +2159,20 @@
21622159
"</tr></thead>"
21632160
"<tbody>");
21642161
db_prepare(&stWeek, blob_str(&sql));
21652162
blob_reset(&sql);
21662163
while( SQLITE_ROW == db_step(&stWeek) ){
2167
- int const nCount = db_column_int(&stWeek, 1);
2164
+ const int nCount = db_column_int(&stWeek, 1);
21682165
if(nCount>nMaxEvents){
21692166
nMaxEvents = nCount;
21702167
}
21712168
}
21722169
db_reset(&stWeek);
21732170
while( SQLITE_ROW == db_step(&stWeek) ){
2174
- char const * zWeek = db_column_text(&stWeek,0);
2175
- int const nCount = db_column_int(&stWeek,1);
2176
- int const nSize = nCount
2171
+ const char * zWeek = db_column_text(&stWeek,0);
2172
+ const int nCount = db_column_int(&stWeek,1);
2173
+ const int nSize = nCount
21772174
? (int)(100 * nCount / nMaxEvents)
21782175
: 0;
21792176
total += nCount;
21802177
cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
21812178
cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
@@ -2215,12 +2212,12 @@
22152212
** view=REPORT_NAME Valid values: bymonth, byyear, byuser
22162213
** user=NAME Restricts statistics to the given user
22172214
*/
22182215
void stats_report_page(){
22192216
HQuery url; /* URL for various branch links */
2220
- char const * zView = P("view"); /* Which view/report to show. */
2221
- char const *zUserName = P("user");
2217
+ const char * zView = P("view"); /* Which view/report to show. */
2218
+ const char *zUserName = P("user");
22222219
if(!zUserName) zUserName = P("u");
22232220
url_initialize(&url, "stats_report");
22242221
22252222
if(zUserName && *zUserName){
22262223
url_add_parameter(&url,"user", zUserName);
22272224
--- src/timeline.c
+++ src/timeline.c
@@ -1841,11 +1841,11 @@
1841 /*
1842 ** Helper for stats_report_by_month_year(), which generates a list of
1843 ** week numbers. zTimeframe should be either a timeframe in the form YYYY
1844 ** or YYYY-MM.
1845 */
1846 static void stats_report_output_week_links(char const * zTimeframe){
1847 Stmt stWeek = empty_Stmt;
1848 char yearPart[5] = {0,0,0,0,0};
1849 memcpy(yearPart, zTimeframe, 4);
1850 db_prepare(&stWeek,
1851 "SELECT DISTINCT strftime('%%W',mtime) AS wk, "
@@ -1855,12 +1855,12 @@
1855 "WHERE ym=%Q AND mtime < current_timestamp "
1856 "GROUP BY wk ORDER BY wk",
1857 strlen(zTimeframe),
1858 zTimeframe);
1859 while( SQLITE_ROW == db_step(&stWeek) ){
1860 char const * zWeek = db_column_text(&stWeek,0);
1861 int const nCount = db_column_int(&stWeek,1);
1862 cgi_printf("<a href='%s/timeline?"
1863 "yw=%t-%t&n=%d'>%s</a>",
1864 g.zTop, yearPart, zWeek,
1865 nCount, zWeek);
1866 }
@@ -1874,19 +1874,18 @@
1874 ** then the report is restricted to events created by the named user
1875 ** account.
1876 */
1877 static void stats_report_by_month_year(char includeMonth,
1878 char includeWeeks,
1879 char const * zUserName){
1880 Stmt query = empty_Stmt;
1881 int const nPixelsPerEvent = 1; /* for sizing the "graph" part */
1882 int nRowNumber = 0; /* current TR number */
1883 int nEventTotal = 0; /* Total event count */
1884 int rowClass = 0; /* counter for alternating
1885 row colors */
1886 Blob sql = empty_blob; /* SQL */
1887 char const * zTimeLabel = includeMonth ? "Year/Month" : "Year";
1888 char zPrevYear[5] = {0}; /* For keeping track of when
1889 we change years while looping */
1890 int nEventsPerYear = 0; /* Total event count for the
1891 current year */
1892 char showYearTotal = 0; /* Flag telling us when to show
@@ -1924,20 +1923,20 @@
1924 Run the query twice. The first time we calculate the maximum
1925 number of events for a given row. Maybe someone with better SQL
1926 Fu can re-implement this with a single query.
1927 */
1928 while( SQLITE_ROW == db_step(&query) ){
1929 int const nCount = db_column_int(&query, 1);
1930 if(nCount>nMaxEvents){
1931 nMaxEvents = nCount;
1932 }
1933 }
1934 db_reset(&query);
1935 while( SQLITE_ROW == db_step(&query) ){
1936 char const * zTimeframe = db_column_text(&query, 0);
1937 int const nCount = db_column_int(&query, 1);
1938 int const nSize = nCount
1939 ? (int)(100 * nCount / nMaxEvents)
1940 : 1;
1941 showYearTotal = 0;
1942 if(includeMonth){
1943 /* For Month/year view, add a separator for each distinct year. */
@@ -2025,11 +2024,10 @@
2025 /*
2026 ** Implements the "byuser" view for /stats_report.
2027 */
2028 static void stats_report_by_user(){
2029 Stmt query = empty_Stmt;
2030 int const nPixelsPerEvent = 1; /* for sizing the "graph" part */
2031 int nRowNumber = 0; /* current TR number */
2032 int nEventTotal = 0; /* Total event count */
2033 int rowClass = 0; /* counter for alternating
2034 row colors */
2035 Blob sql = empty_blob; /* SQL */
@@ -2050,20 +2048,20 @@
2050 @ <th>User</th>
2051 @ <th>Events</th>
2052 @ <th width='90%%'><!-- relative commits graph --></th>
2053 @ </tr></thead><tbody>
2054 while( SQLITE_ROW == db_step(&query) ){
2055 int const nCount = db_column_int(&query, 1);
2056 if(nCount>nMaxEvents){
2057 nMaxEvents = nCount;
2058 }
2059 }
2060 db_reset(&query);
2061 while( SQLITE_ROW == db_step(&query) ){
2062 char const * zUser = db_column_text(&query, 0);
2063 int const nCount = db_column_int(&query, 1);
2064 int const nSize = nCount
2065 ? (int)(100 * nCount / nMaxEvents)
2066 : 0;
2067 if(!nCount) continue /* arguable! Possible? */;
2068 rowClass = ++nRowNumber % 2;
2069 nEventTotal += nCount;
@@ -2090,12 +2088,12 @@
2090 /*
2091 ** Helper for stats_report_by_month_year(), which generates a list of
2092 ** week numbers. zTimeframe should be either a timeframe in the form YYYY
2093 ** or YYYY-MM.
2094 */
2095 static void stats_report_year_weeks(char const * zUserName){
2096 char const * zYear = P("y");
2097 int nYear = zYear ? strlen(zYear) : 0;
2098 int i = 0;
2099 Stmt qYears = empty_Stmt;
2100 char * zDefaultYear = NULL;
2101 Blob sql = empty_blob;
@@ -2111,11 +2109,11 @@
2111 }
2112 blob_append(&sql,"GROUP BY y ORDER BY y", -1);
2113 db_prepare(&qYears, blob_str(&sql));
2114 blob_reset(&sql);
2115 while( SQLITE_ROW == db_step(&qYears) ){
2116 char const * zT = db_column_text(&qYears, 0);
2117 if( i++ ){
2118 cgi_printf(" ");
2119 }
2120 cgi_printf("<a href='?view=byweek&y=%s", zT);
2121 if(zUserName && *zUserName){
@@ -2129,11 +2127,10 @@
2129 zDefaultYear = db_text("????", "SELECT strftime('%%Y')");
2130 zYear = zDefaultYear;
2131 nYear = 4;
2132 }
2133 if(4 == nYear){
2134 int const nPixelsPerEvent = 3; /* for sizing the "graph" part */
2135 Stmt stWeek = empty_Stmt;
2136 int rowCount = 0;
2137 int total = 0;
2138 Blob header = empty_blob;
2139 blob_appendf(&header, "Timeline events for the calendar weeks "
@@ -2162,20 +2159,20 @@
2162 "</tr></thead>"
2163 "<tbody>");
2164 db_prepare(&stWeek, blob_str(&sql));
2165 blob_reset(&sql);
2166 while( SQLITE_ROW == db_step(&stWeek) ){
2167 int const nCount = db_column_int(&stWeek, 1);
2168 if(nCount>nMaxEvents){
2169 nMaxEvents = nCount;
2170 }
2171 }
2172 db_reset(&stWeek);
2173 while( SQLITE_ROW == db_step(&stWeek) ){
2174 char const * zWeek = db_column_text(&stWeek,0);
2175 int const nCount = db_column_int(&stWeek,1);
2176 int const nSize = nCount
2177 ? (int)(100 * nCount / nMaxEvents)
2178 : 0;
2179 total += nCount;
2180 cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
2181 cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
@@ -2215,12 +2212,12 @@
2215 ** view=REPORT_NAME Valid values: bymonth, byyear, byuser
2216 ** user=NAME Restricts statistics to the given user
2217 */
2218 void stats_report_page(){
2219 HQuery url; /* URL for various branch links */
2220 char const * zView = P("view"); /* Which view/report to show. */
2221 char const *zUserName = P("user");
2222 if(!zUserName) zUserName = P("u");
2223 url_initialize(&url, "stats_report");
2224
2225 if(zUserName && *zUserName){
2226 url_add_parameter(&url,"user", zUserName);
2227
--- src/timeline.c
+++ src/timeline.c
@@ -1841,11 +1841,11 @@
1841 /*
1842 ** Helper for stats_report_by_month_year(), which generates a list of
1843 ** week numbers. zTimeframe should be either a timeframe in the form YYYY
1844 ** or YYYY-MM.
1845 */
1846 static void stats_report_output_week_links(const char * zTimeframe){
1847 Stmt stWeek = empty_Stmt;
1848 char yearPart[5] = {0,0,0,0,0};
1849 memcpy(yearPart, zTimeframe, 4);
1850 db_prepare(&stWeek,
1851 "SELECT DISTINCT strftime('%%W',mtime) AS wk, "
@@ -1855,12 +1855,12 @@
1855 "WHERE ym=%Q AND mtime < current_timestamp "
1856 "GROUP BY wk ORDER BY wk",
1857 strlen(zTimeframe),
1858 zTimeframe);
1859 while( SQLITE_ROW == db_step(&stWeek) ){
1860 const char * zWeek = db_column_text(&stWeek,0);
1861 const int nCount = db_column_int(&stWeek,1);
1862 cgi_printf("<a href='%s/timeline?"
1863 "yw=%t-%t&n=%d'>%s</a>",
1864 g.zTop, yearPart, zWeek,
1865 nCount, zWeek);
1866 }
@@ -1874,19 +1874,18 @@
1874 ** then the report is restricted to events created by the named user
1875 ** account.
1876 */
1877 static void stats_report_by_month_year(char includeMonth,
1878 char includeWeeks,
1879 const char * zUserName){
1880 Stmt query = empty_Stmt;
 
1881 int nRowNumber = 0; /* current TR number */
1882 int nEventTotal = 0; /* Total event count */
1883 int rowClass = 0; /* counter for alternating
1884 row colors */
1885 Blob sql = empty_blob; /* SQL */
1886 const char * zTimeLabel = includeMonth ? "Year/Month" : "Year";
1887 char zPrevYear[5] = {0}; /* For keeping track of when
1888 we change years while looping */
1889 int nEventsPerYear = 0; /* Total event count for the
1890 current year */
1891 char showYearTotal = 0; /* Flag telling us when to show
@@ -1924,20 +1923,20 @@
1923 Run the query twice. The first time we calculate the maximum
1924 number of events for a given row. Maybe someone with better SQL
1925 Fu can re-implement this with a single query.
1926 */
1927 while( SQLITE_ROW == db_step(&query) ){
1928 const int nCount = db_column_int(&query, 1);
1929 if(nCount>nMaxEvents){
1930 nMaxEvents = nCount;
1931 }
1932 }
1933 db_reset(&query);
1934 while( SQLITE_ROW == db_step(&query) ){
1935 const char * zTimeframe = db_column_text(&query, 0);
1936 const int nCount = db_column_int(&query, 1);
1937 const int nSize = nCount
1938 ? (int)(100 * nCount / nMaxEvents)
1939 : 1;
1940 showYearTotal = 0;
1941 if(includeMonth){
1942 /* For Month/year view, add a separator for each distinct year. */
@@ -2025,11 +2024,10 @@
2024 /*
2025 ** Implements the "byuser" view for /stats_report.
2026 */
2027 static void stats_report_by_user(){
2028 Stmt query = empty_Stmt;
 
2029 int nRowNumber = 0; /* current TR number */
2030 int nEventTotal = 0; /* Total event count */
2031 int rowClass = 0; /* counter for alternating
2032 row colors */
2033 Blob sql = empty_blob; /* SQL */
@@ -2050,20 +2048,20 @@
2048 @ <th>User</th>
2049 @ <th>Events</th>
2050 @ <th width='90%%'><!-- relative commits graph --></th>
2051 @ </tr></thead><tbody>
2052 while( SQLITE_ROW == db_step(&query) ){
2053 const int nCount = db_column_int(&query, 1);
2054 if(nCount>nMaxEvents){
2055 nMaxEvents = nCount;
2056 }
2057 }
2058 db_reset(&query);
2059 while( SQLITE_ROW == db_step(&query) ){
2060 const char * zUser = db_column_text(&query, 0);
2061 const int nCount = db_column_int(&query, 1);
2062 const int nSize = nCount
2063 ? (int)(100 * nCount / nMaxEvents)
2064 : 0;
2065 if(!nCount) continue /* arguable! Possible? */;
2066 rowClass = ++nRowNumber % 2;
2067 nEventTotal += nCount;
@@ -2090,12 +2088,12 @@
2088 /*
2089 ** Helper for stats_report_by_month_year(), which generates a list of
2090 ** week numbers. zTimeframe should be either a timeframe in the form YYYY
2091 ** or YYYY-MM.
2092 */
2093 static void stats_report_year_weeks(const char * zUserName){
2094 const char * zYear = P("y");
2095 int nYear = zYear ? strlen(zYear) : 0;
2096 int i = 0;
2097 Stmt qYears = empty_Stmt;
2098 char * zDefaultYear = NULL;
2099 Blob sql = empty_blob;
@@ -2111,11 +2109,11 @@
2109 }
2110 blob_append(&sql,"GROUP BY y ORDER BY y", -1);
2111 db_prepare(&qYears, blob_str(&sql));
2112 blob_reset(&sql);
2113 while( SQLITE_ROW == db_step(&qYears) ){
2114 const char * zT = db_column_text(&qYears, 0);
2115 if( i++ ){
2116 cgi_printf(" ");
2117 }
2118 cgi_printf("<a href='?view=byweek&y=%s", zT);
2119 if(zUserName && *zUserName){
@@ -2129,11 +2127,10 @@
2127 zDefaultYear = db_text("????", "SELECT strftime('%%Y')");
2128 zYear = zDefaultYear;
2129 nYear = 4;
2130 }
2131 if(4 == nYear){
 
2132 Stmt stWeek = empty_Stmt;
2133 int rowCount = 0;
2134 int total = 0;
2135 Blob header = empty_blob;
2136 blob_appendf(&header, "Timeline events for the calendar weeks "
@@ -2162,20 +2159,20 @@
2159 "</tr></thead>"
2160 "<tbody>");
2161 db_prepare(&stWeek, blob_str(&sql));
2162 blob_reset(&sql);
2163 while( SQLITE_ROW == db_step(&stWeek) ){
2164 const int nCount = db_column_int(&stWeek, 1);
2165 if(nCount>nMaxEvents){
2166 nMaxEvents = nCount;
2167 }
2168 }
2169 db_reset(&stWeek);
2170 while( SQLITE_ROW == db_step(&stWeek) ){
2171 const char * zWeek = db_column_text(&stWeek,0);
2172 const int nCount = db_column_int(&stWeek,1);
2173 const int nSize = nCount
2174 ? (int)(100 * nCount / nMaxEvents)
2175 : 0;
2176 total += nCount;
2177 cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
2178 cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
@@ -2215,12 +2212,12 @@
2212 ** view=REPORT_NAME Valid values: bymonth, byyear, byuser
2213 ** user=NAME Restricts statistics to the given user
2214 */
2215 void stats_report_page(){
2216 HQuery url; /* URL for various branch links */
2217 const char * zView = P("view"); /* Which view/report to show. */
2218 const char *zUserName = P("user");
2219 if(!zUserName) zUserName = P("u");
2220 url_initialize(&url, "stats_report");
2221
2222 if(zUserName && *zUserName){
2223 url_add_parameter(&url,"user", zUserName);
2224

Keyboard Shortcuts

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