Fossil SCM

Make daysOfWeek a const table. c/char const/const char/

jan.nijtmans 2014-06-23 09:35 trunk
Commit 1d30672588ec8be510fcb8b46d2b7d783b50d31a
1 file changed +9 -9
+9 -9
--- src/timeline.c
+++ src/timeline.c
@@ -1971,11 +1971,11 @@
19711971
19721972
/*
19731973
** Set by stats_report_init_view() to one of the y=XXXX values
19741974
** accepted by /timeline?y=XXXX.
19751975
*/
1976
-static char const * statsReportTimelineYFlag = NULL;
1976
+static const char * statsReportTimelineYFlag = NULL;
19771977
19781978
/*
19791979
** Creates a TEMP VIEW named v_reports which is a wrapper around the
19801980
** EVENT table filtered on event.type. It looks for the request
19811981
** parameter 'type' (reminder: we "should" use 'y' for consistency
@@ -1992,12 +1992,12 @@
19921992
** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
19931993
** filter it applies, or '*' if no filter is applied (i.e. if "all" is
19941994
** used).
19951995
*/
19961996
static int stats_report_init_view(){
1997
- char const * zType = PD("type","*"); /* analog to /timeline?y=... */
1998
- char const * zRealType = NULL; /* normalized form of zType */
1997
+ const char * zType = PD("type","*"); /* analog to /timeline?y=... */
1998
+ const char * zRealType = NULL; /* normalized form of zType */
19991999
int rc = 0; /* result code */
20002000
assert( !statsReportType && "Must not be called more than once." );
20012001
switch( (zType && *zType) ? *zType : 0 ){
20022002
case 'c':
20032003
case 'C':
@@ -2046,11 +2046,11 @@
20462046
** Returns a string suitable (for a given value of suitable) for
20472047
** use in a label with the header of the /reports pages, dependent
20482048
** on the 'type' flag. See stats_report_init_view().
20492049
** The returned bytes are static.
20502050
*/
2051
-static char const * stats_report_label_for_type(){
2051
+static const char * stats_report_label_for_type(){
20522052
assert( statsReportType && "Must call stats_report_init_view() first." );
20532053
switch( statsReportType ){
20542054
case 'c':
20552055
return "checkins";
20562056
case 'w':
@@ -2071,12 +2071,12 @@
20712071
** time this is called. e.g. if called from the 'byuser' view then
20722072
** zCurrentViewName must be "byuser". Any URL parameters which need to
20732073
** be added to the generated URLs should be passed in zParam. The
20742074
** caller is expected to have already encoded any zParam in the %T or
20752075
** %t encoding. */
2076
-static void stats_report_event_types_menu(char const * zCurrentViewName,
2077
- char const * zParam){
2076
+static void stats_report_event_types_menu(const char * zCurrentViewName,
2077
+ const char * zParam){
20782078
char * zTop;
20792079
if(zParam && !*zParam){
20802080
zParam = NULL;
20812081
}
20822082
zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName,
@@ -2296,11 +2296,11 @@
22962296
@ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
22972297
@</tr>
22982298
}
22992299
@ </tbody></table>
23002300
if(nEventTotal){
2301
- char const * zAvgLabel = includeMonth ? "month" : "year";
2301
+ const char * zAvgLabel = includeMonth ? "month" : "year";
23022302
int nAvg = iterations ? (nEventTotal/iterations) : 0;
23032303
@ <br><div>Total events: %d(nEventTotal)
23042304
@ <br>Average per active %s(zAvgLabel): %d(nAvg)
23052305
@ </div>
23062306
}
@@ -2386,15 +2386,15 @@
23862386
int rowClass = 0; /* counter for alternating
23872387
row colors */
23882388
Blob sql = empty_blob; /* SQL */
23892389
int nMaxEvents = 1; /* max number of events for
23902390
all rows. */
2391
- static char const * daysOfWeek[] = {
2391
+ static const char * const daysOfWeek[] = {
23922392
"Monday", "Tuesday", "Wednesday", "Thursday",
23932393
"Friday", "Saturday", "Sunday"
23942394
};
2395
-
2395
+
23962396
stats_report_init_view();
23972397
stats_report_event_types_menu("byweekday", NULL);
23982398
blob_append(&sql,
23992399
"SELECT cast(mtime %% 7 AS INTEGER) dow, "
24002400
"COUNT(*) AS eventCount "
24012401
--- src/timeline.c
+++ src/timeline.c
@@ -1971,11 +1971,11 @@
1971
1972 /*
1973 ** Set by stats_report_init_view() to one of the y=XXXX values
1974 ** accepted by /timeline?y=XXXX.
1975 */
1976 static char const * statsReportTimelineYFlag = NULL;
1977
1978 /*
1979 ** Creates a TEMP VIEW named v_reports which is a wrapper around the
1980 ** EVENT table filtered on event.type. It looks for the request
1981 ** parameter 'type' (reminder: we "should" use 'y' for consistency
@@ -1992,12 +1992,12 @@
1992 ** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
1993 ** filter it applies, or '*' if no filter is applied (i.e. if "all" is
1994 ** used).
1995 */
1996 static int stats_report_init_view(){
1997 char const * zType = PD("type","*"); /* analog to /timeline?y=... */
1998 char const * zRealType = NULL; /* normalized form of zType */
1999 int rc = 0; /* result code */
2000 assert( !statsReportType && "Must not be called more than once." );
2001 switch( (zType && *zType) ? *zType : 0 ){
2002 case 'c':
2003 case 'C':
@@ -2046,11 +2046,11 @@
2046 ** Returns a string suitable (for a given value of suitable) for
2047 ** use in a label with the header of the /reports pages, dependent
2048 ** on the 'type' flag. See stats_report_init_view().
2049 ** The returned bytes are static.
2050 */
2051 static char const * stats_report_label_for_type(){
2052 assert( statsReportType && "Must call stats_report_init_view() first." );
2053 switch( statsReportType ){
2054 case 'c':
2055 return "checkins";
2056 case 'w':
@@ -2071,12 +2071,12 @@
2071 ** time this is called. e.g. if called from the 'byuser' view then
2072 ** zCurrentViewName must be "byuser". Any URL parameters which need to
2073 ** be added to the generated URLs should be passed in zParam. The
2074 ** caller is expected to have already encoded any zParam in the %T or
2075 ** %t encoding. */
2076 static void stats_report_event_types_menu(char const * zCurrentViewName,
2077 char const * zParam){
2078 char * zTop;
2079 if(zParam && !*zParam){
2080 zParam = NULL;
2081 }
2082 zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName,
@@ -2296,11 +2296,11 @@
2296 @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
2297 @</tr>
2298 }
2299 @ </tbody></table>
2300 if(nEventTotal){
2301 char const * zAvgLabel = includeMonth ? "month" : "year";
2302 int nAvg = iterations ? (nEventTotal/iterations) : 0;
2303 @ <br><div>Total events: %d(nEventTotal)
2304 @ <br>Average per active %s(zAvgLabel): %d(nAvg)
2305 @ </div>
2306 }
@@ -2386,15 +2386,15 @@
2386 int rowClass = 0; /* counter for alternating
2387 row colors */
2388 Blob sql = empty_blob; /* SQL */
2389 int nMaxEvents = 1; /* max number of events for
2390 all rows. */
2391 static char const * daysOfWeek[] = {
2392 "Monday", "Tuesday", "Wednesday", "Thursday",
2393 "Friday", "Saturday", "Sunday"
2394 };
2395
2396 stats_report_init_view();
2397 stats_report_event_types_menu("byweekday", NULL);
2398 blob_append(&sql,
2399 "SELECT cast(mtime %% 7 AS INTEGER) dow, "
2400 "COUNT(*) AS eventCount "
2401
--- src/timeline.c
+++ src/timeline.c
@@ -1971,11 +1971,11 @@
1971
1972 /*
1973 ** Set by stats_report_init_view() to one of the y=XXXX values
1974 ** accepted by /timeline?y=XXXX.
1975 */
1976 static const char * statsReportTimelineYFlag = NULL;
1977
1978 /*
1979 ** Creates a TEMP VIEW named v_reports which is a wrapper around the
1980 ** EVENT table filtered on event.type. It looks for the request
1981 ** parameter 'type' (reminder: we "should" use 'y' for consistency
@@ -1992,12 +1992,12 @@
1992 ** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
1993 ** filter it applies, or '*' if no filter is applied (i.e. if "all" is
1994 ** used).
1995 */
1996 static int stats_report_init_view(){
1997 const char * zType = PD("type","*"); /* analog to /timeline?y=... */
1998 const char * zRealType = NULL; /* normalized form of zType */
1999 int rc = 0; /* result code */
2000 assert( !statsReportType && "Must not be called more than once." );
2001 switch( (zType && *zType) ? *zType : 0 ){
2002 case 'c':
2003 case 'C':
@@ -2046,11 +2046,11 @@
2046 ** Returns a string suitable (for a given value of suitable) for
2047 ** use in a label with the header of the /reports pages, dependent
2048 ** on the 'type' flag. See stats_report_init_view().
2049 ** The returned bytes are static.
2050 */
2051 static const char * stats_report_label_for_type(){
2052 assert( statsReportType && "Must call stats_report_init_view() first." );
2053 switch( statsReportType ){
2054 case 'c':
2055 return "checkins";
2056 case 'w':
@@ -2071,12 +2071,12 @@
2071 ** time this is called. e.g. if called from the 'byuser' view then
2072 ** zCurrentViewName must be "byuser". Any URL parameters which need to
2073 ** be added to the generated URLs should be passed in zParam. The
2074 ** caller is expected to have already encoded any zParam in the %T or
2075 ** %t encoding. */
2076 static void stats_report_event_types_menu(const char * zCurrentViewName,
2077 const char * zParam){
2078 char * zTop;
2079 if(zParam && !*zParam){
2080 zParam = NULL;
2081 }
2082 zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName,
@@ -2296,11 +2296,11 @@
2296 @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
2297 @</tr>
2298 }
2299 @ </tbody></table>
2300 if(nEventTotal){
2301 const char * zAvgLabel = includeMonth ? "month" : "year";
2302 int nAvg = iterations ? (nEventTotal/iterations) : 0;
2303 @ <br><div>Total events: %d(nEventTotal)
2304 @ <br>Average per active %s(zAvgLabel): %d(nAvg)
2305 @ </div>
2306 }
@@ -2386,15 +2386,15 @@
2386 int rowClass = 0; /* counter for alternating
2387 row colors */
2388 Blob sql = empty_blob; /* SQL */
2389 int nMaxEvents = 1; /* max number of events for
2390 all rows. */
2391 static const char * const daysOfWeek[] = {
2392 "Monday", "Tuesday", "Wednesday", "Thursday",
2393 "Friday", "Saturday", "Sunday"
2394 };
2395
2396 stats_report_init_view();
2397 stats_report_event_types_menu("byweekday", NULL);
2398 blob_append(&sql,
2399 "SELECT cast(mtime %% 7 AS INTEGER) dow, "
2400 "COUNT(*) AS eventCount "
2401

Keyboard Shortcuts

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