1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

tcl: use the system version, initial work only on linux for now

This commit is contained in:
Jon Trulson 2018-09-17 13:57:57 -06:00
parent bf0b602b9a
commit 68559d4f76
5 changed files with 44 additions and 51 deletions

View file

@ -2,10 +2,10 @@ XCOMM $XConsortium: Imakefile /main/6 1996/11/29 11:06:09 rswiston $
XLATESRC = $(DTSVCSRC)/DtUtil2 XLATESRC = $(DTSVCSRC)/DtUtil2
INCLUDES = -I../lib/tptregexp -I../tcl -I$(XLATESRC) INCLUDES = -I../lib/tptregexp -I$(XLATESRC) -I/usr/include/tcl
DEPLIBS = $(DEPDTSVCLIB) DEPLIBS = $(DEPDTSVCLIB)
LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) \ LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) \
-L../lib/tptregexp -ltptregexp ../tcl/libtcl.a -L../lib/tptregexp -ltptregexp -ltcl
#if defined(SunArchitecture) #if defined(SunArchitecture)
EXTRA_LIBRARIES = -lsocket -lnsl -lgen -lm EXTRA_LIBRARIES = -lsocket -lnsl -lgen -lm
#else #else

View file

@ -324,9 +324,3 @@ void PrintElemTree(Element_t *);
void PrintStats(Element_t *); void PrintStats(Element_t *);
void PrintIDList(); void PrintIDList();
/* ----- other declarations ----- */
#ifdef ultrix
#define strdup(s) strcpy((char *)malloc(strlen(s)+1), s)
#endif

View file

@ -111,19 +111,19 @@ extern void Browse();
static int TclPrintLocation(ClientData clientData, static int TclPrintLocation(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]); const char *argv[]);
static int DefaultOutputString(ClientData clientData, static int DefaultOutputString(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]); const char *argv[]);
static int CompareI18NStrings(ClientData clientData, static int CompareI18NStrings(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]); const char *argv[]);
static int TclReadLocaleStrings(ClientData clientData, static int TclReadLocaleStrings(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]); const char *argv[]);
char *GetOutFileBaseName(); char *GetOutFileBaseName();
char * char *
@ -356,12 +356,11 @@ static char *UnEscapeI18NChars(
static int DefaultOutputString(ClientData clientData, static int DefaultOutputString(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]) const char *argv[])
{ {
#define LOCAL_BUFFER_LENGTH 128 char *string = NULL, *pString = NULL;
char *string, *pString, *pArgv; const char *pArgv = NULL;
char localBuffer[LOCAL_BUFFER_LENGTH]; int retCode = 0, stringLength = 0;
int retCode, stringLength;
if (argc < 2) { if (argc < 2) {
Tcl_SetResult(interpreter, "Missing string to output", TCL_VOLATILE); Tcl_SetResult(interpreter, "Missing string to output", TCL_VOLATILE);
@ -377,12 +376,8 @@ static int DefaultOutputString(ClientData clientData,
pArgv = argv[1]; pArgv = argv[1];
stringLength = (2 * strlen(pArgv)) + 3; stringLength = (2 * strlen(pArgv)) + 3;
/* try to use automatic buffer; use malloc if string is too large */ string = malloc(stringLength);
if (stringLength <= LOCAL_BUFFER_LENGTH) { memset(string, 0, stringLength);
string = localBuffer;
} else {
string = malloc(stringLength);
}
pString = string; pString = string;
@ -409,10 +404,7 @@ static int DefaultOutputString(ClientData clientData,
/* put the string to the output */ /* put the string to the output */
retCode = Tcl_VarEval(interpreter, "puts -nonewline ", string, 0); retCode = Tcl_VarEval(interpreter, "puts -nonewline ", string, 0);
/* free the string if we're not using the automatic buffer */ free(string);
if (string != localBuffer) {
free(string);
}
/* and ripple up any error code we got from the "puts" */ /* and ripple up any error code we got from the "puts" */
return retCode; return retCode;
@ -422,7 +414,7 @@ static int DefaultOutputString(ClientData clientData,
static int CompareI18NStrings(ClientData clientData, static int CompareI18NStrings(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]) const char *argv[])
{ {
int ret_val, len; int ret_val, len;
char *ret_string, *cp; char *ret_string, *cp;
@ -492,7 +484,7 @@ static int CompareI18NStrings(ClientData clientData,
static int TclPrintLocation(ClientData clientData, static int TclPrintLocation(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]) const char *argv[])
{ {
if (argc > 1) { if (argc > 1) {
Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE); Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE);
@ -918,26 +910,26 @@ EscapeI18NChars(
static char * static char *
ReadLocaleStrings(char *file_name, int *ret_code) { ReadLocaleStrings(char *file_name, int *ret_code) {
int fd; int fd;
char *pBuf; char *pBuf;
char *i18nBuf; char *i18nBuf;
off_t size; off_t size;
struct stat stat_buf; struct stat stat_buf;
fd = open(file_name, O_RDONLY); fd = open(file_name, O_RDONLY);
if (fd == -1) { if (fd == -1) {
*ret_code = 1; *ret_code = 1;
return ""; return NULL;
} }
fstat(fd, &stat_buf); fstat(fd, &stat_buf);
size = stat_buf.st_size; size = stat_buf.st_size;
pBuf = malloc(size+1); pBuf = Tcl_Alloc(size+1);
pBuf[size] = 0; memset(pBuf, 0, size+1);
if (read(fd, pBuf, size) != size) { if (read(fd, pBuf, size) != size) {
*ret_code = 2; *ret_code = 2;
return ""; return NULL;
} }
i18nBuf = EscapeI18NChars(pBuf); i18nBuf = EscapeI18NChars(pBuf);
@ -952,10 +944,10 @@ struct stat stat_buf;
static int TclReadLocaleStrings(ClientData clientData, static int TclReadLocaleStrings(ClientData clientData,
Tcl_Interp *interp, Tcl_Interp *interp,
int argc, int argc,
char *argv[]) { const char *argv[]) {
char *pBuf; char *pBuf;
int ret_code; int ret_code;
char errorBuf[512]; char errorBuf[512];
if (argc > 2) { if (argc > 2) {
Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE); Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE);

View file

@ -207,7 +207,7 @@ ExpandVariables(
if (*ip == VDELIM && *(ip+1) == L_CURLY && *(ip+2) != '_') { if (*ip == VDELIM && *(ip+1) == L_CURLY && *(ip+2) != '_') {
ip++; ip++;
ip++; /* point at variable name */ ip++; /* point at variable name */
len + 2; len += 2;
vp = vbuf; vp = vbuf;
/* Look for matching (closing) curly. (watch for nesting) /* Look for matching (closing) curly. (watch for nesting)
* We store the variable content in a tmp buffer, so we don't * We store the variable content in a tmp buffer, so we don't
@ -294,9 +294,16 @@ CallInterpreter(
) )
{ {
int result; int result;
char line[20];
int recursive; int recursive;
#if 0
if (ib)
{
fprintf(stderr, "JET: %s: IB = '%s'\n", __FUNCTION__,
ib);
}
#endif
/* save the value of this "e" to be used by Tcl_PrintLocation in /* save the value of this "e" to be used by Tcl_PrintLocation in
* the case of a user error * the case of a user error
*/ */

View file

@ -525,7 +525,7 @@ OutputString(
int track_pos int track_pos
) )
{ {
char c, *sdata, *cp; char c = 0, *sdata, *cp;
static int char_pos; /* remembers our character position */ static int char_pos; /* remembers our character position */
static int interp_pos; /* like char_pos but when output is to interp */ static int interp_pos; /* like char_pos but when output is to interp */
int *ppos; /* points to appropriate line position var */ int *ppos; /* points to appropriate line position var */
@ -678,8 +678,8 @@ static int CheckOutputBuffer(
*/ */
int FFlush(FILE *stream) int FFlush(FILE *stream)
{ {
if (stream) return fflush(stream); if (stream) return fflush(stream);
return 0; return 0;
} }
@ -722,8 +722,8 @@ int Putc(
if (result != TCL_OK) { if (result != TCL_OK) {
fprintf(stderr, fprintf(stderr,
"interpreter error \"%s\" at line %d executing:\n", "interpreter error \"%s\" at line %d executing:\n",
interpreter->result, Tcl_GetStringResult(interpreter),
interpreter->errorLine); Tcl_GetErrorLine(interpreter));
fprintf(stderr, "\"%s\"\n", commandBuf); fprintf(stderr, "\"%s\"\n", commandBuf);
return EOF; return EOF;
} }
@ -787,8 +787,8 @@ int FPuts(
if (result != TCL_OK) { if (result != TCL_OK) {
fprintf(stderr, fprintf(stderr,
"interpreter error \"%s\" at line %d executing:\n", "interpreter error \"%s\" at line %d executing:\n",
interpreter->result, Tcl_GetStringResult(interpreter),
interpreter->errorLine); Tcl_GetErrorLine(interpreter));
fprintf(stderr, "\"%s\"\n", pBuff); fprintf(stderr, "\"%s\"\n", pBuff);
if (pBuff != commandBuf) free(pBuff); if (pBuff != commandBuf) free(pBuff);
return EOF; return EOF;