Print this page
jlevon comments
*** 592,601 ****
--- 592,623 ----
nomem();
return (ret);
}
+ static boolean_t
+ is_source_file(const char *path)
+ {
+ char *ext = strrchr(path, '.');
+
+ if ((ext == NULL) || ((ext + 1) == '\0'))
+ return (B_FALSE);
+
+ ext += 1;
+
+ if ((strcasecmp(ext, "c") == 0) ||
+ (strcmp(ext, "cc") == 0) ||
+ (strcmp(ext, "i") == 0) ||
+ (strcasecmp(ext, "s") == 0) ||
+ (strcmp(ext, "cpp") == 0)) {
+ return (B_TRUE);
+ }
+
+ return (B_FALSE);
+ }
+
+
static void
do_gcc(cw_ictx_t *ctx)
{
int c;
int nolibc = 0;
*** 657,670 ****
*/
if (!in_output && arglen > 3 &&
strcmp(arg + arglen - 3, ".il") == 0)
continue;
! if (!in_output && arglen > 2 &&
! arg[arglen - 2] == '.' &&
! (arg[arglen - 1] == 'S' || arg[arglen - 1] == 's' ||
! arg[arglen - 1] == 'c' || arg[arglen - 1] == 'i'))
c_files++;
/*
* Otherwise, filenames and partial arguments
* are passed through for gcc to chew on. However,
--- 679,689 ----
*/
if (!in_output && arglen > 3 &&
strcmp(arg + arglen - 3, ".il") == 0)
continue;
! if (!in_output && is_source_file(arg))
c_files++;
/*
* Otherwise, filenames and partial arguments
* are passed through for gcc to chew on. However,
*** 1364,1385 ****
if (asprintf(&nameflag, "-_%s=", ctx->i_compiler->c_name) == -1)
nomem();
while (--ctx->i_oldargc > 0) {
char *arg = *++ctx->i_oldargv;
- size_t arglen = strlen(arg);
if (strncmp(arg, "-_CC=", 5) == 0) {
newae(ctx->i_ae, strchr(arg, '=') + 1);
continue;
}
if (*arg != '-') {
! if (!in_output && arglen > 2 &&
! arg[arglen - 2] == '.' &&
! (arg[arglen - 1] == 'S' || arg[arglen - 1] == 's' ||
! arg[arglen - 1] == 'c' || arg[arglen - 1] == 'i'))
c_files++;
if (in_output == 0 || !(ctx->i_flags & CW_F_SHADOW)) {
newae(ctx->i_ae, arg);
} else {
--- 1383,1400 ----
if (asprintf(&nameflag, "-_%s=", ctx->i_compiler->c_name) == -1)
nomem();
while (--ctx->i_oldargc > 0) {
char *arg = *++ctx->i_oldargv;
if (strncmp(arg, "-_CC=", 5) == 0) {
newae(ctx->i_ae, strchr(arg, '=') + 1);
continue;
}
if (*arg != '-') {
! if (!in_output && is_source_file(arg))
c_files++;
if (in_output == 0 || !(ctx->i_flags & CW_F_SHADOW)) {
newae(ctx->i_ae, arg);
} else {
*** 1676,1688 ****
errno = 0;
while ((dp = readdir(dirp)) != NULL) {
(void) snprintf(buf, MAXPATHLEN, "%s/%s", ctx->i_tmpdir,
dp->d_name);
! if (strncmp(dp->d_name, ".", strlen(dp->d_name)) == 0 ||
! strncmp(dp->d_name, "..", strlen(dp->d_name)) == 0)
continue;
if (unlink(buf) == -1)
err(1, "failed to unlink temp file: %s", dp->d_name);
errno = 0;
}
--- 1691,1704 ----
errno = 0;
while ((dp = readdir(dirp)) != NULL) {
(void) snprintf(buf, MAXPATHLEN, "%s/%s", ctx->i_tmpdir,
dp->d_name);
! if (strcmp(dp->d_name, ".") == 0 ||
! strcmp(dp->d_name, "..") == 0) {
continue;
+ }
if (unlink(buf) == -1)
err(1, "failed to unlink temp file: %s", dp->d_name);
errno = 0;
}