/[emacs]/emacs/src/mac.c
ViewVC logotype

Diff of /emacs/src/mac.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.44 by ttn, Sun Aug 7 12:33:17 2005 UTC revision 1.45 by mituharu, Sun Oct 16 02:22:16 2005 UTC
# Line 3411  terminate_applescript() Line 3411  terminate_applescript()
3411  }  }
3412    
3413  /* Convert a lisp string to the 4 byte character code.  */  /* Convert a lisp string to the 4 byte character code.  */
3414    
3415  OSType  OSType
3416  mac_get_code_from_arg(Lisp_Object arg, OSType defCode)  mac_get_code_from_arg(Lisp_Object arg, OSType defCode)
3417  {  {
# Line 3419  mac_get_code_from_arg(Lisp_Object arg, O Line 3419  mac_get_code_from_arg(Lisp_Object arg, O
3419    if (NILP(arg))    if (NILP(arg))
3420      {      {
3421        result = defCode;        result = defCode;
3422      }      }
3423    else    else
3424      {      {
3425        /* check type string */        /* check type string */
# Line 3483  DEFUN ("mac-get-file-creator", Fmac_get_ Line 3483  DEFUN ("mac-get-file-creator", Fmac_get_
3483    
3484        status = FSpGetFInfo (&fss, &finder_info);        status = FSpGetFInfo (&fss, &finder_info);
3485  #endif  #endif
3486        if (status == noErr)        if (status == noErr)
3487          {          {
3488  #ifdef MAC_OSX  #ifdef MAC_OSX
3489            result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator);            result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator);
# Line 3538  DEFUN ("mac-get-file-type", Fmac_get_fil Line 3538  DEFUN ("mac-get-file-type", Fmac_get_fil
3538    
3539        status = FSpGetFInfo (&fss, &finder_info);        status = FSpGetFInfo (&fss, &finder_info);
3540  #endif  #endif
3541        if (status == noErr)        if (status == noErr)
3542          {          {
3543  #ifdef MAC_OSX  #ifdef MAC_OSX
3544            result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType);            result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType);
# Line 3596  assumed. Return non-nil if successful. Line 3596  assumed. Return non-nil if successful.
3596    
3597        status = FSpGetFInfo (&fss, &finder_info);        status = FSpGetFInfo (&fss, &finder_info);
3598  #endif  #endif
3599        if (status == noErr)        if (status == noErr)
3600          {          {
3601  #ifdef MAC_OSX  #ifdef MAC_OSX
3602          ((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode;          ((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode;
# Line 3656  CODE must be a 4-character string.  Retu Line 3656  CODE must be a 4-character string.  Retu
3656    
3657        status = FSpGetFInfo (&fss, &finder_info);        status = FSpGetFInfo (&fss, &finder_info);
3658  #endif  #endif
3659        if (status == noErr)        if (status == noErr)
3660          {          {
3661  #ifdef MAC_OSX  #ifdef MAC_OSX
3662          ((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode;          ((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode;
# Line 3968  get_cfstring_encoding_from_lisp (obj) Line 3968  get_cfstring_encoding_from_lisp (obj)
3968    CFStringRef iana_name;    CFStringRef iana_name;
3969    CFStringEncoding encoding = kCFStringEncodingInvalidId;    CFStringEncoding encoding = kCFStringEncodingInvalidId;
3970    
3971      if (NILP (obj))
3972        return kCFStringEncodingUnicode;
3973    
3974    if (INTEGERP (obj))    if (INTEGERP (obj))
3975      return XINT (obj);      return XINT (obj);
3976    
3977    if (SYMBOLP (obj) && !NILP (obj) && !NILP (Fcoding_system_p (obj)))    if (SYMBOLP (obj) && !NILP (Fcoding_system_p (obj)))
3978      {      {
3979        Lisp_Object coding_spec, plist;        Lisp_Object coding_spec, plist;
3980    
# Line 4115  DEFUN ("mac-code-convert-string", Fmac_c Line 4118  DEFUN ("mac-code-convert-string", Fmac_c
4118         doc: /* Convert STRING from SOURCE encoding to TARGET encoding.         doc: /* Convert STRING from SOURCE encoding to TARGET encoding.
4119  The conversion is performed using the converter provided by the system.  The conversion is performed using the converter provided by the system.
4120  Each encoding is specified by either a coding system symbol, a mime  Each encoding is specified by either a coding system symbol, a mime
4121  charset string, or an integer as a CFStringEncoding value.  charset string, or an integer as a CFStringEncoding value.  Nil for
4122    encoding means UTF-16 in native byte order, no byte order marker.
4123  On Mac OS X 10.2 and later, you can do Unicode Normalization by  On Mac OS X 10.2 and later, you can do Unicode Normalization by
4124  specifying the optional argument NORMALIZATION-FORM with a symbol NFD,  specifying the optional argument NORMALIZATION-FORM with a symbol NFD,
4125  NFKD, NFC, NFKC, HFS+D, or HFS+C.  NFKD, NFC, NFKC, HFS+D, or HFS+C.
# Line 4126  On successful conversion, return the res Line 4130  On successful conversion, return the res
4130    Lisp_Object result = Qnil;    Lisp_Object result = Qnil;
4131    CFStringEncoding src_encoding, tgt_encoding;    CFStringEncoding src_encoding, tgt_encoding;
4132    CFStringRef str = NULL;    CFStringRef str = NULL;
   CFDataRef data = NULL;  
4133    
4134    CHECK_STRING (string);    CHECK_STRING (string);
4135    if (!INTEGERP (source) && !STRINGP (source))    if (!INTEGERP (source) && !STRINGP (source))
# Line 4148  On successful conversion, return the res Line 4151  On successful conversion, return the res
4151    if (src_encoding != kCFStringEncodingInvalidId    if (src_encoding != kCFStringEncodingInvalidId
4152        && tgt_encoding != kCFStringEncodingInvalidId)        && tgt_encoding != kCFStringEncodingInvalidId)
4153      str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string),      str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string),
4154                                     src_encoding, true);                                     src_encoding, !NILP (source));
4155  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
4156    if (str)    if (str)
4157      {      {
# Line 4160  On successful conversion, return the res Line 4163  On successful conversion, return the res
4163  #endif  #endif
4164    if (str)    if (str)
4165      {      {
4166        data = CFStringCreateExternalRepresentation (NULL, str,        CFIndex str_len, buf_len;
4167                                                     tgt_encoding, '\0');  
4168          str_len = CFStringGetLength (str);
4169          if (CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
4170                                !NILP (target), NULL, 0, &buf_len) == str_len)
4171            {
4172              result = make_uninit_string (buf_len);
4173              CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
4174                                !NILP (target), SDATA (result), buf_len, NULL);
4175            }
4176        CFRelease (str);        CFRelease (str);
4177      }      }
   if (data)  
     {  
       result = cfdata_to_lisp (data);  
       CFRelease (data);  
     }  
4178    
4179    UNBLOCK_INPUT;    UNBLOCK_INPUT;
4180    

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26