#10993: Update eclib to latest upstream release
-----------------------------------+----------------------------------------
Reporter: cremona | Owner: cremona
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.0
Component: packages | Resolution:
Keywords: elliptic curves | Work issues: ldconfig in spkg-install
Report Upstream: N/A | Reviewers: Frithjof Schulze, Jeroen
Demeyer
Authors: John Cremona | Merged in:
Dependencies: #11354 | Stopgaps:
-----------------------------------+----------------------------------------
Comment (by leif):
Replying to [comment:131 leif]:
> You may also simply wrap `getenv()` with an additional (preferably
`const char*`) default parameter, returned if the environment variable
isn't set, just like Python's `os.environ.get("VAR_NAME", default_value)`.
>
> (And the additional parameter might itself default to either `""` or
`NULL`. But if you provide a default parameter for your wrapper function,
you won't be able to just overload `getenv()`. So it would be best to add
a `getenv()` function with an additional ''non-optional'' parameter, then
calling `getenv(NON_DEFINED_NAME)` would just return `NULL`, while
`getenv(NON_DEFINED_NAME, DEFAULT_VALUE)` would return `DEFAULT_VALUE`,
"transparently".)
Like this:
{{{
#!c++
#include <cstdlib>
#include <iostream>
using std::getenv;
const char *getenv(const char *var_name, const char *default_value)
{
const char *val = getenv(var_name);
return val ? val : default_value;
}
int main(void)
{
std::cout << "getenv(\"FOO\"): " << getenv("FOO") << std::endl;
std::cout.clear();
std::cout << std::endl;
std::cout << "getenv(\"FOO\", \"bar\"): " << getenv("FOO", "bar") <<
std::endl;
return 0;
}
}}}
which yields
{{{
getenv("FOO"):
getenv("FOO", "bar"): bar
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10993#comment:134>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.