bridge/class-master/depend/pari/src/language/es.c
/* s truncated to 8 chars, suf possibly NULL */
s truncated to 8 chars, suf possibly NULL
s truncated to 8 chars suf possibly NULL
static char *
init_unique(const char *s, const char *suf)
{
  const char *pre = pari_tmp_dir();
  char *buf, salt[64];
  size_t lpre, lsalt, lsuf;
#ifdef UNIX
  sprintf(salt,"-%ld-%ld", (long)getuid(), (long)getpid());
#else
  sprintf(salt,"-%ld", (long)time(NULL));
#endif
  lsuf = suf? strlen(suf): 0;
  lsalt = strlen(salt);
  lpre = strlen(pre);
  buf = (char*) pari_malloc(lpre + 1 + 8 + lsalt + lsuf + 1);
  strcpy(buf, pre);
  if (buf[lpre-1] != '/') { (void)strcat(buf, "/"); lpre++; }
#if defined(__EMX__) || defined(_WIN32)
  swap_slash(buf);
#endif
  sprintf(buf + lpre, "%.8s%s", s, salt);
  if (lsuf) strcat(buf, suf);
  if (DEBUGFILES) err_printf("I/O: prefix for unique file/dir = %s\n", buf);
  return buf;
}
static char * init_unique ( const char * s , const char * suf ) { const char * pre = pari_tmp_dir ( ) ; char * buf , salt [ 64 ] ; size_t lpre , lsalt , lsuf ; #ifdef UNIX sprintf ( salt , " " , ( long ) getuid ( ) , ( long ) getpid ( ) ) ; #else sprintf ( salt , " " , ( long ) time ( NULL ) ) ; #endif lsuf = suf ? strlen ( suf ) : 0 ; lsalt = strlen ( salt ) ; lpre = strlen ( pre ) ; buf = ( char * ) pari_malloc ( lpre + 1 + 8 + lsalt + lsuf + 1 ) ; strcpy ( buf , pre ) ; if ( buf [ lpre - 1 ] != ' ' ) { ( void ) strcat ( buf , " " ) ; lpre ++ ; } #if defined ( __EMX__ ) || defined ( _WIN32 ) swap_slash ( buf ) ; #endif sprintf ( buf + lpre , " " , s , salt ) ; if ( lsuf ) strcat ( buf , suf ) ; if ( DEBUGFILES ) err_printf ( " \n " , buf ) ; return buf ; }
s truncated to 8 chars, suf possibly NULL
s truncated to 8 chars suf possibly NULL
/* room for prefix + '/' + s + salt + suf + '\0' */