#include "token.h"
#include "listing.h"
-int errcnt; // Error count
-char * err_fname; // Name of error message file
+int errcnt; // Error count
+char * err_fname; // Name of error message file
-static char nl[] = "\n";
+static const char nl[] = "\n";
+static long unused; // For supressing 'write' warnings
//
//
int at_eol(void)
{
- if (*tok != EOL)
- error("syntax error");
+ if (*tok != EOL)
+ error("syntax error");
- return 0;
+ return 0;
}
//
// Cannot Create a File
//
-void cantcreat(char * fn)
+void cantcreat(const char * fn)
{
- printf("cannot create: '%s'\n", fn);
- exit(1);
+ printf("cannot create: '%s'\n", fn);
+ exit(1);
}
{
char fnbuf[FNSIZ];
- setfnum(cfileno);
+// This seems like it's unnecessary, as token.c seems to take care of this all by itself.
+// Can restore if it's really needed. If not, into the bit bucket it goes. :-)
+// setfnum(cfileno);
if (err_fname != NULL)
{
//
// Display Error Message
//
-int error(char * s)
+int error(const char * s)
{
char buf[EBUFSIZ];
unsigned int length;
if (listing > 0)
ship_ln(s);
- sprintf(buf, "%s%d: Error: %s%s", curfname, curlineno, s, nl);
+ sprintf(buf, "%s %d: Error: %s%s", curfname, curlineno, s, nl);
length = strlen(buf);
if (err_flag)
- write(err_fd, buf, length);
+ unused = write(err_fd, buf, length);
else
printf("%s", buf);
taglist('E');
- ++errcnt;
+ errcnt++;
return ERROR;
}
-int errors(char * s, char * s1)
+
+int errors(const char * s, char * s1)
{
char buf[EBUFSIZ];
char buf1[EBUFSIZ];
if (listing > 0)
ship_ln(buf);
- sprintf(buf1, "%s%d: Error: %s%s", curfname, curlineno, buf, nl);
+ sprintf(buf1, "%s %d: Error: %s%s", curfname, curlineno, buf, nl);
if (err_flag)
- write(err_fd, buf1, (LONG)strlen(buf1));
+ unused = write(err_fd, buf1, (LONG)strlen(buf1));
else
printf("%s", buf1);
return ERROR;
}
-int warn(char * s)
+
+int warn(const char * s)
{
char buf[EBUFSIZ];
if (listing > 0)
ship_ln(s);
- sprintf(buf, "%s%d: Warning: %s%s", curfname, curlineno, s, nl);
+ sprintf(buf, "%s %d: Warning: %s%s", curfname, curlineno, s, nl);
if (err_flag)
- write(err_fd, buf, (LONG)strlen(buf));
+ unused = write(err_fd, buf, (LONG)strlen(buf));
else
printf("%s", buf);
return OK;
}
-int warns(char * s, char * s1)
+
+int warns(const char * s, char * s1)
{
char buf[EBUFSIZ];
char buf1[EBUFSIZ];
if (listing > 0)
ship_ln(s);
- sprintf(buf1, "%s%d: Warning: %s%s", curfname, curlineno, buf, nl);
+ sprintf(buf1, "%s %d: Warning: %s%s", curfname, curlineno, buf, nl);
if (err_flag)
- write(err_fd, buf1, (LONG)strlen(buf1));
+ unused = write(err_fd, buf1, (LONG)strlen(buf1));
else
printf("%s", buf1);
return OK;
}
-int warni(char * s, unsigned i)
+
+int warni(const char * s, unsigned i)
{
char buf[EBUFSIZ];
char buf1[EBUFSIZ];
if (listing > 0)
ship_ln(buf);
- sprintf(buf1, "%s%d: Warning: %s%s", curfname, curlineno, buf, nl);
+ sprintf(buf1, "%s %d: Warning: %s%s", curfname, curlineno, buf, nl);
if (err_flag)
- write(err_fd, buf1, (LONG)strlen(buf1));
+ unused = write(err_fd, buf1, (LONG)strlen(buf1));
else
printf("%s", buf1);
return OK;
}
-int fatal(char * s)
+
+int fatal(const char * s)
{
char buf[EBUFSIZ];
if (listing > 0)
ship_ln(s);
- sprintf(buf, "%s%d: Fatal: %s%s", curfname, curlineno, s, nl);
+ sprintf(buf, "%s %d: Fatal: %s%s", curfname, curlineno, s, nl);
if (err_flag)
- write(err_fd, buf, (LONG)strlen(buf));
+ unused = write(err_fd, buf, (LONG)strlen(buf));
else
printf("%s", buf);
exit(1);
}
+
int interror(int n)
{
char buf[EBUFSIZ];
err_setup();
- sprintf(buf, "%s%d: Internal Error Number %d%s", curfname, curlineno, n, nl);
+ sprintf(buf, "%s %d: Internal Error Number %d%s", curfname, curlineno, n, nl);
if (listing > 0)
ship_ln(buf);
if (err_flag)
- write(err_fd, buf, (LONG)strlen(buf));
+ unused = write(err_fd, buf, (LONG)strlen(buf));
else
printf("%s", buf);
exit(1);
}
+