tcl: use the system version, initial work only on linux for now
authorJon Trulson <jon@radscan.com>
Mon, 17 Sep 2018 19:57:57 +0000 (13:57 -0600)
committerJon Trulson <jon@radscan.com>
Wed, 19 Sep 2018 23:40:25 +0000 (17:40 -0600)
cde/programs/dtdocbook/instant/Imakefile
cde/programs/dtdocbook/instant/general.h
cde/programs/dtdocbook/instant/main.c
cde/programs/dtdocbook/instant/translate.c
cde/programs/dtdocbook/instant/util.c

index 9330fd4df9b6a31d4bb2e6000264e1239a185313..8314e0dd2904d1d5cd9dc0b428f445ae16626a8d 100644 (file)
@@ -2,10 +2,10 @@ XCOMM $XConsortium: Imakefile /main/6 1996/11/29 11:06:09 rswiston $
 
 XLATESRC  = $(DTSVCSRC)/DtUtil2
 
-INCLUDES = -I../lib/tptregexp -I../tcl -I$(XLATESRC)
+INCLUDES = -I../lib/tptregexp -I$(XLATESRC) -I/usr/include/tcl
 DEPLIBS = $(DEPDTSVCLIB)
 LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) \
--L../lib/tptregexp -ltptregexp ../tcl/libtcl.a
+-L../lib/tptregexp -ltptregexp -ltcl
 #if defined(SunArchitecture)
 EXTRA_LIBRARIES = -lsocket -lnsl -lgen -lm
 #else
index c2f360e830ac10480ad69b42a4204a9b74c862f5..413e9aabbc98f1a348acc8342ccb39361aa1e475 100644 (file)
@@ -324,9 +324,3 @@ void                PrintElemTree(Element_t *);
 void           PrintStats(Element_t *);
 void           PrintIDList();
 
-/* ----- other declarations ----- */
-
-#ifdef ultrix
-#define strdup(s)      strcpy((char *)malloc(strlen(s)+1), s)
-#endif
-
index 09554a490882896786aab7f709a83c1b26fbada3..8297cf2a7664a5d7d4eb56145ddff6f3663b0753 100644 (file)
@@ -111,19 +111,19 @@ extern void       Browse();
 static int TclPrintLocation(ClientData clientData,
                            Tcl_Interp *interp,
                            int argc,
-                           char *argv[]);
+                           const char *argv[]);
 static int DefaultOutputString(ClientData clientData,
                               Tcl_Interp *interp,
                               int argc,
-                              char *argv[]);
+                              const char *argv[]);
 static int CompareI18NStrings(ClientData clientData,
                              Tcl_Interp *interp,
                              int argc,
-                             char *argv[]);
+                             const char *argv[]);
 static int TclReadLocaleStrings(ClientData clientData,
                                Tcl_Interp *interp,
                                int argc,
-                               char *argv[]);
+                               const char *argv[]);
 char           *GetOutFileBaseName();
 
 char *
@@ -356,12 +356,11 @@ static char *UnEscapeI18NChars(
 static int DefaultOutputString(ClientData clientData,
                               Tcl_Interp *interp,
                               int argc,
-                              char *argv[])
+                              const char *argv[])
 {
-#define LOCAL_BUFFER_LENGTH 128
-    char *string, *pString, *pArgv;
-    char localBuffer[LOCAL_BUFFER_LENGTH];
-    int retCode, stringLength;
+    char *string = NULL, *pString = NULL;
+    const char *pArgv = NULL;
+    int retCode = 0, stringLength = 0;
 
     if (argc < 2) {
        Tcl_SetResult(interpreter, "Missing string to output", TCL_VOLATILE);
@@ -377,12 +376,8 @@ static int DefaultOutputString(ClientData clientData,
     pArgv = argv[1];
     stringLength = (2 * strlen(pArgv)) + 3;
 
-    /* try to use automatic buffer; use malloc if string is too large */
-    if (stringLength <= LOCAL_BUFFER_LENGTH) {
-       string = localBuffer;
-    } else {
-       string = malloc(stringLength);
-    }
+    string = malloc(stringLength);
+    memset(string, 0, stringLength);
     pString = string;
 
 
@@ -409,10 +404,7 @@ static int DefaultOutputString(ClientData clientData,
     /* put the string to the output */
     retCode = Tcl_VarEval(interpreter, "puts -nonewline ", string, 0);
 
-    /* free the string if we're not using the automatic buffer */
-    if (string != localBuffer) {
-       free(string);
-    }
+    free(string);
 
     /* and ripple up any error code we got from the "puts" */
     return retCode;
@@ -422,7 +414,7 @@ static int DefaultOutputString(ClientData clientData,
 static int CompareI18NStrings(ClientData clientData,
                              Tcl_Interp *interp,
                              int argc,
-                             char *argv[])
+                             const char *argv[])
 {
     int   ret_val, len;
     char *ret_string, *cp;
@@ -492,7 +484,7 @@ static int CompareI18NStrings(ClientData clientData,
 static int TclPrintLocation(ClientData clientData,
                            Tcl_Interp *interp,
                            int argc,
-                           char *argv[])
+                           const char *argv[])
 {
     if (argc > 1) {
        Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE);
@@ -918,26 +910,26 @@ EscapeI18NChars(
 
 static char *
 ReadLocaleStrings(char *file_name, int *ret_code) {
-int          fd;
-char        *pBuf;
-char        *i18nBuf;
-off_t        size;
-struct stat  stat_buf;
+    int          fd;
+    char        *pBuf;
+    char        *i18nBuf;
+    off_t        size;
+    struct stat  stat_buf;
 
     fd = open(file_name, O_RDONLY);
     if (fd == -1) {
        *ret_code = 1;
-       return "";
+       return NULL;
     }
 
     fstat(fd, &stat_buf);
     size = stat_buf.st_size;
-    pBuf = malloc(size+1);
-    pBuf[size] = 0;
+    pBuf = Tcl_Alloc(size+1);
+    memset(pBuf, 0, size+1);
 
     if (read(fd, pBuf, size) != size) {
        *ret_code = 2;
-       return "";
+       return NULL;
     }
 
     i18nBuf = EscapeI18NChars(pBuf);
@@ -952,10 +944,10 @@ struct stat  stat_buf;
 static int TclReadLocaleStrings(ClientData  clientData,
                                Tcl_Interp *interp,
                                int         argc,
-                               char       *argv[]) {
-char *pBuf;
-int   ret_code;
-char  errorBuf[512];
+                               const char       *argv[]) {
+    char *pBuf;
+    int   ret_code;
+    char  errorBuf[512];
 
     if (argc > 2) {
         Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE);
index 987c459db94a364bdb8012737c5c30af283579d2..70e68bd90a1339c3a1adaa96929f35e0b20eb461 100644 (file)
@@ -207,7 +207,7 @@ ExpandVariables(
        if (*ip == VDELIM && *(ip+1) == L_CURLY && *(ip+2) != '_') {
            ip++;
            ip++;               /* point at variable name */
-           len + 2;
+           len += 2;
            vp = vbuf;
            /*  Look for matching (closing) curly. (watch for nesting)
             *  We store the variable content in a tmp buffer, so we don't
@@ -294,9 +294,16 @@ CallInterpreter(
 )
 {
     int result;
-    char line[20];
     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
      * the case of a user error
     */
index fa726e0f77660a2ee7a77f95fddd96af1bda0285..f4b081e2c7fee8ac48a39a23e62fe94eebb6cbbd 100644 (file)
@@ -525,7 +525,7 @@ OutputString(
     int                track_pos
 )
 {
-    char       c, *sdata, *cp;
+    char       c = 0, *sdata, *cp;
     static int char_pos;   /* remembers our character position */
     static int  interp_pos; /* like char_pos but when output is to interp */
     int         *ppos;      /* points to appropriate line position var */
@@ -678,8 +678,8 @@ static int CheckOutputBuffer(
  */
 int FFlush(FILE *stream)
 {
-if (stream) return fflush(stream);
-return 0;
+    if (stream) return fflush(stream);
+    return 0;
 }
 
 
@@ -722,8 +722,8 @@ int Putc(
        if (result != TCL_OK) {
            fprintf(stderr,
                    "interpreter error \"%s\" at line %d executing:\n",
-                   interpreter->result,
-                   interpreter->errorLine);
+                   Tcl_GetStringResult(interpreter),
+                   Tcl_GetErrorLine(interpreter));
            fprintf(stderr, "\"%s\"\n", commandBuf);
            return EOF;
        }
@@ -787,8 +787,8 @@ int FPuts(
        if (result != TCL_OK) {
            fprintf(stderr,
                    "interpreter error \"%s\" at line %d executing:\n",
-                   interpreter->result,
-                   interpreter->errorLine);
+                   Tcl_GetStringResult(interpreter),
+                    Tcl_GetErrorLine(interpreter));
            fprintf(stderr, "\"%s\"\n", pBuff);
            if (pBuff != commandBuf) free(pBuff);
            return EOF;