General discussion

Here you can discuss everything related to MOC which doesn't fit other subforum.

menu_items_swap bug [PATCH]

I was attempting to implement a queue feature this afternoon when I came across a bug in menu.c. The interface menu is represented by a doubly-linked list, and swapping two items is pretty tricky. In current usage, the two items are almost always adjacent, and the swap works fine in this case. In case the two items are not adjacent, though, the current code swaps the prev and next pointers in such a way that some data gets clobbered.

In fixing this bug, I introduced a generic swap function in common.h (see below), and I cleaned up the menu_items_swap function a little (to use the new swap function where appropriate).

I've tested the function as thoroughly as I can, and I've tried to stick to the style of the files I changed. Hope this makes it easy for you to apply the patch.

Index: menu.c
===================================================================
--- menu.c	(revision 1986)
+++ menu.c	(working copy)
@@ -776,8 +776,6 @@
 static void menu_items_swap (struct menu *menu, struct menu_item *mi1,
 		struct menu_item *mi2)
 {
-	int t;
-	
 	assert (menu != NULL);
 	assert (mi1 != NULL);
 	assert (mi2 != NULL);
@@ -785,43 +783,28 @@
 
 	/* if they are next to each other, change the pointers so that mi2
 	 * is the second one */
-	if (mi2->next == mi1) {
-		struct menu_item *i = mi1;
+	if (mi2->next == mi1)
+		swap(&mi1, &mi2, sizeof(mi1));
 
-		mi1 = mi2;
-		mi2 = i;
-	}
+	// safe even if mi1->next == mi2
+	if (mi2->next) mi2->next->prev = mi1;
+	if (mi1->prev) mi1->prev->next = mi2;
 
 	if (mi1->next == mi2) {
-		if (mi2->next)
-			mi2->next->prev = mi1;
-		if (mi1->prev)
-			mi1->prev->next = mi2;
-		
 		mi1->next = mi2->next;
 		mi2->prev = mi1->prev;
 		mi1->prev = mi2;
 		mi2->next = mi1;
+	} else {
+		// not safe if mi1->next == mi2
+		if (mi2->prev) mi2->prev->next = mi1;
+		if (mi1->next) mi1->next->prev = mi2;
+
+		swap(&mi1->prev, &mi2->prev, sizeof(mi1->prev));
+		swap(&mi1->next, &mi2->next, sizeof(mi1->next));
 	}
-	else {
-		if (mi2->next)
-			mi2->next->prev = mi1;
-		if (mi2->prev)
-			mi2->prev->next = mi1;
-		mi2->next = mi1->next;
-		mi2->prev = mi1->prev;
-		
-		if (mi1->next)
-			mi1->next->prev = mi2;
-		if (mi1->prev)
-			mi1->prev->next = mi2;
-		mi1->next = mi2->next;
-		mi1->prev = mi2->prev;
-	}
 
-	t = mi1->num;
-	mi1->num = mi2->num;
-	mi2->num = t;
+	swap(&mi1->num, &mi2->num, sizeof(mi1->num));
 
 	if (menu->top == mi1)
 		menu->top = mi2;
Index: common.c
===================================================================
--- common.c	(revision 1986)
+++ common.c	(working copy)
@@ -124,4 +124,16 @@
 	return fname;
 }
 
+static void swap_bytes(char *b1, char *b2) {
+	if (*b1 != *b2) {
+		*b1 ^= *b2;
+		*b2 ^= *b1;
+		*b1 ^= *b2;
+	}
+}
 
+void swap(void *a, void *b, size_t n) {
+	int i = 0;
+	for ( ; i < n; ++i)
+		swap_bytes((char*)a + i, (char*)b + i);
+}
Index: common.h
===================================================================
--- common.h	(revision 1986)
+++ common.h	(working copy)
@@ -55,4 +55,6 @@
 void set_me_server ();
 char *create_file_name (const char *file);
 
+void swap(void *a, void *b, size_t n);
+
 #endif

UTF-8 problem

The UTF8 filename displays perfectly with correct column alignment. I have a problem displaying multi-byte UTF8 strings from ID3v2 tags. I have a mp3 file with ID3 tag containing 0x ff-fe 73-96 55-59 c5-8f, but MOC displays it as 0x b7 b7 b7 instead of 0x e9-99-b3 e5-a5-95 e8-bf-85. I would appreciate any insight for getting this to work. I'm using MOC 2.4.1 in an en_US.UTF-8 locale.

It's compiled with
configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --prefix=/var/tmp/moc-2.4.1-1-root --disable-debug

$ ldd `which mocp`
linux-gate.so.1 => (0x005ea000)
libasound.so.2 => /lib/libasound.so.2 (0x05221000)
libpthread.so.0 => /lib/libpthread.so.0 (0x0085c000)
libsamplerate.so.0 => /usr/lib/libsamplerate.so.0 (0x00810000)
libcurl.so.3 => /usr/lib/libcurl.so.3 (0x00558000)
libdl.so.2 => /lib/libdl.so.2 (0x0075b000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00219000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x0016b000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00d06000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00df7000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x00c17000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00cdb000)
libidn.so.11 => /usr/lib/libidn.so.11 (0x00a92000)
libssl.so.5 => /lib/libssl.so.5 (0x001df000)
libcrypto.so.5 => /lib/libcrypto.so.5 (0x003fa000)
libz.so.1 => /usr/lib/libz.so.1 (0x00761000)
libncursesw.so.5 => /usr/lib/libncursesw.so.5 (0x00776000)
libm.so.6 => /lib/libm.so.6 (0x00734000)
libc.so.6 => /lib/libc.so.6 (0x00609000)
/lib/ld-linux.so.2 (0x005eb000)

Last.fm

Hey there!
I just founded a last.fm group. If you like last.fm and moc feel free to join. Unfortunately moc doesn't support scrobbling.

ExecCommand5 = "mocp -a %f"

i try to set F5 as add to list by this
ExecCommand5 = "mocp -a %f"
and its just freezing
when its freezed 'mocp -a smth' command freezing too
^c in first freez and 2nd flushes
seems trying to update busy client

can not find wma

my mocplayer can not find my wma files, the folder is empty, but i know it contains wma files???

A Survey on Defect Management Practices in Free/Open Source Software

Dear MOC Contributors,

I seek help from designers, developers, testers,defect fixers,project managers or playing any other key role in Free/Open Source software development or maintenence
in carrying out a study on practices and problems of defect management in various Free/Open Source Software projects. The
insights gained from the study can further help us to extract publicly
accessible defect data and determine impact of defect management practices
on software quality.
Please spend a few minutes of your precious time to fill up the
Questionnaire. The most of the questions follow multiple choice formats and
are quite easy to answer.

To have the Online Questionnaire, please visit:

http://anu.puchd.ac.in/phpESP/public/survey.php?name=FOSS_Defect_Survey

(You can also copy and paste this link into your browser, and hit the
'Return' key.)

I hope you will find all the questions interesting and thought-provoking. Your answers will be kept anonymous.The data thus collected will
only be used for research purpose.It would be nice if you may further refer this mail to others actively engaged with Free/Open Source Software development. If you have any query or suggestions then
feel free to contact.

Thank You

With regards,

Anu Gupta
Senior Lecturer
Department of Computer Science and Applications,
Panjab University, Chandigarh.
INDIA

In case of any problem in accessing/using the above mentioned link please contact:
E-mail: anugupta@pu.ac.in
anugupta98@gmail.com

OnSongChange wont work

I've installed 2.5.0alpha from Elimar's repository

in config I've got:
OnSongChange = "/home/pawian/.skrypty/moc_now_play %r - %t [%a]"

to show new song via OSD, unfortunately nothing happens when on songs change

script works (tested manually)

MOC for the little ones...

I hope this is not considered as spamming the forum as this is not my intention.

MOC is a very undemanding player in terms of CPU power and so when I was given the task of installing Linux on a portable PC I just had to put MOC on it. The reason for this post is that I have made some screenshots of it playing back audio. The geek in me wants to share this with anybody interested. For me, MOC and portable PCs beat any iPOD ;-)

If you are into this, come to http://www.tzi.de/~hiben/mocoqo/oqo.html

Pages

Subscribe to RSS - General discussion