mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
* nismodule.c: database keys and values can contain null bytes. be more
careful about these. * arraymodule.c: added 8 byte swap; added 'i' format character; added reverse() method; rename read/write to fromfile/tofile. * config.c: Set version to 0.9.9++. * rotormodule.c (r_rand): declare k1..k5 as unsigned longs so the shifts will have a well-defined effect independent of word size. * bltinmodule.c: renamed bagof() to filter().
This commit is contained in:
parent
78ed420314
commit
e77a757094
5 changed files with 101 additions and 36 deletions
|
@ -67,9 +67,23 @@ nis_foreach (instatus, inkey, inkeylen, inval, invallen, indata)
|
|||
object *indata;
|
||||
{
|
||||
if (instatus == YP_TRUE) {
|
||||
inkey[inkeylen]=0;
|
||||
inval[invallen]=0;
|
||||
dictinsert (indata, inkey, newstringobject (inval));
|
||||
object *key = newsizedstringobject(inkey, inkeylen);
|
||||
object *val = newsizedstringobject(inval, invallen);
|
||||
int err;
|
||||
if (key == NULL || val == NULL) {
|
||||
/* XXX error -- don't know how to handle */
|
||||
err_clear();
|
||||
XDECREF(key);
|
||||
XDECREF(val);
|
||||
return 1;
|
||||
}
|
||||
err = mappinginsert(indata, key, val);
|
||||
DECREF(key);
|
||||
DECREF(val);
|
||||
if (err != 0) {
|
||||
err_clear();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
@ -82,18 +96,18 @@ nis_match (self, args)
|
|||
{
|
||||
char *match;
|
||||
char *domain;
|
||||
int len;
|
||||
int keylen, len;
|
||||
char *key, *map;
|
||||
int err;
|
||||
object *res;
|
||||
|
||||
if (!getargs(args, "(ss)", &key, &map))
|
||||
if (!getargs(args, "(s#s)", &key, &keylen, &map))
|
||||
return NULL;
|
||||
if ((err = yp_get_default_domain(&domain)) != 0)
|
||||
return nis_error(err);
|
||||
BGN_SAVE
|
||||
map = nis_mapname (map);
|
||||
err = yp_match (domain, map, key, strlen (key), &match, &len);
|
||||
err = yp_match (domain, map, key, keylen, &match, &len);
|
||||
END_SAVE
|
||||
if (err != 0)
|
||||
return nis_error(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue