[As with dev-letters.txt, the issue in making this official would be whether anyone would use it. Also needs documentation in cvsclient.texi. -kingdon] 1998-09-05 Jim Kingdon * log.c: Use tagged text for all output. Index: log.c =================================================================== RCS file: /home2/cvsroot/ccvs/src/log.c,v retrieving revision 1.51 diff -u -r1.51 log.c --- log.c 1998/09/01 13:54:54 1.51 +++ log.c 1998/09/05 22:03:25 @@ -477,10 +477,13 @@ Node *lock; void *foo; { - cvs_output ("\n\t", 2); - cvs_output (lock->data, 0); - cvs_output (": ", 2); - cvs_output (lock->key, 0); + cvs_output_tagged ("+lock", NULL); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "\t"); + cvs_output_tagged ("locker", lock->data); + cvs_output_tagged ("test", ": "); + cvs_output_tagged ("revision", lock->key); + cvs_output_tagged ("-lock", NULL); return 0; } @@ -525,8 +528,8 @@ if (log_data->nameonly) { - cvs_output (rcsfile->path, 0); - cvs_output ("\n", 1); + cvs_output_tagged ("rcsfile", rcsfile->path); + cvs_output_tagged ("newline", NULL); return 0; } @@ -544,56 +547,62 @@ function, even though it uses information gathered by the functions in rcs.c. */ - cvs_output ("\n", 1); + cvs_output_tagged ("newline", NULL); - cvs_output ("RCS file: ", 0); - cvs_output (rcsfile->path, 0); + cvs_output_tagged ("text", "RCS file: "); + cvs_output_tagged ("rcsfile", rcsfile->path); - cvs_output ("\nWorking file: ", 0); - if (finfo->update_dir[0] == '\0') - cvs_output (finfo->file, 0); - else - { - cvs_output (finfo->update_dir, 0); - cvs_output ("/", 0); - cvs_output (finfo->file, 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "Working file: "); + cvs_output_tagged ("fname", finfo->fullname); - } - - cvs_output ("\nhead:", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "head:"); if (rcsfile->head != NULL) { - cvs_output (" ", 1); - cvs_output (rcsfile->head, 0); + cvs_output_tagged ("text", " "); + cvs_output_tagged ("head", rcsfile->head); } - cvs_output ("\nbranch:", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "branch:"); if (rcsfile->branch != NULL) { - cvs_output (" ", 1); - cvs_output (rcsfile->branch, 0); + cvs_output_tagged ("text", " "); + cvs_output_tagged ("default-branch", rcsfile->branch); } - cvs_output ("\nlocks:", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "locks:"); if (rcsfile->strict_locks) - cvs_output (" strict", 0); + /* The existence of this tag, not its value, indicates that + locks are strict. */ + cvs_output_tagged ("strict", " strict"); walklist (RCS_getlocks (rcsfile), printlock_proc, NULL); - cvs_output ("\naccess list:", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "access list:"); if (rcsfile->access != NULL) { - const char *cp; + char *cp; cp = rcsfile->access; while (*cp != '\0') { - const char *cp2; + char *cp2; + int save_ch; - cvs_output ("\n\t", 2); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "\t"); cp2 = cp; while (! isspace (*cp2) && *cp2 != '\0') ++cp2; - cvs_output (cp, cp2 - cp); + /* FIXME-reentrancy: Perhaps not an issue, if the RCSNode + data structures aren't shared with anyone. */ + save_ch = cp[cp2 - cp]; + cp[cp2 - cp] = '\0'; + cvs_output_tagged ("accessor", cp); + cp[cp2 - cp] = save_ch; cp = cp2; while (isspace (*cp) && *cp != '\0') ++cp; @@ -604,24 +613,31 @@ { List *syms; - cvs_output ("\nsymbolic names:", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "symbolic names:"); syms = RCS_symbols (rcsfile); walklist (syms, log_symbol, NULL); } - cvs_output ("\nkeyword substitution: ", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "keyword substitution: "); + /* My reasoning for calling this "expand" rather than "kflag" or + "kopt" is that the latter often include the leading "-k". + Not that I'm sure whether existing practice is all that + consistent. */ if (rcsfile->expand == NULL) - cvs_output ("kv", 2); + cvs_output_tagged ("expand", "kv"); else - cvs_output (rcsfile->expand, 0); + cvs_output_tagged ("expand", rcsfile->expand); - cvs_output ("\ntotal revisions: ", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "total revisions: "); sprintf (buf, "%d", walklist (rcsfile->versions, log_count, NULL)); - cvs_output (buf, 0); + cvs_output_tagged ("revision-count", buf); if (! log_data->header && ! log_data->long_header) { - cvs_output (";\tselected revisions: ", 0); + cvs_output_tagged ("text", ";\tselected revisions: "); log_data_and_rcs.log_data = log_data; log_data_and_rcs.revlist = revlist; @@ -638,16 +654,27 @@ sprintf (buf, "%d", walklist (rcsfile->versions, log_count_print, (void *) &log_data_and_rcs)); - cvs_output (buf, 0); + cvs_output_tagged ("selected-revision-count", buf); } - cvs_output ("\n", 1); + cvs_output_tagged ("newline", NULL); if (! log_data->header || log_data->long_header) { - cvs_output ("description:\n", 0); + cvs_output_tagged ("text", "description:"); + cvs_output_tagged ("newline", NULL); if (rcsfile->desc != NULL) + { + /* FIXME: here is where we really should be fixing + the problem with \n inside a tagged text item. But + maybe the +/- workaround points to the clean solution; + perhaps it should _always_ be OK to convert "MT desc foo" + to "MT +desc" "M foo" "MT -desc". That would seem to + fit in reasonably well to XML. */ + cvs_output_tagged ("+desc", NULL); cvs_output (rcsfile->desc, 0); + cvs_output_tagged ("-desc", NULL); + } } if (! log_data->header && ! log_data->long_header && rcsfile->head != NULL) @@ -676,9 +703,9 @@ log_tree (log_data, revlist, rcsfile, rcsfile->head); } - cvs_output("\ -=============================================================================\n", - 0); + cvs_output_tagged ("text", "\ +============================================================================="); + cvs_output_tagged ("newline", NULL); /* Free up the new revlist and restore the old one. */ log_free_revlist (revlist); @@ -1024,10 +1051,13 @@ Node *p; void *closure; { - cvs_output ("\n\t", 2); - cvs_output (p->key, 0); - cvs_output (": ", 2); - cvs_output (p->data, 0); + cvs_output_tagged ("+symbol", NULL); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "\t"); + cvs_output_tagged ("symbol", p->key); + cvs_output_tagged ("text", ": "); + cvs_output_tagged ("revision", p->data); + cvs_output_tagged ("-symbol", NULL); return 0; } @@ -1203,32 +1233,42 @@ if (! log_version_requested (log_data, revlist, rcs, ver)) return; - cvs_output ("----------------------------\nrevision ", 0); - cvs_output (ver->version, 0); + cvs_output_tagged ("text", "----------------------------"); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "revision "); + cvs_output_tagged ("revision", ver->version); p = findnode (RCS_getlocks (rcs), ver->version); if (p != NULL) { - cvs_output ("\tlocked by: ", 0); - cvs_output (p->data, 0); - cvs_output (";", 1); + cvs_output_tagged ("text", "\tlocked by: "); + cvs_output_tagged ("locker", p->data); + cvs_output_tagged ("text", ";"); } - cvs_output ("\ndate: ", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "date: "); (void) sscanf (ver->date, SDATEFORM, &year, &mon, &mday, &hour, &min, &sec); if (year < 1900) year += 1900; sprintf (buf, "%04d/%02d/%02d %02d:%02d:%02d", year, mon, mday, hour, min, sec); - cvs_output (buf, 0); - - cvs_output ("; author: ", 0); - cvs_output (ver->author, 0); - cvs_output ("; state: ", 0); - cvs_output (ver->state, 0); - cvs_output (";", 1); + /* FIXME: especially in the tagged text context, want a more + standard date format. Internet or ISO. As with the "next" + field issue, the clean thing here is the option of a tagged + text field which by default does _not_ display, rather than one + that by default does display. The tagged text infrastructure + doesn't have that yet. */ + cvs_output_tagged ("date", buf); + + cvs_output_tagged ("text", "; author: "); + cvs_output_tagged ("author", ver->author); + + cvs_output_tagged ("text", "; state: "); + cvs_output_tagged ("state", ver->state); + cvs_output_tagged ("text", ";"); if (! trunk) { @@ -1256,19 +1296,20 @@ if (padd != NULL) { - cvs_output (" lines: +", 0); - cvs_output (padd->data, 0); - cvs_output (" -", 2); - cvs_output (pdel->data, 0); + cvs_output_tagged ("text", " lines: +"); + cvs_output_tagged ("add-line-count", padd->data); + cvs_output_tagged ("text", " -"); + cvs_output_tagged ("delete-line-count", pdel->data); } if (ver->branches != NULL) { - cvs_output ("\nbranches:", 0); + cvs_output_tagged ("newline", NULL); + cvs_output_tagged ("text", "branches:"); walklist (ver->branches, log_branch, (void *) NULL); } - cvs_output ("\n", 1); + cvs_output_tagged ("newline", NULL); p = findnode (ver->other, "log"); /* The p->date == NULL case is the normal one for an empty log @@ -1279,14 +1320,21 @@ missing the "log" keyword (which is illegal according to rcsfile.5). */ if (p == NULL || p->data == NULL || p->data[0] == '\0') - cvs_output ("*** empty log message ***\n", 0); + { + /* Note that it is the lack of a "+message" tag which tells the + client that the log message is empty. */ + cvs_output_tagged ("text", "*** empty log message ***"); + cvs_output_tagged ("newline", NULL); + } else { + cvs_output_tagged ("+message", NULL); /* FIXME: Technically, the log message could contain a null byte. */ cvs_output (p->data, 0); if (p->data[strlen (p->data) - 1] != '\n') cvs_output ("\n", 1); + cvs_output_tagged ("-message", NULL); } } @@ -1299,9 +1347,9 @@ Node *p; void *closure; { - cvs_output (" ", 2); + cvs_output_tagged ("text", " "); if ((numdots (p->key) & 1) == 0) - cvs_output (p->key, 0); + cvs_output_tagged ("branch", p->key); else { char *f, *cp; @@ -1309,10 +1357,10 @@ f = xstrdup (p->key); cp = strrchr (f, '.'); *cp = '\0'; - cvs_output (f, 0); + cvs_output_tagged ("branch", f); free (f); } - cvs_output (";", 1); + cvs_output_tagged ("text", ";"); return 0; }