unsetenv.c 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * libcompat - system compatibility library
  3. *
  4. * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  5. *
  6. * This is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2,
  9. * or (at your option) any later version.
  10. *
  11. * This is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public
  17. * License along with dpkg; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <config.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #ifndef HAVE_UNSETENV
  24. int
  25. unsetenv(const char *p)
  26. {
  27. char *q;
  28. q = malloc(strlen(p) + 3);
  29. if (!q)
  30. return -1;
  31. strcpy(q, p);
  32. strcat(q, "=");
  33. return putenv(q);
  34. }
  35. #endif