Esempio n. 1
0
static void
parse_class (xmlNode *node)
{
	xmlNode *i;
	gchar *name;

	g_assert (node);

	name = (gchar*)xmlGetProp (node, (const xmlChar*)"name");
	if (!name)
		return;

	tagEntryInfo *tag = (tagEntryInfo*)malloc (sizeof (tagEntryInfo));
	initTagEntry (tag, name);
	tag->isFileScope = 1;
	tag->kindName = "class";
	tag->kind = 'c';
	get_file_pos (node->line, &tag->filePosition, File.fp);
	tag->lineNumber = node->line;
	makeTagEntry (tag);

	for (i = node->children; i; i = i->next)
	{
		makeTags (i, name);
	}
}
Esempio n. 2
0
static void
makeTags (xmlNode *node, const gchar *parent)
{
	g_assert (node != NULL);
	g_assert (node->name != NULL);

	if (strcmp ((const gchar*)node->name, "text") == 0
			|| strcmp ((const gchar*)node->name, "implements") == 0)
		return;
	if (strcmp ((const gchar*)node->name, "enumeration") == 0
			|| strcmp ((const gchar*)node->name, "union") == 0
			|| strcmp ((const gchar*)node->name, "namespace") == 0
			|| strcmp ((const gchar*)node->name, "class") == 0
			|| strcmp ((const gchar*)node->name, "record") == 0
			|| strcmp ((const gchar*)node->name, "bitfield") == 0
			|| strcmp ((const gchar*)node->name, "interface") == 0)
	{
		parse_class (node);
		return;
	}
	if (strcmp ((const gchar*)node->name, "function") == 0 || strcmp ((const gchar*)node->name, "method") == 0
			|| strcmp ((const gchar*)node->name, "callback") == 0
			|| strcmp ((const gchar*)node->name, "constructor") == 0)
	{
		parse_function (node, parent);
		return;
	}
	if (strcmp ((const gchar*)node->name, "alias") == 0 ||
			strcmp ((const gchar*)node->name, "constant") == 0 ||
			strcmp ((const gchar*)node->name, "signal") == 0 ||
			strcmp ((const gchar*)node->name, "field") == 0 ||
			strcmp ((const gchar*)node->name, "property") == 0 ||
			strcmp ((const gchar*)node->name, "member") == 0)
	{
		gchar *name = (gchar*)xmlGetProp (node, (const xmlChar*)"name");
		if (!name)
			return;
		tagEntryInfo *tag = (tagEntryInfo*)malloc (sizeof (tagEntryInfo));
		initTagEntry (tag, name);
		tag->isFileScope	= 1;
		tag->kindName = "variable";
		tag->kind = 'v';
		get_file_pos (node->line, &tag->filePosition, File.fp);
		tag->lineNumber = node->line;
		if (parent) {
			tag->kindName = "member";
			tag->kind = 'm';
			tag->extensionFields.scope[0] = "class";
			tag->extensionFields.scope[1] = parent;
		}
		makeTagEntry (tag);
		return;
	}
}
Esempio n. 3
0
static void
findTags (JSContext *my_cx)
{
	GList *i;
	g_assert (my_cx != NULL);
	if (my_cx->func_name)
	{
		const char *name = my_cx->func_name;
		gint line = my_cx->bline;
		if (name)
		{
			tagEntryInfo *tag = (tagEntryInfo*)malloc (sizeof (tagEntryInfo));
			initTagEntry (tag, name);
			get_file_pos (line, &tag->filePosition, File.fp);
			tag->lineNumber = line;
			tag->isFileScope	= 1;
			tag->kindName = "class";
			tag->kind = 'c';

			symbols = g_list_append (symbols, g_strdup (name));

			if (my_cx->ret_type)
				tag->extensionFields.returnType = my_cx->ret_type->data;
			if (my_cx->func_arg)
			{
				gchar *str = NULL, *t;
				GList *i;
				for (i = my_cx->func_arg; i; i = g_list_next (i))
				{
					g_assert (i->data != NULL);
					if (i == my_cx->func_arg)
						str = g_strdup_printf ("( %s", (gchar*)i->data);
					else
					{
						t = g_strdup_printf ("%s, %s", str, (gchar*)i->data);
						g_free (str);
						str = t;
					}
				}
				t = g_strdup_printf ("%s)", str);
				g_free (str);
				str = t;
				tag->extensionFields.signature = str;
			}
			tags = g_list_append (tags, tag);
		}
	}
	for (i = my_cx->childs; i; i = g_list_next (i))
	{
		findTags (i->data);
	}
}
Esempio n. 4
0
int main() {
    BLOCK_DEVICE *device;
    FSFILE *file;
    unsigned char i;
    unsigned long filepos;

    /* avoid issues with the interrupt routine hijacking the IY register -
    not sure how big a problem this really is, but can't hurt... */
#asm
    di
#endasm

    buffer_emptybuffers(); // TODO: Can this be sensibly incorporated into fatfs_init?

    printf("Initializing fatfs library\n");
    fatfs_init();
    printf("opening DivIDE master drive\n");
    device = divide_open_drive(DIVIDE_DRIVE_MASTER);
    printf("opening FATfs filesystem on it\n");
    fatfs_fsopen(device, &fs);
    printf("fatfs filesystem at %04x\n", &fs);
    open_root_dir(&fs, &dir);
    printf("dir handle at %04x\n", &dir);
    for (i = 0; i < 13; i++) {
        read_dir(&dir, &entry);
        /* printf("%s\n", entry.filename); */
    }
    printf("dirent at %04x\n", &entry);
    file = open_dirent(&entry, FILE_MODE_EXC_READ);
    printf("file handle at %04x\n", file);
    read_file(file, buffer1, 5);
    printf("first 5 chars stored at %04x\n", buffer1);
    seek_file(file, 2L);
    read_file(file, buffer2, 5);
    printf("chars 2-6 stored at %04x\n", buffer2);
    i = read_byte(file);
    printf("char 7 is %02x\n", i);
    filepos = get_file_pos(file);
    printf("file position is now %08lx\n", filepos);
    close_file(file);

#asm
    ei
#endasm

    return 0;
}
Esempio n. 5
0
static void
findGlobal (JSContext *my_cx)
{
	static int depth = 0;
	GList *i;

	g_assert (my_cx != NULL);
	g_assert (depth <= 1);

	for (i = my_cx->local_var; i; i = g_list_next (i))
	{
		const char *name = ((Var*)i->data)->name;
		gint line = ((Var*)i->data)->line;
		g_assert (name != NULL);

		if (g_strstr_len (name, -1, PROTOTYPE) != NULL)
			continue;

		tagEntryInfo *tag = (tagEntryInfo*)malloc (sizeof (tagEntryInfo));
		initTagEntry (tag, name);
		get_file_pos (line, &tag->filePosition, File.fp);
		tag->lineNumber = line;
		tag->isFileScope	= 1;
		tag->kindName = "variable";
		tag->kind = 'v';
		Type *t = js_context_get_node_type (my_cx, ((Var*)i->data)->node);
		if (t)
		{
			tag->extensionFields.typeRef [0] = "variable";
			tag->extensionFields.typeRef [1] = t->name;
			g_free (t);
		}
		if (my_cx->ret_type)
			tag->extensionFields.returnType = my_cx->ret_type->data;
		if (g_list_find_custom (symbols, name, (GCompareFunc)g_strcmp0) == NULL)
			makeTagEntry (tag);
	}
	if (depth == 0)
	{
		depth++;
		for (i = my_cx->childs; i; i = g_list_next (i))
		{
			findGlobal (i->data);
		}
		depth--;
	}
}
Esempio n. 6
0
int main(int argc, char **real_argv, char **envv)
{
	CAP *cap;
	unsigned char **argv = (unsigned char **)real_argv;
	struct stat sbuf;
	unsigned char *s;
	unsigned char *t;
	long time_rc;
	unsigned char *run;
#ifdef __MSDOS__
	unsigned char *rundir;
#endif
	SCRN *n;
	int opened = 0;
	int omid;
	int backopt;
	int c;

	joe_locale();

	mainenv = (unsigned char **)envv;
	
	vmem = vtmp();
	startup_log = bfind_scratch(USTR "* Startup Log *");
	startup_log->internal = 1;

#ifdef __MSDOS__
	_fmode = O_BINARY;
	zlcpy(stdbuf, sizeof(stdbuf), argv[0]);
	joesep(stdbuf);
	run = namprt(stdbuf);
	rundir = dirprt(stdbuf);
	for (c = 0; run[c]; ++c)
		if (run[c] == '.') {
			run = vstrunc(run, c);
			break;
		}
#else
	run = namprt(argv[0]);
#endif

	if ((s = (unsigned char *)getenv("LINES")) != NULL)
		sscanf((char *)s, "%d", &lines);
	if ((s = (unsigned char *)getenv("COLUMNS")) != NULL)
		sscanf((char *)s, "%d", &columns);
	if ((s = (unsigned char *)getenv("BAUD")) != NULL)
		sscanf((char *)s, "%u", (unsigned *)&Baud);
	if (getenv("DOPADDING"))
		dopadding = 1;
	if (getenv("NOXON"))
		noxon = 1;
	if ((s = (unsigned char *)getenv("JOETERM")) != NULL)
		joeterm = s;

#ifndef __MSDOS__
	if (!(cap = my_getcap(NULL, 9600, NULL, NULL))) {
		logerror_0((char *)joe_gettext(_("Couldn't load termcap/terminfo entry\n")));
		goto exit_errors;
	}
#endif

#ifdef __MSDOS__

	s = vsncpy(NULL, 0, sv(run));
	s = vsncpy(sv(s), sc("rc"));
	c = procrc(cap, s);
	if (c == 0)
		goto donerc;
	if (c == 1) {
		logerror_1((char *)joe_gettext(_("There were errors in '%s'.  Falling back on default.\n")), s);
	}

	vsrm(s);
	s = vsncpy(NULL, 0, sv(rundir));
	s = vsncpy(sv(s), sv(run));
	s = vsncpy(sv(s), sc("rc"));
	c = procrc(cap, s);
	if (c == 0)
		goto donerc;
	if (c == 1) {
		logerror_1((char *)joe_gettext(_("There were errors in '%s'.  Falling back on default.\n")), s);
	}
#else

	/* Name of system joerc file.  Try to find one with matching language... */
	
	/* Try full language: like joerc.de_DE */
	t = vsncpy(NULL, 0, sc(JOERC));
	t = vsncpy(sv(t), sv(run));
	t = vsncpy(sv(t), sc("rc."));
	t = vsncpy(sv(t), sz(locale_msgs));
	if (!stat((char *)t,&sbuf))
		time_rc = sbuf.st_mtime;
	else {
		/* Try generic language: like joerc.de */
		if (locale_msgs[0] && locale_msgs[1] && locale_msgs[2]=='_') {
			vsrm(t);
			t = vsncpy(NULL, 0, sc(JOERC));
			t = vsncpy(sv(t), sv(run));
			t = vsncpy(sv(t), sc("rc."));
			t = vsncpy(sv(t), locale_msgs, 2);
			if (!stat((char *)t,&sbuf))
				time_rc = sbuf.st_mtime;
			else
				goto nope;
		} else {
			nope:
			vsrm(t);
			/* Try Joe's bad english */
			t = vsncpy(NULL, 0, sc(JOERC));
			t = vsncpy(sv(t), sv(run));
			t = vsncpy(sv(t), sc("rc"));
			if (!stat((char *)t,&sbuf))
				time_rc = sbuf.st_mtime;
			else
				time_rc = 0;
		}
	}

	/* User's joerc file */
	s = (unsigned char *)getenv("HOME");
	if (s) {
		s = vsncpy(NULL, 0, sz(s));
		s = vsncpy(sv(s), sc("/."));
		s = vsncpy(sv(s), sv(run));
		s = vsncpy(sv(s), sc("rc"));

		if (!stat((char *)s,&sbuf)) {
			if (sbuf.st_mtime < time_rc) {
				logmessage_2((char *)joe_gettext(_("Warning: %s is newer than your %s.\n")),t,s);
			}
		}

		c = procrc(cap, s);
		if (c == 0) {
			vsrm(t);
			goto donerc;
		}
		if (c == 1) {
			logerror_1((char *)joe_gettext(_("There were errors in '%s'.  Falling back on default.\n")), s);
		}
	}

	vsrm(s);
	s = t;
	c = procrc(cap, s);
	if (c == 0)
		goto donerc;
	if (c == 1) {
		logerror_1((char *)joe_gettext(_("There were errors in '%s'.  Falling back on default.\n")), s);
	}

	/* Try built-in joerc */
	s = vsncpy(NULL, 0, sc("*"));
	s = vsncpy(sv(s), sv(run));
	s = vsncpy(sv(s), sc("rc"));
	c = procrc(cap, s);
	if (c != 0 && c != 1) {
		/* If *fancyjoerc not present, use *joerc which is always there */
		s = vstrunc(s, 0);
		s = vsncpy(sv(s),sc("*joerc"));
		c = procrc(cap, s);
	}
	if (c == 0)
		goto donerc;
	if (c == 1) {
		logerror_1((char *)joe_gettext(_("There were errors in '%s'.  Falling back on default.\n")), s);
	}
#endif

	logerror_1((char *)joe_gettext(_("Couldn't open '%s'\n")), s);
	goto exit_errors;
	return 1;

	donerc:

	if (validate_rc()) {
		logerror_0((char *)joe_gettext(_("rc file has no :main key binding section or no bindings.  Bye.\n")));
		goto exit_errors;
	}

	{
		unsigned char buf[10];
		int x;
		zlcpy(buf, sizeof(buf), USTR "\"`\"	`  ");
		type_backtick = mparse(0, buf, &x, 0);
	}

	shell_kbd = mkkbd(kmap_getcontext(USTR "shell"));

	if (!isatty(fileno(stdin)))
		idleout = 0;

	for (c = 1; argv[c]; ++c) {
		if (argv[c][0] == '-') {
			if (argv[c][1])
				switch (glopt(argv[c] + 1, argv[c + 1], NULL, 1)) {
				case 0:
					logerror_1((char *)joe_gettext(_("Unknown option '%s'\n")), argv[c]);
					break;
				case 1:
					break;
				case 2:
					++c;
					break;
			} else
				idleout = 0;
		}
	}

	/* initialize mouse support */
	if (xmouse && (s=(unsigned char *)getenv("TERM")) && strstr((char *)s,"xterm"))
		usexmouse=1;

	if (!(n = nopen(cap)))
		goto exit_errors;
	maint = screate(n);

	load_state();

	/* It would be better if this ran uedit() to load files */

	/* The business with backopt is to load the file first, then apply file
	 * local options afterwords */

	/* orphan is not compatible with exemac()- macros need a window to exist */
	for (c = 1, backopt = 0; argv[c]; ++c)
		if (argv[c][0] == '+' && argv[c][1]>='0' && argv[c][1]<='9') {
			if (!backopt)
				backopt = c;
		} else if (argv[c][0] == '-' && argv[c][1]) {
			if (!backopt)
				backopt = c;
			if (glopt(argv[c] + 1, argv[c + 1], NULL, 0) == 2)
				++c;
		} else {
			B *b = bfind(argv[c]);
			BW *bw = NULL;
			int er = berror;

			/* This is too annoying */
			/* set_current_dir(argv[c],1); */

			setup_history(&filehist);
			append_history(filehist,sz(argv[c]));

			/* wmktw inserts the window before maint->curwin */
			if (!orphan || !opened) {
				bw = wmktw(maint, b);
				if (er)
					msgnwt(bw->parent, joe_gettext(msgs[-er]));
			} else {
				long line;
				b->orphan = 1;
				b->oldcur = pdup(b->bof, USTR "main");
				pline(b->oldcur, get_file_pos(b->name));
				p_goto_bol(b->oldcur);
				line = b->oldcur->line - (maint->h - 1) / 2;
				if (line < 0)
					line = 0;
				b->oldtop = pdup(b->oldcur, USTR "main");
				pline(b->oldtop, line);
				p_goto_bol(b->oldtop);
			}
			if (bw) {
				long lnum = 0;

				bw->o.readonly = bw->b->rdonly;
				if (backopt) {
					while (backopt != c) {
						if (argv[backopt][0] == '+') {
							sscanf((char *)(argv[backopt] + 1), "%ld", &lnum);
							++backopt;
						} else {
							if (glopt(argv[backopt] + 1, argv[backopt + 1], &bw->o, 0) == 2)
								backopt += 2;
							else
								backopt += 1;
							lazy_opts(bw->b, &bw->o);
						}
					}
				}
				bw->b->o = bw->o;
				bw->b->rdonly = bw->o.readonly;
				/* Put cursor in window, so macros work properly */
				maint->curwin = bw->parent;
				/* Execute macro */
				if (er == -1 && bw->o.mnew)
					exmacro(bw->o.mnew,1);
				if (er == 0 && bw->o.mold)
					exmacro(bw->o.mold,1);
				/* Hmm... window might not exist any more... depends on what macro does... */
				if (lnum > 0)
					pline(bw->cursor, lnum - 1);
				else
					pline(bw->cursor, get_file_pos(bw->b->name));
				p_goto_bol(bw->cursor);
				/* Go back to first window so windows are in same order as command line  */
				if (opened)
					wnext(maint);
				
			}
			opened = 1;
			backopt = 0;
		}

	

	if (opened) {
		wshowall(maint);
		omid = mid;
		mid = 1;
		dofollows();
		mid = omid;
	} else {
		BW *bw = wmktw(maint, bfind(USTR ""));

		if (bw->o.mnew)
			exmacro(bw->o.mnew,1);
	}
	maint->curwin = maint->topwin;

	if (logerrors) {
		B *copied = bcpy(startup_log->bof, startup_log->eof);
		BW *bw = wmktw(maint, copied);
		copied->name = zdup(startup_log->name);
		copied->internal = 1;
		maint->curwin = bw->parent;
		wshowall(maint);
	}

	if (help) {
		help_on(maint);
	}
	if (!nonotice) {
		joe_snprintf_3(msgbuf,JOE_MSGBUFSIZE,joe_gettext(_("\\i** Joe's Own Editor v%s ** (%s) ** Copyright %s 2015 **\\i")),VERSION,locale_map->name,(locale_map->type ? "©" : "(C)"));

		msgnw(((BASE *)lastw(maint)->object)->parent, msgbuf);
	}

	if (!idleout) {
		if (!isatty(fileno(stdin)) && modify_logic(maint->curwin->object, ((BW *)maint->curwin->object)->b)) {
			/* Start shell going in first window */
			unsigned char **a;
			unsigned char *cmd;

			a = vamk(10);
			cmd = vsncpy(NULL, 0, sc("/bin/sh"));
			a = vaadd(a, cmd);
			cmd = vsncpy(NULL, 0, sc("-c"));
			a = vaadd(a, cmd);
			cmd = vsncpy(NULL, 0, sc("/bin/cat"));
			a = vaadd(a, cmd);
			
			cstart (maint->curwin->object, USTR "/bin/sh", a, NULL, NULL, 0, 1, NULL, 0);
		}
	}

	edloop(0);

	save_state();

	/* Delete all buffer so left over locks get eliminated */
	brmall();

	vclose(vmem);
	nclose(n);

	if  (noexmsg) {
		if (notite)
			fprintf(stderr, "\n");
	} else {
		if (exmsg)
			fprintf(stderr, "\n%s\n", exmsg);
		else if (notite)
			fprintf(stderr, "\n");
	}

	return 0;

exit_errors:

	/* Write out error log to console if we are exiting with errors. */
	if (startup_log && startup_log->eof->byte)
		bsavefd(startup_log->bof, 2, startup_log->eof->byte);
	
	return 1;
}
Esempio n. 7
0
int main(int argc, char **real_argv, char **envv)
{
	CAP *cap;
	unsigned char **argv = (unsigned char **)real_argv;
	struct stat sbuf;
	unsigned char *s;
	unsigned char *t;
	long time_rc;
	unsigned char *run;
#ifdef __MSDOS__
	unsigned char *rundir;
#endif
	SCRN *n;
	int opened = 0;
	int omid;
	int backopt;
	int c;

	init_bufs();

	for (c = 1; argv[c] != NULL; ++c) {
		if (0 == zcmp((unsigned char*)argv[c], USTR "-nosys")) {
			read_sys_configs = 0;
		} else if (0 == zcmp((unsigned char*)argv[c], USTR "-nouser")) {
			read_user_configs = 0;
		} else {
			argv[--c] = argv[0];
			argv += c;
			argc -= c;
			break;
		}
	}

	if (read_user_configs) {
		s = (unsigned char *)getenv("HOME");
		if (s) {
			s = vsncpy(NULL, 0, sz(s));
			s = vsncpy(sv(s), sc("/.joe-p37/only.rc"));
			if (!stat((char*)s, &sbuf)) read_sys_configs = 0;
			vsrm(s);
		}
	}

	joe_locale();

	mainenv = (unsigned char **)envv;

#ifdef __MSDOS__
	_fmode = O_BINARY;
	zcpy(stdbuf, argv[0]);
	joesep(stdbuf);
	run = namprt(stdbuf);
	rundir = dirprt(stdbuf);
	for (c = 0; run[c]; ++c)
		if (run[c] == '.') {
			run = vstrunc(run, c);
			break;
		}
#else
	run = namprt(argv[0]);
#endif

	env_lines = 0;
	if ((s = (unsigned char *)getenv("LINES")) != NULL &&
	    sscanf((char *)s, "%d", &env_lines) != 1)
		env_lines = 0;
	env_columns = 0;
	if ((s = (unsigned char *)getenv("COLUMNS")) != NULL &&
	    sscanf((char *)s, "%d", &env_columns) != 1)
		env_columns = 0;
	if ((s = (unsigned char *)getenv("BAUD")) != NULL)
		sscanf((char *)s, "%u", (unsigned *)&Baud);
	if (getenv("DOPADDING"))
		dopadding = 1;
	if (getenv("NOXON"))
		noxon = 1;
	if ((s = (unsigned char *)getenv("JOETERM")) != NULL)
		joeterm = s;

#ifndef __MSDOS__
	if (!(cap = my_getcap(NULL, 9600, NULL, NULL))) {
		fprintf(stderr, (char *)joe_gettext(_("Couldn't load termcap/terminfo entry\n")));
		return 1;
	}
#endif

#ifdef __MSDOS__

	s = vsncpy(NULL, 0, sv(run));
	s = vsncpy(sv(s), sc("rc"));
	c = procrc(cap, s);
	if (c == 0)
		goto donerc;
	if (c == 1) {
		unsigned char buf[8];

		fprintf(stderr, (char *)joe_gettext(_("There were errors in '%s'.  Use it anyway?")), s);
		fflush(stderr);
		if (NULL == fgets(buf, 8, stdin) || yn_checks(yes_key, buf))
			goto donerc;
	}

	vsrm(s);
	s = vsncpy(NULL, 0, sv(rundir));
	s = vsncpy(sv(s), sv(run));
	s = vsncpy(sv(s), sc("rc"));
	c = procrc(cap, s);
	if (c != 0 && c != 1) {
		/* If built-in *fancyjoerc not present, process builtin *joerc,
		 * which is always present.
		 */
		s = vstrunc(s, 0);
		s = vsncpy(sv(s), sc("*joerc"));
		c = procrc(cap, s);
	}
	if (c == 0)
		goto donerc;
	if (c == 1) {
		unsigned char buf[8];

		fprintf(stderr, (char *)joe_gettext(_("There were errors in '%s'.  Use it anyway?")), s);
		fflush(stderr);
		if (NULL == fgets(buf, 8, stdin) || yn_checks(yes_key, buf))
			goto donerc;
	}
#else

	/* Name of system joerc file.  Try to find one with matching language... */
	
	/* Try full language: like joerc.de_DE */
	time_rc = 0;
        if (!read_sys_configs) { t = NULL; goto skip_joerc; }
        t = vsncpy(NULL, 0, sc(JOERC));
	t = vsncpy(sv(t), sv(run));
	t = vsncpy(sv(t), sc("rc."));
	t = vsncpy(sv(t), sz(locale_msgs));
	if (!stat((char *)t,&sbuf))
		time_rc = sbuf.st_mtime;
	else {
		/* Try generic language: like joerc.de */
		if (locale_msgs[0] && locale_msgs[1] && locale_msgs[2]=='_') {
			vsrm(t);
			t = vsncpy(NULL, 0, sc(JOERC));
			t = vsncpy(sv(t), sv(run));
			t = vsncpy(sv(t), sc("rc."));
			t = vsncpy(sv(t), locale_msgs, 2);
			if (!stat((char *)t,&sbuf))
				time_rc = sbuf.st_mtime;
			else
				goto nope;
		} else {
			nope:
			vsrm(t);
			/* Try Joe's bad english */
			t = vsncpy(NULL, 0, sc(JOERC));
			t = vsncpy(sv(t), sv(run));
			t = vsncpy(sv(t), sc("rc"));
			if (!stat((char *)t,&sbuf))
				time_rc = sbuf.st_mtime;
			else {
				/* If built-in *fancyjoerc not present, process builtin *joerc,
				 * which is always present.
				 */
				t = vstrunc(s, 0);
				t = vsncpy(sv(s), sc("*joerc"));
				time_rc = stat((char *)t,&sbuf) ? 0 : sbuf.st_mtime;
			}
		}
	}
	skip_joerc:

	/* User's joerc file */
	s = (unsigned char *)getenv("HOME");
	if (s && !read_sys_configs) {
		if (read_user_configs) {  /* TODO(pts): Don't read /dev/null */
			s = vsncpy(NULL, 0, sz(s));
			s = vsncpy(sv(s), sc("/.joe-p37/rc"));
		} else {
			s = vsncpy(NULL, 0, sc("/dev/null/missing"));
		}
		goto process_user_rc;
	} else if (!read_user_configs) {
		s = vsncpy(NULL, 0, sc("/dev/null/missing"));
		goto process_user_rc;
	} else if (s) {
		unsigned char buf[8];

		s = vsncpy(NULL, 0, sz(s));
		s = vsncpy(sv(s), sc("/."));
		s = vsncpy(sv(s), sv(run));
		s = vsncpy(sv(s), sc("rc"));

		if (!stat((char *)s,&sbuf)) {
			if (sbuf.st_mtime < time_rc) {
				fprintf(stderr,(char *)joe_gettext(_("Warning: %s is newer than your %s.\n")),t,s);
				fprintf(stderr,(char *)joe_gettext(_("You should update or delete %s\n")),s);
				fprintf(stderr,(char *)joe_gettext(_("Hit enter to continue with %s ")),t);
				fflush(stderr);
				(void)!fgets((char *)buf, 8, stdin);
				goto use_sys;
			}
		}

	      process_user_rc:
		c = procrc(cap, s);
		if (c == 0) {
			vsrm(t);
			goto donerc;
		}
		if (c == 1) {
			fprintf(stderr,(char *)joe_gettext(_("There were errors in '%s'.  Use it anyway (y,n)? ")), s);
			fflush(stderr);
			if (NULL == fgets((char *)buf, 8, stdin) || ynchecks(yes_key, buf)) {
				vsrm(t);
				goto donerc;
			}
		}
	}

	use_sys:
	vsrm(s);
	s = t;
	c = s ? procrc(cap, s) : -1;
	if (c == 0)
		goto donerc;
	if (c == 1) {
		unsigned char buf[8];

		fprintf(stderr,(char *)joe_gettext(_("There were errors in '%s'.  Use it anyway (y,n)? ")), s);
		fflush(stderr);
		if (NULL == fgets((char *)buf, 8, stdin) || ynchecks(yes_key, buf))
			goto donerc;
	}

	/* Try built-in *fancyjoerc, e.g. "*joe-p37rc" */
	vsrm(s);
	s = vsncpy(NULL, 0, sc("*"));
	s = vsncpy(sv(s), sv(run));
	s = vsncpy(sv(s), sc("rc"));
	c = procrc(cap, s);
	if (c != 0 && c != 1) {
		/* If built-in *fancyjoerc not present, process builtin "*joerc",
		 * which is always present.
		 */
		s = vstrunc(s, 0);
		s = vsncpy(sv(s), sc("*joerc"));
		c = procrc(cap, s);
	}
	if (c == 0)
		goto donerc;
	if (c == 1) {
		unsigned char buf[8];

		fprintf(stderr,(char *)joe_gettext(_("There were errors in '%s'.  Use it anyway (y,n)? ")), s);
		fflush(stderr);
		if (NULL == fgets((char *)buf, 8, stdin) || ynchecks(yes_key, buf))
			goto donerc;
	}
#endif

	fprintf(stderr,(char *)joe_gettext(_("Couldn't open '%s'\n")), s);
	vsrm(s);
	return 1;

	donerc:
	vsrm(s);

	if (validate_rc()) {
		fprintf(stderr,(char *)joe_gettext(_("rc file has no :main key binding section or no bindings.  Bye.\n")));
		return 1;
	}


	if (!isatty(fileno(stdin)))
		idleout = 0;

	for (c = 1; argv[c]; ++c) {
		if (argv[c][0] == '-') {
			if (argv[c][1])
				switch (glopt(argv[c] + 1, argv[c + 1], NULL, 1)) {
				case 0:
					fprintf(stderr,(char *)joe_gettext(_("Unknown option '%s'\n")), argv[c]);
					break;
				case 1:
					break;
				case 2:
					++c;
					break;
			} else
				idleout = 0;
		}
	}
	if (!dspasis) {  /* Open all files as ASCII by default if `joe --asis' is specified. This is to avoid writing control characters to the UTF-8 terminal. */
		fdefault.charmap = pdefault.charmap = find_charmap(USTR "ascii");
		fdefault.map_name = pdefault.map_name = USTR "ascii";
	}


	/* initialize mouse support */
	if (xmouse && (s=(unsigned char *)getenv("TERM")) && strstr((char *)s,"xterm"))
		usexmouse=1;

	if (!(n = nopen(cap)))
		return 1;
	maint = screate(n);
	vmem = vtmp();

	startup_log = bfind_scratch_incref(USTR "* Startup Log *");
	startup_log->internal = 1;

	load_state();

	/* It would be better if this ran uedit() to load files */

	/* The business with backopt is to load the file first, then apply file
	 * local options afterwords */

	/* orphan is not compatible with exemac()- macros need a window to exist */
	for (c = 1, backopt = 0; argv[c]; ++c)
		if (argv[c][0] == '+' && argv[c][1]>='0' && argv[c][1]<='9') {
			if (!backopt)
				backopt = c;
		} else if (argv[c][0] == '-' && argv[c][1]) {
			if (!backopt)
				backopt = c;
			if (glopt(argv[c] + 1, argv[c + 1], NULL, 0) == 2)
				++c;
		} else {
			B *b = bfind_incref(argv[c]);
			BW *bw = NULL;
			int er = berror;

			/* This is too annoying */
			/* set_current_dir(argv[c],1); */

			setup_history(&filehist);
			append_history(filehist,sz(argv[c]));

			/* wmktw_takeref() inserts the window before maint->curwin */
			if (!orphan || !opened) {
				bw = wmktw_takeref(maint, b);
				if (er)
					msgnwt(bw->parent, joe_gettext(msgs[-er]));
			} else {
				long line;
				b->orphan = 1;
				b->oldcur = pdup(b->bof, USTR "main");
				pline(b->oldcur, get_file_pos(b->name));
				line = b->oldcur->line - (maint->h - 1) / 2;
				if (line < 0)
					line = 0;
				b->oldtop = pdup(b->oldcur, USTR "main");
				pline(b->oldtop, line);
				p_goto_bol(b->oldtop);
			}
			if (bw) {
				long lnum = 0;

				bw->o.readonly = bw->b->rdonly;
				if (backopt) {
					while (backopt != c) {
						if (argv[backopt][0] == '+') {
							sscanf((char *)(argv[backopt] + 1), "%ld", &lnum);
							++backopt;
						} else {
							if (glopt(argv[backopt] + 1, argv[backopt + 1], &bw->o, 0) == 2)
								backopt += 2;
							else
								backopt += 1;
							lazy_opts(bw->b, &bw->o);
						}
					}
				}
				bw->b->o = bw->o;
				bw->b->rdonly = bw->o.readonly;
				/* Put cursor in window, so macros work properly */
				maint->curwin = bw->parent;
				/* Execute macro */
				if (er == -1 && bw->o.mnew)
					exmacro(bw->o.mnew,1);
				if (er == 0 && bw->o.mold)
					exmacro(bw->o.mold,1);
				/* Hmm... window might not exist any more... depends on what macro does... */
				if (lnum > 0)
					pline(bw->cursor, lnum - 1);
				else
					pline(bw->cursor, get_file_pos(bw->b->name));
				p_goto_bol(bw->cursor);
				/* Go back to first window so windows are in same order as command line  */
				if (opened)
					wnext(maint);
				
			}
			opened = 1;
			backopt = 0;
		}

	

	if (opened) {
		wshowall(maint);
		omid = mid;
		mid = 1;
		dofollows();
		mid = omid;
	} else {
		BW *bw = wmktw_takeref(maint, bfind_incref(USTR ""));

		if (bw->o.mnew)
			exmacro(bw->o.mnew,1);
	}
	maint->curwin = maint->topwin;

	if (startup_log->eof->byte) {
		BW *bw = wmktw_takeref(maint, startup_log);
		startup_log = NULL;
		maint->curwin = bw->parent;
		wshowall(maint);
		uparserr(bw);
	}

	if (help) {
		help_on(maint);
	}
	if (!nonotice) {
		joe_snprintf_3(msgbuf,JOE_MSGBUFSIZE,joe_gettext(_("\\i** Joe's Own Editor v%s ** (%s) ** Copyright %s 2008 **\\i")),VERSION,locale_map->name,(locale_map->type ? "©" : "(C)"));

		msgnw(((BASE *)lastw(maint)->object)->parent, msgbuf);
	}

	if (!idleout) {
		if (!isatty(fileno(stdin)) && modify_logic(maint->curwin->object, ((BW *)maint->curwin->object)->b)) {
			/* Start shell going in first window */
			unsigned char **a;
			unsigned char *cmd;

			a = vamk(10);
			cmd = vsncpy(NULL, 0, sc("/bin/sh"));
			a = vaadd(a, cmd);
			cmd = vsncpy(NULL, 0, sc("-c"));
			a = vaadd(a, cmd);
			cmd = vsncpy(NULL, 0, sc("/bin/cat"));
			a = vaadd(a, cmd);
			
			cstart (maint->curwin->object, USTR "/bin/sh", a, NULL, NULL, 0, 1);
		}
	}

	edloop(0);

	save_state();

	/* Delete all buffer so left over locks get eliminated */
	brmall();

	vclose(vmem);
	nclose(n);

	if (exmsg)
		fprintf(stderr, "\n%s\n", exmsg);
	return 0;
}
Esempio n. 8
0
static void
get_member_list (JSContext *my_cx)
{
	GList *i;

	g_assert (my_cx != NULL);

	gint plen = strlen (PROTOTYPE);

	for (i = my_cx->local_var; i; i = g_list_next (i))
	{
		gint len;
		gchar *tstr;
		Var *t = (Var *)i->data;
		if (!t->name)
			continue;
		len = strlen (t->name);
		if (len <= plen)
			continue;
		if (tstr = strstr (t->name, PROTOTYPE), tstr == NULL)
			continue;
		if (strlen (tstr) != plen)
		{
//TODO:puts (t->name);
//Make tag
		}
		else
		{
			JSNode *node = t->node;
			JSNode* iter;

			g_assert (node->pn_type == TOK_RC);
	
			for (iter = node->pn_u.list.head; iter != NULL; iter = iter->pn_next)
			{
				const gchar* name = js_node_get_name (iter->pn_u.binary.left);
				const JSTokenPos* pos = getTagPos (iter->pn_u.binary.left);
				if (!name)
					g_assert_not_reached ();
				else
				{
					gchar *rname = g_strndup (t->name, len - plen);

					if (g_strcmp0 (name, "__proto__") == 0 )
					{
						GList *i;
						Type *t = js_context_get_node_type (my_cx, JS_NODE (iter->pn_u.binary.right));
						if (!t || !t->name)
							continue;
						for (i = tags; i != NULL; i = g_list_next (i))
							if (g_strcmp0 (((tagEntryInfo *)i->data)->name, rname) == 0)
							{
								gchar *tn = g_strdup (t->name), *tstr;
								if (tstr = strstr (tn, PROTOTYPE), tstr != NULL)
								{
									g_assert (strlen (tstr) == plen);
									*tstr = '\0';
								}
								((tagEntryInfo *)i->data)->extensionFields.inheritance = tn;
								break;
							}
					}
					else
					{
						tagEntryInfo *tag = (tagEntryInfo*)malloc (sizeof (tagEntryInfo));

						symbols = g_list_append (symbols, g_strdup (name));
						
						initTagEntry (tag, name);
						tag->isFileScope = 1;
						tag->kindName = "member";
						tag->kind = 'm';
						get_file_pos (pos->begin, &tag->filePosition, File.fp);
						tag->lineNumber = pos->begin;
						tag->extensionFields.scope[0]="class";
						tag->extensionFields.scope[1]=rname;
						JSNode *node = (JSNode *)iter->pn_u.binary.right;
						if (node && node->pn_arity == PN_FUNC && node->pn_u.func.args)
						{
							gchar *str = NULL, *t;
							JSNode *i = node->pn_u.func.args;
							g_assert (i->pn_arity == PN_LIST);
							for (i = (JSNode *)i->pn_u.list.head; i; i = (JSNode *)i->pn_next)
							{
								const gchar *name;
								g_assert (i->pn_arity == PN_NAME);
								name = js_node_get_name (i);
								g_assert (name != NULL);
								if (str == NULL)
									str = g_strdup_printf ("( %s", name);
								else
								{
									t = g_strdup_printf ("%s, %s", str, name);
									g_free (str);
									str = t;
								}
							}
							t = g_strdup_printf ("%s)", str);
							g_free (str);
							str = t;
							tag->extensionFields.signature = str;
						}
						makeTagEntry (tag);
					}
				}
			}
		}
	}
	for (i = my_cx->childs; i; i = g_list_next (i))
	{
		JSContext *t = (JSContext *)i->data;
		get_member_list (t);
	}

}
Esempio n. 9
0
static void
parse_function (xmlNode *node, const gchar *parent)
{
	xmlNode *i, *k;
	gchar *name;
	tagEntryInfo *tag;

	g_assert (node != NULL);

	name = (gchar*)xmlGetProp (node, (xmlChar*)"name");
	if (!name)
		return;

	tag = (tagEntryInfo*)malloc (sizeof (tagEntryInfo));
	initTagEntry (tag, name);
	get_file_pos (node->line, &tag->filePosition, File.fp);
	tag->lineNumber = node->line;
	tag->isFileScope	= 1;
	tag->kindName = "function";
	tag->kind = 'f';
	if (parent) {
		tag->kindName = "member";
		tag->kind = 'm';
		tag->extensionFields.scope[0] = "class";
		tag->extensionFields.scope[1] = parent;
	}

	for (i = node->children; i; i = i->next)
	{
		if (!i->name)
			continue;
		if (strcmp ((const gchar*)i->name, "return-value") == 0)
		{
			for (k = i->children; k; k = k->next)
			{
				const gchar *tmp;
				if (!k->name)
					continue;
				tmp = (const gchar*)xmlGetProp (k, (const xmlChar*)"name");
				if (!tmp)
					continue;
				tag->extensionFields.returnType = tmp;
			}
		}
		if (strcmp ((const gchar*)i->name, "parameters") == 0)
		{
			for (k = i->children; k; k = k->next)
			{
/*TODO:				const gchar *name;
				if (!k->name)
					continue;
				name = (const gchar*)xmlGetProp (node, (const xmlChar*)"name");
				if (!name)
					continue;
				tmp = g_new (Argument, 1);
				tmp->name = g_strdup (name);
				tmp->types = NULL;
				ret->args = g_list_append (ret->args, tmp);*/
			}
		}
	}
	makeTagEntry (tag);
}
Esempio n. 10
0
static uint64_t get_file_position(CPUState *env, PTR file_struct) {
	return get_file_pos(env, file_struct);
}