Click here to Skip to main content
15,890,690 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Comment Pin
Monjurul Habib3-Mar-11 20:09
professionalMonjurul Habib3-Mar-11 20:09 
GeneralRe: Comment Pin
AspDotNetDev3-Mar-11 20:44
protectorAspDotNetDev3-Mar-11 20:44 
GeneralRe: Comment Pin
Monjurul Habib4-Mar-11 10:12
professionalMonjurul Habib4-Mar-11 10:12 
GeneralRe: Comment Pin
Lutosław27-Mar-11 11:15
Lutosław27-Mar-11 11:15 
GeneralRe: Comment Pin
RobCroll3-Mar-11 19:26
RobCroll3-Mar-11 19:26 
GeneralRe: Comment Pin
Monjurul Habib3-Mar-11 20:11
professionalMonjurul Habib3-Mar-11 20:11 
GeneralRe: Comment Pin
Joan M8-Mar-11 0:47
professionalJoan M8-Mar-11 0:47 
Generalwarning C4706: assignment within conditional expression Pin
Samuel Cragg3-Mar-11 8:29
Samuel Cragg3-Mar-11 8:29 
I downloaded some code of the internet which is used as part of Firefox, OpenOffice etc, compiled it and it produced a few warnings. I'm not a fan of warnings so thought I'd have a look to fix it...

C
if (((rv) && 
	( checked_prefix || (words && words[wnum]) ||
	(compoundflag && TESTAFF(rv->astr, compoundflag, rv->alen)) ||
	((oldwordnum == 0) && compoundbegin && TESTAFF(rv->astr, compoundbegin, rv->alen)) ||
	((oldwordnum > 0) && compoundmiddle && TESTAFF(rv->astr, compoundmiddle, rv->alen))// ||
	//            (numdefcpd && )

	// LANG_hu section: spec. Hungarian rule
	|| ((langnum == LANG_hu) && hu_mov_rule && (
	TESTAFF(rv->astr, 'F', rv->alen) || // XXX hardwired Hungarian dictionary codes
	TESTAFF(rv->astr, 'G', rv->alen) ||
	TESTAFF(rv->astr, 'H', rv->alen)
	)
	)
	// END of LANG_hu section
	) &&
	(
	// test CHECKCOMPOUNDPATTERN conditions
	scpd == 0 || checkcpdtable[scpd-1].cond == FLAG_NULL || 
	TESTAFF(rv->astr, checkcpdtable[scpd-1].cond, rv->alen)
	)
	&& ! (( checkcompoundtriple && scpd == 0 && !words && // test triple letters
	(word[i-1]==word[i]) && (
	((i>1) && (word[i-1]==word[i-2])) ||
	((word[i-1]==word[i+1])) // may be word[i+1] == '\0'
	)
	) ||
	(
	checkcompoundcase && scpd == 0 && !words && cpdcase_check(word, i)
	))
	)
	// LANG_hu section: spec. Hungarian rule
	|| ((!rv) && (langnum == LANG_hu) && hu_mov_rule && (rv = affix_check(st,i)) &&
	(sfx && sfx->getCont() && ( // XXX hardwired Hungarian dic. codes
	TESTAFF(sfx->getCont(), (unsigned short) 'x', sfx->getContLen()) ||
	TESTAFF(sfx->getCont(), (unsigned short) '%', sfx->getContLen())
	)
	)
	)
	) {
		// 248 lines of code
	}


In fairness, it's the first time I've seen so many comments inside an if statement! Think I'll live with the warning (i.e. disable it for that particular file.)
GeneralRe: warning C4706: assignment within conditional expression Pin
Monjurul Habib3-Mar-11 10:01
professionalMonjurul Habib3-Mar-11 10:01 
GeneralRe: warning C4706: assignment within conditional expression Pin
makumazan844-Mar-11 2:38
makumazan844-Mar-11 2:38 
GeneralRe: warning C4706: assignment within conditional expression Pin
oggenok644-Mar-11 11:44
oggenok644-Mar-11 11:44 
GeneralRe: warning C4706: assignment within conditional expression Pin
Lutosław27-Mar-11 11:22
Lutosław27-Mar-11 11:22 
GeneralRe: warning C4706: assignment within conditional expression Pin
jsc4213-Apr-11 4:07
professionaljsc4213-Apr-11 4:07 
RantWorst practise - asking a question without searching... Pin
Ed Nutting2-Mar-11 2:09
Ed Nutting2-Mar-11 2:09 
GeneralRe: Worst practise - asking a question without searching... [modified] Pin
_Erik_2-Mar-11 3:17
_Erik_2-Mar-11 3:17 
GeneralRe: Worst practise - asking a question without searching... Pin
Ravi Sant2-Mar-11 5:14
Ravi Sant2-Mar-11 5:14 
GeneralRe: Worst practise - asking a question without searching... Pin
fjdiewornncalwe3-Mar-11 8:58
professionalfjdiewornncalwe3-Mar-11 8:58 
GeneralRe: Worst practise - asking a question without searching... Pin
Ed Nutting3-Mar-11 9:06
Ed Nutting3-Mar-11 9:06 
GeneralRe: Worst practise - asking a question without searching... Pin
BillW3314-Mar-11 6:55
professionalBillW3314-Mar-11 6:55 
GeneralRe: Worst practise - asking a question without searching... Pin
Ed Nutting14-Mar-11 7:24
Ed Nutting14-Mar-11 7:24 
GeneralRe: Worst practise - asking a question without searching... Pin
drummerboy051125-Mar-11 12:31
professionaldrummerboy051125-Mar-11 12:31 
GeneralRe: Worst practise - asking a question without searching... Pin
Lutosław27-Mar-11 11:27
Lutosław27-Mar-11 11:27 
GeneralUltimate Database Fail [updated] Pin
wizardzz1-Mar-11 5:05
wizardzz1-Mar-11 5:05 
GeneralRe: Ultimate Database Fail Pin
musefan1-Mar-11 6:22
musefan1-Mar-11 6:22 
GeneralRe: Ultimate Database Fail Pin
wizardzz1-Mar-11 6:25
wizardzz1-Mar-11 6:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.