Commit 40dd93af authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(main): Removed the 'c' command since l2g_compact no longer exists.

Added the 'i' command that tests iterators.  Adjusted to the new API
of l2g_dump, l2g_read and l2g_write.  Require an extra trailing
newline after the representation l2g_read expects when the 'r' command
is used, and produce a corresponding newline with the 'w' command.
Renamed the 'p' command to 'w'.
parent bbf6a23e
......@@ -16,15 +16,16 @@ const int ARGS = 3;
D m destruct
I m init
C m clear
C m m copy
C d s copy
a m l g append
d m l delete
l m l lookup
n m l next-key
c m compact
u m dump
r m read
p m print
w m write
i m iterate through all texts
i m f e iterate through f..e-1
*/
int
main(void)
......@@ -149,31 +150,56 @@ main(void)
ok = 1;
}
break;
case 'c':
case 'i':
if (n == 1 && num[0] < MAXMAPS)
{
l2g_compact(&maps[num[0]]);
L2g_iterator iter;
for (l2gi_searchall(&iter, &maps[num[0]]);
!iter.search_ended;
l2gi_next(&iter))
printf("%lu:%lu\n",
(unsigned long)iter.lno,
(unsigned long)iter.tno);
ok = 1;
}
else if (n == 3 && num[0] < MAXMAPS)
{
L2g_iterator iter;
for (l2gi_searchsome(&iter, &maps[num[0]],
num[1], num[2]);
!iter.search_ended;
l2gi_next(&iter))
printf("%lu:%lu\n",
(unsigned long)iter.lno,
(unsigned long)iter.tno);
ok = 1;
}
break;
case 'u':
if (n == 1 && num[0] < MAXMAPS)
{
l2g_dump(&maps[num[0]], stdout);
l2g_dump(stdout, &maps[num[0]]);
ok = 1;
}
break;
case 'r':
if (n == 1 && num[0] < MAXMAPS)
{
l2g_read(&maps[num[0]], stdin);
int c;
l2g_read(stdin, &maps[num[0]]);
if ((c = getchar()) != '\n')
{
printf("BAD INPUT: got char %d instead of newline\n", c);
fflush(stdout);
}
ok = 1;
}
break;
case 'p':
case 'w':
if (n == 1 && num[0] < MAXMAPS)
{
l2g_write(&maps[num[0]], stdout);
l2g_write(stdout, &maps[num[0]]);
putchar('\n');
ok = 1;
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment