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

Generated by: LCOV version 1.11