An bug in all the DC++ version! (not an big bug)

Archived discussion about features (predating the use of Bugzilla as a bug and feature tracker)

Moderator: Moderators

Locked
Sh
Posts: 7
Joined: 2003-12-16 08:13

An bug in all the DC++ version! (not an big bug)

Post by Sh » 2004-07-14 13:20

Image
As you see when i click on "Status" te files should be order by "Running" "User online" ... but you see 30 is bigger than 9. why are 9 downer? thats because dc++ is seeing 30 as 3 and 9 as 9... Plis fix it to the next version of dc++


If the DC++ coding crew have problems to find out how, just take an 0 before 9



Sorry my bad english :roll:

TheParanoidOne
Forum Moderator
Posts: 1420
Joined: 2003-04-22 14:37

Post by TheParanoidOne » 2004-07-14 14:03

It's not a bug, and if it were, it's not specific to DC++. That line is text and it is sorted alpabetically. Hence "30" comes before "9". Your workaround to "help" is a hack, at best. What happens if a number more than 99 is needed? Do you just keep on adding zeroes?

As far as I know there is no simple (and efficient) way to do mix and match sorting. I wouldn't hold my breath if I were you.
The world is coming to an end. Please log off.

DC++ Guide | Words

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-07-14 15:12

When XP changed the sorting behavior, it was an enhancement. They call it "Natural Sort Order" or something similar.

[quote="ESR"]Don't claim that you have found a bug

When you are having problems with a piece of software, don't claim you have found a bug unless you are very, very sure of your ground. Hint: unless you can provide a source-code patch that fixes the problem, or a regression test against a previous version that demonstrates incorrect behavior, you are probably not sure enough.

Remember, there are a lot of other users that are not experiencing your problem. Otherwise you would have learned about it while reading the documentation and searching the Web (you did do that before complaining, didn't you?). This means that very probably it is you who are doing something wrong, not the software.

The people who wrote the software work very hard to make it work as well as possible. If you claim you have found a bug, you'll be implying that they did something wrong, and you will almost always offend them â€â€

Twink
Posts: 436
Joined: 2003-03-31 23:31
Location: New Zealand

Post by Twink » 2004-07-20 01:39

here's something i quickly wipped up as a replacement to stricmp. still needs some testing though

Code: Select all

	static bool isNumeric(char c) {
		return (c >= '0' && c <= '9') ? true : false;
	}

static int natstricmp(const char *a, const char* b) {
		int v1, v2;		

		while(*a != 0 && *b != 0) {
			v1 = 0; v2 = 0;
			bool t1 = isNumeric(*a);
			bool t2 = isNumeric(*b);
			if(t1 != t2) return (t1) ? -1 : 1;

			if(!t1) { //string
				if(cmpi[(u_int8_t)*a][(u_int8_t)*b] != 0)
					return cmpi[(u_int8_t)*a][(u_int8_t)*b];
				a++; b++;
			} else { // number
				while(isNumeric(*a)) {
					v1 *= 10;
					v1 += *a - '0';
					a++;
				}

				while(isNumeric(*b)) {
					v2 *= 10;
					v2 += *b - '0';
					b++;
				} 

				if(v1 != v2)
					return (v1 < v2) ? -1 : 1;
			}			
		}

		return cmpi[(u_int8_t)*a][(u_int8_t)*b];
	}


GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-07-20 07:37

It would be easier to modify QueueFrame::compareItems() to sort by online or size().

He's only asking for natural sort order in the queue.

Twink
Posts: 436
Joined: 2003-03-31 23:31
Location: New Zealand

Post by Twink » 2004-07-20 20:14

yes but it would make sense to add it to other things too, I can see it being quite good for filelists.

PseudonympH
Forum Moderator
Posts: 366
Joined: 2004-03-06 02:46

Post by PseudonympH » 2004-07-20 21:52

True, but 90+% of the time the file names are already 0-padded....

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-07-22 18:36

Twink wrote:yes but it would make sense to add it to other things too, I can see it being quite good for filelists.
It is a performance hit, though, so if other means are available, it'd make sense to use them.

If you've tested your code and think it's a good idea, package it up and send it to arnetheduck - I only make and send in patches for code I know people want contributed. :)

Locked