|
29 | 29 | * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
30 | 30 | * Portions Copyright (c) 1994, Regents of the University of California
|
31 | 31 | *
|
32 |
| - *$Id: pqcomm.c,v 1.130 2002/04/03 00:44:27 tgl Exp $ |
| 32 | + *$Id: pqcomm.c,v 1.131 2002/04/20 23:35:43 petere Exp $ |
33 | 33 | *
|
34 | 34 | *-------------------------------------------------------------------------
|
35 | 35 | */
|
@@ -569,20 +569,37 @@ pq_getbytes(char *s, size_t len)
|
569 | 569 | int
|
570 | 570 | pq_getstring(StringInfos)
|
571 | 571 | {
|
572 |
| -intc; |
| 572 | +inti; |
573 | 573 |
|
574 | 574 | /* Reset string to empty */
|
575 | 575 | s->len=0;
|
576 | 576 | s->data[0]='\0';
|
577 | 577 |
|
578 | 578 | /* Read until we get the terminating '\0' */
|
579 |
| -while ((c=pq_getbyte())!=EOF&&c!='\0') |
580 |
| -appendStringInfoCharMacro(s,c); |
| 579 | +for(;;) |
| 580 | +{ |
| 581 | +while (PqRecvPointer >=PqRecvLength) |
| 582 | +{ |
| 583 | +if (pq_recvbuf())/* If nothing in buffer, then recv some */ |
| 584 | +returnEOF;/* Failed to recv data */ |
| 585 | +} |
581 | 586 |
|
582 |
| -if (c==EOF) |
583 |
| -returnEOF; |
| 587 | +for (i=PqRecvPointer;i<PqRecvLength;i++) |
| 588 | +if (PqRecvBuffer[i]=='\0') |
| 589 | +{ |
| 590 | +/* does not copy the \0 */ |
| 591 | +appendBinaryStringInfo(s,PqRecvBuffer+PqRecvPointer, |
| 592 | +i-PqRecvPointer); |
| 593 | +PqRecvPointer+=i+1; |
| 594 | +return0; |
| 595 | +} |
584 | 596 |
|
585 |
| -return0; |
| 597 | +/* If we're here we haven't got the \0 in the buffer yet. */ |
| 598 | + |
| 599 | +appendBinaryStringInfo(s,PqRecvBuffer+PqRecvPointer, |
| 600 | +PqRecvLength-PqRecvPointer); |
| 601 | +PqRecvPointer=PqRecvLength; |
| 602 | +} |
586 | 603 | }
|
587 | 604 |
|
588 | 605 |
|
|