Diff
Not logged in

Differences From:

File src/th.c part of check-in [4e683ef07b] - Add the ability to modify global settings (such as the proxy setting) even when there are no repositories defined. by drh on 2008-05-05 17:24:38. [view]

To:

File src/th.c part of check-in [0c99a1554a] - Modify the TH1 script interperter to use native characters rather than unsigned characters. Fix a bug in the combobox extension command of TH1. by drh on 2008-10-24 16:36:34. [view]

@@ -16,9 +16,9 @@
 ** Interpreter structure.
 */
 struct Th_Interp {
   Th_Vtab *pVtab;     /* Copy of the argument passed to Th_CreateInterp() */
-  uchar *zResult;     /* Current interpreter result (Th_Malloc()ed) */
+  char *zResult;     /* Current interpreter result (Th_Malloc()ed) */
   int nResult;        /* number of bytes in zResult */
   Th_Hash *paCmd;     /* Table of registered commands */
   Th_Frame *pFrame;   /* Current execution frame */
   int isListMode;     /* True if thSplitList() should operate in "list" mode */
@@ -29,9 +29,9 @@
 ** by an instance of the following structure stored in the Th_Interp.paCmd
 ** hash-table.
 */
 struct Th_Command {
-  int (*xProc)(Th_Interp *, void *, int, const uchar **, int *);
+  int (*xProc)(Th_Interp *, void *, int, const char **, int *);
   void *pContext;
   void (*xDel)(Th_Interp *, void *);
 };
 
@@ -84,9 +84,9 @@
 */
 struct Th_Variable {
   int nRef;                   /* Number of references to this structure */
   int nData;                  /* Number of bytes at Th_Variable.zData */
-  uchar *zData;               /* Data for scalar variables */
+  char *zData;               /* Data for scalar variables */
   Th_Hash *pHash;             /* Data for array variables */
 };
 
 /*
@@ -96,13 +96,13 @@
 struct Th_Hash {
   Th_HashEntry *a[TH_HASHSIZE];
 };
 
-static int thEvalLocal(Th_Interp *, const uchar *, int);
-static int thSplitList(Th_Interp*, const uchar*, int, uchar***, int **, int*);
-
-static int thHexdigit(uchar c);
-static int thEndOfLine(const uchar *, int);
+static int thEvalLocal(Th_Interp *, const char *, int);
+static int thSplitList(Th_Interp*, const char*, int, char***, int **, int*);
+
+static int thHexdigit(char c);
+static int thEndOfLine(const char *, int);
 
 static int  thPushFrame(Th_Interp*, Th_Frame*);
 static void thPopFrame(Th_Interp*);
 
@@ -124,13 +124,13 @@
 **   thNextVarname(interp, "$a+1", 4, &nByte);
 **
 ** results in nByte being set to 2.
 */
-static int thNextCommand(Th_Interp*, const uchar *z, int n, int *pN);
-static int thNextEscape (Th_Interp*, const uchar *z, int n, int *pN);
-static int thNextVarname(Th_Interp*, const uchar *z, int n, int *pN);
-static int thNextNumber (Th_Interp*, const uchar *z, int n, int *pN);
-static int thNextSpace  (Th_Interp*, const uchar *z, int n, int *pN);
+static int thNextCommand(Th_Interp*, const char *z, int n, int *pN);
+static int thNextEscape (Th_Interp*, const char *z, int n, int *pN);
+static int thNextVarname(Th_Interp*, const char *z, int n, int *pN);
+static int thNextNumber (Th_Interp*, const char *z, int n, int *pN);
+static int thNextSpace  (Th_Interp*, const char *z, int n, int *pN);
 
 /*
 ** Given that the input string (z, n) contains a language construct of
 ** the relevant type (a command enclosed in [], an escape sequence
@@ -137,11 +137,11 @@
 ** like "\xFF" or a variable reference like "${varname}", perform
 ** substitution on the string and store the resulting string in
 ** the interpreter result.
 */
-static int thSubstCommand(Th_Interp*, const uchar *z, int n);
-static int thSubstEscape (Th_Interp*, const uchar *z, int n);
-static int thSubstVarname(Th_Interp*, const uchar *z, int n);
+static int thSubstCommand(Th_Interp*, const char *z, int n);
+static int thSubstEscape (Th_Interp*, const char *z, int n);
+static int thSubstVarname(Th_Interp*, const char *z, int n);
 
 /*
 ** Given that there is a th1 word located at the start of the input
 ** string (z, n), determine the length in bytes of that word. If the
@@ -148,27 +148,27 @@
 ** isCmd argument is non-zero, then an unescaped ";" byte not
 ** located inside of a block or quoted string is considered to mark
 ** the end of the word.
 */
-static int thNextWord(Th_Interp*, const uchar *z, int n, int *pN, int isCmd);
+static int thNextWord(Th_Interp*, const char *z, int n, int *pN, int isCmd);
 
 /*
 ** Perform substitution on the word contained in the input string (z, n).
 ** Store the resulting string in the interpreter result.
 */
-static int thSubstWord(Th_Interp*, const uchar *z, int n);
+static int thSubstWord(Th_Interp*, const char *z, int n);
 
 /*
 ** The Buffer structure and the thBufferXXX() functions are used to make
 ** memory allocation easier when building up a result.
 */
 struct Buffer {
-  uchar *zBuf;
+  char *zBuf;
   int nBuf;
   int nBufAlloc;
 };
 typedef struct Buffer Buffer;
-static int  thBufferWrite(Th_Interp *interp, Buffer *, const uchar *, int);
+static int  thBufferWrite(Th_Interp *interp, Buffer *, const char *, int);
 static void thBufferInit(Buffer *);
 static void thBufferFree(Th_Interp *interp, Buffer *);
 
 /*
@@ -178,9 +178,9 @@
 */
 static int thBufferWrite(
   Th_Interp *interp,
   Buffer *pBuffer,
-  const uchar *zAdd,
+  const char *zAdd,
   int nAdd
 ){
   int nReq;
 
@@ -189,13 +189,13 @@
   }
   nReq = pBuffer->nBuf+nAdd+1;
 
   if( nReq>pBuffer->nBufAlloc ){
-    uchar *zNew;
+    char *zNew;
     int nNew;
 
     nNew = nReq*2;
-    zNew = (uchar *)Th_Malloc(interp, nNew);
+    zNew = (char *)Th_Malloc(interp, nNew);
     memcpy(zNew, pBuffer->zBuf, pBuffer->nBuf);
     Th_Free(interp, pBuffer->zBuf);
     pBuffer->nBufAlloc = nNew;
     pBuffer->zBuf = zNew;
@@ -206,9 +206,9 @@
   pBuffer->zBuf[pBuffer->nBuf] = '\0';
 
   return TH_OK;
 }
-#define thBufferWrite(a,b,c,d) thBufferWrite(a,b,(const uchar *)c,d)
+#define thBufferWrite(a,b,c,d) thBufferWrite(a,b,(const char *)c,d)
 
 /*
 ** Initialize the Buffer structure pointed to by pBuffer.
 */
@@ -229,9 +229,9 @@
 ** Assuming parameter c contains a hexadecimal digit character,
 ** return the corresponding value of that digit. If c is not
 ** a hexadecimal digit character, -1 is returned.
 */
-static int thHexdigit(uchar c){
+static int thHexdigit(char c){
   switch (c) {
     case '0': return 0;
     case '1': return 1;
     case '2': return 2;
@@ -318,9 +318,9 @@
 ** result to an error message. Otherwise return TH_OK.
 */
 static int thNextEscape(
   Th_Interp *interp,
-  const uchar *zInput,
+  const char *zInput,
   int nInput,
   int *pnEscape
 ){
   int i = 2;
@@ -350,9 +350,9 @@
 ** interpreter result to an error message. Otherwise return TH_OK.
 */
 int thNextVarname(
   Th_Interp *interp,
-  const uchar *zInput,
+  const char *zInput,
   int nInput,
   int *pnVarname
 ){
   int i;
@@ -408,9 +408,9 @@
 ** TH_OK.
 */
 int thNextCommand(
   Th_Interp *interp,
-  const uchar *zInput,
+  const char *zInput,
   int nInput,
   int *pnCommand
 ){
   int nBrace = 0;
@@ -443,9 +443,9 @@
 ** input string (zInput, nInput). Always return TH_OK.
 */
 int thNextSpace(
   Th_Interp *interp,
-  const uchar *zInput,
+  const char *zInput,
   int nInput,
   int *pnSpace
 ){
   int i;
@@ -466,9 +466,9 @@
 ** the end of the word.
 */
 static int thNextWord(
   Th_Interp *interp,
-  const uchar *zInput,
+  const char *zInput,
   int nInput,
   int *pnWord,
   int isCmd
 ){
@@ -521,9 +521,9 @@
 ** resulting string in the interpreter result.
 */
 static int thSubstCommand(
   Th_Interp *interp,
-  const uchar *zWord,
+  const char *zWord,
   int nWord
 ){
   assert(nWord>=2);
   assert(zWord[0]=='[' && zWord[nWord-1]==']');
@@ -537,9 +537,9 @@
 ** result.
 */
 static int thSubstVarname(
   Th_Interp *interp,
-  const uchar *zWord,
+  const char *zWord,
   int nWord
 ){
   assert(nWord>=1);
   assert(zWord[0]=='$');
@@ -552,9 +552,9 @@
     for(i=1; i<nWord && zWord[i]!='('; i++);
     if( i<nWord ){
       Buffer varname;
       int nInner;
-      const uchar *zInner;
+      const char *zInner;
 
       int rc = thSubstWord(interp, &zWord[i+1], nWord-i-2);
       if( rc!=TH_OK ) return rc;
 
@@ -577,12 +577,12 @@
 ** string in the interpreter result.
 */
 static int thSubstEscape(
   Th_Interp *interp,
-  const uchar *zWord,
+  const char *zWord,
   int nWord
 ){
-  uchar c;
+  char c;
 
   assert(nWord>=2);
   assert(zWord[0]=='\\');
 
@@ -613,9 +613,9 @@
 ** string in the interpreter result.
 */
 static int thSubstWord(
   Th_Interp *interp,
-  const uchar *zWord,
+  const char *zWord,
   int nWord
 ){
   int rc = TH_OK;
   Buffer output;
@@ -635,10 +635,10 @@
 
     for(i=0; rc==TH_OK && i<nWord; i++){
       int nGet;
 
-      int (*xGet)(Th_Interp *, const uchar*, int, int *) = 0;
-      int (*xSubst)(Th_Interp *, const uchar*, int) = 0;
+      int (*xGet)(Th_Interp *, const char*, int, int *) = 0;
+      int (*xSubst)(Th_Interp *, const char*, int) = 0;
 
       switch( zWord[i] ){
         case '\\':
           xGet = thNextEscape; xSubst = thSubstEscape;
@@ -663,9 +663,9 @@
       if( rc==TH_OK ){
         rc = xSubst(interp, &zWord[i], nGet);
       }
       if( rc==TH_OK ){
-        const uchar *zRes;
+        const char *zRes;
         int nRes;
         zRes = Th_GetResult(interp, &nRes);
         rc = thBufferWrite(interp, &output, zRes, nRes);
         i += (nGet-1);
@@ -690,9 +690,9 @@
 **     newline character.
 **
 ** Otherwise return false.
 */
-static int thEndOfLine(const uchar *zInput, int nInput){
+static int thEndOfLine(const char *zInput, int nInput){
   int i;
   for(i=0; i<nInput && zInput[i]!='\n' && th_isspace(zInput[i]); i++);
   return ((i==nInput || zInput[i]=='\n')?1:0);
 }
@@ -711,9 +711,9 @@
 ** If TH_OK is returned and pazElem is not NULL, the caller should free the
 ** pointer written to (*pazElem) using Th_Free(). This releases memory
 ** allocated for both the (*pazElem) and (*panElem) arrays. Example:
 **
-**     uchar **argv;
+**     char **argv;
 **     int *argl;
 **     int argc;
 **
 **     // After this call, argv and argl point to valid arrays. The
@@ -728,11 +728,11 @@
 **
 */
 static int thSplitList(
   Th_Interp *interp,      /* Interpreter context */
-  const uchar *zList,     /* Pointer to buffer containing input list */
+  const char *zList,     /* Pointer to buffer containing input list */
   int nList,              /* Size of buffer pointed to by zList */
-  uchar ***pazElem,       /* OUT: Array of list elements */
+  char ***pazElem,       /* OUT: Array of list elements */
   int **panElem,          /* OUT: Lengths of each list element */
   int *pnCount            /* OUT: Number of list elements */
 ){
   int rc = TH_OK;
@@ -740,16 +740,16 @@
   Buffer strbuf;
   Buffer lenbuf;
   int nCount = 0;
 
-  const uchar *zInput = zList;
+  const char *zInput = zList;
   int nInput = nList;
 
   thBufferInit(&strbuf);
   thBufferInit(&lenbuf);
 
   while( nInput>0 ){
-    const uchar *zWord;
+    const char *zWord;
     int nWord;
 
     thNextSpace(interp, zInput, nInput, &nWord);
     zInput += nWord;
@@ -774,17 +774,17 @@
 
   assert((pazElem && panElem) || (!pazElem && !panElem));
   if( pazElem && rc==TH_OK ){
     int i;
-    uchar *zElem;
+    char *zElem;
     int *anElem;
-    uchar **azElem = Th_Malloc(interp,
-      sizeof(uchar*) * nCount +      /* azElem */
+    char **azElem = Th_Malloc(interp,
+      sizeof(char*) * nCount +      /* azElem */
       sizeof(int) * nCount +         /* anElem */
       strbuf.nBuf                    /* space for list element strings */
     );
     anElem = (int *)&azElem[nCount];
-    zElem = (uchar *)&anElem[nCount];
+    zElem = (char *)&anElem[nCount];
     memcpy(anElem, lenbuf.zBuf, lenbuf.nBuf);
     memcpy(zElem, strbuf.zBuf, strbuf.nBuf);
     for(i=0; i<nCount;i++){
       azElem[i] = zElem;
@@ -806,19 +806,19 @@
 /*
 ** Evaluate the th1 script contained in the string (zProgram, nProgram)
 ** in the current stack frame.
 */
-static int thEvalLocal(Th_Interp *interp, const uchar *zProgram, int nProgram){
+static int thEvalLocal(Th_Interp *interp, const char *zProgram, int nProgram){
   int rc = TH_OK;
-  const uchar *zInput = zProgram;
+  const char *zInput = zProgram;
   int nInput = nProgram;
 
   while( rc==TH_OK && nInput ){
     Th_HashEntry *pEntry;
     int nSpace;
-    const uchar *zFirst;
-
-    uchar **argv;
+    const char *zFirst;
+
+    char **argv;
     int *argl;
     int argc;
 
     assert(nInput>=0);
@@ -873,25 +873,25 @@
 
       /* Call the command procedure. */
       if( rc==TH_OK ){
         Th_Command *p = (Th_Command *)(pEntry->pData);
-        const uchar **azArg = (const uchar **)argv;
+        const char **azArg = (const char **)argv;
         rc = p->xProc(interp, p->pContext, argc, azArg, argl);
       }
 
       /* If an error occured, add this command to the stack trace report. */
       if( rc==TH_ERROR ){
-        uchar *zRes;
+        char *zRes;
         int nRes;
-        uchar *zStack = 0;
+        char *zStack = 0;
         int nStack = 0;
 
         zRes = Th_TakeResult(interp, &nRes);
-        if( TH_OK==Th_GetVar(interp, (uchar *)"::th_stack_trace", -1) ){
+        if( TH_OK==Th_GetVar(interp, (char *)"::th_stack_trace", -1) ){
           zStack = Th_TakeResult(interp, &nStack);
         }
         Th_ListAppend(interp, &zStack, &nStack, zFirst, zInput-zFirst);
-        Th_SetVar(interp, (uchar *)"::th_stack_trace", -1, zStack, nStack);
+        Th_SetVar(interp, (char *)"::th_stack_trace", -1, zStack, nStack);
         Th_SetResult(interp, zRes, nRes);
         Th_Free(interp, zRes);
         Th_Free(interp, zStack);
       }
@@ -934,9 +934,9 @@
     p = p->pCaller;
   }
 
   if( !p ){
-    uchar *zFrame;
+    char *zFrame;
     int nFrame;
     Th_SetResultInt(interp, iFrame);
     zFrame = Th_TakeResult(interp, &nFrame);
     Th_ErrorMessage(interp, "no such frame:", zFrame, nFrame);
@@ -951,9 +951,9 @@
 ** argument iFrame. Leave either an error message or a result in the
 ** interpreter result and return a th1 error code (TH_OK, TH_ERROR,
 ** TH_RETURN, TH_CONTINUE or TH_BREAK).
 */
-int Th_Eval(Th_Interp *interp, int iFrame, const uchar *zProgram, int nProgram){
+int Th_Eval(Th_Interp *interp, int iFrame, const char *zProgram, int nProgram){
   int rc = TH_OK;
   Th_Frame *pSavedFrame = interp->pFrame;
 
   /* Set Th_Interp.pFrame to the frame that this script is to be
@@ -993,19 +993,19 @@
 ** If it is an array variable, (*pzInner, *pnInner) is set to the
 ** array key name.
 */
 static int thAnalyseVarname(
-  const uchar *zVarname,
+  const char *zVarname,
   int nVarname,
-  const uchar **pzOuter,     /* OUT: Pointer to scalar/array name */
+  const char **pzOuter,     /* OUT: Pointer to scalar/array name */
   int *pnOuter,              /* OUT: Number of bytes at *pzOuter */
-  const uchar **pzInner,     /* OUT: Pointer to array key (or null) */
+  const char **pzInner,     /* OUT: Pointer to array key (or null) */
   int *pnInner,              /* OUT: Number of bytes at *pzInner */
   int *pisGlobal             /* OUT: Set to true if this is a global ref */
 ){
-  const uchar *zOuter = zVarname;
+  const char *zOuter = zVarname;
   int nOuter;
-  const uchar *zInner = 0;
+  const char *zInner = 0;
   int nInner = 0;
   int isGlobal = 0;
   int i;
 
@@ -1057,16 +1057,16 @@
 ** arrayok is true an array name is Ok.
 */
 static Th_Variable *thFindValue(
   Th_Interp *interp,
-  const uchar *zVar,     /* Pointer to variable name */
+  const char *zVar,     /* Pointer to variable name */
   int nVar,              /* Number of bytes at nVar */
   int create,            /* If true, create the variable if not found */
   int arrayok            /* If true, an array is Ok. Othewise array==error */
 ){
-  const uchar *zOuter;
+  const char *zOuter;
   int nOuter;
-  const uchar *zInner;
+  const char *zInner;
   int nInner;
   int isGlobal;
 
   Th_HashEntry *pEntry;
@@ -1135,9 +1135,9 @@
 **
 ** If the named variable does not exist, return TH_ERROR and leave
 ** an error message in the interpreter result.
 */
-int Th_GetVar(Th_Interp *interp, const uchar *zVar, int nVar){
+int Th_GetVar(Th_Interp *interp, const char *zVar, int nVar){
   Th_Variable *pValue;
 
   pValue = thFindValue(interp, zVar, nVar, 0, 0);
   if( !pValue ){
@@ -1160,11 +1160,11 @@
 ** and an error message left in the interpreter result.
 */
 int Th_SetVar(
   Th_Interp *interp,
-  const uchar *zVar,
+  const char *zVar,
   int nVar,
-  const uchar *zValue,
+  const char *zValue,
   int nValue
 ){
   Th_Variable *pValue;
 
@@ -1195,11 +1195,11 @@
 ** the same as accessing variable (zLink, nLink) in stack frame iFrame.
 */
 int Th_LinkVar(
   Th_Interp *interp,                 /* Interpreter */
-  const uchar *zLocal, int nLocal,   /* Local varname */
+  const char *zLocal, int nLocal,   /* Local varname */
   int iFrame,                        /* Stack frame of linked var */
-  const uchar *zLink, int nLink      /* Linked varname */
+  const char *zLink, int nLink      /* Linked varname */
 ){
   Th_Frame *pSavedFrame = interp->pFrame;
   Th_Frame *pFrame;
   Th_HashEntry *pEntry;
@@ -1230,9 +1230,9 @@
 ** an array, or an array member. If the identified variable exists, it
 ** is deleted and TH_OK returned. Otherwise, an error message is left
 ** in the interpreter result and TH_ERROR is returned.
 */
-int Th_UnsetVar(Th_Interp *interp, const uchar *zVar, int nVar){
+int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){
   Th_Variable *pValue;
 
   pValue = thFindValue(interp, zVar, nVar, 1, 1);
   if( !pValue ){
@@ -1253,10 +1253,10 @@
 ** Return an allocated buffer containing a copy of string (z, n). The
 ** caller is responsible for eventually calling Th_Free() to free
 ** the returned buffer.
 */
-uchar *th_strdup(Th_Interp *interp, const uchar *z, int n){
-  uchar *zRes;
+char *th_strdup(Th_Interp *interp, const char *z, int n){
+  char *zRes;
   if( n<0 ){
     n = th_strlen(z);
   }
   zRes = Th_Malloc(interp, n+1);
@@ -1278,22 +1278,21 @@
 **
 **     Th_ErrorMessage(interp, "no such variable:", zVarname, nVarname);
 **
 */
-int Th_ErrorMessage(Th_Interp *interp, const char *zPre, const uchar *z, int n){
+int Th_ErrorMessage(Th_Interp *interp, const char *zPre, const char *z, int n){
   if( interp ){
-    uchar *zRes = 0;
+    char *zRes = 0;
     int nRes = 0;
-    int nPre = th_strlen(zPre);
-
-    Th_SetVar(interp, (uchar *)"::th_stack_trace", -1, 0, 0);
+
+    Th_SetVar(interp, (char *)"::th_stack_trace", -1, 0, 0);
 
     Th_StringAppend(interp, &zRes, &nRes, zPre, -1);
     if( zRes[nRes-1]=='"' ){
       Th_StringAppend(interp, &zRes, &nRes, z, n);
-      Th_StringAppend(interp, &zRes, &nRes, (const uchar *)"\"", 1);
+      Th_StringAppend(interp, &zRes, &nRes, (const char *)"\"", 1);
     }else{
-      Th_StringAppend(interp, &zRes, &nRes, (const uchar *)" ", 1);
+      Th_StringAppend(interp, &zRes, &nRes, (const char *)" ", 1);
       Th_StringAppend(interp, &zRes, &nRes, z, n);
     }
 
     Th_SetResult(interp, zRes, nRes);
@@ -1306,9 +1305,9 @@
 /*
 ** Set the current interpreter result by taking a copy of the buffer
 ** pointed to by z, size n bytes. TH_OK is always returned.
 */
-int Th_SetResult(Th_Interp *pInterp, const uchar *z, int n){
+int Th_SetResult(Th_Interp *pInterp, const char *z, int n){
 
   /* Free the current result */
   Th_Free(pInterp, pInterp->zResult);
   pInterp->zResult = 0;
@@ -1318,9 +1317,9 @@
     n = th_strlen(z);
   }
 
   if( z && n>0 ){
-    uchar *zResult;
+    char *zResult;
     zResult = Th_Malloc(pInterp, n+1);
     memcpy(zResult, z, n);
     zResult[n] = '\0';
     pInterp->zResult = zResult;
@@ -1334,14 +1333,14 @@
 ** Return a pointer to the buffer containing the current interpreter
 ** result. If pN is not NULL, set *pN to the size of the returned
 ** buffer.
 */
-const uchar *Th_GetResult(Th_Interp *pInterp, int *pN){
+const char *Th_GetResult(Th_Interp *pInterp, int *pN){
   assert(pInterp->zResult || pInterp->nResult==0);
   if( pN ){
     *pN = pInterp->nResult;
   }
-  return (pInterp->zResult ? pInterp->zResult : (const uchar *)"");
+  return (pInterp->zResult ? pInterp->zResult : (const char *)"");
 }
 
 /*
 ** Return a pointer to the buffer containing the current interpreter
@@ -1352,19 +1351,19 @@
 ** caller is responsible for eventually calling Th_Free() on the
 ** returned buffer. The internal interpreter result is cleared
 ** after this function is called.
 */
-uchar *Th_TakeResult(Th_Interp *pInterp, int *pN){
+char *Th_TakeResult(Th_Interp *pInterp, int *pN){
   if( pN ){
     *pN = pInterp->nResult;
   }
   if( pInterp->zResult ){
-    uchar *zResult = pInterp->zResult;
+    char *zResult = pInterp->zResult;
     pInterp->zResult = 0;
     pInterp->nResult = 0;
     return zResult;
   }else{
-    return (uchar *)Th_Malloc(pInterp, 1);
+    return (char *)Th_Malloc(pInterp, 1);
   }
 }
 
 
@@ -1398,9 +1397,9 @@
 ){
   Th_HashEntry *pEntry;
   Th_Command *pCommand;
 
-  pEntry = Th_HashFind(interp, interp->paCmd, (const uchar *)zName, -1, 1);
+  pEntry = Th_HashFind(interp, interp->paCmd, (const char *)zName, -1, 1);
   if( pEntry->pData ){
     pCommand = pEntry->pData;
     if( pCommand->xDel ){
       pCommand->xDel(interp, pCommand->pContext);
@@ -1425,11 +1424,11 @@
 ** interpreter result and TH_ERROR is returned.
 */
 int Th_RenameCommand(
   Th_Interp *interp,
-  const uchar *zName,            /* Existing command name */
+  const char *zName,            /* Existing command name */
   int nName,                     /* Number of bytes at zName */
-  const uchar *zNew,             /* New command name */
+  const char *zNew,             /* New command name */
   int nNew                       /* Number of bytes at zNew */
 ){
   Th_HashEntry *pEntry;
   Th_HashEntry *pNewEntry;
@@ -1496,15 +1495,15 @@
 ** Example:
 **
 **     int nElem;
 **     int *anElem;
-**     uchar **azElem;
+**     char **azElem;
 **     int i;
 **
 **     Th_SplitList(interp, zList, nList, &azElem, &anElem, &nElem);
 **     for(i=0; i<nElem; i++){
 **       int nData = anElem[i];
-**       uchar *zData = azElem[i];
+**       char *zData = azElem[i];
 **       ...
 **     }
 **
 **     Th_Free(interp, azElem);
@@ -1511,11 +1510,11 @@
 **
 */
 int Th_SplitList(
   Th_Interp *interp,
-  const uchar *zList,             /* Pointer to buffer containing list */
+  const char *zList,             /* Pointer to buffer containing list */
   int nList,                      /* Number of bytes at zList */
-  uchar ***pazElem,               /* OUT: Array of pointers to element data */
+  char ***pazElem,               /* OUT: Array of pointers to element data */
   int **panElem,                  /* OUT: Array of element data lengths */
   int *pnCount                    /* OUT: Number of elements in list */
 ){
   int rc;
@@ -1542,12 +1541,12 @@
 ** is similarly updated before returning. The return value is always TH_OK.
 **
 ** Example:
 **
-**     uchar *zList = 0;
+**     char *zList = 0;
 **     int nList = 0;
 **     for (...) {
-**       uchar *zElem = <some expression>;
+**       char *zElem = <some expression>;
 **       Th_ListAppend(interp, &zList, &nList, zElem, -1);
 **     }
 **     Th_SetResult(interp, zList, nList);
 **     Th_Free(interp, zList);
@@ -1554,11 +1553,11 @@
 **
 */
 int Th_ListAppend(
   Th_Interp *interp,           /* Interpreter context */
-  uchar **pzList,              /* IN/OUT: Ptr to ptr to list */
+  char **pzList,              /* IN/OUT: Ptr to ptr to list */
   int *pnList,                 /* IN/OUT: Current length of *pzList */
-  const uchar *zElem,          /* Data to append */
+  const char *zElem,          /* Data to append */
   int nElem                    /* Length of nElem */
 ){
   Buffer output;
   int i;
@@ -1578,9 +1577,9 @@
     thBufferWrite(interp, &output, " ", 1);
   }
 
   for(i=0; i<nElem; i++){
-    uchar c = zElem[i];
+    char c = zElem[i];
     if( th_isspecial(c) ) hasSpecialChar = 1;
     if( c=='\\' ) hasEscapeChar = 1;
     if( c=='{' ) nBrace++;
     if( c=='}' ) nBrace--;
@@ -1591,9 +1590,9 @@
     thBufferWrite(interp, &output, zElem, nElem);
     thBufferWrite(interp, &output, "}", 1);
   }else{
     for(i=0; i<nElem; i++){
-      uchar c = zElem[i];
+      char c = zElem[i];
       if( th_isspecial(c) ) thBufferWrite(interp, &output, "\\", 1);
       thBufferWrite(interp, &output, &c, 1);
     }
   }
@@ -1609,14 +1608,14 @@
 ** the same interface as the Th_ListAppend() function.
 */
 int Th_StringAppend(
   Th_Interp *interp,           /* Interpreter context */
-  uchar **pzStr,               /* IN/OUT: Ptr to ptr to list */
+  char **pzStr,               /* IN/OUT: Ptr to ptr to list */
   int *pnStr,                  /* IN/OUT: Current length of *pzStr */
-  const uchar *zElem,          /* Data to append */
+  const char *zElem,          /* Data to append */
   int nElem                    /* Length of nElem */
 ){
-  uchar *zNew;
+  char *zNew;
   int nNew;
 
   if( nElem<0 ){
     nElem = th_strlen(zElem);
@@ -1688,9 +1687,9 @@
   Expr *pParent;
   Expr *pLeft;
   Expr *pRight;
 
-  uchar *zValue;     /* Pointer to literal value */
+  char *zValue;     /* Pointer to literal value */
   int nValue;        /* Length of literal value buffer */
 };
 
 /* Unary operators */
@@ -1779,16 +1778,16 @@
 ** Set *pnVarname to the number of bytes in the numeric string.
 */
 static int thNextNumber(
   Th_Interp *interp,
-  const uchar *zInput,
+  const char *zInput,
   int nInput,
   int *pnLiteral
 ){
   int i;
   int seenDot = 0;
   for(i=0; i<nInput; i++){
-    uchar c = zInput[i];
+    char c = zInput[i];
     if( (seenDot || c!='.') && !th_isdigit(c) ) break;
     if( c=='.' ) seenDot = 1;
   }
   *pnLiteral = i;
@@ -1825,10 +1824,10 @@
     double fLeft;
     double fRight;
 
     /* Left and right arguments as strings */
-    uchar *zLeft = 0; int nLeft;
-    uchar *zRight = 0; int nRight;
+    char *zLeft = 0; int nLeft;
+    char *zRight = 0; int nRight;
 
     /* Evaluate left and right arguments, if they exist. */
     if( pExpr->pLeft ){
       rc = exprEval(interp, pExpr->pLeft);
@@ -2015,9 +2014,9 @@
 ** Parse a string containing a TH expression to a list of tokens.
 */
 static int exprParse(
   Th_Interp *interp,        /* Interpreter to leave error message in */
-  const uchar *zExpr,       /* Pointer to input string */
+  const char *zExpr,       /* Pointer to input string */
   int nExpr,                /* Number of bytes at zExpr */
   Expr ***papToken,         /* OUT: Array of tokens. */
   int *pnToken              /* OUT: Size of token array */
 ){
@@ -2027,14 +2026,14 @@
   int nToken = 0;
   Expr **apToken = 0;
 
   for(i=0; rc==TH_OK && i<nExpr; ){
-    uchar c = zExpr[i];
+    char c = zExpr[i];
     if( th_isspace(c) ){                                /* White-space     */
       i++;
     }else{
       Expr *pNew = (Expr *)Th_Malloc(interp, sizeof(Expr));
-      const uchar *z = &zExpr[i];
+      const char *z = &zExpr[i];
 
       switch (c) {
         case '0': case '1': case '2': case '3': case '4':
         case '5': case '6': case '7': case '8': case '9':
@@ -2070,9 +2069,9 @@
               if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){
                 continue;
               }
             }
-            nOp = th_strlen((const uchar *)aOperator[j].zOp);
+            nOp = th_strlen((const char *)aOperator[j].zOp);
             if( (nExpr-i)>=nOp && 0==memcmp(aOperator[j].zOp, &zExpr[i], nOp) ){
               pNew->pOp = &aOperator[j];
               i += nOp;
               break;
@@ -2116,9 +2115,9 @@
 ** the result in the interpreter interp and return TH_OK if
 ** successful. If an error occurs, store an error message in
 ** the interpreter result and return an error code.
 */
-int Th_Expr(Th_Interp *interp, const uchar *zExpr, int nExpr){
+int Th_Expr(Th_Interp *interp, const char *zExpr, int nExpr){
   int rc;                           /* Return Code */
   int i;                            /* Loop counter */
 
   int nToken = 0;
@@ -2223,9 +2222,9 @@
 */
 Th_HashEntry *Th_HashFind(
   Th_Interp *interp,
   Th_Hash *pHash,
-  const uchar *zKey,
+  const char *zKey,
   int nKey,
   int op                      /* -ve = delete, 0 = find, +ve = insert */
 ){
   unsigned int iKey = 0;
@@ -2255,9 +2254,9 @@
   }
 
   if( op>0 && !pRet ){
     pRet = (Th_HashEntry *)Th_Malloc(interp, sizeof(Th_HashEntry) + nKey);
-    pRet->zKey = (uchar *)&pRet[1];
+    pRet->zKey = (char *)&pRet[1];
     pRet->nKey = nKey;
     memcpy(pRet->zKey, zKey, nKey);
     pRet->pNext = pHash->a[iKey];
     pHash->a[iKey] = pRet;
@@ -2270,9 +2269,9 @@
 ** This function is the same as the standard strlen() function, except
 ** that it returns 0 (instead of being undefined) if the argument is
 ** a null pointer.
 */
-int th_strlen(const unsigned char *zStr){
+int th_strlen(const char *zStr){
   int n = 0;
   if( zStr ){
     while( zStr[n] ) n++;
   }
@@ -2321,25 +2320,25 @@
 
 /*
 ** Clone of the standard isspace() and isdigit function/macros.
 */
-int th_isspace(unsigned char c){
-  return (aCharProp[c] & 0x01);
+int th_isspace(char c){
+  return (aCharProp[(unsigned char)c] & 0x01);
+}
+int th_isdigit(char c){
+  return (aCharProp[(unsigned char)c] & 0x02);
 }
-int th_isdigit(unsigned char c){
-  return (aCharProp[c] & 0x02);
+int th_isspecial(char c){
+  return (aCharProp[(unsigned char)c] & 0x11);
 }
-int th_isspecial(unsigned char c){
-  return (aCharProp[c] & 0x11);
-}
-int th_isalnum(unsigned char c){
-  return (aCharProp[c] & 0x0A);
+int th_isalnum(char c){
+  return (aCharProp[(unsigned char)c] & 0x0A);
 }
 
 #ifndef LONGDOUBLE_TYPE
 # define LONGDOUBLE_TYPE long double
 #endif
-typedef uchar u8;
+typedef char u8;
 
 
 /*
 ** Return TRUE if z is a pure numeric string.  Return FALSE if the
@@ -2447,9 +2446,9 @@
 ** If the string cannot be converted to an integer, return TH_ERROR.
 ** If the interp argument is not NULL, leave an error message in the
 ** interpreter result too.
 */
-int Th_ToInt(Th_Interp *interp, const uchar *z, int n, int *piOut){
+int Th_ToInt(Th_Interp *interp, const char *z, int n, int *piOut){
   int i = 0;
   int iOut = 0;
 
   if( n<0 ){
@@ -2484,9 +2483,9 @@
 ** interpreter result too.
 */
 int Th_ToDouble(
   Th_Interp *interp,
-  const uchar *z,
+  const char *z,
   int n,
   double *pfOut
 ){
   if( !sqlite3IsNumber((const char *)z, 0) ){
@@ -2503,19 +2502,19 @@
 ** the integer iVal and return TH_OK.
 */
 int Th_SetResultInt(Th_Interp *interp, int iVal){
   int isNegative = 0;
-  uchar zBuf[32];
-  uchar *z = &zBuf[32];
+  char zBuf[32];
+  char *z = &zBuf[32];
 
   if( iVal<0 ){
     isNegative = 1;
     iVal = iVal * -1;
   }
   *(--z) = '\0';
-  *(--z) = (uchar)(48+(iVal%10));
+  *(--z) = (char)(48+(iVal%10));
   while( (iVal = (iVal/10))>0 ){
-    *(--z) = (uchar)(48+(iVal%10));
+    *(--z) = (char)(48+(iVal%10));
     assert(z>zBuf);
   }
   if( isNegative ){
     *(--z) = '-';
@@ -2530,13 +2529,13 @@
 */
 int Th_SetResultDouble(Th_Interp *interp, double fVal){
   int i;                /* Iterator variable */
   double v = fVal;      /* Input value */
-  uchar zBuf[128];      /* Output buffer */
-  uchar *z = zBuf;      /* Output cursor */
+  char zBuf[128];      /* Output buffer */
+  char *z = zBuf;      /* Output cursor */
   int iDot = 0;         /* Digit after which to place decimal point */
   int iExp = 0;         /* Exponent (NN in eNN) */
-  const uchar *zExp;    /* String representation of iExp */
+  const char *zExp;    /* String representation of iExp */
 
   /* Precision: */
   #define INSIGNIFICANT 0.000000000001
   #define ROUNDER       0.0000000000005
@@ -2584,9 +2583,9 @@
   /* Output the digits in real value v. The value of iDot determines
    * where (if at all) the decimal point is placed.
    */
   for(i=0; i<=(iDot+1) || v>=insignificant; i++){
-    *z++ = (uchar)(48 + (int)v);
+    *z++ = (char)(48 + (int)v);
     v = (v - ((double)(int)v)) * 10.0;
     insignificant *= 10.0;
     if( iDot==i ){
       *z++ = '.';
@@ -2606,68 +2605,5 @@
   }
 
   *z = '\0';
   return Th_SetResult(interp, zBuf, -1);
-}
-
-/*
-** Set the result of the interpreter to the th1 representation of
-** the pointer p and return TH_OK. The th1 representation can be
-** converted back to a pointer using Th_ToPtr().
-*/
-int Th_SetResultPtr(Th_Interp *interp, void *p){
-  char zBuf[32];
-  char *z;
-  int i;
-  unsigned int v = (unsigned int)p;
-
-  const char zHex[16] = "0123456789ABCDEF";
-
-  assert( sizeof(unsigned int)==sizeof(void *) );
-
-  zBuf[31] = '\0';
-  z = &zBuf[30];
-
-  for(i=0; i<(sizeof(unsigned int)*2); i++){
-    *z-- = zHex[(v&0x0000000F)];
-    v = v>>4;
-  }
-
-  *z-- = 'x';
-  *z = '0';
-
-  return Th_SetResult(interp, (uchar *)z, -1);
-}
-
-/*
-** Convert input string (z, n) to a generic pointer. If the conversion
-** is successful, store the result in *pp and return TH_OK.
-**
-** If the string cannot be converted to a pointer, return TH_ERROR.
-** If the interp argument is not NULL, leave an error message in the
-** interpreter result too.
-*/
-int Th_ToPtr(Th_Interp *interp, const uchar *z, int n, void **pp){
-  unsigned int iPtr;
-  int i;
-  assert(sizeof(unsigned int)==sizeof(void *));
-
-  if( n<3 || z[0]!='0' || z[1]!='x' ){
-    goto error_out;
-  }
-
-  iPtr = 0;
-  for(i=2; i<n; i++){
-    int digit = thHexdigit(z[i]);
-    if( digit<0 ){
-      goto error_out;
-    }
-    iPtr = (iPtr<<4) + digit;
-  }
-
-  *pp = (void *)iPtr;
-  return TH_OK;
-
-error_out:
-  Th_ErrorMessage(interp, "expected pointer, got: \"", z, n);
-  return TH_ERROR;
 }