Bill Allombert on Wed, 10 Mar 2004 12:59:51 +0100


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

Re: a couple of gp issues


On Sat, Mar 06, 2004 at 03:21:14PM -0500, Igor Schein wrote:
> Hi,
> 
> 1) I would like to be able to concatenate command line gp options,
> e.g. "gp -qf" instead of "gp -q -f".  And while we're at it, why not
> have each option have both short and long variant, like every GNU
> package out there.  Right now, for instance, -q doesn't have
> --quiet (or --silent) counterpart, and --test doesn't have -t
> counterpart.  

The problem is that PARI 2.3 need to support options understood by PARI 2.1
so backward incompatible changes will wait for 2.5.

gp 2.1 support:
        
        [-b buffersize] Deprecated
        [-emacs]        Run as if in Emacs shell
        [-f]            Faststart: do not read .gprc
        [--help]        Print this message
        [-q]            Quiet mode: do not print banner and history numbers
        [-p primelimit] Precalculate primes up to the limit
        [-s stacksize]  Start with the PARI stack of given size (in bytes)
        [-test]         Test mode.  As -q, plus wrap long lines
        [--version]     Output version info and exit

and options clustering does not fit well with X11-style long options
like -test.  Now, we can add
--fast, --quiet, --primelimit and --stacksize.
already.

The attached patch implement that, supporting both --primelimit x
and --primelimit=x syntax.

> 2) Let's say I am piping a bunch of commands to gp, and I wanna skip
> the one that takes too long and continue with the rest of the input.
> I press ^C, and it does just that. However, if I need to ^C some time
> later, it gets trapped somehow.  Here's a simple example:
> 
> % cat << EOD | gp -q -f
> > \e
> > while(1,)
> > while(1,)
> > EOD
>    echo = 1 (on)
> ? while(1,)
>   ***   user interrupt after 2,250 ms.
> ? while(1,)
> 
> at this point ^C is a noop.

I have mentionned this problem on this list recently.
I am not sure what cause it.

Cheers,
Bill.
Index: src/gp/gp.c
===================================================================
RCS file: /home/cvs/pari/src/gp/gp.c,v
retrieving revision 1.218
diff -u -r1.218 gp.c
--- src/gp/gp.c	20 Jan 2004 19:20:32 -0000	1.218
+++ src/gp/gp.c	10 Mar 2004 11:56:07 -0000
@@ -86,13 +86,13 @@
 {
   printf("### Usage: %s [options] [GP files]\n", s);
   printf("Options are:\n");
-  printf("\t[-f]\t\tFaststart: do not read .gprc\n");
-  printf("\t[-q]\t\tQuiet mode: do not print banner and history numbers\n");
-  printf("\t[-p primelimit]\tPrecalculate primes up to the limit\n");
-  printf("\t[-s stacksize]\tStart with the PARI stack of given size (in bytes)\n");
+  printf("\t[-f,--fast]\tFaststart: do not read .gprc\n");
+  printf("\t[-q,--quiet]\tQuiet mode: do not print banner and history numbers\n");
+  printf("\t[-p,--primelimit primelimit]\tPrecalculate primes up to the limit\n");
+  printf("\t[-s,--stacksize stacksize]\tStart with the PARI stack of given size (in bytes)\n");
   printf("\t[--emacs]\tRun as if in Emacs shell\n");
   printf("\t[--help]\tPrint this message\n");
-  printf("\t[--test]\t\tTest mode. No history, wrap long lines (bench only)\n");
+  printf("\t[--test]\tTest mode. No history, wrap long lines (bench only)\n");
   printf("\t[--texmacs]\tRun as if using TeXmacs frontend\n");
   printf("\t[--version]\tOutput version info and exit\n");
   printf("\t[--version-short]\tOutput version number and exit\n\n");
@@ -2485,13 +2485,6 @@
   char **v; /* args */
 } tm_cmd;
 
-static char *
-pari_strndup(char *s, long n)
-{
-  char *t = gpmalloc(n+1);
-  memcpy(t,s,n); t[n] = 0; return t;
-}
-
 static void
 parse_texmacs_command(tm_cmd *c, char *ch)
 {
@@ -2918,6 +2911,16 @@
   *nread = i+1; return argv[i];
 }
 
+static char *
+read_arg_equal(int *nread, char *t, long argc, char **argv)
+{
+  int i = *nread;
+  if (*t=='=' && isdigit((int)t[1])) return t+1;
+  if (*t || i==argc) usage(argv[0]);
+  *nread = i+1; return argv[i];
+}
+
+
 static void
 init_trivial_stack()
 {
@@ -2964,6 +2967,10 @@
         if (strcmp(t, "texmacs") == 0) { GP_DATA->flags |= TEXMACS; break; }
         if (strcmp(t, "emacs") == 0) { GP_DATA->flags |= EMACS; break; }
         if (strcmp(t, "test") == 0) { GP_DATA->flags |= TEST; initrc = 0; break; }
+        if (strcmp(t, "quiet") == 0) { GP_DATA->flags |= QUIET; break; }
+        if (strcmp(t, "fast") == 0) { initrc = 0; break; }
+        if (strncmp(t, "primelimit",10) == 0) {p = read_arg_equal(&i,t+10,argc,argv); break; }
+        if (strncmp(t, "stacksize",9) == 0) {s = read_arg_equal(&i,t+9,argc,argv); break; }
        /* fall through */
       default:
 	usage(argv[0]);