In order to enhance my credibility, let me produce
a test case for getsubopt() that illuminates the
failure of the present implementation of shishi_cfg().

The test program "test_subopt.c", contained in the present
message, produces the following output at execution time.

 GNU libc, OpenSolaris:

    INPUT: name=this,that,those

    NAME: value = 'this', tail = 'that,those'
    default: value = 'that', tail = 'those'
    default: value = 'those', tail = ''

 FreeBSD 8.2, FreeBSD 9.0, OpenBSD 5.0, NetBSD 5.1, DragonflyBSD 3.1:

    INPUT: name=this,that,those

    NAME: value = 'this', tail = 'that,those'
    default: value = '(null)', tail = 'those'
    default: value = '(null)', tail = ''

A common feature in the BSD implementation is to empty VALUE in

  getsubopt(&tail, token, &value);

in case an unrecognised suboption is found. The implementations
in eglibc and in SunOS libc do not behave that way.

Best regards,

  Mats Erik Andersson
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

char *const token[] = {
	"name",
	NULL
};

int main(void) {
	char *value, *tail = strdup("name=this,that,those");

	printf("INPUT: %s\n\n", tail);
	while (tail && *tail) {
		switch (getsubopt(&tail, token, &value)) {
			case 0:
				printf("NAME: value = '%s', tail = '%s'\n",
					value, tail);
				break;
			default:
				printf("default: value = '%s', tail = '%s'\n",
					value, tail);
		}
	}

	return errno;
}
_______________________________________________
Help-shishi mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-shishi

Reply via email to