Improve mta simulator output.
* examples/mta.c (mta_send): A line number refers to the start of each line, not end of it. * mail/testsuite/mail/send.exp: Reflect this change. * sieve/tests/redirect.at: Likewise. * sieve/tests/reject.at: Likewise.
Showing
3 changed files
with
11 additions
and
9 deletions
... | @@ -326,6 +326,7 @@ mta_send (mu_message_t msg) | ... | @@ -326,6 +326,7 @@ mta_send (mu_message_t msg) |
326 | mu_stream_t stream = NULL; | 326 | mu_stream_t stream = NULL; |
327 | size_t line; | 327 | size_t line; |
328 | char *value; | 328 | char *value; |
329 | int newline = 0; | ||
329 | 330 | ||
330 | value = from_address (); | 331 | value = from_address (); |
331 | if (value) | 332 | if (value) |
... | @@ -340,7 +341,7 @@ mta_send (mu_message_t msg) | ... | @@ -340,7 +341,7 @@ mta_send (mu_message_t msg) |
340 | 341 | ||
341 | mu_message_get_streamref (msg, &stream); | 342 | mu_message_get_streamref (msg, &stream); |
342 | line = 0; | 343 | line = 0; |
343 | fprintf (diag, "%4lu: ", (unsigned long) line); | 344 | newline = 1; |
344 | while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0 | 345 | while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0 |
345 | && n != 0) | 346 | && n != 0) |
346 | { | 347 | { |
... | @@ -348,16 +349,23 @@ mta_send (mu_message_t msg) | ... | @@ -348,16 +349,23 @@ mta_send (mu_message_t msg) |
348 | 349 | ||
349 | for (i = 0; i < n; i++) | 350 | for (i = 0; i < n; i++) |
350 | { | 351 | { |
352 | if (newline) | ||
353 | { | ||
354 | fprintf (diag, "%4lu: ", (unsigned long) line); | ||
355 | newline = 0; | ||
356 | } | ||
351 | fputc (buffer[i], diag); | 357 | fputc (buffer[i], diag); |
352 | if (buffer[i] == '\n') | 358 | if (buffer[i] == '\n') |
353 | { | 359 | { |
354 | line++; | 360 | line++; |
355 | fprintf (diag, "%4lu: ", (unsigned long) line); | 361 | newline = 1; |
356 | } | 362 | } |
357 | } | 363 | } |
358 | } | 364 | } |
359 | mu_stream_destroy (&stream); | 365 | mu_stream_destroy (&stream); |
360 | fprintf (diag, "\nEND OF MESSAGE\n"); | 366 | if (!newline) |
367 | fprintf (diag, "\n(no newline at EOF)\n"); | ||
368 | fprintf (diag, "END OF MESSAGE\n"); | ||
361 | fflush (diag); | 369 | fflush (diag); |
362 | return 0; | 370 | return 0; |
363 | } | 371 | } | ... | ... |
... | @@ -52,7 +52,6 @@ ENVELOPE TO: <gray@gnu.org> | ... | @@ -52,7 +52,6 @@ ENVELOPE TO: <gray@gnu.org> |
52 | 13: | 52 | 13: |
53 | 14: -- | 53 | 14: -- |
54 | 15: Wile E. Coyote "Super Genius" coyote@desert.example.org | 54 | 15: Wile E. Coyote "Super Genius" coyote@desert.example.org |
55 | 16: | ||
56 | END OF MESSAGE | 55 | END OF MESSAGE |
57 | ENVELOPE FROM: b1ff@de.res.example.com | 56 | ENVELOPE FROM: b1ff@de.res.example.com |
58 | ENVELOPE TO: <gray@gnu.org> | 57 | ENVELOPE TO: <gray@gnu.org> |
... | @@ -70,7 +69,6 @@ ENVELOPE TO: <gray@gnu.org> | ... | @@ -70,7 +69,6 @@ ENVELOPE TO: <gray@gnu.org> |
70 | 11: $20,000 IN LESS THAN TWO MONTHS! AND IT'S LEGAL!!!!!!!!! | 69 | 11: $20,000 IN LESS THAN TWO MONTHS! AND IT'S LEGAL!!!!!!!!! |
71 | 12: !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1 JUST | 70 | 12: !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1 JUST |
72 | 13: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW! | 71 | 13: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW! |
73 | 14: | ||
74 | END OF MESSAGE | 72 | END OF MESSAGE |
75 | ENVELOPE FROM: bar@dontmailme.org | 73 | ENVELOPE FROM: bar@dontmailme.org |
76 | ENVELOPE TO: <gray@gnu.org> | 74 | ENVELOPE TO: <gray@gnu.org> |
... | @@ -85,7 +83,6 @@ ENVELOPE TO: <gray@gnu.org> | ... | @@ -85,7 +83,6 @@ ENVELOPE TO: <gray@gnu.org> |
85 | 8: Subject: Coffee | 83 | 8: Subject: Coffee |
86 | 9: | 84 | 9: |
87 | 10: How about some coffee? | 85 | 10: How about some coffee? |
88 | 11: | ||
89 | END OF MESSAGE | 86 | END OF MESSAGE |
90 | ], | 87 | ], |
91 | [REDIRECT on msg uid 1: to gray@gnu.org | 88 | [REDIRECT on msg uid 1: to gray@gnu.org | ... | ... |
... | @@ -100,7 +100,6 @@ ENVELOPE TO: <coyote@desert.example.org> | ... | @@ -100,7 +100,6 @@ ENVELOPE TO: <coyote@desert.example.org> |
100 | 43: Wile E. Coyote "Super Genius" coyote@desert.example.org | 100 | 43: Wile E. Coyote "Super Genius" coyote@desert.example.org |
101 | 44: | 101 | 44: |
102 | 45: --(boundary) | 102 | 45: --(boundary) |
103 | 46: | ||
104 | END OF MESSAGE | 103 | END OF MESSAGE |
105 | ENVELOPE FROM: MAILER-DAEMON@nonexistent.net | 104 | ENVELOPE FROM: MAILER-DAEMON@nonexistent.net |
106 | ENVELOPE TO: <b1ff@de.res.example.com> | 105 | ENVELOPE TO: <b1ff@de.res.example.com> |
... | @@ -148,7 +147,6 @@ ENVELOPE TO: <b1ff@de.res.example.com> | ... | @@ -148,7 +147,6 @@ ENVELOPE TO: <b1ff@de.res.example.com> |
148 | 41: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW! | 147 | 41: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW! |
149 | 42: | 148 | 42: |
150 | 43: --(boundary) | 149 | 43: --(boundary) |
151 | 44: | ||
152 | END OF MESSAGE | 150 | END OF MESSAGE |
153 | ENVELOPE FROM: MAILER-DAEMON@nonexistent.net | 151 | ENVELOPE FROM: MAILER-DAEMON@nonexistent.net |
154 | ENVELOPE TO: <bar@dontmailme.org> | 152 | ENVELOPE TO: <bar@dontmailme.org> |
... | @@ -193,7 +191,6 @@ ENVELOPE TO: <bar@dontmailme.org> | ... | @@ -193,7 +191,6 @@ ENVELOPE TO: <bar@dontmailme.org> |
193 | 38: How about some coffee? | 191 | 38: How about some coffee? |
194 | 39: | 192 | 39: |
195 | 40: --(boundary) | 193 | 40: --(boundary) |
196 | 41: | ||
197 | END OF MESSAGE | 194 | END OF MESSAGE |
198 | ], | 195 | ], |
199 | [REJECT on msg uid 1 | 196 | [REJECT on msg uid 1 | ... | ... |
-
Please register or sign in to post a comment