lef: constify static data and LefNextToken() return
LefHelper_DBTechNameType_LefLower() identified and introduced during conversion to const data usage. Only side-effect is some log messages will use original verbatim token now instead of lowercase version (but this seems ok when file parsing, to quote the problematic information source verbatim)
This commit is contained in:
parent
451dab4b9b
commit
ac37927186
|
|
@ -78,7 +78,7 @@ enum def_netspecial_shape_keys {
|
|||
DEF_SPECNET_SHAPE_FILLWIREOPC,
|
||||
DEF_SPECNET_SHAPE_DRCFILL};
|
||||
|
||||
char *
|
||||
const char *
|
||||
DefAddRoutes(
|
||||
CellDef *rootDef, /* Cell to paint */
|
||||
FILE *f, /* Input file */
|
||||
|
|
@ -89,7 +89,7 @@ DefAddRoutes(
|
|||
LefMapping *defLayerMap, /* magic-to-lef layer mapping array */
|
||||
bool annotate) /* If TRUE, do not generate any geometry */
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
LinkedRect *routeList, *newRoute = NULL, *routeTop = NULL;
|
||||
Point refp; /* reference point */
|
||||
bool valid = FALSE; /* is there a valid reference point? */
|
||||
|
|
@ -171,7 +171,7 @@ DefAddRoutes(
|
|||
/* of type mappings in the lef section of the techfile is */
|
||||
/* preferred. */
|
||||
|
||||
routeLayer = DBTechNameType(LefLower(token));
|
||||
routeLayer = LefHelper_DBTechNameType_LefLower(token);
|
||||
lefl = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -459,7 +459,7 @@ DefAddRoutes(
|
|||
|
||||
iscontact = TRUE;
|
||||
}
|
||||
else if ((paintLayer = DBTechNameType(LefLower(token))) >= 0)
|
||||
else if ((paintLayer = LefHelper_DBTechNameType_LefLower(token)) >= 0)
|
||||
{
|
||||
LefError(DEF_ERROR, "Error: Via \"%s\" named but undefined.\n",
|
||||
token);
|
||||
|
|
@ -791,7 +791,7 @@ DefReadNonDefaultRules(
|
|||
float oscale,
|
||||
int total)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
int keyword, subkey;
|
||||
int processed = 0;
|
||||
HashEntry *he;
|
||||
|
|
@ -1052,7 +1052,7 @@ DefReadNets(
|
|||
bool annotate, /* If true, create labels, not geometry */
|
||||
int total)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
char *netname = NULL, *prnet;
|
||||
int keyword, subkey;
|
||||
int processed = 0;
|
||||
|
|
@ -1306,7 +1306,7 @@ DefReadLocation(
|
|||
const Rect *r;
|
||||
Rect tr, rect;
|
||||
int keyword;
|
||||
char *token;
|
||||
const char *token;
|
||||
float x, y;
|
||||
Transform t2;
|
||||
|
||||
|
|
@ -1442,7 +1442,7 @@ DefReadPins(
|
|||
int total,
|
||||
bool annotate)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
char pinname[LEF_LINE_MAX];
|
||||
int keyword, subkey, flags;
|
||||
int processed = 0;
|
||||
|
|
@ -1770,7 +1770,7 @@ DefReadBlockages(
|
|||
float oscale,
|
||||
int total)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
int keyword, subkey;
|
||||
int processed = 0;
|
||||
TileType curlayer;
|
||||
|
|
@ -1885,7 +1885,7 @@ DefReadVias(
|
|||
float oscale,
|
||||
int total)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
char vianame[LEF_LINE_MAX];
|
||||
int keyword, subkey;
|
||||
int processed = 0;
|
||||
|
|
@ -2171,7 +2171,8 @@ DefReadComponents(
|
|||
CellDef *defMacro;
|
||||
CellUse *defUse;
|
||||
Transform t;
|
||||
char *token, *dptr;
|
||||
const char *token;
|
||||
char *dptr;
|
||||
char usename[512];
|
||||
int keyword, subkey;
|
||||
int processed = 0;
|
||||
|
|
@ -2389,7 +2390,7 @@ DefRead(
|
|||
CellDef *rootDef;
|
||||
FILE *f;
|
||||
char *filename;
|
||||
char *token;
|
||||
const char *token;
|
||||
char *bboxstr;
|
||||
int keyword, dscale, total;
|
||||
float oscale;
|
||||
|
|
|
|||
|
|
@ -190,11 +190,11 @@ defWriteHeader(
|
|||
*------------------------------------------------------------
|
||||
*/
|
||||
|
||||
char *
|
||||
const char *
|
||||
defTransPos(
|
||||
Transform *t)
|
||||
{
|
||||
static char *def_orient[] = {
|
||||
static const char * def_orient[] = {
|
||||
"N", "S", "E", "W", "FN", "FS", "FE", "FW"
|
||||
};
|
||||
|
||||
|
|
@ -2486,7 +2486,7 @@ defWriteBlockages(
|
|||
sizeof(TileTypeBitMask));
|
||||
defobsdata.blockData = (LinkedRect **)mallocMagic(numblocks *
|
||||
sizeof(LinkedRect *));
|
||||
defobsdata.baseNames = (char **)mallocMagic(numblocks *
|
||||
defobsdata.baseNames = (const char **)mallocMagic(numblocks *
|
||||
sizeof(char *));
|
||||
|
||||
if (numblocks > 0)
|
||||
|
|
|
|||
|
|
@ -149,8 +149,9 @@ extern int LefParseEndStatement(FILE *f, const char *match);
|
|||
extern void LefSkipSection(FILE *f, const char *section);
|
||||
extern void LefEndStatement(FILE *f);
|
||||
extern CellDef *lefFindCell(const char *name);
|
||||
extern char *LefNextToken(FILE *f, bool ignore_eol);
|
||||
extern const char *LefNextToken(FILE *f, bool ignore_eol);
|
||||
extern char *LefLower(char *token);
|
||||
extern TileType LefHelper_DBTechNameType_LefLower(const char *name);
|
||||
extern LinkedRect *LefReadGeometry(CellDef *lefMacro, FILE *f, float oscale, bool do_list, bool is_imported);
|
||||
extern void LefEstimate(int processed, int total, const char *item_name);
|
||||
extern lefLayer *LefRedefined(lefLayer *lefl, const char *redefname);
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ LefEstimate(
|
|||
*------------------------------------------------------------
|
||||
*/
|
||||
|
||||
char *
|
||||
const char *
|
||||
LefNextToken(
|
||||
FILE *f,
|
||||
bool ignore_eol)
|
||||
|
|
@ -222,7 +222,7 @@ LefNextToken(
|
|||
static char line[LEF_LINE_MAX + 2]; /* input buffer */
|
||||
static char *nexttoken = NULL; /* pointer to next token */
|
||||
static char *curtoken; /* pointer to current token */
|
||||
static char eol_token='\n';
|
||||
static const char eol_token='\n';
|
||||
|
||||
/* Read a new line if necessary */
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ LefParseEndStatement(
|
|||
FILE *f,
|
||||
const char *match)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
int keyword;
|
||||
const char * match_name[2];
|
||||
|
||||
|
|
@ -613,6 +613,38 @@ LefLower(
|
|||
return token;
|
||||
}
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------
|
||||
* LefHelper_DBTechNameType_LefLower --
|
||||
*
|
||||
* Helper function to make other parts of module code more
|
||||
* readable (one liner usage), for the common use of:
|
||||
* tileType = DBTechNameType(LefLower(token));
|
||||
*
|
||||
* This function allows token to be a (const char *) and
|
||||
* original data source is not edited.
|
||||
*
|
||||
* Results:
|
||||
* as per TileType from DBTechNameType() after lookup.
|
||||
*
|
||||
* Side Effects:
|
||||
: None
|
||||
*
|
||||
* Module internal API only.
|
||||
*/
|
||||
|
||||
TileType
|
||||
LefHelper_DBTechNameType_LefLower(const char *name)
|
||||
{
|
||||
char tmp[256];
|
||||
strncpy(tmp, name, sizeof(tmp));
|
||||
/* after maybe helps codegen, only care to check overrun */
|
||||
ASSERT(strlen(name) < sizeof(tmp), "strlen(name)");
|
||||
tmp[sizeof(tmp)-1] = '\0';
|
||||
LefLower(tmp);
|
||||
return DBTechNameType(tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------
|
||||
* LefRedefined --
|
||||
|
|
@ -724,7 +756,7 @@ LefReadLayers(
|
|||
TileType *lreturn,
|
||||
const Rect **rreturn)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
TileType curlayer = -1;
|
||||
lefLayer *lefl = NULL;
|
||||
|
||||
|
|
@ -772,8 +804,7 @@ LefReadLayers(
|
|||
curlayer = DBTechNameType(token);
|
||||
if (curlayer < 0)
|
||||
{
|
||||
(void) LefLower(token);
|
||||
curlayer = DBTechNameType(token);
|
||||
curlayer = LefHelper_DBTechNameType_LefLower(token);
|
||||
}
|
||||
}
|
||||
if ((curlayer < 0) && ((!lefl) || (lefl->lefClass != CLASS_IGNORE)))
|
||||
|
|
@ -843,7 +874,7 @@ LefReadLefPoint(
|
|||
float *xp,
|
||||
float *yp)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
bool needMatch = FALSE;
|
||||
|
||||
token = LefNextToken(f, TRUE);
|
||||
|
|
@ -891,7 +922,7 @@ LefReadRect(
|
|||
TileType curlayer,
|
||||
float oscale)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
float llx, lly, urx, ury;
|
||||
static Rect paintrect;
|
||||
Rect lefrect;
|
||||
|
|
@ -992,7 +1023,7 @@ LefReadPolygon(
|
|||
{
|
||||
LinkedRect *lr = NULL, *newRect;
|
||||
Point *plist = NULL;
|
||||
char *token;
|
||||
const char *token;
|
||||
float px, py;
|
||||
int lpoints = 0;
|
||||
|
||||
|
|
@ -1196,7 +1227,7 @@ LefReadGeometry(
|
|||
{
|
||||
TileType curlayer = -1, otherlayer = -1;
|
||||
|
||||
char *token;
|
||||
const char *token;
|
||||
int keyword;
|
||||
LinkedRect *newRect, *rectList;
|
||||
Point *pointList;
|
||||
|
|
@ -1520,7 +1551,7 @@ LefReadPin(
|
|||
float oscale,
|
||||
bool is_imported)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
char *testpin = pinname;
|
||||
int keyword, subkey;
|
||||
int pinDir = PORT_CLASS_DEFAULT;
|
||||
|
|
@ -1832,7 +1863,7 @@ void
|
|||
LefEndStatement(
|
||||
FILE *f)
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
|
||||
while ((token = LefNextToken(f, TRUE)) != NULL)
|
||||
if (*token == ';') break;
|
||||
|
|
@ -1869,7 +1900,7 @@ LefReadNonDefaultRule(
|
|||
char *rname, /* name of the rule */
|
||||
float oscale) /* scale factor um->magic units */
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
char tsave[128];
|
||||
int keyword;
|
||||
HashEntry *he;
|
||||
|
|
@ -2091,7 +2122,8 @@ LefReadMacro(
|
|||
CellDef *lefMacro;
|
||||
HashEntry *he;
|
||||
|
||||
char *token, tsave[128], *propval;
|
||||
const char *token;
|
||||
char tsave[128], *propval;
|
||||
int keyword, pinNum, propsize;
|
||||
float x, y;
|
||||
bool has_size, is_imported = FALSE, propfound;
|
||||
|
|
@ -2658,7 +2690,7 @@ LefReadLayerSection(
|
|||
int mode, /* layer, via, or viarule */
|
||||
lefLayer *lefl) /* pointer to layer info */
|
||||
{
|
||||
char *token;
|
||||
const char *token;
|
||||
int keyword, typekey;
|
||||
TileType curlayer = -1;
|
||||
float fvalue, oscale;
|
||||
|
|
@ -2808,9 +2840,8 @@ LefReadLayerSection(
|
|||
break;
|
||||
case LEF_LAYER_DIRECTION:
|
||||
token = LefNextToken(f, TRUE);
|
||||
LefLower(token);
|
||||
if (lefl->lefClass == CLASS_ROUTE)
|
||||
lefl->info.route.hdirection = (token[0] == 'h') ? TRUE : FALSE;
|
||||
lefl->info.route.hdirection = (tolower(token[0]) == 'h') ? TRUE : FALSE;
|
||||
LefEndStatement(f);
|
||||
break;
|
||||
case LEF_LAYER_OFFSET:
|
||||
|
|
@ -2895,7 +2926,7 @@ LefRead(
|
|||
{
|
||||
FILE *f;
|
||||
char *filename;
|
||||
char *token;
|
||||
const char *token;
|
||||
char tsave[128];
|
||||
int keyword;
|
||||
float oscale;
|
||||
|
|
@ -3031,7 +3062,7 @@ LefRead(
|
|||
{
|
||||
TileType mtype = DBTechNameType(token);
|
||||
if (mtype < 0)
|
||||
mtype = DBTechNameType(LefLower(token));
|
||||
mtype = LefHelper_DBTechNameType_LefLower(token);
|
||||
if (mtype < 0)
|
||||
{
|
||||
/* Ignore. This is probably a masterslice or */
|
||||
|
|
|
|||
|
|
@ -955,8 +955,9 @@ char *
|
|||
MakeLegalLEFSyntax(
|
||||
char *text)
|
||||
{
|
||||
static char *badLEFchars = ";# -*$\n";
|
||||
char *cptr, *bptr;
|
||||
static const char * const badLEFchars = ";# -*$\n";
|
||||
char *cptr;
|
||||
const char *bptr;
|
||||
char *rstr;
|
||||
|
||||
for (cptr = text; *cptr != '\0'; cptr++)
|
||||
|
|
|
|||
Loading…
Reference in New Issue