Mercurial > vim
comparison src/os_unix.c @ 15470:55ccc2d353bd v8.1.0743
patch 8.1.0743: giving error messages is not flexible
commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 13 23:38:42 2019 +0100
patch 8.1.0743: giving error messages is not flexible
Problem: Giving error messages is not flexible.
Solution: Add semsg(). Change argument from "char_u *" to "char *", also
for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes
#3302) Also make emsg() accept a "char *" argument. Get rid of
an enormous number of type casts.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Jan 2019 23:45:08 +0100 |
parents | 7fff2d18e191 |
children | 3ef31ce9d9f9 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
325 mch_chdir(char *path) | 325 mch_chdir(char *path) |
326 { | 326 { |
327 if (p_verbose >= 5) | 327 if (p_verbose >= 5) |
328 { | 328 { |
329 verbose_enter(); | 329 verbose_enter(); |
330 smsg((char_u *)"chdir(%s)", path); | 330 smsg("chdir(%s)", path); |
331 verbose_leave(); | 331 verbose_leave(); |
332 } | 332 } |
333 # ifdef VMS | 333 # ifdef VMS |
334 return chdir(vms_fixfilename(path)); | 334 return chdir(vms_fixfilename(path)); |
335 # else | 335 # else |
1002 * Usage: | 1002 * Usage: |
1003 * mch_startjmp(); | 1003 * mch_startjmp(); |
1004 * if (SETJMP(lc_jump_env) != 0) | 1004 * if (SETJMP(lc_jump_env) != 0) |
1005 * { | 1005 * { |
1006 * mch_didjmp(); | 1006 * mch_didjmp(); |
1007 * EMSG("crash!"); | 1007 * emsg("crash!"); |
1008 * } | 1008 * } |
1009 * else | 1009 * else |
1010 * { | 1010 * { |
1011 * do_the_work; | 1011 * do_the_work; |
1012 * mch_endjmp(); | 1012 * mch_endjmp(); |
1630 * Give a message about the elapsed time for opening the X window. | 1630 * Give a message about the elapsed time for opening the X window. |
1631 */ | 1631 */ |
1632 static void | 1632 static void |
1633 xopen_message(long elapsed_msec) | 1633 xopen_message(long elapsed_msec) |
1634 { | 1634 { |
1635 smsg((char_u *)_("Opening the X display took %ld msec"), elapsed_msec); | 1635 smsg(_("Opening the X display took %ld msec"), elapsed_msec); |
1636 } | 1636 } |
1637 # endif | 1637 # endif |
1638 #endif | 1638 #endif |
1639 | 1639 |
1640 #if defined(FEAT_X11) && (defined(FEAT_TITLE) || defined(FEAT_XCLIPBOARD)) | 1640 #if defined(FEAT_X11) && (defined(FEAT_TITLE) || defined(FEAT_XCLIPBOARD)) |
2668 } | 2668 } |
2669 else | 2669 else |
2670 #endif | 2670 #endif |
2671 l = mch_chdir((char *)olddir); | 2671 l = mch_chdir((char *)olddir); |
2672 if (l != 0) | 2672 if (l != 0) |
2673 EMSG(_(e_prev_dir)); | 2673 emsg(_(e_prev_dir)); |
2674 } | 2674 } |
2675 | 2675 |
2676 l = STRLEN(buf); | 2676 l = STRLEN(buf); |
2677 if (l >= len - 1) | 2677 if (l >= len - 1) |
2678 retval = FAIL; /* no space for trailing "/" */ | 2678 retval = FAIL; /* no space for trailing "/" */ |
3972 * set screen mode, always fails. | 3972 * set screen mode, always fails. |
3973 */ | 3973 */ |
3974 int | 3974 int |
3975 mch_screenmode(char_u *arg UNUSED) | 3975 mch_screenmode(char_u *arg UNUSED) |
3976 { | 3976 { |
3977 EMSG(_(e_screenmode)); | 3977 emsg(_(e_screenmode)); |
3978 return FAIL; | 3978 return FAIL; |
3979 } | 3979 } |
3980 | 3980 |
3981 #ifndef VMS | 3981 #ifndef VMS |
3982 | 3982 |
5452 char_u *fname = options->jo_io_name[PART_IN]; | 5452 char_u *fname = options->jo_io_name[PART_IN]; |
5453 | 5453 |
5454 fd_in[0] = mch_open((char *)fname, O_RDONLY, 0); | 5454 fd_in[0] = mch_open((char *)fname, O_RDONLY, 0); |
5455 if (fd_in[0] < 0) | 5455 if (fd_in[0] < 0) |
5456 { | 5456 { |
5457 EMSG2(_(e_notopen), fname); | 5457 semsg(_(e_notopen), fname); |
5458 goto failed; | 5458 goto failed; |
5459 } | 5459 } |
5460 } | 5460 } |
5461 else | 5461 else |
5462 /* When writing buffer lines to the input don't use the pty, so that | 5462 /* When writing buffer lines to the input don't use the pty, so that |
5470 char_u *fname = options->jo_io_name[PART_OUT]; | 5470 char_u *fname = options->jo_io_name[PART_OUT]; |
5471 | 5471 |
5472 fd_out[1] = mch_open((char *)fname, O_WRONLY | O_CREAT | O_TRUNC, 0644); | 5472 fd_out[1] = mch_open((char *)fname, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
5473 if (fd_out[1] < 0) | 5473 if (fd_out[1] < 0) |
5474 { | 5474 { |
5475 EMSG2(_(e_notopen), fname); | 5475 semsg(_(e_notopen), fname); |
5476 goto failed; | 5476 goto failed; |
5477 } | 5477 } |
5478 } | 5478 } |
5479 else if (!use_null_for_out && pty_master_fd < 0 && pipe(fd_out) < 0) | 5479 else if (!use_null_for_out && pty_master_fd < 0 && pipe(fd_out) < 0) |
5480 goto failed; | 5480 goto failed; |
5484 char_u *fname = options->jo_io_name[PART_ERR]; | 5484 char_u *fname = options->jo_io_name[PART_ERR]; |
5485 | 5485 |
5486 fd_err[1] = mch_open((char *)fname, O_WRONLY | O_CREAT | O_TRUNC, 0600); | 5486 fd_err[1] = mch_open((char *)fname, O_WRONLY | O_CREAT | O_TRUNC, 0600); |
5487 if (fd_err[1] < 0) | 5487 if (fd_err[1] < 0) |
5488 { | 5488 { |
5489 EMSG2(_(e_notopen), fname); | 5489 semsg(_(e_notopen), fname); |
5490 goto failed; | 5490 goto failed; |
5491 } | 5491 } |
5492 } | 5492 } |
5493 else if (!use_out_for_err && !use_null_for_err | 5493 else if (!use_out_for_err && !use_null_for_err |
5494 && pty_master_fd < 0 && pipe(fd_err) < 0) | 5494 && pty_master_fd < 0 && pipe(fd_err) < 0) |
6507 /* | 6507 /* |
6508 * get a name for the temp file | 6508 * get a name for the temp file |
6509 */ | 6509 */ |
6510 if ((tempname = vim_tempname('o', FALSE)) == NULL) | 6510 if ((tempname = vim_tempname('o', FALSE)) == NULL) |
6511 { | 6511 { |
6512 EMSG(_(e_notmp)); | 6512 emsg(_(e_notmp)); |
6513 return FAIL; | 6513 return FAIL; |
6514 } | 6514 } |
6515 | 6515 |
6516 /* | 6516 /* |
6517 * Let the shell expand the patterns and write the result into the temp | 6517 * Let the shell expand the patterns and write the result into the temp |
6761 fclose(fd); | 6761 fclose(fd); |
6762 mch_remove(tempname); | 6762 mch_remove(tempname); |
6763 if (i != (int)len) | 6763 if (i != (int)len) |
6764 { | 6764 { |
6765 /* unexpected read error */ | 6765 /* unexpected read error */ |
6766 EMSG2(_(e_notread), tempname); | 6766 semsg(_(e_notread), tempname); |
6767 vim_free(tempname); | 6767 vim_free(tempname); |
6768 vim_free(buffer); | 6768 vim_free(buffer); |
6769 return FAIL; | 6769 return FAIL; |
6770 } | 6770 } |
6771 vim_free(tempname); | 6771 vim_free(tempname); |
7345 if (hinstLib == NULL) | 7345 if (hinstLib == NULL) |
7346 { | 7346 { |
7347 /* "dlerr" must be used before dlclose() */ | 7347 /* "dlerr" must be used before dlclose() */ |
7348 dlerr = (char *)dlerror(); | 7348 dlerr = (char *)dlerror(); |
7349 if (dlerr != NULL) | 7349 if (dlerr != NULL) |
7350 EMSG2(_("dlerror = \"%s\""), dlerr); | 7350 semsg(_("dlerror = \"%s\""), dlerr); |
7351 } | 7351 } |
7352 # else | 7352 # else |
7353 hinstLib = shl_load((const char*)libname, BIND_IMMEDIATE|BIND_VERBOSE, 0L); | 7353 hinstLib = shl_load((const char*)libname, BIND_IMMEDIATE|BIND_VERBOSE, 0L); |
7354 # endif | 7354 # endif |
7355 | 7355 |
7440 | 7440 |
7441 /* try to find the name of this signal */ | 7441 /* try to find the name of this signal */ |
7442 for (i = 0; signal_info[i].sig != -1; i++) | 7442 for (i = 0; signal_info[i].sig != -1; i++) |
7443 if (lc_signal == signal_info[i].sig) | 7443 if (lc_signal == signal_info[i].sig) |
7444 break; | 7444 break; |
7445 EMSG2("E368: got SIG%s in libcall()", signal_info[i].name); | 7445 semsg("E368: got SIG%s in libcall()", signal_info[i].name); |
7446 } | 7446 } |
7447 # endif | 7447 # endif |
7448 # endif | 7448 # endif |
7449 | 7449 |
7450 # if defined(USE_DLOPEN) | 7450 # if defined(USE_DLOPEN) |
7451 /* "dlerr" must be used before dlclose() */ | 7451 /* "dlerr" must be used before dlclose() */ |
7452 if (dlerr != NULL) | 7452 if (dlerr != NULL) |
7453 EMSG2(_("dlerror = \"%s\""), dlerr); | 7453 semsg(_("dlerror = \"%s\""), dlerr); |
7454 | 7454 |
7455 /* Free the DLL module. */ | 7455 /* Free the DLL module. */ |
7456 (void)dlclose(hinstLib); | 7456 (void)dlclose(hinstLib); |
7457 # else | 7457 # else |
7458 (void)shl_unload(hinstLib); | 7458 (void)shl_unload(hinstLib); |
7459 # endif | 7459 # endif |
7460 } | 7460 } |
7461 | 7461 |
7462 if (!success) | 7462 if (!success) |
7463 { | 7463 { |
7464 EMSG2(_(e_libcall), funcname); | 7464 semsg(_(e_libcall), funcname); |
7465 return FAIL; | 7465 return FAIL; |
7466 } | 7466 } |
7467 | 7467 |
7468 return OK; | 7468 return OK; |
7469 } | 7469 } |