Beispiel #1
0
static void highlight_match_one (WString *w_string, int id,
                const pcre *regex)
{
        int pmatch[HIGHLIGHT_MATCHES * 3];
        int matches;
        guint i, offset;

        offset = 0;
        while ((matches = pcre_exec (regex, NULL, w_string->string->str,
                                        (int)w_string->string->len, offset, 0,
                                        pmatch, HIGHLIGHT_MATCHES * 3)) > 0) {

                for (i = 0; i < matches; i++) {
			char *tag_name = mangle_name (id, i);
			if (gtk_text_tag_table_lookup (highlight_tag_table,
						tag_name)) {
                                // Make sure the match is valid
                                if (pmatch[i * 2] == -1
                                                || pmatch[i * 2 + 1] == -1) {
                                        g_assert (pmatch[i * 2]
                                                        == pmatch[i * 2 + 1]);
                                } else {
                                        w_string_add_tag (w_string, tag_name,
                                                        pmatch[i * 2],
                                                        pmatch[i * 2 + 1]);
                                }
			}
                }
                // set the offset to the end of the whole match
                offset = pmatch[1];
        }
}
Beispiel #2
0
__export int open_file(const char *name, int flags, struct com32_filedata *filedata)
{
    int rv;
    struct file *file;
    char mangled_name[FILENAME_MAX];

    dprintf("open_file %s\n", name);

    mangle_name(mangled_name, name);
    rv = searchdir(mangled_name, flags);

    if (rv < 0)
	return rv;

    file = handle_to_file(rv);

    if (file->inode->mode != DT_REG) {
	_close_file(file);
	return -1;
    }

    filedata->size	= file->inode->size;
    filedata->blocklg2	= SECTOR_SHIFT(file->fs);
    filedata->handle	= rv;

    return rv;
}
Beispiel #3
0
void pm_mangle_name(com32sys_t *regs)
{
    const char *src = MK_PTR(regs->ds, regs->esi.w[0]);
    char       *dst = MK_PTR(regs->es, regs->edi.w[0]);

    mangle_name(dst, src);
}
Beispiel #4
0
static void highlight_add (guint id)
{
        WarlockHighlight *highlight;
        const char *string;
        gboolean case_sensitive;
        guint i;
        char *name;

        string = preferences_get_string (preferences_get_highlight_key (id,
                                PREF_HIGHLIGHT_STRING));
        case_sensitive = preferences_get_bool (preferences_get_highlight_key
                        (id, PREF_HIGHLIGHT_CASE_SENSITIVE));

        highlight = g_new (WarlockHighlight, 1);
        highlight->id = id;
        highlight->regex = highlight_compile_regex (string, case_sensitive);
        highlight->gconf_connections = NULL;

        highlight_list = g_slist_append (highlight_list, highlight);

        highlight_add_tags (id);

        highlight->gconf_connections = g_slist_append
                (highlight->gconf_connections, GINT_TO_POINTER
                 (preferences_notify_add (preferences_get_highlight_key
                                          (id, PREF_HIGHLIGHT_STRING),
                                          change_string, highlight)));
        highlight->gconf_connections = g_slist_append
                (highlight->gconf_connections, GINT_TO_POINTER
                 (preferences_notify_add (preferences_get_highlight_key
                                          (id, PREF_HIGHLIGHT_CASE_SENSITIVE),
                                          change_string, highlight)));

        for (i = 0; i < HIGHLIGHT_MATCHES; i++) {
                name = mangle_name (id, i);
                highlight->gconf_connections = g_slist_append
                        (highlight->gconf_connections, GINT_TO_POINTER
                         (preferences_notify_add
                          (preferences_get_highlight_match_key
                           (id, i, PREF_HIGHLIGHT_MATCH_TEXT_COLOR),
                           changed_text, name)));

                highlight->gconf_connections = g_slist_append
                        (highlight->gconf_connections, GINT_TO_POINTER
                         (preferences_notify_add
                          (preferences_get_highlight_match_key
                           (id, i, PREF_HIGHLIGHT_MATCH_BASE_COLOR),
                           changed_background, name)));

                highlight->gconf_connections = g_slist_append
                        (highlight->gconf_connections, GINT_TO_POINTER
                         (preferences_notify_add
                          (preferences_get_highlight_match_key
                           (id, i, PREF_HIGHLIGHT_MATCH_FONT),
                           changed_font, name)));
        }
}
Beispiel #5
0
/* get the priority of the match of string[id] */
static gint get_priority (guint id, guint n)
{
	GtkTextTag *tag;

        g_assert (n < HIGHLIGHT_MATCHES);
        tag = gtk_text_tag_table_lookup (highlight_tag_table,
                        mangle_name (id, n));
        g_assert (tag != NULL);
	return gtk_text_tag_get_priority (tag);
}
Beispiel #6
0
char* InliningDatabase::compute_file_name(LookupKey* outer, LookupKey* inner, bool create_directories) {
  char* name = NEW_RESOURCE_ARRAY(char, 1024);

  // Outer key
  char* outer_klass_name    = mangle_name(klass_string(outer->klass()));
  char* outer_selector_name = mangle_name(selector_string(outer->selector()));

  if (create_directories) {
    if (!check_directory(directory())) return NULL;
  }

  strcpy(name, directory());
  strcat(name, "\\");
  strcat(name, outer_klass_name);

  if (create_directories) {
    if (!check_directory(name)) return NULL;
  }

  strcat(name, "\\");
  strcat(name, outer_selector_name);

  if (inner) {
    // Inner key
    char* inner_klass_name  = mangle_name(klass_string(inner->klass()));
    char* inner_method_name = mangle_name(method_string(inner->method()));

    if (create_directories) {
      if (!check_directory(name)) return NULL;
    }
    strcat(name, "\\");
    strcat(name, inner_klass_name);

    if (create_directories) {
      if (!check_directory(name)) return NULL;
    }
    strcat(name, "\\");
    strcat(name, inner_method_name);
  }
  strcat(name, ".txt");
  return name;
}
Beispiel #7
0
static void highlight_remove_tags (guint id)
{
        guint n;

        for (n = 0; n < HIGHLIGHT_MATCHES; n++) {
                GtkTextTag *tag;
                char *name;

                name = mangle_name (id, n);
                tag = gtk_text_tag_table_lookup (highlight_tag_table, name);
                g_assert (tag != NULL);
                gtk_text_tag_table_remove (highlight_tag_table, tag);
                debug ("removed tag %s\n", name);
                next_priority--;
        }
}
Beispiel #8
0
static void set_priority_tags (int id, gint priority)
{
	GtkTextTag *tag;
        int i, p;

        p = priority;
        for (i = 0; i < HIGHLIGHT_MATCHES; i++) {
                tag = gtk_text_tag_table_lookup (highlight_tag_table,
                        mangle_name (id, i));

                if (tag != NULL) {
                        if (p != priority + i) {
                                debug ("Missing a tag\n");
                        }

                        gtk_text_tag_set_priority (tag, p);
                }
        }
}
Beispiel #9
0
void pm_open_file(com32sys_t *regs)
{
    int rv;
    struct file *file;
    const char *name = MK_PTR(regs->es, regs->esi.w[0]);
    char mangled_name[FILENAME_MAX];

    dprintf("pm_open_file %s\n", name);

    mangle_name(mangled_name, name);
    rv = searchdir(mangled_name);
    if (rv < 0) {
	regs->eflags.l |= EFLAGS_CF;
    } else {
	file = handle_to_file(rv);
	regs->eflags.l &= ~EFLAGS_CF;
	regs->eax.l = file->inode->size;
	regs->ecx.w[0] = SECTOR_SIZE(file->fs);
	regs->esi.w[0] = rv;
    }
}
Beispiel #10
0
static void highlight_add_tags (guint id)
{
	/*
	 * don't call this function if you think there might be a tag by this
	 * name already, call highlight_check_tags first if that's the case
	 */
	int i;

        for (i = 0; i < HIGHLIGHT_MATCHES; i++) {
                GdkRGBA *text, *background;
                char *font;

                text = preferences_get_color (
                                preferences_get_highlight_match_key (id, i,
                                        PREF_HIGHLIGHT_MATCH_TEXT_COLOR));
                background = preferences_get_color (
                                preferences_get_highlight_match_key (id, i,
                                        PREF_HIGHLIGHT_MATCH_BASE_COLOR));
                font = preferences_get_string (
                                preferences_get_highlight_match_key (id, i,
                                        PREF_HIGHLIGHT_MATCH_FONT));
                highlight_add_tag (mangle_name (id, i), text, background, font);
        }
}
Beispiel #11
0
cl_object si_mangle_name(cl_narg narg, ...)
{
#line 81
// ------------------------------2
#line 81
	const cl_env_ptr the_env = ecl_process_env();
#line 81
	cl_object as_function;
#line 81
	va_list ARGS;
	va_start(ARGS, narg);
	cl_object symbol = va_arg(ARGS,cl_object);  
#line 81
// ------------------------------3

	cl_index l;
	unsigned char c, *source, *dest;
	cl_object output;
	cl_object package;
	cl_object found = ECL_NIL;
	cl_object maxarg = ecl_make_fixnum(ECL_CALL_ARGUMENTS_LIMIT);
	cl_object minarg = ecl_make_fixnum(0);
	bool is_symbol;
	cl_object name;
#line 92
// ------------------------------4
#line 92
#line 92
	if (ecl_unlikely(narg < 1|| narg > 2)) FEwrong_num_arguments(ecl_make_fixnum(1107));
#line 92
	if (narg > 1) {
#line 92
		as_function = va_arg(ARGS,cl_object);  
#line 92
	} else {
#line 92
		as_function = ECL_NIL;
#line 92
	}
#line 92
// ------------------------------5
	name = ecl_symbol_name(symbol);
	is_symbol = Null(as_function);
	if (is_symbol) {
		cl_fixnum p;
		if (symbol == ECL_NIL)
			{
#line 97
				#line 97
				cl_object __value0 = ECL_T;
#line 97
				cl_object __value1 = make_constant_base_string("ECL_NIL");
#line 97
				the_env->nvalues = 2;
#line 97
				the_env->values[1] = __value1;
#line 97
				return __value0;
#line 97
			}

		else if (symbol == ECL_T)
			{
#line 99
				#line 99
				cl_object __value0 = ECL_T;
#line 99
				cl_object __value1 = make_constant_base_string("ECL_T");
#line 99
				the_env->nvalues = 2;
#line 99
				the_env->values[1] = __value1;
#line 99
				return __value0;
#line 99
			}

		p  = (cl_symbol_initializer*)symbol - cl_symbols;
		if (p >= 0 && p <= cl_num_symbols_in_core) {
			found = ECL_T;
			output = cl_format(4, ECL_NIL,
					   make_constant_base_string("ECL_SYM(~S,~D)"),
					   name, ecl_make_fixnum(p));
			{
#line 106
				#line 106
				cl_object __value0 = found;
#line 106
				cl_object __value1 = output;
#line 106
				cl_object __value2 = maxarg;
#line 106
				the_env->nvalues = 3;
#line 106
				the_env->values[2] = __value2;
#line 106
				the_env->values[1] = __value1;
#line 106
				return __value0;
#line 106
			}

		}
	} else if (!Null(symbol)) {
		cl_object fun = symbol->symbol.gfdef;
		cl_type t = (fun == OBJNULL)? t_other : type_of(fun);
		if ((t == t_cfun || t == t_cfunfixed) && fun->cfun.block == OBJNULL) {
			for (l = 0; l <= cl_num_symbols_in_core; l++) {
				cl_object s = (cl_object)(cl_symbols + l);
				if (fun == ECL_SYM_FUN(s)) {
					symbol = s;
					found = ECL_T;
					if (fun->cfun.narg >= 0) {
					    minarg =
					    maxarg = ecl_make_fixnum(fun->cfun.narg);
					}
					break;
				}
			}
		}
	}
	package = ecl_symbol_package(symbol);
	if (Null(package))
		;
	else if (package == cl_core.lisp_package)
		package = make_constant_base_string("cl");
	else if (package == cl_core.system_package)
		package = make_constant_base_string("si");
	else if (package == cl_core.ext_package)
		package = make_constant_base_string("si");
	else if (package == cl_core.keyword_package)
		package = ECL_NIL;
	else
		package = package->pack.name;
	symbol = ecl_symbol_name(symbol);
	l      = symbol->base_string.fillp;
	source = symbol->base_string.self;
	output = ecl_alloc_simple_base_string(ecl_length(package) + l + 1);
	if (is_symbol && source[0] == '*') {
		if (l > 2 && source[l-1] == '*') l--;
		c = 'V';
		l--;
		source++;
	} else if (is_symbol && l > 2 && source[0] == '+' && source[l-1] == '+') {
		c = 'C';
		l-= 2;
		source++;
	} else if (!is_symbol) {
		c = '_';
	} else if (package == cl_core.keyword_package) {
		c = 'K';
	} else {
		c = 'S';
	}
	output->base_string.fillp = 0;
	if (!Null(package))
		if (!mangle_name(output, package->base_string.self, package->base_string.fillp))
			{
#line 162
				#line 162
				cl_object __value0 = ECL_NIL;
#line 162
				cl_object __value1 = ECL_NIL;
#line 162
				cl_object __value2 = maxarg;
#line 162
				the_env->nvalues = 3;
#line 162
				the_env->values[2] = __value2;
#line 162
				the_env->values[1] = __value1;
#line 162
				return __value0;
#line 162
			}

	output->base_string.self[output->base_string.fillp++] = c;
	if (!(dest = mangle_name(output, source, l)))
		{
#line 165
			#line 165
			cl_object __value0 = ECL_NIL;
#line 165
			cl_object __value1 = ECL_NIL;
#line 165
			cl_object __value2 = maxarg;
#line 165
			the_env->nvalues = 3;
#line 165
			the_env->values[2] = __value2;
#line 165
			the_env->values[1] = __value1;
#line 165
			return __value0;
#line 165
		}

	if (dest[-1] == '_')
		dest[-1] = 'M';
	*(dest++) = '\0';
	{
#line 169
		#line 169
		cl_object __value0 = found;
#line 169
		cl_object __value1 = output;
#line 169
		cl_object __value2 = minarg;
#line 169
		cl_object __value3 = maxarg;
#line 169
		the_env->nvalues = 4;
#line 169
		the_env->values[3] = __value3;
#line 169
		the_env->values[2] = __value2;
#line 169
		the_env->values[1] = __value1;
#line 169
		return __value0;
#line 169
	}

}
Beispiel #12
0
__export void execute(const char *cmdline, uint32_t type, bool sysappend)
{
	const char *kernel, *args;
	const char *p;
	com32sys_t ireg;
	char *q, ch;

	memset(&ireg, 0, sizeof ireg);

	if (strlen(cmdline) >= MAX_CMDLINE_LEN) {
		printf("cmdline too long\n");
		return;
	}

	q = malloc(MAX_CMDLINE_LEN);
	if (!q) {
		printf("%s(): Fail to malloc a buffer to exec %s\n",
			__func__, cmdline);
		return;
	}

	kernel = q;
	p = cmdline;
	while (*p && !my_isspace(*p))
		*q++ = *p++;
	*q++ = '\0';

	args = q;
	while (*p && my_isspace(*p))
		p++;

	do {
		*q++ = ch = *p++;
	} while (ch);

	if (sysappend) {
		/* If we've seen some args, insert a space */
		if (--q != args)
			*q++ = ' ';

		do_sysappend(q);
	}

	dprintf("kernel is %s, args = %s  type = %d \n", kernel, args, type);

	if (kernel[0] == '.') {
		/* It might be a type specifier */
		const struct image_types *t;
		for (t = image_boot_types; t->name; t++) {
			if (!strcmp(kernel + 1, t->name)) {
				/*
				 * Strip the type specifier, apply the
				 * filename extension if COM32 and
				 * retry.
				 */
				p = args;
				if (t->type == IMAGE_TYPE_COM32) {
					p = apply_extension(p, ".c32");
					if (!p)
						return;
				}

				execute(p, t->type, sysappend);
				return;
			}
		}
	}

	if (type == IMAGE_TYPE_COM32) {
		/*
		 * We may be called with the console in an unknown
		 * state, so initialise it.
		 */
		ldlinux_console_init();

		/* new entry for elf format c32 */
		if (create_args_and_load((char *)cmdline))
			printf("Failed to load COM32 file %s\n", kernel);

		/*
		 * The old COM32 module code would run the module then
		 * drop the user back at the command prompt,
		 * irrespective of how the COM32 module was loaded,
		 * e.g. from vesamenu.c32.
		 */
		unload_modules_since(LDLINUX);

		/* Restore the console */
		ldlinux_console_init();

		/* Jump back to the main to call ldlinux_enter_command */
		longjmp(__return_to_command_prompt, 1);
	} else if (type == IMAGE_TYPE_CONFIG) {
		char *argv[] = { LDLINUX, NULL, NULL };
		char *config;
		int rv;

		/* kernel contains the config file name */
		config = malloc(FILENAME_MAX);
		if (!config)
			goto out;

		realpath(config, kernel, FILENAME_MAX);

		/* If we got anything on the command line, do a chdir */
		if (*args)
			mangle_name(config_cwd, args);

		argv[1] = config;
		rv = start_ldlinux(2, argv);
		printf("Failed to exec %s: %s\n", LDLINUX, strerror(rv));
	} else if (type == IMAGE_TYPE_LOCALBOOT) {
		local_boot(strtoul(kernel, NULL, 0));
	} else if (type == IMAGE_TYPE_PXE || type == IMAGE_TYPE_BSS ||
		   type == IMAGE_TYPE_BOOT) {
		chainboot_file(kernel, type);
	} else {
		/* Need add one item for kernel load, as we don't use
		* the assembly runkernel.inc any more */
		new_linux_kernel((char *)kernel, (char *)args);
	}

out:
	free((void *)kernel);

	/* If this returns, something went bad; return to menu */
}