mapchar.cc #1

  • //
  • guest/
  • perforce_software/
  • p4/
  • 2014-1/
  • dbsupp/
  • mapchar.cc
  • View
  • Commits
  • Open Download .zip Download (1 KB)
/*
 * Copyright 1995, 1996 Perforce Software.  All rights reserved.
 *
 * This file is part of Perforce - the FAST SCM System.
 */

# include <stdhdrs.h>
# include <strbuf.h>
# include "mapchar.h"

static const char *const mapCharNames[] = {
	"0",
	"c",
	"/",
	"%",
	"*",
	"."
} ;

int
MapChar::Set( char *&p, int &nStars, int &nDots )
{
	this->c = *p;

	if( c == '/' )
	{
		cc = cSLASH;
		++p;
	}
	else if( c == '.' && p[1] == '.' && p[2] == '.' )
	{
		cc = cDOTS;
		paramNumber = PARAM_BASE_DOTS + nDots++;
		p += 3;
	}
	else if( c == '%' && p[1] == '%' && p[2] >= '0' && p[2] <= '9' )
	{
		cc = cPERC;
		paramNumber = PARAM_BASE_PERCENT + ( p[2] - '0' );
		p += 3;
	}
	else if( c == '*' )
	{
		cc = cSTAR;
		paramNumber = PARAM_BASE_STARS + nStars++;
		++p;
	}
	else if( c == '\0' )
	{
		cc = cEOS;
		return 0;
	}
	else 
	{
		cc = cCHAR;
		++p;
	}

	return 1;
}

void
MapChar::MakeParam( StrBuf &p, MapChar *mc2, int &wildSlot )
{
	if( cc == cDOTS && mc2->cc == cDOTS )
	{
	    p << "...";
	}
	else
	{
	    p << "%%" << ++wildSlot;
	}
}

const char *
MapChar::Name()
{
	return mapCharNames[ cc ];
}

# Change User Description Committed
#1 15902 Matt Attaway A second renaming that I will not obliterate as a badge of shame
//guest/perforce_software/p4/2014_1/dbsupp/mapchar.cc
#1 15901 Matt Attaway Clean up code to fit modern Workshop naming standards
//guest/perforce_software/p4/2014.1/dbsupp/mapchar.cc
#1 12188 Matt Attaway Move 'main' p4 into a release specific directory in prep for new releases
//guest/perforce_software/p4/dbsupp/mapchar.cc
#1 9129 Matt Attaway Initial commit of the 2014.1 p4/p4api source code