idx
int64 | func
string | target
int64 |
|---|---|---|
376,323
|
gpg_decrypt_sync (CamelCipherContext *context,
CamelMimePart *ipart,
CamelMimePart *opart,
GCancellable *cancellable,
GError **error)
{
struct _GpgCtx *gpg = NULL;
CamelCipherValidity *valid = NULL;
CamelStream *ostream, *istream;
CamelDataWrapper *content;
CamelMimePart *encrypted;
CamelMultipart *mp;
CamelContentType *ct;
gboolean success;
if (!ipart) {
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot decrypt message: Incorrect message format"));
return NULL;
}
content = camel_medium_get_content ((CamelMedium *) ipart);
if (!content) {
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot decrypt message: Incorrect message format"));
return NULL;
}
ct = camel_data_wrapper_get_mime_type_field (content);
/* Encrypted part (using our fake mime type) or PGP/Mime multipart */
if (camel_content_type_is (ct, "multipart", "encrypted")) {
mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) ipart);
if (!(encrypted = camel_multipart_get_part (mp, CAMEL_MULTIPART_ENCRYPTED_CONTENT))) {
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Failed to decrypt MIME part: "
"protocol error"));
return NULL;
}
content = camel_medium_get_content ((CamelMedium *) encrypted);
} else if (camel_content_type_is (ct, "application", "x-inlinepgp-encrypted")) {
content = camel_medium_get_content ((CamelMedium *) ipart);
} else {
/* Invalid Mimetype */
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot decrypt message: Incorrect message format"));
return NULL;
}
istream = camel_stream_mem_new ();
if (!camel_data_wrapper_decode_to_stream_sync (
content, istream, cancellable, error)) {
g_object_unref (istream);
return NULL;
}
g_seekable_seek (G_SEEKABLE (istream), 0, G_SEEK_SET, NULL, NULL);
ostream = camel_stream_mem_new ();
camel_stream_mem_set_secure ((CamelStreamMem *) ostream);
gpg = gpg_ctx_new (context);
gpg_ctx_set_mode (gpg, GPG_CTX_MODE_DECRYPT);
gpg_ctx_set_istream (gpg, istream);
gpg_ctx_set_ostream (gpg, ostream);
if (!gpg_ctx_op_start (gpg, error))
goto fail;
while (!gpg_ctx_op_complete (gpg)) {
if (gpg_ctx_op_step (gpg, cancellable, error) == -1) {
gpg_ctx_op_cancel (gpg);
goto fail;
}
}
/* Report errors only if nothing was decrypted; missing sender's key used
for signature of a signed and encrypted messages causes GPG to return
failure, thus count with it.
*/
if (gpg_ctx_op_wait (gpg) != 0 && gpg->nodata) {
const gchar *diagnostics;
diagnostics = gpg_ctx_get_diagnostics (gpg);
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s",
(diagnostics != NULL && *diagnostics != '\0') ?
diagnostics : _("Failed to execute gpg."));
goto fail;
}
g_seekable_seek (G_SEEKABLE (ostream), 0, G_SEEK_SET, NULL, NULL);
if (camel_content_type_is (ct, "multipart", "encrypted")) {
CamelDataWrapper *dw;
CamelStream *null = camel_stream_null_new ();
/* Multipart encrypted - parse a full mime part */
success = camel_data_wrapper_construct_from_stream_sync (
CAMEL_DATA_WRAPPER (opart),
ostream, NULL, error);
dw = camel_medium_get_content ((CamelMedium *) opart);
if (!camel_data_wrapper_decode_to_stream_sync (
dw, null, cancellable, NULL)) {
/* nothing had been decoded from the stream, it doesn't
* contain any header, like Content-Type or such, thus
* write it as a message body */
success = camel_data_wrapper_construct_from_stream_sync (
dw, ostream, cancellable, error);
}
g_object_unref (null);
} else {
/* Inline signed - raw data (may not be a mime part) */
CamelDataWrapper *dw;
dw = camel_data_wrapper_new ();
success = camel_data_wrapper_construct_from_stream_sync (
dw, ostream, NULL, error);
camel_data_wrapper_set_mime_type (dw, "application/octet-stream");
camel_medium_set_content ((CamelMedium *) opart, dw);
g_object_unref (dw);
/* Set mime/type of this new part to application/octet-stream to force type snooping */
camel_mime_part_set_content_type (opart, "application/octet-stream");
}
if (success) {
valid = camel_cipher_validity_new ();
valid->encrypt.description = g_strdup (_("Encrypted content"));
valid->encrypt.status = CAMEL_CIPHER_VALIDITY_ENCRYPT_ENCRYPTED;
if (gpg->hadsig) {
if (gpg->validsig) {
if (gpg->trust == GPG_TRUST_UNDEFINED || gpg->trust == GPG_TRUST_NONE)
valid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_UNKNOWN;
else if (gpg->trust != GPG_TRUST_NEVER)
valid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_GOOD;
else
valid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_BAD;
} else if (gpg->nopubkey) {
valid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_NEED_PUBLIC_KEY;
} else {
valid->sign.status = CAMEL_CIPHER_VALIDITY_SIGN_BAD;
}
add_signers (valid, gpg->signers);
}
}
fail:
g_object_unref (ostream);
g_object_unref (istream);
gpg_ctx_free (gpg);
return valid;
}
| 0
|
391,646
|
NTSTATUS get_relative_fid_filename(connection_struct *conn,
struct smb_request *req,
uint16_t root_dir_fid,
const struct smb_filename *smb_fname,
struct smb_filename **smb_fname_out)
{
files_struct *dir_fsp;
char *parent_fname = NULL;
char *new_base_name = NULL;
NTSTATUS status;
if (root_dir_fid == 0 || !smb_fname) {
status = NT_STATUS_INTERNAL_ERROR;
goto out;
}
dir_fsp = file_fsp(req, root_dir_fid);
if (dir_fsp == NULL) {
status = NT_STATUS_INVALID_HANDLE;
goto out;
}
if (is_ntfs_stream_smb_fname(dir_fsp->fsp_name)) {
status = NT_STATUS_INVALID_HANDLE;
goto out;
}
if (!dir_fsp->is_directory) {
/*
* Check to see if this is a mac fork of some kind.
*/
if ((conn->fs_capabilities & FILE_NAMED_STREAMS) &&
is_ntfs_stream_smb_fname(smb_fname)) {
status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
goto out;
}
/*
we need to handle the case when we get a
relative open relative to a file and the
pathname is blank - this is a reopen!
(hint from demyn plantenberg)
*/
status = NT_STATUS_INVALID_HANDLE;
goto out;
}
if (ISDOT(dir_fsp->fsp_name->base_name)) {
/*
* We're at the toplevel dir, the final file name
* must not contain ./, as this is filtered out
* normally by srvstr_get_path and unix_convert
* explicitly rejects paths containing ./.
*/
parent_fname = talloc_strdup(talloc_tos(), "");
if (parent_fname == NULL) {
status = NT_STATUS_NO_MEMORY;
goto out;
}
} else {
size_t dir_name_len = strlen(dir_fsp->fsp_name->base_name);
/*
* Copy in the base directory name.
*/
parent_fname = talloc_array(talloc_tos(), char,
dir_name_len+2);
if (parent_fname == NULL) {
status = NT_STATUS_NO_MEMORY;
goto out;
}
memcpy(parent_fname, dir_fsp->fsp_name->base_name,
dir_name_len+1);
/*
* Ensure it ends in a '/'.
* We used TALLOC_SIZE +2 to add space for the '/'.
*/
if(dir_name_len
&& (parent_fname[dir_name_len-1] != '\\')
&& (parent_fname[dir_name_len-1] != '/')) {
parent_fname[dir_name_len] = '/';
parent_fname[dir_name_len+1] = '\0';
}
}
new_base_name = talloc_asprintf(talloc_tos(), "%s%s", parent_fname,
smb_fname->base_name);
if (new_base_name == NULL) {
status = NT_STATUS_NO_MEMORY;
goto out;
}
status = filename_convert(req,
conn,
req->flags2 & FLAGS2_DFS_PATHNAMES,
new_base_name,
0,
NULL,
smb_fname_out);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
out:
TALLOC_FREE(parent_fname);
TALLOC_FREE(new_base_name);
return status;
}
| 0
|
430,360
|
static void single_stop(struct seq_file *p, void *v)
{
}
| 0
|
484,746
|
static ssize_t show_rxbuf(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%lu\n", NET_RX_RING_SIZE);
}
| 0
|
359,334
|
bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
safi_t safi, int error)
{
switch (error)
{
case BGP_ERR_AF_UNCONFIGURED:
vty_out (vty,
"%%BGP: Enable %s %s address family for the neighbor %s%s",
afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
peer->host, VTY_NEWLINE);
break;
case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE);
break;
default:
break;
}
}
| 0
|
459,218
|
static void tcf_chain_head_change_dflt(struct tcf_proto *tp_head, void *priv)
{
struct tcf_proto __rcu **p_filter_chain = priv;
rcu_assign_pointer(*p_filter_chain, tp_head);
}
| 0
|
226,280
|
void video_sample_entry_box_del(GF_Box *s)
{
GF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s;
if (ptr == NULL) return;
gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);
if (ptr->slc) gf_odf_desc_del((GF_Descriptor *)ptr->slc);
/*for publishing*/
if (ptr->emul_esd) gf_odf_desc_del((GF_Descriptor *)ptr->emul_esd);
gf_free(ptr);
}
| 0
|
199,833
|
gif_internal_decode_frame(gif_animation *gif,
unsigned int frame,
bool clear_image)
{
unsigned int index = 0;
const unsigned char *gif_data, *gif_end;
ssize_t gif_bytes;
unsigned int width, height, offset_x, offset_y;
unsigned int flags, colour_table_size, interlace;
unsigned int *colour_table;
unsigned int *frame_data = 0; // Set to 0 for no warnings
unsigned int *frame_scanline;
ssize_t save_buffer_position;
unsigned int return_value = 0;
unsigned int x, y, decode_y, burst_bytes;
register unsigned char colour;
/* Ensure this frame is supposed to be decoded */
if (gif->frames[frame].display == false) {
return GIF_OK;
}
/* Ensure the frame is in range to decode */
if (frame > gif->frame_count_partial) {
return GIF_INSUFFICIENT_DATA;
}
/* done if frame is already decoded */
if ((!clear_image) &&
((int)frame == gif->decoded_frame)) {
return GIF_OK;
}
/* Get the start of our frame data and the end of the GIF data */
gif_data = gif->gif_data + gif->frames[frame].frame_pointer;
gif_end = gif->gif_data + gif->buffer_size;
gif_bytes = (gif_end - gif_data);
/*
* Ensure there is a minimal amount of data to proceed. The shortest
* block of data is a 10-byte image descriptor + 1-byte gif trailer
*/
if (gif_bytes < 12) {
return GIF_INSUFFICIENT_FRAME_DATA;
}
/* Save the buffer position */
save_buffer_position = gif->buffer_position;
gif->buffer_position = gif_data - gif->gif_data;
/* Skip any extensions because they have allready been processed */
if ((return_value = gif_skip_frame_extensions(gif)) != GIF_OK) {
goto gif_decode_frame_exit;
}
gif_data = (gif->gif_data + gif->buffer_position);
gif_bytes = (gif_end - gif_data);
/* Ensure we have enough data for the 10-byte image descriptor + 1-byte
* gif trailer
*/
if (gif_bytes < 12) {
return_value = GIF_INSUFFICIENT_FRAME_DATA;
goto gif_decode_frame_exit;
}
/* 10-byte Image Descriptor is:
*
* +0 CHAR Image Separator (0x2c)
* +1 SHORT Image Left Position
* +3 SHORT Image Top Position
* +5 SHORT Width
* +7 SHORT Height
* +9 CHAR __Packed Fields__
* 1BIT Local Colour Table Flag
* 1BIT Interlace Flag
* 1BIT Sort Flag
* 2BITS Reserved
* 3BITS Size of Local Colour Table
*/
if (gif_data[0] != GIF_IMAGE_SEPARATOR) {
return_value = GIF_DATA_ERROR;
goto gif_decode_frame_exit;
}
offset_x = gif_data[1] | (gif_data[2] << 8);
offset_y = gif_data[3] | (gif_data[4] << 8);
width = gif_data[5] | (gif_data[6] << 8);
height = gif_data[7] | (gif_data[8] << 8);
/* Boundary checking - shouldn't ever happen except unless the data has
* been modified since initialisation.
*/
if ((offset_x + width > gif->width) ||
(offset_y + height > gif->height)) {
return_value = GIF_DATA_ERROR;
goto gif_decode_frame_exit;
}
/* Decode the flags */
flags = gif_data[9];
colour_table_size = 2 << (flags & GIF_COLOUR_TABLE_SIZE_MASK);
interlace = flags & GIF_INTERLACE_MASK;
/* Advance data pointer to next block either colour table or image
* data.
*/
gif_data += 10;
gif_bytes = (gif_end - gif_data);
/* Set up the colour table */
if (flags & GIF_COLOUR_TABLE_MASK) {
if (gif_bytes < (int)(3 * colour_table_size)) {
return_value = GIF_INSUFFICIENT_FRAME_DATA;
goto gif_decode_frame_exit;
}
colour_table = gif->local_colour_table;
if (!clear_image) {
for (index = 0; index < colour_table_size; index++) {
/* Gif colour map contents are r,g,b.
*
* We want to pack them bytewise into the
* colour table, such that the red component
* is in byte 0 and the alpha component is in
* byte 3.
*/
unsigned char *entry =
(unsigned char *) &colour_table[index];
entry[0] = gif_data[0]; /* r */
entry[1] = gif_data[1]; /* g */
entry[2] = gif_data[2]; /* b */
entry[3] = 0xff; /* a */
gif_data += 3;
}
} else {
gif_data += 3 * colour_table_size;
}
gif_bytes = (gif_end - gif_data);
} else {
colour_table = gif->global_colour_table;
}
/* Ensure sufficient data remains */
if (gif_bytes < 1) {
return_value = GIF_INSUFFICIENT_FRAME_DATA;
goto gif_decode_frame_exit;
}
/* check for an end marker */
if (gif_data[0] == GIF_TRAILER) {
return_value = GIF_OK;
goto gif_decode_frame_exit;
}
/* Get the frame data */
assert(gif->bitmap_callbacks.bitmap_get_buffer);
frame_data = (void *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);
if (!frame_data) {
return GIF_INSUFFICIENT_MEMORY;
}
/* If we are clearing the image we just clear, if not decode */
if (!clear_image) {
lzw_result res;
const uint8_t *stack_base;
const uint8_t *stack_pos;
/* Ensure we have enough data for a 1-byte LZW code size +
* 1-byte gif trailer
*/
if (gif_bytes < 2) {
return_value = GIF_INSUFFICIENT_FRAME_DATA;
goto gif_decode_frame_exit;
}
/* If we only have a 1-byte LZW code size + 1-byte gif trailer,
* we're finished
*/
if ((gif_bytes == 2) && (gif_data[1] == GIF_TRAILER)) {
return_value = GIF_OK;
goto gif_decode_frame_exit;
}
/* If the previous frame's disposal method requires we restore
* the background colour or this is the first frame, clear
* the frame data
*/
if ((frame == 0) || (gif->decoded_frame == GIF_INVALID_FRAME)) {
memset((char*)frame_data,
GIF_TRANSPARENT_COLOUR,
gif->width * gif->height * sizeof(int));
gif->decoded_frame = frame;
/* The line below would fill the image with its
* background color, but because GIFs support
* transparency we likely wouldn't want to do that. */
/* memset((char*)frame_data, colour_table[gif->background_index], gif->width * gif->height * sizeof(int)); */
} else if ((frame != 0) &&
(gif->frames[frame - 1].disposal_method == GIF_FRAME_CLEAR)) {
return_value = gif_internal_decode_frame(gif,
(frame - 1),
true);
if (return_value != GIF_OK) {
goto gif_decode_frame_exit;
}
} else if ((frame != 0) &&
(gif->frames[frame - 1].disposal_method == GIF_FRAME_RESTORE)) {
/*
* If the previous frame's disposal method requires we
* restore the previous image, find the last image set
* to "do not dispose" and get that frame data
*/
int last_undisposed_frame = frame - 2;
while ((last_undisposed_frame >= 0) &&
(gif->frames[last_undisposed_frame].disposal_method == GIF_FRAME_RESTORE)) {
last_undisposed_frame--;
}
/* If we don't find one, clear the frame data */
if (last_undisposed_frame == -1) {
/* see notes above on transparency
* vs. background color
*/
memset((char*)frame_data,
GIF_TRANSPARENT_COLOUR,
gif->width * gif->height * sizeof(int));
} else {
return_value = gif_internal_decode_frame(gif, last_undisposed_frame, false);
if (return_value != GIF_OK) {
goto gif_decode_frame_exit;
}
/* Get this frame's data */
assert(gif->bitmap_callbacks.bitmap_get_buffer);
frame_data = (void *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);
if (!frame_data) {
return GIF_INSUFFICIENT_MEMORY;
}
}
}
gif->decoded_frame = frame;
gif->buffer_position = (gif_data - gif->gif_data) + 1;
/* Initialise the LZW decoding */
res = lzw_decode_init(gif->lzw_ctx, gif->gif_data,
gif->buffer_size, gif->buffer_position,
gif_data[0], &stack_base, &stack_pos);
if (res != LZW_OK) {
return gif_error_from_lzw(res);
}
/* Decompress the data */
for (y = 0; y < height; y++) {
if (interlace) {
decode_y = gif_interlaced_line(height, y) + offset_y;
} else {
decode_y = y + offset_y;
}
frame_scanline = frame_data + offset_x + (decode_y * gif->width);
/* Rather than decoding pixel by pixel, we try to burst
* out streams of data to remove the need for end-of
* data checks every pixel.
*/
x = width;
while (x > 0) {
burst_bytes = (stack_pos - stack_base);
if (burst_bytes > 0) {
if (burst_bytes > x) {
burst_bytes = x;
}
x -= burst_bytes;
while (burst_bytes-- > 0) {
colour = *--stack_pos;
if (((gif->frames[frame].transparency) &&
(colour != gif->frames[frame].transparency_index)) ||
(!gif->frames[frame].transparency)) {
*frame_scanline = colour_table[colour];
}
frame_scanline++;
}
} else {
res = lzw_decode(gif->lzw_ctx, &stack_pos);
if (res != LZW_OK) {
/* Unexpected end of frame, try to recover */
if (res == LZW_OK_EOD) {
return_value = GIF_OK;
} else {
return_value = gif_error_from_lzw(res);
}
goto gif_decode_frame_exit;
}
}
}
}
} else {
/* Clear our frame */
if (gif->frames[frame].disposal_method == GIF_FRAME_CLEAR) {
for (y = 0; y < height; y++) {
frame_scanline = frame_data + offset_x + ((offset_y + y) * gif->width);
if (gif->frames[frame].transparency) {
memset(frame_scanline,
GIF_TRANSPARENT_COLOUR,
width * 4);
} else {
memset(frame_scanline,
colour_table[gif->background_index],
width * 4);
}
}
}
}
gif_decode_frame_exit:
/* Check if we should test for optimisation */
if (gif->frames[frame].virgin) {
if (gif->bitmap_callbacks.bitmap_test_opaque) {
gif->frames[frame].opaque = gif->bitmap_callbacks.bitmap_test_opaque(gif->frame_image);
} else {
gif->frames[frame].opaque = false;
}
gif->frames[frame].virgin = false;
}
if (gif->bitmap_callbacks.bitmap_set_opaque) {
gif->bitmap_callbacks.bitmap_set_opaque(gif->frame_image, gif->frames[frame].opaque);
}
if (gif->bitmap_callbacks.bitmap_modified) {
gif->bitmap_callbacks.bitmap_modified(gif->frame_image);
}
/* Restore the buffer position */
gif->buffer_position = save_buffer_position;
return return_value;
}
| 1
|
310,196
|
main(int argc, char *argv[])
{
char my_tmpname[PATH_MAX];
char my_altfile[PATH_MAX];
int v_opt = -1;
int smart_defaults = TRUE;
char *termcap;
ENTRY *qp;
int this_opt, last_opt = '?';
int outform = F_TERMINFO; /* output format */
int sortmode = S_TERMINFO; /* sort_mode */
int width = 60;
int height = 65535;
bool formatted = FALSE; /* reformat complex strings? */
bool literal = FALSE; /* suppress post-processing? */
int numbers = 0; /* format "%'char'" to/from "%{number}" */
bool forceresolve = FALSE; /* force resolution */
bool limited = TRUE;
char *tversion = (char *) NULL;
const char *source_file = "terminfo";
char *outdir = (char *) NULL;
bool check_only = FALSE;
bool suppress_untranslatable = FALSE;
int quickdump = 0;
bool quiet = FALSE;
bool wrap_strings = FALSE;
log_fp = stderr;
_nc_progname = _nc_rootname(argv[0]);
atexit(cleanup);
if ((infodump = same_program(_nc_progname, PROG_CAPTOINFO)) != FALSE) {
outform = F_TERMINFO;
sortmode = S_TERMINFO;
}
if ((capdump = same_program(_nc_progname, PROG_INFOTOCAP)) != FALSE) {
outform = F_TERMCAP;
sortmode = S_TERMCAP;
}
#if NCURSES_XNAMES
use_extended_names(FALSE);
#endif
_nc_strict_bsd = 0;
/*
* Processing arguments is a little complicated, since someone made a
* design decision to allow the numeric values for -w, -v options to
* be optional.
*/
while ((this_opt = getopt(argc, argv,
"0123456789CDIKLNQR:TUVWace:fGgo:qrstvwx")) != -1) {
if (isdigit(this_opt)) {
switch (last_opt) {
case 'Q':
add_digit(&quickdump, this_opt);
break;
case 'v':
add_digit(&v_opt, this_opt);
break;
case 'w':
add_digit(&width, this_opt);
break;
default:
switch (this_opt) {
case '0':
last_opt = this_opt;
width = 65535;
height = 1;
break;
case '1':
last_opt = this_opt;
width = 0;
break;
default:
usage();
}
}
continue;
}
switch (this_opt) {
case 'K':
_nc_strict_bsd = 1;
/* the initial version of -K in 20110730 fell-thru here, but the
* same flag is useful when reading sources -TD
*/
break;
case 'C':
capdump = TRUE;
outform = F_TERMCAP;
sortmode = S_TERMCAP;
break;
case 'D':
debug_level = VtoTrace(v_opt);
set_trace_level(debug_level);
show_databases(outdir);
ExitProgram(EXIT_SUCCESS);
break;
case 'I':
infodump = TRUE;
outform = F_TERMINFO;
sortmode = S_TERMINFO;
break;
case 'L':
infodump = TRUE;
outform = F_VARIABLE;
sortmode = S_VARIABLE;
break;
case 'N':
smart_defaults = FALSE;
literal = TRUE;
break;
case 'Q':
quickdump = 0;
break;
case 'R':
tversion = optarg;
break;
case 'T':
limited = FALSE;
break;
case 'U':
literal = TRUE;
break;
case 'V':
puts(curses_version());
ExitProgram(EXIT_SUCCESS);
case 'W':
wrap_strings = TRUE;
break;
case 'c':
check_only = TRUE;
break;
case 'e':
namelst = make_namelist(optarg);
break;
case 'f':
formatted = TRUE;
break;
case 'G':
numbers = 1;
break;
case 'g':
numbers = -1;
break;
case 'o':
outdir = optarg;
break;
case 'q':
quiet = TRUE;
break;
case 'r':
forceresolve = TRUE;
break;
case 's':
showsummary = TRUE;
break;
case 'v':
v_opt = 0;
break;
case 'w':
width = 0;
break;
#if NCURSES_XNAMES
case 't':
_nc_disable_period = FALSE;
suppress_untranslatable = TRUE;
break;
case 'a':
_nc_disable_period = TRUE;
/* FALLTHRU */
case 'x':
use_extended_names(TRUE);
using_extensions = TRUE;
break;
#endif
default:
usage();
}
last_opt = this_opt;
}
debug_level = VtoTrace(v_opt);
set_trace_level(debug_level);
if (_nc_tracing) {
save_check_termtype = _nc_check_termtype2;
_nc_check_termtype2 = check_termtype;
}
#if !HAVE_BIG_CORE
/*
* Aaargh! immedhook seriously hoses us!
*
* One problem with immedhook is it means we can't do -e. Problem
* is that we can't guarantee that for each terminal listed, all the
* terminals it depends on will have been kept in core for reference
* resolution -- in fact it's certain the primitive types at the end
* of reference chains *won't* be in core unless they were explicitly
* in the select list themselves.
*/
if (namelst && (!infodump && !capdump)) {
(void) fprintf(stderr,
"%s: Sorry, -e can't be used without -I or -C\n",
_nc_progname);
ExitProgram(EXIT_FAILURE);
}
#endif /* HAVE_BIG_CORE */
if (optind < argc) {
source_file = argv[optind++];
if (optind < argc) {
fprintf(stderr,
"%s: Too many file names. Usage:\n\t%s %s",
_nc_progname,
_nc_progname,
usage_string);
ExitProgram(EXIT_FAILURE);
}
} else {
if (infodump == TRUE) {
/* captoinfo's no-argument case */
source_file = "/etc/termcap";
if ((termcap = getenv("TERMCAP")) != 0
&& (namelst = make_namelist(getenv("TERM"))) != 0) {
if (access(termcap, F_OK) == 0) {
/* file exists */
source_file = termcap;
} else {
if ((tmp_fp = open_tempfile(my_tmpname)) != 0) {
source_file = my_tmpname;
fprintf(tmp_fp, "%s\n", termcap);
fclose(tmp_fp);
tmp_fp = open_input(source_file, (char *) 0);
to_remove = source_file;
} else {
failed("tmpnam");
}
}
}
} else {
/* tic */
fprintf(stderr,
"%s: File name needed. Usage:\n\t%s %s",
_nc_progname,
_nc_progname,
usage_string);
ExitProgram(EXIT_FAILURE);
}
}
if (tmp_fp == 0) {
tmp_fp = open_input(source_file, my_altfile);
if (!strcmp(source_file, "-")) {
source_file = STDIN_NAME;
}
}
if (infodump || check_only) {
dump_init(tversion,
(smart_defaults
? outform
: F_LITERAL),
sortmode,
wrap_strings, width, height,
debug_level, formatted || check_only, check_only, quickdump);
} else if (capdump) {
dump_init(tversion,
outform,
sortmode,
wrap_strings, width, height,
debug_level, FALSE, FALSE, FALSE);
}
/* parse entries out of the source file */
_nc_set_source(source_file);
#if !HAVE_BIG_CORE
if (!(check_only || infodump || capdump))
_nc_set_writedir(outdir);
#endif /* HAVE_BIG_CORE */
_nc_read_entry_source(tmp_fp, (char *) NULL,
!smart_defaults || literal, FALSE,
((check_only || infodump || capdump)
? NULLHOOK
: immedhook));
/* do use resolution */
if (check_only || (!infodump && !capdump) || forceresolve) {
if (!_nc_resolve_uses2(TRUE, literal) && !check_only) {
ExitProgram(EXIT_FAILURE);
}
}
/* length check */
if (check_only && limited && (capdump || infodump)) {
for_entry_list(qp) {
if (matches(namelst, qp->tterm.term_names)) {
int len = fmt_entry(&qp->tterm, NULL, FALSE, TRUE, infodump, numbers);
if (len > (infodump ? MAX_TERMINFO_LENGTH : MAX_TERMCAP_LENGTH))
(void) fprintf(stderr,
"%s: resolved %s entry is %d bytes long\n",
_nc_progname,
_nc_first_name(qp->tterm.term_names),
len);
}
}
}
/* write or dump all entries */
if (check_only) {
/* this is in case infotocap() generates warnings */
_nc_curr_col = _nc_curr_line = -1;
for_entry_list(qp) {
if (matches(namelst, qp->tterm.term_names)) {
/* this is in case infotocap() generates warnings */
_nc_set_type(_nc_first_name(qp->tterm.term_names));
_nc_curr_line = (int) qp->startline;
repair_acsc(&qp->tterm);
dump_entry(&qp->tterm, suppress_untranslatable,
limited, numbers, NULL);
}
}
} else {
if (!infodump && !capdump) {
_nc_set_writedir(outdir);
for_entry_list(qp) {
if (matches(namelst, qp->tterm.term_names))
write_it(qp);
}
} else {
/* this is in case infotocap() generates warnings */
_nc_curr_col = _nc_curr_line = -1;
for_entry_list(qp) {
if (matches(namelst, qp->tterm.term_names)) {
long j = qp->cend - qp->cstart;
int len = 0;
/* this is in case infotocap() generates warnings */
_nc_set_type(_nc_first_name(qp->tterm.term_names));
if (!quiet) {
(void) fseek(tmp_fp, qp->cstart, SEEK_SET);
while (j-- > 0) {
int ch = fgetc(tmp_fp);
if (ch == EOF || ferror(tmp_fp)) {
break;
} else if (infodump) {
(void) putchar(ch);
} else {
put_translate(ch);
}
}
}
repair_acsc(&qp->tterm);
dump_entry(&qp->tterm, suppress_untranslatable,
limited, numbers, NULL);
for (j = 0; j < (long) qp->nuses; j++)
dump_uses(qp->uses[j].name, !capdump);
len = show_entry();
if (debug_level != 0 && !limited)
printf("# length=%d\n", len);
}
}
if (!namelst && _nc_tail && !quiet) {
int c, oldc = '\0';
bool in_comment = FALSE;
bool trailing_comment = FALSE;
(void) fseek(tmp_fp, _nc_tail->cend, SEEK_SET);
while ((c = fgetc(tmp_fp)) != EOF) {
if (oldc == '\n') {
if (c == '#') {
trailing_comment = TRUE;
in_comment = TRUE;
} else {
in_comment = FALSE;
}
}
if (trailing_comment
&& (in_comment || (oldc == '\n' && c == '\n')))
putchar(c);
oldc = c;
}
}
}
}
/* Show the directory into which entries were written, and the total
* number of entries
*/
if (showsummary
&& (!(check_only || infodump || capdump))) {
int total = _nc_tic_written();
if (total != 0)
fprintf(log_fp, "%d entries written to %s\n",
total,
_nc_tic_dir((char *) 0));
else
fprintf(log_fp, "No entries written\n");
}
ExitProgram(EXIT_SUCCESS);
}
| 0
|
245,171
|
read_mysql_one_value(MYSQL *connection, const char *query)
{
MYSQL_RES *mysql_result;
MYSQL_ROW row;
char *result = NULL;
mysql_result = xb_mysql_query(connection, query, true);
ut_ad(mysql_num_fields(mysql_result) == 1);
if ((row = mysql_fetch_row(mysql_result))) {
result = strdup(row[0]);
}
mysql_free_result(mysql_result);
return(result);
}
| 0
|
454,747
|
static irqreturn_t ismt_handle_isr(struct ismt_priv *priv)
{
complete(&priv->cmp);
return IRQ_HANDLED;
}
| 0
|
244,307
|
GF_Err fpar_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
u32 i;
FilePartitionBox *ptr = (FilePartitionBox *) s;
if (!s) return GF_BAD_PARAM;
e = gf_isom_full_box_write(s, bs);
if (e) return e;
gf_bs_write_int(bs, ptr->itemID, ptr->version ? 32 : 16);
gf_bs_write_u16(bs, ptr->packet_payload_size);
gf_bs_write_u8(bs, 0);
gf_bs_write_u8(bs, ptr->FEC_encoding_ID);
gf_bs_write_u16(bs, ptr->FEC_instance_ID);
gf_bs_write_u16(bs, ptr->max_source_block_length);
gf_bs_write_u16(bs, ptr->encoding_symbol_length);
gf_bs_write_u16(bs, ptr->max_number_of_encoding_symbols);
if (ptr->scheme_specific_info) {
gf_bs_write_data(bs, ptr->scheme_specific_info, (u32)strlen(ptr->scheme_specific_info) );
}
//null terminated string
gf_bs_write_u8(bs, 0);
gf_bs_write_int(bs, ptr->nb_entries, ptr->version ? 32 : 16);
for (i=0;i < ptr->nb_entries; i++) {
gf_bs_write_u16(bs, ptr->entries[i].block_count);
gf_bs_write_u32(bs, ptr->entries[i].block_size);
}
return GF_OK;
}
| 0
|
424,980
|
void iwl_pcie_dump_csr(struct iwl_trans *trans)
{
int i;
static const u32 csr_tbl[] = {
CSR_HW_IF_CONFIG_REG,
CSR_INT_COALESCING,
CSR_INT,
CSR_INT_MASK,
CSR_FH_INT_STATUS,
CSR_GPIO_IN,
CSR_RESET,
CSR_GP_CNTRL,
CSR_HW_REV,
CSR_EEPROM_REG,
CSR_EEPROM_GP,
CSR_OTP_GP_REG,
CSR_GIO_REG,
CSR_GP_UCODE_REG,
CSR_GP_DRIVER_REG,
CSR_UCODE_DRV_GP1,
CSR_UCODE_DRV_GP2,
CSR_LED_REG,
CSR_DRAM_INT_TBL_REG,
CSR_GIO_CHICKEN_BITS,
CSR_ANA_PLL_CFG,
CSR_MONITOR_STATUS_REG,
CSR_HW_REV_WA_REG,
CSR_DBG_HPET_MEM_REG
};
IWL_ERR(trans, "CSR values:\n");
IWL_ERR(trans, "(2nd byte of CSR_INT_COALESCING is "
"CSR_INT_PERIODIC_REG)\n");
for (i = 0; i < ARRAY_SIZE(csr_tbl); i++) {
IWL_ERR(trans, " %25s: 0X%08x\n",
get_csr_string(csr_tbl[i]),
iwl_read32(trans, csr_tbl[i]));
}
}
| 0
|
252,383
|
static MZ_FORCEINLINE void tdefl_find_match(
tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist,
mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) {
mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK,
match_len = *pMatch_len, probe_pos = pos, next_probe_pos,
probe_len;
mz_uint num_probes_left = d->m_max_probes[match_len >= 32];
const mz_uint8 *s = d->m_dict + pos, *p, *q;
mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1];
MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN);
if (max_match_len <= match_len) return;
for (;;) {
for (;;) {
if (--num_probes_left == 0) return;
#define TDEFL_PROBE \
next_probe_pos = d->m_next[probe_pos]; \
if ((!next_probe_pos) || \
((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \
return; \
probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
if ((d->m_dict[probe_pos + match_len] == c0) && \
(d->m_dict[probe_pos + match_len - 1] == c1)) \
break;
TDEFL_PROBE;
TDEFL_PROBE;
TDEFL_PROBE;
}
if (!dist) break;
p = s;
q = d->m_dict + probe_pos;
for (probe_len = 0; probe_len < max_match_len; probe_len++)
if (*p++ != *q++) break;
if (probe_len > match_len) {
*pMatch_dist = dist;
if ((*pMatch_len = match_len = probe_len) == max_match_len) return;
c0 = d->m_dict[pos + match_len];
c1 = d->m_dict[pos + match_len - 1];
}
}
}
| 0
|
294,713
|
c_gregorian_to_yday(int y, int m, int d)
{
assert(m >= 1 && m <= 12);
return yeartab[c_gregorian_leap_p(y) ? 1 : 0][m] + d;
}
| 0
|
220,406
|
mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other)
{
struct RArray *a1 = mrb_ary_ptr(self);
struct RArray *a2 = mrb_ary_ptr(other);
if (a1 != a2) {
ary_replace(mrb, a1, a2);
}
}
| 0
|
198,259
|
void Compute(OpKernelContext* context) override {
// Get the input Tensors.
OpInputList params_nested_splits_in;
OP_REQUIRES_OK(context, context->input_list("params_nested_splits",
¶ms_nested_splits_in));
const Tensor& params_dense_values_in =
context->input(params_nested_splits_in.size());
const Tensor& indices_in =
context->input(params_nested_splits_in.size() + 1);
DCHECK_GT(params_nested_splits_in.size(), 0); // Enforced by REGISTER_OP.
SPLITS_TYPE num_params = params_nested_splits_in[0].dim_size(0) - 1;
OP_REQUIRES_OK(context, ValidateIndices(indices_in, num_params));
OP_REQUIRES(context, params_dense_values_in.dims() > 0,
errors::InvalidArgument("params.rank must be nonzero"));
SPLITS_TYPE num_params_dense_values = params_dense_values_in.dim_size(0);
// Calculate the `splits`, and store the value slices that we need to
// copy in `value_slices`.
std::vector<std::pair<SPLITS_TYPE, SPLITS_TYPE>> value_slices;
SPLITS_TYPE num_values = 0;
std::vector<std::vector<SPLITS_TYPE>> out_splits;
OP_REQUIRES_OK(context, MakeSplits(indices_in, params_nested_splits_in,
num_params_dense_values, &out_splits,
&value_slices, &num_values));
// Write the output tensors.
OP_REQUIRES_OK(context, WriteSplits(out_splits, context));
OP_REQUIRES_OK(context,
WriteValues(params_dense_values_in, value_slices,
out_splits.size(), num_values, context));
}
| 1
|
366,189
|
static struct mountpoint *lock_mount(struct path *path)
{
struct vfsmount *mnt;
struct dentry *dentry = path->dentry;
retry:
inode_lock(dentry->d_inode);
if (unlikely(cant_mount(dentry))) {
inode_unlock(dentry->d_inode);
return ERR_PTR(-ENOENT);
}
namespace_lock();
mnt = lookup_mnt(path);
if (likely(!mnt)) {
struct mountpoint *mp = get_mountpoint(dentry);
if (IS_ERR(mp)) {
namespace_unlock();
inode_unlock(dentry->d_inode);
return mp;
}
return mp;
}
namespace_unlock();
inode_unlock(path->dentry->d_inode);
path_put(path);
path->mnt = mnt;
dentry = path->dentry = dget(mnt->mnt_root);
goto retry;
}
| 0
|
175,785
|
void set_quota_manager(QuotaManager* quota_manager) {
quota_manager_ = quota_manager;
}
| 0
|
498,094
|
void cgit_vprint_error(const char *fmt, va_list ap)
{
va_list cp;
html("<div class='error'>");
va_copy(cp, ap);
html_vtxtf(fmt, cp);
va_end(cp);
html("</div>\n");
}
| 0
|
353,124
|
bool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *catalog, Object *str,
const double *ptm, int paintType, int /*tilingType*/, Dict *resDict,
const double *mat, const double *bbox,
int x0, int y0, int x1, int y1,
double xStep, double yStep)
{
PDFRectangle box;
Gfx *gfx;
Splash *formerSplash = splash;
SplashBitmap *formerBitmap = bitmap;
double width, height;
int surface_width, surface_height, result_width, result_height, i;
int repeatX, repeatY;
SplashCoord matc[6];
Matrix m1;
const double *ctm;
double savedCTM[6];
double kx, ky, sx, sy;
bool retValue = false;
width = bbox[2] - bbox[0];
height = bbox[3] - bbox[1];
if (xStep != width || yStep != height)
return false;
// calculate offsets
ctm = state->getCTM();
for (i = 0; i < 6; ++i) {
savedCTM[i] = ctm[i];
}
state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]);
ctm = state->getCTM();
for (i = 0; i < 6; ++i) {
if (!std::isfinite(ctm[i])) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
}
matc[4] = x0 * xStep * ctm[0] + y0 * yStep * ctm[2] + ctm[4];
matc[5] = x0 * xStep * ctm[1] + y0 * yStep * ctm[3] + ctm[5];
if (splashAbs(ctm[1]) > splashAbs(ctm[0])) {
kx = -ctm[1];
ky = ctm[2] - (ctm[0] * ctm[3]) / ctm[1];
} else {
kx = ctm[0];
ky = ctm[3] - (ctm[1] * ctm[2]) / ctm[0];
}
result_width = (int) ceil(fabs(kx * width * (x1 - x0)));
result_height = (int) ceil(fabs(ky * height * (y1 - y0)));
kx = state->getHDPI() / 72.0;
ky = state->getVDPI() / 72.0;
m1.m[0] = (ptm[0] == 0) ? fabs(ptm[2]) * kx : fabs(ptm[0]) * kx;
m1.m[1] = 0;
m1.m[2] = 0;
m1.m[3] = (ptm[3] == 0) ? fabs(ptm[1]) * ky : fabs(ptm[3]) * ky;
m1.m[4] = 0;
m1.m[5] = 0;
m1.transform(width, height, &kx, &ky);
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
sx = (double) result_width / (surface_width * (x1 - x0));
sy = (double) result_height / (surface_height * (y1 - y0));
m1.m[0] *= sx;
m1.m[3] *= sy;
m1.transform(width, height, &kx, &ky);
if(fabs(kx) < 1 && fabs(ky) < 1) {
kx = std::min<double>(kx, ky);
ky = 2 / kx;
m1.m[0] *= ky;
m1.m[3] *= ky;
m1.transform(width, height, &kx, &ky);
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
repeatX = x1 - x0;
repeatY = y1 - y0;
} else {
if ((unsigned long) surface_width * surface_height > 0x800000L) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
while(fabs(kx) > 16384 || fabs(ky) > 16384) {
// limit pattern bitmap size
m1.m[0] /= 2;
m1.m[3] /= 2;
m1.transform(width, height, &kx, &ky);
}
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
// adjust repeat values to completely fill region
if (unlikely(surface_width == 0 || surface_height == 0)) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
repeatX = result_width / surface_width;
repeatY = result_height / surface_height;
if (surface_width * repeatX < result_width)
repeatX++;
if (surface_height * repeatY < result_height)
repeatY++;
if (x1 - x0 > repeatX)
repeatX = x1 - x0;
if (y1 - y0 > repeatY)
repeatY = y1 - y0;
}
// restore CTM and calculate rotate and scale with rounded matrix
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
state->concatCTM(width * repeatX, 0, 0, height * repeatY, bbox[0], bbox[1]);
ctm = state->getCTM();
matc[0] = ctm[0];
matc[1] = ctm[1];
matc[2] = ctm[2];
matc[3] = ctm[3];
if (surface_width == 0 || surface_height == 0 || repeatX * repeatY <= 4) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
m1.transform(bbox[0], bbox[1], &kx, &ky);
m1.m[4] = -kx;
m1.m[5] = -ky;
bitmap = new SplashBitmap(surface_width, surface_height, 1,
(paintType == 1) ? colorMode : splashModeMono8, true);
if (bitmap->getDataPtr() == nullptr) {
SplashBitmap *tBitmap = bitmap;
bitmap = formerBitmap;
delete tBitmap;
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
splash = new Splash(bitmap, true);
if (paintType == 2) {
SplashColor clearColor;
#ifdef SPLASH_CMYK
clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF;
#else
clearColor[0] = 0xFF;
#endif
splash->clear(clearColor, 0);
} else {
splash->clear(paperColor, 0);
}
splash->setThinLineMode(formerSplash->getThinLineMode());
splash->setMinLineWidth(s_minLineWidth);
box.x1 = bbox[0]; box.y1 = bbox[1];
box.x2 = bbox[2]; box.y2 = bbox[3];
gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);
// set pattern transformation matrix
gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
gfx->display(str);
delete splash;
splash = formerSplash;
TilingSplashOutBitmap imgData;
imgData.bitmap = bitmap;
imgData.paintType = paintType;
imgData.pattern = splash->getFillPattern();
imgData.colorMode = colorMode;
imgData.y = 0;
imgData.repeatX = repeatX;
imgData.repeatY = repeatY;
SplashBitmap *tBitmap = bitmap;
bitmap = formerBitmap;
result_width = tBitmap->getWidth() * imgData.repeatX;
result_height = tBitmap->getHeight() * imgData.repeatY;
if (splashAbs(matc[1]) > splashAbs(matc[0])) {
kx = -matc[1];
ky = matc[2] - (matc[0] * matc[3]) / matc[1];
} else {
kx = matc[0];
ky = matc[3] - (matc[1] * matc[2]) / matc[0];
}
kx = result_width / (fabs(kx) + 1);
ky = result_height / (fabs(ky) + 1);
state->concatCTM(kx, 0, 0, ky, 0, 0);
ctm = state->getCTM();
matc[0] = ctm[0];
matc[1] = ctm[1];
matc[2] = ctm[2];
matc[3] = ctm[3];
bool minorAxisZero = matc[1] == 0 && matc[2] == 0;
if (matc[0] > 0 && minorAxisZero && matc[3] > 0) {
// draw the tiles
for (int y = 0; y < imgData.repeatY; ++y) {
for (int x = 0; x < imgData.repeatX; ++x) {
x0 = splashFloor(matc[4]) + x * tBitmap->getWidth();
y0 = splashFloor(matc[5]) + y * tBitmap->getHeight();
splash->blitImage(tBitmap, true, x0, y0);
}
}
retValue = true;
} else {
retValue = splash->drawImage(&tilingBitmapSrc, nullptr, &imgData, colorMode, true, result_width, result_height, matc, false, true) == splashOk;
}
delete tBitmap;
delete gfx;
return retValue;
}
| 0
|
489,126
|
sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep,
const struct sctp_association *asoc,
const sctp_subtype_t type,
void *arg,
sctp_cmd_seq_t *commands)
{
struct sctp_chunk *chunk = arg;
struct sctp_ulpevent *ev;
if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
/* Make sure that the ERROR chunk has a valid length. */
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t)))
return sctp_sf_violation_chunklen(ep, asoc, type, arg,
commands);
while (chunk->chunk_end > chunk->skb->data) {
ev = sctp_ulpevent_make_remote_error(asoc, chunk, 0,
GFP_ATOMIC);
if (!ev)
goto nomem;
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
SCTP_ULPEVENT(ev));
sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,
SCTP_CHUNK(chunk));
}
return SCTP_DISPOSITION_CONSUME;
nomem:
return SCTP_DISPOSITION_NOMEM;
}
| 0
|
336,690
|
SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(void)
{
return (const char **) spice_server_char_device_recognized_subtypes_list;
}
| 0
|
218,754
|
static wchar_t *ConvertUTF8ToUTF16(const unsigned char *source)
{
size_t
length;
wchar_t
*utf16;
length=UTF8ToUTF16(source,(wchar_t *) NULL);
if (length == 0)
{
ssize_t
i;
/*
Not UTF-8, just copy.
*/
length=strlen((char *) source);
utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
if (utf16 == (wchar_t *) NULL)
return((wchar_t *) NULL);
for (i=0; i <= (ssize_t) length; i++)
utf16[i]=source[i];
return(utf16);
}
utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
if (utf16 == (wchar_t *) NULL)
return((wchar_t *) NULL);
length=UTF8ToUTF16(source,utf16);
return(utf16);
}
| 0
|
387,852
|
jint InstanceKlass::jvmti_class_status() const {
jint result = 0;
if (is_linked()) {
result |= JVMTI_CLASS_STATUS_VERIFIED | JVMTI_CLASS_STATUS_PREPARED;
}
if (is_initialized()) {
assert(is_linked(), "Class status is not consistent");
result |= JVMTI_CLASS_STATUS_INITIALIZED;
}
if (is_in_error_state()) {
result |= JVMTI_CLASS_STATUS_ERROR;
}
return result;
}
| 0
|
455,286
|
shell_is_restricted (name)
char *name;
{
char *temp;
if (restricted)
return 1;
temp = base_pathname (name);
if (*temp == '-')
temp++;
return (STREQ (temp, RESTRICTED_SHELL_NAME));
}
| 0
|
455,171
|
MOBI_RET mobi_parse_huff(MOBIHuffCdic *huffcdic, const MOBIPdbRecord *record) {
MOBIBuffer *buf = mobi_buffer_init_null(record->data, record->size);
if (buf == NULL) {
debug_print("%s\n", "Memory allocation failed");
return MOBI_MALLOC_FAILED;
}
char huff_magic[5];
mobi_buffer_getstring(huff_magic, buf, 4);
const size_t header_length = mobi_buffer_get32(buf);
if (strncmp(huff_magic, HUFF_MAGIC, 4) != 0 || header_length < HUFF_HEADER_LEN) {
debug_print("HUFF wrong magic: %s\n", huff_magic);
mobi_buffer_free_null(buf);
return MOBI_DATA_CORRUPT;
}
const size_t data1_offset = mobi_buffer_get32(buf);
const size_t data2_offset = mobi_buffer_get32(buf);
/* skip little-endian table offsets */
mobi_buffer_setpos(buf, data1_offset);
if (buf->offset + (256 * 4) > buf->maxlen) {
debug_print("%s", "HUFF data1 too short\n");
mobi_buffer_free_null(buf);
return MOBI_DATA_CORRUPT;
}
/* read 256 indices from data1 big-endian */
for (int i = 0; i < 256; i++) {
huffcdic->table1[i] = mobi_buffer_get32(buf);
}
mobi_buffer_setpos(buf, data2_offset);
if (buf->offset + (64 * 4) > buf->maxlen) {
debug_print("%s", "HUFF data2 too short\n");
mobi_buffer_free_null(buf);
return MOBI_DATA_CORRUPT;
}
/* read 32 mincode-maxcode pairs from data2 big-endian */
huffcdic->mincode_table[0] = 0;
huffcdic->maxcode_table[0] = 0xFFFFFFFF;
for (int i = 1; i < HUFF_CODETABLE_SIZE; i++) {
const uint32_t mincode = mobi_buffer_get32(buf);
const uint32_t maxcode = mobi_buffer_get32(buf);
huffcdic->mincode_table[i] = mincode << (32 - i);
huffcdic->maxcode_table[i] = ((maxcode + 1) << (32 - i)) - 1;
}
mobi_buffer_free_null(buf);
return MOBI_SUCCESS;
}
| 0
|
226,056
|
void metx_box_del(GF_Box *s)
{
GF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox*)s;
if (ptr == NULL) return;
gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);
if (ptr->content_encoding) gf_free(ptr->content_encoding);
if (ptr->xml_namespace) gf_free(ptr->xml_namespace);
if (ptr->xml_schema_loc) gf_free(ptr->xml_schema_loc);
if (ptr->mime_type) gf_free(ptr->mime_type);
gf_free(ptr);
| 0
|
198,703
|
int CLASS ljpeg_start (struct jhead *jh, int info_only)
{
int c, tag, len;
uchar data[0x10000];
const uchar *dp;
memset (jh, 0, sizeof *jh);
jh->restart = INT_MAX;
fread (data, 2, 1, ifp);
if (data[1] != 0xd8) return 0;
do {
fread (data, 2, 2, ifp);
tag = data[0] << 8 | data[1];
len = (data[2] << 8 | data[3]) - 2;
if (tag <= 0xff00) return 0;
fread (data, 1, len, ifp);
switch (tag) {
case 0xffc3:
jh->sraw = ((data[7] >> 4) * (data[7] & 15) - 1) & 3;
case 0xffc0:
jh->bits = data[0];
jh->high = data[1] << 8 | data[2];
jh->wide = data[3] << 8 | data[4];
jh->clrs = data[5] + jh->sraw;
if (len == 9 && !dng_version) getc(ifp);
break;
case 0xffc4:
if (info_only) break;
for (dp = data; dp < data+len && (c = *dp++) < 4; )
jh->free[c] = jh->huff[c] = make_decoder_ref (&dp);
break;
case 0xffda:
jh->psv = data[1+data[0]*2];
jh->bits -= data[3+data[0]*2] & 15;
break;
case 0xffdd:
jh->restart = data[0] << 8 | data[1];
}
} while (tag != 0xffda);
if (info_only) return 1;
if (jh->clrs > 6 || !jh->huff[0]) return 0;
FORC(5) if (!jh->huff[c+1]) jh->huff[c+1] = jh->huff[c];
if (jh->sraw) {
FORC(4) jh->huff[2+c] = jh->huff[1];
FORC(jh->sraw) jh->huff[1+c] = jh->huff[0];
}
jh->row = (ushort *) calloc (jh->wide*jh->clrs, 4);
merror (jh->row, "ljpeg_start()");
return zero_after_ff = 1;
}
| 1
|
482,653
|
static inline unsigned long ifname_compare_aligned(const char *_a,
const char *_b,
const char *_mask)
{
const unsigned long *a = (const unsigned long *)_a;
const unsigned long *b = (const unsigned long *)_b;
const unsigned long *mask = (const unsigned long *)_mask;
unsigned long ret;
ret = (a[0] ^ b[0]) & mask[0];
if (IFNAMSIZ > sizeof(unsigned long))
ret |= (a[1] ^ b[1]) & mask[1];
if (IFNAMSIZ > 2 * sizeof(unsigned long))
ret |= (a[2] ^ b[2]) & mask[2];
if (IFNAMSIZ > 3 * sizeof(unsigned long))
ret |= (a[3] ^ b[3]) & mask[3];
BUILD_BUG_ON(IFNAMSIZ > 4 * sizeof(unsigned long));
return ret;
}
| 0
|
225,954
|
/* SimpleTextSampleEntry */
GF_Box *txtc_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_TextConfigBox, GF_ISOM_BOX_TYPE_TXTC);
return (GF_Box *)tmp;
| 0
|
231,685
|
TEST_P(QuicServerTransportAllowMigrationTest, IgnoreInvalidPathResponse) {
auto data = IOBuf::copyBuffer("bad data");
auto packetData = packetToBuf(createStreamPacket(
*clientConnectionId,
*server->getConn().serverConnectionId,
clientNextAppDataPacketNum++,
2,
*data,
0 /* cipherOverhead */,
0 /* largestAcked */));
EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 0);
auto peerAddress = server->getConn().peerAddress;
folly::SocketAddress newPeer("100.101.102.103", 23456);
deliverData(std::move(packetData), false, &newPeer);
EXPECT_TRUE(server->getConn().pendingEvents.pathChallenge);
EXPECT_TRUE(server->getConn().pathValidationLimiter != nullptr);
EXPECT_EQ(server->getConn().peerAddress, newPeer);
EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1);
EXPECT_EQ(
server->getConn().migrationState.previousPeerAddresses.back(),
peerAddress);
loopForWrites();
EXPECT_FALSE(server->getConn().pendingEvents.pathChallenge);
EXPECT_TRUE(server->getConn().outstandingPathValidation);
EXPECT_TRUE(server->getConn().pendingEvents.schedulePathValidationTimeout);
EXPECT_TRUE(server->pathValidationTimeout().isScheduled());
ShortHeader header(
ProtectionType::KeyPhaseZero,
*server->getConn().serverConnectionId,
clientNextAppDataPacketNum++);
RegularQuicPacketBuilder builder(
server->getConn().udpSendPacketLen,
std::move(header),
0 /* largestAcked */);
builder.encodePacketHeader();
ASSERT_TRUE(builder.canBuildPacket());
writeSimpleFrame(
PathResponseFrame(
server->getConn().outstandingPathValidation->pathData ^ 1),
builder);
auto packet = std::move(builder).buildPacket();
deliverData(packetToBuf(packet), false, &newPeer);
EXPECT_TRUE(server->getConn().outstandingPathValidation);
EXPECT_TRUE(server->getConn().pendingEvents.schedulePathValidationTimeout);
EXPECT_TRUE(server->pathValidationTimeout().isScheduled());
}
| 0
|
238,808
|
searchit(
win_T *win, // window to search in; can be NULL for a
// buffer without a window!
buf_T *buf,
pos_T *pos,
pos_T *end_pos, // set to end of the match, unless NULL
int dir,
char_u *pat,
long count,
int options,
int pat_use, // which pattern to use when "pat" is empty
searchit_arg_T *extra_arg) // optional extra arguments, can be NULL
{
int found;
linenr_T lnum; // no init to shut up Apollo cc
colnr_T col;
regmmatch_T regmatch;
char_u *ptr;
colnr_T matchcol;
lpos_T endpos;
lpos_T matchpos;
int loop;
pos_T start_pos;
int at_first_line;
int extra_col;
int start_char_len;
int match_ok;
long nmatched;
int submatch = 0;
int first_match = TRUE;
int called_emsg_before = called_emsg;
#ifdef FEAT_SEARCH_EXTRA
int break_loop = FALSE;
#endif
linenr_T stop_lnum = 0; // stop after this line number when != 0
#ifdef FEAT_RELTIME
proftime_T *tm = NULL; // timeout limit or NULL
int *timed_out = NULL; // set when timed out or NULL
#endif
if (extra_arg != NULL)
{
stop_lnum = extra_arg->sa_stop_lnum;
#ifdef FEAT_RELTIME
tm = extra_arg->sa_tm;
timed_out = &extra_arg->sa_timed_out;
#endif
}
if (search_regcomp(pat, RE_SEARCH, pat_use,
(options & (SEARCH_HIS + SEARCH_KEEP)), ®match) == FAIL)
{
if ((options & SEARCH_MSG) && !rc_did_emsg)
semsg(_(e_invalid_search_string_str), mr_pattern);
return FAIL;
}
/*
* find the string
*/
do // loop for count
{
// When not accepting a match at the start position set "extra_col" to
// a non-zero value. Don't do that when starting at MAXCOL, since
// MAXCOL + 1 is zero.
if (pos->col == MAXCOL)
start_char_len = 0;
// Watch out for the "col" being MAXCOL - 2, used in a closed fold.
else if (has_mbyte
&& pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
&& pos->col < MAXCOL - 2)
{
ptr = ml_get_buf(buf, pos->lnum, FALSE);
if ((int)STRLEN(ptr) <= pos->col)
start_char_len = 1;
else
start_char_len = (*mb_ptr2len)(ptr + pos->col);
}
else
start_char_len = 1;
if (dir == FORWARD)
{
if (options & SEARCH_START)
extra_col = 0;
else
extra_col = start_char_len;
}
else
{
if (options & SEARCH_START)
extra_col = start_char_len;
else
extra_col = 0;
}
start_pos = *pos; // remember start pos for detecting no match
found = 0; // default: not found
at_first_line = TRUE; // default: start in first line
if (pos->lnum == 0) // correct lnum for when starting in line 0
{
pos->lnum = 1;
pos->col = 0;
at_first_line = FALSE; // not in first line now
}
/*
* Start searching in current line, unless searching backwards and
* we're in column 0.
* If we are searching backwards, in column 0, and not including the
* current position, gain some efficiency by skipping back a line.
* Otherwise begin the search in the current line.
*/
if (dir == BACKWARD && start_pos.col == 0
&& (options & SEARCH_START) == 0)
{
lnum = pos->lnum - 1;
at_first_line = FALSE;
}
else
lnum = pos->lnum;
for (loop = 0; loop <= 1; ++loop) // loop twice if 'wrapscan' set
{
for ( ; lnum > 0 && lnum <= buf->b_ml.ml_line_count;
lnum += dir, at_first_line = FALSE)
{
// Stop after checking "stop_lnum", if it's set.
if (stop_lnum != 0 && (dir == FORWARD
? lnum > stop_lnum : lnum < stop_lnum))
break;
#ifdef FEAT_RELTIME
// Stop after passing the "tm" time limit.
if (tm != NULL && profile_passed_limit(tm))
break;
#endif
/*
* Look for a match somewhere in line "lnum".
*/
col = at_first_line && (options & SEARCH_COL) ? pos->col
: (colnr_T)0;
nmatched = vim_regexec_multi(®match, win, buf,
lnum, col,
#ifdef FEAT_RELTIME
tm, timed_out
#else
NULL, NULL
#endif
);
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL)
break;
// Abort searching on an error (e.g., out of stack).
if (called_emsg > called_emsg_before
#ifdef FEAT_RELTIME
|| (timed_out != NULL && *timed_out)
#endif
)
break;
if (nmatched > 0)
{
// match may actually be in another line when using \zs
matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0];
#ifdef FEAT_EVAL
submatch = first_submatch(®match);
#endif
// "lnum" may be past end of buffer for "\n\zs".
if (lnum + matchpos.lnum > buf->b_ml.ml_line_count)
ptr = (char_u *)"";
else
ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
/*
* Forward search in the first line: match should be after
* the start position. If not, continue at the end of the
* match (this is vi compatible) or on the next char.
*/
if (dir == FORWARD && at_first_line)
{
match_ok = TRUE;
/*
* When the match starts in a next line it's certainly
* past the start position.
* When match lands on a NUL the cursor will be put
* one back afterwards, compare with that position,
* otherwise "/$" will get stuck on end of line.
*/
while (matchpos.lnum == 0
&& ((options & SEARCH_END) && first_match
? (nmatched == 1
&& (int)endpos.col - 1
< (int)start_pos.col + extra_col)
: ((int)matchpos.col
- (ptr[matchpos.col] == NUL)
< (int)start_pos.col + extra_col)))
{
/*
* If vi-compatible searching, continue at the end
* of the match, otherwise continue one position
* forward.
*/
if (vim_strchr(p_cpo, CPO_SEARCH) != NULL)
{
if (nmatched > 1)
{
// end is in next line, thus no match in
// this line
match_ok = FALSE;
break;
}
matchcol = endpos.col;
// for empty match: advance one char
if (matchcol == matchpos.col
&& ptr[matchcol] != NUL)
{
if (has_mbyte)
matchcol +=
(*mb_ptr2len)(ptr + matchcol);
else
++matchcol;
}
}
else
{
matchcol = matchpos.col;
if (ptr[matchcol] != NUL)
{
if (has_mbyte)
matchcol += (*mb_ptr2len)(ptr
+ matchcol);
else
++matchcol;
}
}
if (matchcol == 0 && (options & SEARCH_START))
break;
if (ptr[matchcol] == NUL
|| (nmatched = vim_regexec_multi(®match,
win, buf, lnum + matchpos.lnum,
matchcol,
#ifdef FEAT_RELTIME
tm, timed_out
#else
NULL, NULL
#endif
)) == 0)
{
match_ok = FALSE;
break;
}
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL)
break;
matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0];
# ifdef FEAT_EVAL
submatch = first_submatch(®match);
# endif
// Need to get the line pointer again, a
// multi-line search may have made it invalid.
ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
}
if (!match_ok)
continue;
}
if (dir == BACKWARD)
{
/*
* Now, if there are multiple matches on this line,
* we have to get the last one. Or the last one before
* the cursor, if we're on that line.
* When putting the new cursor at the end, compare
* relative to the end of the match.
*/
match_ok = FALSE;
for (;;)
{
// Remember a position that is before the start
// position, we use it if it's the last match in
// the line. Always accept a position after
// wrapping around.
if (loop
|| ((options & SEARCH_END)
? (lnum + regmatch.endpos[0].lnum
< start_pos.lnum
|| (lnum + regmatch.endpos[0].lnum
== start_pos.lnum
&& (int)regmatch.endpos[0].col - 1
< (int)start_pos.col
+ extra_col))
: (lnum + regmatch.startpos[0].lnum
< start_pos.lnum
|| (lnum + regmatch.startpos[0].lnum
== start_pos.lnum
&& (int)regmatch.startpos[0].col
< (int)start_pos.col
+ extra_col))))
{
match_ok = TRUE;
matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0];
# ifdef FEAT_EVAL
submatch = first_submatch(®match);
# endif
}
else
break;
/*
* We found a valid match, now check if there is
* another one after it.
* If vi-compatible searching, continue at the end
* of the match, otherwise continue one position
* forward.
*/
if (vim_strchr(p_cpo, CPO_SEARCH) != NULL)
{
if (nmatched > 1)
break;
matchcol = endpos.col;
// for empty match: advance one char
if (matchcol == matchpos.col
&& ptr[matchcol] != NUL)
{
if (has_mbyte)
matchcol +=
(*mb_ptr2len)(ptr + matchcol);
else
++matchcol;
}
}
else
{
// Stop when the match is in a next line.
if (matchpos.lnum > 0)
break;
matchcol = matchpos.col;
if (ptr[matchcol] != NUL)
{
if (has_mbyte)
matchcol +=
(*mb_ptr2len)(ptr + matchcol);
else
++matchcol;
}
}
if (ptr[matchcol] == NUL
|| (nmatched = vim_regexec_multi(®match,
win, buf, lnum + matchpos.lnum,
matchcol,
#ifdef FEAT_RELTIME
tm, timed_out
#else
NULL, NULL
#endif
)) == 0)
{
#ifdef FEAT_RELTIME
// If the search timed out, we did find a match
// but it might be the wrong one, so that's not
// OK.
if (timed_out != NULL && *timed_out)
match_ok = FALSE;
#endif
break;
}
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL)
break;
// Need to get the line pointer again, a
// multi-line search may have made it invalid.
ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
}
/*
* If there is only a match after the cursor, skip
* this match.
*/
if (!match_ok)
continue;
}
// With the SEARCH_END option move to the last character
// of the match. Don't do it for an empty match, end
// should be same as start then.
if ((options & SEARCH_END) && !(options & SEARCH_NOOF)
&& !(matchpos.lnum == endpos.lnum
&& matchpos.col == endpos.col))
{
// For a match in the first column, set the position
// on the NUL in the previous line.
pos->lnum = lnum + endpos.lnum;
pos->col = endpos.col;
if (endpos.col == 0)
{
if (pos->lnum > 1) // just in case
{
--pos->lnum;
pos->col = (colnr_T)STRLEN(ml_get_buf(buf,
pos->lnum, FALSE));
}
}
else
{
--pos->col;
if (has_mbyte
&& pos->lnum <= buf->b_ml.ml_line_count)
{
ptr = ml_get_buf(buf, pos->lnum, FALSE);
pos->col -= (*mb_head_off)(ptr, ptr + pos->col);
}
}
if (end_pos != NULL)
{
end_pos->lnum = lnum + matchpos.lnum;
end_pos->col = matchpos.col;
}
}
else
{
pos->lnum = lnum + matchpos.lnum;
pos->col = matchpos.col;
if (end_pos != NULL)
{
end_pos->lnum = lnum + endpos.lnum;
end_pos->col = endpos.col;
}
}
pos->coladd = 0;
if (end_pos != NULL)
end_pos->coladd = 0;
found = 1;
first_match = FALSE;
// Set variables used for 'incsearch' highlighting.
search_match_lines = endpos.lnum - matchpos.lnum;
search_match_endcol = endpos.col;
break;
}
line_breakcheck(); // stop if ctrl-C typed
if (got_int)
break;
#ifdef FEAT_SEARCH_EXTRA
// Cancel searching if a character was typed. Used for
// 'incsearch'. Don't check too often, that would slowdown
// searching too much.
if ((options & SEARCH_PEEK)
&& ((lnum - pos->lnum) & 0x3f) == 0
&& char_avail())
{
break_loop = TRUE;
break;
}
#endif
if (loop && lnum == start_pos.lnum)
break; // if second loop, stop where started
}
at_first_line = FALSE;
// vim_regexec_multi() may clear "regprog"
if (regmatch.regprog == NULL)
break;
/*
* Stop the search if wrapscan isn't set, "stop_lnum" is
* specified, after an interrupt, after a match and after looping
* twice.
*/
if (!p_ws || stop_lnum != 0 || got_int
|| called_emsg > called_emsg_before
#ifdef FEAT_RELTIME
|| (timed_out != NULL && *timed_out)
#endif
#ifdef FEAT_SEARCH_EXTRA
|| break_loop
#endif
|| found || loop)
break;
/*
* If 'wrapscan' is set we continue at the other end of the file.
* If 'shortmess' does not contain 's', we give a message.
* This message is also remembered in keep_msg for when the screen
* is redrawn. The keep_msg is cleared whenever another message is
* written.
*/
if (dir == BACKWARD) // start second loop at the other end
lnum = buf->b_ml.ml_line_count;
else
lnum = 1;
if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))
give_warning((char_u *)_(dir == BACKWARD
? top_bot_msg : bot_top_msg), TRUE);
if (extra_arg != NULL)
extra_arg->sa_wrapped = TRUE;
}
if (got_int || called_emsg > called_emsg_before
#ifdef FEAT_RELTIME
|| (timed_out != NULL && *timed_out)
#endif
#ifdef FEAT_SEARCH_EXTRA
|| break_loop
#endif
)
break;
}
while (--count > 0 && found); // stop after count matches or no match
vim_regfree(regmatch.regprog);
if (!found) // did not find it
{
if (got_int)
emsg(_(e_interrupted));
else if ((options & SEARCH_MSG) == SEARCH_MSG)
{
if (p_ws)
semsg(_(e_pattern_not_found_str), mr_pattern);
else if (lnum == 0)
semsg(_(e_search_hit_top_without_match_for_str), mr_pattern);
else
semsg(_(e_search_hit_bottom_without_match_for_str), mr_pattern);
}
return FAIL;
}
// A pattern like "\n\zs" may go past the last line.
if (pos->lnum > buf->b_ml.ml_line_count)
{
pos->lnum = buf->b_ml.ml_line_count;
pos->col = (int)STRLEN(ml_get_buf(buf, pos->lnum, FALSE));
if (pos->col > 0)
--pos->col;
}
return submatch + 1;
}
| 0
|
413,844
|
void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig,
Klass* current_klass,
Klass* sel_klass, TRAPS) {
Handle ref_loader(THREAD, current_klass->class_loader());
Handle sel_loader(THREAD, sel_klass->class_loader());
ResourceMark rm(THREAD); // needed for check_signature_loaders
Symbol* failed_type_symbol =
SystemDictionary::check_signature_loaders(sig,
/*klass_being_linked*/ NULL, // We are not linking class
ref_loader, sel_loader,
false);
if (failed_type_symbol != NULL) {
stringStream ss;
const char* failed_type_name = failed_type_symbol->as_klass_external_name();
ss.print("loader constraint violation: when resolving field \"%s\" of type %s, "
"the class loader %s of the current class, %s, "
"and the class loader %s for the field's defining %s, %s, "
"have different Class objects for type %s (%s; %s)",
field->as_C_string(),
failed_type_name,
current_klass->class_loader_data()->loader_name_and_id(),
current_klass->external_name(),
sel_klass->class_loader_data()->loader_name_and_id(),
sel_klass->external_kind(),
sel_klass->external_name(),
failed_type_name,
current_klass->class_in_module_of_loader(false, true),
sel_klass->class_in_module_of_loader(false, true));
THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string());
}
}
| 0
|
267,843
|
opfunc_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
{
const uint8_t *byte_code_p = frame_ctx_p->byte_code_p + 1;
uint8_t opcode = byte_code_p[-1];
uint32_t arguments_list_len;
if (opcode >= CBC_CALL0)
{
arguments_list_len = (unsigned int) ((opcode - CBC_CALL0) / 6);
}
else
{
arguments_list_len = *byte_code_p++;
}
bool is_call_prop = ((opcode - CBC_CALL) % 6) >= 3;
ecma_value_t *stack_top_p = frame_ctx_p->stack_top_p - arguments_list_len;
ecma_value_t this_value = is_call_prop ? stack_top_p[-3] : ECMA_VALUE_UNDEFINED;
ecma_value_t func_value = stack_top_p[-1];
ecma_value_t completion_value;
if (!ecma_is_value_object (func_value)
|| !ecma_op_object_is_callable (ecma_get_object_from_value (func_value)))
{
completion_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function));
}
else
{
ecma_object_t *func_obj_p = ecma_get_object_from_value (func_value);
completion_value = ecma_op_function_call (func_obj_p,
this_value,
stack_top_p,
arguments_list_len);
}
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_DIRECT_EVAL;
/* Free registers. */
for (uint32_t i = 0; i < arguments_list_len; i++)
{
ecma_fast_free_value (stack_top_p[i]);
}
if (is_call_prop)
{
ecma_free_value (*(--stack_top_p));
ecma_free_value (*(--stack_top_p));
}
if (JERRY_UNLIKELY (ECMA_IS_VALUE_ERROR (completion_value)))
{
#if JERRY_DEBUGGER
JERRY_CONTEXT (debugger_exception_byte_code_p) = frame_ctx_p->byte_code_p;
#endif /* JERRY_DEBUGGER */
frame_ctx_p->byte_code_p = (uint8_t *) vm_error_byte_code_p;
}
else
{
frame_ctx_p->byte_code_p = byte_code_p;
ecma_free_value (*(--stack_top_p));
uint32_t opcode_data = vm_decode_table[opcode];
if (!(opcode_data & (VM_OC_PUT_STACK | VM_OC_PUT_BLOCK)))
{
ecma_fast_free_value (completion_value);
}
else if (opcode_data & VM_OC_PUT_STACK)
{
*stack_top_p++ = completion_value;
}
else
{
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));
VM_GET_REGISTERS (frame_ctx_p)[0] = completion_value;
}
}
frame_ctx_p->stack_top_p = stack_top_p;
} /* opfunc_call */
| 0
|
432,195
|
void memory_region_init_io(struct uc_struct *uc,
MemoryRegion *mr,
const MemoryRegionOps *ops,
void *opaque,
uint64_t size)
{
memory_region_init(uc, mr, size);
mr->ops = ops ? ops : &unassigned_mem_ops;
mr->opaque = opaque;
mr->terminates = true;
}
| 0
|
252,352
|
int mz_deflateInit(mz_streamp pStream, int level) {
return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9,
MZ_DEFAULT_STRATEGY);
}
| 0
|
439,059
|
static Image *ReadTEXTImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
filename[MaxTextExtent],
geometry[MaxTextExtent],
*p,
text[MaxTextExtent];
DrawInfo
*draw_info;
Image
*image,
*texture;
MagickBooleanType
status;
PointInfo
delta;
RectangleInfo
page;
ssize_t
offset;
TypeMetric
metrics;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
(void) memset(text,0,sizeof(text));
(void) ReadBlobString(image,text);
/*
Set the page geometry.
*/
delta.x=DefaultResolution;
delta.y=DefaultResolution;
if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))
{
GeometryInfo
geometry_info;
MagickStatusType
flags;
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
image->x_resolution=geometry_info.rho;
image->y_resolution=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
image->y_resolution=image->x_resolution;
}
page.width=612;
page.height=792;
page.x=43;
page.y=43;
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
/*
Initialize Image structure.
*/
image->columns=(size_t) floor((((double) page.width*image->x_resolution)/
delta.x)+0.5);
image->rows=(size_t) floor((((double) page.height*image->y_resolution)/
delta.y)+0.5);
status=SetImageExtent(image,image->columns,image->rows);
if (status != MagickFalse)
status=ResetImagePixels(image,&image->exception);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
image->page.x=0;
image->page.y=0;
texture=(Image *) NULL;
if (image_info->texture != (char *) NULL)
{
ImageInfo
*read_info;
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) CopyMagickString(read_info->filename,image_info->texture,
MaxTextExtent);
texture=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
}
/*
Annotate the text image.
*/
(void) SetImageBackgroundColor(image);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
(void) CloneString(&draw_info->text,image_info->filename);
(void) FormatLocaleString(geometry,MaxTextExtent,"%gx%g%+g%+g",(double)
image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
status=GetTypeMetrics(image,draw_info,&metrics);
if (status == MagickFalse)
{
draw_info=DestroyDrawInfo(draw_info);
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
}
page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5);
(void) FormatLocaleString(geometry,MaxTextExtent,"%gx%g%+g%+g",(double)
image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
(void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
if (*draw_info->text != '\0')
*draw_info->text='\0';
p=text;
for (offset=2*page.y; p != (char *) NULL; )
{
/*
Annotate image with text.
*/
(void) ConcatenateString(&draw_info->text,text);
(void) ConcatenateString(&draw_info->text,"\n");
offset+=(ssize_t) (metrics.ascent-metrics.descent);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset,
image->rows);
if (status == MagickFalse)
break;
}
p=ReadBlobString(image,text);
if ((offset < (ssize_t) image->rows) && (p != (char *) NULL))
continue;
if (texture != (Image *) NULL)
{
MagickProgressMonitor
progress_monitor;
progress_monitor=SetImageProgressMonitor(image,
(MagickProgressMonitor) NULL,image->client_data);
(void) TextureImage(image,texture);
(void) SetImageProgressMonitor(image,progress_monitor,
image->client_data);
}
(void) AnnotateImage(image,draw_info);
if (p == (char *) NULL)
break;
/*
Page is full-- allocate next image structure.
*/
*draw_info->text='\0';
offset=2*page.y;
AcquireNextImage(image_info,image);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
image->next->columns=image->columns;
image->next->rows=image->rows;
image=SyncNextImageInList(image);
(void) CopyMagickString(image->filename,filename,MaxTextExtent);
(void) SetImageBackgroundColor(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
if (texture != (Image *) NULL)
{
MagickProgressMonitor
progress_monitor;
progress_monitor=SetImageProgressMonitor(image,
(MagickProgressMonitor) NULL,image->client_data);
(void) TextureImage(image,texture);
(void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
}
(void) AnnotateImage(image,draw_info);
if (texture != (Image *) NULL)
texture=DestroyImage(texture);
draw_info=DestroyDrawInfo(draw_info);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
| 0
|
512,849
|
void set_typelib(TYPELIB *typelib)
{
// Non-field Items (e.g. hybrid functions) never have ENUM/SET types yet.
DBUG_ASSERT(0);
}
| 0
|
502,714
|
int ssl_get_new_session(SSL *s, int session)
{
/* This gets used by clients and servers. */
unsigned int tmp;
SSL_SESSION *ss = NULL;
GEN_SESSION_CB cb = def_generate_session_id;
if ((ss = SSL_SESSION_new()) == NULL)
return (0);
/* If the context has a default timeout, use it */
if (s->session_ctx->session_timeout == 0)
ss->timeout = SSL_get_default_timeout(s);
else
ss->timeout = s->session_ctx->session_timeout;
if (s->session != NULL) {
SSL_SESSION_free(s->session);
s->session = NULL;
}
if (session) {
if (s->version == SSL2_VERSION) {
ss->ssl_version = SSL2_VERSION;
ss->session_id_length = SSL2_SSL_SESSION_ID_LENGTH;
} else if (s->version == SSL3_VERSION) {
ss->ssl_version = SSL3_VERSION;
ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
} else if (s->version == TLS1_VERSION) {
ss->ssl_version = TLS1_VERSION;
ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
} else if (s->version == TLS1_1_VERSION) {
ss->ssl_version = TLS1_1_VERSION;
ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
} else if (s->version == TLS1_2_VERSION) {
ss->ssl_version = TLS1_2_VERSION;
ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
} else if (s->version == DTLS1_BAD_VER) {
ss->ssl_version = DTLS1_BAD_VER;
ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
} else if (s->version == DTLS1_VERSION) {
ss->ssl_version = DTLS1_VERSION;
ss->session_id_length = SSL3_SSL_SESSION_ID_LENGTH;
} else {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_UNSUPPORTED_SSL_VERSION);
SSL_SESSION_free(ss);
return (0);
}
#ifndef OPENSSL_NO_TLSEXT
/*-
* If RFC5077 ticket, use empty session ID (as server).
* Note that:
* (a) ssl_get_prev_session() does lookahead into the
* ClientHello extensions to find the session ticket.
* When ssl_get_prev_session() fails, s3_srvr.c calls
* ssl_get_new_session() in ssl3_get_client_hello().
* At that point, it has not yet parsed the extensions,
* however, because of the lookahead, it already knows
* whether a ticket is expected or not.
*
* (b) s3_clnt.c calls ssl_get_new_session() before parsing
* ServerHello extensions, and before recording the session
* ID received from the server, so this block is a noop.
*/
if (s->tlsext_ticket_expected) {
ss->session_id_length = 0;
goto sess_id_done;
}
#endif
/* Choose which callback will set the session ID */
CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX);
if (s->generate_session_id)
cb = s->generate_session_id;
else if (s->session_ctx->generate_session_id)
cb = s->session_ctx->generate_session_id;
CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX);
/* Choose a session ID */
tmp = ss->session_id_length;
if (!cb(s, ss->session_id, &tmp)) {
/* The callback failed */
SSLerr(SSL_F_SSL_GET_NEW_SESSION,
SSL_R_SSL_SESSION_ID_CALLBACK_FAILED);
SSL_SESSION_free(ss);
return (0);
}
/*
* Don't allow the callback to set the session length to zero. nor
* set it higher than it was.
*/
if (!tmp || (tmp > ss->session_id_length)) {
/* The callback set an illegal length */
SSLerr(SSL_F_SSL_GET_NEW_SESSION,
SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH);
SSL_SESSION_free(ss);
return (0);
}
/* If the session length was shrunk and we're SSLv2, pad it */
if ((tmp < ss->session_id_length) && (s->version == SSL2_VERSION))
memset(ss->session_id + tmp, 0, ss->session_id_length - tmp);
else
ss->session_id_length = tmp;
/* Finally, check for a conflict */
if (SSL_has_matching_session_id(s, ss->session_id,
ss->session_id_length)) {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, SSL_R_SSL_SESSION_ID_CONFLICT);
SSL_SESSION_free(ss);
return (0);
}
#ifndef OPENSSL_NO_TLSEXT
sess_id_done:
if (s->tlsext_hostname) {
ss->tlsext_hostname = BUF_strdup(s->tlsext_hostname);
if (ss->tlsext_hostname == NULL) {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);
SSL_SESSION_free(ss);
return 0;
}
}
# ifndef OPENSSL_NO_EC
if (s->tlsext_ecpointformatlist) {
if (ss->tlsext_ecpointformatlist != NULL)
OPENSSL_free(ss->tlsext_ecpointformatlist);
if ((ss->tlsext_ecpointformatlist =
OPENSSL_malloc(s->tlsext_ecpointformatlist_length)) ==
NULL) {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_MALLOC_FAILURE);
SSL_SESSION_free(ss);
return 0;
}
ss->tlsext_ecpointformatlist_length =
s->tlsext_ecpointformatlist_length;
memcpy(ss->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist,
s->tlsext_ecpointformatlist_length);
}
if (s->tlsext_ellipticcurvelist) {
if (ss->tlsext_ellipticcurvelist != NULL)
OPENSSL_free(ss->tlsext_ellipticcurvelist);
if ((ss->tlsext_ellipticcurvelist =
OPENSSL_malloc(s->tlsext_ellipticcurvelist_length)) ==
NULL) {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_MALLOC_FAILURE);
SSL_SESSION_free(ss);
return 0;
}
ss->tlsext_ellipticcurvelist_length =
s->tlsext_ellipticcurvelist_length;
memcpy(ss->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist,
s->tlsext_ellipticcurvelist_length);
}
# endif
#endif
} else {
ss->session_id_length = 0;
}
if (s->sid_ctx_length > sizeof ss->sid_ctx) {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);
SSL_SESSION_free(ss);
return 0;
}
memcpy(ss->sid_ctx, s->sid_ctx, s->sid_ctx_length);
ss->sid_ctx_length = s->sid_ctx_length;
s->session = ss;
ss->ssl_version = s->version;
ss->verify_result = X509_V_OK;
return (1);
}
| 0
|
502,702
|
SSL_SESSION *SSL_SESSION_new(void)
{
SSL_SESSION *ss;
ss = (SSL_SESSION *)OPENSSL_malloc(sizeof(SSL_SESSION));
if (ss == NULL) {
SSLerr(SSL_F_SSL_SESSION_NEW, ERR_R_MALLOC_FAILURE);
return (0);
}
memset(ss, 0, sizeof(SSL_SESSION));
ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */
ss->references = 1;
ss->timeout = 60 * 5 + 4; /* 5 minute timeout by default */
ss->time = (unsigned long)time(NULL);
ss->prev = NULL;
ss->next = NULL;
ss->compress_meth = 0;
#ifndef OPENSSL_NO_TLSEXT
ss->tlsext_hostname = NULL;
# ifndef OPENSSL_NO_EC
ss->tlsext_ecpointformatlist_length = 0;
ss->tlsext_ecpointformatlist = NULL;
ss->tlsext_ellipticcurvelist_length = 0;
ss->tlsext_ellipticcurvelist = NULL;
# endif
#endif
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data);
#ifndef OPENSSL_NO_PSK
ss->psk_identity_hint = NULL;
ss->psk_identity = NULL;
#endif
#ifndef OPENSSL_NO_SRP
ss->srp_username = NULL;
#endif
return (ss);
}
| 0
|
402,640
|
wrap_in_set(cms_context *cms, SECItem *der, SECItem **items)
{
void *ret;
ret = SEC_ASN1EncodeItem(cms->arena, der, &items, &SetTemplate);
if (ret == NULL)
cmsreterr(-1, cms, "could not encode set");
return 0;
}
| 0
|
225,502
|
Status MutableGraphView::UpdateFanoutsInternal(NodeDef* from_node,
NodeDef* to_node) {
VLOG(2) << absl::Substitute("Update fanouts from '$0' to '$1'.",
from_node->name(), to_node->name());
if (from_node == to_node) {
return Status::OK();
}
// Update internal state with the new output_port->input_port edge.
const auto add_edge = [this](const OutputPort& output_port,
const InputPort& input_port) {
fanouts()[output_port].insert(input_port);
};
// Remove invalidated edge from the internal state.
const auto remove_edge = [this](const OutputPort& output_port,
const InputPort& input_port) {
fanouts()[output_port].erase(input_port);
};
// For the control fanouts we do not know the input index in a NodeDef,
// so we have to traverse all control inputs.
auto control_fanouts =
GetFanout(GraphView::OutputPort(from_node, Graph::kControlSlot));
bool to_node_is_switch = IsSwitch(*to_node);
for (const InputPort& control_port : control_fanouts) {
// Node can't be control dependency of itself.
if (control_port.node == to_node) continue;
// Can't add Switch node as a control dependency.
if (to_node_is_switch) {
// Trying to add a Switch as a control dependency, which if allowed will
// make the graph invalid.
return UpdateFanoutsError(from_node->name(), to_node->name())(
absl::Substitute("can't update fanouts to node '$0' as it will "
"become a Switch control dependency",
to_node->name()));
}
NodeDef* node = control_port.node;
RemoveControllingFaninInternal(node, from_node);
AddFaninInternal(node, {to_node, Graph::kControlSlot});
}
// First we update regular fanouts. For the regular fanouts
// `input_port:port_id` is the input index in NodeDef.
auto regular_edges =
GetFanoutEdges(*from_node, /*include_controlled_edges=*/false);
// Maximum index of the `from_node` output tensor that is still used as an
// input to some other node.
int keep_max_regular_output_port = -1;
for (const Edge& edge : regular_edges) {
const OutputPort output_port = edge.src;
const InputPort input_port = edge.dst;
// If the `to_node` reads from the `from_node`, skip this edge (see
// AddAndUpdateFanoutsWithoutSelfLoops test for an example).
if (input_port.node == to_node) {
keep_max_regular_output_port =
std::max(keep_max_regular_output_port, output_port.port_id);
continue;
}
// Update input at destination node.
input_port.node->set_input(
input_port.port_id,
TensorIdToString({to_node->name(), output_port.port_id}));
// Remove old edge between the `from_node` and the fanout node.
remove_edge(output_port, input_port);
// Add an edge between the `to_node` and new fanout node.
add_edge(OutputPort(to_node, output_port.port_id), input_port);
// Dedup control dependency.
if (CanDedupControlWithRegularInput(*this, *to_node)) {
RemoveControllingFaninInternal(input_port.node, to_node);
}
}
// Because we update all regular fanouts of `from_node`, we can just copy
// the value `num_regular_outputs`.
max_regular_output_port()[to_node] = max_regular_output_port()[from_node];
// Check if all fanouts were updated to read from the `to_node`.
if (keep_max_regular_output_port >= 0) {
max_regular_output_port()[from_node] = keep_max_regular_output_port;
} else {
max_regular_output_port().erase(from_node);
}
return Status::OK();
}
| 0
|
226,008
|
void dac3_box_del(GF_Box *s)
{
GF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;
gf_free(ptr);
| 0
|
359,209
|
static __poll_t ringbuf_map_poll(struct bpf_map *map, struct file *filp,
struct poll_table_struct *pts)
{
struct bpf_ringbuf_map *rb_map;
rb_map = container_of(map, struct bpf_ringbuf_map, map);
poll_wait(filp, &rb_map->rb->waitq, pts);
if (ringbuf_avail_data_sz(rb_map->rb))
return EPOLLIN | EPOLLRDNORM;
return 0;
}
| 0
|
343,324
|
static void addreply_newline(const char * const str, const size_t size)
{
struct reply *newline;
if ((newline = (struct reply *) malloc(offsetof(struct reply, line) +
size)) == NULL) {
die_mem();
}
if (firstreply == NULL) {
firstreply = newline;
} else {
lastreply->next = newline;
}
newline->next = NULL;
lastreply = newline;
memcpy(newline->line, str, size);
}
| 0
|
255,574
|
njs_module_path(njs_vm_t *vm, const njs_str_t *dir, njs_module_info_t *info)
{
char *p;
size_t length;
njs_bool_t trail;
char src[NJS_MAX_PATH + 1];
trail = 0;
length = info->name.length;
if (dir != NULL) {
length += dir->length;
if (length == 0) {
return NJS_DECLINED;
}
trail = (dir->start[dir->length - 1] != '/');
if (trail) {
length++;
}
}
if (njs_slow_path(length > NJS_MAX_PATH)) {
return NJS_ERROR;
}
p = &src[0];
if (dir != NULL) {
p = (char *) njs_cpymem(p, dir->start, dir->length);
if (trail) {
*p++ = '/';
}
}
p = (char *) njs_cpymem(p, info->name.start, info->name.length);
*p = '\0';
p = realpath(&src[0], &info->path[0]);
if (p == NULL) {
return NJS_DECLINED;
}
info->fd = open(&info->path[0], O_RDONLY);
if (info->fd < 0) {
return NJS_DECLINED;
}
info->file.start = (u_char *) &info->path[0];
info->file.length = njs_strlen(info->file.start);
return NJS_OK;
}
| 0
|
432,347
|
static void i2c_ddc_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc);
dc->reset = i2c_ddc_reset;
dc->vmsd = &vmstate_i2c_ddc;
dc->props = i2c_ddc_properties;
isc->event = i2c_ddc_event;
isc->recv = i2c_ddc_rx;
isc->send = i2c_ddc_tx;
}
| 0
|
353,169
|
void SplashOutputDev::clipToStrokePath(GfxState *state) {
SplashPath *path2;
SplashPath path = convertPath(state, state->getPath(), false);
path2 = splash->makeStrokePath(&path, state->getLineWidth());
splash->clipToPath(path2, false);
delete path2;
}
| 0
|
389,738
|
typval_compare_func(
typval_T *tv1,
typval_T *tv2,
exprtype_T type,
int ic,
int *res)
{
int val = 0;
if (type != EXPR_EQUAL && type != EXPR_NEQUAL
&& type != EXPR_IS && type != EXPR_ISNOT)
{
emsg(_(e_invalid_operation_for_funcrefs));
return FAIL;
}
if ((tv1->v_type == VAR_PARTIAL && tv1->vval.v_partial == NULL)
|| (tv2->v_type == VAR_PARTIAL && tv2->vval.v_partial == NULL))
// When both partials are NULL, then they are equal.
// Otherwise they are not equal.
val = (tv1->vval.v_partial == tv2->vval.v_partial);
else if (type == EXPR_IS || type == EXPR_ISNOT)
{
if (tv1->v_type == VAR_FUNC && tv2->v_type == VAR_FUNC)
// strings are considered the same if their value is
// the same
val = tv_equal(tv1, tv2, ic, FALSE);
else if (tv1->v_type == VAR_PARTIAL && tv2->v_type == VAR_PARTIAL)
val = (tv1->vval.v_partial == tv2->vval.v_partial);
else
val = FALSE;
}
else
val = tv_equal(tv1, tv2, ic, FALSE);
if (type == EXPR_NEQUAL || type == EXPR_ISNOT)
val = !val;
*res = val;
return OK;
}
| 0
|
195,402
|
int TfLiteIntArrayGetSizeInBytes(int size) {
static TfLiteIntArray dummy;
int computed_size = sizeof(dummy) + sizeof(dummy.data[0]) * size;
#if defined(_MSC_VER)
// Context for why this is needed is in http://b/189926408#comment21
computed_size -= sizeof(dummy.data[0]);
#endif
return computed_size;
}
| 1
|
225,408
|
static int vidioc_enum_frameintervals(struct file *file, void *fh,
struct v4l2_frmivalenum *argp)
{
struct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);
struct v4l2_loopback_opener *opener = fh_to_opener(fh);
if (dev->ready_for_capture) {
if (opener->vidioc_enum_frameintervals_calls > 0)
return -EINVAL;
if (argp->width == dev->pix_format.width &&
argp->height == dev->pix_format.height) {
argp->type = V4L2_FRMIVAL_TYPE_DISCRETE;
argp->discrete = dev->capture_param.timeperframe;
opener->vidioc_enum_frameintervals_calls++;
return 0;
}
return -EINVAL;
}
return 0;
}
| 0
|
481,285
|
struct mlx5_fpga_conn *mlx5_fpga_conn_create(struct mlx5_fpga_device *fdev,
struct mlx5_fpga_conn_attr *attr,
enum mlx5_ifc_fpga_qp_type qp_type)
{
struct mlx5_fpga_conn *ret, *conn;
u8 *remote_mac, *remote_ip;
int err;
if (!attr->recv_cb)
return ERR_PTR(-EINVAL);
conn = kzalloc(sizeof(*conn), GFP_KERNEL);
if (!conn)
return ERR_PTR(-ENOMEM);
conn->fdev = fdev;
INIT_LIST_HEAD(&conn->qp.sq.backlog);
spin_lock_init(&conn->qp.sq.lock);
conn->recv_cb = attr->recv_cb;
conn->cb_arg = attr->cb_arg;
remote_mac = MLX5_ADDR_OF(fpga_qpc, conn->fpga_qpc, remote_mac_47_32);
err = mlx5_query_mac_address(fdev->mdev, remote_mac);
if (err) {
mlx5_fpga_err(fdev, "Failed to query local MAC: %d\n", err);
ret = ERR_PTR(err);
goto err;
}
/* Build Modified EUI-64 IPv6 address from the MAC address */
remote_ip = MLX5_ADDR_OF(fpga_qpc, conn->fpga_qpc, remote_ip);
remote_ip[0] = 0xfe;
remote_ip[1] = 0x80;
addrconf_addr_eui48(&remote_ip[8], remote_mac);
err = mlx5_core_reserved_gid_alloc(fdev->mdev, &conn->qp.sgid_index);
if (err) {
mlx5_fpga_err(fdev, "Failed to allocate SGID: %d\n", err);
ret = ERR_PTR(err);
goto err;
}
err = mlx5_core_roce_gid_set(fdev->mdev, conn->qp.sgid_index,
MLX5_ROCE_VERSION_2,
MLX5_ROCE_L3_TYPE_IPV6,
remote_ip, remote_mac, true, 0,
MLX5_FPGA_PORT_NUM);
if (err) {
mlx5_fpga_err(fdev, "Failed to set SGID: %d\n", err);
ret = ERR_PTR(err);
goto err_rsvd_gid;
}
mlx5_fpga_dbg(fdev, "Reserved SGID index %u\n", conn->qp.sgid_index);
/* Allow for one cqe per rx/tx wqe, plus one cqe for the next wqe,
* created during processing of the cqe
*/
err = mlx5_fpga_conn_create_cq(conn,
(attr->tx_size + attr->rx_size) * 2);
if (err) {
mlx5_fpga_err(fdev, "Failed to create CQ: %d\n", err);
ret = ERR_PTR(err);
goto err_gid;
}
mlx5_fpga_conn_arm_cq(conn);
err = mlx5_fpga_conn_create_qp(conn, attr->tx_size, attr->rx_size);
if (err) {
mlx5_fpga_err(fdev, "Failed to create QP: %d\n", err);
ret = ERR_PTR(err);
goto err_cq;
}
MLX5_SET(fpga_qpc, conn->fpga_qpc, state, MLX5_FPGA_QPC_STATE_INIT);
MLX5_SET(fpga_qpc, conn->fpga_qpc, qp_type, qp_type);
MLX5_SET(fpga_qpc, conn->fpga_qpc, st, MLX5_FPGA_QPC_ST_RC);
MLX5_SET(fpga_qpc, conn->fpga_qpc, ether_type, ETH_P_8021Q);
MLX5_SET(fpga_qpc, conn->fpga_qpc, vid, 0);
MLX5_SET(fpga_qpc, conn->fpga_qpc, next_rcv_psn, 1);
MLX5_SET(fpga_qpc, conn->fpga_qpc, next_send_psn, 0);
MLX5_SET(fpga_qpc, conn->fpga_qpc, pkey, MLX5_FPGA_PKEY);
MLX5_SET(fpga_qpc, conn->fpga_qpc, remote_qpn, conn->qp.mqp.qpn);
MLX5_SET(fpga_qpc, conn->fpga_qpc, rnr_retry, 7);
MLX5_SET(fpga_qpc, conn->fpga_qpc, retry_count, 7);
err = mlx5_fpga_create_qp(fdev->mdev, &conn->fpga_qpc,
&conn->fpga_qpn);
if (err) {
mlx5_fpga_err(fdev, "Failed to create FPGA RC QP: %d\n", err);
ret = ERR_PTR(err);
goto err_qp;
}
err = mlx5_fpga_conn_connect(conn);
if (err) {
ret = ERR_PTR(err);
goto err_conn;
}
mlx5_fpga_dbg(fdev, "FPGA QPN is %u\n", conn->fpga_qpn);
ret = conn;
goto out;
err_conn:
mlx5_fpga_destroy_qp(conn->fdev->mdev, conn->fpga_qpn);
err_qp:
mlx5_fpga_conn_destroy_qp(conn);
err_cq:
mlx5_fpga_conn_destroy_cq(conn);
err_gid:
mlx5_core_roce_gid_set(fdev->mdev, conn->qp.sgid_index, 0, 0, NULL,
NULL, false, 0, MLX5_FPGA_PORT_NUM);
err_rsvd_gid:
mlx5_core_reserved_gid_free(fdev->mdev, conn->qp.sgid_index);
err:
kfree(conn);
out:
return ret;
}
| 0
|
486,810
|
static inline unsigned tx_desc_get_last(uint32_t *desc)
{
return (desc[1] & DESC_1_TX_LAST) ? 1 : 0;
}
| 0
|
252,344
|
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip,
const char *pArchive_filename,
const char *pDst_filename,
mz_uint flags) {
int file_index =
mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags);
if (file_index < 0) return MZ_FALSE;
return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags);
}
| 0
|
513,086
|
Item *get_copy(THD *thd)
{ return get_item_copy<Item_ref>(thd, this); }
| 0
|
273,054
|
ringbuffer_read(uint8_t **dst, size_t dstlen, struct ringbuffer *buf)
{
int remaining;
*dst = buf->buffer + buf->read_pos;
if (buf->read_avail == 0 || dstlen == 0)
return 0;
remaining = buf->size - buf->read_pos;
// The number of bytes we will return will be MIN(dstlen, remaining, read_avail)
if (dstlen > remaining)
dstlen = remaining;
if (dstlen > buf->read_avail)
dstlen = buf->read_avail;
buf->read_pos = (buf->read_pos + dstlen) % buf->size;
buf->write_avail += dstlen;
buf->read_avail -= dstlen;
return dstlen;
}
| 0
|
329,908
|
_inplace_spans (void *abstract_renderer,
int y, int h,
const cairo_half_open_span_t *spans,
unsigned num_spans)
{
cairo_image_span_renderer_t *r = abstract_renderer;
uint8_t *mask;
int x0, x1;
if (num_spans == 0)
return CAIRO_STATUS_SUCCESS;
if (num_spans == 2 && spans[0].coverage == 0xff) {
pixman_image_composite32 (r->op, r->src, NULL, r->u.composite.dst,
spans[0].x + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
spans[0].x, y,
spans[1].x - spans[0].x, h);
return CAIRO_STATUS_SUCCESS;
}
mask = (uint8_t *)pixman_image_get_data (r->mask);
x1 = x0 = spans[0].x;
do {
int len = spans[1].x - spans[0].x;
*mask++ = spans[0].coverage;
if (len > 1) {
if (len >= r->u.composite.run_length && spans[0].coverage == 0xff) {
if (x1 != x0) {
pixman_image_composite32 (r->op, r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
x1 - x0, h);
}
pixman_image_composite32 (r->op, r->src, NULL, r->u.composite.dst,
spans[0].x + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
spans[0].x, y,
len, h);
mask = (uint8_t *)pixman_image_get_data (r->mask);
x0 = spans[1].x;
} else if (spans[0].coverage == 0x0 &&
x1 - x0 > r->u.composite.run_length) {
pixman_image_composite32 (r->op, r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
x1 - x0, h);
mask = (uint8_t *)pixman_image_get_data (r->mask);
x0 = spans[1].x;
}else {
memset (mask, spans[0].coverage, --len);
mask += len;
}
}
x1 = spans[1].x;
spans++;
} while (--num_spans > 1);
if (x1 != x0) {
pixman_image_composite32 (r->op, r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
x1 - x0, h);
}
return CAIRO_STATUS_SUCCESS;
}
| 0
|
232,337
|
void gf_isom_box_del_parent(GF_List **child_boxes, GF_Box*b)
{
if (child_boxes) {
gf_list_del_item(*child_boxes, b);
if (!gf_list_count(*child_boxes)) {
gf_list_del(*child_boxes);
*child_boxes = NULL;
}
}
gf_isom_box_del(b);
| 0
|
364,789
|
tagstack_set_curidx(win_T *wp, int curidx)
{
wp->w_tagstackidx = curidx;
if (wp->w_tagstackidx < 0) // sanity check
wp->w_tagstackidx = 0;
if (wp->w_tagstackidx > wp->w_tagstacklen)
wp->w_tagstackidx = wp->w_tagstacklen;
}
| 0
|
234,200
|
add_shndx_to_cu_tu_entry (unsigned int shndx)
{
if (shndx_pool_used >= shndx_pool_size)
{
error (_("Internal error: out of space in the shndx pool.\n"));
return;
}
shndx_pool [shndx_pool_used++] = shndx;
}
| 0
|
270,406
|
static bool ok_inflater_stored_block_header(ok_inflater *inflater) {
ok_inflater_skip_byte_align(inflater);
if (!ok_inflater_load_bits(inflater, 32)) {
return false;
} else {
uint32_t len = ok_inflater_read_bits(inflater, 16);
uint32_t clen = ok_inflater_read_bits(inflater, 16);
if ((len & 0xffff) != ((~clen) & 0xffff)) {
ok_inflater_error(inflater, "Invalid stored block");
return false;
} else if (len == 0) {
inflater->state = OK_INFLATER_STATE_READY_FOR_NEXT_BLOCK;
return true;
} else {
inflater->state = OK_INFLATER_STATE_READING_STORED_BLOCK;
inflater->state_count = (int)len;
return true;
}
}
}
| 0
|
248,258
|
static cfg_opt_t *cfg_getopt_array(cfg_opt_t *rootopts, int cfg_flags, const char *name)
{
unsigned int i;
cfg_opt_t *opts = rootopts;
if (!rootopts || !name) {
errno = EINVAL;
return NULL;
}
while (name && *name) {
cfg_t *seccfg;
char *secname;
size_t len = strcspn(name, "|");
if (name[len] == 0 /*len == strlen(name) */ )
/* no more subsections */
break;
if (len) {
cfg_opt_t *secopt;
secname = strndup(name, len);
if (!secname)
return NULL;
secopt = cfg_getopt_array(opts, cfg_flags, secname);
free(secname);
if (!secopt) {
/*fprintf(stderr, "section not found\n"); */
return NULL;
}
if (secopt->type != CFGT_SEC) {
/*fprintf(stderr, "not a section!\n"); */
return NULL;
}
if (!is_set(CFGF_MULTI, secopt->flags) && (seccfg = cfg_opt_getnsec(secopt, 0)) != NULL)
opts = seccfg->opts;
else
opts = secopt->subopts;
if (!opts) {
/*fprintf(stderr, "section have no subopts!?\n"); */
return NULL;
}
}
name += len;
name += strspn(name, "|");
}
for (i = 0; opts[i].name; i++) {
if (is_set(CFGF_NOCASE, cfg_flags)) {
if (strcasecmp(opts[i].name, name) == 0)
return &opts[i];
} else {
if (strcmp(opts[i].name, name) == 0)
return &opts[i];
}
}
return NULL;
}
| 0
|
393,520
|
static SQInteger array_append(HSQUIRRELVM v)
{
return SQ_SUCCEEDED(sq_arrayappend(v,-2)) ? 1 : SQ_ERROR;
}
| 0
|
270,376
|
static bool ok_png_read_data(ok_png_decoder *decoder, uint32_t bytes_remaining) {
ok_png *png = decoder->png;
size_t inflate_buffer_size = 64 * 1024;
size_t num_passes = decoder->interlace_method == 0 ? 1 : 7;
uint8_t bits_per_pixel = decoder->bit_depth * OK_PNG_SAMPLES_PER_PIXEL[decoder->color_type];
uint8_t bytes_per_pixel = (bits_per_pixel + 7) / 8;
uint64_t max_bytes_per_scanline = 1 + ((uint64_t)png->width * bits_per_pixel + 7) / 8;
size_t platform_max_bytes_per_scanline = (size_t)max_bytes_per_scanline;
// Create buffers
if (!png->data) {
if (decoder->allocator.image_alloc) {
decoder->allocator.image_alloc(decoder->allocator_user_data,
png->width, png->height, png->bpp,
&png->data, &png->stride);
} else {
uint64_t size = (uint64_t)png->stride * png->height;
size_t platform_size = (size_t)size;
if (platform_size == size) {
png->data = ok_alloc(decoder, platform_size);
}
}
if (!png->data) {
ok_png_error(png, OK_PNG_ERROR_ALLOCATION, "Couldn't allocate memory for image");
return false;
}
if (png->stride < png->width * png->bpp) {
ok_png_error(png, OK_PNG_ERROR_API, "Invalid stride");
return false;
}
}
if (!decoder->prev_scanline) {
if (max_bytes_per_scanline == platform_max_bytes_per_scanline) {
decoder->prev_scanline = ok_alloc(decoder, platform_max_bytes_per_scanline);
}
}
if (!decoder->curr_scanline) {
if (max_bytes_per_scanline == platform_max_bytes_per_scanline) {
decoder->curr_scanline = ok_alloc(decoder, platform_max_bytes_per_scanline);
}
}
if (!decoder->inflate_buffer) {
decoder->inflate_buffer = ok_alloc(decoder, inflate_buffer_size);
}
if (decoder->interlace_method == 1 && !decoder->temp_data_row) {
decoder->temp_data_row = ok_alloc(decoder, png->width * png->bpp);
}
if (!decoder->curr_scanline || !decoder->prev_scanline || !decoder->inflate_buffer ||
(decoder->interlace_method == 1 && !decoder->temp_data_row)) {
ok_png_error(png, OK_PNG_ERROR_ALLOCATION, "Couldn't allocate buffers");
return false;
}
// Setup inflater
if (!decoder->inflater) {
decoder->inflater = ok_inflater_init(decoder->is_ios_format,
decoder->allocator, decoder->allocator_user_data);
if (!decoder->inflater) {
ok_png_error(png, OK_PNG_ERROR_ALLOCATION, "Couldn't init inflater");
return false;
}
}
// Sanity check - this happened with one file in the PNG suite
if (decoder->decoding_completed) {
if (bytes_remaining > 0) {
return ok_seek(decoder, (long)bytes_remaining);
} else {
return true;
}
}
// Read data
uint32_t curr_width = ok_png_get_width_for_pass(decoder);
uint32_t curr_height = ok_png_get_height_for_pass(decoder);
size_t curr_bytes_per_scanline = (size_t)(1 + ((uint64_t)curr_width * bits_per_pixel + 7) / 8);
while (true) {
// Setup pass
while (decoder->ready_for_next_interlace_pass) {
decoder->ready_for_next_interlace_pass = false;
decoder->scanline = 0;
decoder->interlace_pass++;
if (decoder->interlace_pass == num_passes + 1) {
// Done decoding - skip any remaining chunk data
decoder->decoding_completed = true;
if (bytes_remaining > 0) {
return ok_seek(decoder, (long)bytes_remaining);
} else {
return true;
}
}
curr_width = ok_png_get_width_for_pass(decoder);
curr_height = ok_png_get_height_for_pass(decoder);
curr_bytes_per_scanline = (size_t)(1 + ((uint64_t)curr_width * bits_per_pixel + 7) / 8);
if (curr_width == 0 || curr_height == 0) {
// No data for this pass - happens if width or height <= 4
decoder->ready_for_next_interlace_pass = true;
} else {
memset(decoder->curr_scanline, 0, curr_bytes_per_scanline);
memset(decoder->prev_scanline, 0, curr_bytes_per_scanline);
decoder->inflater_bytes_read = 0;
}
}
// Read compressed data
if (ok_inflater_needs_input(decoder->inflater)) {
if (bytes_remaining == 0) {
// Need more data, but there is no remaining data in this chunk.
// There may be another IDAT chunk.
return true;
}
const size_t len = min(inflate_buffer_size, bytes_remaining);
if (!ok_read(decoder, decoder->inflate_buffer, len)) {
return false;
}
bytes_remaining -= len;
ok_inflater_set_input(decoder->inflater, decoder->inflate_buffer, len);
}
// Decompress data
size_t len = ok_inflater_inflate(decoder->inflater,
decoder->curr_scanline + decoder->inflater_bytes_read,
curr_bytes_per_scanline - decoder->inflater_bytes_read);
if (len == OK_SIZE_MAX) {
ok_png_error(png, OK_PNG_ERROR_INFLATER, "Inflater error");
return false;
}
decoder->inflater_bytes_read += len;
if (decoder->inflater_bytes_read == curr_bytes_per_scanline) {
// Apply filter
const int filter = decoder->curr_scanline[0];
if (filter > 0 && filter < OK_PNG_NUM_FILTERS) {
ok_png_decode_filter(decoder->curr_scanline + 1, decoder->prev_scanline + 1,
curr_bytes_per_scanline - 1, filter, bytes_per_pixel);
} else if (filter != 0) {
ok_png_error(png, OK_PNG_ERROR_INVALID, "Invalid filter type");
return false;
}
// Transform
ok_png_transform_scanline(decoder, decoder->curr_scanline + 1, curr_width);
// Setup for next scanline or pass
decoder->scanline++;
if (decoder->scanline == curr_height) {
decoder->ready_for_next_interlace_pass = true;
} else {
uint8_t *temp = decoder->curr_scanline;
decoder->curr_scanline = decoder->prev_scanline;
decoder->prev_scanline = temp;
decoder->inflater_bytes_read = 0;
}
}
}
}
| 0
|
443,151
|
int jfs_commit_inode(struct inode *inode, int wait)
{
int rc = 0;
tid_t tid;
static int noisy = 5;
jfs_info("In jfs_commit_inode, inode = 0x%p", inode);
/*
* Don't commit if inode has been committed since last being
* marked dirty, or if it has been deleted.
*/
if (inode->i_nlink == 0 || !test_cflag(COMMIT_Dirty, inode))
return 0;
if (isReadOnly(inode)) {
/* kernel allows writes to devices on read-only
* partitions and may think inode is dirty
*/
if (!special_file(inode->i_mode) && noisy) {
jfs_err("jfs_commit_inode(0x%p) called on read-only volume",
inode);
jfs_err("Is remount racy?");
noisy--;
}
return 0;
}
tid = txBegin(inode->i_sb, COMMIT_INODE);
mutex_lock(&JFS_IP(inode)->commit_mutex);
/*
* Retest inode state after taking commit_mutex
*/
if (inode->i_nlink && test_cflag(COMMIT_Dirty, inode))
rc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0);
txEnd(tid);
mutex_unlock(&JFS_IP(inode)->commit_mutex);
return rc;
}
| 0
|
293,749
|
static RList *resolve_mig_subsystem(RKernelCacheObj *obj) {
struct section_t *sections = NULL;
if (!(sections = MACH0_(get_sections) (obj->mach0))) {
return NULL;
}
HtPP *mig_hash = NULL;
RList *subsystem = NULL;
ut8 *data_const = NULL;
ut64 data_const_offset = 0, data_const_size = 0, data_const_vaddr = 0;
ut64 text_exec_offset = 0, text_exec_size = 0, text_exec_vaddr = 0;
int incomplete = 2;
int i = 0;
for (; !sections[i].last && incomplete > 0; i++) {
if (strstr (sections[i].name, "__DATA_CONST.__const")) {
data_const_offset = sections[i].offset;
data_const_size = sections[i].size;
data_const_vaddr = K_PPTR (sections[i].addr);
incomplete--;
}
if (strstr (sections[i].name, "__TEXT_EXEC.__text")) {
text_exec_offset = sections[i].offset;
text_exec_size = sections[i].size;
text_exec_vaddr = K_PPTR (sections[i].addr);
incomplete--;
}
}
if (!data_const_offset || !data_const_size || !data_const_vaddr ||
!text_exec_offset || !text_exec_size || !text_exec_vaddr) {
goto beach;
}
data_const = malloc (data_const_size);
if (!data_const) {
goto beach;
}
if (r_buf_read_at (obj->cache_buf, data_const_offset, data_const, data_const_size) < data_const_size) {
goto beach;
}
subsystem = r_list_newf (r_bin_symbol_free);
if (!subsystem) {
goto beach;
}
mig_hash = mig_hash_new ();
if (!mig_hash) {
goto beach;
}
ut8 *cursor = data_const;
ut8 *end = data_const + data_const_size;
while (cursor < end) {
ut64 subs_p = K_PPTR (r_read_le64 (cursor));
if (subs_p < text_exec_vaddr || subs_p >= text_exec_vaddr + text_exec_size) {
cursor += 8;
continue;
}
ut32 subs_min_idx = r_read_le32 (cursor + 8);
ut32 subs_max_idx = r_read_le32 (cursor + 12);
if (subs_min_idx >= subs_max_idx || (subs_max_idx - subs_min_idx) > K_MIG_MAX_ROUTINES) {
cursor += 16;
continue;
}
ut32 n_routines = (subs_max_idx - subs_min_idx);
ut64 *routines = (ut64 *) calloc (n_routines, sizeof (ut64));
if (!routines) {
goto beach;
}
ut8 *array_cursor = cursor + K_MIG_SUBSYSTEM_SIZE;
ut8 *end_array = array_cursor + n_routines * K_MIG_ROUTINE_SIZE;
bool is_consistent = true;
int idx = 0;
while (array_cursor < end_array) {
ut64 should_be_null = r_read_le64 (array_cursor);
if (should_be_null != 0) {
is_consistent = false;
break;
}
ut64 routine_p = K_PPTR (r_read_le64 (array_cursor + 8));
if (routine_p != 0 && (routine_p < text_exec_vaddr || routine_p >= text_exec_vaddr + text_exec_size)) {
is_consistent = false;
break;
}
routines[idx++] = routine_p;
array_cursor += K_MIG_ROUTINE_SIZE;
}
if (is_consistent) {
for (idx = 0; idx < n_routines; idx++) {
ut64 routine_p = routines[idx];
if (!routine_p) {
continue;
}
RBinSymbol *sym = R_NEW0 (RBinSymbol);
if (!sym) {
R_FREE (routines);
goto beach;
}
int num = idx + subs_min_idx;
bool found = false;
r_strf_var (key, 32, "%d", num);
const char *name = sdb_ht_find (mig_hash, key, &found);
if (found && name && *name) {
sym->name = r_str_newf ("mig.%d.%s", num, name);
} else {
sym->name = r_str_newf ("mig.%d", num);
}
sym->vaddr = routine_p;
sym->paddr = sym->vaddr - text_exec_vaddr + text_exec_offset;
sym->size = 0;
sym->forwarder = "NONE";
sym->bind = "GLOBAL";
sym->type = "OBJECT";
r_list_append (subsystem, sym);
}
cursor += K_MIG_SUBSYSTEM_SIZE + n_routines * K_MIG_ROUTINE_SIZE;
} else {
cursor += 8;
}
R_FREE (routines);
}
sdb_ht_free (mig_hash);
R_FREE (data_const);
R_FREE (sections);
return subsystem;
beach:
if (subsystem) {
r_list_free (subsystem);
}
if (mig_hash) {
sdb_ht_free (mig_hash);
}
R_FREE (data_const);
R_FREE (sections);
return NULL;
}
| 0
|
309,957
|
position_check(NCURSES_SP_DCLx int expected_y, int expected_x, char *legend)
/* check to see if the real cursor position matches the virtual */
{
char buf[20];
char *s;
int y, x;
if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
return;
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
memset(buf, '\0', sizeof(buf));
NCURSES_PUTP2_FLUSH("cpr", "\033[6n"); /* only works on ANSI-compatibles */
*(s = buf) = 0;
do {
int ask = sizeof(buf) - 1 - (s - buf);
int got = read(0, s, ask);
if (got == 0)
break;
s += got;
} while (strchr(buf, 'R') == 0);
_tracef("probe returned %s", _nc_visbuf(buf));
/* try to interpret as a position report */
if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) {
_tracef("position probe failed in %s", legend);
} else {
if (expected_x < 0)
expected_x = x - 1;
if (expected_y < 0)
expected_y = y - 1;
if (y - 1 != expected_y || x - 1 != expected_x) {
NCURSES_SP_NAME(beep) (NCURSES_SP_ARG);
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
TIPARM_2("\033[%d;%dH",
expected_y + 1,
expected_x + 1),
1, NCURSES_SP_NAME(_nc_outch));
_tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
y - 1, x - 1, expected_y, expected_x, legend);
} else {
_tracef("position matches OK in %s", legend);
}
}
}
| 0
|
222,540
|
FunctionDefLibrary FunctionLibraryDefinition::ToProto() const {
FunctionDefLibrary lib;
tf_shared_lock l(mu_);
for (const auto& f : function_defs_) {
*lib.add_function() = f.second->fdef;
}
for (const auto& g : func_grad_) {
GradientDef* gd = lib.add_gradient();
gd->set_function_name(g.first);
gd->set_gradient_func(g.second);
}
return lib;
}
| 0
|
473,860
|
is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSED)
{
if (code < 256)
return ENC_IS_ISO_8859_8_CTYPE(code, ctype);
else
return FALSE;
}
| 0
|
312,428
|
qf_get_next_file_line(qfstate_T *state)
{
int discard;
int growbuflen;
if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL)
return QF_END_OF_INPUT;
discard = FALSE;
state->linelen = (int)STRLEN(IObuff);
if (state->linelen == IOSIZE - 1 && !(IObuff[state->linelen - 1] == '\n'))
{
// The current line exceeds IObuff, continue reading using
// growbuf until EOL or LINE_MAXLEN bytes is read.
if (state->growbuf == NULL)
{
state->growbufsiz = 2 * (IOSIZE - 1);
state->growbuf = alloc_id(state->growbufsiz, aid_qf_linebuf);
if (state->growbuf == NULL)
return QF_NOMEM;
}
// Copy the read part of the line, excluding null-terminator
memcpy(state->growbuf, IObuff, IOSIZE - 1);
growbuflen = state->linelen;
for (;;)
{
char_u *p;
if (fgets((char *)state->growbuf + growbuflen,
state->growbufsiz - growbuflen, state->fd) == NULL)
break;
state->linelen = (int)STRLEN(state->growbuf + growbuflen);
growbuflen += state->linelen;
if ((state->growbuf)[growbuflen - 1] == '\n')
break;
if (state->growbufsiz == LINE_MAXLEN)
{
discard = TRUE;
break;
}
state->growbufsiz = 2 * state->growbufsiz < LINE_MAXLEN
? 2 * state->growbufsiz : LINE_MAXLEN;
if ((p = vim_realloc(state->growbuf, state->growbufsiz)) == NULL)
return QF_NOMEM;
state->growbuf = p;
}
while (discard)
{
// The current line is longer than LINE_MAXLEN, continue
// reading but discard everything until EOL or EOF is
// reached.
if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL
|| (int)STRLEN(IObuff) < IOSIZE - 1
|| IObuff[IOSIZE - 2] == '\n')
break;
}
state->linebuf = state->growbuf;
state->linelen = growbuflen;
}
else
state->linebuf = IObuff;
// Convert a line if it contains a non-ASCII character.
if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf))
{
char_u *line;
line = string_convert(&state->vc, state->linebuf, &state->linelen);
if (line != NULL)
{
if (state->linelen < IOSIZE)
{
STRCPY(state->linebuf, line);
vim_free(line);
}
else
{
vim_free(state->growbuf);
state->linebuf = state->growbuf = line;
state->growbufsiz = state->linelen < LINE_MAXLEN
? state->linelen : LINE_MAXLEN;
}
}
}
return QF_OK;
}
| 0
|
90,198
|
static std::string WrapWithTH(std::string text) {
return "<th>" + text + "</th>";
}
| 0
|
512,298
|
void Item_func_case_simple::print(String *str, enum_query_type query_type)
{
Item **pos;
str->append(STRING_WITH_LEN("case "));
args[0]->print_parenthesised(str, query_type, precedence());
str->append(' ');
print_when_then_arguments(str, query_type, &args[1], when_count());
if ((pos= Item_func_case_simple::else_expr_addr()))
print_else_argument(str, query_type, pos[0]);
str->append(STRING_WITH_LEN("end"));
}
| 0
|
473,927
|
mbc_case_fold(OnigCaseFoldType flag,
const UChar** pp, const UChar* end, UChar* lower,
OnigEncoding enc)
{
int len;
const UChar* p = *pp;
if (ONIGENC_IS_MBC_ASCII(p)) {
*lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
(*pp)++;
return 1;
}
else {
int i;
len = enclen(enc, p, end);
for (i = 0; i < len; i++) {
*lower++ = *p++;
}
(*pp) += len;
return len; /* return byte length of converted char to lower */
}
}
| 0
|
336,532
|
static void reds_config_set_image_compression(RedsState *reds, SpiceImageCompression image_compression)
{
if (image_compression == reds->config->image_compression) {
return;
}
switch (image_compression) {
case SPICE_IMAGE_COMPRESSION_AUTO_LZ:
spice_debug("ic auto_lz");
break;
case SPICE_IMAGE_COMPRESSION_AUTO_GLZ:
spice_debug("ic auto_glz");
break;
case SPICE_IMAGE_COMPRESSION_QUIC:
spice_debug("ic quic");
break;
#ifdef USE_LZ4
case SPICE_IMAGE_COMPRESSION_LZ4:
spice_debug("ic lz4");
break;
#endif
case SPICE_IMAGE_COMPRESSION_LZ:
spice_debug("ic lz");
break;
case SPICE_IMAGE_COMPRESSION_GLZ:
spice_debug("ic glz");
break;
case SPICE_IMAGE_COMPRESSION_OFF:
spice_debug("ic off");
break;
default:
spice_warning("ic invalid");
return;
}
reds->config->image_compression = image_compression;
reds_on_ic_change(reds);
}
| 0
|
475,988
|
static inline lzw_result lzw__next_code(
struct lzw_read_ctx *ctx,
uint8_t code_size,
uint32_t *code_out)
{
uint32_t code = 0;
uint8_t current_bit = ctx->sb_bit & 0x7;
uint8_t byte_advance = (current_bit + code_size) >> 3;
assert(byte_advance <= 2);
if (ctx->sb_bit + code_size <= ctx->sb_bit_count) {
/* Fast path: code fully inside this sub-block */
const uint8_t *data = ctx->sb_data + (ctx->sb_bit >> 3);
switch (byte_advance) {
case 2: code |= data[2] << 16; /* Fall through */
case 1: code |= data[1] << 8; /* Fall through */
case 0: code |= data[0] << 0;
}
ctx->sb_bit += code_size;
} else {
/* Slow path: code spans sub-blocks */
uint8_t byte = 0;
uint8_t bits_remaining_0 = (code_size < (8 - current_bit)) ?
code_size : (8 - current_bit);
uint8_t bits_remaining_1 = code_size - bits_remaining_0;
uint8_t bits_used[3] = {
[0] = bits_remaining_0,
[1] = bits_remaining_1 < 8 ? bits_remaining_1 : 8,
[2] = bits_remaining_1 - 8,
};
while (true) {
const uint8_t *data = ctx->sb_data;
lzw_result res;
/* Get any data from end of this sub-block */
while (byte <= byte_advance &&
ctx->sb_bit < ctx->sb_bit_count) {
code |= data[ctx->sb_bit >> 3] << (byte << 3);
ctx->sb_bit += bits_used[byte];
byte++;
}
/* Check if we have all we need */
if (byte > byte_advance) {
break;
}
/* Move to next sub-block */
res = lzw__block_advance(ctx);
if (res != LZW_OK) {
return res;
}
}
}
*code_out = (code >> current_bit) & ((1 << code_size) - 1);
return LZW_OK;
}
| 0
|
459,209
|
static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
struct nlmsghdr *n, struct tcf_proto *tp,
struct tcf_block *block, struct Qdisc *q,
u32 parent, void *fh, bool unicast, bool *last,
bool rtnl_held, struct netlink_ext_ack *extack)
{
struct sk_buff *skb;
u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
int err;
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
if (!skb)
return -ENOBUFS;
if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid,
n->nlmsg_seq, n->nlmsg_flags, RTM_DELTFILTER,
false, rtnl_held) <= 0) {
NL_SET_ERR_MSG(extack, "Failed to build del event notification");
kfree_skb(skb);
return -EINVAL;
}
err = tp->ops->delete(tp, fh, last, rtnl_held, extack);
if (err) {
kfree_skb(skb);
return err;
}
if (unicast)
err = rtnl_unicast(skb, net, portid);
else
err = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
n->nlmsg_flags & NLM_F_ECHO);
if (err < 0)
NL_SET_ERR_MSG(extack, "Failed to send filter delete notification");
return err;
}
| 0
|
336,523
|
static void reds_set_mouse_mode(RedsState *reds, SpiceMouseMode mode)
{
if (reds->mouse_mode == mode) {
return;
}
reds->mouse_mode = mode;
FOREACH_QXL_INSTANCE(reds, qxl) {
red_qxl_set_mouse_mode(qxl, mode);
}
reds->main_channel->push_mouse_mode(reds->mouse_mode,
reds->is_client_mouse_allowed);
}
| 0
|
355,618
|
set_ref_in_item(
typval_T *tv,
int copyID,
ht_stack_T **ht_stack,
list_stack_T **list_stack)
{
int abort = FALSE;
if (tv->v_type == VAR_DICT)
{
dict_T *dd = tv->vval.v_dict;
if (dd != NULL && dd->dv_copyID != copyID)
{
// Didn't see this dict yet.
dd->dv_copyID = copyID;
if (ht_stack == NULL)
{
abort = set_ref_in_ht(&dd->dv_hashtab, copyID, list_stack);
}
else
{
ht_stack_T *newitem = ALLOC_ONE(ht_stack_T);
if (newitem == NULL)
abort = TRUE;
else
{
newitem->ht = &dd->dv_hashtab;
newitem->prev = *ht_stack;
*ht_stack = newitem;
}
}
}
}
else if (tv->v_type == VAR_LIST)
{
list_T *ll = tv->vval.v_list;
if (ll != NULL && ll->lv_copyID != copyID)
{
// Didn't see this list yet.
ll->lv_copyID = copyID;
if (list_stack == NULL)
{
abort = set_ref_in_list_items(ll, copyID, ht_stack);
}
else
{
list_stack_T *newitem = ALLOC_ONE(list_stack_T);
if (newitem == NULL)
abort = TRUE;
else
{
newitem->list = ll;
newitem->prev = *list_stack;
*list_stack = newitem;
}
}
}
}
else if (tv->v_type == VAR_FUNC)
{
abort = set_ref_in_func(tv->vval.v_string, NULL, copyID);
}
else if (tv->v_type == VAR_PARTIAL)
{
partial_T *pt = tv->vval.v_partial;
int i;
if (pt != NULL && pt->pt_copyID != copyID)
{
// Didn't see this partial yet.
pt->pt_copyID = copyID;
abort = set_ref_in_func(pt->pt_name, pt->pt_func, copyID);
if (pt->pt_dict != NULL)
{
typval_T dtv;
dtv.v_type = VAR_DICT;
dtv.vval.v_dict = pt->pt_dict;
set_ref_in_item(&dtv, copyID, ht_stack, list_stack);
}
for (i = 0; i < pt->pt_argc; ++i)
abort = abort || set_ref_in_item(&pt->pt_argv[i], copyID,
ht_stack, list_stack);
// pt_funcstack is handled in set_ref_in_funcstacks()
}
}
#ifdef FEAT_JOB_CHANNEL
else if (tv->v_type == VAR_JOB)
{
job_T *job = tv->vval.v_job;
typval_T dtv;
if (job != NULL && job->jv_copyID != copyID)
{
job->jv_copyID = copyID;
if (job->jv_channel != NULL)
{
dtv.v_type = VAR_CHANNEL;
dtv.vval.v_channel = job->jv_channel;
set_ref_in_item(&dtv, copyID, ht_stack, list_stack);
}
if (job->jv_exit_cb.cb_partial != NULL)
{
dtv.v_type = VAR_PARTIAL;
dtv.vval.v_partial = job->jv_exit_cb.cb_partial;
set_ref_in_item(&dtv, copyID, ht_stack, list_stack);
}
}
}
else if (tv->v_type == VAR_CHANNEL)
{
channel_T *ch =tv->vval.v_channel;
ch_part_T part;
typval_T dtv;
jsonq_T *jq;
cbq_T *cq;
if (ch != NULL && ch->ch_copyID != copyID)
{
ch->ch_copyID = copyID;
for (part = PART_SOCK; part < PART_COUNT; ++part)
{
for (jq = ch->ch_part[part].ch_json_head.jq_next; jq != NULL;
jq = jq->jq_next)
set_ref_in_item(jq->jq_value, copyID, ht_stack, list_stack);
for (cq = ch->ch_part[part].ch_cb_head.cq_next; cq != NULL;
cq = cq->cq_next)
if (cq->cq_callback.cb_partial != NULL)
{
dtv.v_type = VAR_PARTIAL;
dtv.vval.v_partial = cq->cq_callback.cb_partial;
set_ref_in_item(&dtv, copyID, ht_stack, list_stack);
}
if (ch->ch_part[part].ch_callback.cb_partial != NULL)
{
dtv.v_type = VAR_PARTIAL;
dtv.vval.v_partial =
ch->ch_part[part].ch_callback.cb_partial;
set_ref_in_item(&dtv, copyID, ht_stack, list_stack);
}
}
if (ch->ch_callback.cb_partial != NULL)
{
dtv.v_type = VAR_PARTIAL;
dtv.vval.v_partial = ch->ch_callback.cb_partial;
set_ref_in_item(&dtv, copyID, ht_stack, list_stack);
}
if (ch->ch_close_cb.cb_partial != NULL)
{
dtv.v_type = VAR_PARTIAL;
dtv.vval.v_partial = ch->ch_close_cb.cb_partial;
set_ref_in_item(&dtv, copyID, ht_stack, list_stack);
}
}
}
#endif
return abort;
}
| 0
|
390,628
|
XkbWriteGeomShapes(char *wire,XkbGeometryPtr geom,Bool swap)
{
int i;
XkbShapePtr shape;
xkbShapeWireDesc * shapeWire;
for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
register int o;
XkbOutlinePtr ol;
xkbOutlineWireDesc * olWire;
shapeWire= (xkbShapeWireDesc *)wire;
shapeWire->name= shape->name;
shapeWire->nOutlines= shape->num_outlines;
if (shape->primary!=NULL)
shapeWire->primaryNdx= XkbOutlineIndex(shape,shape->primary);
else shapeWire->primaryNdx= XkbNoShape;
if (shape->approx!=NULL)
shapeWire->approxNdx= XkbOutlineIndex(shape,shape->approx);
else shapeWire->approxNdx= XkbNoShape;
if (swap) {
register int n;
swapl(&shapeWire->name,n);
}
wire= (char *)&shapeWire[1];
for (o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {
register int p;
XkbPointPtr pt;
xkbPointWireDesc * ptWire;
olWire= (xkbOutlineWireDesc *)wire;
olWire->nPoints= ol->num_points;
olWire->cornerRadius= ol->corner_radius;
wire= (char *)&olWire[1];
ptWire= (xkbPointWireDesc *)wire;
for (p=0,pt=ol->points;p<ol->num_points;p++,pt++) {
ptWire[p].x= pt->x;
ptWire[p].y= pt->y;
if (swap) {
register int n;
swaps(&ptWire[p].x,n);
swaps(&ptWire[p].y,n);
}
}
wire= (char *)&ptWire[ol->num_points];
}
}
return wire;
}
| 0
|
242,123
|
int LuaSettings::l_remove(lua_State* L)
{
NO_MAP_LOCK_REQUIRED;
LuaSettings* o = checkobject(L, 1);
std::string key = std::string(luaL_checkstring(L, 2));
CHECK_SETTING_SECURITY(L, key);
bool success = o->m_settings->remove(key);
lua_pushboolean(L, success);
return 1;
}
| 0
|
233,880
|
*/
static void php_wddx_serialize_array(wddx_packet *packet, zval *arr)
{
zval *ent;
zend_string *key;
int is_struct = 0;
zend_ulong idx;
HashTable *target_hash;
char tmp_buf[WDDX_BUF_LEN];
zend_ulong ind = 0;
target_hash = Z_ARRVAL_P(arr);
ZEND_HASH_FOREACH_KEY(target_hash, idx, key) {
if (key) {
is_struct = 1;
break;
}
if (idx != ind) {
is_struct = 1;
break;
}
ind++;
} ZEND_HASH_FOREACH_END();
if (is_struct) {
php_wddx_add_chunk_static(packet, WDDX_STRUCT_S);
} else {
snprintf(tmp_buf, sizeof(tmp_buf), WDDX_ARRAY_S, zend_hash_num_elements(target_hash));
php_wddx_add_chunk(packet, tmp_buf);
}
ZEND_HASH_FOREACH_KEY_VAL(target_hash, idx, key, ent) {
if (ent == arr) {
continue;
}
if (is_struct) {
if (key) {
php_wddx_serialize_var(packet, ent, key);
} else {
key = zend_long_to_str(idx);
php_wddx_serialize_var(packet, ent, key);
zend_string_release(key);
}
} else {
php_wddx_serialize_var(packet, ent, NULL);
}
} ZEND_HASH_FOREACH_END();
if (is_struct) {
php_wddx_add_chunk_static(packet, WDDX_STRUCT_E);
} else {
php_wddx_add_chunk_static(packet, WDDX_ARRAY_E);
}
| 0
|
273,068
|
b64_decode(int *dstlen, const char *src)
{
uint8_t *out;
int len;
int ret;
len = AV_BASE64_DECODE_SIZE(strlen(src));
// Add a extra zero byte just in case we are decoding a string without null
// termination
CHECK_NULL(L_MISC, out = calloc(1, len + 1));
ret = av_base64_decode(out, src, len);
if (ret < 0)
{
free(out);
return NULL;
}
if (dstlen)
*dstlen = ret;
return out;
}
| 0
|
213,037
|
mbfl_filt_conv_big5_wchar(int c, mbfl_convert_filter *filter)
{
int k;
int c1, w, c2;
switch (filter->status) {
case 0:
if (filter->from->no_encoding == mbfl_no_encoding_cp950) {
c1 = 0x80;
} else {
c1 = 0xa0;
}
if (c >= 0 && c <= 0x80) { /* latin */
CK((*filter->output_function)(c, filter->data));
} else if (c == 0xff) {
CK((*filter->output_function)(0xf8f8, filter->data));
} else if (c > c1 && c < 0xff) { /* dbcs lead byte */
filter->status = 1;
filter->cache = c;
} else {
w = c & MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
break;
case 1: /* dbcs second byte */
filter->status = 0;
c1 = filter->cache;
if ((c > 0x39 && c < 0x7f) | (c > 0xa0 && c < 0xff)) {
if (c < 0x7f){
w = (c1 - 0xa1)*157 + (c - 0x40);
} else {
w = (c1 - 0xa1)*157 + (c - 0xa1) + 0x3f;
}
if (w >= 0 && w < big5_ucs_table_size) {
w = big5_ucs_table[w];
} else {
w = 0;
}
if (filter->from->no_encoding == mbfl_no_encoding_cp950) {
/* PUA for CP950 */
if (w <= 0 &&
(((c1 >= 0xfa && c1 <= 0xfe) || (c1 >= 0x8e && c1 <= 0xa0) ||
(c1 >= 0x81 && c1 <= 0x8d) ||(c1 >= 0xc7 && c1 <= 0xc8))
&& ((c > 0x39 && c < 0x7f) || (c > 0xa0 && c < 0xff))) ||
((c1 == 0xc6) && (c > 0xa0 && c < 0xff))) {
c2 = c1 << 8 | c;
for (k = 0; k < sizeof(cp950_pua_tbl)/(sizeof(unsigned short)*4); k++) {
if (c2 >= cp950_pua_tbl[k][2] && c2 <= cp950_pua_tbl[k][3]) {
break;
}
}
if ((cp950_pua_tbl[k][2] & 0xff) == 0x40) {
w = 157*(c1 - (cp950_pua_tbl[k][2]>>8)) + c - (c >= 0xa1 ? 0x62 : 0x40)
+ cp950_pua_tbl[k][0];
} else {
w = c2 - cp950_pua_tbl[k][2] + cp950_pua_tbl[k][0];
}
}
}
if (w <= 0) {
w = (c1 << 8) | c;
w &= MBFL_WCSPLANE_MASK;
w |= MBFL_WCSPLANE_BIG5;
}
CK((*filter->output_function)(w, filter->data));
} else if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
CK((*filter->output_function)(c, filter->data));
} else {
w = (c1 << 8) | c;
w &= MBFL_WCSGROUP_MASK;
w |= MBFL_WCSGROUP_THROUGH;
CK((*filter->output_function)(w, filter->data));
}
break;
default:
filter->status = 0;
break;
}
return c;
}
| 1
|
224,281
|
gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
{
char *pos = inbuf;
char *lpos = NULL;
char *tline = NULL;
LOCAL_ARRAY(char, line, TEMP_BUF_SIZE);
char *name = NULL;
char *selector = NULL;
char *host = NULL;
char *port = NULL;
char *escaped_selector = NULL;
const char *icon_url = NULL;
char gtype;
StoreEntry *entry = NULL;
memset(line, '\0', TEMP_BUF_SIZE);
entry = gopherState->entry;
if (gopherState->conversion == GopherStateData::HTML_INDEX_PAGE) {
char *html_url = html_quote(entry->url());
gopherHTMLHeader(entry, "Gopher Index %s", html_url);
storeAppendPrintf(entry,
"<p>This is a searchable Gopher index. Use the search\n"
"function of your browser to enter search terms.\n"
"<ISINDEX>\n");
gopherHTMLFooter(entry);
/* now let start sending stuff to client */
entry->flush();
gopherState->HTML_header_added = 1;
return;
}
if (gopherState->conversion == GopherStateData::HTML_CSO_PAGE) {
char *html_url = html_quote(entry->url());
gopherHTMLHeader(entry, "CSO Search of %s", html_url);
storeAppendPrintf(entry,
"<P>A CSO database usually contains a phonebook or\n"
"directory. Use the search function of your browser to enter\n"
"search terms.</P><ISINDEX>\n");
gopherHTMLFooter(entry);
/* now let start sending stuff to client */
entry->flush();
gopherState->HTML_header_added = 1;
return;
}
SBuf outbuf;
if (!gopherState->HTML_header_added) {
if (gopherState->conversion == GopherStateData::HTML_CSO_RESULT)
gopherHTMLHeader(entry, "CSO Search Result", NULL);
else
gopherHTMLHeader(entry, "Gopher Menu", NULL);
outbuf.append ("<PRE>");
gopherState->HTML_header_added = 1;
gopherState->HTML_pre = 1;
}
while (pos < inbuf + len) {
int llen;
int left = len - (pos - inbuf);
lpos = (char *)memchr(pos, '\n', left);
if (lpos) {
++lpos; /* Next line is after \n */
llen = lpos - pos;
} else {
llen = left;
}
if (gopherState->len + llen >= TEMP_BUF_SIZE) {
debugs(10, DBG_IMPORTANT, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url() );
llen = TEMP_BUF_SIZE - gopherState->len - 1;
gopherState->overflowed = true; // may already be true
}
if (!lpos) {
/* there is no complete line in inbuf */
/* copy it to temp buffer */
/* note: llen is adjusted above */
memcpy(gopherState->buf + gopherState->len, pos, llen);
gopherState->len += llen;
break;
}
if (gopherState->len != 0) {
/* there is something left from last tx. */
memcpy(line, gopherState->buf, gopherState->len);
memcpy(line + gopherState->len, pos, llen);
llen += gopherState->len;
gopherState->len = 0;
} else {
memcpy(line, pos, llen);
}
line[llen + 1] = '\0';
/* move input to next line */
pos = lpos;
/* at this point. We should have one line in buffer to process */
if (*line == '.') {
/* skip it */
memset(line, '\0', TEMP_BUF_SIZE);
continue;
}
switch (gopherState->conversion) {
case GopherStateData::HTML_INDEX_RESULT:
case GopherStateData::HTML_DIR: {
tline = line;
gtype = *tline;
++tline;
name = tline;
selector = strchr(tline, TAB);
if (selector) {
*selector = '\0';
++selector;
host = strchr(selector, TAB);
if (host) {
*host = '\0';
++host;
port = strchr(host, TAB);
if (port) {
char *junk;
port[0] = ':';
junk = strchr(host, TAB);
if (junk)
*junk++ = 0; /* Chop port */
else {
junk = strchr(host, '\r');
if (junk)
*junk++ = 0; /* Chop port */
else {
junk = strchr(host, '\n');
if (junk)
*junk++ = 0; /* Chop port */
}
}
if ((port[1] == '0') && (!port[2]))
port[0] = 0; /* 0 means none */
}
/* escape a selector here */
escaped_selector = xstrdup(rfc1738_escape_part(selector));
switch (gtype) {
case GOPHER_DIRECTORY:
icon_url = mimeGetIconURL("internal-menu");
break;
case GOPHER_HTML:
case GOPHER_FILE:
icon_url = mimeGetIconURL("internal-text");
break;
case GOPHER_INDEX:
case GOPHER_CSO:
icon_url = mimeGetIconURL("internal-index");
break;
case GOPHER_IMAGE:
case GOPHER_GIF:
case GOPHER_PLUS_IMAGE:
icon_url = mimeGetIconURL("internal-image");
break;
case GOPHER_SOUND:
case GOPHER_PLUS_SOUND:
icon_url = mimeGetIconURL("internal-sound");
break;
case GOPHER_PLUS_MOVIE:
icon_url = mimeGetIconURL("internal-movie");
break;
case GOPHER_TELNET:
case GOPHER_3270:
icon_url = mimeGetIconURL("internal-telnet");
break;
case GOPHER_BIN:
case GOPHER_MACBINHEX:
case GOPHER_DOSBIN:
case GOPHER_UUENCODED:
icon_url = mimeGetIconURL("internal-binary");
break;
case GOPHER_INFO:
icon_url = NULL;
break;
case GOPHER_WWW:
icon_url = mimeGetIconURL("internal-link");
break;
default:
icon_url = mimeGetIconURL("internal-unknown");
break;
}
if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {
if (strlen(escaped_selector) != 0)
outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s@%s%s%s/\">%s</A>\n",
icon_url, escaped_selector, rfc1738_escape_part(host),
*port ? ":" : "", port, html_quote(name));
else
outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"telnet://%s%s%s/\">%s</A>\n",
icon_url, rfc1738_escape_part(host), *port ? ":" : "",
port, html_quote(name));
} else if (gtype == GOPHER_INFO) {
outbuf.appendf("\t%s\n", html_quote(name));
} else {
if (strncmp(selector, "GET /", 5) == 0) {
/* WWW link */
outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"http://%s/%s\">%s</A>\n",
icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name));
} else if (gtype == GOPHER_WWW) {
outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n",
icon_url, rfc1738_escape_unescaped(selector), html_quote(name));
} else {
/* Standard link */
outbuf.appendf("<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n",
icon_url, host, gtype, escaped_selector, html_quote(name));
}
}
safe_free(escaped_selector);
} else {
memset(line, '\0', TEMP_BUF_SIZE);
continue;
}
} else {
memset(line, '\0', TEMP_BUF_SIZE);
continue;
}
break;
} /* HTML_DIR, HTML_INDEX_RESULT */
case GopherStateData::HTML_CSO_RESULT: {
if (line[0] == '-') {
int code, recno;
char *s_code, *s_recno, *result;
s_code = strtok(line + 1, ":\n");
s_recno = strtok(NULL, ":\n");
result = strtok(NULL, "\n");
if (!result)
break;
code = atoi(s_code);
recno = atoi(s_recno);
if (code != 200)
break;
if (gopherState->cso_recno != recno) {
outbuf.appendf("</PRE><HR noshade size=\"1px\"><H2>Record# %d<br><i>%s</i></H2>\n<PRE>", recno, html_quote(result));
gopherState->cso_recno = recno;
} else {
outbuf.appendf("%s\n", html_quote(result));
}
break;
} else {
int code;
char *s_code, *result;
s_code = strtok(line, ":");
result = strtok(NULL, "\n");
if (!result)
break;
code = atoi(s_code);
switch (code) {
case 200: {
/* OK */
/* Do nothing here */
break;
}
case 102: /* Number of matches */
case 501: /* No Match */
case 502: { /* Too Many Matches */
/* Print the message the server returns */
outbuf.appendf("</PRE><HR noshade size=\"1px\"><H2>%s</H2>\n<PRE>", html_quote(result));
break;
}
}
}
break;
} /* HTML_CSO_RESULT */
default:
break; /* do nothing */
} /* switch */
} /* while loop */
if (outbuf.length() > 0) {
entry->append(outbuf.rawContent(), outbuf.length());
/* now let start sending stuff to client */
entry->flush();
}
return;
}
| 0
|
310,028
|
drv_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf)
{
SCREEN *sp = TCB->csp;
TERMINAL *_term = (TERMINAL *) TCB;
int result = OK;
AssertTCB();
if (setFlag) {
for (;;) {
if (SET_TTY(_term->Filedes, buf) != 0) {
if (errno == EINTR)
continue;
if (errno == ENOTTY) {
if (sp)
sp->_notty = TRUE;
}
result = ERR;
}
break;
}
} else {
for (;;) {
if (GET_TTY(_term->Filedes, buf) != 0) {
if (errno == EINTR)
continue;
result = ERR;
}
break;
}
}
return result;
}
| 0
|
454,750
|
static void ismt_desc_dump(struct ismt_priv *priv)
{
struct device *dev = &priv->pci_dev->dev;
struct ismt_desc *desc = &priv->hw[priv->head];
dev_dbg(dev, "Dump of the descriptor struct: 0x%X\n", priv->head);
__ismt_desc_dump(dev, desc);
}
| 0
|
369,369
|
static inline void io_cqring_ev_posted(struct io_ring_ctx *ctx)
{
if (unlikely(ctx->off_timeout_used || ctx->drain_active ||
ctx->has_evfd))
__io_commit_cqring_flush(ctx);
io_cqring_wake(ctx);
}
| 0
|
291,837
|
static int post_recv_path(struct rtrs_clt_path *clt_path)
{
size_t q_size = 0;
int err, cid;
for (cid = 0; cid < clt_path->s.con_num; cid++) {
if (cid == 0)
q_size = SERVICE_CON_QUEUE_DEPTH;
else
q_size = clt_path->queue_depth;
/*
* x2 for RDMA read responses + FR key invalidations,
* RDMA writes do not require any FR registrations.
*/
q_size *= 2;
err = post_recv_io(to_clt_con(clt_path->s.con[cid]), q_size);
if (err) {
rtrs_err(clt_path->clt, "post_recv_io(), err: %d\n",
err);
return err;
}
}
return 0;
}
| 0
|
386,508
|
void DL_Dxf::writeDimStyle(DL_WriterA& dw,
double dimasz, double dimexe, double dimexo,
double dimgap, double dimtxt) {
dw.dxfString( 0, "TABLE");
dw.dxfString( 2, "DIMSTYLE");
if (version==DL_VERSION_2000) {
dw.dxfHex(5, 0xA);
dw.dxfString(100, "AcDbSymbolTable");
}
dw.dxfInt( 70, 1);
if (version==DL_VERSION_2000) {
dw.dxfString(100, "AcDbDimStyleTable");
dw.dxfInt( 71, 0);
}
dw.dxfString( 0, "DIMSTYLE");
if (version==DL_VERSION_2000) {
dw.dxfHex(105, 0x27);
}
//dw.handle(105);
//dw.dxfHex(330, 0xA);
if (version==DL_VERSION_2000) {
dw.dxfString(100, "AcDbSymbolTableRecord");
dw.dxfString(100, "AcDbDimStyleTableRecord");
}
dw.dxfString( 2, "Standard");
if (version==DL_VERSION_R12) {
dw.dxfString( 3, "");
dw.dxfString( 4, "");
dw.dxfString( 5, "");
dw.dxfString( 6, "");
dw.dxfString( 7, "");
dw.dxfReal( 40, 1.0);
}
dw.dxfReal( 41, dimasz);
dw.dxfReal( 42, dimexo);
dw.dxfReal( 43, 3.75);
dw.dxfReal( 44, dimexe);
if (version==DL_VERSION_R12) {
dw.dxfReal( 45, 0.0);
dw.dxfReal( 46, 0.0);
dw.dxfReal( 47, 0.0);
dw.dxfReal( 48, 0.0);
}
dw.dxfInt( 70, 0);
if (version==DL_VERSION_R12) {
dw.dxfInt( 71, 0);
dw.dxfInt( 72, 0);
}
dw.dxfInt( 73, 0);
dw.dxfInt( 74, 0);
if (version==DL_VERSION_R12) {
dw.dxfInt( 75, 0);
dw.dxfInt( 76, 0);
}
dw.dxfInt( 77, 1);
dw.dxfInt( 78, 8);
dw.dxfReal(140, dimtxt);
dw.dxfReal(141, 2.5);
if (version==DL_VERSION_R12) {
dw.dxfReal(142, 0.0);
}
dw.dxfReal(143, 0.03937007874016);
if (version==DL_VERSION_R12) {
dw.dxfReal(144, 1.0);
dw.dxfReal(145, 0.0);
dw.dxfReal(146, 1.0);
}
dw.dxfReal(147, dimgap);
if (version==DL_VERSION_R12) {
dw.dxfInt(170, 0);
}
dw.dxfInt(171, 3);
dw.dxfInt(172, 1);
if (version==DL_VERSION_R12) {
dw.dxfInt(173, 0);
dw.dxfInt(174, 0);
dw.dxfInt(175, 0);
dw.dxfInt(176, 0);
dw.dxfInt(177, 0);
dw.dxfInt(178, 0);
}
if (version==DL_VERSION_2000) {
dw.dxfInt(271, 2);
dw.dxfInt(272, 2);
dw.dxfInt(274, 3);
dw.dxfInt(278, 44);
dw.dxfInt(283, 0);
dw.dxfInt(284, 8);
dw.dxfHex(340, styleHandleStd);
//dw.dxfHex(340, 0x11);
}
// * /
dw.dxfString( 0, "ENDTAB");
}
| 0
|
310,042
|
outs(char *s)
{
if (VALID_STRING(s)) {
tputs(s, 1, outc);
return TRUE;
}
return FALSE;
}
| 0
|
474,007
|
is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSED)
{
if (ctype <= ONIGENC_MAX_STD_CTYPE) {
if (code < 128)
return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
else {
if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
return (code_to_mbclen(code, enc) > 1 ? TRUE : FALSE);
}
}
}
else {
PROPERTY_LIST_INIT_CHECK;
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
if (ctype >= (unsigned int )PropertyListNum)
return ONIGERR_TYPE_BUG;
return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
}
return FALSE;
}
| 0
|
294,709
|
d_lite_mjd(VALUE self)
{
get_d1(self);
return f_sub(m_real_local_jd(dat), INT2FIX(2400001));
}
| 0
|
473,893
|
backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
UChar* s, const UChar* range, UChar* adjrange,
UChar** low, UChar** high)
{
int r;
UChar *p;
range += reg->dmin;
p = s;
retry:
switch (reg->optimize) {
case ONIG_OPTIMIZE_EXACT:
exact_method:
p = slow_search_backward(reg->enc, reg->exact, reg->exact_end,
range, adjrange, end, p);
break;
case ONIG_OPTIMIZE_EXACT_IC:
p = slow_search_backward_ic(reg->enc, reg->case_fold_flag,
reg->exact, reg->exact_end,
range, adjrange, end, p);
break;
case ONIG_OPTIMIZE_EXACT_BM:
case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:
if (IS_NULL(reg->int_map_backward)) {
if (s - range < BM_BACKWARD_SEARCH_LENGTH_THRESHOLD)
goto exact_method;
r = set_bm_backward_skip(reg->exact, reg->exact_end, reg->enc,
&(reg->int_map_backward));
if (r) return r;
}
p = bm_search_backward(reg, reg->exact, reg->exact_end, range, adjrange,
end, p);
break;
case ONIG_OPTIMIZE_MAP:
p = map_search_backward(reg->enc, reg->map, range, adjrange, p, end);
break;
}
if (p) {
if (reg->sub_anchor) {
UChar* prev;
switch (reg->sub_anchor) {
case ANCHOR_BEGIN_LINE:
if (!ON_STR_BEGIN(p)) {
prev = onigenc_get_prev_char_head(reg->enc, str, p, end);
if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) {
p = prev;
goto retry;
}
}
break;
case ANCHOR_END_LINE:
if (ON_STR_END(p)) {
#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
prev = onigenc_get_prev_char_head(reg->enc, adjrange, p);
if (IS_NULL(prev)) goto fail;
if (ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) {
p = prev;
goto retry;
}
#endif
}
else if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end)
#ifdef USE_CRNL_AS_LINE_TERMINATOR
&& ! ONIGENC_IS_MBC_CRNL(reg->enc, p, end)
#endif
) {
p = onigenc_get_prev_char_head(reg->enc, adjrange, p, end);
if (IS_NULL(p)) goto fail;
goto retry;
}
break;
}
}
/* no needs to adjust *high, *high is used as range check only */
if (reg->dmax != ONIG_INFINITE_DISTANCE) {
*low = p - reg->dmax;
*high = p - reg->dmin;
*high = onigenc_get_right_adjust_char_head(reg->enc, adjrange, *high, end);
}
#ifdef ONIG_DEBUG_SEARCH
fprintf(stderr, "backward_search_range: low: %d, high: %d\n",
(int )(*low - str), (int )(*high - str));
#endif
return 1; /* success */
}
fail:
#ifdef ONIG_DEBUG_SEARCH
fprintf(stderr, "backward_search_range: fail.\n");
#endif
return 0; /* fail */
}
| 0
|
275,518
|
njs_vm_opt_init(njs_vm_opt_t *options)
{
njs_memzero(options, sizeof(njs_vm_opt_t));
}
| 0
|
455,287
|
mbskipname (pat, dname, flags)
char *pat, *dname;
int flags;
{
int ret, ext;
wchar_t *pat_wc, *dn_wc;
size_t pat_n, dn_n;
if (mbsmbchar (dname) == 0 && mbsmbchar (pat) == 0)
return (skipname (pat, dname, flags));
ext = 0;
#if EXTENDED_GLOB
ext = extglob_pattern_p (pat);
#endif
pat_wc = dn_wc = (wchar_t *)NULL;
pat_n = xdupmbstowcs (&pat_wc, NULL, pat);
if (pat_n != (size_t)-1)
dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
ret = 0;
if (pat_n != (size_t)-1 && dn_n !=(size_t)-1)
ret = ext ? wextglob_skipname (pat_wc, dn_wc, flags) : wskipname (pat_wc, dn_wc, flags);
else
ret = skipname (pat, dname, flags);
FREE (pat_wc);
FREE (dn_wc);
return ret;
}
| 0
|
379,327
|
do_exedit(
exarg_T *eap,
win_T *old_curwin) // curwin before doing a split or NULL
{
int n;
int need_hide;
int exmode_was = exmode_active;
if ((eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW)
|| ERROR_IF_TERM_POPUP_WINDOW)
return;
/*
* ":vi" command ends Ex mode.
*/
if (exmode_active && (eap->cmdidx == CMD_visual
|| eap->cmdidx == CMD_view))
{
exmode_active = FALSE;
ex_pressedreturn = FALSE;
if (*eap->arg == NUL)
{
// Special case: ":global/pat/visual\NLvi-commands"
if (global_busy)
{
int rd = RedrawingDisabled;
int nwr = no_wait_return;
int ms = msg_scroll;
#ifdef FEAT_GUI
int he = hold_gui_events;
#endif
if (eap->nextcmd != NULL)
{
stuffReadbuff(eap->nextcmd);
eap->nextcmd = NULL;
}
if (exmode_was != EXMODE_VIM)
settmode(TMODE_RAW);
RedrawingDisabled = 0;
no_wait_return = 0;
need_wait_return = FALSE;
msg_scroll = 0;
#ifdef FEAT_GUI
hold_gui_events = 0;
#endif
must_redraw = CLEAR;
pending_exmode_active = TRUE;
main_loop(FALSE, TRUE);
pending_exmode_active = FALSE;
RedrawingDisabled = rd;
no_wait_return = nwr;
msg_scroll = ms;
#ifdef FEAT_GUI
hold_gui_events = he;
#endif
}
return;
}
}
if ((eap->cmdidx == CMD_new
|| eap->cmdidx == CMD_tabnew
|| eap->cmdidx == CMD_tabedit
|| eap->cmdidx == CMD_vnew) && *eap->arg == NUL)
{
// ":new" or ":tabnew" without argument: edit a new empty buffer
setpcmark();
(void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
old_curwin == NULL ? curwin : NULL);
}
else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit)
|| *eap->arg != NUL
#ifdef FEAT_BROWSE
|| (cmdmod.cmod_flags & CMOD_BROWSE)
#endif
)
{
// Can't edit another file when "textlock" or "curbuf_lock" is set.
// Only ":edit" or ":script" can bring us here, others are stopped
// earlier.
if (*eap->arg != NUL && text_or_buf_locked())
return;
n = readonlymode;
if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview)
readonlymode = TRUE;
else if (eap->cmdidx == CMD_enew)
readonlymode = FALSE; // 'readonly' doesn't make sense in an
// empty buffer
if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd)
setpcmark();
if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
NULL, eap,
// ":edit" goes to first line if Vi compatible
(*eap->arg == NUL && eap->do_ecmd_lnum == 0
&& vim_strchr(p_cpo, CPO_GOTO1) != NULL)
? ECMD_ONE : eap->do_ecmd_lnum,
(buf_hide(curbuf) ? ECMD_HIDE : 0)
+ (eap->forceit ? ECMD_FORCEIT : 0)
// after a split we can use an existing buffer
+ (old_curwin != NULL ? ECMD_OLDBUF : 0)
+ (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0)
+ (eap->cmdidx == CMD_balt ? ECMD_ALTBUF : 0)
, old_curwin == NULL ? curwin : NULL) == FAIL)
{
// Editing the file failed. If the window was split, close it.
if (old_curwin != NULL)
{
need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1);
if (!need_hide || buf_hide(curbuf))
{
#if defined(FEAT_EVAL)
cleanup_T cs;
// Reset the error/interrupt/exception state here so that
// aborting() returns FALSE when closing a window.
enter_cleanup(&cs);
#endif
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_close(curwin, !need_hide && !buf_hide(curbuf));
#if defined(FEAT_EVAL)
// Restore the error/interrupt/exception state if not
// discarded by a new aborting error, interrupt, or
// uncaught exception.
leave_cleanup(&cs);
#endif
}
}
}
else if (readonlymode && curbuf->b_nwindows == 1)
{
// When editing an already visited buffer, 'readonly' won't be set
// but the previous value is kept. With ":view" and ":sview" we
// want the file to be readonly, except when another window is
// editing the same buffer.
curbuf->b_p_ro = TRUE;
}
readonlymode = n;
}
else
{
if (eap->do_ecmd_cmd != NULL)
do_cmd_argument(eap->do_ecmd_cmd);
n = curwin->w_arg_idx_invalid;
check_arg_idx(curwin);
if (n != curwin->w_arg_idx_invalid)
maketitle();
}
/*
* if ":split file" worked, set alternate file name in old window to new
* file
*/
if (old_curwin != NULL
&& *eap->arg != NUL
&& curwin != old_curwin
&& win_valid(old_curwin)
&& old_curwin->w_buffer != curbuf
&& (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
old_curwin->w_alt_fnum = curbuf->b_fnum;
ex_no_reprint = TRUE;
}
| 0
|
488,434
|
pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,
spinlock_t **ptl)
{
pgd_t * pgd = pgd_offset(mm, addr);
pud_t * pud = pud_alloc(mm, pgd, addr);
if (pud) {
pmd_t * pmd = pmd_alloc(mm, pud, addr);
if (pmd)
return pte_alloc_map_lock(mm, pmd, addr, ptl);
}
return NULL;
}
| 0
|
262,086
|
explicit BoostedTreesCalculateBestFeatureSplitV2(
OpKernelConstruction* const context)
: OpKernel(context) {
OP_REQUIRES_OK(context, context->GetAttr("logits_dimension", &logits_dim_));
OP_REQUIRES_OK(context, context->GetAttr("num_features", &num_features_));
}
| 0
|
230,987
|
mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const mrb_value *argv)
{
struct RProc *p;
mrb_callinfo *ci;
check_block(mrb, b);
p = mrb_proc_ptr(b);
ci = mrb->c->ci;
mrb_stack_extend(mrb, 4);
mrb->c->ci->stack[1] = mrb_ary_new_from_values(mrb, argc, argv);
mrb->c->ci->stack[2] = mrb_nil_value();
mrb->c->ci->stack[3] = mrb_nil_value();
ci->n = 15;
ci->nk = 0;
return exec_irep(mrb, self, p);
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.