- }
-
- cp = NULL;
- if ((cmd = concat(proc, " ", quotec, file_name, quotec, NULL))) {
- FILE *fp;
-
- if ((fp = popen(cmd, "r")) != NULL) {
-
- buf[0] = '\0';
- if (fgets(buf, sizeof buf, fp)) {
- char *eol;
-
- /* Skip leading <filename>:<whitespace>, if present. */
- if ((cp = strchr(buf, ':')) != NULL) {
- ++cp;
- while (*cp && isblank((unsigned char) *cp)) {
- ++cp;
- }
- } else {
- cp = buf;
- }
-
- /* Truncate at newline (LF or CR), if present. */
- if ((eol = strpbrk(cp, "\n\r")) != NULL) {
- *eol = '\0';
- }
- } else if (buf[0] == '\0') {
- /* This can happen on Cygwin if the popen()
- mysteriously fails. Return NULL so that the caller
- will use another method to determine the info. */
- free (cp);
- cp = NULL;
- }