summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ff4d31)
raw | patch | inline | side by side (parent: 3ff4d31)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 27 May 2008 15:27:15 +0000 (17:27 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Tue, 27 May 2008 15:27:15 +0000 (17:27 +0200) |
src/processes.c | patch | blob | history |
diff --git a/src/processes.c b/src/processes.c
index 79451d320d3b500fd321edfd9fed226565d74c7a..14fe1d8cf040dff66e11f3f5a3562ba426bbd7c7 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
/* try to match name against entry, returns 1 if success */
static int ps_list_match (const char *name, const char *cmdline, procstat_t *ps)
{
- if ((ps->re != NULL) && (regexec(ps->re, (strlen(cmdline)!=0)?cmdline:name, 0, NULL, 0) == 0))
- return (1);
- if (strcmp (ps->name, name) == 0) {
- return (1);
+#if HAVE_REGEX_H
+ if (ps->re != NULL)
+ {
+ int status;
+ const char *str;
+
+ str = cmdline;
+ if ((str == NULL) || (str[0] == 0))
+ str = name;
+
+ assert (str != NULL);
+
+ status = regexec (ps->re, str,
+ /* nmatch = */ 0,
+ /* pmatch = */ NULL,
+ /* eflags = */ 0);
+ if (status == 0)
+ return (1);
}
+ else
+#endif
+ if (strcmp (ps->name, name) == 0)
+ return (1);
+
return (0);
-}
+} /* int ps_list_match */
/* add process entry to 'instances' of process 'name' (or refresh it) */
static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t *entry)