1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00

Move the handling of ALLCHARS (-k'*') into the Positions class.

This commit is contained in:
Bruno Haible
2003-04-07 09:50:11 +00:00
parent ec3d1127fa
commit 2535f34494
14 changed files with 398 additions and 241 deletions

View File

@@ -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,41 +124,46 @@ 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--)
{
count--;
if (*p == LASTCHAR)
seen_LASTCHAR = true;
else
{
if (!first)
printf (",");
printf ("%d", *p + 1);
if (count > 0 && p[-1] == *p + 1)
{
printf ("-");
do
{
p--;
count--;
}
while (count > 0 && p[-1] == *p + 1);
printf ("%d", *p + 1);
}
first = false;
}
}
if (seen_LASTCHAR)
{
if (!first)
printf (",");
printf ("%d", *p + 1);
if (count > 0 && p[-1] == *p + 1)
{
printf ("-");
do
{
p--;
count--;
}
while (count > 0 && p[-1] == *p + 1);
printf ("%d", *p + 1);
}
first = false;
printf ("$");
}
}
if (seen_LASTCHAR)
{
if (!first)
printf (",");
printf ("$");
}
}
/* ------------------------------------------------------------------------- */