Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

ExcessBLarg! posted:

I'm guilty of using parentheses with "function-like" keywords like sizeof. It's a little weird, although not entirely uncommon to smash control flow keywords (if, for, while) against the condition parenthesis. Common C style guides (KNF/style(9) and Linux kernel) do include space there, I think in part to distinguish them from function calls, but also because those keywords also introduce expression blocks anyways.

If you merely put an if/for/while against a parenthesis, I will frown at your code and move on. If you do this, however, I will curse you and your descendants to the seventh generation:
code:
if( butt ) {...}
for( fart=... ) {...}
while( dick ) {...}

Adbot
ADBOT LOVES YOU

jony neuemonic
Nov 13, 2009

Zopotantor posted:

If you merely put an if/for/while against a parenthesis, I will frown at your code and move on. If you do this, however, I will curse you and your descendants to the seventh generation:
code:
if( butt ) {...}
for( fart=... ) {...}
while( dick ) {...}

I worked at a place that put whitespace around and inside parens and braces, and also put all braces on newlines. I'm all for whitespace, but come on.

McGlockenshire
Dec 16, 2005

GOLLOCKS!
Ended up auditing our mysql stored procs and found this delightful one, business_day_diff()

code:
RETURN IF(start_date <= end_date,
          5 * (DATEDIFF(end_date, start_date) DIV 7) + MID('0123444401233334012222340111123400012345001234550', 7 * WEEKDAY(start_date) + WEEKDAY(end_date) + 1, 1),
         -(5 * (DATEDIFF(start_date, end_date) DIV 7) + MID('0123444401233334012222340111123400012345001234550', 7 * WEEKDAY(end_date) + WEEKDAY(start_date) + 1, 1))
         )
What's worse, that this exists, that this works, or that this is probably the best way to do it?

e: ffs, it came from StackOverflow... look at those tables. LOOK AT THEM.

McGlockenshire fucked around with this message at 21:34 on Sep 10, 2015

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

McGlockenshire posted:

e: ffs, it came from StackOverflow... look at those tables. LOOK AT THEM.

A hero for our times: that dude who resistd the temptation of showing off his clever coding skills in favour of a sober reminder that no, you need an actual calendar because holidays exist.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

McGlockenshire posted:

What's worse, that this exists, that this works, or that this is probably the best way to do it?

e: ffs, it came from StackOverflow... look at those tables. LOOK AT THEM.

That actually seems pretty clever, and not horrible to me.


NihilCredo posted:

A hero for our times: that dude who resistd the temptation of showing off his clever coding skills in favour of a sober reminder that no, you need an actual calendar because holidays exist.

The questioner specifically stated that holidays need not be taken into account. I am sure everyone who answered that question understands that holidays are a thing.

loinburger
Jul 10, 2004
Sweet Sauce Jones
The Version Control Rules for the project I'm on are that two other developers need to review a pull request before it can be merged - that's pretty much the same as every other project I've worked on for every semi-competent employer. The problem is that this project only has four developers on it and three of them are front end developers with me as the odd man out on the back end, and so none of the front end developers want to review my code. Every few weeks my boss's boss (my direct boss being one of the front end developers) will ask why I have so many unmerged pull requests, I'll say that nobody wants to review them, and he'll tell me to just go ahead and merge them and let QA basically act as a replacement for code review. So the system is broken but more or less works anyway.

sarehu
Apr 20, 2007

(call/cc call/cc)
code:
int parse_integer(const char *s, unsigned int base, T *val);
https://lkml.org/lkml/2015/9/9/602
Why, yes, C programmers are still making interfaces that put error information and success information in the same return value.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

sarehu posted:

code:
int parse_integer(const char *s, unsigned int base, T *val);
https://lkml.org/lkml/2015/9/9/602
Why, yes, C programmers are still making interfaces that put error information and success information in the same return value.

drat. Linus took a claw hammer and went prospecting for new assholes in that guy's colon. I understand he's frustrated, but holy poo poo.

VikingofRock
Aug 24, 2008




Centripetal Horse posted:

drat. Linus took a claw hammer and went prospecting for new assholes in that guy's colon. I understand he's frustrated, but holy poo poo.

That's really not that bad by Linus standards

Kazinsal
Dec 13, 2011


VikingofRock posted:

That's really not that bad by Linus standards

"Mauro, SHUT THE gently caress UP!" will always be the gold standard of Torvalds pushing someone's poo poo in.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I was always partial to "Of course, I'd also suggest that whoever was the genius who thought it was a good idea to read things ONE F*CKING BYTE AT A TIME with system calls for each byte should be retroactively aborted. Who the f*ck does idiotic things like that? How did they noty die as babies, considering that they were likely too stupid to find a tit to suck on?"

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Suspicious Dish posted:

I was always partial to "Of course, I'd also suggest that whoever was the genius who thought it was a good idea to read things ONE F*CKING BYTE AT A TIME with system calls for each byte should be retroactively aborted. Who the f*ck does idiotic things like that? How did they noty die as babies, considering that they were likely too stupid to find a tit to suck on?"

5

He's right though, who could possibly think that's a good idea.

substitute
Aug 30, 2003

you for my mum
I *really* really *don't* understand the use of asterisks as if they're *quotes*. Is that use of markdown, but not parsing in the context?

Space Kablooey
May 6, 2009


Joke answer: Because they will probably break whatever 70's software he's probably using to compose and send mail.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

substitute posted:

I *really* really *don't* understand the use of asterisks as if they're *quotes*. Is that use of markdown, but not parsing in the context?

Many programs (including some mail programs) will bold stuff surrounded by asterisks, underline stuff surrounded by underscores, etc. Markdown didn't come up with that poo poo from thin air. Hell, even terminal irc clients do it.

substitute
Aug 30, 2003

you for my mum

Blotto Skorzany posted:

Many programs (including some mail programs) will bold stuff surrounded by asterisks, underline stuff surrounded by underscores, etc. Markdown didn't come up with that poo poo from thin air. Hell, even terminal irc clients do it.

Got it. Just seemed so weird, like some super sperg thing at first.

Dylan16807
May 12, 2010
Asterisks are a reasonable way to emphasize words. Though one common problem is people doing the opposite, using "scare quotes" for emphasis, and undermining themselves in hilarious ways.


For example:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
*rings bell*

TheresaJayne
Jul 1, 2011

VikingofRock posted:

That's really not that bad by Linus standards

Some of our crucible reviews at work are nasty, one guy did some code and then had 12 people rip him a new one with more and more elegant and better solutiions for this piece of work - I was one of the reviewers and i had to rip one of the other reviewers a new one, as he said that they should have done a switch(string) block,

Which is impossible as we do not use java 1.7 but java 1.5 where switching was only on enums and ints.

(he should have known better though he was the Tech lead for that part of the system (hmmm thats why my yearly review for him was meh)

Corla Plankun
May 8, 2007

improve the lives of everyone

TheresaJayne posted:

Some of our crucible reviews at work are nasty, one guy did some code and then had 12 people rip him a new one with more and more elegant and better solutiions for this piece of work - I was one of the reviewers and i had to rip one of the other reviewers a new one, as he said that they should have done a switch(string) block,

Which is impossible as we do not use java 1.7 but java 1.5 where switching was only on enums and ints.

(he should have known better though he was the Tech lead for that part of the system (hmmm thats why my yearly review for him was meh)

What combination of buzzwords describes your business's methodology because I dont ever want to work anywhere that shares any adjectives with the hellhole you just described.

fritz
Jul 26, 2003


No it's

FamDav
Mar 29, 2008

TheresaJayne posted:

Some of our crucible reviews at work are nasty, one guy did some code and then had 12 people rip him a new one with more and more elegant and better solutiions for this piece of work - I was one of the reviewers and i had to rip one of the other reviewers a new one, as he said that they should have done a switch(string) block,

Which is impossible as we do not use java 1.7 but java 1.5 where switching was only on enums and ints.

(he should have known better though he was the Tech lead for that part of the system (hmmm thats why my yearly review for him was meh)

couldnt figure out an elegant way to get onto a supported version of java, though.

Stringent
Dec 22, 2004


image text goes here

TheresaJayne posted:

Some of our crucible reviews at work are nasty, one guy did some code and then had 12 people rip him a new one with more and more elegant and better solutiions for this piece of work - I was one of the reviewers and i had to rip one of the other reviewers a new one, as he said that they should have done a switch(string) block,

Which is impossible as we do not use java 1.7 but java 1.5 where switching was only on enums and ints.

(he should have known better though he was the Tech lead for that part of the system (hmmm thats why my yearly review for him was meh)

This is some Spergelord of the Flies poo poo right here.

TheresaJayne
Jul 1, 2011

Corla Plankun posted:

What combination of buzzwords describes your business's methodology because I dont ever want to work anywhere that shares any adjectives with the hellhole you just described.

What buzzwords? We use a software package called Crucible for our reviews. https://www.atlassian.com/software/crucible/overview
Our project is split into components and each component has a component tech lead
Every year we have Staff Reviews usually done by our Tech lead and personnel manager
Any large company would have them - although we have to be super careful on releases as one erorr and we lose Billions....

- Our last success http://www.bbc.co.uk/news/science-environment-34217255

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Blotto Skorzany posted:

Many programs (including some mail programs) will bold stuff surrounded by asterisks, underline stuff surrounded by underscores, etc. Markdown didn't come up with that poo poo from thin air. Hell, even terminal irc clients do it.

Markdown and others have that syntax because it's been in use in ASCII communication as emphasis for probably 30 years, long before anything that was displaying it used bold or italic in rendering it.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

TheresaJayne posted:

one erorr and we lose Billions....

Nothing can possiblie go wrong. :v:

Rattus
Sep 11, 2005

A rat, in a hat!

*rings "bell"*

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I personally use ~*~ this convention ~*~ for emphasis.

xzzy
Mar 5, 2009

Pretty sure asteriks for emphasis is an habit from the early days of internet chat, like 80's or earlier. I really only see old school coders doing it.

Linear Zoetrope
Nov 28, 2011

A hero must cook

xzzy posted:

Pretty sure asteriks for emphasis is an habit from the early days of internet chat, like 80's or earlier. I really only see old school coders doing it.

It was pretty common in late '90s AIM chat too. As mentioned, it's still a feature in a large number of websites. It's not just markdown or other coder-y nonsense, Google Talk and Facebook chat both use it as well last I checked. I've mostly switched to using bold tags where applicable, but I still find myself reflexively putting stars around things and I'm very sure it has nothing to do with me being a programmer.

E: Hell, I just went onto Facebook and my 25 year old friend who is a college dropout that majored in Early Childhood Eduction and has never touched a programming language did it.

pseudorandom name
May 6, 2007

Suspicious Dish posted:

I personally use ~*~ this convention ~*~ for emphasis.

Isn't that a sarcasm delimiter?

Ekster
Jul 18, 2013

Planescape: Torment *loves* asterisks.

ExcessBLarg!
Sep 1, 2001
This part is interesting:

Linus posted:

we had similar issues with the completely moronic and misdesigned crap called "strlcpy()", which was introduced for similar reasons, and also caused nasty bugs where the old code was actually correct, and the "converted to better and safer interfaces" code was actually buggy.
So Drepper was right?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Rattus posted:

*rings "bell"*

*"rings" "bell"*

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

ExcessBLarg! posted:

So Drepper was right?

yes. strlcpy is a bad idea.

Soricidus
Oct 21, 2010
freedom-hating statist shill
even if strlcpy wasn't a bad idea, trying to fix c strings by adding a better copy function is like trying to fix my posting by adding better jokes

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Soricidus posted:

even if strlcpy wasn't a bad idea, trying to fix c strings by adding a better copy function is like trying to fix my posting by adding better jokes

worth a try?

Xarn
Jun 26, 2015

Suspicious Dish posted:

yes. strlcpy is a bad idea.

Why? Or at least, what makes it worse than strncpy?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Two major issues. First, silent truncation is dangerous unless taken with care. Second, strlcpy requires a C string as input (so you can detect truncation), and strncpy doesn't. This means that:

C++ code:
static char buf[20];
strncpy(buf, my_str, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
and

C++ code:
static char buf[20];
strlcpy(buf, my_str, sizeof(buf));
are not equivalent in the case where my_str is a fixed-length buffer instead of a C string.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Well yes, strncpy is designed for fixed-length buffers and strlcpy is designed for c strings. The fact that they operate on different data types isn't a problem with either one.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply