static char SccsId[] = "@(#)a2crd.c 3.6\t Mar. 1995"; static char copyright[] = "Copyright 1991-1995 by Martin Leclerc & Mario Dorion"; #include #include "chord.h" FILE *source_fd; int p_put, lchord, ltext, lbuf, c, debug_mode = 0, dirty_chord=0, dirty_text=0, in_header, in_title=0, in_subtitle=0, n_lines, in_chorus=0; char chord_line[MAXLINE], text_line[MAXLINE], buf[MAXLINE], *command_name, source[MAXTOKEN], *current_file, mesgbuf[MAXLINE], *mesg; float spaces=0, not_space=0; double ratio=1.0; extern char *optarg; extern int optind, opterr; /* --------------------------------------------------------------------------------*/ void print_2lines(chord_line, text_line) char chord_line[], text_line[]; { int i, mini=0, max=0; int p_out=0; max = (ltext > lchord) ? ltext : lchord; sprintf (mesg, " print_2lines text_line=[%s]", text_line); debug(mesg); sprintf (mesg, " print_2lines chord_line=[%s]", chord_line); debug(mesg); for (i = 0; i < max ; i++) { if ( (i <= lchord) && ( chord_line[i] != ' ' ) && (chord_line[i] != '\0') && ( i >= mini ) ) { printf ("["); for (mini=i; (chord_line[mini] != ' ') && (mini ratio) || ((spaces==0) && (lbuf<3)) ) /* this must be a chord line */ { sprintf (mesg, "chord is \"%s\"",buf); debug(mesg); if (dirty_chord) { print_2lines (chord_line, text_line); } strcpy (chord_line, buf); lchord=lbuf; dirty_chord++; in_title=0; in_subtitle=0; } else /* so it is a text line ! */ { sprintf (mesg, "text is \"%s\"",buf); debug(mesg); if (dirty_text) { print_2lines (chord_line, text_line); } if (in_title) { printf("{title:%s}\n", buf); in_title=FALSE; in_subtitle=TRUE; } else if (in_subtitle) { printf("{subtitle:%s}\n", buf); } else { strcpy(text_line, buf); ltext=lbuf; dirty_text++; } } lbuf=0; spaces=0; not_space=0; } else { if (dirty_chord || dirty_text) print_2lines(chord_line, text_line); printf ("\n"); if (in_chorus) { printf("{end_of_chorus}\n"); in_chorus=0; } in_subtitle=FALSE; in_title=FALSE; } for (i=0;i