diff options
author | Alan Modra <amodra@gmail.com> | 2018-08-20 09:25:12 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-08-20 09:54:20 +0930 |
commit | 865dcc8a4d397e4d9d032785e8ff318e28355d76 (patch) | |
tree | 73899c3d8ad30ad6e0f8b88782693a31b7a88961 /bfd/mmo.c | |
parent | d203b41ac79b011d63bc1e2467f9c8a81f468eed (diff) | |
download | gdb-865dcc8a4d397e4d9d032785e8ff318e28355d76.zip gdb-865dcc8a4d397e4d9d032785e8ff318e28355d76.tar.gz gdb-865dcc8a4d397e4d9d032785e8ff318e28355d76.tar.bz2 |
Don't init array at run time
When it can be done at compile time.
* mmo.c (valid_mmo_symbol_character_set): Initialize and make
array const.
(mmo_init): Don't init valid_mmo_symbol_character_set.
Diffstat (limited to 'bfd/mmo.c')
-rw-r--r-- | bfd/mmo.c | 51 |
1 files changed, 24 insertions, 27 deletions
@@ -431,22 +431,30 @@ static bfd_boolean mmo_write_section_description (bfd *, asection *); static bfd_boolean mmo_has_leading_or_trailing_zero_tetra_p (bfd *, asection *); -/* Global "const" variables initialized once. Must not depend on - particular input or caller; put such things into the bfd or elsewhere. - Look ma, no static per-invocation data! */ - -static -char valid_mmo_symbol_character_set[/* A-Z a-z (we assume consecutive - codes; sorry EBCDIC:ers!). */ - + 'Z' - 'A' + 1 + 'z' - 'a' + 1 - /* Digits. */ - + 10 - /* ':' and '_'. */ - + 1 + 1 - /* Codes higher than 126. */ - + 256 - 126 - /* Ending zero. */ - + 1]; +static const char +valid_mmo_symbol_character_set[] = +{ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + ':', '_', 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255, + 0 +}; /* Get section SECNAME or create one if it doesn't exist. When creating @@ -484,21 +492,10 @@ static void mmo_init (void) { static bfd_boolean inited = FALSE; - int i = 0; - int j = 0; - static const char letters[] - = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:_"; if (inited) return; inited = TRUE; - - /* Fill in the set of valid symbol characters. */ - strcpy (valid_mmo_symbol_character_set, letters); - i = strlen (letters); - - for (j = 126; j < 256; j++) - valid_mmo_symbol_character_set[i++] = j; } /* Check whether an existing file is an mmo file. */ |