示例#1
0
文件: gwfsxaut.c 项目: fosslc/Ingres
/*
** Name: gwsxa_rightTrimBlank - trim blanks off tails of a (possibly non-terminated)
**	 string. 
** 
** Description:
**	This routine walks through a (possibly non-NULL-terminated) string
**	up to maxlen bytes looking for last non-space character. It then
**      steps over that character and replaces the ensuing space with a NULL.
**
**      This function differs from gwsxa_zapblank() above in that it will
**      allow embeded spaces to remain within the string.
**
** Returns:
**	Nothing.
**
** History:
**	04-Dec-2008 (coomi01) b121323
**	    Created
*/
VOID
gwsxa_rightTrimBlank(char *str, i4 maxlen)
{
    char *notBlankPtr;
    char *currPtr;
    char *endPtr;

    /*
    **  If passed an empty string then just return
    */
    if (!str || (maxlen<=0) )
	return;

    /*
    ** Init the pointers 
    */
    currPtr  = str;
    endPtr   = &str[maxlen];
    notBlankPtr = NULL;

    /* 
    ** Careful, The string maybe dbyte
    */
    while ( currPtr < endPtr )
    {
	if ( (*currPtr != EOS) && !CMspace(currPtr) )
	{
	    /* Save non-space position */
	    notBlankPtr = currPtr;
	}

	/*
	** Step forward
	*/
	CMnext(currPtr);
    }

    if ( NULL != notBlankPtr )
    {
	/* 
	** Step foward, over last non-blank
	*/
	CMnext(notBlankPtr);

	/* 
	** But do not write beyound buffer end
	*/
	if (notBlankPtr < endPtr)
	{
	    *notBlankPtr = EOS;
	}
    }
    else
    {
	/* 
	** String entirely composed of spaces 
	*/
	*str = EOS;
    }
}
示例#2
0
STATUS
s_srem_set()
{
    char	*s;
    char	*send;
    i4		pos;
    i4		n;
    char	short_remark[OOSHORTREMSIZE+1];

    if (St_sr_given)
    {
	s_error(0x3A8, NONFATAL, NULL);
	s_cmd_skip();
	return FAIL;
    }
    if (Cact_ren == NULL)
    {
	    s_error(0x38A, FATAL, NULL);
    }

    St_sr_given = TRUE;

    Tokchar++;
    while (CMspace(Tokchar) || *Tokchar == '\t')
    {
	CMnext(Tokchar);
    }

    s = short_remark;
    send = s + OOSHORTREMSIZE;
    while (*Tokchar != '\n' && *Tokchar != EOS)
    {
        if (s <= send-CMbytecnt(Tokchar))
	{
	    if (*Tokchar == '\t')
	    {
		/* if tab, replace it with the one blank */
		*s = ' ';
		s++;
		Tokchar++;
	    }
	    else
	    {
		CMcpyinc(Tokchar, s);
	    }
	}
	else
	{
	    CMnext(Tokchar);
	}
    }

    *s = EOS;
    Cact_ren->ren_shortrem = STalloc(short_remark);

    return OK;
}
示例#3
0
文件: gwfsxaut.c 项目: fosslc/Ingres
/*
** Name: gwsxa_zapblank - trim blanks off a (possibly non-terminated)
**	 string. 
** 
** Description:
**	This routine walks through a (possibly non-NULL-terminated) string
**	up to maxlen bytes looking for a space. It replaces the space with
**      a NULL value. The use of this function is primarily to convert
**	a blank-padded string to a regular NULL-terminated string for 
**	error reporting.
**
** Returns:
**	Nothing.
**
** History:
**	14-sep-92 (robf)
**	    Created
*/
VOID
gwsxa_zapblank(char *str,i4 maxlen)
{
	i4 i;

	/*
	**	If passed an empty string then just return
	*/
	if (!str)
		return;

	for( i=0; i<maxlen; i++)
	{
		if(CMspace(str))
			break;
		CMnext(str);
	}
	if( i!=maxlen)
		*str= EOS;
}
示例#4
0
/*{
** Name:	mktimestamp - make time stamp
**
** Description:
**	Convert the system specific time string (from TMstr) into a
**	Replicator timestamp of the form dd-mmm-yyy hh:mm:ss.
**	mktimestamp() is only intended as a temporary fix to the problem
**	regarding availablity of TMbreak().
**
** Inputs:
**	timestr
**
** Outputs:
**	timestamp
**
** Returns:
**	none
*/
static void
mktimestamp(
char *timestr,
char *timestamp)
{
	char	*tmwords[MAX_TMWORDS];
	char	*dom;
	char	*mon;
	char	*yr;
	char	*hms;
	i4	count;

	*timestamp = EOS;
	count = MAX_TMWORDS;

# ifdef VMS
	if CMspace(timestr)
		CMnext(timestr);
	RPgetwords(ERx(" -"), timestr, &count, tmwords);
	if (count < 3)
		return;
	dom = tmwords[0];
	mon = tmwords[1];
	yr = tmwords[2];
	hms = tmwords[3];
# else
	STgetwords(timestr, &count, tmwords);
	if (count < 5)
		return;
	mon = tmwords[1];
	dom = tmwords[2];
	hms = tmwords[3];
	yr = tmwords[4];
# endif

	STprintf(timestamp, ERx("%.2s-%.3s-%.4s %.8s"), dom, mon, yr, hms);
}
示例#5
0
i4
STxcompare(
	char	*a_ptr,
	size_t	a_len,
	char	*b_ptr,
	size_t	b_len,
	bool	ic,
	bool	sb)
{
	unsigned char		*ap;
	unsigned char		*bp;
	register size_t	al;
	register size_t	bl;
	i4		ret_val = -2;
	i4		cmp;


	ap = (unsigned char *) a_ptr;
	bp = (unsigned char *) b_ptr;
	al = a_len;

	if (al == 0)
		al = MAXI2;

	bl = b_len;

	if (bl == 0)
		bl = MAXI2;

	if (CMGETDBL)
	{
	    while (ret_val == -2)
	    {
		/* supress blanks in both strings */

		if (sb)
		{
			while (al > 0 && CMspace(ap))
			{
				al -= CMbytecnt(ap);
				CMnext(ap);
			}

			while (bl > 0 && CMspace(bp))
			{
				bl -= CMbytecnt(bp);
				CMnext(bp);
			}
		}


		if (al <= 0)
			ap = (unsigned char *) "";

		if (bl <= 0)
			bp = (unsigned char *) "";

		/* do inequality tests */

		if (ic)
			cmp = CMcmpnocase(ap,bp);
		else
			cmp = CMcmpcase(ap,bp);

		if (cmp < 0)
			ret_val = -1;
		else if (cmp > 0)
			ret_val = 1;
		else if (*ap == '\0')
			ret_val = 0;
		else
		{
			/* go on to the next character */

			al -= CMbytecnt(ap);
			CMnext(ap);
			bl -= CMbytecnt(bp);
			CMnext(bp);
		}
	    }
	}
	else
	{
	    while (ret_val == -2)
	    {
		/* supress blanks in both strings */

		if (sb)
		{
			while (al > 0 && CMspace_SB(ap))
			{
				al -= CMbytecnt_SB(ap);
				CMnext_SB(ap);
			}

			while (bl > 0 && CMspace_SB(bp))
			{
				bl -= CMbytecnt_SB(bp);
				CMnext_SB(bp);
			}
		}


		if (al <= 0)
			ap = (unsigned char *) "";

		if (bl <= 0)
			bp = (unsigned char *) "";

		/* do inequality tests */

		if (ic)
			cmp = CMcmpnocase_SB(ap,bp);
		else
			cmp = CMcmpcase_SB(ap,bp);

		if (cmp < 0)
			ret_val = -1;
		else if (cmp > 0)
			ret_val = 1;
		else if (*ap == '\0')
			ret_val = 0;
		else
		{
			/* go on to the next character */

			al -= CMbytecnt_SB(ap);
			CMnext_SB(ap);
			bl -= CMbytecnt_SB(bp);
			CMnext_SB(bp);
		}
	    }
	}

	return(ret_val);
}
示例#6
0
char * ScanPastSpaces(char * str)
{
   while (CMspace(str))  CMnext(str);       /* scan past blanks */
   return(str);
}