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

Pages: 1-

String manipulation library

Name: Anonymous 2012-01-29 21:30

Hello, /prog/.

I have written a small library for manipulating strings in C. It is very small (~300 LOC), and it's used are limited so far, but it has found great application in many of my programs for things such as reading numbers from strings and generating output filenames. I hope you find it useful.

http://code.google.com/p/str-man/

Feel free to contribute code, I'd love to see this a more complete and useful library. Although, you will have to ask to have your permissions raised so you can, which I'd rather not have to, but whatever.

Name: Anonymous 2012-01-29 21:37

Are you trolling or just retarded?

Name: Anonymous 2012-01-29 21:47

>using null-terminated strings
PIG DISGUSTING!

Name: Anonymous 2012-01-29 21:48

>>2
PROGRAMMING?! ON MY /PROG/?!

Name: Anonymous 2012-01-29 21:50

>>3
>not using null-terminated strings
Well, that's o-Segmentation Fault

Name: Anonymous 2012-01-29 22:06

Not to be a dick, but the code is piss-poor quality and has many serious problems (memory leaks everywhere, not using standard library functions for copying, runtime complexity class of some functions is higher than it should be).

Name: Anonymous 2012-01-29 22:16

>>6
Then stop complaining and contribute some `high quality' code.

Name: Anonymous 2012-01-29 22:21

>>7
It's not worth it. If this is the kind of functions and programming style you'd like to use, I'd recommend looking into another language. One with automatic memory management, preferably.

Name: Anonymous 2012-01-29 22:23

Python has really good string manipulation capabilities.

Name: sage 2012-01-29 22:30

>>8
All of the prsent kinks can be sorted out.

Name: Anonymous 2012-01-29 22:31

>>8
Thanks for pointing out the leaks, I'm horified at the things I missed.

Name: Anonymous 2012-01-30 0:03

░░░░░░░░░░░░░░░▄░░░░░░░░░░░░░░░
░░░░░░░░░░░░░▄▀█░░░░░░░░░░░░░░░
░░░░░░░░░░░▄▀░░█░░░░░░░░░░░░░░░
░░░░░░░░░▄▀░░▄▀░░░░░░░░░░░░░░░░
░░░░░░░░█▄░▄▀░░░░░░░░▄█▄░░░░░░░
░░░░░░░░█░▀▄░░░░░░░▄▀░█░▀▄░░░░░
░░░░░░░░▀▄░░▀▄░░░▄▀░░▄▀▄░░▀▄░░░
░▄░░░░░░░░▀▄░░▀▄▀░░▄▀░░░▀▄░░▀▄░
░█▀▄░░░░░░░░▀▄▀█▀▄▀░░░░░░░▀▄░█░
░█░░▀▄░░░░░▄▀░░█░░▀▄░░░░░░░░▀█░
░░▀▄░░▀▄░▄▀░░▄▀░▀▄░░▀▄░░░░░░░░░
░░░░▀▄░░█░░▄▀░░░░░▀▄░▄█░░░░░░░░
░░░░░░▀▄█▄▀░░░░░░░░▄▀░█░░░░░░░░
░░░░░░░░▀░░░░░░░░▄▀░░▄▀░░░░░░░░
░░░░░░░░░░░░░░░▄▀░░▄▀░░░░░░░░░░
░░░░░░░░░░░░░░░█░▄▀░░░░░░░░░░░░
░░░░░░░░░░░░░░░█▀░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░█▄░█░█░▄▀▀▄░░█░░█░█▀▀░▀█▀░█░░░
░█░█▄░█░█░▄▄░░█▄▄█░█▄▄░░█░░█░░░
░█░░█░█░▀▄▄▀░░█░░█░█▄▄░▄█▄░█▄▄░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

Name: Anonymous 2012-01-31 2:11

This little module is about 30 years behind the times. Why are C programmers repeatedly reinventing these shitty little things, year after year?

It is because in the C culture, programmers who grow out of this are ashamed of this crap and do not pass it down to their successors, so no cross-generation learning takes place and the same crud is reinvented.

Say, I need a collection of things. Hey, I know:

  struct list { struct list *next, *prev; void *item; }

Name: Anonymous 2012-01-31 2:12

Holy crap, is this guy for real???

 /*
  * Creates a copy of the original
  * string without destroying data
  */
 char *str_dup(char *str)
 {
        char *result;
        int len;
       
        if (!str){
                result = malloc(1);
                *result = 0;
                return result;
        }
        len = strlen(str);
        result = malloc(len);
        memcpy(result, str, len);
        return result;
}

And y'all have been down on the guy for using null terminated strings? No, he isn't: look again. :)

Name: Anonymous 2012-01-31 2:32

>>14
Not using it in that case is just bad: you can use strlen on the original string, but not on the new string.

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