本文整理匯總了C++中EMSG2函數的典型用法代碼示例。如果您正苦於以下問題:C++ EMSG2函數的具體用法?C++ EMSG2怎麽用?C++ EMSG2使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EMSG2函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: os_get_hostname
/// Gets the hostname of the current machine.
///
/// @param hostname Buffer to store the hostname.
/// @param size Size of `hostname`.
void os_get_hostname(char *hostname, size_t size)
{
#ifdef HAVE_SYS_UTSNAME_H
struct utsname vutsname;
if (uname(&vutsname) < 0) {
*hostname = '\0';
} else {
xstrlcpy(hostname, vutsname.nodename, size);
}
#elif defined(WIN32)
wchar_t host_utf16[MAX_COMPUTERNAME_LENGTH + 1];
DWORD host_wsize = sizeof(host_utf16) / sizeof(host_utf16[0]);
if (GetComputerNameW(host_utf16, &host_wsize) == 0) {
*hostname = '\0';
DWORD err = GetLastError();
EMSG2("GetComputerNameW failed: %d", err);
return;
}
host_utf16[host_wsize] = '\0';
char *host_utf8;
int conversion_result = utf16_to_utf8(host_utf16, &host_utf8);
if (conversion_result != 0) {
EMSG2("utf16_to_utf8 failed: %d", conversion_result);
return;
}
xstrlcpy(hostname, host_utf8, size);
xfree(host_utf8);
#else
EMSG("os_get_hostname failed: missing uname()");
*hostname = '\0';
#endif
}
示例2: ruby_runtime_link_init
/*
* Load library and get all pointers.
* Parameter 'libname' provides name of DLL.
* Return OK or FAIL.
*/
static int
ruby_runtime_link_init(char *libname, int verbose)
{
int i;
if (hinstRuby)
return OK;
hinstRuby = load_dll(libname);
if (!hinstRuby)
{
if (verbose)
EMSG2(_(e_loadlib), libname);
return FAIL;
}
for (i = 0; ruby_funcname_table[i].ptr; ++i)
{
if (!(*ruby_funcname_table[i].ptr = symbol_from_dll(hinstRuby,
ruby_funcname_table[i].name)))
{
close_dll(hinstRuby);
hinstRuby = NULL;
if (verbose)
EMSG2(_(e_loadfunc), ruby_funcname_table[i].name);
return FAIL;
}
}
return OK;
}
示例3: lua_link_init
static int
lua_link_init(char *libname, int verbose)
{
const luaV_Reg *reg;
if (hinstLua) return OK;
hinstLua = load_dll(libname);
if (!hinstLua)
{
if (verbose)
EMSG2(_(e_loadlib), libname);
return FAIL;
}
for (reg = luaV_dll; reg->func; reg++)
{
if ((*reg->func = symbol_from_dll(hinstLua, reg->name)) == NULL)
{
close_dll(hinstLua);
hinstLua = 0;
if (verbose)
EMSG2(_(e_loadfunc), reg->name);
return FAIL;
}
}
return OK;
}
示例4: get_list_tv
/*
* Allocate a variable for a List and fill it from "*arg".
* Return OK or FAIL.
*/
int
get_list_tv(char_u **arg, typval_T *rettv, int evaluate)
{
list_T *l = NULL;
typval_T tv;
listitem_T *item;
if (evaluate)
{
l = list_alloc();
if (l == NULL)
return FAIL;
}
*arg = skipwhite(*arg + 1);
while (**arg != ']' && **arg != NUL)
{
if (eval1(arg, &tv, evaluate) == FAIL) /* recursive! */
goto failret;
if (evaluate)
{
item = listitem_alloc();
if (item != NULL)
{
item->li_tv = tv;
item->li_tv.v_lock = 0;
list_append(l, item);
}
else
clear_tv(&tv);
}
if (**arg == ']')
break;
if (**arg != ',')
{
EMSG2(_("E696: Missing comma in List: %s"), *arg);
goto failret;
}
*arg = skipwhite(*arg + 1);
}
if (**arg != ']')
{
EMSG2(_("E697: Missing end of List ']': %s"), *arg);
failret:
if (evaluate)
list_free(l);
return FAIL;
}
*arg = skipwhite(*arg + 1);
if (evaluate)
rettv_list_set(rettv, l);
return OK;
}
示例5: gui_mch_get_font
/*
* Get a font structure for highlighting.
*/
GuiFont
gui_mch_get_font(char_u *name, int giveErrorIfMissing)
{
if(vimjs_check_font((char*)name))
return (char*)vim_strsave(name);
if (giveErrorIfMissing)
EMSG2(_(e_font), name);
return NOFONT;
}
示例6: hash_add
/// Add item with key "key" to hashtable "ht".
///
/// @param ht
/// @param key
///
/// @returns FAIL when out of memory or the key is already present.
int hash_add(hashtab_T *ht, char_u *key)
{
hash_T hash = hash_hash(key);
hashitem_T *hi = hash_lookup(ht, key, hash);
if (!HASHITEM_EMPTY(hi)) {
EMSG2(_(e_intern2), "hash_add()");
return FAIL;
}
return hash_add_item(ht, hi, key, hash);
}
示例7: lookup_prop_type
/*
* Lookup a property type by name. First in "buf" and when not found in the
* global types.
* When not found gives an error message and returns NULL.
*/
static proptype_T *
lookup_prop_type(char_u *name, buf_T *buf)
{
proptype_T *type = find_prop(name, buf);
if (type == NULL)
type = find_prop(name, NULL);
if (type == NULL)
EMSG2(_(e_type_not_exist), name);
return type;
}
示例8: python_runtime_link_init
/*
* Load library and get all pointers.
* Parameter 'libname' provides name of DLL.
* Return OK or FAIL.
*/
static int
python_runtime_link_init(char *libname, int verbose)
{
int i;
#if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3)
/* Can't have Python and Python3 loaded at the same time.
* It cause a crash, because RTLD_GLOBAL is needed for
* standard C extension libraries of one or both python versions. */
if (python3_loaded())
{
if (verbose)
EMSG(_("E836: This Vim cannot execute :python after using :py3"));
return FAIL;
}
#endif
if (hinstPython)
return OK;
hinstPython = load_dll(libname);
if (!hinstPython)
{
if (verbose)
EMSG2(_(e_loadlib), libname);
return FAIL;
}
for (i = 0; python_funcname_table[i].ptr; ++i)
{
if ((*python_funcname_table[i].ptr = symbol_from_dll(hinstPython,
python_funcname_table[i].name)) == NULL)
{
close_dll(hinstPython);
hinstPython = 0;
if (verbose)
EMSG2(_(e_loadfunc), python_funcname_table[i].name);
return FAIL;
}
}
return OK;
}
示例9: dictitem_remove
/*
* Remove item "item" from Dictionary "dict" and free it.
*/
void
dictitem_remove(dict_T *dict, dictitem_T *item)
{
hashitem_T *hi;
hi = hash_find(&dict->dv_hashtab, item->di_key);
if (HASHITEM_EMPTY(hi))
EMSG2(_(e_intern2), "dictitem_remove()");
else
hash_remove(&dict->dv_hashtab, hi);
dictitem_free(item);
}
示例10: show_one_mark
static void
show_one_mark(
int c,
char_u *arg,
pos_T *p,
char_u *name,
int current /* in current file */
)
{
static int did_title = FALSE;
int mustfree = FALSE;
if (c == -1) { /* finish up */
if (did_title)
did_title = FALSE;
else {
if (arg == NULL)
MSG(_("No marks set"));
else
EMSG2(_("E283: No marks matching \"%s\""), arg);
}
}
/* don't output anything if 'q' typed at --more-- prompt */
else if (!got_int
&& (arg == NULL || vim_strchr(arg, c) != NULL)
&& p->lnum != 0) {
if (!did_title) {
/* Highlight title */
MSG_PUTS_TITLE(_("\nmark line col file/text"));
did_title = TRUE;
}
msg_putchar('\n');
if (!got_int) {
sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col);
msg_outtrans(IObuff);
if (name == NULL && current) {
name = mark_line(p, 15);
mustfree = TRUE;
}
if (name != NULL) {
msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
if (mustfree) {
xfree(name);
}
}
}
ui_flush(); /* show one line at a time */
}
}
示例11: dict_extend
/*
* Go over all entries in "d2" and add them to "d1".
* When "action" is "error" then a duplicate key is an error.
* When "action" is "force" then a duplicate key is overwritten.
* Otherwise duplicate keys are ignored ("action" is "keep").
*/
void
dict_extend(dict_T *d1, dict_T *d2, char_u *action)
{
dictitem_T *di1;
hashitem_T *hi2;
int todo;
char_u *arg_errmsg = (char_u *)N_("extend() argument");
todo = (int)d2->dv_hashtab.ht_used;
for (hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
{
if (!HASHITEM_EMPTY(hi2))
{
--todo;
di1 = dict_find(d1, hi2->hi_key, -1);
if (d1->dv_scope != 0)
{
/* Disallow replacing a builtin function in l: and g:.
* Check the key to be valid when adding to any scope. */
if (d1->dv_scope == VAR_DEF_SCOPE
&& HI2DI(hi2)->di_tv.v_type == VAR_FUNC
&& var_check_func_name(hi2->hi_key, di1 == NULL))
break;
if (!valid_varname(hi2->hi_key))
break;
}
if (di1 == NULL)
{
di1 = dictitem_copy(HI2DI(hi2));
if (di1 != NULL && dict_add(d1, di1) == FAIL)
dictitem_free(di1);
}
else if (*action == 'e')
{
EMSG2(_("E737: Key already exists: %s"), hi2->hi_key);
break;
}
else if (*action == 'f' && HI2DI(hi2) != di1)
{
if (tv_check_lock(di1->di_tv.v_lock, arg_errmsg, TRUE)
|| var_check_ro(di1->di_flags, arg_errmsg, TRUE))
break;
clear_tv(&di1->di_tv);
copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
}
}
}
}
示例12: show_menus
/*
* Show the mapping associated with a menu item or hierarchy in a sub-menu.
*/
static int show_menus(char_u *path_name, int modes)
{
char_u *p;
char_u *name;
vimmenu_T *menu;
vimmenu_T *parent = NULL;
menu = root_menu;
name = path_name = vim_strsave(path_name);
/* First, find the (sub)menu with the given name */
while (*name) {
p = menu_name_skip(name);
while (menu != NULL) {
if (menu_name_equal(name, menu)) {
/* Found menu */
if (*p != NUL && menu->children == NULL) {
EMSG(_(e_notsubmenu));
free(path_name);
return FAIL;
} else if ((menu->modes & modes) == 0x0) {
EMSG(_(e_othermode));
free(path_name);
return FAIL;
}
break;
}
menu = menu->next;
}
if (menu == NULL) {
EMSG2(_(e_nomenu), name);
free(path_name);
return FAIL;
}
name = p;
parent = menu;
menu = menu->children;
}
free(path_name);
/* Now we have found the matching menu, and we list the mappings */
/* Highlight title */
MSG_PUTS_TITLE(_("\n--- Menus ---"));
show_menus_recursive(parent, modes, 0);
return OK;
}
示例13: menu_nable_recurse
/*
* Set the (sub)menu with the given name to enabled or disabled.
* Called recursively.
*/
static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enable)
{
char_u *p;
if (menu == NULL)
return OK; /* Got to bottom of hierarchy */
/* Get name of this element in the menu hierarchy */
p = menu_name_skip(name);
/* Find the menu */
while (menu != NULL) {
if (*name == NUL || *name == '*' || menu_name_equal(name, menu)) {
if (*p != NUL) {
if (menu->children == NULL) {
EMSG(_(e_notsubmenu));
return FAIL;
}
if (menu_nable_recurse(menu->children, p, modes, enable)
== FAIL)
return FAIL;
} else if (enable)
menu->enabled |= modes;
else
menu->enabled &= ~modes;
/*
* When name is empty, we are doing all menu items for the given
* modes, so keep looping, otherwise we are just doing the named
* menu item (which has been found) so break here.
*/
if (*name != NUL && *name != '*')
break;
}
menu = menu->next;
}
if (*name != NUL && *name != '*' && menu == NULL) {
EMSG2(_(e_nomenu), name);
return FAIL;
}
return OK;
}
示例14: vim_findfile_init
//.........這裏部分代碼省略.........
/* save the fix part of the path */
search_ctx->ffsc_fix_path = vim_strnsave(path, (int)(wc_part - path));
/*
* copy wc_path and add restricts to the '**' wildcard.
* The octet after a '**' is used as a (binary) counter.
* So '**3' is transposed to '**^C' ('^C' is ASCII value 3)
* or '**76' is transposed to '**N'( 'N' is ASCII value 76).
* For EBCDIC you get different character values.
* If no restrict is given after '**' the default is used.
* Due to this technique the path looks awful if you print it as a
* string.
*/
len = 0;
while (*wc_part != NUL) {
if (len + 5 >= MAXPATHL) {
EMSG(_(e_pathtoolong));
break;
}
if (STRNCMP(wc_part, "**", 2) == 0) {
ff_expand_buffer[len++] = *wc_part++;
ff_expand_buffer[len++] = *wc_part++;
llevel = strtol((char *)wc_part, &errpt, 10);
if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255)
ff_expand_buffer[len++] = llevel;
else if ((char_u *)errpt != wc_part && llevel == 0)
/* restrict is 0 -> remove already added '**' */
len -= 2;
else
ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND;
wc_part = (char_u *)errpt;
if (*wc_part != NUL && !vim_ispathsep(*wc_part)) {
EMSG2(_(
"E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."),
PATHSEPSTR);
goto error_return;
}
} else
ff_expand_buffer[len++] = *wc_part++;
}
ff_expand_buffer[len] = NUL;
search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer);
} else
search_ctx->ffsc_fix_path = vim_strsave(path);
if (search_ctx->ffsc_start_dir == NULL) {
/* store the fix part as startdir.
* This is needed if the parameter path is fully qualified.
*/
search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path);
search_ctx->ffsc_fix_path[0] = NUL;
}
/* create an absolute path */
if (STRLEN(search_ctx->ffsc_start_dir)
+ STRLEN(search_ctx->ffsc_fix_path) + 3 >= MAXPATHL) {
EMSG(_(e_pathtoolong));
goto error_return;
}
STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir);
add_pathsep(ff_expand_buffer);
{
size_t eb_len = STRLEN(ff_expand_buffer);
char_u *buf = xmalloc(eb_len + STRLEN(search_ctx->ffsc_fix_path) + 1);
示例15: remove_menu
/*
* Remove the (sub)menu with the given name from the menu hierarchy
* Called recursively.
*/
static int
remove_menu (
vimmenu_T **menup,
char_u *name,
int modes,
bool silent /* don't give error messages */
)
{
vimmenu_T *menu;
vimmenu_T *child;
char_u *p;
if (*menup == NULL)
return OK; /* Got to bottom of hierarchy */
/* Get name of this element in the menu hierarchy */
p = menu_name_skip(name);
/* Find the menu */
while ((menu = *menup) != NULL) {
if (*name == NUL || menu_name_equal(name, menu)) {
if (*p != NUL && menu->children == NULL) {
if (!silent)
EMSG(_(e_notsubmenu));
return FAIL;
}
if ((menu->modes & modes) != 0x0) {
if (remove_menu(&menu->children, p, modes, silent) == FAIL)
return FAIL;
} else if (*name != NUL) {
if (!silent)
EMSG(_(e_othermode));
return FAIL;
}
/*
* When name is empty, we are removing all menu items for the given
* modes, so keep looping, otherwise we are just removing the named
* menu item (which has been found) so break here.
*/
if (*name != NUL)
break;
/* Remove the menu item for the given mode[s]. If the menu item
* is no longer valid in ANY mode, delete it */
menu->modes &= ~modes;
if (modes & MENU_TIP_MODE)
free_menu_string(menu, MENU_INDEX_TIP);
if ((menu->modes & MENU_ALL_MODES) == 0)
free_menu(menup);
else
menup = &menu->next;
} else
menup = &menu->next;
}
if (*name != NUL) {
if (menu == NULL) {
if (!silent)
EMSG2(_(e_nomenu), name);
return FAIL;
}
/* Recalculate modes for menu based on the new updated children */
menu->modes &= ~modes;
child = menu->children;
for (; child != NULL; child = child->next)
menu->modes |= child->modes;
if (modes & MENU_TIP_MODE) {
free_menu_string(menu, MENU_INDEX_TIP);
}
if ((menu->modes & MENU_ALL_MODES) == 0) {
/* The menu item is no longer valid in ANY mode, so delete it */
*menup = menu;
free_menu(menup);
}
}
return OK;
}