diff options
| author | Nick Barnes | 2012-10-26 13:03:44 +0100 |
|---|---|---|
| committer | Nick Barnes | 2012-10-26 13:03:44 +0100 |
| commit | 20ad19da97d50ab8f8d95ecd1029dcf5f9583792 (patch) | |
| tree | aa11031228e96c47b5ed488e43037a5412f6f2a2 /mps/code | |
| parent | 750d51523316c37046c0c31e2a53d19b3b46fee8 (diff) | |
| download | emacs-20ad19da97d50ab8f8d95ecd1029dcf5f9583792.tar.gz emacs-20ad19da97d50ab8f8d95ecd1029dcf5f9583792.zip | |
Make mps_telemetry_control case-insensitive, and make it accept "all" as an event class.
Copied from Perforce
Change: 180098
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/mpsliban.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/mps/code/mpsliban.c b/mps/code/mpsliban.c index 8abab586319..f966df6f4f2 100644 --- a/mps/code/mpsliban.c +++ b/mps/code/mpsliban.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
| 37 | #include <stdio.h> | 37 | #include <stdio.h> |
| 38 | #include <string.h> | 38 | #include <string.h> |
| 39 | #include <ctype.h> | ||
| 39 | 40 | ||
| 40 | 41 | ||
| 41 | int mps_lib_get_EOF(void) | 42 | int mps_lib_get_EOF(void) |
| @@ -119,7 +120,9 @@ unsigned long mps_lib_telemetry_control(void) | |||
| 119 | unsigned long mask; | 120 | unsigned long mask; |
| 120 | char buf[256]; | 121 | char buf[256]; |
| 121 | char *word; | 122 | char *word; |
| 123 | char *p; | ||
| 122 | char *sep = " "; | 124 | char *sep = " "; |
| 125 | char rowName[256]; | ||
| 123 | 126 | ||
| 124 | s = getenv("MPS_TELEMETRY_CONTROL"); | 127 | s = getenv("MPS_TELEMETRY_CONTROL"); |
| 125 | if (s == NULL) | 128 | if (s == NULL) |
| @@ -130,14 +133,29 @@ unsigned long mps_lib_telemetry_control(void) | |||
| 130 | if (mask != 0) | 133 | if (mask != 0) |
| 131 | return mask; | 134 | return mask; |
| 132 | 135 | ||
| 133 | /* Split the value at spaces and try to patch the words against the names | 136 | /* copy the envar to a buffer so we can mess with it. */ |
| 134 | of event kinds, enabling them if there's a match. */ | ||
| 135 | strncpy(buf, s, sizeof(buf) - 1); | 137 | strncpy(buf, s, sizeof(buf) - 1); |
| 136 | buf[sizeof(buf) - 1] = '\0'; | 138 | buf[sizeof(buf) - 1] = '\0'; |
| 139 | /* downcase it */ | ||
| 140 | for (p = buf; *p != '\0'; ++p) | ||
| 141 | *p = (char)tolower(*p); | ||
| 142 | |||
| 143 | /* Split the value at spaces and try to match the words against the names | ||
| 144 | of event kinds, enabling them if there's a match. */ | ||
| 137 | for (word = strtok(buf, sep); word != NULL; word = strtok(NULL, sep)) { | 145 | for (word = strtok(buf, sep); word != NULL; word = strtok(NULL, sep)) { |
| 138 | #define TELEMATCH(X, rowName, rowDoc) \ | 146 | if (strcmp(word, "all") == 0) { |
| 139 | if (strcmp(word, #rowName) == 0) \ | 147 | mask = (unsigned long)-1; |
| 140 | mask |= (1ul << EventKind##rowName); | 148 | printf("All events."); |
| 149 | return mask; | ||
| 150 | } | ||
| 151 | #define TELEMATCH(X, name, rowDoc) \ | ||
| 152 | strncpy(rowName, #name, sizeof(rowName) - 1); \ | ||
| 153 | rowName[sizeof(rowName) - 1] = '\0'; \ | ||
| 154 | for (p = rowName; *p != '\0'; ++p) \ | ||
| 155 | *p = (char)tolower(*p); \ | ||
| 156 | if (strcmp(word, rowName) == 0) { \ | ||
| 157 | mask |= (1ul << EventKind##name); \ | ||
| 158 | printf("Events to include " rowDoc "\n"); } | ||
| 141 | EventKindENUM(TELEMATCH, X) | 159 | EventKindENUM(TELEMATCH, X) |
| 142 | } | 160 | } |
| 143 | 161 | ||