(!isspace(as->as_buf[i + 1])) && (as->as_buf[i + 1] != '#'))
(!isspace((int) as->as_buf[i + 1])) && (as->as_buf[i + 1] != '#'))
keynote_parse_assertion(char *buf, int len, int assertion_flags){    int k, i, j, seen_field = 0, ver = 0, end_of_assertion = 0;    char *ks, *ke, *ts, *te = (char *) NULL;    struct assertion *as;    /* Allocate memory for assertion */    as = (struct assertion *) calloc(1, sizeof(struct assertion));    if (as == (struct assertion *) NULL)    {	keynote_errno = ERROR_MEMORY;	return (struct assertion *) NULL;    }    /* Keep a copy of the assertion around */    as->as_buf = strdup(buf);    if (as->as_buf == (char *) NULL)    {	keynote_errno = ERROR_MEMORY;	keynote_free_assertion(as);	return (struct assertion *) NULL;    }    as->as_flags = assertion_flags & ~(ASSERT_FLAG_SIGGEN |				       ASSERT_FLAG_SIGVER);    /* Skip any leading whitespace */    for (i = 0, j = len; i < j && isspace(as->as_buf[i]); i++)     ;    /* Keyword must start at begining of buffer or line */    if ((i >= j) || ((i != 0) && (as->as_buf[i - 1] != '\n')))    {	keynote_free_assertion(as);	keynote_errno = ERROR_SYNTAX;	return (struct assertion *) NULL;    }    while (i < j)			/* Decomposition loop */    {	ks = as->as_buf + i;	/* Mark begining of assertion for signature purposes */	if (as->as_startofsignature == (char *) NULL)	  as->as_startofsignature = ks;	/* This catches comments at the begining of an assertion only */	if (as->as_buf[i] == '#')	/* Comment */	{	    seen_field = 1;   	    /* Skip until the end of line */	    while ((i< j) && as->as_buf[++i] != '\n')	      ;	    i++;	    continue;  /* Loop */	}	/* Advance until we find a keyword separator */	for (; (as->as_buf[i] != ':') && (i < j); i++)	  ;	if (i + 1 > j)	{	    keynote_free_assertion(as);	    keynote_errno = ERROR_SYNTAX;	    return (struct assertion *) NULL;	}	/* ks points at begining of keyword, ke points at end */	ke = as->as_buf + i;	/* ts points at begining of value field */	ts = as->as_buf + i + 1;	/* Skip ':' */	/*	 * Find the end of the field -- means end of buffer,	 * a newline followed by a non-whitespace character,	 * or two newlines.	 */	while (++i <= j)	{	    /* If end of buffer, we're at the end of the field */	    if (i == j)	    {		end_of_assertion = 1;		te = as->as_buf + i;		break;	    }	    /* If two newlines, end of assertion */	    if ((as->as_buf[i] == '\n') && (i + 1 < j) && 		(as->as_buf[i + 1] == '\n'))	    {		end_of_assertion = 1;		te = as->as_buf + i;		break;	    }	    /* If newline followed by non-whitespace or comment character */	    if ((as->as_buf[i] == '\n') && 		(!isspace(as->as_buf[i + 1])) && (as->as_buf[i + 1] != '#'))	    {	        te = as->as_buf + i;	        break;	    }	}	i++;	/* 	 * On each of the cases (except the first), we check that:	 *  - we've already seen a keynote-version field (and that	 *    it's the first one that appears in the assertion)	 *  - the signature field, if present, is the last one	 *  - no field appears more than once	 */	switch (whichkeyword(ks, ke))	{	    case -1:		keynote_free_assertion(as);		return (struct assertion *) NULL;	    case KEYWORD_VERSION:		if ((ver == 1) || (seen_field == 1))		{		    keynote_free_assertion(as);		    keynote_errno = ERROR_SYNTAX;		    return (struct assertion *) NULL;		}		/* Test for version correctness */		keynote_get_envlist(ts, te, 1);		if (keynote_errno != 0)		{		    keynote_free_assertion(as);		    return (struct assertion *) NULL;		}		ver = 1;		break;	    case KEYWORD_LOCALINIT:		if (as->as_env != (struct environment *) NULL)		{		    keynote_free_assertion(as);		    keynote_errno = ERROR_SYNTAX;		    return (struct assertion *) NULL;		}		as->as_env = keynote_get_envlist(ts, te, 0);		if (keynote_errno != 0)		{		    keynote_free_assertion(as);		    return (struct assertion *) NULL;		}		break;	    case KEYWORD_AUTHORIZER:		if (as->as_authorizer_string_s != (void *) NULL)		{		    keynote_free_assertion(as);		    keynote_errno = ERROR_SYNTAX;		    return (struct assertion *) NULL;		}		as->as_authorizer_string_s = ts;		as->as_authorizer_string_e = te;		break;	    case KEYWORD_LICENSEES:		if (as->as_keypred_s != (char *) NULL)		{		    keynote_free_assertion(as);		    keynote_errno = ERROR_SYNTAX;		    return (struct assertion *) NULL;		}		as->as_keypred_s = ts;		as->as_keypred_e = te;		break;	    case KEYWORD_CONDITIONS:		if (as->as_conditions_s != (char *) NULL)		{		    keynote_free_assertion(as);		    keynote_errno = ERROR_SYNTAX;		    return (struct assertion *) NULL;		}		as->as_conditions_s = ts;		as->as_conditions_e = te;		break;	    case KEYWORD_SIGNATURE:		if (as->as_signature_string_s != (char *) NULL)		{		    keynote_free_assertion(as);		    keynote_errno = ERROR_SYNTAX;		    return (struct assertion *) NULL;		}		end_of_assertion = 1;		as->as_allbutsignature = ks;		as->as_signature_string_s = ts;		as->as_signature_string_e = te;		break;	    case KEYWORD_COMMENT:		if (as->as_comment_s != (char *) NULL)		{		    keynote_free_assertion(as);		    keynote_errno = ERROR_SYNTAX;		    return (struct assertion *) NULL;		}		as->as_comment_s = ts;		as->as_comment_e = te;		break;	}	seen_field = 1;	if (end_of_assertion == 1)	{	    /* End of buffer, good termination */	    if ((te == as->as_buf + len) || (te + 1 == as->as_buf + len) ||		(*(te) == '\0') || (*(te + 1) == '\0'))	      break;	    /* Check whether there's something else following */	    for (k = 1; te + k < as->as_buf + len && *(te + k) != '\n'; k++)   	      if (!isspace(*(te + k)))	      {		  printf("here %c\n", *(te + k));		  keynote_free_assertion(as);		  keynote_errno = ERROR_SYNTAX;		  return (struct assertion *) NULL;	      }	    break; /* Assertion is "properly" terminated */	}    }    /* Check that the basic fields are there */    if (as->as_authorizer_string_s == (char *) NULL)    {	keynote_free_assertion(as);	keynote_errno = ERROR_SYNTAX;	return (struct assertion *) NULL;    }    /* Signature generation/verification handling */    if (assertion_flags & ASSERT_FLAG_SIGGEN)    {        if (keynote_fix_fields(as, 0) != RESULT_TRUE)        {	    keynote_free_assertion(as);	    return (struct assertion *) NULL;        }    }    else      if (assertion_flags & ASSERT_FLAG_SIGVER)	if (keynote_fix_fields(as, 1) != RESULT_TRUE)	{	    keynote_free_assertion(as);	    return (struct assertion *) NULL;	}    return as;}