Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux.fr machine (x86_64 architecture), and agregate them in the final report:

The target is to exceed 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - gp - gp.c (source / functions) Coverage Total Hit
Test: PARI/GP v2.18.1 lcov report (development 31042-0fbe168e69) Lines: 83.0 % 335 278
Test Date: 2026-07-23 17:04:59 Functions: 85.7 % 28 24
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Copyright (C) 2000  The PARI group.
       2              : 
       3              : This file is part of the PARI/GP package.
       4              : 
       5              : PARI/GP is free software; you can redistribute it and/or modify it under the
       6              : terms of the GNU General Public License as published by the Free Software
       7              : Foundation; either version 2 of the License, or (at your option) any later
       8              : version. It is distributed in the hope that it will be useful, but WITHOUT
       9              : ANY WARRANTY WHATSOEVER.
      10              : 
      11              : Check the License for details. You should have received a copy of it, along
      12              : with the package; see the file 'COPYING'. If not, write to the Free Software
      13              : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14              : 
      15              : /*******************************************************************/
      16              : /**                                                               **/
      17              : /**                        PARI CALCULATOR                        **/
      18              : /**                                                               **/
      19              : /*******************************************************************/
      20              : #ifdef _WIN32
      21              : #  include "../systems/mingw/pwinver.h"
      22              : #  include <windows.h>
      23              : #  include "../systems/mingw/mingw.h"
      24              : #endif
      25              : #ifdef DEBUG_FLOATS
      26              : #  undef  _GNU_SOURCE
      27              : #  define _GNU_SOURCE
      28              : #  include <fenv.h>
      29              : /* check for cpp symbol conflict */
      30              : #  include <complex.h>
      31              : #endif
      32              : #include "pari.h"
      33              : #include "paripriv.h"
      34              : #include "gp.h"
      35              : 
      36              : static jmp_buf *env;
      37              : static pari_stack s_env;
      38              : void (*cb_pari_end_output)(void) = NULL;
      39              : 
      40              : static void
      41            0 : gp_ask_confirm(const char *s)
      42              : {
      43            0 :   err_printf(s);
      44            0 :   err_printf(". OK ? (^C if not)\n");
      45            0 :   pari_hit_return();
      46            0 : }
      47              : 
      48              : /* numerr < 0: after changing PARI stack size
      49              :  * numerr > 0: normal error, including SIGINT */
      50              : static void
      51        13563 : gp_err_recover(long numerr)
      52              : {
      53        13563 :   longjmp(env[s_env.n-1], numerr);
      54              : }
      55              : 
      56              : /* numerr >= 0 */
      57              : static void
      58        13090 : gp_pre_recover(long numerr)
      59              : {
      60        13090 :   out_puts(pariErr, "\n"); pariErr->flush();
      61        13090 :   gp_err_recover(numerr);
      62            0 : }
      63              : 
      64              : static void
      65       144356 : reset_ctrlc(void)
      66              : {
      67              : #if defined(_WIN32) || defined(__CYGWIN32__)
      68              :   win32ctrlc = 0;
      69              : #endif
      70       144356 : }
      71              : 
      72              : static int
      73        92235 : is_silent(char *s) { return s[strlen(s) - 1] == ';'; }
      74              : 
      75              : static int stdin_isatty = 0;
      76              : static int
      77         1964 : is_interactive(void)
      78         1964 : { return pari_infile == stdin && stdin_isatty; }
      79              : 
      80              : /*******************************************************************/
      81              : /**                                                               **/
      82              : /**                        INITIALIZATION                         **/
      83              : /**                                                               **/
      84              : /*******************************************************************/
      85              : static void
      86            2 : print_shortversion(void)
      87              : {
      88            2 :   const ulong mask = (1UL<<PARI_VERSION_SHIFT) - 1;
      89            2 :   ulong n = paricfg_version_code, major, minor, patch;
      90              : 
      91            2 :   patch = n & mask; n >>= PARI_VERSION_SHIFT;
      92            2 :   minor = n & mask; n >>= PARI_VERSION_SHIFT;
      93            2 :   major = n;
      94            2 :   printf("%lu.%lu.%lu\n", major,minor,patch); exit(0);
      95              : }
      96              : 
      97              : static void
      98            2 : usage(char *s)
      99              : {
     100            2 :   printf("### Usage: %s [options] [GP files]\n", s);
     101            2 :   printf("Available options:\n");
     102            2 :   printf("  [-f,--fast]\t\tFast start: do not read .gprc\n");
     103            2 :   printf("  [-q,--quiet]\t\tQuiet mode: do not print banner and history numbers\n");
     104            2 :   printf("  [-s stacksize]\tStart with the PARI stack of given size (in bytes)\n");
     105            2 :   printf("  [--default key=val]\tExecute default(key,val) on startup\n");
     106            2 :   printf("  [--emacs]\t\tRun as if in Emacs shell\n");
     107            2 :   printf("  [--help]\t\tPrint this message\n");
     108            2 :   printf("  [--test]\t\tTest mode. No history, wrap long lines (bench only)\n");
     109            2 :   printf("  [--texmacs]\t\tRun as if using TeXmacs frontend\n");
     110            2 :   printf("  [--version]\t\tOutput version info and exit\n");
     111            2 :   printf("  [--version-short]\tOutput version number and exit\n\n");
     112            2 :   exit(0);
     113              : }
     114              : 
     115              : static void
     116            2 : gp_head(void)
     117              : {
     118              :   ulong p, f;
     119            2 :   pari_print_version();
     120            2 :   pari_putc('\n');
     121            2 :   pari_center("Copyright (C) 2000-2025 The PARI Group");
     122            2 :   pari_putc('\n');
     123            2 :   print_text("PARI/GP is free software, covered by the GNU General Public \
     124              : License, and comes WITHOUT ANY WARRANTY WHATSOEVER.");
     125            2 :   pari_puts("\nType ? for help, \\q to quit.\n");
     126            2 :   pari_printf("Type ?%d for how to get moral"
     127              :               " (and possibly technical) support.\n", pari_community());
     128            2 :   p = GP_DATA->primelimit;
     129            2 :   f = GP_DATA->factorlimit;
     130            2 :   if (pari_mainstack->vsize)
     131            0 :     pari_printf("\nparisizemax = %lu, primelimit = %lu, factorlimit = %lu",
     132            0 :                 pari_mainstack->vsize, p, f);
     133              :   else
     134            2 :     pari_printf("\nparisize = %lu, primelimit = %lu, factorlimit = %lu",
     135            2 :                 pari_mainstack->rsize, p, f);
     136            2 :   pari_putc('\n');
     137            2 : }
     138              : 
     139              : static char *
     140            0 : read_arg(long *nread, char *t, long argc, char **argv)
     141              : {
     142            0 :   long i = *nread;
     143            0 :   if (isdigit((unsigned char)*t)) return t;
     144            0 :   if (*t || i==argc) usage(argv[0]);
     145            0 :   *nread = i+1; return argv[i];
     146              : }
     147              : 
     148              : static char *
     149            0 : read_arg_equal(long *nread, char *t, long argc, char **argv)
     150              : {
     151            0 :   long i = *nread;
     152            0 :   if (*t=='=' && isdigit((unsigned char)t[1])) return t+1;
     153            0 :   if (*t || i==argc) usage(argv[0]);
     154            0 :   *nread = i+1; return argv[i];
     155              : }
     156              : 
     157              : static void
     158            2 : init_trivial_stack(void)
     159              : {
     160            2 :   const size_t s = 2048;
     161            2 :   pari_mainstack->size = s;
     162            2 :   pari_mainstack->bot = (pari_sp)pari_malloc(s);
     163            2 :   avma = pari_mainstack->top = pari_mainstack->bot + s;
     164            2 : }
     165              : 
     166              : static void
     167            2 : free_trivial_stack(void)
     168              : {
     169            2 :   free((void*)pari_mainstack->bot);
     170            2 : }
     171              : 
     172              : typedef struct { char *key, *val; } pair_t;
     173              : /* If ab of the form key=val, record pair in new stack entry
     174              :  * P[n].key must be freed by caller to avoid memory leak */
     175              : static void
     176            6 : record_default(pari_stack *s_P, char *ab)
     177              : {
     178            6 :   pair_t *P = (pair_t*)*pari_stack_base(s_P);
     179              :   char *k, *v;
     180              :   long n;
     181            6 :   ab = pari_strdup(ab);
     182            6 :   parse_key_val(ab, &k, &v);
     183            6 :   n = pari_stack_new(s_P);
     184            6 :   P[n].key = k;
     185            6 :   P[n].val = v;
     186            6 : }
     187              : static void
     188         1895 : read_opt(pari_stack *p_A, long argc, char **argv)
     189              : {
     190              :   pair_t *P;
     191              :   pari_stack s_P; /* key / value to record default() settings */
     192         1895 :   char *b = NULL, *p = NULL, *s = NULL;
     193         1895 :   ulong f = GP_DATA->flags;
     194         1895 :   long i = 1, initrc = 1;
     195              : 
     196              :   (void)&p; (void)&b; (void)&s; /* -Wall gcc-2.95 */
     197              : 
     198         1895 :   pari_stack_init(&s_P,sizeof(*P),(void**)&P);
     199         1895 :   pari_stack_alloc(&s_P, 64);
     200         1895 :   pari_outfile = stderr;
     201         5671 :   while (i < argc)
     202              :   {
     203         3782 :     char *t = argv[i];
     204              : 
     205         3782 :     if (*t++ != '-') break;
     206         3782 :     i++;
     207         3782 : START:
     208         3782 :     switch(*t++)
     209              :     {
     210            0 :       case 'p': p = read_arg(&i,t,argc,argv); break;
     211            0 :       case 's': s = read_arg(&i,t,argc,argv); break;
     212            0 :       case 'e':
     213            0 :         f |= gpd_EMACS; if (*t) goto START;
     214            0 :         break;
     215         1883 :       case 'q':
     216         1883 :         f |= gpd_QUIET; if (*t) goto START;
     217         1883 :         break;
     218            0 :       case 't':
     219            0 :         f |= gpd_TEST; if (*t) goto START;
     220            0 :         break;
     221           21 :       case 'f':
     222           21 :         initrc = 0; if (*t) goto START;
     223           21 :         break;
     224            4 :       case 'D':
     225            4 :         if (*t || i == argc) usage(argv[0]);
     226            4 :         record_default(&s_P, argv[i++]);
     227            4 :         break;
     228         1874 :       case '-':
     229         1874 :         if (strcmp(t, "version-short") == 0) { print_shortversion(); exit(0); }
     230         1872 :         if (strcmp(t, "version") == 0) {
     231            2 :           init_trivial_stack(); pari_print_version();
     232            2 :           free_trivial_stack(); exit(0);
     233              :         }
     234         1870 :         if (strcmp(t, "default") == 0) {
     235            2 :           if (i == argc) usage(argv[0]);
     236            2 :           record_default(&s_P, argv[i++]);
     237            2 :           break;
     238              :         }
     239         1868 :         if (strcmp(t, "texmacs") == 0) { f |= gpd_TEXMACS; break; }
     240         1868 :         if (strcmp(t, "emacs") == 0) { f |= gpd_EMACS; break; }
     241         1868 :         if (strcmp(t, "test") == 0) { f |= gpd_TEST; initrc = 0; break; }
     242            6 :         if (strcmp(t, "quiet") == 0) { f |= gpd_QUIET; break; }
     243            4 :         if (strcmp(t, "fast") == 0) { initrc = 0; break; }
     244            2 :         if (strncmp(t, "primelimit",10) == 0) {p = read_arg_equal(&i,t+10,argc,argv); break; }
     245            2 :         if (strncmp(t, "stacksize",9) == 0) {s = read_arg_equal(&i,t+9,argc,argv); break; }
     246              :        /* fall through */
     247              :       default:
     248            2 :         usage(argv[0]);
     249              :     }
     250              :   }
     251         1889 :   if (f & gpd_TEST) stdin_isatty = 0;
     252         1889 :   GP_DATA->flags = f;
     253              : #ifdef READLINE
     254         1889 :   GP_DATA->use_readline = stdin_isatty;
     255              : #endif
     256         1889 :   if (!is_interactive()) GP_DATA->breakloop = 0;
     257         1889 :   if (initrc) gp_initrc(p_A);
     258         1889 :   for ( ; i < argc; i++) pari_stack_pushp(p_A, pari_strdup(argv[i]));
     259              : 
     260              :   /* override the values from gprc */
     261         1889 :   if (p) (void)sd_primelimit(p, d_INITRC);
     262         1889 :   if (s) (void)sd_parisize(s, d_INITRC);
     263         1893 :   for (i = 0; i < s_P.n; i++) {
     264            6 :     setdefault(P[i].key, P[i].val, d_INITRC);
     265            4 :     free((void*)P[i].key);
     266              :   }
     267         1887 :   pari_stack_delete(&s_P);
     268         1887 :   pari_outfile = stdout;
     269         1887 : }
     270              : 
     271              : /*******************************************************************/
     272              : /**                                                               **/
     273              : /**                            TEST MODE                          **/
     274              : /**                                                               **/
     275              : /*******************************************************************/
     276              : static int
     277       269089 : test_is_interactive(void) { return 0; }
     278              : 
     279              : static void
     280        60904 : test_output(long n) { init_linewrap(76); gen_output(pari_get_hist(n)); }
     281              : void
     282         1862 : init_test(void)
     283              : {
     284         1862 :   disable_color = 1;
     285         1862 :   init_linewrap(76);
     286         1862 :   pari_errfile = stdout;
     287         1862 :   cb_pari_display_hist = test_output;
     288         1862 :   cb_pari_is_interactive = test_is_interactive;
     289         1862 : }
     290              : 
     291              : static GEN
     292         1887 : gp_main_loop(long ismain)
     293              : {
     294         1887 :   VOLATILE GEN z = gnil;
     295         1887 :   VOLATILE long t = 0, r = 0;
     296         1887 :   VOLATILE pari_sp av = avma;
     297              :   filtre_t F;
     298         1887 :   Buffer *b = filtered_buffer(&F);
     299              :   struct gp_context rec;
     300              :   long er;
     301         1887 :   if ((er = setjmp(env[s_env.n-1])))
     302              :   { /* recover: jump from error [ > 0 ] or allocatemem [ -1 ] */
     303        13533 :     if (er > 0) { /* true error */
     304        13081 :       if (!(GP_DATA->recover)) exit(1);
     305        13081 :       gp_context_restore(&rec);
     306              :       /* true error not from main instance, let caller sort it out */
     307        13081 :       if (!ismain) { kill_buffers_upto_including(b); return NULL; }
     308              :     } else { /* allocatemem */
     309          452 :       tmp_restore(rec.file.file);
     310          452 :       gp_context_save(&rec);
     311              :     }
     312        13533 :     av = pari_mainstack->top;
     313        13533 :     set_avma(av);
     314        13533 :     parivstack_reset();
     315        13533 :     kill_buffers_upto(b);
     316        13533 :     pari_alarm(0);
     317              :   }
     318              :   for(;;)
     319              :   {
     320       146068 :     gp_context_save(&rec);
     321       146068 :     if (! gp_read_line(&F, NULL))
     322              :     {
     323         1887 :       if (popinfile()) gp_quit(0);
     324            0 :       if (ismain) continue;
     325            0 :       pop_buffer(); return z;
     326              :     }
     327       144181 :     if (ismain)
     328              :     {
     329       144181 :       reset_ctrlc();
     330       144181 :       timer_start(GP_DATA->T);
     331       144181 :       walltimer_start(GP_DATA->Tw);
     332       144181 :       pari_set_last_newline(1);
     333              :     }
     334       144181 :     if (gp_meta(b->buf,ismain)) continue;
     335       122101 :     z = pari_compile_str(b->buf);
     336       122010 :     z = closure_evalres(z);
     337       108589 :     if (!ismain) continue;
     338              : 
     339       108589 :     t = timer_delay(GP_DATA->T);
     340       108589 :     r = walltimer_delay(GP_DATA->Tw);
     341       108589 :     if (!pari_last_was_newline()) pari_putc('\n');
     342       108589 :     pari_alarm(0);
     343       108589 :     if (t && GP_DATA->chrono)
     344              :     {
     345            0 :       if (pari_mt_nbthreads==1)
     346              :       {
     347            0 :         pari_puts("time = ");
     348            0 :         pari_puts(gp_format_time(t));
     349              :       }
     350              :       else
     351              :       {
     352            0 :         pari_puts("cpu time = ");
     353            0 :         pari_puts(gp_format_time(t));
     354            0 :         pari_puts(", real time = ");
     355            0 :         pari_puts(gp_format_time(r));
     356              :       }
     357            0 :       pari_puts(".\n");
     358              :     }
     359       108589 :     if (GP_DATA->simplify) z = simplify_shallow(z);
     360       108589 :     pari_add_hist(z, t, r);
     361       108589 :     if (z != gnil && ! is_silent(b->buf) )
     362        60908 :       gp_display_hist(GP_DATA->hist->total);
     363       108589 :     set_avma(av);
     364       108589 :     parivstack_reset();
     365              :   }
     366              : }
     367              : 
     368              : /* as gp_read_file, before running the main gp instance */
     369              : static void
     370            0 : read_main(const char *s)
     371              : {
     372              :   GEN z;
     373            0 :   if (setjmp(env[s_env.n-1]))
     374            0 :     z = NULL;
     375              :   else {
     376            0 :     FILE *f = switchin(s);
     377            0 :     if (file_is_binary(f)) {
     378            0 :       z = readbin(s,f, NULL);
     379            0 :       popinfile();
     380              :     }
     381            0 :     else z = gp_main_loop(0);
     382              :   }
     383            0 :   if (!z) err_printf("... skipping file '%s'\n", s);
     384            0 :   set_avma(pari_mainstack->top);
     385            0 : }
     386              : 
     387              : static const char *
     388          126 : break_loop_prompt(long n)
     389              : {
     390          126 :   return n==0 ? "GP prompt" : n==1? "break> ": stack_sprintf("break[%ld]> ", n);
     391              : }
     392              : 
     393              : static long frame_level=0, dbg_level = 0;
     394              : 
     395              : static int
     396           63 : break_loop(int numerr)
     397              : {
     398              :   filtre_t F;
     399              :   Buffer *b;
     400           63 :   int sigint = numerr<0, go_on = sigint;
     401              :   struct gp_context rec1, rec2;
     402              :   const char *prompt, *msg;
     403           63 :   long nenv, oldframe_level = frame_level;
     404              :   pari_sp av;
     405              : 
     406           63 :   if (numerr == e_SYNTAX) return 0;
     407           63 :   if (numerr == e_STACK) { evalstate_clone(); set_avma(pari_mainstack->top); }
     408           63 :   gp_context_save(&rec1);
     409              : 
     410           63 :   b = filtered_buffer(&F);
     411           63 :   nenv=pari_stack_new(&s_env);
     412           63 :   prompt = gp_format_prompt(break_loop_prompt(nenv));
     413           63 :   iferr_env = NULL;
     414           63 :   dbg_level = 0;
     415           63 :   frame_level = closure_context(oldframe_level, dbg_level);
     416           63 :   pari_infile = newfile(stdin, "stdin", mf_IN)->file;
     417           63 :   term_color(c_ERR); pari_putc('\n');
     418           63 :   if (sigint)
     419            7 :     msg = "Break loop: <Return> to continue; 'break' to go back to %s";
     420              :   else
     421           56 :     msg = "Break loop: type 'break' to go back to %s";
     422           63 :   msg = stack_sprintf(msg, break_loop_prompt(nenv-1));
     423           63 :   print_errcontext(pariOut, msg, NULL, NULL);
     424           63 :   term_color(c_NONE);
     425           63 :   av = avma;
     426              :   for(;;)
     427           91 :   {
     428              :     GEN x;
     429              :     long er, br_status;
     430          154 :     set_avma(av);
     431          154 :     gp_context_save(&rec2);
     432          154 :     if ((er=setjmp(env[nenv])))
     433              :     {
     434           35 :       if (er < 0)
     435              :       {
     436            7 :         s_env.n = 1;
     437            7 :         frame_level = oldframe_level;
     438            7 :         longjmp(env[s_env.n-1], er);
     439              :       }
     440           28 :       gp_context_restore(&rec2);
     441           28 :       iferr_env = NULL;
     442           28 :       closure_err(dbg_level);
     443           28 :       compilestate_restore(&rec1.eval.comp);
     444           28 :       (void) closure_context(oldframe_level, dbg_level);
     445           28 :       pari_infile = newfile(stdin, "stdin", mf_IN)->file;
     446              :     }
     447          182 :     term_color(c_NONE);
     448          182 :     if (!gp_read_line(&F, prompt))
     449            0 :       br_status = br_BREAK; /* EOF */
     450              :     else
     451              :     {
     452              :       /* Empty input ? Continue if entry on sigint (exit debugger frame) */
     453          182 :       if (! *(b->buf) && sigint) break;
     454          175 :       reset_ctrlc();
     455          175 :       if (gp_meta(b->buf,0)) continue;
     456          175 :       x = pari_compile_str(b->buf);
     457          175 :       x = closure_evalbrk(x, &br_status);
     458              :     }
     459          140 :     switch (br_status)
     460              :     {
     461            0 :       case br_NEXT: case br_MULTINEXT:
     462            0 :         popinfile(); /* exit frame. Don't exit debugger if s_env.n > 2 */
     463           49 :         go_on = 0; goto BR_EXIT;
     464           49 :       case br_BREAK: case br_RETURN:
     465           49 :         killallfiles(); /* completely exit the debugger */
     466           49 :         go_on = 0; goto BR_EXIT;
     467              :     }
     468           91 :     if (x!=gnil && !is_silent(b->buf)) { term_color(c_OUTPUT); gen_output(x); }
     469              :   }
     470           56 : BR_EXIT:
     471           56 :   s_env.n=nenv;
     472           56 :   frame_level = oldframe_level;
     473           56 :   gp_context_restore(&rec1);
     474           56 :   pop_buffer(); return go_on;
     475              : }
     476              : 
     477              : #ifdef __CYGWIN32__
     478              : void
     479              : cyg_environment(int argc, char ** argv)
     480              : {
     481              :   char *ti_dirs = getenv("TERMINFO_DIRS");
     482              :   char *argv0, *p;
     483              :   char *newdir;
     484              :   long n;
     485              : 
     486              :   if (!argc || !argv) return;
     487              :   argv0 = *argv;
     488              :   if (!argv0 || !*argv0) return;
     489              :   p = strrchr(argv0, '/');
     490              :   if (!p)
     491              :     p = argv0 = "";
     492              :   else
     493              :     p++;
     494              :   n = p - argv0;
     495              :   if (ti_dirs)
     496              :   {
     497              :     n += 14 + strlen(ti_dirs) + 1 + 8 + 1;
     498              :     newdir = malloc(n);
     499              :     if (!newdir) return;
     500              :     snprintf(newdir, n-8, "TERMINFO_DIRS=%s:%s", ti_dirs, argv0);
     501              :   }
     502              :   else
     503              :   {
     504              :     n += 14 + 8 + 1;
     505              :     newdir = malloc(n);
     506              :     if (!newdir) return;
     507              :     snprintf(newdir, n-8, "TERMINFO_DIRS=%s", argv0);
     508              :   }
     509              :   strcpy(newdir+n-9,"terminfo");
     510              :   putenv(newdir);
     511              : }
     512              : #endif
     513              : 
     514              : int
     515         1895 : main(int argc, char **argv)
     516              : {
     517              :   char **A;
     518              :   pari_stack s_A;
     519              : 
     520         1895 :   GP_DATA = default_gp_data();
     521         1895 :   pari_stack_init(&s_env, sizeof(*env), (void**)&env);
     522         1895 :   (void)pari_stack_new(&s_env);
     523              : 
     524         1895 :   if (setjmp(env[s_env.n-1]))
     525              :   {
     526            2 :     puts("### Errors on startup, exiting...\n\n");
     527            2 :     exit(1);
     528              :   }
     529              : #ifdef DEBUG_FLOATS
     530              :   feenableexcept(FE_INVALID);
     531              : #endif
     532              : #ifdef __CYGWIN32__
     533              :   cyg_environment(argc, argv);
     534              : #endif
     535         1895 :   stdin_isatty = pari_stdin_isatty();
     536         1895 :   pari_init_defaults();
     537         1895 :   pari_library_path = DL_DFLT_NAME;
     538         1895 :   pari_stack_init(&s_A,sizeof(*A),(void**)&A);
     539              :   /* must be defined here in case an error is raised in pari_init_opts, e.g.
     540              :    * when parsing function prototypes */
     541         1895 :   cb_pari_err_recover = gp_err_recover;
     542         1895 :   pari_init_opts(8000000, 0, INIT_SIGm | INIT_noPRIMEm | INIT_noIMTm);
     543         1895 :   cb_pari_pre_recover = gp_pre_recover;
     544         1895 :   cb_pari_break_loop = break_loop;
     545         1895 :   cb_pari_is_interactive = is_interactive;
     546              : 
     547         1895 :   read_opt(&s_A, argc,argv);
     548         1887 :   pari_init_primes(GP_DATA->primelimit, GP_DATA->factorlimit);
     549              : #ifdef SIGALRM
     550         1887 :   (void)os_signal(SIGALRM,gp_alarm_handler);
     551              : #endif
     552         1887 :   pari_add_module(functions_gp);
     553              : 
     554         1887 :   pari_set_plot_engine(gp_get_plot);
     555         1887 :   cb_pari_quit = gp_quit;
     556         1887 :   cb_pari_whatnow = whatnow;
     557         1887 :   cb_pari_sigint = gp_sigint_fun;
     558         1887 :   cb_pari_handle_exception = gp_handle_exception;
     559         1887 :   cb_pari_ask_confirm = gp_ask_confirm;
     560         1887 :   pari_init_paths();
     561         1887 :   pari_mt_init(); /* MPI: will not return on slaves (pari_MPI_rank = 0) */
     562              : #ifdef _WIN32
     563              :   if (stdin_isatty) win32_set_codepage();
     564              : #endif
     565              : #ifdef READLINE
     566         1887 :   init_readline();
     567              : #endif
     568         1887 :   if (GP_DATA->flags & gpd_EMACS) init_emacs();
     569         1887 :   if (GP_DATA->flags & gpd_TEXMACS) init_texmacs();
     570              : 
     571         1887 :   timer_start(GP_DATA->T);
     572         1887 :   walltimer_start(GP_DATA->Tw);
     573         1887 :   if (!(GP_DATA->flags & gpd_QUIET)) gp_head();
     574         1887 :   if (GP_DATA->flags & gpd_TEST) init_test();
     575         1887 :   if (s_A.n)
     576              :   {
     577            0 :     FILE *l = pari_logfile;
     578              :     long i;
     579            0 :     pari_logfile = NULL;
     580            0 :     for (i = 0; i < s_A.n; pari_free(A[i]),i++) read_main(A[i]);
     581              :     /* Reading one of the input files above can set pari_logfile.
     582              :      * Don't restore in that case. */
     583            0 :     if (!pari_logfile) pari_logfile = l;
     584              :   }
     585         1887 :   pari_stack_delete(&s_A);
     586         1887 :   (void)gp_main_loop(1);
     587            0 :   gp_quit(0);
     588              :   return 0; /* LCOV_EXCL_LINE */
     589              : }
     590              : 
     591              : void
     592            7 : dbg_down(long k)
     593              : {
     594            7 :   if (k<0) k=0;
     595            7 :   dbg_level -= k;
     596            7 :   if (dbg_level<0) dbg_level=0;
     597            7 :   gp_err_recover(e_NONE);
     598            0 : }
     599              : 
     600              : GEN
     601            7 : dbg_err(void) { GEN E = pari_err_last(); return E? gcopy(E):gnil; }
     602              : 
     603              : void
     604           14 : dbg_up(long k)
     605              : {
     606           14 :   if (k<0) k=0;
     607           14 :   dbg_level += k;
     608           14 :   if (dbg_level>frame_level) dbg_level=frame_level;
     609           14 :   gp_err_recover(e_NONE);
     610            0 : }
     611              : 
     612              : void
     613         1887 : gp_quit(long code)
     614              : {
     615         1887 :   pari_kill_plot_engine();
     616         1887 :   pari_close();
     617         1887 :   kill_buffers_upto(NULL);
     618         1887 :   if (!(GP_DATA->flags & gpd_QUIET)) pari_puts("Goodbye!\n");
     619         1887 :   if (cb_pari_end_output) cb_pari_end_output();
     620         1887 :   exit(code);
     621              : }
     622              : 
     623              : void
     624           35 : whatnow0(char *s) { whatnow(pariOut, s,0); }
     625              : 
     626              : #include "gp_init.h"
        

Generated by: LCOV version 2.0-1