Some const correctness.
[gedcom-parse.git] / gedcom / gedcom.y
index 0564018e888f004ec6f70c99ece3ab97f543aaf1..2b52293d16d84b0c3b2f2a6b8409e51a794ad523 100644 (file)
@@ -3680,6 +3680,11 @@ user_sect   : OPEN DELIM opt_xref USERTAG
                      && compat_check_551_tag($4.string, &usertag_buffer)) {
                    $4.string = get_buf_string(&usertag_buffer);
                  }
+                 else if (compat_mode(C_SUBM_COMM) &&
+                          compat_check_subm_comm($4.string, get_parenttag(0),
+                                                 &usertag_buffer)) {
+                   $4.string = get_buf_string(&usertag_buffer);
+                 }
                  else {
                    gedcom_error(_("Undefined tag (and not a valid user tag): %s"),
                                 $4);
@@ -3696,11 +3701,21 @@ user_sect   : OPEN DELIM opt_xref USERTAG
              CLOSE
               { end_element(ELT_USER, PARENT, $<ctxt>7, 
                            GEDCOM_MAKE_NULL(val1));
+               if (compat_mode(C_SUBM_COMM))
+                 compat_close_subm_comm();
              }
             ;
 
 user_sects   : /* empty */     { }
             | user_sects user_sect { }
+            | user_sects gen_sect
+              { if (compat_mode(C_SUBM_COMM)) {
+                }
+               else {
+                 gedcom_error(_("Standard tag not allowed in user section"));
+                 YYERROR;
+               }
+             }
             ;
 
 opt_xref    : /* empty */        { $$ = NULL; }
@@ -3789,9 +3804,23 @@ error_sect  : OPEN DELIM opt_xref anytag opt_value error_subs CLOSE { }
             ;
 
 gen_sect    : OPEN DELIM opt_xref anystdtag
-              { INVALID_TAG($4.string); }
-              opt_value opt_sects CLOSE
-              { }
+              { if (compat_mode(C_SUBM_COMM)
+                   && compat_check_subm_comm_cont($4.string)) {
+                 /* Will pass here */
+               }
+               else {
+                 INVALID_TAG($4.string);
+               }
+             }
+              opt_value
+              { if (compat_mode(C_SUBM_COMM)) {
+                 $<ctxt>$ = compat_subm_comm_cont_start(PARENT, $6);
+                }
+             }
+             opt_sects CLOSE
+              { if (compat_mode(C_SUBM_COMM))
+                 compat_subm_comm_cont_end(PARENT, $<ctxt>7);
+             }
             ;
 
 gen_rec : gen_rec_top
@@ -3968,7 +3997,7 @@ Gedcom_ctxt ctxt_stack[MAXGEDCLEVEL+1];
 void push_countarray(int level)
 {
   int *count = NULL;
-  gedcom_debug_print("Push Count level: %d, level: %d\n", count_level, level);
+  gedcom_debug_print("Push Count level: %d, level: %d", count_level, level);
   if (count_level != level + 1) {
     gedcom_error(_("Internal error: count level mismatch"));
     exit(1);
@@ -3978,7 +4007,7 @@ void push_countarray(int level)
     exit(1);
   }
   else {
-    gedcom_debug_print("calloc countarray %d\n", count_level);
+    gedcom_debug_print("calloc countarray %d", count_level);
     count = (int *)calloc(YYNTOKENS, sizeof(int));
     if (count == NULL) {
       gedcom_error(_("Internal error: count array calloc error"));
@@ -4025,14 +4054,14 @@ int check_occurrence(int tag)
 void pop_countarray()
 {
   int *count;
-  gedcom_debug_print("Pop Count level: %d\n", count_level);
+  gedcom_debug_print("Pop Count level: %d", count_level);
   if (count_level < 0) {
     gedcom_error(_("Internal error: count array underflow"));
     exit(1);
   }
   else {
     count = count_arrays[count_level];
-    gedcom_debug_print("free countarray %d\n", count_level);
+    gedcom_debug_print("free countarray %d", count_level);
     free(count);
     count_arrays[count_level] = NULL;
   }
@@ -4040,7 +4069,7 @@ void pop_countarray()
 
 void clean_up()
 {
-  gedcom_debug_print("Cleanup countarrays\n");
+  gedcom_debug_print("Cleanup countarrays");
   while (count_level > 0) {
     pop_countarray();
     --count_level;