idx
int64 | func
string | target
int64 |
|---|---|---|
404,699
|
void set_close_on_exec(unsigned int fd, int flag)
{
struct files_struct *files = current->files;
struct fdtable *fdt;
spin_lock(&files->file_lock);
fdt = files_fdtable(files);
if (flag)
__set_close_on_exec(fd, fdt);
else
__clear_close_on_exec(fd, fdt);
spin_unlock(&files->file_lock);
}
| 0
|
313,144
|
testStorageFileGetMetadata(const char *path,
int format,
uid_t uid, gid_t gid)
{
struct stat st;
g_autoptr(virStorageSource) def = NULL;
if (!(def = virStorageSourceNew()))
return NULL;
def->type = VIR_STORAGE_TYPE_FILE;
def->format = format;
if (stat(path, &st) == 0) {
if (S_ISDIR(st.st_mode)) {
def->type = VIR_STORAGE_TYPE_DIR;
} else if (S_ISBLK(st.st_mode)) {
def->type = VIR_STORAGE_TYPE_BLOCK;
}
}
def->path = g_strdup(path);
if (virStorageFileGetMetadata(def, uid, gid, true) < 0)
return NULL;
return g_steal_pointer(&def);
}
| 0
|
230,454
|
ra_input(void)
{
uip_lladdr_t lladdr_aligned;
LOG_INFO("Received RA from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO_(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO_("\n");
UIP_STAT(++uip_stat.nd6.recv);
#if UIP_CONF_IPV6_CHECKS
if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||
(!uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr)) ||
(UIP_ICMP_BUF->icode != 0)) {
LOG_ERR("RA received is bad");
goto discard;
}
#endif /*UIP_CONF_IPV6_CHECKS */
if(UIP_ND6_RA_BUF->cur_ttl != 0) {
uip_ds6_if.cur_hop_limit = UIP_ND6_RA_BUF->cur_ttl;
LOG_INFO("uip_ds6_if.cur_hop_limit %u\n", uip_ds6_if.cur_hop_limit);
}
if(UIP_ND6_RA_BUF->reachable_time != 0) {
if(uip_ds6_if.base_reachable_time !=
uip_ntohl(UIP_ND6_RA_BUF->reachable_time)) {
uip_ds6_if.base_reachable_time = uip_ntohl(UIP_ND6_RA_BUF->reachable_time);
uip_ds6_if.reachable_time = uip_ds6_compute_reachable_time();
}
}
if(UIP_ND6_RA_BUF->retrans_timer != 0) {
uip_ds6_if.retrans_timer = uip_ntohl(UIP_ND6_RA_BUF->retrans_timer);
}
/* Options processing */
nd6_opt_offset = UIP_ND6_RA_LEN;
while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {
if(ND6_OPT_HDR_BUF(nd6_opt_offset)->len == 0) {
LOG_ERR("RA received is bad");
goto discard;
}
switch (ND6_OPT_HDR_BUF(nd6_opt_offset)->type) {
case UIP_ND6_OPT_SLLAO:
LOG_DBG("Processing SLLAO option in RA\n");
nd6_opt_llao = (uint8_t *) ND6_OPT_HDR_BUF(nd6_opt_offset);
nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);
if(!extract_lladdr_from_llao_aligned(&lladdr_aligned)) {
/* failed to extract llao - discard packet */
goto discard;
}
if(nbr == NULL) {
nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,
1, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);
} else {
const uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(nbr);
if(lladdr == NULL) {
goto discard;
}
if(nbr->state == NBR_INCOMPLETE) {
nbr->state = NBR_STALE;
}
if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
lladdr, UIP_LLADDR_LEN) != 0) {
/* change of link layer address */
if(uip_ds6_nbr_update_ll(&nbr,
(const uip_lladdr_t *)&lladdr_aligned) < 0) {
/* failed to update the lladdr */
goto discard;
}
nbr->state = NBR_STALE;
}
nbr->isrouter = 1;
}
break;
case UIP_ND6_OPT_MTU:
LOG_DBG("Processing MTU option in RA\n");
uip_ds6_if.link_mtu =
uip_ntohl(((uip_nd6_opt_mtu *) ND6_OPT_HDR_BUF(nd6_opt_offset))->mtu);
break;
case UIP_ND6_OPT_PREFIX_INFO:
LOG_DBG("Processing PREFIX option in RA\n");
nd6_opt_prefix_info = (uip_nd6_opt_prefix_info *) ND6_OPT_HDR_BUF(nd6_opt_offset);
if((uip_ntohl(nd6_opt_prefix_info->validlt) >=
uip_ntohl(nd6_opt_prefix_info->preferredlt))
&& (!uip_is_addr_linklocal(&nd6_opt_prefix_info->prefix))) {
/* on-link flag related processing */
if(nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_ONLINK) {
prefix =
uip_ds6_prefix_lookup(&nd6_opt_prefix_info->prefix,
nd6_opt_prefix_info->preflen);
if(prefix == NULL) {
if(nd6_opt_prefix_info->validlt != 0) {
if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) {
prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix,
nd6_opt_prefix_info->preflen,
uip_ntohl(nd6_opt_prefix_info->
validlt));
} else {
prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix,
nd6_opt_prefix_info->preflen, 0);
}
}
} else {
switch (nd6_opt_prefix_info->validlt) {
case 0:
uip_ds6_prefix_rm(prefix);
break;
case UIP_ND6_INFINITE_LIFETIME:
prefix->isinfinite = 1;
break;
default:
LOG_DBG("Updating timer of prefix ");
LOG_DBG_6ADDR(&prefix->ipaddr);
LOG_DBG_(" new value %"PRIu32"\n", uip_ntohl(nd6_opt_prefix_info->validlt));
stimer_set(&prefix->vlifetime,
uip_ntohl(nd6_opt_prefix_info->validlt));
prefix->isinfinite = 0;
break;
}
}
}
/* End of on-link flag related processing */
/* autonomous flag related processing */
if((nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_AUTONOMOUS)
&& (nd6_opt_prefix_info->validlt != 0)
&& (nd6_opt_prefix_info->preflen == UIP_DEFAULT_PREFIX_LEN)) {
uip_ipaddr_copy(&ipaddr, &nd6_opt_prefix_info->prefix);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
addr = uip_ds6_addr_lookup(&ipaddr);
if((addr != NULL) && (addr->type == ADDR_AUTOCONF)) {
if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) {
/* The processing below is defined in RFC4862 section 5.5.3 e */
if((uip_ntohl(nd6_opt_prefix_info->validlt) > 2 * 60 * 60) ||
(uip_ntohl(nd6_opt_prefix_info->validlt) >
stimer_remaining(&addr->vlifetime))) {
LOG_DBG("Updating timer of address ");
LOG_DBG_6ADDR(&addr->ipaddr);
LOG_DBG_(" new value %lu\n",
(unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt));
stimer_set(&addr->vlifetime,
uip_ntohl(nd6_opt_prefix_info->validlt));
} else {
stimer_set(&addr->vlifetime, 2 * 60 * 60);
LOG_DBG("Updating timer of address ");
LOG_DBG_6ADDR(&addr->ipaddr);
LOG_DBG_(" new value %lu\n", (unsigned long)(2 * 60 * 60));
}
addr->isinfinite = 0;
} else {
addr->isinfinite = 1;
}
} else {
if(uip_ntohl(nd6_opt_prefix_info->validlt) ==
UIP_ND6_INFINITE_LIFETIME) {
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
} else {
uip_ds6_addr_add(&ipaddr, uip_ntohl(nd6_opt_prefix_info->validlt),
ADDR_AUTOCONF);
}
}
}
/* End of autonomous flag related processing */
}
break;
#if UIP_ND6_RA_RDNSS
case UIP_ND6_OPT_RDNSS:
LOG_DBG("Processing RDNSS option\n");
uint8_t naddr = (ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len - 1) / 2;
uip_ipaddr_t *ip = (uip_ipaddr_t *)(&ND6_OPT_RDNSS_BUF(nd6_opt_offset)->ip);
LOG_DBG("got %d nameservers\n", naddr);
while(naddr-- > 0) {
LOG_DBG("nameserver: ");
LOG_DBG_6ADDR(ip);
LOG_DBG_(" lifetime: %"PRIx32"\n", uip_ntohl(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime));
uip_nameserver_update(ip, uip_ntohl(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime));
ip++;
}
break;
#endif /* UIP_ND6_RA_RDNSS */
default:
LOG_ERR("ND option not supported in RA\n");
break;
}
nd6_opt_offset += (ND6_OPT_HDR_BUF(nd6_opt_offset)->len << 3);
}
defrt = uip_ds6_defrt_lookup(&UIP_IP_BUF->srcipaddr);
if(UIP_ND6_RA_BUF->router_lifetime != 0) {
if(nbr != NULL) {
nbr->isrouter = 1;
}
if(defrt == NULL) {
uip_ds6_defrt_add(&UIP_IP_BUF->srcipaddr,
(unsigned
long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime)));
} else {
stimer_set(&(defrt->lifetime),
(unsigned long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime)));
}
} else {
if(defrt != NULL) {
uip_ds6_defrt_rm(defrt);
}
}
#if UIP_CONF_IPV6_QUEUE_PKT
/* If the nbr just became reachable (e.g. it was in NBR_INCOMPLETE state
* and we got a SLLAO), check if we had buffered a pkt for it */
/* if((nbr != NULL) && (nbr->queue_buf_len != 0)) {
uip_len = nbr->queue_buf_len;
memcpy(UIP_IP_BUF, nbr->queue_buf, uip_len);
nbr->queue_buf_len = 0;
return;
}*/
if(nbr != NULL && uip_packetqueue_buflen(&nbr->packethandle) != 0) {
uip_len = uip_packetqueue_buflen(&nbr->packethandle);
memcpy(UIP_IP_BUF, uip_packetqueue_buf(&nbr->packethandle), uip_len);
uip_packetqueue_free(&nbr->packethandle);
return;
}
#endif /*UIP_CONF_IPV6_QUEUE_PKT */
discard:
uipbuf_clear();
return;
}
| 0
|
513,276
|
bool JOIN::setup_subquery_caches()
{
DBUG_ENTER("JOIN::setup_subquery_caches");
/*
We have to check all this condition together because items created in
one of this clauses can be moved to another one by optimizer
*/
if (select_lex->expr_cache_may_be_used[IN_WHERE] ||
select_lex->expr_cache_may_be_used[IN_HAVING] ||
select_lex->expr_cache_may_be_used[IN_ON] ||
select_lex->expr_cache_may_be_used[NO_MATTER])
{
if (conds)
conds= conds->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
JOIN_TAB *tab;
for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES);
tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
{
if (tab->select_cond)
tab->select_cond=
tab->select_cond->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
if (tab->cache_select && tab->cache_select->cond)
tab->cache_select->cond=
tab->cache_select->
cond->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
}
if (having)
having= having->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
if (tmp_having)
{
DBUG_ASSERT(having == NULL);
tmp_having= tmp_having->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
}
}
if (select_lex->expr_cache_may_be_used[SELECT_LIST] ||
select_lex->expr_cache_may_be_used[IN_GROUP_BY] ||
select_lex->expr_cache_may_be_used[NO_MATTER])
{
List_iterator<Item> li(all_fields);
Item *item;
while ((item= li++))
{
Item *new_item=
item->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
if (new_item != item)
{
thd->change_item_tree(li.ref(), new_item);
}
}
for (ORDER *tmp_group= group_list; tmp_group ; tmp_group= tmp_group->next)
{
*tmp_group->item=
(*tmp_group->item)->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
}
}
if (select_lex->expr_cache_may_be_used[NO_MATTER])
{
for (ORDER *ord= order; ord; ord= ord->next)
{
*ord->item=
(*ord->item)->transform(thd, &Item::expr_cache_insert_transformer,
NULL);
}
}
DBUG_RETURN(FALSE);
}
| 0
|
453,033
|
static int nft_chain_offload_cmd(struct nft_base_chain *basechain,
struct net_device *dev,
enum flow_block_command cmd)
{
int err;
if (dev->netdev_ops->ndo_setup_tc)
err = nft_block_offload_cmd(basechain, dev, cmd);
else
err = nft_indr_block_offload_cmd(basechain, dev, cmd);
return err;
}
| 0
|
229,147
|
static size_t write_to_port(VirtIOSerialPort *port,
const uint8_t *buf, size_t size)
{
VirtQueueElement elem;
VirtQueue *vq;
size_t offset;
vq = port->ivq;
if (!virtio_queue_ready(vq)) {
return 0;
}
offset = 0;
while (offset < size) {
size_t len;
if (!virtqueue_pop(vq, &elem)) {
break;
}
len = iov_from_buf(elem.in_sg, elem.in_num, 0,
buf + offset, size - offset);
offset += len;
virtqueue_push(vq, &elem, len);
}
virtio_notify(VIRTIO_DEVICE(port->vser), vq);
return offset;
}
| 0
|
210,928
|
void jfs_evict_inode(struct inode *inode)
{
struct jfs_inode_info *ji = JFS_IP(inode);
jfs_info("In jfs_evict_inode, inode = 0x%p", inode);
if (!inode->i_nlink && !is_bad_inode(inode)) {
dquot_initialize(inode);
if (JFS_IP(inode)->fileset == FILESYSTEM_I) {
truncate_inode_pages_final(&inode->i_data);
if (test_cflag(COMMIT_Freewmap, inode))
jfs_free_zero_link(inode);
if (JFS_SBI(inode->i_sb)->ipimap)
diFree(inode);
/*
* Free the inode from the quota allocation.
*/
dquot_free_inode(inode);
}
} else {
truncate_inode_pages_final(&inode->i_data);
}
clear_inode(inode);
dquot_drop(inode);
BUG_ON(!list_empty(&ji->anon_inode_list));
spin_lock_irq(&ji->ag_lock);
if (ji->active_ag != -1) {
struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;
atomic_dec(&bmap->db_active[ji->active_ag]);
ji->active_ag = -1;
}
spin_unlock_irq(&ji->ag_lock);
}
| 1
|
333,053
|
state_in_list(
nfa_list_T *l, // runtime state list
nfa_state_T *state, // state to update
regsubs_T *subs) // pointers to subexpressions
{
if (state->lastlist[nfa_ll_index] == l->id)
{
if (!rex.nfa_has_backref || has_state_with_pos(l, state, subs, NULL))
return TRUE;
}
return FALSE;
}
| 0
|
364,775
|
findtags_state_free(findtags_state_T *st)
{
vim_free(st->tag_fname);
vim_free(st->lbuf);
vim_regfree(st->orgpat->regmatch.regprog);
vim_free(st->orgpat);
#ifdef FEAT_EMACS_TAGS
vim_free(st->ebuf);
#endif
}
| 0
|
254,880
|
MONGO_COMPILER_NOINLINE DocumentSource::GetNextResult DocumentSourceGroup::initializeSelf(
GetNextResult input) {
const size_t numAccumulators = _accumulatedFields.size();
// Barring any pausing, this loop exhausts 'pSource' and populates '_groups'.
for (; input.isAdvanced(); input = pSource->getNext()) {
if (_memoryTracker.shouldSpillWithAttemptToSaveMemory([this]() { return freeMemory(); })) {
_sortedFiles.push_back(spill());
}
// We release the result document here so that it does not outlive the end of this loop
// iteration. Not releasing could lead to an array copy when this group follows an unwind.
auto rootDocument = input.releaseDocument();
Value id = computeId(rootDocument);
// Look for the _id value in the map. If it's not there, add a new entry with a blank
// accumulator. This is done in a somewhat odd way in order to avoid hashing 'id' and
// looking it up in '_groups' multiple times.
const size_t oldSize = _groups->size();
vector<intrusive_ptr<AccumulatorState>>& group = (*_groups)[id];
const bool inserted = _groups->size() != oldSize;
if (inserted) {
_memoryTracker.memoryUsageBytes += id.getApproximateSize();
// Initialize and add the accumulators
Value expandedId = expandId(id);
Document idDoc =
expandedId.getType() == BSONType::Object ? expandedId.getDocument() : Document();
group.reserve(numAccumulators);
for (auto&& accumulatedField : _accumulatedFields) {
auto accum = accumulatedField.makeAccumulator();
Value initializerValue =
accumulatedField.expr.initializer->evaluate(idDoc, &pExpCtx->variables);
accum->startNewGroup(initializerValue);
group.push_back(accum);
}
} else {
for (auto&& groupObj : group) {
// subtract old mem usage. New usage added back after processing.
_memoryTracker.memoryUsageBytes -= groupObj->memUsageForSorter();
}
}
/* tickle all the accumulators for the group we found */
dassert(numAccumulators == group.size());
for (size_t i = 0; i < numAccumulators; i++) {
group[i]->process(
_accumulatedFields[i].expr.argument->evaluate(rootDocument, &pExpCtx->variables),
_doingMerge);
_memoryTracker.memoryUsageBytes += group[i]->memUsageForSorter();
}
if (kDebugBuild && !storageGlobalParams.readOnly) {
// In debug mode, spill every time we have a duplicate id to stress merge logic.
if (!inserted && // is a dup
!pExpCtx->inMongos && // can't spill to disk in mongos
!_memoryTracker.allowDiskUse && // don't change behavior when testing external sort
_sortedFiles.size() < 20) { // don't open too many FDs
_sortedFiles.push_back(spill());
}
}
}
switch (input.getStatus()) {
case DocumentSource::GetNextResult::ReturnStatus::kAdvanced: {
MONGO_UNREACHABLE; // We consumed all advances above.
}
case DocumentSource::GetNextResult::ReturnStatus::kPauseExecution: {
return input; // Propagate pause.
}
case DocumentSource::GetNextResult::ReturnStatus::kEOF: {
// Do any final steps necessary to prepare to output results.
if (!_sortedFiles.empty()) {
_spilled = true;
if (!_groups->empty()) {
_sortedFiles.push_back(spill());
}
// We won't be using groups again so free its memory.
_groups = pExpCtx->getValueComparator().makeUnorderedValueMap<Accumulators>();
_sorterIterator.reset(Sorter<Value, Value>::Iterator::merge(
_sortedFiles, SortOptions(), SorterComparator(pExpCtx->getValueComparator())));
// prepare current to accumulate data
_currentAccumulators.reserve(numAccumulators);
for (auto&& accumulatedField : _accumulatedFields) {
_currentAccumulators.push_back(accumulatedField.makeAccumulator());
}
verify(_sorterIterator->more()); // we put data in, we should get something out.
_firstPartOfNextGroup = _sorterIterator->next();
} else {
// start the group iterator
groupsIterator = _groups->begin();
}
// This must happen last so that, unless control gets here, we will re-enter
// initialization after getting a GetNextResult::ResultState::kPauseExecution.
_initialized = true;
return input;
}
}
MONGO_UNREACHABLE;
}
| 0
|
229,226
|
std::tuple<net::inet_address, int, client_type> cql_server::connection::make_client_key(const service::client_state& cli_state) {
return std::make_tuple(cli_state.get_client_address().addr(),
cli_state.get_client_port(),
cli_state.is_thrift() ? client_type::thrift : client_type::cql);
}
| 0
|
204,073
|
static char ** split(const char *arg, const char *delim) {
char *copy = dupstr(arg);
char **result = NULL;
int i = 0;
for (char *cptr = strtok(copy, delim); cptr; cptr = strtok(NULL, delim)) {
char **tmp = realloc (result, sizeof *result * (i + 1));
if (!tmp && result) {
while (i > 0) {
free(result[--i]);
}
free(result);
free(copy);
return NULL;
}
result = tmp;
result[i++] = dupstr(cptr);
}
free(copy);
if (i) {
char **tmp = realloc(result, sizeof *result * (i + 1));
if (!tmp) {
while (i > 0) {
free(result[--i]);
}
free(result);
free(copy);
return NULL;
}
result = tmp;
result[i++] = NULL;
}
return result;
}
| 1
|
198,117
|
void Compute(OpKernelContext* context) override {
// Here's the basic idea:
// Batch and depth dimension are independent from row and col dimension. And
// because FractionalAvgPool currently only support pooling along row and
// col, we can basically think of this 4D tensor backpropagation as
// operation of a series of 2D planes.
//
// For each element of a 'slice' (2D plane) of output_backprop, we need to
// figure out its contributors when doing FractionalAvgPool operation. This
// can be done based on row_pooling_sequence, col_pooling_seq and
// overlapping.
// Once we figure out the original contributors, we just need to evenly
// divide the value of this element among these contributors.
//
// Internally, we divide the out_backprop tensor and store it in a temporary
// tensor of double type. And cast it to the corresponding type.
typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>
ConstEigenMatrixMap;
typedef Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>
EigenDoubleMatrixMap;
// Grab the inputs.
const Tensor& orig_input_tensor_shape = context->input(0);
OP_REQUIRES(context,
orig_input_tensor_shape.dims() == 1 &&
orig_input_tensor_shape.NumElements() == 4,
errors::InvalidArgument("original input tensor shape must be"
"1-dimensional and 4 elements"));
const Tensor& out_backprop = context->input(1);
const Tensor& row_seq_tensor = context->input(2);
const Tensor& col_seq_tensor = context->input(3);
const int64_t out_batch = out_backprop.dim_size(0);
const int64_t out_rows = out_backprop.dim_size(1);
const int64_t out_cols = out_backprop.dim_size(2);
const int64_t out_depth = out_backprop.dim_size(3);
OP_REQUIRES(context, row_seq_tensor.NumElements() > out_rows,
errors::InvalidArgument("Given out_backprop shape ",
out_backprop.shape().DebugString(),
", row_seq_tensor must have at least ",
out_rows + 1, " elements, but got ",
row_seq_tensor.NumElements()));
OP_REQUIRES(context, col_seq_tensor.NumElements() > out_cols,
errors::InvalidArgument("Given out_backprop shape ",
out_backprop.shape().DebugString(),
", col_seq_tensor must have at least ",
out_cols + 1, " elements, but got ",
col_seq_tensor.NumElements()));
auto row_seq_tensor_flat = row_seq_tensor.flat<int64>();
auto col_seq_tensor_flat = col_seq_tensor.flat<int64>();
auto orig_input_tensor_shape_flat = orig_input_tensor_shape.flat<int64>();
const int64_t in_batch = orig_input_tensor_shape_flat(0);
const int64_t in_rows = orig_input_tensor_shape_flat(1);
const int64_t in_cols = orig_input_tensor_shape_flat(2);
const int64_t in_depth = orig_input_tensor_shape_flat(3);
constexpr int tensor_in_and_out_dims = 4;
// Transform orig_input_tensor_shape into TensorShape
TensorShape in_shape;
for (auto i = 0; i < tensor_in_and_out_dims; ++i) {
in_shape.AddDim(orig_input_tensor_shape_flat(i));
}
// Create intermediate in_backprop.
Tensor in_backprop_tensor_temp;
OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp(
{0}, DataTypeToEnum<double>::v(), in_shape,
&in_backprop_tensor_temp));
in_backprop_tensor_temp.flat<double>().setZero();
// Transform 4D tensor to 2D matrix.
EigenDoubleMatrixMap in_backprop_tensor_temp_mat(
in_backprop_tensor_temp.flat<double>().data(), in_depth,
in_cols * in_rows * in_batch);
ConstEigenMatrixMap out_backprop_mat(out_backprop.flat<T>().data(),
out_depth,
out_cols * out_rows * out_batch);
// Loop through each element of out_backprop and evenly distribute the
// element to the corresponding pooling cell.
const int64_t in_max_row_index = in_rows - 1;
const int64_t in_max_col_index = in_cols - 1;
for (int64_t b = 0; b < out_batch; ++b) {
for (int64_t r = 0; r < out_rows; ++r) {
const int64_t in_row_start = row_seq_tensor_flat(r);
int64_t in_row_end = overlapping_ ? row_seq_tensor_flat(r + 1)
: row_seq_tensor_flat(r + 1) - 1;
in_row_end = std::min(in_row_end, in_max_row_index);
for (int64_t c = 0; c < out_cols; ++c) {
const int64_t in_col_start = col_seq_tensor_flat(c);
int64_t in_col_end = overlapping_ ? col_seq_tensor_flat(c + 1)
: col_seq_tensor_flat(c + 1) - 1;
in_col_end = std::min(in_col_end, in_max_col_index);
const int64_t num_elements_in_pooling_cell =
(in_row_end - in_row_start + 1) * (in_col_end - in_col_start + 1);
const int64_t out_index = (b * out_rows + r) * out_cols + c;
// Now we can evenly distribute out_backprop(b, h, w, *) to
// in_backprop(b, hs:he, ws:we, *).
for (int64_t in_r = in_row_start; in_r <= in_row_end; ++in_r) {
for (int64_t in_c = in_col_start; in_c <= in_col_end; ++in_c) {
const int64_t in_index = (b * in_rows + in_r) * in_cols + in_c;
// Walk through each channel (depth).
for (int64_t d = 0; d < out_depth; ++d) {
const double out_backprop_element = static_cast<double>(
out_backprop_mat.coeffRef(d, out_index));
double& in_backprop_ref =
in_backprop_tensor_temp_mat.coeffRef(d, in_index);
in_backprop_ref +=
out_backprop_element / num_elements_in_pooling_cell;
}
}
}
}
}
}
// Depending on the type, cast double to type T.
Tensor* in_backprop_tensor = nullptr;
OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(
{0}, 0, in_shape, &in_backprop_tensor));
auto in_backprop_tensor_flat = in_backprop_tensor->flat<T>();
auto in_backprop_tensor_temp_flat = in_backprop_tensor_temp.flat<double>();
for (int64_t i = 0; i < in_backprop_tensor_flat.size(); ++i) {
in_backprop_tensor_flat(i) =
static_cast<T>(in_backprop_tensor_temp_flat(i));
}
}
| 1
|
265,442
|
static char *sqfs_resolve_symlink(struct squashfs_symlink_inode *sym,
const char *base_path)
{
char *resolved, *target;
u32 sz;
sz = get_unaligned_le32(&sym->symlink_size);
target = malloc(sz + 1);
if (!target)
return NULL;
/*
* There is no trailling null byte in the symlink's target path, so a
* copy is made and a '\0' is added at its end.
*/
target[sz] = '\0';
/* Get target name (relative path) */
strncpy(target, sym->symlink, sz);
/* Relative -> absolute path conversion */
resolved = sqfs_get_abs_path(base_path, target);
free(target);
return resolved;
}
| 0
|
335,415
|
restore_current_state(save_state_T *sst)
{
// Restore the previous typeahead.
restore_typeahead(&sst->tabuf, FALSE);
msg_scroll = sst->save_msg_scroll;
restart_edit = sst->save_restart_edit;
p_im = sst->save_insertmode;
finish_op = sst->save_finish_op;
opcount = sst->save_opcount;
reg_executing = sst->save_reg_executing;
pending_end_reg_executing = sst->save_pending_end_reg_executing;
msg_didout |= sst->save_msg_didout; // don't reset msg_didout now
current_sctx.sc_version = sst->save_script_version;
// Restore the state (needed when called from a function executed for
// 'indentexpr'). Update the mouse and cursor, they may have changed.
State = sst->save_State;
#ifdef CURSOR_SHAPE
ui_cursor_shape(); // may show different cursor shape
#endif
}
| 0
|
502,692
|
int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
{
return remove_session_lock(ctx, c, 1);
}
| 0
|
262,027
|
ServiceProtoDispatchRequest(ServiceConnection *conn,
ProtoRequest *req)
{
VGAuthError err;
gchar *packet;
/*
* Many requests must come across a superUser owned pipe.
* Verify that here.
*/
err = Proto_SecurityCheckRequest(conn, req);
if (err != VGAUTH_E_OK) {
Warning("%s: security check failed for request type %d\n",
__FUNCTION__, req->reqType);
packet = Proto_MakeErrorReply(conn,
req,
err,
"Security check failed");
goto sendError;
}
#ifdef _WIN32
/*
* Check if we need to complete an earlier pid verification
*/
if (conn->pidVerifyState == PID_VERIFY_PENDING) {
err = ServiceEndVerifyPid(conn);
if (err != VGAUTH_E_OK) {
VGAUTH_LOG_WARNING("ServiceEndVerifyPid() failed, pipe = %s", conn->pipeName);
packet = Proto_MakeErrorReply(conn,
req,
err,
"Pid verification failed");
goto sendError;
}
}
/*
* Check that we have the client proc handle to process the following
* requests.
*/
switch(req->reqType) {
case PROTO_REQUEST_CREATETICKET:
case PROTO_REQUEST_VALIDATETICKET:
case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN:
if (conn->hProc == NULL) {
VGAUTH_LOG_WARNING("Invalid client process HANDLE, possibly missing Connect, "
"pipe = %s", conn->pipeName);
err = VGAUTH_E_FAIL;
packet = Proto_MakeErrorReply(conn,
req,
err,
"Client process handle check failed");
goto sendError;
}
break;
default:
break;
}
#endif
switch (req->reqType) {
case PROTO_REQUEST_SESSION_REQ:
err = ServiceProtoHandleSessionRequest(conn, req);
break;
case PROTO_REQUEST_CONN:
err = ServiceProtoHandleConnection(conn, req);
break;
case PROTO_REQUEST_ADDALIAS:
err = ServiceProtoAddAlias(conn, req);
break;
case PROTO_REQUEST_REMOVEALIAS:
err = ServiceProtoRemoveAlias(conn, req);
break;
case PROTO_REQUEST_QUERYALIASES:
err = ServiceProtoQueryAliases(conn, req);
break;
case PROTO_REQUEST_QUERYMAPPEDALIASES:
err = ServiceProtoQueryMappedAliases(conn, req);
break;
case PROTO_REQUEST_CREATETICKET:
err = ServiceProtoCreateTicket(conn, req);
break;
case PROTO_REQUEST_VALIDATETICKET:
err = ServiceProtoValidateTicket(conn, req);
break;
case PROTO_REQUEST_REVOKETICKET:
err = ServiceProtoRevokeTicket(conn, req);
break;
case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN:
err = ServiceProtoValidateSamlBearerToken(conn, req);
break;
default:
/*
* Be polite, send an error, and then fail cleanly
*/
err = VGAUTH_E_NOTIMPLEMENTED;
packet = Proto_MakeErrorReply(conn,
req,
err,
"Unrecognized request");
sendError:
/*
* Don't really care if it works since we're about to
* shut it down anyways.
*/
(void) ServiceNetworkWriteData(conn, strlen(packet), packet);
g_free(packet);
break;
}
// 'err' is from ServiceNetworkWriteData(), not from the operation
Log("%s: processed reqType %d(%s REQ), returning "
VGAUTHERR_FMT64" on connection %d\n", __FUNCTION__,
req->reqType, ProtoRequestTypeText(req->reqType), err, conn->connId);
return err;
}
| 0
|
225,554
|
TfLiteStatus TfLiteTensorCopy(const TfLiteTensor* src, TfLiteTensor* dst) {
if (!src || !dst)
return kTfLiteOk;
if (src->bytes != dst->bytes)
return kTfLiteError;
if (src == dst)
return kTfLiteOk;
dst->type = src->type;
if (dst->dims)
TfLiteIntArrayFree(dst->dims);
dst->dims = TfLiteIntArrayCopy(src->dims);
memcpy(dst->data.raw, src->data.raw, src->bytes);
dst->buffer_handle = src->buffer_handle;
dst->data_is_stale = src->data_is_stale;
dst->delegate = src->delegate;
return kTfLiteOk;
}
| 0
|
384,913
|
skipwhite_and_nl(char_u *q)
{
char_u *p = q;
while (VIM_ISWHITE(*p) || *p == NL)
++p;
return p;
}
| 0
|
224,194
|
gen_hash(codegen_scope *s, node *tree, int val, int limit)
{
int slimit = GEN_VAL_STACK_MAX;
if (cursp() >= GEN_LIT_ARY_MAX) slimit = INT16_MAX;
int len = 0;
mrb_bool update = FALSE;
mrb_bool first = TRUE;
while (tree) {
if (nint(tree->car->car->car) == NODE_KW_REST_ARGS) {
if (val && first) {
genop_2(s, OP_HASH, cursp(), 0);
push();
update = TRUE;
}
else if (val && len > 0) {
pop_n(len*2);
if (!update) {
genop_2(s, OP_HASH, cursp(), len);
}
else {
pop();
genop_2(s, OP_HASHADD, cursp(), len);
}
push();
}
codegen(s, tree->car->cdr, val);
if (val && (len > 0 || update)) {
pop(); pop();
genop_1(s, OP_HASHCAT, cursp());
push();
}
update = TRUE;
len = 0;
}
else {
codegen(s, tree->car->car, val);
codegen(s, tree->car->cdr, val);
len++;
}
tree = tree->cdr;
if (val && cursp() >= slimit) {
pop_n(len*2);
if (!update) {
genop_2(s, OP_HASH, cursp(), len);
}
else {
pop();
genop_2(s, OP_HASHADD, cursp(), len);
}
push();
update = TRUE;
len = 0;
}
first = FALSE;
}
if (val && len > limit) {
pop_n(len*2);
genop_2(s, OP_HASH, cursp(), len);
push();
return -1;
}
if (update) {
if (val && len > 0) {
pop_n(len*2+1);
genop_2(s, OP_HASHADD, cursp(), len);
push();
}
return -1; /* variable length */
}
return len;
}
| 0
|
336,612
|
static void reds_handle_sasl_result(void *opaque, RedSaslError status)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
switch (status) {
case RED_SASL_ERROR_OK:
reds_handle_link(link);
break;
case RED_SASL_ERROR_INVALID_DATA:
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
reds_link_free(link);
break;
default:
// in these cases error was reported using SASL protocol
// (RED_SASL_ERROR_AUTH_FAILED) or we just need to close the
// connection
reds_link_free(link);
break;
}
}
| 0
|
309,806
|
bcd_expression(const char *str)
{
/* leave this non-const for HPUX */
static char fmt[] = "%%p%c%%{10}%%/%%{16}%%*%%p%c%%{10}%%m%%+";
int len = 0;
char ch1, ch2;
if (sscanf(str, fmt, &ch1, &ch2) == 2
&& isdigit(UChar(ch1))
&& isdigit(UChar(ch2))
&& (ch1 == ch2)) {
len = 28;
#ifndef NDEBUG
{
char buffer[80];
int tst;
_nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) fmt, ch1, ch2);
tst = strlen(buffer) - 1;
assert(len == tst);
}
#endif
}
return len;
}
| 0
|
430,373
|
void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
int rowsize, int groupsize, const void *buf, size_t len,
bool ascii)
{
const u8 *ptr = buf;
int i, linelen, remaining = len;
char *buffer;
size_t size;
int ret;
if (rowsize != 16 && rowsize != 32)
rowsize = 16;
for (i = 0; i < len && !seq_has_overflowed(m); i += rowsize) {
linelen = min(remaining, rowsize);
remaining -= rowsize;
switch (prefix_type) {
case DUMP_PREFIX_ADDRESS:
seq_printf(m, "%s%p: ", prefix_str, ptr + i);
break;
case DUMP_PREFIX_OFFSET:
seq_printf(m, "%s%.8x: ", prefix_str, i);
break;
default:
seq_printf(m, "%s", prefix_str);
break;
}
size = seq_get_buf(m, &buffer);
ret = hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
buffer, size, ascii);
seq_commit(m, ret < size ? ret : -1);
seq_putc(m, '\n');
}
}
| 0
|
286,737
|
static int SWTPM_HMAC(unsigned char *md, unsigned int *md_len,
const void *key, int key_len,
const unsigned char *in, uint32_t in_length,
const unsigned char *ivec, uint32_t ivec_length)
{
OSSL_PARAM params[2];
EVP_MAC_CTX *ctx;
EVP_MAC *hmac;
size_t outl;
int ret = 0;
hmac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL);
if (!hmac)
return 0;
ctx = EVP_MAC_CTX_new(hmac);
if (!ctx)
goto err;
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_DIGEST,
"sha256", 0);
params[1] = OSSL_PARAM_construct_end();
if (!EVP_MAC_init(ctx, key, key_len, params) ||
!EVP_MAC_update(ctx, in, in_length))
goto err;
if (ivec &&
!EVP_MAC_update(ctx, ivec, ivec_length))
goto err;
if (!EVP_MAC_final(ctx, md, &outl, *md_len))
goto err;
*md_len = outl;
ret = 1;
err:
EVP_MAC_CTX_free(ctx);
EVP_MAC_free(hmac);
return ret;
}
| 0
|
225,806
|
GF_Box *tfrf_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_MSSTimeRefBox, GF_ISOM_BOX_TYPE_UUID);
tmp->internal_4cc = GF_ISOM_BOX_UUID_TFRF;
return (GF_Box *)tmp;
}
| 0
|
352,935
|
csnPretty(
Syntax *syntax,
struct berval *val,
struct berval *out,
void *ctx )
{
return csnNormalize( SLAP_MR_VALUE_OF_SYNTAX, NULL, NULL, val, out, ctx );
}
| 0
|
400,756
|
static unsigned long iov_iter_alignment_bvec(const struct iov_iter *i)
{
unsigned res = 0;
size_t size = i->count;
unsigned skip = i->iov_offset;
unsigned k;
for (k = 0; k < i->nr_segs; k++, skip = 0) {
size_t len = i->bvec[k].bv_len - skip;
res |= (unsigned long)i->bvec[k].bv_offset + skip;
if (len > size)
len = size;
res |= len;
size -= len;
if (!size)
break;
}
return res;
}
| 0
|
398,514
|
static RzList /*<RzBinDwarfARangeSet>*/ *parse_aranges_raw(const ut8 *obuf, size_t obuf_sz, bool big_endian) {
rz_return_val_if_fail(obuf, NULL);
const ut8 *buf = obuf;
const ut8 *buf_end = buf + obuf_sz;
RzList *r = rz_list_newf((RzListFree)rz_bin_dwarf_arange_set_free);
if (!r) {
return NULL;
}
// DWARF 3 Standard Section 6.1.2 Lookup by Address
// also useful to grep for display_debug_aranges in binutils
while (buf < buf_end) {
const ut8 *start = buf;
bool is_64bit;
ut64 unit_length = dwarf_read_initial_length(&is_64bit, big_endian, &buf, buf_end);
// Sanity check: length must be at least the minimal size of the remaining header fields
// and at maximum the remaining buffer size.
size_t header_rest_size = 2 + (is_64bit ? 8 : 4) + 1 + 1;
if (unit_length < header_rest_size || unit_length > buf_end - buf) {
break;
}
const ut8 *next_set_buf = buf + unit_length;
RzBinDwarfARangeSet *set = RZ_NEW(RzBinDwarfARangeSet);
if (!set) {
break;
}
set->unit_length = unit_length;
set->is_64bit = is_64bit;
set->version = READ16(buf);
set->debug_info_offset = dwarf_read_offset(set->is_64bit, big_endian, &buf, buf_end);
set->address_size = READ8(buf);
set->segment_size = READ8(buf);
unit_length -= header_rest_size;
if (!set->address_size) {
free(set);
break;
}
// align to 2*addr_size
size_t off = buf - start;
size_t pad = rz_num_align_delta(off, 2 * set->address_size);
if (pad > unit_length || pad > buf_end - buf) {
free(set);
break;
}
buf += pad;
unit_length -= pad;
size_t arange_size = 2 * set->address_size;
set->aranges_count = unit_length / arange_size;
if (!set->aranges_count) {
free(set);
break;
}
set->aranges = RZ_NEWS0(RzBinDwarfARange, set->aranges_count);
if (!set->aranges) {
free(set);
break;
}
size_t i;
for (i = 0; i < set->aranges_count; i++) {
set->aranges[i].addr = dwarf_read_address(set->address_size, big_endian, &buf, buf_end);
set->aranges[i].length = dwarf_read_address(set->address_size, big_endian, &buf, buf_end);
if (!set->aranges[i].addr && !set->aranges[i].length) {
// last entry has two 0s
i++; // so i will be the total count of read entries
break;
}
}
set->aranges_count = i;
buf = next_set_buf;
rz_list_push(r, set);
}
return r;
}
| 0
|
409,473
|
term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len)
{
int i;
int c;
for (i = ta_len; i < ta_len + len; ++i)
{
if (ta_buf[i] == CSI && len - i > 2)
{
c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]);
if (c == K_DEL || c == K_KDEL || c == K_BS)
{
mch_memmove(ta_buf + i + 1, ta_buf + i + 3,
(size_t)(len - i - 2));
if (c == K_DEL || c == K_KDEL)
ta_buf[i] = DEL;
else
ta_buf[i] = Ctrl_H;
len -= 2;
}
}
else if (ta_buf[i] == '\r')
ta_buf[i] = '\n';
if (has_mbyte)
i += (*mb_ptr2len_len)(ta_buf + i, ta_len + len - i) - 1;
}
}
| 0
|
356,707
|
bool Statement::Bind(const Parameters & parameters) {
if (parameters.size() == 0) {
return true;
}
sqlite3_reset(_handle);
sqlite3_clear_bindings(_handle);
Parameters::const_iterator it = parameters.begin();
Parameters::const_iterator end = parameters.end();
for (; it < end; ++it) {
Values::Field* field = *it;
if (field != NULL) {
unsigned int pos;
if (field->index > 0) {
pos = field->index;
}
else {
pos = sqlite3_bind_parameter_index(_handle, field->name.c_str());
}
switch (field->type) {
case SQLITE_INTEGER: {
status = sqlite3_bind_int(_handle, pos,
((Values::Integer*)field)->value);
} break;
case SQLITE_FLOAT: {
status = sqlite3_bind_double(_handle, pos,
((Values::Float*)field)->value);
} break;
case SQLITE_TEXT: {
status = sqlite3_bind_text(_handle, pos,
((Values::Text*)field)->value.c_str(),
((Values::Text*)field)->value.size(), SQLITE_TRANSIENT);
} break;
case SQLITE_BLOB: {
status = sqlite3_bind_blob(_handle, pos,
((Values::Blob*)field)->value,
((Values::Blob*)field)->length, SQLITE_TRANSIENT);
} break;
case SQLITE_NULL: {
status = sqlite3_bind_null(_handle, pos);
} break;
}
if (status != SQLITE_OK) {
message = std::string(sqlite3_errmsg(db->_handle));
return false;
}
}
}
return true;
}
| 0
|
453,025
|
static void nft_flow_block_offload_init(struct flow_block_offload *bo,
struct net *net,
enum flow_block_command cmd,
struct nft_base_chain *basechain,
struct netlink_ext_ack *extack)
{
memset(bo, 0, sizeof(*bo));
bo->net = net;
bo->block = &basechain->flow_block;
bo->command = cmd;
bo->binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
bo->extack = extack;
bo->cb_list_head = &basechain->flow_block.cb_list;
INIT_LIST_HEAD(&bo->cb_list);
}
| 0
|
240,257
|
copy_yank_reg(yankreg_T *reg)
{
yankreg_T *curr = y_current;
long j;
y_current = reg;
free_yank_all();
*y_current = *curr;
y_current->y_array = lalloc_clear(
sizeof(char_u *) * y_current->y_size, TRUE);
if (y_current->y_array == NULL)
y_current->y_size = 0;
else
for (j = 0; j < y_current->y_size; ++j)
if ((y_current->y_array[j] = vim_strsave(curr->y_array[j])) == NULL)
{
free_yank(j);
y_current->y_size = 0;
break;
}
y_current = curr;
}
| 0
|
247,363
|
static int pgpVersion(const uint8_t *h, size_t hlen, uint8_t *version)
{
if (hlen < 1)
return -1;
*version = h[0];
return 0;
}
| 0
|
231,026
|
void vQueueSetQueueNumber( QueueHandle_t xQueue,
UBaseType_t uxQueueNumber )
{
( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber;
}
| 0
|
291,791
|
static int init_conns(struct rtrs_clt_path *clt_path)
{
unsigned int cid;
int err;
/*
* On every new session connections increase reconnect counter
* to avoid clashes with previous sessions not yet closed
* sessions on a server side.
*/
clt_path->s.recon_cnt++;
/* Establish all RDMA connections */
for (cid = 0; cid < clt_path->s.con_num; cid++) {
err = create_con(clt_path, cid);
if (err)
goto destroy;
err = create_cm(to_clt_con(clt_path->s.con[cid]));
if (err) {
destroy_con(to_clt_con(clt_path->s.con[cid]));
goto destroy;
}
}
err = alloc_path_reqs(clt_path);
if (err)
goto destroy;
rtrs_start_hb(&clt_path->s);
return 0;
destroy:
while (cid--) {
struct rtrs_clt_con *con = to_clt_con(clt_path->s.con[cid]);
stop_cm(con);
mutex_lock(&con->con_mutex);
destroy_con_cq_qp(con);
mutex_unlock(&con->con_mutex);
destroy_cm(con);
destroy_con(con);
}
/*
* If we've never taken async path and got an error, say,
* doing rdma_resolve_addr(), switch to CONNECTION_ERR state
* manually to keep reconnecting.
*/
rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING_ERR, NULL);
return err;
}
| 0
|
265,061
|
promptexpand(char *s, int ns, char *rs, char *Rs, zattr *txtchangep)
{
struct buf_vars new_vars;
if(!s)
return ztrdup("");
if ((termflags & TERM_UNKNOWN) && (unset(INTERACTIVE)))
init_term();
if (isset(PROMPTSUBST)) {
int olderr = errflag;
int oldval = lastval;
s = dupstring(s);
if (!parsestr(&s))
singsub(&s);
/*
* We don't need the special Nularg hack here and we're
* going to be using Nularg for other things.
*/
if (*s == Nularg && s[1] == '\0')
*s = '\0';
/*
* Ignore errors and status change in prompt substitution.
* However, keep any user interrupt error that occurred.
*/
errflag = olderr | (errflag & ERRFLAG_INT);
lastval = oldval;
}
memset(&new_vars, 0, sizeof(new_vars));
new_vars.last = bv;
bv = &new_vars;
new_vars.rstring = rs;
new_vars.Rstring = Rs;
new_vars.fm = s;
new_vars.bufspc = 256;
new_vars.bp = new_vars.bufline = new_vars.buf = zshcalloc(new_vars.bufspc);
new_vars.bp1 = NULL;
new_vars.truncwidth = 0;
putpromptchar(1, '\0', txtchangep);
addbufspc(2);
if (new_vars.dontcount)
*new_vars.bp++ = Outpar;
*new_vars.bp = '\0';
if (!ns) {
/* If zero, Inpar, Outpar and Nularg should be removed. */
for (new_vars.bp = new_vars.buf; *new_vars.bp; ) {
if (*new_vars.bp == Meta)
new_vars.bp += 2;
else if (*new_vars.bp == Inpar || *new_vars.bp == Outpar ||
*new_vars.bp == Nularg)
chuck(new_vars.bp);
else
new_vars.bp++;
}
}
bv = new_vars.last;
return new_vars.buf;
}
| 0
|
175,783
|
FilePath profile_path() const { return data_dir_.path(); }
| 0
|
273,407
|
void Compute(OpKernelContext* ctx) override {
const Tensor* x_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("x", &x_tensor));
const Tensor* cs_prev_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("cs_prev", &cs_prev_tensor));
const Tensor* h_prev_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("h_prev", &h_prev_tensor));
const Tensor* w_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("w", &w_tensor));
const Tensor* wci_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("wci", &wci_tensor));
const Tensor* wcf_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("wcf", &wcf_tensor));
const Tensor* wco_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("wco", &wco_tensor));
const Tensor* b_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("b", &b_tensor));
const int64_t batch_size = x_tensor->dim_size(0);
const int64_t input_size = x_tensor->dim_size(1);
const int64_t cell_size = cs_prev_tensor->dim_size(1);
// Sanity checks for our input shapes.
OP_REQUIRES(ctx, cs_prev_tensor->dim_size(0) == batch_size,
errors::InvalidArgument("cs_prev.dims(0) != batch_size: ",
cs_prev_tensor->dim_size(0), " vs. ",
batch_size));
OP_REQUIRES(ctx, cs_prev_tensor->dim_size(1) == cell_size,
errors::InvalidArgument("cs_prev.dims(1) != cell_size: ",
cs_prev_tensor->dim_size(1), " vs. ",
cell_size));
OP_REQUIRES(ctx, h_prev_tensor->dim_size(0) == batch_size,
errors::InvalidArgument("h_prev.dims(0) != batch_size: ",
h_prev_tensor->dim_size(0), " vs. ",
batch_size));
OP_REQUIRES(ctx, h_prev_tensor->dim_size(1) == cell_size,
errors::InvalidArgument(
"h_prev.dims(1) != cell_size: ", h_prev_tensor->dim_size(1),
" vs. ", cell_size));
OP_REQUIRES(ctx, w_tensor->dim_size(0) == input_size + cell_size,
errors::InvalidArgument(
"w.dim_size(0) != input_size + cell_size: ",
w_tensor->dim_size(0), " vs. ", input_size + cell_size));
OP_REQUIRES(ctx, w_tensor->dim_size(1) == cell_size * 4,
errors::InvalidArgument(
"w.dim_size(1) != cell_size * 4: ", w_tensor->dim_size(1),
" vs. ", cell_size * 4));
OP_REQUIRES(ctx, b_tensor->dim_size(0) == cell_size * 4,
errors::InvalidArgument(
"b.dim_size(0) != cell_size * 4: ", b_tensor->dim_size(0),
" vs. ", cell_size * 4));
// Allocate our output tensors.
Tensor* i_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(
{"h_prev"}, "i",
TensorShape({batch_size, cell_size}), &i_tensor));
Tensor* cs_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("cs", TensorShape({batch_size, cell_size}),
&cs_tensor));
Tensor* f_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("f", TensorShape({batch_size, cell_size}),
&f_tensor));
Tensor* o_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(
{"cs_prev"}, "o",
TensorShape({batch_size, cell_size}), &o_tensor));
Tensor* ci_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("ci", TensorShape({batch_size, cell_size}),
&ci_tensor));
Tensor* co_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("co", TensorShape({batch_size, cell_size}),
&co_tensor));
Tensor* h_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("h", TensorShape({batch_size, cell_size}),
&h_tensor));
// Allocate our temp tensors.
Tensor xh_tensor;
OP_REQUIRES_OK(ctx, ctx->allocate_temp(
DataTypeToEnum<T>::v(),
TensorShape({batch_size, input_size + cell_size}),
&xh_tensor));
Tensor gates_tensor;
OP_REQUIRES_OK(ctx,
ctx->allocate_temp(DataTypeToEnum<T>::v(),
TensorShape({batch_size, cell_size * 4}),
&gates_tensor));
const Device& device = ctx->eigen_device<Device>();
// Sanity check that each of the tensors have the required NDIMS.
OP_REQUIRES(ctx, x_tensor->dims() == 2,
errors::InvalidArgument("x_tensor must be rank 2 but is rank ",
x_tensor->dims(), "."));
OP_REQUIRES(
ctx, cs_prev_tensor->dims() == 2,
errors::InvalidArgument("cs_prev_tensor must be rank 2 but is rank ",
cs_prev_tensor->dims(), "."));
OP_REQUIRES(
ctx, h_prev_tensor->dims() == 2,
errors::InvalidArgument("h_prev_tensor must be rank 2 but is rank ",
h_prev_tensor->dims(), "."));
OP_REQUIRES(ctx, w_tensor->dims() == 2,
errors::InvalidArgument("w_tensor must be rank 2 but is rank ",
w_tensor->dims(), "."));
OP_REQUIRES(
ctx, wci_tensor->dims() == 1,
errors::InvalidArgument("wci_tensor must be rank 1 but is rank ",
wci_tensor->dims(), "."));
OP_REQUIRES(
ctx, wcf_tensor->dims() == 1,
errors::InvalidArgument("wcf_tensor must be rank 1 but is rank ",
wci_tensor->dims(), "."));
OP_REQUIRES(
ctx, wco_tensor->dims() == 1,
errors::InvalidArgument("wco_tensor must be rank 1 but is rank ",
wco_tensor->dims(), "."));
OP_REQUIRES(ctx, b_tensor->dims() == 1,
errors::InvalidArgument("b_tensor must be rank 1 but is rank ",
b_tensor->dims(), "."));
OP_REQUIRES(ctx, xh_tensor.dims() == 2,
errors::InvalidArgument("xh_tensor must be rank 2 but is rank ",
xh_tensor.dims(), "."));
OP_REQUIRES(ctx, i_tensor->dims() == 2,
errors::InvalidArgument("i_tensor must be rank 2 but is rank ",
i_tensor->dims(), "."));
OP_REQUIRES(ctx, cs_tensor->dims() == 2,
errors::InvalidArgument("cs_tensor must be rank 2 but is rank ",
cs_tensor->dims(), "."));
OP_REQUIRES(ctx, f_tensor->dims() == 2,
errors::InvalidArgument("f_tensor must be rank 2 but is rank ",
f_tensor->dims(), "."));
OP_REQUIRES(ctx, o_tensor->dims() == 2,
errors::InvalidArgument("o_tensor must be rank 2 but is rank ",
o_tensor->dims(), "."));
OP_REQUIRES(ctx, ci_tensor->dims() == 2,
errors::InvalidArgument("ci_tensor must be rank 2 but is rank ",
ci_tensor->dims(), "."));
OP_REQUIRES(ctx, co_tensor->dims() == 2,
errors::InvalidArgument("co_tensor must be rank 2 but is rank ",
co_tensor->dims(), "."));
OP_REQUIRES(
ctx, gates_tensor.dims() == 2,
errors::InvalidArgument("gates_tensor must be rank 2 but is rank ",
gates_tensor.dims(), "."));
OP_REQUIRES(ctx, h_tensor->dims() == 2,
errors::InvalidArgument("h_tensor must be rank 2 but is rank ",
h_tensor->dims(), "."));
functor::LSTMBlockCellFprop<Device, T, USE_CUBLAS, gate_layout>(
batch_size, input_size, cell_size)(
ctx, device, forget_bias_, cell_clip_, use_peephole_,
x_tensor->matrix<T>(), cs_prev_tensor->matrix<T>(),
h_prev_tensor->matrix<T>(), w_tensor->matrix<T>(), wci_tensor->vec<T>(),
wcf_tensor->vec<T>(), wco_tensor->vec<T>(), b_tensor->vec<T>(),
xh_tensor.matrix<T>(), i_tensor->matrix<T>(), cs_tensor->matrix<T>(),
f_tensor->matrix<T>(), o_tensor->matrix<T>(), ci_tensor->matrix<T>(),
co_tensor->matrix<T>(), gates_tensor.matrix<T>(),
h_tensor->matrix<T>());
}
| 0
|
474,000
|
onigenc_unicode_mbc_case_fold(OnigEncoding enc,
OnigCaseFoldType flag ARG_UNUSED, const UChar** pp, const UChar* end,
UChar* fold)
{
CodePointList3 *to;
OnigCodePoint code;
int i, len, rlen;
const UChar *p = *pp;
if (CaseFoldInited == 0) init_case_fold_table();
code = ONIGENC_MBC_TO_CODE(enc, p, end);
len = enclen(enc, p, end);
*pp += len;
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
if (code == 0x0049) {
return ONIGENC_CODE_TO_MBC(enc, 0x0131, fold);
}
else if (code == 0x0130) {
return ONIGENC_CODE_TO_MBC(enc, 0x0069, fold);
}
}
#endif
if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0) {
if (to->n == 1) {
return ONIGENC_CODE_TO_MBC(enc, to->code[0], fold);
}
#if 0
/* NO NEEDS TO CHECK */
else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0)
#else
else
#endif
{
rlen = 0;
for (i = 0; i < to->n; i++) {
len = ONIGENC_CODE_TO_MBC(enc, to->code[i], fold);
fold += len;
rlen += len;
}
return rlen;
}
}
for (i = 0; i < len; i++) {
*fold++ = *p++;
}
return len;
}
| 0
|
252,368
|
static bool DecompressRle(unsigned char *dst,
const unsigned long uncompressed_size,
const unsigned char *src, unsigned long src_size) {
if (uncompressed_size == src_size) {
// Data is not compressed(Issue 40).
memcpy(dst, src, src_size);
return true;
}
// Workaround for issue #112.
// TODO(syoyo): Add more robust out-of-bounds check in `rleUncompress`.
if (src_size <= 2) {
return false;
}
std::vector<unsigned char> tmpBuf(uncompressed_size);
int ret = rleUncompress(static_cast<int>(src_size),
static_cast<int>(uncompressed_size),
reinterpret_cast<const signed char *>(src),
reinterpret_cast<char *>(&tmpBuf.at(0)));
if (ret != static_cast<int>(uncompressed_size)) {
return false;
}
//
// Apply EXR-specific? postprocess. Grabbed from OpenEXR's
// ImfRleCompressor.cpp
//
// Predictor.
{
unsigned char *t = &tmpBuf.at(0) + 1;
unsigned char *stop = &tmpBuf.at(0) + uncompressed_size;
while (t < stop) {
int d = int(t[-1]) + int(t[0]) - 128;
t[0] = static_cast<unsigned char>(d);
++t;
}
}
// Reorder the pixel data.
{
const char *t1 = reinterpret_cast<const char *>(&tmpBuf.at(0));
const char *t2 = reinterpret_cast<const char *>(&tmpBuf.at(0)) +
(uncompressed_size + 1) / 2;
char *s = reinterpret_cast<char *>(dst);
char *stop = s + uncompressed_size;
for (;;) {
if (s < stop)
*(s++) = *(t1++);
else
break;
if (s < stop)
*(s++) = *(t2++);
else
break;
}
}
return true;
}
| 0
|
417,469
|
virNodeDeviceCapsListExport(virNodeDeviceDefPtr def,
virNodeDevCapType **list)
{
virNodeDevCapsDefPtr caps = NULL;
virNodeDevCapType *tmp = NULL;
bool want_list = !!list;
int ncaps = 0;
int ret = -1;
#define MAYBE_ADD_CAP(cap) \
do { \
if (want_list) \
tmp[ncaps] = cap; \
} while (0)
if (virNodeDeviceUpdateCaps(def) < 0)
goto cleanup;
if (want_list)
tmp = g_new0(virNodeDevCapType, VIR_NODE_DEV_CAP_LAST - 1);
for (caps = def->caps; caps; caps = caps->next) {
unsigned int flags;
MAYBE_ADD_CAP(caps->data.type);
ncaps++;
/* check nested caps for a given type as well */
if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
flags = caps->data.scsi_host.flags;
if (flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_FC_HOST);
ncaps++;
}
if (flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) {
MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_VPORTS);
ncaps++;
}
}
if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
flags = caps->data.pci_dev.flags;
if (flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) {
MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_MDEV_TYPES);
ncaps++;
}
}
if (caps->data.type == VIR_NODE_DEV_CAP_CSS_DEV) {
flags = caps->data.ccw_dev.flags;
if (flags & VIR_NODE_DEV_CAP_FLAG_CSS_MDEV) {
MAYBE_ADD_CAP(VIR_NODE_DEV_CAP_MDEV_TYPES);
ncaps++;
}
}
}
#undef MAYBE_ADD_CAP
if (want_list)
*list = g_steal_pointer(&tmp);
ret = ncaps;
cleanup:
VIR_FREE(tmp);
return ret;
}
| 0
|
477,355
|
R_API RBinSymbol *r_bin_java_create_new_symbol_from_ref(RBinJavaObj *bin, RBinJavaCPTypeObj *obj, ut64 baddr) {
RBinSymbol *sym = R_NEW0 (RBinSymbol);
if (!sym) {
return NULL;
}
char *class_name, *name, *type_name;
if (obj == NULL || (obj->tag != R_BIN_JAVA_CP_METHODREF &&
obj->tag != R_BIN_JAVA_CP_INTERFACEMETHOD_REF &&
obj->tag != R_BIN_JAVA_CP_FIELDREF)) {
R_FREE (sym);
return sym;
}
if (sym) {
class_name = r_bin_java_get_name_from_bin_cp_list (bin,
obj->info.cp_method.class_idx);
name = r_bin_java_get_name_from_bin_cp_list (bin,
obj->info.cp_method.name_and_type_idx);
type_name = r_bin_java_get_name_from_bin_cp_list (bin,
obj->info.cp_method.name_and_type_idx);
if (name) {
sym->name = name;
name = NULL;
}
if (type_name) {
sym->type = r_str_constpool_get (&bin->constpool, type_name);
R_FREE (type_name);
}
if (class_name) {
sym->classname = strdup (class_name);
}
sym->paddr = obj->file_offset + baddr;
sym->vaddr = obj->file_offset + baddr;
sym->ordinal = obj->metas->ord;
sym->size = 0;
}
return sym;
}
| 0
|
248,264
|
DLLIMPORT char *cfg_searchpath(cfg_searchpath_t *p, const char *file)
{
char *fullpath;
#ifdef HAVE_SYS_STAT_H
struct stat st;
int err;
#endif
if (!p || !file) {
errno = EINVAL;
return NULL;
}
if (file[0] == '/') {
fullpath = strdup(file);
if (!fullpath)
return NULL;
goto check;
}
if ((fullpath = cfg_searchpath(p->next, file)) != NULL)
return fullpath;
if ((fullpath = cfg_make_fullpath(p->dir, file)) == NULL)
return NULL;
check:
#ifdef HAVE_SYS_STAT_H
err = stat((const char *)fullpath, &st);
if ((!err) && S_ISREG(st.st_mode))
return fullpath;
#else
/* needs an alternative check here for win32 */
#endif
free(fullpath);
return NULL;
}
| 0
|
366,207
|
struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
int flag)
{
struct mount *res, *p, *q, *r, *parent;
if (!(flag & CL_COPY_UNBINDABLE) && IS_MNT_UNBINDABLE(mnt))
return ERR_PTR(-EINVAL);
if (!(flag & CL_COPY_MNT_NS_FILE) && is_mnt_ns_file(dentry))
return ERR_PTR(-EINVAL);
res = q = clone_mnt(mnt, dentry, flag);
if (IS_ERR(q))
return q;
q->mnt_mountpoint = mnt->mnt_mountpoint;
p = mnt;
list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) {
struct mount *s;
if (!is_subdir(r->mnt_mountpoint, dentry))
continue;
for (s = r; s; s = next_mnt(s, r)) {
if (!(flag & CL_COPY_UNBINDABLE) &&
IS_MNT_UNBINDABLE(s)) {
if (s->mnt.mnt_flags & MNT_LOCKED) {
/* Both unbindable and locked. */
q = ERR_PTR(-EPERM);
goto out;
} else {
s = skip_mnt_tree(s);
continue;
}
}
if (!(flag & CL_COPY_MNT_NS_FILE) &&
is_mnt_ns_file(s->mnt.mnt_root)) {
s = skip_mnt_tree(s);
continue;
}
while (p != s->mnt_parent) {
p = p->mnt_parent;
q = q->mnt_parent;
}
p = s;
parent = q;
q = clone_mnt(p, p->mnt.mnt_root, flag);
if (IS_ERR(q))
goto out;
lock_mount_hash();
list_add_tail(&q->mnt_list, &res->mnt_list);
attach_mnt(q, parent, p->mnt_mp);
unlock_mount_hash();
}
}
return res;
out:
if (res) {
lock_mount_hash();
umount_tree(res, UMOUNT_SYNC);
unlock_mount_hash();
}
return q;
}
| 0
|
509,518
|
static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
const char *fmt, va_list args)
{
THD *thd= (THD *) param->thd;
Protocol *protocol= thd->protocol;
size_t length, msg_length;
char msgbuf[MYSQL_ERRMSG_SIZE];
char name[NAME_LEN * 2 + 2];
if (param->testflag & T_SUPPRESS_ERR_HANDLING)
return;
msg_length= my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
msgbuf[sizeof(msgbuf) - 1]= 0; // healthy paranoia
DBUG_PRINT(msg_type, ("message: %s", msgbuf));
if (!thd->vio_ok())
{
_ma_check_print(param, msg_type, msgbuf);
return;
}
if (param->testflag &
(T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR))
{
myf flag= 0;
if (msg_type == MA_CHECK_INFO)
flag= ME_NOTE;
else if (msg_type == MA_CHECK_WARNING)
flag= ME_WARNING;
my_message(ER_NOT_KEYFILE, msgbuf, MYF(flag));
if (thd->variables.log_warnings > 2)
_ma_check_print(param, msg_type, msgbuf);
return;
}
length= (uint) (strxmov(name, param->db_name, ".", param->table_name,
NullS) - name);
/*
TODO: switch from protocol to push_warning here. The main reason we didn't
it yet is parallel repair, which threads have no THD object accessible via
current_thd.
Also we likely need to lock mutex here (in both cases with protocol and
push_warning).
*/
protocol->prepare_for_resend();
protocol->store(name, (uint)length, system_charset_info);
protocol->store(param->op_name, system_charset_info);
protocol->store(msg_type, system_charset_info);
protocol->store(msgbuf, (uint)msg_length, system_charset_info);
if (protocol->write())
sql_print_error("Failed on my_net_write, writing to stderr instead: %s.%s: %s\n",
param->db_name, param->table_name, msgbuf);
else if (thd->variables.log_warnings > 2)
_ma_check_print(param, msg_type, msgbuf);
return;
}
| 0
|
413,618
|
static bool block_flags_stat(RFlagItem *fi, void *user) {
struct block_flags_stat_t *u = (struct block_flags_stat_t *)user;
int piece = (fi->offset - u->from) / u->step;
u->as->block[piece].flags++;
return true;
}
| 0
|
226,981
|
IRC_PROTOCOL_CALLBACK(900)
{
IRC_PROTOCOL_MIN_ARGS(6);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, argv[3], command, NULL, NULL),
date,
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s %s(%s%s%s)",
weechat_prefix ("network"),
(argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
argv[3],
IRC_COLOR_CHAT_DELIMITERS);
return WEECHAT_RC_OK;
}
| 0
|
273,891
|
static int list_printf(ctrl_t *ctrl, char *buf, size_t len, char *path, char *name)
{
int dirs;
int mode = ctrl->list_mode;
struct stat st;
if (stat(path, &st))
return -1;
dirs = mode & 0xF0;
mode = mode & 0x0F;
if (dirs && !S_ISDIR(st.st_mode))
return 1;
if (!dirs && S_ISDIR(st.st_mode))
return 1;
switch (mode) {
case 3: /* MLSD */
/* fallthrough */
case 2: /* MLST */
mlsd_printf(ctrl, buf, len, path, name, &st);
break;
case 1: /* NLST */
snprintf(buf, len, "%s\r\n", name);
break;
case 0: /* LIST */
snprintf(buf, len, "%s 1 %5d %5d %12" PRIu64 " %s %s\r\n",
mode_to_str(st.st_mode),
0, 0, (uint64_t)st.st_size,
time_to_str(st.st_mtime), name);
break;
}
return 0;
}
| 0
|
259,322
|
static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int version, offset_size, length_size, base_offset_size, index_size;
int item_count, extent_count;
uint64_t base_offset, extent_offset, extent_length;
uint8_t value;
if (!c->is_still_picture_avif) {
// * For non-avif, we simply ignore the iloc box.
// * For animated avif, we don't care about the iloc box as all the
// necessary information can be found in the moov box.
return 0;
}
if (c->fc->nb_streams) {
av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n");
return 0;
}
version = avio_r8(pb);
avio_rb24(pb); // flags.
value = avio_r8(pb);
offset_size = (value >> 4) & 0xF;
length_size = value & 0xF;
value = avio_r8(pb);
base_offset_size = (value >> 4) & 0xF;
index_size = !version ? 0 : (value & 0xF);
if (index_size) {
av_log(c->fc, AV_LOG_ERROR, "iloc: index_size != 0 not supported.\n");
return AVERROR_PATCHWELCOME;
}
item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
c->avif_info = av_malloc_array(item_count, sizeof(*c->avif_info));
if (!c->avif_info)
return AVERROR(ENOMEM);
c->avif_info_size = item_count;
for (int i = 0; i < item_count; i++) {
int item_id = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
if (avio_feof(pb))
return AVERROR_INVALIDDATA;
c->avif_info[i].item_id = item_id;
if (version > 0)
avio_rb16(pb); // construction_method.
avio_rb16(pb); // data_reference_index.
if (rb_size(pb, &base_offset, base_offset_size) < 0)
return AVERROR_INVALIDDATA;
extent_count = avio_rb16(pb);
if (extent_count > 1) {
// For still AVIF images, we only support one extent item.
av_log(c->fc, AV_LOG_ERROR, "iloc: extent_count > 1 not supported.\n");
return AVERROR_PATCHWELCOME;
}
for (int j = 0; j < extent_count; j++) {
if (rb_size(pb, &extent_offset, offset_size) < 0 ||
rb_size(pb, &extent_length, length_size) < 0)
return AVERROR_INVALIDDATA;
c->avif_info[i].extent_length = extent_length;
c->avif_info[i].extent_offset = base_offset + extent_offset;
}
}
return atom.size;
}
| 0
|
224,287
|
gopherStart(FwdState * fwd)
{
GopherStateData *gopherState = new GopherStateData(fwd);
debugs(10, 3, gopherState->entry->url());
++ statCounter.server.all.requests;
++ statCounter.server.other.requests;
/* Parse url. */
gopher_request_parse(fwd->request,
&gopherState->type_id, gopherState->request);
comm_add_close_handler(fwd->serverConnection()->fd, gopherStateFree, gopherState);
if (((gopherState->type_id == GOPHER_INDEX) || (gopherState->type_id == GOPHER_CSO))
&& (strchr(gopherState->request, '?') == NULL)) {
/* Index URL without query word */
/* We have to generate search page back to client. No need for connection */
gopherMimeCreate(gopherState);
if (gopherState->type_id == GOPHER_INDEX) {
gopherState->conversion = GopherStateData::HTML_INDEX_PAGE;
} else {
if (gopherState->type_id == GOPHER_CSO) {
gopherState->conversion = GopherStateData::HTML_CSO_PAGE;
} else {
gopherState->conversion = GopherStateData::HTML_INDEX_PAGE;
}
}
gopherToHTML(gopherState, (char *) NULL, 0);
fwd->markStoredReplyAsWhole("gopher instant internal request satisfaction");
fwd->complete();
return;
}
// XXX: Sharing open Connection with FwdState that has its own handlers/etc.
gopherState->serverConn = fwd->serverConnection();
gopherSendRequest(fwd->serverConnection()->fd, gopherState);
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "gopherTimeout",
CommTimeoutCbPtrFun(gopherTimeout, gopherState));
commSetConnTimeout(fwd->serverConnection(), Config.Timeout.read, timeoutCall);
}
| 0
|
437,307
|
onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
OnigErrorInfo* einfo)
{
int r;
*reg = (regex_t* )xmalloc(sizeof(regex_t));
if (IS_NULL(*reg)) return ONIGERR_MEMORY;
r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
if (r != 0) goto err;
r = onig_compile(*reg, pattern, pattern_end, einfo);
if (r != 0) {
err:
onig_free(*reg);
*reg = NULL;
}
return r;
}
| 0
|
508,866
|
void st_select_lex_node::exclude()
{
/* exclude from global list */
fast_exclude();
/* exclude from other structures */
exclude_from_tree();
/*
We do not need following statements, because prev pointer of first
list element point to master->slave
if (master->slave == this)
master->slave= next;
*/
}
| 0
|
508,800
|
void LEX::reset_arena_for_set_stmt(Query_arena *backup)
{
DBUG_ENTER("LEX::reset_arena_for_set_stmt");
DBUG_ASSERT(arena_for_set_stmt);
thd->restore_active_arena(arena_for_set_stmt, backup);
DBUG_PRINT("info", ("mem_root: %p arena: %p",
arena_for_set_stmt->mem_root,
arena_for_set_stmt));
DBUG_VOID_RETURN;
}
| 0
|
246,470
|
static RList *r_bin_wasm_get_sections_by_id(RList *sections, ut8 id) {
RList *ret = r_list_newf (NULL);
if (ret) {
RBinWasmSection *sec;
RListIter *iter;
r_list_foreach (sections, iter, sec) {
if (sec->id == id) {
r_list_append (ret, sec);
}
}
}
return ret;
}
| 0
|
293,765
|
static void r_kext_free(RKext *kext) {
if (!kext) {
return;
}
if (kext->mach0) {
MACH0_(mach0_free) (kext->mach0);
kext->mach0 = NULL;
}
if (kext->own_name && kext->name) {
R_FREE (kext->name);
kext->name = NULL;
}
R_FREE (kext);
}
| 0
|
215,162
|
diff_mark_adjust_tp(
tabpage_T *tp,
int idx,
linenr_T line1,
linenr_T line2,
long amount,
long amount_after)
{
diff_T *dp;
diff_T *dprev;
diff_T *dnext;
int i;
int inserted, deleted;
int n, off;
linenr_T last;
linenr_T lnum_deleted = line1; // lnum of remaining deletion
int check_unchanged;
if (diff_internal())
{
// Will update diffs before redrawing. Set _invalid to update the
// diffs themselves, set _update to also update folds properly just
// before redrawing.
// Do update marks here, it is needed for :%diffput.
tp->tp_diff_invalid = TRUE;
tp->tp_diff_update = TRUE;
}
if (line2 == MAXLNUM)
{
// mark_adjust(99, MAXLNUM, 9, 0): insert lines
inserted = amount;
deleted = 0;
}
else if (amount_after > 0)
{
// mark_adjust(99, 98, MAXLNUM, 9): a change that inserts lines
inserted = amount_after;
deleted = 0;
}
else
{
// mark_adjust(98, 99, MAXLNUM, -2): delete lines
inserted = 0;
deleted = -amount_after;
}
dprev = NULL;
dp = tp->tp_first_diff;
for (;;)
{
// If the change is after the previous diff block and before the next
// diff block, thus not touching an existing change, create a new diff
// block. Don't do this when ex_diffgetput() is busy.
if ((dp == NULL || dp->df_lnum[idx] - 1 > line2
|| (line2 == MAXLNUM && dp->df_lnum[idx] > line1))
&& (dprev == NULL
|| dprev->df_lnum[idx] + dprev->df_count[idx] < line1)
&& !diff_busy)
{
dnext = diff_alloc_new(tp, dprev, dp);
if (dnext == NULL)
return;
dnext->df_lnum[idx] = line1;
dnext->df_count[idx] = inserted;
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL && i != idx)
{
if (dprev == NULL)
dnext->df_lnum[i] = line1;
else
dnext->df_lnum[i] = line1
+ (dprev->df_lnum[i] + dprev->df_count[i])
- (dprev->df_lnum[idx] + dprev->df_count[idx]);
dnext->df_count[i] = deleted;
}
}
// if at end of the list, quit
if (dp == NULL)
break;
/*
* Check for these situations:
* 1 2 3
* 1 2 3
* line1 2 3 4 5
* 2 3 4 5
* 2 3 4 5
* line2 2 3 4 5
* 3 5 6
* 3 5 6
*/
// compute last line of this change
last = dp->df_lnum[idx] + dp->df_count[idx] - 1;
// 1. change completely above line1: nothing to do
if (last >= line1 - 1)
{
// 6. change below line2: only adjust for amount_after; also when
// "deleted" became zero when deleted all lines between two diffs
if (dp->df_lnum[idx] - (deleted + inserted != 0) > line2)
{
if (amount_after == 0)
break; // nothing left to change
dp->df_lnum[idx] += amount_after;
}
else
{
check_unchanged = FALSE;
// 2. 3. 4. 5.: inserted/deleted lines touching this diff.
if (deleted > 0)
{
if (dp->df_lnum[idx] >= line1)
{
off = dp->df_lnum[idx] - lnum_deleted;
if (last <= line2)
{
// 4. delete all lines of diff
if (dp->df_next != NULL
&& dp->df_next->df_lnum[idx] - 1 <= line2)
{
// delete continues in next diff, only do
// lines until that one
n = dp->df_next->df_lnum[idx] - lnum_deleted;
deleted -= n;
n -= dp->df_count[idx];
lnum_deleted = dp->df_next->df_lnum[idx];
}
else
n = deleted - dp->df_count[idx];
dp->df_count[idx] = 0;
}
else
{
// 5. delete lines at or just before top of diff
n = off;
dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1;
check_unchanged = TRUE;
}
dp->df_lnum[idx] = line1;
}
else
{
off = 0;
if (last < line2)
{
// 2. delete at end of diff
dp->df_count[idx] -= last - lnum_deleted + 1;
if (dp->df_next != NULL
&& dp->df_next->df_lnum[idx] - 1 <= line2)
{
// delete continues in next diff, only do
// lines until that one
n = dp->df_next->df_lnum[idx] - 1 - last;
deleted -= dp->df_next->df_lnum[idx]
- lnum_deleted;
lnum_deleted = dp->df_next->df_lnum[idx];
}
else
n = line2 - last;
check_unchanged = TRUE;
}
else
{
// 3. delete lines inside the diff
n = 0;
dp->df_count[idx] -= deleted;
}
}
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL && i != idx)
{
dp->df_lnum[i] -= off;
dp->df_count[i] += n;
}
}
else
{
if (dp->df_lnum[idx] <= line1)
{
// inserted lines somewhere in this diff
dp->df_count[idx] += inserted;
check_unchanged = TRUE;
}
else
// inserted lines somewhere above this diff
dp->df_lnum[idx] += inserted;
}
if (check_unchanged)
// Check if inserted lines are equal, may reduce the
// size of the diff. TODO: also check for equal lines
// in the middle and perhaps split the block.
diff_check_unchanged(tp, dp);
}
}
// check if this block touches the previous one, may merge them.
if (dprev != NULL && dprev->df_lnum[idx] + dprev->df_count[idx]
== dp->df_lnum[idx])
{
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL)
dprev->df_count[i] += dp->df_count[i];
dprev->df_next = dp->df_next;
vim_free(dp);
dp = dprev->df_next;
}
else
{
// Advance to next entry.
dprev = dp;
dp = dp->df_next;
}
}
dprev = NULL;
dp = tp->tp_first_diff;
while (dp != NULL)
{
// All counts are zero, remove this entry.
for (i = 0; i < DB_COUNT; ++i)
if (tp->tp_diffbuf[i] != NULL && dp->df_count[i] != 0)
break;
if (i == DB_COUNT)
{
dnext = dp->df_next;
vim_free(dp);
dp = dnext;
if (dprev == NULL)
tp->tp_first_diff = dnext;
else
dprev->df_next = dnext;
}
else
{
// Advance to next entry.
dprev = dp;
dp = dp->df_next;
}
}
if (tp == curtab)
{
// Don't redraw right away, this updates the diffs, which can be slow.
need_diff_redraw = TRUE;
// Need to recompute the scroll binding, may remove or add filler
// lines (e.g., when adding lines above w_topline). But it's slow when
// making many changes, postpone until redrawing.
diff_need_scrollbind = TRUE;
}
}
| 1
|
437,341
|
add_length(regex_t* reg, int len)
{
LengthType l = (LengthType )len;
BB_ADD(reg, &l, SIZE_LENGTH);
return 0;
}
| 0
|
274,863
|
TEST(ComparisonsTest,
QuantizedInt8GreaterWithBroadcastMultiplierGreaterThanOne) {
const float kMin = -127.f;
const float kMax = 127.f;
std::vector<std::vector<int>> test_shapes = {
{6}, {2, 3}, {2, 1, 3}, {1, 3, 1, 2}};
for (int i = 0; i < test_shapes.size(); ++i) {
ComparisonOpModel model({TensorType_INT8, test_shapes[i], kMin, kMax},
{TensorType_INT8, {}, kMin, kMax}, TensorType_INT8,
BuiltinOperator_GREATER);
model.QuantizeAndPopulate<int8_t>(model.input1(),
{572, -2, -71, 8, 11, 20});
model.QuantizeAndPopulate<int8_t>(model.input2(), {8});
model.Invoke();
EXPECT_THAT(model.GetOutput(),
ElementsAre(true, false, false, false, true, true))
<< "With shape number " << i;
}
}
| 0
|
500,059
|
kssl_ctx_show(KSSL_CTX *kssl_ctx)
{
int i;
printf("kssl_ctx: ");
if (kssl_ctx == NULL)
{
printf("NULL\n");
return;
}
else
printf("%p\n", (void *)kssl_ctx);
printf("\tservice:\t%s\n",
(kssl_ctx->service_name)? kssl_ctx->service_name: "NULL");
printf("\tclient:\t%s\n",
(kssl_ctx->client_princ)? kssl_ctx->client_princ: "NULL");
printf("\tserver:\t%s\n",
(kssl_ctx->service_host)? kssl_ctx->service_host: "NULL");
printf("\tkeytab:\t%s\n",
(kssl_ctx->keytab_file)? kssl_ctx->keytab_file: "NULL");
printf("\tkey [%d:%d]:\t",
kssl_ctx->enctype, kssl_ctx->length);
for (i=0; i < kssl_ctx->length && kssl_ctx->key; i++)
{
printf("%02x", kssl_ctx->key[i]);
}
printf("\n");
return;
}
| 0
|
281,656
|
void CLASS packed_load_raw()
{
int vbits=0, bwide, rbits, bite, half, irow, row, col, val, i;
UINT64 bitbuf=0;
bwide = raw_width * tiff_bps / 8;
bwide += bwide & load_flags >> 7;
rbits = bwide * 8 - raw_width * tiff_bps;
if (load_flags & 1) bwide = bwide * 16 / 15;
bite = 8 + (load_flags & 24);
half = (raw_height+1) >> 1;
for (irow=0; irow < raw_height; irow++) {
#ifdef LIBRAW_LIBRARY_BUILD
checkCancel();
#endif
row = irow;
if (load_flags & 2 &&
(row = irow % half * 2 + irow / half) == 1 &&
load_flags & 4) {
if (vbits=0, tiff_compress)
fseek (ifp, data_offset - (-half*bwide & -2048), SEEK_SET);
else {
fseek (ifp, 0, SEEK_END);
fseek (ifp, ftell(ifp) >> 3 << 2, SEEK_SET);
}
}
for (col=0; col < raw_width; col++) {
for (vbits -= tiff_bps; vbits < 0; vbits += bite) {
bitbuf <<= bite;
for (i=0; i < bite; i+=8)
bitbuf |= (unsigned) (fgetc(ifp) << i);
}
val = bitbuf << (64-tiff_bps-vbits) >> (64-tiff_bps);
RAW(row,col ^ (load_flags >> 6 & 1)) = val;
if (load_flags & 1 && (col % 10) == 9 &&
fgetc(ifp) && col < width+left_margin) derror();
}
vbits -= rbits;
}
}
| 0
|
252,339
|
int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version,
const unsigned char *memory, size_t size,
const char **err) {
if (memory == NULL || exr_header == NULL) {
tinyexr::SetErrorMessage(
"Invalid argument. `memory` or `exr_header` argument is null in "
"ParseEXRHeaderFromMemory()",
err);
// Invalid argument
return TINYEXR_ERROR_INVALID_ARGUMENT;
}
if (size < tinyexr::kEXRVersionSize) {
tinyexr::SetErrorMessage("Insufficient header/data size.\n", err);
return TINYEXR_ERROR_INVALID_DATA;
}
const unsigned char *marker = memory + tinyexr::kEXRVersionSize;
size_t marker_size = size - tinyexr::kEXRVersionSize;
tinyexr::HeaderInfo info;
info.clear();
std::string err_str;
int ret = ParseEXRHeader(&info, NULL, version, &err_str, marker, marker_size);
if (ret != TINYEXR_SUCCESS) {
if (err && !err_str.empty()) {
tinyexr::SetErrorMessage(err_str, err);
}
}
ConvertHeader(exr_header, info);
// transfoer `tiled` from version.
exr_header->tiled = version->tiled;
return ret;
}
| 0
|
312,575
|
f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
# ifdef FEAT_QUICKFIX
win_T *wp;
if (in_vim9script()
&& (check_for_number_arg(argvars, 0) == FAIL
|| check_for_opt_dict_arg(argvars, 1) == FAIL))
return;
wp = find_win_by_nr_or_id(&argvars[0]);
get_qf_loc_list(FALSE, wp, &argvars[1], rettv);
# endif
}
| 0
|
313,553
|
static int rose_neigh_show(struct seq_file *seq, void *v)
{
char buf[11];
int i;
if (v == SEQ_START_TOKEN)
seq_puts(seq,
"addr callsign dev count use mode restart t0 tf digipeaters\n");
else {
struct rose_neigh *rose_neigh = v;
/* if (!rose_neigh->loopback) { */
seq_printf(seq, "%05d %-9s %-4s %3d %3d %3s %3s %3lu %3lu",
rose_neigh->number,
(rose_neigh->loopback) ? "RSLOOP-0" : ax2asc(buf, &rose_neigh->callsign),
rose_neigh->dev ? rose_neigh->dev->name : "???",
rose_neigh->count,
rose_neigh->use,
(rose_neigh->dce_mode) ? "DCE" : "DTE",
(rose_neigh->restarted) ? "yes" : "no",
ax25_display_timer(&rose_neigh->t0timer) / HZ,
ax25_display_timer(&rose_neigh->ftimer) / HZ);
if (rose_neigh->digipeat != NULL) {
for (i = 0; i < rose_neigh->digipeat->ndigi; i++)
seq_printf(seq, " %s", ax2asc(buf, &rose_neigh->digipeat->calls[i]));
}
seq_puts(seq, "\n");
}
return 0;
}
| 0
|
281,109
|
static u32 xfrm_gen_index(struct net *net, int dir, u32 index)
{
static u32 idx_generator;
for (;;) {
struct hlist_head *list;
struct xfrm_policy *p;
u32 idx;
int found;
if (!index) {
idx = (idx_generator | dir);
idx_generator += 8;
} else {
idx = index;
index = 0;
}
if (idx == 0)
idx = 8;
list = net->xfrm.policy_byidx + idx_hash(net, idx);
found = 0;
hlist_for_each_entry(p, list, byidx) {
if (p->index == idx) {
found = 1;
break;
}
}
if (!found)
return idx;
}
}
| 0
|
222,739
|
s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)
{
u8 idr_flag;
s32 slice, ret;
u32 nal_hdr;
AVCSliceInfo n_state;
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
nal_hdr = gf_bs_read_u8(bs);
slice = 0;
memcpy(&n_state, &avc->s_info, sizeof(AVCSliceInfo));
avc->last_nal_type_parsed = n_state.nal_unit_type = nal_hdr & 0x1F;
n_state.nal_ref_idc = (nal_hdr >> 5) & 0x3;
idr_flag = 0;
switch (n_state.nal_unit_type) {
case GF_AVC_NALU_ACCESS_UNIT:
case GF_AVC_NALU_END_OF_SEQ:
case GF_AVC_NALU_END_OF_STREAM:
ret = 1;
break;
case GF_AVC_NALU_SVC_SLICE:
SVC_ReadNal_header_extension(bs, &n_state.NalHeader);
// slice buffer - read the info and compare.
/*ret = */svc_parse_slice(bs, avc, &n_state);
if (avc->s_info.nal_ref_idc) {
n_state.poc_lsb_prev = avc->s_info.poc_lsb;
n_state.poc_msb_prev = avc->s_info.poc_msb;
}
avc_compute_poc(&n_state);
if (avc->s_info.poc != n_state.poc) {
memcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));
return 1;
}
memcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));
return 0;
case GF_AVC_NALU_SVC_PREFIX_NALU:
SVC_ReadNal_header_extension(bs, &n_state.NalHeader);
return 0;
case GF_AVC_NALU_IDR_SLICE:
case GF_AVC_NALU_NON_IDR_SLICE:
case GF_AVC_NALU_DP_A_SLICE:
case GF_AVC_NALU_DP_B_SLICE:
case GF_AVC_NALU_DP_C_SLICE:
slice = 1;
/* slice buffer - read the info and compare.*/
ret = avc_parse_slice(bs, avc, idr_flag, &n_state);
if (ret < 0) return ret;
ret = 0;
if (
((avc->s_info.nal_unit_type > GF_AVC_NALU_IDR_SLICE) || (avc->s_info.nal_unit_type < GF_AVC_NALU_NON_IDR_SLICE))
&& (avc->s_info.nal_unit_type != GF_AVC_NALU_SVC_SLICE)
) {
break;
}
if (avc->s_info.frame_num != n_state.frame_num) {
ret = 1;
break;
}
if (avc->s_info.field_pic_flag != n_state.field_pic_flag) {
ret = 1;
break;
}
if ((avc->s_info.nal_ref_idc != n_state.nal_ref_idc) &&
(!avc->s_info.nal_ref_idc || !n_state.nal_ref_idc)) {
ret = 1;
break;
}
if (!avc->s_info.sps)
return -1;
if (avc->s_info.sps->poc_type == n_state.sps->poc_type) {
if (!avc->s_info.sps->poc_type) {
if (!n_state.bottom_field_flag && (avc->s_info.poc_lsb != n_state.poc_lsb)) {
ret = 1;
break;
}
if (avc->s_info.delta_poc_bottom != n_state.delta_poc_bottom) {
ret = 1;
break;
}
}
else if (avc->s_info.sps->poc_type == 1) {
if (avc->s_info.delta_poc[0] != n_state.delta_poc[0]) {
ret = 1;
break;
}
if (avc->s_info.delta_poc[1] != n_state.delta_poc[1]) {
ret = 1;
break;
}
}
}
if (n_state.nal_unit_type == GF_AVC_NALU_IDR_SLICE) {
if (avc->s_info.nal_unit_type != GF_AVC_NALU_IDR_SLICE) { /*IdrPicFlag differs in value*/
ret = 1;
break;
}
else if (avc->s_info.idr_pic_id != n_state.idr_pic_id) { /*both IDR and idr_pic_id differs*/
ret = 1;
break;
}
}
break;
case GF_AVC_NALU_SEQ_PARAM:
avc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 0, NULL, nal_hdr);
if (avc->last_ps_idx < 0) return -1;
return 0;
case GF_AVC_NALU_PIC_PARAM:
avc->last_ps_idx = gf_avc_read_pps_bs_internal(bs, avc, nal_hdr);
if (avc->last_ps_idx < 0) return -1;
return 0;
case GF_AVC_NALU_SVC_SUBSEQ_PARAM:
avc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 1, NULL, nal_hdr);
if (avc->last_ps_idx < 0) return -1;
return 0;
case GF_AVC_NALU_SEQ_PARAM_EXT:
avc->last_ps_idx = (s32) gf_bs_read_ue(bs);
if (avc->last_ps_idx < 0) return -1;
return 0;
case GF_AVC_NALU_SEI:
case GF_AVC_NALU_FILLER_DATA:
return 0;
default:
if (avc->s_info.nal_unit_type <= GF_AVC_NALU_IDR_SLICE) ret = 1;
//To detect change of AU when multiple sps and pps in stream
else if ((nal_hdr & 0x1F) == GF_AVC_NALU_SEI && avc->s_info.nal_unit_type == GF_AVC_NALU_SVC_SLICE)
ret = 1;
else if ((nal_hdr & 0x1F) == GF_AVC_NALU_SEQ_PARAM && avc->s_info.nal_unit_type == GF_AVC_NALU_SVC_SLICE)
ret = 1;
else
ret = 0;
break;
}
/* save _prev values */
if (ret && avc->s_info.sps) {
n_state.frame_num_offset_prev = avc->s_info.frame_num_offset;
if ((avc->s_info.sps->poc_type != 2) || (avc->s_info.nal_ref_idc != 0))
n_state.frame_num_prev = avc->s_info.frame_num;
if (avc->s_info.nal_ref_idc) {
n_state.poc_lsb_prev = avc->s_info.poc_lsb;
n_state.poc_msb_prev = avc->s_info.poc_msb;
}
}
if (slice)
avc_compute_poc(&n_state);
memcpy(&avc->s_info, &n_state, sizeof(AVCSliceInfo));
return ret;
}
| 0
|
214,997
|
compileRule(FileInfo *file, TranslationTableHeader **table,
DisplayTableHeader **displayTable, const MacroList **inScopeMacros) {
CharsString token;
TranslationTableOpcode opcode;
CharsString ruleChars;
CharsString ruleDots;
CharsString cells;
CharsString scratchPad;
CharsString emphClass;
TranslationTableCharacterAttributes after = 0;
TranslationTableCharacterAttributes before = 0;
int noback, nofor, nocross;
noback = nofor = nocross = 0;
doOpcode:
if (!getToken(file, &token, NULL)) return 1; /* blank line */
if (token.chars[0] == '#' || token.chars[0] == '<') return 1; /* comment */
if (file->lineNumber == 1 &&
(eqasc2uni((unsigned char *)"ISO", token.chars, 3) ||
eqasc2uni((unsigned char *)"UTF-8", token.chars, 5))) {
if (table)
compileHyphenation(file, &token, table);
else
/* ignore the whole file */
while (_lou_getALine(file))
;
return 1;
}
opcode = getOpcode(file, &token);
switch (opcode) {
case CTO_Macro: {
const Macro *macro;
#ifdef ENABLE_MACROS
if (!inScopeMacros) {
compileError(file, "Defining macros only allowed in table files.");
return 0;
}
if (compileMacro(file, ¯o)) {
*inScopeMacros = cons_macro(macro, *inScopeMacros);
return 1;
}
return 0;
#else
compileError(file, "Macro feature is disabled.");
return 0;
#endif
}
case CTO_IncludeFile: {
CharsString includedFile;
if (!getToken(file, &token, "include file name")) return 0;
if (!parseChars(file, &includedFile, &token)) return 0;
return includeFile(file, &includedFile, table, displayTable);
}
case CTO_NoBack:
if (nofor) {
compileError(file, "%s already specified.", _lou_findOpcodeName(CTO_NoFor));
return 0;
}
noback = 1;
goto doOpcode;
case CTO_NoFor:
if (noback) {
compileError(file, "%s already specified.", _lou_findOpcodeName(CTO_NoBack));
return 0;
}
nofor = 1;
goto doOpcode;
case CTO_Space:
return compileCharDef(
file, opcode, CTC_Space, noback, nofor, table, displayTable);
case CTO_Digit:
return compileCharDef(
file, opcode, CTC_Digit, noback, nofor, table, displayTable);
case CTO_LitDigit:
return compileCharDef(
file, opcode, CTC_LitDigit, noback, nofor, table, displayTable);
case CTO_Punctuation:
return compileCharDef(
file, opcode, CTC_Punctuation, noback, nofor, table, displayTable);
case CTO_Math:
return compileCharDef(file, opcode, CTC_Math, noback, nofor, table, displayTable);
case CTO_Sign:
return compileCharDef(file, opcode, CTC_Sign, noback, nofor, table, displayTable);
case CTO_Letter:
return compileCharDef(
file, opcode, CTC_Letter, noback, nofor, table, displayTable);
case CTO_UpperCase:
return compileCharDef(
file, opcode, CTC_UpperCase, noback, nofor, table, displayTable);
case CTO_LowerCase:
return compileCharDef(
file, opcode, CTC_LowerCase, noback, nofor, table, displayTable);
case CTO_Grouping:
return compileGrouping(file, noback, nofor, table, displayTable);
case CTO_Display:
if (!displayTable) return 1; // ignore
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (!getRuleDotsPattern(file, &ruleDots)) return 0;
if (ruleChars.length != 1 || ruleDots.length != 1) {
compileError(file, "Exactly one character and one cell are required.");
return 0;
}
return putCharDotsMapping(
file, ruleChars.chars[0], ruleDots.chars[0], displayTable);
case CTO_UpLow:
case CTO_None: {
// check if token is a macro name
if (inScopeMacros) {
const MacroList *macros = *inScopeMacros;
while (macros) {
const Macro *m = macros->head;
if (token.length == strlen(m->name) &&
eqasc2uni((unsigned char *)m->name, token.chars, token.length)) {
if (!inScopeMacros) {
compileError(file, "Calling macros only allowed in table files.");
return 0;
}
FileInfo tmpFile;
memset(&tmpFile, 0, sizeof(tmpFile));
tmpFile.fileName = file->fileName;
tmpFile.sourceFile = file->sourceFile;
tmpFile.lineNumber = file->lineNumber;
tmpFile.encoding = noEncoding;
tmpFile.status = 0;
tmpFile.linepos = 0;
tmpFile.linelen = 0;
int argument_count = 0;
CharsString *arguments =
malloc(m->argument_count * sizeof(CharsString));
while (argument_count < m->argument_count) {
if (getToken(file, &token, "macro argument"))
arguments[argument_count++] = token;
else
break;
}
if (argument_count < m->argument_count) {
compileError(file, "Expected %d arguments", m->argument_count);
return 0;
}
int i = 0;
int subst = 0;
int next = subst < m->substitution_count ? m->substitutions[2 * subst]
: m->definition_length;
for (;;) {
while (i < next) {
widechar c = m->definition[i++];
if (c == '\n') {
if (!compileRule(&tmpFile, table, displayTable,
inScopeMacros)) {
_lou_logMessage(LOU_LOG_ERROR,
"result of macro expansion was: %s",
_lou_showString(
tmpFile.line, tmpFile.linelen, 0));
return 0;
}
tmpFile.linepos = 0;
tmpFile.linelen = 0;
} else if (tmpFile.linelen >= MAXSTRING) {
compileError(file,
"Line exceeds %d characters (post macro "
"expansion)",
MAXSTRING);
return 0;
} else
tmpFile.line[tmpFile.linelen++] = c;
}
if (subst < m->substitution_count) {
CharsString arg =
arguments[m->substitutions[2 * subst + 1] - 1];
for (int j = 0; j < arg.length; j++)
tmpFile.line[tmpFile.linelen++] = arg.chars[j];
subst++;
next = subst < m->substitution_count
? m->substitutions[2 * subst]
: m->definition_length;
} else {
if (!compileRule(
&tmpFile, table, displayTable, inScopeMacros)) {
_lou_logMessage(LOU_LOG_ERROR,
"result of macro expansion was: %s",
_lou_showString(
tmpFile.line, tmpFile.linelen, 0));
return 0;
}
break;
}
}
return 1;
}
macros = macros->tail;
}
}
if (opcode == CTO_UpLow) {
compileError(file, "The uplow opcode is deprecated.");
return 0;
}
compileError(file, "opcode %s not defined.",
_lou_showString(token.chars, token.length, 0));
return 0;
}
/* now only opcodes follow that don't modify the display table */
default:
if (!table) return 1;
switch (opcode) {
case CTO_Locale:
compileWarning(file,
"The locale opcode is not implemented. Use the locale meta data "
"instead.");
return 1;
case CTO_Undefined: {
// not passing pointer because compileBrailleIndicator may reallocate table
TranslationTableOffset ruleOffset = (*table)->undefined;
if (!compileBrailleIndicator(file, "undefined character opcode",
CTO_Undefined, &ruleOffset, noback, nofor, table))
return 0;
(*table)->undefined = ruleOffset;
return 1;
}
case CTO_Match: {
int ok = 0;
widechar *patterns = NULL;
TranslationTableRule *rule;
TranslationTableOffset ruleOffset;
CharsString ptn_before, ptn_after;
TranslationTableOffset patternsOffset;
int len, mrk;
size_t patternsByteSize = sizeof(*patterns) * 27720;
patterns = (widechar *)malloc(patternsByteSize);
if (!patterns) _lou_outOfMemory();
memset(patterns, 0xffff, patternsByteSize);
noback = 1;
getCharacters(file, &ptn_before);
getRuleCharsText(file, &ruleChars);
getCharacters(file, &ptn_after);
getRuleDotsPattern(file, &ruleDots);
if (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset,
&rule, noback, nofor, table))
goto CTO_Match_cleanup;
if (ptn_before.chars[0] == '-' && ptn_before.length == 1)
len = _lou_pattern_compile(
&ptn_before.chars[0], 0, &patterns[1], 13841, *table, file);
else
len = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length,
&patterns[1], 13841, *table, file);
if (!len) goto CTO_Match_cleanup;
mrk = patterns[0] = len + 1;
_lou_pattern_reverse(&patterns[1]);
if (ptn_after.chars[0] == '-' && ptn_after.length == 1)
len = _lou_pattern_compile(
&ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file);
else
len = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length,
&patterns[mrk], 13841, *table, file);
if (!len) goto CTO_Match_cleanup;
len += mrk;
if (!allocateSpaceInTranslationTable(
file, &patternsOffset, len * sizeof(widechar), table))
goto CTO_Match_cleanup;
// allocateSpaceInTranslationTable may have moved table, so make sure rule is
// still valid
rule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset];
memcpy(&(*table)->ruleArea[patternsOffset], patterns, len * sizeof(widechar));
rule->patterns = patternsOffset;
ok = 1;
CTO_Match_cleanup:
free(patterns);
return ok;
}
case CTO_BackMatch: {
int ok = 0;
widechar *patterns = NULL;
TranslationTableRule *rule;
TranslationTableOffset ruleOffset;
CharsString ptn_before, ptn_after;
TranslationTableOffset patternOffset;
int len, mrk;
size_t patternsByteSize = sizeof(*patterns) * 27720;
patterns = (widechar *)malloc(patternsByteSize);
if (!patterns) _lou_outOfMemory();
memset(patterns, 0xffff, patternsByteSize);
nofor = 1;
getCharacters(file, &ptn_before);
getRuleCharsText(file, &ruleChars);
getCharacters(file, &ptn_after);
getRuleDotsPattern(file, &ruleDots);
if (!addRule(file, opcode, &ruleChars, &ruleDots, 0, 0, &ruleOffset, &rule,
noback, nofor, table))
goto CTO_BackMatch_cleanup;
if (ptn_before.chars[0] == '-' && ptn_before.length == 1)
len = _lou_pattern_compile(
&ptn_before.chars[0], 0, &patterns[1], 13841, *table, file);
else
len = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length,
&patterns[1], 13841, *table, file);
if (!len) goto CTO_BackMatch_cleanup;
mrk = patterns[0] = len + 1;
_lou_pattern_reverse(&patterns[1]);
if (ptn_after.chars[0] == '-' && ptn_after.length == 1)
len = _lou_pattern_compile(
&ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file);
else
len = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length,
&patterns[mrk], 13841, *table, file);
if (!len) goto CTO_BackMatch_cleanup;
len += mrk;
if (!allocateSpaceInTranslationTable(
file, &patternOffset, len * sizeof(widechar), table))
goto CTO_BackMatch_cleanup;
// allocateSpaceInTranslationTable may have moved table, so make sure rule is
// still valid
rule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset];
memcpy(&(*table)->ruleArea[patternOffset], patterns, len * sizeof(widechar));
rule->patterns = patternOffset;
ok = 1;
CTO_BackMatch_cleanup:
free(patterns);
return ok;
}
case CTO_CapsLetter:
case CTO_BegCapsWord:
case CTO_EndCapsWord:
case CTO_BegCaps:
case CTO_EndCaps:
case CTO_BegCapsPhrase:
case CTO_EndCapsPhrase:
case CTO_LenCapsPhrase:
/* these 8 general purpose opcodes are compiled further down to more specific
* internal opcodes:
* - modeletter
* - begmodeword
* - endmodeword
* - begmode
* - endmode
* - begmodephrase
* - endmodephrase
* - lenmodephrase
*/
case CTO_ModeLetter:
case CTO_BegModeWord:
case CTO_EndModeWord:
case CTO_BegMode:
case CTO_EndMode:
case CTO_BegModePhrase:
case CTO_EndModePhrase:
case CTO_LenModePhrase: {
TranslationTableCharacterAttributes mode;
int i;
switch (opcode) {
case CTO_CapsLetter:
case CTO_BegCapsWord:
case CTO_EndCapsWord:
case CTO_BegCaps:
case CTO_EndCaps:
case CTO_BegCapsPhrase:
case CTO_EndCapsPhrase:
case CTO_LenCapsPhrase:
mode = CTC_UpperCase;
i = 0;
opcode += (CTO_ModeLetter - CTO_CapsLetter);
break;
default:
if (!getToken(file, &token, "attribute name")) return 0;
if (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {
return 0;
}
const CharacterClass *characterClass = findCharacterClass(&token, *table);
if (!characterClass) {
characterClass =
addCharacterClass(file, token.chars, token.length, *table, 1);
if (!characterClass) return 0;
}
mode = characterClass->attribute;
if (!(mode == CTC_UpperCase || mode == CTC_Digit) && mode >= CTC_Space &&
mode <= CTC_LitDigit) {
compileError(file,
"mode must be \"uppercase\", \"digit\", or a custom "
"attribute name.");
return 0;
}
/* check if this mode is already defined and if the number of modes does
* not exceed the maximal number */
if (mode == CTC_UpperCase)
i = 0;
else {
for (i = 1; i < MAX_MODES && (*table)->modes[i].value; i++) {
if ((*table)->modes[i].mode == mode) {
break;
}
}
if (i == MAX_MODES) {
compileError(file, "Max number of modes (%i) reached", MAX_MODES);
return 0;
}
}
}
if (!(*table)->modes[i].value)
(*table)->modes[i] = (EmphasisClass){ plain_text, mode,
0x1 << (MAX_EMPH_CLASSES + i), MAX_EMPH_CLASSES + i };
switch (opcode) {
case CTO_BegModePhrase: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset];
if (!compileBrailleIndicator(file, "first word capital sign",
CTO_BegCapsPhraseRule + (8 * i), &ruleOffset, noback, nofor,
table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset] = ruleOffset;
return 1;
}
case CTO_EndModePhrase: {
TranslationTableOffset ruleOffset;
switch (compileBeforeAfter(file)) {
case 1: // before
if ((*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset]) {
compileError(
file, "Capital sign after last word already defined.");
return 0;
}
// not passing pointer because compileBrailleIndicator may reallocate
// table
ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i]
[endPhraseBeforeOffset];
if (!compileBrailleIndicator(file, "capital sign before last word",
CTO_EndCapsPhraseBeforeRule + (8 * i), &ruleOffset,
noback, nofor, table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseBeforeOffset] =
ruleOffset;
return 1;
case 2: // after
if ((*table)->emphRules[MAX_EMPH_CLASSES + i]
[endPhraseBeforeOffset]) {
compileError(
file, "Capital sign before last word already defined.");
return 0;
}
// not passing pointer because compileBrailleIndicator may reallocate
// table
ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i]
[endPhraseAfterOffset];
if (!compileBrailleIndicator(file, "capital sign after last word",
CTO_EndCapsPhraseAfterRule + (8 * i), &ruleOffset, noback,
nofor, table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset] =
ruleOffset;
return 1;
default: // error
compileError(file, "Invalid lastword indicator location.");
return 0;
}
return 0;
}
case CTO_BegMode: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset];
if (!compileBrailleIndicator(file, "first letter capital sign",
CTO_BegCapsRule + (8 * i), &ruleOffset, noback, nofor, table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset] = ruleOffset;
return 1;
}
case CTO_EndMode: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset];
if (!compileBrailleIndicator(file, "last letter capital sign",
CTO_EndCapsRule + (8 * i), &ruleOffset, noback, nofor, table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset] = ruleOffset;
return 1;
}
case CTO_ModeLetter: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset];
if (!compileBrailleIndicator(file, "single letter capital sign",
CTO_CapsLetterRule + (8 * i), &ruleOffset, noback, nofor,
table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset] = ruleOffset;
return 1;
}
case CTO_BegModeWord: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset];
if (!compileBrailleIndicator(file, "capital word",
CTO_BegCapsWordRule + (8 * i), &ruleOffset, noback, nofor,
table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset] = ruleOffset;
return 1;
}
case CTO_EndModeWord: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset];
if (!compileBrailleIndicator(file, "capital word stop",
CTO_EndCapsWordRule + (8 * i), &ruleOffset, noback, nofor,
table))
return 0;
(*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset] = ruleOffset;
return 1;
}
case CTO_LenModePhrase:
return (*table)->emphRules[MAX_EMPH_CLASSES + i][lenPhraseOffset] =
compileNumber(file);
default:
break;
}
break;
}
/* these 8 general purpose emphasis opcodes are compiled further down to more
* specific internal opcodes:
* - emphletter
* - begemphword
* - endemphword
* - begemph
* - endemph
* - begemphphrase
* - endemphphrase
* - lenemphphrase
*/
case CTO_EmphClass:
if (!getToken(file, &emphClass, "emphasis class")) {
compileError(file, "emphclass must be followed by a valid class name.");
return 0;
}
int k, i;
char *s = malloc(sizeof(char) * (emphClass.length + 1));
for (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k];
s[k++] = '\0';
for (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++)
if (strcmp(s, (*table)->emphClassNames[i]) == 0) {
_lou_logMessage(LOU_LOG_WARN, "Duplicate emphasis class: %s", s);
warningCount++;
free(s);
return 1;
}
if (i == MAX_EMPH_CLASSES) {
_lou_logMessage(LOU_LOG_ERROR,
"Max number of emphasis classes (%i) reached", MAX_EMPH_CLASSES);
errorCount++;
free(s);
return 0;
}
switch (i) {
/* For backwards compatibility (i.e. because programs will assume
* the first 3 typeform bits are `italic', `underline' and `bold')
* we require that the first 3 emphclass definitions are (in that
* order):
*
* emphclass italic
* emphclass underline
* emphclass bold
*
* While it would be possible to use the emphclass opcode only for
* defining _additional_ classes (not allowing for them to be called
* italic, underline or bold), thereby reducing the amount of
* boilerplate, we deliberately choose not to do that in order to
* not give italic, underline and bold any special status. The
* hope is that eventually all programs will use liblouis for
* emphasis the recommended way (i.e. by looking up the supported
* typeforms in the documentation or API) so that we can drop this
* restriction.
*/
case 0:
if (strcmp(s, "italic") != 0) {
_lou_logMessage(LOU_LOG_ERROR,
"First emphasis class must be \"italic\" but got "
"%s",
s);
errorCount++;
free(s);
return 0;
}
break;
case 1:
if (strcmp(s, "underline") != 0) {
_lou_logMessage(LOU_LOG_ERROR,
"Second emphasis class must be \"underline\" but "
"got "
"%s",
s);
errorCount++;
free(s);
return 0;
}
break;
case 2:
if (strcmp(s, "bold") != 0) {
_lou_logMessage(LOU_LOG_ERROR,
"Third emphasis class must be \"bold\" but got "
"%s",
s);
errorCount++;
free(s);
return 0;
}
break;
}
(*table)->emphClassNames[i] = s;
(*table)->emphClasses[i] = (EmphasisClass){ emph_1
<< i, /* relies on the order of typeforms emph_1..emph_10 */
0, 0x1 << i, i };
return 1;
case CTO_EmphLetter:
case CTO_BegEmphWord:
case CTO_EndEmphWord:
case CTO_BegEmph:
case CTO_EndEmph:
case CTO_BegEmphPhrase:
case CTO_EndEmphPhrase:
case CTO_LenEmphPhrase:
case CTO_EmphModeChars:
case CTO_NoEmphChars: {
if (!getToken(file, &token, "emphasis class")) return 0;
if (!parseChars(file, &emphClass, &token)) return 0;
char *s = malloc(sizeof(char) * (emphClass.length + 1));
int k, i;
for (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k];
s[k++] = '\0';
for (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++)
if (strcmp(s, (*table)->emphClassNames[i]) == 0) break;
if (i == MAX_EMPH_CLASSES || !(*table)->emphClassNames[i]) {
_lou_logMessage(LOU_LOG_ERROR, "Emphasis class %s not declared", s);
errorCount++;
free(s);
return 0;
}
int ok = 0;
switch (opcode) {
case CTO_EmphLetter: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset = (*table)->emphRules[i][letterOffset];
if (!compileBrailleIndicator(file, "single letter",
CTO_Emph1LetterRule + letterOffset + (8 * i), &ruleOffset,
noback, nofor, table))
break;
(*table)->emphRules[i][letterOffset] = ruleOffset;
ok = 1;
break;
}
case CTO_BegEmphWord: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset = (*table)->emphRules[i][begWordOffset];
if (!compileBrailleIndicator(file, "word",
CTO_Emph1LetterRule + begWordOffset + (8 * i), &ruleOffset,
noback, nofor, table))
break;
(*table)->emphRules[i][begWordOffset] = ruleOffset;
ok = 1;
break;
}
case CTO_EndEmphWord: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset = (*table)->emphRules[i][endWordOffset];
if (!compileBrailleIndicator(file, "word stop",
CTO_Emph1LetterRule + endWordOffset + (8 * i), &ruleOffset,
noback, nofor, table))
break;
(*table)->emphRules[i][endWordOffset] = ruleOffset;
ok = 1;
break;
}
case CTO_BegEmph: {
/* fail if both begemph and any of begemphphrase or begemphword are
* defined */
if ((*table)->emphRules[i][begWordOffset] ||
(*table)->emphRules[i][begPhraseOffset]) {
compileError(file,
"Cannot define emphasis for both no context and word or "
"phrase context, i.e. cannot have both begemph and "
"begemphword or begemphphrase.");
break;
}
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset = (*table)->emphRules[i][begOffset];
if (!compileBrailleIndicator(file, "first letter",
CTO_Emph1LetterRule + begOffset + (8 * i), &ruleOffset,
noback, nofor, table))
break;
(*table)->emphRules[i][begOffset] = ruleOffset;
ok = 1;
break;
}
case CTO_EndEmph: {
if ((*table)->emphRules[i][endWordOffset] ||
(*table)->emphRules[i][endPhraseBeforeOffset] ||
(*table)->emphRules[i][endPhraseAfterOffset]) {
compileError(file,
"Cannot define emphasis for both no context and word or "
"phrase context, i.e. cannot have both endemph and "
"endemphword or endemphphrase.");
break;
}
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset = (*table)->emphRules[i][endOffset];
if (!compileBrailleIndicator(file, "last letter",
CTO_Emph1LetterRule + endOffset + (8 * i), &ruleOffset,
noback, nofor, table))
break;
(*table)->emphRules[i][endOffset] = ruleOffset;
ok = 1;
break;
}
case CTO_BegEmphPhrase: {
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[i][begPhraseOffset];
if (!compileBrailleIndicator(file, "first word",
CTO_Emph1LetterRule + begPhraseOffset + (8 * i), &ruleOffset,
noback, nofor, table))
break;
(*table)->emphRules[i][begPhraseOffset] = ruleOffset;
ok = 1;
break;
}
case CTO_EndEmphPhrase:
switch (compileBeforeAfter(file)) {
case 1: { // before
if ((*table)->emphRules[i][endPhraseAfterOffset]) {
compileError(file, "last word after already defined.");
break;
}
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[i][endPhraseBeforeOffset];
if (!compileBrailleIndicator(file, "last word before",
CTO_Emph1LetterRule + endPhraseBeforeOffset + (8 * i),
&ruleOffset, noback, nofor, table))
break;
(*table)->emphRules[i][endPhraseBeforeOffset] = ruleOffset;
ok = 1;
break;
}
case 2: { // after
if ((*table)->emphRules[i][endPhraseBeforeOffset]) {
compileError(file, "last word before already defined.");
break;
}
// not passing pointer because compileBrailleIndicator may reallocate
// table
TranslationTableOffset ruleOffset =
(*table)->emphRules[i][endPhraseAfterOffset];
if (!compileBrailleIndicator(file, "last word after",
CTO_Emph1LetterRule + endPhraseAfterOffset + (8 * i),
&ruleOffset, noback, nofor, table))
break;
(*table)->emphRules[i][endPhraseAfterOffset] = ruleOffset;
ok = 1;
break;
}
default: // error
compileError(file, "Invalid lastword indicator location.");
break;
}
break;
case CTO_LenEmphPhrase:
if (((*table)->emphRules[i][lenPhraseOffset] = compileNumber(file)))
ok = 1;
break;
case CTO_EmphModeChars: {
if (!getRuleCharsText(file, &ruleChars)) break;
widechar *emphmodechars = (*table)->emphModeChars[i];
int len;
for (len = 0; len < EMPHMODECHARSSIZE && emphmodechars[len]; len++)
;
if (len + ruleChars.length > EMPHMODECHARSSIZE) {
compileError(file, "More than %d characters", EMPHMODECHARSSIZE);
break;
}
ok = 1;
for (int k = 0; k < ruleChars.length; k++) {
if (!getChar(ruleChars.chars[k], *table, NULL)) {
compileError(file, "Emphasis mode character undefined");
ok = 0;
break;
}
emphmodechars[len++] = ruleChars.chars[k];
}
break;
}
case CTO_NoEmphChars: {
if (!getRuleCharsText(file, &ruleChars)) break;
widechar *noemphchars = (*table)->noEmphChars[i];
int len;
for (len = 0; len < NOEMPHCHARSSIZE && noemphchars[len]; len++)
;
if (len + ruleChars.length > NOEMPHCHARSSIZE) {
compileError(file, "More than %d characters", NOEMPHCHARSSIZE);
break;
}
ok = 1;
for (int k = 0; k < ruleChars.length; k++) {
if (!getChar(ruleChars.chars[k], *table, NULL)) {
compileError(file, "Character undefined");
ok = 0;
break;
}
noemphchars[len++] = ruleChars.chars[k];
}
break;
}
default:
break;
}
free(s);
return ok;
}
case CTO_LetterSign: {
// not passing pointer because compileBrailleIndicator may reallocate table
TranslationTableOffset ruleOffset = (*table)->letterSign;
if (!compileBrailleIndicator(file, "letter sign", CTO_LetterRule, &ruleOffset,
noback, nofor, table))
return 0;
(*table)->letterSign = ruleOffset;
return 1;
}
case CTO_NoLetsignBefore:
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (((*table)->noLetsignBeforeCount + ruleChars.length) > LETSIGNBEFORESIZE) {
compileError(file, "More than %d characters", LETSIGNBEFORESIZE);
return 0;
}
for (int k = 0; k < ruleChars.length; k++)
(*table)->noLetsignBefore[(*table)->noLetsignBeforeCount++] =
ruleChars.chars[k];
return 1;
case CTO_NoLetsign:
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (((*table)->noLetsignCount + ruleChars.length) > LETSIGNSIZE) {
compileError(file, "More than %d characters", LETSIGNSIZE);
return 0;
}
for (int k = 0; k < ruleChars.length; k++)
(*table)->noLetsign[(*table)->noLetsignCount++] = ruleChars.chars[k];
return 1;
case CTO_NoLetsignAfter:
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (((*table)->noLetsignAfterCount + ruleChars.length) > LETSIGNAFTERSIZE) {
compileError(file, "More than %d characters", LETSIGNAFTERSIZE);
return 0;
}
for (int k = 0; k < ruleChars.length; k++)
(*table)->noLetsignAfter[(*table)->noLetsignAfterCount++] =
ruleChars.chars[k];
return 1;
case CTO_NumberSign: {
// not passing pointer because compileBrailleIndicator may reallocate table
TranslationTableOffset ruleOffset = (*table)->numberSign;
if (!compileBrailleIndicator(file, "number sign", CTO_NumberRule, &ruleOffset,
noback, nofor, table))
return 0;
(*table)->numberSign = ruleOffset;
return 1;
}
case CTO_NumericModeChars:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!c) {
compileError(file, "Numeric mode character undefined: %s",
_lou_showString(&ruleChars.chars[k], 1, 0));
return 0;
}
c->attributes |= CTC_NumericMode;
(*table)->usesNumericMode = 1;
}
return 1;
case CTO_MidEndNumericModeChars:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!c) {
compileError(file, "Midendnumeric mode character undefined");
return 0;
}
c->attributes |= CTC_MidEndNumericMode;
(*table)->usesNumericMode = 1;
}
return 1;
case CTO_NumericNoContractChars:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!c) {
compileError(file, "Numeric no contraction character undefined");
return 0;
}
c->attributes |= CTC_NumericNoContract;
(*table)->usesNumericMode = 1;
}
return 1;
case CTO_NoContractSign: {
// not passing pointer because compileBrailleIndicator may reallocate table
TranslationTableOffset ruleOffset = (*table)->noContractSign;
if (!compileBrailleIndicator(file, "no contractions sign", CTO_NoContractRule,
&ruleOffset, noback, nofor, table))
return 0;
(*table)->noContractSign = ruleOffset;
return 1;
}
case CTO_SeqDelimiter:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!c) {
compileError(file, "Sequence delimiter character undefined");
return 0;
}
c->attributes |= CTC_SeqDelimiter;
(*table)->usesSequences = 1;
}
return 1;
case CTO_SeqBeforeChars:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!c) {
compileError(file, "Sequence before character undefined");
return 0;
}
c->attributes |= CTC_SeqBefore;
}
return 1;
case CTO_SeqAfterChars:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!c) {
compileError(file, "Sequence after character undefined");
return 0;
}
c->attributes |= CTC_SeqAfter;
}
return 1;
case CTO_SeqAfterPattern:
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (((*table)->seqPatternsCount + ruleChars.length + 1) > SEQPATTERNSIZE) {
compileError(file, "More than %d characters", SEQPATTERNSIZE);
return 0;
}
for (int k = 0; k < ruleChars.length; k++)
(*table)->seqPatterns[(*table)->seqPatternsCount++] = ruleChars.chars[k];
(*table)->seqPatterns[(*table)->seqPatternsCount++] = 0;
return 1;
case CTO_SeqAfterExpression:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for ((*table)->seqAfterExpressionLength = 0;
(*table)->seqAfterExpressionLength < ruleChars.length;
(*table)->seqAfterExpressionLength++)
(*table)->seqAfterExpression[(*table)->seqAfterExpressionLength] =
ruleChars.chars[(*table)->seqAfterExpressionLength];
(*table)->seqAfterExpression[(*table)->seqAfterExpressionLength] = 0;
return 1;
case CTO_CapsModeChars:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!c) {
compileError(file, "Capital mode character undefined");
return 0;
}
c->attributes |= CTC_CapsMode;
(*table)->hasCapsModeChars = 1;
}
return 1;
case CTO_BegComp: {
// not passing pointer because compileBrailleIndicator may reallocate table
TranslationTableOffset ruleOffset = (*table)->begComp;
if (!compileBrailleIndicator(file, "begin computer braille", CTO_BegCompRule,
&ruleOffset, noback, nofor, table))
return 0;
(*table)->begComp = ruleOffset;
return 1;
}
case CTO_EndComp: {
// not passing pointer because compileBrailleIndicator may reallocate table
TranslationTableOffset ruleOffset = (*table)->endComp;
if (!compileBrailleIndicator(file, "end computer braslle", CTO_EndCompRule,
&ruleOffset, noback, nofor, table))
return 0;
(*table)->endComp = ruleOffset;
return 1;
}
case CTO_NoCross:
if (nocross) {
compileError(
file, "%s already specified.", _lou_findOpcodeName(CTO_NoCross));
return 0;
}
nocross = 1;
goto doOpcode;
case CTO_Syllable:
(*table)->syllables = 1;
case CTO_Always:
case CTO_LargeSign:
case CTO_WholeWord:
case CTO_PartWord:
case CTO_JoinNum:
case CTO_JoinableWord:
case CTO_LowWord:
case CTO_SuffixableWord:
case CTO_PrefixableWord:
case CTO_BegWord:
case CTO_BegMidWord:
case CTO_MidWord:
case CTO_MidEndWord:
case CTO_EndWord:
case CTO_PrePunc:
case CTO_PostPunc:
case CTO_BegNum:
case CTO_MidNum:
case CTO_EndNum:
case CTO_Repeated:
case CTO_RepWord:
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (!getRuleDotsPattern(file, &ruleDots)) return 0;
if (ruleDots.length == 0)
// check that all characters in a rule with `=` as second operand are
// defined (or based on another character)
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c =
getChar(ruleChars.chars[k], *table, NULL);
if (!(c && (c->definitionRule || c->basechar))) {
compileError(file, "Character %s is not defined",
_lou_showString(&ruleChars.chars[k], 1, 0));
return 0;
}
}
TranslationTableRule *r;
if (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, &r,
noback, nofor, table))
return 0;
if (nocross) r->nocross = 1;
return 1;
// if (opcode == CTO_MidNum)
// {
// TranslationTableCharacter *c = getChar(ruleChars.chars[0]);
// if(c)
// c->attributes |= CTC_NumericMode;
// }
case CTO_RepEndWord:
if (!getRuleCharsText(file, &ruleChars)) return 0;
CharsString dots;
if (!getToken(file, &dots, "dots,dots operand")) return 0;
int len = dots.length;
for (int k = 0; k < len - 1; k++) {
if (dots.chars[k] == ',') {
dots.length = k;
if (!parseDots(file, &ruleDots, &dots)) return 0;
ruleDots.chars[ruleDots.length++] = ',';
k++;
if (k == len - 1 && dots.chars[k] == '=') {
// check that all characters are defined (or based on another
// character)
for (int l = 0; l < ruleChars.length; l++) {
TranslationTableCharacter *c =
getChar(ruleChars.chars[l], *table, NULL);
if (!(c && (c->definitionRule || c->basechar))) {
compileError(file, "Character %s is not defined",
_lou_showString(&ruleChars.chars[l], 1, 0));
return 0;
}
}
} else {
CharsString x, y;
x.length = 0;
while (k < len) x.chars[x.length++] = dots.chars[k++];
if (parseDots(file, &y, &x))
for (int l = 0; l < y.length; l++)
ruleDots.chars[ruleDots.length++] = y.chars[l];
}
return addRule(file, opcode, &ruleChars, &ruleDots, after, before,
NULL, NULL, noback, nofor, table);
}
}
return 0;
case CTO_CompDots:
case CTO_Comp6: {
TranslationTableOffset ruleOffset;
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (ruleChars.length != 1) {
compileError(file, "first operand must be 1 character");
return 0;
}
if (nofor || noback) {
compileWarning(file, "nofor and noback not allowed on comp6 rules");
}
if (!getRuleDotsPattern(file, &ruleDots)) return 0;
if (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset,
NULL, noback, nofor, table))
return 0;
return 1;
}
case CTO_ExactDots:
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (ruleChars.chars[0] != '@') {
compileError(file, "The operand must begin with an at sign (@)");
return 0;
}
for (int k = 1; k < ruleChars.length; k++)
scratchPad.chars[k - 1] = ruleChars.chars[k];
scratchPad.length = ruleChars.length - 1;
if (!parseDots(file, &ruleDots, &scratchPad)) return 0;
return addRule(file, opcode, &ruleChars, &ruleDots, before, after, NULL, NULL,
noback, nofor, table);
case CTO_CapsNoCont: {
TranslationTableOffset ruleOffset;
ruleChars.length = 1;
ruleChars.chars[0] = 'a';
if (!addRule(file, CTO_CapsNoContRule, &ruleChars, NULL, after, before,
&ruleOffset, NULL, noback, nofor, table))
return 0;
(*table)->capsNoCont = ruleOffset;
return 1;
}
case CTO_Replace:
if (getRuleCharsText(file, &ruleChars)) {
if (atEndOfLine(file))
ruleDots.length = ruleDots.chars[0] = 0;
else {
getRuleDotsText(file, &ruleDots);
if (ruleDots.chars[0] == '#')
ruleDots.length = ruleDots.chars[0] = 0;
else if (ruleDots.chars[0] == '\\' && ruleDots.chars[1] == '#')
memmove(&ruleDots.chars[0], &ruleDots.chars[1],
ruleDots.length-- * CHARSIZE);
}
}
for (int k = 0; k < ruleChars.length; k++)
putChar(file, ruleChars.chars[k], table, NULL);
for (int k = 0; k < ruleDots.length; k++)
putChar(file, ruleDots.chars[k], table, NULL);
return addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL,
noback, nofor, table);
case CTO_Correct:
(*table)->corrections = 1;
goto doPass;
case CTO_Pass2:
if ((*table)->numPasses < 2) (*table)->numPasses = 2;
goto doPass;
case CTO_Pass3:
if ((*table)->numPasses < 3) (*table)->numPasses = 3;
goto doPass;
case CTO_Pass4:
if ((*table)->numPasses < 4) (*table)->numPasses = 4;
doPass:
case CTO_Context:
if (!(nofor || noback)) {
compileError(file, "%s or %s must be specified.",
_lou_findOpcodeName(CTO_NoFor), _lou_findOpcodeName(CTO_NoBack));
return 0;
}
return compilePassOpcode(file, opcode, noback, nofor, table);
case CTO_Contraction:
case CTO_NoCont:
case CTO_CompBrl:
case CTO_Literal:
if (!getRuleCharsText(file, &ruleChars)) return 0;
// check that all characters in a compbrl, contraction,
// nocont or literal rule are defined (or based on another
// character)
for (int k = 0; k < ruleChars.length; k++) {
TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL);
if (!(c && (c->definitionRule || c->basechar))) {
compileError(file, "Character %s is not defined",
_lou_showString(&ruleChars.chars[k], 1, 0));
return 0;
}
}
return addRule(file, opcode, &ruleChars, NULL, after, before, NULL, NULL,
noback, nofor, table);
case CTO_MultInd: {
ruleChars.length = 0;
if (!getToken(file, &token, "multiple braille indicators") ||
!parseDots(file, &cells, &token))
return 0;
while (getToken(file, &token, "multind opcodes")) {
opcode = getOpcode(file, &token);
if (opcode == CTO_None) {
compileError(file, "opcode %s not defined.",
_lou_showString(token.chars, token.length, 0));
return 0;
}
if (!(opcode >= CTO_CapsLetter && opcode < CTO_MultInd)) {
compileError(file, "Not a braille indicator opcode.");
return 0;
}
ruleChars.chars[ruleChars.length++] = (widechar)opcode;
if (atEndOfLine(file)) break;
}
return addRule(file, CTO_MultInd, &ruleChars, &cells, after, before, NULL,
NULL, noback, nofor, table);
}
case CTO_Class:
compileWarning(file, "class is deprecated, use attribute instead");
case CTO_Attribute: {
if (nofor || noback) {
compileWarning(
file, "nofor and noback not allowed before class/attribute");
}
if ((opcode == CTO_Class && (*table)->usesAttributeOrClass == 1) ||
(opcode == CTO_Attribute && (*table)->usesAttributeOrClass == 2)) {
compileError(file,
"attribute and class rules must not be both present in a table");
return 0;
}
if (opcode == CTO_Class)
(*table)->usesAttributeOrClass = 2;
else
(*table)->usesAttributeOrClass = 1;
if (!getToken(file, &token, "attribute name")) {
compileError(file, "Expected %s", "attribute name");
return 0;
}
if (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {
return 0;
}
TranslationTableCharacterAttributes attribute = 0;
{
int attrNumber = -1;
switch (token.chars[0]) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
attrNumber = token.chars[0] - '0';
break;
}
if (attrNumber >= 0) {
if (opcode == CTO_Class) {
compileError(file,
"Invalid class name: may not contain digits, use "
"attribute instead of class");
return 0;
}
if (token.length > 1 || attrNumber > 7) {
compileError(file,
"Invalid attribute name: must be a digit between 0 and 7 "
"or a word containing only letters");
return 0;
}
if (!(*table)->numberedAttributes[attrNumber])
// attribute not used before yet: assign it a value
(*table)->numberedAttributes[attrNumber] =
getNextNumberedAttribute(*table);
attribute = (*table)->numberedAttributes[attrNumber];
} else {
const CharacterClass *namedAttr = findCharacterClass(&token, *table);
if (!namedAttr) {
// no class with that name: create one
namedAttr = addCharacterClass(
file, &token.chars[0], token.length, *table, 1);
if (!namedAttr) return 0;
}
// there is a class with that name or a new class was successfully
// created
attribute = namedAttr->attribute;
if (attribute == CTC_UpperCase || attribute == CTC_LowerCase)
attribute |= CTC_Letter;
}
}
CharsString characters;
if (!getCharacters(file, &characters)) return 0;
for (int i = 0; i < characters.length; i++) {
// get the character from the table, or if it is not defined yet,
// define it
TranslationTableCharacter *character =
putChar(file, characters.chars[i], table, NULL);
// set the attribute
character->attributes |= attribute;
// also set the attribute on the associated dots (if any)
if (character->basechar)
character = (TranslationTableCharacter *)&(*table)
->ruleArea[character->basechar];
if (character->definitionRule) {
TranslationTableRule *defRule =
(TranslationTableRule *)&(*table)
->ruleArea[character->definitionRule];
if (defRule->dotslen == 1) {
TranslationTableCharacter *dots =
getDots(defRule->charsdots[defRule->charslen], *table);
if (dots) dots->attributes |= attribute;
}
}
}
return 1;
}
{
TranslationTableCharacterAttributes *attributes;
const CharacterClass *class;
case CTO_After:
attributes = &after;
goto doBeforeAfter;
case CTO_Before:
attributes = &before;
doBeforeAfter:
if (!(*table)->characterClasses) {
if (!allocateCharacterClasses(*table)) return 0;
}
if (!getToken(file, &token, "attribute name")) return 0;
if (!(class = findCharacterClass(&token, *table))) {
compileError(file, "attribute not defined");
return 0;
}
*attributes |= class->attribute;
goto doOpcode;
}
case CTO_Base:
if (nofor || noback) {
compileWarning(file, "nofor and noback not allowed before base");
}
if (!getToken(file, &token, "attribute name")) {
compileError(
file, "base opcode must be followed by a valid attribute name.");
return 0;
}
if (!(*table)->characterClasses && !allocateCharacterClasses(*table)) {
return 0;
}
const CharacterClass *mode = findCharacterClass(&token, *table);
if (!mode) {
mode = addCharacterClass(file, token.chars, token.length, *table, 1);
if (!mode) return 0;
}
if (!(mode->attribute == CTC_UpperCase || mode->attribute == CTC_Digit) &&
mode->attribute >= CTC_Space && mode->attribute <= CTC_LitDigit) {
compileError(file,
"base opcode must be followed by \"uppercase\", \"digit\", or a "
"custom attribute name.");
return 0;
}
if (!getRuleCharsText(file, &token)) return 0;
if (token.length != 1) {
compileError(file,
"Exactly one character followed by one base character is "
"required.");
return 0;
}
TranslationTableOffset characterOffset;
TranslationTableCharacter *character =
putChar(file, token.chars[0], table, &characterOffset);
if (!getRuleCharsText(file, &token)) return 0;
if (token.length != 1) {
compileError(file, "Exactly one base character is required.");
return 0;
}
if (character->definitionRule) {
TranslationTableRule *prevRule =
(TranslationTableRule *)&(*table)
->ruleArea[character->definitionRule];
_lou_logMessage(LOU_LOG_DEBUG,
"%s:%d: Character already defined (%s). The base rule will take "
"precedence.",
file->fileName, file->lineNumber,
printSource(file, prevRule->sourceFile, prevRule->sourceLine));
character->definitionRule = 0;
}
TranslationTableOffset basechar;
putChar(file, token.chars[0], table, &basechar);
// putChar may have moved table, so make sure character is still valid
character = (TranslationTableCharacter *)&(*table)->ruleArea[characterOffset];
if (character->basechar) {
if (character->basechar == basechar &&
character->mode == mode->attribute) {
_lou_logMessage(LOU_LOG_DEBUG, "%s:%d: Duplicate base rule.",
file->fileName, file->lineNumber);
} else {
_lou_logMessage(LOU_LOG_DEBUG,
"%s:%d: A different base rule already exists for this "
"character (%s). The new rule will take precedence.",
file->fileName, file->lineNumber,
printSource(
file, character->sourceFile, character->sourceLine));
}
}
character->basechar = basechar;
character->mode = mode->attribute;
character->sourceFile = file->sourceFile;
character->sourceLine = file->lineNumber;
/* some other processing is done at the end of the compilation, in
* finalizeTable() */
return 1;
case CTO_EmpMatchBefore:
before |= CTC_EmpMatch;
goto doOpcode;
case CTO_EmpMatchAfter:
after |= CTC_EmpMatch;
goto doOpcode;
case CTO_SwapCc:
case CTO_SwapCd:
case CTO_SwapDd:
return compileSwap(file, opcode, noback, nofor, table);
case CTO_Hyphen:
case CTO_DecPoint:
// case CTO_Apostrophe:
// case CTO_Initial:
if (!getRuleCharsText(file, &ruleChars)) return 0;
if (!getRuleDotsPattern(file, &ruleDots)) return 0;
if (ruleChars.length != 1 || ruleDots.length < 1) {
compileError(file,
"One Unicode character and at least one cell are "
"required.");
return 0;
}
return addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL,
noback, nofor, table);
// if (opcode == CTO_DecPoint)
// {
// TranslationTableCharacter *c =
// getChar(ruleChars.chars[0]);
// if(c)
// c->attributes |= CTC_NumericMode;
// }
default:
compileError(file, "unimplemented opcode.");
return 0;
}
}
return 0;
}
| 1
|
231,722
|
void setSourceTokens(std::vector<folly::IPAddress> srcAddrs) {
sourceAddrs_ = srcAddrs;
}
| 0
|
317,038
|
static int smack_inode_setsecurity(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
struct smack_known *skp;
struct inode_smack *nsp = smack_inode(inode);
struct socket_smack *ssp;
struct socket *sock;
int rc = 0;
if (value == NULL || size > SMK_LONGLABEL || size == 0)
return -EINVAL;
skp = smk_import_entry(value, size);
if (IS_ERR(skp))
return PTR_ERR(skp);
if (strcmp(name, XATTR_SMACK_SUFFIX) == 0) {
nsp->smk_inode = skp;
nsp->smk_flags |= SMK_INODE_INSTANT;
return 0;
}
/*
* The rest of the Smack xattrs are only on sockets.
*/
if (inode->i_sb->s_magic != SOCKFS_MAGIC)
return -EOPNOTSUPP;
sock = SOCKET_I(inode);
if (sock == NULL || sock->sk == NULL)
return -EOPNOTSUPP;
ssp = sock->sk->sk_security;
if (strcmp(name, XATTR_SMACK_IPIN) == 0)
ssp->smk_in = skp;
else if (strcmp(name, XATTR_SMACK_IPOUT) == 0) {
ssp->smk_out = skp;
if (sock->sk->sk_family == PF_INET) {
rc = smack_netlbl_add(sock->sk);
if (rc != 0)
printk(KERN_WARNING
"Smack: \"%s\" netlbl error %d.\n",
__func__, -rc);
}
} else
return -EOPNOTSUPP;
#ifdef SMACK_IPV6_PORT_LABELING
if (sock->sk->sk_family == PF_INET6)
smk_ipv6_port_label(sock, NULL);
#endif
return 0;
}
| 0
|
293,501
|
gif_initialise_frame_extensions(gif_animation *gif, const int frame)
{
const unsigned char *gif_data, *gif_end;
ssize_t gif_bytes;
ssize_t block_size;
/* Get our buffer position etc. */
gif_data = (const unsigned char *)(gif->gif_data + gif->buffer_position);
gif_end = (const unsigned char *)(gif->gif_data + gif->buffer_size);
/* Initialise the extensions */
while (gif_data < gif_end && gif_data[0] == GIF_EXTENSION_INTRODUCER) {
++gif_data;
if ((gif_bytes = (gif_end - gif_data)) < 1) {
return GIF_INSUFFICIENT_FRAME_DATA;
}
/* Switch on extension label */
switch (gif_data[0]) {
case GIF_EXTENSION_GRAPHIC_CONTROL:
/* 6-byte Graphic Control Extension is:
*
* +0 CHAR Graphic Control Label
* +1 CHAR Block Size
* +2 CHAR __Packed Fields__
* 3BITS Reserved
* 3BITS Disposal Method
* 1BIT User Input Flag
* 1BIT Transparent Color Flag
* +3 SHORT Delay Time
* +5 CHAR Transparent Color Index
*/
if (gif_bytes < 6) {
return GIF_INSUFFICIENT_FRAME_DATA;
}
gif->frames[frame].frame_delay = gif_data[3] | (gif_data[4] << 8);
if (gif_data[2] & GIF_TRANSPARENCY_MASK) {
gif->frames[frame].transparency = true;
gif->frames[frame].transparency_index = gif_data[5];
}
gif->frames[frame].disposal_method = ((gif_data[2] & GIF_DISPOSAL_MASK) >> 2);
/* I have encountered documentation and GIFs in the
* wild that use 0x04 to restore the previous frame,
* rather than the officially documented 0x03. I
* believe some (older?) software may even actually
* export this way. We handle this as a type of
* "quirks" mode.
*/
if (gif->frames[frame].disposal_method == GIF_FRAME_QUIRKS_RESTORE) {
gif->frames[frame].disposal_method = GIF_FRAME_RESTORE;
}
gif_data += (2 + gif_data[1]);
break;
case GIF_EXTENSION_APPLICATION:
/* 14-byte+ Application Extension is:
*
* +0 CHAR Application Extension Label
* +1 CHAR Block Size
* +2 8CHARS Application Identifier
* +10 3CHARS Appl. Authentication Code
* +13 1-256 Application Data (Data sub-blocks)
*/
if (gif_bytes < 17) {
return GIF_INSUFFICIENT_FRAME_DATA;
}
if ((gif_data[1] == 0x0b) &&
(strncmp((const char *) gif_data + 2,
"NETSCAPE2.0", 11) == 0) &&
(gif_data[13] == 0x03) &&
(gif_data[14] == 0x01)) {
gif->loop_count = gif_data[15] | (gif_data[16] << 8);
}
gif_data += (2 + gif_data[1]);
break;
case GIF_EXTENSION_COMMENT:
/* Move the pointer to the first data sub-block Skip 1
* byte for the extension label
*/
++gif_data;
break;
default:
/* Move the pointer to the first data sub-block Skip 2
* bytes for the extension label and size fields Skip
* the extension size itself
*/
if (gif_bytes < 2) {
return GIF_INSUFFICIENT_FRAME_DATA;
}
gif_data += (2 + gif_data[1]);
}
/* Repeatedly skip blocks until we get a zero block or run out
* of data This data is ignored by this gif decoder
*/
gif_bytes = (gif_end - gif_data);
block_size = 0;
while (gif_data < gif_end && gif_data[0] != GIF_BLOCK_TERMINATOR) {
block_size = gif_data[0] + 1;
if ((gif_bytes -= block_size) < 0) {
return GIF_INSUFFICIENT_FRAME_DATA;
}
gif_data += block_size;
}
++gif_data;
}
/* Set buffer position and return */
gif->buffer_position = (gif_data - gif->gif_data);
return GIF_OK;
}
| 0
|
508,923
|
st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond,
TABLE_LIST *derived)
{
cond->clear_extraction_flag();
if (cond->type() == Item::COND_ITEM)
{
bool and_cond= ((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC;
List<Item> *arg_list= ((Item_cond*) cond)->argument_list();
List_iterator<Item> li(*arg_list);
uint count= 0; // to count items not containing NO_EXTRACTION_FL
uint count_full= 0; // to count items with FULL_EXTRACTION_FL
Item *item;
while ((item=li++))
{
check_cond_extraction_for_grouping_fields(item, derived);
if (item->get_extraction_flag() != NO_EXTRACTION_FL)
{
count++;
if (item->get_extraction_flag() == FULL_EXTRACTION_FL)
count_full++;
}
else if (!and_cond)
break;
}
if ((and_cond && count == 0) || item)
cond->set_extraction_flag(NO_EXTRACTION_FL);
if (count_full == arg_list->elements)
cond->set_extraction_flag(FULL_EXTRACTION_FL);
if (cond->get_extraction_flag() != 0)
{
li.rewind();
while ((item=li++))
item->clear_extraction_flag();
}
}
else
{
int fl= cond->excl_dep_on_grouping_fields(this) ?
FULL_EXTRACTION_FL : NO_EXTRACTION_FL;
cond->set_extraction_flag(fl);
}
}
| 0
|
512,799
|
longlong val_int()
{
if (value <= (double) LONGLONG_MIN)
{
return LONGLONG_MIN;
}
else if (value >= (double) (ulonglong) LONGLONG_MAX)
{
return LONGLONG_MAX;
}
return (longlong) rint(value);
}
| 0
|
255,769
|
create_lookup_state(apr_pool_t *result_pool)
{
lookup_state_t *state = apr_pcalloc(result_pool, sizeof(*state));
state->next = apr_array_make(result_pool, 4, sizeof(node_t *));
state->current = apr_array_make(result_pool, 4, sizeof(node_t *));
/* Virtually all path segments should fit into this buffer. If they
* don't, the buffer gets automatically reallocated.
*
* Using a smaller initial size would be fine as well but does not
* buy us much for the increased risk of being expanded anyway - at
* some extra cost. */
state->scratch_pad = svn_stringbuf_create_ensure(200, result_pool);
/* Most paths should fit into this buffer. The same rationale as
* above applies. */
state->parent_path = svn_stringbuf_create_ensure(200, result_pool);
return state;
}
| 0
|
512,667
|
virtual void print(String *str, enum_query_type query_type)
{
decimal_value.to_string(&str_value);
str->append(str_value);
}
| 0
|
405,398
|
static int xfrm_policy_match(const struct xfrm_policy *pol,
const struct flowi *fl,
u8 type, u16 family, int dir, u32 if_id)
{
const struct xfrm_selector *sel = &pol->selector;
int ret = -ESRCH;
bool match;
if (pol->family != family ||
pol->if_id != if_id ||
(fl->flowi_mark & pol->mark.m) != pol->mark.v ||
pol->type != type)
return ret;
match = xfrm_selector_match(sel, fl, family);
if (match)
ret = security_xfrm_policy_lookup(pol->security, fl->flowi_secid);
return ret;
}
| 0
|
413,861
|
void LinkResolver::check_klass_accessibility(Klass* ref_klass, Klass* sel_klass, TRAPS) {
Klass* base_klass = sel_klass;
if (sel_klass->is_objArray_klass()) {
base_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();
}
// The element type could be a typeArray - we only need the access
// check if it is a reference to another class.
if (!base_klass->is_instance_klass()) {
return; // no relevant check to do
}
Reflection::VerifyClassAccessResults vca_result =
Reflection::verify_class_access(ref_klass, InstanceKlass::cast(base_klass), true);
if (vca_result != Reflection::ACCESS_OK) {
ResourceMark rm(THREAD);
char* msg = Reflection::verify_class_access_msg(ref_klass,
InstanceKlass::cast(base_klass),
vca_result);
bool same_module = (base_klass->module() == ref_klass->module());
if (msg == NULL) {
Exceptions::fthrow(
THREAD_AND_LOCATION,
vmSymbols::java_lang_IllegalAccessError(),
"failed to access class %s from class %s (%s%s%s)",
base_klass->external_name(),
ref_klass->external_name(),
(same_module) ? base_klass->joint_in_module_of_loader(ref_klass) : base_klass->class_in_module_of_loader(),
(same_module) ? "" : "; ",
(same_module) ? "" : ref_klass->class_in_module_of_loader());
} else {
// Use module specific message returned by verify_class_access_msg().
Exceptions::fthrow(
THREAD_AND_LOCATION,
vmSymbols::java_lang_IllegalAccessError(),
"%s", msg);
}
}
}
| 0
|
278,261
|
get_breakindent_win(
win_T *wp,
char_u *line) // start of the line
{
static int prev_indent = 0; // cached indent value
static long prev_ts = 0L; // cached tabstop value
static char_u *prev_line = NULL; // cached pointer to line
static varnumber_T prev_tick = 0; // changedtick of cached value
# ifdef FEAT_VARTABS
static int *prev_vts = NULL; // cached vartabs values
# endif
static int prev_list = 0; // cached list value
static int prev_listopt = 0; // cached w_p_briopt_list value
// cached formatlistpat value
static char_u *prev_flp = NULL;
int bri = 0;
// window width minus window margin space, i.e. what rests for text
const int eff_wwidth = wp->w_width
- ((wp->w_p_nu || wp->w_p_rnu)
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
? number_width(wp) + 1 : 0);
// used cached indent, unless
// - line pointer changed
// - 'tabstop' changed
// - 'briopt_list changed' changed or
// - 'formatlistpattern' changed
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
|| prev_tick != CHANGEDTICK(wp->w_buffer)
|| prev_listopt != wp->w_briopt_list
|| (prev_flp == NULL
|| (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))
# ifdef FEAT_VARTABS
|| prev_vts != wp->w_buffer->b_p_vts_array
# endif
)
{
prev_line = line;
prev_ts = wp->w_buffer->b_p_ts;
prev_tick = CHANGEDTICK(wp->w_buffer);
# ifdef FEAT_VARTABS
prev_vts = wp->w_buffer->b_p_vts_array;
if (wp->w_briopt_vcol == 0)
prev_indent = get_indent_str_vtab(line,
(int)wp->w_buffer->b_p_ts,
wp->w_buffer->b_p_vts_array, wp->w_p_list);
# else
if (wp->w_briopt_vcol == 0)
prev_indent = get_indent_str(line,
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
# endif
prev_listopt = wp->w_briopt_list;
prev_list = 0;
vim_free(prev_flp);
prev_flp = vim_strsave(get_flp_value(wp->w_buffer));
// add additional indent for numbered lists
if (wp->w_briopt_list != 0 && wp->w_briopt_vcol == 0)
{
regmatch_T regmatch;
regmatch.regprog = vim_regcomp(prev_flp,
RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT);
if (regmatch.regprog != NULL)
{
regmatch.rm_ic = FALSE;
if (vim_regexec(®match, line, 0))
{
if (wp->w_briopt_list > 0)
prev_list = wp->w_briopt_list;
else
prev_list = (*regmatch.endp - *regmatch.startp);
}
vim_regfree(regmatch.regprog);
}
}
}
if (wp->w_briopt_vcol != 0)
{
// column value has priority
bri = wp->w_briopt_vcol;
prev_list = 0;
}
else
bri = prev_indent + wp->w_briopt_shift;
// Add offset for number column, if 'n' is in 'cpoptions'
bri += win_col_off2(wp);
// add additional indent for numbered lists
if (wp->w_briopt_list != 0)
{
if (wp->w_briopt_list > 0)
bri += prev_list;
else
bri = prev_list;
}
// indent minus the length of the showbreak string
if (wp->w_briopt_sbr)
bri -= vim_strsize(get_showbreak_value(wp));
// never indent past left window margin
if (bri < 0)
bri = 0;
// always leave at least bri_min characters on the left,
// if text width is sufficient
else if (bri > eff_wwidth - wp->w_briopt_min)
bri = (eff_wwidth - wp->w_briopt_min < 0)
? 0 : eff_wwidth - wp->w_briopt_min;
return bri;
}
| 0
|
247,683
|
TEST_P(SslSocketTest, TestConnectionFailsWhenRejectOnExpiredAndResponseExpired) {
const std::string server_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
- certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/good_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/good_key.pem"
ocsp_staple:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/unknown_ocsp_resp.der"
ocsp_staple_policy: strict_stapling
)EOF";
const std::string client_ctx_yaml = R"EOF(
common_tls_context:
tls_params:
cipher_suites:
- TLS_RSA_WITH_AES_128_GCM_SHA256
)EOF";
TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());
testUtil(test_options.setExpectedServerStats("ssl.ocsp_staple_failed").enableOcspStapling());
}
| 0
|
512,742
|
Item_func_if::fix_fields(THD *thd, Item **ref)
{
DBUG_ASSERT(fixed == 0);
args[0]->top_level_item();
if (Item_func::fix_fields(thd, ref))
return 1;
return 0;
}
| 0
|
402,643
|
handle_sign_detached_with_file_type(context *ctx, struct pollfd *pollfd, socklen_t size)
{
handle_sign_helper(ctx, pollfd, size, 0, true);
}
| 0
|
359,212
|
static struct bpf_map *ringbuf_map_alloc(union bpf_attr *attr)
{
struct bpf_ringbuf_map *rb_map;
if (attr->map_flags & ~RINGBUF_CREATE_FLAG_MASK)
return ERR_PTR(-EINVAL);
if (attr->key_size || attr->value_size ||
!is_power_of_2(attr->max_entries) ||
!PAGE_ALIGNED(attr->max_entries))
return ERR_PTR(-EINVAL);
#ifdef CONFIG_64BIT
/* on 32-bit arch, it's impossible to overflow record's hdr->pgoff */
if (attr->max_entries > RINGBUF_MAX_DATA_SZ)
return ERR_PTR(-E2BIG);
#endif
rb_map = kzalloc(sizeof(*rb_map), GFP_USER | __GFP_ACCOUNT);
if (!rb_map)
return ERR_PTR(-ENOMEM);
bpf_map_init_from_attr(&rb_map->map, attr);
rb_map->rb = bpf_ringbuf_alloc(attr->max_entries, rb_map->map.numa_node);
if (!rb_map->rb) {
kfree(rb_map);
return ERR_PTR(-ENOMEM);
}
return &rb_map->map;
}
| 0
|
466,141
|
static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned seg,
int reg, struct operand *op)
{
int df = (ctxt->eflags & EFLG_DF) ? -1 : 1;
register_address_increment(ctxt, &ctxt->regs[reg], df * op->bytes);
op->addr.mem.ea = register_address(ctxt, ctxt->regs[reg]);
op->addr.mem.seg = seg;
}
| 0
|
215,122
|
getvcol(
win_T *wp,
pos_T *pos,
colnr_T *start,
colnr_T *cursor,
colnr_T *end)
{
colnr_T vcol;
char_u *ptr; // points to current char
char_u *posptr; // points to char at pos->col
char_u *line; // start of the line
int incr;
int head;
#ifdef FEAT_VARTABS
int *vts = wp->w_buffer->b_p_vts_array;
#endif
int ts = wp->w_buffer->b_p_ts;
int c;
vcol = 0;
line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
if (pos->col == MAXCOL)
posptr = NULL; // continue until the NUL
else
{
// Special check for an empty line, which can happen on exit, when
// ml_get_buf() always returns an empty string.
if (*ptr == NUL)
pos->col = 0;
posptr = ptr + pos->col;
if (has_mbyte)
// always start on the first byte
posptr -= (*mb_head_off)(line, posptr);
}
/*
* This function is used very often, do some speed optimizations.
* When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
* use a simple loop.
* Also use this when 'list' is set but tabs take their normal size.
*/
if ((!wp->w_p_list || wp->w_lcs_chars.tab1 != NUL)
#ifdef FEAT_LINEBREAK
&& !wp->w_p_lbr && *get_showbreak_value(wp) == NUL && !wp->w_p_bri
#endif
)
{
for (;;)
{
head = 0;
c = *ptr;
// make sure we don't go past the end of the line
if (c == NUL)
{
incr = 1; // NUL at end of line only takes one column
break;
}
// A tab gets expanded, depending on the current column
if (c == TAB)
#ifdef FEAT_VARTABS
incr = tabstop_padding(vcol, ts, vts);
#else
incr = ts - (vcol % ts);
#endif
else
{
if (has_mbyte)
{
// For utf-8, if the byte is >= 0x80, need to look at
// further bytes to find the cell width.
if (enc_utf8 && c >= 0x80)
incr = utf_ptr2cells(ptr);
else
incr = g_chartab[c] & CT_CELL_MASK;
// If a double-cell char doesn't fit at the end of a line
// it wraps to the next line, it's like this char is three
// cells wide.
if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1
&& in_win_border(wp, vcol))
{
++incr;
head = 1;
}
}
else
incr = g_chartab[c] & CT_CELL_MASK;
}
if (posptr != NULL && ptr >= posptr) // character at pos->col
break;
vcol += incr;
MB_PTR_ADV(ptr);
}
}
else
{
for (;;)
{
// A tab gets expanded, depending on the current column
head = 0;
incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);
// make sure we don't go past the end of the line
if (*ptr == NUL)
{
incr = 1; // NUL at end of line only takes one column
break;
}
if (posptr != NULL && ptr >= posptr) // character at pos->col
break;
vcol += incr;
MB_PTR_ADV(ptr);
}
}
if (start != NULL)
*start = vcol + head;
if (end != NULL)
*end = vcol + incr - 1;
if (cursor != NULL)
{
if (*ptr == TAB
&& (State & NORMAL)
&& !wp->w_p_list
&& !virtual_active()
&& !(VIsual_active
&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))
)
*cursor = vcol + incr - 1; // cursor at end
else
*cursor = vcol + head; // cursor at start
}
}
| 1
|
437,683
|
static unsigned int txclk_tx_s_carrier(struct cx23885_dev *dev,
unsigned int freq,
u16 *divider)
{
*divider = carrier_freq_to_clock_divider(freq);
cx23888_ir_write4(dev, CX23888_IR_TXCLK_REG, *divider);
return clock_divider_to_carrier_freq(*divider);
}
| 0
|
215,142
|
setup_secureChannel(void) {
TestingPolicy(&dummyPolicy, dummyCertificate, &fCalled, &keySizes);
UA_SecureChannel_init(&testChannel, &UA_ConnectionConfig_default);
UA_SecureChannel_setSecurityPolicy(&testChannel, &dummyPolicy, &dummyCertificate);
testingConnection = createDummyConnection(65535, &sentData);
UA_Connection_attachSecureChannel(&testingConnection, &testChannel);
testChannel.connection = &testingConnection;
testChannel.state = UA_SECURECHANNELSTATE_OPEN;
}
| 1
|
473,928
|
mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)
{
int firstbyte = *p++;
state_t s;
s = trans[0][firstbyte];
if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1) :
ONIGENC_CONSTRUCT_MBCLEN_INVALID();
if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-1);
s = trans[s][*p++];
if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2) :
ONIGENC_CONSTRUCT_MBCLEN_INVALID();
if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-2);
s = trans[s][*p++];
if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(3) :
ONIGENC_CONSTRUCT_MBCLEN_INVALID();
if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-3);
s = trans[s][*p++];
return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(4) :
ONIGENC_CONSTRUCT_MBCLEN_INVALID();
}
| 0
|
312,550
|
qf_parse_fmt_c(regmatch_T *rmp, int midx, qffields_T *fields)
{
if (rmp->startp[midx] == NULL)
return QF_FAIL;
fields->col = (int)atol((char *)rmp->startp[midx]);
return QF_OK;
}
| 0
|
247,533
|
void initialize() {
TestUtility::loadFromYaml(TestEnvironment::substitute(server_ctx_yaml_),
downstream_tls_context_);
auto server_cfg =
std::make_unique<ServerContextConfigImpl>(downstream_tls_context_, factory_context_);
manager_ = std::make_unique<ContextManagerImpl>(time_system_);
server_ssl_socket_factory_ = std::make_unique<ServerSslSocketFactory>(
std::move(server_cfg), *manager_, server_stats_store_, std::vector<std::string>{});
socket_ = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(
Network::Test::getCanonicalLoopbackAddress(GetParam()));
listener_ = dispatcher_->createListener(socket_, listener_callbacks_, runtime_, true, false);
TestUtility::loadFromYaml(TestEnvironment::substitute(client_ctx_yaml_), upstream_tls_context_);
auto client_cfg =
std::make_unique<ClientContextConfigImpl>(upstream_tls_context_, factory_context_);
client_ssl_socket_factory_ = std::make_unique<ClientSslSocketFactory>(
std::move(client_cfg), *manager_, client_stats_store_);
auto transport_socket = client_ssl_socket_factory_->createTransportSocket(nullptr);
client_transport_socket_ = transport_socket.get();
client_connection_ =
dispatcher_->createClientConnection(socket_->connectionInfoProvider().localAddress(),
source_address_, std::move(transport_socket), nullptr);
client_connection_->addConnectionCallbacks(client_callbacks_);
client_connection_->connect();
read_filter_ = std::make_shared<Network::MockReadFilter>();
}
| 0
|
238,613
|
static int acquire_reference_state(struct bpf_verifier_env *env, int insn_idx)
{
struct bpf_func_state *state = cur_func(env);
int new_ofs = state->acquired_refs;
int id, err;
err = resize_reference_state(state, state->acquired_refs + 1);
if (err)
return err;
id = ++env->id_gen;
state->refs[new_ofs].id = id;
state->refs[new_ofs].insn_idx = insn_idx;
return id;
}
| 0
|
359,288
|
peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi,
const char *direct_str)
{
int ret;
struct peer *peer;
int direct = FILTER_IN;
peer = peer_and_group_lookup_vty (vty, ip_str);
if (! peer)
return CMD_WARNING;
/* Check filter direction. */
if (strncmp (direct_str, "i", 1) == 0)
direct = FILTER_IN;
else if (strncmp (direct_str, "o", 1) == 0)
direct = FILTER_OUT;
ret = peer_aslist_unset (peer, afi, safi, direct);
return bgp_vty_return (vty, ret);
}
| 0
|
232,930
|
static void zstd_close_writer(struct Curl_easy *data,
struct contenc_writer *writer)
{
struct zstd_params *zp = (struct zstd_params *)&writer->params;
(void)data;
if(zp->decomp) {
free(zp->decomp);
zp->decomp = NULL;
}
if(zp->zds) {
ZSTD_freeDStream(zp->zds);
zp->zds = NULL;
}
}
| 0
|
512,656
|
void Item_func_in::print(String *str, enum_query_type query_type)
{
args[0]->print_parenthesised(str, query_type, precedence());
if (negated)
str->append(STRING_WITH_LEN(" not"));
str->append(STRING_WITH_LEN(" in ("));
print_args(str, 1, query_type);
str->append(STRING_WITH_LEN(")"));
}
| 0
|
231,038
|
BaseType_t xQueueCRSend( QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait )
{
BaseType_t xReturn;
Queue_t * const pxQueue = xQueue;
/* If the queue is already full we may have to block. A critical section
* is required to prevent an interrupt removing something from the queue
* between the check to see if the queue is full and blocking on the queue. */
portDISABLE_INTERRUPTS();
{
if( prvIsQueueFull( pxQueue ) != pdFALSE )
{
/* The queue is full - do we want to block or just leave without
* posting? */
if( xTicksToWait > ( TickType_t ) 0 )
{
/* As this is called from a coroutine we cannot block directly, but
* return indicating that we need to block. */
vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );
portENABLE_INTERRUPTS();
return errQUEUE_BLOCKED;
}
else
{
portENABLE_INTERRUPTS();
return errQUEUE_FULL;
}
}
}
portENABLE_INTERRUPTS();
portDISABLE_INTERRUPTS();
{
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
{
/* There is room in the queue, copy the data into the queue. */
prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );
xReturn = pdPASS;
/* Were any co-routines waiting for data to become available? */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
/* In this instance the co-routine could be placed directly
* into the ready list as we are within a critical section.
* Instead the same pending ready list mechanism is used as if
* the event were caused from within an interrupt. */
if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The co-routine waiting has a higher priority so record
* that a yield might be appropriate. */
xReturn = errQUEUE_YIELD;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
xReturn = errQUEUE_FULL;
}
}
portENABLE_INTERRUPTS();
return xReturn;
}
| 0
|
409,506
|
report_default_term(char_u *term)
{
mch_errmsg(_("defaulting to '"));
mch_errmsg((char *)term);
mch_errmsg("'\r\n");
if (emsg_silent == 0 && !in_assert_fails)
{
screen_start(); // don't know where cursor is now
out_flush();
if (!is_not_a_term())
ui_delay(2007L, TRUE);
}
}
| 0
|
483,492
|
static ssize_t systab_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
char *str = buf;
if (!kobj || !buf)
return -EINVAL;
if (efi.mps != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "MPS=0x%lx\n", efi.mps);
if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "ACPI20=0x%lx\n", efi.acpi20);
if (efi.acpi != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "ACPI=0x%lx\n", efi.acpi);
/*
* If both SMBIOS and SMBIOS3 entry points are implemented, the
* SMBIOS3 entry point shall be preferred, so we list it first to
* let applications stop parsing after the first match.
*/
if (efi.smbios3 != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "SMBIOS3=0x%lx\n", efi.smbios3);
if (efi.smbios != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "SMBIOS=0x%lx\n", efi.smbios);
if (efi.hcdp != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "HCDP=0x%lx\n", efi.hcdp);
if (efi.boot_info != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "BOOTINFO=0x%lx\n", efi.boot_info);
if (efi.uga != EFI_INVALID_TABLE_ADDR)
str += sprintf(str, "UGA=0x%lx\n", efi.uga);
return str - buf;
}
| 0
|
462,551
|
std::string controller::prepare_message(unsigned int pos, unsigned int max) {
if (max > 0) {
return strprintf::fmt("(%u/%u) ", pos, max);
}
return "";
}
| 0
|
90,188
|
static std::string ToHtmlTableHeader(Network* network) {
std::string str;
if (network->type() == TYPE_WIFI || network->type() == TYPE_CELLULAR) {
str += WrapWithTH("Name") + WrapWithTH("Auto-Connect") +
WrapWithTH("Strength");
if (network->type() == TYPE_WIFI)
str += WrapWithTH("Encryption") + WrapWithTH("Passphrase") +
WrapWithTH("Identity") + WrapWithTH("Certificate");
}
str += WrapWithTH("State") + WrapWithTH("Error") + WrapWithTH("IP Address");
return str;
}
| 0
|
269,322
|
static void Run(OpKernelContext *ctx, typename TTypes<T>::Scalar &s, const typename TTypes<T>::UnalignedVec &v) {
s.device(ctx->eigen_cpu_device()) = v.maximum();
}
| 0
|
206,588
|
gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
{
int lastBorder;
/* Seek left */
int leftLimit, rightLimit;
int i;
leftLimit = (-1);
if (border < 0)
{
/* Refuse to fill to a non-solid border */
return;
}
for (i = x; (i >= 0); i--)
{
if (gdImageGetPixel (im, i, y) == border)
{
break;
}
gdImageSetPixel (im, i, y, color);
leftLimit = i;
}
if (leftLimit == (-1))
{
return;
}
/* Seek right */
rightLimit = x;
for (i = (x + 1); (i < im->sx); i++)
{
if (gdImageGetPixel (im, i, y) == border)
{
break;
}
gdImageSetPixel (im, i, y, color);
rightLimit = i;
}
/* Look at lines above and below and start paints */
/* Above */
if (y > 0)
{
lastBorder = 1;
for (i = leftLimit; (i <= rightLimit); i++)
{
int c;
c = gdImageGetPixel (im, i, y - 1);
if (lastBorder)
{
if ((c != border) && (c != color))
{
gdImageFillToBorder (im, i, y - 1,
border, color);
lastBorder = 0;
}
}
else if ((c == border) || (c == color))
{
lastBorder = 1;
}
}
}
/* Below */
if (y < ((im->sy) - 1))
{
lastBorder = 1;
for (i = leftLimit; (i <= rightLimit); i++)
{
int c;
c = gdImageGetPixel (im, i, y + 1);
if (lastBorder)
{
if ((c != border) && (c != color))
{
gdImageFillToBorder (im, i, y + 1,
border, color);
lastBorder = 0;
}
}
else if ((c == border) || (c == color))
{
lastBorder = 1;
}
}
}
}
| 1
|
369,228
|
static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags)
{
if (req->file || !io_op_defs[req->opcode].needs_file)
return true;
if (req->flags & REQ_F_FIXED_FILE)
req->file = io_file_get_fixed(req, req->fd, issue_flags);
else
req->file = io_file_get_normal(req, req->fd);
if (req->file)
return true;
req_set_fail(req);
req->result = -EBADF;
return false;
| 0
|
333,065
|
nfa_regfree(regprog_T *prog)
{
if (prog != NULL)
{
vim_free(((nfa_regprog_T *)prog)->match_text);
vim_free(((nfa_regprog_T *)prog)->pattern);
vim_free(prog);
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.