- FILE* ccproc;
-
- if (lstat (sunpro_cc, &sb) == 0) {
- strcpy (cmd, sunpro_cc);
- strcat (cmd, " -V 2>&1");
- if ((ccproc = popen (cmd, "r")) != NULL) {
- if (fgets (buf, PATH_MAX, ccproc) != NULL) {
- vptr = strrchr (buf, 'C');
- for (; !isdigit(*vptr); vptr++);
- (void) sscanf (vptr, "%d.%d", &cmajor, &cminor);
- fprintf (inFile,
- "#define DefaultSunProCCompilerMajorVersion %d\n",
- cmajor);
- fprintf (inFile,
- "#define DefaultSunProCCompilerMinorVersion %d\n",
- cminor);
+ FILE *ccproc;
+ int ret;
+ char vendor[4];
+
+ if (lstat (fspec, &sb) != 0)
+ return ENOENT;
+
+ strncpy (cmd, fspec, PATH_MAX);
+ strlcpy (vendor, product, 4);
+
+ if (strcmp (vendor, "Sun") == 0)
+ strncat (cmd, " -V 2>&1", 8);
+ else if (strcmp (vendor, "Gnu") == 0)
+ strncat (cmd, " --version 2>&1", 15);
+ else
+ return EINVAL;
+
+ if ((ccproc = popen (cmd, "r")) != NULL) {
+ if (fgets (buf, PATH_MAX, ccproc) != NULL) {
+ for (vptr = buf; !isdigit(*vptr) && *vptr != NULL; vptr++);
+ if (*vptr == NULL) {
+ pclose (ccproc);
+ return EINVAL;
+ } else {
+ ret = sscanf (vptr, "%d.%d", cmajor, cminor);