comparison src/mac.c @ 90385:72dea2ff0142

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-57 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 226-238) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/progmodes/python.el (python-mode): Fix typo. * gnus--rel--5.10 (patch 86-90) - Update from CVS - Merge from emacs--devo--0
author Miles Bader <miles@gnu.org>
date Fri, 21 Apr 2006 05:39:14 +0000
parents c156f6a9e7b5 e82c1fc1df38
children 2ecafc6d5db7
comparison
equal deleted inserted replaced
90384:c156f6a9e7b5 90385:72dea2ff0142
451 #else 451 #else
452 FSSpec fs; 452 FSSpec fs;
453 char *buf; 453 char *buf;
454 454
455 buf = xmalloc (data_size + 1); 455 buf = xmalloc (data_size + 1);
456 if (buf) 456 memcpy (buf, data_ptr, data_size);
457 { 457 buf[data_size] = '\0';
458 memcpy (buf, data_ptr, data_size); 458 err = posix_pathname_to_fsspec (buf, &fs);
459 buf[data_size] = '\0'; 459 xfree (buf);
460 err = posix_pathname_to_fsspec (buf, &fs);
461 xfree (buf);
462 }
463 else
464 err = memFullErr;
465 if (err == noErr) 460 if (err == noErr)
466 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result); 461 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result);
467 #endif 462 #endif
468 } 463 }
469 else if (to_type == TYPE_FILE_NAME) 464 else if (to_type == TYPE_FILE_NAME)
487 typeFileURL, &desc); 482 typeFileURL, &desc);
488 if (err == noErr) 483 if (err == noErr)
489 { 484 {
490 size = AEGetDescDataSize (&desc); 485 size = AEGetDescDataSize (&desc);
491 buf = xmalloc (size); 486 buf = xmalloc (size);
492 if (buf) 487 err = AEGetDescData (&desc, buf, size);
493 { 488 if (err == noErr)
494 err = AEGetDescData (&desc, buf, size); 489 url = CFURLCreateWithBytes (NULL, buf, size,
495 if (err == noErr) 490 kCFStringEncodingUTF8, NULL);
496 url = CFURLCreateWithBytes (NULL, buf, size, 491 xfree (buf);
497 kCFStringEncodingUTF8, NULL);
498 xfree (buf);
499 }
500 AEDisposeDesc (&desc); 492 AEDisposeDesc (&desc);
501 } 493 }
502 } 494 }
503 if (url) 495 if (url)
504 { 496 {
579 data_size = AEGetDescDataSize (from_desc); 571 data_size = AEGetDescDataSize (from_desc);
580 #else 572 #else
581 data_size = GetHandleSize (from_desc->dataHandle); 573 data_size = GetHandleSize (from_desc->dataHandle);
582 #endif 574 #endif
583 data_ptr = xmalloc (data_size); 575 data_ptr = xmalloc (data_size);
584 if (data_ptr)
585 {
586 #if TARGET_API_MAC_CARBON 576 #if TARGET_API_MAC_CARBON
587 err = AEGetDescData (from_desc, data_ptr, data_size); 577 err = AEGetDescData (from_desc, data_ptr, data_size);
588 #else 578 #else
589 memcpy (data_ptr, *(from_desc->dataHandle), data_size); 579 memcpy (data_ptr, *(from_desc->dataHandle), data_size);
590 #endif 580 #endif
591 if (err == noErr) 581 if (err == noErr)
592 err = mac_coerce_file_name_ptr (from_type, data_ptr, 582 err = mac_coerce_file_name_ptr (from_type, data_ptr,
593 data_size, to_type, 583 data_size, to_type,
594 handler_refcon, result); 584 handler_refcon, result);
595 xfree (data_ptr); 585 xfree (data_ptr);
596 }
597 else
598 err = memFullErr;
599 } 586 }
600 587
601 if (err != noErr) 588 if (err != noErr)
602 return errAECoercionFail; 589 return errAECoercionFail;
603 return noErr; 590 return noErr;
689 err = GetEventParameter (event, names[i], types[i], NULL, 676 err = GetEventParameter (event, names[i], types[i], NULL,
690 0, &size, NULL); 677 0, &size, NULL);
691 if (err != noErr) 678 if (err != noErr)
692 break; 679 break;
693 buf = xmalloc (size); 680 buf = xmalloc (size);
694 if (buf == NULL)
695 break;
696 err = GetEventParameter (event, names[i], types[i], NULL, 681 err = GetEventParameter (event, names[i], types[i], NULL,
697 size, NULL, buf); 682 size, NULL, buf);
698 if (err == noErr) 683 if (err == noErr)
699 AEPutParamPtr (result, names[i], types[i], buf, size); 684 AEPutParamPtr (result, names[i], types[i], buf, size);
700 xfree (buf); 685 xfree (buf);
1594 } 1579 }
1595 } 1580 }
1596 1581
1597 count = CFSetGetCount (key_set); 1582 count = CFSetGetCount (key_set);
1598 keys = xmalloc (sizeof (CFStringRef) * count); 1583 keys = xmalloc (sizeof (CFStringRef) * count);
1599 if (keys == NULL)
1600 goto out;
1601 CFSetGetValues (key_set, (const void **)keys); 1584 CFSetGetValues (key_set, (const void **)keys);
1602 for (index = 0; index < count; index++) 1585 for (index = 0; index < count; index++)
1603 { 1586 {
1604 res_name = SDATA (cfstring_to_lisp_nodecode (keys[index])); 1587 res_name = SDATA (cfstring_to_lisp_nodecode (keys[index]));
1605 quarks = parse_resource_name (&res_name); 1588 quarks = parse_resource_name (&res_name);
4545 4528
4546 in_text = (UniChar *)CFStringGetCharactersPtr (str); 4529 in_text = (UniChar *)CFStringGetCharactersPtr (str);
4547 if (in_text == NULL) 4530 if (in_text == NULL)
4548 { 4531 {
4549 buffer = xmalloc (sizeof (UniChar) * length); 4532 buffer = xmalloc (sizeof (UniChar) * length);
4550 if (buffer) 4533 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4551 { 4534 in_text = buffer;
4552 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4553 in_text = buffer;
4554 }
4555 } 4535 }
4556 4536
4557 if (in_text) 4537 if (in_text)
4558 err = CreateUnicodeToTextInfo(&map, &uni); 4538 err = CreateUnicodeToTextInfo(&map, &uni);
4559 while (err == noErr) 4539 while (err == noErr)
4560 { 4540 {
4561 out_buf = xmalloc (out_size); 4541 out_buf = xmalloc (out_size);
4562 if (out_buf == NULL) 4542 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar),
4563 err = mFulErr; 4543 in_text,
4564 else 4544 kUnicodeDefaultDirectionMask,
4565 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar), 4545 0, NULL, NULL, NULL,
4566 in_text, 4546 out_size, &out_read, &out_len,
4567 kUnicodeDefaultDirectionMask, 4547 out_buf);
4568 0, NULL, NULL, NULL,
4569 out_size, &out_read, &out_len,
4570 out_buf);
4571 if (err == noErr && out_read < length * sizeof (UniChar)) 4548 if (err == noErr && out_read < length * sizeof (UniChar))
4572 { 4549 {
4573 xfree (out_buf); 4550 xfree (out_buf);
4574 out_size += length; 4551 out_size += length;
4575 } 4552 }