01-remove_getline.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  4. @@ -243,48 +243,6 @@
  5. }
  6. #endif // defined SNPRINTF_STORAGE_CLASS
  7. -#if defined(__APPLE__) && defined(__GNUC__)
  8. -// getline() replacement for Darwin, might work on other systems
  9. -// written according to the getline man page included with Debian Linux
  10. -ssize_t
  11. -getline(char **lineptr, size_t *n, FILE *stream)
  12. -{
  13. - char *buf = *lineptr; // could be NULL, in which case we allocate
  14. - size_t bufsize = *n; // current buffer size, adjust if we (re)alloc
  15. -
  16. - char *temp = NULL;
  17. - size_t tempsize = 0;
  18. -
  19. - // temp is not a C string and we don't own the buffer it points into
  20. - // must copy into a malloced buffer and NULL terminate
  21. - temp = fgetln(stream, &tempsize);
  22. - if(!temp) return -1;
  23. -
  24. - tempsize++; // adjust for NULL terminator
  25. - if(buf) {
  26. - // check if we have to reallocate
  27. - if(bufsize < tempsize) {
  28. - bufsize = tempsize;
  29. - buf = (char*)realloc(buf, tempsize);
  30. - if(!buf) return -1;
  31. - }
  32. - } else {
  33. - bufsize = tempsize;
  34. - buf = (char*)malloc(bufsize);
  35. - if(!buf) return -1;
  36. - }
  37. -
  38. - memcpy(buf, temp, tempsize-1);
  39. - buf[tempsize-1] = '\0';
  40. -
  41. - // give new pointer and size back, nondestructive if we didn't change anything..
  42. - *n = bufsize;
  43. - *lineptr = buf;
  44. -
  45. - return (ssize_t)(tempsize-1); // don't include the NULL terminator, per getline man page
  46. -}
  47. -#endif
  48. -
  49. // Convert a numerical string to a float, and multiply the result by an
  50. // SI-style multiplier if provided; supported multipliers are Ki, Mi, Gi, k, M
  51. // and G.