temp = cuserid((char *)NULL);
/* the_user */
the_user_len = strlen(temp);
- the_user = alloc_string(the_user_len + 1);
- xstrncpy(the_user, the_user_len, temp);
+ the_user = alloc_string(the_user_len);
+ xstrncpy(the_user, temp, the_user_len+1);
/* alloc the_string */
the_string_len = 3 + prefix_length + the_user_len + date_length;
the_string = alloc_string(the_string_len);
- temp_len = the_string_len;
+ temp_len = the_string_len+1;
temp = the_string;
- xstrncpy(temp, temp_len, FROM_PREFIX);
+ xstrncpy(temp, FROM_PREFIX, temp_len);
temp = &temp[prefix_length];
*temp++ = ' ';
temp_len -= prefix_length + 1;
- xstrncpy(temp, temp_len, the_user);
+ xstrncpy(temp, the_user, temp_len);
temp = &temp[the_user_len];
*temp++ = ' ';
temp_len -= the_user_len + 1;
- xstrncpy(temp, temp_len, the_date);
+ xstrncpy(temp, the_date, temp_len);
result = new_list();
result->string = the_string;
char *skip_non_spaces PP((char *cp));
char *savenstr PP((char *cp, int len));
char *savestr PP((char *cp));
-char *etags_strchr PP((char *sp, int c));
-char *etags_strrchr PP((char *sp, int c));
char *etags_getcwd PP((void));
char *relative_filename PP((char *file, char *dir));
char *absolute_filename PP((char *file, char *dir));
long *xmalloc PP((unsigned int size));
long *xrealloc PP((char *ptr, unsigned int size));
\f
+#if HAVE_STRRCHR
+#define etags_strrchr strrchr
+#else
+/*
+ * Return the ptr in sp at which the character c last
+ * appears; NULL if not found
+ *
+ * Identical to POSIX strrchr, included for portability.
+ */
+static char *
+etags_strrchr (sp, c)
+register const char *sp;
+register int c;
+{
+ register const char *r;
+
+ r = NULL;
+ do
+ {
+ if (*sp == c)
+ r = sp;
+ } while (*sp++);
+ return (char *)r;
+}
+#endif
+
+#if HAVE_STRCHR
+#define etags_strchr strchr
+#else
+/*
+ * Return the ptr in sp at which the character c first
+ * appears; NULL if not found
+ *
+ * Identical to POSIX strchr, included for portability.
+ */
+static char *
+etags_strchr (sp, c)
+register const char *sp;
+register int c;
+{
+ do
+ {
+ if (*sp == c)
+ return (char *)sp;
+ } while (*sp++);
+ return NULL;
+}
+#endif
+\f
char searchar = '/'; /* use /.../ searches */
char *tagfile; /* output file */
objdef = omethodtag;
methodlen = len;
grow_linebuffer(&token_name, methodlen + 1);
- xstrncpy(token_name.buffer, str, len);
+ xstrncpy(token_name.buffer, str, methodlen+1);
token_name.buffer[methodlen] = '\0';
token_name.len = methodlen;
return TRUE;
newlb.
buffer +
tokoff,
- toklen);
- token_name.
- buffer
- [toklen] =
- '\0';
+ toklen + 1);
token_name.len =
toklen;
/* Name macros. */
/* save all values for later tagging */
grow_linebuffer(&tline, lb.len + 1);
- xstrncpy(tline.buffer, lb.buffer, lb.len);
+ xstrncpy(tline.buffer, lb.buffer, lb.len + 1);
save_lineno = lineno;
save_lcno = linecharno;
else if (len + 1 > allocated)
last = xrnew(last, len + 1, char);
allocated = len + 1;
- xstrncpy(last, cp, len);
- last[len] = '\0';
+ xstrncpy(last, cp, allocated);
}
}
free(last);
else if (len + 1 > allocated)
last = xrnew(last, len + 1, char);
allocated = len + 1;
- xstrncpy(last, cp, len);
- last[len] = '\0';
+ xstrncpy(last, cp, allocated);
}
}
free(last);
size -= 1;
/* Allocate space and do the substitutions. */
- result = xnew(size + 1, char);
+ size_t avail = size + 1;
+ result = xnew(avail, char);
for (t = result; *out != '\0'; out++)
if (*out == '\\' && isdigit(*++out)) {
/* Using "dig2" satisfies my debugger. Bleah. */
dig = *out - '0';
diglen = regs->end[dig] - regs->start[dig];
- xstrncpy(t, in + regs->start[dig], diglen);
+ xstrncpy(t, in + regs->start[dig], avail);
t += diglen;
- } else
+ avail -= diglen;
+ } else {
*t++ = *out;
+ avail --;
+ }
*t = '\0';
if (DEBUG && (t > result + size || t - result != strlen(result)))
register char *dp;
dp = xnew(len + 1, char);
- xstrncpy(dp, cp, len);
+ xstrncpy(dp, cp, len+1);
dp[len] = '\0';
return dp;
}
-/*
- * Return the ptr in sp at which the character c last
- * appears; NULL if not found
- *
- * Identical to System V strrchr, included for portability.
- */
-char *etags_strrchr(sp, c)
-register char *sp;
-register int c;
-{
- register char *r;
-
- r = NULL;
- do {
- if (*sp == c)
- r = sp;
- } while (*sp++);
- return r;
-}
-
-/*
- * Return the ptr in sp at which the character c first
- * appears; NULL if not found
- *
- * Identical to System V strchr, included for portability.
- */
-char *etags_strchr(sp, c)
-register char *sp;
-register int c;
-{
- do {
- if (*sp == c)
- return sp;
- } while (*sp++);
- return NULL;
-}
-
/* Skip spaces, return new pointer. */
char *skip_spaces(cp)
char *cp;
xstrncpy(res, file, len);
/* if we were using side effects we woulda matched the above cond */
result = dirname(res);
- xstrncpy(res, result, xmin_size_t(len, xstrlen(result)));
+ xstrncpy(res, result, len);
return;
}
#elif defined(HAVE_DIRNAME)
{
/* assumes res is malloc'd of size LEN */
char *result = dirname(res);
- xstrncpy(res, result, xmin_size_t(len, xstrlen(result)));
+ xstrncpy(res, result, len);
return;
}
#endif
extern_inline char*
xdirname(const char *file)
{
- size_t len = xstrlen(file);
+ size_t len = xstrlen(file)+1;
char *res = xmalloc_atomic(len);
x__dirname(res, file, len);