Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue L61104     [previous patch]

ListMaker doesn't support 'serial' commas
Submitted by: Andrew Plotkin     Appeared in: Libraries long ago     Fixed in: -
Enhancement

The WriteListFrom() listmaker doesn't support 'serial' commas (aka Oxford or Harvard commas): Tom, Dick, and Harry.

Solution

Apply this patch.

diff -c libg611/English.h libg611-new/English.h
*** libg611/English.h	Fri Feb 27 06:11:00 2004
--- libg611-new/English.h	Tue Mar 30 22:51:27 2004
***************
*** 352,364 ****

  Constant THOSET__TX     = "those things";
  Constant THAT__TX       = "that";
- Constant OR__TX         = " or ";
  Constant NOTHING__TX    = "nothing";
  Constant IS__TX         = " is";
  Constant ARE__TX        = " are";
  Constant IS2__TX        = "is ";
  Constant ARE2__TX       = "are ";
  Constant AND__TX        = " and ";
  Constant WHOM__TX       = "whom ";
  Constant WHICH__TX      = "which ";
  Constant COMMA__TX      = ", ";
--- 352,373 ----

  Constant THOSET__TX     = "those things";
  Constant THAT__TX       = "that";
  Constant NOTHING__TX    = "nothing";
  Constant IS__TX         = " is";
  Constant ARE__TX        = " are";
  Constant IS2__TX        = "is ";
  Constant ARE2__TX       = "are ";
+ #ifdef SERIAL_COMMAS;
+ Constant OR__TX         = ", or ";
+ Constant OR2__TX        = " or ";
+ Constant AND__TX        = ", and ";
+ Constant AND2__TX       = " and ";
+ #ifnot;
+ Constant OR__TX         = " or ";
+ Constant OR2__TX        = OR__TX;
  Constant AND__TX        = " and ";
+ Constant AND2__TX       = AND__TX;
+ #endif;
  Constant WHOM__TX       = "whom ";
  Constant WHICH__TX      = "which ";
  Constant COMMA__TX      = ", ";
***************
*** 641,647 ****
              if (TASKS_PROVIDED == 0) print ", give the FULL score for that game";
              if (deadflag == 2 && AMUSING_PROVIDED == 0)
                  print ", see some suggestions for AMUSING things to do";
!             " or QUIT?";
          6:  "[Your interpreter does not provide ~undo~.  Sorry!]";
              #Ifdef TARGET_ZCODE;
          7:  "~Undo~ failed.  [Not all interpreters provide it.]";
--- 650,657 ----
              if (TASKS_PROVIDED == 0) print ", give the FULL score for that game";
              if (deadflag == 2 && AMUSING_PROVIDED == 0)
                  print ", see some suggestions for AMUSING things to do";
!             print (string) OR__TX;
!             "QUIT?";
          6:  "[Your interpreter does not provide ~undo~.  Sorry!]";
              #Ifdef TARGET_ZCODE;
          7:  "~Undo~ failed.  [Not all interpreters provide it.]";
diff -c libg611/parserm.h libg611-new/parserm.h
*** libg611/parserm.h	Fri Feb 27 06:11:00 2004
--- libg611-new/parserm.h	Tue Mar 30 22:11:26 2004
***************
*** 2821,2827 ****
          if (match_classes-->marker > 0) print (the) k; else print (a) k;

          if (i < j-1)  print (string) COMMA__TX;
!         if (i == j-1) print (string) OR__TX;
      }
      L__M(##Miscellany, 57);

--- 2821,2830 ----
          if (match_classes-->marker > 0) print (the) k; else print (a) k;

          if (i < j-1)  print (string) COMMA__TX;
!         if (i == j-1) {
!             if (j > 2) print (string) OR__TX;
!             else       print (string) OR2__TX;
!         }
      }
      L__M(##Miscellany, 57);

***************
*** 4403,4409 ****
          }
          d++;
          if (d < c-1) print (string) COMMA__TX;
!         if (d == c-1) print (string) AND__TX;
      }
      if (player ~= selfobj) {
          print "~", (address) ME1__WD, "~ "; L__M(##Pronouns, 2);
--- 4406,4415 ----
          }
          d++;
          if (d < c-1) print (string) COMMA__TX;
!         if (d == c-1) {
!             if (c > 2) print (string) AND__TX;
!             else       print (string) AND2__TX;
!         }
      }
      if (player ~= selfobj) {
          print "~", (address) ME1__WD, "~ "; L__M(##Pronouns, 2);
diff -c libg611/verblibm.h libg611-new/verblibm.h
*** libg611/verblibm.h	Fri Feb 27 06:11:00 2004
--- libg611-new/verblibm.h	Tue Mar 30 22:26:19 2004
***************
*** 415,421 ****

        .Omit_WL2;

!         if (WriteBeforeEntry(j, depth, -senc) == 1) jump Omit_FL2;
          if (sizes_p->i == 1) {
              if (c_style & NOARTICLE_BIT ~= 0) print (name) j;
              else {
--- 415,421 ----

        .Omit_WL2;

!         if (WriteBeforeEntry(j, depth, 0, senc) == 1) jump Omit_FL2;
          if (sizes_p->i == 1) {
              if (c_style & NOARTICLE_BIT ~= 0) print (name) j;
              else {
***************
*** 436,442 ****
        .Omit_EL2;

          if (c_style & ENGLISH_BIT ~= 0) {
!             if (senc == 1) print (string) AND__TX;
              if (senc > 1) print (string) COMMA__TX;
          }
       .Omit_FL2;
--- 436,445 ----
        .Omit_EL2;

          if (c_style & ENGLISH_BIT ~= 0) {
!             if (senc == 1) {
!                 if (i > 2) print (string) AND__TX;
!                 else       print (string) AND2__TX;
!             }
              if (senc > 1) print (string) COMMA__TX;
          }
       .Omit_FL2;
***************
*** 515,521 ****

        .Omit_WL;

!         if (WriteBeforeEntry(j, depth, i-senc) == 1) jump Omit_FL;
          if (c_style & NOARTICLE_BIT ~= 0) print (name) j;
          else {
              if (c_style & DEFART_BIT ~= 0) print (the) j; else print (a) j;
--- 518,524 ----

        .Omit_WL;

!         if (WriteBeforeEntry(j, depth, i, senc) == 1) jump Omit_FL;
          if (c_style & NOARTICLE_BIT ~= 0) print (name) j;
          else {
              if (c_style & DEFART_BIT ~= 0) print (the) j; else print (a) j;
***************
*** 525,531 ****
        .Omit_EL;

          if (c_style & ENGLISH_BIT ~= 0) {
!             if (i == senc-1) print (string) AND__TX;
              if (i < senc-1) print (string) COMMA__TX;
          }

--- 528,537 ----
        .Omit_EL;

          if (c_style & ENGLISH_BIT ~= 0) {
!             if (i == senc-1) {
!                 if (senc > 2) print (string) AND__TX;
!                 else          print (string) AND2__TX;
!             }
              if (i < senc-1) print (string) COMMA__TX;
          }

***************
*** 534,540 ****
      }
  ]; ! end of WriteListR

! [ WriteBeforeEntry o depth sentencepos
      flag;

      inventory_stage = 1;
--- 540,546 ----
      }
  ]; ! end of WriteListR

! [ WriteBeforeEntry o depth ipos sentencepos
      flag;

      inventory_stage = 1;
***************
*** 543,550 ****
          flag = PrintOrRun(o, invent, 1);
          if (flag) {
              if (c_style & ENGLISH_BIT) {
!                 if (sentencepos == -1) print (string) AND__TX;
!                 if (sentencepos <  -1) print (string) COMMA__TX;
              }
              if (c_style & NEWLINE_BIT) new_line;
          }
--- 549,559 ----
          flag = PrintOrRun(o, invent, 1);
          if (flag) {
              if (c_style & ENGLISH_BIT) {
!                 if (ipos == sentencepos-1) {
!                     if (sentencepos > 2) print (string) AND__TX;
!                     else                 print (string) AND2__TX;
!                 }
!                 if (ipos < sentencepos-1) print (string) COMMA__TX;
              }
              if (c_style & NEWLINE_BIT) new_line;
          }
***************
*** 580,586 ****

          if (o has container)
              if (o has openable) {
!                 if (parenth_flag) print (string) AND__TX;
                  else              L__M(##ListMiscellany, 11, o);
                  if (o has open)
                      if (child(o)) L__M(##ListMiscellany, 12, o);
--- 589,595 ----

          if (o has container)
              if (o has openable) {
!                 if (parenth_flag) print (string) AND2__TX;
                  else              L__M(##ListMiscellany, 11, o);
                  if (o has open)
                      if (child(o)) L__M(##ListMiscellany, 12, o);
***************
*** 1227,1233 ****
      objectloop (i has visited) {
          print (name) i; k++;
          if (k == j) { L__M(##Places, 2); return; }
!         if (k == j-1) print (string) AND__TX;
          else          print (string) COMMA__TX;
      }
  ];
--- 1236,1245 ----
      objectloop (i has visited) {
          print (name) i; k++;
          if (k == j) { L__M(##Places, 2); return; }
!         if (k == j-1) {
!             if (j>2)  print (string) AND__TX;
!             else      print (string) AND2__TX;
!         }
          else          print (string) COMMA__TX;
      }
  ];
Update (by Cedric Knight)

It looks like translators would have to add two more string constants. This could be avoided, and also the code size reduced for existing behaviour, if the implementation were instead as a routine SerialComma(items); which would print a comma iff items>2 and the SERIAL_COMMAS constant were defined.


Last updated 17 April 2013. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.