[DNG] Fwd: Mini init script written in Perl boots.
Hi, KatolaZ wrote: << My humble impression is that you need just 4 things: - "The C programming language" (Kernighan & Ritchie), - "C in a nutshell" (Prinz & Crawford), - "The Unix programming environment" (Ritchie & Pike N.B.: *not the one by Burgess*, which is a nice book but not even close to the original UPE), - "Advanced programming in the Unix environment" (Stevens & Rago). >> I will attempt to purchase these books. I love books, they make a good company. In an earlier post you wrote: << Nothing is beyond human comprehension, if you are ready to make the required effort to *study* and *understand* it. >> You seem to work in a university's maths faculty. Can you explain to me this paradox? Consider Set I = {, -3, -2, -1, 0, 1, 2 , 3, }, the set of Integers that is infinite in size having neither a lower bound nor an upper bound. Now, consider Set M = {, -9, -6, -3, 0, 3, 6, 9, }, the set of multiples of 3 that also has neither a lower bound nor an upper bound. BOTH sets are infinite, yet, set I has 3 elements for EVERY element in set M! This gives the impression infinity is graded. But does it makes sense to claim a graded infinity? If it is graded, is it still infinite? Edward ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
[DNG] [OT] Re: Fwd: Mini init script written in Perl boots.
On Mon, Jun 20, 2016 at 09:35:17AM +0200, Edward Bartolo wrote: [cut] > > Consider Set I = {, -3, -2, -1, 0, 1, 2 , 3, }, the set of > Integers that is infinite in size having neither a lower bound nor an > upper bound. > > Now, consider Set M = {, -9, -6, -3, 0, 3, 6, 9, }, the set of > multiples of 3 that also has neither a lower bound nor an upper bound. > > BOTH sets are infinite, yet, set I has 3 elements for EVERY element in > set M! This gives the impression infinity is graded. But does it makes > sense to claim a graded infinity? If it is graded, is it still > infinite? > Despite your question might be a bit off-topic in this list, I am sorry but there is no paradox here. The two sets belong to the class of numerable infinity and have the same cardinality (i.e., the same number of elements), however strange this might seem at a first sight. The proof consists into showing that both have the same size of the set of natural integer numbers N=0,1,2,... and proceeds by assigning the "0" in each set to the number "0", positive elements to odd integers and negative elements to even integers. QED KatolaZ -- [ ~.,_ Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab ] [ "+. katolaz [at] freaknet.org --- katolaz [at] yahoo.it ] [ @) http://kalos.mine.nu --- Devuan GNU + Linux User ] [ @@) http://maths.qmul.ac.uk/~vnicosia -- GPG: 0B5F062F ] [ (@@@) Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ ] ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] How to stop udev from re-ordering devices
Rainer Weikusat wrote: > This is published here in the hope that it is useful for someting. > > The basic design of udev is similar to that of a forking server: There's > a parent process listening for uevents from the kernel on a netlink > socket which passes these events to worker processes for actual > processing. In case no idle worker process is found, a new one is > forked, up to a configurable limit (=> udevd(8)). > > One could argue if using more than one worker process is > actually sensible considering that uevent processing happens > mostly during startup and isn't going to take much time, > especially as this is a text book example of the simple, obvious > design one shouldn't be using if good performance is to be > achieved: The process which read the uevent from the socket is > already running and the CPU executing it has all the data in its > cache and kicking this to another CPU is a waste: The process/ > thread which received the event should process it and another > should be listening for more uevents while this is happening. > > A less-than-desirable side-effect of this model is that uevents causing > driver loads may end up loading the drivers in an order different from > the one the uevents came in. So it's suboptimal - perhaps why the systemd guys are so fond of it ! It also explains the "random" ordering that the systemd guys have "fixed" by making the names even more unfriendly. Personally, I've always just edited /etc/udev/rules.d/70-persistent-net-rules* to give user-friendly names to my interfaces. Typically I use things like ethint, ethext, and so on - far better than trying to remember that eth0 is the internal port, eth1 is the outside, and so on. * Don't know if that's "standard" or a Debian packaging thing. ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
[DNG] Debian Multimedia leftovers
Hallo list! Just an info for those of you with longer running Devuan (alpha) installations: I recently noticed that there are some Debian Multimedia (DMO) leftovers on my system, from the time when it had been merged into the Devuan repository. As DMO is no longer merged, those packages won't receive updates anymore, so it makes sense to remove or downgrade them, or manually add the repo to the sources.list (see http://www.deb-multimedia.org). If you use Synaptic for package management, you can find those packages under the "local" repository. Assuming that all DMO packages end on "-dmo*", you can also find installed packages with one of the following commands: $ dpkg-query -l '*' | grep \\\-dmo | grep ^ii or $ aptitude search -F '%p %v#' ~i | grep \\\-dmo Latest aptitude versions also support the "origin" (%O) escape: $ aptitude search -F '%p %O' ~i | grep \\\-dmo Note that Jessie's aptitude doesn't support this escape yet and returns empty, see dbts #813319. libre Grüße, Florian ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Debian Multimedia leftovers
On Mon, 20 Jun 2016 10:58:10 +0200 Florian Zieboll wrote: > $ aptitude search -F '%p %O' ~i | grep \\\-dmo grepping is here obviously not necessary resp. only works when the "%v#" escape is also given. f. ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] [OT] Re: Fwd: Mini init script written in Perl boots.
Hi KatolaZ, Thanks to your reading list, I downloaded "The C programming language" by (Kernighan & Ritchie) and I am reading it. P.S. That proof is a temptation to pass some time with when I can. I will attempt it. :) Edward On 20/06/2016, KatolaZ wrote: > On Mon, Jun 20, 2016 at 09:35:17AM +0200, Edward Bartolo wrote: > > [cut] > >> >> Consider Set I = {, -3, -2, -1, 0, 1, 2 , 3, }, the set of >> Integers that is infinite in size having neither a lower bound nor an >> upper bound. >> >> Now, consider Set M = {, -9, -6, -3, 0, 3, 6, 9, }, the set of >> multiples of 3 that also has neither a lower bound nor an upper bound. >> >> BOTH sets are infinite, yet, set I has 3 elements for EVERY element in >> set M! This gives the impression infinity is graded. But does it makes >> sense to claim a graded infinity? If it is graded, is it still >> infinite? >> > > Despite your question might be a bit off-topic in this list, I am > sorry but there is no paradox here. The two sets belong to the class > of numerable infinity and have the same cardinality (i.e., the same > number of elements), however strange this might seem at a first > sight. > > The proof consists into showing that both have the same size of the > set of natural integer numbers N=0,1,2,... and proceeds by assigning > the "0" in each set to the number "0", positive elements to odd > integers and negative elements to even integers. > > QED > > KatolaZ > > -- > [ ~.,_ Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab ] > [ "+. katolaz [at] freaknet.org --- katolaz [at] yahoo.it ] > [ @) http://kalos.mine.nu --- Devuan GNU + Linux User ] > [ @@) http://maths.qmul.ac.uk/~vnicosia -- GPG: 0B5F062F ] > [ (@@@) Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ ] > ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
[DNG] jessie-security repository and mirrors in general
Hallo, to my surprise I just noticed, that the version of "locales" in the jessie-security repository is older than the one in the "merged" repo. Not a problem, as the latest version will be installed, but nevertheless I want to report for the case that there's something wrong. BTW, does the auto-mirror check if the provided mirrors are up-to-date? libre Grüße, Florian ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Mini init script written in Perl boots.
Edward Bartolo writes: So, I joined Devuan to contribute code. But, I am NOT appreciated, and to be sincere, sometimes I even think about leaving the project altogether. I am being denigrated just because I make a conscious effort to write simple code. I think not. Because you say things like "sysvinit blah awe", rather, which can get rather tiring. FWIW I think you might both enjoy and benefit from reading Andrew Tannenbaum's book "Operating Systems, Design and Implementation". Any edition will do, you don't need the 3rd. (I have read it cover to cover, including all the code, and I think Linus said he did, too.) Arnt ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Fwd: Mini init script written in Perl boots.
On Mon, Jun 20, 2016 at 09:35:17AM +0200, Edward Bartolo wrote: > > You seem to work in a university's maths faculty. Can you explain to > me this paradox? > > Consider Set I = {, -3, -2, -1, 0, 1, 2 , 3, }, the set of > Integers that is infinite in size having neither a lower bound nor an > upper bound. > > Now, consider Set M = {, -9, -6, -3, 0, 3, 6, 9, }, the set of > multiples of 3 that also has neither a lower bound nor an upper bound. > > BOTH sets are infinite, yet, set I has 3 elements for EVERY element in > set M! This gives the impression infinity is graded. But does it makes > sense to claim a graded infinity? If it is graded, is it still > infinite? Yes, it is a paradox. It arises from thinking about infinite sets with the same intuitions we get in the real worlds about finite sets. It is resolved bu realising the differences. Both sets have the same number of elements. They can be placed in one-to-one correspondence: ... -9 <-> -3 -6 <-> -2 -3 <-> -1 0 <-> 0 3 <-> 1 6 <-> 2 9 <-> 3 ... and one-to-oe correspondence is generally theway mathematicians define the concept of two sets havein the same number of elements. When I studied math in the 60's, we *defined* an infinite set to mean a set that was in one-to-one correspondence with a proper subset of itself. For fun, google "Hilbert's Hotel", for example, https://en.wikipedia.org/wiki/Hilbert%27s_paradox_of_the_Grand_Hotel -- hendrik ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] [OT] Re: Fwd: Mini init script written in Perl, boots.
On 06/20/2016 02:00 PM, Edward Bartolo wrote: Hi KatolaZ, Thanks to your reading list, I downloaded "The C programming language" by (Kernighan & Ritchie) and I am reading it. P.S. That proof is a temptation to pass some time with when I can. I will attempt it.:) Edward Yes..., it's available in pdf. https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf Thanks, Aitor. ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
[DNG] (no subject)
Hi, NOTE: If this thread is not acceptable for DMG admins, please delete. Hi All C gurus, Since I am studying C as instructed, I am encountering situations where I may need help to clarify things a bit. I studying: "The C programming language" (Kernighan & Ritchie) as suggested by KatolaZ. On page Page 34 Exercise 1-9 "Write a program to copy its input to its output, replacing each string of blanks one ore more blanks by a single blank." I wrote the following, tested it, and seems to work, but I think it is too complicated. Any suggestions? -- #include int main() { int c, d = 0; while ((c = getchar()) != EOF) { if (c != ' ') { d = 0; putchar(c); } if (c == ' ' && d == 0) { putchar(c); d = 1; } } return 0; } Edward ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
[DNG] Studying C as told. (For help)
Hi, NOTE: If this thread is not acceptable for DMG admins, please delete. Hi All C gurus, Since I am studying C as instructed, I am encountering situations where I may need help to clarify things a bit. I studying: "The C programming language" (Kernighan & Ritchie) as suggested by KatolaZ. On page Page 34 Exercise 1-9 "Write a program to copy its input to its output, replacing each string of blanks one ore more blanks by a single blank." I wrote the following, tested it, and it seems to work, but I think it is too complicated. Any suggestions? -- #include int main() { int c, d = 0; while ((c = getchar()) != EOF) { if (c != ' ') { d = 0; putchar(c); } if (c == ' ' && d == 0) { putchar(c); d = 1; } } return 0; } Edward ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Studying C as told. (For help)
On Mon, 20 Jun 2016 16:37:08 +0200, Edward Bartolo wrote: [...] > "The C programming language" (Kernighan & Ritchie) [...] > On page Page 34 Exercise 1-9 > "Write a program to copy its input to its output, replacing each > string of blanks one ore more blanks by a single blank." > > I wrote the following, tested it, and it seems to work, but I think it is > too complicated. Any suggestions? > > -- > #include > > int main() > { > int c, d = 0; > while ((c = getchar()) != EOF) { > if (c != ' ') { > d = 0; > putchar(c); > } > if (c == ' ' && d == 0) { > putchar(c); > d = 1; > } > } > > return 0; > } > Good job so far! Note to other readers: The 'else' keyword has not been covered at this point in the book. So the solution looks a bit suboptimal, but is correct nonetheless. However, since the '&&' operator has not been covered as well, the second if-block would read something like that in a straight-forward true-to-the-letter solution: if (c == ' ') { if (d == 0) { putchar(c); d = 1; } } One more hint: There exists a web page listing possible solutions to the exercises in K&R2, peer reviewed by designated expert C programmers: http://clc-wiki.net/wiki/K%26R2_solutions HTH, Regards Urban ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
[DNG] [OT] [Re: Studying C as told. (For help)
On Mon, Jun 20, 2016 at 04:37:08PM +0200, Edward Bartolo wrote: [cut] > > On page Page 34 Exercise 1-9 > "Write a program to copy its input to its output, replacing each > string of blanks one ore more blanks by a single blank." > > I wrote the following, tested it, and it seems to work, but I think it is > too complicated. Any suggestions? > > -- > #include > > int main() > { > int c, d = 0; > while ((c = getchar()) != EOF) { > if (c != ' ') { > d = 0; > putchar(c); > } > if (c == ' ' && d == 0) { > putchar(c); > d = 1; > } > } > > return 0; > } > It looks plain and correct to me :) An equivalent version which avoids the chain of ifs might read: -- #include int main (int argc, char *argv[]){ int c,d=0; while((c=getchar()) != EOF){ putchar(c); while(c == ' ' && (c=getchar()) != EOF ){ d=1; } if (d){ putchar(c); } d=0; } } - which can be further streched into: - #include int main (int argc, char *argv[]){ int c,d=0; while((c=getchar()) != EOF){ c=putchar(c); while(c == ' ' && (c=getchar()) != EOF && (d=1)); if (d && putchar(c) && (d=0)); } } - But, admittedly, sacrifying quite a lot in terms of readability without a reason. WD KatolaZ -- [ ~.,_ Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab ] [ "+. katolaz [at] freaknet.org --- katolaz [at] yahoo.it ] [ @) http://kalos.mine.nu --- Devuan GNU + Linux User ] [ @@) http://maths.qmul.ac.uk/~vnicosia -- GPG: 0B5F062F ] [ (@@@) Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ ] ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] (no subject)
Edward Bartolo writes: [...] > On page Page 34 Exercise 1-9 > "Write a program to copy its input to its output, replacing each > string of blanks one ore more blanks by a single blank." > > I wrote the following, tested it, and seems to work, but I think it is > too complicated. Any suggestions? > > -- > #include > > int main() > { > int c, d = 0; > while ((c = getchar()) != EOF) { > if (c != ' ') { > d = 0; > putchar(c); > } > if (c == ' ' && d == 0) { > putchar(c); > d = 1; > } > } > > return 0; > } > Conventional approach using a state variable: #include int main(void) { int c, blanks; blanks = 0; while ((c = getchar()) != EOF) { if (blanks) { if (c == ' ') continue; blanks = 0; } else blanks = c == ' '; putchar(c); } return 0; } Less conventional approach using a function pointer as state variable. NB: This is really overkill here but very helpful in case of (much) more complicated state machines. #include static void put_a_char(int); static void (*process_char)(int) = put_a_char; static void skip_blanks(int c) { if (c == ' ') return; process_char = put_a_char; putchar(c); } static void put_a_char(int c) { putchar(c); if (c == ' ') process_char = skip_blanks; } int main(void) { int c; while ((c = getchar()) != EOF) process_char(c); return 0; } ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] [OT] [Re: Studying C as told. (For help)
On Mon, Jun 20, 2016 at 04:27:12PM +0100, KatolaZ wrote: [cut] > > which can be further streched into: > ^ I obviously meant "squeezed into" HND KatolaZ -- [ ~.,_ Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab ] [ "+. katolaz [at] freaknet.org --- katolaz [at] yahoo.it ] [ @) http://kalos.mine.nu --- Devuan GNU + Linux User ] [ @@) http://maths.qmul.ac.uk/~vnicosia -- GPG: 0B5F062F ] [ (@@@) Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ ] ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] (no subject)
Hi, Rainer wrote: << Conventional approach using a state variable: #include int main(void) { int c, blanks; blanks = 0; while ((c = getchar()) != EOF) { if (blanks) { if (c == ' ') continue; blanks = 0; } else blanks = c == ' '; putchar(c); } return 0; } >> If a blank is already found, and c is yet another blank, jump to next iteration. If not, set blanks to zero and place c in the output stream. If blank is set to zero, test whether c is a blank and assign the new value to blank. Execute the next statement putchar(c). I see the action of blank like a toggle switch. If the switch is on, certain conditions apply, if not, other distinct conditions apply. Rainer wrote: << #include static void put_a_char(int); static void (*process_char)(int) = put_a_char; static void skip_blanks(int c) { if (c == ' ') return; process_char = put_a_char; putchar(c); } static void put_a_char(int c) { putchar(c); if (c == ' ') process_char = skip_blanks; } int main(void) { int c; while ((c = getchar()) != EOF) process_char(c); return 0; } >> I will try although I may fail. The main function: a while loop repeatedly runs getchar assigning it to c and testing whether it is an EOF. If not, process_char is called with c as parameter passed by value. Initially process_char is assigned put_a_char which calls putchar(c), checks whether c is a space in which case it assigns process_char the address of skip_blanks. The next iteration must call skip_blanks, which returns immediately if a blank is found. If not, c is not a blank, and the function pointer is assigned the previous value. After this step putchar(c) is called. Thanks, Edward. On 20/06/2016, Rainer Weikusat wrote: > Edward Bartolo writes: > > [...] > >> On page Page 34 Exercise 1-9 >> "Write a program to copy its input to its output, replacing each >> string of blanks one ore more blanks by a single blank." >> >> I wrote the following, tested it, and seems to work, but I think it is >> too complicated. Any suggestions? >> >> -- >> #include >> >> int main() >> { >> int c, d = 0; >> while ((c = getchar()) != EOF) { >> if (c != ' ') { >> d = 0; >> putchar(c); >> } >> if (c == ' ' && d == 0) { >> putchar(c); >> d = 1; >> } >> } >> >> return 0; >> } >> > > Conventional approach using a state variable: > > > #include > > int main(void) > { > int c, blanks; > > blanks = 0; > while ((c = getchar()) != EOF) { > if (blanks) { > if (c == ' ') continue; > blanks = 0; > } else > blanks = c == ' '; > > putchar(c); > } > > return 0; > } > > > Less conventional approach using a function pointer as state variable. > > NB: This is really overkill here but very helpful in case of (much) more > complicated state machines. > > > #include > > static void put_a_char(int); > > static void (*process_char)(int) = put_a_char; > > static void skip_blanks(int c) > { > if (c == ' ') return; > > process_char = put_a_char; > putchar(c); > } > > static void put_a_char(int c) > { > putchar(c); > if (c == ' ') process_char = skip_blanks; > } > > > int main(void) > { > int c; > > while ((c = getchar()) != EOF) process_char(c); > > return 0; > } > > ___ > Dng mailing list > Dng@lists.dyne.org > https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng > ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] How to stop udev from re-ordering devices
On Mon, 20 Jun 2016 09:26:56 +0100 Simon Hobson wrote: > Rainer Weikusat wrote: > > > This is published here in the hope that it is useful for someting. > > > > The basic design of udev is similar to that of a forking server: > > There's a parent process listening for uevents from the kernel on a > > netlink socket which passes these events to worker processes for > > actual processing. In case no idle worker process is found, a new > > one is forked, up to a configurable limit (=> udevd(8)). > > > > One could argue if using more than one worker process is > > actually sensible considering that uevent processing happens > > mostly during startup and isn't going to take much time, > > especially as this is a text book example of the simple, > > obvious design one shouldn't be using if good performance is to be > > achieved: The process which read the uevent from the socket > > is already running and the CPU executing it has all the data in its > > cache and kicking this to another CPU is a waste: The > > process/ thread which received the event should process it and > > another should be listening for more uevents while this is > > happening. > > > > A less-than-desirable side-effect of this model is that uevents > > causing driver loads may end up loading the drivers in an order > > different from the one the uevents came in. > > So it's suboptimal - perhaps why the systemd guys are so fond of it ! > It also explains the "random" ordering that the systemd guys have > "fixed" by making the names even more unfriendly. > > Personally, I've always just > edited /etc/udev/rules.d/70-persistent-net-rules* to give > user-friendly names to my interfaces. Typically I use things like > ethint, ethext, and so on - far better than trying to remember that > eth0 is the internal port, eth1 is the outside, and so on. > > * Don't know if that's "standard" or a Debian packaging thing. Of all the escapades of FreeDesktop.Org, managers of Lennart and the Redhats, these name thingies are some of the least onerous. I put a shellscript on the list a few months ago that delivers the wifi device name, and that script can be used in init scripts and the like. I mean, by all means use it as a talking point, but if it's actually giving you trouble, look up my shellscript and use it. SteveT Steve Litt June 2016 featured book: Troubleshooting: Why Bother? http://www.troubleshooters.com/twb ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] [Completely OT] Re: Fwd: Mini init script written in Perl boots.
On Mon, 20 Jun 2016 12:55:11 +0200 Edward Bartolo wrote: > Hi KatolaZ, > > Thanks to your reading list, I downloaded "The C programming language" > by (Kernighan & Ritchie) and I am reading it. > > P.S. > That proof is a temptation to pass some time with when I can. I will > attempt it. :) > > Edward Maan, that brings back memories. 1984-1988, I roller biked, skated and skateboarded all around Venice, Santa Monica, Culver City, West LA, Hollywood and LA. Everywhere I went, in my backpack was "The C programming language", ***FIRST EDITION***. That edition was half as thick, and twice as mysterious. IIRC there was no such thing as function prototypes in that book: Back then you declared function args in some really weird syntax I was happy to forget. By the early 1990's, my book was so shredded it could no longer be held together by tape the way it had in the past half decade. I literally wore out the book. I threw it in the trash, went on down to Opamp Books (RIP), and bought the 2nd edition, which was a spectacular improvement. I hope you're reading the 2nd edition, because the 1st edition was quirky, too clever for its own good, and utterly obsolete by 1995. By the way, the book that really taught me C in 1984 was this one: http://www.barnesandnoble.com/w/c-puzzle-book-alan-r-feuer/1100482268?ean=9780201604610&quickview=true And Edward, learn from my mistakes, never do this: char * tweak_string(char * st){ maxsize=1000; if (strlen(st)> maxsize-20) return NULL; char buf[maxsize]; strcpy(buf, "pre_"); strncat(buf, st, maxsize-20); buf[strlen(st)+3] = '\0'; return(buf); } I should have gotten fired. It created an intermittent that took 2 weeks to track down. I never did it again. SteveT Steve Litt June 2016 featured book: Troubleshooting: Why Bother? http://www.troubleshooters.com/twb ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] [OT] Re: Fwd: Mini init script written in Perl, boots.
On Mon, 20 Jun 2016 15:53:30 +0200 aitor_czr wrote: > Yes..., it's available in pdf. > > https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf Is that legal? SteveT Steve Litt June 2016 featured book: Troubleshooting: Why Bother? http://www.troubleshooters.com/twb ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] LXC template for Devuan
On 06/20/2016 07:28 AM, Greg Olsen wrote: Hi Simon, No rush. Unless I find some glaring bug, after a bit more testing I intend to refocus on pushing upstream and what's needed to make "lxc-devuan" packages for Jessie/Ascii/Ceres. It'll be the first .deb package I've made completely from scratch (suggestions are welcome, please). Disable --no-check-gpg as the fallback? No votes against this: +1 Simon Walter +1 Greg Olsen So when convenient, I may go ahead and disable that. Hi Greg, I've added a branch called add-netconf, which you have probably seen. I thought to just add one feature per branch so that review is easier. Let me know how you prefer to collaborate. I was not sure about what style/standards we are using. However, the hashbang tells me bash. I looked at the other templates, and most use bash. I wasn't sure if having all the settings in one argument or separate was better. The logic behind having them all in one argument is that all those are needed and cannot be derived from one another. So IP, netmask, and gateway are all in one comma separated argument. Maybe the parameter name should be "interface" or "ifconfig". For my next edit, I would like to add the password parameter and if not specified would set a random one. Then I was thinking of adding a parameter for MAC address, in case it should be explicitly set or not set or set to a random address. I would appreciate your comments on that and of course on the netconf parameter and it's functionality. One question, is --main-only the default? What is the default for the Devuan install? I am not sure, but I think the default is only main. If so, maybe we should reverse that argument to be something like --extra-repos. Or even --add-repos=main,non-free. That way the use can specify exactly the additional repositories on the command line. I think that would be very useful for orchestration tools such as vagrant or cdist for example. Cheers, Simon ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] Studying C as told. (For help)
> On June 20, 2016 at 10:37 AM Edward Bartolo wrote: > > On page Page 34 Exercise 1-9 > "Write a program to copy its input to its output, replacing each > string of blanks one ore more blanks by a single blank." > > I wrote the following, tested it, and it seems to work, but I think it is > too complicated. Any suggestions? Here's another way to do it: /* * K&R exercise * * Replace multiple blanks with single blank */ #include #include #include static int filter (void) { int ch = getchar ();/* all the logic is here */ if (EOF != ch) { putchar (ch); if (' ' == ch) for (;;) { ch = getchar (); if (' ' != ch) { if (EOF != ch) putchar (ch); break; } } } return ch; } static int checkError (FILE * fp, const char *arg) { if (ferror (fp)) { const char *pgmName = strrchr (arg, '/'); if (pgmName) pgmName++;/* get beyond the slash */ else pgmName = arg; fprintf (stderr, "%s: I/O error: %s\n", pgmName, strerror (errno)); return 1; } return 0; } int main (int argc, char **argv) { while (EOF != filter ()) continue; /* this version encodes state in program structure */ if (checkError (stdin, argv[0])) return 1; /* this version checks for errors */ if (checkError (stdout, argv[0])) return 1; /* I didn't actually reproduce this error, it is hard to test */ return 0; } I hope this survives line wrapping :-) Peter Olson ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] [OT] [Re: Studying C as told. (For help)
Hi, I wrote: << This is the previous version compressed by using another && operand in the boolean expressions. The final sub-expression is an assignment, which always evaluates to true provided the other two sub-expressions evaluate to true. The final statement uses a similar strategy to compress statements. The key is that a chain of && statements must be always fully evaluated for the result of the whole expression to be known. A chain of || only need a sub-expression to evaluate to true for the result of the whole expression to be known. >> I studied 'and' and 'or' boolean operators back when I studied Delphi Pascal. I am embarrassed to have written such a stupid thing. It must be due to the fact I wrote the email just before going to bed. AND: requires ALL sub-expressions to be true to evaluate to true i.e. Q = A ^ B ^ C ^ D Q = 1 if and only if A = B = C = D = 1 OR: only requires ONE sub-exression to be true to evaluate to true i.e. Q = A v B v C v D Q = 1 if any Ai = 1 These properties are used by compilers to optimize on boolean expression evaluation. If I remember well, there are also specific algorithms to optimize boolean evaluation. I can mention boolean expression simplification techniques as used to minimize the number of gates used in logic circuits. Thanks, Edward On 21/06/2016, KatolaZ wrote: > On Mon, Jun 20, 2016 at 10:12:40PM +0200, Edward Bartolo wrote: > > [cut] > >> int main (int argc, char *argv[]){ >> >> int c,d=0; >> while((c=getchar()) != EOF){ >> c=putchar(c); >> while(c == ' ' && (c=getchar()) != EOF && (d=1)); >> if (d && putchar(c) && (d=0)); >> } >> } >> >> >> >> This is the previous version compressed by using another && operand in >> the boolean expressions. The final sub-expression is an assignment, >> which always evaluates to true provided the other two sub-expressions > > No, this last sentence is not correct. The value of an assignment > expression is the value of the right-hand-side of the assignment, as > you can verify by running this little program: > > > > #include > > int main(){ > int c; > if (c = 0){ > printf("tad!\n"); > } > } > > > > Note the condition of the if statement (c=0 and not c==0)... > >> evaluate to true. The final statement uses a similar strategy to >> compress statements. The key is that a chain of && statements must be >> always fully evaluated for the result of the whole expression to be >> known. A chain of || only need a sub-expression to evaluate to true >> for the result of the whole expression to be known. > > Also this is false. Each element of a chain of "&&" is evaluated until > one of the elements evaluate to FALSE (0), since in that case the > result of the && is known (and is equal to 0). The dual happens for > expressions chained through ||: each of them is evaluated until there > is one that evaluates to TRUE (!=0), because at that point the result > of the chain is known (and is equal to 1). > > This is called "operator short-circuiting", and can give rise to > pretty unreadable code in C... > > HND > > KatolaZ > > -- > [ ~.,_ Enzo Nicosia aka KatolaZ - GLUGCT -- Freaknet Medialab ] > [ "+. katolaz [at] freaknet.org --- katolaz [at] yahoo.it ] > [ @) http://kalos.mine.nu --- Devuan GNU + Linux User ] > [ @@) http://maths.qmul.ac.uk/~vnicosia -- GPG: 0B5F062F ] > [ (@@@) Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ ] > ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng