summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-01-21 19:25:05 +0200
committerToomas Soome <tsoome@me.com>2019-06-18 20:21:20 +0300
commite207f0de2012ff5024160daa7e6e3cf11d04f2dc (patch)
tree36a655e318578dc0c22334422b2462236a682548
parent077efea49519c17f19d69473223f9664f3c94812 (diff)
downloadillumos-joyent-e207f0de2012ff5024160daa7e6e3cf11d04f2dc.tar.gz
11111 lex: NULL pointer errors
Reviewed by: Rob Johnston <rob.johnston@joyent.com> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/cmd/sgs/lex/common/ldefs.h8
-rw-r--r--usr/src/cmd/sgs/lex/common/sub1.c40
2 files changed, 23 insertions, 25 deletions
diff --git a/usr/src/cmd/sgs/lex/common/ldefs.h b/usr/src/cmd/sgs/lex/common/ldefs.h
index b94134fcfa..18758ea191 100644
--- a/usr/src/cmd/sgs/lex/common/ldefs.h
+++ b/usr/src/cmd/sgs/lex/common/ldefs.h
@@ -29,8 +29,6 @@
#ifndef _LDEFS_H
#define _LDEFS_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <stdlib.h>
@@ -129,7 +127,7 @@
* example, a lex character class "[_0-9a-zA-Z]"
* would be translated to the intermidiate
* form:
- * RCCL
+ * RCCL
* |
* |
* v
@@ -250,8 +248,8 @@ void phead2(void);
void ptail(void);
void statistics(void);
void error_tail(void) __NORETURN;
-void error();
-void warning();
+void error(char *, ...);
+void warning(char *, ...);
void lgate(void);
void scopy(CHR *s, CHR *t);
void cclinter(int sw);
diff --git a/usr/src/cmd/sgs/lex/common/sub1.c b/usr/src/cmd/sgs/lex/common/sub1.c
index 69eb0b545c..f1d3fa601b 100644
--- a/usr/src/cmd/sgs/lex/common/sub1.c
+++ b/usr/src/cmd/sgs/lex/common/sub1.c
@@ -26,8 +26,8 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
+#include <stdio.h>
+#include <stdarg.h>
#include "ldefs.h"
#include <limits.h>
@@ -88,23 +88,23 @@ digit(int c)
return (c >= '0' && c <= '9');
}
-/* VARARGS1 */
void
-error(s, p, d)
-char *s;
-int p, d;
+error(char *s, ...)
{
+ va_list ap;
+
/* if(!eof) */
- if (!yyline)
+ if (!yyline) {
(void) fprintf(errorf, "Command line: ");
- else {
+ } else {
(void) fprintf(errorf,
- !no_input ? "" : "\"%s\":", sargv[optind]);
+ !no_input ? "" : "\"%s\":", sargv[optind]);
(void) fprintf(errorf, "line %d: ", yyline);
}
(void) fprintf(errorf, "Error: ");
- /*LINTED: E_SEC_PRINTF_VAR_FMT*/
- (void) fprintf(errorf, s, p, d);
+ va_start(ap, s);
+ (void) vfprintf(errorf, s, ap);
+ va_end(ap);
(void) putc('\n', errorf);
if (fatal)
error_tail();
@@ -126,24 +126,24 @@ error_tail(void)
/* NOTREACHED */
}
-/* VARARGS1 */
void
-warning(s, p, d)
-char *s;
-int p, d;
+warning(char *s, ...)
{
+ va_list ap;
+
if (!eof)
if (!yyline)
(void) fprintf(errorf, "Command line: ");
else {
(void) fprintf(errorf,
- !no_input?"":"\"%s\":", sargv[optind]);
+ !no_input ? "" : "\"%s\":", sargv[optind]);
(void) fprintf(errorf,
- "line %d: ", yyline);
+ "line %d: ", yyline);
}
(void) fprintf(errorf, "Warning: ");
- /*LINTED: E_SEC_PRINTF_VAR_FMT*/
- (void) fprintf(errorf, s, p, d);
+ va_start(ap, s);
+ (void) vfprintf(errorf, s, ap);
+ va_end(ap);
(void) putc('\n', errorf);
(void) fflush(errorf);
if (fout)
@@ -490,7 +490,7 @@ cpycom(CHR *p)
* FIX BUG #1058428, not parsing comments correctly
* that span more than one line
*/
- if (*t != NULL)
+ if (*t != 0)
(void) putc(*t++, fout);
}
(void) putc('\n', fout);