commands now takes arguments and line start at 1
This commit is contained in:
parent
731da51b61
commit
7c73c27e75
@ -1,4 +1,4 @@
|
|||||||
cmd_add(text)
|
cmd_add(text, args)
|
||||||
{
|
{
|
||||||
local line;
|
local line;
|
||||||
local i, j;
|
local i, j;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
cmd_print(text)
|
cmd_print(text, args)
|
||||||
{
|
{
|
||||||
putstr([[text + LOCATION_ARRAY] + [text + LOCATION_CURRENT_LINE]]);
|
putstr([[text + LOCATION_ARRAY] + [text + LOCATION_CURRENT_LINE]]);
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@ parsing(text, cmd_ptr)
|
|||||||
if (isdigit([input]) == 1)
|
if (isdigit([input]) == 1)
|
||||||
{
|
{
|
||||||
line_application = aton(input);
|
line_application = aton(input);
|
||||||
if (line_application >= [text + LOCATION_LENGTH])
|
if (line_application == 0 | line_application >= [text + LOCATION_LENGTH] + 1)
|
||||||
{
|
{
|
||||||
[cmd_ptr] = NULL;
|
[cmd_ptr] = NULL;
|
||||||
putstr("invalid line\n");
|
putstr("invalid line\n");
|
||||||
free(input);
|
free(input);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
[text + LOCATION_CURRENT_LINE] = line_application;
|
[text + LOCATION_CURRENT_LINE] = line_application - 1;
|
||||||
}
|
}
|
||||||
tmp = input;
|
tmp = input;
|
||||||
loop
|
loop
|
||||||
@ -66,11 +66,10 @@ main()
|
|||||||
return 1;
|
return 1;
|
||||||
if (cmd != NULL)
|
if (cmd != NULL)
|
||||||
{
|
{
|
||||||
dbg [text + LOCATION_CURRENT_LINE];
|
|
||||||
if (strcmp(cmd, "a") == 0)
|
if (strcmp(cmd, "a") == 0)
|
||||||
cmd_add(text);
|
cmd_add(text, NULL);
|
||||||
else if (strcmp(cmd, "p") == 0)
|
else if (strcmp(cmd, "p") == 0)
|
||||||
cmd_print(text);
|
cmd_print(text, NULL);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user