Exemple #1
0
static void
yyputline( char *outtext)
{
	char token_buf[MAX_LINE+1];
	char token_val[MAX_LINE+1];
	char *p = token_buf;
	static char *symc = ERx( 
	   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$");
	i4 symc_l = STlength(symc);
	i4 defidx;
	static i4  iterate_level = 0;

	/* Check to make sure we don't have runaway recursion */
	if (iterate_level++ > MAX_ITERATION)
	{
		SIfprintf( stderr, E_YAPP006 );
		yydump();
	}

	/* Break up the string into tokens and try to resolve symbols */
	while (*outtext != EOS)
	{
		p = token_buf;
		while (STindex(symc, outtext, symc_l) != NULL) {
			STlcopy(outtext, p, 1);
			CMnext(outtext);
			CMnext(p);
		}

		/* Found a token that may be defined as a symbol */
		if (p != token_buf)
		{
			/* If the token is defined then translate the */
			/* value of the substituted text, otherwise just */
			/* output the untranslated text. */
			STcopy(ERx(""), p);
			if (OK == is_defined(token_buf, token_val)) 
				yyputline( token_val );
			else 
				SIprintf("%s", token_buf);
		}

		/* The text being processed at this point is whitespace, */
		/* operators, or some other characters that are not */
		/* valid for tokens. */
		else 
		{
			SIputc(*outtext, stdout);
			CMnext(outtext);
		}
	}
	iterate_level--;
}
Exemple #2
0
edit()
{
	register char		*p;
	LOCATION		t_loc,
				loc;
	FILE			*fp;
	char			errbuf[ER_MAX_LEN + 1];
	char			input[MAX_LOC + 1];
	char			*editfile;
	char			*ingedit;
	i4			rflag;
	STATUS			status;
	i4			c;
#ifdef CMS
	i4			Notempty = 1;
#endif /* CMS */

	GLOBALREF	char	*IIMOildInitLnDraw;

	FUNC_EXTERN 	char		*getfilenm();
	FUNC_EXTERN 	char		*macro();


	if (!Newline)
	{
		q_putc(Qryiop, '\n');
		Newline = TRUE;
	}

	Autoclear	= 0;
	editfile	= getfilenm();
	rflag		= 0;

	if (*editfile == '\0')
	{
		rflag	 = 1;
		input[0] = EOS;


		if ((status = NMloc( TEMP, PATH, (char *)NULL, &t_loc)) ||
		    (status = LOuniq( ERx( "query" ), ERx( "edt" ), &t_loc)))
		{
			STcopy( ERx( "queryXXX" ), input );
		}
		else
		{
			LOcopy( &t_loc, input, &loc );
		}

		status = SIfopen( &loc, ERx( "w" ), (i4)SI_TXT,
				  (i4)SI_MAX_TXT_REC, &fp );
	}
	else
	{
		/* use the path and file name the user gave you */

		STcopy(editfile, input);

		if (!(status = LOfroms(PATH & FILENAME, input, &loc)))
			status = SIfopen( &loc, ERx("w"), (i4)SI_TXT,
					  (i4)SI_MAX_TXT_REC, &fp );
	}

	if (status)
	{
		if (status == FAIL)
			errbuf[0] = '\0';
		else
			ERreport(status, errbuf);

		putprintf(ERget(F_MO000C_Cant_create_qry_file),
				input, errbuf);

		cgprompt();
		return(0);
	}

	if (q_ropen(Qryiop, 'r') == (struct qbuf *)NULL)
		/* edit: q_ropen 1 */
		ipanic(E_MO0044_1500400);

	while ((c = (i4)q_getc(Qryiop)) > 0)
		SIputc((char)c, fp);

	SIclose(fp);

	if (Nodayfile >= 0)
	{
		putprintf(ERget(F_MO000D_editor_prompt));
		SIflush(stdout);
	}

	/*
	**	macro returns NULL if undefined, UTedit uses
	**		default editor if passed NULL.
	*/

	/* Bug 4875	-	Use editor defined by environment variable
		ING_EDIT. If that is not set then use the macro(editor). 
	*/

	NMgtAt((ERx("ING_EDIT")), &ingedit);
	if ( ingedit != NULL && *ingedit != EOS )
		p = ingedit;
	else

		p = macro(ERx("{editor}"));

	if (status = UTedit(p, &loc))
	{
		ERreport(status, errbuf);
		putprintf(ERget(F_MO000E_Can_t_start_up_editor), errbuf);

		cgprompt();
		return(0);
	}

	if (!rflag)
	{
		if (q_ropen(Qryiop, 'a') == (struct qbuf *)NULL)
			/* edit: q_ropen 2 */
			ipanic(E_MO0045_1500401);
	}
	else
	{
		if (q_ropen(Qryiop, 'w') == (struct qbuf *)NULL)
			/* edit: q_ropen 3 */
			ipanic(E_MO0046_1500402);

		if (status = SIfopen( &loc, ERx("r"), (i4)SI_TXT,
				      (i4)SI_MAX_TXT_REC, &fp ))
#ifdef CMS
		{
			Notempty = 0;
		}
#else
		{
			ERreport(status, errbuf);
			/* can't reopen editfile %s: %s\n */
			ipanic(E_MO0047_1500403,
				editfile, errbuf);
		}
#endif /* CMS */

#ifdef CMS
		if (Notempty)
		{
#endif /* CMS */
		Notnull = 0;

		while ((c = SIgetc(fp)) != EOF)
		{
			if (status)
			{
				ERreport(status, errbuf);
				/* Error reading edit file: %s\n */
				ipanic(E_MO0048_1500404, errbuf);
			}

			Notnull = 1;

			q_putc(Qryiop, (char)c);
		}

		SIclose(fp);


		if (status = LOpurge(&loc, 0))
		{
			ERreport(status, errbuf);
			putprintf(ERget(F_MO000F_Cant_delete_file), editfile, errbuf);
		}
#ifdef CMS
		} /* endif Notempty */
#endif /* CMS */
	}

#ifndef FT3270
	/* Re-Initialize IT line drawing */
	{
	    if (Outisterm && IIMOildInitLnDraw != NULL)
		SIprintf(ERx("%s"), IIMOildInitLnDraw);
	}
#endif

	cgprompt();

	return(0);
}