Fossil SCM
Use our own isspace() function since the standard-library isspace() sometimes gives incorrect results for non-ASCII characters.
Commit
054dd31b715829b7dd0c75f03e0f2c837f3db1c8
Parent
db31a1a51afe011…
1 file changed
+13
-4
+13
-4
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -73,10 +73,19 @@ | ||
| 73 | 73 | #define blob_is_reset(x) \ |
| 74 | 74 | assert((x)->xRealloc!=blobReallocMalloc || (x)->nAlloc==0) |
| 75 | 75 | #else |
| 76 | 76 | #define blob_is_reset(x) |
| 77 | 77 | #endif |
| 78 | + | |
| 79 | +/* | |
| 80 | +** We find that the built-in isspace() function does not work for | |
| 81 | +** some international character sets. So here is a substitute. | |
| 82 | +*/ | |
| 83 | +static int blob_isspace(char c){ | |
| 84 | + return c==' ' || c=='\n' || c=='\t' || | |
| 85 | + c=='\r' || c=='\f' || c=='\v'; | |
| 86 | +} | |
| 78 | 87 | |
| 79 | 88 | /* |
| 80 | 89 | ** This routine is called if a blob operation fails because we |
| 81 | 90 | ** have run out of memory. |
| 82 | 91 | */ |
| @@ -411,11 +420,11 @@ | ||
| 411 | 420 | ** not insert a new zero terminator. |
| 412 | 421 | */ |
| 413 | 422 | int blob_trim(Blob *p){ |
| 414 | 423 | char *z = p->aData; |
| 415 | 424 | int n = p->nUsed; |
| 416 | - while( n>0 && isspace(z[n-1]) ){ n--; } | |
| 425 | + while( n>0 && blob_isspace(z[n-1]) ){ n--; } | |
| 417 | 426 | p->nUsed = n; |
| 418 | 427 | return n; |
| 419 | 428 | } |
| 420 | 429 | |
| 421 | 430 | /* |
| @@ -434,15 +443,15 @@ | ||
| 434 | 443 | */ |
| 435 | 444 | int blob_token(Blob *pFrom, Blob *pTo){ |
| 436 | 445 | char *aData = pFrom->aData; |
| 437 | 446 | int n = pFrom->nUsed; |
| 438 | 447 | int i = pFrom->iCursor; |
| 439 | - while( i<n && isspace(aData[i]) ){ i++; } | |
| 448 | + while( i<n && blob_isspace(aData[i]) ){ i++; } | |
| 440 | 449 | pFrom->iCursor = i; |
| 441 | - while( i<n && !isspace(aData[i]) ){ i++; } | |
| 450 | + while( i<n && !blob_isspace(aData[i]) ){ i++; } | |
| 442 | 451 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 443 | - while( i<n && isspace(aData[i]) ){ i++; } | |
| 452 | + while( i<n && blob_isspace(aData[i]) ){ i++; } | |
| 444 | 453 | pFrom->iCursor = i; |
| 445 | 454 | return pTo->nUsed; |
| 446 | 455 | } |
| 447 | 456 | |
| 448 | 457 | /* |
| 449 | 458 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -73,10 +73,19 @@ | |
| 73 | #define blob_is_reset(x) \ |
| 74 | assert((x)->xRealloc!=blobReallocMalloc || (x)->nAlloc==0) |
| 75 | #else |
| 76 | #define blob_is_reset(x) |
| 77 | #endif |
| 78 | |
| 79 | /* |
| 80 | ** This routine is called if a blob operation fails because we |
| 81 | ** have run out of memory. |
| 82 | */ |
| @@ -411,11 +420,11 @@ | |
| 411 | ** not insert a new zero terminator. |
| 412 | */ |
| 413 | int blob_trim(Blob *p){ |
| 414 | char *z = p->aData; |
| 415 | int n = p->nUsed; |
| 416 | while( n>0 && isspace(z[n-1]) ){ n--; } |
| 417 | p->nUsed = n; |
| 418 | return n; |
| 419 | } |
| 420 | |
| 421 | /* |
| @@ -434,15 +443,15 @@ | |
| 434 | */ |
| 435 | int blob_token(Blob *pFrom, Blob *pTo){ |
| 436 | char *aData = pFrom->aData; |
| 437 | int n = pFrom->nUsed; |
| 438 | int i = pFrom->iCursor; |
| 439 | while( i<n && isspace(aData[i]) ){ i++; } |
| 440 | pFrom->iCursor = i; |
| 441 | while( i<n && !isspace(aData[i]) ){ i++; } |
| 442 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 443 | while( i<n && isspace(aData[i]) ){ i++; } |
| 444 | pFrom->iCursor = i; |
| 445 | return pTo->nUsed; |
| 446 | } |
| 447 | |
| 448 | /* |
| 449 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -73,10 +73,19 @@ | |
| 73 | #define blob_is_reset(x) \ |
| 74 | assert((x)->xRealloc!=blobReallocMalloc || (x)->nAlloc==0) |
| 75 | #else |
| 76 | #define blob_is_reset(x) |
| 77 | #endif |
| 78 | |
| 79 | /* |
| 80 | ** We find that the built-in isspace() function does not work for |
| 81 | ** some international character sets. So here is a substitute. |
| 82 | */ |
| 83 | static int blob_isspace(char c){ |
| 84 | return c==' ' || c=='\n' || c=='\t' || |
| 85 | c=='\r' || c=='\f' || c=='\v'; |
| 86 | } |
| 87 | |
| 88 | /* |
| 89 | ** This routine is called if a blob operation fails because we |
| 90 | ** have run out of memory. |
| 91 | */ |
| @@ -411,11 +420,11 @@ | |
| 420 | ** not insert a new zero terminator. |
| 421 | */ |
| 422 | int blob_trim(Blob *p){ |
| 423 | char *z = p->aData; |
| 424 | int n = p->nUsed; |
| 425 | while( n>0 && blob_isspace(z[n-1]) ){ n--; } |
| 426 | p->nUsed = n; |
| 427 | return n; |
| 428 | } |
| 429 | |
| 430 | /* |
| @@ -434,15 +443,15 @@ | |
| 443 | */ |
| 444 | int blob_token(Blob *pFrom, Blob *pTo){ |
| 445 | char *aData = pFrom->aData; |
| 446 | int n = pFrom->nUsed; |
| 447 | int i = pFrom->iCursor; |
| 448 | while( i<n && blob_isspace(aData[i]) ){ i++; } |
| 449 | pFrom->iCursor = i; |
| 450 | while( i<n && !blob_isspace(aData[i]) ){ i++; } |
| 451 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 452 | while( i<n && blob_isspace(aData[i]) ){ i++; } |
| 453 | pFrom->iCursor = i; |
| 454 | return pTo->nUsed; |
| 455 | } |
| 456 | |
| 457 | /* |
| 458 |