comparison src/fileio.c @ 12716:351cf7c67bbe v8.0.1236

patch 8.0.1236: Mac features are confusing commit https://github.com/vim/vim/commit/d057301b1f28736f094affa17b190244ad56e8d9 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 28 21:11:06 2017 +0200 patch 8.0.1236: Mac features are confusing Problem: Mac features are confusing. Solution: Make feature names more consistent, add "osxdarwin". Rename feature flags, cleanup Mac code. (Kazunobu Kuriyama, closes #2178)
author Christian Brabandt <cb@256bit.org>
date Sat, 28 Oct 2017 21:15:35 +0200
parents 6d3d64be7945
children 8984342ab09e
comparison
equal deleted inserted replaced
12715:279ec0abb4ac 12716:351cf7c67bbe
66 # ifdef WIN3264 66 # ifdef WIN3264
67 # define FIO_CODEPAGE 0x20 /* convert MS-Windows codepage */ 67 # define FIO_CODEPAGE 0x20 /* convert MS-Windows codepage */
68 # define FIO_PUT_CP(x) (((x) & 0xffff) << 16) /* put codepage in top word */ 68 # define FIO_PUT_CP(x) (((x) & 0xffff) << 16) /* put codepage in top word */
69 # define FIO_GET_CP(x) (((x)>>16) & 0xffff) /* get codepage from top word */ 69 # define FIO_GET_CP(x) (((x)>>16) & 0xffff) /* get codepage from top word */
70 # endif 70 # endif
71 # ifdef MACOS_X 71 # ifdef MACOS_CONVERT
72 # define FIO_MACROMAN 0x20 /* convert MacRoman */ 72 # define FIO_MACROMAN 0x20 /* convert MacRoman */
73 # endif 73 # endif
74 # define FIO_ENDIAN_L 0x80 /* little endian */ 74 # define FIO_ENDIAN_L 0x80 /* little endian */
75 # define FIO_ENCRYPTED 0x1000 /* encrypt written bytes */ 75 # define FIO_ENCRYPTED 0x1000 /* encrypt written bytes */
76 # define FIO_NOCONVERT 0x2000 /* skip encoding conversion */ 76 # define FIO_NOCONVERT 0x2000 /* skip encoding conversion */
125 static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags); 125 static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags);
126 static int make_bom(char_u *buf, char_u *name); 126 static int make_bom(char_u *buf, char_u *name);
127 # ifdef WIN3264 127 # ifdef WIN3264
128 static int get_win_fio_flags(char_u *ptr); 128 static int get_win_fio_flags(char_u *ptr);
129 # endif 129 # endif
130 # ifdef MACOS_X 130 # ifdef MACOS_CONVERT
131 static int get_mac_fio_flags(char_u *ptr); 131 static int get_mac_fio_flags(char_u *ptr);
132 # endif 132 # endif
133 #endif 133 #endif
134 static int move_lines(buf_T *frombuf, buf_T *tobuf); 134 static int move_lines(buf_T *frombuf, buf_T *tobuf);
135 #ifdef TEMPDIRNAMES 135 #ifdef TEMPDIRNAMES
1086 */ 1086 */
1087 if (fio_flags == 0) 1087 if (fio_flags == 0)
1088 fio_flags = get_win_fio_flags(fenc); 1088 fio_flags = get_win_fio_flags(fenc);
1089 # endif 1089 # endif
1090 1090
1091 # ifdef MACOS_X 1091 # ifdef MACOS_CONVERT
1092 /* Conversion from Apple MacRoman to latin1 or UTF-8 */ 1092 /* Conversion from Apple MacRoman to latin1 or UTF-8 */
1093 if (fio_flags == 0) 1093 if (fio_flags == 0)
1094 fio_flags = get_mac_fio_flags(fenc); 1094 fio_flags = get_mac_fio_flags(fenc);
1095 # endif 1095 # endif
1096 1096
1272 size = size / ICONV_MULT; /* worst case */ 1272 size = size / ICONV_MULT; /* worst case */
1273 # ifdef WIN3264 1273 # ifdef WIN3264
1274 else if (fio_flags & FIO_CODEPAGE) 1274 else if (fio_flags & FIO_CODEPAGE)
1275 size = size / ICONV_MULT; /* also worst case */ 1275 size = size / ICONV_MULT; /* also worst case */
1276 # endif 1276 # endif
1277 # ifdef MACOS_X 1277 # ifdef MACOS_CONVERT
1278 else if (fio_flags & FIO_MACROMAN) 1278 else if (fio_flags & FIO_MACROMAN)
1279 size = size / ICONV_MULT; /* also worst case */ 1279 size = size / ICONV_MULT; /* also worst case */
1280 # endif 1280 # endif
1281 #endif 1281 #endif
1282 1282
4198 errmsg = (char_u *)_(e_interr); 4198 errmsg = (char_u *)_(e_interr);
4199 goto restore_backup; 4199 goto restore_backup;
4200 } 4200 }
4201 } 4201 }
4202 4202
4203 #ifdef MACOS_CLASSIC /* TODO: Is it need for MACOS_X? (Dany) */
4204 /*
4205 * Before risking to lose the original file verify if there's
4206 * a resource fork to preserve, and if cannot be done warn
4207 * the users. This happens when overwriting without backups.
4208 */
4209 if (backup == NULL && overwriting && !append)
4210 if (mch_has_resource_fork(fname))
4211 {
4212 errmsg = (char_u *)_("E460: The resource fork would be lost (add ! to override)");
4213 goto restore_backup;
4214 }
4215 #endif
4216
4217 #ifdef VMS 4203 #ifdef VMS
4218 vms_remove_version(fname); /* remove version */ 4204 vms_remove_version(fname); /* remove version */
4219 #endif 4205 #endif
4220 /* Default: write the file directly. May write to a temp file for 4206 /* Default: write the file directly. May write to a temp file for
4221 * multi-byte conversion. */ 4207 * multi-byte conversion. */
4269 if (write_info.bw_conv_buf == NULL) 4255 if (write_info.bw_conv_buf == NULL)
4270 end = 0; 4256 end = 0;
4271 } 4257 }
4272 # endif 4258 # endif
4273 4259
4274 # ifdef MACOS_X 4260 # ifdef MACOS_CONVERT
4275 if (converted && wb_flags == 0 && (wb_flags = get_mac_fio_flags(fenc)) != 0) 4261 if (converted && wb_flags == 0 && (wb_flags = get_mac_fio_flags(fenc)) != 0)
4276 { 4262 {
4277 write_info.bw_conv_buflen = bufsize * 3; 4263 write_info.bw_conv_buflen = bufsize * 3;
4278 write_info.bw_conv_buf 4264 write_info.bw_conv_buf
4279 = lalloc((long_u)write_info.bw_conv_buflen, TRUE); 4265 = lalloc((long_u)write_info.bw_conv_buflen, TRUE);
4472 #endif 4458 #endif
4473 goto fail; 4459 goto fail;
4474 } 4460 }
4475 write_info.bw_fd = fd; 4461 write_info.bw_fd = fd;
4476 4462
4477 #if defined(MACOS_CLASSIC) || defined(WIN3264) 4463 #if defined(WIN3264)
4478 /* TODO: Is it need for MACOS_X? (Dany) */
4479 /*
4480 * On macintosh copy the original files attributes (i.e. the backup)
4481 * This is done in order to preserve the resource fork and the
4482 * Finder attribute (label, comments, custom icons, file creator)
4483 */
4484 if (backup != NULL && overwriting && !append) 4464 if (backup != NULL && overwriting && !append)
4485 { 4465 {
4486 if (backup_copy) 4466 if (backup_copy)
4487 (void)mch_copy_file_attribute(wfname, backup); 4467 (void)mch_copy_file_attribute(wfname, backup);
4488 else 4468 else
5197 } 5177 }
5198 #endif 5178 #endif
5199 5179
5200 got_int |= prev_got_int; 5180 got_int |= prev_got_int;
5201 5181
5202 #ifdef MACOS_CLASSIC /* TODO: Is it need for MACOS_X? (Dany) */
5203 /* Update machine specific information. */
5204 mch_post_buffer_write(buf);
5205 #endif
5206 return retval; 5182 return retval;
5207 } 5183 }
5208 5184
5209 /* 5185 /*
5210 * Set the name of the current buffer. Use when the buffer doesn't have a 5186 * Set the name of the current buffer. Use when the buffer doesn't have a
5970 } 5946 }
5971 return FIO_PUT_CP(cp) | FIO_CODEPAGE; 5947 return FIO_PUT_CP(cp) | FIO_CODEPAGE;
5972 } 5948 }
5973 #endif 5949 #endif
5974 5950
5975 #ifdef MACOS_X 5951 #ifdef MACOS_CONVERT
5976 /* 5952 /*
5977 * Check "ptr" for a Carbon supported encoding and return the FIO_ flags 5953 * Check "ptr" for a Carbon supported encoding and return the FIO_ flags
5978 * needed for the internal conversion to/from utf-8 or latin1. 5954 * needed for the internal conversion to/from utf-8 or latin1.
5979 */ 5955 */
5980 static int 5956 static int