Don't use dangling elses.

This commit is contained in:
joerg 2012-01-06 15:16:02 +00:00
parent 44fb314fb7
commit 3a4dc84ff4
17 changed files with 101 additions and 39 deletions

View File

@ -1556,10 +1556,12 @@ undotlines (leading_dot, start, num)
{
write_output (".\n", 2);
if (leading_dot)
{
if (num == 1)
printf_output ("%ds/^\\.//\n", start);
else
printf_output ("%d,%ds/^\\.//\n", start, start + num - 1);
}
}
/*
@ -1751,10 +1753,12 @@ output_diff3_merge (infile, diff, mapping, rev_mapping,
{
c = getc (infile);
if (c == EOF)
{
if (ferror (infile))
diff3_perror_with_exit ("input file");
else if (feof (infile))
diff3_fatal ("input file shrank");
}
cc = c;
write_output (&cc, 1);
}
@ -1805,6 +1809,7 @@ output_diff3_merge (infile, diff, mapping, rev_mapping,
while (0 <= --i)
while ((c = getc (infile)) != '\n')
if (c == EOF)
{
if (ferror (infile))
diff3_perror_with_exit ("input file");
else if (feof (infile))
@ -1813,6 +1818,7 @@ output_diff3_merge (infile, diff, mapping, rev_mapping,
diff3_fatal ("input file shrank");
return conflicts_found;
}
}
}
/* Copy rest of common file. */
while ((c = getc (infile)) != EOF || !(ferror (infile) | feof (infile)))

View File

@ -123,6 +123,7 @@ print_half_line (line, indent, out_bound)
case '\b':
if (in_position != 0 && --in_position < out_bound)
{
if (out_position <= in_position)
/* Add spaces to make up for suppressed tab past out_bound. */
for (; out_position < in_position; out_position++)
@ -133,6 +134,7 @@ print_half_line (line, indent, out_bound)
cc = c;
write_output (&cc, 1);
}
}
break;
case '\f':

View File

@ -923,10 +923,12 @@ namespace std
}
iterator __j = iterator(__y);
if (__comp)
{
if (__j == begin())
return pair<iterator,bool>(_M_insert(__x, __y, __v), true);
else
--__j;
}
if (_M_impl._M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v)))
return pair<iterator, bool>(_M_insert(__x, __y, __v), true);
return pair<iterator, bool>(__j, false);

View File

@ -311,10 +311,12 @@ namespace std
strstreambuf::_M_free(char* p)
{
if (p)
{
if (_M_free_fun)
_M_free_fun(p);
else
delete[] p;
}
}
void

View File

@ -315,18 +315,22 @@ namespace std
__z->_M_parent->_M_left = __x;
else
__z->_M_parent->_M_right = __x;
if (__leftmost == __z)
if (__leftmost == __z)
{
if (__z->_M_right == 0) // __z->_M_left must be null also
__leftmost = __z->_M_parent;
// makes __leftmost == _M_header if __z == __root
else
__leftmost = _Rb_tree_node_base::_S_minimum(__x);
if (__rightmost == __z)
}
if (__rightmost == __z)
{
if (__z->_M_left == 0) // __z->_M_right must be null also
__rightmost = __z->_M_parent;
// makes __rightmost == _M_header if __z == __root
else // __x == __z->_M_left
__rightmost = _Rb_tree_node_base::_S_maximum(__x);
}
}
if (__y->_M_color != _S_red)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: input.cpp,v 1.1.1.3 2006/02/06 18:14:11 wiz Exp $ */
/* $NetBSD: input.cpp,v 1.2 2012/01/06 15:16:03 joerg Exp $ */
// -*- C++ -*-
/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2005
@ -2798,11 +2798,12 @@ void process_input_stack()
do {
node *n;
cc = get_copy(&n);
if (cc != EOF)
if (cc != EOF) {
if (cc != '\0')
curdiv->transparent_output(transparent_translate(cc));
else
curdiv->transparent_output(n);
}
} while (cc != '\n' && cc != EOF);
if (cc == EOF)
curdiv->transparent_output('\n');

View File

@ -1,4 +1,4 @@
/* $NetBSD: mtsm.cpp,v 1.2 2010/05/06 18:54:35 drochner Exp $ */
/* $NetBSD: mtsm.cpp,v 1.3 2012/01/06 15:16:03 joerg Exp $ */
// -*- C++ -*-
/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
@ -484,21 +484,24 @@ void mtsm::flush(FILE *fp, statem *s, string tag_list)
void statem::display_state()
{
fprintf(stderr, " <state ");
if (bool_values[MTSM_BR].is_known)
if (bool_values[MTSM_BR].is_known) {
if (bool_values[MTSM_BR].value)
fprintf(stderr, "[br]");
else
fprintf(stderr, "[!br]");
if (bool_values[MTSM_EOL].is_known)
}
if (bool_values[MTSM_EOL].is_known) {
if (bool_values[MTSM_EOL].value)
fprintf(stderr, "[eol]");
else
fprintf(stderr, "[!eol]");
if (int_values[MTSM_SP].is_known)
}
if (int_values[MTSM_SP].is_known) {
if (int_values[MTSM_SP].value)
fprintf(stderr, "[sp %d]", int_values[MTSM_SP].value);
else
fprintf(stderr, "[!sp]");
}
fprintf(stderr, ">");
fflush(stderr);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: node.cpp,v 1.1.1.3 2006/02/06 18:14:14 wiz Exp $ */
/* $NetBSD: node.cpp,v 1.2 2012/01/06 15:16:03 joerg Exp $ */
// -*- C++ -*-
/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2005
@ -4602,7 +4602,7 @@ void hline_node::tprint(troff_output_file *out)
}
else {
hunits rem = x - w*i;
if (rem > H0)
if (rem > H0) {
if (n->overlaps_horizontally()) {
if (out->is_on())
n->tprint(out);
@ -4610,6 +4610,7 @@ void hline_node::tprint(troff_output_file *out)
}
else
out->right(rem);
}
while (--i >= 0)
if (out->is_on())
n->tprint(out);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ci.c,v 1.4 1996/10/15 06:59:54 veego Exp $ */
/* $NetBSD: ci.c,v 1.5 2012/01/06 15:16:03 joerg Exp $ */
/* Check in revisions of RCS files from working files. */
@ -31,6 +31,9 @@ Report problems and direct all questions to:
/*
* $Log: ci.c,v $
* Revision 1.5 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.4 1996/10/15 06:59:54 veego
* Merge rcs 5.7.
*
@ -1141,7 +1144,7 @@ struct hshentry * delta;
num=delta->num;
for (trail = &Locks; (next = *trail); trail = &next->nextlock)
if (next->delta == delta)
if (next->delta == delta) {
if (strcmp(getcaller(), next->login) == 0) {
/* We found a lock on delta by caller; delete it. */
*trail = next->nextlock;
@ -1151,6 +1154,7 @@ struct hshentry * delta;
rcserror("revision %s locked by %s", num, next->login);
return -1;
}
}
if (!StrictLocks && myself(RCSstat.st_uid))
return 0;
rcserror("no lock set by %s for revision %s", getcaller(), num);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ident.c,v 1.5 2006/03/26 22:50:48 christos Exp $ */
/* $NetBSD: ident.c,v 1.6 2012/01/06 15:16:03 joerg Exp $ */
/* Identify RCS keyword strings in files. */
/* Copyright 1982, 1988, 1989 Walter Tichy
@ -30,6 +30,9 @@ Report problems and direct all questions to:
/*
* $Log: ident.c,v $
* Revision 1.6 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.5 2006/03/26 22:50:48 christos
* Coverity CID 1202: Always return on EOF, otherwise we would try to use
* ctab[-1].
@ -142,7 +145,7 @@ mainProg(identId, "ident", "Id: ident.c,v 5.9 1995/06/16 06:19:24 eggert Exp")
break;
}
if (0 <= quiet)
if (0 <= quiet) {
if (!a)
VOID scanfile(stdin, (char*)0, quiet);
else
@ -156,7 +159,7 @@ mainProg(identId, "ident", "Id: ident.c,v 5.9 1995/06/16 06:19:24 eggert Exp")
)
break;
} while ((a = *++argv));
}
if (ferror(stdout) || fclose(stdout)!=0) {
reportError("standard output");
status = EXIT_FAILURE;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcsbase.h,v 1.9 1998/09/14 18:36:07 tv Exp $ */
/* $NetBSD: rcsbase.h,v 1.10 2012/01/06 15:16:03 joerg Exp $ */
/* RCS common definitions and data structures */
@ -33,6 +33,9 @@ Report problems and direct all questions to:
/*
* $Log: rcsbase.h,v $
* Revision 1.10 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.9 1998/09/14 18:36:07 tv
* Increase "keylength" to 32, inspired by <prlw1@newn.cam.ac.uk> in PR
* bin/5415. This will not be a significant performance hit, but allows
@ -283,14 +286,14 @@ Report problems and direct all questions to:
# if maps_memory
# define declarecache register Iptr_type ptr, lim
# define setupcache(f) (lim = (f)->lim)
# define Igeteof_(f,c,s) if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++;
# define cachegeteof_(c,s) if (ptr==lim) s else (c)= *ptr++;
# define Igeteof_(f,c,s) do { if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++; } while(0);
# define cachegeteof_(c,s) do { if (ptr==lim) s else (c)= *ptr++; } while(0);
# else
int Igetmore P((RILE*));
# define declarecache register Iptr_type ptr; register RILE *rRILE
# define setupcache(f) (rRILE = (f))
# define Igeteof_(f,c,s) if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++;
# define cachegeteof_(c,s) if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++;
# define Igeteof_(f,c,s) do { if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++; } while (0);
# define cachegeteof_(c,s) do { if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++; } } while (0);
# endif
# define uncache(f) ((f)->ptr = ptr)
# define cache(f) (ptr = (f)->ptr)

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcsedit.c,v 1.9 2011/05/15 14:31:13 christos Exp $ */
/* $NetBSD: rcsedit.c,v 1.10 2012/01/06 15:16:03 joerg Exp $ */
/* RCS stream editor */
@ -38,6 +38,9 @@ Report problems and direct all questions to:
/*
* $Log: rcsedit.c,v $
* Revision 1.10 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.9 2011/05/15 14:31:13 christos
* register c -> int c
*
@ -1085,12 +1088,13 @@ keyreplace(marker, delta, delimstuffed, infile, out, dolog)
RCSv==VERSION(3) && delta->lockedby ? "Locked"
: delta->state
);
if (delta->lockedby)
if (delta->lockedby) {
if (VERSION(5) <= RCSv) {
if (locker_expansion || exp==KEYVALLOCK_EXPAND)
aprintf(out, " %s", delta->lockedby);
} else if (RCSv == VERSION(4))
aprintf(out, " Locker: %s", delta->lockedby);
}
break;
case Locker:
if (delta->lockedby)
@ -1753,7 +1757,7 @@ addlock(delta, verbose)
register struct rcslock *next;
for (next = Locks; next; next = next->nextlock)
if (cmpnum(delta->num, next->delta->num) == 0)
if (cmpnum(delta->num, next->delta->num) == 0) {
if (strcmp(getcaller(), next->login) == 0)
return 0;
else {
@ -1763,6 +1767,7 @@ addlock(delta, verbose)
);
return -1;
}
}
next = ftalloc(struct rcslock);
delta->lockedby = next->login = getcaller();
next->delta = delta;
@ -1786,7 +1791,7 @@ addsymbol(num, name, rebind)
register struct assoc *next;
for (next = Symbols; next; next = next->nextassoc)
if (strcmp(name, next->symbol) == 0)
if (strcmp(name, next->symbol) == 0) {
if (strcmp(next->num,num) == 0)
return 0;
else if (rebind) {
@ -1798,6 +1803,7 @@ addsymbol(num, name, rebind)
);
return -1;
}
}
next = ftalloc(struct assoc);
next->symbol = name;
next->num = num;
@ -1857,7 +1863,7 @@ dorewrite(lockflag, changed)
{
int r = 0, e;
if (lockflag)
if (lockflag) {
if (changed) {
if (changed < 0)
return -1;
@ -1893,6 +1899,7 @@ dorewrite(lockflag, changed)
}
# endif
}
}
return r;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcsgen.c,v 1.4 1996/10/15 07:00:20 veego Exp $ */
/* $NetBSD: rcsgen.c,v 1.5 2012/01/06 15:16:03 joerg Exp $ */
/* Generate RCS revisions. */
@ -31,6 +31,9 @@ Report problems and direct all questions to:
/*
* $Log: rcsgen.c,v $
* Revision 1.5 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.4 1996/10/15 07:00:20 veego
* Merge rcs 5.7.
*
@ -449,7 +452,7 @@ getsstdin(option, name, note, buf)
c = getcstdin(), !feof(stdin);
bufrealloc(buf, i+1), p = buf->string, p[i++] = c
)
if (c == '\n')
if (c == '\n') {
if (i && p[i-1]=='.' && (i==1 || p[i-2]=='\n')) {
/* Remove trailing '.'. */
--i;
@ -458,6 +461,7 @@ getsstdin(option, name, note, buf)
aputs(">> ", stderr);
eflush();
}
}
return cleanlogmsg(p, i);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcsrev.c,v 1.6 2006/03/26 22:20:04 christos Exp $ */
/* $NetBSD: rcsrev.c,v 1.7 2012/01/06 15:16:03 joerg Exp $ */
/* Handle RCS revision numbers. */
@ -31,6 +31,9 @@ Report problems and direct all questions to:
/*
* $Log: rcsrev.c,v $
* Revision 1.7 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.6 2006/03/26 22:20:04 christos
* Coverity CID 2361: Avoid possible NULL deref.
*
@ -761,7 +764,7 @@ fexpandsym(source, target, fp)
for (bp = tp; *bp=='0' && isdigit(bp[1]); bp++)
continue;
if (!*bp)
if (!*bp) {
if (s || *sp!='.')
break;
else {
@ -777,6 +780,7 @@ fexpandsym(source, target, fp)
bp = tp = target->string;
tlim = tp + target->size;
}
}
}
while ((*tp++ = *bp++))

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcs.c,v 1.6 2011/05/15 14:33:12 christos Exp $ */
/* $NetBSD: rcs.c,v 1.7 2012/01/06 15:16:03 joerg Exp $ */
/* Change RCS file attributes. */
@ -31,6 +31,9 @@ Report problems and direct all questions to:
/*
* $Log: rcs.c,v $
* Revision 1.7 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.6 2011/05/15 14:33:12 christos
* register c -> int c
*
@ -1403,7 +1406,7 @@ dolocks()
for (lockpt = rmvlocklst; lockpt; lockpt = lockpt->nextrev)
if (expandsym(lockpt->revno, &numrev)) {
target = genrevs(numrev.string, (char *)0, (char *)0, (char *)0, &gendeltas);
if ( target )
if ( target ) {
if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
rcserror("can't unlock nonexisting revision %s",
lockpt->revno
@ -1411,19 +1414,21 @@ dolocks()
else
changed |= breaklock(target);
/* breaklock does its own diagnose */
}
}
/* add new locks which stored in newlocklst */
for (lockpt = newlocklst; lockpt; lockpt = lockpt->nextrev)
changed |= setlock(lockpt->revno);
if (lockhead) /* lock default branch or head */
if (lockhead) { /* lock default branch or head */
if (Dbranch)
changed |= setlock(Dbranch);
else if (Head)
changed |= setlock(Head->num);
else
rcswarn("can't lock an empty tree");
}
return changed;
}
@ -1442,7 +1447,7 @@ setlock(rev)
if (expandsym(rev, &numrev)) {
target = genrevs(numrev.string, (char*)0, (char*)0,
(char*)0, &gendeltas);
if ( target )
if ( target ) {
if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
rcserror("can't lock nonexisting revision %s",
numrev.string
@ -1456,6 +1461,7 @@ setlock(rev)
return r;
}
}
}
}
return 0;
}
@ -1498,7 +1504,7 @@ rcs_setstate(rev,status)
if (expandsym(rev, &numrev)) {
target = genrevs(numrev.string, (char*)0, (char*)0,
(char*)0, &gendeltas);
if ( target )
if ( target ) {
if (!(countnumflds(numrev.string)&1) && cmpnum(target->num,numrev.string))
rcserror("can't set state of nonexisting revision %s",
numrev.string
@ -1507,6 +1513,7 @@ rcs_setstate(rev,status)
target->state = status;
return true;
}
}
}
return false;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcsdiff.c,v 1.7 2011/05/15 14:33:12 christos Exp $ */
/* $NetBSD: rcsdiff.c,v 1.8 2012/01/06 15:16:03 joerg Exp $ */
/* Compare RCS revisions. */
@ -31,6 +31,9 @@ Report problems and direct all questions to:
/*
* $Log: rcsdiff.c,v $
* Revision 1.8 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.7 2011/05/15 14:33:12 christos
* register c -> int c
*
@ -381,13 +384,14 @@ mainProg(rcsdiffId, "rcsdiff", "Id: rcsdiff.c,v 5.19 1995/06/16 06:19:24 eggert
lexpandarg = "-kkvl";
Izclose(&workptr);
#if DIFF_L
if (diff_label2)
if (diff_label2) {
if (revnums == 2)
*diff_label2 = setup_label(&labelbuf[1], target->num, target->date);
else {
time2date(workstat.st_mtime, date2);
*diff_label2 = setup_label(&labelbuf[1], (char*)0, date2);
}
}
#endif
diagnose("retrieving revision %s\n", xrev1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rlog.c,v 1.5 2011/05/15 14:33:12 christos Exp $ */
/* $NetBSD: rlog.c,v 1.6 2012/01/06 15:16:03 joerg Exp $ */
/* Print log messages and other information about RCS files. */
@ -31,6 +31,9 @@ Report problems and direct all questions to:
/*
* $Log: rlog.c,v $
* Revision 1.6 2012/01/06 15:16:03 joerg
* Don't use dangling elses.
*
* Revision 1.5 2011/05/15 14:33:12 christos
* register c -> int c
*
@ -591,13 +594,14 @@ putadelta(node,editscript,trunk)
node->author, node->state
);
if ( editscript )
if ( editscript ) {
if(trunk)
aprintf(out, insDelFormat,
editscript->deletelns, editscript->insertlns);
else
aprintf(out, insDelFormat,
editscript->insertlns, editscript->deletelns);
}
newbranch = node->branches;
if ( newbranch ) {
@ -973,12 +977,13 @@ extractdelta(pdelta)
while (strcmp(pstate->status, pdelta->state) != 0)
if (!(pstate = pstate->nextstate))
return false;
if (lockflag) /* only locked revisions wanted */
if (lockflag) { /* only locked revisions wanted */
for (plock = Locks; ; plock = plock->nextlock)
if (!plock)
return false;
else if (plock->delta == pdelta)
break;
}
if ((prevision = Revlst)) /* only certain revs or branches wanted */
for (;;) {
length = prevision->numfld;