[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] Declension of month names in dates
From:       Pal-Kristian Engstad <engstad () naughtydog ! com>
Date:       2002-08-16 2:24:59
[Download RAW message or body]

Not to be pedantic, but you can always "break" out of a loop. I.e., replace:

	    j = 1;
	    while (error && (j < 13)) {
	      QString s = monthNamePossessive(j, c == 'b').lower();
	      int len = s.length();
	      if (str.mid(strpos, len) == s) {
	        month = j;
	        strpos += len;
                error = false;
	      }
	      j++;
	    }

with:
	for (j = 1; j < 13; j++) {
		QString s = monthNamePossesive(j, c == 'b').lower();
		int len = s.length();
		if (str.mid(strpos, len) == s) {
			month = j;
			strpos += len;
			break;
		}
	}

This is much clearer. Now, if you need to use 'error' as a flag for an early 
out, there's nothing wrong by using a goto, or even better, restructure it to 
return. 

PKE.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic