aboutsummaryrefslogtreecommitdiffstats
path: root/lcc/etc
diff options
context:
space:
mode:
Diffstat (limited to 'lcc/etc')
-rw-r--r--lcc/etc/bprint.c12
-rw-r--r--lcc/etc/lcc.c25
-rw-r--r--lcc/etc/linux.c4
3 files changed, 19 insertions, 22 deletions
diff --git a/lcc/etc/bprint.c b/lcc/etc/bprint.c
index d22f537..fd073ab 100644
--- a/lcc/etc/bprint.c
+++ b/lcc/etc/bprint.c
@@ -70,7 +70,7 @@ void *alloc(unsigned n) {
void emitdata(char *file) {
FILE *fp;
- if (fp = fopen(file, "w")) {
+ if ((fp = fopen(file, "w"))) {
struct file *p;
for (p = filelist; p; p = p->link) {
int i;
@@ -78,7 +78,7 @@ void emitdata(char *file) {
struct caller *r;
fprintf(fp, "1\n%s\n", p->name);
for (i = 0, q = p->funcs; q; i++, q = q->link)
- if (r = q->callers)
+ if ((r = q->callers))
for (i--; r; r = r->link)
i++;
fprintf(fp, "%d\n", i);
@@ -109,7 +109,7 @@ FILE *openfile(char *name) {
for (i = 0; dirs[i]; i++) {
char buf[200];
sprintf(buf, "%s/%s", dirs[i], name);
- if (fp = fopen(buf, "r"))
+ if ((fp = fopen(buf, "r")))
return fp;
}
return fopen(name, "r");
@@ -297,9 +297,9 @@ int findcount(char *file, int x, int y) {
struct count *c = cursor->counts;
for (l = 0, u = cursor->count - 1; l <= u; ) {
int k = (l + u)/2;
- if (c[k].y > y || c[k].y == y && c[k].x > x)
+ if (c[k].y > y || (c[k].y == y && c[k].x > x))
u = k - 1;
- else if (c[k].y < y || c[k].y == y && c[k].x < x)
+ else if (c[k].y < y || (c[k].y == y && c[k].x < x))
l = k + 1;
else
return c[k].count;
@@ -461,7 +461,7 @@ int main(int argc, char *argv[]) {
if (i < argc) {
int nf = i < argc - 1 ? 1 : 0;
for ( ; i < argc; i++, nf ? nf++ : 0)
- if (p = findfile(string(argv[i])))
+ if ((p = findfile(string(argv[i]))))
(*f)(p, nf);
else
fprintf(stderr, "%s: no data for `%s'\n", progname, argv[i]);
diff --git a/lcc/etc/lcc.c b/lcc/etc/lcc.c
index a52119b..3b8e6e2 100644
--- a/lcc/etc/lcc.c
+++ b/lcc/etc/lcc.c
@@ -11,6 +11,7 @@ static char rcsid[] = "Id: dummy rcsid";
#include <assert.h>
#include <ctype.h>
#include <signal.h>
+#include <unistd.h>
#ifndef TEMPDIR
#define TEMPDIR "/tmp"
@@ -47,7 +48,6 @@ extern char *stringf(const char *, ...);
extern int suffix(char *, char *[], int);
extern char *tempname(char *);
-extern int access(char *, int);
extern int getpid(void);
extern char *cpp[], *include[], *com[], *as[],*ld[], inputs[], *suffixes[];
@@ -71,7 +71,7 @@ char *tempdir = TEMPDIR; /* directory for temporary files */
static char *progname;
static List lccinputs; /* list of input directories */
-main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
int i, j, nf;
progname = argv[0];
@@ -93,7 +93,7 @@ main(int argc, char *argv[]) {
tempdir = getenv("TMPDIR");
assert(tempdir);
i = strlen(tempdir);
- for (; i > 0 && tempdir[i-1] == '/' || tempdir[i-1] == '\\'; i--)
+ for (; (i > 0 && tempdir[i-1] == '/') || tempdir[i-1] == '\\'; i--)
tempdir[i-1] = '\0';
if (argc <= 1) {
help();
@@ -149,7 +149,7 @@ main(int argc, char *argv[]) {
char *name = exists(argv[i]);
if (name) {
if (strcmp(name, argv[i]) != 0
- || nf > 1 && suffix(name, suffixes, 3) >= 0)
+ || (nf > 1 && suffix(name, suffixes, 3) >= 0))
fprintf(stderr, "%s:\n", name);
filename(name, 0);
} else
@@ -214,7 +214,6 @@ char *basepath(char *name) {
#define _P_WAIT 0
extern int fork(void);
extern int wait(int *);
-extern void execv(const char *, char *[]);
static int _spawnvp(int mode, const char *cmdname, char *argv[]) {
int pid, n, status;
@@ -261,7 +260,7 @@ static int callsys(char **av) {
}
for (i = 0; status == 0 && av[i] != NULL; ) {
int j = 0;
- char *s;
+ char *s = NULL;
for ( ; av[i] != NULL && (s = strchr(av[i], '\n')) == NULL; i++)
argv[j++] = av[i];
if (s != NULL) {
@@ -319,7 +318,7 @@ static void compose(char *cmd[], List a, List b, List c) {
if (s && isdigit(s[1])) {
int k = s[1] - '0';
assert(k >=1 && k <= 3);
- if (b = lists[k-1]) {
+ if ((b = lists[k-1])) {
b = b->link;
av[j] = alloc(strlen(cmd[i]) + strlen(b->str) - 1);
strncpy(av[j], cmd[i], s - cmd[i]);
@@ -452,7 +451,7 @@ static int filename(char *name, char *base) {
static List find(char *str, List list) {
List b;
- if (b = list)
+ if ((b = list))
do {
if (strcmp(str, b->str) == 0)
return b;
@@ -508,7 +507,7 @@ static void help(void) {
if (strncmp("-tempdir", msgs[i], 8) == 0 && tempdir)
fprintf(stderr, "; default=%s", tempdir);
}
-#define xx(v) if (s = getenv(#v)) fprintf(stderr, #v "=%s\n", s)
+#define xx(v) if ((s = getenv(#v))) fprintf(stderr, #v "=%s\n", s)
xx(LCCINPUTS);
xx(LCCDIR);
#ifdef WIN32
@@ -521,13 +520,13 @@ static void help(void) {
/* initinputs - if LCCINPUTS or include is defined, use them to initialize various lists */
static void initinputs(void) {
char *s = getenv("LCCINPUTS");
- List list, b;
+ List b;
if (s == 0 || (s = inputs)[0] == 0)
s = ".";
if (s) {
lccinputs = path2list(s);
- if (b = lccinputs)
+ if ((b = lccinputs))
do {
b = b->link;
if (strcmp(b->str, ".") != 0) {
@@ -701,7 +700,7 @@ static List path2list(const char *path) {
sep = ';';
while (*path) {
char *p, buf[512];
- if (p = strchr(path, sep)) {
+ if ((p = strchr(path, sep))) {
assert(p - path < sizeof buf);
strncpy(buf, path, p - path);
buf[p-path] = '\0';
@@ -767,7 +766,7 @@ int suffix(char *name, char *tails[], int n) {
for (i = 0; i < n; i++) {
char *s = tails[i], *t;
- for ( ; t = strchr(s, ';'); s = t + 1) {
+ for ( ; (t = strchr(s, ';')); s = t + 1) {
int m = t - s;
if (len > m && strncmp(&name[len-m], s, m) == 0)
return i;
diff --git a/lcc/etc/linux.c b/lcc/etc/linux.c
index a65636d..bf50025 100644
--- a/lcc/etc/linux.c
+++ b/lcc/etc/linux.c
@@ -2,8 +2,6 @@
#include <string.h>
-static char rcsid[] = "Dummy rcsid";
-
/*
TTimo - 10-18-2001
our binaries are named q3lcc q3rcc and q3cpp
@@ -26,7 +24,7 @@ char *cpp[] = { LCCDIR "q3cpp",
"$1", "$2", "$3", 0 };
char *include[] = {"-I" LCCDIR "include", "-I" LCCDIR "gcc/include", "-I/usr/include",
"-I" SYSTEM "include", 0 };
-char *com[] = {LCCDIR "q3rcc", "-target=x86/linux", "$1", "$2", "$3", 0 };
+char *com[] = {LCCDIR "q3rcc", "-target=bytecode", "$1", "$2", "$3", 0 };
char *as[] = { "/usr/bin/as", "-o", "$3", "$1", "$2", 0 };
// NOTE TTimo I don't think we have any use with the native linkage
// our target is always bytecode..