commit 9cd765acd9c8cb41139dc26d68d4a2e428d92a18
parent 30229cba3c91d512f1190c770268f2d7e07cbd57
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Wed, 23 Dec 2020 11:43:43 -0800
Add goto command which acts on gopher items and fix bug
The cgoto() function is much better than sgoto because it's much
simpler, easier, and less error prone (say, when they have separators
in the name or cannot handle '//'[quux.org] and such).
Fix sunwind requiring an argument.
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -441,9 +441,12 @@ sunwind(int argc, const char **argv, int depth, const char **addr)
{
unsigned int n;
- if (badargs(1, 1, argc, argv))
+ if (badargs(0, 1, argc, argv))
return 1;
- if (strtorange(&n, 1, INT_MAX, argv[0]))
+
+ if (argc == 0)
+ n = 1;
+ else if (strtorange(&n, 1, INT_MAX, argv[0]))
return 0;
return n;
}
@@ -525,6 +528,12 @@ cextern(int argc, const char **argv, int index, const char **item)
return 0;
}
+int
+cgoto(int argc, const char **argv, int index, const char **item)
+{
+ return gawk(reqtoaddr(item));
+}
+
command *
getcommand(int c)
{
@@ -537,6 +546,8 @@ getcommand(int c)
return cfetch;
case 'e':
return cextern;
+ case 'G':
+ return cgoto;
default:
return NULL;
}