summaryrefslogtreecommitdiff
path: root/src/scan.l
diff options
context:
space:
mode:
authorMichael McConville <mmcconville@mykolab.com>2015-12-02 11:32:42 -0500
committerWill Estes <westes575@gmail.com>2015-12-02 14:39:09 -0500
commit399e94f904b913a4093295426820ab89fc3cd24f (patch)
treeac04185a0167975ba0b6ba6265a5a11e1e536761 /src/scan.l
parent9ba6e5283efd2fe454d3bc92eca960b3ebd91294 (diff)
Made string copying more standard.
copy_string() was a clone of the stdlib's strdup(). For safety, simplicity, and speed, we should use that instead. We introduce xstrdup() which wraps strdup() in a failure upon memory allocation errors.
Diffstat (limited to 'src/scan.l')
-rw-r--r--src/scan.l6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/scan.l b/src/scan.l
index bc316be..4a96f23 100644
--- a/src/scan.l
+++ b/src/scan.l
@@ -232,7 +232,7 @@ M4QEND "]]"
\"[^"\n]*\" {
flex_free( (void *) infilename );
- infilename = copy_string( yytext + 1 );
+ infilename = xstrdup(yytext + 1);
infilename[strlen( infilename ) - 1] = '\0';
}
. /* ignore spurious characters */
@@ -994,7 +994,7 @@ void set_input_file( char *file )
{
if ( file && strcmp( file, "-" ) )
{
- infilename = copy_string( file );
+ infilename = xstrdup(file);
yyin = fopen( infilename, "r" );
if ( yyin == NULL )
@@ -1004,7 +1004,7 @@ void set_input_file( char *file )
else
{
yyin = stdin;
- infilename = copy_string( "<stdin>" );
+ infilename = xstrdup("<stdin>");
}
linenum = 1;