@@ -926,13 +926,9 @@ - (int)showDialogWithAttributes:(NSDictionary *)attr textField:(char *)txtfield
926926 if (txtfield && [dialogReturn count ] > 1 ) {
927927 NSString *retString = [dialogReturn objectAtIndex: 1 ];
928928 char_u *ret = (char_u*)[retString UTF8String ];
929- #ifdef FEAT_MBYTE
930929 ret = CONVERT_FROM_UTF8 (ret);
931- #endif
932930 vim_strncpy ((char_u*)txtfield, ret, IOSIZE - 1 );
933- #ifdef FEAT_MBYTE
934931 CONVERT_FROM_UTF8_FREE (ret);
935- #endif
936932 }
937933 }
938934
@@ -1350,25 +1346,17 @@ - (NSString *)evaluateExpression:(in bycopy NSString *)expr
13501346 NSString *eval = nil ;
13511347 char_u *s = (char_u*)[expr UTF8String ];
13521348
1353- #ifdef FEAT_MBYTE
13541349 s = CONVERT_FROM_UTF8 (s);
1355- #endif
13561350
13571351 char_u *res = eval_client_expr_to_string (s);
13581352
1359- #ifdef FEAT_MBYTE
13601353 CONVERT_FROM_UTF8_FREE (s);
1361- #endif
13621354
13631355 if (res != NULL ) {
13641356 s = res;
1365- #ifdef FEAT_MBYTE
13661357 s = CONVERT_TO_UTF8 (s);
1367- #endif
13681358 eval = [NSString stringWithUTF8String: (char *)s];
1369- #ifdef FEAT_MBYTE
13701359 CONVERT_TO_UTF8_FREE (s);
1371- #endif
13721360 vim_free (res);
13731361 }
13741362
@@ -1400,15 +1388,13 @@ - (BOOL)starRegisterToPasteboard:(byref NSPasteboard *)pboard
14001388
14011389 // TODO: Avoid overflow.
14021390 int len = (int )llen;
1403- #ifdef FEAT_MBYTE
14041391 if (output_conv.vc_type != CONV_NONE) {
14051392 char_u *conv_str = string_convert (&output_conv, str, &len);
14061393 if (conv_str) {
14071394 vim_free (str);
14081395 str = conv_str;
14091396 }
14101397 }
1411- #endif
14121398
14131399 NSString *string = [[NSString alloc ]
14141400 initWithBytes: str length: len encoding: NSUTF8StringEncoding];
@@ -1526,13 +1512,9 @@ - (BOOL)sendToServer:(NSString *)name string:(NSString *)string
15261512 if (!conn) {
15271513 if (!silent) {
15281514 char_u *s = (char_u*)[name UTF8String ];
1529- #ifdef FEAT_MBYTE
15301515 s = CONVERT_FROM_UTF8 (s);
1531- #endif
15321516 semsg (_ (e_noserver), s);
1533- #ifdef FEAT_MBYTE
15341517 CONVERT_FROM_UTF8_FREE (s);
1535- #endif
15361518 }
15371519 return NO ;
15381520 }
@@ -2143,14 +2125,12 @@ - (void)doKeyDown:(NSString *)key
21432125 if ([self handleSpecialKey: key keyCode: code modifiers: mods])
21442126 return ;
21452127
2146- #ifdef FEAT_MBYTE
21472128 char_u *conv_str = NULL ;
21482129 if (input_conv.vc_type != CONV_NONE) {
21492130 conv_str = string_convert (&input_conv, str, &len);
21502131 if (conv_str)
21512132 str = conv_str;
21522133 }
2153- #endif
21542134
21552135 if (mods & MOD_MASK_CMD) {
21562136 // NOTE: For normal input (non-special, 'macmeta' off) the modifier
@@ -2195,10 +2175,8 @@ - (void)doKeyDown:(NSString *)key
21952175 }
21962176 }
21972177
2198- #ifdef FEAT_MBYTE
21992178 if (conv_str)
22002179 vim_free (conv_str);
2201- #endif
22022180}
22032181
22042182- (BOOL )handleSpecialKey : (NSString *)key
@@ -2230,9 +2208,7 @@ - (BOOL)handleSpecialKey:(NSString *)key
22302208 chars[2 ] = K_THIRD (ikey);
22312209 len = 3 ;
22322210 } else if (mods & MOD_MASK_ALT && special_keys[i].vim_code1 == 0
2233- #ifdef FEAT_MBYTE
22342211 && !enc_dbcs // TODO: ? (taken from gui_gtk_x11.c)
2235- #endif
22362212 ) {
22372213 ASLogDebug (@" Alt special=%d " , ikey);
22382214
@@ -2242,7 +2218,6 @@ - (BOOL)handleSpecialKey:(NSString *)key
22422218 // The following code was gleaned from gui_gtk_x11.c.
22432219 mods &= ~MOD_MASK_ALT;
22442220 int mkey = 0x80 | ikey;
2245- #ifdef FEAT_MBYTE
22462221 if (enc_utf8) { // TODO: What about other encodings?
22472222 // Convert to utf-8
22482223 chars[0 ] = (mkey >> 6 ) + 0xc0 ;
@@ -2256,7 +2231,6 @@ - (BOOL)handleSpecialKey:(NSString *)key
22562231 len = 2 ;
22572232 }
22582233 } else
2259- #endif
22602234 {
22612235 chars[0 ] = mkey;
22622236 len = 1 ;
@@ -2308,7 +2282,7 @@ - (BOOL)handleMacMetaKey:(int)ikey modifiers:(int)mods
23082282 }
23092283
23102284 string[len++] = ch;
2311- # ifdef FEAT_MBYTE
2285+
23122286 // TODO: What if 'enc' is not "utf-8"?
23132287 if (enc_utf8 && (ch & 0x80 )) { // convert to utf-8
23142288 string[len++] = ch & 0xbf ;
@@ -2318,7 +2292,6 @@ - (BOOL)handleMacMetaKey:(int)ikey modifiers:(int)mods
23182292 string[len++] = (int )KE_CSI;
23192293 }
23202294 }
2321- #endif
23222295
23232296 add_to_input_buf (string, len);
23242297 return YES ;
@@ -2492,12 +2465,10 @@ - (void)handleSetFont:(NSData *)data
24922465 ws = (char_u*)[wname UTF8String ];
24932466 }
24942467
2495- #ifdef FEAT_MBYTE
24962468 s = CONVERT_FROM_UTF8 (s);
24972469 if (ws) {
24982470 ws = CONVERT_FROM_UTF8 (ws);
24992471 }
2500- #endif
25012472
25022473 set_option_value ((char_u*)" guifont" , 0 , s, 0 );
25032474
@@ -2508,12 +2479,10 @@ - (void)handleSetFont:(NSData *)data
25082479 set_option_value ((char_u*)" guifontwide" , 0 , ws, 0 );
25092480 }
25102481
2511- #ifdef FEAT_MBYTE
25122482 if (ws) {
25132483 CONVERT_FROM_UTF8_FREE (ws);
25142484 }
25152485 CONVERT_FROM_UTF8_FREE (s);
2516- #endif
25172486
25182487 [self redrawScreen ];
25192488}
@@ -2584,15 +2553,11 @@ - (void)handleDropString:(NSData *)data
25842553
25852554 len = [string lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
25862555 char_u *s = (char_u*)[string UTF8String ];
2587- #ifdef FEAT_MBYTE
25882556 if (input_conv.vc_type != CONV_NONE)
25892557 s = string_convert (&input_conv, s, &len);
2590- #endif
25912558 dnd_yank_drag_data (s, len);
2592- #ifdef FEAT_MBYTE
25932559 if (input_conv.vc_type != CONV_NONE)
25942560 vim_free (s);
2595- #endif
25962561 add_to_input_buf (dropkey, sizeof (dropkey));
25972562#endif // FEAT_DND
25982563}
@@ -3326,13 +3291,9 @@ static id vimToCocoa(typval_T * tv, int depth)
33263291 if (!val) {
33273292 result = [NSString string ];
33283293 } else {
3329- #ifdef FEAT_MBYTE
33303294 val = CONVERT_TO_UTF8 (val);
3331- #endif
33323295 result = [NSString stringWithUTF8String: (char *)val];
3333- #ifdef FEAT_MBYTE
33343296 CONVERT_TO_UTF8_FREE (val);
3335- #endif
33363297 }
33373298 } else if (tv->v_type == VAR_NUMBER) {
33383299 // looks like sizeof(varnumber_T) is always <= sizeof(long)
@@ -3366,13 +3327,9 @@ static id vimToCocoa(typval_T * tv, int depth)
33663327 newObj = vimToCocoa (&di->di_tv , depth + 1 );
33673328
33683329 char_u * keyval = hi->hi_key ;
3369- #ifdef FEAT_MBYTE
33703330 keyval = CONVERT_TO_UTF8 (keyval);
3371- #endif
33723331 NSString * key = [NSString stringWithUTF8String: (char *)keyval];
3373- #ifdef FEAT_MBYTE
33743332 CONVERT_TO_UTF8_FREE (keyval);
3375- #endif
33763333 [dict setObject: newObj forKey: key];
33773334 }
33783335 }
@@ -3395,9 +3352,7 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr)
33953352
33963353 char_u *s = (char_u*)[expr UTF8String ];
33973354
3398- #ifdef FEAT_MBYTE
33993355 s = CONVERT_FROM_UTF8 (s);
3400- #endif
34013356
34023357 int save_dbl = debug_break_level;
34033358 int save_ro = redir_off;
@@ -3415,9 +3370,7 @@ static id evalExprCocoa(NSString * expr, NSString ** errstr)
34153370 setcursor ();
34163371 out_flush ();
34173372
3418- #ifdef FEAT_MBYTE
34193373 CONVERT_FROM_UTF8_FREE (s);
3420- #endif
34213374
34223375#ifdef FEAT_GUI
34233376 if (gui.in_use )
@@ -3451,19 +3404,15 @@ + (id)stringWithVimString:(char_u *)s
34513404 // still fails an empty NSString is returned.
34523405 NSString *string = nil ;
34533406 if (s) {
3454- #ifdef FEAT_MBYTE
34553407 s = CONVERT_TO_UTF8 (s);
3456- #endif
34573408 string = [NSString stringWithUTF8String: (char *)s];
34583409 if (!string) {
34593410 // HACK! Apparently 's' is not a valid utf-8 string, maybe it is
34603411 // latin-1?
34613412 string = [NSString stringWithCString: (char *)s
34623413 encoding: NSISOLatin1StringEncoding];
34633414 }
3464- #ifdef FEAT_MBYTE
34653415 CONVERT_TO_UTF8_FREE (s);
3466- #endif
34673416 }
34683417
34693418 return string != nil ? string : [NSString string ];
@@ -3473,13 +3422,9 @@ - (char_u *)vimStringSave
34733422{
34743423 char_u *s = (char_u*)[self UTF8String ], *ret = NULL ;
34753424
3476- #ifdef FEAT_MBYTE
34773425 s = CONVERT_FROM_UTF8 (s);
3478- #endif
34793426 ret = vim_strsave (s);
3480- #ifdef FEAT_MBYTE
34813427 CONVERT_FROM_UTF8_FREE (s);
3482- #endif
34833428
34843429 return ret;
34853430}
0 commit comments