mutt stable branch with some hacks

Declare many structures const (closes #3552)

Many structs used in mutt are actually constant but are defined
without the 'const' keyword. This can slow initialization (slightly)
in some environments due to extra copying and increases the amount of
writable RAM required at run-time, which can be significant on non-MMU
systems. Using const can also increase the opportunities for compiler
optimization.

The attached patch marks many such structures as const. On my test x86
build, this reduces the size of .data by over 50%.

+122 -121
+1 -1
addrbook.c
··· 33 33 34 34 #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x 35 35 36 - static struct mapping_t AliasHelp[] = { 36 + static const struct mapping_t AliasHelp[] = { 37 37 { N_("Exit"), OP_EXIT }, 38 38 { N_("Del"), OP_DELETE }, 39 39 { N_("Undel"), OP_UNDELETE },
+1 -1
browser.c
··· 42 42 #include <errno.h> 43 43 #include <locale.h> 44 44 45 - static struct mapping_t FolderHelp[] = { 45 + static const struct mapping_t FolderHelp[] = { 46 46 { N_("Exit"), OP_EXIT }, 47 47 { N_("Chdir"), OP_CHANGE_DIRECTORY }, 48 48 { N_("Mask"), OP_ENTER_MASK },
+3 -3
charset.c
··· 50 50 * a preferred MIME name is given. 51 51 */ 52 52 53 - static struct 53 + static const const struct 54 54 { 55 - char *key; 56 - char *pref; 55 + const char *key; 56 + const char *pref; 57 57 } 58 58 PreferredMIMENames[] = 59 59 {
+3 -3
color.c
··· 55 55 static COLOR_LIST *ColorList = NULL; 56 56 static int UserColors = 0; 57 57 58 - static struct mapping_t Colors[] = 58 + static const struct mapping_t Colors[] = 59 59 { 60 60 { "black", COLOR_BLACK }, 61 61 { "blue", COLOR_BLUE }, ··· 73 73 74 74 #endif /* HAVE_COLOR */ 75 75 76 - static struct mapping_t Fields[] = 76 + static const struct mapping_t Fields[] = 77 77 { 78 78 { "hdrdefault", MT_COLOR_HDEFAULT }, 79 79 { "quoted", MT_COLOR_QUOTED }, ··· 159 159 #ifdef USE_SLANG_CURSES 160 160 static char *get_color_name (char *dest, size_t destlen, int val) 161 161 { 162 - static char * missing[3] = {"brown", "lightgray", "default"}; 162 + static const char * const missing[3] = {"brown", "lightgray", "default"}; 163 163 int i; 164 164 165 165 switch (val)
+2 -2
compose.c
··· 74 74 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ 75 75 #define W (COLS - HDR_XOFFSET) 76 76 77 - static char *Prompts[] = 77 + static const char * const Prompts[] = 78 78 { 79 79 "From: ", 80 80 "To: ", ··· 85 85 "Fcc: " 86 86 }; 87 87 88 - static struct mapping_t ComposeHelp[] = { 88 + static const struct mapping_t ComposeHelp[] = { 89 89 { N_("Send"), OP_COMPOSE_SEND_MESSAGE }, 90 90 { N_("Abort"), OP_EXIT }, 91 91 { "To", OP_COMPOSE_EDIT_TO },
+2 -2
crypt-gpgme.c
··· 129 129 * General helper functions. 130 130 */ 131 131 132 - /* return true when S pints to a didgit or letter. */ 132 + /* return true when s points to a digit or letter. */ 133 133 static int 134 134 digit_or_letter (const unsigned char *s) 135 135 { ··· 2923 2923 static void 2924 2924 print_dn_parts (FILE *fp, struct dn_array_s *dn) 2925 2925 { 2926 - const char *stdpart[] = { 2926 + static const char * const stdpart[] = { 2927 2927 "CN", "OU", "O", "STREET", "L", "ST", "C", NULL 2928 2928 }; 2929 2929 int any=0, any2=0, i;
+2 -2
curs_lib.c
··· 129 129 return (ch == ctrl ('G') ? err : ret); 130 130 } 131 131 132 - int _mutt_get_field (/* const */ char *field, char *buf, size_t buflen, int complete, int multiple, char ***files, int *numfiles) 132 + int _mutt_get_field (const char *field, char *buf, size_t buflen, int complete, int multiple, char ***files, int *numfiles) 133 133 { 134 134 int ret; 135 135 int x, y; ··· 139 139 do 140 140 { 141 141 CLEARLINE (LINES-1); 142 - addstr (field); 142 + addstr ((char *)field); /* cast to get around bad prototypes */ 143 143 mutt_refresh (); 144 144 getyx (stdscr, y, x); 145 145 ret = _mutt_enter_string (buf, buflen, y, x, complete, multiple, files, numfiles, es);
+1 -1
curs_main.c
··· 401 401 menu->redraw = REDRAW_INDEX | REDRAW_STATUS; 402 402 } 403 403 404 - static struct mapping_t IndexHelp[] = { 404 + static const struct mapping_t IndexHelp[] = { 405 405 { N_("Quit"), OP_QUIT }, 406 406 { N_("Del"), OP_DELETE }, 407 407 { N_("Undel"), OP_UNDELETE },
+2 -2
date.c
··· 69 69 { 70 70 time_t g; 71 71 72 - static int AccumDaysPerMonth[12] = { 72 + static const int AccumDaysPerMonth[12] = { 73 73 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 74 74 }; 75 75 ··· 118 118 119 119 void mutt_normalize_time (struct tm *tm) 120 120 { 121 - static char DaysPerMonth[12] = { 121 + static const char DaysPerMonth[12] = { 122 122 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 123 123 }; 124 124 int nLeap;
+1 -1
enter.c
··· 191 191 */ 192 192 static inline int is_shell_char(wchar_t ch) 193 193 { 194 - static wchar_t shell_chars[] = L"<>&()$?*;{}| "; /* ! not included because it can be part of a pathname in Mutt */ 194 + static const wchar_t shell_chars[] = L"<>&()$?*;{}| "; /* ! not included because it can be part of a pathname in Mutt */ 195 195 return wcschr(shell_chars, ch) != NULL; 196 196 } 197 197
+13 -13
functions.h
··· 38 38 # include "doc/makedoc-defs.h" 39 39 #endif 40 40 41 - struct binding_t OpGeneric[] = { /* map: generic */ 41 + const struct binding_t OpGeneric[] = { /* map: generic */ 42 42 /* 43 43 ** <para> 44 44 ** The <emphasis>generic</emphasis> menu is not a real menu, but specifies common functions ··· 82 82 { NULL, 0, NULL } 83 83 }; 84 84 85 - struct binding_t OpMain[] = { /* map: index */ 85 + const struct binding_t OpMain[] = { /* map: index */ 86 86 { "create-alias", OP_CREATE_ALIAS, "a" }, 87 87 { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, 88 88 { "break-thread", OP_MAIN_BREAK_THREAD, "#" }, ··· 172 172 { NULL, 0, NULL } 173 173 }; 174 174 175 - struct binding_t OpPager[] = { /* map: pager */ 175 + const struct binding_t OpPager[] = { /* map: pager */ 176 176 { "break-thread", OP_MAIN_BREAK_THREAD, "#" }, 177 177 { "create-alias", OP_CREATE_ALIAS, "a" }, 178 178 { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, ··· 275 275 { NULL, 0, NULL } 276 276 }; 277 277 278 - struct binding_t OpAttach[] = { /* map: attachment */ 278 + const struct binding_t OpAttach[] = { /* map: attachment */ 279 279 { "bounce-message", OP_BOUNCE_MESSAGE, "b" }, 280 280 { "display-toggle-weed", OP_DISPLAY_HEADERS, "h" }, 281 281 { "edit-type", OP_EDIT_TYPE, "\005" }, ··· 301 301 { NULL, 0, NULL } 302 302 }; 303 303 304 - struct binding_t OpCompose[] = { /* map: compose */ 304 + const struct binding_t OpCompose[] = { /* map: compose */ 305 305 { "attach-file", OP_COMPOSE_ATTACH_FILE, "a" }, 306 306 { "attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A" }, 307 307 { "edit-bcc", OP_COMPOSE_EDIT_BCC, "b" }, ··· 351 351 { NULL, 0, NULL } 352 352 }; 353 353 354 - struct binding_t OpPost[] = { /* map: postpone */ 354 + const struct binding_t OpPost[] = { /* map: postpone */ 355 355 { "delete-entry", OP_DELETE, "d" }, 356 356 { "undelete-entry", OP_UNDELETE, "u" }, 357 357 { NULL, 0, NULL } 358 358 }; 359 359 360 - struct binding_t OpAlias[] = { /* map: alias */ 360 + const struct binding_t OpAlias[] = { /* map: alias */ 361 361 { "delete-entry", OP_DELETE, "d" }, 362 362 { "undelete-entry", OP_UNDELETE, "u" }, 363 363 { NULL, 0, NULL } ··· 365 365 366 366 367 367 /* The file browser */ 368 - struct binding_t OpBrowser[] = { /* map: browser */ 368 + const struct binding_t OpBrowser[] = { /* map: browser */ 369 369 { "change-dir", OP_CHANGE_DIRECTORY, "c" }, 370 370 { "display-filename", OP_BROWSER_TELL, "@" }, 371 371 { "enter-mask", OP_ENTER_MASK, "m" }, ··· 388 388 }; 389 389 390 390 /* External Query Menu */ 391 - struct binding_t OpQuery[] = { /* map: query */ 391 + const struct binding_t OpQuery[] = { /* map: query */ 392 392 { "create-alias", OP_CREATE_ALIAS, "a" }, 393 393 { "mail", OP_MAIL, "m" }, 394 394 { "query", OP_QUERY, "Q" }, ··· 396 396 { NULL, 0, NULL } 397 397 }; 398 398 399 - struct binding_t OpEditor[] = { /* map: editor */ 399 + const struct binding_t OpEditor[] = { /* map: editor */ 400 400 { "bol", OP_EDITOR_BOL, "\001" }, 401 401 { "backward-char", OP_EDITOR_BACKWARD_CHAR, "\002" }, 402 402 { "backward-word", OP_EDITOR_BACKWARD_WORD, "\033b"}, ··· 424 424 425 425 426 426 427 - struct binding_t OpPgp[] = { /* map: pgp */ 427 + const struct binding_t OpPgp[] = { /* map: pgp */ 428 428 { "verify-key", OP_VERIFY_KEY, "c" }, 429 429 { "view-name", OP_VIEW_ID, "%" }, 430 430 { NULL, 0, NULL } ··· 434 434 435 435 /* When using the GPGME based backend we have some useful functions 436 436 for the SMIME menu. */ 437 - struct binding_t OpSmime[] = { /* map: smime */ 437 + const struct binding_t OpSmime[] = { /* map: smime */ 438 438 #ifdef CRYPT_BACKEND_GPGME 439 439 { "verify-key", OP_VERIFY_KEY, "c" }, 440 440 { "view-name", OP_VIEW_ID, "%" }, ··· 445 445 446 446 447 447 #ifdef MIXMASTER 448 - struct binding_t OpMix[] = { /* map: mixmaster */ 448 + const struct binding_t OpMix[] = { /* map: mixmaster */ 449 449 { "accept", OP_MIX_USE, M_ENTER_S }, 450 450 { "append", OP_MIX_APPEND, "a" }, 451 451 { "insert", OP_MIX_INSERT, "i" },
+6 -6
globals.h
··· 266 266 267 267 268 268 #ifdef MAIN_C 269 - const char *Weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; 270 - const char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "ERR" }; 269 + const char * const Weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; 270 + const char * const Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "ERR" }; 271 271 272 - const char *BodyTypes[] = { "x-unknown", "audio", "application", "image", "message", "model", "multipart", "text", "video" }; 273 - const char *BodyEncodings[] = { "x-unknown", "7bit", "8bit", "quoted-printable", "base64", "binary", "x-uuencoded" }; 272 + const char * const BodyTypes[] = { "x-unknown", "audio", "application", "image", "message", "model", "multipart", "text", "video" }; 273 + const char * const BodyEncodings[] = { "x-unknown", "7bit", "8bit", "quoted-printable", "base64", "binary", "x-uuencoded" }; 274 274 #else 275 - extern const char *Weekdays[]; 276 - extern const char *Months[]; 275 + extern const char * const Weekdays[]; 276 + extern const char * const Months[]; 277 277 #endif 278 278 279 279 #ifdef MAIN_C
+3 -3
handler.c
··· 43 43 44 44 typedef int (*handler_t) (BODY *, STATE *); 45 45 46 - int Index_hex[128] = { 46 + const int Index_hex[128] = { 47 47 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, 48 48 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, 49 49 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, ··· 54 54 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1 55 55 }; 56 56 57 - int Index_64[128] = { 57 + const int Index_64[128] = { 58 58 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, 59 59 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, 60 60 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, ··· 434 434 RICH_INDENT, RICH_INDENT_RIGHT, RICH_EXCERPT, RICH_CENTER, RICH_FLUSHLEFT, 435 435 RICH_FLUSHRIGHT, RICH_COLOR, RICH_LAST_TAG }; 436 436 437 - static struct { 437 + static const struct { 438 438 const wchar_t *tag_name; 439 439 int index; 440 440 } EnrichedTags[] = {
+7 -7
help.c
··· 31 31 #include <ctype.h> 32 32 #include <string.h> 33 33 34 - static struct binding_t *help_lookupFunction (int op, int menu) 34 + static const struct binding_t *help_lookupFunction (int op, int menu) 35 35 { 36 36 int i; 37 - struct binding_t *map; 37 + const struct binding_t *map; 38 38 39 39 if (menu != MENU_PAGER) 40 40 { ··· 66 66 } 67 67 68 68 char * 69 - mutt_compile_help (char *buf, size_t buflen, int menu, struct mapping_t *items) 69 + mutt_compile_help (char *buf, size_t buflen, int menu, const struct mapping_t *items) 70 70 { 71 71 int i; 72 72 size_t len; ··· 282 282 static void dump_menu (FILE *f, int menu) 283 283 { 284 284 struct keymap_t *map; 285 - struct binding_t *b; 285 + const struct binding_t *b; 286 286 char buf[SHORT_STRING]; 287 287 288 288 /* browse through the keymap table */ ··· 318 318 } 319 319 320 320 static void dump_unbound (FILE *f, 321 - struct binding_t *funcs, 321 + const struct binding_t *funcs, 322 322 struct keymap_t *map, 323 323 struct keymap_t *aux) 324 324 { ··· 336 336 { 337 337 char t[_POSIX_PATH_MAX]; 338 338 char buf[SHORT_STRING]; 339 - char *desc; 339 + const char *desc; 340 340 FILE *f; 341 - struct binding_t *funcs; 341 + const struct binding_t *funcs; 342 342 343 343 mutt_mktemp (t, sizeof (t)); 344 344
+2 -2
imap/auth.c
··· 28 28 #include "imap_private.h" 29 29 #include "auth.h" 30 30 31 - static imap_auth_t imap_authenticators[] = { 31 + static const imap_auth_t imap_authenticators[] = { 32 32 #ifdef USE_SASL 33 33 { imap_auth_sasl, NULL }, 34 34 #else ··· 50 50 * authentication method if specified, or any. */ 51 51 int imap_authenticate (IMAP_DATA* idata) 52 52 { 53 - imap_auth_t* authenticator; 53 + const imap_auth_t* authenticator; 54 54 char* methods; 55 55 char* method; 56 56 char* delim;
+1 -1
imap/command.c
··· 53 53 static void cmd_parse_search (IMAP_DATA* idata, const char* s); 54 54 static void cmd_parse_status (IMAP_DATA* idata, char* s); 55 55 56 - static char *Capabilities[] = { 56 + static const char * const Capabilities[] = { 57 57 "IMAP4", 58 58 "IMAP4rev1", 59 59 "STATUS",
+1 -1
imap/message.c
··· 71 71 int rc, mfhrc, oldmsgcount; 72 72 int fetchlast = 0; 73 73 int maxuid = 0; 74 - const char *want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL"; 74 + static const char * const want_headers = "DATE FROM SUBJECT TO CC MESSAGE-ID REFERENCES CONTENT-TYPE CONTENT-DESCRIPTION IN-REPLY-TO REPLY-TO LINES LIST-POST X-LABEL"; 75 75 progress_t progress; 76 76 int retval = -1; 77 77
+2 -2
imap/utf7.c
··· 24 24 #include "charset.h" 25 25 #include "imap_private.h" 26 26 27 - static int Index_64[128] = { 27 + static const int Index_64[128] = { 28 28 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, 29 29 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, 30 30 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, 63,-1,-1,-1, ··· 35 35 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1 36 36 }; 37 37 38 - static char B64Chars[64] = { 38 + static const char B64Chars[64] = { 39 39 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 40 40 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 41 41 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+2 -1
imap/util.c
··· 612 612 * surround string with quotes, escape " and \ with \ */ 613 613 void imap_quote_string (char *dest, size_t dlen, const char *src) 614 614 { 615 - char quote[] = "\"\\", *pt; 615 + static const char quote[] = "\"\\"; 616 + char *pt; 616 617 const char *s; 617 618 618 619 pt = dest;
+9 -8
init.c
··· 1691 1691 { 1692 1692 int query, unset, inv, reset, r = 0; 1693 1693 int idx = -1; 1694 - char *p, scratch[_POSIX_PATH_MAX]; 1694 + const char *p; 1695 + char scratch[_POSIX_PATH_MAX]; 1695 1696 char* myvar; 1696 1697 1697 1698 while (MoreArgs (s)) ··· 2113 2114 { 2114 2115 if (query) 2115 2116 { 2116 - char *vals[] = { "no", "yes", "ask-no", "ask-yes" }; 2117 + static const char * const vals[] = { "no", "yes", "ask-no", "ask-yes" }; 2117 2118 2118 2119 snprintf (err->data, err->dsize, "%s=%s", MuttVars[idx].option, 2119 2120 vals [ quadoption (MuttVars[idx].data) ]); ··· 2481 2482 || !mutt_strncmp (buffer, "reset", 5) 2482 2483 || !mutt_strncmp (buffer, "toggle", 6)) 2483 2484 { /* complete variables */ 2484 - char *prefixes[] = { "no", "inv", "?", "&", 0 }; 2485 + static const char * const prefixes[] = { "no", "inv", "?", "&", 0 }; 2485 2486 2486 2487 pt++; 2487 2488 /* loop through all the possible prefixes (no, inv, ...) */ ··· 2533 2534 } 2534 2535 else if (!mutt_strncmp (buffer, "exec", 4)) 2535 2536 { 2536 - struct binding_t *menu = km_get_table (CurrentMenu); 2537 + const struct binding_t *menu = km_get_table (CurrentMenu); 2537 2538 2538 2539 if (!menu && CurrentMenu != MENU_PAGER) 2539 2540 menu = OpGeneric; ··· 2632 2633 static int var_to_string (int idx, char* val, size_t len) 2633 2634 { 2634 2635 char tmp[LONG_STRING]; 2635 - char *vals[] = { "no", "yes", "ask-no", "ask-yes" }; 2636 + static const char * const vals[] = { "no", "yes", "ask-no", "ask-yes" }; 2636 2637 2637 2638 tmp[0] = '\0'; 2638 2639 ··· 2663 2664 else if (DTYPE (MuttVars[idx].type) == DT_SORT) 2664 2665 { 2665 2666 const struct mapping_t *map; 2666 - char *p; 2667 + const char *p; 2667 2668 2668 2669 switch (MuttVars[idx].type & DT_SUBTYPE_MASK) 2669 2670 { ··· 2789 2790 return 0; 2790 2791 } 2791 2792 2792 - char *mutt_getnamebyvalue (int val, const struct mapping_t *map) 2793 + const char *mutt_getnamebyvalue (int val, const struct mapping_t *map) 2793 2794 { 2794 2795 int i; 2795 2796 ··· 3150 3151 3151 3152 int mutt_get_hook_type (const char *name) 3152 3153 { 3153 - struct command_t *c; 3154 + const struct command_t *c; 3154 3155 3155 3156 for (c = Commands ; c->name ; c++) 3156 3157 if (c->func == mutt_parse_hook && ascii_strcasecmp (c->name, name) == 0)
+1 -1
init.h
··· 3488 3488 unsigned long data; 3489 3489 }; 3490 3490 3491 - struct command_t Commands[] = { 3491 + const struct command_t Commands[] = { 3492 3492 { "alternates", parse_alternates, 0 }, 3493 3493 { "unalternates", parse_unalternates, 0 }, 3494 3494 #ifdef USE_SOCKET
+12 -12
keymap.c
··· 36 36 37 37 #include "functions.h" 38 38 39 - struct mapping_t Menus[] = { 39 + const struct mapping_t Menus[] = { 40 40 { "alias", MENU_ALIAS }, 41 41 { "attach", MENU_ATTACH }, 42 42 { "browser", MENU_FOLDER }, ··· 298 298 km_bind (s, menu, op, NULL, NULL); 299 299 } 300 300 301 - static int get_op (struct binding_t *bindings, const char *start, size_t len) 301 + static int get_op (const struct binding_t *bindings, const char *start, size_t len) 302 302 { 303 303 int i; 304 304 ··· 312 312 return OP_NULL; 313 313 } 314 314 315 - static char *get_func (struct binding_t *bindings, int op) 315 + static char *get_func (const struct binding_t *bindings, int op) 316 316 { 317 317 int i; 318 318 ··· 366 366 * skip the '<' and the '>' when comparing */ 367 367 for (i = 0; Menus[i].name; i++) 368 368 { 369 - struct binding_t *binding = km_get_table (Menus[i].value); 369 + const struct binding_t *binding = km_get_table (Menus[i].value); 370 370 if (binding) 371 371 { 372 372 op = get_op (binding, pp + 1, l - 2); ··· 465 465 if (tmp.op) 466 466 { 467 467 char *func = NULL; 468 - struct binding_t *bindings; 468 + const struct binding_t *bindings; 469 469 470 470 /* is this a valid op for this menu? */ 471 471 if ((bindings = km_get_table (menu)) && ··· 540 540 /* not reached */ 541 541 } 542 542 543 - static void create_bindings (struct binding_t *map, int menu) 543 + static void create_bindings (const struct binding_t *map, int menu) 544 544 { 545 545 int i; 546 546 ··· 549 549 km_bindkey (map[i].seq, menu, map[i].op); 550 550 } 551 551 552 - char *km_keyname (int c) 552 + static const char *km_keyname (int c) 553 553 { 554 554 static char buf[10]; 555 - char *p; 555 + const char *p; 556 556 557 557 if ((p = mutt_getnamebyvalue (c, KeyNames))) 558 558 return p; ··· 911 911 } 912 912 913 913 static int 914 - try_bind (char *key, int menu, char *func, struct binding_t *bindings) 914 + try_bind (char *key, int menu, char *func, const struct binding_t *bindings) 915 915 { 916 916 int i; 917 917 ··· 924 924 return (-1); 925 925 } 926 926 927 - struct binding_t *km_get_table (int menu) 927 + const struct binding_t *km_get_table (int menu) 928 928 { 929 929 switch (menu) 930 930 { ··· 971 971 /* bind menu-name '<key_sequence>' function-name */ 972 972 int mutt_parse_bind (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 973 973 { 974 - struct binding_t *bindings = NULL; 974 + const struct binding_t *bindings = NULL; 975 975 char *key; 976 976 int menu[sizeof(Menus)/sizeof(struct mapping_t)-1], r = 0, nummenus, i; 977 977 ··· 1072 1072 { 1073 1073 int ops[128]; 1074 1074 int nops = 0; 1075 - struct binding_t *bindings = NULL; 1075 + const struct binding_t *bindings = NULL; 1076 1076 char *function; 1077 1077 1078 1078 if (!MoreArgs (s))
+15 -16
keymap.h
··· 45 45 keycode_t *keys; /* key sequence */ 46 46 }; 47 47 48 - char *km_keyname (int); 49 48 int km_expand_key (char *, size_t, struct keymap_t *); 50 49 struct keymap_t *km_find_func (int, int); 51 50 void km_init (void); ··· 89 88 /* dokey() records the last real key pressed */ 90 89 extern int LastKey; 91 90 92 - extern struct mapping_t Menus[]; 91 + extern const struct mapping_t Menus[]; 93 92 94 93 struct binding_t 95 94 { ··· 98 97 char *seq; /* default key binding */ 99 98 }; 100 99 101 - struct binding_t *km_get_table (int menu); 100 + const struct binding_t *km_get_table (int menu); 102 101 103 - extern struct binding_t OpGeneric[]; 104 - extern struct binding_t OpPost[]; 105 - extern struct binding_t OpMain[]; 106 - extern struct binding_t OpAttach[]; 107 - extern struct binding_t OpPager[]; 108 - extern struct binding_t OpCompose[]; 109 - extern struct binding_t OpBrowser[]; 110 - extern struct binding_t OpEditor[]; 111 - extern struct binding_t OpQuery[]; 112 - extern struct binding_t OpAlias[]; 102 + extern const struct binding_t OpGeneric[]; 103 + extern const struct binding_t OpPost[]; 104 + extern const struct binding_t OpMain[]; 105 + extern const struct binding_t OpAttach[]; 106 + extern const struct binding_t OpPager[]; 107 + extern const struct binding_t OpCompose[]; 108 + extern const struct binding_t OpBrowser[]; 109 + extern const struct binding_t OpEditor[]; 110 + extern const struct binding_t OpQuery[]; 111 + extern const struct binding_t OpAlias[]; 113 112 114 - extern struct binding_t OpPgp[]; 113 + extern const struct binding_t OpPgp[]; 115 114 116 - extern struct binding_t OpSmime[]; 115 + extern const struct binding_t OpSmime[]; 117 116 118 117 #ifdef MIXMASTER 119 - extern struct binding_t OpMix[]; 118 + extern const struct binding_t OpMix[]; 120 119 #endif 121 120 122 121 #include "keymap_defs.h"
+3 -3
lib.c
··· 53 53 #include "lib.h" 54 54 55 55 56 - static struct sysexits 56 + static const struct sysexits 57 57 { 58 58 int v; 59 59 const char *str; ··· 696 696 return (fopen (path, mode)); 697 697 } 698 698 699 - static char safe_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+@{}._-:%/"; 699 + static const char safe_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+@{}._-:%/"; 700 700 701 701 void mutt_sanitize_filename (char *f, short slash) 702 702 { ··· 711 711 712 712 /* these characters must be escaped in regular expressions */ 713 713 714 - static char rx_special_chars[] = "^.[$()|*+?{\\"; 714 + static const char rx_special_chars[] = "^.[$()|*+?{\\"; 715 715 716 716 int mutt_rx_sanitize_string (char *dest, size_t destlen, const char *src) 717 717 {
+3 -3
mapping.h
··· 21 21 22 22 struct mapping_t 23 23 { 24 - char *name; 24 + const char *name; 25 25 int value; 26 26 }; 27 27 28 - char *mutt_getnamebyvalue (int, const struct mapping_t *); 29 - char *mutt_compile_help (char *, size_t, int, struct mapping_t *); 28 + const char *mutt_getnamebyvalue (int, const struct mapping_t *); 29 + char *mutt_compile_help (char *, size_t, int, const struct mapping_t *); 30 30 31 31 int mutt_getvaluebyname (const char *, const struct mapping_t *); 32 32
+3 -3
mime.h
··· 55 55 /* MIME encoding/decoding global vars */ 56 56 57 57 #ifndef _SENDLIB_C 58 - extern int Index_hex[]; 59 - extern int Index_64[]; 60 - extern char B64Chars[]; 58 + extern const int Index_hex[]; 59 + extern const int Index_64[]; 60 + extern const char B64Chars[]; 61 61 #endif 62 62 63 63 #define hexval(c) Index_hex[(unsigned int)(c)]
+1 -1
mutt_ssl.c
··· 911 911 912 912 static int interactive_check_cert (X509 *cert, int idx, int len) 913 913 { 914 - char *part[] = 914 + static const char * const part[] = 915 915 {"/CN=", "/Email=", "/O=", "/OU=", "/L=", "/ST=", "/C="}; 916 916 char helpstr[LONG_STRING]; 917 917 char buf[STRING];
+2 -2
pager.c
··· 1526 1526 return cur; 1527 1527 } 1528 1528 1529 - static struct mapping_t PagerHelp[] = { 1529 + static const struct mapping_t PagerHelp[] = { 1530 1530 { N_("Exit"), OP_EXIT }, 1531 1531 { N_("PrevPg"), OP_PREV_PAGE }, 1532 1532 { N_("NextPg"), OP_NEXT_PAGE }, 1533 1533 { NULL, 0 } 1534 1534 }; 1535 - static struct mapping_t PagerHelpExtra[] = { 1535 + static const struct mapping_t PagerHelpExtra[] = { 1536 1536 { N_("View Attachm."), OP_VIEW_ATTACHMENTS }, 1537 1537 { N_("Del"), OP_DELETE }, 1538 1538 { N_("Reply"), OP_REPLY },
+1 -1
parse.c
··· 672 672 return buf; 673 673 } 674 674 675 - static struct tz_t 675 + static const struct tz_t 676 676 { 677 677 char tzname[5]; 678 678 unsigned char zhours;
+3 -3
pattern.c
··· 47 47 static int eat_range (pattern_t *pat, BUFFER *, BUFFER *); 48 48 static int patmatch (const pattern_t *pat, const char *buf); 49 49 50 - static struct pattern_flags 50 + static const struct pattern_flags 51 51 { 52 52 int tag; /* character used to represent this op */ 53 53 int op; /* operation to perform */ ··· 712 712 return regexec (pat->p.rx, buf, 0, NULL, 0); 713 713 } 714 714 715 - static struct pattern_flags *lookup_tag (char tag) 715 + static const struct pattern_flags *lookup_tag (char tag) 716 716 { 717 717 int i; 718 718 ··· 774 774 int alladdr = 0; 775 775 int or = 0; 776 776 int implicit = 1; /* used to detect logical AND operator */ 777 - struct pattern_flags *entry; 777 + const struct pattern_flags *entry; 778 778 char *p; 779 779 char *buf; 780 780 BUFFER ps;
+1 -1
pgpkey.c
··· 52 52 53 53 static struct pgp_cache *id_defaults = NULL; 54 54 55 - static char trust_flags[] = "?- +"; 55 + static const char trust_flags[] = "?- +"; 56 56 57 57 static char *pgp_key_abilities (int flags) 58 58 {
+1 -1
pgpmicalg.c
··· 35 35 #include <string.h> 36 36 #include <ctype.h> 37 37 38 - static struct 38 + static const struct 39 39 { 40 40 short id; 41 41 const char *name;
+2 -2
pop_auth.c
··· 277 277 return POP_A_FAILURE; 278 278 } 279 279 280 - static pop_auth_t pop_authenticators[] = { 280 + static const pop_auth_t pop_authenticators[] = { 281 281 #ifdef USE_SASL 282 282 { pop_auth_sasl, NULL }, 283 283 #endif ··· 296 296 int pop_authenticate (POP_DATA* pop_data) 297 297 { 298 298 ACCOUNT *acct = &pop_data->conn->account; 299 - pop_auth_t* authenticator; 299 + const pop_auth_t* authenticator; 300 300 char* methods; 301 301 char* comma; 302 302 char* method;
+1 -1
postpone.c
··· 37 37 #include <string.h> 38 38 #include <sys/stat.h> 39 39 40 - static struct mapping_t PostponeHelp[] = { 40 + static const struct mapping_t PostponeHelp[] = { 41 41 { N_("Exit"), OP_EXIT }, 42 42 { N_("Del"), OP_DELETE }, 43 43 { N_("Undel"), OP_UNDELETE },
+1 -1
protos.h
··· 300 300 int mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags); 301 301 int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *, ENTER_STATE *); 302 302 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL) 303 - int _mutt_get_field (char *, char *, size_t, int, int, char ***, int *); 303 + int _mutt_get_field (const char *, char *, size_t, int, int, char ***, int *); 304 304 int mutt_get_hook_type (const char *); 305 305 int mutt_get_field_unbuffered (char *, char *, size_t, int); 306 306 #define mutt_get_password(A,B,C) mutt_get_field_unbuffered(A,B,C,M_PASS)
+1 -1
query.c
··· 44 44 QUERY *data; 45 45 } ENTRY; 46 46 47 - static struct mapping_t QueryHelp[] = { 47 + static const struct mapping_t QueryHelp[] = { 48 48 { N_("Exit"), OP_EXIT }, 49 49 { N_("Mail"), OP_MAIL }, 50 50 { N_("New Query"), OP_QUERY },
+1 -1
recvattach.c
··· 49 49 break; \ 50 50 } 51 51 52 - static struct mapping_t AttachHelp[] = { 52 + static const struct mapping_t AttachHelp[] = { 53 53 { N_("Exit"), OP_EXIT }, 54 54 { N_("Save"), OP_SAVE }, 55 55 { N_("Pipe"), OP_PIPE },
+1 -1
remailer.c
··· 480 480 return 0; 481 481 } 482 482 483 - static struct mapping_t RemailerHelp[] = 483 + static const struct mapping_t RemailerHelp[] = 484 484 { 485 485 { N_("Append"), OP_MIX_APPEND }, 486 486 { N_("Insert"), OP_MIX_INSERT },
+1 -1
rfc2047.c
··· 234 234 static size_t q_encoder (char *s, ICONV_CONST char *d, size_t dlen, 235 235 const char *tocode) 236 236 { 237 - char hex[] = "0123456789ABCDEF"; 237 + static const char hex[] = "0123456789ABCDEF"; 238 238 char *s0 = s; 239 239 240 240 memcpy (s, "=?", 2), s += 2;
+1 -1
rfc822.c
··· 51 51 int RFC822Error = 0; 52 52 53 53 /* these must defined in the same order as the numerated errors given in rfc822.h */ 54 - const char *RFC822Errors[] = { 54 + const char * const RFC822Errors[] = { 55 55 "out of memory", 56 56 "mismatched parenthesis", 57 57 "mismatched quotes",
+1 -1
rfc822.h
··· 61 61 int rfc822_remove_from_adrlist (ADDRESS **a, const char *mailbox); 62 62 63 63 extern int RFC822Error; 64 - extern const char *RFC822Errors[]; 64 + extern const char * const RFC822Errors[]; 65 65 66 66 #define rfc822_error(x) RFC822Errors[x] 67 67 #define rfc822_new_address() safe_calloc(1,sizeof(ADDRESS))
+1 -1
sendlib.c
··· 65 65 66 66 const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t"; 67 67 68 - char B64Chars[64] = { 68 + const char B64Chars[64] = { 69 69 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 70 70 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 71 71 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+1 -1
url.c
··· 32 32 33 33 #include <ctype.h> 34 34 35 - static struct mapping_t UrlMap[] = 35 + static const struct mapping_t UrlMap[] = 36 36 { 37 37 { "file", U_FILE }, 38 38 { "imap", U_IMAP },