From 8e98a317c86f10e0c7e866c069e143bf48cf9814 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 22 Mar 2012 22:51:28 +0100 Subject: [PATCH] Removed the trivial peekc() and put the code at the appropriate places. --- h/prototypes.h | 1 - sbr/Makefile.in | 2 +- sbr/peekc.c | 20 -------------------- uip/burst.c | 12 +++++++----- 4 files changed, 8 insertions(+), 27 deletions(-) delete mode 100644 sbr/peekc.c diff --git a/h/prototypes.h b/h/prototypes.h index 7c105f6..61e2c49 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -80,7 +80,6 @@ int makedir(char *); char *nmh_getpass(const char *); char *norm_charmap(char *); char *new_fs(char *, char *); -int peekc(FILE *ib); int pidwait(pid_t, int); int pidstatus(int, FILE *, char *); void print_help(char *, struct swit *, int); diff --git a/sbr/Makefile.in b/sbr/Makefile.in index 58f8293..d3782ff 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -60,7 +60,7 @@ SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c \ m_convert.c m_draft.c m_getfld.c m_gmprot.c \ m_name.c \ makedir.c mts.c norm_charmap.c \ - path.c peekc.c pidwait.c pidstatus.c \ + path.c pidwait.c pidstatus.c \ print_help.c print_sw.c print_version.c \ putenv.c refile.c mhbasename.c \ readconfig.c ruserpass.c seq_add.c seq_bits.c \ diff --git a/sbr/peekc.c b/sbr/peekc.c deleted file mode 100644 index 7d5f7f9..0000000 --- a/sbr/peekc.c +++ /dev/null @@ -1,20 +0,0 @@ -/* -** peekc.c -- peek at the next character in a stream -** -** This code is Copyright (c) 2002, by the authors of nmh. See the -** COPYRIGHT file in the root directory of the nmh distribution for -** complete copyright information. -*/ - -#include - - -int -peekc(FILE *fp) -{ - register int c; - - c = getc(fp); - ungetc(c, fp); - return c; -} diff --git a/uip/burst.c b/uip/burst.c index 725abec..fdc78f4 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -216,11 +216,13 @@ find_delim(int msgnum, struct smsg *smsgs) for (c = 0; fgets(buffer, sizeof(buffer), in); c = buffer[0]) { if (strncmp(buffer, delim3, ld3) == 0 - && (msgp == 1 || c == '\n') - && ((cc = peekc(in)) == '\n' || - cc == EOF)) - break; - else + && (msgp == 1 || c == '\n')) { + cc = getc(in); + ungetc(cc, in); + if (cc == '\n' || cc == EOF) { + break; + } + } else pos += (long) strlen(buffer); } -- 1.7.10.4