diff options
author | Bruno Haible <bruno@clisp.org> | 2003-04-07 09:50:11 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2003-04-07 09:50:11 +0000 |
commit | 2535f34494011d57d9603d6e44604d357f83a4b0 (patch) | |
tree | b64db3a05de58cdd2af82157b5218a13fd318b83 /src/positions.cc | |
parent | ec3d1127fa7742bd291bfe039fd76b4d2381da6f (diff) | |
download | gperf-2535f34494011d57d9603d6e44604d357f83a4b0.tar.gz |
Move the handling of ALLCHARS (-k'*') into the Positions class.
Diffstat (limited to 'src/positions.cc')
-rw-r--r-- | src/positions.cc | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/src/positions.cc b/src/positions.cc index 2a096c1..f6439e3 100644 --- a/src/positions.cc +++ b/src/positions.cc @@ -50,6 +50,8 @@ Positions::contains (int pos) const void Positions::add (int pos) { + set_useall (false); + unsigned int count = _size; if (count == MAX_SIZE) @@ -78,6 +80,8 @@ Positions::add (int pos) void Positions::remove (int pos) { + set_useall (false); + unsigned int count = _size; if (count > 0) { @@ -120,40 +124,45 @@ Positions::remove (int pos) void Positions::print () const { - bool first = true; - bool seen_LASTCHAR = false; - unsigned int count = _size; - const int *p = _positions + _size - 1; - - for (; count > 0; p--) + if (_useall) + printf ("*"); + else { - count--; - if (*p == LASTCHAR) - seen_LASTCHAR = true; - else + bool first = true; + bool seen_LASTCHAR = false; + unsigned int count = _size; + const int *p = _positions + _size - 1; + + for (; count > 0; p--) { - if (!first) - printf (","); - printf ("%d", *p + 1); - if (count > 0 && p[-1] == *p + 1) + count--; + if (*p == LASTCHAR) + seen_LASTCHAR = true; + else { - printf ("-"); - do + if (!first) + printf (","); + printf ("%d", *p + 1); + if (count > 0 && p[-1] == *p + 1) { - p--; - count--; + printf ("-"); + do + { + p--; + count--; + } + while (count > 0 && p[-1] == *p + 1); + printf ("%d", *p + 1); } - while (count > 0 && p[-1] == *p + 1); - printf ("%d", *p + 1); + first = false; } - first = false; } - } - if (seen_LASTCHAR) - { - if (!first) - printf (","); - printf ("$"); + if (seen_LASTCHAR) + { + if (!first) + printf (","); + printf ("$"); + } } } |