* [PATCH] Add verbose comments to split_msg()
@ 2006-12-11 22:12 Andy Parkins
2006-12-12 1:15 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Andy Parkins @ 2006-12-11 22:12 UTC (permalink / raw)
To: git
I was going to fix a bug in imap-send that was making it include the "From "
line from git-format-patch in the message sent to the IMAP server. So I
commented up what split_msg already does.
It turns out the bug was fixed in commit
e0b0830726286287744cc9e1a629a534bbe75452. So comments only, no fix needed.
(cherry picked from 3d5b1768f15b5cd430b869f416e72f4f3afe3d4a commit)
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
imap-send.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index a6a6568..110bd54 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1216,35 +1216,48 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )
{
char *p, *data;
+ /* Clear this message's slot */
memset( msg, 0, sizeof *msg );
+ /* If we've run out of data, stop*/
if (*ofs >= all_msgs->len)
return 0;
+ /* Point at the next message chunk */
data = &all_msgs->data[ *ofs ];
+ /* This message length is at most, the length of all messages
+ * minus our current position */
msg->len = all_msgs->len - *ofs;
+ /* If there isn't enough data remaining for a whole message or there
+ * is no , give up */
if (msg->len < 5 || strncmp( data, "From ", 5 ))
return 0;
+ /* Find the end of the "From " line */
p = strchr( data, '\n' );
if (p) {
+ /* Skip this line from the outgoing buffer */
p = &p[1];
msg->len -= p-data;
*ofs += p-data;
data = p;
}
+ /* Find the next message (if any) */
p = strstr( data, "\nFrom " );
if (p)
msg->len = &p[1] - data;
+ /* Alloc enough space for this message */
msg->data = xmalloc( msg->len + 1 );
if (!msg->data)
return 0;
+ /* Copy the message from "all" to it's own holder and terminate */
memcpy( msg->data, data, msg->len );
msg->data[ msg->len ] = 0;
+ /* Move the data pointer to the next message */
*ofs += msg->len;
return 1;
}
--
1.4.4.1.geeee8
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Add verbose comments to split_msg()
2006-12-11 22:12 [PATCH] Add verbose comments to split_msg() Andy Parkins
@ 2006-12-12 1:15 ` Junio C Hamano
2006-12-12 8:20 ` Andreas Ericsson
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-12-12 1:15 UTC (permalink / raw)
To: Andy Parkins; +Cc: git
Andy Parkins <andyparkins@gmail.com> writes:
> I was going to fix a bug in imap-send that was making it include the "From "
> line from git-format-patch in the message sent to the IMAP server. So I
> commented up what split_msg already does.
>
> It turns out the bug was fixed in commit
> e0b0830726286287744cc9e1a629a534bbe75452. So comments only, no fix needed.
> (cherry picked from 3d5b1768f15b5cd430b869f416e72f4f3afe3d4a commit)
>
> Signed-off-by: Andy Parkins <andyparkins@gmail.com>
3d5b1768 is not a public commit and is not useful information
other than your self. Please omit the last line.
Linus and everybody was right and I was wrong to leave this
message default in git-cherry-pick for a long time.
> ---
> imap-send.c | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/imap-send.c b/imap-send.c
> index a6a6568..110bd54 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -1216,35 +1216,48 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )
> {
> char *p, *data;
>
> + /* Clear this message's slot */
> memset( msg, 0, sizeof *msg );
> + /* If we've run out of data, stop*/
"..., stop */"
> if (*ofs >= all_msgs->len)
> return 0;
>
> + /* Point at the next message chunk */
> data = &all_msgs->data[ *ofs ];
> + /* This message length is at most, the length of all messages
> + * minus our current position */
Style?
/*
* This message ...
* ... position.
*/
> msg->len = all_msgs->len - *ofs;
>
> + /* If there isn't enough data remaining for a whole message or there
> + * is no , give up */
"there is no , "???
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add verbose comments to split_msg()
2006-12-12 1:15 ` Junio C Hamano
@ 2006-12-12 8:20 ` Andreas Ericsson
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Ericsson @ 2006-12-12 8:20 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Andy Parkins, git
Junio C Hamano wrote:
> Andy Parkins <andyparkins@gmail.com> writes:
>
>>
>> + /* If there isn't enough data remaining for a whole message or there
>> + * is no , give up */
>
> "there is no , "???
>
spoon
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-12-12 8:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-11 22:12 [PATCH] Add verbose comments to split_msg() Andy Parkins
2006-12-12 1:15 ` Junio C Hamano
2006-12-12 8:20 ` Andreas Ericsson
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).