summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4000988)
EndsWithC returns true if non-NULL string s ends with a c before the
terminating NUL.
char *rfind_str (const char [], size_t, const char *);
char *nmh_strcasestr (const char *, const char *);
char *rfind_str (const char [], size_t, const char *);
char *nmh_strcasestr (const char *, const char *);
+bool EndsWithC(char *s, int c);
void TrimSuffixC(char *s, int c);
/*
void TrimSuffixC(char *s, int c);
/*
+/* EndsWithC returns true if non-NULL string s ends with a c before the
+ * terminating NUL. */
+bool EndsWithC(char *s, int c)
+{
+ return *s && s[strlen(s) - 1] == c;
+}
+
+
/* TrimSuffixC deletes c from the end of non-NULL string s if it's
* present, shortening s by 1. Only one instance of c is removed. */
void TrimSuffixC(char *s, int c)
/* TrimSuffixC deletes c from the end of non-NULL string s if it's
* present, shortening s by 1. Only one instance of c is removed. */
void TrimSuffixC(char *s, int c)
* If program was invoked with name ending
* in `s', then add switch `-all'.
*/
* If program was invoked with name ending
* in `s', then add switch `-all'.
*/
- if (argv[0][strlen (argv[0]) - 1] == 's')
- all = TRUE;
+ all = EndsWithC(argv[0], 's');
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
* If program was invoked with name ending
* in `s', then add switch `-all'.
*/
* If program was invoked with name ending
* in `s', then add switch `-all'.
*/
- if (argv[0][strlen (argv[0]) - 1] == 's')
- all = 1;
+ all = EndsWithC(argv[0], 's');
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;