| | @@ -15,11 +15,11 @@ |
| 15 | 15 | /* |
| 16 | 16 | ** Interpreter structure. |
| 17 | 17 | */ |
| 18 | 18 | struct Th_Interp { |
| 19 | 19 | Th_Vtab *pVtab; /* Copy of the argument passed to Th_CreateInterp() */ |
| 20 | | - uchar *zResult; /* Current interpreter result (Th_Malloc()ed) */ |
| 20 | + char *zResult; /* Current interpreter result (Th_Malloc()ed) */ |
| 21 | 21 | int nResult; /* number of bytes in zResult */ |
| 22 | 22 | Th_Hash *paCmd; /* Table of registered commands */ |
| 23 | 23 | Th_Frame *pFrame; /* Current execution frame */ |
| 24 | 24 | int isListMode; /* True if thSplitList() should operate in "list" mode */ |
| 25 | 25 | }; |
| | @@ -28,11 +28,11 @@ |
| 28 | 28 | ** Each TH command registered using Th_CreateCommand() is represented |
| 29 | 29 | ** by an instance of the following structure stored in the Th_Interp.paCmd |
| 30 | 30 | ** hash-table. |
| 31 | 31 | */ |
| 32 | 32 | struct Th_Command { |
| 33 | | - int (*xProc)(Th_Interp *, void *, int, const uchar **, int *); |
| 33 | + int (*xProc)(Th_Interp *, void *, int, const char **, int *); |
| 34 | 34 | void *pContext; |
| 35 | 35 | void (*xDel)(Th_Interp *, void *); |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | 38 | /* |
| | @@ -83,11 +83,11 @@ |
| 83 | 83 | ** value. |
| 84 | 84 | */ |
| 85 | 85 | struct Th_Variable { |
| 86 | 86 | int nRef; /* Number of references to this structure */ |
| 87 | 87 | int nData; /* Number of bytes at Th_Variable.zData */ |
| 88 | | - uchar *zData; /* Data for scalar variables */ |
| 88 | + char *zData; /* Data for scalar variables */ |
| 89 | 89 | Th_Hash *pHash; /* Data for array variables */ |
| 90 | 90 | }; |
| 91 | 91 | |
| 92 | 92 | /* |
| 93 | 93 | ** Hash table API: |
| | @@ -95,15 +95,15 @@ |
| 95 | 95 | #define TH_HASHSIZE 257 |
| 96 | 96 | struct Th_Hash { |
| 97 | 97 | Th_HashEntry *a[TH_HASHSIZE]; |
| 98 | 98 | }; |
| 99 | 99 | |
| 100 | | -static int thEvalLocal(Th_Interp *, const uchar *, int); |
| 101 | | -static int thSplitList(Th_Interp*, const uchar*, int, uchar***, int **, int*); |
| 100 | +static int thEvalLocal(Th_Interp *, const char *, int); |
| 101 | +static int thSplitList(Th_Interp*, const char*, int, char***, int **, int*); |
| 102 | 102 | |
| 103 | | -static int thHexdigit(uchar c); |
| 104 | | -static int thEndOfLine(const uchar *, int); |
| 103 | +static int thHexdigit(char c); |
| 104 | +static int thEndOfLine(const char *, int); |
| 105 | 105 | |
| 106 | 106 | static int thPushFrame(Th_Interp*, Th_Frame*); |
| 107 | 107 | static void thPopFrame(Th_Interp*); |
| 108 | 108 | |
| 109 | 109 | static void thFreeVariable(Th_HashEntry*, void*); |
| | @@ -123,53 +123,53 @@ |
| 123 | 123 | ** |
| 124 | 124 | ** thNextVarname(interp, "$a+1", 4, &nByte); |
| 125 | 125 | ** |
| 126 | 126 | ** results in nByte being set to 2. |
| 127 | 127 | */ |
| 128 | | -static int thNextCommand(Th_Interp*, const uchar *z, int n, int *pN); |
| 129 | | -static int thNextEscape (Th_Interp*, const uchar *z, int n, int *pN); |
| 130 | | -static int thNextVarname(Th_Interp*, const uchar *z, int n, int *pN); |
| 131 | | -static int thNextNumber (Th_Interp*, const uchar *z, int n, int *pN); |
| 132 | | -static int thNextSpace (Th_Interp*, const uchar *z, int n, int *pN); |
| 128 | +static int thNextCommand(Th_Interp*, const char *z, int n, int *pN); |
| 129 | +static int thNextEscape (Th_Interp*, const char *z, int n, int *pN); |
| 130 | +static int thNextVarname(Th_Interp*, const char *z, int n, int *pN); |
| 131 | +static int thNextNumber (Th_Interp*, const char *z, int n, int *pN); |
| 132 | +static int thNextSpace (Th_Interp*, const char *z, int n, int *pN); |
| 133 | 133 | |
| 134 | 134 | /* |
| 135 | 135 | ** Given that the input string (z, n) contains a language construct of |
| 136 | 136 | ** the relevant type (a command enclosed in [], an escape sequence |
| 137 | 137 | ** like "\xFF" or a variable reference like "${varname}", perform |
| 138 | 138 | ** substitution on the string and store the resulting string in |
| 139 | 139 | ** the interpreter result. |
| 140 | 140 | */ |
| 141 | | -static int thSubstCommand(Th_Interp*, const uchar *z, int n); |
| 142 | | -static int thSubstEscape (Th_Interp*, const uchar *z, int n); |
| 143 | | -static int thSubstVarname(Th_Interp*, const uchar *z, int n); |
| 141 | +static int thSubstCommand(Th_Interp*, const char *z, int n); |
| 142 | +static int thSubstEscape (Th_Interp*, const char *z, int n); |
| 143 | +static int thSubstVarname(Th_Interp*, const char *z, int n); |
| 144 | 144 | |
| 145 | 145 | /* |
| 146 | 146 | ** Given that there is a th1 word located at the start of the input |
| 147 | 147 | ** string (z, n), determine the length in bytes of that word. If the |
| 148 | 148 | ** isCmd argument is non-zero, then an unescaped ";" byte not |
| 149 | 149 | ** located inside of a block or quoted string is considered to mark |
| 150 | 150 | ** the end of the word. |
| 151 | 151 | */ |
| 152 | | -static int thNextWord(Th_Interp*, const uchar *z, int n, int *pN, int isCmd); |
| 152 | +static int thNextWord(Th_Interp*, const char *z, int n, int *pN, int isCmd); |
| 153 | 153 | |
| 154 | 154 | /* |
| 155 | 155 | ** Perform substitution on the word contained in the input string (z, n). |
| 156 | 156 | ** Store the resulting string in the interpreter result. |
| 157 | 157 | */ |
| 158 | | -static int thSubstWord(Th_Interp*, const uchar *z, int n); |
| 158 | +static int thSubstWord(Th_Interp*, const char *z, int n); |
| 159 | 159 | |
| 160 | 160 | /* |
| 161 | 161 | ** The Buffer structure and the thBufferXXX() functions are used to make |
| 162 | 162 | ** memory allocation easier when building up a result. |
| 163 | 163 | */ |
| 164 | 164 | struct Buffer { |
| 165 | | - uchar *zBuf; |
| 165 | + char *zBuf; |
| 166 | 166 | int nBuf; |
| 167 | 167 | int nBufAlloc; |
| 168 | 168 | }; |
| 169 | 169 | typedef struct Buffer Buffer; |
| 170 | | -static int thBufferWrite(Th_Interp *interp, Buffer *, const uchar *, int); |
| 170 | +static int thBufferWrite(Th_Interp *interp, Buffer *, const char *, int); |
| 171 | 171 | static void thBufferInit(Buffer *); |
| 172 | 172 | static void thBufferFree(Th_Interp *interp, Buffer *); |
| 173 | 173 | |
| 174 | 174 | /* |
| 175 | 175 | ** Append nAdd bytes of content copied from zAdd to the end of buffer |
| | @@ -177,11 +177,11 @@ |
| 177 | 177 | ** the allocation to make space. |
| 178 | 178 | */ |
| 179 | 179 | static int thBufferWrite( |
| 180 | 180 | Th_Interp *interp, |
| 181 | 181 | Buffer *pBuffer, |
| 182 | | - const uchar *zAdd, |
| 182 | + const char *zAdd, |
| 183 | 183 | int nAdd |
| 184 | 184 | ){ |
| 185 | 185 | int nReq; |
| 186 | 186 | |
| 187 | 187 | if( nAdd<0 ){ |
| | @@ -188,15 +188,15 @@ |
| 188 | 188 | nAdd = th_strlen(zAdd); |
| 189 | 189 | } |
| 190 | 190 | nReq = pBuffer->nBuf+nAdd+1; |
| 191 | 191 | |
| 192 | 192 | if( nReq>pBuffer->nBufAlloc ){ |
| 193 | | - uchar *zNew; |
| 193 | + char *zNew; |
| 194 | 194 | int nNew; |
| 195 | 195 | |
| 196 | 196 | nNew = nReq*2; |
| 197 | | - zNew = (uchar *)Th_Malloc(interp, nNew); |
| 197 | + zNew = (char *)Th_Malloc(interp, nNew); |
| 198 | 198 | memcpy(zNew, pBuffer->zBuf, pBuffer->nBuf); |
| 199 | 199 | Th_Free(interp, pBuffer->zBuf); |
| 200 | 200 | pBuffer->nBufAlloc = nNew; |
| 201 | 201 | pBuffer->zBuf = zNew; |
| 202 | 202 | } |
| | @@ -205,11 +205,11 @@ |
| 205 | 205 | pBuffer->nBuf += nAdd; |
| 206 | 206 | pBuffer->zBuf[pBuffer->nBuf] = '\0'; |
| 207 | 207 | |
| 208 | 208 | return TH_OK; |
| 209 | 209 | } |
| 210 | | -#define thBufferWrite(a,b,c,d) thBufferWrite(a,b,(const uchar *)c,d) |
| 210 | +#define thBufferWrite(a,b,c,d) thBufferWrite(a,b,(const char *)c,d) |
| 211 | 211 | |
| 212 | 212 | /* |
| 213 | 213 | ** Initialize the Buffer structure pointed to by pBuffer. |
| 214 | 214 | */ |
| 215 | 215 | static void thBufferInit(Buffer *pBuffer){ |
| | @@ -228,11 +228,11 @@ |
| 228 | 228 | /* |
| 229 | 229 | ** Assuming parameter c contains a hexadecimal digit character, |
| 230 | 230 | ** return the corresponding value of that digit. If c is not |
| 231 | 231 | ** a hexadecimal digit character, -1 is returned. |
| 232 | 232 | */ |
| 233 | | -static int thHexdigit(uchar c){ |
| 233 | +static int thHexdigit(char c){ |
| 234 | 234 | switch (c) { |
| 235 | 235 | case '0': return 0; |
| 236 | 236 | case '1': return 1; |
| 237 | 237 | case '2': return 2; |
| 238 | 238 | case '3': return 3; |
| | @@ -317,11 +317,11 @@ |
| 317 | 317 | ** If there is a parse error, return TH_ERROR and set the interpreter |
| 318 | 318 | ** result to an error message. Otherwise return TH_OK. |
| 319 | 319 | */ |
| 320 | 320 | static int thNextEscape( |
| 321 | 321 | Th_Interp *interp, |
| 322 | | - const uchar *zInput, |
| 322 | + const char *zInput, |
| 323 | 323 | int nInput, |
| 324 | 324 | int *pnEscape |
| 325 | 325 | ){ |
| 326 | 326 | int i = 2; |
| 327 | 327 | |
| | @@ -349,11 +349,11 @@ |
| 349 | 349 | ** reference. If there is a parse error, return TH_ERROR and set the |
| 350 | 350 | ** interpreter result to an error message. Otherwise return TH_OK. |
| 351 | 351 | */ |
| 352 | 352 | int thNextVarname( |
| 353 | 353 | Th_Interp *interp, |
| 354 | | - const uchar *zInput, |
| 354 | + const char *zInput, |
| 355 | 355 | int nInput, |
| 356 | 356 | int *pnVarname |
| 357 | 357 | ){ |
| 358 | 358 | int i; |
| 359 | 359 | |
| | @@ -407,11 +407,11 @@ |
| 407 | 407 | ** and set the interpreter result to an error message. Otherwise return |
| 408 | 408 | ** TH_OK. |
| 409 | 409 | */ |
| 410 | 410 | int thNextCommand( |
| 411 | 411 | Th_Interp *interp, |
| 412 | | - const uchar *zInput, |
| 412 | + const char *zInput, |
| 413 | 413 | int nInput, |
| 414 | 414 | int *pnCommand |
| 415 | 415 | ){ |
| 416 | 416 | int nBrace = 0; |
| 417 | 417 | int nSquare = 0; |
| | @@ -442,11 +442,11 @@ |
| 442 | 442 | ** Set *pnSpace to the number of whitespace bytes at the start of |
| 443 | 443 | ** input string (zInput, nInput). Always return TH_OK. |
| 444 | 444 | */ |
| 445 | 445 | int thNextSpace( |
| 446 | 446 | Th_Interp *interp, |
| 447 | | - const uchar *zInput, |
| 447 | + const char *zInput, |
| 448 | 448 | int nInput, |
| 449 | 449 | int *pnSpace |
| 450 | 450 | ){ |
| 451 | 451 | int i; |
| 452 | 452 | for(i=0; i<nInput && th_isspace(zInput[i]); i++); |
| | @@ -465,11 +465,11 @@ |
| 465 | 465 | ** located inside of a block or quoted string is considered to mark |
| 466 | 466 | ** the end of the word. |
| 467 | 467 | */ |
| 468 | 468 | static int thNextWord( |
| 469 | 469 | Th_Interp *interp, |
| 470 | | - const uchar *zInput, |
| 470 | + const char *zInput, |
| 471 | 471 | int nInput, |
| 472 | 472 | int *pnWord, |
| 473 | 473 | int isCmd |
| 474 | 474 | ){ |
| 475 | 475 | int iEnd = 0; |
| | @@ -520,11 +520,11 @@ |
| 520 | 520 | ** a [] block. Perform substitution on the input string and store the |
| 521 | 521 | ** resulting string in the interpreter result. |
| 522 | 522 | */ |
| 523 | 523 | static int thSubstCommand( |
| 524 | 524 | Th_Interp *interp, |
| 525 | | - const uchar *zWord, |
| 525 | + const char *zWord, |
| 526 | 526 | int nWord |
| 527 | 527 | ){ |
| 528 | 528 | assert(nWord>=2); |
| 529 | 529 | assert(zWord[0]=='[' && zWord[nWord-1]==']'); |
| 530 | 530 | return thEvalLocal(interp, &zWord[1], nWord-2); |
| | @@ -536,11 +536,11 @@ |
| 536 | 536 | ** the input string and store the resulting string in the interpreter |
| 537 | 537 | ** result. |
| 538 | 538 | */ |
| 539 | 539 | static int thSubstVarname( |
| 540 | 540 | Th_Interp *interp, |
| 541 | | - const uchar *zWord, |
| 541 | + const char *zWord, |
| 542 | 542 | int nWord |
| 543 | 543 | ){ |
| 544 | 544 | assert(nWord>=1); |
| 545 | 545 | assert(zWord[0]=='$'); |
| 546 | 546 | assert(nWord==1 || zWord[1]!='{' || zWord[nWord-1]=='}'); |
| | @@ -551,11 +551,11 @@ |
| 551 | 551 | int i; |
| 552 | 552 | for(i=1; i<nWord && zWord[i]!='('; i++); |
| 553 | 553 | if( i<nWord ){ |
| 554 | 554 | Buffer varname; |
| 555 | 555 | int nInner; |
| 556 | | - const uchar *zInner; |
| 556 | + const char *zInner; |
| 557 | 557 | |
| 558 | 558 | int rc = thSubstWord(interp, &zWord[i+1], nWord-i-2); |
| 559 | 559 | if( rc!=TH_OK ) return rc; |
| 560 | 560 | |
| 561 | 561 | zInner = Th_GetResult(interp, &nInner); |
| | @@ -576,14 +576,14 @@ |
| 576 | 576 | ** Perform substitution on the input string and store the resulting |
| 577 | 577 | ** string in the interpreter result. |
| 578 | 578 | */ |
| 579 | 579 | static int thSubstEscape( |
| 580 | 580 | Th_Interp *interp, |
| 581 | | - const uchar *zWord, |
| 581 | + const char *zWord, |
| 582 | 582 | int nWord |
| 583 | 583 | ){ |
| 584 | | - uchar c; |
| 584 | + char c; |
| 585 | 585 | |
| 586 | 586 | assert(nWord>=2); |
| 587 | 587 | assert(zWord[0]=='\\'); |
| 588 | 588 | |
| 589 | 589 | switch( zWord[1] ){ |
| | @@ -612,11 +612,11 @@ |
| 612 | 612 | ** substitution on the input string and store the resulting |
| 613 | 613 | ** string in the interpreter result. |
| 614 | 614 | */ |
| 615 | 615 | static int thSubstWord( |
| 616 | 616 | Th_Interp *interp, |
| 617 | | - const uchar *zWord, |
| 617 | + const char *zWord, |
| 618 | 618 | int nWord |
| 619 | 619 | ){ |
| 620 | 620 | int rc = TH_OK; |
| 621 | 621 | Buffer output; |
| 622 | 622 | int i; |
| | @@ -634,12 +634,12 @@ |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | for(i=0; rc==TH_OK && i<nWord; i++){ |
| 637 | 637 | int nGet; |
| 638 | 638 | |
| 639 | | - int (*xGet)(Th_Interp *, const uchar*, int, int *) = 0; |
| 640 | | - int (*xSubst)(Th_Interp *, const uchar*, int) = 0; |
| 639 | + int (*xGet)(Th_Interp *, const char*, int, int *) = 0; |
| 640 | + int (*xSubst)(Th_Interp *, const char*, int) = 0; |
| 641 | 641 | |
| 642 | 642 | switch( zWord[i] ){ |
| 643 | 643 | case '\\': |
| 644 | 644 | xGet = thNextEscape; xSubst = thSubstEscape; |
| 645 | 645 | break; |
| | @@ -662,11 +662,11 @@ |
| 662 | 662 | rc = xGet(interp, &zWord[i], nWord-i, &nGet); |
| 663 | 663 | if( rc==TH_OK ){ |
| 664 | 664 | rc = xSubst(interp, &zWord[i], nGet); |
| 665 | 665 | } |
| 666 | 666 | if( rc==TH_OK ){ |
| 667 | | - const uchar *zRes; |
| 667 | + const char *zRes; |
| 668 | 668 | int nRes; |
| 669 | 669 | zRes = Th_GetResult(interp, &nRes); |
| 670 | 670 | rc = thBufferWrite(interp, &output, zRes, nRes); |
| 671 | 671 | i += (nGet-1); |
| 672 | 672 | } |
| | @@ -689,11 +689,11 @@ |
| 689 | 689 | ** + It contains no non-white-space characters before the first |
| 690 | 690 | ** newline character. |
| 691 | 691 | ** |
| 692 | 692 | ** Otherwise return false. |
| 693 | 693 | */ |
| 694 | | -static int thEndOfLine(const uchar *zInput, int nInput){ |
| 694 | +static int thEndOfLine(const char *zInput, int nInput){ |
| 695 | 695 | int i; |
| 696 | 696 | for(i=0; i<nInput && zInput[i]!='\n' && th_isspace(zInput[i]); i++); |
| 697 | 697 | return ((i==nInput || zInput[i]=='\n')?1:0); |
| 698 | 698 | } |
| 699 | 699 | |
| | @@ -710,11 +710,11 @@ |
| 710 | 710 | ** |
| 711 | 711 | ** If TH_OK is returned and pazElem is not NULL, the caller should free the |
| 712 | 712 | ** pointer written to (*pazElem) using Th_Free(). This releases memory |
| 713 | 713 | ** allocated for both the (*pazElem) and (*panElem) arrays. Example: |
| 714 | 714 | ** |
| 715 | | -** uchar **argv; |
| 715 | +** char **argv; |
| 716 | 716 | ** int *argl; |
| 717 | 717 | ** int argc; |
| 718 | 718 | ** |
| 719 | 719 | ** // After this call, argv and argl point to valid arrays. The |
| 720 | 720 | ** // number of elements in each is argc. |
| | @@ -727,30 +727,30 @@ |
| 727 | 727 | ** Th_Free(interp, argv); |
| 728 | 728 | ** |
| 729 | 729 | */ |
| 730 | 730 | static int thSplitList( |
| 731 | 731 | Th_Interp *interp, /* Interpreter context */ |
| 732 | | - const uchar *zList, /* Pointer to buffer containing input list */ |
| 732 | + const char *zList, /* Pointer to buffer containing input list */ |
| 733 | 733 | int nList, /* Size of buffer pointed to by zList */ |
| 734 | | - uchar ***pazElem, /* OUT: Array of list elements */ |
| 734 | + char ***pazElem, /* OUT: Array of list elements */ |
| 735 | 735 | int **panElem, /* OUT: Lengths of each list element */ |
| 736 | 736 | int *pnCount /* OUT: Number of list elements */ |
| 737 | 737 | ){ |
| 738 | 738 | int rc = TH_OK; |
| 739 | 739 | |
| 740 | 740 | Buffer strbuf; |
| 741 | 741 | Buffer lenbuf; |
| 742 | 742 | int nCount = 0; |
| 743 | 743 | |
| 744 | | - const uchar *zInput = zList; |
| 744 | + const char *zInput = zList; |
| 745 | 745 | int nInput = nList; |
| 746 | 746 | |
| 747 | 747 | thBufferInit(&strbuf); |
| 748 | 748 | thBufferInit(&lenbuf); |
| 749 | 749 | |
| 750 | 750 | while( nInput>0 ){ |
| 751 | | - const uchar *zWord; |
| 751 | + const char *zWord; |
| 752 | 752 | int nWord; |
| 753 | 753 | |
| 754 | 754 | thNextSpace(interp, zInput, nInput, &nWord); |
| 755 | 755 | zInput += nWord; |
| 756 | 756 | nInput = nList-(zInput-zList); |
| | @@ -773,19 +773,19 @@ |
| 773 | 773 | assert((lenbuf.nBuf/sizeof(int))==nCount); |
| 774 | 774 | |
| 775 | 775 | assert((pazElem && panElem) || (!pazElem && !panElem)); |
| 776 | 776 | if( pazElem && rc==TH_OK ){ |
| 777 | 777 | int i; |
| 778 | | - uchar *zElem; |
| 778 | + char *zElem; |
| 779 | 779 | int *anElem; |
| 780 | | - uchar **azElem = Th_Malloc(interp, |
| 781 | | - sizeof(uchar*) * nCount + /* azElem */ |
| 780 | + char **azElem = Th_Malloc(interp, |
| 781 | + sizeof(char*) * nCount + /* azElem */ |
| 782 | 782 | sizeof(int) * nCount + /* anElem */ |
| 783 | 783 | strbuf.nBuf /* space for list element strings */ |
| 784 | 784 | ); |
| 785 | 785 | anElem = (int *)&azElem[nCount]; |
| 786 | | - zElem = (uchar *)&anElem[nCount]; |
| 786 | + zElem = (char *)&anElem[nCount]; |
| 787 | 787 | memcpy(anElem, lenbuf.zBuf, lenbuf.nBuf); |
| 788 | 788 | memcpy(zElem, strbuf.zBuf, strbuf.nBuf); |
| 789 | 789 | for(i=0; i<nCount;i++){ |
| 790 | 790 | azElem[i] = zElem; |
| 791 | 791 | zElem += (anElem[i] + 1); |
| | @@ -805,21 +805,21 @@ |
| 805 | 805 | |
| 806 | 806 | /* |
| 807 | 807 | ** Evaluate the th1 script contained in the string (zProgram, nProgram) |
| 808 | 808 | ** in the current stack frame. |
| 809 | 809 | */ |
| 810 | | -static int thEvalLocal(Th_Interp *interp, const uchar *zProgram, int nProgram){ |
| 810 | +static int thEvalLocal(Th_Interp *interp, const char *zProgram, int nProgram){ |
| 811 | 811 | int rc = TH_OK; |
| 812 | | - const uchar *zInput = zProgram; |
| 812 | + const char *zInput = zProgram; |
| 813 | 813 | int nInput = nProgram; |
| 814 | 814 | |
| 815 | 815 | while( rc==TH_OK && nInput ){ |
| 816 | 816 | Th_HashEntry *pEntry; |
| 817 | 817 | int nSpace; |
| 818 | | - const uchar *zFirst; |
| 818 | + const char *zFirst; |
| 819 | 819 | |
| 820 | | - uchar **argv; |
| 820 | + char **argv; |
| 821 | 821 | int *argl; |
| 822 | 822 | int argc; |
| 823 | 823 | |
| 824 | 824 | assert(nInput>=0); |
| 825 | 825 | |
| | @@ -872,27 +872,27 @@ |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | /* Call the command procedure. */ |
| 875 | 875 | if( rc==TH_OK ){ |
| 876 | 876 | Th_Command *p = (Th_Command *)(pEntry->pData); |
| 877 | | - const uchar **azArg = (const uchar **)argv; |
| 877 | + const char **azArg = (const char **)argv; |
| 878 | 878 | rc = p->xProc(interp, p->pContext, argc, azArg, argl); |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /* If an error occured, add this command to the stack trace report. */ |
| 882 | 882 | if( rc==TH_ERROR ){ |
| 883 | | - uchar *zRes; |
| 883 | + char *zRes; |
| 884 | 884 | int nRes; |
| 885 | | - uchar *zStack = 0; |
| 885 | + char *zStack = 0; |
| 886 | 886 | int nStack = 0; |
| 887 | 887 | |
| 888 | 888 | zRes = Th_TakeResult(interp, &nRes); |
| 889 | | - if( TH_OK==Th_GetVar(interp, (uchar *)"::th_stack_trace", -1) ){ |
| 889 | + if( TH_OK==Th_GetVar(interp, (char *)"::th_stack_trace", -1) ){ |
| 890 | 890 | zStack = Th_TakeResult(interp, &nStack); |
| 891 | 891 | } |
| 892 | 892 | Th_ListAppend(interp, &zStack, &nStack, zFirst, zInput-zFirst); |
| 893 | | - Th_SetVar(interp, (uchar *)"::th_stack_trace", -1, zStack, nStack); |
| 893 | + Th_SetVar(interp, (char *)"::th_stack_trace", -1, zStack, nStack); |
| 894 | 894 | Th_SetResult(interp, zRes, nRes); |
| 895 | 895 | Th_Free(interp, zRes); |
| 896 | 896 | Th_Free(interp, zStack); |
| 897 | 897 | } |
| 898 | 898 | } |
| | @@ -933,11 +933,11 @@ |
| 933 | 933 | for(i=0; p && i<(iFrame*-1); i++){ |
| 934 | 934 | p = p->pCaller; |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | if( !p ){ |
| 938 | | - uchar *zFrame; |
| 938 | + char *zFrame; |
| 939 | 939 | int nFrame; |
| 940 | 940 | Th_SetResultInt(interp, iFrame); |
| 941 | 941 | zFrame = Th_TakeResult(interp, &nFrame); |
| 942 | 942 | Th_ErrorMessage(interp, "no such frame:", zFrame, nFrame); |
| 943 | 943 | Th_Free(interp, zFrame); |
| | @@ -950,11 +950,11 @@ |
| 950 | 950 | ** Evaluate th1 script (zProgram, nProgram) in the frame identified by |
| 951 | 951 | ** argument iFrame. Leave either an error message or a result in the |
| 952 | 952 | ** interpreter result and return a th1 error code (TH_OK, TH_ERROR, |
| 953 | 953 | ** TH_RETURN, TH_CONTINUE or TH_BREAK). |
| 954 | 954 | */ |
| 955 | | -int Th_Eval(Th_Interp *interp, int iFrame, const uchar *zProgram, int nProgram){ |
| 955 | +int Th_Eval(Th_Interp *interp, int iFrame, const char *zProgram, int nProgram){ |
| 956 | 956 | int rc = TH_OK; |
| 957 | 957 | Th_Frame *pSavedFrame = interp->pFrame; |
| 958 | 958 | |
| 959 | 959 | /* Set Th_Interp.pFrame to the frame that this script is to be |
| 960 | 960 | ** evaluated in. The current frame is saved in pSavedFrame and will |
| | @@ -992,21 +992,21 @@ |
| 992 | 992 | ** array variable. If the variable is a scalar, *pzInner is set to 0. |
| 993 | 993 | ** If it is an array variable, (*pzInner, *pnInner) is set to the |
| 994 | 994 | ** array key name. |
| 995 | 995 | */ |
| 996 | 996 | static int thAnalyseVarname( |
| 997 | | - const uchar *zVarname, |
| 997 | + const char *zVarname, |
| 998 | 998 | int nVarname, |
| 999 | | - const uchar **pzOuter, /* OUT: Pointer to scalar/array name */ |
| 999 | + const char **pzOuter, /* OUT: Pointer to scalar/array name */ |
| 1000 | 1000 | int *pnOuter, /* OUT: Number of bytes at *pzOuter */ |
| 1001 | | - const uchar **pzInner, /* OUT: Pointer to array key (or null) */ |
| 1001 | + const char **pzInner, /* OUT: Pointer to array key (or null) */ |
| 1002 | 1002 | int *pnInner, /* OUT: Number of bytes at *pzInner */ |
| 1003 | 1003 | int *pisGlobal /* OUT: Set to true if this is a global ref */ |
| 1004 | 1004 | ){ |
| 1005 | | - const uchar *zOuter = zVarname; |
| 1005 | + const char *zOuter = zVarname; |
| 1006 | 1006 | int nOuter; |
| 1007 | | - const uchar *zInner = 0; |
| 1007 | + const char *zInner = 0; |
| 1008 | 1008 | int nInner = 0; |
| 1009 | 1009 | int isGlobal = 0; |
| 1010 | 1010 | int i; |
| 1011 | 1011 | |
| 1012 | 1012 | if( nVarname<0 ){ |
| | @@ -1056,18 +1056,18 @@ |
| 1056 | 1056 | ** an error is left in the interpreter result and NULL returned. If |
| 1057 | 1057 | ** arrayok is true an array name is Ok. |
| 1058 | 1058 | */ |
| 1059 | 1059 | static Th_Variable *thFindValue( |
| 1060 | 1060 | Th_Interp *interp, |
| 1061 | | - const uchar *zVar, /* Pointer to variable name */ |
| 1061 | + const char *zVar, /* Pointer to variable name */ |
| 1062 | 1062 | int nVar, /* Number of bytes at nVar */ |
| 1063 | 1063 | int create, /* If true, create the variable if not found */ |
| 1064 | 1064 | int arrayok /* If true, an array is Ok. Othewise array==error */ |
| 1065 | 1065 | ){ |
| 1066 | | - const uchar *zOuter; |
| 1066 | + const char *zOuter; |
| 1067 | 1067 | int nOuter; |
| 1068 | | - const uchar *zInner; |
| 1068 | + const char *zInner; |
| 1069 | 1069 | int nInner; |
| 1070 | 1070 | int isGlobal; |
| 1071 | 1071 | |
| 1072 | 1072 | Th_HashEntry *pEntry; |
| 1073 | 1073 | Th_Frame *pFrame = interp->pFrame; |
| | @@ -1134,11 +1134,11 @@ |
| 1134 | 1134 | ** the interpreter result and return TH_OK. |
| 1135 | 1135 | ** |
| 1136 | 1136 | ** If the named variable does not exist, return TH_ERROR and leave |
| 1137 | 1137 | ** an error message in the interpreter result. |
| 1138 | 1138 | */ |
| 1139 | | -int Th_GetVar(Th_Interp *interp, const uchar *zVar, int nVar){ |
| 1139 | +int Th_GetVar(Th_Interp *interp, const char *zVar, int nVar){ |
| 1140 | 1140 | Th_Variable *pValue; |
| 1141 | 1141 | |
| 1142 | 1142 | pValue = thFindValue(interp, zVar, nVar, 0, 0); |
| 1143 | 1143 | if( !pValue ){ |
| 1144 | 1144 | return TH_ERROR; |
| | @@ -1159,13 +1159,13 @@ |
| 1159 | 1159 | ** If (zVar, nVar) refers to an existing array, TH_ERROR is returned |
| 1160 | 1160 | ** and an error message left in the interpreter result. |
| 1161 | 1161 | */ |
| 1162 | 1162 | int Th_SetVar( |
| 1163 | 1163 | Th_Interp *interp, |
| 1164 | | - const uchar *zVar, |
| 1164 | + const char *zVar, |
| 1165 | 1165 | int nVar, |
| 1166 | | - const uchar *zValue, |
| 1166 | + const char *zValue, |
| 1167 | 1167 | int nValue |
| 1168 | 1168 | ){ |
| 1169 | 1169 | Th_Variable *pValue; |
| 1170 | 1170 | |
| 1171 | 1171 | pValue = thFindValue(interp, zVar, nVar, 1, 0); |
| | @@ -1194,13 +1194,13 @@ |
| 1194 | 1194 | ** Create a variable link so that accessing variable (zLocal, nLocal) is |
| 1195 | 1195 | ** the same as accessing variable (zLink, nLink) in stack frame iFrame. |
| 1196 | 1196 | */ |
| 1197 | 1197 | int Th_LinkVar( |
| 1198 | 1198 | Th_Interp *interp, /* Interpreter */ |
| 1199 | | - const uchar *zLocal, int nLocal, /* Local varname */ |
| 1199 | + const char *zLocal, int nLocal, /* Local varname */ |
| 1200 | 1200 | int iFrame, /* Stack frame of linked var */ |
| 1201 | | - const uchar *zLink, int nLink /* Linked varname */ |
| 1201 | + const char *zLink, int nLink /* Linked varname */ |
| 1202 | 1202 | ){ |
| 1203 | 1203 | Th_Frame *pSavedFrame = interp->pFrame; |
| 1204 | 1204 | Th_Frame *pFrame; |
| 1205 | 1205 | Th_HashEntry *pEntry; |
| 1206 | 1206 | Th_Variable *pValue; |
| | @@ -1229,11 +1229,11 @@ |
| 1229 | 1229 | ** Input string (zVar, nVar) must contain the name of a scalar variable, |
| 1230 | 1230 | ** an array, or an array member. If the identified variable exists, it |
| 1231 | 1231 | ** is deleted and TH_OK returned. Otherwise, an error message is left |
| 1232 | 1232 | ** in the interpreter result and TH_ERROR is returned. |
| 1233 | 1233 | */ |
| 1234 | | -int Th_UnsetVar(Th_Interp *interp, const uchar *zVar, int nVar){ |
| 1234 | +int Th_UnsetVar(Th_Interp *interp, const char *zVar, int nVar){ |
| 1235 | 1235 | Th_Variable *pValue; |
| 1236 | 1236 | |
| 1237 | 1237 | pValue = thFindValue(interp, zVar, nVar, 1, 1); |
| 1238 | 1238 | if( !pValue ){ |
| 1239 | 1239 | return TH_ERROR; |
| | @@ -1252,12 +1252,12 @@ |
| 1252 | 1252 | /* |
| 1253 | 1253 | ** Return an allocated buffer containing a copy of string (z, n). The |
| 1254 | 1254 | ** caller is responsible for eventually calling Th_Free() to free |
| 1255 | 1255 | ** the returned buffer. |
| 1256 | 1256 | */ |
| 1257 | | -uchar *th_strdup(Th_Interp *interp, const uchar *z, int n){ |
| 1258 | | - uchar *zRes; |
| 1257 | +char *th_strdup(Th_Interp *interp, const char *z, int n){ |
| 1258 | + char *zRes; |
| 1259 | 1259 | if( n<0 ){ |
| 1260 | 1260 | n = th_strlen(z); |
| 1261 | 1261 | } |
| 1262 | 1262 | zRes = Th_Malloc(interp, n+1); |
| 1263 | 1263 | memcpy(zRes, z, n); |
| | @@ -1277,24 +1277,23 @@ |
| 1277 | 1277 | ** Example: |
| 1278 | 1278 | ** |
| 1279 | 1279 | ** Th_ErrorMessage(interp, "no such variable:", zVarname, nVarname); |
| 1280 | 1280 | ** |
| 1281 | 1281 | */ |
| 1282 | | -int Th_ErrorMessage(Th_Interp *interp, const char *zPre, const uchar *z, int n){ |
| 1282 | +int Th_ErrorMessage(Th_Interp *interp, const char *zPre, const char *z, int n){ |
| 1283 | 1283 | if( interp ){ |
| 1284 | | - uchar *zRes = 0; |
| 1284 | + char *zRes = 0; |
| 1285 | 1285 | int nRes = 0; |
| 1286 | | - int nPre = th_strlen(zPre); |
| 1287 | 1286 | |
| 1288 | | - Th_SetVar(interp, (uchar *)"::th_stack_trace", -1, 0, 0); |
| 1287 | + Th_SetVar(interp, (char *)"::th_stack_trace", -1, 0, 0); |
| 1289 | 1288 | |
| 1290 | 1289 | Th_StringAppend(interp, &zRes, &nRes, zPre, -1); |
| 1291 | 1290 | if( zRes[nRes-1]=='"' ){ |
| 1292 | 1291 | Th_StringAppend(interp, &zRes, &nRes, z, n); |
| 1293 | | - Th_StringAppend(interp, &zRes, &nRes, (const uchar *)"\"", 1); |
| 1292 | + Th_StringAppend(interp, &zRes, &nRes, (const char *)"\"", 1); |
| 1294 | 1293 | }else{ |
| 1295 | | - Th_StringAppend(interp, &zRes, &nRes, (const uchar *)" ", 1); |
| 1294 | + Th_StringAppend(interp, &zRes, &nRes, (const char *)" ", 1); |
| 1296 | 1295 | Th_StringAppend(interp, &zRes, &nRes, z, n); |
| 1297 | 1296 | } |
| 1298 | 1297 | |
| 1299 | 1298 | Th_SetResult(interp, zRes, nRes); |
| 1300 | 1299 | Th_Free(interp, zRes); |
| | @@ -1305,11 +1304,11 @@ |
| 1305 | 1304 | |
| 1306 | 1305 | /* |
| 1307 | 1306 | ** Set the current interpreter result by taking a copy of the buffer |
| 1308 | 1307 | ** pointed to by z, size n bytes. TH_OK is always returned. |
| 1309 | 1308 | */ |
| 1310 | | -int Th_SetResult(Th_Interp *pInterp, const uchar *z, int n){ |
| 1309 | +int Th_SetResult(Th_Interp *pInterp, const char *z, int n){ |
| 1311 | 1310 | |
| 1312 | 1311 | /* Free the current result */ |
| 1313 | 1312 | Th_Free(pInterp, pInterp->zResult); |
| 1314 | 1313 | pInterp->zResult = 0; |
| 1315 | 1314 | pInterp->nResult = 0; |
| | @@ -1317,11 +1316,11 @@ |
| 1317 | 1316 | if( n<0 ){ |
| 1318 | 1317 | n = th_strlen(z); |
| 1319 | 1318 | } |
| 1320 | 1319 | |
| 1321 | 1320 | if( z && n>0 ){ |
| 1322 | | - uchar *zResult; |
| 1321 | + char *zResult; |
| 1323 | 1322 | zResult = Th_Malloc(pInterp, n+1); |
| 1324 | 1323 | memcpy(zResult, z, n); |
| 1325 | 1324 | zResult[n] = '\0'; |
| 1326 | 1325 | pInterp->zResult = zResult; |
| 1327 | 1326 | pInterp->nResult = n; |
| | @@ -1333,16 +1332,16 @@ |
| 1333 | 1332 | /* |
| 1334 | 1333 | ** Return a pointer to the buffer containing the current interpreter |
| 1335 | 1334 | ** result. If pN is not NULL, set *pN to the size of the returned |
| 1336 | 1335 | ** buffer. |
| 1337 | 1336 | */ |
| 1338 | | -const uchar *Th_GetResult(Th_Interp *pInterp, int *pN){ |
| 1337 | +const char *Th_GetResult(Th_Interp *pInterp, int *pN){ |
| 1339 | 1338 | assert(pInterp->zResult || pInterp->nResult==0); |
| 1340 | 1339 | if( pN ){ |
| 1341 | 1340 | *pN = pInterp->nResult; |
| 1342 | 1341 | } |
| 1343 | | - return (pInterp->zResult ? pInterp->zResult : (const uchar *)""); |
| 1342 | + return (pInterp->zResult ? pInterp->zResult : (const char *)""); |
| 1344 | 1343 | } |
| 1345 | 1344 | |
| 1346 | 1345 | /* |
| 1347 | 1346 | ** Return a pointer to the buffer containing the current interpreter |
| 1348 | 1347 | ** result. If pN is not NULL, set *pN to the size of the returned |
| | @@ -1351,21 +1350,21 @@ |
| 1351 | 1350 | ** This function is the same as Th_GetResult() except that the |
| 1352 | 1351 | ** caller is responsible for eventually calling Th_Free() on the |
| 1353 | 1352 | ** returned buffer. The internal interpreter result is cleared |
| 1354 | 1353 | ** after this function is called. |
| 1355 | 1354 | */ |
| 1356 | | -uchar *Th_TakeResult(Th_Interp *pInterp, int *pN){ |
| 1355 | +char *Th_TakeResult(Th_Interp *pInterp, int *pN){ |
| 1357 | 1356 | if( pN ){ |
| 1358 | 1357 | *pN = pInterp->nResult; |
| 1359 | 1358 | } |
| 1360 | 1359 | if( pInterp->zResult ){ |
| 1361 | | - uchar *zResult = pInterp->zResult; |
| 1360 | + char *zResult = pInterp->zResult; |
| 1362 | 1361 | pInterp->zResult = 0; |
| 1363 | 1362 | pInterp->nResult = 0; |
| 1364 | 1363 | return zResult; |
| 1365 | 1364 | }else{ |
| 1366 | | - return (uchar *)Th_Malloc(pInterp, 1); |
| 1365 | + return (char *)Th_Malloc(pInterp, 1); |
| 1367 | 1366 | } |
| 1368 | 1367 | } |
| 1369 | 1368 | |
| 1370 | 1369 | |
| 1371 | 1370 | /* |
| | @@ -1397,11 +1396,11 @@ |
| 1397 | 1396 | void (*xDel)(Th_Interp *, void *) /* Command destructor callback */ |
| 1398 | 1397 | ){ |
| 1399 | 1398 | Th_HashEntry *pEntry; |
| 1400 | 1399 | Th_Command *pCommand; |
| 1401 | 1400 | |
| 1402 | | - pEntry = Th_HashFind(interp, interp->paCmd, (const uchar *)zName, -1, 1); |
| 1401 | + pEntry = Th_HashFind(interp, interp->paCmd, (const char *)zName, -1, 1); |
| 1403 | 1402 | if( pEntry->pData ){ |
| 1404 | 1403 | pCommand = pEntry->pData; |
| 1405 | 1404 | if( pCommand->xDel ){ |
| 1406 | 1405 | pCommand->xDel(interp, pCommand->pContext); |
| 1407 | 1406 | } |
| | @@ -1424,13 +1423,13 @@ |
| 1424 | 1423 | ** if command zNew already exists, an error message is left in the |
| 1425 | 1424 | ** interpreter result and TH_ERROR is returned. |
| 1426 | 1425 | */ |
| 1427 | 1426 | int Th_RenameCommand( |
| 1428 | 1427 | Th_Interp *interp, |
| 1429 | | - const uchar *zName, /* Existing command name */ |
| 1428 | + const char *zName, /* Existing command name */ |
| 1430 | 1429 | int nName, /* Number of bytes at zName */ |
| 1431 | | - const uchar *zNew, /* New command name */ |
| 1430 | + const char *zNew, /* New command name */ |
| 1432 | 1431 | int nNew /* Number of bytes at zNew */ |
| 1433 | 1432 | ){ |
| 1434 | 1433 | Th_HashEntry *pEntry; |
| 1435 | 1434 | Th_HashEntry *pNewEntry; |
| 1436 | 1435 | |
| | @@ -1495,28 +1494,28 @@ |
| 1495 | 1494 | ** |
| 1496 | 1495 | ** Example: |
| 1497 | 1496 | ** |
| 1498 | 1497 | ** int nElem; |
| 1499 | 1498 | ** int *anElem; |
| 1500 | | -** uchar **azElem; |
| 1499 | +** char **azElem; |
| 1501 | 1500 | ** int i; |
| 1502 | 1501 | ** |
| 1503 | 1502 | ** Th_SplitList(interp, zList, nList, &azElem, &anElem, &nElem); |
| 1504 | 1503 | ** for(i=0; i<nElem; i++){ |
| 1505 | 1504 | ** int nData = anElem[i]; |
| 1506 | | -** uchar *zData = azElem[i]; |
| 1505 | +** char *zData = azElem[i]; |
| 1507 | 1506 | ** ... |
| 1508 | 1507 | ** } |
| 1509 | 1508 | ** |
| 1510 | 1509 | ** Th_Free(interp, azElem); |
| 1511 | 1510 | ** |
| 1512 | 1511 | */ |
| 1513 | 1512 | int Th_SplitList( |
| 1514 | 1513 | Th_Interp *interp, |
| 1515 | | - const uchar *zList, /* Pointer to buffer containing list */ |
| 1514 | + const char *zList, /* Pointer to buffer containing list */ |
| 1516 | 1515 | int nList, /* Number of bytes at zList */ |
| 1517 | | - uchar ***pazElem, /* OUT: Array of pointers to element data */ |
| 1516 | + char ***pazElem, /* OUT: Array of pointers to element data */ |
| 1518 | 1517 | int **panElem, /* OUT: Array of element data lengths */ |
| 1519 | 1518 | int *pnCount /* OUT: Number of elements in list */ |
| 1520 | 1519 | ){ |
| 1521 | 1520 | int rc; |
| 1522 | 1521 | interp->isListMode = 1; |
| | @@ -1541,25 +1540,25 @@ |
| 1541 | 1540 | ** *pzList to point to a new buffer containing the new list value. *pnList |
| 1542 | 1541 | ** is similarly updated before returning. The return value is always TH_OK. |
| 1543 | 1542 | ** |
| 1544 | 1543 | ** Example: |
| 1545 | 1544 | ** |
| 1546 | | -** uchar *zList = 0; |
| 1545 | +** char *zList = 0; |
| 1547 | 1546 | ** int nList = 0; |
| 1548 | 1547 | ** for (...) { |
| 1549 | | -** uchar *zElem = <some expression>; |
| 1548 | +** char *zElem = <some expression>; |
| 1550 | 1549 | ** Th_ListAppend(interp, &zList, &nList, zElem, -1); |
| 1551 | 1550 | ** } |
| 1552 | 1551 | ** Th_SetResult(interp, zList, nList); |
| 1553 | 1552 | ** Th_Free(interp, zList); |
| 1554 | 1553 | ** |
| 1555 | 1554 | */ |
| 1556 | 1555 | int Th_ListAppend( |
| 1557 | 1556 | Th_Interp *interp, /* Interpreter context */ |
| 1558 | | - uchar **pzList, /* IN/OUT: Ptr to ptr to list */ |
| 1557 | + char **pzList, /* IN/OUT: Ptr to ptr to list */ |
| 1559 | 1558 | int *pnList, /* IN/OUT: Current length of *pzList */ |
| 1560 | | - const uchar *zElem, /* Data to append */ |
| 1559 | + const char *zElem, /* Data to append */ |
| 1561 | 1560 | int nElem /* Length of nElem */ |
| 1562 | 1561 | ){ |
| 1563 | 1562 | Buffer output; |
| 1564 | 1563 | int i; |
| 1565 | 1564 | |
| | @@ -1577,11 +1576,11 @@ |
| 1577 | 1576 | if( output.nBuf>0 ){ |
| 1578 | 1577 | thBufferWrite(interp, &output, " ", 1); |
| 1579 | 1578 | } |
| 1580 | 1579 | |
| 1581 | 1580 | for(i=0; i<nElem; i++){ |
| 1582 | | - uchar c = zElem[i]; |
| 1581 | + char c = zElem[i]; |
| 1583 | 1582 | if( th_isspecial(c) ) hasSpecialChar = 1; |
| 1584 | 1583 | if( c=='\\' ) hasEscapeChar = 1; |
| 1585 | 1584 | if( c=='{' ) nBrace++; |
| 1586 | 1585 | if( c=='}' ) nBrace--; |
| 1587 | 1586 | } |
| | @@ -1590,11 +1589,11 @@ |
| 1590 | 1589 | thBufferWrite(interp, &output, "{", 1); |
| 1591 | 1590 | thBufferWrite(interp, &output, zElem, nElem); |
| 1592 | 1591 | thBufferWrite(interp, &output, "}", 1); |
| 1593 | 1592 | }else{ |
| 1594 | 1593 | for(i=0; i<nElem; i++){ |
| 1595 | | - uchar c = zElem[i]; |
| 1594 | + char c = zElem[i]; |
| 1596 | 1595 | if( th_isspecial(c) ) thBufferWrite(interp, &output, "\\", 1); |
| 1597 | 1596 | thBufferWrite(interp, &output, &c, 1); |
| 1598 | 1597 | } |
| 1599 | 1598 | } |
| 1600 | 1599 | |
| | @@ -1608,16 +1607,16 @@ |
| 1608 | 1607 | ** Append a new element to an existing th1 string. This function uses |
| 1609 | 1608 | ** the same interface as the Th_ListAppend() function. |
| 1610 | 1609 | */ |
| 1611 | 1610 | int Th_StringAppend( |
| 1612 | 1611 | Th_Interp *interp, /* Interpreter context */ |
| 1613 | | - uchar **pzStr, /* IN/OUT: Ptr to ptr to list */ |
| 1612 | + char **pzStr, /* IN/OUT: Ptr to ptr to list */ |
| 1614 | 1613 | int *pnStr, /* IN/OUT: Current length of *pzStr */ |
| 1615 | | - const uchar *zElem, /* Data to append */ |
| 1614 | + const char *zElem, /* Data to append */ |
| 1616 | 1615 | int nElem /* Length of nElem */ |
| 1617 | 1616 | ){ |
| 1618 | | - uchar *zNew; |
| 1617 | + char *zNew; |
| 1619 | 1618 | int nNew; |
| 1620 | 1619 | |
| 1621 | 1620 | if( nElem<0 ){ |
| 1622 | 1621 | nElem = th_strlen(zElem); |
| 1623 | 1622 | } |
| | @@ -1687,11 +1686,11 @@ |
| 1687 | 1686 | Operator *pOp; |
| 1688 | 1687 | Expr *pParent; |
| 1689 | 1688 | Expr *pLeft; |
| 1690 | 1689 | Expr *pRight; |
| 1691 | 1690 | |
| 1692 | | - uchar *zValue; /* Pointer to literal value */ |
| 1691 | + char *zValue; /* Pointer to literal value */ |
| 1693 | 1692 | int nValue; /* Length of literal value buffer */ |
| 1694 | 1693 | }; |
| 1695 | 1694 | |
| 1696 | 1695 | /* Unary operators */ |
| 1697 | 1696 | #define OP_UNARY_MINUS 2 |
| | @@ -1778,18 +1777,18 @@ |
| 1778 | 1777 | ** The first part of the string (zInput,nInput) contains a number. |
| 1779 | 1778 | ** Set *pnVarname to the number of bytes in the numeric string. |
| 1780 | 1779 | */ |
| 1781 | 1780 | static int thNextNumber( |
| 1782 | 1781 | Th_Interp *interp, |
| 1783 | | - const uchar *zInput, |
| 1782 | + const char *zInput, |
| 1784 | 1783 | int nInput, |
| 1785 | 1784 | int *pnLiteral |
| 1786 | 1785 | ){ |
| 1787 | 1786 | int i; |
| 1788 | 1787 | int seenDot = 0; |
| 1789 | 1788 | for(i=0; i<nInput; i++){ |
| 1790 | | - uchar c = zInput[i]; |
| 1789 | + char c = zInput[i]; |
| 1791 | 1790 | if( (seenDot || c!='.') && !th_isdigit(c) ) break; |
| 1792 | 1791 | if( c=='.' ) seenDot = 1; |
| 1793 | 1792 | } |
| 1794 | 1793 | *pnLiteral = i; |
| 1795 | 1794 | return TH_OK; |
| | @@ -1824,12 +1823,12 @@ |
| 1824 | 1823 | int iRight; |
| 1825 | 1824 | double fLeft; |
| 1826 | 1825 | double fRight; |
| 1827 | 1826 | |
| 1828 | 1827 | /* Left and right arguments as strings */ |
| 1829 | | - uchar *zLeft = 0; int nLeft; |
| 1830 | | - uchar *zRight = 0; int nRight; |
| 1828 | + char *zLeft = 0; int nLeft; |
| 1829 | + char *zRight = 0; int nRight; |
| 1831 | 1830 | |
| 1832 | 1831 | /* Evaluate left and right arguments, if they exist. */ |
| 1833 | 1832 | if( pExpr->pLeft ){ |
| 1834 | 1833 | rc = exprEval(interp, pExpr->pLeft); |
| 1835 | 1834 | if( rc==TH_OK ){ |
| | @@ -2014,11 +2013,11 @@ |
| 2014 | 2013 | /* |
| 2015 | 2014 | ** Parse a string containing a TH expression to a list of tokens. |
| 2016 | 2015 | */ |
| 2017 | 2016 | static int exprParse( |
| 2018 | 2017 | Th_Interp *interp, /* Interpreter to leave error message in */ |
| 2019 | | - const uchar *zExpr, /* Pointer to input string */ |
| 2018 | + const char *zExpr, /* Pointer to input string */ |
| 2020 | 2019 | int nExpr, /* Number of bytes at zExpr */ |
| 2021 | 2020 | Expr ***papToken, /* OUT: Array of tokens. */ |
| 2022 | 2021 | int *pnToken /* OUT: Size of token array */ |
| 2023 | 2022 | ){ |
| 2024 | 2023 | int i; |
| | @@ -2026,16 +2025,16 @@ |
| 2026 | 2025 | int rc = TH_OK; |
| 2027 | 2026 | int nToken = 0; |
| 2028 | 2027 | Expr **apToken = 0; |
| 2029 | 2028 | |
| 2030 | 2029 | for(i=0; rc==TH_OK && i<nExpr; ){ |
| 2031 | | - uchar c = zExpr[i]; |
| 2030 | + char c = zExpr[i]; |
| 2032 | 2031 | if( th_isspace(c) ){ /* White-space */ |
| 2033 | 2032 | i++; |
| 2034 | 2033 | }else{ |
| 2035 | 2034 | Expr *pNew = (Expr *)Th_Malloc(interp, sizeof(Expr)); |
| 2036 | | - const uchar *z = &zExpr[i]; |
| 2035 | + const char *z = &zExpr[i]; |
| 2037 | 2036 | |
| 2038 | 2037 | switch (c) { |
| 2039 | 2038 | case '0': case '1': case '2': case '3': case '4': |
| 2040 | 2039 | case '5': case '6': case '7': case '8': case '9': |
| 2041 | 2040 | thNextNumber(interp, z, nExpr-i, &pNew->nValue); |
| | @@ -2069,11 +2068,11 @@ |
| 2069 | 2068 | Expr *pPrev = apToken[nToken-1]; |
| 2070 | 2069 | if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){ |
| 2071 | 2070 | continue; |
| 2072 | 2071 | } |
| 2073 | 2072 | } |
| 2074 | | - nOp = th_strlen((const uchar *)aOperator[j].zOp); |
| 2073 | + nOp = th_strlen((const char *)aOperator[j].zOp); |
| 2075 | 2074 | if( (nExpr-i)>=nOp && 0==memcmp(aOperator[j].zOp, &zExpr[i], nOp) ){ |
| 2076 | 2075 | pNew->pOp = &aOperator[j]; |
| 2077 | 2076 | i += nOp; |
| 2078 | 2077 | break; |
| 2079 | 2078 | } |
| | @@ -2115,11 +2114,11 @@ |
| 2115 | 2114 | ** Evaluate the string (zExpr, nExpr) as a Th expression. Store |
| 2116 | 2115 | ** the result in the interpreter interp and return TH_OK if |
| 2117 | 2116 | ** successful. If an error occurs, store an error message in |
| 2118 | 2117 | ** the interpreter result and return an error code. |
| 2119 | 2118 | */ |
| 2120 | | -int Th_Expr(Th_Interp *interp, const uchar *zExpr, int nExpr){ |
| 2119 | +int Th_Expr(Th_Interp *interp, const char *zExpr, int nExpr){ |
| 2121 | 2120 | int rc; /* Return Code */ |
| 2122 | 2121 | int i; /* Loop counter */ |
| 2123 | 2122 | |
| 2124 | 2123 | int nToken = 0; |
| 2125 | 2124 | Expr **apToken = 0; |
| | @@ -2222,11 +2221,11 @@ |
| 2222 | 2221 | ** not already present in the hash-table. |
| 2223 | 2222 | */ |
| 2224 | 2223 | Th_HashEntry *Th_HashFind( |
| 2225 | 2224 | Th_Interp *interp, |
| 2226 | 2225 | Th_Hash *pHash, |
| 2227 | | - const uchar *zKey, |
| 2226 | + const char *zKey, |
| 2228 | 2227 | int nKey, |
| 2229 | 2228 | int op /* -ve = delete, 0 = find, +ve = insert */ |
| 2230 | 2229 | ){ |
| 2231 | 2230 | unsigned int iKey = 0; |
| 2232 | 2231 | int i; |
| | @@ -2254,11 +2253,11 @@ |
| 2254 | 2253 | pRet = 0; |
| 2255 | 2254 | } |
| 2256 | 2255 | |
| 2257 | 2256 | if( op>0 && !pRet ){ |
| 2258 | 2257 | pRet = (Th_HashEntry *)Th_Malloc(interp, sizeof(Th_HashEntry) + nKey); |
| 2259 | | - pRet->zKey = (uchar *)&pRet[1]; |
| 2258 | + pRet->zKey = (char *)&pRet[1]; |
| 2260 | 2259 | pRet->nKey = nKey; |
| 2261 | 2260 | memcpy(pRet->zKey, zKey, nKey); |
| 2262 | 2261 | pRet->pNext = pHash->a[iKey]; |
| 2263 | 2262 | pHash->a[iKey] = pRet; |
| 2264 | 2263 | } |
| | @@ -2269,11 +2268,11 @@ |
| 2269 | 2268 | /* |
| 2270 | 2269 | ** This function is the same as the standard strlen() function, except |
| 2271 | 2270 | ** that it returns 0 (instead of being undefined) if the argument is |
| 2272 | 2271 | ** a null pointer. |
| 2273 | 2272 | */ |
| 2274 | | -int th_strlen(const unsigned char *zStr){ |
| 2273 | +int th_strlen(const char *zStr){ |
| 2275 | 2274 | int n = 0; |
| 2276 | 2275 | if( zStr ){ |
| 2277 | 2276 | while( zStr[n] ) n++; |
| 2278 | 2277 | } |
| 2279 | 2278 | return n; |
| | @@ -2320,27 +2319,27 @@ |
| 2320 | 2319 | }; |
| 2321 | 2320 | |
| 2322 | 2321 | /* |
| 2323 | 2322 | ** Clone of the standard isspace() and isdigit function/macros. |
| 2324 | 2323 | */ |
| 2325 | | -int th_isspace(unsigned char c){ |
| 2326 | | - return (aCharProp[c] & 0x01); |
| 2327 | | -} |
| 2328 | | -int th_isdigit(unsigned char c){ |
| 2329 | | - return (aCharProp[c] & 0x02); |
| 2330 | | -} |
| 2331 | | -int th_isspecial(unsigned char c){ |
| 2332 | | - return (aCharProp[c] & 0x11); |
| 2333 | | -} |
| 2334 | | -int th_isalnum(unsigned char c){ |
| 2335 | | - return (aCharProp[c] & 0x0A); |
| 2324 | +int th_isspace(char c){ |
| 2325 | + return (aCharProp[(unsigned char)c] & 0x01); |
| 2326 | +} |
| 2327 | +int th_isdigit(char c){ |
| 2328 | + return (aCharProp[(unsigned char)c] & 0x02); |
| 2329 | +} |
| 2330 | +int th_isspecial(char c){ |
| 2331 | + return (aCharProp[(unsigned char)c] & 0x11); |
| 2332 | +} |
| 2333 | +int th_isalnum(char c){ |
| 2334 | + return (aCharProp[(unsigned char)c] & 0x0A); |
| 2336 | 2335 | } |
| 2337 | 2336 | |
| 2338 | 2337 | #ifndef LONGDOUBLE_TYPE |
| 2339 | 2338 | # define LONGDOUBLE_TYPE long double |
| 2340 | 2339 | #endif |
| 2341 | | -typedef uchar u8; |
| 2340 | +typedef char u8; |
| 2342 | 2341 | |
| 2343 | 2342 | |
| 2344 | 2343 | /* |
| 2345 | 2344 | ** Return TRUE if z is a pure numeric string. Return FALSE if the |
| 2346 | 2345 | ** string contains any character which is not part of a number. If |
| | @@ -2446,11 +2445,11 @@ |
| 2446 | 2445 | ** |
| 2447 | 2446 | ** If the string cannot be converted to an integer, return TH_ERROR. |
| 2448 | 2447 | ** If the interp argument is not NULL, leave an error message in the |
| 2449 | 2448 | ** interpreter result too. |
| 2450 | 2449 | */ |
| 2451 | | -int Th_ToInt(Th_Interp *interp, const uchar *z, int n, int *piOut){ |
| 2450 | +int Th_ToInt(Th_Interp *interp, const char *z, int n, int *piOut){ |
| 2452 | 2451 | int i = 0; |
| 2453 | 2452 | int iOut = 0; |
| 2454 | 2453 | |
| 2455 | 2454 | if( n<0 ){ |
| 2456 | 2455 | n = th_strlen(z); |
| | @@ -2483,11 +2482,11 @@ |
| 2483 | 2482 | ** If the interp argument is not NULL, leave an error message in the |
| 2484 | 2483 | ** interpreter result too. |
| 2485 | 2484 | */ |
| 2486 | 2485 | int Th_ToDouble( |
| 2487 | 2486 | Th_Interp *interp, |
| 2488 | | - const uchar *z, |
| 2487 | + const char *z, |
| 2489 | 2488 | int n, |
| 2490 | 2489 | double *pfOut |
| 2491 | 2490 | ){ |
| 2492 | 2491 | if( !sqlite3IsNumber((const char *)z, 0) ){ |
| 2493 | 2492 | Th_ErrorMessage(interp, "expected number, got: \"", z, n); |
| | @@ -2502,21 +2501,21 @@ |
| 2502 | 2501 | ** Set the result of the interpreter to the th1 representation of |
| 2503 | 2502 | ** the integer iVal and return TH_OK. |
| 2504 | 2503 | */ |
| 2505 | 2504 | int Th_SetResultInt(Th_Interp *interp, int iVal){ |
| 2506 | 2505 | int isNegative = 0; |
| 2507 | | - uchar zBuf[32]; |
| 2508 | | - uchar *z = &zBuf[32]; |
| 2506 | + char zBuf[32]; |
| 2507 | + char *z = &zBuf[32]; |
| 2509 | 2508 | |
| 2510 | 2509 | if( iVal<0 ){ |
| 2511 | 2510 | isNegative = 1; |
| 2512 | 2511 | iVal = iVal * -1; |
| 2513 | 2512 | } |
| 2514 | 2513 | *(--z) = '\0'; |
| 2515 | | - *(--z) = (uchar)(48+(iVal%10)); |
| 2514 | + *(--z) = (char)(48+(iVal%10)); |
| 2516 | 2515 | while( (iVal = (iVal/10))>0 ){ |
| 2517 | | - *(--z) = (uchar)(48+(iVal%10)); |
| 2516 | + *(--z) = (char)(48+(iVal%10)); |
| 2518 | 2517 | assert(z>zBuf); |
| 2519 | 2518 | } |
| 2520 | 2519 | if( isNegative ){ |
| 2521 | 2520 | *(--z) = '-'; |
| 2522 | 2521 | } |
| | @@ -2529,15 +2528,15 @@ |
| 2529 | 2528 | ** the double fVal and return TH_OK. |
| 2530 | 2529 | */ |
| 2531 | 2530 | int Th_SetResultDouble(Th_Interp *interp, double fVal){ |
| 2532 | 2531 | int i; /* Iterator variable */ |
| 2533 | 2532 | double v = fVal; /* Input value */ |
| 2534 | | - uchar zBuf[128]; /* Output buffer */ |
| 2535 | | - uchar *z = zBuf; /* Output cursor */ |
| 2533 | + char zBuf[128]; /* Output buffer */ |
| 2534 | + char *z = zBuf; /* Output cursor */ |
| 2536 | 2535 | int iDot = 0; /* Digit after which to place decimal point */ |
| 2537 | 2536 | int iExp = 0; /* Exponent (NN in eNN) */ |
| 2538 | | - const uchar *zExp; /* String representation of iExp */ |
| 2537 | + const char *zExp; /* String representation of iExp */ |
| 2539 | 2538 | |
| 2540 | 2539 | /* Precision: */ |
| 2541 | 2540 | #define INSIGNIFICANT 0.000000000001 |
| 2542 | 2541 | #define ROUNDER 0.0000000000005 |
| 2543 | 2542 | double insignificant = INSIGNIFICANT; |
| | @@ -2583,11 +2582,11 @@ |
| 2583 | 2582 | |
| 2584 | 2583 | /* Output the digits in real value v. The value of iDot determines |
| 2585 | 2584 | * where (if at all) the decimal point is placed. |
| 2586 | 2585 | */ |
| 2587 | 2586 | for(i=0; i<=(iDot+1) || v>=insignificant; i++){ |
| 2588 | | - *z++ = (uchar)(48 + (int)v); |
| 2587 | + *z++ = (char)(48 + (int)v); |
| 2589 | 2588 | v = (v - ((double)(int)v)) * 10.0; |
| 2590 | 2589 | insignificant *= 10.0; |
| 2591 | 2590 | if( iDot==i ){ |
| 2592 | 2591 | *z++ = '.'; |
| 2593 | 2592 | } |
| | @@ -2606,68 +2605,5 @@ |
| 2606 | 2605 | } |
| 2607 | 2606 | |
| 2608 | 2607 | *z = '\0'; |
| 2609 | 2608 | return Th_SetResult(interp, zBuf, -1); |
| 2610 | 2609 | } |
| 2611 | | - |
| 2612 | | -/* |
| 2613 | | -** Set the result of the interpreter to the th1 representation of |
| 2614 | | -** the pointer p and return TH_OK. The th1 representation can be |
| 2615 | | -** converted back to a pointer using Th_ToPtr(). |
| 2616 | | -*/ |
| 2617 | | -int Th_SetResultPtr(Th_Interp *interp, void *p){ |
| 2618 | | - char zBuf[32]; |
| 2619 | | - char *z; |
| 2620 | | - int i; |
| 2621 | | - unsigned int v = (unsigned int)p; |
| 2622 | | - |
| 2623 | | - const char zHex[16] = "0123456789ABCDEF"; |
| 2624 | | - |
| 2625 | | - assert( sizeof(unsigned int)==sizeof(void *) ); |
| 2626 | | - |
| 2627 | | - zBuf[31] = '\0'; |
| 2628 | | - z = &zBuf[30]; |
| 2629 | | - |
| 2630 | | - for(i=0; i<(sizeof(unsigned int)*2); i++){ |
| 2631 | | - *z-- = zHex[(v&0x0000000F)]; |
| 2632 | | - v = v>>4; |
| 2633 | | - } |
| 2634 | | - |
| 2635 | | - *z-- = 'x'; |
| 2636 | | - *z = '0'; |
| 2637 | | - |
| 2638 | | - return Th_SetResult(interp, (uchar *)z, -1); |
| 2639 | | -} |
| 2640 | | - |
| 2641 | | -/* |
| 2642 | | -** Convert input string (z, n) to a generic pointer. If the conversion |
| 2643 | | -** is successful, store the result in *pp and return TH_OK. |
| 2644 | | -** |
| 2645 | | -** If the string cannot be converted to a pointer, return TH_ERROR. |
| 2646 | | -** If the interp argument is not NULL, leave an error message in the |
| 2647 | | -** interpreter result too. |
| 2648 | | -*/ |
| 2649 | | -int Th_ToPtr(Th_Interp *interp, const uchar *z, int n, void **pp){ |
| 2650 | | - unsigned int iPtr; |
| 2651 | | - int i; |
| 2652 | | - assert(sizeof(unsigned int)==sizeof(void *)); |
| 2653 | | - |
| 2654 | | - if( n<3 || z[0]!='0' || z[1]!='x' ){ |
| 2655 | | - goto error_out; |
| 2656 | | - } |
| 2657 | | - |
| 2658 | | - iPtr = 0; |
| 2659 | | - for(i=2; i<n; i++){ |
| 2660 | | - int digit = thHexdigit(z[i]); |
| 2661 | | - if( digit<0 ){ |
| 2662 | | - goto error_out; |
| 2663 | | - } |
| 2664 | | - iPtr = (iPtr<<4) + digit; |
| 2665 | | - } |
| 2666 | | - |
| 2667 | | - *pp = (void *)iPtr; |
| 2668 | | - return TH_OK; |
| 2669 | | - |
| 2670 | | -error_out: |
| 2671 | | - Th_ErrorMessage(interp, "expected pointer, got: \"", z, n); |
| 2672 | | - return TH_ERROR; |
| 2673 | | -} |
| 2674 | 2610 | |