sfdisk.010.index-rindex-fix-2.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. diff -ru sfdisk_vanilla/sfdisk.c sfdisk_index-rindex-fix/sfdisk.c
  2. --- sfdisk_vanilla/sfdisk.c 2004-01-13 13:03:11.000000000 +0000
  3. +++ sfdisk_index-rindex-fix/sfdisk.c 2008-04-17 13:44:40.000000000 +0000
  4. @@ -40,7 +40,7 @@
  5. #include <unistd.h> /* read, write */
  6. #include <fcntl.h> /* O_RDWR */
  7. #include <errno.h> /* ERANGE */
  8. -#include <string.h> /* index() */
  9. +#include <string.h> /* strchr, strrchr */
  10. #include <ctype.h>
  11. #include <getopt.h>
  12. #include <sys/ioctl.h>
  13. @@ -1672,12 +1672,12 @@
  14. eof = 1;
  15. return RD_EOF;
  16. }
  17. - if (!(lp = index(lp, '\n')))
  18. + if (!(lp = strchr(lp, '\n')))
  19. fatal(_("long or incomplete input line - quitting\n"));
  20. *lp = 0;
  21. /* remove comments, if any */
  22. - if ((lp = index(line+2, '#')) != 0)
  23. + if ((lp = strchr(line+2, '#')) != 0)
  24. *lp = 0;
  25. /* recognize a few commands - to be expanded */
  26. @@ -1687,7 +1687,7 @@
  27. }
  28. /* dump style? - then bad input is fatal */
  29. - if ((ip = index(line+2, ':')) != 0) {
  30. + if ((ip = strchr(line+2, ':')) != 0) {
  31. struct dumpfld *d;
  32. nxtfld:
  33. @@ -2436,7 +2436,7 @@
  34. if (argc < 1)
  35. fatal(_("no command?\n"));
  36. - if ((progn = rindex(argv[0], '/')) == NULL)
  37. + if ((progn = strrchr(argv[0], '/')) == NULL)
  38. progn = argv[0];
  39. else
  40. progn++;