Mercurial > vim
comparison src/os_mac_conv.c @ 7833:c079097365f3 v7.4.1213
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 30 20:31:25 2016 +0100
patch 7.4.1213
Problem: Using old style function declarations.
Solution: Change to new style function declarations. (script by Hirohito
Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Jan 2016 20:45:04 +0100 |
parents | 7fda54504fee |
children | 068f397d0da4 |
comparison
equal
deleted
inserted
replaced
7832:f1ac913b8ff3 | 7833:c079097365f3 |
---|---|
42 | 42 |
43 /* | 43 /* |
44 * A Mac version of string_convert_ext() for special cases. | 44 * A Mac version of string_convert_ext() for special cases. |
45 */ | 45 */ |
46 char_u * | 46 char_u * |
47 mac_string_convert(ptr, len, lenp, fail_on_error, from_enc, to_enc, unconvlenp) | 47 mac_string_convert( |
48 char_u *ptr; | 48 char_u *ptr, |
49 int len; | 49 int len, |
50 int *lenp; | 50 int *lenp, |
51 int fail_on_error; | 51 int fail_on_error, |
52 int from_enc; | 52 int from_enc, |
53 int to_enc; | 53 int to_enc, |
54 int *unconvlenp; | 54 int *unconvlenp) |
55 { | 55 { |
56 char_u *retval, *d; | 56 char_u *retval, *d; |
57 CFStringRef cfstr; | 57 CFStringRef cfstr; |
58 int buflen, in, out, l, i; | 58 int buflen, in, out, l, i; |
59 CFStringEncoding from; | 59 CFStringEncoding from; |
178 * "real_size" is the size of the buffer that "ptr" points to. | 178 * "real_size" is the size of the buffer that "ptr" points to. |
179 * output is in-place, "sizep" is adjusted. | 179 * output is in-place, "sizep" is adjusted. |
180 * Returns OK or FAIL. | 180 * Returns OK or FAIL. |
181 */ | 181 */ |
182 int | 182 int |
183 macroman2enc(ptr, sizep, real_size) | 183 macroman2enc( |
184 char_u *ptr; | 184 char_u *ptr, |
185 long *sizep; | 185 long *sizep, |
186 long real_size; | 186 long real_size) |
187 { | 187 { |
188 CFStringRef cfstr; | 188 CFStringRef cfstr; |
189 CFRange r; | 189 CFRange r; |
190 CFIndex len = *sizep; | 190 CFIndex len = *sizep; |
191 | 191 |
224 * Output: "to[maxtolen]" length in "*tolenp" | 224 * Output: "to[maxtolen]" length in "*tolenp" |
225 * Unconverted rest in rest[*restlenp]. | 225 * Unconverted rest in rest[*restlenp]. |
226 * Returns OK or FAIL. | 226 * Returns OK or FAIL. |
227 */ | 227 */ |
228 int | 228 int |
229 enc2macroman(from, fromlen, to, tolenp, maxtolen, rest, restlenp) | 229 enc2macroman( |
230 char_u *from; | 230 char_u *from, |
231 size_t fromlen; | 231 size_t fromlen, |
232 char_u *to; | 232 char_u *to, |
233 int *tolenp; | 233 int *tolenp, |
234 int maxtolen; | 234 int maxtolen, |
235 char_u *rest; | 235 char_u *rest, |
236 int *restlenp; | 236 int *restlenp) |
237 { | 237 { |
238 CFStringRef cfstr; | 238 CFStringRef cfstr; |
239 CFRange r; | 239 CFRange r; |
240 CFIndex l; | 240 CFIndex l; |
241 | 241 |
272 | 272 |
273 /* | 273 /* |
274 * Initializes text converters | 274 * Initializes text converters |
275 */ | 275 */ |
276 void | 276 void |
277 mac_conv_init() | 277 mac_conv_init(void) |
278 { | 278 { |
279 TextEncoding utf8_encoding; | 279 TextEncoding utf8_encoding; |
280 TextEncoding utf8_hfsplus_encoding; | 280 TextEncoding utf8_hfsplus_encoding; |
281 TextEncoding utf8_canon_encoding; | 281 TextEncoding utf8_canon_encoding; |
282 TextEncoding utf16_encoding; | 282 TextEncoding utf16_encoding; |
307 | 307 |
308 /* | 308 /* |
309 * Destroys text converters | 309 * Destroys text converters |
310 */ | 310 */ |
311 void | 311 void |
312 mac_conv_cleanup() | 312 mac_conv_cleanup(void) |
313 { | 313 { |
314 if (gUTF16ToUTF8Converter) | 314 if (gUTF16ToUTF8Converter) |
315 { | 315 { |
316 TECDisposeConverter(gUTF16ToUTF8Converter); | 316 TECDisposeConverter(gUTF16ToUTF8Converter); |
317 gUTF16ToUTF8Converter = NULL; | 317 gUTF16ToUTF8Converter = NULL; |
328 * Conversion from UTF-16 UniChars to 'encoding' | 328 * Conversion from UTF-16 UniChars to 'encoding' |
329 * The function signature uses the real type of UniChar (as typedef'ed in | 329 * The function signature uses the real type of UniChar (as typedef'ed in |
330 * CFBase.h) to avoid clashes with X11 header files in the .pro file | 330 * CFBase.h) to avoid clashes with X11 header files in the .pro file |
331 */ | 331 */ |
332 char_u * | 332 char_u * |
333 mac_utf16_to_enc(from, fromLen, actualLen) | 333 mac_utf16_to_enc( |
334 unsigned short *from; | 334 unsigned short *from, |
335 size_t fromLen; | 335 size_t fromLen, |
336 size_t *actualLen; | 336 size_t *actualLen) |
337 { | 337 { |
338 /* Following code borrows somewhat from os_mswin.c */ | 338 /* Following code borrows somewhat from os_mswin.c */ |
339 vimconv_T conv; | 339 vimconv_T conv; |
340 size_t utf8_len; | 340 size_t utf8_len; |
341 char_u *utf8_str; | 341 char_u *utf8_str; |
382 * Conversion from 'encoding' to UTF-16 UniChars | 382 * Conversion from 'encoding' to UTF-16 UniChars |
383 * The function return uses the real type of UniChar (as typedef'ed in | 383 * The function return uses the real type of UniChar (as typedef'ed in |
384 * CFBase.h) to avoid clashes with X11 header files in the .pro file | 384 * CFBase.h) to avoid clashes with X11 header files in the .pro file |
385 */ | 385 */ |
386 unsigned short * | 386 unsigned short * |
387 mac_enc_to_utf16(from, fromLen, actualLen) | 387 mac_enc_to_utf16( |
388 char_u *from; | 388 char_u *from, |
389 size_t fromLen; | 389 size_t fromLen, |
390 size_t *actualLen; | 390 size_t *actualLen) |
391 { | 391 { |
392 /* Following code borrows somewhat from os_mswin.c */ | 392 /* Following code borrows somewhat from os_mswin.c */ |
393 vimconv_T conv; | 393 vimconv_T conv; |
394 size_t utf8_len; | 394 size_t utf8_len; |
395 char_u *utf8_str; | 395 char_u *utf8_str; |
441 /* | 441 /* |
442 * Converts from UTF-16 UniChars to CFString | 442 * Converts from UTF-16 UniChars to CFString |
443 * The void * return type is actually a CFStringRef | 443 * The void * return type is actually a CFStringRef |
444 */ | 444 */ |
445 void * | 445 void * |
446 mac_enc_to_cfstring(from, fromLen) | 446 mac_enc_to_cfstring( |
447 char_u *from; | 447 char_u *from, |
448 size_t fromLen; | 448 size_t fromLen) |
449 { | 449 { |
450 UniChar *utf16_str; | 450 UniChar *utf16_str; |
451 size_t utf16_len; | 451 size_t utf16_len; |
452 CFStringRef result = NULL; | 452 CFStringRef result = NULL; |
453 | 453 |
463 | 463 |
464 /* | 464 /* |
465 * Converts a decomposed HFS+ UTF-8 path to precomposed UTF-8 | 465 * Converts a decomposed HFS+ UTF-8 path to precomposed UTF-8 |
466 */ | 466 */ |
467 char_u * | 467 char_u * |
468 mac_precompose_path(decompPath, decompLen, precompLen) | 468 mac_precompose_path( |
469 char_u *decompPath; | 469 char_u *decompPath, |
470 size_t decompLen; | 470 size_t decompLen, |
471 size_t *precompLen; | 471 size_t *precompLen) |
472 { | 472 { |
473 char_u *result = NULL; | 473 char_u *result = NULL; |
474 size_t actualLen = 0; | 474 size_t actualLen = 0; |
475 | 475 |
476 if (gPathConverter) | 476 if (gPathConverter) |
496 | 496 |
497 /* | 497 /* |
498 * Converts from UTF-16 UniChars to precomposed UTF-8 | 498 * Converts from UTF-16 UniChars to precomposed UTF-8 |
499 */ | 499 */ |
500 static char_u * | 500 static char_u * |
501 mac_utf16_to_utf8(from, fromLen, actualLen) | 501 mac_utf16_to_utf8( |
502 UniChar *from; | 502 UniChar *from, |
503 size_t fromLen; | 503 size_t fromLen, |
504 size_t *actualLen; | 504 size_t *actualLen) |
505 { | 505 { |
506 ByteCount utf8_len; | 506 ByteCount utf8_len; |
507 ByteCount inputRead; | 507 ByteCount inputRead; |
508 char_u *result; | 508 char_u *result; |
509 | 509 |
536 | 536 |
537 /* | 537 /* |
538 * Converts from UTF-8 to UTF-16 UniChars | 538 * Converts from UTF-8 to UTF-16 UniChars |
539 */ | 539 */ |
540 static UniChar * | 540 static UniChar * |
541 mac_utf8_to_utf16(from, fromLen, actualLen) | 541 mac_utf8_to_utf16( |
542 char_u *from; | 542 char_u *from, |
543 size_t fromLen; | 543 size_t fromLen, |
544 size_t *actualLen; | 544 size_t *actualLen) |
545 { | 545 { |
546 CFStringRef utf8_str; | 546 CFStringRef utf8_str; |
547 CFRange convertRange; | 547 CFRange convertRange; |
548 UniChar *result = NULL; | 548 UniChar *result = NULL; |
549 | 549 |
571 | 571 |
572 /* | 572 /* |
573 * Sets LANG environment variable in Vim from Mac locale | 573 * Sets LANG environment variable in Vim from Mac locale |
574 */ | 574 */ |
575 void | 575 void |
576 mac_lang_init() { | 576 mac_lang_init(void) |
577 { | |
577 if (mch_getenv((char_u *)"LANG") == NULL) | 578 if (mch_getenv((char_u *)"LANG") == NULL) |
578 { | 579 { |
579 char buf[20]; | 580 char buf[20]; |
580 if (LocaleRefGetPartString(NULL, | 581 if (LocaleRefGetPartString(NULL, |
581 kLocaleLanguageMask | kLocaleLanguageVariantMask | | 582 kLocaleLanguageMask | kLocaleLanguageVariantMask | |