From: Billy G. A. <bal...@us...> - 2001-09-21 03:00:27
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv27936 Modified Files: pgconnection.c Log Message: 20SEP2001 bga [Bug #455514] Modified pgFixEsc to that if will also handle octal escape sequences. If the escape sequence comes in as octal, then a character encoding such as Latin-2 is in use. If the value of the character is > 127, then the escape se- quence is replaced by the actual character. This should fix the reported problem. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pgconnection.c 2001/09/19 03:47:56 1.5 --- pgconnection.c 2001/09/21 03:00:24 1.6 *************** *** 29,32 **** --- 29,38 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 20SEP2001 bga [Bug #455514] Modified pgFixEsc to that if will also | + | handle octal escape sequences. If the escape sequence | + | comes in as octal, then a character encoding such as | + | Latin-2 is in use. If the value of the character is > | + | 127, then the escape sequence is replaced by the actual | + | character. This should fix the reported problem. | | 19SEP2001 bga Re-ordered the items in PgConnection_members so that | | the attributes handled directly by PgConnection_getattr | *************** *** 83,90 **** | seqences in the form '\xNN', PostgreSQL wants them as '\OOO'. | |-----------------------------------------------------------------------| ! | Note: If the value of the escaped charact > 127, then the actual | ! | character is placed in the string. This provides a work-around | ! | for an apparent problem in PostgreSQL. See bug #455514 for de- | ! | tails. | \***********************************************************************/ --- 89,97 ---- | seqences in the form '\xNN', PostgreSQL wants them as '\OOO'. | |-----------------------------------------------------------------------| ! | Note: If the value of the escaped character comes in as octal, then a | ! | character encoding such as Latin-2 is in use. If the value of | ! | the character is > 127, then the escape sequence is replaced by | ! | the actual character. This provides a work-around for an ap- | ! | parent problem in PostgreSQL. See bug #455514 for details. | \***********************************************************************/ *************** *** 93,97 **** char *p, *s, *e; int v; ! char ibuf[3] = "00"; s = p = src; --- 100,105 ---- char *p, *s, *e; int v; ! char obuf[4] = "000"; ! char *xbuf = &obuf[1]; s = p = src; *************** *** 102,124 **** if (*p == 'x' || *p == 'X') { ! if (isxdigit(*(p+1)) && isxdigit(*(p+2))) { ! p++; ! ibuf[0] = *p++; ! ibuf[1] = *p++; ! if ((v = strtol(ibuf, NULL, 16)) < 128) ! { ! s[2] = (v & 7) + '0'; ! v >>= 3; ! s[1] = (v & 7) + '0'; ! v >>= 3; ! s[0] = (v & 7) + '0'; ! s += 3; ! } ! else ! { ! s[-1] = v; ! } } } } --- 110,139 ---- if (*p == 'x' || *p == 'X') { ! p++; ! xbuf[0] = *p++; ! xbuf[1] = *p++; ! v = strtol(xbuf, &e, 16); ! if (e == (xbuf + 2)) { ! s[2] = (v & 7) + '0'; ! v >>= 3; ! s[1] = (v & 7) + '0'; ! v >>= 3; ! s[0] = (v & 7) + '0'; } + s += 3; + } + else if (isdigit(*p)) + { + obuf[0] = *p++; + obuf[1] = *p++; + obuf[2] = *p++; + v = strtol(obuf, &e, 8); + if ((e == (obuf + 3)) && (v > 127)) + { + s[-1] = (char)v; + } + else + s += 3; } } |