]> git.pond.sub.org Git - empserver/commitdiff
read can print telegram without header after deletion prompt
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 18 Feb 2012 09:04:06 +0000 (10:04 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 21 Feb 2012 17:12:12 +0000 (18:12 +0100)
rea() loops if more telegrams arrive while we wait for the player to
confirm deletion.  If the first new one is a continuation of the last
old one, its header is suppressed.  Don't do that.

Broken in commit 17223e8f, v4.3.29.

src/lib/commands/rea.c

index 118e08696ea7e174dc43526d5193510ed43da53c..2a8ca2fe3e1e20352478543fc264a9a3474aa8d7 100644 (file)
@@ -59,7 +59,7 @@ rea(void)
     char mbox_buf[256];                /* Maximum path length */
     struct telstr tgm;
     FILE *telfp;
     char mbox_buf[256];                /* Maximum path length */
     struct telstr tgm;
     FILE *telfp;
-    int teles;
+    int teles, need_hdr;
     char buf[1024];
     char *kind;
     int n, res;
     char buf[1024];
     char *kind;
     int n, res;
@@ -99,6 +99,7 @@ rea(void)
        return RET_FAIL;
     }
     teles = 0;
        return RET_FAIL;
     }
     teles = 0;
+    need_hdr = 1;
     for (;;) {
        res = tel_read_header(telfp, mbox, &tgm);
     more:
     for (;;) {
        res = tel_read_header(telfp, mbox, &tgm);
     more:
@@ -115,7 +116,7 @@ rea(void)
        }
        if (!teles && *kind == 'a')
            pr("\nAnnouncements since %s", ctime(&then));
        }
        if (!teles && *kind == 'a')
            pr("\nAnnouncements since %s", ctime(&then));
-       if (!teles || !tgm.tel_cont) {
+       if (need_hdr || !tgm.tel_cont) {
            pr("\n> ");
            pr("%s ", telnames[tgm.tel_type]);
            if ((tgm.tel_type == TEL_NORM) ||
            pr("\n> ");
            pr("%s ", telnames[tgm.tel_type]);
            if ((tgm.tel_type == TEL_NORM) ||
@@ -125,6 +126,7 @@ rea(void)
            pr("  dated %s", ctime(&tgm.tel_date));
        }
        teles++;
            pr("  dated %s", ctime(&tgm.tel_date));
        }
        teles++;
+       need_hdr = 0;
        res = tel_read_body(telfp, mbox, &tgm, print_sink, NULL);
        if (res < 0)
            break;
        res = tel_read_body(telfp, mbox, &tgm, print_sink, NULL);
        if (res < 0)
            break;
@@ -169,6 +171,7 @@ rea(void)
                res = tel_read_header(telfp, mbox, &tgm);
                if (res != 0) {
                    pr("Wait a sec!  A new %s has arrived...\n", kind);
                res = tel_read_header(telfp, mbox, &tgm);
                if (res != 0) {
                    pr("Wait a sec!  A new %s has arrived...\n", kind);
+                   need_hdr = 1;
                    goto more;
                }
                /* Here, we just re-open the file for "w" only,
                    goto more;
                }
                /* Here, we just re-open the file for "w" only,