From 99e89d0fcc69e509924b0a14a56e10d15721ccb0 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 5 Jan 2012 11:28:18 +0100 Subject: [PATCH] Refactoring in sbr/m_convert.c --- sbr/m_convert.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/sbr/m_convert.c b/sbr/m_convert.c index b42a5aa..b535fe3 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -250,10 +250,12 @@ m_conv(struct msgs *mp, char *str, int call) { register int i; register unsigned char *cp, *bp; - unsigned char buf[16]; + unsigned char buf[16]; /* for reserved sequence name */ convdir = 1; cp = bp = str; + + /* Handle an integer */ if (isdigit(*cp)) { while (isdigit(*bp)) bp++; @@ -276,39 +278,41 @@ m_conv(struct msgs *mp, char *str, int call) *bp++ = '\0'; delimp = cp; - if (!strcmp(buf, seq_first)) + /* Which one of the reserved names is it? */ + if (strcmp(buf, seq_first)==0) { return (mp->hghmsg || !(mp->msgflags & ALLOW_BEYOND) ? mp->lowmsg : BADMSG); - if (!strcmp(buf, seq_last)) { + } else if (strcmp(buf, seq_last)==0) { convdir = -1; return (mp->hghmsg || !(mp->msgflags & ALLOW_BEYOND) ? mp->hghmsg : BADMSG); - } - if (!strcmp(buf, seq_cur)) + } else if (strcmp(buf, seq_cur)==0) { return (mp->curmsg > 0 ? mp->curmsg : BADMSG); - if (!strcmp(buf, seq_prev)) { + } else if (strcmp(buf, seq_prev)==0) { convdir = -1; - for (i = (mp->curmsg <= mp->hghmsg) ? mp->curmsg - 1 : mp->hghmsg; - i >= mp->lowmsg; i--) { + for (i = (mp->curmsg <= mp->hghmsg) ? + mp->curmsg - 1 : mp->hghmsg; + i >= mp->lowmsg; i--) { if (does_exist(mp, i)) return i; } return BADMSG; - } - if (!strcmp(buf, seq_next)) { - for (i = (mp->curmsg >= mp->lowmsg) ? mp->curmsg + 1 : mp->lowmsg; - i <= mp->hghmsg; i++) { + } else if (strcmp(buf, seq_next)==0) { + for (i = (mp->curmsg >= mp->lowmsg) ? + mp->curmsg + 1 : mp->lowmsg; + i <= mp->hghmsg; i++) { if (does_exist(mp, i)) return i; } return BADMSG; - } - return BADLST; + } else { + return BADLST; + } } /* -- 1.7.10.4