static char * game_file_to_help_section (const char *game_file) { char *p, *buf; buf = g_path_get_basename (game_file); if ((p = strrchr (buf, '.'))) *p = '\0'; for (p = buf; p = strchr (p, '-'), p && *p;) *p = '_'; for (p = buf; p = strchr (p, '_'), p && *p;) { char *next = p + 1; char q = *next; if (q != '\0' && g_ascii_islower (q)) { *next = g_ascii_toupper (q); ++p; } } if (g_ascii_islower (buf[0])) { buf[0] = g_ascii_toupper (buf[0]); } return buf; }
int textual_dict_gen_t::generate_article(const article_data_t& article) { contents_puts("<article>\n"); glib::CharStr temp; temp.reset(g_markup_printf_escaped("<key>%s</key>\n", article.key.c_str())); contents_puts(temp); for(size_t i=0; i<article.synonyms.size(); ++i) { temp.reset(g_markup_printf_escaped("<synonym>%s</synonym>\n", article.synonyms[i].c_str())); contents_puts(temp); } std::vector<char> buf; for(size_t i=0; i<article.definitions.size(); ++i) { const article_def_t& def = article.definitions[i]; const char type_id = def.type; if(g_ascii_islower(type_id)) { if(type_id == 'r') { generate_field_r(def.resources); } else { buf.resize(def.size + 1); if(parsed_norm_dict->read_data(&buf[0], def.size, def.offset)) return EXIT_FAILURE; buf[def.size] = '\0'; generate_field_CDATA(type_id, &buf[0]); } } else { g_message("Index item %s, type = '%c'. Binary data types are not supported presently. Skipping.", article.key.c_str(), type_id); } } contents_puts("</article>\n\n"); return EXIT_SUCCESS; }
void convert_stardict2txt(const char *ifofilename, print_info_t print_info) { gchar *buffer; g_file_get_contents(ifofilename, &buffer, NULL, NULL); if (!g_str_has_prefix(buffer, "StarDict's dict ifo file\nversion=")) { print_info("Error, file version is not 2.4.2\n"); g_free(buffer); return; } gchar *p1,*p2; p1 = buffer; p2 = strstr(p1,"\nsametypesequence="); if (!p2) { print_info("Error, no sametypesequence=\n"); g_free(buffer); return; } p2 += sizeof("\nsametypesequence=") -1; if (g_ascii_islower(*p2) && *(p2+1)=='\n') { convert2tabfile(ifofilename, print_info); } else { print_info("Error, sametypesequence is not m\n"); g_free(buffer); return; } g_free(buffer); }
static gchar* id_to_macro (const gchar *id) { GString *macro = NULL; const gchar *cp; /* gtk-foo-bar -> GTK_STOCK_FOO_BAR */ macro = g_string_new (NULL); cp = id; if (strncmp (cp, "gtk-", 4) == 0) { g_string_append (macro, "GTK_STOCK_"); cp += 4; } while (*cp) { if (*cp == '-') g_string_append_c (macro, '_'); else if (g_ascii_islower (*cp)) g_string_append_c (macro, g_ascii_toupper (*cp)); else g_string_append_c (macro, *cp); cp++; } return g_string_free (macro, FALSE); }
static char * panel_layout_object_generate_id (const char *iid) { GString *generated_id; const char *applet; char old; applet = g_strrstr (iid, "::"); if (applet == NULL) return NULL; generated_id = g_string_new (""); applet += 2; old = applet[0]; while (applet[0] != '\0') { if (g_ascii_isupper (applet[0]) && old != ':' && g_ascii_islower (applet[1]) && generated_id->len != 0) { g_string_append_printf (generated_id, "-%c", g_ascii_tolower (applet[0])); } else { g_string_append_c (generated_id, applet[0] != ':' ? g_ascii_tolower (applet[0]) : '-'); } old = applet[0]; applet += 1; } return g_string_free (generated_id, FALSE); }
/* Convert all ASCII letters to upper case, in place. */ gchar * ascii_strup_inplace(gchar *str) { gchar *s; for (s = str; *s; s++) /* What 'g_ascii_toupper (gchar c)' does, this should be slightly more efficient */ *s = g_ascii_islower (*s) ? *s - 'a' + 'A' : *s; return (str); }
/** * editable: The GTK_ENTRY that changed * user_data: the progress bar to update * * Will update the password quality displayed in the progress bar. * **/ static void on_password_changed (GtkEditable *editable, gpointer user_data) { const char *password; int length, i; int upper, lower, digit, misc; gdouble pwstrength; password = gtk_entry_get_text (GTK_ENTRY (editable)); /* * This code is based on the Master Password dialog in Firefox * (pref-masterpass.js) * Original code triple-licensed under the MPL, GPL, and LGPL * so is license-compatible with this file */ length = strlen (password); upper = 0; lower = 0; digit = 0; misc = 0; for ( i = 0; i < length ; i++) { if (g_ascii_isdigit (password[i])) digit++; else if (g_ascii_islower (password[i])) lower++; else if (g_ascii_isupper (password[i])) upper++; else misc++; } if (length > 5) length = 5; if (digit > 3) digit = 3; if (upper > 3) upper = 3; if (misc > 3) misc = 3; pwstrength = ((length*0.1)-0.2) + (digit*0.1) + (misc*0.15) + (upper*0.1); if (pwstrength < 0.0) pwstrength = 0.0; if (pwstrength > 1.0) pwstrength = 1.0; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (user_data), pwstrength); }
/* This code is based on the Master Password dialog in Firefox * (pref-masterpass.js) * Original code triple-licensed under the MPL, GPL, and LGPL * so is license-compatible with this file */ static gdouble compute_password_strength (const gchar *password) { gint length; gint upper, lower, digit, misc; gint i; gdouble strength; length = strlen (password); upper = 0; lower = 0; digit = 0; misc = 0; for (i = 0; i < length ; i++) { if (g_ascii_isdigit (password[i])) digit++; else if (g_ascii_islower (password[i])) lower++; else if (g_ascii_isupper (password[i])) upper++; else misc++; } if (length > 5) length = 5; if (digit > 3) digit = 3; if (upper > 3) upper = 3; if (misc > 3) misc = 3; strength = ((length * 0.1) - 0.2) + (digit * 0.1) + (misc * 0.15) + (upper * 0.1); strength = CLAMP (strength, 0.0, 1.0); return strength; }
static CK_RV test_validator (GkmObject *obj, CK_ATTRIBUTE_PTR attr) { const gchar *data; guint i; g_assert (obj == object); g_assert (attr); g_assert (attr->type == CKA_LABEL); /* Test that the whole string is ascii and lower case */ data = attr->pValue; for (i = 0; i < attr->ulValueLen; ++i) { if (!g_ascii_isprint(data[i]) || !g_ascii_islower (data[i])) return CKR_ATTRIBUTE_VALUE_INVALID; } return CKR_OK; }
void xim_init(void) { GSList *it; gchar *aname, *aclass; aname = g_strdup(g_get_prgname()); if(!aname) aname = g_strdup("obt"); aclass = g_strdup(aname); if(g_ascii_islower(aclass[0])) aclass[0] = g_ascii_toupper(aclass[0]); xim = XOpenIM(t_display, NULL, aname, aclass); if(!xim) g_message("Failed to open an Input Method"); else { XIMStyles *xim_styles = NULL; char *r; r = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); if(r || !xim_styles) g_message("Input Method does not support any styles"); if(xim_styles) { int i; for(i = 0; i < xim_styles->count_styles; ++i) { if(xim_styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) { xim_style = xim_styles->supported_styles[i]; break; } } XFree(xim_styles); } if(!xim_style) { g_message("Input Method does not support a usable style"); XCloseIM(xim); xim = NULL; } } for(it = xic_all; it; it = g_slist_next(it)) t_keyboard_context_renew(it->data); g_free(aclass); g_free(aname); }
static inline gboolean validate_name (const gchar * name) { guint i, len; len = strlen (name); if (len == 0) return FALSE; /* First character can only be a lower case ASCII character */ if (!g_ascii_isalpha (name[0]) || !g_ascii_islower (name[0])) return FALSE; /* All following characters can only by: * either a lower case ASCII character * or an hyphen * or a numeric */ for (i = 1; i < len; i++) { /* if uppercase ASCII letter, return */ if (g_ascii_isupper (name[i])) return FALSE; /* if a digit, continue */ if (g_ascii_isdigit (name[i])) continue; /* if an hyphen, continue */ if (name[i] == '-') continue; /* if an ';', continue (list delimiter) */ if (name[i] == ';') { continue; } /* remaining should only be ascii letters */ if (!g_ascii_isalpha (name[i])) return FALSE; } return TRUE; }
void generate_username_choices (const gchar *name, GtkListStore *store) { gboolean in_use, same_as_initial; char *lc_name, *ascii_name, *stripped_name; char *default_username; char **words1; char **words2 = NULL; char **w1, **w2; char *c; char *unicode_fallback = "?"; GString *first_word, *last_word; GString *item0, *item1, *item2, *item3, *item4; int len; int nwords1, nwords2, i; GHashTable *items = NULL; GtkTreeIter iter; gtk_list_store_clear (store); ascii_name = g_convert_with_fallback (name, -1, "ASCII//TRANSLIT", "UTF-8", unicode_fallback, NULL, NULL, NULL); lc_name = g_ascii_strdown (ascii_name, -1); /* Remove all non ASCII alphanumeric chars from the name, * apart from the few allowed symbols. * * We do remove '.', even though it is usually allowed, * since it often comes in via an abbreviated middle name, * and the dot looks just wrong in the proposals then. */ stripped_name = g_strnfill (strlen (lc_name) + 1, '\0'); i = 0; for (c = lc_name; *c; c++) { if (!(g_ascii_isdigit (*c) || g_ascii_islower (*c) || *c == ' ' || *c == '-' || *c == '_' || /* used to track invalid words, removed below */ *c == '?') ) continue; stripped_name[i] = *c; i++; } if (strlen (stripped_name) == 0) { g_free (ascii_name); g_free (lc_name); g_free (stripped_name); goto bailout; } /* we split name on spaces, and then on dashes, so that we can treat * words linked with dashes the same way, i.e. both fully shown, or * both abbreviated */ words1 = g_strsplit_set (stripped_name, " ", -1); len = g_strv_length (words1); item0 = g_string_sized_new (strlen (stripped_name)); g_free (ascii_name); g_free (lc_name); g_free (stripped_name); /* Concatenate the whole first word with the first letter of each * word (item1), and the last word with the first letter of each * word (item2). item3 and item4 are symmetrical respectively to * item1 and item2. * * Constant 5 is the max reasonable number of words we may get when * splitting on dashes, since we can't guess it at this point, * and reallocating would be too bad. */ item1 = g_string_sized_new (strlen (words1[0]) + len - 1 + 5); item3 = g_string_sized_new (strlen (words1[0]) + len - 1 + 5); item2 = g_string_sized_new (strlen (words1[len - 1]) + len - 1 + 5); item4 = g_string_sized_new (strlen (words1[len - 1]) + len - 1 + 5); /* again, guess at the max size of names */ first_word = g_string_sized_new (20); last_word = g_string_sized_new (20); nwords1 = 0; nwords2 = 0; for (w1 = words1; *w1; w1++) { if (strlen (*w1) == 0) continue; /* skip words with string '?', most likely resulting * from failed transliteration to ASCII */ if (strstr (*w1, unicode_fallback) != NULL) continue; nwords1++; /* count real words, excluding empty string */ item0 = g_string_append (item0, *w1); words2 = g_strsplit_set (*w1, "-", -1); /* reset last word if a new non-empty word has been found */ if (strlen (*words2) > 0) last_word = g_string_set_size (last_word, 0); for (w2 = words2; *w2; w2++) { if (strlen (*w2) == 0) continue; nwords2++; /* part of the first "toplevel" real word */ if (nwords1 == 1) { item1 = g_string_append (item1, *w2); first_word = g_string_append (first_word, *w2); } else { item1 = g_string_append_unichar (item1, g_utf8_get_char (*w2)); item3 = g_string_append_unichar (item3, g_utf8_get_char (*w2)); } /* not part of the last "toplevel" word */ if (w1 != words1 + len - 1) { item2 = g_string_append_unichar (item2, g_utf8_get_char (*w2)); item4 = g_string_append_unichar (item4, g_utf8_get_char (*w2)); } /* always save current word so that we have it if last one reveals empty */ last_word = g_string_append (last_word, *w2); } g_strfreev (words2); } g_string_truncate (first_word, MAXNAMELEN); g_string_truncate (last_word, MAXNAMELEN); item2 = g_string_append (item2, last_word->str); item3 = g_string_append (item3, first_word->str); item4 = g_string_prepend (item4, last_word->str); g_string_truncate (item0, MAXNAMELEN); g_string_truncate (item1, MAXNAMELEN); g_string_truncate (item2, MAXNAMELEN); g_string_truncate (item3, MAXNAMELEN); g_string_truncate (item4, MAXNAMELEN); items = g_hash_table_new (g_str_hash, g_str_equal); /* add the first word */ in_use = is_username_used (first_word->str); if (*first_word->str && !in_use && !g_ascii_isdigit (first_word->str[0]) && !g_hash_table_lookup (items, first_word->str)) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, first_word->str, -1); g_hash_table_insert (items, first_word->str, first_word->str); } /* add the last word */ in_use = is_username_used (last_word->str); if (*last_word->str && !in_use && !g_ascii_isdigit (last_word->str[0]) && !g_hash_table_lookup (items, last_word->str)) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, last_word->str, -1); g_hash_table_insert (items, last_word->str, last_word->str); } /* if there's only one word, would be the same as item1 */ if (nwords2 > 1) { /* add other items */ in_use = is_username_used (item0->str); if (*item0->str && !in_use && !g_ascii_isdigit (item0->str[0])) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, item0->str, -1); g_hash_table_insert (items, item0->str, item0->str); } in_use = is_username_used (item1->str); same_as_initial = (g_strcmp0 (item0->str, item1->str) == 0); if (*item1->str && !same_as_initial && nwords2 > 0 && !in_use && !g_ascii_isdigit (item1->str[0])) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, item1->str, -1); g_hash_table_insert (items, item1->str, item1->str); } in_use = is_username_used (item2->str); if (*item2->str && !in_use && !g_ascii_isdigit (item2->str[0]) && !g_hash_table_lookup (items, item2->str)) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, item2->str, -1); g_hash_table_insert (items, item2->str, item2->str); } in_use = is_username_used (item3->str); if (*item3->str && !in_use && !g_ascii_isdigit (item3->str[0]) && !g_hash_table_lookup (items, item3->str)) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, item3->str, -1); g_hash_table_insert (items, item3->str, item3->str); } in_use = is_username_used (item4->str); if (*item4->str && !in_use && !g_ascii_isdigit (item4->str[0]) && !g_hash_table_lookup (items, item4->str)) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, item4->str, -1); g_hash_table_insert (items, item4->str, item4->str); } } g_strfreev (words1); g_string_free (first_word, TRUE); g_string_free (last_word, TRUE); g_string_free (item0, TRUE); g_string_free (item1, TRUE); g_string_free (item2, TRUE); g_string_free (item3, TRUE); g_string_free (item4, TRUE); bailout: if (items == NULL || g_hash_table_size (items) == 0) { gtk_list_store_append (store, &iter); default_username = g_strdup (DEFAULT_USERNAME); i = 0; while (is_username_used (default_username)) { g_free (default_username); default_username = g_strdup_printf (DEFAULT_USERNAME "%d", ++i); } gtk_list_store_set (store, &iter, 0, default_username, -1); g_free (default_username); } if (items != NULL) { g_hash_table_destroy (items); } }
static gboolean is_valid_keyname (const gchar *key, GError **error) { gint i; if (key[0] == '\0') { g_set_error_literal (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "empty names are not permitted"); return FALSE; } if (allow_any_name) return TRUE; if (!g_ascii_islower (key[0])) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "invalid name '%s': names must begin " "with a lowercase letter", key); return FALSE; } for (i = 1; key[i]; i++) { if (key[i] != '-' && !g_ascii_islower (key[i]) && !g_ascii_isdigit (key[i])) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "invalid name '%s': invalid character '%c'; " "only lowercase letters, numbers and dash ('-') " "are permitted.", key, key[i]); return FALSE; } if (key[i] == '-' && key[i + 1] == '-') { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "invalid name '%s': two successive dashes ('--') are " "not permitted.", key); return FALSE; } } if (key[i - 1] == '-') { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "invalid name '%s': the last character may not be a " "dash ('-').", key); return FALSE; } if (i > 32) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "invalid name '%s': maximum length is 32", key); return FALSE; } return TRUE; }
static int append_hex_digits(char *ascii_buf, int ascii_offset, int max_offset, char *data, int *err, gchar **err_info) { int in_offset, out_offset; int c; unsigned int i; gboolean overflow = FALSE; in_offset = 0; out_offset = ascii_offset; for (;;) { /* * Process a block of up to 16 hex digits. * The block is terminated early by an end-of-line indication (NUL, * CR, or LF), by a space (which terminates the last block of the * data we're processing), or by a "*", which introduces the ASCII representation * of the data. * All characters in the block must be upper-case hex digits; * there might or might not be a space *after* a block, but, if so, * that will be skipped over after the block is processed. */ for (i = 0; i < 16; i++, in_offset++) { /* * If we see an end-of-line indication, or an early-end-of-block * indication (space), we're done. (Only the last block ends * early.) */ c = data[in_offset] & 0xFF; if (c == '\0' || c == ' ' || c == '*' || c == '\r' || c == '\n') { goto done; } if (!g_ascii_isxdigit(c) || g_ascii_islower(c)) { /* * Not a hex digit, or a lower-case hex digit. * Treat this as an indication that the line isn't a data * line, so we just ignore it. * * XXX - do so only for continuation lines; treat non-hex-digit * characters as errors for other lines? */ return ascii_offset; /* pretend we appended nothing */ } if (out_offset >= max_offset) overflow = TRUE; else { ascii_buf[out_offset] = c; out_offset++; } } /* * Skip blanks, if any. */ for (; (data[in_offset] & 0xFF) == ' '; in_offset++) ; } done: /* * If we processed an *odd* number of hex digits, report an error. */ if ((i % 2) != 0) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("iseries: odd number of hex digits in a line"); return -1; } if (overflow) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("iseries: more packet data than the packet length indicated"); return -1; } return out_offset; }
char * expand_format (struct WEdit *edit_widget, char c, gboolean do_quote) { WPanel *panel = NULL; char *(*quote_func) (const char *, int); char *fname = NULL; char *result; char c_lc; #ifndef USE_INTERNAL_EDIT (void) edit_widget; #endif if (c == '%') return g_strdup ("%"); switch (mc_global.mc_run_mode) { case MC_RUN_FULL: if (g_ascii_islower ((gchar) c)) panel = current_panel; else { if (get_other_type () != view_listing) return g_strdup (""); panel = other_panel; } fname = g_strdup (panel->dir.list[panel->selected].fname); break; #ifdef USE_INTERNAL_EDIT case MC_RUN_EDITOR: fname = edit_get_file_name (edit_widget); break; #endif default: /* other modes don't use formats */ return g_strdup (""); } if (do_quote) quote_func = name_quote; else quote_func = fake_name_quote; c_lc = g_ascii_tolower ((gchar) c); switch (c_lc) { case 'f': case 'p': result = (*quote_func) (fname, 0); goto ret; case 'x': result = (*quote_func) (extension (fname), 0); goto ret; case 'd': { char *cwd; char *qstr; if (panel) cwd = g_strdup (vfs_path_as_str (panel->cwd_vpath)); else cwd = vfs_get_current_dir (); qstr = (*quote_func) (cwd, 0); g_free (cwd); result = qstr; goto ret; } case 'i': /* indent equal number cursor position in line */ #ifdef USE_INTERNAL_EDIT if (edit_widget) { result = g_strnfill (edit_get_curs_col (edit_widget), ' '); goto ret; } #endif break; case 'y': /* syntax type */ #ifdef USE_INTERNAL_EDIT if (edit_widget) { const char *syntax_type = edit_get_syntax_type (edit_widget); if (syntax_type != NULL) { result = g_strdup (syntax_type); goto ret; } } #endif break; case 'k': /* block file name */ case 'b': /* block file name / strip extension */ { #ifdef USE_INTERNAL_EDIT if (edit_widget) { char *file; file = mc_config_get_full_path (EDIT_BLOCK_FILE); result = (*quote_func) (file, 0); g_free (file); goto ret; } #endif if (c_lc == 'b') { result = strip_ext ((*quote_func) (fname, 0)); goto ret; } break; } case 'n': /* strip extension in editor */ #ifdef USE_INTERNAL_EDIT if (edit_widget) { result = strip_ext ((*quote_func) (fname, 0)); goto ret; } #endif break; case 'm': /* menu file name */ if (menu) { result = (*quote_func) (menu, 0); goto ret; } break; case 's': if (!panel || !panel->marked) { result = (*quote_func) (fname, 0); goto ret; } /* Fall through */ case 't': case 'u': { GString *block; int i; if (panel == NULL) { result = g_strdup (""); goto ret; } block = g_string_sized_new (16); for (i = 0; i < panel->dir.len; i++) if (panel->dir.list[i].f.marked) { char *tmp; tmp = (*quote_func) (panel->dir.list[i].fname, 0); g_string_append (block, tmp); g_string_append_c (block, ' '); g_free (tmp); if (c_lc == 'u') do_file_mark (panel, i, 0); } result = g_string_free (block, FALSE); goto ret; } /* sub case block */ } /* switch */ result = g_strdup ("% "); result[1] = c; ret: g_free (fname); return result; }
char * expand_format (struct WEdit *edit_widget, char c, gboolean do_quote) { WPanel *panel = NULL; char *(*quote_func) (const char *, int); char *fname = NULL; char *result; char c_lc; #ifndef USE_INTERNAL_EDIT (void) edit_widget; #endif if (c == '%') return g_strdup ("%"); if (mc_run_mode == MC_RUN_FULL) { if (g_ascii_islower ((gchar) c)) panel = current_panel; else { if (get_other_type () != view_listing) return g_strdup (""); panel = other_panel; } fname = panel->dir.list[panel->selected].fname; } #ifdef USE_INTERNAL_EDIT else if (mc_run_mode == MC_RUN_EDITOR) fname = (char *) edit_get_file_name (edit_widget); #endif if (do_quote) quote_func = name_quote; else quote_func = fake_name_quote; c_lc = g_ascii_tolower ((gchar) c); switch (c_lc) { case 'f': case 'p': return (*quote_func) (fname, 0); case 'x': return (*quote_func) (extension (fname), 0); case 'd': { char *cwd; char *qstr; cwd = g_malloc (MC_MAXPATHLEN + 1); if (panel) g_strlcpy (cwd, panel->cwd, MC_MAXPATHLEN + 1); else mc_get_current_wd (cwd, MC_MAXPATHLEN + 1); qstr = (*quote_func) (cwd, 0); g_free (cwd); return qstr; } case 'i': /* indent equal number cursor position in line */ #ifdef USE_INTERNAL_EDIT if (edit_widget) return g_strnfill (edit_get_curs_col (edit_widget), ' '); #endif break; case 'y': /* syntax type */ #ifdef USE_INTERNAL_EDIT if (edit_widget) { const char *syntax_type = edit_get_syntax_type (edit_widget); if (syntax_type != NULL) return g_strdup (syntax_type); } #endif break; case 'k': /* block file name */ case 'b': /* block file name / strip extension */ { #ifdef USE_INTERNAL_EDIT if (edit_widget) { char *file = concat_dir_and_file (mc_config_get_cache_path (), EDIT_BLOCK_FILE); fname = (*quote_func) (file, 0); g_free (file); return fname; } #endif if (c_lc == 'b') return strip_ext ((*quote_func) (fname, 0)); break; } case 'n': /* strip extension in editor */ #ifdef USE_INTERNAL_EDIT if (edit_widget) return strip_ext ((*quote_func) (fname, 0)); #endif break; case 'm': /* menu file name */ if (menu) return (*quote_func) (menu, 0); break; case 's': if (!panel || !panel->marked) return (*quote_func) (fname, 0); /* Fall through */ case 't': case 'u': { int length = 2, i; char *block, *tmp; if (!panel) return g_strdup (""); for (i = 0; i < panel->count; i++) if (panel->dir.list[i].f.marked) length += strlen (panel->dir.list[i].fname) + 1; /* for space */ block = g_malloc (length * 2 + 1); *block = 0; for (i = 0; i < panel->count; i++) if (panel->dir.list[i].f.marked) { tmp = (*quote_func) (panel->dir.list[i].fname, 0); strcat (block, tmp); g_free (tmp); strcat (block, " "); if (c_lc == 'u') do_file_mark (panel, i, 0); } return block; } /* sub case block */ } /* switch */ result = g_strdup ("% "); result[1] = c; return result; }