dirname() -> ngdirname()

This commit is contained in:
h_vogt 2011-06-25 23:07:13 +00:00
parent f3565bab6b
commit cc36fb8071
6 changed files with 16 additions and 34 deletions

View File

@ -1,5 +1,7 @@
2011-06-25 Holger Vogt
* ivars.c: fix usage of dirname()
* ivars.c, ivars.h, inpcom.c, inp.c, util.c, util.h:
rename internal fcn dirname() to ngdirname() because it is different
from LINUX dirnam().
2011-06-25 Robert Larice
* src/ngsconvert.c :

View File

@ -11,11 +11,6 @@ $Id$
#include "ngspice.h"
#ifdef HAVE_LIBGEN_H /* dirname */
#include <libgen.h>
#define HAVE_DECL_BASENAME 1
#endif
#include "cpdefs.h"
#include "inpdefs.h"
#include "ftedefs.h"
@ -29,7 +24,7 @@ $Id$
#include "completion.h"
#include "variable.h"
#include "breakp2.h"
#include "../misc/util.h" /* dirname() */
#include "../misc/util.h" /* ngdirname() */
#include "../misc/mktemp.h"
#include "subckt.h"
#include "spiceif.h"
@ -330,7 +325,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
/* read in the deck from a file */
char *filename_dup = ( filename == NULL ) ? strdup(".") : strdup(filename);
inp_readall(fp, &deck, 0, dirname(filename_dup), comfile);
inp_readall(fp, &deck, 0, ngdirname(filename_dup), comfile);
tfree(filename_dup);
/* if nothing came back from inp_readall, just close fp and return to caller */

View File

@ -32,11 +32,6 @@ Author: 1985 Wayne A. Christopher
#include "ngspice.h"
#ifdef HAVE_LIBGEN_H /* dirname */
#include <libgen.h>
#define HAVE_DECL_BASENAME 1
#endif
#include "cpdefs.h"
#include "ftedefs.h"
#include "fteext.h"
@ -46,7 +41,7 @@ Author: 1985 Wayne A. Christopher
#include "inpcom.h"
#include "variable.h"
#include "../misc/util.h" /* dirname() */
#include "../misc/util.h" /* ngdirname() */
#include "../misc/stringutil.h"
#include <wordlist.h>
@ -1280,7 +1275,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c
if ( dir_name_flag == FALSE ) {
char *s_dup = strdup(s);
inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, dirname(s_dup), FALSE);
inp_readall(newfp, &libraries[num_libraries-1], call_depth+1, ngdirname(s_dup), FALSE);
tfree(s_dup);
}
else
@ -1342,7 +1337,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name, bool c
if ( dir_name_flag == FALSE ) {
char *s_dup = strdup(s);
inp_readall(newfp, &newcard, call_depth+1, dirname(s_dup), FALSE); /* read stuff in include file into netlist */
inp_readall(newfp, &newcard, call_depth+1, ngdirname(s_dup), FALSE); /* read stuff in include file into netlist */
tfree(s_dup);
}
else

View File

@ -4,7 +4,7 @@ Copyright 1991 Regents of the University of California. All rights reserved.
#include "ngspice.h"
#include "ivars.h"
#include "util.h"
#include "../misc/util.h" /* ngdirname() */
#ifdef HAVE_ASPRINTF
#ifdef HAVE_LIBIBERTY_H /* asprintf */
@ -62,7 +62,7 @@ mkvar(char **p, char *path_prefix, char *var_dir, char *env_var)
void
ivars(char *argv0)
{
char *temp=NULL, *ngpath=NULL;
char *temp=NULL, *ngpath;
/* $dprefix has been set to /usr/local or C:/Spice (Windows) in configure.ac,
NGSPICEBINDIR has been set to $dprefix/bin in configure.ac,
Spice_Exec_Dir has been set to NGSPICEBINDIR in conf.c,
@ -82,16 +82,10 @@ ivars(char *argv0)
mkvar(&Spice_Path, Spice_Exec_Dir, "ngspice", "SPICE_PATH");
/* may be used to store input files (*.lib, *.include, ...) */
/* get directory where ngspice resides */
#if defined(_MSC_VER) || defined(__MINGW32__) /* FIXME dirname() different in util.c and LINUX */
ngpath = dirname(argv0);
#else
ngpath = copy(argv0);
dirname(ngpath);
#endif
ngpath = ngdirname(argv0);
/* set path either to <ngspice-directory>/input or, if set, to
environment variable NGSPICE_INPUT */
mkvar(&Inp_Path, ngpath, "input", "NGSPICE_INPUT");
if (ngpath) tfree(ngpath);
env_overr(&Spice_Host, "SPICE_HOST"); /* aspice */
env_overr(&Bug_Addr, "SPICE_BUGADDR");

View File

@ -149,7 +149,7 @@ char * absolute_pathname(char *string, char *dot_path)
}
#ifndef HAVE_DIRNAME
/*
char *
basename(const char *name)
@ -185,11 +185,12 @@ basename(const char *name)
return base;
}
*/
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
/* allow back slashes \\ */
char *
dirname(const char *name)
ngdirname(const char *name)
{
static char *ret = NULL;
int len;
@ -239,7 +240,7 @@ dirname(const char *name)
#else
char *
dirname(const char *name)
ngdirname(const char *name)
{
static char *ret = NULL;
int len;
@ -280,4 +281,3 @@ dirname(const char *name)
}
#endif
#endif

View File

@ -8,10 +8,6 @@
char *canonicalize_pathname(char *path);
char *absolute_pathname(char *string, char *dot_path);
#ifndef HAVE_DIRNAME
char *basename(const char *name);
char *dirname(const char *name);
#endif
char *ngdirname(const char *name);
#endif