Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Aptana radrails

Name: Anonymous 2008-02-08 23:36

I myself mostly an editor guy, have found Aptana studio and its plugin radrails to be fuckomg awsome, now just one question, at hand, mongrel skeleton, is there a better one?

Name: Anonymous 2008-02-09 2:08

END TO END YO

Name: Anonymous 2008-02-09 4:23

lol rails

Name: Anonymous 2008-02-09 10:18

HAY GUYS WHAT DO YOU THINK OF MY DOESCONTAIN FUNCTION?

(i cant create new threads so I am hijacking this one)


int doescontain(char *s, int (*is)(int)) {
  while(*s++)
    if(is(*s))
      return 1;
  return 0;
}

#include <ctype.h>
#include <stdio.h>

int main(int argc, char **argv) {

  printf("%d\n",argc);
  if(!argv[1]) {
    return 1;
  }

  if(doescontain(argv[1],isalpha))
    printf("contains alpha\n");
  if(doescontain(argv[1],isdigit))
    printf("contains digit\n");
  if(doescontain(argv[1],isupper))
    printf("contains upper\n");
  if(doescontain(argv[1],islower))
    printf("contains lower\n");

  return 0;
}

Name: Anonymous 2008-02-09 10:22

>>4
what

Name: Anonymous 2008-02-09 10:22

>>4
doescontain("1", isdigit); will not work.
Also, did you just learn about function pointers or what?
Also, it's buggy.
There are two bugs there and one is major.

Name: Anonymous 2008-02-09 10:23

>>6
2 bugs EXCEPT about doescontain("1", isdigit); not working i ment.

Name: Anonymous 2008-02-09 10:25

>>7
bugs or stfu

Name: Anonymous 2008-02-09 10:28

OH HAY I FOUND ONE. THAT *s++ IS A BIT STUPID. I WAS TRYING TO BE TOO CLEVAR! AHAHAHAH

Name: Anonymous 2008-02-09 10:36

fuck aptana

Name: Anonymous 2008-02-09 10:36

USE EMACS

Name: Anonymous 2008-02-09 10:38

>>8
Bug 1: while(*s++) is stupid. think.
Bug 2: what is passed to is/to[alpha|other] must be casted to (unsigned char). If you want your doescontain to work with any int(*)(int) then it is not possible to cast it inside the function. change the prototype to something more explicit
Bug 3: argc may be 0, which would mean there is no argv[1]. Your program would crash in the if check. use argc instead.

Name: Anonymous 2008-02-09 10:43

1. noted.
2. i use the same types that the is* functions are defined with.
3. argv[argc] is guaranteed to be NULL)

Name: Anonymous 2008-02-09 10:44

>>13
3. argv[argc] is guaranteed to be NULL)
Correct, read what I said.
Bug 3: argc may be 0, which would mean there is no argv[1]. Your program would crash in the if check. use argc instead.
*argv is NULL and you dereference argv+1.
faggot.

Name: Anonymous 2008-02-09 10:45

when is argc ever 0?

Name: Anonymous 2008-02-09 10:59

>>15

execl("./foo", NULL);

You still have a lot to learn, you also did not understand bug 2.

Name: Anonymous 2009-03-06 10:20


The purest Lisp j.

Name: Anonymous 2010-11-26 15:18

Name: Anonymous 2011-02-02 23:54

Don't change these.
Name: Email:
Entire Thread Thread List