Skip to content

Commit 0e64f83

Browse files
committed
配布のための中間生成ファイルの更新です。
update intermediate files for dist.
1 parent a07c882 commit 0e64f83

File tree

14 files changed

+21251
-9828
lines changed

14 files changed

+21251
-9828
lines changed

cobc/parser.c

Lines changed: 7576 additions & 7336 deletions
Large diffs are not rendered by default.

cobc/parser.h

Lines changed: 388 additions & 384 deletions
Large diffs are not rendered by default.

cobc/pplex.c

Lines changed: 624 additions & 504 deletions
Large diffs are not rendered by default.

cobc/pplex.l

Lines changed: 89 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ ALNUM_LITERAL \"[^\"\n]*\"|\'[^\'\n]*\'
131131
"SUPPRESS" { return SUPPRESS; }
132132
"PRINTING" { return PRINTING; }
133133
"REPLACING" { return REPLACING; }
134+
"LEADING" { return LEADING; }
135+
"TRAILING" { return TRAILING; }
134136
{WORD} {
135137
#ifdef I18N_UTF8
136138
convert_ucs_hyphen_minus (yytext);
@@ -790,43 +792,106 @@ ppecho (const char *text)
790792

791793
text_queue = cb_text_list_add (text_queue, text);
792794

793-
for (r = current_replace_list; r; r = r->next) {
794-
queue = text_queue;
795-
for (l = r->old_text; l; l = l->next) {
795+
while (text_queue) {
796+
for (r = current_replace_list; r; r = r->next) {
797+
queue = text_queue;
798+
for (l = r->old_text; l; l = l->next) {
799+
while (l && (l->text[0] == ' ' || l->text[0] == '\n')) {
800+
l = l->next;
801+
}
802+
if (l == NULL) {
803+
break;
804+
}
805+
while (queue && (queue->text[0] == ' ' ||
806+
queue->text[0] == '\n')) {
807+
queue = queue->next;
808+
}
809+
if (queue == NULL) {
810+
return; /* partial match */
811+
}
812+
if (r->replace_type == CB_REPLACE_LEADING) {
813+
break;
814+
} else if (r->replace_type == CB_REPLACE_TRAILING) {
815+
break;
816+
} else if (r->replace_type == CB_REPLACE_OTHER) {
817+
if (strcasecmp (l->text, queue->text) != 0) {
818+
break;
819+
}
820+
}
821+
queue = queue->next;
822+
}
823+
if (r->replace_type == CB_REPLACE_LEADING) {
824+
if (!l || !queue) {
825+
continue;
826+
}
827+
if (strncasecmp (l->text, queue->text, strlen (l->text)) == 0) {
828+
break;
829+
}
830+
} else if (r->replace_type == CB_REPLACE_TRAILING) {
831+
if (!l || !queue || strlen (queue->text) < strlen (r->old_text->text)) {
832+
continue;
833+
}
834+
if (strcasecmp (queue->text + strlen (queue->text) - strlen (r->old_text->text), r->old_text->text) == 0) {
835+
break;
836+
}
837+
} else if (l == NULL) {
838+
/* match */
839+
break;
840+
}
841+
}
842+
843+
/* match */
844+
if (r && r->replace_type == CB_REPLACE_LEADING) {
845+
int oldlen = strlen (l->text);
846+
for (l = text_queue; l != queue; l = l->next) {
847+
fputs (l->text, ppout);
848+
}
849+
l = r->new_text;
796850
while (l && (l->text[0] == ' ' || l->text[0] == '\n')) {
797851
l = l->next;
798852
}
799-
if (l == NULL) {
800-
break;
853+
if (l) {
854+
fputs (l->text, ppout);
801855
}
802-
while (queue && (queue->text[0] == ' ' ||
803-
queue->text[0] == '\n')) {
804-
queue = queue->next;
856+
fputs (queue->text + oldlen, ppout);
857+
queue = queue->next;
858+
} else if (r && r->replace_type == CB_REPLACE_TRAILING) {
859+
int i;
860+
int oldlen = strlen (l->text);
861+
for (l = text_queue; l != queue; l = l->next) {
862+
fputs (l->text, ppout);
805863
}
806-
if (queue == NULL) {
807-
return; /* partial match */
864+
for (i = 0; i < strlen (queue->text) - oldlen; i++) {
865+
fputc (queue->text[i], ppout);
808866
}
809-
if (strcasecmp (l->text, queue->text) != 0) {
810-
break;
867+
l = r->new_text;
868+
while (l && (l->text[0] == ' ' || l->text[0] == '\n')) {
869+
l = l->next;
870+
}
871+
if (l) {
872+
fputs (l->text, ppout);
811873
}
812874
queue = queue->next;
813-
}
814-
if (l == NULL) {
815-
/* match */
875+
} else if (r && l == NULL) {
816876
for (l = r->new_text; l; l = l->next) {
817877
fputs (l->text, ppout);
818878
}
819-
/*
820-
text_queue = queue ? queue->next : NULL;
821-
*/
822-
text_queue = queue;
823-
continue;
879+
} else {
880+
/* no match */
881+
if (!text_queue) {
882+
break;
883+
}
884+
fputs (text_queue->text, ppout);
885+
queue = text_queue->next;
824886
}
825-
}
826887

827-
/* no match */
828-
for (; text_queue; text_queue = text_queue->next) {
829-
fputs (text_queue->text, ppout);
888+
while (text_queue != queue) {
889+
if (!text_queue) break;
890+
891+
l = text_queue->next;
892+
free (text_queue);
893+
text_queue = l;
894+
}
830895
}
831896
}
832897
}

0 commit comments

Comments
 (0)