| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10
Comments:
<0> and jobs <1> the gift certificate will only be good on ebay. <0> well we are only 2nd level ninjas so we can't read minds yet <1> okay... <2> MarkT-: Aww =/ <1> aed: what? <2> MarkT-: You can just give me the gift certificate... <1> aedi: heh... sorry, it's non transferrable. Otherwise I would sell it. <1> and then just use the money. <1> and we probably wouldn't be getting a large screen tv then either... there are more important things that we could use the money for. <0> like cocaine and hookers <0> :/ <2> g 10 <2> TextMate is so cool <2> I wish I had money. <3> Jack on....*clap clap* jack off *clap clap*
<4> wow. that was a close one. we almost had a flag burning ammendment. <2> Yep <2> I don't see any reason why someone would want to burn a flag, but I don't think it's anyone's right to stop them from burning it <2> And unless they're affecting someone else by burning it, let them do it. <2> At worst I'd probably ask them to do it a little further from me, but for safety and health reasons. =] <5> whats goin on? <2> I'm looking for a fun project. <5> hmm <5> I always thought burning the flag was already illegal <6> aedinius: I challenge you to understand http://glide.stanford.edu/lxr/source/include/linux/moduleparam.h?v=linux-2.6.10 without getting a headache <6> preprocessor abuse of the worst kind I have seen yet <4> hi aedi. <4> aedinius, write an Apple 1 application. <4> CompHobby, it seems quite clear to me <4> i do much eviler things in the preprocessor than that on a regular basis. <6> OrageTide: the stuff that module_param() is based on confused the hell out of me, mostly from everything having the same param names and similar function names and me not having a notepad handy <7> I have written far worse abuse of the preprocessor <7> Same chunk of code that gets compiled in 16 different ways accordingly to 4 #define <4> CompHobby, well the nice thing about lxr sites is you can quickly look up where things are defined. <8> Why would you want to be a channel op? <9> jeffloc, gotta keep all those noobs in line. <2> Because @ is ***ier than + <10> hello there! <2> Lies. <2> I'm going to bed. <10> hehehe <2> Look what you did? You made me go to bed. <10> good night :) i'm going to bed soon too <10> hehe, sorry aedinius <2> Hehe. Night. =] <11> if I have char array[8]; char filename[] = "c:\12345678.txt"; memset(array, '\0', sizeof(array)); strncpy(array, filename, 8); I end up with "12345678(GARBAGE)" in array instead of "12345678(NULL)" what am I doing wrong? <12> naturally. <12> don't use strncpy. <11> I thought strncpy was recommended over strcpy because it does bounds checking? <12> not really. <4> yea. strncpy is really only for filling out struct members for doing binary i/o <12> a thinking programmer is much better. <4> memcpy(array, filename, 8); filename[8]=0; is what you want. <12> truncation often has security issues as well, so even a "safe" replacement for strcpy would still have problems. <4> also a char array[8] holding "12345678" isn't holding a string. because it wouldn't be null terminated. <11> so basically use memcpy, and then explicitly terminate the final character of the dst buffer <12> *shrug* <4> ncaller, yes. memcpy works well if you already know the length <11> if you know the length you want to copy, or the available room in the dst buffer? <12> how about not doing it at all? <4> char array[8] = "1234567"; or char array[9] = "12345678"; <12> if (sizeof array <= strlen(filename)) { puts("sorry charlie"); abort(); } <4> i love calling abort() <11> twkm: and if it gets past that if statement, then what would you do? call memcpy? or call strcpy? <12> ncaller: sure. <12> strcpy. <12> if (sizeof array <= strlen(filename)) { puts("sorry charlie"); abort(); } strcpy(array, filename); /* silly, just use filename, but anyway */ <8> :) <11> okay so what is the purpose of strncpy then if it doesn't fix this situation <12> but, step back even further. how is it you manage to have so short a buffer for an unbounded input? there should be more dynamics, or input validation, or something, so you don't even approach copying filename to array. <12> strncpy was handy for filling in fields of a database when bytes were considered precious enough that extra programming effort to save them was worthwhile. <12> (often a false trade-off, but history is immutable) <11> well I read in a directory entry into filename with entry = readdir() and then filename is really entry->d_name <12> e.g., strncpy(array, filename, sizeof array); ... printf("array: %.*s\n", sizeof array, array); <13> ncaller if you read the manpage it will state that if strncpy(dst, src, len), the num of characters is more than or equal to len, the dst will not be null-terminated. <8> too bad functions such as strncpy don't return how many chars they copied instead of a pointer you already have
<13> num of characters in src sry <11> but I want to add the file to my table by hashing the first 8 characters of the filename <12> jeffloc: yes, but even that was "useful" strcat(strcat(strcpy(buffer,first),second),third). <12> not that one couldn't write the buffer+=returnvalue version just as cryptically. <12> ncaller: then perhaps you don't want a string anyway. <8> didn't say strcpy, said strncpy <12> ncaller: if the filename doesn't have 8 characters what should the "trailing" characters be? null? space? something else? <12> jeffloc: the same holds true for strn* as for str*. <8> a count value would certainly make more sense there <11> nothing if the filename doesn't have 8.3 format it should be skipped <12> ncaller: then you made a non-string and worked with it as if it were a string. <11> entry->d_name is not a string? <12> ncaller: why? if you want a string that can be 8 characters you *know* (don't you?) that you must have a buffer of at least 9 bytes. <11> but if I declare array[8] is that not 9 bytes (012345678) <12> no! <12> ****. <12> ****! <12> where did you learn c?!?!? <11> here <12> then youa re a moron. <12> get a book. <8> :) <4> ncaller, how can 8 be 9? <12> char buf[8]; /* EXACTLY 8 BYTES, only [0] thru [7] are valid */ <12> in the early days d_name was not a string, and was one of the prime targets of strncpy, and the additional .* effort in printf was needed, along with other efforts to manage it as a non-string. <4> c is funny like that char foo[8]; the largest value you can index it by is 7. and if you put a string it in the index of the last character is 6. ehhe <8> only because it starts counting from 0 <8> still ****s up some people though <11> like me apparently <11> but I see that I am wrong now <8> you really would be far better off with an ansi C manual <4> calc k&r2 <14> Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, Second Edition, Prentice Hall, 1988, ISBN 0-13-110362-8, 0-13-110370-9. [K&R2] <4> if you read that, do the exercises at the end of each chapter you'll actually be hirable. <8> there are some you can download or look at as web pages. don't know if they are much good <11> fair enough I'll look it up on half <15> ya, K&R2 is a good book. <4> i picked up a beat up used copy of it for $12 for my girlfriend. <11> and does she code C now? <4> not really. she edits c code a bit for her mud. that's about it. <4> she likes to write stories and design games more than actually coding them. ehhe <11> So I am scanning a directory tree for filenames and hashing those names and placing the full names and paths into a hash table. Would it be appropriate to make that hash table a global pointer? Or should I p*** it in and out of all my functions <12> your program design, your decision. <11> does it hurt performance at all to go one way or the other, from what I can see it only affects how difficult it is to get working properly <12> globals affect how hard it is to decide it should have been a module. <12> also it has implications on recursion and reentrancy. <11> well one of my functions that goes down through directories is recursive <12> which directly impacts the ability to make it threaded. <11> so I think you are saying that if I want this to eventually scale or be threaded it needs to not use globals rather p*** pointers around <12> it impacts the subsequent choices you can make. <11> in a negative way <12> it might make them easier. <11> like we don't need to make that choice because it is now impossible without going back and redesigning the whole thing <12> yes, that is sometimes the case. <11> okay <11> why do so many people in here like to call abort() instead of exit() to exit a program on an error condition. I read the manpages and exit says it does cleanup of resouces where abort does not <12> i always use abort in my examples so that the person will think about what should happen. <12> if they just use what i provide they get a nice, dead corpse, which they can discect later. if they replace it with exit(something) then they don't get one, and can hope they used distinctive something's to help them determine just what is wrong. <12> err, dissect. <11> but won't the OS clean up everything after abort is called anywasy? <12> buffers won't be flushed, sysv ipc will remain, etc. <11> would you use abort() in production code that was going to be in use somewhere by non-programmers who were not going to be analyzing a program crash ? <12> depends on the code. <12> non-programmers can forward the corpse to me for analysis. <12> sometimes dieing is completely inappropriate, you must find a safe return state and continue -- the design of such programs is harder. <11> does it have any impact on when they try to rerun the program like it can't run because some pipe is open or some file is locked open or anything <12> but, such a program might still produce a corpse, even as it continues. <12> ncaller: yes, as i said, sysv ipc won't be changed (for most cases) so a semaphore might remain locked, which naive code might stall upon. <11> do the OS copy routines such as /bin/cp or copy.exe do any kind of checksum to ensure what they copied happened okay? Or do they just check the bytes read/written from each call to read()/write() while it goes <12> depends on the o/s. <12> many depend on the devices involved to detect any problems. <11> well I face the decision once again to sleep for like 2 hours or just stay up, tonight I think I will go for 2. later all <8> bugger sleeping. you should learn to do without it <16> hi there, anyone able to point me in the right direction as to an open source library for programming bluetooth apps on an hp ipaq using broadcom stack.. ?
Return to
#c or Go to some related
logs:
#dsl #beginner #stocks #politics #unixhelp quotesdb cafebleu Dell Latitude D800 Power Button broken #solaris wasps-holes in mud
how to set tcl script on racbot
|
|