Fossil SCM
Make daysOfWeek a const table. c/char const/const char/
Commit
1d30672588ec8be510fcb8b46d2b7d783b50d31a
Parent
76303fb0c035fbe…
1 file changed
+9
-9
+9
-9
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1971,11 +1971,11 @@ | ||
| 1971 | 1971 | |
| 1972 | 1972 | /* |
| 1973 | 1973 | ** Set by stats_report_init_view() to one of the y=XXXX values |
| 1974 | 1974 | ** accepted by /timeline?y=XXXX. |
| 1975 | 1975 | */ |
| 1976 | -static char const * statsReportTimelineYFlag = NULL; | |
| 1976 | +static const char * statsReportTimelineYFlag = NULL; | |
| 1977 | 1977 | |
| 1978 | 1978 | /* |
| 1979 | 1979 | ** Creates a TEMP VIEW named v_reports which is a wrapper around the |
| 1980 | 1980 | ** EVENT table filtered on event.type. It looks for the request |
| 1981 | 1981 | ** parameter 'type' (reminder: we "should" use 'y' for consistency |
| @@ -1992,12 +1992,12 @@ | ||
| 1992 | 1992 | ** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of |
| 1993 | 1993 | ** filter it applies, or '*' if no filter is applied (i.e. if "all" is |
| 1994 | 1994 | ** used). |
| 1995 | 1995 | */ |
| 1996 | 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 */ | |
| 1997 | + const char * zType = PD("type","*"); /* analog to /timeline?y=... */ | |
| 1998 | + const char * zRealType = NULL; /* normalized form of zType */ | |
| 1999 | 1999 | int rc = 0; /* result code */ |
| 2000 | 2000 | assert( !statsReportType && "Must not be called more than once." ); |
| 2001 | 2001 | switch( (zType && *zType) ? *zType : 0 ){ |
| 2002 | 2002 | case 'c': |
| 2003 | 2003 | case 'C': |
| @@ -2046,11 +2046,11 @@ | ||
| 2046 | 2046 | ** Returns a string suitable (for a given value of suitable) for |
| 2047 | 2047 | ** use in a label with the header of the /reports pages, dependent |
| 2048 | 2048 | ** on the 'type' flag. See stats_report_init_view(). |
| 2049 | 2049 | ** The returned bytes are static. |
| 2050 | 2050 | */ |
| 2051 | -static char const * stats_report_label_for_type(){ | |
| 2051 | +static const char * stats_report_label_for_type(){ | |
| 2052 | 2052 | assert( statsReportType && "Must call stats_report_init_view() first." ); |
| 2053 | 2053 | switch( statsReportType ){ |
| 2054 | 2054 | case 'c': |
| 2055 | 2055 | return "checkins"; |
| 2056 | 2056 | case 'w': |
| @@ -2071,12 +2071,12 @@ | ||
| 2071 | 2071 | ** time this is called. e.g. if called from the 'byuser' view then |
| 2072 | 2072 | ** zCurrentViewName must be "byuser". Any URL parameters which need to |
| 2073 | 2073 | ** be added to the generated URLs should be passed in zParam. The |
| 2074 | 2074 | ** caller is expected to have already encoded any zParam in the %T or |
| 2075 | 2075 | ** %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){ | |
| 2078 | 2078 | char * zTop; |
| 2079 | 2079 | if(zParam && !*zParam){ |
| 2080 | 2080 | zParam = NULL; |
| 2081 | 2081 | } |
| 2082 | 2082 | zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName, |
| @@ -2296,11 +2296,11 @@ | ||
| 2296 | 2296 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2297 | 2297 | @</tr> |
| 2298 | 2298 | } |
| 2299 | 2299 | @ </tbody></table> |
| 2300 | 2300 | if(nEventTotal){ |
| 2301 | - char const * zAvgLabel = includeMonth ? "month" : "year"; | |
| 2301 | + const char * zAvgLabel = includeMonth ? "month" : "year"; | |
| 2302 | 2302 | int nAvg = iterations ? (nEventTotal/iterations) : 0; |
| 2303 | 2303 | @ <br><div>Total events: %d(nEventTotal) |
| 2304 | 2304 | @ <br>Average per active %s(zAvgLabel): %d(nAvg) |
| 2305 | 2305 | @ </div> |
| 2306 | 2306 | } |
| @@ -2386,15 +2386,15 @@ | ||
| 2386 | 2386 | int rowClass = 0; /* counter for alternating |
| 2387 | 2387 | row colors */ |
| 2388 | 2388 | Blob sql = empty_blob; /* SQL */ |
| 2389 | 2389 | int nMaxEvents = 1; /* max number of events for |
| 2390 | 2390 | all rows. */ |
| 2391 | - static char const * daysOfWeek[] = { | |
| 2391 | + static const char * const daysOfWeek[] = { | |
| 2392 | 2392 | "Monday", "Tuesday", "Wednesday", "Thursday", |
| 2393 | 2393 | "Friday", "Saturday", "Sunday" |
| 2394 | 2394 | }; |
| 2395 | - | |
| 2395 | + | |
| 2396 | 2396 | stats_report_init_view(); |
| 2397 | 2397 | stats_report_event_types_menu("byweekday", NULL); |
| 2398 | 2398 | blob_append(&sql, |
| 2399 | 2399 | "SELECT cast(mtime %% 7 AS INTEGER) dow, " |
| 2400 | 2400 | "COUNT(*) AS eventCount " |
| 2401 | 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 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 |