aboutsummaryrefslogtreecommitdiff
path: root/lex.c
diff options
context:
space:
mode:
authorzoulasc <zoulasc@users.noreply.github.com>2019-10-24 09:40:15 -0400
committerArnold Robbins <arnold@skeeve.com>2019-10-24 09:40:15 -0400
commit6589208eaf7e7da73a5a3fe8420c37c970206edc (patch)
tree79b28afbc59b47b32967ebcf004faecec437d9ae /lex.c
parent1633ba1c8830ccd6592f27c732980a60579d81f2 (diff)
downloadone-true-awk-6589208eaf7e7da73a5a3fe8420c37c970206edc.tar.gz
More cleanups: (#53)
- sprinkle const - add a macro (setptr) that cheats const to temporarily NUL terminate strings remove casts from allocations - use strdup instead of strlen+strcpy - use x = malloc(sizeof(*x)) instead of x = malloc(sizeof(type of *x))) - add -Wcast-qual (and casts through unitptr_t in the two macros we cheat (xfree, setptr)).
Diffstat (limited to 'lex.c')
-rw-r--r--lex.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lex.c b/lex.c
index 8be9cfa..d64fa0b 100644
--- a/lex.c
+++ b/lex.c
@@ -173,7 +173,7 @@ int yylex(void)
static char *buf = NULL;
static int bufsize = 5; /* BUG: setting this small causes core dump! */
- if (buf == NULL && (buf = (char *) malloc(bufsize)) == NULL)
+ if (buf == NULL && (buf = malloc(bufsize)) == NULL)
FATAL( "out of space in yylex" );
if (sc) {
sc = 0;
@@ -363,7 +363,7 @@ int string(void)
static char *buf = NULL;
static int bufsz = 500;
- if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL)
+ if (buf == NULL && (buf = malloc(bufsz)) == NULL)
FATAL("out of space for strings");
for (bp = buf; (c = input()) != '"'; ) {
if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, "string"))
@@ -510,7 +510,7 @@ int regexpr(void)
static int bufsz = 500;
char *bp;
- if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL)
+ if (buf == NULL && (buf = malloc(bufsz)) == NULL)
FATAL("out of space for rex expr");
bp = buf;
for ( ; (c = input()) != '/' && c != 0; ) {