liupfskygre / ea-utils

Automatically exported from code.google.com/p/ea-utils
0 stars 0 forks source link

fastq-mcf doesn't work on Lion #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Apparently it cannot work on OS X 10.7 (nor on 10.6) because of getopt function 
which always returns -1.

I suggest to apply this patch to use getopt_long:

$ diff -u fastq-mcf.c fastq-mcf.c.new 
--- fastq-mcf.c 2011-11-09 21:33:42.000000000 +0100
+++ fastq-mcf.c.new 2011-12-20 14:30:53.000000000 +0100
@@ -29,6 +29,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <getopt.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
@@ -87,7 +88,7 @@
 int debug=0;
 int warncount = 0;
 int main (int argc, char **argv) {
-   char c;
+   int c;
    bool eol;
    int nmin = 1, nkeep = 15, nmax=0;
    float minpct = 0.25;
@@ -116,7 +117,7 @@
    int e_n = 0;
    bool skipb = 0;

-   while ( (c = getopt (argc, argv, "-nf0uUVSRdbehp:o:l:s:m:t:k:x:P:q:L:C:w:")) 
!= -1) {
+   while ( (c = getopt_long (argc, argv, 
"-nf0uUVSRdbehp:o:l:s:m:t:k:x:P:q:L:C:w:", NULL, NULL)) != -1) {
        switch (c) {
        case '\1': 
            if (!afil) 

Original issue reported on code.google.com by daweonline on 20 Dec 2011 at 1:35

GoogleCodeExporter commented 8 years ago
This is probably true for all utilities

Original comment by daweonline on 20 Dec 2011 at 1:35

GoogleCodeExporter commented 8 years ago
I'd like to try to get regular getopt to work on a Mac first.   It's supposed 
to work.  I can't imagine it's broken entirely....

Original comment by earone...@gmail.com on 11 Jan 2012 at 5:45

GoogleCodeExporter commented 8 years ago
It is supposed to work but, since this probably depends on a os x bug, OS X 
users cannot simply use ea-utils if running on Lion.
Given that "The implementation can completely replace getopt(3), but right now 
we are using separate code." (from getopt_long(3)), given that the getopt_long 
version is not dramatically different from the original, I would suggest to use 
it as default (allowing for future long options).

Original comment by daweonline on 11 Jan 2012 at 10:40

GoogleCodeExporter commented 8 years ago
ok, i'll try it as the default

all the utils need a getline for OSX as well

Original comment by mooncost...@gmail.com on 13 Jan 2012 at 4:37

GoogleCodeExporter commented 8 years ago
Did you try adding the #include <getopt.h> only... i think that's all it needs.

Original comment by earone...@gmail.com on 13 Jan 2012 at 4:08

GoogleCodeExporter commented 8 years ago
I really need an OSX shell account. I made a bunch of changes to get things to 
work (including getline, ifdefs, etc) but I don't know if they do.

Original comment by earone...@gmail.com on 13 Jan 2012 at 4:18

GoogleCodeExporter commented 8 years ago
I'll try to add the include ASAP, although unistd.h should include getopt.

Original comment by daweonline on 13 Jan 2012 at 4:33

GoogleCodeExporter commented 8 years ago
Tried. Doesn't work. I'm suspecting some odd behavior of g++.

Original comment by daweonline on 17 Jan 2012 at 10:20

GoogleCodeExporter commented 8 years ago
New ver should have better os/x support as far as a built-in "getline".   I'm 
still a bit reluctant to make this change without knowing what's wrong .... It 
seems to me that hundreds of programs would break if getopt wasn't working in 
Lion.  maybe it was just the "int" ... that was nonstandard (but common).

Original comment by earone...@gmail.com on 17 Jan 2012 at 3:05

GoogleCodeExporter commented 8 years ago
I want to help in debug and I will do. The "int" thing, well, that is 
definitely not the problem (behavior is the same with int or char).

Original comment by daweonline on 17 Jan 2012 at 3:27

GoogleCodeExporter commented 8 years ago
I can confirm version 1.1.2-301 works

Original comment by daweonline on 17 Jan 2012 at 10:33

GoogleCodeExporter commented 8 years ago
marking as fixed as of 301 as per daweonline's test

Original comment by earone...@gmail.com on 23 Jan 2012 at 8:29