Bladeren bron

libcompat: Change unsetenv to return a status code

Guillem Jover 18 jaren geleden
bovenliggende
commit
6467b82b7b
3 gewijzigde bestanden met toevoegingen van 10 en 4 verwijderingen
  1. 6 0
      ChangeLog
  2. 1 1
      libcompat/compat.h
  3. 3 3
      libcompat/unsetenv.c

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-09-14  Guillem Jover  <guillem@debian.org>
+
+	* libcompat/compat.h (unsetenv): Change return type from void to int.
+	* libcompat/unsetenv.c (unsetenv): Likewise. Return -1 on error, or
+	pass through the status code from putenv.
+
 2008-09-14  Guillem Jover  <guillem@debian.org>
 2008-09-14  Guillem Jover  <guillem@debian.org>
 
 
 	* dselect/methkeys.cc: Remove unused headers <stdio.h>, <string.h>,
 	* dselect/methkeys.cc: Remove unused headers <stdio.h>, <string.h>,

+ 1 - 1
libcompat/compat.h

@@ -70,7 +70,7 @@ int alphasort(const struct dirent *a, const struct dirent *b);
 #endif
 #endif
 
 
 #ifndef HAVE_UNSETENV
 #ifndef HAVE_UNSETENV
-void unsetenv(const char *x);
+int unsetenv(const char *x);
 #endif
 #endif
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus

+ 3 - 3
libcompat/unsetenv.c

@@ -24,18 +24,18 @@
 #include <string.h>
 #include <string.h>
 
 
 #ifndef HAVE_UNSETENV
 #ifndef HAVE_UNSETENV
-void
+int
 unsetenv(const char *p)
 unsetenv(const char *p)
 {
 {
 	char *q;
 	char *q;
 
 
 	q = malloc(strlen(p) + 3);
 	q = malloc(strlen(p) + 3);
 	if (!q)
 	if (!q)
-		return;
+		return -1;
 
 
 	strcpy(q, p);
 	strcpy(q, p);
 	strcat(q, "=");
 	strcat(q, "=");
-	putenv(q);
+	return putenv(q);
 }
 }
 #endif
 #endif