summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1999-02-12 20:56:49 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1999-02-12 20:56:49 +0000
commitfe444e3c5bdb3ba9391629947fecd764c992d8a6 (patch)
treed43f98ce66922e213db7a9103a222f770144f20d
parent56fc98761177ec30c5b9adb2a6f55176078a0ec0 (diff)
Notes
-rw-r--r--usr.bin/colldef/parse.y20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/colldef/parse.y b/usr.bin/colldef/parse.y
index ca377435fb51..8a817262b51d 100644
--- a/usr.bin/colldef/parse.y
+++ b/usr.bin/colldef/parse.y
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: parse.y,v 1.11 1998/12/06 22:58:17 archie Exp $
+ * $Id: parse.y,v 1.12 1999/02/12 20:39:05 ache Exp $
*/
#include <err.h>
@@ -86,6 +86,10 @@ charmap : DEFN CHAR {
substitute : SUBSTITUTE STRING WITH STRING {
u_char ch = $2[0];
+ if (strlen($2) > 1)
+ yyerror("Only characters can be substituted, not strings");
+ if (ch == '\0')
+ yyerror("NUL character can't be substituted");
if (strchr($4, ch) != NULL)
yyerror("Char 0x%02x substitution is recursive", ch);
strcpy(__collate_substitute_table[ch], $4);
@@ -93,14 +97,16 @@ substitute : SUBSTITUTE STRING WITH STRING {
;
order : ORDER order_list {
FILE *fp;
- int ch;
+ int ch, substed, ordered;
- for (ch = 0; ch < UCHAR_MAX + 1; ch++)
- if ( !__collate_char_pri_table[ch].prim
- && __collate_substitute_table[ch][0] == ch
- && __collate_substitute_table[ch][1] == '\0'
- )
+ for (ch = 0; ch < UCHAR_MAX + 1; ch++) {
+ substed = (__collate_substitute_table[ch][0] != ch);
+ ordered = !!__collate_char_pri_table[ch].prim;
+ if (!ordered && !substed)
yyerror("Char 0x%02x not found", ch);
+ if (substed && ordered)
+ yyerror("Char 0x%02x can't be ordered since substituted", ch);
+ }
fp = fopen(out_file, "w");
if(!fp)