Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28485 views
License: GPL3
ubuntu2004
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
#include "pari.h"
16
#include "paripriv.h"
17
#include "gp.h"
18
#include "whatnow.h"
19
20
static void
21
msg(PariOUT *out, const char *s)
22
{
23
out_term_color(out, c_HELP);
24
out_print_text(out, s);
25
out_putc(out, '\n');
26
out_term_color(out, c_NONE);
27
}
28
/* If flag = 0 (default): check if s existed in 1.39.15 and print verbosely
29
* the answer.
30
* Else: return 1 if function changed, 0 otherwise, and print help message
31
* plus the above. */
32
int
33
whatnow(PariOUT *out, const char *s, int flag)
34
{
35
const char *def;
36
const whatnow_t *wp = whatnowlist;
37
entree *ep;
38
39
while (wp->old && strcmp(wp->old,s)) wp++;
40
/* Above linear search is slow, esp. if the symbol is not found. BUT no
41
* point in wasting time by preallocating [ or autoloading ] a hashtable:
42
* whatnow() is never used in a case where speed would be necessary */
43
if (!wp->old)
44
{
45
if (!flag) msg(out, "This function did not exist in Pari 1.39");
46
return 0;
47
}
48
def = wp->name;
49
if (def == SAME)
50
{
51
if (!flag)
52
msg(out, "This function did not change");
53
return 0;
54
}
55
if (flag)
56
{
57
out_term_color(out, c_NONE);
58
out_print_text(out, "\nA function with that name existed in GP-1.39.15. Please update your script.");
59
out_putc(out, '\n');
60
}
61
62
if (def == REMOV)
63
{
64
msg(out, "This function no longer exists");
65
return 0;
66
}
67
/* special case compimag -> x*y */
68
if (!strcmp(def,"x*y")) def = "_*_";
69
ep = is_entry(def);
70
if (!ep) pari_err_BUG("whatnow");
71
out_puts(out, "New syntax: ");
72
out_term_color(out, c_ERR);
73
out_printf(out, "%s%s ===> %s%s\n\n", s, wp->oldarg, wp->name, wp->newarg);
74
msg(out, ep->help);
75
out_term_color(out, c_NONE); return 1;
76
}
77
78