ref: ad7078ab39dda36b08c4e673202bf5b34cd56acb
parent: 1e65f096bbff9993fedc691c440837d20737a8a3
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri Mar 2 08:14:22 EST 2018
cp: the zero-th argument
--- a/cp.c
+++ b/cp.c
@@ -73,7 +73,7 @@
cp_noninext();
}
if (str_get(map(reg)))
- in_push(str_get(map(reg)), buf ? args + 1 : NULL);
+ in_push(str_get(map(reg)), buf ? args : NULL);
else if (!n_cp)
tr_req(map(reg), args);
free(buf);
@@ -92,7 +92,7 @@
char *s;
int i;
sbuf_init(&sb);
- for (i = 1; i <= in_nargs(); i++) {
+ for (i = 1; i < in_nargs(); i++) {
sbuf_append(&sb, i > 1 ? " " : "");
sbuf_append(&sb, quote ? "\"" : "");
s = in_arg(i);
@@ -126,7 +126,7 @@
return;
}
argnum = atoi(argname);
- if (argnum > 0 && argnum < NARGS + 1)
+ if (argnum >= 0 && argnum < NARGS)
arg = in_arg(argnum);
if (arg)
in_push(arg, NULL);
--- a/in.c
+++ b/in.c
@@ -143,7 +143,8 @@
struct inbuf *cur = buf;
while (cur && !cur->args)
cur = cur->prev;
- return cur && cur->args && cur->args[i - 1] ? cur->args[i - 1] : "";
+ return cur && cur->args && i < NARGS &&
+ cur->args[i] ? cur->args[i] : "";
}
int in_nargs(void)
--- a/reg.c
+++ b/reg.c
@@ -114,7 +114,7 @@
sprintf(numbuf, "%s", directory(in_filename()));
return numbuf;
case '$':
- sprintf(numbuf, "%d", in_nargs());
+ sprintf(numbuf, "%d", in_nargs() - 1);
return numbuf;
}
}
--- a/tr.c
+++ b/tr.c
@@ -54,7 +54,7 @@
static void tr_rr(char **args)
{
int i;
- for (i = 1; i <= NARGS; i++)
+ for (i = 1; i < NARGS; i++)
if (args[i])
num_del(map(args[i]));
}
@@ -87,7 +87,7 @@
static void tr_rm(char **args)
{
int i;
- for (i = 1; i <= NARGS; i++)
+ for (i = 1; i < NARGS; i++)
if (args[i])
str_rm(map(args[i]));
}
@@ -612,7 +612,7 @@
{
struct font *fn = args[1] ? dev_font(dev_pos(args[1])) : NULL;
int i;
- for (i = 2; i <= NARGS; i++)
+ for (i = 2; i < NARGS; i++)
if (fn && args[i] && args[i][0] && args[i][1])
font_feat(fn, args[i] + 1, args[i][0] == '+');
}
@@ -825,7 +825,7 @@
static void tr_rchar(char **args)
{
int i;
- for (i = 1; i <= NARGS; i++)
+ for (i = 1; i < NARGS; i++)
if (args[i])
cdef_remove(NULL, args[i]);
}
@@ -1230,7 +1230,7 @@
jmp_eol();
cp_copymode(0);
if (str_get(map(cmd)))
- in_push(str_get(map(cmd)), args + 1);
+ in_push(str_get(map(cmd)), args);
free(buf);
}
free(args[0]);