Re: long strings
Joe Orton <[email protected]>
| Newsgroups | gmane.comp.web.sitecopy |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Oct 15, 2004 at 11:43:22AM +0300, Eugene Tumachoff wrote:
> I'm using sitecopy Windows port. And I just noticed that long strings in the
> text files that are longer than 1024 bytes just splits by two parts!
> Is it right?
Nope, that's a bug, thanks for the report. Can you try this patch?
Index: src/ftp.c
===================================================================
RCS file: /home/cvs/sitecopy/src/ftp.c,v
retrieving revision 1.98
diff -u -r1.98 ftp.c
--- src/ftp.c 12 Sep 2004 16:43:32 -0000 1.98
+++ src/ftp.c 17 Oct 2004 14:45:46 -0000
@@ -415,28 +415,34 @@
off_t total = 0, lasttotal = 0;
while (fgets(buffer, BUFSIZ - 1, f) != NULL) {
+ size_t buflen;
+
/* Ensure that line-ending is CRLF. */
pnt = strchr(buffer, '\r');
if (pnt == NULL) {
/* We need to add the CR in */
pnt = strchr(buffer, '\n');
- if (pnt == NULL) {
- /* No CRLF; last line of file */
- pnt = memchr(buffer, '\0', sizeof buffer);
- assert(pnt != NULL);
+ if (pnt) {
+ /* Now, pnt points to the first character after the
+ * end of the line, i.e., where we want to put the CR.
+ */
+ *pnt++ = '\r';
+ /* And lob in an LF afterwards */
+ *pnt-- = '\n';
+ buflen = 2 + pnt - buffer;
+ } else {
+ /* line with no CRLF. */
+ buflen = strlen(buffer);
}
- /* Now, pnt points to the first character after the
- * end of the line, i.e., where we want to put the CR.
- */
- *pnt++ = '\r';
- /* And lob in an LF afterwards */
- *pnt-- = '\n';
- }
+ } else {
+ buflen = 2 + pnt - buffer;
+ }
+
/* At this point, pnt points to the CR.
* We send everything between pnt and the beginning of the buffer,
* +2 for the CRLF
*/
- ret = ne_sock_fullwrite(sess->dtpsock, buffer, 2 + pnt - buffer);
+ ret = ne_sock_fullwrite(sess->dtpsock, buffer, buflen);
if (ret) {
set_sockerr(sess, sess->dtpsock, _("Error sending file"), ret);
return -1;
_______________________________________________
sitecopy maillist - [email protected]
http://dav.lyra.org/mailman/listinfo/sitecopy