OSSP CVS Repository

ossp - Check-in [2255]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2255
Date: 2002-Jul-08 15:45:13 (local)
2002-Jul-08 13:45:13 (UTC)
User:rse
Branch:
Comment: add more error checking
Tickets:
Inspections:
Files:
ossp-pkg/cfg/Makefile      1.6 -> 1.7     4 inserted, 0 deleted
ossp-pkg/cfg/cfg_syn.c      1.9 -> 1.10     8 inserted, 0 deleted
ossp-pkg/cfg/cfg_syn_scan.l      1.6 -> 1.7     16 inserted, 0 deleted

ossp-pkg/cfg/Makefile 1.6 -> 1.7

--- Makefile     2002/07/05 17:30:23     1.6
+++ Makefile     2002/07/08 13:45:13     1.7
@@ -16,6 +16,7 @@
 RM     = rm -f
 BISON  = bison
 FLEX   = flex-beta
+GDB    = gdb
 
 LIB    = libcfg.a
 OBJ    = cfg_buf.o cfg_grid.o cfg_data.o cfg_node.o cfg_fmt.o cfg_syn.o cfg_syn_parse.o cfg_syn_scan.o cfg_util.o
@@ -53,3 +54,6 @@
         ./$(TST) sample.cfg
         ./$(TST) sample2.cfg
 
+debug: $(TST)
+        $(GDB) $(TST)
+


ossp-pkg/cfg/cfg_syn.c 1.9 -> 1.10

--- cfg_syn.c    2002/07/05 20:49:58     1.9
+++ cfg_syn.c    2002/07/08 13:45:13     1.10
@@ -109,7 +109,15 @@
 
     /* determine first and last positions of token */
     cpF = ctx->inputbuf+loc->first;
+    if (cpF < ctx->inputbuf)
+        cpF = ctx->inputbuf;
+    if (cpF > ctx->inputbuf+ctx->inputlen)
+        cpF = ctx->inputbuf+ctx->inputlen;
     cpL = ctx->inputbuf+loc->last;
+    if (cpL < ctx->inputbuf)
+        cpL = ctx->inputbuf;
+    if (cpL > ctx->inputbuf+ctx->inputlen)
+        cpL = ctx->inputbuf+ctx->inputlen;
 
     /* determine epilog and prolog of token */
     cpP = cpF-4;


ossp-pkg/cfg/cfg_syn_scan.l 1.6 -> 1.7

--- cfg_syn_scan.l       2002/07/06 18:44:46     1.6
+++ cfg_syn_scan.l       2002/07/08 13:45:13     1.7
@@ -101,6 +101,10 @@
 <SS_CO_C>(.|\n) {
     /* no-op */
 }
+<SS_CO_C><<EOF>> {
+    cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated C-style block comment");
+    return 0;
+}
 
     /* C++-style EOL comment */
 "//"[^\n]* {
@@ -159,6 +163,10 @@
 <SS_DQ>(.|\n) {
     *cpStr++ = yytext[1];
 }
+<SS_DQ><<EOF>> {
+    cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated double-quoted string");
+    return 0;
+}
 
     /* single-quoted word ('...') */
 \' {
@@ -189,6 +197,10 @@
 <SS_SQ>(.|\n) {
     *cpStr++ = yytext[1];
 }
+<SS_SQ><<EOF>> {
+    cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated single-quoted string");
+    return 0;
+}
 
     /* flexible-quoted word (q(.)[^\1]\1)
        the delimiting character has to one a special character c, i.e.,
@@ -235,6 +247,10 @@
     else
         *cpStr++ = yytext[0];
 }
+<SS_FQ><<EOF>> {
+    cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated flexible-quoted string");
+    return 0;
+}
 
    /* special tokens */
 ";" { return T_SEP;   }

CVSTrac 2.0.1