2011-06-19 Paul Eggert <eggert@cs.ucla.edu>
+ * emacs.c: Don't assume string length fits in 'int'.
+ (DEFINE_DUMMY_FUNCTION, sort_args): Use ptrdiff_t, not int.
+ (main): Don't invoke strlen when not needed.
+
* dbusbind.c (XD_ERROR): Don't arbitrarily truncate string.
(XD_DEBUG_MESSAGE): Don't waste a byte.
int minlen, char **valptr, int *skipptr)
{
char *p = NULL;
- int arglen;
+ ptrdiff_t arglen;
char *arg;
/* Don't access argv[argc]; give up in advance. */
dname_arg2[0] = '\0';
sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]),
dname_arg2);
- dname_arg = strlen (dname_arg2) ? dname_arg2 : NULL;
+ dname_arg = *dname_arg2 ? dname_arg2 : NULL;
}
#endif /* NS_IMPL_COCOA */
priority[from] = 0;
if (argv[from][0] == '-')
{
- int match, thislen;
- char *equals;
+ int match;
/* If we have found "--", don't consider
any more arguments as options. */
>= 0 (the table index of the match) if just one match so far. */
if (argv[from][1] == '-')
{
+ char const *equals = strchr (argv[from], '=');
+ ptrdiff_t thislen =
+ equals ? equals - argv[from] : strlen (argv[from]);
+
match = -1;
- thislen = strlen (argv[from]);
- equals = strchr (argv[from], '=');
- if (equals != 0)
- thislen = equals - argv[from];
for (i = 0;
i < sizeof (standard_args) / sizeof (standard_args[0]); i++)