From dcdd19ed72ca8953fdf397bedc33c0e751dcbfb2 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Sun, 12 Nov 2006 18:24:55 +0000 Subject: [PATCH] The scanner regression test cases for error conditions in quoted strings uncovered three different bugs. This changeset fixes them all. It also updates the sensors.conf(5) man page to be unambiguous regarding the requirement for whitespace between elements. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4235 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/conf-lex.l | 24 +++++++++++++++++++++--- lib/sensors.conf.5 | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/conf-lex.l b/lib/conf-lex.l index 6668e724..f1770628 100644 --- a/lib/conf-lex.l +++ b/lib/conf-lex.l @@ -262,19 +262,37 @@ ignore{BLANK}* { { - /* Oops, newline while in a string is not good */ + /* Oops, newline or EOF while in a string is not good */ \n | \\\n { buffer_add_char("\0"); - strcpy(sensors_lex_error,"No matching double quote"); + strcpy(sensors_lex_error, + "No matching double quote."); buffer_free(); - BEGIN(INITIAL); + yyless(0); + BEGIN(ERR); + return ERROR; + } + +<> { + strcpy(sensors_lex_error, + "Reached end-of-file without a matching double quote."); + BEGIN(MIDDLE); return ERROR; } /* At the end */ +\"\" { + buffer_add_char("\0"); + strcpy(sensors_lex_error, + "Quoted strings must be separated by whitespace."); + buffer_free(); + BEGIN(ERR); + return ERROR; + } + \" { buffer_add_char("\0"); sensors_yylval.name = strdup(buffer); diff --git a/lib/sensors.conf.5 b/lib/sensors.conf.5 index 6de5905b..be2c7a7f 100644 --- a/lib/sensors.conf.5 +++ b/lib/sensors.conf.5 @@ -34,7 +34,7 @@ translate the raw readings from the kernel modules to real\-world values. .SH SYNTAX Comments are introduces by hash marks. A comment continues to the end of the line. Empty lines, and lines containing only whitespace or comments are -ignored. Other lines have one of the below forms. There should be whitespace +ignored. Other lines have one of the below forms. There must be whitespace between each element, but the amount of whitespace is unimportant. A line may be continued on the next line by ending it with a backslash; this does not work within a comment,