Mercurial > hg > octave-nkf > gnulib-hg
changeset 7429:5c6e946feae3
Use bool.
Rename minimal to find_minimal.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 07 Oct 2006 15:53:27 +0000 |
parents | 7f2348458267 |
children | f53f84143fe3 |
files | lib/fstrcmp.c |
diffstat | 1 files changed, 27 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/fstrcmp.c +++ b/lib/fstrcmp.c @@ -49,6 +49,7 @@ #include "fstrcmp.h" #include <string.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <limits.h> @@ -128,11 +129,11 @@ /* Midpoints of this partition. */ int xmid, ymid; - /* Nonzero if low half will be analyzed minimally. */ - int lo_minimal; + /* True if low half will be analyzed minimally. */ + bool lo_minimal; /* Likewise for high half. */ - int hi_minimal; + bool hi_minimal; }; @@ -140,7 +141,7 @@ diag - find diagonal path SYNOPSIS - int diag(int xoff, int xlim, int yoff, int ylim, int minimal, + int diag(int xoff, int xlim, int yoff, int ylim, bool find_minimal, struct partition *part, struct context *ctxt); DESCRIPTION @@ -152,7 +153,7 @@ edit-sequence. When the two searches meet, we have found the midpoint of the shortest edit sequence. - If MINIMAL is nonzero, find the minimal edit script regardless + If FIND_MINIMAL is true, find the minimal edit script regardless of expense. Otherwise, if the search is too expensive, use heuristics to stop the search and report a suboptimal answer. @@ -181,7 +182,7 @@ output. */ static OFFSET -diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, OFFSET minimal, +diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, bool find_minimal, struct partition *part, struct context *ctxt) { OFFSET *const fd = ctxt->fdiag; /* Give the compiler a chance. */ @@ -197,7 +198,7 @@ OFFSET bmin = bmid; OFFSET bmax = bmid; /* Limits of bottom-up search. */ OFFSET c; /* Cost. */ - int odd = (fmid - bmid) & 1; + bool odd = (fmid - bmid) & 1; /* * True if southeast corner is on an odd diagonal with respect @@ -208,9 +209,9 @@ for (c = 1;; ++c) { OFFSET d; /* Active diagonal. */ - int big_snake; + bool big_snake; - big_snake = 0; + big_snake = false; /* Extend the top-down search by an edit step in each diagonal. */ if (fmin > dmin) fd[--fmin - 1] = -1; @@ -243,13 +244,13 @@ ++y; } if (x - oldx > SNAKE_LIMIT) - big_snake = 1; + big_snake = true; fd[d] = x; if (odd && bmin <= d && d <= bmax && bd[d] <= x) { part->xmid = x; part->ymid = y; - part->lo_minimal = part->hi_minimal = 1; + part->lo_minimal = part->hi_minimal = true; return 2 * c - 1; } } @@ -284,18 +285,18 @@ --y; } if (oldx - x > SNAKE_LIMIT) - big_snake = 1; + big_snake = true; bd[d] = x; if (!odd && fmin <= d && d <= fmax && x <= fd[d]) { part->xmid = x; part->ymid = y; - part->lo_minimal = part->hi_minimal = 1; + part->lo_minimal = part->hi_minimal = true; return 2 * c; } } - if (minimal) + if (find_minimal) continue; #ifdef MINUS_H_FLAG @@ -357,8 +358,8 @@ } if (best > 0) { - part->lo_minimal = 1; - part->hi_minimal = 0; + part->lo_minimal = true; + part->hi_minimal = false; return 2 * c - 1; } best = 0; @@ -398,8 +399,8 @@ } if (best > 0) { - part->lo_minimal = 0; - part->hi_minimal = 1; + part->lo_minimal = false; + part->hi_minimal = true; return 2 * c - 1; } } @@ -465,15 +466,15 @@ { part->xmid = fxbest; part->ymid = fxybest - fxbest; - part->lo_minimal = 1; - part->hi_minimal = 0; + part->lo_minimal = true; + part->hi_minimal = false; } else { part->xmid = bxbest; part->ymid = bxybest - bxbest; - part->lo_minimal = 0; - part->hi_minimal = 1; + part->lo_minimal = false; + part->hi_minimal = true; } return 2 * c - 1; } @@ -485,7 +486,7 @@ compareseq - find edit sequence SYNOPSIS - void compareseq(int xoff, int xlim, int yoff, int ylim, int minimal, + void compareseq(int xoff, int xlim, int yoff, int ylim, bool find_minimal, struct context *ctxt); DESCRIPTION @@ -498,11 +499,11 @@ Note that XLIM, YLIM are exclusive bounds. All character numbers are origin-0. - If MINIMAL is nonzero, find a minimal difference no matter how + If FIND_MINIMAL is nonzero, find a minimal difference no matter how expensive it is. */ static void -compareseq (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, int minimal, +compareseq (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, bool find_minimal, struct context *ctxt) { const ELEMENT *const xv = ctxt->string[0].data; /* Help the compiler. */ @@ -545,7 +546,7 @@ struct partition part; /* Find a point of correspondence in the middle of the strings. */ - c = diag (xoff, xlim, yoff, ylim, minimal, &part, ctxt); + c = diag (xoff, xlim, yoff, ylim, find_minimal, &part, ctxt); if (c == 1) { #if 0