Friday, September 4, 2020

Digest for comp.lang.c++@googlegroups.com - 10 updates in 3 topics

Frederick Gotham <cauldwell.thomas@gmail.com>: Sep 04 10:38AM -0700

On operating systems similar to Unix (e.g. Linux, MacOS, Android), there are a handful of ways that people convert an ASCII hexadecimal to raw binary at the command line. Typically one of the following is used:
 
xxd
hexdump
od
bc
 
As I work on embedded Linux a lot, where I don't have 'bash' and where there's a very limited number of utilities available, I'm trying to find the most basic way of achieving my objective -- that will work on pretty much every Unix-like system.
 
Lots of embedded Linux systems don't have hexdump, xxd, od, bc.
 
The most simple I've been able to make it is the following 3 ubiquitous programs:
 
echo
sed
xargs
 
Like this:
 
some_other_program | sed 's/../\\x&/g' | xargs echo -e
 
Can anyone think of an even more simple way?
Juha Nieminen <nospam@thanks.invalid>: Sep 04 07:19PM

> Can anyone think of an even more simple way?
 
Since you are asking a C++ group, you could write it in C++ (or C),
but I don't know if it would be the simplest way. (Well, after it
has been implemented an compiled it will become really simple.)
 
But it would certainly be extremely efficient.
 
Of course implementing it depends on your requirements. What is
the exact input syntax? Is whitespace allowed (and to be ignored)?
What should happen if the input contains non-hexadecimal characters?
Should the program support input files and/or output files as
command-line parameters?
legalize+jeeves@mail.xmission.com (Richard): Sep 04 07:38PM

[Please do not mail me a copy of your followup]
 
Frederick Gotham <cauldwell.thomas@gmail.com> spake the secret code
 
>Can anyone think of an even more simple way?
 
Why not write your own?
 
#include <cstdio>
 
int main(int argc, char *argv[])
{
while (!std::feof(stdin))
{
int val{};
if (std::scanf("%2x", &val) == 1)
{
std::printf("%c", static_cast<char>(val));
}
}
return 0;
}
 
> echo 22 | ./a.out
"
> (echo 22; echo 22) | ./a.out
""
 
scanf will skip interposing whitespace when parsing integers. You can
add additional whitespace handling if that is what you need.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Sep 04 09:12PM +0100

On 04/09/2020 18:38, Frederick Gotham wrote:
 
> Like this:
 
> some_other_program | sed 's/../\\x&/g' | xargs echo -e
 
> Can anyone think of an even more simple way?
 
You are mistaken, macOS is not similar to UNIX, macOS *is* UNIX.
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Sep 04 01:54PM -0700

> }
> return 0;
> }
 
I advise against using feof() to determine whether there's any remaining
input. The above will be an infinite loop if there's an input error.
Use the value returned by the input function. (In this case, scanf()
returns EOF on end-of-file or an input error.)
 
[...]
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
olcott <NoOne@NoWhere.com>: Sep 03 10:02PM -0500

On 9/3/2020 8:50 PM, Ben Bacarisse wrote:
> rate, in another 20 months, you will have a blank piece of paper.
 
> And you don't have to show Turing completeness or equivalence. All of
> that is a red herring
 
No it was proactively eliminating the basis for rejection.
I wanted to eliminate the possibility that I would have to spent another
two years convincing people that my works applies to Turing Machines.
 
> written as a TM or in x86 code, Fortran, C anything else) can never
> require more than a finite quantity of memory. You don't need an
> unbounded model for one finite computation.
 
Yes now lets make sure we totally describe that completely using all the
right terms of the art. When I describe the gist of what I have so that
this gist can be easily understood you always tear it apart on what
seems to me to be nit-picky trivialities.
 
Basically what I have is code that matches the Linz H-hat template in
that it presents halt deciders with the conventional self-referential
seemingly impossible case. It only matches this aspect of the Linz
template. http://www.liarparadox.org/Peter_Linz_HP(Pages_315-320).pdf
 
I implemented this code to be equivalent to a UTM with the exception of
unlimited memory. It is well known in the field that RASP machines are
Turing equivalent and equivalent to UTMs,
 
I did it this way to eliminate the tedious dichotomy of a machine and
its description. The x86 machine code is both the machine and its
description. H_Hat can both examine itself and execute itself in
debug-step mode. H_Hat can also correctly decide halting for many other
x86 programs.
 
It was designed so that it can provide correct yes or no answers to
whether it halts on itself as input. The 2018 implementation was very
brittle it could only decide a single instance of itself. The latest
design is much more robust. I could add this much great robustness with
very little extra coding.
 
> the boasting party will be over when you have to publish, so you will
> delay for as long as you possibly can. That's probably going to be
> years, isn't it?
 
No. The Master UTM equivalent is almost done. I have been working on it
for many months at least 60 hours per week. The master UTM may be ready
for review next week. There might be another delay in getting it to work
on Linux again. I may eventually implement it as a web-service.
 
Once all the infrastructure is in place implementing the: (every single
step of design is already complete) halting code will be nearly trivial.
 
 
 
--
Copyright 2020 Pete Olcott
Jeff Barnett <jbb@notatt.com>: Sep 03 10:44PM -0600

On 9/3/2020 9:02 PM, olcott wrote:
> for many months at least 60 hours per week. The master UTM may be ready
> for review next week. There might be another delay in getting it to work
> on Linux again. I may eventually implement it as a web-service.
 
Nonsense! Let's add it up per week:
 
60 hours coding an insufficient and impossible program;
 
an average of 20 emails per day at 15 minutes per msg is 35 hours per week;
 
time to recall previous lies and mistakes and plan to not expose your
back side to more humiliation is about 3 hours a week;
 
average of 3 new quotes per day of undigested material at 15 minutes per
is 5+ hours a week;
 
time to celebrate if a troll or recover from humiliation if a pseudo
philosopher is about 30 minutes per day and 3+ hours per week;
 
an average of 1 hour a day to procure food, prepare it, then consume it
is 7 hours a week;
 
time to work on your {G|g}od blog is 3 hours a week;
 
time to brush teeth, shower, etc. 3+ hours a week;
 
assuming you aren't completely constipated, 3 hours a week in front of
or on the throne;
 
average time to pay bills, renew insurance, etc. is 3 hours per week;
 
tidy up your place, do or submit your laundry, take out the garbage,
etc. averages 3 hours a week.
-------------------------------------------------------------------
I think the above comes to 122 hours a week leaving 22 hours or 3 hours
a day for sleep. I assume that you don't have a pet, a live in person
with whom you interact, or any hobbies. If any of these assumptions are
false, there's even less sleep.
--
Jeff Barnett
red floyd <no.spam.here@its.invalid>: Sep 04 11:09AM -0700

On 9/3/2020 9:44 PM, Jeff Barnett wrote:
[redacted]
> a day for sleep. I assume that you don't have a pet, a live in person
> with whom you interact, or any hobbies. If any of these assumptions are
> false, there's even less sleep.
 
Minor math error. There are 168 hours in a week. 168-122 = 46. He has
just over 6 hours to sleep, and do anything else.
olcott <NoOne@NoWhere.com>: Sep 04 01:34PM -0500

On 9/4/2020 1:09 PM, red floyd wrote:
>> false, there's even less sleep.
 
> Minor math error. There are 168 hours in a week. 168-122 = 46. He has
> just over 6 hours to sleep, and do anything else.
 
Between discussing this on the internet and the software engineering of
my x86 based UTM equivalent I spent at least twelve hours per day six
days per week and only 8 hours on my day of rest.
 
I usually get between 7 and 8 hours per night of sleep, I take many
short-cuts to greatly reduce the other normal daily chores. For example
daily food preparation takes about two minutes per five small meals.
Roasting a chicken once per week takes less that 30 minutes of labor
including packaging the portions. Grocery shopping is point and click.
 
--
Copyright 2020 Pete Olcott
RM <robert_magdziarz@wp.pl>: Sep 04 04:44PM +0200

I am programming PHP obfuscator in C++.
I want to encode PHP string literals. I want to encode PHP code treated
as text:
 
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
 
into text:
 
namespace app\assets;
define('gkvxplzzsz_y_y_', 'yii\bootstrap\BootstrapAsset');
define('gbajlprgjb_y_y_', 'yii\web\YiiAsset'); define('ufapteqrhz_y_y_',
'css/site.css'); define('zgvjafbnir_y_y_', '@webroot');
define('gyoltyituv_y_y_', '@web');
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = zgvjafbnir_y_y_;
public $baseUrl = gyoltyituv_y_y_;
public $css = [
ufapteqrhz_y_y_,
];
public $js = [
];
public $depends = [
gbajlprgjb_y_y_,
gkvxplzzsz_y_y_,
];
}
 
To achieve this I wrote C++ function:
 
string insert_string_defines(const string &defines, const string &subject) {
size_t pos = subject.find("<?php");
if (pos == string::npos) {
return subject;
}
regex
re_namespace(R"((declare(\s|\n)*\([A-Za-z0-9_=\s]+\)(\s|\n)*;(\s|\n)*)*namespace\s+([A-Za-z0-9_\\]+)(\s|\n)+;)"
/* regex::extended */);
// optional namespace definition must occur before almost anything
(PHP syntax requirement):
string s = subject.substr(0, pos) +
regex_replace(subject.substr(pos), re_namespace, "$1\nnamespace $2;\n" +
defines);
if (s != subject) {
return s;
}
return subject.substr(0, pos) + "<?php\n" + defines + '\n' +
subject.substr(pos + 5);
}
 
I failed to find C++ regex tester in WWW, thus I don't know what's wrong
with my regex. Please help.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: