VATTR *vattr_define( char *name, int number, int flags ) { VATTR *vp; /* * Be ruthless. */ if( strlen( name ) >= VNAME_SIZE ) { name[VNAME_SIZE - 1] = '\0'; } fixcase( name ); if( !ok_attr_name( name ) ) { return ( NULL ); } if( ( vp = vattr_find( name ) ) != NULL ) { return ( vp ); } vp = ( VATTR * ) XMALLOC( sizeof( VATTR ), "vattr_define" ); vp->name = store_string( name ); vp->flags = flags; vp->number = number; hashadd( vp->name, ( int * ) vp, &mudstate.vattr_name_htab, 0 ); anum_extend( vp->number ); anum_set( vp->number, ( ATTR * ) vp ); return ( vp ); }
char * place(char *sp, char *l1, char *l2) { while (l1 < l2) { *sp++ = fixcase(*l1++); if (sp >= &genbuf[LBSIZE]) return (0); } return (sp); }
VATTR *vattr_rename( char *name, char *newname ) { VATTR *vp; fixcase( name ); if( !ok_attr_name( name ) ) { return ( NULL ); } /* * Be ruthless. */ if( strlen( newname ) >= VNAME_SIZE ) { newname[VNAME_SIZE - 1] = '\0'; } fixcase( newname ); if( !ok_attr_name( newname ) ) { return ( NULL ); } /* * We must explicitly delete and add the name to the hashtable, * * since we are changing the data. */ vp = ( VATTR * ) hashfind( name, &mudstate.vattr_name_htab ); if( vp ) { vp->name = store_string( newname ); hashdelete( name, &mudstate.vattr_name_htab ); hashadd( newname, ( int * ) vp, &mudstate.vattr_name_htab, 0 ); } return ( vp ); }
void vattr_delete( char *name ) { VATTR *vp; int number; fixcase( name ); if( !ok_attr_name( name ) ) { return; } number = 0; vp = ( VATTR * ) hashfind( name, &mudstate.vattr_name_htab ); if( vp ) { number = vp->number; anum_set( number, NULL ); hashdelete( name, &mudstate.vattr_name_htab ); XFREE( vp, "vattr_delete" ); } return; }
static void dosub(void) { register char *lp, *sp, *rp; int c; lp = linebuf; sp = genbuf; rp = rhsbuf; while (lp < loc1) *sp++ = *lp++; casecnt = 0; while ((c = *rp++)) { if (c & RE_QUOTE) switch (c & TRIM) { case '&': sp = place(sp, loc1, loc2); if (sp == 0) goto ovflo; continue; case 'l': casecnt = 1; destuc = 0; continue; case 'L': casecnt = LBSIZE; destuc = 0; continue; case 'u': casecnt = 1; destuc = 1; continue; case 'U': casecnt = LBSIZE; destuc = 1; continue; case 'E': case 'e': casecnt = 0; continue; } if (c < 0 && (c &= TRIM) >= '1' && c < nbra + '1') { sp = place(sp, braslist[c - '1'], braelist[c - '1']); if (sp == 0) goto ovflo; continue; } if (casecnt) *sp++ = fixcase(c & TRIM); else *sp++ = c & TRIM; if (sp >= &genbuf[LBSIZE]) ovflo: error("Line overflow@in substitute - limit 512 chars"); } lp = loc2; loc2 = sp + (linebuf - genbuf) + (loc1 == loc2); while ((*sp++ = *lp++)) if (sp >= &genbuf[LBSIZE]) goto ovflo; strcLIN(genbuf); }
/** * 'Optimizes' and corrects the dependencies. */ void depOptimize(int fFixCase, int fQuiet) { /* * Walk the list correct the names and re-insert them. */ PDEP pDepOrg = g_pDeps; PDEP pDep = g_pDeps; g_pDeps = NULL; for (; pDep; pDep = pDep->pNext) { #ifndef PATH_MAX char szFilename[_MAX_PATH + 1]; #else char szFilename[PATH_MAX + 1]; #endif char *pszFilename; struct stat s; /* * Skip some fictive names like <built-in> and <command line>. */ if ( pDep->szFilename[0] == '<' && pDep->szFilename[pDep->cchFilename - 1] == '>') continue; pszFilename = pDep->szFilename; #if K_OS != K_OS_OS2 && K_OS != K_OS_WINDOWS /* * Skip any drive letters from compilers running in wine. */ if (pszFilename[1] == ':') pszFilename += 2; #endif /* * The microsoft compilers are notoriously screwing up the casing. * This will screw up kmk (/ GNU Make). */ if (fFixCase) { #if K_OS == K_OS_WINDOWS nt_fullpath(pszFilename, szFilename, sizeof(szFilename)); fixslash(szFilename); #else strcpy(szFilename, pszFilename); fixslash(szFilename); fixcase(szFilename); #endif pszFilename = szFilename; } /* * Check that the file exists before we start depending on it. */ if (stat(pszFilename, &s)) { if ( !fQuiet || errno != ENOENT || ( pszFilename[0] != '/' && pszFilename[0] != '\\' && ( !isalpha(pszFilename[0]) || pszFilename[1] != ':' || ( pszFilename[2] != '/' && pszFilename[2] != '\\'))) ) fprintf(stderr, "kDep: Skipping '%s' - %s!\n", pszFilename, strerror(errno)); continue; } /* * Insert the corrected dependency. */ depAdd(pszFilename, strlen(pszFilename)); } /* * Free the old ones. */ while (pDepOrg) { pDep = pDepOrg; pDepOrg = pDepOrg->pNext; free(pDep); } }