1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Fix bugs in plpgsql and ecpg caused by assuming that isspace() would only

return true for exactly the characters treated as whitespace by their flex
scanners.  Per report from Victor Snezhko and subsequent investigation.

Also fix a passel of unsafe usages of <ctype.h> functions, that is, ye olde
char-vs-unsigned-char issue.  I won't miss <ctype.h> when we are finally
able to stop using it.
This commit is contained in:
Tom Lane
2006-09-22 21:39:58 +00:00
parent 6d0efd3a09
commit beca984e5f
19 changed files with 112 additions and 61 deletions

View File

@ -27,7 +27,7 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.c,v 1.4 2006/07/19 17:05:50 neilc Exp $ */
/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.c,v 1.5 2006/09/22 21:39:57 tgl Exp $ */
#include "postgres.h"
#include "px.h"
@ -1799,7 +1799,7 @@ mp_result mp_int_read_cstring(mp_int z, mp_size radix, const char *str, char **e
return MP_RANGE;
/* Skip leading whitespace */
while(isspace((int)*str))
while(isspace((unsigned char) *str))
++str;
/* Handle leading sign tag (+/-, positive default) */
@ -3127,10 +3127,10 @@ static int s_ch2val(char c, int r)
{
int out;
if(isdigit((int)c))
if(isdigit((unsigned char)c))
out = c - '0';
else if(r > 10 && isalpha((int)c))
out = toupper(c) - 'A' + 10;
else if(r > 10 && isalpha((unsigned char) c))
out = toupper((unsigned char) c) - 'A' + 10;
else
return -1;
@ -3151,7 +3151,7 @@ static char s_val2ch(int v, int caps)
char out = (v - 10) + 'a';
if(caps)
return toupper(out);
return toupper((unsigned char) out);
else
return out;
}