groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff ChangeLog Makefile.in NEWS doc/pic.ms src...


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog Makefile.in NEWS doc/pic.ms src...
Date: Mon, 11 Dec 2006 16:12:16 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     06/12/11 16:12:15

Modified files:
        .              : ChangeLog Makefile.in NEWS 
        doc            : pic.ms 
        src/preproc/pic: lex.cpp 

Log message:
        Support up to 32 macro arguments in pic (and up to 16 on EBCDIC
        hosts).
        
        * src/preproc/pic/lex.cpp (ARG1): Redefine.  Update all users.
        (MAX_ARG): New macro.  Use it everywhere to replace hard-coded
        limit of 9 arguments.
        (process_body): Handle argument numbers with more than a single
        digit.
        (interpolate_macro_with_args): Protect against exceeding number of
        arguments.
        
        * NEWS, src/preproc/pic/pic.man, doc/pic.ms: Document it.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1009&r2=1.1010
http://cvs.savannah.gnu.org/viewcvs/groff/Makefile.in?cvsroot=groff&r1=1.100&r2=1.101
http://cvs.savannah.gnu.org/viewcvs/groff/NEWS?cvsroot=groff&r1=1.228&r2=1.229
http://cvs.savannah.gnu.org/viewcvs/groff/doc/pic.ms?cvsroot=groff&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/groff/src/preproc/pic/lex.cpp?cvsroot=groff&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1009
retrieving revision 1.1010
diff -u -b -r1.1009 -r1.1010
--- ChangeLog   8 Dec 2006 21:22:07 -0000       1.1009
+++ ChangeLog   11 Dec 2006 16:12:15 -0000      1.1010
@@ -1,3 +1,24 @@
+2006-12-11  Werner LEMBERG  <address@hidden>
+
+       Support up to 32 macro arguments in pic (and up to 16 on EBCDIC
+       hosts).
+
+       * src/preproc/pic/lex.cpp (ARG1): Redefine.  Update all users.
+       (MAX_ARG): New macro.  Use it everywhere to replace hard-coded
+       limit of 9 arguments.
+       (process_body): Handle argument numbers with more than a single
+       digit.
+       (interpolate_macro_with_args): Protect against exceeding number of
+       arguments.
+
+       * NEWS, src/preproc/pic/pic.man, doc/pic.ms: Document it.
+
+2006-12-10  Werner LEMBERG  <address@hidden>
+
+       * Makefile.in (site.exp, docheck): Commented out.  Not working
+       currently.
+       (check): Just emit dummy message.
+
 2006-12-08  Werner LEMBERG  <address@hidden>
 
        During installation, create soft link from <version> to `current' in

Index: Makefile.in
===================================================================
RCS file: /cvsroot/groff/groff/Makefile.in,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -b -r1.100 -r1.101
--- Makefile.in 8 Dec 2006 21:22:07 -0000       1.100
+++ Makefile.in 11 Dec 2006 16:12:15 -0000      1.101
@@ -806,32 +806,37 @@
          $(libprogramdir) $(libdir) \
          $(datadir)/doc/groff $(datadir)/doc $(datadir) 2>/dev/null || :
 
-.PHONY: check docheck
-check: site.exp docheck
+.PHONY: check
+check:
+       @echo There is no validation suite for this package.
 
-docheck:
-       if $(SHELL) -c "runtest --version" > /dev/null 2>&1; then \
-         runtest; \
-       else \
-         echo "WARNING: could not find \`runtest'" 1>&2; \
-       fi
+
+#check: site.exp docheck
+#.PHONY: docheck
+
+#docheck:
+#      if $(SHELL) -c "runtest --version" > /dev/null 2>&1; then \
+#        runtest; \
+#      else \
+#        echo "WARNING: could not find \`runtest'" 1>&2; \
+#      fi
 
 # This snippet has been taken from the automake package.
 
-site.exp:
-       @echo "Making a new site.exp file..."
-       @echo "## these variables are automatically generated by make ##" 
>site.tmp
-       @echo "# Do not edit here.  If you wish to override these values" 
>>site.tmp
-       @echo "# edit the last section" >>site.tmp
-       @echo "set tool groff" >>site.tmp
-       @echo "set srcdir $(srcdir)/testsuite" >>site.tmp
-       @echo "set objdir `pwd`" >> site.tmp
-       @echo "## All variables above are generated by configure.  Do not edit! 
##" >> site.tmp
-       @test ! -f site.exp \
-         || sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
-       @-rm -f site.bak
-       @test ! -f site.exp || mv site.exp site.bak
-       @mv site.tmp site.exp
+#site.exp:
+#      @echo "Making a new site.exp file..."
+#      @echo "## these variables are automatically generated by make ##" 
>site.tmp
+#      @echo "# Do not edit here.  If you wish to override these values" 
>>site.tmp
+#      @echo "# edit the last section" >>site.tmp
+#      @echo "set tool groff" >>site.tmp
+#      @echo "set srcdir $(srcdir)/testsuite" >>site.tmp
+#      @echo "set objdir `pwd`" >> site.tmp
+#      @echo "## All variables above are generated by configure.  Do not edit! 
##" >> site.tmp
+#      @test ! -f site.exp \
+#        || sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+#      @-rm -f site.bak
+#      @test ! -f site.exp || mv site.exp site.bak
+#      @mv site.tmp site.exp
 
 FORCE:
 

Index: NEWS
===================================================================
RCS file: /cvsroot/groff/groff/NEWS,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -b -r1.228 -r1.229
--- NEWS        8 Dec 2006 21:22:07 -0000       1.228
+++ NEWS        11 Dec 2006 16:12:15 -0000      1.229
@@ -71,6 +71,9 @@
   of x, this is, it rounds towards zero and not towards the next integer
   less than or equal to x.
 
+o Pic now supports up to 32 macro arguments (and up to 16 on EBCDIC
+  platforms).
+
 Chem
 ----
 

Index: doc/pic.ms
===================================================================
RCS file: /cvsroot/groff/groff/doc/pic.ms,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- doc/pic.ms  21 Mar 2006 07:57:57 -0000      1.33
+++ doc/pic.ms  11 Dec 2006 16:12:15 -0000      1.34
@@ -31,7 +31,7 @@
 .\" Eric S. Raymond <address@hidden> in August 1995.  It has been put
 .\" under the GPL in March 2006.
 .\"
-.\"    $Id: pic.ms,v 1.33 2006/03/21 07:57:57 wl Exp $ 
+.\"    $Id: pic.ms,v 1.34 2006/12/11 16:12:15 wl Exp $ 
 .
 .
 .\" Set a proper TeX and LaTeX
@@ -1576,7 +1576,8 @@
 .NH 1
 Macros
 .PP
-You can define macros in \fBpic\fP.  This is useful for diagrams with
+You can define macros in \fBpic\fP, with up to 32 arguments (up to 16
+on EBCDIC platforms).  This is useful for diagrams with
 repetitive parts.  In conjunction with the scope rules for block
 composites, it effectively gives you the ability to write functions.
 .PP

Index: src/preproc/pic/lex.cpp
===================================================================
RCS file: /cvsroot/groff/groff/src/preproc/pic/lex.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- src/preproc/pic/lex.cpp     26 May 2005 21:02:01 -0000      1.4
+++ src/preproc/pic/lex.cpp     11 Dec 2006 16:12:15 -0000      1.5
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004, 2006
      Free Software Foundation, Inc.
      Written by James Clark (address@hidden)
 
@@ -29,6 +29,16 @@
 
 PTABLE(char) macro_table;
 
+// First character of the range representing $1-$<MAX_ARG>.
+// All of them must be invalid input characters.
+#ifndef IS_EBCDIC_HOST
+#define ARG1 0x80
+#define MAX_ARG 32
+#else
+#define ARG1 0x30
+#define MAX_ARG 16
+#endif
+
 class macro_input : public input {
   char *s;
   char *p;
@@ -44,7 +54,7 @@
   char *p;
   char *ap;
   int argc;
-  char *argv[9];
+  char *argv[MAX_ARG];
 public:
   argument_macro_input(const char *, int, char **);
   ~argument_macro_input();
@@ -154,17 +164,29 @@
     return (unsigned char)*p;
 }
 
-// Character representing $1.  Must be invalid input character.
-#define ARG1 14
-
 char *process_body(const char *body)
 {
   char *s = strsave(body);
   int j = 0;
   for (int i = 0; s[i] != '\0'; i++)
-    if (s[i] == '$' && s[i+1] >= '0' && s[i+1] <= '9') {
-      if (s[i+1] != '0')
-       s[j++] = ARG1 + s[++i] - '1';
+    if (s[i] == '$' && csdigit(s[i + 1])) {
+      int n = 0;
+      int start = i;
+      i++;
+      while (csdigit(s[i]))
+       if (n > MAX_ARG)
+         i++;
+       else
+         n = 10 * n + s[i++] - '0';
+      if (n > MAX_ARG) {
+       string arg;
+       for (int k = start; k < i; k++)
+         arg += s[k];
+       lex_error("invalid macro argument number %1", arg.contents());
+      }
+      else if (n > 0)
+       s[j++] = ARG1 + n - 1;
+      i--;
     }
     else
       s[j++] = s[i];
@@ -172,7 +194,6 @@
   return s;
 }
 
-
 argument_macro_input::argument_macro_input(const char *body, int ac, char **av)
 : ap(0), argc(ac)
 {
@@ -181,7 +202,6 @@
   p = s = process_body(body);
 }
 
-
 argument_macro_input::~argument_macro_input()
 {
   for (int i = 0; i < argc; i++)
@@ -198,8 +218,9 @@
   }
   if (p == 0)
     return EOF;
-  while (*p >= ARG1 && *p <= ARG1 + 8) {
-    int i = *p++ - ARG1;
+  while ((unsigned char)*p >= ARG1 
+        && (unsigned char)*p <= ARG1 + MAX_ARG - 1) {
+    int i = (unsigned char)*p++ - ARG1;
     if (i < argc && argv[i] != 0 && argv[i][0] != '\0') {
       ap = argv[i];
       return (unsigned char)*ap++;
@@ -219,8 +240,9 @@
   }
   if (p == 0)
     return EOF;
-  while (*p >= ARG1 && *p <= ARG1 + 8) {
-    int i = *p++ - ARG1;
+  while ((unsigned char)*p >= ARG1
+        && (unsigned char)*p <= ARG1 + MAX_ARG - 1) {
+    int i = (unsigned char)*p++ - ARG1;
     if (i < argc && argv[i] != 0 && argv[i][0] != '\0') {
       ap = argv[i];
       return (unsigned char)*ap;
@@ -359,10 +381,11 @@
 
 void interpolate_macro_with_args(const char *body)
 {
-  char *argv[9];
+  char *argv[MAX_ARG];
   int argc = 0;
+  int ignore = 0;
   int i;
-  for (i = 0; i < 9; i++)
+  for (i = 0; i < MAX_ARG; i++)
     argv[i] = 0;
   int level = 0;
   int c;
@@ -378,10 +401,18 @@
       if (state == NORMAL && level == 0 && (c == ',' || c == ')')) {
        if (token_buffer.length() > 0) {
          token_buffer +=  '\0';
+         if (!ignore) {
+           if (argc == MAX_ARG) {
+             lex_warning("only %1 macro arguments supported", MAX_ARG);
+             ignore = 1;
+           }
+           else
          argv[argc] = strsave(token_buffer.contents());
        }
+       }
        // for `foo()', argc = 0
        if (argc > 0 || c != ')' || i > 0)
+         if (!ignore)
          argc++;
        break;
       }
@@ -1441,7 +1472,7 @@
   char *until;
   const char *p;
   const char *ap;
-  int argv[9];
+  int argv[MAX_ARG];
   int argc;
   string line;
   int get_line();
@@ -1540,8 +1571,9 @@
       p = 0;
       return '\n';
     }
-    while (*p >= ARG1 && *p <= ARG1 + 8) {
-      int i = *p++ - ARG1;
+    while ((unsigned char)*p >= ARG1
+          && (unsigned char)*p <= ARG1 + MAX_ARG - 1) {
+      int i = (unsigned char)*p++ - ARG1;
       if (i < argc && line[argv[i]] != '\0') {
        ap = line.contents() + argv[i];
        return (unsigned char)*ap++;
@@ -1568,8 +1600,9 @@
     }
     if (*p == '\0')
       return '\n';
-    while (*p >= ARG1 && *p <= ARG1 + 8) {
-      int i = *p++ - ARG1;
+    while ((unsigned char)*p >= ARG1
+          && (unsigned char)*p <= ARG1 + MAX_ARG - 1) {
+      int i = (unsigned char)*p++ - ARG1;
       if (i < argc && line[argv[i]] != '\0') {
        ap = line.contents() + argv[i];
        return (unsigned char)*ap;
@@ -1593,7 +1626,7 @@
       c = inget();
     if (c == EOF || c == '\n')
       break;
-    if (argc == 9) {
+    if (argc == MAX_ARG) {
       do {
        c = inget();
       } while (c != '\n' && c != EOF);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]