Browse Source

Use static locals in utf_mapper.h

Scott Lahteine 8 years ago
parent
commit
d5b7c595ae
1 changed files with 14 additions and 11 deletions
  1. 14
    11
      Marlin/utf_mapper.h

+ 14
- 11
Marlin/utf_mapper.h View File

@@ -130,9 +130,10 @@
130 130
   }
131 131
 
132 132
 #elif ENABLED(MAPPER_C2C3)
133
-  uint8_t utf_hi_char; // UTF-8 high part
134
-  bool seen_c2 = false;
135
-  char charset_mapper(char c){
133
+
134
+  char charset_mapper(char c) {
135
+    static uint8_t utf_hi_char; // UTF-8 high part
136
+    static bool seen_c2 = false;
136 137
     uint8_t d = c;
137 138
     if ( d >= 0x80 ) { // UTF-8 handling
138 139
       if ( (d >= 0xc0) && (!seen_c2) ) {
@@ -160,12 +161,12 @@
160 161
   }
161 162
 
162 163
 #elif ENABLED(MAPPER_D0D1_MOD)
163
-  uint8_t utf_hi_char; // UTF-8 high part
164
-  bool seen_d5 = false;
165 164
 
166 165
   char charset_mapper(char c) {
167 166
     // it is a Russian alphabet translation
168 167
     // except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
168
+    static uint8_t utf_hi_char; // UTF-8 high part
169
+    static bool seen_d5 = false;
169 170
     uint8_t d = c;
170 171
     if (d >= 0x80) { // UTF-8 handling
171 172
       if (d >= 0xd0 && !seen_d5) {
@@ -197,9 +198,10 @@
197 198
   }
198 199
 
199 200
 #elif ENABLED(MAPPER_D0D1)
200
-  uint8_t utf_hi_char; // UTF-8 high part
201
-  bool seen_d5 = false;
201
+
202 202
   char charset_mapper(char c) {
203
+    static uint8_t utf_hi_char; // UTF-8 high part
204
+    static bool seen_d5 = false;
203 205
     uint8_t d = c;
204 206
     if (d >= 0x80u) { // UTF-8 handling
205 207
       if (d >= 0xd0u && !seen_d5) {
@@ -227,10 +229,11 @@
227 229
   }
228 230
 
229 231
 #elif ENABLED(MAPPER_E382E383)
230
-  uint8_t utf_hi_char; // UTF-8 high part
231
-  bool seen_e3 = false;
232
-  bool seen_82_83 = false;
233
-  char charset_mapper(char c){
232
+
233
+  char charset_mapper(char c) {
234
+    static uint8_t utf_hi_char; // UTF-8 high part
235
+    static bool seen_e3 = false;
236
+    static bool seen_82_83 = false;
234 237
     uint8_t d = c;
235 238
     if (d >= 0x80) { // UTF-8 handling
236 239
       if (d == 0xe3 && !seen_e3) {

Loading…
Cancel
Save