1 diff -urN genext2fs-1.4rc1/genext2fs.c genext2fs-1.4rc1.new/genext2fs.c
2 --- genext2fs-1.4rc1/genext2fs.c 2005-05-17 18:29:10.000000000 +0200
3 +++ genext2fs-1.4rc1.new/genext2fs.c 2007-01-03 15:21:16.000000000 +0100
6 #endif // defined SNPRINTF_STORAGE_CLASS
8 -#if defined(__APPLE__) && defined(__GNUC__)
9 -// getline() replacement for Darwin, might work on other systems
10 -// written according to the getline man page included with Debian Linux
12 -getline(char **lineptr, size_t *n, FILE *stream)
14 - char *buf = *lineptr; // could be NULL, in which case we allocate
15 - size_t bufsize = *n; // current buffer size, adjust if we (re)alloc
18 - size_t tempsize = 0;
20 - // temp is not a C string and we don't own the buffer it points into
21 - // must copy into a malloced buffer and NULL terminate
22 - temp = fgetln(stream, &tempsize);
23 - if(!temp) return -1;
25 - tempsize++; // adjust for NULL terminator
27 - // check if we have to reallocate
28 - if(bufsize < tempsize) {
30 - buf = (char*)realloc(buf, tempsize);
35 - buf = (char*)malloc(bufsize);
39 - memcpy(buf, temp, tempsize-1);
40 - buf[tempsize-1] = '\0';
42 - // give new pointer and size back, nondestructive if we didn't change anything..
46 - return (ssize_t)(tempsize-1); // don't include the NULL terminator, per getline man page
50 // Convert a numerical string to a float, and multiply the result by an
51 // SI-style multiplier if provided; supported multipliers are Ki, Mi, Gi, k, M