|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 3169 (0xc61)
Types: TextFile
Names: »calledit.BSD4_n.c«, »calledit.SYS_V.c«
└─⟦060c9c824⟧ Bits:30007080 DKUUG TeX 2/12/89
└─⟦this⟧ »./tex82/Unsupported/MFpxl/mflib/calledit.BSD4_n.c«
└─⟦this⟧ »./tex82/Unsupported/MFpxl/mflib/calledit.SYS_V.c«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
└─⟦beba6c409⟧ »unix3.0/Unsupported.tar.Z«
└─⟦25c524ae4⟧
└─⟦this⟧ »Unsupported/MFpxl/mflib/calledit.BSD4_n.c«
└─⟦this⟧ »Unsupported/MFpxl/mflib/calledit.SYS_V.c«
#ifndef lint
static char RCSid[] = "$Header: calledit.c,v 1.0 86/01/31 14:58:43 richards Released $";
#endif
/*
** CALLEDIT.C -- external procedures:
**
** procedure calledit(
** var filename: ASCIIcode;
** fnlength,
** linenumber: integer );
** { invoke the system editor on "filename" (of length fnlength) }
** { to start on line "linenumber" of the file }
** { the editor is started using environment variable MFEDITOR }
** { as a pattern for constructing the arguments to the editor }
*/
#include "h00vars.h"
#include "mftypes.h"
/*
** The following procedure is due to sjc@s1-c.
**
** calledit(filename, fnlength, linenumber)
**
** MetaFont84 can call this to implement the 'e' feature in error-recovery
** mode, invoking a text editor on the erroneous source file.
**
** You should pass to "filename" the first character of the packed array
** containing the filename, and to "fnlength" the size of the filename.
**
** Ordinarily, this invokes "/usr/ucb/vi". If you want a different
** editor, create a shell environment variable MFEDITOR containing
** the string that invokes that editor, with "%s" indicating where
** the filename goes and "%d" indicating where the decimal
** linenumber (if any) goes. For example, a MFEDITOR string for a
** variant copy of "vi" might be:
**
** setenv MFEDITOR "/usr/local/bin/vi +%d %s"
**
*/
char *getenv();
char *malloc();
char dvalue[] = "/usr/ucb/vi +%d %s";
char *mfeditvalue = &dvalue[0];
calledit(filename, fnlength, linenumber)
ASCIIcode *filename;
integer fnlength, linenumber;
{
char *temp, *command, c;
int sdone, ddone, i;
sdone = ddone = 0;
/* Replace default with environment variable if possible. */
if (NULL != (temp = (char *) getenv("MFEDITOR")))
mfeditvalue = temp;
/* Make command string containing envvalue, filename, and linenumber */
if (NULL ==
(command = (char *) malloc(strlen(mfeditvalue) + fnlength + 25))) {
fprintf(stderr, "! Not enough memory to issue editor command\n");
exit(1);
}
temp = command;
while ((c = *mfeditvalue++) != '\0') {
if (c == '%') {
switch (c = *mfeditvalue++) {
case 'd':
if (ddone) {
fprintf(stderr,
"! Line number cannot appear twice in editor command\n");
exit(1);
}
sprintf(temp, "%d", linenumber);
while (*temp != '\0')
temp++;
ddone = 1;
break;
case 's':
if (sdone) {
fprintf(stderr,
"! Filename cannot appear twice in editor command\n");
exit(1);
}
i = 0;
while (i < fnlength)
*temp++ = filename[i++];
sdone = 1;
break;
case '\0':
*temp++ = '%';
mfeditvalue--; /* Back up to \0 to force termination. */
break;
default:
*temp++ = '%';
*temp++ = c;
break;
}
}
else
*temp++ = c;
}
*temp = '\0';
/* Execute command. */
if (0 != system(command))
fprintf(stderr, "! Trouble executing command %s\n", command);
/* Quit, indicating MetaFont had found an error before you typed "e". */
exit(1);
}