problem
stringlengths
26
131k
labels
class label
2 classes
static inline void gen_bx(DisasContext *s, TCGv_i32 var) { s->is_jmp = DISAS_UPDATE; tcg_gen_andi_i32(cpu_R[15], var, ~1); tcg_gen_andi_i32(var, var, 1); store_cpu_field(var, thumb); }
1threat
I have an issue with ${name} thing, how do i construct it? : <p>This is the code:</p> <pre><code>function greetings(input){ let name = input.shift(); console.log('Hello, ${name}!'); } greetings(["Niki"]); </code></pre> <p>Where is the issue, because by the given example it is written the same way and the exit code is:</p> <pre><code>Hello, ${name}! </code></pre> <p>How do I type the code to actually write a name?</p>
0debug
forEach not a function error in node JS : I was taking a Udemy course, here is my code for an exercise that I was doing. Faker is a package downloaded from the NPM library var faker = require("faker"); console.log("+++++++++++++++++++"); console.log("Welcome to my shop!"); console.log("+++++++++++++++++++"); var data = faker.commerce.productName(); data.forEach(function(print){ console.log(data); }); I was expecting the code to iterate over every item in the variable "data" and print the result, however this is the result I get +++++++++++++++++++ Welcome to my shop! +++++++++++++++++++ /home/ubuntu/workspace/node_practice/demo_app/app.js:8 data.forEach(function(print){ ^ TypeError: data.forEach is not a function at Object.<anonymous> (/home/ubuntu/workspace/node_practice/demo_app/app.js:8:6) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:389:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:504:3 I am using Cloud9 ide, why am I getting this error?
0debug
Detecting odd and even number in batch script : <p>I would like to know if I can make my batch script (<code>.bat</code>) to detect if a number is odd or even. Example: if the imput is an odd number, do this, if even, do that. This would be very helpfull for my next project.</p> <p>Thanks!</p>
0debug
How to implement a switch button with a button : <p>Helllo, i'm new in programming android my question is there a method for let a button create a new switch button with some caratteristic i want to, for example the name and a number.</p>
0debug
how can i copy an array from a class and double the size of the new array? : CDCatalogue::CDCatalogue() //creates array of 4 { maxsize=4; numcds = 0; cds = new CD[maxsize]; } //this copy cat into new array with double the size of cat CDCatalogue::CDCatalogue(const CDCatalogue& cat) { }
0debug
static void disas_ldst_excl(DisasContext *s, uint32_t insn) { int rt = extract32(insn, 0, 5); int rn = extract32(insn, 5, 5); int rt2 = extract32(insn, 10, 5); int is_lasr = extract32(insn, 15, 1); int rs = extract32(insn, 16, 5); int is_pair = extract32(insn, 21, 1); int is_store = !extract32(insn, 22, 1); int is_excl = !extract32(insn, 23, 1); int size = extract32(insn, 30, 2); TCGv_i64 tcg_addr; if ((!is_excl && !is_lasr) || (is_pair && size < 2)) { unallocated_encoding(s); return; } if (rn == 31) { gen_check_sp_alignment(s); } tcg_addr = read_cpu_reg_sp(s, rn, 1); if (is_excl) { if (!is_store) { s->is_ldex = true; gen_load_exclusive(s, rt, rt2, tcg_addr, size, is_pair); } else { gen_store_exclusive(s, rs, rt, rt2, tcg_addr, size, is_pair); } } else { TCGv_i64 tcg_rt = cpu_reg(s, rt); if (is_store) { do_gpr_st(s, tcg_rt, tcg_addr, size); } else { do_gpr_ld(s, tcg_rt, tcg_addr, size, false, false); } if (is_pair) { TCGv_i64 tcg_rt2 = cpu_reg(s, rt); tcg_gen_addi_i64(tcg_addr, tcg_addr, 1 << size); if (is_store) { do_gpr_st(s, tcg_rt2, tcg_addr, size); } else { do_gpr_ld(s, tcg_rt2, tcg_addr, size, false, false); } } } }
1threat
ScalaTest DeferredAbortedSuite error when running simple tests. : <p>My original code had a lot more going on, which distracted me from the true cause of the problem. This captures the essential problem.</p> <pre><code>import org.scalatest.AsyncFlatSpec import scala.concurrent.Future class AsyncFlatSpecSpec extends AsyncFlatSpec { it should "parse an XML file" in { // ... Parsing ... Future.successful(succeed) } it should "parse an XML file" in { // ... Serializing ... Future.successful(succeed) } } </code></pre> <p>This produced these errors:</p> <pre><code>[info] DeferredAbortedSuite: [error] Uncaught exception when running AsyncFlatSpecSpec: java.lang.ArrayIndexOutOfBoundsException: 17 [trace] Stack trace suppressed: run last test:testOnly for the full output. </code></pre> <p>There is no array access happening anywhere in my code. What's going on?</p> <p>Running "last test:testOnly" wasn't much help:</p> <pre><code>[info] DeferredAbortedSuite: [error] Uncaught exception when running AsyncFlatSpecSpec: java.lang.ArrayIndexOutOfBoundsException: 17 sbt.ForkMain$ForkError: java.lang.ArrayIndexOutOfBoundsException: 17 at org.scalatest.exceptions.StackDepth$class.stackTraceElement(StackDepth.scala:63) at org.scalatest.exceptions.StackDepth$class.failedCodeFileName(StackDepth.scala:77) at org.scalatest.exceptions.StackDepthException.failedCodeFileName(StackDepthException.scala:36) at org.scalatest.exceptions.StackDepth$class.failedCodeFileNameAndLineNumberString(StackDepth.scala:59) at org.scalatest.exceptions.StackDepthException.failedCodeFileNameAndLineNumberString(StackDepthException.scala:36) at org.scalatest.tools.StringReporter$.withPossibleLineNumber(StringReporter.scala:442) at org.scalatest.tools.StringReporter$.stringsToPrintOnError(StringReporter.scala:916) at org.scalatest.tools.StringReporter$.fragmentsForEvent(StringReporter.scala:747) at org.scalatest.tools.Framework$SbtLogInfoReporter.apply(Framework.scala:622) at org.scalatest.tools.FilterReporter.apply(FilterReporter.scala:41) at org.scalatest.tools.SbtDispatchReporter$$anonfun$apply$1.apply(SbtDispatchReporter.scala:23) at org.scalatest.tools.SbtDispatchReporter$$anonfun$apply$1.apply(SbtDispatchReporter.scala:23) at scala.collection.Iterator$class.foreach(Iterator.scala:893) at scala.collection.AbstractIterator.foreach(Iterator.scala:1336) at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) at scala.collection.AbstractIterable.foreach(Iterable.scala:54) at org.scalatest.tools.SbtDispatchReporter.apply(SbtDispatchReporter.scala:23) at org.scalatest.tools.Framework$SbtReporter.apply(Framework.scala:1119) at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:387) at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:506) at sbt.ForkMain$Run$2.call(ForkMain.java:296) at sbt.ForkMain$Run$2.call(ForkMain.java:286) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) </code></pre> <p>Confused, I retreated to the non-Async version, to see if that fared any better.</p> <pre><code>import org.scalatest.FlatSpec class FlatSpecSpec extends FlatSpec { it should "parse an XML file" in { // ... Parsing ... succeed } it should "parse an XML file" in { // ... Serializing ... succeed } } </code></pre> <p>It produced this different, but still cryptic error message:</p> <pre><code>[info] DeferredAbortedSuite: [info] Exception encountered when attempting to run a suite with class name: org.scalatest.DeferredAbortedSuite *** ABORTED *** (20 milliseconds) [info] Exception encountered when attempting to run a suite with class name: org.scalatest.DeferredAbortedSuite (AsyncFlatSpecSpec.scala:32) [info] ScalaTest </code></pre> <p>For completeness, here are the related portions of my build.sbt:</p> <pre><code>scalaVersion := "2.11.8" libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0-M15" % "test" libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.0-M15" </code></pre> <p>This was ultimately a trivial mistake on my part, but I wanted to post this for the sake of anyone else Googling these errors.</p>
0debug
Category and Sub category in one row in sql : How we can show category and sub category in one row in sql.Both columns are present in same table.If anyone knows please help. Thanks in advance!!!!!
0debug
How do I only allow letters when asking for a name in python? : <p>I am new to coding in python and need to know how to only allow the user to enter letters when inputting a name. So if they input a number or nothing at all, I want the code to say something like "Please only use letters, try again".</p> <p>Cheers Chris</p>
0debug
What goes in a Stack package.yaml file? : <p>I notice that Stack supports using a <code>package.yaml</code> file that it will use to generate a <code>.cabal</code> file. For example, <a href="https://github.com/yi-editor/yi/blob/2f0c7b738b3a1f79ff149034db2c4392273ee26f/yi-core/package.yaml">yi-core/package.yaml</a>. Its structure seems very similar to a Cabal file, but not quite the same. Some of the keys have been renamed (for example, Stack uses <code>source-dirs</code> instead of <code>hs-source-dirs</code>).</p> <p>I haven't found any documentation on this feature. <a href="https://docs.haskellstack.org/en/stable/yaml_configuration/">The Stack docs</a> don't seem to mention <code>package.yaml</code> at all. Does a specification exist?</p>
0debug
static int slice_decode_thread(AVCodecContext *c, void *arg){ MpegEncContext *s= *(void**)arg; const uint8_t *buf= s->gb.buffer; int mb_y= s->start_mb_y; const int field_pic= s->picture_structure != PICT_FRAME; s->error_count= (3*(s->end_mb_y - s->start_mb_y)*s->mb_width) >> field_pic; for(;;){ uint32_t start_code; int ret; ret= mpeg_decode_slice((Mpeg1Context*)s, mb_y, &buf, s->gb.buffer_end - buf); emms_c(); if(ret < 0){ if(s->resync_mb_x>=0 && s->resync_mb_y>=0) ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR); }else{ ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END); } if(s->mb_y == s->end_mb_y) return 0; start_code= -1; buf = ff_find_start_code(buf, s->gb.buffer_end, &start_code); mb_y= (start_code - SLICE_MIN_START_CODE) << field_pic; if (s->picture_structure == PICT_BOTTOM_FIELD) mb_y++; if(mb_y < 0 || mb_y >= s->end_mb_y) return -1; } return 0; }
1threat
my echo "<tr> </tr"; error when i use bootsrap : echo "<tr class ='a'> <td>".$data->id."</td> <td>".$data->nis."</td> <td>".$data->nama."</td> <td>".$data->jenis_kelamin."</td> <td>".$data->telp."</td> <td>".$data->alamat."</td> <td><a class="btn btn-warning" href="'.base_url("siswa/ubah/".$data->id).'">Ubah</a></td> <td><a class="btn btn-danger" href="'.base_url("siswa/hapus/".$data->id).'">Hapus</a></td> </tr>"; its error when i use bootstrap in my coding, how to keep this from error?
0debug
how to search with specific permission in unix : Print a listing, in long form, of all non-hidden entries ( files, directories, etc.) in the current directory that are executable by at least one of owner, group, other (the other permission bits could be anything).
0debug
Convert Object to a List of Arrays : <p>I am being passed a key/value object called obj that needs to convert to a list of arrays in an array ( arr[ [key: value] [key: value] ] )</p> <pre><code>function convertObjectToList(obj) { var arr = []; var i = 0; for(var key in obj){ arr[0][i][0] = key; arr[0][i][1] = obj[key]; i++; } return arr; } </code></pre>
0debug
Error:Internal error: (java.lang.ClassNotFoundException) com.google.wireless.android.sdk.stats.IntellijIndexingStats$Index : <p>Android Studio 3.4.</p> <p>Project SDK (Android API 19 Platform).</p> <p>Not using FindBugs or SpotBugs.</p> <p>Every attempt to build, I get this error:</p> <pre><code>Information:9/05/2019 4:02 PM - Compilation completed with 1 error and 0 warnings in 1 s 763 ms Error:Internal error: (java.lang.ClassNotFoundException) com.google.wireless.android.sdk.stats.IntellijIndexingStats$Index java.lang.ClassNotFoundException: com.google.wireless.android.sdk.stats.IntellijIndexingStats$Index at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.intellij.util.indexing.counters.IndexCounters.&lt;clinit&gt;(IndexCounters.java:34) at com.intellij.util.indexing.impl.MapReduceIndex.&lt;init&gt;(MapReduceIndex.java:86) at org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex$CompilerMapReduceIndex.&lt;init&gt;(CompilerReferenceIndex.java:214) at org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex.&lt;init&gt;(CompilerReferenceIndex.java:73) at org.jetbrains.jps.backwardRefs.JavaCompilerBackwardReferenceIndex.&lt;init&gt;(JavaCompilerBackwardReferenceIndex.java:12) at org.jetbrains.jps.backwardRefs.JavaBackwardReferenceIndexWriter.initialize(JavaBackwardReferenceIndexWriter.java:74) at org.jetbrains.jps.backwardRefs.JavaBackwardReferenceIndexBuilder.buildStarted(JavaBackwardReferenceIndexBuilder.java:40) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:358) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135) at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:229) at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) </code></pre>
0debug
NSDateFormatter and current language in iOS11 : <p>It appears that default behavior for <code>NSDateFormatter</code> has been changed in iOS11. This code used to work and produced date formatter according to currently selected iPhone/iPad language prior to iOS11:</p> <pre><code> _dateFormatterInstance = [[NSDateFormatter alloc] init]; _dateFormatterInstance.timeZone = [NSTimeZone systemTimeZone]; </code></pre> <p>Looks like in iOS11 we have to explicitly specify locale property for it:</p> <pre><code> _dateFormatterInstance = [[NSDateFormatter alloc] init]; _dateFormatterInstance.timeZone = [NSTimeZone systemTimeZone]; _dateFormatterInstance.locale = [NSLocale localeWithLocaleIdentifier:[[NSLocale preferredLanguages] firstObject]]; </code></pre> <p>Can somebody confirm my findings? </p>
0debug
Firebase gets stuck on no INTERNET connection : <p>In my app, I am using Firebase for database. Now when I am listening for any change in child nodes of a particular location, and if there is no internet connection, no callback gets fired. The firebase call just gets stuck.</p> <p>I am using this,</p> <pre><code>FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(); firebaseDatabase.setPersistenceEnabled(true); </code></pre> <p>So, persistence is enabled. The problem occurs only one one scenario. When there is no data on the local persistence of Firebase and the internet connection is also not available. </p> <p>I am using this,</p> <pre><code>addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { } @Override public void onCancelled(DatabaseError databaseError) { Timber.d("Cancelled"); } }); </code></pre> <p>I am not getting any of the two callbacks for that particular scenario.</p> <p>What should I do to tackle this kind of scenario? </p>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
android - ViewCompat setBackgroundTintList not working in API 21 : <p>I have a <em>AppCompatEditText</em> with the property <em>backgroundTint</em> setted to an specific color. I've created a method to change the background tint programmatically and its working in all Android versions since API 17 (4.2 Jelly Bean) to API 25 (7.1.1 Nougat), <strong>except API 21 (5.0 Lollipop)</strong>.</p> <p>I don't know what I'm doing wrong. Here's my code:</p> <pre><code> public void changeViewBackgroundColor(Context context, View view, int color) { int theColor = ContextCompat.getColor(context, color); if (view instanceof TintableBackgroundView) { ColorStateList colorStateList = ColorStateList.valueOf(theColor); ViewCompat.setBackgroundTintList(view, colorStateList); } else { view.setBackgroundColor(theColor); } view.invalidate(); } </code></pre>
0debug
why when modal pops up, other places are darkened? : [a modal](https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal) example is here, I can not figure out which part of the code makes the things darkened when we click open modal, please give me any hint, thank you.
0debug
HTML set values : I have these 2 table cells. The One span is outside td, other is around td. <tr height="30"> <span data-name="toDD1" class="sstNumber"> </span> <td>Y</td> <span data-name="toDD2" class="sstNumber"> <td>Y</td> </span> </tr> When I do the following code to set values, the value does not get updated. `document.querySelector('span[data-name="toDD1"]').value = "a"; document.querySelector('span[data-name="toDD2"]').value = "b";`
0debug
php file isn't working properly, I can't open it on browser, it opens the text editer instead : <p>So I'm just starting to learn php, and when trying " Hello World" the file isn't executing properly. I have Bitnami MAMP Stack 5.6.31 . I'm pretty sure it's not something wrong with the code, possibly with the install of the AMP stack, but this is the code anyway :</p> <pre><code> &lt;?php echo "Hello World"; ?&gt; </code></pre>
0debug
How do you reference images contained in a folder in the Firebase storage and display them in a recycler view : <p>I'm trying to get a reference to images stored within a folder in firebase Storage,with text(which are stored in Firebase Database) on a card view stored and display them on a recycler view. please i hope this is well asked as it is my first question on stackoverflow</p>
0debug
Undefined index: action : <p>The highlighted line is line 24</p> <p>Notice: Undefined index: action in C:\xampp\htdocs\authors.php on line 24</p> <pre><code> **if($_GET['action'] == "list") {** $current = "members"; $list = "members"; } else if($_GET["list"] == "authors") $current = "authors"; else $current = "members"; </code></pre>
0debug
static float get_band_cost_NONE_mips(struct AACEncContext *s, PutBitContext *pb, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits) { av_assert0(0); return 0; }
1threat
static void vnc_zlib_start(VncState *vs) { buffer_reset(&vs->zlib); vs->zlib_tmp = vs->output; vs->output = vs->zlib; }
1threat
int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback, void *opaque, Error **errp) { int fd; switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: fd = inet_connect_saddr(addr->u.inet.data, callback, opaque, errp); break; case SOCKET_ADDRESS_KIND_UNIX: fd = unix_connect_saddr(addr->u.q_unix.data, callback, opaque, errp); break; case SOCKET_ADDRESS_KIND_FD: fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp); if (fd >= 0 && callback) { qemu_set_nonblock(fd); callback(fd, NULL, opaque); } break; case SOCKET_ADDRESS_KIND_VSOCK: fd = vsock_connect_saddr(addr->u.vsock.data, callback, opaque, errp); break; default: abort(); } return fd; }
1threat
static void qemu_chr_free_common(CharDriverState *chr) { g_free(chr->filename); g_free(chr->label); if (chr->logfd != -1) { close(chr->logfd); qemu_mutex_destroy(&chr->chr_write_lock); g_free(chr);
1threat
Parse download of Json Data from URL in C# : I have some json data which i have downloaded from a URL as gz file, i then decropressed and read the json as a string I am trying to loop through the records and neither jArray or JObject seem to work Any ideas how best to read in this data object by object? {"user_id":"25c6b8080aa26","email":"XXZZZZ@gmail.com","roles":"Manager"} {"user_id":"1a25c6b8080b6ac","email":"XXXXX@gmail.com"}
0debug
static void fill_buffer(AVIOContext *s) { int max_buffer_size = s->max_packet_size ? s->max_packet_size : IO_BUFFER_SIZE; uint8_t *dst = s->buf_end - s->buffer + max_buffer_size < s->buffer_size ? s->buf_end : s->buffer; int len = s->buffer_size - (dst - s->buffer); if (!s->read_packet && s->buf_ptr >= s->buf_end) s->eof_reached = 1; if (s->eof_reached) return; if (s->update_checksum && dst == s->buffer) { if (s->buf_end > s->checksum_ptr) s->checksum = s->update_checksum(s->checksum, s->checksum_ptr, s->buf_end - s->checksum_ptr); s->checksum_ptr = s->buffer; } if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size) { if (dst == s->buffer && s->buf_ptr != dst) { int ret = ffio_set_buf_size(s, s->orig_buffer_size); if (ret < 0) av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n"); s->checksum_ptr = dst = s->buffer; } av_assert0(len >= s->orig_buffer_size); len = s->orig_buffer_size; } if (s->read_packet) len = s->read_packet(s->opaque, dst, len); else len = AVERROR_EOF; if (len == AVERROR_EOF) { s->eof_reached = 1; } else if (len < 0) { s->eof_reached = 1; s->error= len; } else { s->pos += len; s->buf_ptr = dst; s->buf_end = dst + len; s->bytes_read += len; } }
1threat
int img_convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src, int src_pix_fmt, int src_width, int src_height) { static int inited; int i, ret, dst_width, dst_height, int_pix_fmt; const PixFmtInfo *src_pix, *dst_pix; const ConvertEntry *ce; AVPicture tmp1, *tmp = &tmp1; if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB || dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB) return -1; if (src_width <= 0 || src_height <= 0) return 0; if (!inited) { inited = 1; img_convert_init(); } dst_width = src_width; dst_height = src_height; dst_pix = &pix_fmt_info[dst_pix_fmt]; src_pix = &pix_fmt_info[src_pix_fmt]; if (src_pix_fmt == dst_pix_fmt) { av_picture_copy(dst, src, dst_pix_fmt, dst_width, dst_height); return 0; } ce = &convert_table[src_pix_fmt][dst_pix_fmt]; if (ce->convert) { ce->convert(dst, src, dst_width, dst_height); return 0; } if (is_yuv_planar(dst_pix) && src_pix_fmt == PIX_FMT_GRAY8) { int w, h, y; uint8_t *d; if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { ff_img_copy_plane(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_jpeg_to_ccir); } w = dst_width; h = dst_height; w >>= dst_pix->x_chroma_shift; h >>= dst_pix->y_chroma_shift; for(i = 1; i <= 2; i++) { d = dst->data[i]; for(y = 0; y< h; y++) { memset(d, 128, w); d += dst->linesize[i]; } } return 0; } if (is_yuv_planar(src_pix) && dst_pix_fmt == PIX_FMT_GRAY8) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) { ff_img_copy_plane(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); } else { img_apply_table(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height, y_ccir_to_jpeg); } return 0; } if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) { int x_shift, y_shift, w, h, xy_shift; void (*resize_func)(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); w = dst_width; h = dst_height; if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift) w >>= dst_pix->x_chroma_shift; else w >>= src_pix->x_chroma_shift; if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift) h >>= dst_pix->y_chroma_shift; else h >>= src_pix->y_chroma_shift; x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift); y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift); xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf); switch(xy_shift) { case 0x00: resize_func = ff_img_copy_plane; break; case 0x10: resize_func = shrink21; break; case 0x20: resize_func = shrink41; break; case 0x01: resize_func = shrink12; break; case 0x11: resize_func = ff_shrink22; break; case 0x22: resize_func = ff_shrink44; break; case 0xf0: resize_func = grow21; break; case 0x0f: resize_func = grow12; break; case 0xe0: resize_func = grow41; break; case 0xff: resize_func = grow22; break; case 0xee: resize_func = grow44; break; case 0xf1: resize_func = conv411; break; default: goto no_chroma_filter; } ff_img_copy_plane(dst->data[0], dst->linesize[0], src->data[0], src->linesize[0], dst_width, dst_height); for(i = 1;i <= 2; i++) resize_func(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift); if (dst_pix->color_type != src_pix->color_type) { const uint8_t *y_table, *c_table; if (dst_pix->color_type == FF_COLOR_YUV) { y_table = y_jpeg_to_ccir; c_table = c_jpeg_to_ccir; } else { y_table = y_ccir_to_jpeg; c_table = c_ccir_to_jpeg; } img_apply_table(dst->data[0], dst->linesize[0], dst->data[0], dst->linesize[0], dst_width, dst_height, y_table); for(i = 1;i <= 2; i++) img_apply_table(dst->data[i], dst->linesize[i], dst->data[i], dst->linesize[i], dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift, c_table); } return 0; } no_chroma_filter: if (src_pix_fmt == PIX_FMT_YUYV422 || dst_pix_fmt == PIX_FMT_YUYV422) { int_pix_fmt = PIX_FMT_YUV422P; } else if (src_pix_fmt == PIX_FMT_UYVY422 || dst_pix_fmt == PIX_FMT_UYVY422) { int_pix_fmt = PIX_FMT_YUV422P; } else if (src_pix_fmt == PIX_FMT_UYYVYY411 || dst_pix_fmt == PIX_FMT_UYYVYY411) { int_pix_fmt = PIX_FMT_YUV411P; } else if ((src_pix->color_type == FF_COLOR_GRAY && src_pix_fmt != PIX_FMT_GRAY8) || (dst_pix->color_type == FF_COLOR_GRAY && dst_pix_fmt != PIX_FMT_GRAY8)) { int_pix_fmt = PIX_FMT_GRAY8; } else if ((is_yuv_planar(src_pix) && src_pix_fmt != PIX_FMT_YUV444P && src_pix_fmt != PIX_FMT_YUVJ444P)) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else if ((is_yuv_planar(dst_pix) && dst_pix_fmt != PIX_FMT_YUV444P && dst_pix_fmt != PIX_FMT_YUVJ444P)) { if (dst_pix->color_type == FF_COLOR_YUV_JPEG) int_pix_fmt = PIX_FMT_YUVJ444P; else int_pix_fmt = PIX_FMT_YUV444P; } else { if (src_pix->is_alpha && dst_pix->is_alpha) int_pix_fmt = PIX_FMT_RGB32; else int_pix_fmt = PIX_FMT_RGB24; } if (src_pix_fmt == int_pix_fmt) return -1; if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0) return -1; ret = -1; if (img_convert(tmp, int_pix_fmt, src, src_pix_fmt, src_width, src_height) < 0) goto fail1; if (img_convert(dst, dst_pix_fmt, tmp, int_pix_fmt, dst_width, dst_height) < 0) goto fail1; ret = 0; fail1: avpicture_free(tmp); return ret; }
1threat
static int http_open(URLContext *h, const char *uri, int flags) { HTTPContext *s = h->priv_data; h->is_streamed = 1; s->filesize = -1; av_strlcpy(s->location, uri, sizeof(s->location)); if (s->headers) { int len = strlen(s->headers); if (len < 2 || strcmp("\r\n", s->headers + len - 2)) av_log(h, AV_LOG_WARNING, "No trailing CRLF found in HTTP header.\n"); } return http_open_cnx(h); }
1threat
ConcurrentDictionary AddOrUpdate method(C#) throwing Index was outside the bounds of the array : Looks like objects are trying to get added to the HashSet at the same time and throwing this error. Is there any solution for this ? System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Collections.Generic.HashSet`1.SetCapacity(Int32 newSize, Boolean forceNewHashCodes) at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value) at Raj.OPS.Common.Test.<>c__DisplayClass38_0.<SetOrAddKey>b__1(mKey key, HashSet`1 alloc) in at System.Collections.Concurrent.ConcurrentDictionary`2.**AddOrUpdate**(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory)
0debug
static void set_port(struct sockaddr_storage *ss, int port) { sockaddr_union ssu = (sockaddr_union){.storage = *ss}; if (ss->ss_family == AF_INET) ssu.in.sin_port = htons(port); #if HAVE_STRUCT_SOCKADDR_IN6 else if (ss->ss_family == AF_INET6) ssu.in6.sin6_port = htons(port); #endif *ss = ssu.storage; }
1threat
ValueError: all the input arrays must have same number of dimensions : <p>I'm having a problem with <code>np.append</code>.</p> <p>I'm trying to duplicate the last column of 20x361 matrix <code>n_list_converted</code> by using the code below:</p> <pre><code>n_last = [] n_last = n_list_converted[:, -1] n_lists = np.append(n_list_converted, n_last, axis=1) </code></pre> <p>But I get error: </p> <blockquote> <p>ValueError: all the input arrays must have same number of dimensions</p> </blockquote> <p>However, I've checked the matrix dimensions by doing</p> <pre><code> print(n_last.shape, type(n_last), n_list_converted.shape, type(n_list_converted)) </code></pre> <p>and I get </p> <blockquote> <p>(20L,) (20L, 361L) </p> </blockquote> <p>so the dimensions match? Where is the mistake?</p>
0debug
How block a keyboard to write in other Applications? : I am using a simple Hookup to record the keys from a BarcodeScanner which is a connect via Usb as Keyboard. I am using this example out of the I-net: using System.Windows.Forms; namespace RawInput { public partial class Form1 : Form { InputDevice id; int NumberOfKeyboards; public Form1() { InitializeComponent(); // Create a new InputDevice object, get the number of // keyboards, and register the method which will handle the // InputDevice KeyPressed event id = new InputDevice( Handle ); NumberOfKeyboards = id.EnumerateDevices(); id.KeyPressed += new InputDevice.DeviceEventHandler( m_KeyPressed ); } // The WndProc is overridden to allow InputDevice to intercept // messages to the window and thus catch WM_INPUT messages protected override void WndProc( ref Message message ) { if( id != null ) { id.ProcessMessage( message ); } base.WndProc( ref message ); } private void m_KeyPressed( object sender, InputDevice.KeyControlEventArgs e ) { //Replace() is just a cosmetic fix to stop ampersands turning into underlines lbHandle.Text = e.Keyboard.deviceHandle.ToString(); lbType.Text = e.Keyboard.deviceType; lbName.Text = e.Keyboard.deviceName.Replace("&", "&&"); lbDescription.Text = e.Keyboard.Name; lbKey.Text = e.Keyboard.key.ToString(); lbNumKeyboards.Text = NumberOfKeyboards.ToString(); lbVKey.Text = e.Keyboard.vKey; } private void btnClose_Click(object sender, System.EventArgs e) { this.Close(); } } } I have the problem now that the BarCode Scanner writes his stuff at the current program. My Application should run in the background so its not possible to just use focus on form and focus on text field. i am to dumb to google after it, i only find how only block evrything, without getting the Keypress.
0debug
static void gen_sse(DisasContext *s, int b, target_ulong pc_start, int rex_r) { int b1, op1_offset, op2_offset, is_xmm, val, ot; int modrm, mod, rm, reg, reg_addr, offset_addr; void *sse_op2; b &= 0xff; if (s->prefix & PREFIX_DATA) b1 = 1; else if (s->prefix & PREFIX_REPZ) b1 = 2; else if (s->prefix & PREFIX_REPNZ) b1 = 3; else b1 = 0; sse_op2 = sse_op_table1[b][b1]; if (!sse_op2) goto illegal_op; if ((b <= 0x5f && b >= 0x10) || b == 0xc6 || b == 0xc2) { is_xmm = 1; } else { if (b1 == 0) { is_xmm = 0; } else { is_xmm = 1; } } if (s->flags & HF_TS_MASK) { gen_exception(s, EXCP07_PREX, pc_start - s->cs_base); return; } if (s->flags & HF_EM_MASK) { illegal_op: gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base); return; } if (is_xmm && !(s->flags & HF_OSFXSR_MASK)) if ((b != 0x38 && b != 0x3a) || (s->prefix & PREFIX_DATA)) goto illegal_op; if (b == 0x0e) { if (!(s->cpuid_ext2_features & CPUID_EXT2_3DNOW)) goto illegal_op; tcg_gen_helper_0_0(helper_emms); return; } if (b == 0x77) { tcg_gen_helper_0_0(helper_emms); return; } if (!is_xmm) { tcg_gen_helper_0_0(helper_enter_mmx); } modrm = ldub_code(s->pc++); reg = ((modrm >> 3) & 7); if (is_xmm) reg |= rex_r; mod = (modrm >> 6) & 3; if (sse_op2 == SSE_SPECIAL) { b |= (b1 << 8); switch(b) { case 0x0e7: if (mod == 3) goto illegal_op; gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_stq_env_A0(s->mem_index, offsetof(CPUX86State,fpregs[reg].mmx)); break; case 0x1e7: case 0x02b: case 0x12b: case 0x3f0: if (mod == 3) goto illegal_op; gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_sto_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg])); break; case 0x6e: #ifdef TARGET_X86_64 if (s->dflag == 2) { gen_ldst_modrm(s, modrm, OT_QUAD, OR_TMP0, 0); tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,fpregs[reg].mmx)); } else #endif { gen_ldst_modrm(s, modrm, OT_LONG, OR_TMP0, 0); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,fpregs[reg].mmx)); tcg_gen_helper_0_2(helper_movl_mm_T0_mmx, cpu_ptr0, cpu_T[0]); } break; case 0x16e: #ifdef TARGET_X86_64 if (s->dflag == 2) { gen_ldst_modrm(s, modrm, OT_QUAD, OR_TMP0, 0); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,xmm_regs[reg])); tcg_gen_helper_0_2(helper_movq_mm_T0_xmm, cpu_ptr0, cpu_T[0]); } else #endif { gen_ldst_modrm(s, modrm, OT_LONG, OR_TMP0, 0); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,xmm_regs[reg])); tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]); tcg_gen_helper_0_2(helper_movl_mm_T0_xmm, cpu_ptr0, cpu_tmp2_i32); } break; case 0x6f: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,fpregs[reg].mmx)); } else { rm = (modrm & 7); tcg_gen_ld_i64(cpu_tmp1_i64, cpu_env, offsetof(CPUX86State,fpregs[rm].mmx)); tcg_gen_st_i64(cpu_tmp1_i64, cpu_env, offsetof(CPUX86State,fpregs[reg].mmx)); } break; case 0x010: case 0x110: case 0x028: case 0x128: case 0x16f: case 0x26f: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldo_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg])); } else { rm = (modrm & 7) | REX_B(s); gen_op_movo(offsetof(CPUX86State,xmm_regs[reg]), offsetof(CPUX86State,xmm_regs[rm])); } break; case 0x210: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_op_ld_T0_A0(OT_LONG + s->mem_index); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(0))); gen_op_movl_T0_0(); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(1))); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(2))); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(3))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(0)), offsetof(CPUX86State,xmm_regs[rm].XMM_L(0))); } break; case 0x310: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); gen_op_movl_T0_0(); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(2))); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(3))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0)), offsetof(CPUX86State,xmm_regs[rm].XMM_Q(0))); } break; case 0x012: case 0x112: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0)), offsetof(CPUX86State,xmm_regs[rm].XMM_Q(1))); } break; case 0x212: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldo_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg])); } else { rm = (modrm & 7) | REX_B(s); gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(0)), offsetof(CPUX86State,xmm_regs[rm].XMM_L(0))); gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(2)), offsetof(CPUX86State,xmm_regs[rm].XMM_L(2))); } gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(1)), offsetof(CPUX86State,xmm_regs[reg].XMM_L(0))); gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(3)), offsetof(CPUX86State,xmm_regs[reg].XMM_L(2))); break; case 0x312: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0)), offsetof(CPUX86State,xmm_regs[rm].XMM_Q(0))); } gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(1)), offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); break; case 0x016: case 0x116: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(1))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(1)), offsetof(CPUX86State,xmm_regs[rm].XMM_Q(0))); } break; case 0x216: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldo_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg])); } else { rm = (modrm & 7) | REX_B(s); gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(1)), offsetof(CPUX86State,xmm_regs[rm].XMM_L(1))); gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(3)), offsetof(CPUX86State,xmm_regs[rm].XMM_L(3))); } gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(0)), offsetof(CPUX86State,xmm_regs[reg].XMM_L(1))); gen_op_movl(offsetof(CPUX86State,xmm_regs[reg].XMM_L(2)), offsetof(CPUX86State,xmm_regs[reg].XMM_L(3))); break; case 0x7e: #ifdef TARGET_X86_64 if (s->dflag == 2) { tcg_gen_ld_i64(cpu_T[0], cpu_env, offsetof(CPUX86State,fpregs[reg].mmx)); gen_ldst_modrm(s, modrm, OT_QUAD, OR_TMP0, 1); } else #endif { tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,fpregs[reg].mmx.MMX_L(0))); gen_ldst_modrm(s, modrm, OT_LONG, OR_TMP0, 1); } break; case 0x17e: #ifdef TARGET_X86_64 if (s->dflag == 2) { tcg_gen_ld_i64(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); gen_ldst_modrm(s, modrm, OT_QUAD, OR_TMP0, 1); } else #endif { tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(0))); gen_ldst_modrm(s, modrm, OT_LONG, OR_TMP0, 1); } break; case 0x27e: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0)), offsetof(CPUX86State,xmm_regs[rm].XMM_Q(0))); } gen_op_movq_env_0(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(1))); break; case 0x7f: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_stq_env_A0(s->mem_index, offsetof(CPUX86State,fpregs[reg].mmx)); } else { rm = (modrm & 7); gen_op_movq(offsetof(CPUX86State,fpregs[rm].mmx), offsetof(CPUX86State,fpregs[reg].mmx)); } break; case 0x011: case 0x111: case 0x029: case 0x129: case 0x17f: case 0x27f: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_sto_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg])); } else { rm = (modrm & 7) | REX_B(s); gen_op_movo(offsetof(CPUX86State,xmm_regs[rm]), offsetof(CPUX86State,xmm_regs[reg])); } break; case 0x211: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_L(0))); gen_op_st_T0_A0(OT_LONG + s->mem_index); } else { rm = (modrm & 7) | REX_B(s); gen_op_movl(offsetof(CPUX86State,xmm_regs[rm].XMM_L(0)), offsetof(CPUX86State,xmm_regs[reg].XMM_L(0))); } break; case 0x311: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_stq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,xmm_regs[rm].XMM_Q(0)), offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); } break; case 0x013: case 0x113: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_stq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); } else { goto illegal_op; } break; case 0x017: case 0x117: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_stq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(1))); } else { goto illegal_op; } break; case 0x71: case 0x72: case 0x73: case 0x171: case 0x172: case 0x173: val = ldub_code(s->pc++); if (is_xmm) { gen_op_movl_T0_im(val); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_t0.XMM_L(0))); gen_op_movl_T0_0(); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_t0.XMM_L(1))); op1_offset = offsetof(CPUX86State,xmm_t0); } else { gen_op_movl_T0_im(val); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,mmx_t0.MMX_L(0))); gen_op_movl_T0_0(); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,mmx_t0.MMX_L(1))); op1_offset = offsetof(CPUX86State,mmx_t0); } sse_op2 = sse_op_table2[((b - 1) & 3) * 8 + (((modrm >> 3)) & 7)][b1]; if (!sse_op2) goto illegal_op; if (is_xmm) { rm = (modrm & 7) | REX_B(s); op2_offset = offsetof(CPUX86State,xmm_regs[rm]); } else { rm = (modrm & 7); op2_offset = offsetof(CPUX86State,fpregs[rm].mmx); } tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op2_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op1_offset); tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1); break; case 0x050: rm = (modrm & 7) | REX_B(s); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,xmm_regs[rm])); tcg_gen_helper_1_1(helper_movmskps, cpu_tmp2_i32, cpu_ptr0); tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32); gen_op_mov_reg_T0(OT_LONG, reg); break; case 0x150: rm = (modrm & 7) | REX_B(s); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,xmm_regs[rm])); tcg_gen_helper_1_1(helper_movmskpd, cpu_tmp2_i32, cpu_ptr0); tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32); gen_op_mov_reg_T0(OT_LONG, reg); break; case 0x02a: case 0x12a: tcg_gen_helper_0_0(helper_enter_mmx); if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); op2_offset = offsetof(CPUX86State,mmx_t0); gen_ldq_env_A0(s->mem_index, op2_offset); } else { rm = (modrm & 7); op2_offset = offsetof(CPUX86State,fpregs[rm].mmx); } op1_offset = offsetof(CPUX86State,xmm_regs[reg]); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); switch(b >> 8) { case 0x0: tcg_gen_helper_0_2(helper_cvtpi2ps, cpu_ptr0, cpu_ptr1); break; default: case 0x1: tcg_gen_helper_0_2(helper_cvtpi2pd, cpu_ptr0, cpu_ptr1); break; } break; case 0x22a: case 0x32a: ot = (s->dflag == 2) ? OT_QUAD : OT_LONG; gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0); op1_offset = offsetof(CPUX86State,xmm_regs[reg]); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); sse_op2 = sse_op_table3[(s->dflag == 2) * 2 + ((b >> 8) - 2)]; if (ot == OT_LONG) { tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]); tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_tmp2_i32); } else { tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_T[0]); } break; case 0x02c: case 0x12c: case 0x02d: case 0x12d: tcg_gen_helper_0_0(helper_enter_mmx); if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); op2_offset = offsetof(CPUX86State,xmm_t0); gen_ldo_env_A0(s->mem_index, op2_offset); } else { rm = (modrm & 7) | REX_B(s); op2_offset = offsetof(CPUX86State,xmm_regs[rm]); } op1_offset = offsetof(CPUX86State,fpregs[reg & 7].mmx); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); switch(b) { case 0x02c: tcg_gen_helper_0_2(helper_cvttps2pi, cpu_ptr0, cpu_ptr1); break; case 0x12c: tcg_gen_helper_0_2(helper_cvttpd2pi, cpu_ptr0, cpu_ptr1); break; case 0x02d: tcg_gen_helper_0_2(helper_cvtps2pi, cpu_ptr0, cpu_ptr1); break; case 0x12d: tcg_gen_helper_0_2(helper_cvtpd2pi, cpu_ptr0, cpu_ptr1); break; } break; case 0x22c: case 0x32c: case 0x22d: case 0x32d: ot = (s->dflag == 2) ? OT_QUAD : OT_LONG; if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); if ((b >> 8) & 1) { gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_t0.XMM_Q(0))); } else { gen_op_ld_T0_A0(OT_LONG + s->mem_index); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_t0.XMM_L(0))); } op2_offset = offsetof(CPUX86State,xmm_t0); } else { rm = (modrm & 7) | REX_B(s); op2_offset = offsetof(CPUX86State,xmm_regs[rm]); } sse_op2 = sse_op_table3[(s->dflag == 2) * 2 + ((b >> 8) - 2) + 4 + (b & 1) * 4]; tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op2_offset); if (ot == OT_LONG) { tcg_gen_helper_1_1(sse_op2, cpu_tmp2_i32, cpu_ptr0); tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32); } else { tcg_gen_helper_1_1(sse_op2, cpu_T[0], cpu_ptr0); } gen_op_mov_reg_T0(ot, reg); break; case 0xc4: case 0x1c4: s->rip_offset = 1; gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0); val = ldub_code(s->pc++); if (b1) { val &= 7; tcg_gen_st16_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[reg].XMM_W(val))); } else { val &= 3; tcg_gen_st16_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,fpregs[reg].mmx.MMX_W(val))); } break; case 0xc5: case 0x1c5: if (mod != 3) goto illegal_op; ot = (s->dflag == 2) ? OT_QUAD : OT_LONG; val = ldub_code(s->pc++); if (b1) { val &= 7; rm = (modrm & 7) | REX_B(s); tcg_gen_ld16u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_regs[rm].XMM_W(val))); } else { val &= 3; rm = (modrm & 7); tcg_gen_ld16u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,fpregs[rm].mmx.MMX_W(val))); } reg = ((modrm >> 3) & 7) | rex_r; gen_op_mov_reg_T0(ot, reg); break; case 0x1d6: if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_stq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); } else { rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,xmm_regs[rm].XMM_Q(0)), offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0))); gen_op_movq_env_0(offsetof(CPUX86State,xmm_regs[rm].XMM_Q(1))); } break; case 0x2d6: tcg_gen_helper_0_0(helper_enter_mmx); rm = (modrm & 7); gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0)), offsetof(CPUX86State,fpregs[rm].mmx)); gen_op_movq_env_0(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(1))); break; case 0x3d6: tcg_gen_helper_0_0(helper_enter_mmx); rm = (modrm & 7) | REX_B(s); gen_op_movq(offsetof(CPUX86State,fpregs[reg & 7].mmx), offsetof(CPUX86State,xmm_regs[rm].XMM_Q(0))); break; case 0xd7: case 0x1d7: if (mod != 3) goto illegal_op; if (b1) { rm = (modrm & 7) | REX_B(s); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,xmm_regs[rm])); tcg_gen_helper_1_1(helper_pmovmskb_xmm, cpu_tmp2_i32, cpu_ptr0); } else { rm = (modrm & 7); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,fpregs[rm].mmx)); tcg_gen_helper_1_1(helper_pmovmskb_mmx, cpu_tmp2_i32, cpu_ptr0); } tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32); reg = ((modrm >> 3) & 7) | rex_r; gen_op_mov_reg_T0(OT_LONG, reg); break; case 0x038: case 0x138: b = modrm; modrm = ldub_code(s->pc++); rm = modrm & 7; reg = ((modrm >> 3) & 7) | rex_r; mod = (modrm >> 6) & 3; if (s->prefix & PREFIX_REPNZ) goto crc32; sse_op2 = sse_op_table6[b].op[b1]; if (!sse_op2) goto illegal_op; if (!(s->cpuid_ext_features & sse_op_table6[b].ext_mask)) goto illegal_op; if (b1) { op1_offset = offsetof(CPUX86State,xmm_regs[reg]); if (mod == 3) { op2_offset = offsetof(CPUX86State,xmm_regs[rm | REX_B(s)]); } else { op2_offset = offsetof(CPUX86State,xmm_t0); gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); switch (b) { case 0x20: case 0x30: case 0x23: case 0x33: case 0x25: case 0x35: gen_ldq_env_A0(s->mem_index, op2_offset + offsetof(XMMReg, XMM_Q(0))); break; case 0x21: case 0x31: case 0x24: case 0x34: tcg_gen_qemu_ld32u(cpu_tmp2_i32, cpu_A0, (s->mem_index >> 2) - 1); tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, op2_offset + offsetof(XMMReg, XMM_L(0))); break; case 0x22: case 0x32: tcg_gen_qemu_ld16u(cpu_tmp0, cpu_A0, (s->mem_index >> 2) - 1); tcg_gen_st16_tl(cpu_tmp0, cpu_env, op2_offset + offsetof(XMMReg, XMM_W(0))); break; case 0x2a: gen_ldo_env_A0(s->mem_index, op1_offset); return; default: gen_ldo_env_A0(s->mem_index, op2_offset); } } } else { op1_offset = offsetof(CPUX86State,fpregs[reg].mmx); if (mod == 3) { op2_offset = offsetof(CPUX86State,fpregs[rm].mmx); } else { op2_offset = offsetof(CPUX86State,mmx_t0); gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, op2_offset); } } if (sse_op2 == SSE_SPECIAL) goto illegal_op; tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1); if (b == 0x17) s->cc_op = CC_OP_EFLAGS; break; case 0x338: crc32: b = modrm; modrm = ldub_code(s->pc++); reg = ((modrm >> 3) & 7) | rex_r; if (b != 0xf0 && b != 0xf1) goto illegal_op; if (!(s->cpuid_ext_features & CPUID_EXT_SSE42)) goto illegal_op; if (b == 0xf0) ot = OT_BYTE; else if (b == 0xf1 && s->dflag != 2) if (s->prefix & PREFIX_DATA) ot = OT_WORD; else ot = OT_LONG; else ot = OT_QUAD; gen_op_mov_TN_reg(OT_LONG, 0, reg); tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]); gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0); tcg_gen_helper_1_3(helper_crc32, cpu_T[0], cpu_tmp2_i32, cpu_T[0], tcg_const_i32(8 << ot)); ot = (s->dflag == 2) ? OT_QUAD : OT_LONG; gen_op_mov_reg_T0(ot, reg); break; case 0x03a: case 0x13a: b = modrm; modrm = ldub_code(s->pc++); rm = modrm & 7; reg = ((modrm >> 3) & 7) | rex_r; mod = (modrm >> 6) & 3; sse_op2 = sse_op_table7[b].op[b1]; if (!sse_op2) goto illegal_op; if (!(s->cpuid_ext_features & sse_op_table7[b].ext_mask)) goto illegal_op; if (sse_op2 == SSE_SPECIAL) { ot = (s->dflag == 2) ? OT_QUAD : OT_LONG; rm = (modrm & 7) | REX_B(s); if (mod != 3) gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); reg = ((modrm >> 3) & 7) | rex_r; val = ldub_code(s->pc++); switch (b) { case 0x14: tcg_gen_ld8u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_B(val & 15))); if (mod == 3) gen_op_mov_reg_T0(ot, rm); else tcg_gen_qemu_st8(cpu_T[0], cpu_A0, (s->mem_index >> 2) - 1); break; case 0x15: tcg_gen_ld16u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_W(val & 7))); if (mod == 3) gen_op_mov_reg_T0(ot, rm); else tcg_gen_qemu_st16(cpu_T[0], cpu_A0, (s->mem_index >> 2) - 1); break; case 0x16: if (ot == OT_LONG) { tcg_gen_ld_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_L(val & 3))); if (mod == 3) gen_op_mov_reg_v(ot, rm, cpu_tmp2_i32); else tcg_gen_qemu_st32(cpu_tmp2_i32, cpu_A0, (s->mem_index >> 2) - 1); } else { tcg_gen_ld_i64(cpu_tmp1_i64, cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_Q(val & 1))); if (mod == 3) gen_op_mov_reg_v(ot, rm, cpu_tmp1_i64); else tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0, (s->mem_index >> 2) - 1); } break; case 0x17: tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_L(val & 3))); if (mod == 3) gen_op_mov_reg_T0(ot, rm); else tcg_gen_qemu_st32(cpu_T[0], cpu_A0, (s->mem_index >> 2) - 1); break; case 0x20: if (mod == 3) gen_op_mov_TN_reg(OT_LONG, 0, rm); else tcg_gen_qemu_ld8u(cpu_T[0], cpu_A0, (s->mem_index >> 2) - 1); tcg_gen_st8_tl(cpu_T[0], cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_B(val & 15))); break; case 0x21: if (mod == 3) tcg_gen_ld_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUX86State,xmm_regs[rm] .XMM_L((val >> 6) & 3))); else tcg_gen_qemu_ld32u(cpu_tmp2_i32, cpu_A0, (s->mem_index >> 2) - 1); tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUX86State,xmm_regs[reg] .XMM_L((val >> 4) & 3))); if ((val >> 0) & 1) tcg_gen_st_i32(tcg_const_i32(0 ), cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_L(0))); if ((val >> 1) & 1) tcg_gen_st_i32(tcg_const_i32(0 ), cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_L(1))); if ((val >> 2) & 1) tcg_gen_st_i32(tcg_const_i32(0 ), cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_L(2))); if ((val >> 3) & 1) tcg_gen_st_i32(tcg_const_i32(0 ), cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_L(3))); break; case 0x22: if (ot == OT_LONG) { if (mod == 3) gen_op_mov_v_reg(ot, cpu_tmp2_i32, rm); else tcg_gen_qemu_ld32u(cpu_tmp2_i32, cpu_A0, (s->mem_index >> 2) - 1); tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_L(val & 3))); } else { if (mod == 3) gen_op_mov_v_reg(ot, cpu_tmp1_i64, rm); else tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0, (s->mem_index >> 2) - 1); tcg_gen_st_i64(cpu_tmp1_i64, cpu_env, offsetof(CPUX86State, xmm_regs[reg].XMM_Q(val & 1))); } break; } return; } if (b1) { op1_offset = offsetof(CPUX86State,xmm_regs[reg]); if (mod == 3) { op2_offset = offsetof(CPUX86State,xmm_regs[rm | REX_B(s)]); } else { op2_offset = offsetof(CPUX86State,xmm_t0); gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldo_env_A0(s->mem_index, op2_offset); } } else { op1_offset = offsetof(CPUX86State,fpregs[reg].mmx); if (mod == 3) { op2_offset = offsetof(CPUX86State,fpregs[rm].mmx); } else { op2_offset = offsetof(CPUX86State,mmx_t0); gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); gen_ldq_env_A0(s->mem_index, op2_offset); } } val = ldub_code(s->pc++); if ((b & 0xfc) == 0x60) { s->cc_op = CC_OP_EFLAGS; if (s->dflag == 2) val |= 1 << 8; } tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); tcg_gen_helper_0_3(sse_op2, cpu_ptr0, cpu_ptr1, tcg_const_i32(val)); break; default: goto illegal_op; } } else { switch(b) { case 0x70: case 0xc6: case 0xc2: s->rip_offset = 1; break; default: break; } if (is_xmm) { op1_offset = offsetof(CPUX86State,xmm_regs[reg]); if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); op2_offset = offsetof(CPUX86State,xmm_t0); if (b1 >= 2 && ((b >= 0x50 && b <= 0x5f && b != 0x5b) || b == 0xc2)) { if (b1 == 2) { gen_op_ld_T0_A0(OT_LONG + s->mem_index); tcg_gen_st32_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,xmm_t0.XMM_L(0))); } else { gen_ldq_env_A0(s->mem_index, offsetof(CPUX86State,xmm_t0.XMM_D(0))); } } else { gen_ldo_env_A0(s->mem_index, op2_offset); } } else { rm = (modrm & 7) | REX_B(s); op2_offset = offsetof(CPUX86State,xmm_regs[rm]); } } else { op1_offset = offsetof(CPUX86State,fpregs[reg].mmx); if (mod != 3) { gen_lea_modrm(s, modrm, &reg_addr, &offset_addr); op2_offset = offsetof(CPUX86State,mmx_t0); gen_ldq_env_A0(s->mem_index, op2_offset); } else { rm = (modrm & 7); op2_offset = offsetof(CPUX86State,fpregs[rm].mmx); } } switch(b) { case 0x0f: if (!(s->cpuid_ext2_features & CPUID_EXT2_3DNOW)) goto illegal_op; val = ldub_code(s->pc++); sse_op2 = sse_op_table5[val]; if (!sse_op2) goto illegal_op; tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1); break; case 0x70: case 0xc6: val = ldub_code(s->pc++); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); tcg_gen_helper_0_3(sse_op2, cpu_ptr0, cpu_ptr1, tcg_const_i32(val)); break; case 0xc2: val = ldub_code(s->pc++); if (val >= 8) goto illegal_op; sse_op2 = sse_op_table4[val][b1]; tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1); break; case 0xf7: if (mod != 3) goto illegal_op; #ifdef TARGET_X86_64 if (s->aflag == 2) { gen_op_movq_A0_reg(R_EDI); } else #endif { gen_op_movl_A0_reg(R_EDI); if (s->aflag == 0) gen_op_andl_A0_ffff(); } gen_add_A0_ds_seg(s); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); tcg_gen_helper_0_3(sse_op2, cpu_ptr0, cpu_ptr1, cpu_A0); break; default: tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset); tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1); break; } if (b == 0x2e || b == 0x2f) { s->cc_op = CC_OP_EFLAGS; } } }
1threat
Reusing exception handling code in C++ : <p>I have these two functions, with duplicated exception treatment, which has the sole purpose of displaying an error message:</p> <pre><code>void func1() noexcept { try { do_task(); do_another_task(); } catch (const std::out_of_range&amp; e) { show_msg("Out of range error", e.what()); } catch (const std::logic_error&amp; e) { show_msg("Logic error", e.what()); } catch (const std::system_error&amp; e) { show_msg("System error", e.what()); } catch (const std::runtime_error&amp; e) { show_msg("Runtime error", e.what()); } catch (const std::exception&amp; e) { show_msg("Generic error", e.what()); } } void func2() noexcept { try { do_something(); do_something_else(); do_even_more(); } catch (const std::out_of_range&amp; e) { show_msg("Out of range error", e.what()); } catch (const std::logic_error&amp; e) { show_msg("Logic error", e.what()); } catch (const std::system_error&amp; e) { show_msg("System error", e.what()); } catch (const std::runtime_error&amp; e) { show_msg("Runtime error", e.what()); } catch (const std::exception&amp; e) { show_msg("Generic error", e.what()); } } </code></pre> <p>I could just handle <code>std::exception</code> and show a single generic message, but I want to be more specific, that's why I'm catching all possible exceptions.</p> <p>I want to reuse this exception treatment code. I thought about this:</p> <pre><code>void run_treated(std::function&lt;void()&gt; func) noexcept { try { func(); } catch // ... all the catches go here } void func1() noexcept { run_treated([]()-&gt;void { do_task(); do_another_task(); }); } void func2() noexcept { do_something(); do_something_else(); do_even_more(); } </code></pre> <ol> <li>Is this a good approach?</li> <li>If so, <code>run_treated</code> will be called <em>a lot</em>. Should I be concerned about performance?</li> <li>Any other approaches?</li> </ol>
0debug
How to make a responsive sticky/fixed position (links floated right) with dropdown links? : <p>I am trying to make a responsive drop-down menu which has the following criteria; the links are floated right; the menu is responsive; and there is a drop-down menu.</p> <p>I have tried modifying the w3 schools responsive navbar but there always seems to be an issue which I cannot resolve. A JSfiddle of the w3 schools responsive navbar <a href="https://jsfiddle.net/g19h45ep/3/" rel="nofollow noreferrer">https://jsfiddle.net/g19h45ep/3/</a></p> <pre><code>testing code </code></pre>
0debug
Can I detect element visibility using only CSS? : <p>I checked the API for some pseudo-selector such as <code>:visible</code> or <code>:hidden</code>, but was disappointed to find no such selector exists. Since jQuery has supported these selectors for a while now, I was hoping they'd be implemented. The idea is, that I'd like to show a certain element only when the element next to it is hidden, but I don't want to use JavaScript to do so. Any options?</p>
0debug
Don't delete AppSettings not declared in a template : <p>When deploying an <strong>Azure Function App</strong> and <strong>AppSettings</strong> via an <strong>ARM Template</strong>, is it possible to tell Azure not to delete <strong>AppSettings</strong> that are not declared in the template?</p> <p>For example, take the following <strong>AppSettings</strong> config from the template and imagine that I'm updating an existing <strong>Function App</strong>. In this case, an <strong>AppSetting</strong> called <strong>storageaccountname_STORAGE</strong> would be deleted, which is undesirable as (for example) it has been created to facilitate a binding.</p> <pre><code>{ "apiVersion":"2016-08-01", "name":"appsettings", "type":"config", "dependsOn":[ "[resourceId('Microsoft.Web/Sites/Slots', variables('functionAppName'), 'Staging')]" ], "properties":{ "AzureWebJobsStorage":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]", "AzureWebJobsDashboard":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]", "APPINSIGHTS_INSTRUMENTATIONKEY":"[reference(resourceId('Microsoft.Insights/components', variables('applicationInsightsName')), '2014-04-01').InstrumentationKey]", "FUNCTION_APP_EDIT_MODE":"readwrite", "FUNCTIONS_EXTENSION_VERSION":"~1", "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]", "WEBSITE_CONTENTSHARE":"[toLower(variables('functionAppName'))]", "WEBSITE_NODE_DEFAULT_VERSION":"6.5.0" } } </code></pre> <p>Is there a way to selectivly set <strong>AppSettings</strong> via an <strong>ARM Template</strong>, or are the templates simply not capale of functioning as desired for such a scenario?</p>
0debug
Create a function that return the pow b^e - is my function correct? : int function_power (int b, int e) { int power; power = pow(b,e); return power; } Is my code correct? I have to create a function that return the value of b^e. Excuse me for my noob question, I'm a beginner
0debug
SQLite3connection: near "(":Systax error in Lazarus : I have a Sql deviation statement, but I found the error when running. I have researched many related topics to come up with solutions, but I have not yet solved it. SQLite3connection: near "(":Systax error I hope to get help from everyone. ----------------------------------- strSQL:='SELECT Mathang.Stt,Mathang.Mahang, Mathang.Tenhang,SUM(CASE WHEN Xuatnhap.Loaiphieu="N" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) AS Tongnhap,SUM(CASE WHEN Xuatnhap.Loaiphieu="X" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) AS Tongxuat,SUM(CASE WHEN Xuatnhap.Loaiphieu="N" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) - SUM(CASE WHEN Xuatnhap.Loaiphieu="X" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) AS Tongton FROM Mathang INNER JOIN Xuatnhap ON Mathang.Mahang=Xuatnhap.Mahang GROUP BY Mathang.Stt,Mathang.Mahang, Mathang.Tenhang';
0debug
static void kvm_s390_enable_cmma(KVMState *s) { int rc; struct kvm_device_attr attr = { .group = KVM_S390_VM_MEM_CTRL, .attr = KVM_S390_VM_MEM_ENABLE_CMMA, }; if (kvm_s390_check_enable_cmma(s) || kvm_s390_check_clear_cmma(s)) { return; } rc = kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr); if (!rc) { qemu_register_reset(kvm_s390_clear_cmma_callback, s); } trace_kvm_enable_cmma(rc); }
1threat
static void gen_farith (DisasContext *ctx, uint32_t op1, int ft, int fs, int fd, int cc) { const char *opn = "farith"; const char *condnames[] = { "c.f", "c.un", "c.eq", "c.ueq", "c.olt", "c.ult", "c.ole", "c.ule", "c.sf", "c.ngle", "c.seq", "c.ngl", "c.lt", "c.nge", "c.le", "c.ngt", }; const char *condnames_abs[] = { "cabs.f", "cabs.un", "cabs.eq", "cabs.ueq", "cabs.olt", "cabs.ult", "cabs.ole", "cabs.ule", "cabs.sf", "cabs.ngle", "cabs.seq", "cabs.ngl", "cabs.lt", "cabs.nge", "cabs.le", "cabs.ngt", }; enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP; uint32_t func = ctx->opcode & 0x3f; switch (ctx->opcode & FOP(0x3f, 0x1f)) { case FOP(0, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_add_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "add.s"; optype = BINOP; break; case FOP(1, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_sub_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "sub.s"; optype = BINOP; break; case FOP(2, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_mul_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "mul.s"; optype = BINOP; break; case FOP(3, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_div_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "div.s"; optype = BINOP; break; case FOP(4, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_sqrt_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "sqrt.s"; break; case FOP(5, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_abs_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "abs.s"; break; case FOP(6, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "mov.s"; break; case FOP(7, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_chs_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "neg.s"; break; case FOP(8, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_roundl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "round.l.s"; break; case FOP(9, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_truncl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "trunc.l.s"; break; case FOP(10, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_ceill_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "ceil.l.s"; break; case FOP(11, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_floorl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "floor.l.s"; break; case FOP(12, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_roundw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "round.w.s"; break; case FOP(13, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_truncw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "trunc.w.s"; break; case FOP(14, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_ceilw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "ceil.w.s"; break; case FOP(15, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_floorw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "floor.w.s"; break; case FOP(17, 16): gen_movcf_s(fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.s"; break; case FOP(18, 16): { int l1 = gen_new_label(); TCGv_i32 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); } fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); gen_set_label(l1); } opn = "movz.s"; break; case FOP(19, 16): { int l1 = gen_new_label(); TCGv_i32 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); gen_set_label(l1); } } opn = "movn.s"; break; case FOP(21, 16): check_cop1x(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_recip_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip.s"; break; case FOP(22, 16): check_cop1x(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_rsqrt_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt.s"; break; case FOP(28, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, fd); gen_helper_float_recip2_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip2.s"; break; case FOP(29, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_recip1_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "recip1.s"; break; case FOP(30, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_rsqrt1_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt1.s"; break; case FOP(31, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_helper_float_rsqrt2_s(fp0, fp0, fp1); tcg_temp_free_i32(fp1); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "rsqrt2.s"; break; case FOP(33, 16): check_cp1_registers(ctx, fd); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtd_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.d.s"; break; case FOP(36, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvtw_s(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.w.s"; break; case FOP(37, 16): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtl_s(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.l.s"; break; case FOP(38, 16): check_cp1_64bitmode(ctx); { TCGv_i64 fp64 = tcg_temp_new_i64(); TCGv_i32 fp32_0 = tcg_temp_new_i32(); TCGv_i32 fp32_1 = tcg_temp_new_i32(); gen_load_fpr32(fp32_0, fs); gen_load_fpr32(fp32_1, ft); tcg_gen_concat_i32_i64(fp64, fp32_0, fp32_1); tcg_temp_free_i32(fp32_1); tcg_temp_free_i32(fp32_0); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.ps.s"; break; case FOP(48, 16): case FOP(49, 16): case FOP(50, 16): case FOP(51, 16): case FOP(52, 16): case FOP(53, 16): case FOP(54, 16): case FOP(55, 16): case FOP(56, 16): case FOP(57, 16): case FOP(58, 16): case FOP(59, 16): case FOP(60, 16): case FOP(61, 16): case FOP(62, 16): case FOP(63, 16): { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); if (ctx->opcode & (1 << 6)) { check_cop1x(ctx); gen_cmpabs_s(func-48, fp0, fp1, cc); opn = condnames_abs[func-48]; } else { gen_cmp_s(func-48, fp0, fp1, cc); opn = condnames[func-48]; } tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } break; case FOP(0, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_add_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "add.d"; optype = BINOP; break; case FOP(1, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_sub_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sub.d"; optype = BINOP; break; case FOP(2, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_mul_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mul.d"; optype = BINOP; break; case FOP(3, 17): check_cp1_registers(ctx, fs | ft | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_div_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "div.d"; optype = BINOP; break; case FOP(4, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_sqrt_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sqrt.d"; break; case FOP(5, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_abs_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "abs.d"; break; case FOP(6, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mov.d"; break; case FOP(7, 17): check_cp1_registers(ctx, fs | fd); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_chs_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "neg.d"; break; case FOP(8, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_roundl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "round.l.d"; break; case FOP(9, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_truncl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "trunc.l.d"; break; case FOP(10, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_ceill_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "ceil.l.d"; break; case FOP(11, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_floorl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "floor.l.d"; break; case FOP(12, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_roundw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "round.w.d"; break; case FOP(13, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_truncw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "trunc.w.d"; break; case FOP(14, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_ceilw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "ceil.w.d"; break; case FOP(15, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_floorw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "floor.w.d"; break; case FOP(17, 17): gen_movcf_d(ctx, fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.d"; break; case FOP(18, 17): { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); } fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } opn = "movz.d"; break; case FOP(19, 17): { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } } opn = "movn.d"; break; case FOP(21, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip.d"; break; case FOP(22, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt.d"; break; case FOP(28, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_recip2_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip2.d"; break; case FOP(29, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip1_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip1.d"; break; case FOP(30, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt1_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt1.d"; break; case FOP(31, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_rsqrt2_d(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt2.d"; break; case FOP(48, 17): case FOP(49, 17): case FOP(50, 17): case FOP(51, 17): case FOP(52, 17): case FOP(53, 17): case FOP(54, 17): case FOP(55, 17): case FOP(56, 17): case FOP(57, 17): case FOP(58, 17): case FOP(59, 17): case FOP(60, 17): case FOP(61, 17): case FOP(62, 17): case FOP(63, 17): { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); if (ctx->opcode & (1 << 6)) { check_cop1x(ctx); check_cp1_registers(ctx, fs | ft); gen_cmpabs_d(func-48, fp0, fp1, cc); opn = condnames_abs[func-48]; } else { check_cp1_registers(ctx, fs | ft); gen_cmp_d(func-48, fp0, fp1, cc); opn = condnames[func-48]; } tcg_temp_free_i64(fp0); tcg_temp_free_i64(fp1); } break; case FOP(32, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvts_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.s.d"; break; case FOP(36, 17): check_cp1_registers(ctx, fs); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvtw_d(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.w.d"; break; case FOP(37, 17): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtl_d(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.l.d"; break; case FOP(32, 20): { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvts_w(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.w"; break; case FOP(33, 20): check_cp1_registers(ctx, fd); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr32(fp32, fs); gen_helper_float_cvtd_w(fp64, fp32); tcg_temp_free_i32(fp32); gen_store_fpr64(ctx, fp64, fd); tcg_temp_free_i64(fp64); } opn = "cvt.d.w"; break; case FOP(32, 21): check_cp1_64bitmode(ctx); { TCGv_i32 fp32 = tcg_temp_new_i32(); TCGv_i64 fp64 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp64, fs); gen_helper_float_cvts_l(fp32, fp64); tcg_temp_free_i64(fp64); gen_store_fpr32(fp32, fd); tcg_temp_free_i32(fp32); } opn = "cvt.s.l"; break; case FOP(33, 21): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtd_l(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.d.l"; break; case FOP(38, 20): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtps_pw(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.ps.pw"; break; case FOP(0, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_add_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "add.ps"; break; case FOP(1, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_sub_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "sub.ps"; break; case FOP(2, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_mul_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mul.ps"; break; case FOP(5, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_abs_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "abs.ps"; break; case FOP(6, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mov.ps"; break; case FOP(7, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_chs_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "neg.ps"; break; case FOP(17, 22): check_cp1_64bitmode(ctx); gen_movcf_ps(fs, fd, (ft >> 2) & 0x7, ft & 0x1); opn = "movcf.ps"; break; case FOP(18, 22): check_cp1_64bitmode(ctx); { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } opn = "movz.ps"; break; case FOP(19, 22): check_cp1_64bitmode(ctx); { int l1 = gen_new_label(); TCGv_i64 fp0; if (ft != 0) { tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[ft], 0, l1); fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); gen_set_label(l1); } } opn = "movn.ps"; break; case FOP(24, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, ft); gen_load_fpr64(ctx, fp1, fs); gen_helper_float_addr_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "addr.ps"; break; case FOP(26, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, ft); gen_load_fpr64(ctx, fp1, fs); gen_helper_float_mulr_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "mulr.ps"; break; case FOP(28, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, fd); gen_helper_float_recip2_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip2.ps"; break; case FOP(29, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_recip1_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "recip1.ps"; break; case FOP(30, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_rsqrt1_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt1.ps"; break; case FOP(31, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); gen_helper_float_rsqrt2_ps(fp0, fp0, fp1); tcg_temp_free_i64(fp1); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "rsqrt2.ps"; break; case FOP(32, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_helper_float_cvts_pu(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.pu"; break; case FOP(36, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_helper_float_cvtpw_ps(fp0, fp0); gen_store_fpr64(ctx, fp0, fd); tcg_temp_free_i64(fp0); } opn = "cvt.pw.ps"; break; case FOP(40, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_helper_float_cvts_pl(fp0, fp0); gen_store_fpr32(fp0, fd); tcg_temp_free_i32(fp0); } opn = "cvt.s.pl"; break; case FOP(44, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32(fp1, ft); gen_store_fpr32h(fp0, fd); gen_store_fpr32(fp1, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "pll.ps"; break; case FOP(45, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32(fp0, fs); gen_load_fpr32h(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "plu.ps"; break; case FOP(46, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_load_fpr32(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "pul.ps"; break; case FOP(47, 22): check_cp1_64bitmode(ctx); { TCGv_i32 fp0 = tcg_temp_new_i32(); TCGv_i32 fp1 = tcg_temp_new_i32(); gen_load_fpr32h(fp0, fs); gen_load_fpr32h(fp1, ft); gen_store_fpr32(fp1, fd); gen_store_fpr32h(fp0, fd); tcg_temp_free_i32(fp0); tcg_temp_free_i32(fp1); } opn = "puu.ps"; break; case FOP(48, 22): case FOP(49, 22): case FOP(50, 22): case FOP(51, 22): case FOP(52, 22): case FOP(53, 22): case FOP(54, 22): case FOP(55, 22): case FOP(56, 22): case FOP(57, 22): case FOP(58, 22): case FOP(59, 22): case FOP(60, 22): case FOP(61, 22): case FOP(62, 22): case FOP(63, 22): check_cp1_64bitmode(ctx); { TCGv_i64 fp0 = tcg_temp_new_i64(); TCGv_i64 fp1 = tcg_temp_new_i64(); gen_load_fpr64(ctx, fp0, fs); gen_load_fpr64(ctx, fp1, ft); if (ctx->opcode & (1 << 6)) { gen_cmpabs_ps(func-48, fp0, fp1, cc); opn = condnames_abs[func-48]; } else { gen_cmp_ps(func-48, fp0, fp1, cc); opn = condnames[func-48]; } tcg_temp_free_i64(fp0); tcg_temp_free_i64(fp1); } break; default: MIPS_INVAL(opn); generate_exception (ctx, EXCP_RI); return; } switch (optype) { case BINOP: MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]); break; case CMPOP: MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]); break; default: MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]); break; } }
1threat
Java 8/9: Can a character in a String be mapped to its indices (using streams)? : <p>Given a <code>String s</code> and a <code>char c</code>, I'm curious if there exists some method of producing a <code>List&lt;Integer&gt; list</code> from <code>s</code> (where the elements within <code>list</code> represent the indices of <code>c</code> within <code>s</code>).</p> <p>A close, but <strong>incorrect</strong> approach would be:</p> <pre><code>public static List&lt;Integer&gt; getIndexList(String s, char c) { return s.chars() .mapToObj(i -&gt; (char) i) .filter(ch -&gt; ch == c) .map(s::indexOf) // Will obviously return the first index every time. .collect(Collectors.toList()); } </code></pre> <p>The following inputs should yield the following output:</p> <pre><code>getIndexList("Hello world!", 'l') -&gt; [2, 3, 9] </code></pre>
0debug
Using Ansible per directory instead of per host : <p>I know it will sound a bit strange but I wonder if there is a way to use Ansible per directory instead of per host.</p> <p>Our current use case is the following: the same application (here WordPress) is deployed into multiple folders onto the same host (probably a very common scenario at a hosting provider).</p> <p>We want to manage the configuration of all the instances in a 'smart' way (hence the idea of using Ansible). for instance, the same file (plugin) should be copied into the same subfolders of the instances.</p> <p>This could be very easily achieved if all instances were hosted on different hosts, but I can find a way to achieve this in different folders on the same host.</p> <p>Is that completely stupid? Is there a better tool to do that? Any insight will be greatly appreciated.</p>
0debug
Extract normal font to new cell : <p>I have multiple cells with bold font and normal font, I am looking to only extract the font that isn't bold to a new cell. Does anyone know how I can do this?</p> <p>Thanks</p>
0debug
I can't find a way to input on the screen value of the words in Morse Alphabet : Don't be punish please me , I am just trying to create a output Morse Alphabet in java , but in my case , there are problems , when I input the letter , this coincide to my require , for example - A output ".-" . There are two problems in my program , first , if I enter B and after D for example there is no output . Second problem , this is not work for words , when I entering word . public class Example { public static void main(String[] args) { Map<String, String> map = createAlphabet(); Scanner in = new Scanner(System.in); String s = in.nextLine(); for (Map.Entry<String , String> entry : map.entrySet()){ if (entry.getKey().equalsIgnoreCase(s)){ System.out.println(entry.getValue()); } } } public static Map<String , String> createAlphabet() { Map<String , String> alphabet = new HashMap<>(); alphabet.put("A" , ".-"); alphabet.put("B" , "-..."); alphabet.put("C" , "-.-"); alphabet.put("D" , "-.."); alphabet.put("E" , "."); alphabet.put("F" , "..-."); alphabet.put("G" , "--."); alphabet.put("H" , "...."); alphabet.put("I" , ".."); alphabet.put("J" , ".---"); alphabet.put("K" , "-.-"); alphabet.put("L" , ".-.."); alphabet.put("M" , "--"); alphabet.put("N" , "-."); alphabet.put("O" , "---"); alphabet.put("P" , ".--"); alphabet.put("Q" , "--.-"); alphabet.put("R" , ".-."); alphabet.put("S" , "..."); alphabet.put("T" , "-"); alphabet.put("U" , "..-"); alphabet.put("V" , "...-"); alphabet.put("W" , ".--"); alphabet.put("X" , "-..-"); alphabet.put("Y" , "-.--"); alphabet.put("Z" , "--.."); return alphabet; } }
0debug
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { AnsiContext *s = avctx->priv_data; uint8_t *buf = avpkt->data; int buf_size = avpkt->size; const uint8_t *buf_end = buf+buf_size; int ret, i, count; if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) return ret; if (!avctx->frame_number) { for (i=0; i<avctx->height; i++) memset(s->frame->data[0]+ i*s->frame->linesize[0], 0, avctx->width); memset(s->frame->data[1], 0, AVPALETTE_SIZE); } s->frame->pict_type = AV_PICTURE_TYPE_I; s->frame->palette_has_changed = 1; set_palette((uint32_t *)s->frame->data[1]); if (!s->first_frame) { erase_screen(avctx); s->first_frame = 1; } while(buf < buf_end) { switch(s->state) { case STATE_NORMAL: switch (buf[0]) { case 0x00: case 0x07: case 0x1A: break; case 0x08: s->x = FFMAX(s->x - 1, 0); break; case 0x09: i = s->x / FONT_WIDTH; count = ((i + 8) & ~7) - i; for (i = 0; i < count; i++) draw_char(avctx, ' '); break; case 0x0A: hscroll(avctx); case 0x0D: s->x = 0; break; case 0x0C: erase_screen(avctx); break; case 0x1B: s->state = STATE_ESCAPE; break; default: draw_char(avctx, buf[0]); } break; case STATE_ESCAPE: if (buf[0] == '[') { s->state = STATE_CODE; s->nb_args = 0; s->args[0] = -1; } else { s->state = STATE_NORMAL; draw_char(avctx, 0x1B); continue; } break; case STATE_CODE: switch(buf[0]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (s->nb_args < MAX_NB_ARGS) s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0'; break; case ';': s->nb_args++; if (s->nb_args < MAX_NB_ARGS) s->args[s->nb_args] = 0; break; case 'M': s->state = STATE_MUSIC_PREAMBLE; break; case '=': case '?': break; default: if (s->nb_args > MAX_NB_ARGS) av_log(avctx, AV_LOG_WARNING, "args overflow (%i)\n", s->nb_args); if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] >= 0) s->nb_args++; if ((ret = execute_code(avctx, buf[0])) < 0) return ret; s->state = STATE_NORMAL; } break; case STATE_MUSIC_PREAMBLE: if (buf[0] == 0x0E || buf[0] == 0x1B) s->state = STATE_NORMAL; break; } buf++; } *got_frame = 1; if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; return buf_size; }
1threat
How can i remove duplicate words unseparated in a python string? : string1 = "calvin kleinklein design dress" How can I remove the second duplicate "klein"? The result should look like string2 = "calvin klein design dress"
0debug
static void create_header32(DumpState *s, Error **errp) { DiskDumpHeader32 *dh = NULL; KdumpSubHeader32 *kh = NULL; size_t size; uint32_t block_size; uint32_t sub_hdr_size; uint32_t bitmap_blocks; uint32_t status = 0; uint64_t offset_note; Error *local_err = NULL; size = sizeof(DiskDumpHeader32); dh = g_malloc0(size); strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE)); dh->header_version = cpu_to_dump32(s, 6); block_size = s->dump_info.page_size; dh->block_size = cpu_to_dump32(s, block_size); sub_hdr_size = sizeof(struct KdumpSubHeader32) + s->note_size; sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size); dh->sub_hdr_size = cpu_to_dump32(s, sub_hdr_size); dh->max_mapnr = cpu_to_dump32(s, MIN(s->max_mapnr, UINT_MAX)); dh->nr_cpus = cpu_to_dump32(s, s->nr_cpus); bitmap_blocks = DIV_ROUND_UP(s->len_dump_bitmap, block_size) * 2; dh->bitmap_blocks = cpu_to_dump32(s, bitmap_blocks); strncpy(dh->utsname.machine, ELF_MACHINE_UNAME, sizeof(dh->utsname.machine)); if (s->flag_compress & DUMP_DH_COMPRESSED_ZLIB) { status |= DUMP_DH_COMPRESSED_ZLIB; #ifdef CONFIG_LZO if (s->flag_compress & DUMP_DH_COMPRESSED_LZO) { status |= DUMP_DH_COMPRESSED_LZO; #endif #ifdef CONFIG_SNAPPY if (s->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) { status |= DUMP_DH_COMPRESSED_SNAPPY; #endif dh->status = cpu_to_dump32(s, status); if (write_buffer(s->fd, 0, dh, size) < 0) { error_setg(errp, "dump: failed to write disk dump header"); goto out; size = sizeof(KdumpSubHeader32); kh = g_malloc0(size); kh->max_mapnr_64 = cpu_to_dump64(s, s->max_mapnr); kh->phys_base = cpu_to_dump32(s, s->dump_info.phys_base); kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL); offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size; kh->offset_note = cpu_to_dump64(s, offset_note); kh->note_size = cpu_to_dump32(s, s->note_size); if (write_buffer(s->fd, DISKDUMP_HEADER_BLOCKS * block_size, kh, size) < 0) { error_setg(errp, "dump: failed to write kdump sub header"); goto out; s->note_buf = g_malloc0(s->note_size); s->note_buf_offset = 0; write_elf32_notes(buf_write_note, s, &local_err); if (local_err) { error_propagate(errp, local_err); goto out; if (write_buffer(s->fd, offset_note, s->note_buf, s->note_size) < 0) { error_setg(errp, "dump: failed to write notes"); goto out; s->offset_dump_bitmap = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size) * block_size; s->offset_page = (DISKDUMP_HEADER_BLOCKS + sub_hdr_size + bitmap_blocks) * block_size; out: g_free(dh); g_free(kh); g_free(s->note_buf);
1threat
How to sort an array given a range? : <p>First of all I am using java and my first objective is to use bubble sort to sort an array in descending order given the range lowindex..highindex (inclusive). So my question is how to sort an array given a range? An example would be greatly appreciated to get me started on doing this. </p>
0debug
static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc) { int16_t *filterPos = c->hLumFilterPos; int16_t *filter = c->hLumFilter; void *mmx2FilterCode= c->lumMmx2FilterCode; int i; #if defined(PIC) uint64_t ebxsave; #endif #if ARCH_X86_64 uint64_t retsave; #endif __asm__ volatile( #if defined(PIC) "mov %%"REG_b", %5 \n\t" #if ARCH_X86_64 "mov -8(%%rsp), %%"REG_a" \n\t" "mov %%"REG_a", %6 \n\t" #endif #else #if ARCH_X86_64 "mov -8(%%rsp), %%"REG_a" \n\t" "mov %%"REG_a", %5 \n\t" #endif #endif "pxor %%mm7, %%mm7 \n\t" "mov %0, %%"REG_c" \n\t" "mov %1, %%"REG_D" \n\t" "mov %2, %%"REG_d" \n\t" "mov %3, %%"REG_b" \n\t" "xor %%"REG_a", %%"REG_a" \n\t" PREFETCH" (%%"REG_c") \n\t" PREFETCH" 32(%%"REG_c") \n\t" PREFETCH" 64(%%"REG_c") \n\t" #if ARCH_X86_64 #define CALL_MMX2_FILTER_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\ "add %%"REG_S", %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #else #define CALL_MMX2_FILTER_CODE \ "movl (%%"REG_b"), %%esi \n\t"\ "call *%4 \n\t"\ "addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\ "add %%"REG_a", %%"REG_D" \n\t"\ "xor %%"REG_a", %%"REG_a" \n\t"\ #endif CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE CALL_MMX2_FILTER_CODE #if defined(PIC) "mov %5, %%"REG_b" \n\t" #if ARCH_X86_64 "mov %6, %%"REG_a" \n\t" "mov %%"REG_a", -8(%%rsp) \n\t" #endif #else #if ARCH_X86_64 "mov %5, %%"REG_a" \n\t" "mov %%"REG_a", -8(%%rsp) \n\t" #endif #endif :: "m" (src), "m" (dst), "m" (filter), "m" (filterPos), "m" (mmx2FilterCode) #if defined(PIC) ,"m" (ebxsave) #endif #if ARCH_X86_64 ,"m"(retsave) #endif : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D #if !defined(PIC) ,"%"REG_b #endif ); for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128; }
1threat
def sorted_models(models): sorted_models = sorted(models, key = lambda x: x['color']) return sorted_models
0debug
Gradle duplicate entry error: META-INF/MANIFEST.MF (Or how to delete a file from jar) : <p>I've cloned a github repository because I wanted to study the code, but when I tried to build it in Android Studio, I ran into some trouble. After adding the google maven repository (as prompted by Android Studio) and updating both the Gradle Plugin Version and the Grade Version (to 3.5.2 and to 5.4.1, respectively), the build fails because of the following error:</p> <blockquote> <p>Cause: duplicate entry: META-INF/MANIFEST.MF</p> </blockquote> <p>And this, to be more specific:</p> <blockquote> <p>Caused by: java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF</p> </blockquote> <p>Here is my project level build.gradle file:</p> <pre><code> buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.5.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() maven { url 'https://maven.google.com' } } } </code></pre> <p>Here's my module build.gradle file (before trying anything):</p> <pre><code> apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion '28.0.3' defaultConfig { applicationId "com.thelittlenaruto.supportdesignexample" minSdkVersion 11 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation ('com.android.support:appcompat-v7:22.2.1') implementation ('com.android.support:design:22.2.1') implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar' } </code></pre> <p>Here's what I've tried so far:</p> <ul> <li>Adding the following to the android section of my module build.gradle file:</li> </ul> <pre><code> sourceSets { main{ java{ exclude '**/META-INF/MANIFEST' exclude '**/META-INF/MANIFEST.MF' exclude 'META-INF/MANIFEST' exclude 'META-INF/MANIFEST.MF' exclude '!META-INF/MANIFEST.MF' } } } </code></pre> <ul> <li>Adding this:</li> </ul> <pre><code> sourceSets.main.res.filter.exclude 'META-INF/MANIFEST' sourceSets.main.res.filter.exclude 'META-INF/MANIFEST.MF' </code></pre> <ul> <li>Also this:</li> </ul> <pre><code> packagingOptions { apply plugin: 'project-report' exclude '**/META-INF/MANIFEST' exclude '**/META-INF/MANIFEST.MF' exclude 'META-INF/MANIFEST' exclude 'META-INF/MANIFEST.MF' exclude '!META-INF/MANIFEST.MF' } </code></pre> <ul> <li>And this:</li> </ul> <pre><code> packagingOptions { pickFirst '**/META-INF/MANIFEST' pickFirst '**/META-INF/MANIFEST.MF' pickFirst 'META-INF/MANIFEST' pickFirst 'META-INF/MANIFEST.MF' pickFirst '!META-INF/MANIFEST.MF' } </code></pre> <ul> <li>This:</li> </ul> <pre><code> aaptOptions { ignoreAssetsPattern "!META-INF/MANIFEST.MF" ignoreAssetsPattern "META-INF/MANIFEST.MF" } </code></pre> <p>I think I've tried mostly everything in this question: <a href="https://stackoverflow.com/questions/41899973/how-to-exclude-certain-files-from-android-studio-gradle-builds">How to exclude certain files from Android Studio gradle builds?</a></p> <p>Nothing worked.</p> <p>After searching for a solution, I think the problem is that I have duplicated dependencies. So I've tried the following:</p> <pre><code> dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation ('com.android.support:appcompat-v7:22.2.1'){ exclude module: 'support-v4' } implementation ('com.android.support:design:22.2.1') implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar' } </code></pre> <p>And this:</p> <pre><code> dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation ('com.android.support:design:22.2.1'){ exclude module: 'support-v7' } implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar' } </code></pre> <p>I still get the same error.</p> <p>Could anyone please tell me what I'm doing wrong? Thank you in anticipation. :)</p>
0debug
Why "try...else" is "invalid syntax" in Python? : <p>normal:</p> <pre><code>try: something may go wrong... except: pass else: others func... </code></pre> <p>what i need:</p> <pre><code>try: something may go wrong... else: others func... </code></pre> <p>Are there some reasons for 'try...else' not exists?</p>
0debug
static int ohci_eof_timer_pre_load(void *opaque) { OHCIState *ohci = opaque; ohci_bus_start(ohci); return 0; }
1threat
Different MD5 hash with the same value : <p>I'm making a registration page, and I encrypt users' password with md5, when I made the login page everytime I tried to logged in it said wrong password, so I checked if the md5 hash is the same as in the database, but it's not, and I'm sure the password is correct. I use the same code in the login page and the registration page too: <code>$password = md5($password)</code></p>
0debug
static void pxb_host_class_init(ObjectClass *class, void *data) { DeviceClass *dc = DEVICE_CLASS(class); SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(class); PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class); dc->fw_name = "pci"; sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address; hc->root_bus_path = pxb_host_root_bus_path; }
1threat
fetch API to get HTML response : <p>I am trying to get a page's HTML using fetch API. Here is my code.</p> <pre><code>var quizUrl = 'http://www.lipsum.com/'; var myHeaders = new Headers(); myHeaders.append('Content-Type', 'text/html'); fetch(quizUrl,{ mode: 'no-cors', method: 'get', headers: myHeaders }).then(function(response) { response.text().then(function(text) { console.log(text); }) }).catch(function(err) { console.log(err) }); </code></pre> <p>It returns empty string. Any guesses why it doesn't work?</p>
0debug
Margin defined in XML file to be included has no impact : I am trying to re-use the XML defined for a button in a calculator app but the margin value defined within the Button's XML has no effect after it is included in a layout file. Button's XML: <?xml version="1.0" encoding="utf-8"?> <Button xmlns:android="http://schemas.android.com/apk/res/android" android:text="@string/standard_sqrt" android:gravity="center" android:textStyle="italic" android:textSize="25dp" android:padding="16dp" android:background="@drawable/dark_button_selector" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_margin="5dp"/> Button seems to be handling margin pretty well on its own: [![Button Layout][1]][1] Now, I am simply including it in a TablowRow like this: <TableRow android:layout_weight="2" android:gravity="center"> <include layout="@layout/button_component" /> <include layout="@layout/button_component" /> <include layout="@layout/button_component" /> <include layout="@layout/button_component" /> </TableRow> No matter what value I assign the margin/height/width of the Button, they act the same when included in the table row (i.e without any spaces between them). [![Included buttons][2]][2] [1]: https://i.stack.imgur.com/P0FRP.png [2]: https://i.stack.imgur.com/cnZNR.png
0debug
mixlibshellout not executing with specified location : begin > cwdkernel = Dir.glob('/var/cache/acpchef/src/ap-kernelmodule-10*') > cmd = Mixlib::ShellOut.new("build cmd", :cwd => 'cwdkernel') > cmd.run_command > log 'run' end this does seem to execute the command, Is the syntax wrong? I am very new to chef and ruby, please help.
0debug
SQL - display by query the table, groups of rows as columns : i am trying to take range of codes in one column and display their results under one column per catgory<br> <br> example of my table <br> ID | TEST_NUM | RESULT | <BR> 1 | R1 | 33 |<BR> 1 | R2 | 31 |<BR> 1 | C1 | 24 |<BR> 1 | C2 | 19 |<BR> by quert from table above i am trying to get the next table: <BR><br> ID | TEST_NUM OF R ONLY | R RESULTS | C RESULTS | <BR> 1 | R1 | 33 | 24 <BR> 1 | R2 | 31 | 19 <BR>
0debug
void do_mulldo (void) { int64_t th; uint64_t tl; muls64(&tl, &th, T0, T1); if (likely(th == 0)) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } T0 = (int64_t)tl; }
1threat
Ouputting data using system.out from array that's inside a loop JAVA : **The code below supposed to take the users input, name and bad/good teeth, ( allow the user to enter that in an array using a loop, 10 times and the program supposed to output that list of data in a table format ( the format you can find at the bottom of the code) __ ** ---------- import java.util.Scanner; ---------- public class pbclass; ---------- { public static void main(String[] args) { pbclass objectt = new pbclass(); objectt.dentistpractice(); } ---------- public void dentistpractice() { Scanner scan = new Scanner(System.in); String[] patientFamName = new String[10]; String[] patientFirstName = new String[10]; String[] PatientGoodTeeth = new String[10]; String[] PatientBadTeeth = new String[10]; for(int i = 0; i < 10; ++i) { System.out.println("Enter surname name "); patientFamName[i] = scan.nextLine(); if (patientFamName[i].equalsIgnoreCase("close") ==true) { break; } System.out.println("Enter first name "); patientFirstName[i] = scan.nextLine(); System.out.println("Enter good teeth "); PatientGoodTeeth[i] = scan.nextLine(); int numconverterForHomeTeam = Integer.parseInt(PatientGoodTeeth[i]); System.out.println("Enter score for away team: "); PatientBadTeeth[i] = scan.nextLine(); int numconverterForAwayTeam = Integer.parseInt(PatientBadTeeth[i]); } System.out.println(patientFamName[0] + patientFirstName[0] + " ||||||| " +PatientGoodTeeth[0] + PatientBadTeeth[0] ); System.out.println(patientFamName[1] + patientFirstName[1] + " ||||||| " +PatientGoodTeeth[1] + PatientBadTeeth[1] ); } **the problem I am facing is that I do not know how to output the data in a simple way, as it is it works now, but what if the array was 1000 variables or even longer? and how do I prevent 'null' from showing on the display table if the user types 'exit' the loop should stop and display the already inputted data excluding null values)**
0debug
static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { int async_ret; BlockDriverAIOCB *acb; async_ret = NOT_DONE; qemu_aio_wait_start(); acb = bdrv_aio_write(bs, sector_num, buf, nb_sectors, bdrv_rw_em_cb, &async_ret); if (acb == NULL) { qemu_aio_wait_end(); return -1; } while (async_ret == NOT_DONE) { qemu_aio_wait(); } qemu_aio_wait_end(); return async_ret; }
1threat
int main_loop(void *opaque) { struct pollfd ufds[2], *pf, *serial_ufd, *net_ufd, *gdb_ufd; int ret, n, timeout; uint8_t ch; CPUState *env = global_env; if (!term_inited) { term_inited = 1; term_init(); } for(;;) { ret = cpu_x86_exec(env); if (reset_requested) break; if (ret == EXCP_DEBUG) return EXCP_DEBUG; if (ret == EXCP_HLT) timeout = 10; else timeout = 0; serial_ufd = NULL; pf = ufds; if (!(serial_ports[0].lsr & UART_LSR_DR)) { serial_ufd = pf; pf->fd = 0; pf->events = POLLIN; pf++; } net_ufd = NULL; if (net_fd > 0 && ne2000_can_receive(&ne2000_state)) { net_ufd = pf; pf->fd = net_fd; pf->events = POLLIN; pf++; } gdb_ufd = NULL; if (gdbstub_fd > 0) { gdb_ufd = pf; pf->fd = gdbstub_fd; pf->events = POLLIN; pf++; } ret = poll(ufds, pf - ufds, timeout); if (ret > 0) { if (serial_ufd && (serial_ufd->revents & POLLIN)) { n = read(0, &ch, 1); if (n == 1) { serial_received_byte(&serial_ports[0], ch); } } if (net_ufd && (net_ufd->revents & POLLIN)) { uint8_t buf[MAX_ETH_FRAME_SIZE]; n = read(net_fd, buf, MAX_ETH_FRAME_SIZE); if (n > 0) { if (n < 60) { memset(buf + n, 0, 60 - n); n = 60; } ne2000_receive(&ne2000_state, buf, n); } } if (gdb_ufd && (gdb_ufd->revents & POLLIN)) { uint8_t buf[1]; n = read(gdbstub_fd, buf, 1); if (n == 1) break; } } if (timer_irq_pending) { pic_set_irq(0, 1); pic_set_irq(0, 0); timer_irq_pending = 0; } if (gui_refresh_pending) { display_state.dpy_refresh(&display_state); gui_refresh_pending = 0; } } return EXCP_INTERRUPT; }
1threat
QT Applications - Replacing embedded resources : <p>Is it possible to replace embedded resources [e.g. styles, images, text] in a Linux [ELF] binary?</p> <p>I noticed that I can change text but if I type more text or if I remove text, then the segmentation faults start coming up. I have not gone through the ELF spec yet but I am wondering if it is possible.</p> <p>I managed to extract the images from the binary using the <a href="https://github.com/panzi/mediaextract" rel="noreferrer">mediaextract</a> project but I need to do just the opposite without breaking the binary structure.</p>
0debug
Creating simple 'calculator' (Javascript) : I am trying to solve a problem given to me and it involves using basic loops, functions and conditions. I have been given the below: // TODO: complete program console.log(calculate(4, "+", 6)); // Must show 10 console.log(calculate(4, "-", 6)); // Must show -2 console.log(calculate(2, "*", 0)); // Must show 0 console.log(calculate(12, "/", 0)); // Must show Infinity and this is my attempt (not working of course). Can anyone give me a nudge of a pointer as to what I am doing wrong? function calculate(n1, n2, n3) { let calc if n2 = "+" { (calc = +) }; else if n2 = "-"{ (calc = -) }; else if n2 = "*"{ (calc = *) }; else { (calc = /) }; let acalc = (n1 + n2 + n3); return acalc; } console.log(calculate(4, "+", 6)); // Must show 10 console.log(calculate(4, "-", 6)); // Must show -2 console.log(calculate(2, "*", 0)); // Must show 0 console.log(calculate(12, "/", 0)); // Must show Infinity
0debug
static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; if((uint64_t)atom.size > (1<<30)) return -1; if (st->codec->codec_id == CODEC_ID_QDM2) { av_free(st->codec->extradata); st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = atom.size; get_buffer(pb, st->codec->extradata, atom.size); } else if (atom.size > 8) { if (mov_read_default(c, pb, atom) < 0) return -1; } else url_fskip(pb, atom.size); return 0; }
1threat
Ipad Safari elements are disappear and reapear with a delay : For this bug I have referred the below stack overflow question and applied in the css as follows (Refer: http://stackoverflow.com/questions/9807620/ipad-safari-scrolling-causes-html-elements-to-disappear-and-reappear-with-a-dela) *:not(html) { -webkit-transform: translate3d(0, 0, 0); } **After applied, I am facing new issue. That is if I apply fixed position for a element, that's not fixed in the browser top instead of scrolling.** ***If I remove the above css, It is working fine.*** (Refer: http://stackoverflow.com/questions/36855473/position-fixed-not-working-is-working-like-absolute) How to fix the issue without affecting the fixed element?
0debug
Django Programming error column does not exist even after running migrations : <p>I run <code>python manage.py makemigrations</code> and I get: No changes detected Then, <code>python manage.py migrate</code> and I get: No migrations to apply.</p> <p>Then, I try to push the changes to production: git push heroku master Everything up-to-date</p> <p>Then, in production, I repeat the command: heroku run python manage.py migrate No migrations to apply.</p> <p>Just in case, I run <code>makemigrations</code> in production:</p> <pre><code>heroku run python manage.py makemigrations No changes detected </code></pre> <p>WHY then I get a </p> <pre><code>ProgrammingError at .... column .... does not exist </code></pre> <p>"No changes detected" means the database is coherent with the code. How can I debug this?Β‘?</p>
0debug
static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride) { const int index = size2index[log2h][log2w]; const int h = 1 << log2h; int code = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table, BLOCK_TYPE_VLC_BITS, 1); uint16_t *start = f->last_frame_buffer; uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w); int ret; int scale = 1; unsigned dc = 0; if (code < 0 || code > 6 || log2w < 0) return AVERROR_INVALIDDATA; if (code == 1) { log2h--; if ((ret = decode_p_block(f, dst, src, log2w, log2h, stride)) < 0) return ret; return decode_p_block(f, dst + (stride << log2h), src + (stride << log2h), log2w, log2h, stride); } else if (code == 2) { log2w--; if ((ret = decode_p_block(f, dst , src, log2w, log2h, stride)) < 0) return ret; return decode_p_block(f, dst + (1 << log2w), src + (1 << log2w), log2w, log2h, stride); } else if (code == 6) { if (log2w) { dst[0] = bytestream2_get_le16(&f->g2); dst[1] = bytestream2_get_le16(&f->g2); } else { dst[0] = bytestream2_get_le16(&f->g2); dst[stride] = bytestream2_get_le16(&f->g2); } return 0; } if (code == 0) { src += f->mv[bytestream2_get_byte(&f->g)]; } else if (code == 3 && f->version >= 2) { return 0; } else if (code == 4) { src += f->mv[bytestream2_get_byte(&f->g)]; dc = bytestream2_get_le16(&f->g2); } else if (code == 5) { scale = 0; dc = bytestream2_get_le16(&f->g2); } if (start > src || src > end) { av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); return AVERROR_INVALIDDATA; } mcdc(dst, src, log2w, h, stride, scale, dc); return 0; }
1threat
Python: List existing values in a list : <pre><code>data = [{u'class': u'A'}, {u'class': u'A'}, {u'class': u'B'}] </code></pre> <p>I want to get a list with all existing class values in data. Is there any efficient way to sort out double values?</p> <pre><code>output = [{u'class': u'A'}, {u'class': u'B'}] </code></pre>
0debug
how convert double to string : <pre><code>public String solve() { ss = log(pow(y, -sqrt(abs(x)))) * (x + y / 2) + sin(atan(z)); result = toString(ss); return result; } </code></pre> <p>Don't get how do I convert <code>ss</code> to string. I neen return result in String format</p>
0debug
static inline void tcg_out_qemu_st(TCGContext *s, int cond, const TCGArg *args, int opc) { int addr_reg, data_reg, data_reg2; #ifdef CONFIG_SOFTMMU int mem_index, s_bits; # if TARGET_LONG_BITS == 64 int addr_reg2; # endif uint32_t *label_ptr; #endif data_reg = *args++; if (opc == 3) data_reg2 = *args++; else data_reg2 = 0; addr_reg = *args++; #if TARGET_LONG_BITS == 64 addr_reg2 = *args++; #endif #ifdef CONFIG_SOFTMMU mem_index = *args; s_bits = opc & 3; tcg_out_dat_reg(s, COND_AL, ARITH_MOV, 8, 0, addr_reg, SHIFT_IMM_LSR(TARGET_PAGE_BITS)); tcg_out_dat_imm(s, COND_AL, ARITH_AND, 0, 8, CPU_TLB_SIZE - 1); tcg_out_dat_reg(s, COND_AL, ARITH_ADD, 0, TCG_AREG0, 0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS)); if (mem_index) tcg_out_dat_imm(s, COND_AL, ARITH_ADD, 0, 0, (mem_index << (TLB_SHIFT & 1)) | ((16 - (TLB_SHIFT >> 1)) << 8)); tcg_out_ld32_12(s, COND_AL, 1, 0, offsetof(CPUState, tlb_table[0][0].addr_write)); tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, 1, 8, SHIFT_IMM_LSL(TARGET_PAGE_BITS)); if (s_bits) tcg_out_dat_imm(s, COND_EQ, ARITH_TST, 0, addr_reg, (1 << s_bits) - 1); # if TARGET_LONG_BITS == 64 tcg_out_ld32_12(s, COND_EQ, 1, 0, offsetof(CPUState, tlb_table[0][0].addr_write) + 4); tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0, 1, addr_reg2, SHIFT_IMM_LSL(0)); # endif tcg_out_ld32_12(s, COND_EQ, 1, 0, offsetof(CPUState, tlb_table[0][0].addend)); switch (opc) { case 0: tcg_out_st8_r(s, COND_EQ, data_reg, addr_reg, 1); break; case 0 | 4: tcg_out_st8s_r(s, COND_EQ, data_reg, addr_reg, 1); break; case 1: tcg_out_st16u_r(s, COND_EQ, data_reg, addr_reg, 1); break; case 1 | 4: tcg_out_st16s_r(s, COND_EQ, data_reg, addr_reg, 1); break; case 2: default: tcg_out_st32_r(s, COND_EQ, data_reg, addr_reg, 1); break; case 3: tcg_out_st32_rwb(s, COND_EQ, data_reg, 1, addr_reg); tcg_out_st32_12(s, COND_EQ, data_reg2, 1, 4); break; } label_ptr = (void *) s->code_ptr; tcg_out_b(s, COND_EQ, 8); if (addr_reg) tcg_out_dat_reg(s, cond, ARITH_MOV, 0, 0, addr_reg, SHIFT_IMM_LSL(0)); # if TARGET_LONG_BITS == 32 switch (opc) { case 0: tcg_out_dat_imm(s, cond, ARITH_AND, 1, data_reg, 0xff); tcg_out_dat_imm(s, cond, ARITH_MOV, 2, 0, mem_index); break; case 1: tcg_out_dat_reg(s, cond, ARITH_MOV, 1, 0, data_reg, SHIFT_IMM_LSL(16)); tcg_out_dat_reg(s, cond, ARITH_MOV, 1, 0, 1, SHIFT_IMM_LSR(16)); tcg_out_dat_imm(s, cond, ARITH_MOV, 2, 0, mem_index); break; case 2: if (data_reg != 1) tcg_out_dat_reg(s, cond, ARITH_MOV, 1, 0, data_reg, SHIFT_IMM_LSL(0)); tcg_out_dat_imm(s, cond, ARITH_MOV, 2, 0, mem_index); break; case 3: if (data_reg != 1) tcg_out_dat_reg(s, cond, ARITH_MOV, 1, 0, data_reg, SHIFT_IMM_LSL(0)); if (data_reg2 != 2) tcg_out_dat_reg(s, cond, ARITH_MOV, 2, 0, data_reg2, SHIFT_IMM_LSL(0)); tcg_out_dat_imm(s, cond, ARITH_MOV, 3, 0, mem_index); break; } # else if (addr_reg2 != 1) tcg_out_dat_reg(s, cond, ARITH_MOV, 1, 0, addr_reg2, SHIFT_IMM_LSL(0)); switch (opc) { case 0: tcg_out_dat_imm(s, cond, ARITH_AND, 2, data_reg, 0xff); tcg_out_dat_imm(s, cond, ARITH_MOV, 3, 0, mem_index); break; case 1: tcg_out_dat_reg(s, cond, ARITH_MOV, 2, 0, data_reg, SHIFT_IMM_LSL(16)); tcg_out_dat_reg(s, cond, ARITH_MOV, 2, 0, 2, SHIFT_IMM_LSR(16)); tcg_out_dat_imm(s, cond, ARITH_MOV, 3, 0, mem_index); break; case 2: if (data_reg != 2) tcg_out_dat_reg(s, cond, ARITH_MOV, 2, 0, data_reg, SHIFT_IMM_LSL(0)); tcg_out_dat_imm(s, cond, ARITH_MOV, 3, 0, mem_index); break; case 3: tcg_out_dat_imm(s, cond, ARITH_MOV, 8, 0, mem_index); tcg_out32(s, (cond << 28) | 0x052d8010); if (data_reg != 2) tcg_out_dat_reg(s, cond, ARITH_MOV, 2, 0, data_reg, SHIFT_IMM_LSL(0)); if (data_reg2 != 3) tcg_out_dat_reg(s, cond, ARITH_MOV, 3, 0, data_reg2, SHIFT_IMM_LSL(0)); break; } # endif # ifdef SAVE_LR tcg_out_dat_reg(s, cond, ARITH_MOV, 8, 0, 14, SHIFT_IMM_LSL(0)); # endif tcg_out_bl(s, cond, (tcg_target_long) qemu_st_helpers[s_bits] - (tcg_target_long) s->code_ptr); # if TARGET_LONG_BITS == 64 if (opc == 3) tcg_out_dat_imm(s, cond, ARITH_ADD, 13, 13, 0x10); # endif # ifdef SAVE_LR tcg_out_dat_reg(s, cond, ARITH_MOV, 14, 0, 8, SHIFT_IMM_LSL(0)); # endif *label_ptr += ((void *) s->code_ptr - (void *) label_ptr - 8) >> 2; #else switch (opc) { case 0: tcg_out_st8_12(s, COND_AL, data_reg, addr_reg, 0); break; case 0 | 4: tcg_out_st8s_8(s, COND_AL, data_reg, addr_reg, 0); break; case 1: tcg_out_st16u_8(s, COND_AL, data_reg, addr_reg, 0); break; case 1 | 4: tcg_out_st16s_8(s, COND_AL, data_reg, addr_reg, 0); break; case 2: default: tcg_out_st32_12(s, COND_AL, data_reg, addr_reg, 0); break; case 3: tcg_out_st32_12(s, COND_AL, data_reg, addr_reg, 0); tcg_out_st32_12(s, COND_AL, data_reg2, addr_reg, 4); break; } #endif }
1threat
static int parse_times(void *log_ctx, int64_t **times, int *nb_times, const char *times_str) { char *p; int i, ret = 0; char *times_str1 = av_strdup(times_str); char *saveptr = NULL; if (!times_str1) return AVERROR(ENOMEM); #define FAIL(err) ret = err; goto end *nb_times = 1; for (p = times_str1; *p; p++) if (*p == ',') (*nb_times)++; *times = av_malloc(sizeof(**times) * *nb_times); if (!*times) { av_log(log_ctx, AV_LOG_ERROR, "Could not allocate forced times array\n"); FAIL(AVERROR(ENOMEM)); } p = times_str1; for (i = 0; i < *nb_times; i++) { int64_t t; char *tstr = av_strtok(p, ",", &saveptr); av_assert0(tstr); p = NULL; ret = av_parse_time(&t, tstr, 1); if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "Invalid time duration specification in %s\n", p); FAIL(AVERROR(EINVAL)); } (*times)[i] = t; if (i && (*times)[i-1] > (*times)[i]) { av_log(log_ctx, AV_LOG_ERROR, "Specified time %f is greater than the following time %f\n", (float)((*times)[i])/1000000, (float)((*times)[i-1])/1000000); FAIL(AVERROR(EINVAL)); } } end: av_free(times_str1); return ret; }
1threat
Regex use in Notepad++, searching : <p>I have a bunch of JSON key-value pairs. Most of them are empty, like this </p> <pre><code>"object": [] </code></pre> <p>However, some of them aren't. I want to use Notepad++'s regex search to find every "object" that has something between the []. I know this is a very basic question, but I don't know anything about regexes except that they could probably be used to solve this problem. If someone can take a few seconds to answer my question it'd save me a lot of searching. Thanks!</p>
0debug
Ngrok errors '502 bad gateway' : <p>Quite new to using any sort of Web App stuff, and I've been trying to slowly build a Facebook Messenger Bot. When I try to use ngrok I can't visit the address I'm given, i.e:</p> <pre><code>ngrok http 5000 </code></pre> <p>is what I'm putting in the command line, and it's returning this:</p> <pre><code>ngrok by @inconshreveable Session Status online Version 2.1.18 Region United States (us) Web Interface http://127.0.0.1:4040 Forwarding http://ea986ca5.ngrok.io -&gt; localhost:5000 Forwarding https://ea986ca5.ngrok.io -&gt; localhost:5000 Connections ttl opn rt1 rt5 p50 p90 0 0 0.00 0.00 0.00 0.00 </code></pre> <p>But when I take the address '<a href="https://ea986ca5.ngrok.io" rel="noreferrer">https://ea986ca5.ngrok.io</a>' as is required by the Facebook developer's page, it says:</p> <pre><code>The connection to http://ea986ca5.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:5000. Make sure that a web service is running on localhost:5000 and that it is a valid address. The error encountered was: dial tcp [::1]:5000: connectex: No connection could be made because the target machine actively refused it. </code></pre> <p>Is it a problem with my local port? Thanks!</p>
0debug
iOS Swift 3 : Convert "yyyy-MM-dd'T'HH:mm:ssZ" format string to date object : <p>Hello i have a dictionary</p> <pre><code>self.publishedAt = dictionary["publishedAt"] as? NSString </code></pre> <p>in which i'm getting date "<strong>2017-01-27T18:36:36Z</strong>". I want to convert it in readable format : <strong>dd-MM-yyyy hh:mm:ss</strong>. i tried via</p> <pre><code>let dateFormatter = DateFormatter() dateFormatter.dateFormat = "dd-MM-yyyy hh:mm:ss" let date = dateFormatter.date(from: (self.publishedAt as? String)!) print("EXACT_DATE : \(date)") </code></pre> <p>But getting nil. :(</p> <p>What is the correct way to get date in simple format?</p>
0debug
ONLY FOR THE BRAVE AND FEARLESS... AttributeError: 'module' object has no attribute 'cbook' NEW VERSION : I've been trying to solve this issue on my own but have concluded that this issue is above my capabilities. I viewed various answers but none seem to work. I've uninstalled matplotlib and all its accessories and re-installed it as well as downgraded with the hopes that it might be version issue. These is what I've found relative to my problem: http://stackoverflow.com/questions/35236953/attributeerror-module-object-has-no-attribute-cbook https://groups.google.com/forum/#!topic/modwsgi/97bnQk9ojtY https://github.com/matplotlib/matplotlib/pull/593 However, none of these option seem to resolve my current issue. This is the output I receive: Traceback (most recent call last): File "/home/ulab03/Documents/PlotExample.py", line 13, in <module> from matplotlib import pyplot as plt File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module> import matplotlib.colorbar File "/usr/lib64/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module> import matplotlib.artist as martist File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 11, in <module> import matplotlib.cbook as cbook AttributeError: 'module' object has no attribute 'cbook' This is the example that I'm using: import matplotlib import numpy as np try: import matplotlib.cbook print 'SUCCESS_1' except: print 'FAIL_1' import matplotlib.pyplot as plt x_data = np.linspace(0,10,11) y_data = np.linspace(0,10,11) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x_data,y_data) plt.show() plt.close() Additional Info: Python Version: 2.7.5 Matplotlib Version: 1.5.0 Numpy Version: 1.11.2 =========================== Please Help. Anyone? Thank you. Did I mention... Happy Holidays
0debug
Configuration.resolve has an unknown property 'root' : <p>I get the following error :</p> <blockquote> <p>Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.resolve has an unknown property 'root'. These properties are valid: object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }</p> </blockquote> <p>I use <a href="https://webpack.js.org/" rel="noreferrer">webpack 2.3.2</a>.</p> <hr> <p>My <strong>webpack.config.js</strong> looks like this :</p> <pre><code>module.exports= { entry:'./public/app.jsx', output: { path: __dirname, filename:'./public/bundle.js' }, resolve: { root: __dirname, alias:{ Mod1: 'public/components/mod1.jsx', Mod2:'public/components/mod2.jsx', Mod3: 'public/components/mod3.jsx' }, extensions: ['*','.js','.jsx'] }, module :{ loaders:[{ loader :'babel-loader', query :{ presets:['react','es2015','es2017'] }, test:/\.jsx?$/, exclude:/(node_modules|bower_components)/ }] } }; </code></pre>
0debug
Amazon S3 static hosting with Namecheap DNS - How to correctly route non-www prefixed url : <p>I have been reading other posts to try to get down to the bottom of this issue... but I need some clarification.</p> <p>I am able to get all of my domain requests to hit my Amazon S3 bucket perfectly when entering www.FOO.com/MyDirectory</p> <p>If I enter FOO.com/MyDirectory without the www it will fail. </p> <p>What is the proper method to make url requests without the www route correctly to the same Amazon S3 bucket? </p> <p>Any tips would help greatly. Thanks</p>
0debug
void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) { KeyValue *key = g_new0(KeyValue, 1); key->type = KEY_VALUE_KIND_NUMBER; key->u.number = num; qemu_input_event_send_key(src, key, down); }
1threat
Converting UNIX timestamps into pandas datetime taking timezone into account : <p>I would like to convert the following pandas series containing UNIX timestamps into a pandas datetime using either <code>to_datetime()</code> or <code>arrow</code> library in Python. I want to set the timezone to UTC and currently it is <code>Europe/Paris</code></p> <p>For Pandas I am using the following function, but not sure how to take the <code>Europe\Paris</code> timezone into account</p> <p><code>pd.to_datetime(df['dates'], unit='s')</code></p>
0debug
Open cv - Processing - detect and tracking some ball : I have a problem with opencv, I must detect and tracking some balls using the program: processing, how do it do? Can I have an exemple? thankyou
0debug
int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest) { int size = av_fifo_size(f); if (size < buf_size) return -1; while (buf_size > 0) { int len = FFMIN(f->end - f->rptr, buf_size); if(func) func(dest, f->rptr, len); else{ memcpy(dest, f->rptr, len); dest = (uint8_t*)dest + len; } av_fifo_drain(f, len); buf_size -= len; } return 0; }
1threat
static int init_tile(Jpeg2000DecoderContext *s, int tileno) { int compno; int tilex = tileno % s->numXtiles; int tiley = tileno / s->numXtiles; Jpeg2000Tile *tile = s->tile + tileno; if (!tile->comp) return AVERROR(ENOMEM); tile->coord[0][0] = FFMAX(tilex * s->tile_width + s->tile_offset_x, s->image_offset_x); tile->coord[0][1] = FFMIN((tilex + 1) * s->tile_width + s->tile_offset_x, s->width); tile->coord[1][0] = FFMAX(tiley * s->tile_height + s->tile_offset_y, s->image_offset_y); tile->coord[1][1] = FFMIN((tiley + 1) * s->tile_height + s->tile_offset_y, s->height); for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; int ret; comp->coord_o[0][0] = tile->coord[0][0]; comp->coord_o[0][1] = tile->coord[0][1]; comp->coord_o[1][0] = tile->coord[1][0]; comp->coord_o[1][1] = tile->coord[1][1]; if (compno) { comp->coord_o[0][0] /= s->cdx[compno]; comp->coord_o[0][1] /= s->cdx[compno]; comp->coord_o[1][0] /= s->cdy[compno]; comp->coord_o[1][1] /= s->cdy[compno]; } comp->coord[0][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][0], s->reduction_factor); comp->coord[0][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[0][1], s->reduction_factor); comp->coord[1][0] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][0], s->reduction_factor); comp->coord[1][1] = ff_jpeg2000_ceildivpow2(comp->coord_o[1][1], s->reduction_factor); if (ret = ff_jpeg2000_init_component(comp, codsty, qntsty, s->cbps[compno], s->cdx[compno], s->cdy[compno], s->avctx)) return ret; } return 0; }
1threat
How to add Adsense to a website built with GatsbyJS? : <p>I'd like to know where I should add the <code>&lt;script&gt;&lt;/script&gt;</code> provided by Google Adsense.</p> <p>They say to add it into the <code>&lt;head&gt;&lt;/head&gt;</code>, but in Gatsby you have Helmet as <code>&lt;head&gt;</code>.</p> <p>I tried also to add the script inside an html.js file where it's located a <code>&lt;head&gt;</code> tag with <code>{``}</code> to escape the <code>&lt;script&gt;</code> tag, but it outputs at the top of the website the script content.</p> <p><strong>TL;DR: What is the optimal way to add Adsense to a website built with GatsbyJS?</strong></p> <ul> <li>I've tried to use the <a href="https://www.npmjs.com/package/react-adsense" rel="noreferrer">react adsense package</a> but I do not understand how to use it with Gatsby.</li> <li>I have tried to add the <code>&lt;script&gt;</code> tag to html.js and it doesn't compile. </li> <li>If you escape it with <code>{``}</code> you get the script as is, on top of the website.</li> </ul> <pre><code>&lt;head&gt; &lt;meta charSet="utf-8" /&gt; &lt;meta httpEquiv="x-ua-compatible" content="ie=edge" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /&gt; {this.props.headComponents} {`&lt;script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"&gt;&lt;/script&gt;`} {` &lt;script&gt; (adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-1540853335472527", enable_page_level_ads: true }); &lt;/script&gt; `} &lt;/head&gt; </code></pre> <p>source: html.js</p> <p><strong>The website should get detected by the Google crawlers.</strong></p>
0debug
static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, int len, hwaddr addr1, hwaddr l, MemoryRegion *mr) { uint8_t *ptr; uint64_t val; MemTxResult result = MEMTX_OK; bool release_lock = false; for (;;) { if (!memory_access_is_direct(mr, true)) { release_lock |= prepare_mmio_access(mr); l = memory_access_size(mr, l, addr1); switch (l) { case 8: val = ldq_p(buf); result |= memory_region_dispatch_write(mr, addr1, val, 8, attrs); break; case 4: val = ldl_p(buf); result |= memory_region_dispatch_write(mr, addr1, val, 4, attrs); break; case 2: val = lduw_p(buf); result |= memory_region_dispatch_write(mr, addr1, val, 2, attrs); break; case 1: val = ldub_p(buf); result |= memory_region_dispatch_write(mr, addr1, val, 1, attrs); break; default: abort(); } } else { ptr = qemu_map_ram_ptr(mr->ram_block, addr1); memcpy(ptr, buf, l); invalidate_and_set_dirty(mr, addr1, l); } if (release_lock) { qemu_mutex_unlock_iothread(); release_lock = false; } len -= l; buf += l; addr += l; if (!len) { break; } l = len; mr = address_space_translate(as, addr, &addr1, &l, true); } return result; }
1threat
theres a syntax error but i didn't find it? : <pre><code>#include &lt;iostream&gt; #include &lt;bits/stdc++.h&gt; using namespace std; int main() { char a[27]= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' '}; char A[27]= {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' '}; string U[27]= {"AAAAA","AAAAB","AAABA","AAABB","AABAA","AABAB","AABBA","AABBB","ABAAA","ABAAB","ABABA","ABABB","ABBAA","ABBAB","ABBBA","ABBBB","BAAAA","BAAAB","BAABA","BAABB","BABAA","BABAB","BABBA","BABBB","BBAAA","BBAAB"," "}; char choiceNum; while (true) { cout&lt;&lt;"Choose what do you want to do today"&lt;&lt;endl&lt;&lt;"1-cipher "&lt;&lt;endl&lt;&lt;"2-decipher"&lt;&lt;endl&lt;&lt;"3-If you End what you want"&lt;&lt;endl; cin&gt;&gt;choiceNum; cin.ignore(); string message, newMessage, message2; int i,k, j ; if (choiceNum=="1") { cout&lt;&lt;"Enter your message to cipher ya man-.-"&lt;&lt;endl; newMessage=""; getline(cin,message); for(i=0 ; i&lt;message.length() ; i++) { for (j=0 ; j&lt;27 ; j++) { if (message[i]==a[j]|| message[i]==A[j] ) { newMessage=newMessage+U[j]; } } } cout&lt;&lt;newMessage&lt;&lt;endl; } if (choiceNum=="2") { cout&lt;&lt;"Enter your message to decipher ya man-.- :"&lt;&lt;endl; newMessage=""; message2=""; getline(cin,message); for(i=0 ; i&lt;message.length() ; ++i) { if (message[i]=='a' || message[i]=='A') { message[i]='A'; } else if (message[i]=='b' || message[i]=='B') { message[i]='B'; } } for(k=0 ; k&lt;message.length() ; ++k) { message2=message2+message[k]; for (j=0 ; j&lt;27 ; ++j) { if (message2==U[j]) { newMessage=newMessage+A[j]; message2=""; } } } cout&lt;&lt;newMessage&lt;&lt;endl; } if (choiceNum=="3") { cout&lt;&lt;"End"; break; } } return 0; </code></pre> <blockquote> <p>||=== Build file: "no target" in "no project" (compiler: unknown) ===| \Baconian cipher.cpp||In function 'int main()':| \Baconian cipher.cpp|25|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]| \Baconian cipher.cpp|49|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]| \Baconian cipher.cpp|91|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]| ||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 5 second(s)) ===|</p> </blockquote> <p>}</p>
0debug
json_decode a json string sent via cors : I was looking around and tried to decode, but it doesn't seem to work for me. //Receive the RAW post responseData. $contentJSON = trim(file_get_contents("php://input")); //Attempt to decode the incoming RAW post responseData from JSON. $contentDECODED = json_decode($contentJSON , true); $action = mysqli_real_escape_string($connection, $contentDECODED["action"]); $customerID = intval(mysqli_real_escape_string($connection, $contentDECODED["customerId"])); $productID_Array = $contentDECODED[gArrayOfProductIds]; `var_dump($productID_Array)` will output: array(3) { [0]=> array(1) { ["productId"]=> int(52979957765) } [1]=> array(1) { ["productId"]=> int(69956304901) } [2]=> array(1) { ["productId"]=> int(69888278533) } } but `var_dump(implode(",",array_map('intval',$productID_Array)));` will output: "1,1,1" and `var_dump(implode(",",$productID_Array));` will output: "Array,Array,Array" could someone shred some light on my problem? along side that what would be the best way to sanitize the input from the json? **HUGE thanks for anyone who might help !**
0debug
How is a GUI made from scratch? : <p>I just got into java GUIs, but the graphics are built upon layers of abstractions. At the fundamental level, what goes into these layers? For example, do primitive types build images. Are they simply a multidimensional array of integers? </p> <p>What should I study to understand how a GUI is built from scratch?</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
what is the difference between ASP.NET Identity and IdentityServer? : <p>I can not understand the difference between the two, asp.net identy is based on OWIN and does not introduce a middleware while IdentityServer introduced him, I'm confused ..</p>
0debug
How to compare a string as a variable to an another variable string? : <p>So, I want to get an answer from the user (Yes or No), and if it's yes do someting, and if no, do something else.</p> <p>I'm using c++ (with Code::Blocks), and I'm a beginner at programming. This is what I managed to do:</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstdlib&gt; using namespace std; int main() { char answer; answer = 1; int x; x = 1; int number1; while ( x &gt; 0 ) { //Ez egy kΓΆszΓΆnΓ©s! cout&lt;&lt;"Type in a number!\n"; //KΓ©rek egy szΓ‘mot cin&gt;&gt; number1; cin.ignore(); //KiΓ­rom a szΓ‘mot cout&lt;&lt;"You entered: "&lt;&lt; number1 &lt;&lt;"\n"; if ( number1 == 666 ) //Ha number1 = 666 akkor kiΓ­rjuk hogy Are you the Devil? { cout&lt;&lt;"Are you the Devil?\n"; x = 0; } if ( number1 != 666 ) { if ( number1 &gt; 5 ) //Ha number1 nagyobb 5nΓ©l kiΓ­rjuk hogy Great Job! { cout&lt;&lt;"Great job!\n"; } if ( number1 &lt; 5 ) //Ha number1 kisebb 5nΓ©l kiΓ­rjuk hogy Good Job! { cout&lt;&lt;"Good job!\n"; } if ( number1 == 5 ) //Ha number1 = 5 akkor kiΓ­rjuk hogy Thank you { cout&lt;&lt;"Thank You\n"; } } cout&lt;&lt;"\n"; //sortΓΆrΓ©s } cin&gt;&gt; answer; if ( answer == 1 ) { cout&lt;&lt;"OH GOD,NO!"; } } </code></pre> <p>It suposed to ask for a number, if you give it one if it's less tan 5 it would say:Good Job!, if more Great Job!, if 5 Thank you, and do it in a loop. And if you type in 666 it would ask if you're devil.and here I want to get an input from the user, Yes or No. if No then it would say: OH GOD,NO, if Yes, well I didn't got there yet...</p>
0debug
static int scale_vector(int16_t *vector, int length) { int bits, max = 0; int64_t scale; int i; for (i = 0; i < length; i++) max = FFMAX(max, FFABS(vector[i])); max = FFMIN(max, 0x7FFF); bits = normalize_bits(max, 15); scale = (bits == 15) ? 0x7FFF : (1 << bits); for (i = 0; i < length; i++) vector[i] = av_clipl_int32(vector[i] * scale << 1) >> 4; return bits - 3; }
1threat
How can I create a while loop that runs all the time but doesn't interfere with the order that the code runs in (PYTHON)? : I'm making a text adventure game in Python to get myself started, as I am not that good at Python yet. I have tried to implement a set of health rules: while True: if health == maxHealth: playerAtMaxHealth = True; elif health > maxHealth: health = maxHealth; elif health < 0: health = 0 elif health == 0: playerDead = True; Here is it with the rest of my code: def startUp(): StartPRINT("""╔═══╗ ║╔══╝ β•‘β•šβ•β•β•¦β•β•β•¦β•β•β•¦β•β•β•¦β•β•β•¦β•β•β•— ║╔══╣══╣╔═╣╔╗║╔╗║║═╣ β•‘β•šβ•β•β•¬β•β•β•‘β•šβ•β•£β•”β•—β•‘β•šβ•β•‘β•‘β•β•£ β•šβ•β•β•β•©β•β•β•©β•β•β•©β•β•šβ•£β•”β•β•©β•β•β• ─────────────║║ β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•šβ• \n""") global gold global health global inventory global berryCollected; global maxHealth; global playerAtMaxHealth; global playerDead berryCollected = False; playerAtMaxHealth = True; playerDead = False gold = 0 health = 30 maxHealth = 30 inventory = [] time.sleep(2) while True: if health == maxHealth: playerAtMaxHealth = True; elif health > maxHealth: health = maxHealth; elif health < 0: health = 0 elif health == 0: playerDead = True; forest() Basically what happens is that it prints out the start text, but then it just gets stuck in the while loop and doesn't move onto forest(). Any help would be greatly appreciated!
0debug